Skip to content

fix(bin): name the Lavish read message count by the same label as its section - #6785

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
falkoro:fix/lavish-message-count-label-6743
Oct 7, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
falkoro:fix/lavish-message-count-label-6743

Conversation

@falkoro

@falkoro falkoro commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Intent

Resolve kunchenguid/firstmate issue #6743 as an outside contributor PR, following CONTRIBUTING.md (fork falkoro/firstmate, raised through no-mistakes), using exactly the REDUCED scope the maintainer's triage set, not the issue's original ask.

Triage (on main 237e1cf) reproduced that bin/fm-procevent-lavish.sh read on a capture with four tag=message composer rows and no session_ended prints them as CAPTAIN MESSAGE PART 1..4 (nothing dropped) but the count line says session_ending_message_count: 4, calling messages on a still-open session "session-ending". The script header promises the session-ending label only when the session ended, and the section label already switches between CAPTAIN MESSAGE and SESSION-ENDING MESSAGE, but the count line did not. Triage asked: make the count line match the section label (neutral captain-message count, or switch name the same way the section header does) and say "session-ending" only when session_ended is true; add parser fixtures for several message rows with and without session_ended plus a mixed capture with real annotations; leave annotation classification alone.

Decisions made:

  • Chose the "switch name the same way the section header does" option: the count key is session_ending_message_count when session_ended is true (unchanged output for ended sessions, so every existing assertion holds) and captain_message_count otherwise. Both the section label and the count key derive from one $ended boolean so they cannot drift.
  • Used a named $message_count_key variable rather than print $ended ? ... : ... because Perl can parse print $scalar ... as a filehandle print.
  • Explicitly declined (per triage, which called it new-default): reclassifying tag=message rows as annotations. annotation_count still counts only non-message rows.
  • Deliberately left unchanged: the empty-section line SESSION-ENDING MESSAGE: (none). Existing tests assert it for an status: ended capture that carries no session_ended field, so changing it reaches beyond the triaged count-line scope.
  • Did NOT bump the header's "verified against 0.1.80" note to 0.1.83 even though triage said it "would also help": lavish-axi is not installed here, so I could not verify the poll/reply interfaces against 0.1.83, and claiming that would be false.
  • Header usage comment for read updated to state the count-line naming.
  • Regression added to tests/fm-procevent.test.sh (existing read-presentation section): a capture with three tag=message rows plus one real element annotation, run once without and once with session_ended, asserting the label, the third part body, the matching count key with value 3, absence of the other key, and annotation_count: 1. No first-party consumer reads these count keys outside tests.

Local evidence: bin/fm-lint.sh clean. bin/fm-test-run.sh tests/fm-procevent.test.sh passes all read-presentation cases including the new one, then fails later at the unrelated pre-existing case "the listener under test was not reparented away from its session (ppid 884)". That case assumes orphans reparent to PID 1, but on this host PID 884 is systemd --user, a child subreaper. It is environment-specific and unrelated to this change.

What Changed

  • bin/fm-procevent-lavish.sh read now derives both the section label and the message count key from one $ended boolean. The count line is session_ending_message_count when session_ended is true (unchanged for ended sessions) and captain_message_count otherwise. The read usage comment in the script header documents this naming.
  • Annotation classification is unchanged: annotation_count still counts only non-message rows. The empty-section line SESSION-ENDING MESSAGE: (none) is also unchanged.
  • Added a regression case to the read-presentation section of tests/fm-procevent.test.sh. It uses a capture with three tag=message rows and one element annotation, run once without and once with session_ended. It asserts the section label, the third part body, the matching count key with value 3, absence of the other key, and annotation_count: 1.

Closes #6743 (reduced scope per maintainer triage)

Risk Assessment

✅ Low: A single $ended boolean now drives both the section label and the count key, and the existing assertions that expect session_ending_message_count use session_ended: true fixtures, so they still hold. The new test runs the real read command and checks its output for both ended and open sessions.

Testing

I ran the real read script on a capture with three tag=message rows and one real annotation, with and without session_ended. Both runs behaved correctly. I did not run the repo test file, because its later failure on the host's systemd subreaper was already noted as unrelated.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Open session with several message rows: the count line says captain_message_count: 3, the section says CAPTAIN MESSAGE, and annotation_count stays 1 ✅ pass live new.txt
Ended session with the same rows: the section and count key both say session-ending (session_ending_message_count: 3, annotation_count: 1) ✅ pass live new.txt
Base-commit script on the open-session capture, for comparison: it prints session_ending_message_count: 3 and a SESSION-ENDING label (not the intended new behaviour) ✅ pass live old.txt
Evidence: read output after the change

Source: read output after the change

=== ended=no (new)
CAPTAIN MESSAGE
CAPTAIN MESSAGE PART 1 of 3
| first comment
CAPTAIN MESSAGE PART 2 of 3
| second comment
CAPTAIN MESSAGE PART 3 of 3
| third comment
END CAPTAIN MESSAGE

declared_items: 4
presented_items: 4
malformed_items: 0
complete: yes
lifecycle: feedback
session_ended: (unset)
annotation_count: 1
captain_message_count: 3

ANNOTATIONS
ANNOTATION 1 of 1
element_uid: el-a
element_selector: aside.sidebar
tag: note
text:
| Sidebar note
END ANNOTATIONS
END LAVISH RESULT (4 of 4)
=== ended=yes (new)
SESSION-ENDING MESSAGE
SESSION-ENDING MESSAGE PART 1 of 3
| first comment
SESSION-ENDING MESSAGE PART 2 of 3
| second comment
SESSION-ENDING MESSAGE PART 3 of 3
| third comment
END SESSION-ENDING MESSAGE

declared_items: 4
presented_items: 4
malformed_items: 0
complete: yes
lifecycle: feedback
session_ended: true
annotation_count: 1
session_ending_message_count: 3

ANNOTATIONS
ANNOTATION 1 of 1
element_uid: el-a
element_selector: aside.sidebar
tag: note
text:
| Sidebar note
END ANNOTATIONS
END LAVISH RESULT (4 of 4)
Evidence: read output from the base-commit script

Source: read output from the base-commit script

=== OLD ended=no
SESSION-ENDING MESSAGE
SESSION-ENDING MESSAGE PART 1 of 3
SESSION-ENDING MESSAGE PART 2 of 3
SESSION-ENDING MESSAGE PART 3 of 3
END SESSION-ENDING MESSAGE
annotation_count: 1
session_ending_message_count: 3

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Open session with several message rows: the count line says captain_message_count: 3, the section says CAPTAIN MESSAGE, and annotation_count stays 1 ✅ pass live new.txt
Ended session with the same rows: the section and count key both say session-ending (session_ending_message_count: 3, annotation_count: 1) ✅ pass live new.txt
Base-commit script on the open-session capture, for comparison: it prints session_ending_message_count: 3 and a SESSION-ENDING label (not the intended new behaviour) ✅ pass live old.txt
  • bin/fm-procevent-lavish.sh read on a 3-message + 1-annotation capture without session_ended
  • same capture with session_ended: true
  • same capture run through the base-commit script (ac0811c) for comparison
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Issues

Closes #6743

… section

fm-procevent-lavish.sh read labels tag=message rows SESSION-ENDING MESSAGE
only when session_ended is true and CAPTAIN MESSAGE otherwise, but the
count line always said session_ending_message_count. Several composer
messages on a still-open board were therefore counted as session-ending.

The count line now follows the same session_ended switch:
session_ending_message_count once the session ended, captain_message_count
otherwise. Message rows stay out of the annotation count, per triage.

Fixes kunchenguid#6743
@kunchenguid
kunchenguid merged commit 228b27d into kunchenguid:main Oct 7, 2026
19 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

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

