fix(mothership): let the agent copy files between workspaces without Projects by waleedlatif1 · Pull Request #9288 · simstudioai/sim · GitHub
Skip to content

fix(mothership): let the agent copy files between workspaces without Projects - #9288

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/workspace-file-copy-without-projects
Oct 21, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/workspace-file-copy-without-projects

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The agent could not copy files at all while Projects are off. A copy between workspaces needs only the turn's resource admission, but the copy authorizer required the Projects rollout for every copy, and the agent was offered copies only through Project file-owner negotiation, which Sim sends only with Projects on.

  • The copy authorizer requires Projects only when a copy names a Project owner (copiesWithinWorkspaces, shared with the sandbox copy routing and proxy). Every workspace belongs to a Project whether or not Projects are on, so the rest of the authorization is unchanged. This also opens POST /api/v2/files/copy between workspaces to direct callers (session, personal API key, OAuth api:write) while Projects are off, under the same per-side role, files.use and personal-key checks that already apply with Projects on; workspace API keys and executors stay refused.
  • Admitted, non-Assistant chat turns declare the worker's new workspace-file-copy capability in clientCapabilities whether or not Projects are on (withFileOwnerContext). A worker that predates the token ignores it; this Sim's older releases never send it, so neither side offers a copy the other can't serve.
  • The recovery marker that restores a turn's resource admission is written for every admitted turn, not only while Projects are on, so a recovered turn can still copy. Every release since the marker shipped (v0.9.28) parses it; a Sim rolled back past that would refuse to recover runs in flight, and during a rolling deploy a run started on the new build whose copy lands on an old build gets the old 503 until the deploy completes.
  • The sandbox lease records workspaceFileCopy for an admitted tool and exports SIM_WORKSPACE_FILE_COPY, and workspace-only copies route through the paired-copy proxy, which still refuses a Project owner without the negotiated protocol.
  • Regenerates generated/protocol.ts from the companion mothership PR.

Companion: simstudioai/mothership#794

Type of Change

  • Bug fix

Testing

  • New unit tests for the sandbox lease, env, copy routing and recovery marker fail on the pre-fix code (6) and pass with the fix; the touched suites pass (67/67)
  • New integration test: a workspace copy authorizes for a direct caller and the agent's paired grant with Projects off, and a Project copy still gets 503
  • The hint integration test now covers the capability on admitted turns, its absence on Assistant turns and the resume route
  • The companion worker suite runs Sim's real CLI through the workbench terminal with SIM_WORKSPACE_FILE_COPY and no protocol

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

@github-actions github-actions Bot added the requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep label Oct 21, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Cross-repo companion check

One or more companion PRs aren't merged into staging yet. Merging this without them will leave copilot and sim out of sync — merge them in lockstep.

  • ❌ simstudioai/mothership#794 — OPEN, not merged (targets staging) — feat(worker): copy files between workspaces where Sim declares it without Projec

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 16 files

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/tools/sandbox-resource-transport.ts
@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issues remain.

Summary

Lets admitted agent turns copy files between workspaces while Projects are off.

  • Workspace-to-workspace copies work without Projects enabled.
  • Admitted agent turns can copy between workspaces without owner negotiation.
  • Recovered admitted turns keep their workspace-copy access.

No actionable new issues found. The earlier unnumbered helper finding is fixed with toArray. This review inspected code; it did not run tests.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Admitted non-Assistant turn] --> B[Declare workspace-file-copy]
  A --> C[Save recovery marker]
  A --> D[Create scoped sandbox lease]
  D --> E[Export SIM_WORKSPACE_FILE_COPY]
  E --> F[Paired copy callback]
  F --> G{Both owners are workspaces?}
  G -->|Yes| I[Check both owners' access]
  G -->|No| H[Require file-owner protocol and Projects]
  H --> I
  I --> J[Copy files]
Loading

Reviews (3) · Last reviewed commit: "chore(mothership): sync the workspace-fi..." · Reviewed by Greptile

Comment thread apps/sim/lib/mothership/application/file-owner-context.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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 issues found across 16 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

…Projects

A copy between workspaces needs only the turn's resource admission, but the copy
authorizer required the Projects rollout for every copy and the agent was offered
copies only through Project file-owner negotiation, so with Projects off every
agent copy failed. The authorizer now requires Projects only for a copy that names
a Project owner. Admitted chat turns declare the worker's workspace-file-copy
capability whether or not Projects are on, the recovery marker restoring
admission is written for every admitted turn, and the sandbox lease records and
exports the same so the workbench terminal binds workspace copies under the
paired grant.
@waleedlatif1
waleedlatif1 force-pushed the fix/workspace-file-copy-without-projects branch from e34b3d8 to d888da2 Compare October 21, 2026 18:58
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai 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 issues found across 16 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 20b9461 into staging Oct 21, 2026
56 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/workspace-file-copy-without-projects branch October 21, 2026 19:17

This branch was previously deployed

1 inactive deployment
Preview — d888da21 Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant