Skip to content

fix(automations): let a host create workspaces for another owner's automation run - #35978

Merged
nwparker merged 1 commit into
mainfrom
fix/34525-host-unknown-automation-provenance
Oct 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/34525-host-unknown-automation-provenance

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19

ELI5

Scheduled automations that a desktop runs on a managed Orca host failed every time with "Invalid automation provenance request". The desktop sent the host a ticket that only the desktop itself can check. #34525 stopped new desktops from sending that ticket. This change makes the host accept the run anyway when an older desktop still sends it.

What Changed

  • On a runtime host's RPC create paths (worktree.create and agent launch), a provenance request for an automation the host doesn't hold (or a host with no automation store) now creates a plain workspace instead of failing.
  • Requests for the host's own automations are still fully verified: run, status, repo and dispatch token.
  • Other store errors (I/O, a corrupt store) still propagate.
  • The desktop's own IPC create path stays strict.

Why

The dispatch token lives in the desktop main process's memory, so a host can never verify a token another owner minted. Rejecting it breaks every scheduled run. Accepting it can't leak anything, because the result is exactly what a client gets by leaving the field out: a workspace with no automation metadata. It crosses no boundary, and it can't touch the host's own run records.

Mixed versions:

Desktop automation workspaces on a host still have no automation badge, and their run pane closes instead of sleeping when the run finishes. The follow-up records the desktop's provenance on the host behind a capability.

Linked Issue

Refs #34433

Thanks @nm7-jp for the detailed report and diagnosis.

Visual Proof

N/A. This is host-side validation only; there's no UI change.

Testing

  • New worktree.create and agent-launch tests. Each fails on base and passes with the fix. The agent-launch test also checks that a store error is still thrown.
  • The existing provenance tests (forged and invalid requests for known automations) still pass.
  • Typecheck, the full static job, the changed-code quality gate, and the orcad terminal smoke all pass locally.

…tomation run

A desktop older than #34525 still sends the host its own dispatch token, which
only that desktop can verify, so the host rejected every run with "Invalid
automation provenance request". A runtime host now ignores a provenance
request for an automation it does not own and creates a plain workspace;
requests for its own automations are still verified.

Refs #34433
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Lets worktree.create and agent.launch create plain workspaces when the host cannot find the requested automation or has no automation store.

  • Runtime hosts create plain workspaces for automation requests they cannot verify.

nwparker acknowledges that these workspaces lack automation badges and close their run panes instead of sleeping them. Host-side attribution is deferred.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[RPC workspace create] --> B{Host finds automation?}
  B -->|Missing automation or no store| C[Create plain workspace]
  B -->|Other error| D[Return error]
  B -->|Yes| E[Check run, repo, status, and token]
  E -->|Valid| F[Create workspace with automation metadata]
  E -->|Invalid| D
Loading

Reviews (1) · Last reviewed commit: "fix(automations): let a host create work..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The provenance resolver now accepts an optional ignoreUnknownAutomation flag. When enabled, it returns undefined for recognized unknown-automation or unavailable-runtime errors, and rethrows other errors. The worktree.create handler and agent launch worktree factory enable this option. Tests cover unknown automation provenance and propagation of an unrelated lookup error.

Priority: Normal

Merge Risk: Minimal · up to 97637

Foreign automation requests can create plain workspaces while owned runs remain subject to validation. No merge-blocking defect was established.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description covers the user impact, implementation, rationale, compatibility behavior, testing, and visual-proof requirement. However, the required Linked Issue section uses "Refs #34433" instead … Replace "Refs #34433" with a valid linked issue reference that satisfies the repository template, such as "Fixes #34433" if appropriate.
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: allowing a host to create workspaces for another owner's automation run.
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.
Full details: Description check

Explanation

The description covers the user impact, implementation, rationale, compatibility behavior, testing, and visual-proof requirement. However, the required Linked Issue section uses "Refs #34433" instead of an actual issue link or "Fixes #" reference.

Resolution

Replace "Refs #34433" with a valid linked issue reference that satisfies the repository template, such as "Fixes #34433" if appropriate.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 5 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Nitpick comments: 1
src/main/runtime/rpc/methods/worktree-create-foreign-automation-provenance.test.ts: 1

7-52: Trivial · Maintainability & Code Quality · Quick win

Cover the no-automation-store branch in worktree.create.

runtime_unavailable represents a host with no automation store. This test covers only Automation not found. The existing runtime_unavailable test covers a prestart launch failure, not this dispatcher path. Add the missing case so this compatibility behavior cannot regress unnoticed.

Suggested fix
-it('creates a plain workspace for a dispatch token from another automation owner', async () => {
+it.each(['Automation not found', 'runtime_unavailable'])(
+  'creates a plain workspace when the automation lookup returns %s',
+  async (automationLookupError) => {
...
-      throw new Error('Automation not found')
+      throw new Error(automationLookupError)
...
-})
+  }
+)

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 61520dc1-abdf-4a91-8ad8-9757d0fbf381
Commits

Reviewing files that changed from the base of the PR and between 5cd7b5d and 976370b.

Files selected for processing: 5
  • src/main/automations/workspace-provenance.ts
  • src/main/runtime/rpc/methods/agent-launch-worktree-creation.ts
  • src/main/runtime/rpc/methods/agent-launch.test.ts
  • src/main/runtime/rpc/methods/worktree-create-foreign-automation-provenance.test.ts
  • src/main/runtime/rpc/methods/worktree.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@nwparker
nwparker merged commit 770a1b8 into main Oct 29, 2026
49 checks passed
@nwparker
nwparker deleted the fix/34525-host-unknown-automation-provenance branch October 29, 2026 14:53
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