← Back to Pull requests

feat(release): add a read-only host doctor that run, resume and prepare consult first #2454

Closed
unknown closed this pull request without merging on Oct 21, 2026 08:36 UTC
View on GitHub
unknown unknown commented on Oct 21, 2026 06:22 UTC
Author

Summary

Item 5 of the "now" plan in #2422 (with the automatable half of item 7). Every non-product failure of 2.0.122.0's prepare and resume rounds was a host condition the tool could have named before starting: the pinned emsdk deleted by a cleanup, a signing key sought in the wrong keyring, a stale gh login, a second driver on the journal, a workstation at load 35 with fseventsd pegged, the M1 runner executing a candidate batch on the same cores.

Change

  • New tools/release/doctor.py: run_doctor is a read-only preflight (no build, no write, no lock held beyond a non-blocking probe) that reports each check as ok, fail with why and remedy, or skip where it does not apply to the platform:

  • - emsdk: $EMSDK or build/toolchains/emsdk exists, its Git HEAD, release mapping and installed emscripten-version.txt match tools/web-runtime/emscripten.lock.json; the remedy is the exact install sequence and a reminder that build/toolchains is release-owned.
    - signing keys: the product role in the ambient keyring (GNUPGHOME or ~/.gnupg), the checksum role in the dedicated keyring, each by policy fingerprint; the remedy names the keyring and the release-signing-role-keyrings pitfall and says not to move the other role's key.
    - gh auth: GITHUB_TOKEN or gh auth token.
    - journal lock: writer.lock takeable (never deleted); an unopenable lock (permissions, a symlink) is a distinct failure with the ownership remedy.
    - release processes: another interpreter (any options, cli.py or -m tools.release.cli) running a driving command (run, resume, retire, prepare, push-tag, create-draft, publish-draft, promote, editorial, rehearsal); read-only commands beside a driver, this process's own wrapper shells, and a shell whose command string merely mentions the path do not count.
    - disk space (20 GiB for two clean Web Host builds and the Core package) and host load (1-minute load above the cpu count fails; the remedy names what to stop and the runner pause).
    - fseventsd and Spotlight cpu pressure (macOS), with the restart / Spotlight Privacy remedies.
    - M1 runner: every loaded actions.runner. service is inspected; a Runner.Worker running from a service's directory (launch-agent WorkingDirectory, else its program's directory) fails against that service (a worker under a service whose agent definition is unreadable is reported as unattributable, with every service's pause command); a loaded runner fails for prepare and for a resume whose next step is prepared (the batch a run or an earlier resume waits on executes on this runner, so those keep it up and print each service's exact launchctl bootout / bootstrap pause and resume commands); no service passes.
  • scripts/release.sh doctor prints the report and exits 0/2; an unreadable policy or Git directory is itself reported as a failed check with a remedy. run, resume and prepare call it first and refuse with the report while any check fails (a resume of a request the journal does not hold is reported by the journal, read-only, before the doctor); after the canonical fetch they check both key roles again against the fetched policy's fingerprints (confirm_canonical_signing_keys), since the checkout's policy may be stale. status, audit and the other read-only commands never wait on it.

  • The lmdj-release skill names the doctor and what it covers.
  • Probes are injected (HostProbes), so every check is exercised without the host; the production probes are plain os/subprocess reads.

    Related Issue

    Related issue: #2422

    Premise refresh (issue-done §0)

    Base: origin/main at 10d656507ccc15ebe582379913234ca9edb4dcdc. No doctor existed in tools/release/ or scripts/release.sh; run/resume/prepare started with no host check. Still outstanding; delivered here.

    Verification

    New tests, each fixing one fact:

  • release_doctor_test (18): the pinned emsdk passes and each drift (HEAD, release mapping, installed version), a missing SDK and an unreadable lock fail with the install remedy; each key role is looked up in its own keyring and a missing role names its keyring and the pitfall; gh auth accepts a token or a login; a held writer lock is named and never deleted; only an interpreter running the CLI counts as a release process; disk and load thresholds; fseventsd/Spotlight limits and skip off macOS; runner idle/busy/absent with the pause and resume commands; run_doctor order and fail-closed aggregate; a failed Check must carry a remedy; HostProbes.lock_free against a real held flock; ps row parsing.

  • release_cli_orchestration_test (7 new): prepare and a resume at the prepared step require the runner paused, earlier resumes and run do not; an unknown resume is reported while another writer holds the lock; an unknown resume is reported before the doctor; the doctor reports its own unreadable inputs as checks; the key roles are rechecked against the canonical policy after the fetch and a missing canonical key refuses before the orchestration policy is built; run, resume and prepare refuse with the report and remedy before any context is built, and status never consults the doctor; the doctor subcommand prints every check and exits 0/2; release_doctor binds the policy fingerprints and the journal root.
  • Mutation proofs (file restored with a fresh mtime, __pycache__ cleared, exit read):

  • CLI gate removed: test_run_resume_and_prepare_refuse_while_the_doctor_fails fails (3 cases).

  • runner check without the live-worker detection: test_runner_states_pause_and_resume_commands fails.

  • 15dc831: canonical key gate removed → test_the_signing_keys_are_rechecked_against_the_canonical_policy fails; lock probe back to O_RDWR → test_lock_free… fails; any worker counts → test_runner_states… fails.

  • 7e7ebe1: any cli.py process counts → the read-only cases of test_only_an_interpreter… fail; first label only → test_every_loaded_runner_service_is_inspected fails.

  • ac0e859: own pid only → the wrapper-shell tail of test_only_an_interpreter… fails; no program-directory fallback → test_runner_states… fails; load_policy left to raise → test_release_doctor_reports_its_own_unreadable_inputs_as_checks fails.

  • ef489df: unreadable lock treated as held → test_a_held_writer_lock… fails; module form dropped → test_only_an_interpreter… fails; unknown-resume gate removed → test_an_unknown_resume_is_reported_before_the_host_doctor fails; unattributable worker blamed on the service → test_runner_states… fails.

  • 663a3c6: writable precheck → test_an_unknown_resume… fails; paused-runner flag ignored → test_runner_states…, the aggregate test and test_prepare_and_a_resume_at_the_prepared_step… fail; split()[0] → the fseventsd/Spotlight test errors.

  • restored: 18 / 42 / 45 pass.
  • Commands run on the committed head:

    python3 tests/build/release_doctor_test.py            # 18 OK
    python3 tests/build/release_cli_orchestration_test.py # 42 OK
    python3 tests/build/release_skill_test.py             # OK
    python3 tests/build/ci_change_scope_test.py           # OK (two added files owned)
    git diff --cached --check                             # clean
    

    Real runs on this M1 (worktree, EMSDK exported). Quiet host: all 11 checks ok, exit 0; without EMSDK the emsdk check fails with the install remedy, exit 2. Later, while this PR's own CI job ran on the M1 and the release suite ran locally, the same command reported exactly the conditions item 7 lists: host load: load 29.1 exceeds 8 cpus, spotlight: Spotlight is indexing at 68% cpu, m1 runner: … is executing a CI job on this host (worker under ~/actions-runner/lmdj/bin.2.337.0/), each with its remedy, exit 2. Quiet-host output:

    [ok] emsdk: …/build/toolchains/emsdk: emsdk 6.0.5 at dfb9d1a46c3b
    [ok] signing key (product): 6F954D29 in …/.gnupg
    [ok] signing key (checksum): 9FC1478B in …/.gnupg-lmdj-release
    [ok] gh auth: gh is logged in (token available)
    [ok] journal lock: writer.lock is free
    [ok] release processes: no other release.sh process
    [ok] disk space: 23.4 GiB free
    [ok] host load: load 1.4 on 8 cpus
    [ok] fseventsd: 5% cpu
    [ok] spotlight: 5% cpu; volume indexing enabled
    [ok] m1 runner: actions.runner.endaye-lmdj.endaye-mbp-m1 loaded, idle; pause it before prepare: launchctl bootout gui/$(id -u)/…; resume afterwards: launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/….plist
    release doctor: all checks passed
    

    Complete tests/build/release__test.py run (all 80 modules including the new release_doctor_test, one at a time, started on c2444e5): 79 PASS, 1 FAIL. The modules the later commits touch (release_doctor_test, release_cli_orchestration_test, release_prepare_test) were rerun on the final head 663a3c6: 18 / 42 / 45 OK. The one failure, release_prepare_test.test_cli_reports_the_sanitized_subprocess_reason, drove prepare through cli.main on a bare fixture root and stopped at the doctor's missing policy before reaching the subprocess diagnostic it pins; e17e641 stubs the doctor there (test-only), and the module passes again (45 OK). The other 79 modules are unaffected by that commit.

    PR Review

    Head SHA: 663a3c6f70a8ac6d93b48ba423ec582875d90339. The review of ef489df raised four findings (unknown-resume precheck took the writer lock; idle loaded runner passed despite the pause remedy; blank ps command fields ×2), all fixed in 663a3c6. The review of d12ae01 raised four findings (CLI invocation forms, unopenable lock reported as held, unknown resume hidden behind the doctor, unattributable worker blamed on a service), all fixed in ef489df. Earlier: Reviews: c2444e5 → three findings (checkout policy, lock probe write access, worker attribution), fixed in 15dc831; 15dc831 → zero; e17e641 (test-only) → two (read-only commands counted as a driver; only the first runner label inspected), fixed in 7e7ebe1; 7e7ebe1 → four (wrapper shell counted as a driver; runner without WorkingDirectory; doctor's own unreadable inputs; EMSDK containment — answered: it is the same path the build verifies), three fixed in ac0e859. d12ae01 is test-only (stubs the doctor in the prepare usage case). All threads resolved. Earlier: the review of c2444e5 raised three findings (doctor read the checkout's policy; lock probe needed write access; any Runner.Worker attributed to the M1 runner); all fixed in 15dc831 and resolved in their threads. Current-head review evidence is checked with scripts/ci/review_wait.py before merge; findings and dispositions are recorded in the thread.

    CI Scope

    Expected mode: focused
    Expected selected lanes: ci_contract deploy_contract docs_static
    Expected skipped lanes: core_asan core_coverage core_macos core_ubuntu creator package portal web_runtime_host web_runtime_lab web_toolchain
    ci:full required: no
    Reason: release tooling, its Python tests and the release skill only.

    Version Management

    Version impact: none
    Reason: release tooling only; no Module, Host, Contract or Product identity changes.

    Documentation Impact

    Documentation impact: none
    Affected portal pages:
    Reason: release-tool behaviour and the .agents skill; no page under apps/docs-site/docs/ changes.

    Pitfall Impact

    Pitfall impact: none — reason: the host conditions are now a gate with named remedies (gate:tests/build/release_doctor_test.py); the operator checklist itself (item 7) lands in the next PR with the skill text.

    Merge Danger

    Door: two-way
    Blast Radius: run, resume and prepare now stop on a failed host check with the report; the doctor performs no write and no build.

    Release Impact

    Release impact: none
    Candidate tag: none
    Profile: none
    Channel: none
    Intent disposition: none
    Release assets: none
    Release gates: none
    Reason: no release is active; tags, Releases and the ledger are untouched.

    Transition authority

    Authorized transitions: push | PR | merge (standing Task authorization in CLAUDE.md; cleanup not requested)
    No tag, Release, deploy, publication, or Channel promotion is implied.

    🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: endaye Review duration: 133m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2454"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository