Skip to content

FIX-1927: a local checkout's run starts from the current base, not a stale main - #3201

Merged
jhoffner merged 14 commits into
mainfrom
claude/project-thread-q5dgf7
Oct 13, 2026
Merged

jhoffner merged 14 commits into
mainfrom
claude/project-thread-q5dgf7

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

Implements FIX-1927 per the merged spec at specs/issues/FIX-1927/.

Before: a coding run on a checkout listed on this machine, like the Lab's FSD checkout, started from whatever main the person last pulled. Its PR could conflict with work already merged, or redo it, and nothing said so.

After: before it cuts a new run's branch, the host fetches that branch's upstream and starts from whichever is newer. If you haven't pulled, the run starts from upstream. If you have unpushed commits, it starts from yours. If both have moved, the run is refused as base-diverged before anything is created, and the refusal names both commits. When offline, the run starts from the copy last fetched and logs a warning. Your main, index and files never move. A retry or a later turn gets its existing checkout back untouched and fetches nothing.

How: the fetch lives in the workspace host (provisionLocalCheckout), so both the Lab's mapped checkouts and harness-manager's sourceRepo path get it. Only the one upstream branch is fetched, into its remote-tracking ref. Its URL passes the same shape rules as any remote (checkRemote is split into shared shape rules plus the allowlist gate), and git may speak only that URL's scheme. Listing the checkout is what allows the fetch (D3), so remotes.allow is not consulted. readRunCommits now also leaves out <base>@{upstream}, and the docs give git log -p <branch> --not main origin/main as the review command.

Evidence

  • Workspace tests: 251 passed. Harness-manager tests: 262 passed. Typecheck passes for workspace, harness-manager, shift-manager and workforce.
  • Red on unmodified main: the new local-host-upstream.spec.ts fails 13 of 20, and the behind case fails starts-from-upstream.
  • Negative control: with the fetch removed, 10 of 20 fail, including the goal case. When the fetch is made to throw, the fallback tests go red.
  • The test of two provisions at once passed 5 of 5 reruns.

Notes

  • A tracked ref that isn't refs/heads/… is skipped with a warning and not fetched. This keeps the rule that no local branch moves.
  • A malformed file:// URL on a host that doesn't allow file is now refused as invalid-remote instead of remote-not-allowed. Either way it is refused before git sees it.
  • Changeset: @flow-state-dev/workspace minor, @flow-state-dev/harness-manager patch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt


Generated by Claude Code


Note

High Risk
Changes git provisioning for all localRepositories runs (fetch, divergence refusal, and security-sensitive remote handling) and alters how run commits are measured via persisted baseCommit.

Overview
Local checkouts now start coding runs from the current base, not whatever main last looked like on disk. For repos in localRepositories, the workspace host fetches only the base branch’s upstream, compares it to the local base, and cuts a new run branch from whichever is newer—without moving the developer’s branch, index, or working tree. Diverged local/upstream bases refuse with base-diverged before any worktree is created; failed fetches fall back to the last-fetched tracking ref with a warning.

The provision records place.repo.baseCommit, which harness-manager pins on the run record and passes into readRunCommits so commit counts and review commands (git log … --not main main@{upstream}) reflect the actual cut point, even when shared refs/config change during a run. checkRemoteShape validates upstream URLs without remotes.allow; fetch uses host-start pins and an isolated scratch git so runs can’t repoint the next fetch via repo config.

Docs (Shift Manager, projects, workspace README) and the FSD Lab checkout config comments are updated to match.

Reviewed by Cursor Bugbot for commit ce28ffa. Configure here.

…its base and upstream (FIX-1927)

Before cutting a new branch in a repository listed in localRepositories,
the host fetches that base's upstream branch into its tracking ref only,
then cuts from local when it is equal or ahead, from upstream's commit
when local is behind, and refuses base-diverged when both have moved.
A failed fetch, or an upstream URL that fails the shape check, warns and
compares with the last-fetched copy. Listing the checkout admits its
upstream; remotes.allow isn't asked. place.repo.baseCommit is now set.

checkRemote is split into shared shape rules plus the allowlist gate;
checkRemoteShape asks only the first, reading an absolute path as file://.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt
…FIX-1927)

A local checkout's run can now be cut from <base>@{upstream}, which may
live on a remote not called origin; those commits are not the run's.
Also a behind case through provisionCheckout, and hostForConfig's doc.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt
Shift Manager overview and README, Workforce projects guide, workspace
README (base-diverged refusal), Lab profile comments, and the changeset
(workspace minor, harness-manager patch).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt
@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

FIX-1927

@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 13, 2026 1:58am UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 13, 2026 1:58am UTC
flow-state-dev-ui Ignored Ignored Preview Oct 13, 2026 1:58am UTC

Request Review

@jhoffner jhoffner self-assigned this Oct 13, 2026
@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot 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: afae4bab-e165-4b46-8dce-2278662d904a)

@jhoffner

Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Collaborator Author

Second look + architecture review (read-only; for the implementing agent to triage)

Overall: the approach is sound and about as lean as it can be. Fetching in the host (provisionLocalCheckout) rather than in each caller is the right place. Cutting at the commit instead of the ref name, so the run branch doesn't inherit tracking, is a good detail. Fetch failure is a warning and probe failure is raised, which is the correct asymmetry. I found no blocking correctness problems. The items below are ordered by how much I'd act on them.

1. Worth doing in this PR (small)

a. fetchUpstream + isAncestor are git-comparison logic living inside the localWorkspaceHost closure. local-host.ts already carries many responsibilities, and this adds ~90 lines of closure-captured helpers (git, run, env) that have no dependence on host state beyond those three. This PR is a natural moment to lift them into a small module (e.g. upstream.ts: resolveUpstreamBase({ repo, base, git, run, env, left }) → { ref, commit, commitish } | refused) next to remotes.ts. The gain is that the three-way outcome (equal/ahead, behind, diverged) becomes unit-testable against a plain repo without provisioning a place. Today it's only reachable through local-host-upstream.spec.ts at host level. This is optional if you'd rather keep the diff small, but it's the one refactor this feature earns.

b. shapeOf returns a three-way union discriminated by key probing ("reason" in, then "unspoken" in, then .host === null). It works, but each caller re-learns the protocol. A tagged result ({ kind: "refused" | "unspoken" | "ok", … }) would remove the in checks in both checkRemote and checkRemoteShape. Low risk since both are pure and well covered by remotes.spec.ts.

2. Behavioural points to confirm (no change necessarily needed)

  • Forced update of the tracking ref (+refs/heads/x:refs/remotes/origin/x): correct for a tracking ref, and the PR notes say non-refs/heads/ upstreams are skipped. I'd just add one test line asserting a force-pushed upstream (non-fast-forward on the remote) is still picked up and then classified base-diverged/behind correctly, since that is the case + exists for.
  • Fetch timeout kills git mid-fetch. A killed git fetch can leave .git/refs/remotes/.../x.lock behind, which would make every later fetch for that branch fail into the "falls back with warning" path indefinitely. The doc comment mentions losing a ref lock to a concurrent fetch, but not a stale lock from our own timeout. Either mention it in the warning text or confirm git cleans it on SIGTERM (it generally does for SIGTERM, not SIGKILL; worth knowing which run sends).
  • Silent staleness is warn-only by design (D3). Reasonable, but the only signal that a run started from a stale base is a console.warn. If the Lab surfaces run metadata anywhere, the returned baseCommit is now available on the place; a follow-up could show "started from (upstream not fetched)". Not for this PR.
  • checkRemoteShape treats an absolute path as a file:// URL. On Windows isAbsolute + pathToFileURL handles drive paths, but remote get-url output for UNC paths is untested. Low priority given the Lab targets POSIX.

3. Things I'd leave alone

  • Not adding a remotes.allow check for the upstream: consistent with D3 (listing the checkout is the allowance), and the shape rules plus GIT_ALLOW_PROTOCOL still bound what git can speak. GIT_TERMINAL_PROMPT=0 is already in the shared env, so a credential prompt can't hang the fetch.
  • readRunCommits adding ${baseRef}@{upstream} as a third copy is the minimal fix and matches how the existing two copies are treated.
  • The malformed-file:// change from remote-not-allowed to invalid-remote is an acceptable, disclosed behaviour change.

4. Tests, docs, changeset

Test evidence in the PR description is strong (red-on-main plus negative controls). Docs updates and the changeset (workspace minor, harness-manager patch) look appropriate for a public behaviour change; no prose-leak concerns spotted in the titles I skimmed.


Generated by Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T02:07:26.393377Z ce28ffa Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt
@jhoffner

Copy link
Copy Markdown
Collaborator Author

Architect: FIX-1927 D3 conditions

Three of the D3 conditions from the #3198 review are missing. They need to land before this counts as Architect Approved.

  1. The upstream URL isn't pinned. fetchUpstream reads git remote get-url <remote> live from the checkout's config on every run (packages/workspace/src/local-host.ts:796). An agent in an earlier run can repoint origin, and the next run will fetch from there. Fix: record each listed repo's upstream URL when the host is constructed (from localRepositories), and refuse or skip the fetch if the live URL is different.
  2. Admission is shape-only. checkRemoteShape(url) (local-host.ts:801, remotes.ts checkRemoteShape) accepts any file:// path and any ssh or https host. Fix: compare against the pinned scheme and host from (1), and accept only an exact match.
  3. Command-running config is still live during the fetch. The fetch at local-host.ts:807-821 passes no -c overrides, so the repo's core.sshCommand, remote.<name>.uploadpack, credential.helper, core.hooksPath, core.fsmonitor and protocol.*.allow all apply. Fix: add -c core.sshCommand=ssh -c credential.helper= -c core.hooksPath=/dev/null -c core.fsmonitor=false (or the equivalent GIT_CONFIG_* env), pass --upload-pack=git-upload-pack, and set GIT_SSH_COMMAND/GIT_SSH explicitly. Add a test to test/local-host-upstream.spec.ts that plants core.sshCommand, uploadpack and a credential helper that write a marker file, then asserts the marker file never appears.

Related: a skipped fetch caused by a changed or invalid URL surfaces only through console.warn (local-host.ts:791). It should be recorded on the run (place warning or run record) so a person sees it.

Item 4 (the localRepositories doc at local-host.ts:156-169) and the per-fetch GIT_ALLOW_PROTOCOL: judged.scheme (:821) look good.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Snob — already tight. No POC.

Read packages/workspace/src/local-host.ts, packages/workspace/src/remotes.ts, packages/workspace/src/worktree.ts (firstLine), packages/harness-manager/src/commits.ts, packages/harness-manager/src/workspace.ts, packages/workspace/test/local-host-upstream.spec.ts, and packages/harness-manager/test/workspace.spec.ts. Head cc6c9c007.

A rewrite does not shrink the contract:

  • isAncestor is the two comparisons. Inlining copies the exit-1-versus-throw split. One rev-list --left-right --count is fewer calls and a worse reading of equal, ahead, behind, and split.
  • skip is the one warning, used four times. FETCH_BUDGET_SHARE is 0.5 once; inlining drops the name and leaves the slice comment already on the call.
  • shapeOf is the one judge. checkRemote still applies the allowlist, so an unknown scheme and file stay remote-not-allowed. checkRemoteShape does not ask it, and an absolute path becomes file://. A flag on checkRemote spends a parameter to get those two reasons back.
  • refs/remotes/origin/<base> and <base>@{upstream} are the two copies. The second is the remote that is not named origin.
  • The behind comment is why the cut is the commit id. fetchUpstream's comment names the cases the early returns do not: not a local branch, tracking a local branch, never fetched, and a failed probe is not "no upstream".
  • The file header, localRepositories, provisionLocalCheckout, and the refusal reason list are the docs this change has to keep true. The Lab overview, the projects page, and the README are three readers. cc6c9c007 already broke the README wall into the three cases.
  • The harness test's local git is that one test's dozen calls. The rest of the file makes one call at a time.
Open in Web View Automation 

Sent by Cursor Automation: Code Snob

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict

The core approach fits the product constraint (never move the operator’s branch, but don’t start runs from a stale base). Implementing that in the workspace host with a targeted upstream fetch, merge-base classification, and base-diverged refusal is reasonable. I don’t see a materially simpler design that keeps the same guarantees without either pushing git pull onto users or weakening the security model around remotes.

Approve — the added complexity tracks real policy and is backed by a strong test matrix. The items below are optional trims or follow-ups, not merge blockers.


What’s working

  • remotes.ts refactor — Extracting shapeOf + checkRemoteShape is the right reuse: listed-checkout upstream fetch needs shape rules without the clone allowlist, without duplicating the ext:: / credential guards.
  • local-host-upstream.spec.ts — Exercises behavior through the person’s repo (not just place metadata), covers security (ext::), budget/timeout, fallback, and base-diverged cleanup. That’s the right altitude for this change.
  • readRunCommits + @{upstream} — Small, aligned fix so commit counts match “cut from newer upstream.”

