Repository navigation
Conversation
The poll's per-call bound was a hard five seconds, and a single GitHub API latency spike above it (one measured at 7.5s) recorded "forge observation unavailable or changed during read" and woke supervision. Roughly fifteen such wakes arrived in a week; every one had no pending signals, the prior observation intact, and the same reads succeeding by hand moments later. Raise the per-call bound to ten seconds while the poll deadline stays the outer bound. Retry a failed observation once when the failure was not the budget's, and keep an attempt the budget cuts short unmeasured exactly like a first attempt: prior records untouched, no unavailable record. Append the failing read's first bounded, single-line stderr text to the recorded reason so a record names the failed call while the existing prefix, wake text, acknowledgement contract, schema, locking, and rotation stay unchanged. Tests cover a read between the old and raised bounds completing fresh without a wake, one transient failure recovering on the single retry without a wake, and a retry cut short by the budget staying unmeasured. The fixture fake clock now resolves the host's date instead of /bin/date so the suite also runs on hosts without an FHS bin tree.
…URL polls do not abort
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
No captain words drove this task; it is firstmate-repo maintenance filed by firstmate. The captain-facing line is short: the contributions observer has been emitting repeated
contributions: observation unavailable for <url>wakes because its hard per-call timeout is shorter than the GitHub API's occasional latency spikes, and this task hardens it.Evidence:
data/learnings.md(2026-10-03 entry) records the reproduction - the per-call bound inforge()is a hard 5s, individualgh apicalls normally take 0.5-1s but spike past 5s (one measured 7.5s), and a burst can fail many URLs in one poll (six URLs failed in the 2026-10-06 poll). Every recorded failure hadpendingempty, the prior observation intact, and the same reads succeeding by hand moments later, so these are benign latency transients that cost a wake and a reconciliation each time. Roughly fifteen such wakes in a week.What Changed
forge()from 5s to 10s so GitHub latency spikes complete instead of being killed as budget refusal.Risk Assessment
✅ Low: The change is a small, well-bounded hardening with behavioral regression tests for the raised bound, the successful retry, and the budget-cut retry; the remaining notes are a test-only date-fallback gap and the accepted cost of repeating deterministic failures.
Testing
Drove bin/fm-contributions.sh poll from the gate worktree in a throwaway marked lab home against the real GitHub API with the machine's logged-in gh, perturbing only the CONNECT path (delay/502) to reproduce latency spikes and transient failures. Thirteen live scenarios covered: healthy polls, a 7s core-read spike completing under the raised 10s bound (with an ac0811c A/B that leaves the record unmeasured), reads past the bound staying silent budget refusals with no retry, a single 502 retried once and self-healing (with a base A/B showing the reported wake), a retry cut by the budget staying unmeasured, a persistent outage waking once per episode with the failing call named in the record, a shared URL served by one retry for both owners, and both cross-URL stderr fixes (GitHub-first isolation, and the rotated unreadable-first order whose f8ecd43 A/B aborts with BUDGET_EXHAUSTED unbound). The focused fixture suite on 92c1683 is green (54 ok, 0 not ok) and the round-2 regression test is red against f8ecd43. Only the head-changed-during-observation retry could not be forced live (no deterministic way to race a real PR head); it is covered by the fixture test
test_shared_url_observed_oncehead mode. No reviewer-visible visual surface exists for this CLI change, so evidence is CLI transcripts and persisted record JSON. No actionable findings; every live scenario passed.Evidence: Round-3 live validation summary (results, excerpts, transcript index)
Source: Round-3 live validation summary (results, excerpts, transcript index)
Evidence: S8b rotated poll: target rc=0 with per-URL errors; f8ecd43 rc=1 unbound
Evidence: Focused regression suite on 92c1683
Evidence: S1 healthy poll, no proxy (fresh observation, no wake)
Source: S1 healthy poll, no proxy (fresh observation, no wake)
Evidence: S1b healthy poll through passthrough proxy
Source: S1b healthy poll through passthrough proxy
Evidence: S2 7s spike completes under raised bound (target, elapsed 9s)
Source: S2 7s spike completes under raised bound (target, elapsed 9s)
Evidence: S2-base 7s spike at ac0811c left unmeasured
Source: S2-base 7s spike at ac0811c left unmeasured
Evidence: S3 read past 10s bound: one attempt, silent, untouched
Source: S3 read past 10s bound: one attempt, silent, untouched
Evidence: S4 single 502 retried once and heals (target)
Source: S4 single 502 retried once and heals (target)
Evidence: S4-base single 502 wakes at ac0811c (reported symptom)
Source: S4-base single 502 wakes at ac0811c (reported symptom)
Evidence: S5 retry cut by budget stays unmeasured and silent
Source: S5 retry cut by budget stays unmeasured and silent
Evidence: S6 persistent outage: one wake, second poll silent, error names failed call
Source: S6 persistent outage: one wake, second poll silent, error names failed call
Evidence: S7 shared URL served by one retry for both owners
Source: S7 shared URL served by one retry for both owners
Evidence: S8 GitHub-first cross-URL error isolation
Source: S8 GitHub-first cross-URL error isolation
Evidence: S8b rotated GitLab-first poll completes with per-URL errors
Source: S8b rotated GitLab-first poll completes with per-URL errors
Evidence: S8b-prefix adversarial A/B: f8ecd43 aborts rotated poll
Source: S8b-prefix adversarial A/B: f8ecd43 aborts rotated poll
Evidence: Focused test file run on 92c1683 (54 ok, 0 not ok)
Source: Focused test file run on 92c1683 (54 ok, 0 not ok)
Evidence: Red slice: rotated unreadable-first test against f8ecd43
Source: Red slice: rotated unreadable-first test against f8ecd43
Pipeline
Updates from git push no-mistakes
... (3 earlier update rounds omitted to keep the PR body within GitHub's 65536-char limit; full history is in the run log.)
🔧 **Test** - 2 issues found → auto-fixed (2) ✅
bin/fm-contributions.sh:260- The new per-read stderr evidence can be misattributed across URLs in one poll. observe() clears $TMP/last-forge.err only at line 264, after the scheme check at line 260, so a canonical-but-unreadable URL (GitLab .../-/merge_requests/N, which poll necessarily records as unmeasured) returns early and the error composed at line 445 appends the detail still held from the previous URL's genuine forge failure. Live A/B (S8): with a real GitHub PR's reads 502'd and a GitLab merge_request URL read in the same poll, the GitLab record's error became 'forge observation unavailable or changed during read: Get "https://api.github.com/repos/kunchenguid/firstmate/pulls/6780": Bad Gateway' even though no forge call was made for it (proxy log shows only the GitHub attempts); the base commit recorded the generic message with no detail. Suggested fix: move ': > "$TMP/last-forge.err"' above the scheme check in observe() (or append the detail only when this URL's own forge read failed); a scratch probe with that one-line move restored the generic message for the GitLab record while the GitHub record kept its own detail (raw/transcript-s8-cross-url-detail-probe.txt).read-onlygh auth statusandgh api repos/kunchenguid/firstmate/pulls/6780to confirm a real logged-in gh 2.97.0 and a real open PR for the fixturebin/fm-lab-home.sh create $(mktemp -d "${TMPDIR:-/tmp}/fm-lab.XXXXXX")for a disposable marked lab home; removed withrm -rf $LABat the end of the runS0:env -u NO_MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE -u FM_DATA_OVERRIDE -u FM_CONFIG_OVERRIDE -u FM_PROJECTS_OVERRIDE FM_HOME=$LAB bin/fm-contributions.sh poll— unperturbed real-GitHub pollS1: same poll withHTTPS_PROXY=http://127.0.0.1:18920pointed at the perturbing proxy in passthrough mode (control)S2: CONNECT #1 to api.github.com delayed 7s, fixedbin/fm-contributions.shvs$LAB/base/bin/fm-contributions.sh(base extracted withgit archive ac0811c | tar -xinto the lab)S3: CONNECT #1 delayed 14s (past the raised bound)S4: CONNECT #1 returned HTTP 502 on CONNECT, fixed vs baseS5: CONNECT #1 502'd and CONNECT #2 delayed 25s (retry cut by the budget)S6: CONNECTs #1-#4 502'd across two consecutive pollsS7: two task records owning the same PR URL, CONNECT #1 502'dS8: GitHub PR failure followed by a GitLab.../-/merge_requests/1URL in one poll — fixed, base, and a scratch probe with ': > "$TMP/last-forge.err"' moved above observe()'s scheme checkbash tests/fm-contributions.test.sh— 52 ok, 0 not ok (includes the new tests test_slow_forge_read_within_raised_bound_completes, test_transient_forge_failure_retries_once_and_recovers, test_budget_cut_retry_stays_unmeasured)🔧 Fix applied.
1 error still open:
bin/fm-contributions.sh:419- Live S8b (rotated URL order): when a canonical but unsupported URL (any non-GitHub /-/merge_requests/N, which poll necessarily records as unmeasured) is first in the poll rotation, observe() returns before assigning BUDGET_EXHAUSTED, so the new retry check expanded the unset variable and set -u aborted the poll with 'BUDGET_EXHAUSTED: unbound variable' (rc=1, no record updated). The base commit ac0811c was reachable through the same ordering at its continue line (line 399), so the crash predates this change; but the new retry code is now the first dereference and the change's cross-URL regression test pinned only the GitHub-first order. Fixed during this test phase: poll() initializes BUDGET_EXHAUSTED=0 before the loop (line 383) and tests/fm-contributions.test.sh adds test_rotated_unreadable_url_first_does_not_abort_poll (red against f8ecd43, green after the fix). Live S8b then completed rc=0 with the GitLab record generic and the GitHub record carrying its own stderr detail. The product fix and its regression test are already applied in this worktree.bash raw/r2-live-harness.sh- 11 live scenarios driving the real bin/fm-contributions.sh poll against the real GitHub API (PR kunchenguid/firstmate#6780) from a disposable marked lab home through the perturbing CONNECT proxy; run on f8ecd43 and re-run after the test-phase fixgit archive ac0811c binbase-source lab run of the GitHub-first cross-URL poll for before/after comparison (raw/transcript-r2-s8-base-cross-url-detail.txt)git archive f8ecd43 binlive pre-fix rotated-order reproduction in a fresh lab home (raw/transcript-r2-s8b-pre-fix-rotated.txt)red/green slice run oftest_rotated_unreadable_url_first_does_not_abort_pollagainst f8ecd43 and the fixed worktree (raw/r2-red-slice.txt)bash tests/fm-contributions.test.sh- focused file after the fix, 54 ok / 0 not ok (raw/focused-test-run-r2.log)🔧 Fix applied.
✅ Re-checked - no issues remain.
Baseline:gh api repos/kunchenguid/firstmate/pulls/6780confirmed the live fixture PR is still open at head e032f755e72ef9771458ae0064ef215900062c3abash tests/fm-contributions.test.shon 92c1683 -> 54 ok, 0 not ok, exit 0 (raw/focused-test-run-r3.log)bash raw/r3-live-harness.sh-> 13 live scenarios against real gh/GitHub API in a disposablebin/fm-lab-home.shlab, perturbed byraw/perturbing-connect-proxy.pl(raw/r3-harness-run.log,raw/transcript-r3-*.txt)Live S1/S1b healthy polls:env -u NO_MISTAKES_GATE ... FM_HOME=$LAB FM_CONTRIBUTIONS_BUDGET=20 bin/fm-contributions.sh poll(direct and via passthrough proxy) -> fresh observation, no wakeLive S2/S2-base: same poll with proxy rule1:delay:7on the target and ongit archive ac0811c-> target 7s read completes fresh; base kills at 5s and leaves the record unmeasuredLive S3: proxy rule1:delay:14-> killed at the 10s bound, exactly one CONNECT, silent, record untouchedLive S4/S4-base: proxy rule1:fail-> target retries once and heals; base emitscontributions: observation unavailable for <url>Live S5: rules1:fail 2:delay:25-> retry cut at the 10s bound, record untouched, no wakeLive S6: rules1:fail 2:fail 3:fail 4:failover two polls -> one wake, second poll silent, error...: Get "https://api.github.com/repos/kunchenguid/firstmate/pulls/6780": Bad GatewayLive S7 shared URL: rule1:fail-> one retry, both owners fresh, no wakeLive S8/S8b cross-URL detail (GitHub-first and rotated GitLab-first): rules1:fail 2:fail-> both orders complete with GitLab generic and GitHub's own stderr detailLive S8b-prefix adversarial A/B: same rotated poll withgit archive f8ecd43->line 416: BUDGET_EXHAUSTED: unbound variable, rc=1, both records untouchedRed slice: current test file'stest_rotated_unreadable_url_first_does_not_abort_pollagainst extracted f8ecd43 ->not ok - a poll whose first URL is unreadable aborted(raw/r3-red-slice-rotated.txt)Teardown:git status --porcelainclean, lab home/proxy/scratch roots removed after the run✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.