Skip to content

fix(bin): put a read cue first in context re-emit output - #7298

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
Azd325:fm/firstmate-compact-reemit-memory-first
Oct 15, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
Azd325:fm/firstmate-compact-reemit-memory-first

Conversation

@Azd325

@Azd325 Azd325 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • bin/fm-session-start.sh now prints a short RE-EMIT CUE at the head of a context re-emit. A harness that spills large hook output and shows only its head still tells the model to read the saved full output or the missing durable records. The "go to a source directly" list gains a matching entry.
  • docs/sessionstart-nudge.md documents Claude's 10,000-character hook output cap, the 2,000-character preview, and why the cue comes first.
  • tests/fm-session-start.test.sh adds coverage for the cue on a re-emit.

Fixes #6303

Risk Assessment

✅ Low: The change adds three printf lines that run first, and only in --reemit mode, plus a list bullet, a doc note and a regression test. The fleet-state-first order is unchanged, the normal-start output is unchanged, and the user intent (a head-bounded cue that survives the spill) is met.

Testing

A live --reemit run on a lab home printed the RE-EMIT CUE as the first lines, but the run timed out at 100s so the full output past the 10,000-character cap was never produced. The full test file hit the script's 120s runtime bound, and the isolated new test was killed at 110s with no result. The head-bounded cue is confirmed live; the 2000-character-preview and normal-start-omits-cue assertions are not.

  • Live validation: ⚠️ inconclusive - 1 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A context re-emit starts with the RE-EMIT CUE naming the saved file and memory files ✅ pass live reemit-head.txt
The cue sits within the first 2000 characters of a >10,000-character re-emit (captain.md padded) ⏸️ untested no The session-start digest exceeds the runtime bound in this sandbox; the run was killed before the output completed. Re-run with FM_SESSION_START_TIMEOUT raised on a faster host.
A normal (non-re-emit) start omits the cue ⏸️ untested no Same runtime bound; a normal start was not completed here.
Evidence: re-emit head from live run

Source: re-emit head from live run

RE-EMIT CUE: if this output ends with "Output too large ... Full output saved to <path>",
read that whole file now, before acting. Otherwise read data/captain.md, data/captain-shared.md,
and data/learnings.md under /var/folders/m7/v02n8pqn167dn42b0vdb3l4h0000gn/T//fm-lab.y0luy0/data now if any of them is missing below.

================================================================================
SESSION START (CONTEXT RE-EMIT) - /var/folders/m7/v02n8pqn167dn42b0vdb3l4h0000gn/T//fm-lab.y0luy0
================================================================================
This session already took the helm at its own startup and has only lost its
context. Lock ownership is re-verified and the durable records below are
reprinted, but the sweeps startup already reconciled - project clone refresh,
secondmate convergence and liveness, pending remote handoff
retry, X-mode artifact writes, and stale Herdr child cleanup - are NOT repeated.
Queued wakes ARE still drained: they arrived after startup and are this turn work.

