Repository navigation
fix(bin): keep home-summary collection inside its refresh deadline - #7376
Conversation
77b0325 to
fd404cb
Compare
[Medium impact] The PR appears safe to merge; no new blocking issue was found. Reviews (2) · Last reviewed commit: "no-mistakes(review): Rename per-task row..." · Reviewed by Greptile |
|
Speaking as Kun's firstmate: thank you @LifeBringer for keeping home-summary collection inside its refresh deadline on Gates: coverage guard, repo invariants and no-mistakes all pass on this head; attestation binds Contract-class: restore. Main already promises Next: nothing waiting on you. Ours to run Full; restore path means auto-merge after Full is green. |
|
Speaking as Kun's firstmate: thank you @LifeBringer. Quick checks are green on |
A home of twelve scouts with long status histories repeatedly hit the 60-second home-summary refresh deadline while fm-fleet-snapshot.sh was still collecting. After the bounded concurrent reads, every task row was composed one task at a time, and each row re-folded that task's whole append-only status history through status_open_decisions, which forked four to five subshells per decision transition. Collection cost grew with task count times history and had no concurrency of its own, so a busy host pushed it past the whole-operation bound before validation or publication. Fold each task's status history inside its own observation worker while its bounded current-state read is outstanding, and compose its row in that same worker, so FM_SNAPSHOT_LOCAL_READ_CONCURRENCY now bounds the whole per-task cost. Give the whole-file fold's per-line helpers the optional out-variable form status_line_verb already uses, so the fold no longer forks per line; every printed form is unchanged for other callers. The refresh deadline, per-child current-state bound, validation, atomic last-good publication, and refresh lock are unchanged.
…history-growth cost
fd404cb to
daaa666
Compare
|
Speaking as Kun's firstmate: thanks @LifeBringer for rebasing onto current main. I read the full diff on The no-mistakes attestation binds Next: |
|
Speaking as Kun's firstmate: this is merged. Thank you @LifeBringer — really appreciate you taking the time on this. |
…unchenguid#7376) * fix(bin): keep home-summary collection inside its refresh deadline A home of twelve scouts with long status histories repeatedly hit the 60-second home-summary refresh deadline while fm-fleet-snapshot.sh was still collecting. After the bounded concurrent reads, every task row was composed one task at a time, and each row re-folded that task's whole append-only status history through status_open_decisions, which forked four to five subshells per decision transition. Collection cost grew with task count times history and had no concurrency of its own, so a busy host pushed it past the whole-operation bound before validation or publication. Fold each task's status history inside its own observation worker while its bounded current-state read is outstanding, and compose its row in that same worker, so FM_SNAPSHOT_LOCAL_READ_CONCURRENCY now bounds the whole per-task cost. Give the whole-file fold's per-line helpers the optional out-variable form status_line_verb already uses, so the fold no longer forks per line; every printed form is unchanged for other callers. The refresh deadline, per-child current-state bound, validation, atomic last-good publication, and refresh lock are unchanged. * no-mistakes(review): Describe batched snapshot workers and remaining history-growth cost * no-mistakes(review): Rename per-task row temp file to avoid dotted-id collisions
Intent
Fixes #6257. On a home with many tasks and long status histories, bin/fm-home-summary-refresh.sh exits 124 at its unchanged 60-second deadline while bin/fm-fleet-snapshot.sh --secondmate-home-summary is still collecting, so the home summary stops updating. The snapshot composed every task row one task at a time after the bounded reads, and each row re-folded the task's whole status history through status_open_decisions, which forked subshells for every status line. This change runs each task's open-decision fold and row composition inside that task's own observation worker (still batched by FM_SNAPSHOT_LOCAL_READ_CONCURRENCY, default 8), and lets the fold helpers in bin/fm-classify-lib.sh fill an optional output variable so the whole-file fold forks nothing per line; called without that variable they print exactly what they printed before. The 60-second deadline, the per-child read bounds, the default concurrency, and the published summary content stay unchanged. Collection cost still grows with unbounded history, and the pending-reply retention from the issue's follow-up is out of scope; both are follow-ups. Earlier open PRs #6464 and #6980 target the same issue; the maintainer chooses the direction to keep. This revision rebases onto current main to clear a conflict with the timed fold view in _fm_decision_fold_line. Evidence, from the reproduction posted at #6257 (comment): running the incident-shaped case of tests/fm-home-summary-refresh.test.sh (12 tasks, about 508 status lines each, default 60s deadline) on main a9ae3c0 printed INCIDENT_WALL=37s on a quiet machine and 'not ok - the incident-shaped fleet did not publish within the default deadline' (stderr 'refresh exceeded its 60-second deadline') under background-QoS contention; the pre-rebase head fd404cb printed 6s quiet and 20s contended. After the rebase, 480 whole-file, per-line, and timed folds over 40 fuzzed status logs matched main byte for byte.
AI assistance: an assistant helped write this change and ran the documented checks through no-mistakes.
What Changed
bin/fm-fleet-snapshot.shnow folds each local task's open decisions and builds its row inside that task's own observation worker. Workers still run in batches ofFM_SNAPSHOT_LOCAL_READ_CONCURRENCY(default 8). Before, every row was built one task at a time after the bounded reads finished. The 60-second refresh deadline, the per-child read bounds, and the published summary content are unchanged.bin/fm-classify-lib.sh(status_line_note,_fm_decision_key,_fm_key_at_note_head,_fm_decision_drop,_fm_decision_fold_line) accept an optional output variable. With it, a whole-file status-history fold starts no subshell per line. Without it, they print the same output as before.tests/fm-home-summary-refresh.test.shadds three cases: a hung row build that must still be stopped by the deadline, a check that row builds run concurrently, and an incident-shaped fleet (12 tasks with long status histories) that must publish within the default deadline.docs/configuration.mdupdates theFM_SNAPSHOT_LOCAL_READ_CONCURRENCYdescription to match the new behavior.Risk Assessment
✅ Low: The out-variable forms of the fold helpers reproduce the old command-substitution results: trailing newlines are stripped the same way, invalid-slug and keyless paths match, and local names cannot collide with the caller variables (folded, key, note, stated, open). Moving each task's row composition into its own observation worker keeps the generation-race discard, the failure handling, and the empty-fleet output; the deadline, the read bounds, and the default concurrency are unchanged, as the intent requires.
Testing
I drove the real snapshot producer and refresh writer against a disposable lab home shaped like the incident, on both head and base. Head collected in 4s vs 26s (11s vs 60s at concurrency 1) and published in 7s vs 39s. The snapshot JSON was byte-identical, and the published summaries matched apart from nothing at all (the generated stamp was pinned and equal). Fuzzed fold-helper output on head matched base exactly in print and out-var modes. The targeted test file passed its new incident and concurrency cases every time. One unchanged existing case, a dead publication lock, flaked twice under host load and passed twice once load dropped; it is reported as a warning. No UI surface is involved, so the evidence is CLI transcripts and JSON.
Evidence: Incident-shaped lab home: head vs base snapshot and refresh timing plus content equality
Source: Incident-shaped lab home: head vs base snapshot and refresh timing plus content equality
Evidence: Same scenario with FM_SNAPSHOT_LOCAL_READ_CONCURRENCY=1
Source: Same scenario with FM_SNAPSHOT_LOCAL_READ_CONCURRENCY=1
Evidence: Published home-summary.json from head refresh
Source: Published home-summary.json from head refresh
Evidence: Published home-summary.json from base refresh
Source: Published home-summary.json from base refresh
Evidence: Fold helper fuzz equivalence base vs head
Source: Fold helper fuzz equivalence base vs head
Evidence: Targeted test run 3 (all pass)
Source: Targeted test run 3 (all pass)
Evidence: Targeted test run 1 (flaky dead-lock case failed under load)
Source: Targeted test run 1 (flaky dead-lock case failed under load)
Evidence: Targeted test run 2 (flaky dead-lock case failed under load)
Source: Targeted test run 2 (flaky dead-lock case failed under load)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
bin/fm-classify-lib.sh- merge conflict rebasing onto refs/remotes/no-mistakes-push/fm/firstmate-home-summary-timeout✅ **Review** - passed
✅ No issues found.
tests/fm-home-summary-refresh.test.sh:1081- The unchanged case 'a dead publication lock wedged publication' in tests/fm-home-summary-refresh.test.sh failed in 2 of 4 head runs. Both failures came while the host load average was about 9 (15-minute average about 26). It passed in 2 later runs at load about 5 to 6, and base passed the same test file once at moderate load. The case gives a background best-effort publication only 10s (200 x 0.05s) to appear, which looks like a timing-only flake under host contention. This change speeds collection up and does not slow it down. It may still need a longer wait if CI hosts are as loaded.bash tests/fm-home-summary-refresh.test.shon head, 3 times (first 2 failed only at the dead-publication-lock case under high load, third passed fully); the new incident-shaped and concurrent-composition cases passed in every runbash tests/fm-home-summary-refresh.test.shon an extracted copy of base a9ae3c0c (passed)Lab home minted withbin/fm-lab-home.sh create(private tmux dir) and seeded with 12 tasks of 508-line incident histories plus varied open decisions:bin/fm-fleet-snapshot.sh --secondmate-home-summaryrun on head and base, timed, and the JSON comparedRealbin/fm-home-summary-refresh.shrun on head and base against the same lab home: exit code, wall time, and the published state/home-summary.json comparedThe same lab scenario withFM_SNAPSHOT_LOCAL_READ_CONCURRENCY=1on head and baseFuzz equivalence: 80 random status logs (both key positions, malformed slugs, colon time tags, until tags, unterminated last line) folded through status_open_decisions, per-line _fm_decision_fold_line (plain and timed, kinds ship/scout/secondmate), status_line_note, and _fm_decision_key, on base (print) vs head (print and out-var)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.