Skip to content

refactor(native-chat): give each structured dispatch state exactly one meaning - #20133

Merged
brennanb2025 merged 12 commits into
mainfrom
brennanb2025/simplify-dispatch-doubt-states
Sep 13, 2026
Merged

brennanb2025 merged 12 commits into
mainfrom
brennanb2025/simplify-dispatch-doubt-states

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When a message can't be sent, Orca now says which of two things happened — "it definitely didn't go" or "I genuinely can't tell" — instead of saying "I can't tell" for both. That matters because Retry is safe in the first case and dangerous in the second.

The critical change, in one sentence

Retry's safety stops depending on a list being correct, and starts depending on the state itself.

Before, every failed send landed in one state — unknown, "delivery in doubt" — and Retry consulted a lookup of reasons to decide whether re-delivering that particular unknown was safe:

dispatchState = 'unknown'
reason        = 'provider_write_failed: broken pipe'   <- allowlisted, re-delivery permitted
reason        = 'provider_exited_before_acknowledgement' <- not allowlisted, refused
reason        = 'host_restarted_before_acknowledgement'  <- not allowlisted, refused

That is a runtime judgement call standing in front of a duplicate-delivery hazard. It is only safe while the list is right, and nothing fails when somebody adds a new reason and forgets it.

After, the one case that was provably safe is not an unknown at all — a write the agent's input pump never took resolves rejected, because "provably did not happen" is what rejected already means. With that case gone, the allowlist has no entries left and is deleted. Retry's rule becomes unconditional:

Never re-deliver an unknown. No exceptions, nothing to look up.

Re-sending after a rejected is safe by construction rather than by permission: it goes out under a fresh client message id, so it is a new message and cannot duplicate an old one.

That is the whole change. A judgement call became a structural invariant. Everything below — the copy fixes, the mobile fixes — follows from the states now meaning one thing each.

What you see today vs after

Case A — the agent's input pipe breaks (agent crashed, was killed, restarted). The message provably never left your machine.

Today After
Banner "Message delivery is unconfirmed." "Message was not sent."
Second line provider_write_failed: broken pipe in red "Couldn't reach the agent. Your message was not sent — Retry to send it again."
Retry Refuses — nothing happens, forever Sends it as a genuinely new message

Today that red line is an internal identifier on your screen. There is nothing you can do with it, and the Retry button next to it is inert.

Case B — Orca genuinely can't tell (host restarted mid-send, ack lost). The agent may or may not have it.

Unchanged on purpose: still "Message delivery is unconfirmed.", still refuses to re-deliver. That refusal is the point — see Why.

On mobile. Today, a send whose outcome is unknown reports as sent: the composer clears your draft and the message looks delivered. After: it reports unknown, keeps your draft, and says "Delivery unconfirmed — check chat before retrying."

Why

Retry used to re-deliver messages that had already reached the model. In one measured session a single message reached the model five times. The root cause was fixed in #19863 (a 10-second timer that declared healthy sends "unconfirmed" — 25% of all sends tripped it). This PR fixes the state model underneath it.

unknown meant five different things, only one of which was real ambiguity. A one-entry allowlist then existed to teach Retry that one particular unknown was safe. That is a judgement call sitting in front of a duplicate-delivery hazard.

Moving the provable case to rejected deletes the allowlist and makes it an invariant: Retry never re-delivers an unknown, no exceptions to reason about. The asymmetry justifies being strict — refusing a legitimate retry costs you a retype; allowing a bad one silently puts a second copy of your message in the model's context, where you won't see it.

Four states, one meaning each:

state means
pending written, waiting for the agent to acknowledge
accepted the agent has it
rejected provably did not happen
unknown genuinely cannot tell

What changed in the code

  • A transport write the agent's input pump never took now resolves rejected instead of unknown.
  • The redelivery allowlist is deleted; performSend cannot re-deliver an unknown at all.
  • Rejection reasons split into the provider's own words (shown verbatim — "Claude does not support the image type .bmp" is the whole answer) and internal causes (never shown; replaced with copy you can act on).
  • Mobile reads the send's real state instead of treating any successful RPC as delivered, and keeps its operation id when delivery is unknown — reusing that id delivers if nothing landed and replays if something did, so it can't duplicate.
  • A refused worker-start preamble throws a typed code instead of prose a caller has to parse.

Review history worth knowing

A mid-review commit made mobile rotate its operation id on unknown, which host-side is a second dispatch — the exact defect this PR removes, reintroduced on another surface. It was caught, reverted, and the guard restored with a test that fails against the pre-fix code. The mobile send fixture was also replaced: it returned a shape that structurally could not express this bug, which is why the inversion passed review.

Testing

pnpm tc clean. Affected suites green; mobile src/session 160 files / 1511 tests. Every new test ablated — including an arm running the production file at the pre-fix commit with the new tests kept, which fails.

One pre-existing failure, claude-structured-real-cli.test.ts, verified to fail identically on plain main.

Visual proof

The only user-visible change is copy, tabulated above. Not run in the app — flagging that rather than claiming N/A.

Notes

…e meaning

`unknown` meant five different things. Only one of them was genuine
ambiguity.

A transport write that the provider's input pump never took is provably
undelivered -- which is what `rejected` already means. It was recorded as
`unknown` anyway, and a one-entry allowlist then existed solely to teach
Retry that this particular `unknown` was safe to re-deliver.

Collapsing that case into `rejected` deletes the allowlist and turns a
predicate into an invariant: Retry never re-delivers an `unknown`, with no
exception to reason about. The four states now each assert one thing --
`pending` written and awaiting, `accepted` the provider has it, `rejected`
provably did not happen, `unknown` genuinely cannot tell.

A fail-closed guard is the right default here because the asymmetry is
severe: refusing a legitimate retry costs the user a retype, while allowing
an illegitimate one sends the model a second copy of their message.

Also fixed, found while auditing every reader of `rejected`:

- The renderer printed `submission.reason` verbatim, so a broken pipe put
  the internal token `provider_write_failed: broken pipe` on screen in
  destructive red. The journal reason is unchanged -- it is the durable
  evidence and the transport-versus-content discriminator -- but the screen
  now gets copy that names the cause and says the message is safe to
  resend. Content rejections still show the provider's own words.
- The fallback copy "Message was not accepted" read as a content refusal.
  A null reason now yields "Message was not sent.", which asserts only what
  every rejection shares.
- A refused worker-start preamble threw a plain Error out of the dispatch
  path. It now throws `OrchestrationError('dispatch_preamble_undelivered')`
  so a coordinator can tell "we could not send it" from "we sent it and
  something else broke" without parsing prose. Retain/discard behaviour is
  unchanged; only the verdict's legibility improves.

Two behaviours improve as a consequence rather than by design: a provably
undelivered message no longer blocks conversation commands, and no longer
leaves the session reading as "working" in chat and in every session list.

Not addressed here, and named rather than implied: a message left `unknown`
by a dead child or a host restart still has no recourse but retyping. The
restart reconciler that would decide those on evidence is written and has
never had a production caller. Parking the refused entry instead would
reintroduce the head-of-queue wedge removed in #19863, so it is not an
option.

Note for whoever edits `journal-reducer.ts` next: it sits at 297 of its 300
counted lines. The next statement added there needs a split, not a shave.
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change separates confirmed transport write failures from unknown delivery outcomes. Claude dispatch now returns rejected for unwritten messages. Unknown submissions remain non-redeliverable under the same client message ID. Host and mobile journals preserve operation state across recovery. Rejected submissions retry with a new ID. Transport clients track delivery ambiguity. Outbox and mobile presentation provide retry guidance.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to a8d3d

