Repository navigation
fix: report delayed blocker handling in away return briefs - #44
Merged
Merged
Conversation
Owner
Author
|
Fixture provenance: the report's A7 event could not be verified and is not represented as a real fixture. Closure beating a late steer is covered by a clearly labelled synthetic recombination of real S2 status transitions and an S4 inbox header. The Servora 5h32m status fixture remains explicitly labelled reconstructed because the original worker log no longer survives. |
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Away mode should notice and report when a blocker raised during the away window was never handled. On 2026-11-05 a Servora worker sat blocked for 5 h 32 m while the captain was away and the return brief never said so. Round 2 (firstmate PR 43) tried to build this check and the captain cut it after three fix rounds moved the bug (Q1779 B). On 2026-11-06 the captain approved a redesign from real logs, then a build (Q1804 Y: "q1804 y").
The design is /root/firstmate/data/fm-afk-blocker-check-redesign-d1/report.md. Its summary: stop trying to prove who handled a blocker from supervision logs; instead report, from the worker's own durable records (status log and steering inbox), how long each blocker raised during the away window sat before the first real action on it. On this home's real records every handled blocker had its first action within 0-6 minutes, and the 2026-11-05 stall shows 5 h 32 m. The return brief should carry a line such as: "servora-s15-ics-feed [key=default] blocked 09:43Z; no action for 5h32m - the longest wait this window."
Substance of the approved redesign referred to above:
At return and on subsequent check, measure the latest blocked interval per decision key on each still-live task record. Its opening epoch must be inside the away window from the stored entered_epoch through the evaluation time; never infer event time from file mtime, a wake, or observation time. Use the existing keyed status fold, including its resolved/captain-held closures and ship/scout done/failed terminal closure. A later working or paused line is not closure. For each interval take the first real action strictly after it opened: its keyed closure, a root or acknowledged steering-inbox record's at timestamp, or terminal task completion. Message prose is not parsed. Without action, measure through evaluation time. A blocker is handled when this gap is less than GRACE, default 900 seconds, with the single FM_AFK_BLOCKER_GRACE knob. Report inclusively at gap >= GRACE, including a late rescue as late rather than erasing the earlier wait.
Feed the existing Tried and failed, or could not be fixed section, longest wait first, showing task/key, blocked UTC time, first action and measured gap or no-action duration, and open/closed context. Keep the existing remediation wording on still-open blockers. Do not print handled intervals below grace. Count untimed blocked events in an honesty note without attributing them to this window, and name live task records with missing or unreadable status logs. Keep the existing catch-up gate, guard, and catchup-summary behavior unchanged; the dwell rows inform while that gate decides.
Use the worker-owned status and steering-inbox records for the predicate, independent of Pi branch, supervision-host, or away-daemon authorship and bookkeeping. The approved acceptance cases require real handled status/inbox fixtures to produce no dwell noise; the explicitly reconstructed Servora incident to show 5h32m; already-escalated daemon notices, unrelated progress, pre-entry blockers, and rotated ledgers not to count as action; needs-decision-only windows not to produce blocker rows; exact grace boundary and same-key reopening coverage; identical dwell output under all three bookkeeping sidecar shapes; and existing blocker-gate regressions unchanged. The design explicitly asks for a structural source guard excluding .supervision-host.log, .supervise-daemon.log, and branch-outcomes from the new dwell computation. Keep the reconstructed incident labelled as reconstructed. The predicate does not add actor inference, a turn counter, a watcher check, cadence, a new lock, or a fired-once ledger. During-window waking, needs-decision coverage, escalation-as-context requiring per-row queries, and cleaned-up-task history are separate follow-ups, not part of this return-time build.
What Changed
FM_AFK_BLOCKER_GRACE(default 900 seconds) for action, longest first, using worker status and steering inbox timestamps. Preserve late-action history and existing catch-up gating.Risk Assessment
blockedon a key that is still open. That case shows up in this home's real records, so it is worth fixing, but it can safely follow the merge.Testing
Three focused regression scripts and fresh wall-clock CLI scenarios passed. Live checks used shortened configurable grace; the exact reconstructed 5h32m case passed deterministic regression. CLI transcripts capture the product output. Disposable labs were removed and the worktree remained clean.
Evidence: Live return/check CLI transcript
Source: Live return/check CLI transcript
Evidence: Live attribution and ordering transcript
Source: Live attribution and ordering transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-afk-return.sh:252- scan_blocker_dwell treats every validblockedline as the start of a new interval. Lines 252-253 replace the key'slatestrecord unconditionally, even when the running fold already holds that key open as blocked. Workers do repeatblockedon a key that is still open: the real fixture pv-delivery-hide-leftovers-l1.status has four consecutiveblocked:lines on the default key with no closure between them. Concrete failing case (since=900):blocked [at=1000]: X, then the worker retries and writesblocked [at=20000]: still X, and the return runs at now=20300. The scan measures from 20000, so gap=300 < GRACE and no dwell row prints. The real wait was 19300s with no action, which is the Servora-style stall the intent requires the brief to report. When the second line comes later in the window, the wait is still under-reported (for example 1h15m instead of 5h32m). Same invariant, sibling site: if the re-stated line has no time stamp (line 250 sets epoch=-), the whole in-window interval is dropped at line 257, and the stall falls into the untimed note instead of a row. Fix: in the scan loop, keep a running fold of the status log using _fm_decision_fold_line, including resolve, captain-held and terminal lines, and only record a new opening epoch when the key was not already open asblockedbefore this line. status_key_closing_verb's watch already matches on the opening line's epoch, so it will then find the first closure of the true interval. Add a test for a re-stated blocker while the key is still open.bin/fm-classify-lib.sh:1080- Simplification: status_key_closing_verb gained two optional modes. One is an out-var with no opening epoch, which returns the epoch of the last closure (lines 1067-1068 when $4 is empty, plus line 1080). The other is the out-var with an opening epoch, which returns the first closure of that interval. The only production caller, bin/fm-afk-return.sh:261, always passes both arguments. The existing caller, bin/fm-captain-hold.sh:2032, passes neither. So the 3-argument mode without an opening epoch is used only by tests (tests/fm-classify-decision-key.test.sh:617-632). No intent requirement needs it. Recommended remedy: remove that mode, so the out-var is only filled when the blocked-epoch argument is present, and drop or adapt the tests that exercise it.tests/fm-afk-return.test.sh:1642- test_blocker_dwell_source_boundary only greps the text of bin/fm-afk-return.sh betweenscan_blocker_dwell()andwrite_pending_seed()for sidecar filenames. That is a source-content-only assertion, which the repository's test-quality rule says to flag. It also misses any helper the scan calls outside that span. The user intent does explicitly ask for 'a structural source guard excluding .supervision-host.log, .supervise-daemon.log, and branch-outcomes', and test_blocker_dwell_ignores_supervision_sidecars already proves the same boundary behaviorally across all the sidecar shapes. The intent and the test rule conflict here, so the user needs to decide whether to keep this grep test or rely on the behavioral test alone.bin/fm-afk-return.sh:288- blocker_dwell_iso (line 288) is the samedate -u -r || date -u -d @formatter as the existing epoch_to_iso (line 561). blocker_dwell_duration (line 293) is a second copy of format_duration (line 553), differing only in zero-padding the minutes (5h5m vs 5h05m). Have the dwell rows reuse epoch_to_iso and format_duration so the brief has one time format and one duration format.🔧 Fix applied.
4 issues (2 warnings, 2 infos) still open:
bin/fm-afk-return.sh:252- scan_blocker_dwell treats every validblockedline as the start of a new interval. Lines 252-253 replace the key'slatestrecord unconditionally, even when the running fold already holds that key open as blocked. Workers do repeatblockedon a key that is still open: the real fixture pv-delivery-hide-leftovers-l1.status has four consecutiveblocked:lines on the default key with no closure between them. Concrete failing case (since=900):blocked [at=1000]: X, then the worker retries and writesblocked [at=20000]: still X, and the return runs at now=20300. The scan measures from 20000, so gap=300 < GRACE and no dwell row prints. The real wait was 19300s with no action, which is the Servora-style stall the intent requires the brief to report. When the second line comes later in the window, the wait is still under-reported (for example 1h15m instead of 5h32m). Same invariant, sibling site: if the re-stated line has no time stamp (line 250 sets epoch=-), the whole in-window interval is dropped at line 257, and the stall falls into the untimed note instead of a row. Fix: in the scan loop, keep a running fold of the status log using _fm_decision_fold_line, including resolve, captain-held and terminal lines, and only record a new opening epoch when the key was not already open asblockedbefore this line. status_key_closing_verb's watch already matches on the opening line's epoch, so it will then find the first closure of the true interval. Add a test for a re-stated blocker while the key is still open.tests/fm-afk-return.test.sh:1642- test_blocker_dwell_source_boundary only greps the text of bin/fm-afk-return.sh betweenscan_blocker_dwell()andwrite_pending_seed()for sidecar filenames. That is a source-content-only assertion, which the repository's test-quality rule says to flag. It also misses any helper the scan calls outside that span. The user intent does explicitly ask for 'a structural source guard excluding .supervision-host.log, .supervise-daemon.log, and branch-outcomes', and test_blocker_dwell_ignores_supervision_sidecars already proves the same boundary behaviorally across all the sidecar shapes. The intent and the test rule conflict here, so the user needs to decide whether to keep this grep test or rely on the behavioral test alone.bin/fm-afk-return.sh:288- blocker_dwell_iso (line 288) is the samedate -u -r || date -u -d @formatter as the existing epoch_to_iso (line 561). blocker_dwell_duration (line 293) is a second copy of format_duration (line 553), differing only in zero-padding the minutes (5h5m vs 5h05m). Have the dwell rows reuse epoch_to_iso and format_duration so the brief has one time format and one duration format.bin/fm-afk-return.sh:244- The round-1 fix for dwell-reassert-restarts-interval brought in this cost. It now runsfolded=$(_fm_decision_fold_line ...)in a command substitution on every line of every live task's status log, before the verb check. That forks a subshell per line, so the return-time cost grows with each log's whole lifetime length. Status logs are append-only, so a worker's progress lines keep adding to it. The repo avoids exactly this cost elsewhere. status_open_decisions (bin/fm-classify-lib.sh:903-907) runs the fold only for needs-decision/blocked/done/failed/resolve/held lines, and status_key_closing_verb pre-filters lines with grep, with a comment calling per-line cost a concern. Concrete case: 10 live tasks with 500-line logs means about 5000 extra forks each time the return brief or check runs. Only a few dozen of those lines are transitions, and the fold leaves the open set unchanged for every other line (it early-returns$open). Fix: call status_line_verb first and run the fold only when the verb is needs-decision|blocked|done|failed|$resolve|$held. This matches status_open_decisions and gives the same result. Optionally, reuse that fold's result in place of the separatevalid=$(_fm_decision_fold_line '' ...)fork at line 250.🔧 Fix applied.
1 info still open:
tests/fm-afk-return.test.sh:1642- test_blocker_dwell_source_boundary only greps the text of bin/fm-afk-return.sh betweenscan_blocker_dwell()andwrite_pending_seed()for sidecar filenames. That is a source-content-only assertion, which the repository's test-quality rule says to flag. It also misses any helper the scan calls outside that span. The user intent does explicitly ask for 'a structural source guard excluding .supervision-host.log, .supervise-daemon.log, and branch-outcomes', and test_blocker_dwell_ignores_supervision_sidecars already proves the same boundary behaviorally across all the sidecar shapes. The intent and the test rule conflict here, so the user needs to decide whether to keep this grep test or rely on the behavioral test alone.✅ **Test** - passed
✅ No issues found.
bash tests/fm-afk-return.test.sh— includes real-record excerpts, the explicitly reconstructed Servora 5h32m case, sidecar invariance, and existing gate regressions.bash tests/fm-classify-decision-key.test.shbash tests/fm-task-inbox.test.shpython3 ~/.no-mistakes/evidence/01M6R9JQBC9XXM9G75QQXE88JY/live-dwell.py— real CLI, wall clock, isolated marked lab home.python3 ~/.no-mistakes/evidence/01M6R9JQBC9XXM9G75QQXE88JY/live-boundaries.py— adversarial attribution, ordering, and late terminal action.git status --short— clean after disposable lab cleanup.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.