Simpler approaches considered

Alternative Why it’s not clearly better
Document “pull main before you ask” Solves staleness but not the stated FIX-1927 outcome; worse operator UX for the Lab.
git pull / merge in the checkout Violates “never switch/reset/clean the person’s tree.”
Third-party git library No existing dep; subprocess + GIT_ALLOW_PROTOCOL + bounded run() is already the package pattern.
Share refresh() with clone path Different scope (all branches + prune), failure mode (throw vs warn), and allowlist semantics — a shared helper for argv/env only would be marginal.

Optional simplification (non-blocking)

  1. Doc triplication — The upstream-fetch policy appears in the local-host module header, LocalWorkspaceHostOptions.localRepositories, and the fetchUpstream block comment. One canonical place (options JSDoc + a short pointer in fetchUpstream) would shrink the diff mentally.
  2. Classify local vs upstream with one merge-base — Two isAncestor calls are clear and cheap; a single merge-base <local> <upstream> plus equality checks could shave a subprocess and one branch story (minor).
  3. Fetch even when local is already ahead — fetchUpstream always runs before the ancestry checks, so the common “I’m ahead / level” path still pays network + ref updates. That may be intentional freshness; if latency matters, a cheap rev-parse of cached tracking ref before fetch could skip work when local already contains it (product tradeoff).
  4. Concurrent provisions on one checkout — Per-place locks mean two new runs can each git fetch the same upstream (clone path serializes on cloneKey lock). Tests expect both to succeed; acceptable, but worth a one-line comment or a follow-up if duplicate fetches show up in practice.
  5. Test suite size — local-host-upstream.spec.ts is large but purposeful. A tiny advanceUpstream() fixture helper would trim repetition without losing scenarios. The sleep 30 hang test is valuable; if CI ever flakes, consider a shorter sleep with the same timeout assertion.

Skipped (needs product call)

  • Repo-wide single-flight fetch mutex for localRepositories paths.
  • Narrowing changeset scope / splitting docs-only churn (process preference, not code smell).

No changeset concern from this review — the published surface change looks correctly versioned.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread packages/workspace/src/local-host.ts Resolved
Comment thread packages/workspace/src/local-host.ts Resolved
Comment thread packages/workspace/src/remotes.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2348dbd6b9

ℹ️ 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".

Comment thread packages/harness-manager/src/commits.ts Resolved
Comment thread apps/docs/docs/workforce/projects.md Resolved
…rogram-running config (FIX-1927)

A run's worktree shares the listed repository's .git/config, so a run could
aim the next run's upstream fetch or plant a command for it to run.

- Each listed repository's remote fetch URLs are read when the host is built
  (git remote -v, insteadOf expanded). The fetch hands git the pinned URL;
  a remote whose live URL differs, a remote not there at start, or a pinned
  URL a newer url.insteadOf rewrites is skipped with a warning naming the
  repository, remote and both URLs, falling back to the last-fetched copy.
- The fetch runs with core.sshCommand=ssh (and GIT_SSH_COMMAND=ssh),
  core.askPass=, core.hooksPath=/dev/null, core.fsmonitor=false,
  protocol.allow=never plus the pinned scheme, --upload-pack=git-upload-pack,
  and credential.helper= to clear every helper; the helpers from system,
  global and command-line config, read at start, are replayed after it so a
  private https upstream still authenticates.
- Comment that the fetch always runs on purpose, and cross-reference the
  unknown-scheme reasons of checkRemote and checkRemoteShape.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt
…mmits leave out that branch's upstream (FIX-1927)

A local checkout provisioned with no baseRef recorded "HEAD", and
readRunCommits then left out only refs/remotes/origin/HEAD. A main tracking
a non-origin upstream, or a stale origin/HEAD, had upstream commits counted
as the run's. The host now records the branch HEAD is on (e.g. "main"), so
readRunCommits leaves out <branch> and <branch>@{upstream}; a detached HEAD
is still recorded as "HEAD". Nothing else reads the recorded base for a
local checkout except pinnedAnswer, which re-cuts a lost branch from the
named branch rather than wherever HEAD has moved since.

Docs: the review command is `git log -p <branch> --not main main@{upstream}`,
following the base branch's configured upstream rather than origin/main.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt

Copy link
Copy Markdown
Collaborator Author

from: fsd-claude
session: fix-1927
kind: reply