Mobile sends can become stuck as unknown or repeatedly fail after transient storage or expired-operation conditions, and a renderer retry can replay a terminal rejection after an outbox write failure. These retry and delivery recovery paths should be fixed before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.39% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 67 functions across 64 files. (5 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the change, motivation, behavior, testing, and known limitations in detail. However, it omits the required Linked Issue section, the required checklist and review sections, th… Add the required Linked Issue with an issue reference. Add the Visual Proof section with before-and-after attachments, or write exactly N/A with a brief reason if the change has no visual or interaction impact. Complete the Testing checkb…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: structured dispatch states now have distinct meanings. It is concise and specific.
Full details: Docstring Coverage

Explanation

Docstring coverage is 22.39% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 67 functions across 64 files. (5 skipped: 1 unsupported, 4 over the file limit.)

Full details: Description check

Explanation

The description explains the change, motivation, behavior, testing, and known limitations in detail. However, it omits the required Linked Issue section, the required checklist and review sections, the Agent skill upstream boundary section, and the required visual proof or exact N/A statement. It also reports pending platform validation.

Resolution

Add the required Linked Issue with an issue reference. Add the Visual Proof section with before-and-after attachments, or write exactly N/A with a brief reason if the change has no visual or interaction impact. Complete the Testing checkboxes and report platform coverage. Add the AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections from the repository template. Update the validation status for pending macOS and Windows smoke checks before merge, or clearly document that CI will cover them if permitted by repository policy.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes

  • Collapse provably-unwritten writes into rejected — dispatchClaudeTurn now returns rejected (not unknown) when the frame never reached the SDK's input pump, so each of the four states asserts exactly one thing.
  • Delete the redelivery allowlist — dispatchDoubtProvesUndelivered, dispatchMayMatchProviderEcho and retryWouldRedeliver are gone; performSend never re-delivers an unknown under its own id, turning a judgement call into an invariant.
  • Split rejection taxonomy into a shared module — structured-agent-session-dispatch-rejection.ts owns the provider_write_failed marker and the transport-vs-content classifier used by both host and client.
  • Scrub internal-token copy in the renderer — rejectionNotice replaces verbatim submission.reason, so a broken pipe shows friendly copy instead of provider_write_failed: broken pipe.
  • Verdict-code the worker preamble — a refused preamble now throws OrchestrationError('dispatch_preamble_undelivered') rather than a prose Error.

ℹ️ Durable unknown + provider_write_failed rows replay as echo-matchable after upgrade

Journals persisted by an older client still carry unknown submissions whose reason is provider_write_failed: …. The old dispatchMayMatchProviderEcho explicitly excluded that combination from provider-echo matching; the new candidate.dispatchState !== 'rejected' check does not, so a stale row whose payload fingerprint matches a later, genuinely-accepted resend of the same text can alias that echo to the wrong (old) submission. The consequence is cosmetic — the fail-closed invariant still prevents any re-delivery, so there is no duplication — but it is a durable-state compatibility gap the Notes section does not cover, unlike the wire story.

Technical details
# Stale `unknown` + `provider_write_failed` replay semantics

## Affected sites
- src/main/native-chat/agent-session-journal/journal-reducer.ts:167 — `candidate.dispatchState !== 'rejected'` now admits the legacy `unknown` + `provider_write_failed` shape to echo matching.

## Required outcome
- Either normalize legacy rows at replay (treat an `unknown` whose reason starts with `provider_write_failed` as `rejected`), or document the upgrade behavior as intentionally narrow.

## Open questions for the human (optional)
- Is cross-version journal replay in scope for this change, or is the legacy shape acceptable to leave as-is?

ℹ️ Nitpicks

  • rejectionNotice shows every non-provider_write_failed reason verbatim, so a pre-existing local-capacity rejection like claude structured dispatch queue is full still puts an internal token on screen — it is neither provider copy nor a transport write failure, so the content-vs-transport dichotomy in structured-agent-session-dispatch-rejection.ts has a third, unclassified case.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Both are narrow and both were real.

A journal written before a refused write became `rejected` still holds that
submission as `unknown` with the transport marker. The predicate this change
replaced excluded exactly that shape from provider-echo matching; the
state-only check that replaced it does not, so on replay such a row could
claim the echo of a later, genuinely delivered send of the same text and
attach the delivery to the wrong message. Fail-closed still prevented any
re-delivery, so nothing duplicated — but the wrong submission was credited.
Replay now excludes the legacy shape too.

And the content-versus-transport split had a third case neither side covers:
a local capacity refusal is neither the provider explaining itself nor a
frame that failed to leave. It fell through to the verbatim branch, so
`claude structured dispatch queue is full` reached the screen — the same
class of leak this change set out to fix, one reason short of being caught.
Internal reasons now get copy; only a provider's own words are shown as
written.

Each is pinned by a test that fails with its guard reverted and passes with
it restored.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Closed the durable-state replay gap — resolveJournalItemId now excludes unknown rows whose reason is the transport marker (provider_write_failed: …) from echo matching, so a stale row written by an older client can no longer alias a later, genuinely delivered resend of the same text.
  • Scrubbed the local-capacity token — the queue-full refusal is now the shared DISPATCH_REJECTED_QUEUE_FULL constant, classified as internal by dispatchRejectionReasonIsInternal, and mapped to friendly copy instead of leaking claude structured dispatch queue is full on screen.
  • Added guards for both — a reducer test asserts a legacy unknown write failure does not claim a newer identical echo, and a disposition test asserts the queue-full marker never reaches the screen.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof — structured native-chat surface

Isolated ORCA_BACKGROUND_LAUNCH=1 CDP session of this worktree (http://127.0.0.1:9335, renderer http://127.0.0.1:5174/).

App identity (window.api.app.getIdentity()):

  • name: Orca: brennanb2025/simplify-dispatch-doubt-states
  • isDev: true
  • devBranch: brennanb2025/simplify-dispatch-doubt-states
  • devWorktreeName: simplify-dispatch-doubt-states
  • devRepoRoot: /Users/brennanbenson/orca/workspaces/orca/simplify-dispatch-doubt-states

Scenario exercised: enabled experimental native-chat + structured native-chat + open-agent-tabs-in-chat via window.api.settings.set, added this repo, activated the worktree, and launched Claude from the real New tab menu. That opened a structured agent-session tab (contentType: agent-session, agentSessionAgent: claude) titled Claude Chat.

Visible state: empty structured native-chat pane — "Start a chat with Claude", composer "Send a message…", model Opus (1M context) / High. No rejection banner, no Retry, and no provider_write_failed token on screen.

Rejection/resent copy gap: the user-visible copy (Couldn't reach the agent. Your message was not sent — Retry to send it again., internal-reason copy, and the Retry control) only renders after a live agentSession.send returns dispatchState: 'rejected'. A healthy empty session never produces that. I did not inject journal/outbox rows or mock a rejected send.

native-chat-structured-empty.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Mobile native QA evidence (iOS Simulator, iPhone 17 Pro Max / iOS 26.5): the Orca app loaded and rendered the home screen. The exact send/retry path could not be exercised because the configured desktop was offline (“Can’t connect — check Tailscale”); no pairing/live session was available in this run.

iOS Simulator app loaded

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Rotated the mobile operation id after an ambiguous send — use-mobile-structured-agent-session.ts now drops the retained id on an unknown result, so a user resend is a fresh message instead of a retryUnknown replay the host now refuses to redeliver; the test asserts a new clientOperationId with no retryUnknown, and fails without the delete.
  • Preserved the preamble refusal code across runtime RPC — dispatch_preamble_undelivered joins STRUCTURED_RUNTIME_PASSTHROUGH_CODES, so a refused worker-start preamble reaches a coordinator as its own code rather than a flattened runtime_error; pinned by a mapRuntimeError test. The worker-start classifier already treats it as a definite failure (not outcome_unknown), matching the "provably did not happen" verdict.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Rotated the id on an immediate rejection — StructuredAgentSessionSendDisposition now carries retryWithFreshClientMessageId, and the outbox hook stores it in a ref so retry rotates even when the journal snapshot has not yet published the rejected row. The updated test retries before any submissions update and asserts a new clientOperationId with no retryUnknown, which fails without the ref guard.
  • Corrected two stale comments — the mobile mutate comment now says sends rotate operation ids on retry, and the doubt-reasons file points at structured-agent-session-dispatch-rejection.ts rather than a file that never existed.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: clean after fixes

The review loop is complete. The PR is ready to land after the remaining required CI checks finish.

Fixes pushed

  • 8bea7c8372 — preserve dispatch_preamble_undelivered through runtime RPC mapping and rotate mobile retries to a fresh operation ID after an unknown outcome.
  • fd8ea0ecbd — close the renderer fast-click race that could let Retry reuse a rejected operation ID before the journal snapshot arrived.
  • 8f6bfe40dd, b0dc0f0b29, fde4f77bc6 — correct stale semantic comments; no functional scope expansion.

Validation

  • 176 focused root tests passed; renderer/shared focused tests: 22 passed; mobile structured-session tests: 16 passed.
  • pnpm tc passed.
  • Changed-code quality/type-aware checks and React Doctor: 0 findings across the 24 changed files.
  • End-of-session readiness audit: no P0/P1/P2 findings.
  • Electron visual proof is attached in this comment. The real structured Claude Chat surface loaded in an isolated background CDP session; the live rejection path was not fabricated because no rejected send was reachable.
  • iOS Simulator evidence is attached in this comment. The app loaded, but the exact send/retry flow was blocked by the configured desktop being offline.

Remaining gates / notes

  • GitHub checks are still pending: verify, pullfrog, mac native smoke, Ubuntu native smoke, and Windows native smoke. Linux/Windows matrix entries are skipped by the workflow.
  • A broader native-chat sweep had two unrelated failures (structured-agent-session-handoff-options.test.ts timeout and structured-agent-session-lease-renewer.test.ts cleanup ENOTEMPTY); the affected PR suites and static checks passed.
  • The worktree retains only the pre-existing unrelated root pnpm-lock.yaml modification.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

CI update\n\nSince the review-status comment above, verify, pullfrog, and native-smoke (ubuntu-22.04) have passed. mac-native-owner-smoke and native-smoke (windows-latest) remain pending; Linux/Windows matrix entries are skipped by workflow.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof (hidden-renderer CDP)

Focused Electron validation of structured native-chat dispatch on brennanb2025/simplify-dispatch-doubt-states (PR #20133). No source or lockfile edits.

App identity

  • Dev instance: simplify-dispatch-doubt-states
  • window.api.app.getIdentity(): Orca: brennanb2025/simplify-dispatch-doubt-states
  • Worktree: /Users/brennanbenson/orca/workspaces/orca/simplify-dispatch-doubt-states
  • Isolated profile + ORCA_BACKGROUND_LAUNCH=1 + CDP 127.0.0.1:9333 (window stayed off-screen)

UI state exercised

Enabled Chat UI + structured native chat in this isolated profile, added this worktree, and launched a structured Claude session. Typed a benign prompt into the real composer and clicked Send.

Before send: empty structured Claude Chat pane, composer draft ready, Send enabled, no Retry/error strip.

native-chat-structured-composer.png

After send: dispatch accepted. User bubble rendered, assistant replied pong in 1s, composer cleared, sidebar shows Claude Chat - pong. No Retry banner and no provider_write_failed copy — correct for an accepted send.

native-chat-structured-dispatch-accepted.png

Commands

  • ORCA_BACKGROUND_LAUNCH=1 REMOTE_DEBUGGING_PORT=9333 node config/scripts/run-electron-vite-dev.mjs (isolated ORCA_DEV_USER_DATA_PATH)
  • Playwright CDP attach to http://127.0.0.1:9333
  • Real composer fill + Send click on structured Claude Chat

Remaining gap

The rejected-transport Retry copy (Couldn't reach the agent. Your message was not sent — Retry to send it again.) was not live-rendered. That path needs a provable write failure (provider_write_failed); inducing it would require killing/breaking a child this run did not own. Closest reachable state is the structured session composer + accepted-dispatch conversation above.

…unknown

Mobile released the retained operation id whenever a send came back
`unknown`, so the user's next send of the same text went out under a fresh
id. A fresh id has no ledger row, so the host treats it as a first delivery
and dispatches it -- even though `unknown` is the one answer that says the
provider may already have the message. That is the duplicate this branch
exists to remove, reintroduced on the client that has no outbox.

Which case that was matters. Mobile only ever sees `unknown` from ack-loss
(`isRpcDeliveryUnknown`: "the host may have processed it and only the ack
was lost"), because the mapper reported every `ok` result as `accepted`
without reading `dispatchState`. So the rotation fired exclusively where
delivery was ambiguous and never where it was provably refused, which is
the inverse of the rule this branch establishes.

Retaining the id is what makes a retry safe, and it costs no liveness:
`performSend` answers a second request under a recorded id from the journal
and never puts it back on the wire, so a reused id delivers when nothing
landed and replays when something did. Rotating can only ever add a second
copy. The retention stays bounded by the host's admission window, which
`retainStructuredSessionOperationId` already enforces.

`retryUnknown` goes with it: the host ignores it for delivery, and all it
does is skip the cached answer to re-read the same row.

Keeping the id exposes what the rotation was hiding, so fix that too: a
replayed `unknown` comes back `ok`, and mobile called it `accepted` and
cleared the composer as if the message had landed. `dispatchState` now
decides, in one pure function:

  accepted/pending  sent, and the id is spent
  rejected          provably did not happen and terminal in the reducer, so
                    reusing the id could only replay that rejection: spent,
                    and the next attempt is a first delivery under a new id
  unknown           keeps its id

Reading `dispatchState` at all is a pre-existing defect, fixed here because
the false "sent" cannot be removed without it, and scoped to the send path.
`mutate`'s rotation for prompt/option/cancel plans is untouched. The
rejection copy is the desktop's notice, so an internal reason
(`provider_write_failed: ...`) still never reaches a person.

Tests: the hook test that was flipped to assert a rotated id now pins the
opposite -- one id across an ack-loss and two `unknown` replays, each
reported `unknown` rather than `accepted`. The send fixture grew the durable
submission row a real host returns; without it every send test asserted
against a shape that cannot express the bug.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 26190f22-1ad1-4da8-ac7b-d259487ca638

📥 Commits

Reviewing files that changed from the base of the PR and between 8bea7c8 and 1733ebb.

📒 Files selected for processing (10)
  • mobile/src/session/mobile-structured-send-delivery.test.ts
  • mobile/src/session/mobile-structured-send-delivery.ts
  • mobile/src/session/structured-agent-send-result.test-fixture.ts
  • mobile/src/session/use-mobile-structured-agent-session.test.tsx
  • mobile/src/session/use-mobile-structured-agent-session.ts
  • src/main/native-chat/agent-session-journal/journal-dispatch-doubt-reasons.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-mutation-plans.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts
  • src/shared/structured-agent-session-send-disposition.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/native-chat/agent-session-wire/structured-agent-session-mutation-plans.ts
  • src/main/native-chat/agent-session-journal/journal-dispatch-doubt-reasons.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

(submission?.dispatchState === 'rejected' ||
retryWithFreshClientMessageIdRef.current === clientMessageId)
) {
retryWithFreshClientMessageIdRef.current = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve the rotation marker until the rotated entry is saved.

If writeOutbox(sessionId, rotated) fails, the original queued entry remains in memory. The current code has already cleared retryWithFreshClientMessageIdRef and reset blockedIdRef. Before the journal snapshot arrives, a later Retry can therefore resend the rejected ID and receive the same terminal rejection. Restore the block on failure and clear the rotation marker only after a successful write.

Proposed fix
-      retryWithFreshClientMessageIdRef.current = null
       const rotated = outboxRef.current.map((entry) =>
         entry.clientMessageId === clientMessageId
           ? {
@@
       if (!writeOutbox(sessionId, rotated)) {
+        blockedIdRef.current = clientMessageId
         setError('Message could not be saved to the outbox')
         return
       }
+      retryWithFreshClientMessageIdRef.current = null

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new mobile send handling keeps the operation id, but dropping retryUnknown is what breaks the ledger-unknown replay it is trying to protect.

Reviewed changes

  • Reversed the mobile id rotation — mobile now keeps a send's retained operation id on unknown and reads submission.dispatchState through a new pure mobileStructuredSendDelivery (accepted/pending → sent, rejected → rejected, unknown → keep id).
  • Dropped retryUnknown from the mobile send request and replaced the inline rationale comment.
  • Shared the rejection-notice copy — rejectionNotice is exported as structuredAgentSessionRejectionNotice and reused by mobile, with a new send-result fixture and mapping test.

⚠️ A ledger-unknown send retried from mobile is refused and then re-sent as a new message

Removing retryUnknown here is what breaks the ledger-unknown replay this commit is trying to protect. sendPlan.rerunWhenReplayMissing is gated on retryUnknown === true, so a retry whose host ledger outcome is unknown is refused with agent_session_operation_unknown and never reaches performSend; mobile maps that refusal to rejected and spends the id, so the user's next retry is a first delivery under a fresh id — the duplicate this branch exists to remove. Desktop keeps sending retryUnknown for exactly this state, and performSend still answers a recorded id without re-dispatching, so restoring it here cannot re-send.

Technical details
# Mobile drops `retryUnknown`, so a ledger-`unknown` send cannot replay

## Affected sites
- `mobile/src/session/use-mobile-structured-agent-session.ts:205` — the send request no longer sends `retryUnknown`, so `sendPlan.rerunWhenReplayMissing` (`structured-agent-session-mutation-plans.ts:53-59`) is false.
- `structured-agent-session-replay-outcome.ts:37-51` — an `unknown` ledger outcome with no `recoverUnknownFromDurableState` and no rerun refuses with `agent_session_operation_unknown`. `sendPlan` never sets `recoverUnknownFromDurableState`.
- `mobile/src/session/mobile-structured-agent-session-rpc.ts:140-149` — the `agent_session_operation_unknown` → `{status:'unknown'}` mapping is gated to `agentSession.conversationCommand`, so a send refusal becomes `{status:'refused'}`.
- `mobile/src/session/mobile-structured-send-delivery.ts:43-48` — `refused`/`failed` return `operationIdSpent: true`, and `use-mobile-structured-agent-session.ts:209-210` deletes the retained id.

## Reachability
- `runSettledAgentSessionMutation` records `{status:'unknown'}` whenever `plan.run` throws (`structured-agent-session-operation-settlement.ts:36-38`). For a send that is the `resolveDispatch`-after-dispatch failure (`structured-agent-session-turns.ts:139-154`), where the provider may already hold the frame. An ack-loss then leaves mobile holding the id against a host row that only refuses.
- Existing host tests already pin the divergence: `structured-agent-session-send.test.ts:266-300` shows a retry without `retryUnknown` refusing while one with it replays; `structured-agent-session-refusal-retry.test.ts:343-349` records a send refusal of `agent_session_operation_unknown`.
- The desktop outbox emits `retryUnknown: true` for this state (`src/shared/structured-agent-session-outbox.ts:165`), and the worker preamble does too (`orchestration-structured-worker-session.ts:242`) — only mobile stopped.
- The new mobile test mocks the post-ack-loss retries as `ok:true` + `submission.dispatchState:'unknown'` (ledger `succeeded`), which replays through `reconstruct()` and never hits the refusal, so it cannot catch this.

## Required outcome
- A mobile retry that reuses a retained id must still reach the durable submission when the host ledger row is `unknown`, so the outcome stays `unknown` and the id is kept. Retaining the id without that either wedges (if the refusal is mapped to `unknown`) or duplicates (current behaviour).

## Suggested approach
- Restore what the desktop outbox does: keep `const priorOperationId = operationIdsRef.current.get(key)` and pass `...(priorOperationId ? { retryUnknown: true } : {})` alongside the retained id. `performSend` answers a recorded id from the journal without dispatching, so this cannot re-send.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/lib/structured-agent-session-launch-prompt.ts (1)

80-80: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Rotate clientMessageId after a confirmed rejected submission.

When dispatchState === 'rejected', this branch keeps the same ID, retains retry metadata, and sets the entry to queued. The outbox dispatcher can send it again, but the host replays the recorded rejection for the same clientOperationId and payload fingerprint. Generate a new operation ID and clear lastAttemptAt and retryAfterUnknownSubmittedAt before requeueing. Add a test that asserts the second envelope uses a new clientOperationId.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f3bb27ac-de48-4802-a482-0eae5db9026b

📥 Commits

Reviewing files that changed from the base of the PR and between 1733ebb and a8d3de8.

📒 Files selected for processing (55)
  • config/reliability-gates.jsonc
  • mobile/src/session/mobile-native-chat-controller-contract.ts
  • mobile/src/session/mobile-native-chat-image-attachment.test.ts
  • mobile/src/session/mobile-native-chat-image-attachment.ts
  • mobile/src/session/mobile-structured-agent-session-rpc.ts
  • mobile/src/session/mobile-structured-agent-session-send.ts
  • mobile/src/session/mobile-structured-composer-command.test.ts
  • mobile/src/session/mobile-structured-send-delivery.test.ts
  • mobile/src/session/mobile-structured-send-delivery.ts
  • mobile/src/session/mobile-structured-send-operation-journal.test.ts
  • mobile/src/session/mobile-structured-send-operation-journal.ts
  • mobile/src/session/mobile-structured-session-operation-retention.test.ts
  • mobile/src/session/use-mobile-native-chat-controller.ts
  • mobile/src/session/use-mobile-native-chat-image-attachments.test.ts
  • mobile/src/session/use-mobile-native-chat-session-lane.ts
  • mobile/src/session/use-mobile-session-image-attachments.ts
  • mobile/src/session/use-mobile-structured-agent-session-send.test.tsx
  • mobile/src/session/use-mobile-structured-agent-session.test.tsx
  • mobile/src/session/use-mobile-structured-agent-session.ts
  • mobile/src/session/use-mobile-structured-native-chat-send-bridge.ts
  • mobile/src/session/use-mobile-structured-send-operation-reconciliation.ts
  • mobile/src/transport/direct-rpc-client.ts
  • mobile/src/transport/mobile-relay-rpc-session.test.ts
  • mobile/src/transport/mobile-relay-rpc-session.ts
  • mobile/src/transport/relay-pending-requests.ts
  • mobile/src/transport/rpc-client-delivery-ambiguity.test.ts
  • mobile/src/transport/stable-logical-rpc-client.test.ts
  • mobile/src/transport/stable-logical-rpc-client.ts
  • src/main/native-chat/agent-session-journal/journal-dispatch-doubt-reasons.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-mutation-admission.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-mutation-plans.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-operation-settlement.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-refusal-retry.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-send.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-turns.ts
  • src/main/runtime/agent-session-operation-admission.test.ts
  • src/main/runtime/agent-session-operation-admission.ts
  • src/main/runtime/agent-session-record-store.ts
  • src/main/runtime/orchestration/structured-mailbox-pointer-delivery.test.ts
  • src/main/runtime/orchestration/structured-mailbox-pointer-delivery.ts
  • src/main/runtime/orchestration/structured-mailbox-pointer-host.test.ts
  • src/main/runtime/orchestration/structured-mailbox-pointer-host.ts
  • src/main/runtime/orchestration/structured-pointer-operation-id.test.ts
  • src/main/runtime/orchestration/structured-pointer-operation-id.ts
  • src/main/runtime/rpc/methods/orchestration-structured-worker-session.ts
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.transport-probe.test.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSessionDelivery.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts
  • src/renderer/src/lib/structured-agent-session-launch-prompt.ts
  • src/shared/agent-session-host-authority.ts
  • src/shared/agent-session-refusal-retry.ts
  • src/shared/structured-agent-session-outbox.ts
  • src/shared/structured-agent-session-send-disposition.test.ts
  • src/shared/structured-agent-session-send-disposition.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Comment on lines +106 to +109
} catch {
// A retained settled id can suppress a later identical send, never
// duplicate this one; the next replay gets another clear chance.
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Retry durable cleanup after storage failures.

When direct cleanup fails for an accepted send, the retained operation ID remains in storage. A later identical send reuses that ID; the host replays the accepted submission without dispatching it, and mobileStructuredSendDelivery(..., retained: true) returns unknown without retrying cleanup. The reconciliation effect also suppresses failures and has no independent retry, so the entry can remain indefinitely.

Retry both cleanup paths with bounded backoff. Stop when cleanup succeeds or the exact operation ID is obsolete.

Comment on lines +47 to +53
if (refusalState === 'unknown') {
return { outcome: 'unknown', operationIdSpent: false, error: null }
}
return {
outcome: 'rejected',
operationIdSpent: !retained,
error: result.message

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Keep retained operations unknown after RPC refusal or failure.

When retained is true, the journal reuses the existing operation ID without age validation or rotation. After the host removes its ledger row, agent_session_operation_expired can reject that same ID. The current result keeps the ID but reports rejected, so each identical retry can submit the same expired ID and repeat the refusal. Return unknown for retained refusals and failures without a durable submission.

Proposed fix
   if (result.status === 'refused') {
     const refusalState = agentSessionRefusalOperationState('agentSession.send', result.code)
-    if (refusalState === 'unknown') {
+    if (refusalState === 'unknown' || retained) {
       return { outcome: 'unknown', operationIdSpent: false, error: null }
     }
     return {
       outcome: 'rejected',
       operationIdSpent: !retained,
       error: result.message
     }
   }
   if (result.status !== 'accepted') {
+    if (retained) {
+      return { outcome: 'unknown', operationIdSpent: false, error: null }
+    }
     return {
       outcome: 'rejected',
       operationIdSpent: !retained,
       error: result.message === 'Request not sent' ? 'Message not sent' : result.message
     }
   }

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes (delta since the prior pullfrog review at 1733ebba7e)

  • Reworked mobile send replay host-side — sendPlan now sets operationIdScope: 'global', markUnknownBeforeRun: true, and recoverUnknownFromDurableState: true, and its replay reconstructs a durable unknown submission (DISPATCH_DOUBT_SUBMISSION_MISSING, recovered: true) when the journal row is gone. A mobile retry that reuses a retained id without retryUnknown now replays instead of being refused, which closes the prior review's finding while keeping the id.
  • Added a mobile durable send-operation journal — mobile-structured-send-operation-journal.ts persists (sessionKey, intentFingerprint) → operation id in AsyncStorage, refuses new sends at capacity rather than evicting an ambiguous id, and is reconciled against authoritative accepted/rejected submissions.
  • Extracted the mobile send — new mobile-structured-agent-session-send.ts owns intent/payload fingerprinting, original-attachment-path reuse, and operationIdSpent-driven clearing; mobileStructuredSendDelivery(result, retained) now reports a settled answer under a retained id as still-ambiguous.
  • Tightened refusal/id rotation — the desktop outbox and launch prompt rotate a settled-rejected refusal's id via requeueStructuredAgentSessionSendRefusal's new retainOperationId, while ambiguous entries keep theirs; pre-effect refusals with a fresh ledger row are settled failed.
  • Marked delivery ambiguity at the transport edge — relay pending requests track whether a frame was written and only mark timeouts/close as delivery-unknown, a correlated response resolves even if logical close or cutover won the callback race, and unauthorized settles its own request before failing the rest.
  • Aligned the pointer/preamble lanes — structured pointer id re-minting is no longer driven by age (only a different batch/session), a rejected pointer dispatch deletes the stored id, and both lanes drop retryUnknown.

I traced the host send path (admitAndRunAgentSessionMutation → resolveAgentSessionReplayOutcome → runSettledAgentSessionMutation → performSend) and the mobile journal end to end: the recoverUnknownFromDurableState branch means send never reaches the rerun path, and performSend returns an existing submission without dispatching, so there is no second provider delivery under one id. The mobile journal entry's payloadFingerprint is byte-identical to the host submission row's, so reconciliation clears settled entries. The remaining liveness limit — a retained mobile id stays blocked on a later refusal — is the deliberate fail-closed behavior already recorded in the gate's knownGaps.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes (delta since the prior pullfrog review at a8d3de8)

  • Separated local fingerprint domains from RPC methods — the new structuredAgentSessionDomainFingerprint wraps structuredAgentSessionPayloadFingerprint, forwarding domain as the hashed method; the three mobile callers (mobile-native-chat-image-attachment.ts, mobile-structured-agent-session-send.ts, mobile-structured-send-operation-journal.ts) now use it for their mobile.* domains.
  • Pinned the digest compatibility contract — a new test asserts the domain helper produces the same digest as the payload helper for the same input, so already-persisted mobile send-operation journal entries still reconcile with host submission rows.
  • Aligned retry tests with the settled-rejected classification — the option test (use-structured-agent-session.test.tsx) and send-outbox test (use-structured-agent-session-outbox.test.tsx) now expect an operation-id rotation for agent_session_checkpoint_stale, matching agentSessionRefusalOperationState; the outbox test's randomUUID mock was made to return distinct ids so the rotation is observable.

I ran the three touched root suites (structured-agent-session-mutation, use-structured-agent-session, use-structured-agent-session-outbox) — 36 tests green. The mobile substitutions are mechanical and pass the same domain strings through unchanged, so their digests are unaffected; mobile deps are not installed in this environment, so its suites were not exercised here.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one small cleanup inline.

Reviewed changes (delta since the prior pullfrog review at 3b9c8e20ce)

  • Kept transient admissions retryable on the host — admitAndRunAgentSessionMutation now admits the ledger row and the lease/fence preconditions in a single transact, and deletes the freshly admitted row when admission refuses, so a same-id retry after the client refreshes its fence runs a first delivery instead of replaying a settled failure.
  • Reclassified checkpoint_stale and agent_session_conflict as pending-admission — agentSessionRefusalOperationState no longer calls a stale fence or a runtime-kind conflict settled, so clients keep the operation id rather than rotating it; the dead duplicate execution_owner_reconciling case was removed.
  • Aligned client id retention — the desktop outbox now rotates only on settled-rejected, and mobileStructuredSendDelivery spends a refused id only for a settled-rejected refusal on a non-retained id.
  • Tightened the guards — the refusal-retry host oracle now proves the retention classification against real host retries, and the renderer option/outbox plus mobile send tests assert id reuse across a pending-admission refusal.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

})
}

admitMutationOperation = (args: AgentSessionMutationOperationAdmission) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new admitMutationOperation replaces the last caller of the admitGlobalOperation method just above it: the plan.operationIdScope === 'global' branch in admitAndRunAgentSessionMutation now passes the scope here instead of dispatching to the store method. admitGlobalOperation has no remaining callers anywhere in the repo, so it is dead code — consider deleting it rather than keeping two store entry points for the same admission.

@brennanb2025
brennanb2025 merged commit 8999a00 into main Sep 13, 2026
34 checks passed
brennanb2025 added a commit that referenced this pull request Sep 13, 2026
Resolved journal-dispatch-doubt-reasons.ts by dropping BOTH sides of the
conflict region: #20133 moved provider_write_failed into the new shared
rejection module, and this branch removed the codex-turn-unnamed reason
because Codex no longer settles a send on a deadline. Main's two tests
that imported that constant now spell the reason as a literal, since rows
written by an older Orca still carry it.

Routed the Codex queue-full rejection through the shared rejection module
so #20133's classifier does not print an internal marker to the user.
Jinwoo-H added a commit that referenced this pull request Sep 13, 2026
Conflict in mobile/src/transport/stable-logical-rpc-client.ts: #20133 removed the
post-hoc close/cutover rejection on the success path ("a correlated response is
definitive"), which collides with this branch deleting migrateTo's eager pending
rejection. Kept both — main's unconditional resolve on success, this branch's
cause-carrying LogicalClientCutoverError on the physical error path — and restored
the requestGeneration capture that only the error path still needs.

Also drops rpc-client-close-settlement.test.ts and repoints the close() contract
doc at the two tests that exercise the real clients. Per review (#20280 comments
from coderabbitai and pullfrog) that file drove RpcClientRequestTracker.rejectAll
and RelayPendingRequests.rejectAll directly, so it pinned the trackers rather than
either close(); main's new per-request `written` flag then made its relay case
assert a mark that a bypassed send path never earns.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
salvadorgu7 added a commit to OrbittechIA/orca that referenced this pull request Sep 23, 2026
* feat(work-items): port structured Start to Orca 1.4.203

Work Item Start opens exactly one structured agent session for a linked work item,
delivers its prompt once, and refuses before creating anything when it cannot.

A squash-port of the proven 1.4.201 checkpoint (05ac9d8)
onto the official 1.4.203 base (tag v1.4.203, commit 776e424,
tree df262ab). 1.4.203 ships no Work Item Start surface, so
the whole contract still applies; the substrate it lands on changed in eight files and the
delta was re-decided there instead of replayed.

Contract (unchanged from the checkpoint)
- `agent-session.work-item-start.v1` is a negotiated runtime capability; an older host does
  not advertise it and the route refuses instead of half-opening a session.
- `launchOrigin: 'work-item-start'` admits one launch to the structured route and
  `launchAuthority` records who admitted it; both are host-derived, never wire-accepted.
- Strict (`submit-after-ready`) launches declare no `legacyFallback`: a definitive refusal
  settles as `failed` and no terminal writer opens behind it.
- The strict preflight runs BEFORE `git worktree add` and before `createFolderWorkspace`.
- A structured session is created on the runtime that owns its workspace; an ambiguous
  owner fails closed.
- `worktree ps` projects the structured `sessionId` and provider handle for Core adoption.
- Packaged builds embed version/commit/tree/buildId; `status.get` publishes it and
  `runtime.buildAttestation` hashes the running executable on demand.

Re-decided on 1.4.203
- Unknown send refusal: 1.4.203 (stablyai#20133) retains the operation id and replays the same
  envelope through the host's durable send plan, and names parking the entry as the
  head-of-queue wedge stablyai#19863 removed. The checkpoint's `unconfirmed`/-1 parking hunk in
  `requeueStructuredAgentSessionSendRefusal` is dropped; the official function is kept
  verbatim. The Start path still reports `deliveryUnknown` from the refusal code so no
  second writer is opened, and its test now asserts the official same-envelope replay
  (`retryUnknown` is compatibility-only on 1.4.203 and is no longer sent).
- RPC params type parity (new in 1.4.203) required `runtime.buildAttestation` in the
  generated catalog; regenerated with the official script.
- Mobile Tasks parity hashes recomputed over the merged 1.4.203 source.
- Localization catalog: the Start strings now have `en.json` entries, which the 1.4.201
  checkpoint lacked; `verify:localization-*` passes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Re-decided on 1.4.209 (port of this commit onto stablyai/orca v1.4.209)
- 1.4.209 (stablyai#20502) removed the renderer terminal fallback and made structured launches open
  a provisional chat tab that owns its own retry. Strict Start no longer needs to withhold a
  `legacyFallback`: none exists. Strict worktree/direct/folder Starts now await the launch
  settlement and prompt delivery on top of the provisional handle; non-strict launches keep
  the upstream fire-and-forget behaviour.
- The pending-creation recovery lane (`worktree-creation-structured-recovery.ts`) that
  1.4.209 deleted is kept for strict Start only; its retry re-enters the launch registry,
  which restarts an unknown launch under the same intent instead of minting another.
- The shared launch-prompt dispatch (stablyai#20502) returns a boolean; `deliveryUnknown` is carried
  beside it, and read back from the outbox entry when the mounted chat ran the shared send.
- stablyai#20944 stopped routing on terminal arguments (`requiresTuiLaunchCommand`); the strict
  preflight and planners follow it, so they predict the same route as the post-create plan.
- `launchOrigin` and the owning runtime target now survive the intent retry/restore split
  and the reload-persisted launch record (the create fingerprint covers `launchOrigin`).
- Mobile: the createSupport probe uses the typed RPC operation; the new-worktree route
  builder carries the combined setup + session warning.

* fix(work-items): scope every status event per subscriber; certify against 1.4.203

Two blockers the independent review found on 4e098c4, each with a regression that fails
on the previous code.

Status feed access scope (P1)
- `subscribe(includeSession)` filtered only the opening snapshot; `broadcast` looked for a
  top-level `sessionId`, which a `status` event never has (it names its session at
  `event.session.sessionId`). A paired runtime denied a Work Item Start session therefore
  received every later publish and ownership revoke for it.
- Every session-bearing event now passes the subscriber's filter (`scopeStatusEvent`):
  `status` is withheld, `snapshot` is filtered, `end` always arrives. The filter is dropped
  together with its subscriber on direct `unsubscribe`, on the disposer, and on emit failure;
  a re-subscribe under the same id never inherits an earlier filter.
- Regressions: the feed itself (denied subscriber gets an empty snapshot and zero status
  events across publish and revoke, the allowed session still flows, `end` exactly once,
  filter cleanup on both removal paths) and the RPC boundary through
  `agentSession.subscribeStatus` with `canAccessWorkItemStartStructuredSession`, for a
  paired runtime and a mobile client on their own connections while the owner's connection
  receives both events. The RPC fixture now shares one real feed per test over a journal the
  test can advance, and exposes the live reply list of a streaming call.

Certification baseline
- `WORK_ITEM_START_E2E_BASELINE_VERSION` was still `1.4.201`, so this candidate's own
  evidence validator would have rejected a correct 1.4.203 paired run. It is `1.4.203` now,
  fixed rather than derived from the manifest: the manifest says what was packaged, the
  constant says what the owner certifies, and a self-consistent 1.4.201 pair must still be
  refused. Fixtures bind to the official v1.4.203 base (776e424 / df262ab, buildId
  7bbdd813f784, as `build-provenance.mjs` derives it). Matched 1.4.199 and 1.4.201 pairs are
  rejected on both sides even when they match their own manifest; a 1.4.201 side behind a
  1.4.203 side is rejected by baseline, identity, and version mismatch. The Windows-client,
  distinct-artifact, commit/tree/buildId, capability, single-executor, one-prompt, and
  zero-terminal checks are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(work-items): close the remaining 4e098c4 review findings (A–H)

Each finding has a regression that fails on 8b87c61 and passes here; each was proved by
reverting only that finding's implementation.

A  Strict quick-create keeps `launchOrigin: 'work-item-start'` and declares no
   `legacyFallback`; a definitive refusal settles as `structured-refused` (workspace kept,
   no writer, no terminal, Retry allowed).
B  Every launch exposes `recovery = { intent, clientMessageId }`. The pending creation
   persists it on an unknown launch/delivery and Retry re-enters with `recover`: the exact
   intent (same session id and create envelope, replayed through `reconcileUnknownLaunch`)
   and the staged prompt looked up by operation id. A lost staged entry is unknown, never
   success. Prompt staging moved to `structured-agent-session-launch-staging.ts`.
C  A definitively refused launch prompt is deleted from the outbox instead of requeued
   under a fresh id; only unknown / not-yet-admitted refusals retain and replay the same id.
D  Mobile admission is tri-state (`terminal` / `structured` / `refused` / `unknown`) with a
   10 s status timeout; both Start entry points stop BEFORE `worktree.create` on refused or
   unknown and never fall back to the terminal.
E  The mobile send envelope is persisted in the operation journal before dispatch;
   `agent_session_operation_unknown` on `agentSession.send` is unknown; unknown outcomes
   replay the same operation id a bounded number of times and stay persisted until settled.
F  `prepareStructuredAgentSessionCreateForWorktree` passes `expectedWorktreeTarget` to the
   resolver, where the full record comparison (path, instance, identity, host, creator) runs.
G  `worktree ps` merges the host's projection with the hook-store row that shares its pane
   key: one row per session, with `sessionId` and provider handle.
H  Build provenance is fail-closed: any working-tree change yields no identity, an
   `ORCA_BUILD_COMMIT/TREE` that contradicts (or cannot be confirmed by) the repository
   throws, the packaged `app.asar` bundle is verified in `afterPack`, the candidate manifest
   is written after every artifact, `build:*` run `verify:build-provenance`, and the paired
   spec requires `ORCA_CANDIDATE_MANIFEST`. `ORCA_BUILD_UNCERTIFIED=1` is the only escape and
   embeds nothing certifiable.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Re-decided on 1.4.209
- B lands on the 1.4.209 launch registry: a recovery re-enters the registered state when it
  still exists (a restart that finds, rather than skips, the staged operation) and otherwise
  rebuilds it from the persisted intent through `reconcileUnknownLaunch`. Publication is
  verified with the authoritative tab snapshot (stablyai#20502 removed the renderer-tab shortcut).
- A: 1.4.209 has no terminal fallback, so a refused strict create simply settles `failed`
  and maps to `structured-refused`.
- `recovery` is optional on hand-built settlements; the settle loop always sets it.
- D: the mobile admission read goes through a typed `status.get` RpcOperation, as the
  1.4.209 raw-request-port ratchet requires.

* fix(build): do not count electron-vite's transient config bundle as a dirty build input

The first fail-closed package refused itself: electron-vite bundles its config into
`electron.vite.config.<timestamp>.mjs` in the working directory while the config loads —
which is when `readBuildProvenanceLiteral` runs — and deletes it afterwards. It is derived
from the tracked config, not an input. Ignored in git and excluded by exact pattern in
`dirtyBuildInputs`; a modified config or any other stray file still yields no identity.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(work-items): strict quick-create never reads missing delivery evidence as success

Re-review counterexample on e7567c6: a structured settlement that resolves with a session
but carries no prompt-delivery state completed the strict creation, because
`!delivery || delivery.delivered` took the success branch. Missing evidence is not evidence
of delivery. In strict mode an absent delivery result now settles as `promptDeliveryUnknown`
with the launch's `recovery`, so Retry reconciles the same session and operation; nothing
completes, nothing mints a second session, and no terminal fallback exists on this path.

Regression: the counterexample itself, asserting durable unknown with the recovery intent,
one launch, and only the structured chat's own activation (never a startup terminal).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(build): bind provenance to the real embed site and keep the transient bundle out by timing

Two re-review holes in the provenance gate.

P1 — a name-based whitelist admitted ANY `electron.vite.config.<digits>.mjs` as clean, so an
unverifiable file could hide under a numeric transient name. No name is exempt now: the build
wrapper (`run-electron-vite-build.mjs`) reads the identity BEFORE electron-vite writes its
transient config bundle and hands it to the config through
`ORCA_ELECTRON_VITE_BUILD_PROVENANCE`; the config accepts it only if its commit and tree are
what git reports at load time (malformed, contradicted or unconfirmable hand-overs throw), and
falls back to the strict read without it. The gitignore entry is gone, so a lookalike is a
dirty input like any other and the identity is null. Regression: the exact counterexample
(`?? electron.vite.config.123456789.mjs` → dirty → null) beside the genuine path (hand-over
accepted while the transient is on disk).

P2 — the bundle verifier accepted any bundle in which the expected strings occurred somewhere,
so `value:null` plus a comment passed. The runtime read site now carries an exact sentinel
(`site:'orca:build-provenance:embed', value:<substituted>`, checked at runtime so no minifier
drops it) and the verifier parses the value right after that sentinel: exactly one site, a
well-formed identity, equal to the expected one; null, an unreplaced identifier, a malformed
object, two sites, or another build's identity all refuse, whatever else the bundle contains.
Regressions: null + expected strings in a comment; forged identity at the site + expected
strings elsewhere; duplicate sites; unreplaced identifier; sentinel byte-equal on both sides.

Packaging hooks: `artifactBuildCompleted` validates the AppImage synchronously again and
returns the manifest write; `ORCA_BUILD_UNCERTIFIED` is read per call. The electron-builder
hook tests broken since b52da80 are fixed (layout tests run as throwaway packages) and two
deterministic refusals added: a manifest under a contradicted override, and an afterPack
whose packaged bundle embeds null.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(work-items): settle mobile M1 only on ledger settlement, hold the workspace lifecycle through attach, full sha for mac local builds

Final source round of the independent review (R1–R3), each with a regression that fails on
the previous implementation.

R1 — mobile durable journal. `deliverWorkItemStartPrompt` cleared the persisted M1 for every
non-unknown mutation result, so a lost reply followed by an `agent_session_operation_capacity`
("try later") replay deleted M1 and reported undelivered while the host may hold it. The
canonical `agentSessionRefusalOperationState` now decides: `unknown` and `pending-admission`
(and any code the ledger does not classify) replay the SAME operation id a bounded number of
times and, still undecided, stay persisted and are reported `unconfirmed` with the exact
envelope; only `settled-rejected` (and a pre-handler failure that never reached the host)
clears. M2 is never minted.

R2 — worktree target TOCTOU. The full expected-target comparison ran in the resolver, then
launch preparation awaited, then `attach` ran with nothing keeping the record what it was.
The runtime now has a workspace lifecycle hold (a second instance of the existing
shared/exclusive `WorktreeTerminalMutationLock`, its own key space): a structured create
holds the shared side from authoritative resolution through attach — scoped creates before
resolving, generic ones once resolved — and `removeManagedWorktree` (every removal branch,
therefore every replacement) takes the exclusive side around the whole removal, refusing as
`worktree_lifecycle_busy` past a bounded wait rather than being granted later. Belt to that
brace: `commit` re-resolves the exact full target (path, instance, identity, host, creator)
under the hold immediately before attach and refuses on any difference. Deterministic
regressions with the real `OrcaRuntimeService`: A attaches once; A replaced by B during a
paused preparation → attach never called; a removal waits for the in-flight create; a create
arriving during a removal sees B and is refused; a removal past its deadline is busy. The
terminal-only lock is not used: removal never took it.

R3 — mac local build. `getLocalBuildIdentity` passed `git rev-parse --short=12` as
`ORCA_BUILD_COMMIT`, which the provenance gate compares byte-for-byte with `rev-parse HEAD`,
so the local mac build refused itself. It now hands over the full sha (and refuses anything
else); only `createLocalBuildVersion` abbreviates it for the human version suffix. The
verifier is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(work-items): strict quick-create fails closed on a thrown launch or a generic failed settlement

Last material blocker of the independent review on 0fd77da: with a strict (`submit-after-ready`)
non-empty prompt, `launchStructuredWorktreeSession` still answered `accepted: true` when the
launch threw during launch-intent creation (an ambiguous runtime owner) or when the settlement
was a generic `{ kind: 'failed' }`; the caller then completed and removed the pending creation
with no structured session and no delivery proof.

Both now settle as `failure: 'structured-launch'` in strict mode — the same discipline as a
host refusal: the workspace exists with no writer, no legacy terminal opens, the creation is
marked as a retryable error instead of completed, and nothing mints a second session. The
non-strict path is unchanged.

Regressions (the strict suite moved to `worktree-creation-structured-session-strict.test.ts`
to stay under max-lines): a thrown `worktree_runtime_owner_ambiguous` from the launch's sync
prologue, and a generic failed settlement, each asserting `accepted: false`,
`failure: 'structured-launch'`, no fallback claim, no startup terminal, no after-wake terminal,
no trust preflight; and, at the flow level, that such a result is kept on the retry surface
and never completes or removes the pending creation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Re-decided on 1.4.209: the strict lane also fails closed when the provisional chat surface
could not open (reveal failed) and the creation was not cancelled; the strict suite runs the
real plan, settle loop and provisional tab, and asserts the only activation is the chat's own.

* fix(work-items): strict quick-create fails closed when the launcher itself throws

The same fail-open one level above e1d9c5e's fix: the caller of
`launchStructuredWorktreeSession` in `worktree-creation-flow-execute.ts` caught any exception
that escaped the launcher, logged it, and fell through to `completeWorktreeCreation` with
`structuredLaunchAccepted` still true — no session, no delivery proof, pending creation removed.

For a strict (`submit-after-ready`) Work Item Start an escaped exception now marks the
existing workspace with the retryable `structured-launch` error and returns before completion:
no legacy terminal, no pending removal, no second session. The non-strict path keeps its
historical behaviour (treated as a failed-but-accepted launch).

Regression at the caller level: `launchStructuredWorktreeSession` itself is mocked to reject
(not the plan inside it); `completeWorktreeCreation` never runs, the pending entry is a
retryable `structured-launch` error bound to the worktree, and no startup / activation
terminal is seeded. Fails on e1d9c5e's file, passes here; the helper-level throw and generic
failed-settlement tests are kept.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore(work-items): clear the changed-code quality gate (83 type-assertion findings) without behaviour change

`check:code-quality:changed` against the official v1.4.203 base reported 83
`typescript/consistent-type-assertions` findings across the port (9 production sites, 66 in
tests). It now passes with 0 findings.

Production: checked narrowing instead of casts. A tiny shared guard (`isUnknownRecord`) narrows
untyped input in the build-provenance parser, the launch-authority parser and the mobile
admission reader; the attestation stream is typed as an `AsyncIterable<Buffer | string>`; the
pre-create preflight declares the detected-agents promise type the routing already requires;
the session-tab projection spreads the base projection over the change instead of asserting;
the IPC dispatch response needed no assertion at all. One production cast is unavoidable and
carries the repository's line-specific SAFETY rationale: the `globalThis.ORCA_BUILD_PROVENANCE`
read, which the packager's define substitutes textually and which the cli/mobile tsconfigs
(no `build-constants.d.ts`) also compile. The inherited web settings API `satisfies … as`
carries one too (the web preload implements a checked subset).

Tests: `vi.hoisted` state is declared with types instead of asserted; RPC/mock params are read
through `isUnknownRecord`; `JSON.parse` results are assigned to typed bindings; DOM elements are
narrowed with `instanceof`; worktree-target fixtures are typed with `Pick<Worktree, …>`.
Fixtures that deliberately pin a subset of a large interface (runtime stores, structured hosts,
protected resolvers, GlobalSettings) keep a single SAFETY-annotated cast each, usually behind a
small helper so one rationale covers the repeats. No rule is disabled and no allowlist grows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore(work-items): recompute Mobile Tasks parity hashes over the merged source

The refactor-parity guard pins hashes of the Mobile Tasks source; the port
onto v1.4.205 merges the Work Item Start changes into upstream's RpcOperation
migration of the same files, so the screen-hook, statement, declaration and
semantics fingerprints (and the semantics line count, 3452 -> 3458) are
recomputed over the merged tree, exactly as the 1.4.203 port did. Render tree,
style and diff-hook fingerprints are unchanged. No behaviour change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Re-decided on 1.4.209: recomputed over the Work Item Start changes merged into the 1.4.209
Mobile Tasks source (semantics line count 3274 -> 3280); render tree, style and diff-hook
fingerprints unchanged.

* fix(work-items): scope the workspace lifecycle hold per execution host on 1.4.205

Upstream v1.4.205 runs same-id workspace removals on different hosts
concurrently (a local row and an `ssh:*` row under the migrated spelling),
and its integration suites build partial runtime fakes. The reviewed R2 hold
(0fd77da) keyed the lifecycle lock by worktree id alone, so on the 1.4.205
base the remote removal waited on the local one until `worktree_lifecycle_busy`
and three upstream integration suites failed with
`holdWorktreeLifecycle is not a function`.

- `runtimeWorktreeLifecycleKey` keys the hold per execution host; no host is
  the local machine, which is what an unscoped hold always meant.
- The create path holds the host the admitted target names (or the resolved
  location's host); the removal path holds the host it routes to, resolved
  from the explicit host or the owner repo before the hold is taken.
- The removal hold helper receives the scope it needs instead of a bare id.
- Upstream's three integration fixtures declare the hold, as the reviewed
  fixtures already did.
- Regression: a remote exclusive hold neither waits for nor blocks the local
  create, and the local scope is still the one the create held.

Verified on this tree: `pnpm tc`; the previously failing suites plus their
neighbours (orca-runtime, orca-runtime-tests, structured-session
integration/replay/claude, create-lifecycle, precommit refusal, worker seed
options, worktree ps: 8 files, 1320 tests) pass; oxlint on changed files;
`check:code-quality:changed` against 11aba8b: 0 findings; `git diff --check`.
The one remaining failure in the targeted desktop run,
`hourly-build-version.test.mjs` "stays on the already-shipped hourly base",
fails identically on pristine v1.4.205 (upstream's own stale expectation) and
is not part of this delta.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix: repair v1.4.205 port CI and Windows provenance paths

Re-decided on 1.4.209: the legacy adapter freeze hunk is dropped — 1.4.209 (stablyai#20872) already
reads own-property descriptors, which is the lint fix this worked around; the added freeze
assertions are kept and pass. The mobile admission read keeps its typed operation.

* test: check Windows target watcher in architecture packaging guard

* test: use retrying cleanup for Windows package fixtures

* fix(work-items): preserve scoped Start authority at production callers

* fix(work-items): retain strict delivery across incomplete settings refreshes

* fix(work-items): preserve legacy settings wire behavior outside strict Start

* fix(codex): preserve yolo semantics in structured app-server

Re-decided on 1.4.209: stablyai#20944 deleted `codex-structured-app-server-args.ts` and stopped
passing configured CLI arguments to app-server. The Yolo posture now travels as the
thread's explicit `approvalPolicy: never` / `sandbox: danger-full-access` on thread/start
and thread/resume, derived from the bypass flag wherever it sits in the arguments, and
conflicting `-c approval_policy` / `--sandbox` tokens never reach app-server. So the patch's
`-c` overrides are dropped with the deleted file, and its guarantee (Yolo is final regardless
of argument order) is pinned against `codexStructuredPermissionPolicyForSettings`.

* fix(mobile): restore the 1.4.209 web client context seam

The 1.4.205 CI repair moved the RPC client context into a native-only
rpc-client-context.ts and pointed host-client-hooks at it. 1.4.209 ships a
client-context.web.tsx with its own context, so on the web page every
useHostClient read a context the web provider never fills: 27 bridge-parity
goldens failed (base: 793/793). Back to upstream's import layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(work-items): adapt direct and composer Start to 1.4.209

Split the strict submit-after-ready half of launchWorkItemDirect into
launch-work-item-direct-strict-start.ts and the mobile composer Start into
composer-work-item-start.ts, with unchanged behaviour. The strict pre-create
preflight keeps reading the settings snapshot taken at launch rather than
re-reading the store after the awaits.

1.4.209 keeps structured launches with configured agent arguments and refuses
only a command override, so the unavailable copy now says "custom launch
command" and the folder composer test pins arguments as non-blocking. Test
fixtures follow 1.4.209 APIs (retired-name registry, agentLaunchSupported,
repoName, provisional-tab store fields, cancelStructuredAgentLaunch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): read a missing support method as a verdict

The Start's probeFailed marks an unanswered createSupport probe so a strict
Start reports unconfirmed instead of refused. It also swallowed
method_not_found, which is a host answering that it has no structured route:
structured-launch-support-refused diverged from its golden. Definitive codes
(isDefinitiveAgentSessionCreateRefusal) are plain unsupported again; other
ok:false replies stay probeFailed, so the two reply-matrix goldens whose
generic refusal partitions now settle probeFailed are re-recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(work-items): pin the closures and capabilities Start changes on 1.4.209

- The structured RPC module imported the native-chat write floor from
  mobile-native-chat-send, dragging terminal-write families into the Tasks
  and Files pages. The constant moves to a leaf module.
- The layout's composer now opens the Start's structured session, so C1
  (and C5, which inlines it) pins agentSession.structured-create/launch with
  their replay verdicts; C2/C3/C5 censuses move by +2 families, +9 goldens.
- The session route closure is 4329 modules (+6 Start modules).
- The desktop renderer advertises the structured capabilities to paired
  remotes too, which the port added so a paired Start is not refused; the
  divergence test records that decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(daemon): reap terminal descendants during shutdown on 1.4.209

Port of upstream 632ae13 ("fix(daemon): reap terminal descendants
during shutdown (stablyai#22232)") onto the v1.4.209 tree. The release's pr.yml
already runs config/scripts/run-daemon-shutdown-descendants-docker.mjs,
but the harness was never shipped and the leak it guards was live: a
setsid'd, SIGTERM-ignoring child of a live PTY shell survived daemon
exit.

Host dispose now captures each live session's descendants, escalates
them with identity-checked SIGTERM/SIGKILL and waits for verification
(bounded to 2.5s inside the daemon's 5s budget) before force-killing the
shell and releasing its PTY. In-flight teardowns are upgraded to
immediate and awaited instead of being disposed a second time.

Carried as-is: the teardown/verification runtime, the per-pid partial
read verifier, the process-table parser split, tests, and the Docker
oracle plus its PR-scope classification. Not carried: the
daemon-cgroup-scope busctl hunk (the module was removed in 1.4.209) and
the pr.yml step (already present in the release).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(work-items): scope Start session reach to its owner on 1.4.209

- hold, reveal, restartResumable/Resume/Continue authorize each concrete
  sessionId: a Work Item Start session is reachable by its owner alone,
  even with global structured chat off; cross-owner access is refused.
- Add the Start-only client capability agent-session.work-item-start.client.v1.
  Paired desktop and web clients advertise it instead of the generic
  structured-session capability, so Start no longer grants reach into
  ordinary structured chats. Hosts still accept the generic capability.
- Ordinary structured tab restore stays behind the v1.4.209 setting; with
  it off, a Start caller restores only its own visible Start tabs, latched
  per record so owners never spend each other's sweep.
- worktree.ps drops sessionId and provider thread ids from structured rows
  the caller cannot reach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(work-items): close the remaining 1.4.209 Start review findings

Settings wire: settings.update accepts the optional workItemStartPromptDelivery
('draft' | 'submit-after-ready') that paired web clients already send; legacy
payloads are unchanged and an unknown value is refused.

Prompt refusal: only a strict Work Item Start (submit-after-ready) settles a
definitively refused prompt, and it names one fresh retry id. Every other
structured launch keeps the v1.4.209 requeue.

Desktop strict retry: a recovery whose staged prompt is gone restages it under
the SAME operation id, so the host ledger replays an accepted send instead of
delivering twice. A strict refusal leaves one retry id and keeps Retry enabled.
A refused create retries with its never-dispatched prompt, and a thrown
unadmitted refusal is definitive rather than unknown.

Quick create: the strict preflight checks the host the workspace runs on
(ephemeral VM or run target), not the source repo's, before any worktree exists.

Mobile: a strict Start refuses SSH, runtime-hosted and WSL repos before
worktree.create. A durable attempt journal, written after worktree.create and
before the session request, makes every retry re-enter the same session id and
create operation. The composer returns the created workspace with a warning
instead of an error that left Create armed for a second workspace; the workspace
screen offers Retry Start; the Tasks create path has a synchronous in-flight
guard. Support probes are bounded to 10 s on mobile and desktop.

Build provenance: the hourly, daily and adhoc mac version scripts emit the full
commit sha (display names still slice seven), and provenance refuses any
ORCA_BUILD_COMMIT/ORCA_BUILD_TREE that is not a full 40-hex id.

Certification evidence: the 1.4.203 pin is gone and evidence binds to the
candidate manifest's version, commit, tree and build id, with an optional
ORCA_CANDIDATE_EXPECTED_COMMIT pin. The runtime attestation adds optional
appContent (the app.asar hash) and attestationId, and packaging records the
asar hash per artifact in the manifest. The paired spec runs its contract steps
in PR CI against a new inert Codex app-server fixture; candidate evidence runs
only with ORCA_WORK_ITEM_START_CERTIFICATION=1, where nothing may skip.

Also: the terminal-paste path is fenced from strict Start and pinned by a test,
mobile/pnpm-lock.yaml is restored to its v1.4.209 bytes (a format-only rewrite
with no package.json change), and three parity pins plus six mobile RPC goldens
are refreshed for the intended probe-timeout and create-guard changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(work-items): close the 1.4.209 Start CI findings outside the RPC pin

- runtime-executable-attestation: read the original-fs shape and
  process.resourcesPath through typed property access, not Reflect.get.
- write-candidate-manifest: rpm names x64 `x86_64`, which the bare `x86`
  match read as ia32; the package job refused the manifest for want of an
  ia32 app-content sidecar. Covered by a linux x64 binding test.
- Session route closure 4329 -> 4333: the four Start modules added in
  8ecea75 (attempt journal, prompt delivery, retry banner, execution host).
- Web runtime capability tests assert the Start-scoped structured capability
  is advertised and the generic structured capabilities are not.
- The e2e workflow contract finds its Windows launcher by listing rather than
  naming a batch-shim literal; it only reads the file, never spawns it.
- en.json gains the retryable prompt-refusal copy the recovery path reads.

The RPC recording pin stays red: the 9 structured goldens record the
support probe's new 10s budget, which the pinned baseline tree does not
send. Only a repin plus full re-record satisfies both replays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(rpc): repin recordings to final 1.4.209 Start candidate

* fix(work-items): refuse unsupported strict Start repos before worktree.create

A strict Work Item Start now asks the host for the source repo's
structured-session verdict (agentSession.createSupport with a repo
selector) after admission and before any setup or worktree.create.
A remote/wsl/agent refusal, an older host that rejects the repo params,
or an unanswered probe stops the Start with nothing created. Draft mode
never sends the probe.

The host derives the would-be location from the repo row, the project
runtime's configured WSL distro and a WSL UNC path, so a C:\ repo whose
project runs in WSL is refused before a workspace exists.

Also binds mac zips to the macos app-content sidecar in the candidate
manifest, refusing zips whose platform is ambiguous.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(mobile): expect the pre-create repo probe in the Start submit hook

ef2ff81 made a strict Work Item Start ask agentSession.createSupport with a
repo selector before worktree.create, and updated the Tasks-side tests, but
not the new-workspace submit hook test. Its expected call sequence still
omitted the repo probe, failing Mobile Checks deterministically.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(work-items): deliver strict quick-create Start as submit-after-ready

Quick-create derived its structured prompt delivery as `auto-submit` whenever
no draft prompt existed, which is always the case for a strict Work Item
Start. The launch carried `launchOrigin: work-item-start` but not
`submit-after-ready`, so the strict send guard never applied and a refused
send was requeued into the legacy chat outbox behind the Start.

The route resolver now owns the delivery decision: a strict Start always
delivers `submit-after-ready`, legacy quick-create keeps `draft` /
`auto-submit`. The worktree-creation launch boundary also pins strict delivery
from `workItemStartPromptDelivery`, so a stale request cannot reach the legacy
requeue. A strict Start with an empty prompt is refused before any workspace
exists instead of completing or reconciling on an empty send. Direct and
folder Start are unchanged; both already sent `submit-after-ready`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(work-items): report managed Claude account ineligibility as agent, not wsl

`agentSession.createSupport` answered a managed Claude account mismatch with
reason `wsl`, even for a native repo, so mobile told the user the repository
runs inside WSL and orchestration downgraded with "this workspace runs under
WSL". The verdict now uses the existing `agent` reason, which every client
already maps, so no schema or wire change is needed. Mobile's `agent` copy,
before and after create, now names the selected agent or its active account.
Real WSL workspace / project-runtime refusals keep reason `wsl`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(work-items): add strict Start empty-prompt localization

* fix(work-items): single-flight strict Start and Retry per workspace

A mobile Start and a Retry Start (or two Retry taps) for the same workspace
could overlap. The attempt and send journals only make a sequential
re-entry safe: the first flow cleared the send record when it settled, the
overlapping one minted a new send operation, and the prompt reached the
session twice.

Start and Retry now share one module-level in-flight promise per workspace.
Every overlapping caller awaits that same promise, so there is one create,
one session and one prompt. The slot is released only by the promise that
holds it, on success or on a throw, so a later Retry after a settled
outcome runs normally. Retry reads the attempt journal inside the flight,
so a stale banner tap after a settled Start finds nothing and sends
nothing. The banner also guards double taps with a ref.

A phone paired with mobile scope is now told that the refusal is about its
pairing scope instead of being blamed on an older host. Pairing authority
is unchanged.

The pre-create route decision moves unchanged to work-item-start-route.ts
(plus its tests) to keep both files under max-lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(work-items): pin strict Start mobile route closure

* chore(work-items): preserve reviewed mobile Start sources

---------

Co-authored-by: salvadorgu7 <206022846+salvadorgu7@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant