Skip to content

M3.E fix SV STOP→START losing PTP sample-clock certification - #296

Draft
masarray wants to merge 20 commits into
fix/m3d-preserve-fresh-bench-gm-seed-20261024from
fix/m3e-continuous-sv-clock-authority-20261024
Draft

masarray wants to merge 20 commits into
fix/m3d-preserve-fresh-bench-gm-seed-20261024from
fix/m3e-continuous-sv-clock-authority-20261024

Conversation

@masarray

@masarray masarray commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Field regression

ESP32-P4 laboratory PTP GM and SV stream initially report synchronized, but an SV-only STOP/START causes NOT SYNC although PTP/4-kHz sample timebase should remain active.

Root cause

The prior M3.A–D implementation parks the GPTimer but resets canonical MAC descriptor evidence at each SV START. Warm resume relies only on the instantaneous source sync flag and does not persist the previously measured sample-clock certification as a property of the parked timebase. At a STOP boundary it can be revoked and the next START is treated as cold acquisition. IEC 61850-9-2 synchronization status describes sampling relative to the synchronizing time source, not the mere SV publisher running state.

Fix

  • Introduce portable SvParkedClockAuthority preservation/resume policy requiring old measured SOURCE certification, same PTP lease/generation, uninterrupted GPTimer/profile, accepted 1Hz phase, fresh phase observation, and AUTO mode.
  • Capture certification when publishing stops and the timer moves to a dry 4-kHz phase-tracking state. Keep it while PTP and phase observations stay healthy.
  • On warm START, restore the same already-verified timebase certification before the first resumed SV frame; reset publisher MAC descriptor measurement separately and require a new true MAC pair within the previous 8-epoch bound.
  • Any PTP/GM fault, stale phase, rate/mode change, missed slot or actual canonical TX failure still revokes. No forced smpSynch=2; the bench simulated Global GM authorization remains separately gated.
  • Portable regression of 100 STOP/START sequences and negative clock/lease/phase cases, plus Studio static guard.

Acceptance not yet established

Green CI != physical FAT. Need matched ESP32-P4 firmware + Windows preview and a PCAP of 100 STOP/START with stable smpSynch=2, PTP announce/source identity, continuous sampling phase and SIPROTEC 5 acceptance. No merge to main/checkpoints.\n### Extra PTP root cause found during source audit\nThe old firmware incremented g_ptp_source_generation on every PTP TX readiness recovery, even though the IEEE1588 EMAC hardware clock never restarted. The resulting fake lease/GM change caused the 4-kHz phase observer to invalidate a still-continuous clock. Generation is now incremented once when the SOURCE hardware timebase successfully starts, not when Announce/Sync transmission health returns. Actual PTP TX failure still revokes READY; this patch does NOT mask faults or force GLOBAL. CI source guard prevents recurrence.\n

M3.E integration hardening (commit 4412e19)

  • STOP/PARK transition race: the 1-Hz phase observer previously tested asynchronous RUNNING || PREFLIGHT and revoked a still-owned GPTimer/EMAC clock while the publisher was transitioning. Now steering is authorized only from the actual owned GPTimer + unchanged PTP lease + valid phase/fault/session + AUTO mode, independent of those toggles.
  • START boundary race: RUNNING=true is set before the PTP-second ISR turns on SV publisher notifications. Live MAC requalification is now keyed to that real ISR notification gate, so a dry sample grid cannot be misclassified as a missing SV stream.
  • Portable test: 100 STOP/PARK/START flag-order combinations and negative gates for stopped timer, new GM, stale phase, publisher fault, non-AUTO override.
  • The matched FAT firmware job must now grep CONFIG_AR_PTP_BOOT_SIMULATED_GLOBAL_GM=y in compiled sdkconfig; manifest includes bootSimulatedGlobalGmEnabled, bootSourceAutostartEnabled, and globalGmTraceabilityPhysicallyProven=false. Windows packaging explicitly refuses firmware without these true Global GM simulation and phase/MAC evidence gates.
  • One paired M3.E firmware ZIP is built by the Windows Native Preview workflow from the exact GUI commit; no old standalone firmware is acceptable for FAT. PTP/Core, embedded and firmware CI are green on current HEAD; physical relay lock and 100-cycle hardware FAT are NOT claimed.

@masarray
masarray marked this pull request as ready for review October 23, 2026 23:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T01:00:47.350570Z c192b7b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29a3630825

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1178 to +1180
const bool resume_certified =
smp_synch_source_local_qualified() ||
g_parked_source_clock_certified.load(std::memory_order_acquire);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Invalidate parked certification on sync-policy changes

If a certified clock is parked and PROFILE SMPSYNCH 1 followed by PROFILE SMPSYNCH AUTO arrives before the publisher's next 200-ms idle check, smp_synch_lab_set_mode() clears the existing SOURCE qualification but never clears this new latch. The timer and PTP lease remain unchanged, so START accepts the cached certificate and restores qualification without fresh MAC evidence, defeating the existing fail-closed mode-change behavior tested in test_smp_synch_policy.cpp. Checking only the current AUTO mode cannot detect this intervening invalidation. Tie parked certification to the shared qualification invalidation path or a policy generation so a revoked certificate cannot be resurrected.

AGENTS.md reference: AGENTS.md:L30-L30

Useful? React with 👍 / 👎.

@masarray
masarray marked this pull request as draft October 23, 2026 23:58
@masarray
masarray marked this pull request as ready for review October 24, 2026 00:59
@masarray
masarray marked this pull request as draft October 24, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant