← Back to Pull requests

fix(runtime): recover the published startup diagnostic after the ready budget #7743

Closed
unknown closed this pull request without merging on Nov 01, 2026 02:36 UTC
View on GitHub
unknown unknown commented on Oct 30, 2026 13:10 UTC
Author

Goal and source

The windows-powershell lane fails intermittently on operations that start the
Effect runtime and wait for it to become ready. One retrievable run of that
lane (1e3401591) failed with

assert 'runtime_startup_timeout' == 'mutation_lock_timeout'

That assertion is the whole subject of this PR: the runtime computed the exact
typed code, and the host reported a generic timeout instead.

The
S2/S12 startup diagnostic checkpoint
of 2026-10-04 established that a live mutation lock must fail with the exact
mutation_lock_timeout code, and explicitly did not qualify Windows.

The gap

The TypeScript runtime publishes its typed startup envelope to stderr when it
gives up. Python reads that envelope only when process.poll() shows the child
has already exited; otherwise it terminates the child at the ready budget and
reports the generic runtime_startup_timeout.

The envelope is published at the moment the child exits, so there is nothing
typed to read while the child is still running: at one second, three seconds
and five seconds the child is still running and stderr holds zero bytes, and
the envelope appears only once it exits, at about 5.8 s, together with exit
code 2.

runtime_startup_timeout is produced whenever the parent does not observe the
child's exit inside the ready loop. The baseline reads the published envelope
only when a poll within that loop reports an exit; after the loop it polls
once more, but only to decide whether to terminate the child, and it then
always reports the generic timeout. The historical run therefore does not
distinguish two situations: the child had not published yet when the budget
expired, or the child had already published and exited and the parent had not
observed that exit before it left the loop. The same job's pytest step ran 439
cases in 5 min 31 s, and the chunk holding the failure took two minutes
against six seconds for the chunk before it, so the runner was heavily loaded —
a plausible contributor to a late publication, not a demonstrated cause.

The repair below covers both situations, so it does not depend on knowing which
one the recorded failure was.

The startup cost itself has ample headroom — measured on the Windows runner at
2f544f9692 and on macOS at d3d9ad209d:

| Host | Ready startup | Live-lock total | Diagnostic delivered |
| --- | --- | --- | --- |
| Windows (nt) | 0.406 s | 5.813 s | mutation_lock_timeout |
| macOS (posix) | 0.170 s | 5.140 s | mutation_lock_timeout |

STARTUP_READY_TIMEOUT_SECONDS is 15.0 and the TypeScript
MUTATION_LOCK_TIMEOUT_MS is 5,000. Neither budget is the constraint, and
neither is widened here. The lock in this path is held by a live owner, so the
owner-liveness check behaves correctly for it and is not touched.

The repair

loopx/control_plane/effect_runtime.py now gives a runtime that is still
running when the ready budget expires a bounded window in which it may publish
either its locator or its typed diagnostic. The host reads the published
envelope during that window and reports the exact code it carries.

The window is bounded by a budget the repository already owns rather than by a
new number: STARTUP_DIAGNOSTIC_GRACE_SECONDS is one more ready budget, so a
single startup attempt waits at most twice STARTUP_READY_TIMEOUT_SECONDS.
When the window closes with nothing published, the runtime is terminated and
the generic runtime_startup_timeout is reported, so the wait stays bounded.

A runtime that publishes its locator inside the window is now accepted instead
of terminated. Before the repair, a runtime that was merely slow was killed at
the ready budget; that outcome is unchanged in kind, only later in time.

Two consequences a reviewer should read as intended rather than as regressions:

  • The user-visible guidance changes with the code. A caller that receives the

  • exact mutation_lock_timeout is now told to repair or reinstall LoopX,
    where it was previously told that startup timed out, because
    loopx/cli_commands/start_goal.py gives runtime_startup_timeout its own
    remediation text and mutation_lock_timeout falls through to the shared
    default.
  • A failed startup now blocks its caller for up to twice the ready budget

  • instead of once, and effect_runtime_request retries a startup failure once
    for a retry-safe call. The retry policy is unchanged here. That is the wait
    this startup path adds, not an absolute ceiling for the whole call: the
    startup lock, the Node probe and the outer retry each carry their own cost.

    Acceptance evidence

    The repair is pinned by a test that reproduces the observed failure without a
    Windows runner. With the ready budget shortened and a live mutation lock held
    by the current process, the pre-repair host reports the generic timeout, and
    the assertion is the one the Windows lane produced:

    assert 'runtime_startup_timeout' == 'mutation_lock_timeout'
    

    After the repair the same fixture delivers the exact mutation_lock_timeout,
    the published envelope, and the preserved live lock.

    A second test pins the other situation the historical record cannot separate:
    an envelope the runtime published before the deadline, whose exit the parent's
    poll missed, is still read — the parent polls once more after the loop, but
    the baseline never reads the capture again. Both tests report the generic
    timeout on the baseline.

    A third test pins the bound: a runtime that publishes nothing is terminated and
    still reports runtime_startup_timeout after exactly one ready budget plus one
    grace window.

    Validation

    uv run --extra test python -m pytest \
      tests/control_plane/test_effect_runtime_integration.py -q                    102 passed, 1 skipped
    uv run --extra test python -m pytest \
      tests/control_plane/test_effect_runtime_host_permission.py \
      tests/control_plane/test_effect_runtime_node_probe.py \
      tests/control_plane/test_start_goal_compact_projection.py \
      tests/test_chat_server_cors.py -q                                            201 passed
    python examples/control_plane/control-plane-maintainability-ratchet-smoke.py    ok
    python examples/semantic-vocabulary-drift-smoke.py                             ok
    python examples/docs-governance-smoke.py                                       docs-governance-smoke ok
    python scripts/generate_rfc_status_index.py --check                            clean
    scripts/check_rfc_bilingual.py --base origin/main --head HEAD                  passed
    mkdocs build --strict                                                          built, 0 warnings
    uv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main
                                                                                   17 selected, 0 failures, 0 warnings
    

    The maintainability ratchet caught the first form of this change: the grace
    window had pushed _start_runtime past the repository's decision-function
    limit. The window now lives in _await_startup_publication, and the ratchet
    reports no oversized decision function.

    Changed surfaces and boundary notes

  • loopx/control_plane/effect_runtime.py — runtime startup path. No public

  • protocol, schema or state vocabulary changes; the diagnostic codes involved
    (runtime_startup_timeout, mutation_lock_timeout) already existed.
  • tests/control_plane/test_effect_runtime_integration.py — the file the

  • Windows lane runs explicitly, so both new tests run on that lane.
  • docs/architecture/rfcs/ledger/loopx-overall-roadmap-v0/2026-10-30-s2-s12-startup-diagnostic-grace.md

  • and its Chinese mirror, plus the derived status index.

    No first screen changed: this is a runtime startup path, and there is no user
    interface, screenshot or preview to show for it.

    The measurement that motivated the repair is re-derivable rather than taken on
    trust: the commit that produced the two figures is reachable as
    codex/measurement-archive on the fork, and it raises a deliberate
    AssertionError carrying the measurement, because the Windows lane runs pytest
    without -s and would otherwise capture the output.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: JasonBuildAI Review duration: 2245m
    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 #7743"
    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%