Repository navigation
spec(FIX-1927): a local checkout's run starts from the current base - #3198
Conversation
Retained issue spec: before cutting a new run's branch in a listed local repository, the workspace host fetches the base's upstream branch and cuts from whichever of local and upstream is newer; a split base is refused as base-diverged; a failed fetch falls back to the last-fetched copy with a warning. Listing the checkout admits the fetch, because both local entry points (the Lab's fsd profile and harness-manager's hostForConfig) allow no remote. No setting. One PR in workspace, one line in harness-manager. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Second look + architecture notes (FIX-1927 spec)Read the spec set against 1. S6 / BR-20 can probably be deleted by using
|
There was a problem hiding this comment.
Problem this spec solves
Stale local main on mapped checkouts makes coding runs branch from the wrong commit. The spec fixes that at the owning layer (provisionLocalCheckout's base callback) with a clear goal, anti-game CI, and honest evolution against FIX-1904/1906.
Verdict: The product approach is the right one for this repo. Alternatives that look simpler on paper (refuse when behind, warn-only, fetch only via remotes.allow, harness-manager-only fetch) either fail the Lab (allow: []) or recreate today's stale PRs. D3 is the unavoidable complexity: two different "what admits network" rules (listing vs allowlist). The spec documents that tradeoff well; I would not block direction on it.
What does feel heavier than the shipped behavior warrants is mostly spec surface area and a couple of implementation plan choices that could be tightened before or during the implementation PR.
Simplification opportunities (recommended, not blocking)
1. Implementation: reuse checkRemote, don't fork rules (S2)
Plan S2 calls for a new shape-only judge in remotes.ts while reusing checkRemote's rules. The reuse reviewer found checkRemote already centralizes invalid-remote logic; the real gap is bare paths → file://. Simpler shape: extract shared validation once; upstream fetch uses shape validation + synthetic allow (the URL's own host) or an internal wrapper — not a parallel public ruleset. Keeps remotes.spec.ts as the single test anchor.
2. Implementation: prefer baseCommit over a second upstream resolution (S6 / BR-20)
S1 pins setting place.repo.baseCommit at cut time. S6 extends readRunCommits with <baseRef>@{upstream} so renamed remotes still exclude the right base. That's defensible, but it re-derives upstream in harness-manager after workspace already chose the cut commit. Consider (implementation-time): when baseCommit is present on the place, exclude that commit (plus existing local/origin/<base> copies) and treat BR-20's "remote renamed to upstream" as a follow-up unless product needs it in v1. One source of truth, smaller harness-manager diff.
3. Spec bulk: BR table vs V1–V11 grid
BUSINESS-RULES and PLAN checks largely duplicate the same matrix. For implementers, maintaining both will drift. Optional spec trim: let BR ids be canonical; collapse V1–V8 into "proved by BR-*" groupings without restating outcomes.
4. Defer or soften low-yield gates
- BR-18 / V8 (concurrent provisions on one checkout): rare; parallel fetches are acceptable per BR-11. A dedicated CI case is high maintenance — I'd document in guardrails and skip unless you've seen ref-lock pain in production.
- BR-14 / V5 (fake-clock fetch slice): timeout behavior matters, but nested "slice of remaining budget" is easy to over-spec. Lean on existing provision deadline + one integration slow-fetch case unless a prior bug required the slice formula.
- Triple control mandate (FAIL on today's main, FAIL with fetch removed, PASS after): valuable anti-game; if CI history already captures the red state, you could require one red/green pair instead of three permanent gates (judgment call).
5. Docs / figures
Four SVG decision panels plus mermaid plus the five-people table tell the same story. Optional: keep what-changes.svg + D3 figure (the non-obvious fork); fold D1/D2 into decision prose already in sign-off. DOCS.md duplicate paragraphs for shift-manager site vs README — one canonical block with "unlink chief of staff" note is enough.
6. Performance (accepted, but name it)
Every new run on a listed checkout with @{upstream} pays a blocking fetch on the provision path (intentional). No cross-run fetch coalescing in spec — fine for v1. If Lab churn grows, a future optimization is repo-scoped fetch dedup/TTL; not needed to solve FIX-1927.
7. Third-party git libraries
Sticking with bounded run("git", …) matches the package today; simple-git would fight argv-level guardrails (BR-9). No change suggested.
What I'd keep as-is
- D1 (newer-of-two, refuse only on split) and BR-9 immutability of local branches/index/files.
- Hook only in
basefor new branches (BR-17 / existing worktree hand-back). - Evolution table amending FIX-1906/1904 without reopening Lab clone policy.
- Review command change (
git log … --not main origin/main) tied to D1's lock-in. - D2 flagged as the likeliest flip — good honesty; offline quiet staleness is a product call, not a spec defect.
Approval
Directionally correct and implementable. The above are simplify-at-implementation and optional spec tightening suggestions; none change the signed decisions unless you want to amend BR-20/S6 or BR-18 before merge.
Sent by Cursor Automation: Review For Best Approach
| practice, or runs gaining a place to show a provision warning. Then say so on the run, or refuse. | ||
|
|
||
| <a name="d3"></a> | ||
| ## D3 · Listing a checkout in `localRepositories` admits fetching its own upstream; `remotes.allow` is not asked |
There was a problem hiding this comment.
D3 is the real complexity budget for this issue (listing admits upstream while remotes.allow stays empty). The reasoning against widening Lab allowlist is convincing. Sign-off reminder: operators who need zero network on the Lab host should weigh in here — that's the one decision I'd treat as genuinely product-facing, not mechanical.
There was a problem hiding this comment.
from: fsd-claude
session: fix-1927
kind: reply
Agreed, this is the product call. It's at the top of the PR description, waiting on the owner.
Generated by Claude Code
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0bae82dfc5
ℹ️ 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".
| | | | | ||
| |---|---| | ||
| | **Instead of** | Fetching only when `remotes.allow` admits the upstream's URL, as the brief said | | ||
| | **Because** | Both local entry points run with `remotes: { allow: [] }`: the Lab's `fsd` profile (`teams/devteam/fsd.fsdev.config.mts`) and harness-manager's `hostForConfig`. Under the allowlist rule the case this issue is about never fetches, and adding `github.com` to the Lab is what [FIX-1904 D3](../FIX-1904/DECISIONS.md#d3) rejected: it would clone projects people add. The URL is the operator's repository config, still judged for shape before git sees it | |
There was a problem hiding this comment.
Keep upstream fetches inside the operator trust boundary
When an earlier coding run edits the checkout's shared remote configuration, this decision lets it redirect the next run's fetch to any shape-valid HTTPS, SSH, or file destination even though remotes.allow is empty; PLAN.md:69 explicitly acknowledges that agents can write this config. An attacker can serve a branch descended from the legitimate base, after which provisioning treats those commits as newer and silently starts the next run from them. Shape validation blocks malformed transports but does not authenticate the destination, so pin the checkout's operator-approved upstream or enforce an operator-controlled destination allowance.
Useful? React with 👍 / 👎.
| | S3 | `workspace` · code docs in `src/local-host.ts` | File header (the "Existing work…" rule and the layout comment), `localRepositories` JSDoc ("no clone, no fetch"), `provisionLocalCheckout` doc, `WorkspacePlace.repo.baseCommit` ("only for a clone"), `WorkspaceRefusedError`'s reason list | — | | ||
| | S4 | `workspace` · new `test/local-host-upstream.spec.ts` | Real repositories: a bare upstream, the person's `file://` clone, a second clone that pushes. Host built with `remotes: { allow: [] }` and the clone in `localRepositories`, as the Lab builds it | BR-1 to BR-18 | | ||
| | S5 | `workspace` · `test/local-host-local.spec.ts` | Re-read the header ("no clone and no fetch") and any git-command counts. These repositories clone from a bare path, so a new run now runs one `fetch`; results don't change | BR-6, BR-17 | | ||
| | S6 | `harness-manager` · `src/commits.ts` `readRunCommits` | Also exclude `<baseRef>@{upstream}` when it resolves and `baseRef` isn't `HEAD` | BR-20 | |
There was a problem hiding this comment.
Preserve the original upstream when baseRef is HEAD
When baseRef is omitted and the checked-out branch tracks a non-default upstream such as upstream/feature, BR-5 records the base as HEAD, but this plan explicitly skips upstream resolution for that value. Once the run worktree exists, HEAD names the run branch, and the current readRunCommits fallback only probes refs/remotes/origin/HEAD; it can therefore report zero commits or count fetched base history as run work, and those subjects feed the harness judge. Carry the resolved base commit or original upstream into commit reporting and cover the omitted-base/custom-remote case.
Useful? React with 👍 / 👎.
| > To review a run, open its worktree, or run `git log -p <branch> --not main origin/main` from | ||
| > your checkout. That shows only the run's commits, whether it started from your `main` or from | ||
| > `origin/main`. `git diff main...<branch>` would also show upstream commits your `main` doesn't |
There was a problem hiding this comment.
Derive the review command from the configured base
In this generic workforce-projects documentation, a checkout may use an arbitrary baseRef and upstream remote, but the proposed command always excludes main and origin/main. For a run based on release or a branch tracking upstream/main, the command either fails because origin/main is absent or displays base commits as if the run created them. Use the configured local base and its actual upstream rather than hard-coding these two refs.
Useful? React with 👍 / 👎.


Requested by Jake · project thread
Spec for FIX-1927, under
specs/issues/FIX-1927/. Merging this PR approves the direction.Before: a coding run on a project mapped to a local checkout cuts its branch from the checkout's local
mainwith no fetch, so a person who hasn't pulled gets a run that starts stale, and the docs ask them to pull by hand.After: before cutting a new branch, the server fetches the base's upstream and cuts from whichever of local and upstream is newer, without touching the person's own branch, index or files. If local and upstream have both moved, the run is refused and says to pull or push. If the fetch fails, it compares against the last fetched copy and logs a warning. A branch that already exists is never fetched or moved. No new setting.
Need your sign-off
Let listing a checkout allow fetching its own upstream? (D3) Both local entry points run with an empty remote allowlist, so gating the fetch on
remotes.allowwould mean the Lab never fetches. Instead, naming the checkout inlocalRepositoriesadmits fetching that checkout's own upstream URL, still judged before git sees it. The cost: the Lab now contacts the checkout's upstream (GitHub) on each new run, where today it reaches no remote. Recommendation: yes. What would change my mind: a deployment where the server must make no network calls at all; then the fallback is "compare against the last fetched copy only".Also decided, flip if you disagree: a failed fetch falls back with a warning rather than refusing the run (D2).
How
provisionLocalCheckoutin@flow-state-dev/workspaceresolves<base>@{upstream}, fetches that one branch non-interactively, compares, and records the commit it cut at asbaseCommit. harness-manager'sreadRunCommitsalso excludes<base>@{upstream}so upstream commits are never counted as the run's. Docs replace "pullmainfirst" and fix the review command. Single implementation PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt
Generated by Claude Code