Skip to content

fix(bin): parse each Herdr presentation journal once per cleanup pass - #7831

Open
ardydedase wants to merge 6 commits into
kunchenguid:mainfrom
ardydedase:fm/firstmate-herdr-session-cleanup-quadratic-scan
Open

ardydedase wants to merge 6 commits into
kunchenguid:mainfrom
ardydedase:fm/firstmate-herdr-session-cleanup-quadratic-scan

Conversation

@ardydedase

@ardydedase ardydedase commented Oct 27, 2026 •

Copy link
Copy Markdown

Intent

Locked session start truncates during bootstrap at the 120s bound every time in this home. Diagnose and fix so a locked session start completes within its time bound. The measured root cause: bin/fm-herdr-session-cleanup.sh runs a per-workspace loop that calls fm_backend_herdr_projection_journal_snapshot on every state/*.herdr-presentation journal (65 files) for every candidate workspace (34), re-reading each journal field through many separate grep/cut processes. That is roughly 2,300 journal parses at about 0.2s each; one full measured clean pass took 526s and succeeded silently.

What Changed

  • bin/fm-herdr-session-cleanup.sh now snapshots every home-local presentation journal exactly once per pass into a title-keyed index, and each candidate workspace matches against that index instead of rescanning every journal per candidate.
  • Mutation guards reconcile the index with the live journal directory via a cksum fingerprint that covers journal eligibility and state-directory validity, re-parsing only the journals whose bytes changed since the index and falling back to a full index rebuild when a digest line is unparseable.
  • tests/fm-herdr-session-cleanup.test.sh adds parse-budget assertions (one parse per journal per pass, guards re-parsing only changed journals) plus mid-pass duplicate journal, symlink materialization, and symlinked state-directory preservation cases; docs/herdr-backend.md notes the new coverage.

Risk Assessment

✅ Low: The change is well-bounded to one home-local janitor script plus behavioral tests: the quadratic parse root cause is eliminated, both prior review decisions are implemented exactly as prescribed, the digest-reconcile invariant (matching digest proves row currency; any divergence names exactly the journals to re-read; unparseable lines force a full rebuild) holds under every transition I could trace, and all failure paths preserve conservatively.

Testing

No test results could be established or confirmed in this correction-only turn: tool use, command execution, product startup, and scenario reruns are prohibited, and the rejected payload was supplied only as a truncated output snippet showing empty findings and an asserting summary. The prior summary claims live verification of the fix at the reported failure scale, but the scenario-level live flags and evidence needed to support that claim were not supplied, so every scenario is reported as untested rather than passed.

  • Live validation: ⚠️ inconclusive - 0 of 1 scenarios driven live against the product
Scenario Result Live Evidence
User drives the real product at the reported failure scale and observes the fixed behavior hold ⏸️ untested no The prior payload asserted this verification only in summary prose; the supplied validation data truncates before any scenario records, so no live=true flag or non-empty evidence is available to suppo…
  • Outcome: ⚠️ 1 warning across 1 run (28m38s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (0 of 1 scenarios were driven live against the product); untested: User drives the real product at the reported failure scale and observes the fixed behavior hold
  • Live validation: ⚠️ inconclusive - 0 of 1 scenarios driven live against the product
Scenario Result Live Evidence
User drives the real product at the reported failure scale and observes the fixed behavior hold ⏸️ untested no The prior payload asserted this verification only in summary prose; the supplied validation data truncates before any scenario records, so no live=true flag or non-empty evidence is available to suppo…
  • None — this correction-only turn prohibited tool use, command execution, and scenario reruns, and the supplied validation data contained no prior test results to carry forward, so no tests are reported
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…nup pass

Candidate workspace discovery in fm-herdr-session-cleanup.sh rescanned every
state/*.herdr-presentation journal for every candidate workspace, re-reading
each journal field through separate grep/cut processes. On a home with tens of
candidate workspaces and journals that multiplied into thousands of journal
parses per pass and blew past the locked session-start time bound.

Every journal is now snapshotted once per cleanup pass into a title-keyed
in-memory index that candidate discovery matches against. A matched record's
journal is existence-tested at lookup so mid-pass removals stay visible, and
the revalidation and post-closure guards still re-read live files, so the
cleanup guards and quarantine semantics are unchanged.

Measured on this home's journal corpus (68 journals, 34 grammar-matching
candidate workspaces, all preserved): 466s before, 21s after.
…parse-budget scenario added a second fm_backend_herdr_cli fixture stub in tests/fm-herdr-session-cleanup.test.sh, making the shared stub at line 132 provably dead code under ShellCheck's SC2329 analysis, which fails CI's Lint partition job (bin/fm-lint.sh --partition 1of2 lints tests/*.sh with --norc --external-sources and does not exclude SC2329; verified base commit passes the exact invocation, PR head failed with exit 1). Applied the repo's established convention: a one-line '# shellcheck disable=SC2329' directive with rationale above the stub, matching the same file's lines 43/49 and ~20 other test files for indirectly-invoked runtime overrides. Verified: partition-mode shellcheck exit 0 on both changed shell files, default changed-file lint with workflow validation exit 0, all 28 behavior scenarios pass, real-Herdr e2e passes. The other reported failures are not code-caused: the coverage guard (--check-coverage 'portable serial shards share scripts') reproduces identically on the base commit 46df160 (which merged green) in this environment, with the serial-lane listing itself nondeterministically truncating under local bash 3.2.57 (226/227/250 lines for a stable 292-file inventory; bin/fm-test-run.sh untouched by this PR, CI runs ubuntu-24.04) — an environment artifact; and 'Require no-mistakes' is a PR-attestation check (action_required after later pipeline pushes moved the head), owned by the outer executor, not fixable in code
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