Skip to content

feat: writable per-run copy of a workload's context - #532

Merged
moonlight16 merged 2 commits into
rossoctl:mainfrom
moonlight16:feat/workloads-writable-copy
Oct 14, 2026
Merged

moonlight16 merged 2 commits into
rossoctl:mainfrom
moonlight16:feat/workloads-writable-copy

Conversation

@moonlight16

@moonlight16 moonlight16 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #520 (mocactl workloads and spawn --workload, now merged). Implements the middle option from #517 (seed sandbox files before a leaf runs), for flows such as a "fix" subagent that edits a repo and reruns its tests.

Writable per-run copy

  • A workload run may set contextWritable: true; mocactl spawn --workload ID --writable sends it. Only true requires a workloadId; a non-boolean is 400 context_writable_invalid.
  • That run gets its own writable copy of the workload's files, at the path the agent is told, and the copy is discarded when the run ends. The prompt tells the agent to return its changes, such as a diff or test output. The shared cache copy stays read-only, and writable runs can use up to twice a revision's size on disk.
  • The cache now removes write permission but keeps exec bits, so a bundled ./test.sh runs in both read-only and writable runs.
  • mocactl subagents --json shows "writable": true on rows that have it.
  • Checked in a real ubi9-minimal container as the sandbox user: edits, new files and ./test.sh work in the writable copy; writes to the cache are refused; cleanup leaves nothing behind.

#520 review follow-ups

  • workloads create generates the name client-side (wl- plus 8 hex characters) when --name is omitted, so a lost reply still says which workload to delete.
  • spawn --workload checks the workload with GET /workloads/{id} first and fails fast if it is missing or not ready.
  • The upload sends the grant's contentType and refuses any other value.

Durable writes that outlive a run are #476 (phase 2: per-workload sandboxes and storage).

🤖 Generated with Claude Code

@moonlight16
moonlight16 requested a review from pdettori as a code owner October 14, 2026 19:28
@evaline-ju evaline-ju added ready-for-ai-review Request automated AI code review from clawgenti and removed ready-for-ai-review Request automated AI code review from clawgenti labels Oct 14, 2026
@evaline-ju

Copy link
Copy Markdown
Contributor

#520 is merged so rebase can be done

@moonlight16
moonlight16 force-pushed the feat/workloads-writable-copy branch from d19d87b to 5bcdf5e Compare October 14, 2026 19:36
@evaline-ju evaline-ju added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 14, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the writable per-run context copy (harness overlay + sweep + cleanup scripts, /v1/runs contextWritable validation, mocactl --writable, spawn preflight, client-side workload names, grant contentType check) and the docs/OpenAPI updates against main 67366cf. No blocking issues found.

  • The cp -a → chmod u+w → touch → rename sequence stays inside the ref the run holds, and cleanup never chmod -Rs through the link. The sweep skips links, so it never touches the shared cache.
  • rejectInvalidContextWritable runs before the async/workload gates. workloadId: null still reaches resolveWorkloadRun, so true can't be silently dropped.
  • chmod -R u+rX,a-w keeps dirs traversable and keeps exec bits, and the real-shell tests cover it.

There are a few nits, all about wrapping. CI is green on this head, and the one commit has a DCO sign-off.

Comment thread docs/context-service.md Outdated
archive with more entries than the entry limit, extracts it read-only (directories `0555`, files
`0444`) and publishes the revision atomically under `flock`.
archive with more entries than the entry limit, extracts it read-only (write permission removed;
directories stay traversable and executable files keep their exec bit) and publishes the revision atomically under `flock`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: this line runs to ~123 chars after the edit. Please reflow the paragraph to the file's ~100-column wrap.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reflowed in 537b4ac.

Comment thread docs/context-service.md Outdated
After the run, its view is removed and, by default, so is any revision no run still uses. Shared
After the run, its view, or its writable copy, is removed and, by default, so is any revision no
run still uses. A writable copy left by a harness that died is swept a day later, as abandoned
uploads are. Shared

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: uploads are. Shared is left as a stub line by the insertion. Reflow the paragraph so it wraps evenly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reflowed in 537b4ac.

Comment thread harness/src/context-overlay.ts Outdated
* identical content. The owner's part of the key is an HMAC under a secret agents never see, so an
* on a miss. A writable run gets its own copy of the cached revision there instead of a link, which
* it may change and which cleanup removes; the cached copy stays read-only. Keying the cache by
* owner means two users never share a copy, even when both uploaded identical content. The owner's part of the key is an HMAC under a secret agents never see, so an

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: this doc-comment line is ~165 chars, and prettier won't rewrap comments (printWidth 100). Please reflow it by hand.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reflowed in 537b4ac.

moonlight16 added a commit to moonlight16/moca that referenced this pull request Oct 14, 2026
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Jeremy Cohn <[email protected]>
A workload run may set contextWritable: true (mocactl spawn --workload ID --writable). That run gets its own writable copy of the workload's files, discarded when the run ends; the shared cache stays read-only. The cache now keeps exec bits while removing write permission.

Also addresses rossoctl#520 review: workloads create generates the name client-side, spawn --workload checks the workload is ready first, and the upload sends the grant's content type.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Jeremy Cohn <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Jeremy Cohn <[email protected]>
@moonlight16
moonlight16 force-pushed the feat/workloads-writable-copy branch from 537b4ac to 8f565d0 Compare October 14, 2026 21:02
@moonlight16
moonlight16 merged commit 324e202 into rossoctl:main Oct 14, 2026
15 checks passed
@evaline-ju evaline-ju linked an issue Oct 15, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to seed sandbox files before a leaf starts running

3 participants