Repository navigation
Conversation
Replace single-slot unresolvedTurn/backgroundWork with liveWorkByGeneration keyed by hostStartMarker so archive can refuse or clear per worker generation. Runner-owned rows probe PID+marker via ProbeSessionExit before clearing; empty-map clears use the hub-owned null sentinel. Closes tiann#2657. Co-authored-by: Cursor <[email protected]>
Attribute durable latches to the keepalive's hostPid+marker, not the current row; key owners as machineId:hostPid:hostStartMarker; skip durable writes for terminal/unmarked reports so Archive cannot strand non-runner rows. Addresses remasure Approach on tiann#2659. Co-authored-by: Cursor <[email protected]>
KeepAlive carries machineId; durable writes never take owner fields from the current row. Background snapshots stay in-memory only until they can carry a reporting owner. Legacy projection refuses to pair a prior latch marker with the replacement's pid. Refresh Claude parity goldens for the new session-alive fields. Co-authored-by: Cursor <[email protected]>
Freeze hostPid/start-marker from the OS process at ApiSessionClient construct time so metadata refreshes after replacement cannot re-attribute heartbeats. Stamp reportingOwner on background_tasks_changed messages and durable-latch attributed snapshots under that owner only. Co-authored-by: Cursor <[email protected]>
Construct ApiSessionClient with this process's metadata (not the prior row), refuse inherited hostPid/marker from a different PID, and stamp reportingOwner on sendClaudeSessionMessage background snapshots so AGY and Claude durable-latch under the real sender. Co-authored-by: Cursor <[email protected]>
…n#2658) Co-authored-by: Cursor <[email protected]>
When the wrapper PID is gone, still return still_alive if a Codex owned runtime for that wrapper generation has a live app-server. Prevents Archive from clearing a prior-gen latch while the owned server remains. Co-authored-by: Cursor <[email protected]>
Strict Codex runtime registry reads fail closed; scope scans to hub+auth; project legacy turn/bg as separate owners when markers differ; clear stale permission requests after verified exit; probe capability on the recorded owner machine; skip no-op durable metadata writes. Co-authored-by: Cursor <[email protected]>
Scope ProbeSessionExit to session namespace at rpcGateway dispatch (machine row + socket). Clear only requests stamped for the verified owner. Keep markerless legacy work under UNKNOWN. Union live-work maps across resume/dedup merges. Probe by entry identity after terminal resume. PID-reuse continues to the Codex registry then already_gone. Co-authored-by: Cursor <[email protected]>
Stamp ownership on permission requests changed the wrapper wire transcript; re-record the four ask/approve/deny cases. Co-authored-by: Cursor <[email protected]>
Stamp full machineId+hostPid+marker on permission requests; clear only exact matches. Probe attributed request owners without a turn latch. Bind durable writes to reporter runnerOwned, not row startedBy. Fresh live-work transfer immediately before merge delete. Match Codex runtimes by hub+auth+marker (not survivor hubSessionId). Clear stale thinking only for the verified owner. Refresh parity goldens. Co-authored-by: Cursor <[email protected]>
Legacy projection never attaches current-row pid from marker equality. Request probe requires runnerOwned=true; CLI stamps only newly added asks with full owner + runnerOwned. Background snapshots carry runnerOwned; verified exit clears that owner's transient bg/thinking. Drop hub-side request stamping. Refresh all parity goldens + unit test. Co-authored-by: Cursor <[email protected]>
Reset thinking/background ownership on unattributed reports. Match Codex runtimes by PID and marker. Probe process-group descendants before already_gone. Clear derived tool work and terminal pending asks after verified exit / CLI-gone. Preserve replacement transient signals. Co-authored-by: Cursor <[email protected]>
…anscript, merge Fail closed on Windows descendant ambiguity; keep replacement row-wide background tasks; leave queued-prompt thinking hub-owned; retire stale terminal asks before the Archive guard; bound transcript-derived work to the current generation; transfer fresh source live-work without retaining stale first-merge copies. Co-authored-by: Cursor <[email protected]>
…r-owner bg Verify Windows descendants via process table (tombstone on reuse); retire terminal asks only after PID+marker probe; keep per-owner background snapshots; protect queued-prompt grace from worker clear; advance transcript boundary only for the current row generation. Co-authored-by: Cursor <[email protected]>
…rminal exit Check process-group/Windows tree before trusting PID tombstones; keep per-owner thinking so late idles cannot wipe a replacement; bound transcript work by seq; preserve queued-prompt grace against prior-gen heartbeats; clear transient owner maps on expiry; reconcile standalone terminal asks when inactive and the socket is gone. Co-authored-by: Cursor <[email protected]>
… edges Fail closed on Windows when grandchildren may be reparented; drop weak PID-only exit tombstones; union overlapping owners on merge transfer; keep unattributed thinking; retire stale terminal thinking on current-row idle; bound transcript at metadata identity change; require long-inactive before clearing standalone terminal asks. Co-authored-by: Cursor <[email protected]>
…l, merge Capture Windows tree members while the wrapper is alive so root-gone probes can re-check generation-scoped PIDs. Bound transcript work on metadata patch, keep terminal asks through disconnect, expire stale thinking without wiping markerless bits, and strip settled source turns from merge destinations. Co-authored-by: Cursor <[email protected]>
…atch, merge Fail closed on incomplete Windows witness membership; tombstone only after tree-confirmed StopSession. Latch prior transcript tool work before cutoff, keep live-work out of early merges, expire departed terminal background snapshots, and align terminal request probes with legacy capability lists. Co-authored-by: Cursor <[email protected]>
…iann#2660 Add transcriptOpenWork so idle thinking cannot clear latched tool work, keep dest-independent entries on deleting merges, expire terminal background snapshots on the heartbeat path, and recover standalone asks when the owner machine is gone from the hub. Windows launch-time tree containment stays fail-closed unknown and is tracked in tiann#2660. Co-authored-by: Cursor <[email protected]>
…ecovery Freeze CLI machineId after bootstrap; latch transcript work with the prior owner's runner provenance; union dest turns on merge; refresh background liveness on attributed heartbeats; recover standalone asks when a registered machine is inactive and the session socket is gone. Windows containment remains deferred to tiann#2660. Co-authored-by: Cursor <[email protected]>
…l asks Revert kill-direction clear on machine-inactive alone. Idle heartbeats update only their reporter's thinking bit. Persist transcriptOpenWork when the derived sweep observes open tools, and latch departing owners only against their existing sequence boundary. Co-authored-by: Cursor <[email protected]>
…lear Write transcriptGenerationBoundary into metadata so hub restart cannot re-attribute a prior owner's open tool call. noteDerivedWork(false) only clears the display flag — durable transcriptOpenWork waits for exit or owner-scoped settlement. Co-authored-by: Cursor <[email protected]>
…nscript work ProbeSessionExit on Windows consults generation-keyed tombstones only — session-scoped and bare PID-N wrapper-only records stay unknown. Owner-scoped settlement clears transcriptOpenWork; late tool traffic stamps the reporter. Standalone terminal recovery deferred to tiann#2662. Co-authored-by: Cursor <[email protected]>
Agent tool traffic now carries reportingOwner on the wire and in message meta; re-record the Claude corpus so wrapper-parity matches tip. Co-authored-by: Cursor <[email protected]>
…cans Require verified treeDeath before Windows webhook tombstones; retain the stop marker across child-exit races; owner-filter settlement so foreign results cannot clear another worker; keep durable bits on inconclusive lookback; scope handoff latching; block markerless cutoff moves; recompute background tasks from remaining owners after exit clear. Co-authored-by: Cursor <[email protected]>
Document the Accepted trade: clear a generation solely on runner-owned PID+marker ProbeSessionExit; strand elsewhere (tiann#2660/tiann#2662). Message handler uses three-state scan (no clear on inconclusive). Windows tree stop refuses confirmation when the recorded root was never observed. Co-authored-by: Cursor <[email protected]>
…pt settle Pass expected start marker into Windows tree stop so confirmed exit needs the initial snapshot to observe that exact PID+marker before any generation tombstone. Owner-scoped transcript scans no longer treat a replacement human prompt as settlement for a prior owner's open tool work (tiann#2658). Co-authored-by: Cursor <[email protected]>
Recompute row-wide background after removing an attributed owner even when the remaining set is empty, so a verified sole-reporter exit unblocks Archive. Skip derivedToolWork latch when the row has machine+pid but no start marker (terminal bootstrap), so a prior runner's stamped open call cannot credit the replacement. Also consult the generation tombstone on Windows PID reuse. Co-authored-by: Cursor <[email protected]>
…l sweep Return before seeding or signalling when the expected Windows root marker is absent or mismatched, including the CIM-failure fallback. Scope markerless terminal transcript sweeps by machine+pid so current terminal tool work stays visible to Archive while prior-runner stamps stay excluded (tiann#2658). Co-authored-by: Cursor <[email protected]>
Archive now scans current-owner transcript tool work immediately before the shutdown decision so a terminal call cannot race the derived sweep. Unix process-group probes treat EPERM as still-alive and other non-ESRCH errors as unknown, so an unprobeable member cannot authorize already_gone (tiann#2658). Co-authored-by: Cursor <[email protected]>
…atch After ProbeSessionExit clears a generation, leftover open transcript calls must not recreate that owner's derived/durable work and permanently block Archive. Track verified-exited owner keys for the attempt and skip the pre-shutdown scan for those owners (tiann#2658). Co-authored-by: Cursor <[email protected]>
Raw-PID already_gone now requires process-group proof; Archive defers durable latch clear until unblocked so retries keep exit evidence; unattributed thinking and owner timestamp maps get THINKING_STALE_MS / end+expire cleanup so hub retention stays bounded. Co-authored-by: Cursor <[email protected]>
Cast the in-memory guardSession so the liveWorkByGeneration null sentinel from the row does not fail hub typecheck under blocksHardArchive. Co-authored-by: Cursor <[email protected]>
controlServer HTTP narrows to sessionId-only; raw-PID PGID tests need the apiMachine/ProbeSessionExit opts form. Cast the captured runner closure so typecheck:cli accepts processStartMarker. Co-authored-by: Cursor <[email protected]>
Restore legitimate archives the guard had stranded: Windows markerless dead-PID StopSession, mid-probe derived re-latch, offline terminal transcript orphans, ACP lookback settlement, and idleReconcileExempt scoped back to automatic idle only. Co-authored-by: Cursor <[email protected]>
Per-call identity retires matching results/cancels without clearing a concurrent aged-out call (tiann#2673). Owner-scoped derived clear keeps a live terminal's work when a prior runner exit verifies (tiann#2658). CLI publishes cancelled tool_call status on settleCancelled so the hub can retire the id. Co-authored-by: Cursor <[email protected]>
Forward open/settled call IDs through startHub socket deps so SessionCache sees matching retire patches. Emit provider cancellation without inventing name/input, and skip Claude text scans that cannot change live tool work. Co-authored-by: Cursor <[email protected]>
Generation-bound tree-exit evidence is not obtainable on Windows from the normal child-exit path. Keep windowsProcessStop correctness, but fall through to merge-base KillSession/StopSession cleanup for win32 machines so unplanned complete exits archive instead of permanently 409ing. Co-authored-by: Cursor <[email protected]>
…ncel publish survivors Apply the tiann#2660 platform scope consistently: strip Windows-owned runner requests from the Archive guard and retire them on fall-through, and stop consulting/writing Windows generation tombstones for Probe clear. Publish prompt-cancel terminals only for calls opened in the cancelled prompt, via tool_result so survivors keep their durable ids. Co-authored-by: Cursor <[email protected]>
Abort→cancelPrompt publishes one failed/cancelled tool_result for calls settled in an in-flight prompt; move the old zero-result assertions to require that wire shape (and messageConverter tool-call-result, not a running tool-call card) while keeping bgEntries empty. Idle and discard paths that never settle keep the zero-result invariant. Co-authored-by: Cursor <[email protected]>
Collect unsettled Claude tool_use ids into openCallIds so a sibling tool_result cannot empty the durable latch. After pgrep members are all ESRCH, signal-0 the process group before claiming absence (EPERM=live). Co-authored-by: Cursor <[email protected]>
Empty POSIX scans and all-ESRCH lists both need kill(-pgid,0) before absence. Settled ACP/Claude ids must leave the open set after a DESC scan so an out-of-order result cannot latch Archive forever. Co-authored-by: Cursor <[email protected]>
Enumerate processGroupMayBeAlive end-to-end so pgrep ENOENT/unexpected status fall through to kill(-pgid,0) instead of stranding Archive. Share endEventMatchesCurrentOwner across session-end and child-exited so a stamped prior worker cannot clear a live replacement terminal. Co-authored-by: Cursor <[email protected]>
Accept unknown metadata so socket StoredSession and SessionCache rows share one gate. Persist hostStartMarker through insertActiveSession and cover both PID-mismatch and same-PID wrong-marker rejects. Co-authored-by: Cursor <[email protected]>
…arity Session-end stamps only a registered hostStartMarker so terminal exits match bootstrap. Tool-call upserts require matching reporting owners so a restored ACP call gets its own stamped row. Parity goldens updated for the finalized runner session-end payload only. Co-authored-by: Cursor <[email protected]>
…r re-probe ProbeSessionExit maps unreadable/malformed Codex registry to null (fall through) and skips the registry for known non-Codex generations. sessionFactory passes the bootstrap marker (including null) so ApiSessionClient never repeats a blocking OS start-marker probe on startup (tiann#2658). Co-authored-by: Cursor <[email protected]>
Zombies answer kill(0) but are not executing — skip Z/X, treat unreadable state as unknown, and only clear when the group is zombies-only or ESRCH. Co-authored-by: Cursor <[email protected]>
Recheck process-group membership after a zombie-only classify so a forking successor cannot invent absence; treat an unreaped Linux wrapper zombie as not still_alive and continue to group/owned-runtime checks. Co-authored-by: Cursor <[email protected]>
…n#2659 Operator cut (A): drop Windows exit-evidence / request-stripping and the ACP synthetic cancel publish. Keep hub POSIX-only durable refuse (win32 omits ProbeSessionExit and falls through to merge-base cleanup). Costs and follow-ups: tiann#2660, tiann#2696, tiann#2697. Co-authored-by: Cursor <[email protected]>
Reopen-class fixes: Windows abandoned permissions no longer permanently block Archive (in-memory guard omit; clear after confirmed stop or child-exit). Codex registry treats Linux unreaped zombies as not alive. Ingest applies generation cutoff for the boundary owner; markerless terminal background survives late attributed empty snapshots. Co-authored-by: Cursor <[email protected]>
…nn#2697) A generation's durable latch now clears solely from an owning-runner session-child-exited or a stamped session-end for that exact owner (machineId + hostPid + processStartMarker). Both write a hub-owned metadata.liveWorkGenerationExits[ownerKey] record, then drop that owner's latch, pending requests and transient/derived bits. Stamped prior-worker ends now reach the engine (socket still skips the queue sweep) and clear their own latch without deactivating the replacement. Late reports from an exited owner never re-latch. Archive no longer treats ProbeSessionExit already_gone/stopped as clear authority. Durable work without an exit record refuses (archive-session-working) - documented strand, routed to tiann#2660 / operator recovery. Windows platform-scope omit is unchanged. Co-authored-by: Cursor <[email protected]>
6 of 7 tasks
Collaborator
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2697
Design lock (Meta)
Clear only on an event or durable exit record. Strand (refuse clear, say so) where none exists — that case is #2660 launch-time containment, not this PR.
Authoritative
child-exitfor its own childliveWorkGenerationExits)Not authoritative (samples — never clear on these alone)
/proc/ heartbeat gap / empty snapshot / registry lookupSuccess criterion: never clear without proof; never block forever without a documented route out.
What this tip does
Hub-owned
liveWorkGenerationExits: stamp on child-exit / prior session-end; Archive and generation clear require a matching record. Probes stay observational. Windows prior-gen with no event still strands until #2660.Tip:
9ac44fca8onfeat/authoritative-exit-2697(branched from standing #2659 tipf5467ac8c).Stack / #2659 fate (decision needed)
This branch currently stacks the #2697 core on the standing #2659 tip. Tip of #2659 (
f5467ac8c) is unchanged — six live threads stay open, no pushes to that PR.9ac44fca8vsf5467ac8c)mainupstream/main...HEAD)Not deciding A vs B here — bringing file counts for Meta as requested.
Known residual (out of core)
Terminal-asks path can still consult a probe sample for UX; it must not be treated as clear-proof. Track under #2662 / follow-up if it still drives a clear.
Test plan
bun test hub/src/sync/syncEngineArchiveSession.test.ts hub/src/sync/sessionChildExited.test.ts hub/src/sync/liveWorkByGeneration.test.ts(77 pass)Made with Cursor