Skip to content

fix(mobile): name a create's launch so a lost reply cannot build two workspaces - #21137

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/mobile-launch-operation-id
Sep 17, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/mobile-launch-operation-id

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​955 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​943
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​239 $\color{#cf222e}{\Huge{\mathbf{−}}}$​104 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​135

ELI5

If the mobile app asked Orca to create a workspace and the reply was lost, retrying could create a second workspace. The retry now carries the same launch identity, and the host returns the first launch's recorded result instead of running it again.

What Changed

  • Added a dedicated agent.launchReplay RPC and the required agent.launch.replay-required.v1 capability. A mobile client uses this route only when the receiving host advertises it; mixed-version hosts refuse the unavailable method instead of silently dropping replay identity.
  • Moved replay authority to the receiving host. A durable launch receipt records the operation before effects run and returns the recorded success or failure to later deliveries with the same operation ID.
  • Kept one operation ID across ambiguous delivery retries. The host owns workspace-name collision detection and suffix selection, so the client does not invent a new identity or infer retry safety from error text.
  • Added cross-boundary contract tests under Mobile Checks and a workflow assertion that keeps every directly imported root dependency in that workflow's path triggers.

Before this change, a lost reply followed by a retry could run the launch twice. After this change, the receiver either replays the recorded outcome or refuses the replay route before any launch effect occurs.

Why

Replay safety has to be enforced where the launch runs. Making identity optional on the existing RPC allowed an older or intermediate receiver to strip it and still execute, while client-side classification could mistake nested error text for proof that retrying was safe. A required replay route, negotiated capability, and host-owned receipt make admission explicit and keep bookkeeping failures from authorizing another launch.

The change stays limited to mobile workspace creation, its host launch path, and the tests and workflow triggers needed to protect that contract.

Linked Issue

N/A — reported directly in this PR.

Visual Proof

Native iOS validation used an iPhone 17 Pro simulator with the Electron host launched in background mode and inspected through CDP.

Before create After create
Mobile create form Created mobile workspace

Full native QA evidence and selected-agent screenshot

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Native iOS flow: selected Claude, submitted one create, and observed exactly one workspace and one agent session.

  • Focused contract validation: 100 root tests and all 20 mobile replay/architecture cases passed under the Mobile Checks dependency shape.

  • Local verification: root and mobile typechecks, generated RPC catalog verification, changed-code quality checks, and formatting checks passed.

  • Exact-head CI: Mobile Checks; eight Node test shards; typecheck; static analysis; package and Windows package; cross-version wire compatibility; and macOS, Windows, and Ubuntu native smoke checks passed.

  • The native run exercised the real create flow. Lost-reply fault injection is covered by the automated replay tests rather than the simulator run.

AI Disclosure

Review

Seven adversarial review loops completed. The final loop was clean after an independent architecture challenge and correction of the Mobile Checks dependency boundary. The final readiness audit found no blocking product, architecture, performance, security, cross-platform, SSH, folder-workspace, or compatibility issue.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The replay method and capability are additive for remote-wire compatibility. Hosts that do not advertise the capability are never sent the replay RPC, and their legacy RPC contracts are unchanged. The runtime path adds no polling or repeated scans; replay is a bounded receipt lookup on launch delivery.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…workspaces

`agent.launch` admits a caller-supplied `operationId` through a durable ledger, so
exactly one execution happens and every replay returns the recorded answer. No client
sent one, so the machinery was inert and the original defect was still live: mobile
retries a lost create by design, and a retried launch built a second agent in a second
workspace.

Mobile now mints an operation id per create candidate and sends it whenever the host
advertises `agent.launch.replay.v1`.

The invariant is one operation per candidate. `computeAgentLaunchFingerprint` folds
`target` whole, so the workspace name is inside the fingerprint; carrying one id across
a name-collision bump would meet its own row under a differing fingerprint and refuse
`agent_session_operation_conflict`, failing the create outright on the second candidate.
The id is therefore minted beside `clientMutationId` at the top of each loop iteration
and reused verbatim by every retry arm inside that candidate — never re-minted, since a
new id is a new operation.

Admission runs ahead of every effect, so `_invalid` / `_expired` / `_capacity` prove
nothing launched: those re-send the same candidate unnamed rather than let bookkeeping
fail a create the host would have performed. `_unknown` is the one refusal that is not
safe to re-send, and it surfaces.

Also corrects a false comment: the legacy path caches the whole launch under
`clientMutationId`, so inside its 60s window a replay adds neither a workspace nor a
surface, and outside it adds both — not "a second surface, never a second workspace".
@coderabbitai

coderabbitai Bot commented Sep 17, 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f8fac29b-d43c-4ef3-a30e-2bf7d88ff79c

📥 Commits

Reviewing files that changed from the base of the PR and between 8f5a716 and a293e8e.

⛔ Files ignored due to path filters (1)
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (17)
  • .github/workflows/mobile.yml
  • mobile/src/tasks/agent-launch-mobile-replay.test.ts
  • mobile/src/tasks/mobile-agent-launch-architecture.test.ts
  • mobile/src/tasks/mobile-workspace-create-operations.ts
  • mobile/src/tasks/worktree-create-capability.test.ts
  • mobile/src/tasks/worktree-create-capability.ts
  • mobile/src/tasks/worktree-create-launch-operation.test.ts
  • mobile/src/tasks/worktree-create-retry.ts
  • src/main/ipc/worktree-remote.ts
  • src/main/runtime/rpc/errors.ts
  • src/main/runtime/rpc/methods/agent-launch-schemas.ts
  • src/main/runtime/rpc/methods/agent-launch.ts
  • src/main/runtime/runtime-local-worktree-create-candidate.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-mobile-method-allowlist.ts
  • src/shared/new-workspace/worktree-create-collision.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/agent-launch-params.ts

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


📝 Walkthrough

Walkthrough

The change introduces structured agent-launch capability data with replay support. Mobile worktree creation now mints and reuses durable operation IDs, selects replay-specific RPC operations, and applies route-specific retry behavior. Runtime handlers add agent.launchReplay, preserve collision and replay errors, and record collision failures. New tests cover capability negotiation, retries, reconnections, durable receipts, refusals, and collision handling. Mobile workflow path filters are also updated.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to a293e

A migration to a host without replay support can unnecessarily fail workspace creation instead of using the safe fallback, but the impact is limited to this compatibility path.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 28 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the required change, rationale, testing, visual proof, and checklist. However, the required Linked Issue section contains “N/A” instead of an issue reference. Add a valid linked issue, such as Fixes #123``, and update the Linked Issue section before merging.
Linked Issues check ⚠️ Warning The pull request explicitly states Linked Issue: N/A, but the repository template requires an issue link in every pull request. Link the pull request to the issue it addresses using the required Fixes #<issue-number> format.
✅ Passed checks (2 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes remain aligned with mobile workspace creation replay safety, host-side launch handling, related contracts, tests, and workflow coverage.
Title check ✅ Passed The title clearly describes the primary change: assigning a launch identity to prevent duplicate workspace creation after a lost reply.
Full details: Docstring Coverage

Explanation

Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 28 files. (1 skipped: 1 unsupported.)

  • 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.

@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.

Caution

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

⚠️ Outside diff range comments (1)

🟠 Major · Do not gate replay-safe agent.launch retries on… · worktree-create-retry.ts:247-248

mobile/src/tasks/worktree-create-retry.ts:247-248
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Do not gate replay-safe agent.launch retries on worktreeCreateIdempotency.

When launch.replay is true, launchOperationId is sent to the durable agent.launch ledger. The host records and replays the full launch result for that ID. After expiry, it rejects the stale ID instead of treating it as a new launch.

This guard still rejects delivery-unknown and cutover retries when only worktree idempotency is unavailable. If the launch committed before its response was lost, the flow reports failure, and a later user retry can mint a new operation ID and create another workspace.

Allow retries when launchAgent && launchOperationId is present. Keep the existing deadline only for worktree.create; a separate route-aware deadline is not required for the launch ledger. Add coverage for { replay: true } with worktreeCreateIdempotency: false.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 38e7de1f-5384-48f1-88ef-9c118abe37f9

📥 Commits

Reviewing files that changed from the base of the PR and between 2c2d068 and 5febb5c.

📒 Files selected for processing (12)
  • mobile/src/components/use-new-workspace-create-submit.ts
  • mobile/src/session/mobile-structured-agent-session-launch.ts
  • mobile/src/session/mobile-structured-agent-session-rpc.ts
  • mobile/src/session/mobile-structured-agent-session-send.ts
  • mobile/src/session/structured-session-operation-id.ts
  • mobile/src/tasks/agent-launch-worktree-create.ts
  • mobile/src/tasks/blank-workspace-create.ts
  • mobile/src/tasks/source-workspace-create.ts
  • mobile/src/tasks/worktree-create-capability.test.ts
  • mobile/src/tasks/worktree-create-capability.ts
  • mobile/src/tasks/worktree-create-launch-operation.test.ts
  • mobile/src/tasks/worktree-create-retry.ts

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

@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 unnamed re-send arm can still build a second workspace. agent_session_operation_capacity is not exclusive to the launch's own pre-effect admission — the nested structured-session attach shares the same durable ledger and can raise it after the worktree already exists, and this arm then re-runs the launch unnamed. See the inline note on worktree-create-retry.ts.

Reviewed changes

  • Named launches — mobile mints a durable operationId per candidate and sends it on agent.launch, reusing it verbatim across the ambiguous-drop and cutover replay arms within that candidate (worktree-create-retry.ts).
  • Replay capability negotiation — NewWorktreeRuntimeCapabilities.agentLaunch becomes { replay: boolean } | false, answered by the same status.get probe as worktree-create idempotency; the id is only sent once the host advertises agent.launch.replay.v1 (worktree-create-capability.ts).
  • Refusal classification — classifyAgentLaunchOperationRefusal splits ledger refusals into unadmitted (re-send unnamed) and unknown (surface), with _conflict deliberately unhandled (agent-launch-worktree-create.ts).
  • Operation-id minter — extracted to structured-session-operation-id.ts so tasks/ can reuse it without the native-chat send graph; the three existing importers were updated.
  • Tests — new worktree-create-launch-operation.test.ts pins per-candidate reuse, re-minting on a collision bump, capability gating, each refusal class, and the shipped minter shape.

ℹ️ Nitpicks

  • classifyAgentLaunchOperationRefusal's 'unknown' return is never distinguished from null — the only caller compares === 'unadmitted' — and its comment ("The same id may be re-sent") describes behavior the caller does not perform. Returning a boolean, or having the caller act on 'unknown', would remove the dead branch rather than leave a classification that reads as if it were driving a decision.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek 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

  • Ledger refusals preserve launch identity — the unnamed re-send arm is gone; agent_session_operation_capacity / _invalid / _expired now surface with the same operationId instead of re-sending the candidate without one, so a refusal raised after the worktree exists (the nested structured-session attach) can no longer produce a second workspace (worktree-create-retry.ts:117-149).
  • Refusal classification deleted — classifyAgentLaunchOperationRefusal and UNADMITTED_LAUNCH_OPERATION_CODES are removed, so nothing branches on ledger codes client-side any more (agent-launch-worktree-create.ts).
  • Replay-aware downgrade guard — sendWorktreeCreateResilient returns { response, replayed }, and the agent_launch_unsupported downgrade is skipped when the response came from a cutover/ambiguous replay, where the first call may already have created the workspace (worktree-create-retry.ts:205-230).
  • Host-level replay test — agent-launch-mobile-replay.test.ts drives the real dispatcher and the mobile retry loop, asserting one createManagedWorktree, one attempt, and an unknown ledger row after a nested capacity refusal.
  • Capability test fixtures — agentLaunchSupported fixtures move from true to { replay: false } to match the { replay: boolean } | false shape.

ℹ️ Nitpicks

  • The PR description still documents the removed unnamed fallback ("The unnamed fallback, stated plainly", and the _unknown / _conflict ablation table). It now describes behavior the code deliberately does not perform, so it is worth rewriting before merge.

Pullfrog  | View workflow run | Using DeepSeek 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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: fab39547-f4b1-48de-90eb-93c6ad6d3600

📥 Commits

Reviewing files that changed from the base of the PR and between 5febb5c and 3befd85.

📒 Files selected for processing (6)
  • mobile/src/tasks/agent-launch-worktree-create.ts
  • mobile/src/tasks/blank-workspace-create.test.ts
  • mobile/src/tasks/source-workspace-create.test.ts
  • mobile/src/tasks/worktree-create-launch-operation.test.ts
  • mobile/src/tasks/worktree-create-retry.ts
  • src/main/runtime/rpc/methods/agent-launch-mobile-replay.test.ts

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

timeoutMs: WORKTREE_CREATE_TIMEOUT_MS
}))
// A refusal on the replacement connection says nothing about what the first call created.
return { response, replayed: migrationRetry > 0 || ambiguousRetry > 0 }

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 | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '190,245p' mobile/src/tasks/worktree-create-retry.ts
sed -n '1,140p' mobile/src/transport/stable-logical-rpc-client.ts
rg -n 'LogicalClientCutoverError|isRpcDeliveryUnknown' mobile/src

Repository: stablyai/orca

Length of output: 23144


🏁 Script executed:

#!/bin/bash
sed -n '1,180p' mobile/src/tasks/worktree-create-retry.ts
sed -n '180,275p' mobile/src/tasks/worktree-create-retry.ts
cat -n mobile/src/transport/rpc-delivery-ambiguity.ts
sed -n '150,245p' mobile/src/tasks/worktree-create-retry.test.ts
sed -n '300,355p' mobile/src/tasks/worktree-create-retry.test.ts
rg -n -C 8 'replayed|method_not_found|agent_launch_unsupported|LogicalClientCutoverError|markRpcDeliveryUnknown' mobile/src/tasks/worktree-create-retry.test.ts mobile/src/tasks/worktree-create-launch-operation.test.ts

Repository: stablyai/orca

Length of output: 50369


Do not mark every cutover as replayed.

LogicalClientCutoverError carries isRpcDeliveryUnknown only when its cause is marked delivery-unknown. The current migrationRetry > 0 check marks even a known-unsent cutover as replayed. When the replacement returns agent_launch_unsupported or method_not_found, this suppresses the safe worktree.create downgrade and returns an error. The existing launch-operation test reproduces this path.

Track whether the earlier request may have executed from isRpcDeliveryUnknown(error), including delivery-unknown cutovers. Preserve replay protection for those cutovers while allowing downgrade after a known-unsent cutover.

@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 behavior change worth confirming inline.

Reviewed changes

  • Launch receipts now authorize replay — sendWorktreeCreateResilient derives replaySupport from the selected method: a named launch's durable operationId authorizes the ambiguous and connected-timeout arms, while the unnamed worktree.create route keeps the clientMutationId deadline (worktree-create-retry.ts).
  • Durable ids get an unbounded deadline — the connected-transport timeout guard no longer blocks a named launch, because the host itself refuses expired or unknown operation ids; the reconnect wait stays bounded by WORKTREE_CREATE_AMBIGUOUS_RECONNECT_WAIT_MS (worktree-create-retry.ts).
  • Tests — a mobile case proves a replay: true launch still retries under a cutover when worktreeCreateIdempotency is false, a bounded-timeout case proves retries reuse one id, and a host-level case proves an unnamed launch is not replayed after a restart (worktree-create-launch-operation.test.ts, agent-launch-mobile-replay.test.ts).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

): Promise<RpcResponse> {
): Promise<{ response: RpcResponse; replayed: boolean }> {
// Only the selected method's receipt can authorize replay after an ambiguous delivery.
const replaySupport = launchAgent ? launchOperationId : worktreeCreateIdempotency

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.

replaySupport is null whenever the launch route is selected without replay (an agent.launch.v2 host that does not advertise agent.launch.replay.v1), so the !replaySupport guard now throws before the cutover arm too — not just the ambiguous arm. On main those creates retried under worktreeCreateIdempotency, whose advertised 60s TTL is the same dedupeWorktreeCreate cache the unnamed launch path keys on agent.launch:<clientMutationId>, so a real cutover (same host, warm cache) was safe to retry. Was dropping that intended, or should the launch route fall back to launchOperationId ?? worktreeCreateIdempotency?

Technical details
# The selected-method gate also disables the legacy cutover retry

## Affected sites
- `mobile/src/tasks/worktree-create-retry.ts:213` — `replaySupport = launchAgent ? launchOperationId : worktreeCreateIdempotency`; `launchOperationId` is `null` when `launch.replay` is false (`:109`), so `replaySupport` is `null` on that host.
- `mobile/src/tasks/worktree-create-retry.ts:234-245` — `if (!replaySupport) throw error` precedes `isLogicalClientCutoverError`, so the bounded cutover retry (`WORKTREE_CREATE_CUTOVER_MAX_RETRIES`) no longer runs.
- Host (unchanged): `src/main/runtime/rpc/methods/agent-launch.ts:140-154` — the unnamed launch path dedupes through `context.runtime.dedupeWorktreeCreate(repo, 'agent.launch:' + clientMutationId, ...)`, the same cache `status.get` describes via `worktreeCreateIdempotency: { dedupeTtlMs: WORKTREE_CREATE_RESULT_TTL_MS }` (`orca-runtime-get-status.ts:125`, `orca-runtime-core.ts:72`).
- `agent-launch-mobile-replay.test.ts:99-116` — the new "does not replay an unnamed launch" case models the lost receipt with a cutover plus a dispatcher swap, but a real cutover swaps the transport to the same host, not the host process.

## Required outcome
- Decide whether an `agent.launch.v2`-without-`replay.v1` host may still retry a cutover/delivery-ambiguous launch under the clientMutationId cache. If yes, fall back to `worktreeCreateIdempotency` when `launchOperationId` is absent; if no, the rationale is that an in-memory receipt is never trusted, which is stricter than the `worktree.create` route still is.

## Open questions for the human (optional)
- Can a released host advertise `agent.launch.v2` without `agent.launch.replay.v1`? The two capabilities landed ~2h apart (#20999 then #21106), so if no desktop release was cut between them this is unreachable and the note is moot.

@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 move fixes the typecheck job, but the unit suite it now lives in is still red — the inline note has the CI evidence and the options for making the test actually run.

Reviewed changes

  • Moved the host-level mobile launch replay test from src/main/runtime/rpc/methods/agent-launch-mobile-replay.test.ts to tests/e2e/agent-launch-mobile-replay.unit.test.ts, rewriting its mobile and main imports to the new relative depth and matching the existing tests/e2e/**/*.unit.test.ts convention. This clears the tsconfig.node.json "not listed within the file list" errors and the typecheck job now passes, but the test still cannot be transformed by the root Vitest project that collects it.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek 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.

Important

The delta's new host-level test cannot run: tests/e2e/mobile-agent-launch-architecture.unit.test.ts is collected by the root unit project and its mobile/src/** imports fail to transform (TSConfckParseError), so the unit shard stays red and the new coverage never executes. The rest of the redesign reads coherent.

Reviewed changes

  • Distinct replay method — agent.launchReplay requires operationId via AgentLaunch.required(...), so an older receiver cannot silently drop the replay requirement; it is negotiated by a new agent.launch.replay-required.v1 capability and mobile only sends it once that is advertised (agent-launch.ts, agent-launch-params.ts, protocol-version.ts, worktree-create-capability.ts).
  • Typed collision — the host's exhausted name search now throws WorktreeCreateCollisionError / worktree_create_collision, so the ledger settles the row failed before any workspace exists and a replay answers the collision instead of re-running it (worktree-create-collision.ts, runtime-local-worktree-create-candidate.ts, worktree-remote.ts, agent-launch.ts).
  • Mobile loop changes — for a replay launch the candidate-bump loop is disabled and ledger refusals surface with the same operation id; the worktree.create downgrade is gated on !sent.replayed, and the named arms share one id across cutover / ambiguous / timeout retries (worktree-create-retry.ts).
  • Tests — new mobile (worktree-create-launch-operation.test.ts) and host-level (mobile-agent-launch-architecture.unit.test.ts) suites, plus the WebSocket-allowlist case.

ℹ️ Nitpicks

  • agentLaunchCreateParams' third operationId parameter is never non-null at its only call site: sendWorktreeCreateResilient routes a truthy id to agentLaunchReplayRun and builds that branch's params inline, so the helper is only ever called with launchOperationId in the null branch (worktree-create-retry.ts:228-241). Dropping the parameter and the ...(operationId ? ...) spread would stop it reading as if agent.launch still carries an id from this path.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

// on — expanding or renaming entries without updating the CLI would silently
// change user-visible error codes.
const RUNTIME_PASSTHROUGH_CODES: ReadonlySet<string> = new Set([
WORKTREE_CREATE_COLLISION_CODE,

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.

WORKTREE_CREATE_COLLISION_CODE only ever travels as an error's .code (set in agent-launch.ts:284), but RUNTIME_PASSTHROUGH_CODES is matched against the thrown error's message (errors.ts:208), so this entry can never fire — the code reaches clients through the STRUCTURED_RUNTIME_PASSTHROUGH_CODES entry at line 86. Harmless as-is, but if the intent was for worktree.create (which throws WorktreeCreateCollisionError with no .code) to surface worktree_create_collision, that error needs to carry the code; today it still maps to runtime_error.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual proof (native iOS)

Device: iPhone 17 Pro, iOS 26.5 Simulator

Flow: Opened this PR's mobile development client, paired to a hidden desktop instance of this worktree, then ran the real Create worktree path with Claude selected (project qa-seed, suggested name left empty).

Observed single-result outcome: One submit produced one new workspace (handfish) and one Claude launch. Host/Electron state after submit: worktrees main (pre-existing seed checkout) + handfish; one launch config (agentType: claude) and one terminal pane. Mobile landed on the connected session with a single Terminal 1 tab and “Start a chat with Claude”.

Gap: The lost-reply replay edge is nonvisual. It was not fault-injected here: there is no safe, reversible production control to drop the create reply and retry the same candidate without source edits.

Connected host (before create):

https://github.com/user-attachments/assets/5dc43659-6da7-4306-acd1-5bac26af4ce7

Create form before submit (Claude selected):

https://github.com/user-attachments/assets/a6bcc4cf-afb7-409f-8599-d0517ab9b023

Connected workspace/session after submit:

https://github.com/user-attachments/assets/4cc3f319-9ad5-47b5-ad0f-b2957ead9d19

@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 CI-trigger gap inline.

Reviewed changes

  • Relocated the two host-level launch contract suites from tests/e2e/ into mobile/src/tasks/, where mobile/vitest.config.ts (oxc: { tsconfig: false }) can collect them; the root unit project no longer matches, and the suites run and pass (35 tests across the three launch files locally).
  • Added host/shared paths to the Mobile Checks pull_request trigger so desktop-side edits these suites exercise re-run the mobile job, and dropped the now-redundant single src/shared/agent-launch-intent.ts entry in favour of src/shared/agent-launch-*.ts / agent-session-*.ts globs.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread .github/workflows/mobile.yml Resolved

@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 in this delta.

Reviewed changes

  • Mobile Checks trigger coverage — added src/main/runtime/device-registry.ts and src/main/runtime/orca-runtime.ts to the mobile.yml path filter, closing the direct-import gap flagged against a293e8e (mobile-agent-launch-architecture.test.ts constructs a DeviceRegistry). The addressed thread was resolved.
  • Trigger contract test — new config/scripts/mobile-launch-contract-workflow.test.mjs parses both host-level launch contract suites' direct relative imports and asserts every resolved src/ dependency matches a workflow path pattern. Confirmed the RED arm locally by removing the device-registry.ts entry (suite fails), then restored a clean tree; oxlint and oxfmt --check clean.

Two earlier threads on this PR are untouched by this delta and remain open, so this run is not an approval: the launch-route replay fallback (worktree-create-retry.ts:219) and the inert worktree_create_collision entry in RUNTIME_PASSTHROUGH_CODES (src/main/runtime/rpc/errors.ts:58).

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: CLEAN

Final reviewed head: b4e5d6179a9a61572ee26706d39de2f6b636a2bf

  • Completed seven adversarial review loops with the same high-reasoning reviewer. The final loop found no remaining meaningful issue.
  • After repeated findings, an independent architecture challenge replaced the optional client-side guard with a receiver-enforced replay RPC, negotiated required capability, and host-owned durable launch receipt. Private reference comparison supported the ownership and admission mechanism; material lifecycle differences were reviewed and recorded internally.
  • Fixed every substantive finding on the PR branch, including refusal/replay identity handling, host-owned collision suffixing, nested-error retry authorization, test collection, Mobile Checks coverage, and direct-dependency workflow triggers.
  • The start and end release-readiness audits completed. The final exact-head audit found no blocking correctness, architecture, performance, security, cross-platform, SSH, folder-workspace, or compatibility issue.

Validation

  • Exact-head CI is green: Mobile Checks; all eight Node test shards; typecheck; static analysis; package and Windows package; cross-version wire compatibility; and macOS, Windows, and Ubuntu native smoke checks.
  • Focused local validation passed 100 root tests, all 20 mobile replay/architecture contract cases, root and mobile typechecks, generated-contract verification, changed-code quality checks, and formatting checks.
  • Native iOS visual proof covers the real create flow with one resulting workspace and one agent session.

The lost-reply edge was not fault-injected in the native simulator because there is no safe production control for dropping only that reply. The automated replay suites cover that case. No blocking gap remains.

@brennanb2025
brennanb2025 merged commit abc8386 into main Sep 17, 2026
34 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…workspaces (stablyai#21137)

* fix(mobile): name a create's launch so a lost reply cannot build two workspaces

`agent.launch` admits a caller-supplied `operationId` through a durable ledger, so
exactly one execution happens and every replay returns the recorded answer. No client
sent one, so the machinery was inert and the original defect was still live: mobile
retries a lost create by design, and a retried launch built a second agent in a second
workspace.

Mobile now mints an operation id per create candidate and sends it whenever the host
advertises `agent.launch.replay.v1`.

The invariant is one operation per candidate. `computeAgentLaunchFingerprint` folds
`target` whole, so the workspace name is inside the fingerprint; carrying one id across
a name-collision bump would meet its own row under a differing fingerprint and refuse
`agent_session_operation_conflict`, failing the create outright on the second candidate.
The id is therefore minted beside `clientMutationId` at the top of each loop iteration
and reused verbatim by every retry arm inside that candidate — never re-minted, since a
new id is a new operation.

Admission runs ahead of every effect, so `_invalid` / `_expired` / `_capacity` prove
nothing launched: those re-send the same candidate unnamed rather than let bookkeeping
fail a create the host would have performed. `_unknown` is the one refusal that is not
safe to re-send, and it surfaces.

Also corrects a false comment: the legacy path caches the whole launch under
`clientMutationId`, so inside its 60s window a replay adds neither a workspace nor a
surface, and outside it adds both — not "a second surface, never a second workspace".

* fix(mobile): preserve launch identity on refusals

* fix(mobile): use launch receipts to authorize replay

* test: move mobile launch replay coverage outside node project

* fix(mobile): enforce replay-safe launch delivery at the host

* test: run mobile launch contracts in mobile checks

* test: cover mobile launch contract workflow dependencies
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