umeranjum17 added a commit to umeranjum17/juggernaut that referenced this pull request Oct 9, 2026
…upervision fixes (#44)

* fix(pi): hide duplicate assistant finals from hidden processing retries (#5863)

* fix(pi): silence unacknowledged processing retry replies

Suppress autonomous processing prose before persistence and during streaming while retaining tool calls, signed reasoning, and retryable outcomes. Restore ordinary output after acknowledgement or a user message.

Fixes #4954

* no-mistakes(review): Silence only processing retries, keep first presentation visible

* fix(pi): preserve differing processing retry replies

* test(pi): accept Pi 1.0.1's renamed HTML export renderer lookup (#6530)

Pi 1.0.1's createToolHtmlRenderer reads getToolRenderers and ignores
getToolDefinition. Calm /export still includes stock grep HTML; the
fixture has to pass the lookup key the installed Pi actually reads.

* fix(bin): tolerate transient quota read failures (#6490)

* fix(procevent-quota): tolerate consecutive slow quota-axi reads

The quota allowance poll treated any quota_json failure as terminal, so one
slow quota-axi --json (measured max ~29s under a 48s derived bound) shut the
watch down until someone re-armed it, and the detail always said
"missing/incompatible". Tolerate three consecutive failed or timed-out reads
before going terminal, reset the streak on any good read, and report a
timeout distinctly from a missing or incompatible tool. Each timed poll runs
exactly one bounded --version and one bounded --json: validate the captured
version text through fm_quota_axi_version_compatible rather than launching a
second probe, and describe a mixed failure streak by count plus last cause.

* no-mistakes(document): Document quota polling failure tolerance

* no-mistakes(ci): Fixed ci-2 and ci-3. Permanent quota read failures (rc 2 missing, rc 3 incompatible) now report on the first poll, while transient rc 1/4 failures retain the existing three-failure retry behavior. The missing-binary test now uses an isolated PATH without quota-axi and asserts both permanent failures stop at condition_polls: 1. Verification passed: tests/fm-procevent-quota.test.sh, canonical fast lint for both changed files, bash syntax checks, and git diff --check

* no-mistakes(review): Classify untimed quota version failures as transient

* no-mistakes(document): Clarify quota polling failure budget

* fix(bin): clarify scratch guidance and dirty teardown refusals (#6505)

* fix(teardown): clarify scratch guidance and dirty worktree refusals

Keep ship proof material outside the task worktree and distinguish untracked-only leftovers from tracked edits without changing cleanup guards.

Fixes #6319

* fix(ci): Fixed ci-3 only. Both promotion outputs now replace the scout restriction and require external scratch storage and a clean worktree before done. Verification: 27 delivery tests passed, five mutations caught, restored test passed, pinned ShellCheck and syntax/whitespace checks passed. ci-1, ci-2, and ci-4 remain untouched

* fix(bin): escalate inbox instructions blocked by busy workers (#6518)

* Escalate inbox instructions stuck behind a busy worker

Count consecutive busy-deferred due doorbells durably and escalate at the configured bound without typing into the worker pane.

Fixes #6445

* fix(review): Fix inbox escalation deduplication and busy streak resets

* fix(review): Preserve busy inbox escalations through daemon supervision

* fix(document): Correct busy-inbox escalation documentation

* fix(ci): Fixed SC2034 in tests/fm-task-inbox.test.sh by including the loop counter in the failure diagnostic. Source-aware lint, all 34 inbox tests, and git diff --check pass. Behavior portable serial 6 reproduces identically on base 1f3e7696 and target 78156b86 with Pi 1.0.1: an unrelated renderer API change breaks the unchanged Calm test. No Calm changes made; that failure is addressed separately by https://github.com/kunchenguid/firstmate/pull/6516. Logs retained in scratchpad-ci/

* fix(ci): Fixed ci-2, ci-3, and ci-4: successor failures surface, reset alerts deduplicate, and oversized busy limits fall back to two. Passed 47 inbox tests, 7 focused daemon checks, all 13 mutation checks, lint, documentation checks, and diff checks. Evidence: scratchpad-ci-selected/summary.json. ci-1 remains unchanged and unwaived. Fresh live Herdr proof remains with the outer driver

* fix: prevent unnecessary remote worker turnover (#6431)

* fix: prevent healthy remote job worker turnover

* no-mistakes(review): Serialize full LaunchAgent repair and verify launchd-tracked owners

* no-mistakes(review): Let launchd-tracked unpublished spawns start before reloading

* no-mistakes(document): Document remote worker heartbeat and serialized LaunchAgent recovery

* no-mistakes(ci): Full CI log showed the idle-worker regression exceeded its outdated command budget (82 versus 80) after independent heartbeat ownership checks were added. Raised the budget to 120 while retaining the separate busy-poll sleep limit. Remote-job and LaunchAgent executable tests passed, as did bash syntax validation and git diff --check. No production behavior changed

* no-mistakes(ci): Fixed missing readiness recovery under verified live ownership, preserving the serving PID and private file mode. Added executable regressions for deletion during a blocked sweep and stale readiness diagnostics without LaunchAgent reload. Deletion regression failed before the fix. Both remote-job test suites, bash syntax validation, and git diff --check passed

* no-mistakes(ci): Full CI log identified a flaky ownership-loss test racing an already-authorized heartbeat refresh. Replaced backdating and a fixed sleep with bounded observation of readiness expiry through the public probe. Production behavior unchanged. Remote-job and LaunchAgent executable suites passed; bash syntax validation and git diff --check passed

* fix: wait for launchd bootout cleanup

* no-mistakes(document): Document remote worker recovery and read-only turnover verification

* no-mistakes(review): Publish worker identity before lock owner records

* no-mistakes(document): Document worker identity publication safety invariant

* no-mistakes(ci): Fixed ci-1: replacement workers discard predecessor readiness before publishing identity and roll back identity if lock-owner recording fails. Added executable regressions reproducing both defects. LaunchAgent and orphan-reap suites, shell syntax checks, and git diff --check passed. No live service state was modified

* no-mistakes(ci): Restored lock-owner-before-identity publication and removed the identity rollback and reordering-only tests. Retained an executable regression proving predecessor readiness is rejected until replacement startup completes. LaunchAgent and orphan-reap suites, shell syntax checks, and git diff --check passed. Other changes remain intact; the retained-identity interrupted-repair edge remains out of scope. No live service state was modified

* fix: speed up remote-job sequence claim cleanup (#6575)

* fix(remote-job): reap expired seq claims with one directory walk

The hourly claim sweep forked uname+stat per .seq-claims entry and blocked
serving for ~85s at ~17k dirs. Delete expired empty claim dirs with a single
find -exec rmdir batch and cache the host uname for remaining mtime reads.

* no-mistakes(review): Restore original path mtime helper and drop uname cache

* no-mistakes(test): Restore claim retention eligibility; focused retention and serving tests pass

* no-mistakes(document): Document single-walk claim cleanup and regression entrypoints

* no-mistakes(ci): Fixed Lint 2’s reproduced SC1091 by adding the tests/lib.sh ShellCheck source directive to the retention test. Runtime behavior is unchanged. ShellCheck passed for both new claim tests; Bash syntax, the retention behavior test, and git diff --check passed

* fix(tests): keep fixture registries out of git worktree roots

A TMPDIR pointed at a repository root placed live .fm-test-* registries
beside tracked files, and a concurrent git add during the claim-walk CI
fix round committed three of them. Route registries and fixture roots
through a TMPDIR that refuses git worktree roots, remove the stray files,
and pin the escape with a behavioral cleanup test.

* no-mistakes(review): Preserve whole-second claim expiry in single-walk sweep

* no-mistakes(document): Correct temporary-directory resolution documentation

* no-mistakes(ci): Fixed ci-3 by changing only the stale, fresh, and read-only orphan fixture paths in tests/fm-test-fixture-cleanup.test.sh to use $FM_TEST_TMPDIR. All seven tests passed both normally and with TMPDIR set to the worktree root. Shell syntax and git diff --check passed

* feat(bin): record no-mistakes pipeline spend per task at teardown, opt-in (#5354)

* feat(bin): record each task's no-mistakes pipeline spend at cleanup

no-mistakes keeps every pipeline agent invocation's token usage only in its
local agent_invocations records, and cold pipeline agents (review, test,
document) leave no session log, so a task's review-loop cost never reached
Firstmate's records and could not be attributed after cleanup.

bin/fm-pipeline-spend.sh attributes a task's runs by the repository
no-mistakes resolves for the task copy, the task branch, and the branch's
creation (a relaunch mints a new spawn_gen while the branch keeps
validating), then sums every invocation, failed and cancelled included.
Token fields use no-mistakes' per-round deltas so resumed review rounds are
not counted twice, and unrecorded values stay unknown rather than zero.
show prints the record read-only; record appends it once per task
incarnation to data/pipeline-spend.jsonl. Teardown records it for every
ship task it cleans up, before deleting the branch and the task record.

fm_nm_state_db becomes the one owner of where no-mistakes' state database
lives, shared with the capped run-inventory reader.

* no-mistakes(review): Drop spend show command and timeout override

* style(bin): rewrap fm-pipeline-spend header comment

* Make pipeline spend recording opt-in

* feat(bin): record each task's no-mistakes pipeline spend at cleanup

no-mistakes keeps every pipeline agent invocation's token usage only in its
local agent_invocations records, and cold pipeline agents (review, test,
document) leave no session log, so a task's review-loop cost never reached
Firstmate's records and could not be attributed after cleanup.

bin/fm-pipeline-spend.sh attributes a task's runs by the repository
no-mistakes resolves for the task copy, the task branch, and the branch's
creation (a relaunch mints a new spawn_gen while the branch keeps
validating), then sums every invocation, failed and cancelled included.
Token fields use no-mistakes' per-round deltas so resumed review rounds are
not counted twice, and unrecorded values stay unknown rather than zero.
show prints the record read-only; record appends it once per task
incarnation to data/pipeline-spend.jsonl. Teardown records it for every
ship task it cleans up, before deleting the branch and the task record.

fm_nm_state_db becomes the one owner of where no-mistakes' state database
lives, shared with the capped run-inventory reader.

* no-mistakes(review): Drop spend show command and timeout override

* style(bin): rewrap fm-pipeline-spend header comment

* Make pipeline spend recording opt-in

* no-mistakes(document): Note pipeline-spend opt-in gate in teardown comments

* no-mistakes(ci): I fixed all three Greptile findings following your decision. Both test suites pass: tests/fm-teardown.test.sh (105 ok, exit 0) and tests/fm-pipeline-spend.test.sh (8 ok). I didn't run either new test against the old code, so the claim that they fail before the fix is from reading the code, not a run. Nothing was committed or pushed. **ci-1 / ci-2 (bin/fm-teardown.sh):** The rule is that every owned ship task in a home that has opted in gets a durable spend record before its task record is deleted. T