Re the Architect's D3 conditions: items 1–3 are in 047ec05.

  1. Pinned URL. When the host is built, it records each listed repo's fetch URLs from git remote -v. The fetch is given the pinned URL. If the live URL differs, or the remote didn't exist at start, the fetch is skipped with a warning that names the repo, the remote and both URLs. It is also skipped if a newly added url.insteadOf rule would rewrite the pinned URL.
  2. Admission. The pinned URL still goes through checkRemoteShape. The fetched URL must exactly equal it, and only its scheme is allowed.
  3. Program-running config. The fetch passes -c core.sshCommand=ssh -c credential.helper= -c core.hooksPath=/dev/null -c core.fsmonitor=false -c core.askPass= along with the protocol pins, plus --upload-pack=git-upload-pack and GIT_SSH_COMMAND=ssh. Clearing credential.helper also clears the repo's own helpers. The system and global helpers read when the host was built are then added back, so a private https upstream still authenticates through the person's own helper (for example gh or osxkeychain). New tests plant core.sshCommand, remote.origin.uploadpack and a credential helper that answers a local 401. Each one writes a marker file, and each test fails with its fix reverted. A repointed origin and a planted insteadOf each fail the same way without the pin.

Known remaining gap: the live-URL check and the fetch are separate git calls. A run in progress could add an insteadOf rule between the two. The insteadOf check narrows that gap, and there is no -c that clears every insteadOf rule.

A skipped fetch recorded on the run: I haven't built this, because the approved spec (D2) chose a warning in the log rather than a new field on the run record. I've raised it with Jake as a follow-up.

GIT_SSH is not unset, because the exec helper can only add environment variables. GIT_SSH_COMMAND takes precedence over it.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6dfdd3101c

ℹ️ 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".

Comment thread packages/workspace/src/local-host.ts Resolved
Comment thread packages/workspace/src/local-host.ts Resolved
… the commit compared (FIX-1927)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef5d129a02

ℹ️ 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".

// Read now, before any run of this process could rewrite a listed
// repository's config: its worktrees share that config, so a run could
// otherwise aim the next run's fetch.
const fetchPins = new Map([...localRepositories].map((path) => [path, readFetchPins(path)] as const));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Store upstream pins outside the shared repository

When a coding worktree rewrites the repository-wide remote URL or branch upstream and the host is later reconstructed, this line accepts the run-modified values as the new trusted pins. The next run can therefore fetch and branch from a different, attacker-controlled upstream even though remotes.allow is empty. The fresh evidence beyond the earlier pinning fix is that these pins are reconstructed from the already-shared config on every host restart—and on every direct provisionCheckout call—so persist the operator-approved pins somewhere workers cannot edit.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

from: fsd-claude
session: fix-1927
kind: reply

This is real, and it is not fixed in this PR. It's filed as FIX-1934. The path takes two steps: a run rewrites the shared config, and the host is rebuilt after that. The manager builds its host once per process. provisionCheckout builds a new one on every call, but only tests use it. To persist the pins somewhere runs can't write, someone also has to decide how the person legitimately changes their remote, and that is a product decision for Jake, not a review fix. There is a bigger gap under the same threat model: a run can move refs/heads/<base> directly, because refs are shared too. This PR doesn't guard that either, and FIX-1934 records it.


Generated by Claude Code

Comment thread packages/workspace/src/local-host.ts Resolved
Comment thread packages/harness-manager/src/commits.ts Resolved
Comment thread packages/workspace/src/local-host.ts Resolved
…nce, and count a run's commits from its recorded base (FIX-1927)

- The upstream fetch runs in an empty scratch repository writing into the
  person's object store, so no url.insteadOf in the shared config can
  redirect it, however late it is added. The ls-remote pre-check is gone.
- The base callback names HEAD's branch once and reads the commit, the
  recorded ref and the upstream off that one name.
- The run record keeps the commit the run's branch was cut at, and
  readRunCommits excludes it instead of the worker-writable @{upstream}.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6378b887f

ℹ️ 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".

