Repository navigation
feat(orchestration): deliver worker results to a structured chat coordinator - #22631
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — three test-strength suggestions inline.
Reviewed changes
Read all 20 changed files across the 7 commits at 3d12695 against base brennanb2025/d3-cli-injection (51f9685).
- Handle-less coordinator delivery —
handleLessCoordinatorSessionIdresolves a Run's coordinator fromcoordinator_actoronly whencoordinator_handleis null, so a chat coordinator'srun:mailbox now reaches the session instead of falling between the two lanes. session:<id>recipients —readSessionRecipient/refuseUndeliverableSessionRecipientmake any reachable session addressable, reusing the existingsession_caller_*codes and storing atsession:<id>before pointing it as a turn.- Wake on eviction — the pointer lane takes a transient
host.holdaround each attempt and releases it infinally, resuming a chat the release clock evicted and handing it back afterwards. - Idle-edge redrive —
onStructuredSessionStatusForMailretries parked mail and re-derives the Runs plus direct mailbox a session owns on every non-working status edge, host-wide rather than per-dispatch. - Terminal-view ownership — a terminal view speaks for its session: the mailbox owner takes the session's Run/Dispatch, and the delivery target resolves the PTY the write gate binds to that session.
- Shared session rules —
structured-session-mail-address.tscentralizes reach, delivery view andsessionOrchestrationIdentity, consumed by both the caller resolver and mail delivery. - Worker preamble settlement —
sendStructuredWorkerPreamblewaits out apendingfirst answer viawaitForSendSettlementinstead of discarding a worker whose turn had begun.
I traced the wake/hold pair against the real StructuredAgentSessionHolds and release clock (resume works, the holder is always removed, release lands after send, and an active turn re-arms the clock rather than evicting), and audited the visibleSessionIds writers (a released lease does not remove the id, so a backgrounded or non-active-workspace chat stays reachable). The remaining notes are about test strength, not production behavior.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| { dispatchState: 'accepted', reason: null } | ||
| ) | ||
| ) | ||
| ).resolves.toBeUndefined() |
There was a problem hiding this comment.
This asserts the resolved outcome but never that waitForSendSettlement was awaited, so a pending → return short-circuit (claiming delivered before the provider echo) would also resolve undefined and pass. A toHaveBeenCalledWith(sessionId, 'c1') assertion on the host's settlement method is what the test name promises.
| await host.flushStreamedEvents(COORDINATOR) | ||
|
|
||
| await finishWorker(taskId) | ||
| await new Promise((resolve) => setTimeout(resolve, 20)) |
There was a problem hiding this comment.
The fixed 20 ms sleep is the only thing separating "retained mid-turn" from "folded into the running turn" — if the pointer send lands just after this check, the test still ends green with two turns, and the assertion at line 417 cannot tell the difference. Synchronize on a delivery marker (or assert the pointer is still parked) instead of wall-clock.
3d12695 to
a7f58f3
Compare
There was a problem hiding this comment.
Important
The new pointer constant is a POSIX-only shell expansion applied to every structured session, including Windows where it is shell-invalid. It is anchorable, so the detail lives inline.
Reviewed changes
Re-reviewed the delta since the prior pullfrog review (3d12695). The branch was rebased onto #22568 (c0767e101a), rewriting SHAs, so the net change is one commit, a7f58f3, plus #22568 dropping out of the PR diff.
- CLI named by its env var in the pointer turn — added
STRUCTURED_SESSION_CLI_COMMAND = '"$ORCA_CLI_COMMAND"'and pass it from the structured pointer lane, so a login shell that rebuildsPATH(Codex'szsh -lc) cannot reroute a bareorcato a global install. formatMessagePointerwidened — itscliCommandparameter now acceptsOrchestrationCliCommand | typeof STRUCTURED_SESSION_CLI_COMMAND; the PTY lane's resolved command and the default are unchanged.- Integration test updated — the real-host test's
POINTERregex and the peer-chat assertion now expect the env-var form.
The three open threads from the prior review (the eviction-retention test's missing wake assertion, the preamble test's missing waitForSendSettlement assertion, and the fixed 20 ms mid-turn discriminator) are unchanged by this commit and left open.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
a7f58f3 to
1c08143
Compare
There was a problem hiding this comment.
Important
The pointer now renders the Windows form for Codex, but the win32 + Claude arm still assumes Git Bash unconditionally — an assumption Orca's own Claude hook code does not make.
Reviewed changes
Re-reviewed the delta since the prior pullfrog review (a7f58f3): three commits (a520e9b8f2..1c08143) across 12 files, after the branch was rebased onto #22568.
- Per-shell pointer invocation — the fixed
STRUCTURED_SESSION_CLI_COMMANDconstant becamestructuredSessionCliInvocation({ platform, provider }); the structured pointer lane reads the provider off the session record and now renders& $env:ORCA_CLI_COMMANDfor Windows Codex alongside the POSIX form. - Session recipients addressed where their
checkreads — asession:<id>or bare-id recipient for a structured worker now resolves to the worker's own handle/Dispatch mailbox (sessionOrchestrationIdentity().address) instead of thesession:<id>mailbox itschecknever reads. - Released-lease caller wording — a released lease now refuses as "is not running right now … retry then" rather than "has ended", matching the fact that mail can revive it.
- Idle-edge redrive wiring pinned — a new test pins the runtime's own
onSessionStatusChanged→onStructuredSessionStatusForMailline, which the integration test's own callback had previously masked.
I traced the worker-address change through resolveBareOrchestrationRecipient (it reaches the Dispatch branch via the worker's paneKey, and the flagless check reads both the handle and Dispatch mailboxes), and confirmed the 42 tests in the four touched suites pass.
ℹ️ Nitpicks
SessionRecipient.actor(session-recipient.ts:28) is written but never read —recipient-routing.tsandrefuseUndeliverableSessionRecipientconsume onlysessionId.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one design question in the body and one stale comment inline.
Reviewed changes
Re-reviewed the delta since the prior pullfrog review (1c08143): six commits across 18 files. This run covers the /clear adoption path, the pointer-eligibility rework, and the wake diagnostic.
/clearadoption —adoptClearedPredecessorMailrebinds a cleared predecessor's Runs to the successor through the ordinarybindRun(generation bump, fenced deliveries, coordinator-mail reroute) and re-addresses its unread direct mail withdelivered_at = NULL;runStructuredConversationCommandreports the replacement at the commit, and the runtime redrives the successor's mail at that edge and on every idle edge.- Pointer eligibility reworked — the "an unacknowledged batch exists" latch is gone. The lane now excludes the batch the reader already holds, points newer mail, and names
--ack <deliveryId>so the reader can release the held batch and reach the new mail. pendingcounts as pointed — an admitted-but-not-yet-echoed send now marks the rows delivered (structuredDispatchDeliveredreturns true forpending);unknownstill retains.- Wake diagnostics — a
host.holdthat cannot resume the session now logs the reason instead of failing silently. - Test budgets — coordinator-mail waits use a 10s budget.
I traced the eligibility change through check (it returns read = 0 rows regardless of delivered_at, so marking delivered never hides mail from a reader), confirmed getOrCreateMailboxDelivery only ever creates deliveries for run:/dispatch: handles (so the named --ack always reaches a check path that supports it), and verified runBoundToCoordinator restricts adoption to handle-less bindings.
ℹ️ Run mail pointed at a /clear predecessor is not re-pointed at the successor
The direct-mail half of the adoption deliberately resets the pointer fact (delivered_at = NULL) because "its old pointer, if any, went to a session nobody runs". The Run half does not: bindRun bumps the generation and fences outstanding deliveries, but leaves delivered_at set on the Run mailbox's rows. Pointer eligibility is delivered_at IS NULL, so a worker_done that was pointed at the predecessor but not read before the clear stays unprompted on the successor — the successor's idle-edge deliverPendingMessagesForHandle('run:<id>') selects nothing. The result is still readable with an explicit check --run <id>, but nothing tells the new coordinator it is there. Raising to confirm the window is intentional/accepted rather than an omission.
Technical details
# Run-mail already pointed at the predecessor is not re-pointed to the successor
## Affected sites
- `src/main/runtime/orchestration/structured-session-mail-target.ts:131-145` — `adoptClearedPredecessorMail` rebinds each Run via `bindRun`, then re-addresses *direct* mail; no step resets `delivered_at` on the Run mailbox.
- `src/main/runtime/orchestration/db/runs/run-binding.ts:119-160` — `bindRun` bumps `consumer_generation` and calls `fenceUnacknowledgedMailboxDeliveries`, but only touches the `deliveries` table, not `messages.delivered_at`.
- `src/main/runtime/orchestration/db/messages/direct-mailbox-routing.ts:189-200` — the direct-mail path *does* set `delivered_at = NULL`, which is the inconsistency.
## Why it matters
`selectOrchestrationPointerBatch` selects via `getUndeliveredUnreadMessages` (`delivered_at IS NULL`, `read = 0`). The structured pointer lane calls `markAsDelivered(staged)` as soon as `host.send` returns accepted/pending — before the provider turn reads the mail. If the pointer turn settles without the chat running `check`, then `/clear` replaces the session, the row survives the rebind as `read = 0, delivered_at` set, and the successor is never pointed at it.
## Required outcome
Decide whether a Run result pointed at a cleared predecessor should be re-pointed at the successor, matching the direct-mail path. If so, reset `delivered_at` (e.g. `markAsUndelivered`) on the rebounded Run's unread messages during adoption, before `structuredSessionOwnedMailboxes` re-derives the mailbox.
## Open questions for the human
- Is the pointer turn's read effectively guaranteed before `/clear` is admitted (making the window unreachable), or is this an accepted gap?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| // A pending send is not an acknowledgement, so the mail is retained and retried on every edge | ||
| // until the host confirms it: before the echo, and again at the turn's idle edge. |
There was a problem hiding this comment.
This comment describes the pre-delta behavior. Now that pending is a pointed state (structuredDispatchDelivered), the pointer's send marks the rows delivered immediately, so the retries at lines 356-358 are no-ops rather than the retention this comment claims to exercise. The assertion still holds; only the rationale is stale.
| // A pending send is not an acknowledgement, so the mail is retained and retried on every edge | |
| // until the host confirms it: before the echo, and again at the turn's idle edge. | |
| // The pointer marks the rows delivered as soon as the host admits the turn, so these retries | |
| // are idempotent no-ops; the test pins that they never produce a second pointer. |
ca9b471 to
6abb9d9
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — one design tradeoff in the body worth confirming.
Reviewed changes
Re-reviewed the 4 commits on top of the prior pullfrog review (ca9b4718): the pending-settlement give-back, the /clear observer guard, and their tests.
- An admitted pointer is given back when its turn never settles —
StructuredMailboxPointerHost.sendnow returns asettlementpromise forpending(built fromwaitForSendSettlement), andsettlePendingPointerdeletes this send's operation row and callsmarkAsUndelivered+retainon any verdict other thanaccepted. The row is dropped so the re-point mints a fresh id instead of replaying the recordedunknown, which would land no turn at all. - A committed
/clearno longer fails on a throwing replacement observer —runStructuredConversationCommandwrapsonConversationReplacedin try/catch and warns; the idle edge re-derives adoption, so bookkeeping behind an already-committed clear cannot turn it into a failure. - Tests — provider death before the echo now gives the result back and re-points it once on the idle edge; a chain of clears is adopted fully and the predecessor's
checkreads nothing of the successor's mail; the host's settlement mapping covers echo, provider death, timeout, and a disappeared send.
I traced the give-back against the real DB semantics (getUndeliveredUnreadMessages requires delivered_at IS NULL; markAsUndelivered guards read = 0; resolveStructuredPointerOperation reuses an id only for the same mailbox+session+batch) and the real trigger paths (deliver/inFlight, onJournalActivity, the idle edge). The message-row half of the give-back has no operation_id guard, but delivered_at exclusivity plus inFlight serialization keeps a message out of two staged batches, so it cannot clobber a newer pointer's claim. structured-mailbox-pointer-delivery.test.ts, structured-mailbox-pointer-host.test.ts, and structured-conversation-command.test.ts pass (55 tests).
ℹ️ An ambiguous pending settlement can produce a second pointer turn
settlePendingPointer now gives the batch back on any non-accepted verdict, which is the right call for a dead provider — but unknown also covers the 30s waitForSendSettlement timeout, where the turn may still be queued and later echo accepted. By then the operation row is gone and the rows are undelivered again, so the accepted echo's journal edge mints a new id and sends a second pointer turn for the same mail. It is rare (a normal echo is sub-second, and the PR notes legacy clients already abandon at 15s) and strictly better than the silent strand it replaces, but the coordinator can now receive a duplicate "you have mail" turn. Confirming that is acceptable; if not, giving back only on a definitive verdict (session close, not timeout) would bound it.
Technical details
# Duplicate pointer turn on an ambiguous pending settlement
## Affected sites
- `src/main/runtime/orchestration/structured-mailbox-pointer-delivery.ts:284-325` — the `pending` branch marks rows delivered and defers; `settlePendingPointer` deletes the op row and `markAsUndelivered`s on any non-`accepted` verdict, including the timeout-derived `unknown`.
- `src/main/runtime/orchestration/structured-mailbox-pointer-host.ts:135-154` — `settlement` maps an `undefined` result (the 30s timeout) to `'unknown'`.
- `src/main/native-chat/agent-session-wire/structured-agent-session-send-settlement.ts:84-88` — the timeout resolves the waiter `undefined` even though the submission is still live; a later `publish` would have resolved it `accepted`, but the waiter is already removed.
## Why it matters
`getUndeliveredUnreadMessages` gates on `delivered_at IS NULL`. After the give-back, the accepted echo publishes a journal item → `onJournalActivity` → `deliver` finds the rows selectable again and mints a fresh operation id (the row was deleted), dispatching a second provider turn for the same batch. The mail is not lost or double-read; the cost is a redundant turn in the coordinator chat.
## Required outcome
Decide whether the duplicate turn on an ambiguous `unknown` is acceptable. If not, distinguish a timeout/waiter-cap `unknown` from a definitive dead-session verdict and only give back in the definitive case.
## Open questions for the human
- Is the duplicate turn acceptable given it replaces the prior silent strand, or should the give-back be limited to definitive failures?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
2d9dc67 to
fef6854
Compare
6abb9d9 to
a32a526
Compare
fef6854 to
3af56b1
Compare
e1e205d to
55692e7
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — the
/clearredesign is clean; two informational notes below.
Reviewed changes
Re-reviewed the three commits since the prior pullfrog review (55692e7e6b), which replace /clear continuity handling and add a restart-recovery path.
/clearcontinuity is derived, not rewritten —structuredSessionLineageresolves any session of a clear chain to its lineage root (the conversation's stablesession:<root>address) and its live end;sessionOrchestrationIdentitytakes the actor from the root and the worker identity from the live session. Runs, direct mail and the caller identity all stay under one address with nothing rewritten at the clear, andadoptClearedPredecessorMail,readdressUnreadSessionMailand theonConversationReplacedwiring are removed.- Restart recovery for structured pointer claims —
releaseRestoredStructuredPointerClaimsruns when the orchestration DB opens: for each durable pointer-operation row it finds that row's stamped batch by fingerprint among the mailbox's pointed-unread rows, marks it undelivered and drops the row, so a claim whose settlement waiter died with the previous process is re-pointed by the normal undelivered scan. - Idle-edge redrive opens the DB itself —
structuredSessionIdleEdgeMailboxescallsgetOrchestrationDb()so a restarted chat's idle edge redrives mail stored before the restart; a DB that cannot open is logged rather than skipped silently.
ℹ️ The /clear section of the PR description describes the mechanism this delta removed
The PR body is the design doc here, and §6 still explains /clear continuity as a rebind of Runs plus a re-address of direct mail, driven by an onConversationReplaced observer. All three were removed by 060790e567, so a reviewer reading the body against the code will look for machinery that is gone.
Technical details
# Stale PR description for `/clear` continuity
## Affected sites
- PR body §6 "A `/clear`-replaced coordinator's Runs and mail follow the new session" — describes `bindRun` rebinding and `readdressUnreadSessionMail`, both removed.
- PR body §6 "Two edges drive it" — names the clear's commit (`onConversationReplaced`) and the successor's first status publication; the observer and its runtime wiring are gone.
- PR body "Testing" and "Ablations" — list `/clear`-predecessor, chain-adoption and `structured-conversation-command.test.ts` replacement-observer cases that no longer exist.
## Required outcome
- §6 should describe the lineage-derived conversation address (root actor for the address, live session for the delivery target, nothing rewritten at the clear); the Testing/Ablation lists should drop the removed cases.ℹ️ Restart recovery assumes one outstanding pointer claim per mailbox
The recovery releases only the batch whose fingerprint matches the single operation row per mailbox. Because that row is an upsert keyed by mailbox, a newer batch pointed while an earlier one is still pending replaces the earlier row, and the earlier batch is then not released on restart. Worth confirming this window is accepted (it needs process death inside the pending interval).
Technical details
# An earlier pending batch is not released when a newer batch overwrote its operation row
## Affected sites
- `src/main/runtime/orchestration/structured-pointer-claim-restore.ts:28-34` — iterates `listStructuredPointerOperations()` (one row per `mailbox_handle`) and releases only the batch whose fingerprint matches that row.
- `src/main/runtime/orchestration/db/messages/structured-pointer-operation-store.ts:21-41` — `putStructuredPointerOperation` upserts on `mailbox_handle`, so a newer batch overwrites the earlier row.
- `src/main/runtime/orchestration/structured-mailbox-pointer-delivery.ts:283-297` — a `pending` send marks rows delivered and keeps the op row; a later batch on the same mailbox mints a new id and overwrites it (`resolveStructuredPointerOperation`).
## Why it matters
If batch X is admitted `pending` (rows `markAsDelivered`ed, op row = X) and batch Y is pointed before X settles, Y's `putStructuredPointerOperation` replaces the row. On restart `getPointedUnreadMessages` returns `[X, Y]`, `stampedBatch` matches only Y, and X stays `delivered_at`-stamped with no row: the undelivered scan never re-points it (it stays readable via an explicit `check`). In-process this is fine — `settlePendingPointer`'s `markAsUndelivered(staged)` is not guarded by the op-row check — so only process death inside the pending window loses X.
## Required outcome
- Confirm whether a single row per mailbox is the intended scope. If earlier batches must also be recovered, note that "stamped rows with no matching row" cannot be released wholesale: an accepted-but-unread batch legitimately has no operation row.
## Open questions for the human
- Is the multi-batch window accepted, or should each batch's claim be stored separately?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the one follow-up commit (e79d321f0a) on top of the prior review.
- The idle edge no longer creates the orchestration database — a new
getExistingOrchestrationDb()opens the database only when its file already exists (or it is already open), andstructuredSessionIdleEdgeMailboxestakes() => OrchestrationDb | null, returning no mailboxes when there is none. A profile that never orchestrated stays without a database file and logs nothing; failing to open an existing file is still logged. - Tests updated — the restart test seeds a real database file under a fake
userDataand asserts the idle edge opens it; a new test pins that no file is created and nothing is logged.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
0ef7f31 to
3f5f798
Compare
e79d321 to
92ecd41
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the one commit on top of the prior pullfrog review (e79d321f0a). The branch was rebased, so the new commit is isolated by subject rather than ancestry.
- A handle-less Run's coordinator actor now counts only at the Run's current generation —
handleLessCoordinatorSessionIdreads the coordinator throughcurrentRunCoordinatorActor, so an actor an older binary's rebind or unbind left behind no longer routes the Run's mail. This is the same rulerunCoordinatorKey,runBoundToCoordinator,runsBoundToCoordinatorand the v42 backfill already apply, so delivery and ownership can no longer disagree about which session a Run is bound to. - Tests pin both the read and the write —
structured-session-mail-target.test.tsbumpsconsumer_generationand asserts therun:mailbox stops resolving (this case fails against the pre-commit raw-actor read);structured-chat-coordinator-mail.test.tsasserts a cleared chat'srun-create/run-usestore the conversation's root actor at the Run's current generation.
I traced the write paths (createRun writes coordinator_actor_generation = 1 beside consumer_generation = 1; bindRun always writes the actor at consumer_generation or consumer_generation + 1; the backfill stamps consumer_generation) and confirmed no other production reader consumes the raw coordinator_actor column.
Four earlier Pullfrog threads remain open (they are test-strength/design notes, unchanged by this commit) and are not re-raised here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
3f5f798 to
00f4525
Compare
92ecd41 to
34d9401
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the one commit on top of the prior pullfrog review (92ecd41040, rebased so SHAs differ): 34d9401a80, which carries the base branch's "Orca session id" rename into this PR's coordinator-delivery code.
- A session's orchestration identity is now a bare Orca session id —
sessionOrchestrationIdentityreturnsorcaSessionId(the lineage root's) and derives itssession:<id>address throughformatOrcaSessionAddress;hasLostStructuredWorkerIdentityreadsidentity.orcaSessionIdinstead of parsing an actor string. - Coordinator resolution reads the renamed column —
handleLessCoordinatorSessionIdreturnscurrentRunCoordinatorOrcaSessionId(run);structuredSessionAddressTargetandsession-recipientuseparseOrcaSessionAddress/isOrcaSessionIdin place of the removed actor codec. - Session ids from records and PTY bindings are validated before becoming identities —
sessionMailOwner,structuredSessionMailReachandstructuredSessionOwnedMailboxesguard withisOrcaSessionId;bindDeclaredCalleracceptsformatOrcaSessionAddress(caller.sessionId). - Tests updated — the touched suites use the
testOrcaSessionId/formatOrcaSessionAddressfixtures and assert thecoordinator_orca_session_idcolumn.
I checked the rename against the removed orchestration-actor codec: isOrcaSessionId keeps the same isAgentSessionId predicate and terminal-handle refusals, and parseOrcaSessionAddress/formatOrcaSessionAddress are equivalent for session:<id> at every call site. No production file still references the deleted module or an actor field. The four earlier Pullfrog threads remain open and are unchanged by this commit (test-strength and Windows-Claude-shell notes), so this is not an approval.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
00f4525 to
9d02ccc
Compare
34d9401 to
5183dd5
Compare
9d02ccc to
52774a0
Compare
5183dd5 to
f75fbe4
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe change adds Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue remains in the supplied evidence; the change is mergeable after normal checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Comments Outside DiffThese findings could not be posted inline.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the three commits since the prior pullfrog review (5322945058 at 5c47b2546f), after the branch was restacked onto main (2ca4ecbc61).
- A
/cleared chat may restate its address —sessionAddressForHostnow lets asession:<id>that is not this session's own spelling pass the CLI entry guard and be forwarded as the caller param; the host'scanonicalOrcaSessionId/resolveOrchestrationPartycheck accepts the lineage root or refuses a stranger withconsumer_fencedbefore any effect. A sessionsendalso stops carrying an inheritedsenderPaneKey. - Mail reaches a chat whose agent is not running through the plain send —
mainremoved the host'shold/release, so the pointer lane'swakestep and its log are deleted; an accepted send starts the stopped agent itself, and a non-acceptedverdict is still given back. - Test adaptation — the coordinator-mail fixture awaits the now-async
journalSnapshotand waits for the held turn's handover, so the mid-turn case no longer races the provider echo.
The prior review's structured-session-mail-target.ts:70 finding (a cleared worker's live successor unreachable once the predecessor is released) is untouched by these commits and remains open, so this is not an approval.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…of respawning it for mail A pointer whose provider died before echoing it is given back. The death's own status edge then redrove the mail, and since a send starts the agent, a provider that died on every turn was restarted about once a second for as long as the mail was unread. The pointer lane now reads, on every attempt, whether the session's latest send never ran because its provider exited or could not start, and holds the mail until a later send runs. Every trigger passes through that gate: a parked retry, the idle edge's re-derive and new mail. A rejection for any other reason still points at the next idle edge.
…ing every failure kind A start refused for a reason only the person can fix (not signed in, history too large, a managed-account problem) or one the host stopped because it never came is held like a failed start: the mail waits for the person's next message, which also retries the start. An account switch still in progress is transient, so it stays ungated and the first edge after the switch settles points the mail. One exhaustive record places every rejection kind, so a new kind does not compile until it is placed.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the two commits since the prior pullfrog review (5346464757 at 1719b18e1b): the new gate that holds a structured session's mail while its latest send never ran.
- A dead provider is left stopped instead of respawned —
latestSendHoldsMailreads the session's latest submission (sorted bysubmittedAt): anunknowndoubt whose reason isprovider_exited_before_acknowledgement(the marker a real provider exit writes), or a rejection inREJECTION_HOLDS_MAIL(a start that failed, or one that needs the person), holds the mailbox.readPointerGateFactsfolds that into the pointer lane's gate as the newawaiting-next-turnretain, so a death's own status edge no longer re-points the mail and restarts the provider. - Every failure kind is placed —
REJECTION_HOLDS_MAILissatisfies Record<SubmissionRejectionKind, boolean>, and the host test asserts one behavioral expectation perAGENT_SESSION_FAILURE_KINDSentry, so a new kind cannot compile until it is classified. Only a provider death or a start that needs the person holds; a healthy agent's refused write (queueFull,writeFailed, …) still points at the next idle edge. - Tests — the integration suite pins the no-respawn window (a fixed 1.5s window with a provider that dies before every echo), a start the person must fix (nothing retried before the next message), an account switch settling on its own, and a healthy agent's refused write still being pointed.
The prior review's structured-session-mail-target.ts:70 finding (a cleared worker's live successor is unreachable once its predecessor lease is released) is untouched by these commits and remains open, so this is not an approval.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ad of gating on the failure reason A pointer send that failed was given back and re-sent under a fresh operation id, so every status edge after a provider death was a new send that started the provider again. A reason-string gate held some of those deaths, but missed a Codex crash with turn/start in flight (it settles unknown with the connection's error), latched all later mail after one transient death, and did not keep a user's Stop. A retry now reuses the mailbox's operation id, which the host answers by replaying the recorded verdict without reaching the provider. The id is re-minted only for new mail, after a later send ran, for a row an earlier process left, or once an account switch settles. Rows are stamped only on accepted, so the admitted-stage claim, its give-back and the restart claim-release scan are gone.
…e next status edge, too
…s a terminal's The chat lane pointed newer mail past a batch its reader had checked and not acknowledged, while the terminal lane skips a mailbox until that batch is acked. A chat now waits for the ack the same way a terminal does, and the lookup that let the chat lane filter the held batch out is removed.
…ist --run would drop The CLI entry lets a `session:` address that is not the session's own spelling through for the host to place, but gate-list and task-list send no caller when --run names the Run, so `--from session:<other>` was silently ignored. With --run they now refuse it (consumer_fenced) before any request, the same as a conflicting terminal handle.
… first-turn workspace rename A structured session's status callback redrives its mail before the first-turn workspace auto-rename, outside any try, so a database error there threw past the rename. The redrive now logs its failure and returns.
…the send branch narrows
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the six PR-authored commits since the prior pullfrog review (5348746912 at 4c7e5aec48), plus a merge of main and a lockfile restore.
- A failed pointer now retries under its own operation id —
decideStructuredPointerAttemptreplaces the reason-stringlatestSendHoldsMailhold and the pending-settlement/claim-restore machinery withmint/reuse/stamp/park, keyed on the mailbox's durable row, its batch fingerprint and the session's recorded sends. Areuseresend replays the ledger's recorded verdict (sendPlanrecovers or replays and never reaches the provider), so a provider that dies on every turn is not respawned and a user's Stop stays stopped, while genuinely new mail (a new batch) is pointed normally. Rows are stamped only onaccepted. - A chat waits for the ack like a terminal — the held-batch exclusion is removed and
hasOutstandingMailboxDeliveryrestored, so a chat that rancheckwithout acking is not pointed at newer results until it acks, matching the PTY lane. gate-list/task-list --runrefuse a session address they would otherwise drop —refuseUnsentSessionAddressthrowsconsumer_fencedbefore any request when asession:<id>that is not the caller's own spelling accompanies--run; the shared error factory is extracted.- A failed idle-edge redrive no longer skips the first-turn workspace rename — the redrive body is wrapped in a try/catch that logs and returns.
- Type narrowing —
stampandparkget separate variants instead of a shared union member.
I traced the retry path through sendPlan/resolveAgentSessionReplayOutcome (a reused id with a failed or unknown outcome refuses or replays and never dispatches a second turn; the ledger's 48h replay window bounds this) and the restart path through the journal crash boundary (surviving submissions settle to unknown, so a pending-at-crash row is re-minted exactly once at the new lane). The focused suites pass locally: 196 unit tests plus the 20-test real-host coordinator-mail suite.
The earlier structured-session-mail-target.ts:70 finding (a cleared worker's live successor unreachable once its predecessor lease is released) is untouched by these commits and remains open, so this is not an approval.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…2025/d4-coordinator-delivery
| const ranSince = submissions.slice(index + 1).some((entry) => entry.dispatchState === 'accepted') | ||
| const leftByEarlierProcess = row.minted_at_ms < input.laneStartedAtMs | ||
| const accountSwitchSettling = | ||
| sent.dispatchState === 'rejected' && sent.rejection?.kind === 'accountSwitchInProgress' | ||
| return ranSince || leftByEarlierProcess || accountSwitchSettling ? 'mint' : 'reuse' |
There was a problem hiding this comment.
Rejected pointers cannot retry When a pointer send is rejected while the session is otherwise healthy, the next journal edge reuses the same operation ID. The host replays the rejection without sending another turn, leaving the worker result unpointed unless new mail changes the batch or another send runs.
Knowledge Base Used: Agent workspaces and sessions
… cannot strand it A pointer row whose id had no submission in the journal was always resent under that id, before any re-mint test ran. After a rewind rebuilt the journal, or a send refused before it was recorded aged past the host's 24h admission window, the mail was held forever: neither the person's next turn nor a restart pointed it again. The re-mint tests now run first. "The agent has run since" is any accepted send submitted after the row was minted; "an earlier process minted it" is a row whose id this lane did not send, not a wall-clock comparison a clock step could fool; and a row the host never recorded is re-minted once it is too old for the host to admit. The account-switch exception is gone: nothing tells the lane when a switch ends, and each outside edge during one added another pointer and failure to the chat. A parked pointer now retains as turn-unsettled.
…t or task-list --run names 5f753af refused any `--from session:<x>` beside --run that was not the session's own spelling, which also refused a /clear-ed chat restating its lineage root, an address the host accepts everywhere else. The CLI now sends that address with --run, and the host's declared caller check accepts the root and refuses anyone else (consumer_fenced) before any effect.
| const ranSince = submissions.some( | ||
| (entry) => entry.dispatchState === 'accepted' && entry.submittedAt > row.minted_at_ms | ||
| ) | ||
| const tooOldToAdmit = | ||
| !sent && input.now - row.minted_at_ms > AGENT_SESSION_MAX_NEW_OPERATION_AGE_MS | ||
| return ranSince || !input.mintedByThisProcess || tooOldToAdmit ? 'mint' : 'reuse' |
There was a problem hiding this comment.
Account switch leaves mail unpointed When a pointer send is rejected because an account switch is in progress, this code reuses its operation ID on later attempts. The host replays the rejection instead of sending a new pointer. Finishing the switch does not itself add an accepted send, so the coordinator receives no pointer until someone sends another message.
Knowledge Base Used: Agent workspaces and sessions
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the two commits since the prior pullfrog review (5350174468 at 1581a50582), plus a merge of main.
- A held pointer is re-minted from facts that cannot strand it —
decideStructuredPointerAttemptnow runs its re-mint tests before the "reuse the row's id" fallback: a peer turn accepted after the row was minted, a row this process did not send (sentOperationIds/sentByThisProcessreplaces theDate.now()lane-start comparison, so a clock step cannot fake it), or a row the host never recorded and is now past its 24h admission window all mint a fresh id. A recorded failure still replays under its id, so a provider that dies on every turn is not respawned and a Stop stays stopped. TheaccountSwitchInProgressmint exception is removed, and a parked pointer now retains asturn-unsettled. gate-list/task-listwith--runforward a session caller to the host — the client-siderefuseUnsentSessionAddressrefusal is deleted;runScopedSessionCallersends asession:<id>that is not the caller's own spelling with the request, and the host'sbindDeclaredCalleraccepts a/clearlineage root and refuses anyone else withconsumer_fencedbefore any effect.- Tests — new unit cases pin each mint boundary (including a wall-clock step and the exact 24h edge), and real-host cases cover a rewind-dropped send and a host-unrecorded send aged past admission. The CLI test now asserts the address is forwarded; the runtime test pins root-accepted/stranger-refused for both list methods.
I traced the 24h boundary against the host ledger's agent_session_operation_expired check (both use > on the same id-embedded timestamp, so they flip together), and the declared-caller path against resolveOrchestrationSessionCaller/bindDeclaredCaller (the forwarded session: address is canonicalized before resolveRunScope, which would otherwise ignore a caller for an explicit --run).
The earlier structured-session-mail-target.ts:70 finding (a cleared worker's live successor is unreachable once its predecessor lease is released) is untouched by these commits and remains open, so this is not an approval.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…rd clock step cannot re-mint it every edge
| minted_at_ms: args.submissions.reduce( | ||
| (latest, entry) => Math.max(latest, entry.submittedAt), | ||
| now | ||
| ) |
There was a problem hiding this comment.
Clock changes can strand pointers If the clock moves backward, an earlier journal submission can have a timestamp later than a new pointer operation. This code saves that future timestamp as the operation’s mint time. A user turn that actually runs afterward can then fail the retry check, so a rejected or unknown pointer keeps replaying its old operation ID instead of sending a new pointer. The mail remains unpointed until the clock catches up. The timestamp mismatch can also delay replacement of an unrecorded operation after its ID expires.
Knowledge Base Used: Agent workspaces and sessions
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the one commit since the prior pullfrog review (5350502521 at ed12df519e): a journal-clock correction to how a structured pointer's operation row is dated.
- A pointer's operation row is dated on the journal's clock —
resolveStructuredPointerOperationnow writesminted_at_ms = max(now, every submission.submittedAt)instead of barenow. An accepted turn recorded before the pointer can therefore no longer satisfyranSinceafter a backward clock step, which previously re-minted the id on every status edge. - Test — a fake-
Datecase with an accepted person turn timestamped before the step asserts the pointer keeps a single operation id across three edges; it goes red pre-fix, because each edge mints a new id.
The earlier structured-session-mail-target.ts:70 finding (a cleared worker's live successor is unreachable once its predecessor lease is released) is untouched by this commit and remains open, so this is not an approval.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status (head
|

What this changes for you
Who hits it: anyone who runs Orca orchestration from a native (structured) Claude or Codex chat, with the chat acting as the coordinator that starts workers and waits for their results.
Before: a chat coordinator could create a Run and start workers, but when a worker finished and sent its
worker_done, nothing told the chat. The result sat unread in the chat's mailbox until you noticed and told the chat to runorca orchestration check. A terminal coordinator in the same situation is told automatically.orca orchestration check …") as a real turn, runscheckby itself and reports the resultsession:<id>/clearNot affected: terminal agents (their delivery code is unchanged), SSH and WSL sessions (a chat's mail lane is local only; mail to a session on another host is refused), mobile, and stored data (no schema change).
Known gap, not fixed here: if the one start attempt fails, the chat does not show the announcement or the failure notice; only the tab's red "Failed" dot shows it. That is an existing display rule on
main(a refused message is hidden unless this window sent it, and the failure line folds into the previous finished turn). It already applies to structured workers today; this PR makes it visible on a chat you watch. It needs a renderer change and is a separate follow-up.The plan this PR belongs to
Six steps let a native chat take part in Orca orchestration the same way a terminal agent does:
What Changed
formatMessagePointerwith the same local CLI name (localOrchestrationCliCommand:orca, ororca-devin a dev build).structured_pointer_operationsrowmainalready had). Sending again under the same id makes the host replay the recorded result without touching the agent, so a retry of a failed attempt cannot start the agent again. A new id is minted only when:Mail is marked announced only when the host accepts the send.
checkbut has not acknowledged, it is not announced newer mail, exactly like a terminal coordinator.session:<id>is a valid mail address for a chat. Live or stopped chats accept it; a closed chat, an unknown id, a provider's own id, or a session on another host is refused with the existing refusal codes./clear./clearcreates a replacement session. The id hookcanonicalOrcaSessionId(whichmainleft as a no-op with a comment that lineage plugs in there) now walks the recorded replacement chain back to its first session, so the cleared chat, its Runs and its mail keep one address. A cleared structured worker keeps acting as its worker. The CLI forwards a restatedsession:address to the host, which accepts the chat's own lineage and refuses anyone else before any effect (consumer_fenced).Why
checka terminal agent uses.checkreplay the old batch anyway. If agents skipping the acknowledgement turns out to be a real problem, it should be fixed once, for both lanes./clear:/clearalready records a replacement session onmain. Deriving the address from that chain at read time stores nothing new and rewrites nothing.Linked Issue
Part of the orchestration-for-native-chats plan above; no separate issue.
Visual Proof
Claude: live in a dev build on a separate Mac with a real Claude agent, hidden window driven over the DevTools protocol. Before is
mainatc49388cd339, after is this PR at0105f570641, same prompt in both. Every worker was a native chat.Before: the coordinator's reply tells you to run
checkyourself, and 5.5 minutes after the worker finished the chat is unchanged; the result is still unread.After: about 0.05 s after the worker's
worker_done, the announcement arrives as a turn; Claude runscheck, reports the line counts, releases the worker and acknowledges the mail.Agent that cannot start: the coordinator's agent was stopped and set to fail every start ("not signed in"). When the worker finished, Orca tried exactly once; the start log stayed at one attempt at +1, +2 and +3 minutes. The chat shows only the red "Failed" dot (the known gap above).
After the agent could start again, "Carry on." ran and the held result was read and reported.
Stop: Stop pressed while the announcement was starting the agent; two minutes later nothing was re-sent.
Codex: the same check with a real Codex coordinator (hidden dev build with that Mac's own Codex login, before
mainatc49388cd339, after this PR at0105f570641, each with the unrelated open #23552 merged locally only for the test rig). Onmainnothing arrived in 6 minutes 20 seconds. With this PR, exactly one announcement was sent in the same second as the worker'sworker_done, and Codex rancheckby itself; no duplicate after a full app restart.Testing
New or changed tests (11 files), all passing at
0105f570641:structured-chat-coordinator-mail.test.ts(real session host, real journal and orchestration database, fake Codex app server): the coordinator gets exactly one announcement with the terminal text; an agent that dies on every start, at initialize, before acknowledging, with its turn start in flight, or after acknowledging, is started at most once across many status edges; a new worker result after a transient crash is announced once; Stop is kept; a restart re-offers once; a rewind that dropped the send, and a send the host never recorded that is past 24 hours, are both recovered after the next turn; not-signed-in and account-switch refusals add no extra rows over five edges.structured-pointer-operation-id.test.tsandstructured-mailbox-pointer-delivery.test.ts: the mint / reuse / stamp / park decision table, including a backward clock step.structured-session-mail-target.test.ts,orchestration-session-recipient.test.ts,orchestration-session-caller.test.ts,orchestration-session-caller-cli.test.ts: mail targets,session:<id>recipients and refusals,/clearlineage, and the CLI's caller forwarding includinggate-list --run/task-list --run.Each regression test added in review was run against the code before its fix and failed there (for example, the in-flight crash started the agent 3 to 4 times, and a backward clock step re-minted on every edge).
Checks:
tc:nodepasses at0105f570641,tc:cliated12df519e9(no CLI change after it);oxlintclean on changed files; no lockfile, schema or renderer changes.Not verified: Windows, Linux, SSH and mobile live runs; a live
/clearof a coordinator mid-run (covered by tests only).Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance.
/clearlineage; any other address is refused on the host before any effect.sendcarry readable messages./clearlineage lookup scans session records in memory on each call; cheap today, worth watching as records accumulate.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Checklist
/clearaddress work into its own PR is proposed in the review status comment)N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)