Repository navigation
fix(bin): stop false wakes from killed forge reads and slow first beats - #6668
Vela3202019 wants to merge 6 commits into
Conversation
|
| if [ "$observed" -ne 0 ] && [ $((DEADLINE - $(date +%s))) -ge "$OBSERVATION_RESERVE" ]; then | ||
| observed=0 | ||
| observe "$url" || observed=$? |
There was a problem hiding this comment.
Repeated failures consume poll budget This retry also runs when the URL already has an open error episode, which cannot emit another unavailable wake. If a persistent forge failure takes seconds per read, the extra attempt uses the shared poll budget and can leave later healthy URLs unchecked. Skipping that extra read for an already-recorded failure would preserve more coverage.
Knowledge Base Used: Keep contribution records when the poll budget expires
e1ebbd3 to
d31c6b7
Compare
… the contributions poll
…with a fresh beacon
d31c6b7 to
a3c21fe
Compare
|
Note on test status: tests/fm-watch-arm.test.sh has one failure in this branch's local validation run: "re-append was not byte-identical to the inherited row" (test_append_wakes_handling_successor after-ack missing identical). This failure is pre-existing on origin/main - running origin/main's own fm-watch-arm suite fails the identical test - so it is not caused by this change and was intentionally left out of scope. The other affected suites (fm-contributions, fm-watch-triage, fm-wake-queue) pass. |
|
Speaking as Kun's firstmate: thank you @Vela3202019 for picking this back up with a fresh no-mistakes raise and live watcher runs. What I checked (head Contract-class (my own read): new-default. These are reasonable fixes for false wakes, but they change what an unconfigured home does on default-on paths: the watcher's startup order changes, a background beat loop runs during startup, and every contributions poll gets an extra retry read. Under our rules that's a captain call, not an auto-merge, even though the motive is a bugfix. VISION.md per rule: One captain aligns (fewer false wakes) · Authority aligns (no new grant assumed) · Scripts aligns (bounded deterministic mechanics) · Restart aligns (stale-lock evidence kept on refusal, wedged startup still goes stale) · Delegation aligns · Vendor neutral · Scope aligns. Status: waiting on CI, not on you. Once CI finishes green on this head, I'll pass it to Kun for the merge decision. The contributions retry scenarios ran against a stub forge rather than live. If you're able to capture one real transient forge failure being retried, that would strengthen the case, but it's optional. Thanks also for flagging the |
|
Speaking as Kun's firstmate: thanks @Vela3202019. CI finished on head
When you've rebased and fixed those, please re-raise through |
|
Superseded by #7944, which carries this same fix rebased onto current main, with the full suite green, Greptile at 5/5 and no open review threads. Closing this one so there is a single PR to review. The follow-up windows the maintainer asked about (rebase, Lint 1 / SC2031, serial 4, serial 9, re-raise through |
What Changed
bin/fm-contributions.shre-observes a URL whose observation failed, as long as the remaining budget still covers a full observation reserve. The error and the unavailable wake are recorded only after a second consecutive failure. A transient forge failure, or a head that moved mid-read, now costs one extra read instead of raising a false wake.bin/fm-watch.shnow runs the blocking recovery-marker transitions (reopen-announcedandarm-check) after the singleton lock identity is published. A helper touches the liveness beacon every second while those transitions run, so a watcher waiting on a long wake-queue drain reads to the guard and racing arms as a healthy, identity-matched holder. Both the startup beat and the transitions' lock waits stop atWATCHER_STALL_BOUND, using a new optional max-seconds argument inbin/fm-wake-lib.sh, so a startup stuck behind a hung holder still goes stale.fm_lock_acquire_wait_maxnow gives up immediately when the lock's parent directory is gone.exit_if_world_gonefunction. It also runs when a startup transition is refused and when the secondmate liveness or wake-stall ticks fail, so a deleted state directory exits with the teardown reason. A refused startup transition skips the cleanup trap and keeps the stale-lock evidence. Docs (turnend-guard.md,watcher-continuity.md) and tests (contributions, wake-queue, watch-arm, watch-triage) are updated to match.Risk Assessment
Testing
I drove the watcher startup scenarios live with the real arm and watcher scripts in throwaway marked lab homes. Each used a private tmux socket and its own wake-queue lock holder, and each lab was removed afterwards. - Blocked startup: a watcher stuck behind the lock was confirmed as started. A racing arm 8s later attached to it rather than refusing a stale heartbeat. The watcher kept polling once the lock was released. - Wedged startup: a watcher still blocked at the stall bound refused with "retaining stale lock evidence" and kept its lock evidence. Its beacon then went stale, and a later arm started a replacement. - State directory deleted during the block: the watcher exited at once with the state-gone reason in 4/4 live runs. The existing state-dir test passed 4/4; it flaked in an earlier round. For the contributions retry, the real poll ran only against a disposable stub forge, so these scenarios are marked untested rather than live: - With the stub, a single 502 was retried and left a clean record with no wake. - With the stub, a persistent 502 recorded the error and printed exactly one unavailable line. The surrounding targeted contributions tests also passed. This is a CLI and background-process change, so there is no visual surface; the evidence is the CLI transcripts.ghforge (contributions-retry-transcript.log; test_transient_forge_fail…Evidence: Live driver script (lab-home watcher scenarios)
Source: Live driver script (lab-home watcher scenarios)
Evidence: Blocked startup: arm reports started, racing arm attaches, no stale refusal
Source: Blocked startup: arm reports started, racing arm attaches, no stale refusal
[blocked +0s] arm A output: watcher: started pid=78809 (beacon fresh) [blocked +0s] lock pid=78809 pid-identity present=yes beacon age=0s [blocked +8s] after 8s more blocked (grace=3s, confirm=2s): watcher alive=yes beacon age=1s holder still holding=yes [blocked +9s] racing arm B output: watcher: attached pid=78809 (beacon 1s) [blocked +9s] no stale-heartbeat refusal [blocked +13s] watcher alive after release=yes beacon age=1sEvidence: Wedged startup goes stale at the stall bound and is replaceable
Source: Wedged startup goes stale at the stall bound and is replaceable
[wedged +5s] watcher exited rc=1 after ~4s; stderr: watcher: recovery state could not be reopened safely; retaining stale lock evidence [wedged +5s] lock evidence retained: pid file=91386 [wedged +8s] beacon age 1s -> 4s (keeps growing = stale, no helper still beating) [wedged +9s] later arm (grace 3s) after hung holder released: watcher: started pid=93376 (beacon fresh)Evidence: State dir deleted during blocked startup: prompt state-gone exit (4/4)
Source: State dir deleted during blocked startup: prompt state-gone exit (4/4)
Evidence: Contributions poll retry transcript (transient vs persistent 502, stub forge)
Source: Contributions poll retry transcript (transient vs persistent 502, stub forge)
retry-once: stdout <empty - no unavailable wake>; core reads 2; record error null fail-persist: stdout 'contributions: observation unavailable for https://github.com/o/r/pull/8 - core read exited 1 with 19s of budget left: HTTP 502'; core reads 2; record error retainedEvidence: Targeted watch-arm tests
Source: Targeted watch-arm tests
Evidence: Targeted contributions tests
Source: Targeted contributions tests
Pipeline
Updates from git push no-mistakes
⏭️ **intent** - skipped
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
ghforge (contributions-retry-transcript.log; test_transient_forge_fail…drive-watcher.sh blocked: in a marked lab home (fm-lab-home.sh create), a live holder keeps the wake-queue lock. The real bin/fm-watch-arm.sh runs with FM_GUARD_GRACE=3 and FM_ARM_CONFIRM_TIMEOUT=2. After 8s still blocked, a second real arm races it, then the lock is released.drive-watcher.sh wedged: the real bin/fm-watch.sh runs with FM_WATCHER_STALL_BOUND=4 behind a wake-queue lock holder that never releases. Then the beacon age is measured and a later arm is run.drive-watcher.sh stategonex4: an arm starts a watcher blocked at startup, the lab's state directory is deleted while the lock is still held, and the watcher's exit reason is checked.fm-watch-arm.test.shselectors: test_arm_confirms_a_watcher_blocked_on_the_wake_queue_lock, test_wedged_startup_goes_stale_at_the_stall_bound, test_watcher_exits_when_its_state_directory_is_removed (x4)Realbin/fm-contributions.sh pollagainst a disposable stub forge with faultsretry-onceandfail-persist; transcript records stdout, read count, record error and wake queue.fm-contributions.test.shselectors: test_transient_forge_failure_retries_once, test_persistent_forge_failure_still_records_after_retry, test_unavailable_forge_records_error_and_wakes_once_per_episode, test_http_500_once_retries_without_waking, test_shared_url_observed_once, test_unmeasured_url_does_not_starve_the_tail, test_slow_read_deadline_kill_is_budget_refusal✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.