fix(runtime): recover a live daemon from a damaged locator #6892
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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 #6892"
general
weight: 0.35
JasonBuildAI
Goal And Delivered Outcome
loopx doctorreports the runtime as stopped._read_infocollapsed JSON/schema/fingerprint/field failures intoNone; callers treated that as "no runtime", and doctor had no way to show the live recorded PID.schema_versioncorrupted, before: doctorstopped, diagnosticnull, a new daemon started while the old PID stayed alive and serving. After: doctorrunning,locator_state=invalid,recorded_pid_alive=true, diagnosticruntime_locator_schema_mismatch, and the next RPC reuses the original PID. The real-daemon test intests/control_plane/test_effect_runtime_locator_recovery.pyproves this end to end.loopx-project/loopx:mainat764b989dc.Author Declaration
AI disclosure: this change was drafted with AI assistance at my request, under my direction and review.
The problem and constraints were set by the human requester; this PR is submitted for human review.
Implemented against
mainat764b989dc).| Criterion (spec clause) | Disposition | Symbol / path | Test or command |
| --- | --- | --- | --- |
| Distinguish "no locator" from "locator present but unreadable" | implemented |
_inspect_info,_RuntimeLocatorReadinloopx/control_plane/effect_runtime.py|tests/control_plane/test_effect_runtime_locator_recovery.py|| Keep a diagnostic code | implemented |
_RuntimeLocatorDiagnostic; lifecyclediagnostic_code| same test;collect_effect_runtime_readiness|| Doctor reports PID liveness alongside locator state | implemented |
collect_effect_runtime_readiness,render_doctor_markdown| doctor markdown assertions in the same test || Before cold-starting, reuse a live daemon that still answers on the recorded port/token | implemented |
_recover_runtime_info,_runtime_info_for_request| real-daemon schema-corruption test || Do not trust damaged bytes without proof | implemented | authenticated
runtime.pingmust match PID, fingerprint and locator path | same test || Malformed bytes do not crash doctor | implemented |
UnicodeError/JSON/type guards in_inspect_info| malformed JSON and invalid UTF-8 tests |main, and confirmed the old behavior before changing code. Deliberately left out unrelated refactors and new dependencies. A locator whose token/endpoint are destroyed cannot be authenticated safely; that path cold-starts and retains theruntime_locator_unreadablediagnostic.Scope And Continuation
4b340d9e6): a deep probe now refreshes the locator projection after it may have started the runtime, preserves a damaged-locator diagnostic on success, and reports host-permission or generic locator read failures asinvalidrather thanmissing. Focused tests cover both outcomes.607a787ce): recovery now propagates a host-permission denial instead of treating it as no runtime and cold-starting, and readiness inspects locator state/PID liveness even when the Node probe is unavailable. Regressions cover both boundaries.9dadb773d): out-of-range recorded PIDs are rejected before the OS liveness probe and platform overflow is contained, so damaged locator bytes cannot crash readiness or the installation-only doctor. API and real console-command regressions cover the boundary.1940477fb): added explicit recovery tests for a ping from a different PID, a rejected token, a different fingerprint, and a different published locator path. Each case asserts that the damaged locator is not reused.Validation
1940477fb7913811db0315547d02ceb82647af8a(all listed checks ran on the final tree).| Check kind | Result | Public-safe evidence / limitation |
| --- | --- | --- |
|
static|passed|uv run --extra test ruff check ...→All checks passed!;git diff --check 764b989dce...HEADclean. ||
unit|passed|uv run --extra test pytest -q tests/control_plane/test_effect_runtime_locator_recovery.py tests/control_plane/test_effect_runtime_host_permission.py tests/control_plane/test_turn_journal_runtime_readiness.py→51 passed in 56.58s. ||
integration|passed| Effect runtime/readiness suite over 10 files →220 passed, 7 skipped, 3 warnings in 152.15s; skips are the platform-gated cases already present in the suite. ||
real_entrypoint|passed| Real Node daemon througheffect_runtime.effect_runtime_result; corrupting onlyschema_versionreportsrunning/invalid/PID alive and reuses the same PID;loopx doctormarkdown readback includes the diagnostic. ||
real_backend|passed| Node.js managed runtime over loopback in an isolated temporary runtime directory; no external service or private state. ||
regression_parity|passed| New recovery tests failed2before the fix and pass after; malformed JSON and invalid UTF-8 retainruntime_locator_unreadableinstead of looking absent. Follow-up tests prove deep success refreshes absent → valid and preserves damaged → invalid, while host-permission and generic read errors remain visible. ||
regression_parity|passed| The second review regressions failed2before the follow-up (must not cold start;locator_statewasmissing) and pass after; the tests prove host-permission recovery does not launch a replacement and Node-unavailable readiness still reports a valid live locator. ||
regression_parity|passed| The oversized-PID API and console-command regressions failed2before9dadb773d(liveness was incorrectly reported asFalse) and pass after; both retainlocator_state=invalidwith unknown liveness and structured doctor JSON. ||
regression_parity|passed| The four reporter-requested identity rejections pass: different PID, rejected token, different fingerprint, and different published locator path all return no recoverable runtime, so a damaged locator cannot route a request to another daemon. ||
static|passed| Semantic inventory advisory reports only the local_RuntimeLocatorState/_RuntimeLocatorDiagnosticaliases for the branch; decision: remain local toeffect_runtime.py, extending the existingloopx_effect_runtime_lifecycle_v0readback; no registered vocabulary or shared contract change. ||
static|failed|uv run --extra test python -m mypy --follow-imports=silent loopx/control_plane/effect_runtime.py loopx/doctor.pyexits 1 with the same 48 errors and 4 unique diagnostic shapes as base764b989dc; this branch adds no new normalized mypy diagnostic. ||
integration|failed| Exact-head premergestandardagainst the original PR base764b989dc: all direct checks, module ceiling, 8/8 risk-profile smokes and public boundary passed. Four catalog canaries failed and each was reproduced independently on that base:install-local-smoke(WinError 1314, symlink privilege),codex-cli-packaged-install-smoke(Bash unavailable),loopx-update-smoke(next_action=None), andsemantic-vocabulary-drift-smoke(44 twins vs budget 43). |Frontend / Visual Evidence
locator_state,recorded_pid_alive) to the existing runtime lifecycle block; no new screen, hero or CTA.Type of Change
LoopX Area
Technical Direction
locator_stateand its diagnostics stay local to the existing Python Effect runtime adapter; the TypeScript protocol and locator schema are unchanged.Shared-authority RFC fixture impact
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).python3 scripts/check_rfc_bilingual.py --base origin/main --head HEADpasses, or no paired RFC changed.none.Signed-off-bytrailer (git commit -s).