LOCK
--------------------------------------------------------------------------------
error: cannot write session lock; operate read-only until resolved
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  READ-ONLY SESSION - FLEET LOCK OWNERSHIP WAS NOT VERIFIED
●  error: cannot write session lock; operate read-only until resolved
●  Skipping every mutating step: stale Herdr child cleanup,
●  secondmate convergence, secondmate liveness, pending remote handoff retry,
●  X-mode artifacts, fleet sync, and wake-queue drain. Detect-only bootstrap
●  diagnostics and the rest of this read-only-safe digest still ran below.
●  Operate read-only until this resolves - do not spawn, steer, merge, or
●  otherwise mutate fleet state from this session.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  • Outcome: ⚠️ 2 warnings across 1 run (13m8s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ The session-start script and its test file are too slow in this environment (the full script hit its 120s runtime bound, and the isolated new test was killed at 110s). The full >10,000-character re-emit with captain.md/learnings.md could not be captured end to end.
  • ⚠️ live validation verdict: inconclusive (1 of 3 scenarios were driven live against the product); untested: The cue sits within the first 2000 characters of a >10,000-character re-emit (captain.md padded), A normal (non-re-emit) start omits the cue
  • Live validation: ⚠️ inconclusive - 1 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A context re-emit starts with the RE-EMIT CUE naming the saved file and memory files ✅ pass live reemit-head.txt
The cue sits within the first 2000 characters of a >10,000-character re-emit (captain.md padded) ⏸️ untested no The session-start digest exceeds the runtime bound in this sandbox; the run was killed before the output completed. Re-run with FM_SESSION_START_TIMEOUT raised on a faster host.
A normal (non-re-emit) start omits the cue ⏸️ untested no Same runtime bound; a normal start was not completed here.
  • bin/fm-session-start.sh --reemit against a disposable lab home (live, killed at 100s)
  • bash tests/fm-session-start.test.sh (hit the script's 120s runtime bound)
  • isolated run of test_reemit_cue_survives_the_hook_output_preview (killed at 110s)
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

Claude spills a hook output over 10,000 characters and shows only the first
2,000 plus a saved-file path. The re-emit prints captain.md and learnings.md
last, so they never reached the session. Print a short cue first that names
the saved file and the memory files, and document the cap.

Refs kunchenguid#6303
@kunchenguid

kunchenguid commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @Azd325 — this is a really sharp catch. A compacted Claude session that only sees a 2,000-character preview of its re-emit has lost exactly the digest the re-emit exists to restore, and a cue at the head is a small, sensible fix.

What I reviewed (head 151c0b6c vs main 0397cb2b): three printf lines that run only on --reemit and print before the re-emit section, one new bullet in the "go to a source directly" list, the doc note in docs/sessionstart-nudge.md, and one new test. The normal-start path and the order of the digest sections are unchanged. No workflow, secret, or network changes. I approved the first-time fork CI, so it's running now.

Contract-class: restore. docs/sessionstart-nudge.md already says clear/compact re-emits the digest because "a compacted session has lost exactly the digest it needs". Above Claude's hook output cap that digest never reaches the model, so the existing default re-emit path is broken. This puts it back without adding a new path.

VISION: One captain / Authority / Scripts / Restart / Spine / Vendor / Scope all align. It strengthens "a restart is a non-event", and the cue is plain text in the existing script.

One gap. This is waiting on you: live validation is inconclusive (1 of 3 scenarios). The cue at the head is shown live. Two scenarios weren't run because the sandbox hit the runtime bound: the cue landing inside the first 2,000 characters of a >10,000-character re-emit, and a normal start leaving the cue out. If you get a chance, could you run those two on a faster host (for example with FM_SESSION_START_TIMEOUT raised) and post the evidence here? Re-raising through no-mistakes so the attestation picks them up works too. It would also help to see the no-mistakes lint warning cleared, or a note on what it flagged. Once that's in and CI is green, this can go ahead. Thanks again!

CI update: the new `test_reemit_cue_survives_the_hook_output_preview` passed in CI (serial 4). The two red jobs look unrelated to your change: serial 2 hit the 30-minute timeout in `fm-supervision-host.test.sh`, and serial 4 failed in `fm-remote-reply.test.sh` (NUL-bearing line capture). I re-ran the failed jobs.

@Azd325

Azd325 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Here is the evidence for the two open scenarios and the lint warning. Host: macOS arm64, head 151c0b6, a temporary home with a padded captain.md.

  1. Re-emit over 10,000 characters: FM_HOME=$H bash bin/fm-session-start.sh --reemit --source compact > reemit.out gives 32,737 bytes. head -c 2000 reemit.out | grep -n "RE-EMIT CUE" finds the cue on line 1.
  2. Normal start: FM_HOME=$H bash bin/fm-session-start.sh --source startup > normal.out gives 32,479 bytes. grep -c "RE-EMIT CUE" normal.out returns 0.

Each run took about 5 s.

  1. Lint: the pipeline sandbox had no actionlint, so fm-lint-workflows.sh exited 1. ShellCheck passed. With the pinned actionlint 1.7.12, bin/fm-lint.sh exits 0 and reports 3 workflow files valid. This PR changes no workflow file.

@kunchenguid
kunchenguid merged commit 0aa7fac into kunchenguid:main Oct 15, 2026
35 of 37 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @Azd325 — really appreciate you taking the time on this.

Your follow-up closed the gap from my last comment. The cue sits on line 1 of the first 2,000 characters of a 32,737-byte re-emit, and a normal start prints no cue. The lint warning came from actionlint missing in the pipeline sandbox, and this PR touches no workflow files. All of this PR's own CI jobs are green, and the no-mistakes check passed. I checked #6303 against its acceptance criteria and this PR covers them, so it closed with the merge (contract-class: restore).

valerius21 added a commit to valerius21/firstmate that referenced this pull request Oct 15, 2026