Repository navigation
feat(harness-manager): FIX-1762 provision runs through the workspace host (3/4) - #2744
Conversation
…e worktree provisioning (FIX-1762) A host lists repositories on its own machine in `localRepositories`. A source answering one of those paths gets a worktree of that repository itself: no clone, no fetch on a retry, and the run's branch kept in it. Any other bare path is still refused before git runs. Worktree provisioning moves into `worktree.ts` and is shared by the clone path and the local path: one budget for the whole provision, the interrupted-provision marker corroborated against the tree, refusals for a deleted, switched or foreign branch, and an optional directory the repository must keep out of git. Exports what harness-manager needs to stop keeping its own copies: the "same repository" check, the bounded process runner and the lock. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
…-1762)
`harnessManager({ workspace })` takes a workspace host as well as a
fixed `{ root, sourceRepo, baseRef }`, which becomes a host whose
source always answers that repository. One provisioning path either
way; the checkout paths and branches a fixed repository derives are
unchanged.
The run record keeps the remote and base a run was first provisioned
from, and a retry uses them after the source moves (BR-19). Kept files
are saved at the end of each turn, when the run parks, and when the
harness fails, with the result on the record's `lastSave`.
harness-manager's own exec, completion detection and identity check
are deleted in favour of the host's; its run-long lease is a thin
wrapper over the host's lock. No git runs from this package any more.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
…les run's save (FIX-1762) A run with no repository works inside its kept files, so a caller's own file there (harness-manager's question marker) was saved into the project's collection with the run's work. The host now hides `ignored.dir` inside `workspace/` from the flush's listing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
…etrying it (FIX-1762) A source answering `refused`, or a host refusing what the source named, gives the same answer on every retry, so failing the attempt spent the row's attempts one by one on it. The manager now throws `HarnessRunRefused`, and its failure recorder cancels the row with the refusal as the reason, under the attempt's own claim. The board's recorder then has nothing to re-queue: one attempt, no retry granted. Also pins that a files run's question marker is not saved with its work. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 4997f70f-c588-4000-8bc0-59624fae4f16) |
Second look + architecture pass (read-only; for the implementing agent to triage)Overall: The shape is right. One provisioning path, the git moved into Worth doing in this PR (they touch code this PR already rewrites)
Worth considering (judgment calls)
Architecture (only where this PR is already the opportunity)
Not flaggedRun-record fields ( Generated by Claude Code |
There was a problem hiding this comment.
Code Snob — already tight. No POC.
Head 74cd0f75dcde38d67193ac30f2861c0a8283a1f2. I read manager.ts (pinnedAnswer, saveKeptFiles, the host wiring), workspace.ts (hostForConfig, provisionCheckout, acquireCheckout), timeouts.ts, checkout.ts, guards.ts, worktree.ts, local-host.ts (provisionLocalCheckout, provisionClonedCheckout, leavingOut), repository.ts, lock.ts, and workspace-host.spec.ts.
The move into provisionWorktree is the subtraction. The local path and the clone path are the two adapters over it (lock, marker, checkout path, fetch versus HEAD). One function with a mode is as long as that difference. pinnedAnswer's two file branches are the same extraction; collapsing them is a few lines, not a shape. A helper around the two source asks is longer than the check it replaces, and the second ask stays because a collection ref is bound to the context that resolved it. saveKeptFiles is the one save; the failure path's .catch is what keeps a save error from replacing the error being unwound. timeouts.ts is the one wait that is not a git budget. acquireCheckout and provisionCheckout are the checkout entry conductor and the workspace tests call. leavingOut inlined ties. The provisionTimeoutMs ternary reads the same property on both sides of isWorkspaceHost; one line, not a rewrite.
Not reopening the cancelled-versus-errored settlement, or the phase validate note left for PR 4.
Sent by Cursor Automation: Code Snob
There was a problem hiding this comment.
Assessment
FIX-1762 moves git/exec/worktree provisioning into @flow-state-dev/workspace and teaches harnessManager to accept a WorkspaceHost (or the existing fixed { root, sourceRepo, baseRef } via hostForConfig). The main simplification question is whether that seam added avoidable complexity.
Verdict: the approach is sound and I’m approving. The old harness-local git stack was the wrong layer; centralizing run, locks, worktree.ts, and localWorkspaceHost matches the workspace package charter and gives other workers a shared path. What stays in harness-manager (path/branch grammar, attempt-scoped checkout lease, pin remote/baseRef on the run record, kept-files save at stop points, HarnessRunRefused + cancel-without-retry) is product logic that would land in the manager under any design.
Complexity mostly moved (~800 lines out of harness workspace.ts) rather than net-new. The tradeoff is two heavy files (manager.ts orchestration + local-host.ts) instead of one monolith — acceptable for a 3/4 stack PR.
Simpler alternatives (considered, not blocking)
| Alternative | Why it wasn’t taken / why I’m not pushing it |
|---|---|
Host-only API — drop WorkspaceConfig from options; callers always pass hostForConfig(...) |
Shrinks isWorkspaceHost and union typing; pushes boilerplate to every fixed-repo mount. Reasonable follow-up, not clearly simpler overall. |
| Push save/refusal into workspace | Would mix run-record and board semantics into the host; current layering keeps workspace about places and projections. |
| simple-git / execa / proper-lockfile | Provisioning markers, single cross-command budget, stale-lock re-read, and ask-marker ignore rules are bespoke; npm wrappers don’t remove the hard parts and fight the “one run module” convention. |
Performance
No busy-waits or logging in hot paths. Save/flush does sync tree walks + per-file reads (security-boundary tradeoff); remote provision refreshes on new branch cuts by design. Fine at typical board scale.
Optional polish before or right after merge
See inline notes on the dead provisionTimeoutMs ternary and the duplicated accessor comment blocks — quick wins, not architectural.
Non-blocking follow-ups
- Harden or document
isWorkspaceHost(provisionduck check) ifWorkspaceConfigever grows. - Make
pinnedAnswereasier to audit (switchvs nested ternary) for BR-19. - Cross-package test import of
workspace/test/fake-collection— consider a shared testing export. host.source(ctx)twice per attempt is fine if sources stay cheap; memoize per attempt if they won’t.
No changeset concerns from this review; the PR already carries the appropriate fragment.
Sent by Cursor Automation: Review For Best Approach
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74cd0f75dc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ing and saves (FIX-1762) - A run first provisioned with no repository is recorded as one (`filesOnly`), so a project that gains a repository before a retry does not move it off the files it saved. - A provision's budget covers its waits for the place and clone locks, in process and on disk, so a caller sizing its lease from `provisionTimeoutMs` is not outlived by a queued provision. - Each provision of a files place holds it under a fresh token; `save` refuses an older handle and `release` on one does nothing, so a superseded attempt cannot flush or unlink its replacement's files. - A run whose phase is done but whose final save failed fails the attempt instead of completing, so the retry saves the files. - A relative fixed `sourceRepo` is resolved before it reaches the host, which takes only absolute paths as local repositories. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011KTy6FK6trgHQhStU5yxgi


Requested by Jake · project thread
PR 3 of 4 for FIX-1762, stacked on #2737 (based on its head
e66372b45). Spec:specs/issues/FIX-1762/, PLAN row 3 (S4).Before
harness-manager made its own checkouts. It had its own process runner, its own
git worktreeprovisioning, its own completion detection, its own "same repository" check, and its own lock. That was a second copy of what the workspace host from #2737 does. A run could only come from one fixedsourceRepo, and nothing a run wrote outside git was saved.After
harnessManager({ workspace })takes a workspace host, or the fixed{ root, sourceRepo, baseRef }as before. Both go through one provisioning path. A fixedsourceRepobecomes a host whose source always answers that repository. Checkout paths and branch names are unchanged, and the derivation snapshot still passes.localWorkspaceHost({ localRepositories })cuts the run's branch in that repository itself. There is no clone, no fetch on a retry, and the branch stays insourceRepo, as it did before. The allowlist is still checked before any git runs, and any other bare path is still refused.filesOnly) and stays on its kept files if the project gains a repository.lastSave. A failed save doesn't fail the run, except at completion: a run whose phase is done but whose save failed fails that attempt, so the retry saves the files.provisionTimeoutMs. Each provision of a files place holds it under a fresh token, so a superseded attempt's handle can't save or release its replacement's files.refusedand a host refusing what the source named. The manager throwsHarnessRunRefused, and its failure recorder cancels the row on its first attempt, under that attempt's claim, with the refusal as the reason. No retry is granted, so the refusal can't burn through the row's attempts.ignoreddirectory out of a files run's save.child_processorexecFilecomes back intosrc/.How
worktree.tsholds the hardened provisioning. Both the clone path and the local path use it: one budget for the whole provision, the interrupted-provision marker checked against the tree, refusals for a deleted, switched or foreign branch, and an optionalignoreddirectory the repository must keep out of git.repository.tsholds the singleidentityFromCommonDir, plusrepositoryIdentityandresolvesToCommit.lock.tsalso serves a run-long lease with no heartbeat (signal, injectable clock).locate,provisionTimeoutMsandlocalRepositories.ignored.dirinsideworkspace/from the flush's listing, sosavenever writes it.src/exec.tsis deleted.checkout.tsandguards.tsre-export the workspace versions.acquireLock.manager.tsasks the host's source and pins the answer, provisions through the host, records the remote and base on the first provision, and saves at the three save points.refusedanswer, or aWorkspaceRefusedErrorfromprovision) becomesHarnessRunRefused.recordFailurecancels the row with a claim ticket for the attempt, so a superseded attempt can't cancel its replacement's row.minorchangeset covers harness-manager and workspace.Verification
workspace.spec,message-door,mailbox-boardandslot. The workspace suite passes: 176 tests. labs/conductor passes 154 tests. Typecheck passes for workspace, harness-manager, labs/conductor and goals.test/workspace-host.spec.tsdrives the full board → manager → host flow. Each check below goes red when its mechanism is removed:decide.recordFailure.pinnedAnswer.maxAttempts: 3: the row is cancelled at attempt 1 with no retry granted, the harness never runs, and a later drain changes nothing. Red without the cancel inrecordFailure, which re-pends with a retry granted..fsdev/ask/…. Red without the host's listing filter. A matching unit test is inlocal-host-files.spec.ts.sourceRepoprovisions.test/local-host-local.spec.ts(workspace) shows the branch is cut in the local repository with no clone and no fetch on retry, and that the ignored-directory refusal leaves nothing behind.localRepository()to answer nothing (the remote path) fails 6 of 8 local-host-local tests and 35 harness-managerworkspace.spectests.What's asked of you
One call to check: a refused run settles as
cancelled, noterrored. The task substrate has no "fail without retry" write, sincefailre-pends while attempts remain. Adding one would change orchestration, so I didn't. If you'd rather it readerrored, that's a small substrate change for a follow-up.A note for PR 4: a phase's
validatereceives the host when a host is passed, so devforce-lab'sphase.mtsneeds to stop readingsourceRepothere.🤖 Generated with Claude Code
https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
https://claude.ai/code/session_011KTy6FK6trgHQhStU5yxgi