Comment thread packages/harness-manager/src/commits.ts Resolved
Comment on lines +919 to +920
try {
return { ref, commit: await git(repo, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`], left()) };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the fallback upstream SHA outside shared refs

When an earlier coding worktree writes its own tip to refs/remotes/origin/main and changes the live remote URL so the fetch is deliberately skipped, this lookup treats that worker-written ref as the "copy last fetched." Because the planted tip descends from local main, the next provision selects it as the newer base and inherits code from the prior run. Git explicitly allows a worktree to update a named ref with git update-ref (git-update-ref), so retain the trusted fallback SHA outside the worker-writable repository and return the isolated fetch's SHA directly after a successful fetch.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

from: fsd-claude
session: fix-1927
kind: reply

Part of this is fixed in 181cfe5: after a successful fetch, the comparison uses the fetched SHA directly. The fallback path is the same gap as FIX-1934, and I'm leaving it there. A run that can plant refs/remotes/origin/main can also plant refs/heads/main, and the next run is cut from that no matter what upstream says. Keeping a trusted SHA outside the repository closes only one of those two doors. FIX-1934 covers both, together with the restart pins, because they need one place outside the repository that runs can't write.


Generated by Claude Code

Comment thread packages/workspace/src/local-host.ts Resolved
…nd never rewind a tracking ref another provision moved (FIX-1927)

- readRunCommits uses the recorded baseCommit alone when there is one; the
  named refs, which a run's worktree shares, are only a fallback for older
  records.
- After a fetch, the tracking ref moves only if it still holds the commit
  the fetch started from, and the comparison uses the fetched commit rather
  than re-reading the shared ref.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 181cfe5dc2

ℹ️ 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".

Comment thread packages/workspace/src/local-host.ts Resolved
Comment thread packages/workspace/src/local-host.ts Resolved
…tch's scratch directory can't be made (FIX-1927)

The recorded base commit now carries what the branch name was recorded for,
so `baseRef` goes back to the ref asked for (BR-5, BR-8). The scratch
directory is made inside the fetch's try, so a full or read-only temp dir
is a warning and a fallback, not a failed provision.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e11bc5cb47

ℹ️ 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".

{
cwd: scratch,
timeoutMs: Math.max(1, Math.floor(left() * FETCH_BUDGET_SHARE)),
env: { ...isolated, GIT_ALLOW_PROTOCOL: judged.scheme, GIT_SSH_COMMAND: "ssh" },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Isolate the fetch from mutable global URL rewrites

When an unsandboxed coding run changes ~/.gitconfig after the live URL check but before this fetch starts, the scratch repository still inherits that mutable global config through process.env; a same-scheme url.<attacker>.insteadOf rule can therefore redirect the pinned URL and make the next run start from attacker-controlled code. Git documents that matching URLs are “rewritten to start, instead, with <base>” in url.<base>.insteadOf, and the exact GIT_DIR and protocol flags used here still apply such a global rewrite. The fresh evidence beyond the earlier repository-local rewrite fix is that an empty scratch repository suppresses local config but not global config; use an immutable snapshot or disable global configuration for the fetch while replaying only explicitly pinned settings.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

from: fsd-claude
session: fix-1927
kind: reply

This stays as is. The boundary here is the repository's config, because a run's worktree shares it and writes to it by design. ~/.gitconfig is on the other side of that boundary: a run that can write it can also write ~/.ssh/config, the shell profile, or the credential store, and none of that is something a fetch can guard against. Turning off global config for the fetch would also break things people depend on, such as http.proxy, http.sslCAInfo and the global insteadOf rules that are already applied to the pinned URL. Protecting the person's home directory from a run is the sandbox's job, not this PR's.


Generated by Claude Code

Comment thread packages/workspace/src/local-host.ts Resolved
Comment thread apps/docs/docs/workforce/projects.md Resolved
…d give the review command for a base with no upstream (FIX-1927)

A failed compare-and-swap is fine when another provision moved the ref; any
other failure (a lock) is now a failed fetch, warned about, and compared
with the copy last fetched.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d80e63cbc

ℹ️ 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".

Comment thread packages/workspace/src/local-host.ts Resolved
…r a branch it was made to point at (FIX-1927)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ddc2276ab

ℹ️ 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".

Comment thread packages/workspace/src/local-host.ts Resolved
…onfigured upstream in the Shift Manager pages, and make the changeset one sentence (FIX-1927)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fad1eab9e

ℹ️ 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".

Comment thread packages/workspace/src/local-host.ts Resolved
…r overrides the provision (FIX-1927)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ9UL2RHLrxJsiGFnkuxjt
@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot 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: f3fd7cd6-55ae-43e8-80b8-b1660ae516a4)

Copy link
Copy Markdown
Collaborator Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: ce28ffa850

ℹ️ 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".

@jhoffner
jhoffner merged commit 1f982f0 into main Oct 13, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants