Repository navigation
Conversation
Supersedes contaminated tiann#2021: clean tip from upstream/main with only archive_peer / hapi archive-peer, shared hub archive-session-working pre-stop guard (builds on tiann#2616 waiting + idleReconcileExempt), and matching web hide/skip for live work. No softStandDown exception; verified Runner cleanup for every caller. No fork-only tools. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
Review mode: initial
Requirement — Pass
Orchestrators need a first-class way to stop finished peers and reclaim runner memory while retaining session history. The revised scope adds CLI and MCP entry points, protects sessions with visible work, and requires the existing Runner cleanup confirmation.
Evidence
- Issue #2020 and its follow-up describe idle peers retaining memory, the manual REST workaround, and the revised requirement to refuse busy archives before sending stop RPCs.
- The base CLI registers peer discovery, messaging, and spawning commands in cli/src/commands/registry.ts:46. The existing archive operation is documented in hub/README.md:147.
Approach — Pass
Reusing the namespace-scoped archive endpoint gives CLI and MCP callers the same lifecycle contract as web callers. Checking for live work in the hub before process termination keeps that policy enforceable for every caller.
Evidence
- cli/src/modules/archivePeer/archivePeer.ts:230 exchanges the CLI credential, resolves the target, and calls the existing archive route. hub/src/web/routes/guards.ts:23 scopes access to the authenticated namespace.
- hub/src/sync/syncEngine.ts:3927 checks eligibility before KillSession and the existing Runner confirmation path.
Code — Reviewed
The fixed-head diff was reviewed statically. The findings cover archive recovery, client behavior, credential exposure, and MCP availability.
- [Major] Persisted work markers can strand a stopped session —
hub/src/sync/syncEngine.ts:3928 - [Major] Dissolve group partially archives groups with busy members —
web/src/components/ProjectGroupRow.tsx:19 - [Major] Debug output can expose hub credentials —
cli/src/commands/archivePeer.ts:101 - [Major] Peer archive times out before the hub's cleanup deadline —
cli/src/modules/archivePeer/archivePeer.ts:199 - [Minor] Sidebar summaries omit two archive eligibility signals —
web/src/lib/sessionHasLiveWork.ts:33 - [Minor] Pi sessions cannot discover archive_peer —
cli/src/claude/utils/startHappyServer.ts:919
Testing
Not run (automation; PR code execution is prohibited).
- For head 6ee34dc, core, unit-web, integration, wrapper-parity, windows-codex-mcp, and drift-gate passed. Browser and pr-review were in progress at the last check.
- unit-cli failed in agyReactiveWakeup.test.ts and opencodeRemoteLauncher.test.ts. The changed archive, MCP registration, bridge, and permission suites passed in that job. Whether the two failures reproduce on base remains unverified.
- The fixed diff passed git diff --check. Review verification was read-only.
HAPI Bot
Inactive stale waiting markers can reach verified Runner cleanup; dissolve fail-closes on busy members; DEBUG never dumps Axios; client archive timeout covers the hub 90s budget; summaries project waiting/exempt; Pi gets archive_peer on the peer MCP allowlist. Co-authored-by: Cursor <[email protected]>
Auto-fix tip
|
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Orchestrators need a CLI and MCP command to stop finished peers, reclaim Runner memory, and retain session history. The revised requirement also protects sessions with visible work and preserves verified Runner cleanup.
Evidence
- Issue #2020 describes idle workers retaining memory and the manual JWT and REST workaround. Its follow-up specifies refusal before stop RPCs for working sessions and retains verified cleanup.
- The base CLI registers peer discovery, messaging, and spawning without a peer archive command. cli/src/commands/registry.ts:46
- The base hub already documents an archive endpoint that waits for Runner cleanup. hub/README.md:147
Approach — Pass
Reusing the namespace-scoped archive endpoint gives CLI and MCP callers the existing lifecycle and cleanup contract. A hub-side precondition can protect work across callers, while projected session state lets the web reflect eligibility.
Evidence
- The shared CLI helper exchanges the CLI credential, resolves the session, and calls the existing archive endpoint. cli/src/modules/archivePeer/archivePeer.ts:233
- The route resolves session access against the authenticated namespace. hub/src/web/routes/guards.ts:23
- The hub checks eligibility before its existing KillSession and Runner cleanup sequence. hub/src/sync/syncEngine.ts:3930
Code — Reviewed
Reviewed the full merge-base diff at 3967bbb. The main remaining issues are archiving a live peer after its heartbeat expires and reporting premature failures through the MCP bridge.
- [Major] Heartbeat expiry lets archive stop a peer that still has work —
hub/src/sync/syncEngine.ts:3931 - [Major] MCP bridge times out before archive can report its result —
cli/src/codex/happyMcpStdioBridge.ts:535 - [Minor] Stale work markers hide archive recovery in the web UI —
web/src/lib/sessionHasLiveWork.ts:34 - [Minor] Archive refusal gives an ineffective next step for metadata blockers —
hub/src/sync/archiveCleanupError.ts:16
Testing
Not run (automation; PR code execution is prohibited).
- For fixed head 3967bbb, the test, core, unit-cli, unit-web, integration, browser, wrapper-parity, windows-codex-mcp, and drift-gate checks passed. The advisory review check was in progress.
- The merge-base diff passed git diff --check. Review verification was read-only.
- The added tests cover already-gone inactive sessions and groups already busy at confirmation. They do not exercise a still-live Runner worker after heartbeat expiry, a member becoming busy after confirmation, or an archive response that crosses the MCP bridge's default deadline.
HAPI Bot
Probe inactive protected rows via non-destructive hostPid before stop RPCs; raise Codex MCP bridge archive_peer timeout to 130s; align web Archive gate with inactive recovery; return waiting/exempt-specific refusal guidance. Co-authored-by: Cursor <[email protected]>
Follow-up tip
|
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Orchestrators need a first-class way to stop finished peers, reclaim Runner memory, and keep conversation history. Archive should refuse while the target has live work and continue to require verified Runner cleanup.
Evidence
- Issue #2020 describes the manual JWT and REST workaround. Its follow-up calls for a live-work check before stopping the session and retains verified cleanup.
- The base CLI registers peer discovery, messaging, and spawning without a peer archive command. cli/src/commands/registry.ts:46
- The base hub already documents an archive endpoint with verified Runner cleanup. hub/README.md:147
Approach — Pass
Reusing the namespace-scoped archive endpoint gives CLI and MCP callers the existing lifecycle and cleanup contract. A hub-side guard enforces the policy across callers, and the web can use projected session state to hide unavailable actions.
Evidence
- The CLI and MCP share a helper that exchanges the CLI credential, resolves the peer, and calls the archive endpoint. cli/src/modules/archivePeer/archivePeer.ts:233
- The route resolves session access in the authenticated namespace. hub/src/web/routes/guards.ts:23
- The guard runs before the existing cleanup sequence. hub/src/sync/syncEngine.ts:3930
- Group dissolve uses the same policy and refuses when its current snapshot contains a protected member. web/src/components/DissolveGroupButton.tsx:97
Code — Reviewed
Reviewed the full merge-base diff at 65c026a. The inactive-session probe can authorize a stop using evidence about an earlier process and can block retries for an already-stopped Codex root.
- [Major] A dead PID can authorize stopping a replacement worker —
hub/src/sync/syncEngine.ts:3948 - [Minor] Archive retries reject stopped Codex roots on shared wrappers —
hub/src/sync/syncEngine.ts:3952 - [Minor] Dissolve gives ineffective recovery guidance for waiting or exempt members —
web/src/lib/locales/en.ts:543
Testing
Not run (automation; PR code execution is prohibited).
- For fixed head 65c026a, core, unit-cli, unit-web, integration, wrapper-parity, windows-codex-mcp, and drift-gate passed. Browser and pr-review were still in progress.
- The merge-base diff passed git diff --check. PR code and tests were not run locally.
- The added hub tests mock a dead or live PID. They do not cover a binding change during the probe or an archived Codex root whose sibling keeps the wrapper alive.
HAPI Bot
Recheck hostPid/active after inactive probes so a replacement worker cannot inherit a dead-PID pass; use session-scoped stop for already-archived shared roots; dissolve busy toast names waiting/exempt blockers. Co-authored-by: Cursor <[email protected]>
Follow-up tip
|
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Orchestrators need a first-class CLI and MCP command that stops finished peers, frees Runner memory, and preserves conversation history. Archive should refuse while work is ongoing and require verified Runner cleanup before reporting success.
Evidence
- Issue #2020 describes the manual JWT and REST workaround. Its follow-up specifies a live-work check before stopping the session and retains verified cleanup.
- The base CLI registers peer discovery, messaging, and spawning without a peer archive command. cli/src/commands/registry.ts:46
- The base hub documents the archive endpoint and its Runner cleanup contract. hub/README.md:147
Approach — Pass
Reusing the namespace-scoped archive endpoint gives CLI and MCP callers the existing cleanup contract. The hub is the right place to enforce the work guard, and the web can use session summaries to reflect archive eligibility.
Evidence
- The shared CLI and MCP helper resolves the peer and calls the existing archive endpoint. cli/src/modules/archivePeer/archivePeer.ts:233
- The route resolves session access in the authenticated namespace. hub/src/web/routes/guards.ts:23
- The hub checks live work before the existing cleanup sequence, and session summaries carry waiting and exemption state. hub/src/sync/syncEngine.ts:3930, shared/src/sessionSummary.ts:282
Suggestions
- Update the PR description to reflect that group dissolve refuses when its preflight detects protected work.
Code — Reviewed
Reviewed the full merge-base diff at 83b3430. The hub guard has gaps around disconnected workers and archive retries, and group dissolve can still partially archive a group when a disconnected member is protected.
- [Major] Archive retry can stop a resumed worker during the guard —
hub/src/sync/syncEngine.ts:3953 - [Major] Heartbeat expiry removes the work evidence the guard needs —
hub/src/sync/syncEngine.ts:3931 - [Major] The PID probe can use the wrong Runner's exit evidence —
hub/src/sync/syncEngine.ts:3941 - [Minor] Dissolve preflight misses disconnected members with protected work —
web/src/components/DissolveGroupButton.tsx:97
Testing
Not run (automation; PR code execution is prohibited).
- For fixed head 83b3430, core, unit-cli, unit-web, integration, browser, wrapper-parity, windows-codex-mcp, drift-gate, and the aggregate test check passed. pr-review was in progress and owner-approval was skipped.
- The merge-base diff passed git diff --check. PR code and tests were inspected statically.
- The added hub tests mock the StopSession result and a numeric PID change. They leave live replacement bindings, mismatched Runner and PID ownership, and work-state loss on heartbeat expiry uncovered. The dissolve test covers an active busy member.
HAPI Bot
Drop inactive hostPid/session Stop probes under waiting/exempt markers. Those races with resume and shared Codex wrappers; recovery is clear the marker then archive. Web Archive/dissolve gates match the hub refuse. Co-authored-by: Cursor <[email protected]>
Tip
|
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Orchestrators need a CLI and MCP command that stops finished peers, frees Runner memory, and preserves session history. Archive should refuse before interrupting ongoing work and report success only after the existing Runner cleanup checks pass.
Evidence
- Issue #2020 describes the manual JWT and REST workflow. Its follow-up specifies a shared live-work precondition and retains verified Runner cleanup.
- The base CLI exposes peer discovery, messaging, and spawning. Peer archive still requires a direct request to the existing hub endpoint. cli/src/commands/registry.ts:46, hub/README.md:147
Approach — Pass
A shared CLI and MCP helper reuses the namespace-scoped archive endpoint. The hub enforces eligibility before shutdown, and the web uses session summaries to reflect that policy.
Evidence
- The helper resolves the target and calls the existing archive endpoint. The route checks access in the authenticated namespace. cli/src/modules/archivePeer/archivePeer.ts:233, hub/src/web/routes/guards.ts:23
- The hub checks eligibility before KillSession and retains the Runner confirmation sequence. The list summary carries waiting and exemption markers. hub/src/sync/syncEngine.ts:3930, shared/src/sessionSummary.ts:282
Suggestions
- Update the PR description to say that group dissolve refuses when its preflight finds a protected target.
Code — Reviewed
Reviewed the full merge-base diff at 9c7ea02. The new head removes the destructive guard probes and includes inactive members with a live lifecycle in the dissolve preflight. Heartbeat expiry and recovery from stale waiting markers still have gaps.
- [Major] Archive can stop a working peer after heartbeat expiry —
hub/src/sync/syncEngine.ts:3930 - [Major] A crashed peer can leave archive permanently blocked —
hub/src/sync/archiveCleanupError.ts:6
Testing
Not run (automation; PR code execution is prohibited).
- GitHub checks for 9c7ea02 passed for core, unit-cli, unit-web, integration, browser, wrapper-parity, windows-codex-mcp, drift-gate, and the aggregate test check. pr-review was in progress and owner-approval was skipped.
- The fixed merge-base diff passed git diff --check. PR code and tests were inspected statically.
- The added hub tests cover refusal with populated flags and an inactive waiting marker. They leave heartbeat expiry during live work and recovery after the waiting peer exits uncovered.
HAPI Bot
Inactive archives probe markerless hostPid on metadata.machineId only — already_gone recovers crashed waiting rows; still_alive refuses before Kill. No session-scoped Stop in the guard. Dissolve still blocks on waiting/exempt markers to avoid partial archive. Co-authored-by: Cursor <[email protected]>
Tip
|
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Orchestrators need a CLI and MCP command to archive finished peers, reclaim Runner memory, and preserve session history. Archive should refuse before interrupting live work and retain verified Runner cleanup.
Evidence
- Issue #2020 documents the manual JWT and REST workflow. Its follow-up calls for a shared precondition that protects live work for every archive caller.
- The base CLI exposes peer discovery, messaging, and spawning. Peer archive still requires a direct request to the hub endpoint. cli/src/commands/registry.ts:46, hub/README.md:147
Approach — Needs changes
The namespace-scoped endpoint and shared hub guard are appropriate. The inactive-session guard uses a bare OS PID to decide whether a session can proceed to cleanup. That probe cannot verify the state of an individual session on a shared wrapper, and requiring it also makes inactive terminal sessions depend on a Runner.
Evidence
- The new guard probes every inactive row with a machine ID and host PID before reaching the existing cleanup logic. A markerless probe returns unknown while the PID is alive. hub/src/sync/syncEngine.ts:3941, cli/src/runner/sharedSessionStop.ts:43
- A Codex root can complete shutdown while siblings keep its wrapper alive. Its inactive registry binding is existing stop evidence, but the PID gate returns 409 on retry before the Runner can consult that binding. cli/src/codex/shared/runtime.ts:156, cli/src/runner/run.ts:1475, hub/src/web/routes/sessions.ts:1146
- Terminal sessions also report a machine ID and PID. An inactive terminal row with a live lifecycle and no Runner now fails the mandatory probe before it reaches the terminal path, where Runner cleanup is best effort. cli/src/agent/sessionFactory.ts:128, hub/src/web/routes/sessions.ts:1153, hub/src/sync/syncEngine.ts:4051
Suggestions
- Base inactive-session recovery on read-only evidence tied to the target session and its owner generation. Accept a verified exit for a dedicated worker or a verified inactive binding for a shared Codex root. Preserve Runner-independent terminal recovery where the session's end is confirmed, and refuse shutdown while ownership or live work remains uncertain.
Code — Not reviewed
Code review stopped at the approach stage because the inactive-session guard needs a session-scoped way to verify cleanup.
Testing
Not run (automation; PR code execution is prohibited).
- The fixed merge-base diff passed git diff --check. PR code and tests were inspected statically.
- For f69549e, drift-gate and windows-codex-mcp passed. Core, unit-cli, unit-web, integration, browser, wrapper-parity, and pr-review were in progress when checked.
- The added hub tests mock the PID probe for dead and live workers. They leave the shared Codex retry with a live sibling and the inactive terminal case without a Runner uncovered.
HAPI Bot
Tip
|
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Orchestrators need a CLI and MCP command to stop finished peers, reclaim worker memory, and retain conversation history. Archive should protect live work and preserve verified Runner cleanup for every caller.
Evidence
- Issue #2020 documents the manual JWT and REST workflow and calls for a shared live-work precondition with verified cleanup. #2020
- The base CLI offers peer messaging, inspection, and spawning. Archive requires a direct hub request. cli/src/commands/registry.ts:46, hub/README.md:147
Approach — Needs changes
Reusing the namespace-scoped archive endpoint and checking live work before shutdown are sound. A wrapper PID cannot establish whether an individual Codex root has stopped, and the terminal fallback still permits shutdown when liveness is uncertain.
Evidence
- A shared Codex root records its binding as inactive when it ends. The existing Runner cleanup can use that binding to confirm the stop while siblings keep the wrapper alive. The new precheck sees the live PID, gets
unknown, and returns 409 before the session-scoped confirmation can run. Archive retries can remain blocked until the siblings exit. cli/src/codex/shared/runtime.ts:156, cli/src/runner/sharedSessionStop.ts:43, cli/src/runner/run.ts:1475, hub/src/sync/syncEngine.ts:3948 - The new commit refuses Runner-owned rows when the probe fails, but terminal rows still proceed to
KillSessionwithout a fresh state check. Heartbeat expiry clears transient work flags independently of session RPC registration. If a terminal session is still working and its RPC is reachable, archive can end it while the Runner is absent or its probe times out. hub/src/sync/sessionCache.ts:1198, hub/src/sync/rpcGateway.ts:898, hub/src/sync/syncEngine.ts:3949, cli/src/claude/registerKillSessionHandler.ts:92
Suggestions
- Use read-only stop evidence tied to the target session and owner generation. Let a verified inactive Codex binding reach cleanup confirmation while siblings keep running.
- Require affirmative idle or ended evidence before proceeding after a failed probe. Recheck the current session state after the RPC attempt and preserve Runner-independent recovery for terminal sessions with confirmed end evidence.
Code — Not reviewed
Code review stopped at the approach stage because the inactive-session guard can block confirmed cleanup retries and permit shutdown while terminal work remains live.
Testing
Not run (automation; PR code execution is prohibited).
- The fixed merge-base diff passed
git diff --check. No PR code or tests ran locally. - The added tests cover refusal on an unknown wrapper PID and successful terminal archive without a Runner. They do not cover a successful retry with an inactive Codex binding and a live sibling, or refusal when a working terminal session remains reachable after a failed probe. hub/src/sync/syncEngineArchiveSession.test.ts:464, hub/src/sync/syncEngineArchiveSession.test.ts:485
- For ff9e498, GitHub reported success for core, windows-codex-mcp, integration, and drift-gate. Browser, unit-web, wrapper-parity, unit-cli, and pr-review were still in progress when checked.
HAPI Bot
Probe throw/unavailable no longer falls through to KillSession. Markerless unknown hostPid asks read-only STATUS-<sessionId> for inactive Codex binding or verified exit so finished shared roots can archive while siblings keep the wrapper. Co-authored-by: Cursor <[email protected]>
|
Tip
Regression coverage: probe-throw + no markers → zero KillSession; inactive Codex binding + live sibling wrapper → archive proceeds via STATUS evidence ( PR description updated for dissolve refuse on protected work. Prepare-only; no cold-review-clean requested. |
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Orchestrators need a first-class way to stop finished peers, reclaim worker memory, and retain conversation history. Archive should protect live work and preserve verified Runner cleanup.
Evidence
- Issue #2020 documents the manual JWT and REST workflow. The follow-up discussion narrows the request to a shared live-work precondition with verified cleanup. #2020
- The base CLI exposes peer messaging, inspection, and spawning. Peer archive requires a direct hub request. cli/src/commands/registry.ts:46, hub/README.md:147
Approach — Needs changes
Reusing the namespace-scoped archive endpoint and checking for live work before shutdown are sound. The inactive-session guard can accept evidence from a previous Codex owner and makes terminal crash recovery depend on a Runner.
Evidence
- A shared Codex wrapper retains an inactive binding while siblings run, and a cold resume can bind the same HAPI session ID in a second wrapper. STATUS looks up the first binding by session ID without receiving the probed PID or generation. If the resumed root's heartbeat expires, the old inactive binding can authorize archive while the new root is still working. cli/src/codex/shared/runtime.ts:156, cli/src/codex/shared/runtime.ts:395, cli/src/runner/sharedSessionStop.ts:65, cli/src/runner/run.ts:1385, hub/src/sync/syncEngine.ts:3987
- Terminal sessions publish a machine ID and host PID. After an abrupt exit leaves a terminal row inactive with a running or idle lifecycle, archive now returns 503 when its host has no Runner. The base explicitly supported hub-side archive recovery in that configuration. cli/src/agent/sessionFactory.ts:123, hub/src/web/routes/sessions.ts:1153, hub/src/sync/syncEngine.ts:3953, hub/src/sync/syncEngine.ts:4082
Suggestions
- Tie read-only end evidence and subsequent shutdown to the same current owner generation. Include the wrapper identity in the status request and let any current active binding take precedence over historical inactive bindings or exit records.
- Provide a Runner-independent terminal recovery path using affirmative idle or end evidence. Keep destructive calls blocked when heartbeat expiry is the only evidence.
Code — Not reviewed
Code review stopped at the approach stage because the inactive-session guard can authorize shutdown for the wrong owner and prevent recovery on Runner-free terminal hosts.
Testing
Not run (automation; PR code execution is prohibited).
- The fixed merge-base diff passed git diff --check. No PR code or tests ran locally.
- The added STATUS tests cover individual active and inactive bindings. They do not exercise an old inactive binding alongside a resumed active binding for the same session. The Runner-free terminal test starts with an active row and does not exercise crash recovery. cli/src/runner/run.stopSession.test.ts:146, hub/src/sync/syncEngineArchiveSession.test.ts:804
- For 5422796, GitHub reported success for core, windows-codex-mcp, unit-cli, wrapper-parity, integration, and drift-gate. Unit-web, browser, and the current PR review were in progress. An earlier PR review run was cancelled.
HAPI Bot
STATUS-<pid>:<session> prefers any active binding (cold-resume on another wrapper) over a historical inactive binding. Terminal / non-runnerOwned rows skip the Runner hostPid probe so crash recovery stays KillSession-based. Co-authored-by: Cursor <[email protected]>
|
Tip
Regression: resumed active binding on another PID → STATUS still_alive; quiet inactive terminal + no Runner → archive proceeds. Prepare-only; no CRC. |
Codex PR Review Analyze hung across three attempts on 602e7d9; empty tip to force a fresh pull_request_target review run. Co-authored-by: Cursor <[email protected]>
Comment-only sync with the shipped STATUS-<hostPid>:<sessionId> + terminal skip behavior so synchronize re-triggers CI/review after a hung Analyze. Co-authored-by: Cursor <[email protected]>
|
Temporary close/reopen to re-trigger CI + tip-matched Codex PR Review after synchronize events stopped delivering (tip 2392574). Prepare-only. |
|
Ops note (prepare-only): tip Timeline:
Today is also GitHub's 2026-12-02 No cold-review-clean requested from this tip. |
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Orchestrators need a supported way to stop finished peers, reclaim worker memory, and retain conversation history. The issue discussion calls for a shared archive guard that protects live work and preserves verified Runner cleanup.
Evidence
- Issue #2020 describes the manual JWT and REST workflow. Its follow-up adopts a common live-work precondition for all archive callers. #2020
- The base CLI supports pinging, inspecting, and spawning peers. Archive requires a direct hub request. cli/src/commands/registry.ts:46, hub/README.md:147
Approach — Needs changes
Reusing the namespace-scoped archive endpoint and checking live work before shutdown are sound. The inactive-session policy still lets a heartbeat-expired terminal session be archived mid-turn and can make Codex resume recovery depend on an obsolete Runner.
Evidence
- Heartbeat expiry clears thinking, background tasks, and open-tool state. A terminal-started Codex session disconnected mid-turn can therefore pass the guard without any idle or exit evidence. If KillSession cannot reach it and there is no Runner, the hub writes archive metadata. The CLI reads that metadata on reconnect and ends the root. hub/src/sync/sessionCache.ts:1198, hub/src/sync/syncEngine.ts:3954, hub/src/sync/syncEngine.ts:4095, cli/src/api/apiSession.ts:315, cli/src/codex/shared/root.ts:690
- An unconfirmed Codex resume can record a pending Runner distinct from the previous machine, such as when resume falls back to an online Runner with the same hostname. The preflight probes the previous machine and returns 503 if it is offline, before cleanup can ask the pending Runner to confirm termination. This blocks an existing recovery path even when the pending Runner can prove the process exited. hub/src/sync/syncEngine.ts:434, hub/src/sync/syncEngine.ts:3951, hub/src/sync/syncEngine.ts:4038, hub/src/sync/syncEngine.ts:5810, hub/src/sync/archivedFork.test.ts:121
Suggestions
- Preserve the last known working state across heartbeat expiry for archive eligibility. Keep Runner-free recovery for quiet terminal crashes, and require fresh idle or explicit end evidence before archiving a disconnected terminal session last seen working.
- Use the persisted pending resume target for reconciliation. Require any read-only status evidence to identify that owner, and preserve the existing verified cleanup path for an unconfirmed startup.
Code — Not reviewed
Code review stopped at the approach stage because inactive archive eligibility can discard live terminal work and block recovery of an unconfirmed Codex resume.
Testing
Not run (automation; PR code execution is prohibited).
- The fixed merge-base diff passed git diff --check. This review did not execute PR code or tests.
- The added Runner-free terminal test starts with a quiet inactive row and mocks a successful KillSession. It leaves the mid-turn disconnect case uncovered. hub/src/sync/syncEngineArchiveSession.test.ts:515
- For 2392574, GitHub reported success for core, windows-codex-mcp, unit-cli, unit-web, wrapper-parity, integration, browser, test, and drift-gate. The current PR review check was in progress and an earlier run was cancelled.
HAPI Bot
Answers tip-matched Evidence on 2392574: - inactive + hostPid always markerless-probes (terminal included); throw / unknown refuse before KillSession; already_gone/stopped may proceed - prefer codexResumePending.machineId over metadata.machineId for probes Deliberately declines aspirational Suggestion "preserve last known working state across heartbeat expiry" (no expireInactive redesign). Co-authored-by: Cursor <[email protected]>
Preserve mid-turn archive refusal after expireInactive clears thinking/tools; quiet terminal crashes without the latch still archive Runner-free. Clear the flag on reconnect; hostPid already_gone still proves exit. Co-authored-by: Cursor <[email protected]>
|
Addressed both Approach bullets from tip
No CRC. Prepare-only. |
Co-authored-by: Cursor <[email protected]>
Conflict re-merge only for tiann#2740 Gate 1; preserve Approach semantics.
Merge resolution note (
|
Merge with main moved dissolve into the context menu; the quiet-path group test still clicked a missing button. Co-authored-by: Cursor <[email protected]>
|
Follow-up on merge tip: |
Summary
Clean supersede of contaminated #2021 (do not rebase that tip - it re-thinned onto fork
origin/mainand leaked fork-only MCP tools +scripts/toolinginto a 957-file upstream-facing tip).This branch is cut from
upstream/mainwith only:hapi archive-peer+ MCParchive_peer- same JWT path asping_peer/spawn_peer; archive only, never delete; posts{}toPOST /api/sessions/:id/archive.archive-session-workingwhenblocksHardArchiveis true (idleReconcileExempt,expiredWhileWorking, orhasLiveWork). Builds on already-merged #2616 (metadata.waitinginsidehasLiveWork); also treatsderivedToolWorkas live work. No softStandDown exception - verified Runner cleanup for every caller.PID-N—already_gone/stoppedmay proceed (crash recovery);still_aliverefuses; Runner-ownedunknownasks read-onlySTATUS-<hostPid>:<sessionId>for inactive Codex binding / verified exit (shared wrappers with live siblings); terminalunknown/probe throw refuses without KillSession. PrefercodexResumePending.machineIdovermetadata.machineIdso STATUS/cleanup targets the pending resume owner.expireInactivesets hub-ownedmetadata.expiredWhileWorkingwhen keepalive dies mid-thinking / derived-tool / background work so cleared turn UI flags alone cannot authorize KillSession on a disconnected terminal last seen working. Quiet inactive terminal crash (no latch, no hostPid) still archives Runner-free. Latch clears on become-active.sessionBlocksHardArchiveorsessionHasProtectedArchiveMarkers, including disconnected members with waiting/exempt).Honest tool/help copy: live-work refuse first; unconfirmed Runner stop still 409 after that.
Approach follow-up (tip-matched)
Approach Needs changes on OID
239257494(two bullets) was answered on6de1e0976:expiredWhileWorkinglatch across heartbeat expiry (mid-turn disconnect + expiry + no Runner → refuse; quiet crash → archive OK).codexResumePending.machineIdfor inactive probe / STATUS reconciliation.Codex PR Review on
6de1e0976hitstartup_failure(0 jobs; cannot retry). PR body edit here is the synchronize kick — no content change required beyond documenting that status. Trivial tip0f88bf15b(comment-only) may also have been pushed earlier for the same reason.Test plan
sessionIdle/syncEngineArchiveSession/sessionsroute tests forarchive-session-working(thinking, derivedToolWork, waiting, idleReconcileExempt, expiredWhileWorking), probe throw refuse, STATUS Codex sibling recovery, pending-machine prefer, and existing cleanup codesarchivePeermodule + arg parse + MCP registration / bridge / permission / expected tool catalogs; runnerSTATUS-*read-only probe testssessionHasLiveWork+ quick-archive hide-while-busy + dissolve-group protected-marker preflightbun run typecheck:cli|hub|webbun run test(cli green; hub has pre-existing unrelated flakes onupstream/mainalso:steerDeliveryLifecycleopencode reconnect + two timeouts)Issues
Fixes #2020
Supersedes #2021 (leave open for operator close after this lands).