Repository navigation
feat(bin): stamp status events with their emission time - #3764
kunchenguid merged 43 commits into
Conversation
|
Speaking as Kun's firstmate: First look on HEAD Diff reviewed: optional Attestation: incomplete (WIP; no-mistakes validation pending per body). Out of scope note: known concurrent pending-reply race ( Security skim: status-line time field + snapshot JSON only; no workflow/credential surface. Clean. VISION.md (each rule)
Contract-class: opt-in — new writers may stamp; legacy events remain valid with unknown time/age. Waiting on author (finish WIP / leave draft / complete attestation). No Firstmate escalate. |
2620f80 to
0f7d458
Compare
|
Speaking as Kun's firstmate: Tip Contract-class: opt-in — optional VISION: aligns on honest interface, explicit authority (unknown stays unknown), scripts-own-mechanics, restart durability, and scope. Outcome: waiting-author — bump Stock macOS expect 18→19, finish/undraft when green; rebase optional. Never merge a draft. Working #3764 for #3746. |
|
Addressed the stock macOS count correction at |
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (4): Last reviewed commit: "no-mistakes(ci): Captain, fixed malforme..." | Re-trigger Greptile |
539cf65 to
a3a6965
Compare
|
Speaking as Kun's firstmate: Triage: Tip Blockers (waiting on the author / current tip, not a captain card):
Contract-class: opt-in. New status records may carry optional VISION (per rule, inspected the classify-lib patch surface, snapshot writers, and the Greptile P1):
Security: no. Greptile P1 is a parse correctness hole, not a hidden workflow. Waiting on the author to clear the P1 on a new tip (and get serial 4 to a real pass). Not a Firstmate flag. |
|
Following up on the current-tip triage: I verified the malformed-colon notification case on the exact current head Could you retry only Behavior portable serial 4, job 101913485137? |
|
Speaking as Kun's firstmate: Re-reviewed newer tip CI: latest run Greptile P1 ( Contract-class: VISION.md: aligns (honest event age; unknown stays unknown; scripts own parse; restart durability; scope). Outcome: |
|
Following up on the 2026-09-10 triage (waiting-ci). I re-verified the live PR just now rather than relying on an earlier reading:
That is the fully green CI run the triage asked for. I have not pushed, rebased, or otherwise moved the head, so the attestation remains bound to it. Is there anything further needed from my side? |
b13559c to
1ad5b0b
Compare
|
Head is now |
kunchenguid
left a comment
There was a problem hiding this comment.
Speaking as Kun's firstmate: approving after tip security review (fork ruleset require_extra_approval_for_unattributed_changes). Tip 1ad5b0b3072c80703612480c94034737606e30a4 — CI green including NM + macOS; attestation MATCH; class opt-in; ci.yml is test-count only.
kunchenguid
left a comment
There was a problem hiding this comment.
Speaking as Kun's firstmate: approving after tip security review for fork unattributed-changes ruleset.
|
Speaking as Kun's firstmate: Triage: Tip CI: run Greptile P1: sole review thread is resolved + outdated (malformed Contract-class: opt-in (re-verified) — optional VISION / security: aligns (honest event age; scripts own parse). BLOCKED root cause: Outcome: |
|
Follow-up after base drift. Your 2026-09-12 triage was on head We cleared the conflict by merging current upstream main into the branch (no rebase of the feature commits). New head is Re-verified live just now:
Nothing else from our side is outstanding that I can see. If you need a different shape of conflict resolution or a split of the workflow-file touch, say the word. |
kunchenguid
left a comment
There was a problem hiding this comment.
Speaking as Kun's firstmate: re-approving tip 9a9a17a7d34a700ff784e8a92b441aedfadd814d after conflict-clear merges of main (fork/unattributed-changes ruleset). .github/workflows/ci.yml remains test-count 18→19 only.
|
Speaking as Kun's firstmate: Re-triage on tip CI: run Contract-class: opt-in (re-verified) — optional VISION.md per-rule
BLOCKED root cause (unchanged class): tip still updates Outcome: |
Intent
Clear base conflicts on #3764.
Branch fm/firstmate-issue3746-status-event-time, last known head b4a1328cbd8b.
The change is: stamp status events with their emission time. Long-running babysit; keep that intent; clear conflicts; renew attestation and CI without opening a second PR. Never merge upstream.
What Changed
bin/fm-classify-lib.shgains an optional[at=<epoch>]tag before a status line's first colon, with one parser owning the grammar (canonical unsigned decimal, at most 12 digits, missing/malformed/duplicate means unknown time) plusstatus_line_at_epoch,status_stamp_line,status_stamp_width,status_event_recorded, and two strippers. Captain relevance, the event scan, the note and key readers, and the decision fold now locate the head on an unstamped copy so a worker-written stamp cannot hide an actionable event or move the head/note separator, while stored and surfaced bytes stay the caller's own; the open-decisions fold version bumps to 9 to discard cursors folded under the old reading.fm-wake-lib.sh, the parent-channel, merge-outcome, and secondmate-report publishes, remote-reply ingest infm-procevent-remote-reply.sh, and the Kimi/Rovo/agy spawn-failure lines infm-spawn.sh.fm-send.shsubtractsstatus_stamp_widthfrom its resolve-key line cap so the close record still fits,fm-inactive-reconcile.sh's PR-URL scrape accepts a stampeddone:line, and thefm-brief.sh/fm-dod-lib.shscaffolds tell workers to append{state} [at=<epoch>]: ...with a literal placeholder.fm-fleet-snapshot.shpublishespaths.status_log.last_event.age_secondsderived from the event time (null when the time is unknown or in the future) and reuses it for the secondmateparent_event, while the unreadable-home fallback'sfreshness.age_secondsstays the mtime-based observation age. Docs (AGENTS.md, architecture, configuration, captain-hold lifecycle, secondmate parent channel and its verification record) drop stale unstamped line spellings, and the test suites accept optional stamps, with new classifier cases covering well-formed, malformed, and colon-bearing stamps against relevance, notes, keys, and the decision fold.Risk Assessment
Testing
I stood up a real tmux 3.6 server with an interactive bash pane as the worker and an isolated FM_HOME, then drove the change through the real firstmate scripts rather than the test harness. A worker opened a stamped decision from its own pane, the captain's wake drain read the stamp through to a clean key and note, firstmate answered with fm-send --resolve-key, and the appended close carried its real emission epoch and closed the key. The fleet snapshot reported a 125-second emission age for a line written one second earlier, proving age comes from the stamp and not from file mtime, and honestly reported null for the brief's unsubstituted placeholder. Every adversarial case was replayed over identical fixtures on base a452a79, the previous head ce3b5c2 and the target: on ce3b5c2 a worker writing a readable clock time silently closed the captain's open api-shape decision and opened a phantom keyless one, and both symptoms are gone at the target; on base a colon-bearing stamp sliced the note into "03:00Z]: PR ..." and the target reads it cleanly. The real watcher absorbed a benign working line and then surfaced the malformed-stamped terminal event, and the drain's outcome backstop presented that same event on all three trees, so a bad stamp never hides an outcome. A 400-character answer stored a 236-character line on ce3b5c2 against the 220 cap fm-send's own refusal cites, and exactly 220 at the target while still closing the key. A stale decision cursor folded under the old reading was discarded and refolded correctly by the upgraded tree. Ten targeted suites plus the PR-merge suite all pass. The one scenario I could not drive live is the retried upward publication against a real forge:
tests/fm-pr-merge.test.shexercises it only over a stubbed forge, so I report it untested rather than passing. This is a shell CLI change with no GUI surface, so the reviewer-visible evidence is annotated terminal transcripts of the live runs rather than screenshots.needs-decision [key=api-shape] [at=1789880334]: ...;bin/fm-wake-drain.shlisted it with a clean key and note;bin/fm-send.sh t1 --resolve-key api-shapeappended `resolved […bin/fm-fleet-snapshot.shreturned age_seconds 125 for a line stamped 125s earlier in a file written one second before the read, age_seconds 10 for the brief round trip, and null for[at=<epoch>].…api-shapeentirely (open: []); the target keeps it open. 02-malformed-stamp-adversarial.txt sections 3-4needs-decision [at=10:30] which base branchopened adefaultdecision on ce3b5c2 (drain and hints.open_decisions) and opens nothing on the target. 02-malformed-stamp-adversarial.txt sections 3-4done [at=2026-09-20T14:03:00Z]: PR .../pull/1 checks greenyielded note "03:00Z]: PR ..." on base a452a79 and the clean note on the target, read throughbin/fm-fleet-snapshot.sh. 02-malformed-stam…bin/fm-watch.shabsorbed aworking:baseline then surfacedsignal: .../t1.statuson the malformed-stamped done line; the drain's STATUS OUTCOME BACKSTOP presented the same event on base, ce…bin/fm-send.sh --resolve-keywith a 400-character answer stored 236 characters on ce3b5c2 and exactly 220 on the target; the drain then showed no open decision, so truncation did not eat the [k…bin/fm-brief.sh t7 demo --mode no-mistakesrendered the[at=<epoch>]instruction plus thedate +%ssubstitution note at 10 sites; that exact echo was executed in the live worker pane and read ba…tests/fm-pr-merge.test.sh, which drives the real fm-pr-merge over a stubbed forge, so no live result was…Evidence: Live round trip: stamped decision, stamped close, emission age
Source: Live round trip: stamped decision, stamped close, emission age
Evidence: Adversarial malformed stamps: before/after across three trees
Source: Adversarial malformed stamps: before/after across three trees
Evidence: Status-line cap with the stamp reserved, and the generated ship brief
Source: Status-line cap with the stamp reserved, and the generated ship brief
Evidence: Secondmate upward report on the real parent channel
Source: Secondmate upward report on the real parent channel
Evidence: Captain wake digest reads a stamped decision through to a clean key and note
Evidence: A mis-spelled worker stamp no longer decides a captain's decision
Evidence: Emission age comes from the stamp, never from file mtime
Evidence: Stamped close stays inside the 220-character cap
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 4 issues found → auto-fixed ✅
bin/fm-procevent-remote-reply.sh- merge conflict rebasing onto origin/mainbin/fm-spawn.sh- merge conflict rebasing onto origin/mainbin/fm-wake-lib.sh- merge conflict rebasing onto origin/maintests/fm-remote-reply.test.sh- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 3 issues found → auto-fixed ✅
bin/fm-classify-lib.sh:669-_fm_decision_fold_line's two colon tests still read the RAW line, so a colon living inside a mis-spelled[at=...]tag is mistaken for the head/note separator that the module's four other readers now correctly skip. A worker-written tag therefore decides whether a captain's open decision survives. This is the one round-8 fix the user selected that was never committed - the branch head is still the round-7 follow-up, and the defect is live in the current tree.The declaration guard at :668-671 (
case "$line" in *:*|*\[key=*\]*) and the terminal rule at :673-675 (case "$line" in *:*) case "$verb:$kind" in done:ship|done:scout|failed:ship|failed:scout) return 0) both match$line, whilestatus_line_note:554,_fm_decision_key:570,status_is_captain_relevant:227and_fm_status_event_scan:174all go through_fm_status_unstampedfirst.Reproduced by executing the library against a kind=ship status file:
needs-decision [key=api-shape] [at=1700000000]: REST or gRPC?
done [at=17:00] finished the audit
-> status_open_decisions: (empty) -- api-shape SILENTLY CLOSED
same opener +
done [at=1700000000] finished the audit-> api-shape still open (correct)same opener +
done finished the audit-> api-shape still open (correct)The inverse symptom, same root cause:
needs-decision [at=17:00] which base branch
-> open: default\tneeds-decision\tneeds-decision which base branch -- PHANTOM opened
needs-decision [at=1700000000] which base branch -> open: (empty)
needs-decision which base branch -> open: (empty)
Both outcomes contradict rules the module states about itself.
_fm_status_unstamped's header at :356-361 says a worker tag "must never decide whether a terminal event reaches its supervisor - not when the worker left the brief's <epoch> placeholder unsubstituted, and not when they wrote a readable time whose colons swallow the head/note separator." Fold version 8's note at :930-932 says "a colonless line without a complete '[key=...]' token is no longer a transition at all, so a cursor holding a phantom decision that bare prose opened - which no later line could close - is discarded." Post-unstamping,done [at=17:00] finished the auditIS a colonless keyless line to every other reader in the module.Newly reachable because of this change: bin/fm-brief.sh:291, :390 and :478 now instruct every worker in all three scaffolds to append
{state} [at=<epoch>]: {one short line}and to substitute<epoch>by hand fromdate +%s, and the change's own tests/fm-classify-corr-token.test.sh:702-712 enumerate[at=17:00],[at=10:30]and[at=2026-09-20T14:03:00Z]as spellings that must not change classification. Those tests assert verb, note, key, relevance andstatus_span_first_actionablefor that input class - but neverstatus_open_decisions, which is the uncovered path.The wrong set propagates: bin/fm-fleet-snapshot.sh publishes it as
hints.open_decisions,status_current_line:733-742 derives the current declaration from it for bin/fm-crew-state.sh, and bin/fm-send.sh--resolve-keyvalidates against it.Remedy at the earliest shared boundary the change already owns: normalize once at the top of
_fm_decision_fold_linewith_fm_status_unstamped "$line" unstampedand run bothcasetests on$unstamped(leavestatus_line_verband the stored/surfaced bytes untouched), then bumpFM_OPEN_DECISIONS_FOLD_VERSIONat :936 from 8 to 9 with a version note, because :879-881 states that variable "must be bumped whenever _fm_decision_fold_line semantics change, so persisted state from an older interpretation is discarded and rebuilt from byte 0." That is existing documented machinery, not new state, so this corrects what the change already does rather than extending it.bin/fm-send.sh:698- The 220-character status-line cap is applied to the close line and the stamp is then inserted, so the line actually appended is 236 characters and every 220-capped rendering downstream loses real content. Also a round-8 finding the user chose to fix that was never committed.Measured by executing the two functions together:
fm_cap_line_var "resolved [key=api-shape]: answered: <400 x's>"yields exactly 220 characters, andstatus_stamp_lineon that result yields 236 -[at=1789877213]is 16 characters inserted into the head. bin/fm-send.sh:698 caps; bin/fm-wake-lib.sh:2195-2197 stamps every line it appends.Two concrete consequences. First, bin/fm-session-start.sh:528-529 prints the status tail with each line "capped at $FM_LINE_CAP_DEFAULT characters" and re-cuts at 220, replacing the tail with FM_LINE_CAP_SUFFIX - so the captain-facing digest of a long close now shows roughly 16 fewer characters of the actual note than before this change, and shows a truncation marker on a line that was already marked truncated. Second, bin/fm-send.sh:676's pre-send refusal still explains itself in terms of "the $FM_LINE_CAP_DEFAULT-character status-line cap" while the line the same function goes on to write is 236 characters, so the guard and the writer no longer agree on the cap being enforced.
The same pre-stamp budgeting applies to bin/fm-parent-channel-lib.sh:129 (
fm_parent_channel_clean_notecuts to 1200, thenfm_parent_channel_report:152 stamps the result).The remedy is already fixed by the recorded round-8 decision - "The 220-character cap applies to the line that is actually appended, stamp included. Reserve stamp width when capping a line that will be stamped. Do not raise the default cap" - so this is mechanical now: subtract the stamp width from
maxat the cap call sites whose output the writer will stamp, rather than capping after stamping or raising FM_LINE_CAP_DEFAULT.tests/fm-bearings-snapshot.test.sh:434- The GNU-stat fixture test droppedassert_contains "$(cat "$stat_log")" '-c %Y' "GNU parent-event mtime must use stat -c"and put a.parent_event.age_seconds == nulljq check in its place (lines 434-437), but that replacement cannot fail if the mtime reader is broken: for a legacy unstamped eventparent_event.age_secondsis null whether or notfile_mtime_epochworks.file_mtime_epochis still live and is still called on this exact code path - bin/fm-fleet-snapshot.sh:1770 runsobserved_epoch=$(file_mtime_epoch "$status_observation_file")unconditionally for every secondmate row, before the structured-home / fallback branch. Breaking the GNU branch (for example making it call/usr/bin/stat -f '%m') leaves the new assertion green. The surviving-c %a(line 433) and-c %s(line 438) assertions and the no--fcheck cover mode, size and platform selection; nothing in this suite now exercises the mtime read. .github/workflows/ci.yml:446 runs this whole file under stock macOS Bash 3.2 as a platform-portability gate.Note the round-8 remedy as written does not work here: the
domain-alpharecord this test inspects takes the structured-home branch, whosefreshness.age_secondscomes from$summary_age(bin/fm-fleet-snapshot.sh:1882), not fromfile_mtime_epoch. Adding.freshness.age_secondsto that jq filter would assert nothing about stat. Because line 1770 is unconditional, simply restoring the-c %Yassertion alongside the new age check is both correct and falsifiable.Separately, the definition-order swap of
file_mtime_epochandfile_mode_octalat bin/fm-fleet-snapshot.sh:1159-1166 is a pure no-op reorder (definition order affects neither call order nor the stat log) and can be reverted to shrink the diff.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
needs-decision [key=api-shape] [at=1789880334]: ...;bin/fm-wake-drain.shlisted it with a clean key and note;bin/fm-send.sh t1 --resolve-key api-shapeappended `resolved […bin/fm-fleet-snapshot.shreturned age_seconds 125 for a line stamped 125s earlier in a file written one second before the read, age_seconds 10 for the brief round trip, and null for[at=<epoch>].…api-shapeentirely (open: []); the target keeps it open. 02-malformed-stamp-adversarial.txt sections 3-4needs-decision [at=10:30] which base branchopened adefaultdecision on ce3b5c2 (drain and hints.open_decisions) and opens nothing on the target. 02-malformed-stamp-adversarial.txt sections 3-4done [at=2026-09-20T14:03:00Z]: PR .../pull/1 checks greenyielded note "03:00Z]: PR ..." on base a452a79 and the clean note on the target, read throughbin/fm-fleet-snapshot.sh. 02-malformed-stam…bin/fm-watch.shabsorbed aworking:baseline then surfacedsignal: .../t1.statuson the malformed-stamped done line; the drain's STATUS OUTCOME BACKSTOP presented the same event on base, ce…bin/fm-send.sh --resolve-keywith a 400-character answer stored 236 characters on ce3b5c2 and exactly 220 on the target; the drain then showed no open decision, so truncation did not eat the [k…bin/fm-brief.sh t7 demo --mode no-mistakesrendered the[at=<epoch>]instruction plus thedate +%ssubstitution note at 10 sites; that exact echo was executed in the live worker pane and read ba…tests/fm-pr-merge.test.sh, which drives the real fm-pr-merge over a stubbed forge, so no live result was…Live: realtmux 3.6server on a private socket, sessionfmlive, a real interactive bash pane acting as the worker, driven withtmux send-keysLive:bin/fm-send.sh t1 --resolve-key api-shape 'go with REST; gRPC stays internal'against an isolated FM_HOMELive:bin/fm-send.sh t2 --resolve-key rollout-plan '<400-character answer>'(cap boundary), replayed on ce3b5c2 for the beforeLive:bin/fm-wake-drain.shunderFM_STATE_OVERRIDE, run on base a452a79, ce3b5c2 and the target over identical fixturesLive:bin/fm-fleet-snapshot.shpiped throughjqforpaths.status_log.last_eventandhints.open_decisions, on all three treesLive:bin/fm-watch.shwithFM_POLL=1- absorbed a benignworking:line, then surfaced a malformed-stamped terminal eventLive:bin/fm-brief.sh t7 demo --mode no-mistakes, then the rendered instruction executed verbatim in the worker pane and read back through the snapshotLive:bin/fm-session-start.shstatus-tail digest, target vs ce3b5c2Live:bin/fm-secondmate-report.sh done <corr> 'audit complete, no findings'on a local-route parent channelbash tests/fm-classify-corr-token.test.shbash tests/fm-send-resolve-key.test.shbash tests/fm-brief.test.shbash tests/fm-bearings-snapshot.test.shbash tests/fm-fleet-snapshot-view.test.shbash tests/fm-inactive-reconcile.test.shbash tests/fm-pending-reply.test.shbash tests/fm-remote-reply.test.shbash tests/fm-classify-decision-key.test.shbash tests/fm-crew-state.test.shbash tests/fm-pr-merge.test.sh(stubbed forge, not a live forge run)tests/fm-brief.test.sh:800-bin/fm-lint.shexits 1 on this branch, independent of the documentation phase. ShellCheck 0.11.0 reports four SC2016 (info) findings in tests/fm-brief.test.sh at lines 800, 812, 813 and 822, and fm-lint.sh runs at ShellCheck's default severity, so info-level findings fail the gate. The lines were added by commits 3ffd3b7 and a1f1e2b, both newer than 437bd52 ("Fix ShellCheck quoting in status emission-time tests"), so this is an unfixed regression at the branch head rather than a pre-branch condition. Verified:bin/fm-lint.sh tests/fm-brief.test.shexits 1, whilebin/fm-lint.sh bin/fm-wake-lib.sh(this phase's only script edit) exits 0. Fixing it means editing a test file, which this document phase may not do; the lint phase owns it.docs/verification/secondmate-parent-channel.md:4- This maintainer-verification record's own refresh rule is "rerun the fixture after changing any publisher named in bin/fm-parent-channel-lib.sh", and this change fired it: all four transcript lines are published through fm_parent_channel_report, which now calls status_stamp_line, so a rerun writes[at=<epoch>]closing each head. Rerunning needs live tmux panes, two real watchers and a macOS bash 3.2 fixture, which this phase cannot execute, and inventing stamped bytes would falsify a dated evidence record. I annotated the drift instead: two lines at the top state that the run predates stamping, show where the tag lands, and name bin/fm-classify-lib.sh as the owner of its syntax. Everything the record proves about delivery is unaffected by the tag. A maintainer may still want a genuine rerun to restore byte-exact evidence.🔧 Fix applied.
1 info still open:
tests/fm-brief.test.sh:800- This phase normally may edit only documentation and doc comments, but the selected finding could only be resolved by re-quoting a test file, and the recorded user instruction was explicit: "Quote the new brief tests so ShellCheck SC2016 does not fail lint. Do not skip lint." I applied the quoting change rather than deferring it again to the lint phase. The edit is quoting only: the case patterns and grep patterns match exactly the same strings as before (verified by executing both forms), no assertion or control flow changed, and tests/fm-brief.test.sh passes. Flagging the boundary crossing so the executor knows a non-documentation file is in this phase's diff.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.