Skip to content

Commit a09090d

Browse files
feat(bin): stamp status events with their emission time (kunchenguid#3764)
* test(status): reproduce missing event emission time * wip(status): preserve optional event emission time * test(status): document indirect clock stub invocation * no-mistakes(review): Preserve historical status bytes during reply recovery * no-mistakes(test): Fix timestamped status assertions and remote fixture dependencies * no-mistakes(review): Preserve captain regex overrides for timestamped status events * no-mistakes(document): Clarify status event timing and publication contracts * no-mistakes(lint): Quote literal done to satisfy ShellCheck * no-mistakes(ci): Captain, updated .github/workflows/ci.yml to expect 19 snapshot tests instead of 18, matching the PR’s added regression. Reproduced the failure before the fix. Stock Bash 3.2.57 verification passed: parse sweep, 19 snapshot tests, 53 Bearings tests, and the public-followup regression. Workflow lint and diff checks passed * no-mistakes(test): Preserve terminal notifications with malformed timestamp tags * no-mistakes(test): Stamp Rovo spawn failures with emission time * no-mistakes(document): Verify status event documentation * no-mistakes(lint): Fix ShellCheck quoting in status emission-time tests * no-mistakes(ci): Captain, fixed four lifecycle assertions to accept emission timestamps while preserving publication and retry checks. Reproduced the CI failure before the fix. The lifecycle suite now passes with six Beads capability skips; syntax, targeted ShellCheck, and diff checks passed * no-mistakes(ci): Captain, fixed malformed timestamp colons hiding actionable events using shared normalization. Original bytes and unknown ages are preserved. Regression reproduced before the fix; classifier and remote-reply suites, targeted lint, syntax, and diff checks passed * no-mistakes(review): Stamp remote escalations at call sites, drop new flag * no-mistakes(review): Accept stamped escalation and close lines in test assertions * no-mistakes(review): Restore reserved-key answered-note guard for stamped closes * test(status): accept optional emission time in PR-provenance assertions The kunchenguid#4148 provenance test landed on main with exact unstamped greps. Parent-channel lines from this branch carry [at=<epoch>], so strip only that tag before the same exact match. No production change. * no-mistakes(review): Accept stamped ready signal in PR fallback scrape * no-mistakes(review): Drop relay flag, stamp parent events at call sites * no-mistakes(review): Stamp worker terminal-signal instructions, revert fm-on fixture * no-mistakes(review): Accept optional stamp in live cmux drift guard * no-mistakes(review): Restore original test invocation order in two suites * no-mistakes(review): Strip only well-formed numeric status time tags * no-mistakes(document): Drop stale unstamped PR-ready line spelling from channel doc * no-mistakes(review): Stamp agy spawn-failure status lines with event time * fix(bin): normalize status event times in-shell and freeze the budget test clock Two paths made a status event's emission time cost more than it should. The captain-relevance fallback piped every line through awk to drop a well-formed `[at=<epoch>]` tag before matching, so a supervisor sweep paid a fork per line just to prepare a regex match. Shell parameter expansion does the same strip with no fork, and the retry-dedup scan now reuses that one helper instead of carrying a second copy of the rule in awk. The copies had already drifted: the shell side stripped tags from lines with no colon, which the awk rule left whole, so a colonless line could be mistaken for one already recorded. One definition, checked against the awk rule it replaces over the edge cases and a 4000-line fuzz. tests/fm-contributions.test.sh froze its fixture clock only in exhaust mode. In hang mode the poll set DEADLINE to the real now plus a one-second budget, and when the second ticked before the first forge call the loop broke without ever calling gh: forge/calls was never written and the assertion failed reading a missing file. Freezing the clock in both modes removes the dependence on wall time; the bounded call is still cut by the real timeout, so the observation the test asserts still starts. Emission time stays optional on new status records, and legacy or malformed lines keep an unknown age. * no-mistakes(review): Stamp ask-user escalation line and fix Kimi status assertion * no-mistakes(document): Drop stale unstamped done-line spelling from watcher docs * test: fold emission-time snapshot coverage into the fixture case Drop the incidental ci.yml 18-to-19 count hunk so the PR no longer touches workflows. Keep every emission-time assertion by folding it into test_fixture_snapshot_json. * no-mistakes(review): replace brief date substitution with epoch placeholder; drop emitted_at_epoch * no-mistakes(review): align untimed normalizer with epoch parser; tolerate placeholder stamp in PR scrape * no-mistakes(review): strip undelimited at-tags; correct brief stamp header * no-mistakes(review): normalize stamps at both captain-regex sites; restore mtime freshness * no-mistakes(review): strip colon-bearing stamps for relevance; fix headers and test oracles * no-mistakes(review): narrow escalation match to stamp tolerance; pin note verb * no-mistakes(review): read note and key past colon-bearing stamps * test(status): keep inactive reconcile assertions stamp-tolerant These two oracles were made stamp-tolerant while resolving one of the branch's merges from main. The rebase drops merge commits, so that adaptation was lost and both assertions went back to matching an exact substring that a stamped line no longer contains: the tag lands before the colon, so "failed [key=k]: ..." is now "failed [key=k] [at=N]: ...". Strip a well-formed tag before matching, as the branch's other oracles do. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * no-mistakes(review): unstamp fold colon tests; reserve stamp width in cap * no-mistakes(document): correct stale unstamped status-line spellings in docs * no-mistakes(document): quote brief-test literals for lint; correct stamp-helper contract comments * no-mistakes(ci): rename subshell-local epoch in delivery-race stub The serialization test overrides fm_pending_reply_mark_delivered inside a (..) subshell. Its `epoch` local collided with the same name in status_line_at_epoch/status_stamp_line, which this branch added and this suite now calls at top level, so ShellCheck 0.11.0 reported SC2030 and failed Lint 2. The stub already prefixes its other locals with `pending_` for the same reason; `epoch` was the leftover. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 1b1b3cd commit a09090d

44 files changed

Lines changed: 861 additions & 199 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ data/ personal fleet records; LOCAL, gitignored as a whole
9898
<id>/report.md scout task deliverable, written by the crewmate; survives teardown
9999
projects/ cloned repos; gitignored; read-only except under hard rule 1's concrete captain-approved project operation exception
100100
state/ runtime records and signals; gitignored
101-
<id>.status appended by crewmates: "<state>: <note>" wake-event lines, not current-state truth
101+
<id>.status append-only wake events, not current-state truth; bin/fm-classify-lib.sh owns their syntax
102102
<id>.turn-ended touched by turn-end hooks
103103
<id>.progress touched for observed native-harness activity inside one Pi turn; bin/fm-busy-event.sh owns its generation binding and bin/fm-watch.sh reads it beside turn-ended for the busy-age bound only, never as a completed turn
104104
<id>.busy-state <id>.busy-gen semantic busy-state record (one line, atomically replaced) and its per-incarnation gen sidecar; bin/fm-busy-event.sh is the only writer and bin/fm-busy-lib.sh owns the record format and classification; arming again replaces the previous incarnation so late events carrying its gen are rejected as stale; removed by retire and teardown
@@ -389,7 +389,7 @@ The worker reports the PR when CI first becomes green rather than waiting for me
389389

390390
### PR ready, landing, and teardown
391391

392-
For PR-based ship tasks, the ready signal depends on mode: `no-mistakes` reports `done: PR <url> checks green` after CI is green, while `direct-PR` reports `done: PR <url>` after opening the PR.
392+
For PR-based ship tasks, the ready signal depends on mode: `no-mistakes` reports `done [at=<epoch>]: PR <url> checks green` after CI is green, while `direct-PR` reports `done [at=<epoch>]: PR <url>` after opening the PR.
393393
Run `bin/fm-pr-check.sh <id> <PR url>` with the URL copied from that ready signal - it records `pr=` and the forge's `pr_head=` when available in the task's meta and arms the watcher's merge poll.
394394
Tell the captain the PR's full `https://...` URL copied from the worker's ready line or the task's `pr=` metadata, a concise outcome summary, and the no-mistakes risk level when applicable.
395395
A captain instruction to merge is explicit authority; `yolo` is the only standing routine merge authority.

‎bin/fm-branch-prompt.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Write summaries in the captain's outcome language - the project, the fix, the PR
7878
7979
# PR identity: copy or abstain
8080
81-
A PR URL you pass to a tool or write into a summary is copied verbatim from the task's `done: PR <url>` status line or its `pr=` metadata field.
81+
A PR URL you pass to a tool or write into a summary is copied verbatim from the task's `done [at=<epoch>]: PR <url>` status line or its `pr=` metadata field.
8282
Never assemble an owner, repository, host, or number from memory, from another PR, or from a bare number the worker printed; a plausible URL built that way is how a dead link reaches the captain.
8383
When no record holds the URL yet, report the identifier you do have ("PR 108 is open") and leave the PR check unarmed; the worker's ready line brings the URL on its own.
8484

‎bin/fm-brief.sh‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
# declared-external-wait verb (FM_CLASSIFY_PAUSED_VERB, default "paused") from
6161
# "blocked:": pause for a known external wait expected to clear on its own,
6262
# blocked when firstmate must act.
63+
# Emission-time syntax and legacy unknown-time handling are owned by
64+
# bin/fm-classify-lib.sh; each scaffold renders the stamp as a literal <epoch>
65+
# placeholder the worker replaces with a numeric Unix time as it appends, so a
66+
# scaffold never emits a substitution a file-write tool would copy through.
6367
# Every scaffold also carries the steering-inbox receive-and-ack section:
6468
# process state/<id>.inbox/*.msg in order and acknowledge each by moving it to
6569
# handled/ (record, doorbell, and ladder owned by bin/fm-task-inbox-lib.sh).
@@ -284,8 +288,9 @@ $INBOX_SECTION
284288
# Escalation to main firstmate
285289
Handle routine work yourself.
286290
Report only true captain-relevant outcomes or a declared external wait by appending one line:
287-
\`echo "{state}: {one short line}" >> $STATUS_FILE\`
291+
\`echo "{state} [at=<epoch>]: {one short line}" >> $STATUS_FILE\`
288292
States: working, needs-decision, blocked, $PAUSED_VERB, done, failed.
293+
Substitute \`<epoch>\` with the current Unix time in seconds - run \`date +%s\` and write the number it printed; a stamp that is not plain digits records no time at all.
289294
Use \`$PAUSED_VERB: {why}\` (distinct from \`blocked:\`) only when your domain is deliberately idling on a known external wait you expect to clear on its own, naming when it clears with \`until <YYYY-MM-DDTHH:MMZ>\` (UTC) when you know; use \`blocked:\` when you are stuck and need firstmate to act.
290295
Use this only for material phase changes, a captain decision, a real blocker, a failure, work ready for review, or work you landed.
291296
Work you landed includes a merge you performed yourself under standing merge authority and one the captain merged on the forge: under that authority nothing is ever \"ready for review\", so a landed merge that goes unreported reaches the captain as silence.
@@ -294,17 +299,17 @@ A marked request requires one correlated answer after the work; it does not requ
294299
Never append \`working:\` merely to acknowledge receipt or announce that a marked request has started.
295300
When a routed-work phase has a supervisor-actionable material change worth reporting under the rule above, give that reported phase a stable key.
296301
If its first reportable event is \`working [key=<work-slug>]: {material phase}\`, use the same key on its later \`$PAUSED_VERB\`, \`done\`, \`failed\`, \`needs-decision\`, or \`blocked\` event so the earlier working phase is superseded.
297-
When a keyed phase ends without another reportable state, append \`resolved [key=<work-slug>]: {why it is no longer active}\`.
302+
When a keyed phase ends without another reportable state, append \`resolved [key=<work-slug>] [at=<epoch>]: {why it is no longer active}\`.
298303
\`resolved\` separately closes an escalated decision or blocker, and only a \`resolved\` line carrying that decision's exact key closes it: a later \`done\` or \`working\` event never does, even when the answer is what started that work.
299-
The main firstmate's answer normally writes that closing line at answer time; when a blocker or wait clears WITHOUT an answer from the main firstmate, append \`resolved: {how it cleared}\` yourself (keyed with \`[key=<slug>]\` if you opened it with one) as your domain resumes.
304+
The main firstmate's answer normally writes that closing line at answer time; when a blocker or wait clears WITHOUT an answer from the main firstmate, append \`resolved [at=<epoch>]: {how it cleared}\` yourself (keyed with \`[key=<slug>]\` if you opened it with one) as your domain resumes.
300305
Routine internal supervision, heartbeats, retries, and crewmate churn stay inside your own home and must not touch that status file.
301306
302307
# Definition of done
303308
You are persistent by default. Do not exit just because your queue is empty.
304309
On startup and restart, run normal firstmate bootstrap and recovery through \`bin/fm-session-start.sh\` for your own home, but only to RECONCILE work that is already yours: in-flight crewmates, tracked backlog items, and durable watches recorded in this home.
305310
When you have no assigned or in-flight work after that reconciliation, go idle and wait silently for the main firstmate to route you a task.
306311
An empty queue is a healthy resting state, not a cue to invent work: never spawn a survey, audit, or any self-directed "find work" task on your own initiative.
307-
If this charter cannot be carried out, append \`blocked: {why}\` or \`failed: {why}\` to the main status file and stop.
312+
If this charter cannot be carried out, append \`blocked [at=<epoch>]: {why}\` or \`failed [at=<epoch>]: {why}\` to the main status file and stop.
308313
EOF
309314
if [ "$SECONDMATE_CHARTER" = "{TASK}" ]; then
310315
echo "scaffolded: $BRIEF (secondmate charter; replace {TASK})"
@@ -382,8 +387,9 @@ The report is the only thing that survives, so anything worth keeping must be in
382387
2. Stay inside this worktree; the only files you may write outside it are the report and the status file below.
383388
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
384389
4. Report status by appending one line:
385-
\`echo "{state}: {one short line}" >> $STATUS_FILE\`
390+
\`echo "{state} [at=<epoch>]: {one short line}" >> $STATUS_FILE\`
386391
States: working, needs-decision, blocked, $PAUSED_VERB, done, failed.
392+
Substitute \`<epoch>\` with the current Unix time in seconds - run \`date +%s\` and write the number it printed; a stamp that is not plain digits records no time at all.
387393
Each append wakes firstmate, so report sparingly: only phase changes a supervisor
388394
would act on and the needs-decision/blocked/paused/done/failed states. No step-by-step
389395
FYI progress lines; firstmate reads your pane for that.
@@ -396,17 +402,17 @@ The report is the only thing that survives, so anything worth keeping must be in
396402
treating it as a possible wedge. When you know when the wait clears, say so in the line with
397403
\`until <YYYY-MM-DDTHH:MMZ>\` (UTC) and firstmate rechecks at that time instead.
398404
Use \`blocked:\` when you are stuck and need help.
399-
5. If you hit the same obstacle twice, append \`blocked: {why}\` and stop; firstmate will help.
405+
5. If you hit the same obstacle twice, append \`blocked [at=<epoch>]: {why}\` and stop; firstmate will help.
400406
6. If a decision belongs to a human (product choices, destructive actions),
401-
append \`needs-decision: {summary of options}\` and stop. Firstmate will reply with the decision.
407+
append \`needs-decision [at=<epoch>]: {summary of options}\` and stop. Firstmate will reply with the decision.
402408
A decision or blocker you opened stays open until a \`resolved\` line carrying its exact key lands; a later \`done:\` or \`working:\` line never closes it, even when the answer is what started that work.
403-
Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append \`resolved: {how it cleared}\` yourself (same \`[key=<slug>]\` if you opened it with one) as you resume.
409+
Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append \`resolved [at=<epoch>]: {how it cleared}\` yourself (same \`[key=<slug>]\` if you opened it with one) as you resume.
404410
7. Never stop, restart, or update the shared \`no-mistakes\` daemon - it is one instance serving
405411
every lane/home, so restarting it kills other lanes' in-flight pipeline runs; only firstmate
406412
manages the daemon.
407413
Before you append \`blocked:\` about the pipeline, run \`no-mistakes daemon status\` and
408414
\`no-mistakes axi status\`. If the daemon socket refuses connections or is missing, append
409-
\`blocked: {the daemon error}\` and stop even when the local run record still says running or
415+
\`blocked [at=<epoch>]: {the daemon error}\` and stop even when the local run record still says running or
410416
fixing, because that record can be stale after the daemon exits. A run record failed with a
411417
daemon error is also a real block.
412418
Only after ruling out socket refusal, if the run is still running or fixing, reattach and keep
@@ -421,7 +427,7 @@ Write your findings to \`$DATA/$ID/report.md\`.
421427
The report must stand alone: what you did, what you found, the evidence (commands run, output, file:line references), and what you recommend.
422428
$LAVISH_LINE
423429
Before reporting done, read and follow \`$FM_ROOT/.agents/skills/captain-hold-lifecycle/SKILL.md\` and pass its shared completion gate for the report and any visual review.
424-
When the report is complete, append \`done: {one-line conclusion}\` to the status file and stop.
430+
When the report is complete, append \`done [at=<epoch>]: {one-line conclusion}\` to the status file and stop.
425431
If your findings reveal work that should ship (e.g. you reproduced a bug and the fix is clear), say so in the report; firstmate may promote this task in place, and you would then receive mode-specific ship instructions as a follow-up message.
426432
EOF
427433
echo "scaffolded: $BRIEF (scout; replace {TASK} and {FIRSTMATE_SPEC})"
@@ -460,7 +466,7 @@ You are in a disposable git worktree of $REPO, at a detached HEAD on a clean def
460466
461467
**Verify isolation before anything else.** Run \`pwd -P\` and \`git rev-parse --show-toplevel\`; both must resolve to the disposable task worktree you were launched in, such as a treehouse pool path or an Orca-managed worktree, not the primary checkout firstmate operates from.
462468
The path check is authoritative: \`git rev-parse --git-dir\` and \`git rev-parse --git-common-dir\` can help inspect the repo, but they do not prove you are outside the primary checkout.
463-
If the top-level path is the primary checkout or not the worktree you were launched in, STOP - do not branch or commit here - append \`blocked: launched in primary checkout, not an isolated worktree\` to the status file and stop.
469+
If the top-level path is the primary checkout or not the worktree you were launched in, STOP - do not branch or commit here - append \`blocked [at=<epoch>]: launched in primary checkout, not an isolated worktree\` to the status file and stop.
464470
465471
1. First action: create your branch: \`git checkout -b fm/$ID\`$SETUP2
466472
@@ -469,8 +475,9 @@ $RULE1
469475
2. Stay inside this worktree; modify nothing outside it.
470476
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
471477
4. Report status by appending one line:
472-
\`echo "{state}: {one short line}" >> $STATUS_FILE\`
478+
\`echo "{state} [at=<epoch>]: {one short line}" >> $STATUS_FILE\`
473479
States: working, needs-decision, blocked, $PAUSED_VERB, done, failed.
480+
Substitute \`<epoch>\` with the current Unix time in seconds - run \`date +%s\` and write the number it printed; a stamp that is not plain digits records no time at all.
474481
Each append wakes firstmate, so report sparingly: only phase changes a supervisor
475482
would act on (setup done, bug reproduced, fix implemented, validation passed) and the
476483
needs-decision/blocked/paused/done/failed states. No step-by-step FYI progress lines;
@@ -484,18 +491,18 @@ $RULE1
484491
known external wait you expect to clear on its own ($CREWMATE_PAUSE_WAIT_EXAMPLES):
485492
firstmate then leaves your idle pane alone and rechecks it on a long
486493
cadence instead of treating it as a possible wedge. Use \`blocked:\` when you are stuck and need help.
487-
5. If you hit the same obstacle twice, append \`blocked: {why}\` and stop; firstmate will help.
494+
5. If you hit the same obstacle twice, append \`blocked [at=<epoch>]: {why}\` and stop; firstmate will help.
488495
6. If a decision belongs above the implementation worker (product choices, destructive actions),
489-
append \`needs-decision: {summary of options}\` and stop. Firstmate will reply with the decision.
496+
append \`needs-decision [at=<epoch>]: {summary of options}\` and stop. Firstmate will reply with the decision.
490497
$ASK_USER_BLOCK
491498
A decision or blocker you opened stays open until a \`resolved\` line carrying its exact key lands; a later \`done:\` or \`working:\` line never closes it, even when the answer is what started that work.
492-
Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append \`resolved: {how it cleared}\` yourself (same \`[key=<slug>]\` if you opened it with one) as you resume.
499+
Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append \`resolved [at=<epoch>]: {how it cleared}\` yourself (same \`[key=<slug>]\` if you opened it with one) as you resume.
493500
7. Never stop, restart, or update the shared \`no-mistakes\` daemon - it is one instance serving
494501
every lane/home, so restarting it kills other lanes' in-flight pipeline runs; only firstmate
495502
manages the daemon.
496503
Before you append \`blocked:\` about the pipeline, run \`no-mistakes daemon status\` and
497504
\`no-mistakes axi status\`. If the daemon socket refuses connections or is missing, append
498-
\`blocked: {the daemon error}\` and stop even when the local run record still says running or
505+
\`blocked [at=<epoch>]: {the daemon error}\` and stop even when the local run record still says running or
499506
fixing, because that record can be stale after the daemon exits. A run record failed with a
500507
daemon error is also a real block.
501508
Only after ruling out socket refusal, if the run is still running or fixing, reattach and keep

0 commit comments

Comments
 (0)