Repository navigation
feat: workload runs start in their context - #534
Conversation
A workload run's working directory is now its context view (or writable copy), so pwd and ls show the project at once. When a revision has a workspace/ root (contextctl ctx pack), the view and the copy point at it, so files appear as in the source folder. The prompt names the session directory as scratch space for read-only runs. Docs and mocactl hints use contextctl ctx pack. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Jeremy Cohn <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Starting a workload run in its context, and rooting the view at workspace/, is a clean change. It reuses the solve leaf's podCwd override. The [ ! -L ] guard keeps a bundled workspace link from re-rooting a view outside the cache. Cleanup and the sweep are unaffected, because they never resolve the link target. The worker creates the scratch directory on every Exec (WorkspaceRunner.Run MkdirAll), so the note's podCwd always exists.
Blocking: the check job (Test step) is red on this head. Main is green at the base and after it. The new real-shell populate test stubs sha256sum with a function that doesn't read stdin, which races printf into SIGPIPE under pipefail. That is the likely cause; see the inline comment. Please fix it and re-run CI.
Non-blocking: sibling bundle roots are hidden when workspace/ exists, the docs/hints depend on the unmerged rossoctl/context-service#56, and the scratch path wording is container-tier only.
Author: moonlight16 (MEMBER — maintainer)
Areas reviewed: TypeScript (harness overlay scripts, prompt leaf), tests, Docs, mocactl CLI text
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: failing (check → Test step); all other checks pass
| // No flock(1) on macOS, and its sha256sum lacks --status; neither is under test here. | ||
| execFileSync('bash', [ | ||
| '-c', | ||
| 'flock() { :; }\nsha256sum() { :; }\n' + |
There was a problem hiding this comment.
must-fix — this stub makes the test flaky, and it is the most likely cause of the red check job (Test step) on this head.
The populate script runs printf '%s %s\n' … "$ARCHIVE" | sha256sum -c --status under set -euo pipefail. sha256sum() { :; } exits without reading stdin. When it exits before printf writes, printf gets SIGPIPE (exit 141), pipefail makes the pipeline fail, set -e aborts the script, and execFileSync throws. The same pipeline on GNU bash 5.2 failed 23 of 300 runs here.
Main is green before and after this PR's base, and every other ci.yml run today passed. The 29 tests in the two changed files also passed once in an isolated rerun, which is what you'd expect from an intermittent failure.
Suggested fix: drain stdin in the stub:
'flock() { :; }\nsha256sum() { cat >/dev/null; }\n' +There was a problem hiding this comment.
Fixed in 367474a: the stub now drains stdin (sha256sum() { cat >/dev/null; }). That test passed 25 runs in a row locally.
| * the cache. | ||
| */ | ||
| const VIEW_SOURCE = | ||
| 'SRC="$CACHE"; if [ -d "$CACHE/workspace" ] && [ ! -L "$CACHE/workspace" ]; then SRC="$CACHE/workspace"; fi'; |
There was a problem hiding this comment.
suggestion — when a revision has workspace/ and other top-level roots, the view now hides those roots. The agent can no longer reach the revision root at all: the prompt names only the view, and the view is cache/<rev>/workspace.
rossoctl/context-service#56 documents bundle content under harnesses/, memory/, knowledge/, artifacts/, or workspace/. ctx pack writes only workspace/ (plus manifest/checksums), but a bundle that mixes workspace/ with memory/ or knowledge/ would silently lose them. Options:
- re-root only when
workspace/is the only content root, or - when siblings exist, add the revision root's path to the prompt note.
At minimum, the "Runs" docs should say that a revision's other roots aren't visible when it has workspace/.
There was a problem hiding this comment.
Done in 367474a: the view re-roots at workspace/ only when it is the revision's only content root. With harnesses/, memory/, knowledge/ or artifacts/ present, the view is the whole revision, so nothing is hidden. Added a real-shell test for the mixed case and documented it under Runs.
| `contextctl ctx pack` puts a directory's files, the view shows that directory, so `src/` sits at the | ||
| root of the working directory. Otherwise the view shows the whole revision. Only a real directory | ||
| counts: a `workspace` link in the bundle is ignored. The prompt tells the agent its working | ||
| directory and, for a read-only run, that the session's own directory, `/workspace/<session>`, is |
There was a problem hiding this comment.
nit — /workspace/<session> is the scratch directory only on container workers that advertise workspace-subdir (sessionPodCwd, select-sandbox.ts:398). The microVM tier and older workers keep podCwd at /workspace, so there the note points at /workspace. The code is right, since the note uses the lease's actual podCwd. Consider "the session's own working directory (/workspace/<session> on container workers)" here and in packages/mocactl/README.md:188.
There was a problem hiding this comment.
Done in 367474a: "the session's own working directory (/workspace/<session> on container workers)" in both docs.
| } catch { | ||
| io.err( | ||
| `--context ${opts.contextPath} does not exist (build one with \`contextctl ctx export\`)`, | ||
| `--context ${opts.contextPath} does not exist (build one with \`contextctl ctx pack DIR --type workspace -o FILE\`)`, |
There was a problem hiding this comment.
suggestion — this hint and the docs (README.md:177/185, docs/context-service.md:34-36) now point users only at contextctl ctx pack, which exists only in the still-open rossoctl/context-service#56. A Context Service without #56 also rejects bundles containing workspace/. Until #56 merges and ships, a user following these instructions has no command that works.
Either merge after #56 ships, or keep ctx export as the fallback here. Also, "coming in a Context Service PR" should link rossoctl/context-service#56 directly in both docs. Minor: --type workspace is #56's default and only accepted value, so the hint could drop it.
There was a problem hiding this comment.
Done in 367474a: both docs link rossoctl/context-service#56 directly, and --type workspace is dropped from the hint and docs. I'll merge this after #56 ships.
- Drain stdin in the populate test's sha256sum stub, so printf never hits SIGPIPE under pipefail (the flaky check job). - Root the view at workspace/ only when it is the revision's only content root, so harnesses/, memory/, knowledge/ and artifacts/ are never hidden. - Describe the scratch directory as the session's own working directory (/workspace/<session> on container workers). - Link rossoctl/context-service#56 for ctx pack and drop the redundant --type workspace. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Jeremy Cohn <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
All four items from the b707c71 review are fixed in 367474a, and CI is green on this head, including check.
- must-fix (flaky test): the
sha256sumstub now drains stdin (cat >/dev/null), soprintfcan no longer hit SIGPIPE underpipefail.checkpasses. - sibling roots hidden:
VIEW_SOURCEnow re-roots atworkspace/only when none ofharnesses/,memory/,knowledge/orartifacts/exist. This one string still drives acquire (hit path), populate and writable, so the paths can't drift apart. A new real-shell test covers a mixed bundle on both the read-only and writable paths, plus cleanup. The[ ! -L ]guard is unchanged.[ ! -e ]follows links, so a danglingmemorylink still re-roots atworkspace/. That's harmless because nothing escapes the cache. - scratch wording: both docs now say "(
/workspace/<session>on container workers)". - context-service#56: linked from both docs, and
--type workspaceis dropped. #56 merged at 2026-10-15 18:28 UTC, but context-service's latest release is still v0.1.0 (2026-09-16). The author said they'd merge after #56 ships, so that's a merge-timing call, not a review blocker.
Base 324e202 is behind main. Since then, main only touched harness/src/run-leaf.ts (leafTurnConfig in runPromptLeaf, right next to this PR's contextNote line). mergeable_state is blocked (reviews), not dirty, so it merges cleanly.
Author: moonlight16 (MEMBER — maintainer)
Areas reviewed: TypeScript (harness overlay script), tests, Docs, mocactl CLI text
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing (all 15 checks)
| `ctx pack` puts the directory's files under the bundle's `workspace/` directory. It needs a Context | ||
| Service with [rossoctl/context-service#56](https://github.com/rossoctl/context-service/pull/56) (workspace bundles). A run starts in its context: the agent's working directory shows the | ||
| bundle's `workspace/` directory (`src/`, not `workspace/src/`), or the whole bundle when it has | ||
| other content too. A read-only run gets the session's own working directory (`/workspace/<session>` |
There was a problem hiding this comment.
nit: "or the whole bundle when it has other content too" no longer covers a bundle without a workspace/ directory, which also shows the whole bundle. Suggest: "or the whole bundle when it has no workspace/ directory or has other content too".
There was a problem hiding this comment.
Done in 74f0edb, and rewrapped the paragraph.
…l#534 review) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Jeremy Cohn <[email protected]>
Fixes a gap found while moving a demo off
kubectl cponto workloads (#517, seed sandbox files before a leaf runs): aftermocactl spawn --workload, the agent started in an empty directory and had to search for its files.What changes
--writable, feat: writable per-run copy of a workload's context #532), sopwdandlsshow the project immediately. This mirrors how solve runs start in their cloned repo.workspace/root. When a revision has aworkspace/folder, whichcontextctl ctx packproduces (feat: workspace bundles and contextctl ctx pack context-service#56, workspace bundles), the view and the writable copy point at it, so files appear exactly as in the source folder (src/greet.py, notworkspace/src/greet.py). Bundles withoutworkspace/work as before. Aworkspacesymlink inside a bundle is ignored, so a view never points outside the cache.mocactlhints now usecontextctl ctx pack <dir> --type workspace -o FILE, which needs a Context Service with feat: workspace bundles and contextctl ctx pack context-service#56.Checked in a real
ubi9-minimalcontainer as the sandbox user, for bundles with and withoutworkspace/, read-only and writable: the working directory listssrcdirectly, writes are refused read-only and allowed in the writable copy, and cleanup leaves nothing behind.🤖 Generated with Claude Code