You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bind timeouts on doc-health's last three git subprocess sites: pin_class, preflight, ideation_readiness (#1128) - #1142
On Brett Heap's words."do 1 and 2, claim 5" (#745 comment 5767008640) and "merge both when green, then fix 5 and merge when green" (#745 comment 5767058861, recorded on #1128 as comment 5767206176). Both #745 PRs have landed, so finding 5 — #1128 — is next.
What this binds. The three call sites #1128 measured inside scripts/doc_health/: the last unbounded git subprocesses there after #1098 / PR #1102 bound corpus.RealGit's pair. Each now binds a timeout and catches subprocess.TimeoutExpired beside OSError, mapped to the failure its caller already produces — never a new exception type for a caller to learn, never a silent success, never a hang. No contract, schema or policy text moves (#1128 declares code_surface: openxFactory, code-only), so no OpenSpec packet is owed.
Per site: before → after
1. scripts/doc_health/pin_class.py — _git (:1685)
Before
subprocess.run(["git", "-C", str(repo), *args], capture_output=True, check=check, text=True, encoding="utf-8", errors="replace") — no timeout=, and no try/except at all, not even a bare OSError. Nine call sites route through it, including verify()'s first act (:2451).
What it caught
Nothing. A missing git raised FileNotFoundError out of whatever reachability read was in progress; a hung git never returned at all.
The caller's own handling
Every one of the nine reads .returncode / .stdout / .stderr; not one checks for None. verify() raises GitUnavailable (a RuntimeError subclass whose docstring is "Never silently a pass") when _git(...).returncode != 0.
After
timeout=_GIT_TIMEOUT_SECONDS (30 s, the sibling bound) and except (OSError, subprocess.TimeoutExpired) answering CompletedProcess(args=argv, returncode=1, stdout="", stderr=<reason>) — the only "failed" shape this module has, so all nine callers are untouched. On the hot path that is the designed failure: verify()'s rev-parse raises GitUnavailable, exactly as it does for a git that said no. check=True is re-raised rather than translated, because that caller never reads the returncode and handing it a non-zero CompletedProcess would be the silent success this bound exists to prevent (no caller passes check= today — measured across scripts/ and tests/).
subprocess.run(cmd, cwd=repo_path, capture_output=True, text=True, env={...}) — no timeout=; the whole 72-line file contained zero try and zero except.
What it caught
Nothing. And cmd is not fixed to git: _entrypoints() builds python3 <validator>, bash scripts/validate-docs.sh or make validate per discovered repository.
The caller's own handling
A non-zero exit becomes Finding(ERROR, "preflight", repo, <path>, ...). But run_preflight is the first act of run_suite (runner.py:227) whenever no --family is passed — which is how the nightly invokes it — so a hang blocked every family before one ran, and never reached the Finding-producing branch at all.
After
timeout=_ENTRYPOINT_TIMEOUT_SECONDS and except (OSError, subprocess.TimeoutExpired) producing the sameFinding(ERROR, "preflight", ...), same family and same path so regression matching between two reports is unchanged, with the reason (timed out after 120s / could not be run: …) standing in for the output tail there is none of.
The 120 s here is a decision, not a slip, and the constant says so in the file. It is deliberately not the 30 s the two git sites bind. Those are single git plumbing calls; a preflight entrypoint is a whole repository's validator suite (make validate, bash scripts/validate-docs.sh, or a python validator that spawns git subprocesses of its own — validate-domain-openxfactory-pins.py does). A bound tight enough to cut an honest slow validator would convert a green nightly into an ERROR finding, i.e. a defect this PR would have introduced. The number is measured: the slowest entrypoint this repository can run is scripts/validate-memory-gateway.py at 3.26 s (the four openxFactory no-arg validators measured 0.12 / 0.49 / 0.77 / 3.26 s on 2026-09-21), so 120 s carries ~37x headroom over the slowest thing actually observed — while still being small enough that the whole preflight fits inside its own job: .github/workflows/doc-health-reusable.yml bounds that job at timeout-minutes: 45, and even if all ~13 entrypoints an aggregation run discovers timed out, 13 x 120 s = 26 min, so the timeouts surface as Findings rather than as a killed job with no report at all.
subprocess.run(["git", "-C", str(root), "archive", pin, "ideation"], capture_output=True) — no timeout=, no try/except. The third in-package site, which #1098's own 2026-09-17 sweep did not name.
What it caught
Nothing.
The caller's own handling
A non-zero return already answers (None, "the corpus at <pin> could not be reconstructed, so reproduction was NOT ASKED rather than answered: …") — the function's documented third outcome.
After
timeout=_GIT_TIMEOUT_SECONDS (30 s) and except (OSError, subprocess.TimeoutExpired) returning that same(None, "NOT ASKED rather than answered"). Never False: False would blame the committed body for a question nobody could put, which is the distinction test_reproduction_that_cannot_be_asked_is_neither_pass_nor_fail exists to keep.
Regression tests, failing → passing
Nine new tests: five appended to tests/doc-health/test_pin_reachability.py and a new tests/doc-health/test_preflight.py (#1128 measured that nothing tested that file). They assert the bound the call actually carries (kwargs["timeout"] == 30 / == 120, and that it is the module's declared constant) and raise TimeoutExpired, rather than timing a sleeping shim — a shim that sleeps proves only that the shim exited. Each then compares the timed-out result against the one a real unrunnable git or unspawnable entrypoint already produces (an emptied PATH), which is #1098's second, separate gap.
With the three source files swapped for origin/main's and the new tests present: 6 failed, 3 passed.
Restored: 9 passed. The three that pass on main too are contract pins rather than defect pins, and are there so the bind cannot move the surrounding contract: the two preflight baselines (an ordinary validator failure is still the Finding it always was; a clean validator still reports none) and the check=True guard, which main satisfies by catching nothing at all.
Validation
All foreground, private --basetemp, in a fresh clone.
…the same, on a pristine origin/main clone (@ 0f23341f)
7 failed, 1900 passed, 1 skipped (452.08 s) — the same seven names, all container-local (validate_index / pinned-validator / real-lines cases). +9 passed on this branch = the nine new tests.
touched test files (test_pin_reachability.py, test_preflight.py, test_ideation_readiness.py)
3 failed, 122 passed (151.02 s) — the three container-local test_ideation_readiness.py ones, which fail identically on the pristine clone (3 failed, 42 passed for that file alone)
python3 scripts/doc-health.py --single-repo . --as-of 2026-09-22 (no --family, so run_preflight runs), before vs after
verify_pin_reachability(".", allow_remote=False) before vs after
byte-identical, 130 lines. (families.py names neither pin_class nor ideation_readiness, so these two sites feed no doc-health family — the pin-reachability probe is their surface, and it is compared directly instead.)
106 passed, 1 failed (add-chain-attestation) — identical totals on the pristine main clone; that item carries a recorded disposition in contracts/openspec-cli-pin.yaml
python3 scripts/proposal-support.py . verify
proposal support verification ok
Both before/after comparisons swap only the three source files inside this one clone (git show origin/main:<path> > <path>, run, restore), so the corpus and the checkout kind are identical and the only variable is the code.
Out of scope
The 61 unbounded subprocess.run call sites #1128 mechanically scanned outsidescripts/doc_health/ — across 29 files, scripts/proposal-support.py alone holding 14, scripts/sequenced_after.py 6, scripts/attest-openspec-cli-pin-lockfile.py 4 — are out of scope for this PR and untouched. That scan is textual only (it cannot resolve kwargs-indirection such as validate-openspec-cli-pin.py's _run(argv, **kwargs)), and #1128 names it as a separate finding if it is taken at all.
Lands under Rule 6 on the word when the eight required checks are green and Copilot is clean.
Review round by lane openxfactory-4 (openXfactory-4-openDox_extraction)
Driven to the gate by a second lane on the holder's assignment, with Brett Heap's landing word of 2026-09-22 — verbatim "land #1142 too when green", recorded at #656 comment 5779648105. The original authorship above is lane openxfactory-2's and is left as written. This PR is NOT ratified and needs no ratification: code-only, no openspec/changes/ path, no README OpenSpec Records edit — it lands on a plain gate, not in a Rule 6 window, and takes no place in the #1140 → #1141 order.
Two Copilot findings at d78efc7c, both correctness, both taken as fixes at 9a6dd963.
r4073457110 — the bound turned an unaskable question into a confident answer
merge-base --is-ancestor reports "not an ancestor" by exiting non-zero, which is the same shape the timeout translation produces. So a bound that fired became a confident False, and verify() published it as ORPHAN or HISTORICAL — a pin declared unreached by main on a question nobody got to ask. is_truncated was worse in kind: it fell through to "--is-shallow-repository is false for <repo> and it declares no promisor remote", asserting two observations that were never made, under a docstring whose first line promises "OBSERVED not conjectured".
The module's own doctrine had already decided this, which is what makes the finding decisive rather than arguable:
remote_retention_refs refuses an empty dict for an unaskable namespace, because it "would be indistinguishable from the namespace is empty, and would silently convert an unaskable question into an answer";
retention_holder's unconsultable remote is reported "as INCONCLUSIVE rather than as an orphan";
verify() already renders could not be performed as INCONCLUSIVE for the retention read.
The fix._git returns an _Unavailable subclass of CompletedProcess — still non-zero, so the seven callers that only ever needed "this did not succeed" are unchanged, exactly as the translation intends. A subclass rather than a sentinel returncode: an exit code would collide the day a real git chose the same number, and isinstance cannot be spoofed. reachable_from_main and is_truncated answer None for "could not be asked", and verify() renders both INCONCLUSIVE at three call sites.
This reverses a scoping decision this branch had PINNED IN A TEST — that a third state "would change a caller contract this fix is not allowed to move". The cost the review measured is not payable: the bound introduced the path, so the bound owns it. The test is rewritten to pin the corrected behaviour and carries the reversal with its reason.
The new regression test is proved, not asserted.test_an_unaskable_ancestry_is_INCONCLUSIVE_and_never_orphan_or_historical lets the opening rev-parse succeed with real git and makes only merge-base --is-ancestor unaskable — the scenario the review named, and the only way to reach it, since verify() raises GitUnavailable on the first probe under a blanket timeout. Run against the pre-fix reader it FAILS with assert 'orphan' != 'orphan'; with the fix it passes. Both runs were performed.
ideation_readiness is not in this class and was checked: it handles its timeouts with named errors rather than translating them into a returncode.
r4073457175 — the fallback must not raise the race it is the fallback for
Every caller of _terminate_group sits inside _run_entrypoint's except subprocess.TimeoutExpired handler, whose whole job is to re-raise that timeout so run_preflight can turn it into a finding. If the child exits between communicate() timing out and cleanup, os.getpgid() raises ProcessLookupError — which is why the fallback exists — and a bare proc.kill() can then raise the sameProcessLookupError from inside the except handling it. That second exception replaces the TimeoutExpired, escapes the handler, and takes the run down at the moment a preflight finding was owed.
_kill_direct(proc) swallows OSErrorand nothing else; every other exception still propagates and the original timeout is re-raised unchanged. Both call sites use it, including the non-POSIX branch, which carried the same exposure.
Measurement
python3 -m pytest tests/doc-health -q → 1905 passed, 8 failed. Those 8 are the same 8 that fail on clean mainac50d70d in this clone (test_ideation_readiness ×3, test_readiness_dispatch ×1, test_sentinel_vocabulary ×3, test_status_reader_real_lines ×1) — proven by running them on main in the same checkout. Zero new failures.
Both threads answered and resolved.
Round 2 — the same defect in two more readers, found by the review of the fix
The first round corrected reachable_from_main and is_truncated and left two more readers in the same state. The review caught both; they are taken rather than argued, because the defect is identical and the argument was already made.
finding
what it was
r4073820387committed_text
git show reports "no such path in that revision" by exiting NON-ZERO — the same shape the bound produces — so a fired bound silently dropped pin sites from the sweep and made index_reproduces_at report a committed index as uncommitted. False negatives that look exactly like a clean answer. Now raises GitUnavailable, whose docstring is the doctrine verbatim: "The repository could not be asked. Never silently a pass."list_committed already raises it for the identical condition one call earlier in the same walk, so the two readers now agree.
r4073820387retention_holder
rev-parse --verify --quiet reports absence by exiting non-zero, so an unavailable LOCAL read fell through, consulted the remote, and — where the namespace legitimately does not advertise the pin — published ORPHAN on the strength of a local read that never happened. Now returns the unavailability, with the detail carrying the exact phrase verify() matches to render it INCONCLUSIVE.
r4073820457PinClassReport.truncated
Annotated bool while verify() assigned the None the previous commit made possible — an API that lied about itself, introduced by that same commit. Now `bool
Three more regression tests, each failing against the pre-fix reader — and the committed_text one also asserts that a genuinely uncommitted path still answers None, so the fix cannot over-reach.
Measured:pytest tests/doc-health → 1908 passed, 8 failed — the same 8 that fail on clean mainac50d70d in this clone, and three more passing than before because of the tests added here. Zero new failures.
Round 3 — the finding a zero-thread count would never have caught
The review at bf90d87c reported "Findings: None" with zero unresolved threads, and carried a "previously missed" item in its body — in code this branch had not touched — that was a real defect this branch had introduced:
is_truncated() answers THREE states since this branch, and None is FALSEY. Two real-repository helpers tested if truncated:, so an unobservable truncation fell through to verify() and asserted report.clean — which deliberately excludes inconclusive. The required reachability proof could therefore pass over unanswered results whenever the remaining pins happened to be reachable.
Fixed at 18dd8158: both helpers now test is not False / is None explicitly, and the second says which of the two conditions it hit, because "could not observe" and "observed, and it is truncated" send a reader to different remedies.
The pattern is worth naming, because it appeared three times on one branch: introducing a third state into a two-state reader leaves every truth test on that reader silently wrong, since the new state is falsey and reads as the old negative. The two production callers were corrected when the state was introduced; two test helpers were not.
This is also why the review BODY gets read and not just the thread count — a 0-unresolved count was true and told me nothing.
Round 4 — the new failure mode had a caller nobody had walked to
r4074075244, HIGH, at d78efc7c: rounds 2–3 made committed_textraiseGitUnavailable where it had returned None, and did not walk its callers. ideation_readiness.index_reproduces_at and _committed_status both call it, neither caught the new exception, so an unavailable git took the readiness probe down instead of answering the NOT-ASKED outcome each of them already has.
Fixed at 3c3deef2. index_reproduces_at returns (None, "…could not be read at…") — its own unanswered shape, distinct in wording from "is not committed", because an unreadable file and an absent one send a reader to different remedies. _committed_status returns None; its docstring now states why the conflation is acceptable in that one place and nowhere else — its single caller uses it only to choose a repair route to print for a pin already judged a defect.
Named, because this branch has now produced it twice:changing a reader's failure shape is not finished until its callers are walked. Round 2 caught it for the two production readers; this caught it for the two readiness probes.
Round 5 — an unreadable ref is not an absent one, and not None is not a proof
Two findings at 3c3deef2, both correctness, both taken as fixes at c3fa4da6. Both are the same class this branch exists to remove: an unaskable question silently converted into an answer.
finding
disposition
r4074256405resolve_main() still treats an unavailable probe as an ordinary missing ref
FIXED.MAIN_REF_ORDER tries refs/remotes/origin/main first because it is the authoritative spelling; refs/heads/main is its stand-in only in a clone that HAS no remote-tracking ref — the one condition the fallback was written for. --verify --quiet spells "not there" with the same non-zero exit _Unavailable carries, so a probe that TIMED OUT on the authoritative ref promoted the local branch to the authority for the whole run, and verify() published every reachability verdict in the report against it. A pin that IS an ancestor of origin/main but not yet of a stale local main comes back ORPHAN or HISTORICAL from that. The loop now stops at an unavailable ref; verify() already answers a Nonemain with INCONCLUSIVE at every site, so no new verdict was needed downstream.
r4074256452not pc.reachable_from_main(...) passes on the new None
FIXED at both sites. The reader returns True, False or None and nothing else, so not X and X is False differ on exactly one value — None, which is the value this branch introduced. not None is true, so an ancestry read that never happened would have satisfied the very assertion written to prove one did. Both now demand is False; the truthy sibling at the digest-collision fixture is spelled is True for the same reason, where it had been failing correctly only by accident.
The signature moves to (value, detail) — this module's own shape, already carried by is_truncated, remote_retention_refs and retention_holder — because the two Nones are different facts and the report has to say which one it met. A bare None would have left verify() printing no \main` in this clone (looked for ...)over a clone whosemain` may be sitting right there unread: one unmade observation traded for another. Nine call sites moved; measured, there are no others.
Proved both ways.test_an_unreadable_origin_main_does_not_promote_the_local_branch makes the WRONG answer available — refs/heads/main is real and readable, only the origin spelling times out — which is the only way to prove the right one is chosen. The module-wide timeout test cannot catch this, because it stops every probe: the case the old loop happened to get right. Against the pre-fix fall-through it fails with the defect in its own message:
AssertionError: the authoritative ref could not be READ, so the branch half of the
ref set is unknown — not ('refs/heads/main', '5e23da84...'), which is the stale
local branch answering a question that was put to origin
A second test pins that the fallback the ORDER exists for still works, so the narrowing did not swap one defect for another.
Where round 5's second fix runs. Those two assertions sit in test_every_declared_repo_local_pin_in_this_repository_resolves, which skips in the authoring checkout — a partial clone (remote.origin.promisor true), reported as such by the test's own skip reason — so CI is what exercises them. That is also why the change is safe there rather than merely intended: the return domain is three-valued, so is False can only fail where not passed on a None.
Measurement at the head c3fa4da6
pytest tests/doc-health/test_pin_reachability.py → 77 passed, 8 skipped (partial-clone skips, self-reported). pytest tests/doc-health → 1911 passed, 8 failed — and those 8 were proved this round rather than recalled: the run was repeated with these two files stashed, and the two FAILED lists are byte-identical (diff clean, 8 vs 8). They are this environment's, not this commit's.
(Round-5 tally as of c3fa4da6: five rounds, nine findings. Superseded by the round-6 tally below, stated as of the landing head.)
Round 6 — the same class again, and this time it predated the branch
One finding at c3fa4da6, taken as a fix at 77bc7ef9. verify_pin_reachability called pin_class.verify()with no handler for GitUnavailable, which verify() raises from its opening rev-parseand from every later inventory read. A bound firing on the twentieth git show of a sweep therefore escaped as an uncaught crash and took down whatever surface called in — a pytest run, a preflight pass, a nightly — at the moment a SKIP was owed and available. The function's own contract already had the answer: a three-valued verdict whose third value is PIN_PROBE_SKIP, already returned for report.inconclusive one branch below.
WIDENED, NOT CREATED — measured on origin/main rather than assumed.main raises GitUnavailable in exactly two places: committed_paths (main:1834) and verify()'s opening rev-parse (main:2453). committed_paths runs AFTER the opening probe, so the later-read crash was already reachable on main. What this branch added was a second later raise site, committed_text. The regression test proves it through the OLD site — the pre-fix failure is raised at pin_class.py:1976, inside committed_paths, which is main's line:
E doc_health.pin_class.GitUnavailable: cannot list committed paths at bc92d20f...
could not be performed: Command '[... ls-tree ...]' timed out after 30 seconds
scripts/doc_health/pin_class.py:1976: GitUnavailable
SKIP and not FAIL, deliberately. Every FAIL this function returns names a defect in an artifact and offers the repair route that artifact's class allows; there is no artifact defect here and no route to offer, only a question that could not be put. The report is None because there is no report — the inventory never completed, and a fabricated empty one would render as a clean sweep of zero sites, the silent pass this branch exists to prevent.
The test arms the timeout for ls-tree ALONE and asserts that rev-parse ran and succeeded first, because a test that stopped every probe would exercise the opening raise — the path that was never in doubt. A second test pins that the same surface still returns a real verdict and a real report when nothing is interfered with.
Measurement at the head 77bc7ef9
pytest tests/doc-health → 1913 passed, 8 failed. The 8 FAILED lines are byte-identical to the list this clone produces with the branch's changes stashed (diff clean, 8 vs 8) — compared this round rather than recalled. Zero new failures.
(Round-6 tally as of 77bc7ef9: six rounds, ten findings. Superseded by the round-7 tally below, stated as of the landing head.)
Five of the six rounds found a defect introduced by the round before it, and the sixth found one that predated the branch entirely. The pattern is worth stating once, since it is this branch's whole lesson: changing a reader's failure shape is not finished until its callers are walked — and "the caller" includes the caller's caller. Round 2 walked the two production readers, round 4 the two readiness probes, round 6 the surface above both.
Round 7 — the group id was a lookup of a number the code already had
One previously-missed finding at 77bc7ef9, preflight.py:84, taken as a fix at 91ffa6e6 — in code this branch had already touched once, which is the second time a previously-missed item has caught something a zero-thread count would not have.
_run_entrypoint spawns with start_new_session=True on exactly this path, so the child calls setsid() and IS the session and process-group leader: the group id equals the child pid by construction.os.getpgid(proc.pid) was therefore asking the kernel for a number the function already had — and asking can FAIL where the answer stays valid. If the leader has exited and been reaped while a descendant still holds the group and the inherited stdout/stderr pipe — which is what made communicate() block into the bound in the first place — the lookup raises ProcessLookupError, cleanup falls through to _kill_direct, and proc.kill() on an already-gone leader is a no-op. The descendant then survives while the timeout finding is recorded: precisely the accumulation _terminate_group exists to prevent, arriving by the one route the lookup opened. Signalling the group directly cannot meet that failure, because a process group outlives its leader as long as any member remains.
PID reuse is not a risk, and the ordering is what makes that true rather than luck:_terminate_group runs before the reaping communicate() in every caller, so the direct child is at worst a zombie still holding its pid, and an unreaped pid cannot be recycled. That is stated in the docstring, because a future kill-after-reap would not be safe and the next reader should not have to rediscover why.
_kill_direct's own docstring is corrected in the same commit — it explained the fallback in terms of "os.getpgid() raises ProcessLookupError", a call that no longer exists. A comment describing a line that is gone is a comment that will mislead.
Proved both ways. The test builds the shape rather than approximating it: the wrapper backgrounds a long sleep and exits rather than waiting, so the leader is gone within milliseconds while the descendant keeps the pipes open. os.getpgid is stubbed to raise the ProcessLookupError the premise names, since the reap it depends on is a race that cannot be scheduled. Against the pre-fix lookup:
E AssertionError: the descendant (4045338) outlived the timeout: the leader had
already exited, so a pgid LOOKUP failed and the direct kill hit a process that
was gone — while the work this bound exists to stop kept running under a group
nobody signalled
Two assertions, because the behaviour and the design are different claims: the descendant is dead (the outcome), and the lookup was never consulted (the reason it stays dead in every ordering, not only this one).
Measurement at the landing head 91ffa6e6
pytest tests/doc-health/test_preflight.py → 7 passed. pytest tests/doc-health → 1913 passed, 8 failed, and the 8 FAILED lines are byte-identical to the list this clone produces with the branch's changes stashed (diff clean, 8 vs 8) — compared again this round rather than carried forward. Zero new failures.
Running tally, as of the landing head 91ffa6e6: seven rounds, ELEVEN findings, all FIXED, all threads resolved. The review at 91ffa6e6 reports Findings: None with no Previously-missed block and no Suppressed block, and all 12 checks pass.
Six of the seven rounds found a defect introduced by the round before it, and the seventh found one that predated the branch. Stated once, because it is this branch's whole lesson: changing a reader's failure shape is not finished until its callers are walked — and "the caller" includes the caller's caller. Round 2 walked the two production readers, round 4 the two readiness probes, round 6 the surface above both, and round 7 the one place that asked the kernel for something it already knew.
Summary by Sourcery
Bound doc-health subprocesses and preserve honest inconclusive outcomes when git or validator operations cannot be completed.
New Features:
Add timeout protection and failure handling for the remaining unbounded git and document-validation subprocesses in doc-health checks.
Bug Fixes:
Prevent hung or unavailable subprocesses from blocking doc-health runs or producing misleading reachability, retention, reproduction, and readiness results.
Preserve inconclusive or skipped outcomes when repository data cannot be consulted instead of reporting false passes, orphaned pins, or historical pins.
Ensure timed-out validator process groups and descendants are terminated without masking the original timeout failure.
Enhancements:
Propagate explicit unavailable states and diagnostic details through pin reachability and readiness checks while preserving existing caller contracts where appropriate.
Treat authoritative main-ref and ancestry reads as unanswered when unavailable, and require explicit three-state handling in production and regression checks.
Tests:
Add regression coverage for git and validator timeouts, spawn failures, unavailable repository reads, three-state reachability, readiness mapping, and descendant process cleanup.
…lass._git, preflight.run_preflight, ideation_readiness — a hang becomes the failure each caller already handles (#1128)
The three call sites #1128 measured inside `scripts/doc_health/`, the last
unbounded ones there after #1098/PR #1102 bound `corpus.RealGit`'s pair. Each
binds a timeout and catches `subprocess.TimeoutExpired` beside `OSError`,
mapped to the failure the caller ALREADY produces — never a new exception type,
never a silent success, and never a hang.
- `pin_class._git` (nine call sites route through it; zero exception handling
before this) answers a `CompletedProcess(returncode=1, stdout="",
stderr=<reason>)` — the only "failed" shape this module has, the one every
caller reads. On the hot path that is the designed failure: `verify()`'s
first act is `_git(repo, "rev-parse", rev)`, whose non-zero return raises
`GitUnavailable`. `check=True` is re-raised rather than translated, since
that caller never reads the returncode. 30 s, the sibling bound.
- `ideation_readiness.index_reproduces_at`'s `git archive` answers the same
`(None, "NOT ASKED rather than answered")` its non-zero branch already
answers — never False, which would blame the body for an unaskable question.
30 s, the sibling bound.
- `preflight.run_preflight` answers the same `Finding(ERROR, "preflight", …)`
an ordinary validator failure produces, same family and path so regression
matching is unchanged, with the reason in place of the output tail. Its bound
is 120 s, NOT 30 s, and the constant says why: an entrypoint here is a whole
repository's validator suite (`make validate`, `bash validate-docs.sh`), the
slowest measurable one runs 3.26 s, and 120 s keeps ~37x headroom while the
whole preflight still fits inside the nightly job's own 45-minute bound.
Regression tests: five in `tests/doc-health/test_pin_reachability.py` and a new
`tests/doc-health/test_preflight.py` (nothing tested that file before). They
assert the bound the call carries rather than elapsed time, and compare the
timed-out result against the one a REAL unrunnable git or unspawnable
entrypoint already produces. With the three source files swapped for
origin/main's: 6 failed, 3 passed; restored: 9 passed.
The 61 unbounded `subprocess.run` sites OUTSIDE `scripts/doc_health/` that
#1128 mechanically scanned are out of scope and untouched here.
refs #1128
refs #1098
Lane: openxfactory-2
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…yword next to an issue reference
GitHub's closing-reference parser is the reason, not style: a keyword adjacent
to an issue reference has auto-closed an issue on landing in this estate before
(openxFactory #1053, 2026-09-22), and the finding this branch answers must stay
open for its own review. "bind" says the same thing and cannot be read as a
closing keyword.
refs #1128
Lane: openxfactory-2
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The PR eliminates the last three unbounded subprocess sites in scripts/doc_health by applying measured timeouts and mapping timeouts or launch failures into the same failure outcomes callers already handle, with regression tests pinning timeout values and contract preservation.
Sequence diagram for bounded doc-health subprocess failures
sequenceDiagram
participant Caller
participant DocHealth
participant Subprocess
Caller->>DocHealth: run git or validator operation
DocHealth->>Subprocess: subprocess.run(..., timeout=30s or 120s)
alt Process completes
Subprocess-->>DocHealth: CompletedProcess
DocHealth-->>Caller: Existing success or failure outcome
else OSError or TimeoutExpired
Subprocess-->>DocHealth: exception
alt Git reader
DocHealth-->>Caller: Failed CompletedProcess, returncode=1
else Preflight validator
DocHealth-->>Caller: Finding(ERROR, preflight, ...)
end
end
Loading
File-Level Changes
Change
Details
Files
Bound the remaining subprocess calls in doc-health and preserve each caller’s existing failure semantics.
Add a 30-second timeout to pin reachability git reads and translate spawn/timeouts into failed CompletedProcess results, while preserving check=True exceptions.
Add a 30-second timeout to ideation archive reconstruction and retain the existing NOT ASKED outcome on failure.
Add a 120-second timeout to repository preflight entrypoints and convert spawn/timeouts into the existing preflight ERROR finding shape.
Trigger a new review: Comment @sourcery-ai review on the pull request.
Continue discussions: Reply directly to Sourcery's review comments.
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with @sourcery-ai issue to create an issue from it.
Generate a pull request title: Write @sourcery-ai anywhere in the pull
request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
Generate a pull request summary: Write @sourcery-ai summary anywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment @sourcery-ai summary on the pull request to
(re-)generate the summary at any time.
Generate reviewer's guide: Comment @sourcery-ai guide on the pull
request to (re-)generate the reviewer's guide at any time.
Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!
WORD — Brett Heap, 2026-09-22T15:11:31Z, in session to lane openXfactory-2, verbatim: "merge 1142 when green" (register: RULED lane openXfactory-2 → #1142). Lands by squash under Rule 6 when the eight required checks are green at the head and Copilot is clean.
Copilot at a9660732: 🟡 one finding, RULED REAL, being fixed — subprocess.run(timeout=) terminates only the direct child, and a preflight entrypoint (make validate, bash validate-docs.sh, a Python validator that spawns git) fans out, so a timed-out validator would orphan its descendants. The fix runs the entrypoint in its own process group and kills the group on timeout, with a regression test that a grandchild is gone; OSError regression coverage from the overview is added beside it. The head moves; the landing waits for Copilot's re-review at the new head.
…ut, and add OSError coverage beside the timeout tests (#1128)
Copilot's review of PR #1142 is right, and it is measured here rather than
argued: `subprocess.run(timeout=…)` kills and reaps the DIRECT child only, and
every entrypoint the preflight discovers is a wrapper whose real work is done
by children of its own (`bash validate-docs.sh`, `make validate`, or a python
validator that spawns git — `validate-domain-openxfactory-pins.py` has its own
`_git`). With the parent-only shape this branch carried one commit ago, a
wrapper's backgrounded child was still RUNNING, not even a zombie, after the
bound fired. A nightly that times out repeatedly would accumulate them.
So the one site that spawns wrappers starts the child in its own session
(`start_new_session=True`, POSIX-guarded) and SIGKILLs the whole group on
timeout, guarding `ProcessLookupError`/`PermissionError` and falling back to
killing the direct child where there are no process groups. That means a
managed `Popen` + `communicate(timeout=…)` in place of `run()` — `run()` kills
only its own child and, by the time it re-raises, the `Popen` is out of reach —
and every other semantic `run()` gave is kept: captured text output, the same
`CompletedProcess`, the same `OSError` on an unspawnable command, the same
`TimeoutExpired`. The drain after the kill is itself bounded (5s) so that
something outliving SIGKILL cannot become the block the timeout exists to stop.
The two git sites keep the plain `subprocess.run(timeout=30)` their four
siblings use: they are not wrappers, and a divergence there is a separate act
across five call sites rather than a half-migration made in passing.
Tests: a real entrypoint that backgrounds `sleep 300` and waits on it, asserting
the recorded grandchild pid is gone once `run_preflight` returns — a killed but
unreaped process stays in the table as a zombie and `os.kill(pid, 0)` keeps
succeeding for it (measured: PID 1 here does not reap), so the state is read out
of `/proc` instead. Plus OSError coverage on its own at all three sites, so a
later edit narrowing an `except` back to `TimeoutExpired` alone goes red rather
than passing on the strength of the timeout tests.
Against origin/main's preflight: 4 failed, 2 passed. Against 66fe57a (bounded,
parent-only): the grandchild test fails on the surviving child. Now: 84 passed
across both touched test files.
refs #1128
Lane: openxfactory-2
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…l cannot lose the timeout
Two Copilot findings on this pull request, both correctness, both taken.
r4073457110 - THE BOUND TURNED AN UNASKABLE QUESTION INTO A CONFIDENT ANSWER, in
the two callers where "git said NO" and "git could not be asked" mean different
things. `merge-base --is-ancestor` reports "not an ancestor" by EXITING
NON-ZERO, which is the same shape the timeout translation produces - so a bound
that fired became `False`, and verify() published it as ORPHAN or HISTORICAL: a
pin declared unreached by main on a question nobody got to ask. is_truncated was
worse in kind, falling through to the sentence "--is-shallow-repository is false
for <repo> and it declares no promisor remote", asserting TWO observations that
were never made under a docstring whose first line promises "OBSERVED not
conjectured".
THE MODULE'S OWN DOCTRINE ALREADY DECIDED THIS. remote_retention_refs refuses to
return an empty dict for an unaskable namespace because it "would be
indistinguishable from the namespace is empty"; retention_holder's unconsultable
remote is reported "as INCONCLUSIVE rather than as an orphan"; verify() already
renders `could not be performed` as INCONCLUSIVE for the retention read. The
ancestry and truncation probes owed the same refusal and did not make it.
THE FIX: _git returns an _Unavailable subclass of CompletedProcess - still
non-zero, so the seven callers that only needed "this did not succeed" are
unchanged, exactly as the translation intends. A subclass rather than a sentinel
returncode because an exit code would collide the day a real git chose the same
number, and isinstance cannot be spoofed. reachable_from_main and is_truncated
now answer None for "could not be asked", and verify() renders both INCONCLUSIVE
at three call sites.
THIS REVERSES A SCOPING DECISION THIS BRANCH ITSELF PINNED. The old test asserted
the False answers and argued a third state "would change a caller contract this
fix is not allowed to move". The review measured what that costs and the cost is
not payable - the bound INTRODUCED the path, so the bound owns it. The test is
rewritten to pin the corrected behaviour and carries the reversal with its
reason.
NEW REGRESSION TEST, and it is proved rather than asserted:
test_an_unaskable_ancestry_is_INCONCLUSIVE_and_never_orphan_or_historical lets
the opening rev-parse succeed with real git and makes only `merge-base
--is-ancestor` unaskable - the scenario the review named, and the only way to
reach it, since verify() raises GitUnavailable on the first probe under a blanket
timeout. Run against the pre-fix reachable_from_main it FAILS with
"assert 'orphan' != 'orphan'"; with the fix it passes.
r4073457175 - THE FALLBACK MUST NOT RAISE THE RACE IT IS THE FALLBACK FOR. If the
child exits between communicate() timing out and cleanup, os.getpgid() raises
ProcessLookupError - which is why the fallback exists - and a bare proc.kill()
can then raise the SAME ProcessLookupError from inside the except handling it.
That second exception REPLACES the TimeoutExpired, escapes run_preflight's
handler, and takes the run down at the moment an entrypoint was supposed to
become an ordinary preflight finding. _kill_direct swallows OSError and nothing
else; every other exception still propagates.
ideation_readiness is NOT in this class and was checked: it handles its timeouts
with named errors rather than translating them into a returncode.
Measured: pytest tests/doc-health = 1905 passed, 8 failed, and those 8 are the
SAME 8 that fail on clean main ac50d70 in this clone (ideation_readiness x3,
readiness_dispatch x1, sentinel_vocabulary x3, status_reader_real_lines x1).
Zero new failures.
Lane: openxfactory-4
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
NOTED 2026-09-22T16:22:41Z — two landing words, one branch, one lander. Lane openxfactory-4 pushed 9a6dd963 to this branch under Brett Heap's word to it, verbatim "land #1142 too when green" (2026-09-22T15:55:19Z, #656 comment 5779648105), answering Copilot's round-2 threads with an _Unavailable sentinel and None returns; this lane's own word, verbatim "merge 1142 when green" (comment 5779016355), stands. Both are landing words for the same PR, so the lanes are coordinating by name: ONE writer finishes Copilot's round-3 threads at 9a6dd963 (PRRT_kwDOTAvnrs6k0Am- committed_text/retention_holder treat an unavailable read as absent; PRRT_kwDOTAvnrs6k0AnpPinClassReport.truncated typed bool while is_truncated() may now answer None; and resolve_main() carries the same class of gap, found by this lane's writer), and ONE lane lands under Rule 6 and posts the LANDED record that ends #1128 — lane 2 as the PR's owner unless lane 4's word requires otherwise. This lane's competing raise-based fix for round 2 was never pushed and is discarded; the branch is consistent at 9a6dd963.
… the report type lied
Both findings are follow-ons from the previous commit's own fix, which corrected
two readers and left two more in the same state. They are taken rather than
argued, because the defect is identical and the argument was already made.
r4073820387 - COMMITTED_TEXT READ AN UNASKABLE `git show` AS AN ABSENT PATH.
`git show` reports "no such path in that revision" by exiting NON-ZERO, the same
shape the bound produces, so a fired bound SILENTLY DROPPED pin sites from the
sweep and made index_reproduces_at report a committed index as uncommitted. Both
are false negatives that look exactly like a clean answer. It now raises
GitUnavailable - this module's own instrument, whose docstring is the doctrine:
"The repository could not be asked. Never silently a pass." list_committed
already raises it for the identical condition one call earlier in the same walk,
so the two readers now agree and the eleven callers keep their `str | None`
contract for every answer git actually gives.
r4073820387 (second half) - RETENTION_HOLDER READ AN UNASKABLE LOCAL PROBE AS
"no local ref". `rev-parse --verify --quiet` reports absence by exiting non-zero,
so falling through consulted the remote and - where the namespace legitimately
does not advertise the pin - published ORPHAN on the strength of a local read
that never happened. It now returns the unavailability, and the detail carries
the phrase verify() already matches to render it INCONCLUSIVE.
r4073820457 - THE REPORT TYPE LIED ABOUT ITSELF. PinClassReport.truncated was
annotated `bool` while verify() assigned the `None` that is_truncated can now
answer. Annotated `bool | None`, with the reason beside it.
THREE REGRESSION TESTS, each failing against the pre-fix reader: an unaskable
`show` raises instead of reading as absent (and a genuinely uncommitted path
still answers None, unchanged); an unaskable local retention read carries the
exact phrase verify() matches, asserted as that string rather than merely as
None; and the report's annotation is pinned beside the behaviour so the two
cannot drift.
Measured: pytest tests/doc-health = 1908 passed, 8 failed - the same 8 that fail
on clean main ac50d70 in this clone, and three more passing than before because
of the three tests added here. Zero new failures.
Lane: openxfactory-4
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Treat unavailable truncation probes as unanswerable
scripts/doc_health/pin_class.py:1788
Making is_truncated() return None introduces an unavailable state, but the real-repository test helper still checks only if truncated: before calling verify() and asserting report.clean; clean deliberately excludes inconclusive. A timeout of the truncation probes can therefore let the required reachability test pass with unanswered results (for example when the remaining pins are reachable). Update every caller to treat None as unanswerable, and have the helper skip or assert fully_verified rather than accepting clean alone.
…ot run past it
Copilot's "previously missed" finding at bf90d87, in code this branch had not
touched, and it is real: `is_truncated` answers THREE states since this branch
and `None` - the observation could not be MADE - is FALSEY. So `if truncated:`
fell through, `verify()` ran, and the proof asserted `report.clean`, which
DELIBERATELY EXCLUDES `inconclusive`. An unobservable truncation could therefore
let the required reachability proof pass over unanswered results whenever the
remaining pins happened to be reachable.
Both helpers now test `is not False` / `is None` explicitly. A question that
could not be asked skips for the same reason a genuinely truncated clone does -
neither is a fact about an artifact - and the second helper says which of the two
it hit, because "could not observe" and "observed, and it is truncated" send a
reader to different remedies.
THIS IS THE THIRD PLACE THE SAME MISTAKE APPEARED, and the pattern is worth
naming: introducing a third state into a two-state reader leaves every truth test
on that reader silently wrong, because the new state is falsey and reads as the
old negative. The two production callers were corrected when the state was
introduced; these two test helpers were not, and a 0-unresolved-thread count
would not have caught it - it arrived in the review BODY under "previously
missed", which is exactly why that block gets read.
Measured: pytest tests/doc-health/test_pin_reachability.py = 74 passed,
8 skipped, unchanged.
Lane: openxfactory-4
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…comes
Copilot r4074075244, and it is the last consequence of raising instead of
returning None: `committed_text` now RAISES on an unaskable git, and two
readiness surfaces call it outside any handler - `index_reproduces_at`, before
its own `git archive` try block, and `_committed_status`, reached from
`verify_pin_reachability`. So a timeout there CRASHED a probe whose documented
contract is a verdict, which is a worse failure than the one the raise fixed.
Each is mapped to the shape it already had, not to a new one:
index_reproduces_at returns (None, reason) - the same "could not be asked"
shape its own `git archive` bound already returns - and the reason
distinguishes "could not be read" from "is not committed", which is the whole
distinction the raise exists to preserve.
_committed_status returns None. THE CONFLATION IS ACCEPTABLE HERE AND NOWHERE
ELSE IN THIS CHANGE, and the docstring now says why: its ONE caller reaches it
only for a pin ALREADY judged a defect, to choose which repair route to PRINT.
The verdict is settled before it runs and is not moved by the answer, so the
cost is a default route hint instead of a tailored one - against the cost of
crashing a probe. Where an unavailable read would change a VERDICT -
is_truncated, reachable_from_main, committed_text itself, retention_holder -
it does not answer, it refuses.
Regression test asserts both mappings, including that the reproduction probe's
reason does NOT say "is not committed" for a read that never happened.
Measured: pytest tests/doc-health = 1909 passed, 8 failed - the same 8 that fail
on clean main ac50d70 in this clone. Zero new failures.
Lane: openxfactory-4
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Retain process group ID for reliable timeout termination
scripts/doc_health/preflight.py:84
The process-group lookup is still racy for a wrapper that exits while a descendant keeps the captured pipe open: communicate() can time out after the direct child has exited, so os.getpgid(proc.pid) raises ProcessLookupError; _kill_direct then has no effect because the wrapper is already gone, while the descendant survives after the preflight finding is recorded. Since start_new_session=True makes the child PID the session's process-group ID, retain/use that ID for the timeout kill instead of looking it up after the wait.
… a proof
Both findings are Copilot's at 3c3deef, and both are the SAME defect class this
branch exists to remove: an unaskable question silently converted into an answer.
FINDING 1 - resolve_main fell THROUGH an unavailable probe.
MAIN_REF_ORDER tries refs/remotes/origin/main first because it is the
authoritative spelling; refs/heads/main is its stand-in only in a clone that HAS
no remote-tracking ref, which is the one condition the fallback was written for.
`--verify --quiet` reports "not there" by exiting non-zero - the same shape the
new _Unavailable carries - so a probe that TIMED OUT on the authoritative ref
promoted the local branch to the authority for the whole run, and verify()
published every reachability verdict in the report against it. A local main
sitting behind origin is not a neutral substitute: a pin that IS an ancestor of
origin/main but not yet of the stale branch comes back ORPHAN or HISTORICAL. The
bound this branch added introduced that path, so the bound owns it. The loop now
STOPS at an unavailable ref. No new verdict was needed downstream - verify()
already answers a None main with INCONCLUSIVE at every site.
The signature moves to the module's own (value, detail) shape, already carried by
is_truncated, remote_retention_refs and retention_holder, because THE TWO NONES
ARE DIFFERENT FACTS AND THE REPORT MUST SAY WHICH IT MET. Returning a bare None
would have left verify() printing "no `main` in this clone (looked for ...)" over
a clone whose main may be sitting right there unread - trading one unmade
observation for another, in a module whose every reader refuses exactly that.
Nine call sites moved; measured, there are no others.
FINDING 2 - two real-repository assertions passed on an unmade observation.
test_every_declared_repo_local_pin_in_this_repository_resolves asserted
`not pc.reachable_from_main(...)` twice. reachable_from_main returns True, False
or None and nothing else, so `not X` and `X is False` differ on exactly one
value: None. That is the value this branch just introduced, and `not None` is
true - so an ancestry read that never happened would have satisfied the very
assertion written to prove one did. Both now demand `is False`. The truthy
sibling at the digest-collision fixture is spelled `is True` for the same reason,
where it was already failing correctly by accident.
PROVEN BOTH WAYS, not asserted. The new regression test makes the WRONG answer
available - refs/heads/main is real and readable, and only the origin spelling
times out - which is the only way to prove the right one is chosen; the
module-wide timeout test cannot catch this because it stops every probe, which is
the case the old loop happened to get right. Against the pre-fix fall-through it
fails with the defect in its own message:
AssertionError: the authoritative ref could not be READ, so the branch half of
the ref set is unknown - not ('refs/heads/main', '5e23da84...'), which is the
stale local branch answering a question that was put to origin
A second test pins that the fallback the ORDER exists for still works, so the
narrowing did not swap one defect for another.
tests/doc-health/test_pin_reachability.py: 77 passed, 8 skipped (the skips are a
partial-clone fact about this checkout, reported as such by the tests
themselves). tests/doc-health entire: 1911 passed, 8 failed - and the 8 are
BYTE-IDENTICAL to the 8 this same clone produces with these two files stashed, so
they are this environment's, not this commit's.
Lane: openxfactory-4
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ot crash it
Copilot's finding at c3fa4da, and it is TRUE - with one correction to the
attribution that matters for how far the fix reaches.
WHAT WAS WRONG. verify_pin_reachability calls pin_class.verify() with no handler
for GitUnavailable. verify() raises it from its OPENING rev-parse and from every
LATER inventory read, so a bound that fires on the twentieth `git show` of a
sweep escapes as an uncaught crash and takes down whatever surface called in - a
pytest run, a preflight pass, a nightly - at the moment a SKIP was owed and
available. The function's own contract already has the answer: it documents a
three-valued verdict whose third value is PIN_PROBE_SKIP, and it already returns
that for report.inconclusive one branch below.
WIDENED, NOT CREATED - measured on origin/main rather than assumed. main raises
GitUnavailable in exactly two places: committed_paths (main:1834) and verify's
opening rev-parse (main:2453). committed_paths is called by verify() AFTER the
opening probe, so the later-read crash Copilot describes was already reachable on
main through the inventory listing. What this branch added was a second later
raise site, committed_text. The fix therefore closes a pre-existing hole that
this branch made easier to fall into, and the regression test proves it through
the OLD site - the pre-fix failure is raised at pin_class.py:1976, inside
committed_paths, which is main's line.
SKIP AND NOT FAIL, deliberately. Every FAIL this function returns names a defect
IN AN ARTIFACT and offers the repair route that artifact's class allows. There is
no artifact defect here and no route to offer, only a question that could not be
put - which is the distinction report.inconclusive already draws one branch
below. The two now arrive at the same verdict by different roads, which is what
makes this the existing answer rather than a new one.
THE REPORT IS None BECAUSE THERE IS NO REPORT. The inventory never completed. A
fabricated empty one would render as a clean sweep of zero sites - the silent
pass this whole branch exists to prevent - so the docstring states the one case
in which the third element is None instead.
PROVEN BOTH WAYS. test_a_bound_that_fires_AFTER_the_opening_probes_is_a_skip_not_a_crash
arms the timeout for `ls-tree` ALONE, so rev-parse and is_truncated answer with
real git first and the test asserts that they ran; a test that stopped every
probe would exercise the opening raise, which is the path that was never in
doubt. Against the pre-fix boundary it fails with the crash itself:
E doc_health.pin_class.GitUnavailable: cannot list committed paths at
bc92d20f... could not be performed: Command '[... ls-tree ...]' timed out
after 30 seconds
scripts/doc_health/pin_class.py:1976: GitUnavailable
A second test pins that the same surface still returns a real verdict and a real
report when nothing is interfered with, so the new `except` catches the
unconsultable repository and nothing else.
MEASURED: pytest tests/doc-health -> 1913 passed, 8 failed. The 8 FAILED lines
are BYTE-IDENTICAL to the list this clone produces with this branch's changes
stashed (diff clean, 8 vs 8, compared this round rather than recalled), so they
are this environment's and not this commit's. Two more passing than the round
before, from the two tests added here.
Lane: openxfactory-4
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Ensure descendants are killed when the session leader exits
scripts/doc_health/preflight.py:84
When the session leader has exited but a descendant still holds the captured stdout/stderr pipe, os.getpgid(proc.pid) can fail and _kill_direct then becomes a no-op, so the descendant survives while the timeout finding is recorded. Because start_new_session=True makes the child PID the process-group ID, retain/pass that group ID (or signal proc.pid directly) instead of looking it up during cleanup, and cover the leader-exits-before-cleanup case.
Copilot's "previously missed" finding at 77bc7ef, in code this branch had
already touched once - and it is right.
_run_entrypoint spawns with start_new_session=True on exactly this path, so the
child calls setsid() and IS the session and process-group leader: the group id
EQUALS the child pid by construction. os.getpgid(proc.pid) was therefore asking
the kernel for a number this function already had - and asking can FAIL where the
answer stays valid. If the leader has exited and been reaped while a descendant
still holds the group and the inherited stdout/stderr pipe - which is what made
communicate() block into the bound in the first place - the lookup raises
ProcessLookupError, cleanup falls through to _kill_direct, and proc.kill() on an
already-gone leader is a no-op. THE DESCENDANT THEN SURVIVES while the timeout
finding is recorded: precisely the accumulation _terminate_group exists to
prevent, arriving by the one route the lookup opened. Signalling the group
directly cannot meet that failure, because a process group outlives its leader as
long as any member remains.
PID REUSE IS NOT A RISK, and the ordering is what makes that true rather than
luck: _terminate_group runs BEFORE the reaping communicate() in every caller, so
the direct child is at worst a ZOMBIE still holding its pid, and an unreaped pid
cannot be recycled. proc.pid is still this group's number and no other's. That is
stated in the docstring, because a future kill-after-reap would not be safe and
the next reader should not have to rediscover why.
_kill_direct's own docstring is corrected in the same commit: it explained the
fallback in terms of "os.getpgid() raises ProcessLookupError", a call that no
longer exists. It now names the group signal above. A comment that describes a
line that is gone is a comment that will mislead the next reader.
PROVEN BOTH WAYS. test_the_group_is_killed_by_id_and_not_by_a_lookup_that_can_fail
builds the shape rather than approximating it: the wrapper backgrounds a long
sleep and EXITS rather than waiting, so the leader is gone within milliseconds
while the descendant keeps stdout and stderr open. os.getpgid is stubbed to raise
the ProcessLookupError the premise names, since the reap it depends on is a race
that cannot be scheduled. Against the pre-fix lookup:
E AssertionError: the descendant (4045338) outlived the timeout: the leader
had already exited, so a pgid LOOKUP failed and the direct kill hit a
process that was gone - while the work this bound exists to stop kept
running under a group nobody signalled
TWO ASSERTIONS, because the behaviour and the design are different claims: the
descendant is dead (the outcome), and the lookup was never consulted (the reason
it stays dead in every ordering and not only this one).
MEASURED: pytest tests/doc-health/test_preflight.py -> 7 passed.
Lane: openxfactory-4
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
RULED CLEAN at 91ffa6e6 — landing now on Brett Heap's word "merge 1142 when green" (comment 5779016355; lane openxfactory-4's "land #1142 too when green", #656 comment 5779648105, is the same word from the other side). Eight required checks green at the head; copilot-pull-request-reviewer completed; Copilot's review at 91ffa6e6 reads "🔵 Needs a closer look … Findings: None" with 0 unresolved threads of the five rounds (lane 4 fixed rounds 2–5: _Unavailable/GitUnavailable is never a valid negative, committed_text/retention_holder/is_truncated/reachable_from_main answer unavailability explicitly, the report type says bool | None, ideation_readiness maps it to NOT ASKED, preflight kills the whole process group with a race-safe cleanup). Closing-keyword scan of the live body and every commit: none. Squash by lane 2 as the PR owner; the LANDED record on #1128 follows.
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
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.
Lane: openxfactory-2 (openXfactory-2)
On Brett Heap's words. "do 1 and 2, claim 5" (#745 comment 5767008640) and "merge both when green, then fix 5 and merge when green" (#745 comment 5767058861, recorded on #1128 as comment 5767206176). Both #745 PRs have landed, so finding 5 — #1128 — is next.
What this binds. The three call sites #1128 measured inside
scripts/doc_health/: the last unbounded git subprocesses there after #1098 / PR #1102 boundcorpus.RealGit's pair. Each now binds a timeout and catchessubprocess.TimeoutExpiredbesideOSError, mapped to the failure its caller already produces — never a new exception type for a caller to learn, never a silent success, never a hang. No contract, schema or policy text moves (#1128 declarescode_surface: openxFactory, code-only), so no OpenSpec packet is owed.Per site: before → after
1.
scripts/doc_health/pin_class.py—_git(:1685)subprocess.run(["git", "-C", str(repo), *args], capture_output=True, check=check, text=True, encoding="utf-8", errors="replace")— notimeout=, and notry/exceptat all, not even a bareOSError. Nine call sites route through it, includingverify()'s first act (:2451).gitraisedFileNotFoundErrorout of whatever reachability read was in progress; a hunggitnever returned at all..returncode/.stdout/.stderr; not one checks forNone.verify()raisesGitUnavailable(aRuntimeErrorsubclass whose docstring is "Never silently a pass") when_git(...).returncode != 0.timeout=_GIT_TIMEOUT_SECONDS(30 s, the sibling bound) andexcept (OSError, subprocess.TimeoutExpired)answeringCompletedProcess(args=argv, returncode=1, stdout="", stderr=<reason>)— the only "failed" shape this module has, so all nine callers are untouched. On the hot path that is the designed failure:verify()'srev-parseraisesGitUnavailable, exactly as it does for a git that said no.check=Trueis re-raised rather than translated, because that caller never reads the returncode and handing it a non-zeroCompletedProcesswould be the silent success this bound exists to prevent (no caller passescheck=today — measured acrossscripts/andtests/).2.
scripts/doc_health/preflight.py—run_preflight(:57)subprocess.run(cmd, cwd=repo_path, capture_output=True, text=True, env={...})— notimeout=; the whole 72-line file contained zerotryand zeroexcept.cmdis not fixed togit:_entrypoints()buildspython3 <validator>,bash scripts/validate-docs.shormake validateper discovered repository.Finding(ERROR, "preflight", repo, <path>, ...). Butrun_preflightis the first act ofrun_suite(runner.py:227) whenever no--familyis passed — which is how the nightly invokes it — so a hang blocked every family before one ran, and never reached theFinding-producing branch at all.timeout=_ENTRYPOINT_TIMEOUT_SECONDSandexcept (OSError, subprocess.TimeoutExpired)producing the sameFinding(ERROR, "preflight", ...), same family and same path so regression matching between two reports is unchanged, with the reason (timed out after 120s/could not be run: …) standing in for the output tail there is none of.The 120 s here is a decision, not a slip, and the constant says so in the file. It is deliberately not the 30 s the two git sites bind. Those are single git plumbing calls; a preflight entrypoint is a whole repository's validator suite (
make validate,bash scripts/validate-docs.sh, or a python validator that spawns git subprocesses of its own —validate-domain-openxfactory-pins.pydoes). A bound tight enough to cut an honest slow validator would convert a green nightly into an ERROR finding, i.e. a defect this PR would have introduced. The number is measured: the slowest entrypoint this repository can run isscripts/validate-memory-gateway.pyat 3.26 s (the four openxFactory no-arg validators measured 0.12 / 0.49 / 0.77 / 3.26 s on 2026-09-21), so 120 s carries ~37x headroom over the slowest thing actually observed — while still being small enough that the whole preflight fits inside its own job:.github/workflows/doc-health-reusable.ymlbounds that job attimeout-minutes: 45, and even if all ~13 entrypoints an aggregation run discovers timed out, 13 x 120 s = 26 min, so the timeouts surface as Findings rather than as a killed job with no report at all.3.
scripts/doc_health/ideation_readiness.py—index_reproduces_at(:884)subprocess.run(["git", "-C", str(root), "archive", pin, "ideation"], capture_output=True)— notimeout=, notry/except. The third in-package site, which #1098's own 2026-09-17 sweep did not name.(None, "the corpus at <pin> could not be reconstructed, so reproduction was NOT ASKED rather than answered: …")— the function's documented third outcome.timeout=_GIT_TIMEOUT_SECONDS(30 s) andexcept (OSError, subprocess.TimeoutExpired)returning that same(None, "NOT ASKED rather than answered"). NeverFalse:Falsewould blame the committed body for a question nobody could put, which is the distinctiontest_reproduction_that_cannot_be_asked_is_neither_pass_nor_failexists to keep.Regression tests, failing → passing
Nine new tests: five appended to
tests/doc-health/test_pin_reachability.pyand a newtests/doc-health/test_preflight.py(#1128 measured that nothing tested that file). They assert the bound the call actually carries (kwargs["timeout"] == 30/== 120, and that it is the module's declared constant) and raiseTimeoutExpired, rather than timing a sleeping shim — a shim that sleeps proves only that the shim exited. Each then compares the timed-out result against the one a real unrunnable git or unspawnable entrypoint already produces (an emptiedPATH), which is #1098's second, separate gap.With the three source files swapped for
origin/main's and the new tests present: 6 failed, 3 passed.Restored: 9 passed. The three that pass on
maintoo are contract pins rather than defect pins, and are there so the bind cannot move the surrounding contract: the two preflight baselines (an ordinary validator failure is still the Finding it always was; a clean validator still reports none) and thecheck=Trueguard, whichmainsatisfies by catching nothing at all.Validation
All foreground, private
--basetemp, in a fresh clone.pytest -q -p no:cacheprovider tests/doc-health(whole)origin/mainclone (@0f23341f)validate_index/ pinned-validator / real-lines cases). +9 passed on this branch = the nine new tests.test_pin_reachability.py,test_preflight.py,test_ideation_readiness.py)test_ideation_readiness.pyones, which fail identically on the pristine clone (3 failed, 42 passed for that file alone)python3 scripts/doc-health.py --single-repo . --as-of 2026-09-22(no--family, sorun_preflightruns), before vs afterdiffempty; 113- severity=finding lines unchangedverify_pin_reachability(".", allow_remote=False)before vs afterfamilies.pynames neitherpin_classnorideation_readiness, so these two sites feed no doc-health family — the pin-reachability probe is their surface, and it is compared directly instead.)OPENSPEC_TELEMETRY=0 openspec validate --all --strictadd-chain-attestation) — identical totals on the pristine main clone; that item carries a recorded disposition incontracts/openspec-cli-pin.yamlpython3 scripts/proposal-support.py . verifyproposal support verification okBoth before/after comparisons swap only the three source files inside this one clone (
git show origin/main:<path> > <path>, run, restore), so the corpus and the checkout kind are identical and the only variable is the code.Out of scope
The 61 unbounded
subprocess.runcall sites #1128 mechanically scanned outsidescripts/doc_health/— across 29 files,scripts/proposal-support.pyalone holding 14,scripts/sequenced_after.py6,scripts/attest-openspec-cli-pin-lockfile.py4 — are out of scope for this PR and untouched. That scan is textual only (it cannot resolve kwargs-indirection such asvalidate-openspec-cli-pin.py's_run(argv, **kwargs)), and #1128 names it as a separate finding if it is taken at all.Lands under Rule 6 on the word when the eight required checks are green and Copilot is clean.
refs #1128
refs #1098
Review round by lane
openxfactory-4(openXfactory-4-openDox_extraction)Driven to the gate by a second lane on the holder's assignment, with Brett Heap's landing word of 2026-09-22 — verbatim "land #1142 too when green", recorded at
#656comment5779648105. The original authorship above is laneopenxfactory-2's and is left as written. This PR is NOT ratified and needs no ratification: code-only, noopenspec/changes/path, no README OpenSpec Records edit — it lands on a plain gate, not in a Rule 6 window, and takes no place in the#1140 → #1141order.Two Copilot findings at
d78efc7c, both correctness, both taken as fixes at9a6dd963.r4073457110— the bound turned an unaskable question into a confident answermerge-base --is-ancestorreports "not an ancestor" by exiting non-zero, which is the same shape the timeout translation produces. So a bound that fired became a confidentFalse, andverify()published it as ORPHAN or HISTORICAL — a pin declared unreached bymainon a question nobody got to ask.is_truncatedwas worse in kind: it fell through to "--is-shallow-repositoryis false for<repo>and it declares no promisor remote", asserting two observations that were never made, under a docstring whose first line promises "OBSERVED not conjectured".The module's own doctrine had already decided this, which is what makes the finding decisive rather than arguable:
remote_retention_refsrefuses an empty dict for an unaskable namespace, because it "would be indistinguishable from the namespace is empty, and would silently convert an unaskable question into an answer";retention_holder's unconsultable remote is reported "as INCONCLUSIVE rather than as an orphan";verify()already renderscould not be performedas INCONCLUSIVE for the retention read.The fix.
_gitreturns an_Unavailablesubclass ofCompletedProcess— still non-zero, so the seven callers that only ever needed "this did not succeed" are unchanged, exactly as the translation intends. A subclass rather than a sentinel returncode: an exit code would collide the day a realgitchose the same number, andisinstancecannot be spoofed.reachable_from_mainandis_truncatedanswerNonefor "could not be asked", andverify()renders both INCONCLUSIVE at three call sites.This reverses a scoping decision this branch had PINNED IN A TEST — that a third state "would change a caller contract this fix is not allowed to move". The cost the review measured is not payable: the bound introduced the path, so the bound owns it. The test is rewritten to pin the corrected behaviour and carries the reversal with its reason.
The new regression test is proved, not asserted.
test_an_unaskable_ancestry_is_INCONCLUSIVE_and_never_orphan_or_historicallets the openingrev-parsesucceed with real git and makes onlymerge-base --is-ancestorunaskable — the scenario the review named, and the only way to reach it, sinceverify()raisesGitUnavailableon the first probe under a blanket timeout. Run against the pre-fix reader it FAILS withassert 'orphan' != 'orphan'; with the fix it passes. Both runs were performed.ideation_readinessis not in this class and was checked: it handles its timeouts with named errors rather than translating them into a returncode.r4073457175— the fallback must not raise the race it is the fallback forEvery caller of
_terminate_groupsits inside_run_entrypoint'sexcept subprocess.TimeoutExpiredhandler, whose whole job is to re-raise that timeout sorun_preflightcan turn it into a finding. If the child exits betweencommunicate()timing out and cleanup,os.getpgid()raisesProcessLookupError— which is why the fallback exists — and a bareproc.kill()can then raise the sameProcessLookupErrorfrom inside theexcepthandling it. That second exception replaces theTimeoutExpired, escapes the handler, and takes the run down at the moment a preflight finding was owed._kill_direct(proc)swallowsOSErrorand nothing else; every other exception still propagates and the original timeout is re-raised unchanged. Both call sites use it, including the non-POSIX branch, which carried the same exposure.Measurement
python3 -m pytest tests/doc-health -q→ 1905 passed, 8 failed. Those 8 are the same 8 that fail on cleanmainac50d70din this clone (test_ideation_readiness×3,test_readiness_dispatch×1,test_sentinel_vocabulary×3,test_status_reader_real_lines×1) — proven by running them onmainin the same checkout. Zero new failures.Both threads answered and resolved.
Round 2 — the same defect in two more readers, found by the review of the fix
The first round corrected
reachable_from_mainandis_truncatedand left two more readers in the same state. The review caught both; they are taken rather than argued, because the defect is identical and the argument was already made.r4073820387committed_textgit showreports "no such path in that revision" by exiting NON-ZERO — the same shape the bound produces — so a fired bound silently dropped pin sites from the sweep and madeindex_reproduces_atreport a committed index as uncommitted. False negatives that look exactly like a clean answer. Now raisesGitUnavailable, whose docstring is the doctrine verbatim: "The repository could not be asked. Never silently a pass."list_committedalready raises it for the identical condition one call earlier in the same walk, so the two readers now agree.r4073820387retention_holderrev-parse --verify --quietreports absence by exiting non-zero, so an unavailable LOCAL read fell through, consulted the remote, and — where the namespace legitimately does not advertise the pin — published ORPHAN on the strength of a local read that never happened. Now returns the unavailability, with the detail carrying the exact phraseverify()matches to render it INCONCLUSIVE.r4073820457PinClassReport.truncatedboolwhileverify()assigned theNonethe previous commit made possible — an API that lied about itself, introduced by that same commit. Now `boolThree more regression tests, each failing against the pre-fix reader — and the
committed_textone also asserts that a genuinely uncommitted path still answersNone, so the fix cannot over-reach.Measured:
pytest tests/doc-health→ 1908 passed, 8 failed — the same 8 that fail on cleanmainac50d70din this clone, and three more passing than before because of the tests added here. Zero new failures.Round 3 — the finding a zero-thread count would never have caught
The review at
bf90d87creported "Findings: None" with zero unresolved threads, and carried a "previously missed" item in its body — in code this branch had not touched — that was a real defect this branch had introduced:Fixed at
18dd8158: both helpers now testis not False/is Noneexplicitly, and the second says which of the two conditions it hit, because "could not observe" and "observed, and it is truncated" send a reader to different remedies.The pattern is worth naming, because it appeared three times on one branch: introducing a third state into a two-state reader leaves every truth test on that reader silently wrong, since the new state is falsey and reads as the old negative. The two production callers were corrected when the state was introduced; two test helpers were not.
This is also why the review BODY gets read and not just the thread count — a 0-unresolved count was true and told me nothing.
Round 4 — the new failure mode had a caller nobody had walked to
r4074075244, HIGH, atd78efc7c: rounds 2–3 madecommitted_textraiseGitUnavailablewhere it had returnedNone, and did not walk its callers.ideation_readiness.index_reproduces_atand_committed_statusboth call it, neither caught the new exception, so an unavailable git took the readiness probe down instead of answering the NOT-ASKED outcome each of them already has.Fixed at
3c3deef2.index_reproduces_atreturns(None, "…could not be read at…")— its own unanswered shape, distinct in wording from "is not committed", because an unreadable file and an absent one send a reader to different remedies._committed_statusreturnsNone; its docstring now states why the conflation is acceptable in that one place and nowhere else — its single caller uses it only to choose a repair route to print for a pin already judged a defect.Named, because this branch has now produced it twice: changing a reader's failure shape is not finished until its callers are walked. Round 2 caught it for the two production readers; this caught it for the two readiness probes.
Round 5 — an unreadable ref is not an absent one, and
not Noneis not a proofTwo findings at
3c3deef2, both correctness, both taken as fixes atc3fa4da6. Both are the same class this branch exists to remove: an unaskable question silently converted into an answer.r4074256405resolve_main()still treats an unavailable probe as an ordinary missing refMAIN_REF_ORDERtriesrefs/remotes/origin/mainfirst because it is the authoritative spelling;refs/heads/mainis its stand-in only in a clone that HAS no remote-tracking ref — the one condition the fallback was written for.--verify --quietspells "not there" with the same non-zero exit_Unavailablecarries, so a probe that TIMED OUT on the authoritative ref promoted the local branch to the authority for the whole run, andverify()published every reachability verdict in the report against it. A pin that IS an ancestor oforigin/mainbut not yet of a stale localmaincomes back ORPHAN or HISTORICAL from that. The loop now stops at an unavailable ref;verify()already answers aNonemainwith INCONCLUSIVE at every site, so no new verdict was needed downstream.r4074256452not pc.reachable_from_main(...)passes on the newNoneTrue,FalseorNoneand nothing else, sonot XandX is Falsediffer on exactly one value —None, which is the value this branch introduced.not Noneis true, so an ancestry read that never happened would have satisfied the very assertion written to prove one did. Both now demandis False; the truthy sibling at the digest-collision fixture is spelledis Truefor the same reason, where it had been failing correctly only by accident.The signature moves to
(value, detail)— this module's own shape, already carried byis_truncated,remote_retention_refsandretention_holder— because the twoNones are different facts and the report has to say which one it met. A bareNonewould have leftverify()printingno \main` in this clone (looked for ...)over a clone whosemain` may be sitting right there unread: one unmade observation traded for another. Nine call sites moved; measured, there are no others.Proved both ways.
test_an_unreadable_origin_main_does_not_promote_the_local_branchmakes the WRONG answer available —refs/heads/mainis real and readable, only the origin spelling times out — which is the only way to prove the right one is chosen. The module-wide timeout test cannot catch this, because it stops every probe: the case the old loop happened to get right. Against the pre-fix fall-through it fails with the defect in its own message:A second test pins that the fallback the ORDER exists for still works, so the narrowing did not swap one defect for another.
Where round 5's second fix runs. Those two assertions sit in
test_every_declared_repo_local_pin_in_this_repository_resolves, which skips in the authoring checkout — a partial clone (remote.origin.promisor true), reported as such by the test's own skip reason — so CI is what exercises them. That is also why the change is safe there rather than merely intended: the return domain is three-valued, sois Falsecan only fail wherenotpassed on aNone.Measurement at the head
c3fa4da6pytest tests/doc-health/test_pin_reachability.py→ 77 passed, 8 skipped (partial-clone skips, self-reported).pytest tests/doc-health→ 1911 passed, 8 failed — and those 8 were proved this round rather than recalled: the run was repeated with these two files stashed, and the twoFAILEDlists are byte-identical (diffclean, 8 vs 8). They are this environment's, not this commit's.(Round-5 tally as of
c3fa4da6: five rounds, nine findings. Superseded by the round-6 tally below, stated as of the landing head.)Round 6 — the same class again, and this time it predated the branch
One finding at
c3fa4da6, taken as a fix at77bc7ef9.verify_pin_reachabilitycalledpin_class.verify()with no handler forGitUnavailable, whichverify()raises from its openingrev-parseand from every later inventory read. A bound firing on the twentiethgit showof a sweep therefore escaped as an uncaught crash and took down whatever surface called in — a pytest run, a preflight pass, a nightly — at the moment a SKIP was owed and available. The function's own contract already had the answer: a three-valued verdict whose third value isPIN_PROBE_SKIP, already returned forreport.inconclusiveone branch below.WIDENED, NOT CREATED — measured on
origin/mainrather than assumed.mainraisesGitUnavailablein exactly two places:committed_paths(main:1834) andverify()'s openingrev-parse(main:2453).committed_pathsruns AFTER the opening probe, so the later-read crash was already reachable onmain. What this branch added was a second later raise site,committed_text. The regression test proves it through the OLD site — the pre-fix failure is raised atpin_class.py:1976, insidecommitted_paths, which ismain's line:SKIP and not FAIL, deliberately. Every FAIL this function returns names a defect in an artifact and offers the repair route that artifact's class allows; there is no artifact defect here and no route to offer, only a question that could not be put. The report is
Nonebecause there is no report — the inventory never completed, and a fabricated empty one would render as a clean sweep of zero sites, the silent pass this branch exists to prevent.The test arms the timeout for
ls-treeALONE and asserts thatrev-parseran and succeeded first, because a test that stopped every probe would exercise the opening raise — the path that was never in doubt. A second test pins that the same surface still returns a real verdict and a real report when nothing is interfered with.Measurement at the head
77bc7ef9pytest tests/doc-health→ 1913 passed, 8 failed. The 8FAILEDlines are byte-identical to the list this clone produces with the branch's changes stashed (diffclean, 8 vs 8) — compared this round rather than recalled. Zero new failures.(Round-6 tally as of
77bc7ef9: six rounds, ten findings. Superseded by the round-7 tally below, stated as of the landing head.)Five of the six rounds found a defect introduced by the round before it, and the sixth found one that predated the branch entirely. The pattern is worth stating once, since it is this branch's whole lesson: changing a reader's failure shape is not finished until its callers are walked — and "the caller" includes the caller's caller. Round 2 walked the two production readers, round 4 the two readiness probes, round 6 the surface above both.
Round 7 — the group id was a lookup of a number the code already had
One previously-missed finding at
77bc7ef9,preflight.py:84, taken as a fix at91ffa6e6— in code this branch had already touched once, which is the second time a previously-missed item has caught something a zero-thread count would not have._run_entrypointspawns withstart_new_session=Trueon exactly this path, so the child callssetsid()and IS the session and process-group leader: the group id equals the child pid by construction.os.getpgid(proc.pid)was therefore asking the kernel for a number the function already had — and asking can FAIL where the answer stays valid. If the leader has exited and been reaped while a descendant still holds the group and the inherited stdout/stderr pipe — which is what madecommunicate()block into the bound in the first place — the lookup raisesProcessLookupError, cleanup falls through to_kill_direct, andproc.kill()on an already-gone leader is a no-op. The descendant then survives while the timeout finding is recorded: precisely the accumulation_terminate_groupexists to prevent, arriving by the one route the lookup opened. Signalling the group directly cannot meet that failure, because a process group outlives its leader as long as any member remains.PID reuse is not a risk, and the ordering is what makes that true rather than luck:
_terminate_groupruns before the reapingcommunicate()in every caller, so the direct child is at worst a zombie still holding its pid, and an unreaped pid cannot be recycled. That is stated in the docstring, because a future kill-after-reap would not be safe and the next reader should not have to rediscover why._kill_direct's own docstring is corrected in the same commit — it explained the fallback in terms of "os.getpgid()raisesProcessLookupError", a call that no longer exists. A comment describing a line that is gone is a comment that will mislead.Proved both ways. The test builds the shape rather than approximating it: the wrapper backgrounds a long sleep and exits rather than waiting, so the leader is gone within milliseconds while the descendant keeps the pipes open.
os.getpgidis stubbed to raise theProcessLookupErrorthe premise names, since the reap it depends on is a race that cannot be scheduled. Against the pre-fix lookup:Two assertions, because the behaviour and the design are different claims: the descendant is dead (the outcome), and the lookup was never consulted (the reason it stays dead in every ordering, not only this one).
Measurement at the landing head
91ffa6e6pytest tests/doc-health/test_preflight.py→ 7 passed.pytest tests/doc-health→ 1913 passed, 8 failed, and the 8FAILEDlines are byte-identical to the list this clone produces with the branch's changes stashed (diffclean, 8 vs 8) — compared again this round rather than carried forward. Zero new failures.Running tally, as of the landing head
91ffa6e6: seven rounds, ELEVEN findings, all FIXED, all threads resolved. The review at91ffa6e6reports Findings: None with no Previously-missed block and no Suppressed block, and all 12 checks pass.Six of the seven rounds found a defect introduced by the round before it, and the seventh found one that predated the branch. Stated once, because it is this branch's whole lesson: changing a reader's failure shape is not finished until its callers are walked — and "the caller" includes the caller's caller. Round 2 walked the two production readers, round 4 the two readiness probes, round 6 the surface above both, and round 7 the one place that asked the kernel for something it already knew.
Summary by Sourcery
Bound doc-health subprocesses and preserve honest inconclusive outcomes when git or validator operations cannot be completed.
New Features:
Bug Fixes:
Enhancements:
Tests:
🤖 Generated with Claude Code