Skip to content

fix(bin): keep signal-stopped contribution reads unmeasured - #6564

Closed
sgwoods wants to merge 4 commits into
kunchenguid:mainfrom
sgwoods:fm/fm-contrib-bound-reads-unmeasured
Closed

sgwoods wants to merge 4 commits into
kunchenguid:mainfrom
sgwoods:fm/fm-contrib-bound-reads-unmeasured

Conversation

@sgwoods

@sgwoods sgwoods commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Intent

The symptom is real. A supervisor polling its own contributions was woken with
contributions: observation unavailable for <pr-url> six times in one afternoon, every time on a pull
request that was open, cleanly mergeable, and unchanged at the commit already on record. Running the
same generated check by hand succeeded and cleared the record's error to None with a complete
observation, head and checks included, so the pull request was not the variable.

This change fixes one real defect found while investigating that symptom. A read stopped by a
signal aimed at the read alone reached forge() unnormalized and was recorded as
error: "forge observation unavailable or changed during read". That means 137 from an external kill,
or TERM's 143, INT's 130 and HUP's 129 delivered to the read rather than to the poll. Such a read
answered nothing, so it is unmeasured, not a forge failure.

Two things this change deliberately does not claim.

  • It does not fix the five-second per-read cap. That path was already correct: every timeout mechanism
    normalizes its own bound to 124 (fm_run_external_timeout collapses its own 124|137, the perl
    watchdog exits 124 from its handler, the bash fallback returns 124 when its deadline fired), and
    forge() already treated 124 as unmeasured. On a host using the perl mechanism,
    fm_run_timed 1 sleep 3 returns 124.
  • It no longer addresses unsupported-forge URLs. fix: keep unsupported contribution URLs unmeasured #7233 fixed that independently, by gating
    observation on supported_url and keeping unsupported URLs out of final settlement and the
    forge-read rotation — which also removes the first-iteration unbound-variable abort. An earlier
    revision of this branch carried its own fix for that behaviour. It is withdrawn here as redundant,
    together with its test, because that test passes against upstream without this change and so
    demonstrates nothing. A test that cannot fail is worse than no test, since it claims coverage it
    does not have.

The cause of the observed wakes remains unidentified and is tracked separately. Candidates
consistent with the evidence include gh exiting nonzero — for example a secondary rate limit from the
six concurrent paginated reads in a pull observation — or the observation's jq/valid_record checks
failing. None can be confirmed today, because each read's stderr is discarded when the poll cleans up.

The documented contract was already right. The header states that a read the budget refuses
"remains bounded and may be unmeasured, rather than being mislabeled unavailable". Where behaviour and
that contract disagreed, the contract was correct and the code was changed to match it.

Prior context: this supersedes #6493, which was closed. Nothing from that pull request's argument is
repeated here; this stands on its own merits.

What Changed

  • bin/fm-contributions.sh adds read_cut_short, which asks fm-timeout-lib.sh which statuses report
    its own bound (124, and 137) and adds the three signal statuses 129, 130 and 143. A read matching any
    of them is recorded through a new unmeasured helper, which forge() also uses on its existing
    budget-refusal path. Before this change only 124 was recognized, so a read ended by one of the other
    statuses was recorded as a failure.
  • Only a forge failure, a malformed response, a client death outside that set (such as SIGSEGV's 139),
    or a head change during the observation records an error. The header's error-condition sentence is
    corrected to say so, because it previously named only a forge failure or head change.
  • The read-outcome classification contract is stated in full exactly once, in the script header that
    usage() publishes; read_cut_short and forge() carry one-line cross-references rather than their
    own copies.
  • tests/fm-contributions.test.sh adds test_read_outcome_classification, which drives one read to
    each distinct end and asserts opposite outcomes in the same test: the bound and signal statuses stay
    unmeasured, silent, and leave the prior record byte-identical, while a forge failure, a SIGSEGV
    client crash and a head change during the observation each record an error and wake. One existing
    pass message is reworded from "budget refusal" to "unmeasured" to match the corrected contract.

No other file is touched, and no other part of the observer's contract changes.

Risk Assessment

⚠️ Low. The change is small and narrowly scoped: it widens the set of statuses treated as "this read
answered nothing" and changes nothing else. The failure edges are asserted in the same test as the
silent ones, so the change cannot be mistaken for silencing errors generally. The residual risk is that
this does not resolve the originally reported wakes, whose cause is still unidentified and tracked
separately; that is stated above rather than implied.

Testing

Verified against this head, rebased onto current main:

  • bash tests/fm-contributions.test.sh — 52 of 52 pass, exit 0. Run serially; two of the file's
    wall-clock assertions (test_unmeasured_url_does_not_starve_the_tail,
    test_shared_url_observed_once) fail under heavy parallel load on a contended machine and pass in
    isolation, which is worth knowing for a busy runner.
  • bin/fm-lint.sh — exit 0, with the pinned ShellCheck 0.11.0 and actionlint 1.7.12, 3 workflow files
    valid. shellcheck -x -S style is clean on both changed files.
  • Both directions, against unmodified upstream. test_read_outcome_classification placed on the
    untouched upstream tree fails on the 137 case
    (an unmeasured read (cut-kill) printed an unavailable wake) and passes with this change. That is
    what establishes the defect is real and still present upstream.
  • The signal classification was additionally exercised live by an earlier revision of this branch,
    against a real open pull request in a disposable lab home, with the read stopped by real SIGTERM,
    SIGKILL, SIGHUP and SIGINT rather than simulated exit 13x statuses, each compared against the base
    commit, where the base woke and the change stayed silent. A SIGSEGV client death and an HTTP 502
    forge failure still woke. That classification code is unchanged since those runs.
  • The head-change-during-read case is covered by the fixture test only. Forcing a real pull request's
    head to move mid-read would require pushing to a forge.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Updates contribution-read timeout and signal handling logic.

The PR appears safe to merge based on the reviewed changes.

Reviews (2) · Last reviewed commit: "fix(bin): keep signal-stopped and unsupp..."

@sgwoods sgwoods changed the title fix(bin): keep bound-stopped and unsupported contribution reads unmeasured fix(bin): keep signal-stopped and unsupported contribution reads unmeasured Oct 4, 2026

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: triage complete for this PR.

Contract-class: restore — concrete existing contributions-poll classification path was broken: signal-stopped reads (TERM/INT/HUP/kill bound) and unsupported-forge URLs were collapsing into forge-unavailable error/wake episodes. Restores the documented unmeasured contract (no false unavailable wakes) without new default-on surfaces.

VISION (per rule):

  • One captain one interface: PASS — fewer false contribution wakes
  • Authority explicit: PASS — no new autonomy
  • Scripts vs agents: PASS — deterministic read-outcome classification
  • Restart non-event: PASS — durable observations unchanged on unmeasured cuts
  • Delegation with spine: PASS — contribution watcher mechanics only
  • Fleet outlives vendor: PASS — unsupported forge stays unread/unmeasured
  • Scope: PASS — contributions poll classification only

Gates: attestation MATCH. Greptile SUCCESS (no P1s; confidence 5/5; appears safe to merge pending CI). MERGEABLE. Fork CI + Require no-mistakes approved this pass (CI run 37206427458; NM 37206965465 / duplicates).

Waiting on CI (approved, running/pending) — not waiting on author.

…sured

A contribution read that a bound stopped answered nothing, so it is unmeasured
rather than a forge failure. forge() recognized only the 124 the timeout runner
reports for its own cap, so a read ended by an external SIGKILL or by TERM, INT
or HUP aimed at the read alone was recorded as "forge observation unavailable or
changed during read" and woke supervision for a pull request that was open,
mergeable and unchanged at the commit already on record. Nothing deduplicated
the repeat, because every poll recorded the error afresh.

observe() also reset its per-URL flags after the unsupported-forge and
unsupported-kind returns, so a URL that was never read inherited the previous
URL's result and could be reported as a failure. Resetting first also keeps an
unsupported URL at the head of the rotation from reading an unset flag.

A genuine forge failure, a client death outside the bound set, and a head change
during the observation all still record an error and still wake; those are the
cases the error exists for.

The read-outcome contract is stated in full once, in the header usage()
publishes, and read_cut_short() and forge() carry one-line pointers at it.

Tests pin both directions in one table: a read stopped by its bound or by any of
137, 143, 130 and 129 records no error and raises no wake, while a forge failure,
a SIGSEGV client crash and a head change each record one and wake. The
unsupported-forge case runs with that URL both ahead of and behind a supported
one, because only the trailing position can catch the inherited result and only
the leading position covers the first iteration.
…asured

A read stopped by a signal aimed at the read alone now stays unmeasured rather than being recorded as a forge failure.
An unsupported-forge URL can no longer inherit the previous URL's result.
It can also no longer abort the poll on its first iteration by reading an unset flag under set -u.
A genuine forge failure, a client death outside the bound set, and a head change during the observation each still record an error and still wake.
What produced the observation-unavailable wakes seen in the field is not yet established, and is tracked separately.
This change does not fix those wakes.
A read stopped at the runner's own five-second cap is not newly fixed here.
Every timeout mechanism normalizes its own bound to 124, and that status was already treated as unmeasured before this change.
This commit corrects the delivery prose only and changes no code or test behaviour.
@sgwoods
sgwoods force-pushed the fm/fm-contrib-bound-reads-unmeasured branch from d3f32bf to 1240f89 Compare October 14, 2026 14:10
@sgwoods sgwoods changed the title fix(bin): keep signal-stopped and unsupported contribution reads unmeasured fix(bin): keep signal-stopped contribution reads unmeasured Oct 14, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @sgwoods — re-read tip 1240f89a against main after #7233 landed (89028578).

Overlap: #7233 already keeps unsupported forge URLs unmeasured. Your rewrite correctly withdrew that half. What remains — read_cut_short treating bound/signal stops (124/137 via fm_timed_out, plus TERM/INT/HUP 143/130/129) as unmeasured instead of forge-unavailable — is a distinct defect. Main still only special-cases rc==124. So this is not closed as leftover; it is still useful.

Contract-class: restore. The contributions header already promised bound-stopped reads stay unmeasured; signal-stopped reads were mislabeled unavailable.

VISION: all seven rules align (fewer false wakes; script owns classification; command-layer scope).

This pass: fork CI approved. Blocker: the PR body no longer carries a no-mistakes-pipeline-attestation for this tip, so Require no-mistakes cannot MATCH. When you have a chance, please re-raise through git push no-mistakes (and any live note you can spare for the signal-stopped path). No rush. No Firstmate flag; no security tip.

…uid#7233

Upstream kunchenguid#7233 "keep unsupported contribution URLs unmeasured" fixed this
independently and better, one layer up: it gates observation on supported_url
and keeps unsupported URLs out of final settlement and the forge-read rotation
entirely. Because observe() is therefore never called for an unsupported URL,
the two guards this branch added inside it are unreachable, and the
first-iteration unbound-variable abort they also fixed can no longer happen.

So this commit removes that half and restores observe() to upstream's form,
byte for byte. It also drops test_unsupported_forge_url_is_never_recorded_as_a_failure,
which passes against upstream without this branch's changes and therefore
proves nothing; a test that cannot fail is worse than no test, because it
claims coverage it does not have.

The earlier commits on this branch are kept rather than rewritten so the
superseded work stays visible and reviewable. Anyone reading the branch should
see why that half appears and then goes.

What remains is the distinct defect upstream still has: a contribution read
stopped by a signal aimed at the read alone is recorded as a forge failure
rather than as unmeasured. read_cut_short, the unmeasured helper,
test_read_outcome_classification and the corrected header prose all stay.
@sgwoods
sgwoods force-pushed the fm/fm-contrib-bound-reads-unmeasured branch from 1240f89 to 986b840 Compare October 15, 2026 02:15
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks for the new push, @sgwoods — I re-read head 986b8405 against main 33503ab3.

Still useful: main's forge() still only treats rc==124 as budget refusal, so the 137 bound-kill and the read-only TERM/INT/HUP stops are still recorded as forge-unavailable. Neither #7233 nor #6810 covers that.

Contract-class: restore (my own read). The script header on main already says a read killed at the bound is budget refusal, never a forge failure, and that only a genuine forge failure, structural refusal or head change records an error. The code just doesn't do that yet.

VISION: all seven rules align. It cuts false wakes, the script owns the classification, and the scope stays in the contributions poll.

What's in the way right now:

When you have a moment, could you rebase onto current main (keeping #6810's failing-step line for genuine failures) and re-raise through git push no-mistakes? If a no-mistakes run is already going, please ignore this part. A one-line note that your signal-stopped lab check still holds after the rebase would be lovely too. No rush, and thank you for the careful write-up.

@sgwoods

sgwoods commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #7332, which is the same change raised on a clean branch with a bound attestation.

Why it moved: the validation attestation could not be bound to this branch. It had been force-pushed by
hand, which broke the pipeline's push binding, and every subsequent attempt to re-attest was refused —
correctly, since the guard cannot tell an authorised narrowing from lost work. That was our doing, not a
fault in the gate, and raising it fresh was cheaper than asking anyone to waive a check the project
deliberately requires.

Thank you for the two reviews here — they shaped what #7332 contains rather than merely approving it.
Confirming that #7233 already keeps unsupported-forge URLs unmeasured is what led us to withdraw that
half entirely, along with its test, which passes against main without the change and so proved
nothing. And your read that the remainder is a distinct defect — that main still treats only rc==124
as a budget refusal, leaving the 137 bound-kill and the read-only TERM/INT/HUP stops recorded as
forge-unavailable — is exactly what #7332 now fixes and nothing else. It also keeps #6810's
failing-step line intact for genuine failures, and merges your error-condition wording with ours into a
single sentence rather than two.

Closing this in favour of #7332.

@sgwoods sgwoods closed this Oct 15, 2026
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.

2 participants