Repository navigation
feat(harness): Extend config bundle to solve leaves - #468
Conversation
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Evaline Ju <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
This threads the promoted config bundle into realProduceSolve and adds the empty-configRef guard to runSolveLeaf. The guard and the plumbing are fine. Moving the heartbeat ahead of converge is a good change on its own. One blocking problem: on a solve leaf, the overlay's per-leaf link path is inside the solve worktree path. Because the attach now runs before converge, converge skips git worktree add, so every non-SWE-bench solve leaf that sets configRef runs in an empty, non-git directory and then fails at diff capture. Details are inline. CI is green because nothing exercises realProduceSolve with a configRef: the new tests stop at runSolveLeaf with a fake produceSolve, and the Kind smoke doesn't send one.
Author: evaline-ju (MEMBER — maintainer)
Areas reviewed: TypeScript (harness), tests
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes (subject uses the :sparkles: feat(...) emoji form, which is fine)
CI status: passing (branch is 24 commits behind main, no merge conflicts)
…e applying review fixes Catches the branch up with 40 upstream commits (last fetched @22d891e) so the review-fix commit lands on top of current main rather than requiring a rebase + force-push.
…, overlay symlink excluded from patches
The attach-before-converge order in realProduceSolve collided with the worktree:
leafConfigDir(sid) = /workspace/leaves/<sid>/.sh-config is a child of
leafWorkspaceRef(sid) = /workspace/leaves/<sid>. buildLeafBindScript's `mkdir -p
"$(dirname "$LEAF")"` created the parent dir as a side effect, which made
buildConvergeScript's `[ -d "$LEAF" ] || git worktree add` skip the worktree —
so every non-swebench solve leaf with a configRef ran in an empty non-git
directory and then failed at captureWorkspaceDiff with `diff capture failed`.
Fixes applied:
- Reorder in realProduceSolve: heartbeat → converge → attach. Attach still
happens before Pi session construction so a resolver/overlay throw fails
the leaf before any tokens are spent.
- buildConvergeScript now appends `.sh-config` to the main repo's
info/exclude (inside the flock, idempotent via `grep -qxF`). Without this,
`git add -A` in buildDiffCaptureScript would stage the overlay symlink
into every captured solve patch.
- buildSwebenchCleanupScript also removes /workspace/leaves/<sid> so the
dir created by buildLeafBindScript's mkdir doesn't leak on the pooled
sandbox after a swebench solve.
- Extract emptyConfigRefFailure helper used by both runSolveLeaf and
runPromptLeaf, replacing the duplicated empty-string guard.
- runSolveLeaf's deps now use `{ produceSolve? } & ProduceSolveDeps`
intersection to avoid repeating the field list.
Tests:
- New run-leaf-solve-produce.test.ts: observes transport.exec script
sequence through a fully-mocked realProduceSolve and asserts converge
runs before the resolver (the ordering invariant the reviewer pinned).
- converge.test.ts: pins the info/exclude line is written inside the
flock, before worktree add, with an exact-full-line idempotence check.
- swebench-setup.test.ts: pins the cleanup script removes the leaves dir
in a single rm -rf alongside co-/venv-.
- run-leaf-solve-promoted.test.ts and run-leaf-promoted.test.ts stay
green under the shared helper.
Verified: 607/607 harness tests pass with Redis up, typecheck + prettier clean.
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
|
Thanks for the careful review @ingpaolodettori-dev. Review-fix pass pushed in 2a7eb18 (on top of a merge from Must-fix — overlay/worktree collision: reordered Smaller point — swebench orphan dir: Nit — DRY: Tests you asked for: new 607/607 harness tests pass with Redis up; |
…atches Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Evaline Ju <[email protected]>
2a7eb18 to
62349c6
Compare
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up review @ 62349c6
All items from our review at 05baa1b are addressed, and I checked each fix against the code:
- must-fix (overlay link vs. solve worktree): fixed.
realProduceSolvenow runs heartbeat → converge → attach, soworktree addis no longer skipped, and the attach still runs before any model spend.buildConvergeScriptadds.sh-configto the common-dirinfo/exclude(under the flock, exact-line guard), sogit add -Ain diff capture no longer stages the symlink. - SWE-bench orphan dir: fixed. The cleanup script now also removes
/workspace/leaves/<sid>. - nit (deps type / duplicated guard): fixed with
{ produceSolve? } & ProduceSolveDepsand the sharedemptyConfigRefFailure.
I also checked the origin/main merge (e3e60d0) with git show --remerge-diff, and it is clean. CI is fully green on this head.
Approving. I left two non-blocking test suggestions inline: the no-configRef ordering test can't fail as written, and the exclude behavior is only pinned by substring checks. There are also two small nits.
Author: evaline-ju (MEMBER — maintainer)
Areas reviewed: TypeScript (harness), shell scripts embedded in TS, tests
Agent/IDE config (.claude/.vscode): none
Commits: 3 (incl. 1 merge), non-merge commits signed-off: yes
CI status: passing
| execMock.mockReset().mockImplementation(async () => { | ||
| // Any exec after convergeWorkspace (session.prompt → captureWorkspaceDiff → cleanup) would | ||
| // keep the test running against the real Pi stack; throw once converge returns to halt. | ||
| throw new Error('halt after converge'); |
There was a problem hiding this comment.
suggestion: This test can't fail as written. execMock throws on every exec, including the converge script, so convergeWorkspace throws before realProduceSolve reaches the configRef check. The resolver is never called whether or not configRef is set, so deleting or inverting the env.configRef !== undefined guard would still pass. Return the leaf path for the converge script (as the first test does), and halt later instead, e.g. throw on the next exec or from a mocked createAgentSession. Then not.toHaveBeenCalled() actually exercises the opt-in branch.
There was a problem hiding this comment.
Thanks — fixed. Convergescript now returns the leaf path like the ordering test above; the halt moved into createAgentSession.mockImplementationOnce, which runs after the configRef branch, so deleting the opt-in guard would now fail the test. Added a sanity expect(scripts).toContain(expectedConverge) so a regression in the test's own ordering surfaces explicitly.
| const evil = buildConvergeScript("https://x/r.git'; rm -rf /; '", 'main', 'leaf-1'); | ||
| expect(evil).toContain(`'https://x/r.git'\\''; rm -rf /; '\\'''`); | ||
| }); | ||
| it('appends `.sh-config` to the repo info/exclude so the promoted-config overlay symlink is ignored by `git add -A`', () => { |
There was a problem hiding this comment.
suggestion: These two tests pin the exclude line as substrings, but not the property we care about. config-overlay.test.ts already runs the real scripts under bash with /workspace rewritten to a tmp root, so the same pattern could prove it end to end. Converge a local file:// repo → run buildLeafBindScript → write a file in the leaf → run buildDiffCaptureScript. Then assert that the leaf is a git worktree and that the patch contains the edit and no .sh-config. That would have caught the original collision, and it would catch a regression in either ordering or exclusion.
There was a problem hiding this comment.
Took your suggestion. New describe block at the bottom of the file: converge a local file:// repo → bind the overlay → write a tracked-file edit → diff capture. Asserts the leaf is a git worktree, the patch contains the edit, and the patch does NOT contain .sh-config. Reuses the tmp-root + flock-stub + bash execFileSync pattern from config-overlay.test.ts. Verified: fails if the .sh-config exclude line is removed from buildConvergeScript.
| // Ignore an untracked `.sh-config` under any worktree: on a solve leaf with a configRef the | ||
| // promoted-config overlay symlinks `.sh-config` into the leaf dir, and without this | ||
| // `git add -A` in buildDiffCaptureScript would stage that symlink into every captured patch. | ||
| // No-op when the entry is already present; a no-op when the overlay didn't run. |
There was a problem hiding this comment.
nit: The comment says this is "a no-op when the overlay didn't run", but the entry is written on every converge, whether or not there's a configRef. That's harmless, but the comment should say so. Optional hardening: mkdir -p "$REPO/.git/info" before the append. git init normally creates the directory from templates, but without it, echo >> fails under set -eu and takes down every converge, configRef or not.
There was a problem hiding this comment.
Done. Comment rewritten (the entry is harmless-always-written, not conditional). Added mkdir -p "$REPO/.git/info" before the append — thanks for catching that set -eu + a missing templates dir would have taken down every converge.
| return [ | ||
| `set -u`, | ||
| `rm -rf ${sq(swebenchCheckoutDir(sessionId))} ${sq(swebenchVenvDir(sessionId))}`, | ||
| `rm -rf ${sq(swebenchCheckoutDir(sessionId))} ${sq(swebenchVenvDir(sessionId))} ${sq(`/workspace/leaves/${sessionId}`)}`, |
There was a problem hiding this comment.
nit: /workspace/leaves/${sessionId} re-spells leafWorkspaceRef(sessionId) from converge.ts (and dirname(leafConfigDir(sid))). Importing the helper would keep the three paths from drifting apart.
There was a problem hiding this comment.
Done. Imported leafWorkspaceRef from ./converge.js and used it in the cleanup script.
Signed-off-by: Evaline Ju <[email protected]>
Summary
A
solveleaf now runs with the session's promoted config bundle in its sandbox. Before this, a session created withmocactl run --config <digest>applied the bundle topromptturns but ransolveturns bare of the user's skills and CLAUDE.md. An empty-or-whitespaceconfigRefon a solve request now fails loudly instead of being silently ignored (closes the solve half of #222). Sessions that don't setconfigRefsee no change.Rationale: B9 (#397) acceptance item 1 — "load the bundle for converge and solve." Reuses the shared
attachPromotedConfighelper and session-boundconfigRefdelivery that #458 (ADR-0038) landed. Unblocks "implementation subagents" (clone a repo + apply a fix under the user's promoted skills) that today run bare on the solve path.Refs: #397, #458, #378
Assisted-By: Claude (Anthropic AI) [email protected]
Addresses part of #397