Repository navigation
fix(harness-manager): keep one person's runs in two organizations apart (FIX-1926) - #3199
Conversation
…rt (FIX-1926) The coding run's checkout folder and branch were derived from the tenant and the user, with no organization. The tenant is optional and header-supplied, so one user in two organizations on one host, with no tenant header, derived one checkout and one branch for the same board and issue-phase. The organization the request was admitted under is now a segment of the place and the branch. A run whose record already names the branch derived without it keeps that branch and its checkout, so in-flight work is not stranded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0155MhTh7kAjLFSg9Wq6ggab
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
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: 71156d32-6dcf-43d4-97fd-71ca6f98400d) |
|
@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. |
Second look + architecture pass (read-only review; no changes pushed)Verdict: the approach is sound and proportionate. Org as its own injective segment is the right fix, and 1. The bridge is a permanent legacy branch with no exit (worth a decision)
2.
|
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
Code Snob. Already tight. No POC.
Files: packages/harness-manager/src/workspace.ts (principalSegments, RunLocation.orgless, locationFor, branchFor, placeFor), src/manager.ts (open and provision), src/run-owner.ts (runOwnerFor, runPrincipal), test/org-place.spec.ts, test/workspace.spec.ts, test/board-id.spec.ts, test/claim-host.ts, labs/conductor/README.md, .changeset/org-in-run-checkout.md.
locationFor is the one comparison: the recorded branch equals branchFor of that place with orgless. principalSegments is the one fork, so the path and the branch stay one derivation. A second segment function repeats tenant, user, epic, and leaf. Passing the recorded branch into branchFor and placeFor separately is how open and provision can disagree.
The ternary is the two recorded orders (tenant, org, user, or tenant, user). A conditional spread of the org segment is more lines. The two locationFor calls are the two steps: open reads the row, provision uses state.branch. A helper that takes epic, issue, phase, and branch spends the function to save the braces.
runPrincipal's organization check matches the user check. The wording differs (user identity / principals, organization / organizations), so one throw helper is the same length. runOwnerFor leaves organization off the owner record; the board is the organization. The request-identity comment is why orgId comes from ctx.request.
putRecord is the scoped write the in-flight test uses; records is the read. That file is one handler per action. inOrg keeps the default organization's session id. Always prefixing the id is one line shorter and changes every session id in the harness.
The swap test is the separate-digest check. locationFor's unit cases are null, undefined, the new branch, and the old branch. org-place.spec.ts is the manager on one store. The snapshot loop passes orgless because derivation-snapshot.json is the older derivation.
The orgless field comment is the warning that setting it on a new run shares a checkout. locationFor's second paragraph is why another organization's run cannot inherit that place through the record. The README paragraph is the path. Folding the lone patchState({ branch }) into the pin write is two lines and changes when branch is committed.
A rewrite would not shrink this contract.
Sent by Cursor Automation: Code Snob
There was a problem hiding this comment.
Simplify review (FIX-1926)
Problem framing: One person on one host in two organizations must not share checkout, branch, or conflated git state. That is a real isolation gap: the framework partitions boards/records by org, but derived filesystem/git paths did not.
Verdict on approach: Putting orgId on RunPrincipal, encoding it as its own segment (same as user/tenant), and reading it from ctx.request.identity (admitted org, BP-031) is the straightforward fix and matches how the engine already thinks about org (createExecutionMetadata). I would not try to infer org from board metadata alone without proving it is the same trusted admission path.
Where complexity landed: Almost all of the extra surface area is backward compatibility for runs that already have a pre-org branch on the record — RunLocation.orgless plus locationFor(..., recordedBranch) comparing against branchFor(orgless). That is defensible (retries must not strand work), but it is also the main place a simpler design could have lived:
| Alternative | Trade-off |
|---|---|
| Current (branch equality) | No migration; one function owns the rule; inference edge cases (e.g. branch missing but workspacePath still legacy) are implicit. |
Explicit placeVersion / legacyPlace on the run record |
Slightly more storage and a write on open; clearer than string matching; easier to test partial records. |
| Cutover only (no compat) | Simplest code; unacceptable for in-flight harness retries unless you accept stranded trees. |
I am not sure the branch-equality approach is wrong for production, but if this compat window is long-lived, an explicit record field may age better than keeping orgless on the public RunLocation type (tests can call branchFor({ orgless: true }) and bypass the “never for new runs” invariant).
Smaller simplifications (optional, not blockers):
- Validate org with
isValidOrgIdfrom@flow-state-dev/coreinrunPrincipal(same rule as transport/engine) instead oftypeof+ non-empty. - On the open path, hoist one
runPrincipal(ctx)instead of calling it again forlocationFor(owner check already computed principal in the same block). - Consider merging the post-read
patchState({ branch })into the next patch to avoid an extra sequencer write (minor). locationForalways computesbranchFor(orgless)whenrecordedBranch != null; a cheap shape check might skip that on the common new-branch path (micro-optimization only).
What reads well: org-place.spec.ts + claim-host.inOrg() is the right level of proof (two orgs → two trees, legacy record → same checkout). Conductor README path diagram update is clear. Reusing harness-manager encodeSegment (not engine’s unrelated homonym) is correct.
Tests: I ran pnpm --filter @flow-state-dev/harness-manager test locally and saw 7 failures (mostly lock/path ENOENT around workspace provisioning tests). That may be environment flake rather than this PR; worth confirming CI on your side.
No changes requested for merge — this is feedback on simplification and alternatives. Happy to approve on a follow-up pass if you want a clean approve after addressing any of the optional items.
Sent by Cursor Automation: Review For Best Approach


Requested by Jake · project thread
The problem
A person who works in two organizations on one host got the same coding-run checkout folder and the same git branch in both, for the same board and issue-phase, when the request had no tenant header. The second organization's run opened a tree that held the first one's commits and uncommitted work. A pull request on the shared branch could satisfy the other run's completion check, so one organization's run could report success on another organization's work.
What this does
The checkout folder and the branch now include the organization the request was admitted under (the verified one on the request identity, not a header). The layout is
<tenant>/<org>/<user>/<board>/<issue>--<phase>, and the branch isconductor/plus the same segments.A run that started before this change keeps its place. Its run record names the older branch, and the manager continues on that branch and that checkout, so a retry does not lose its work. The run record is kept per user and organization, so another organization never reads it and never gets the older place through it.
What's asked of you
Nothing here is yours to decide. This is a bug fix; this PR is the review.
Parts worth reviewing closely
packages/harness-manager/src/workspace.ts→locationFor: the bridge for in-flight runs. It uses the older derivation only when the run's own record already names the older branch.packages/harness-manager/src/manager.ts: the open step now reads the run record before it derives the branch. The provision step derives from the branch the open step chose, so the two steps always agree.packages/harness-manager/src/run-owner.ts→runPrincipal: readsorgIdfromctx.request.identity(the user-scope identity has no org) and refuses a request with no organization, as it already does for a missing user.Links
Linear: FIX-1926. Found while building FIX-1906 (#3185), under epic FIX-1903. Bug route, so no spec. This PR merges.
Engineering calls
minorchangeset.RunPrincipalnow requiresorgId, and new runs derive new paths. A host that builds aRunPrincipalitself has to pass the org.fixed-board-parity.snapshot.jsonwas regenerated once, deliberately. The values it held before are now pinned literally inorg-place.spec.tsas the place an in-flight run keeps.derivation-snapshot.jsonis unchanged:board-id.spec.tscompares it against the older derivation, which in-flight runs still use.Verification
test/org-place.spec.tsruns the real manager on one store:workspace.spec.ts: two orgs derive different paths and branches;locationForpicks the older place only on a matching record.pnpm vitest runinpackages/harness-manager: 266 passed.labs/conductor: 154 passed.harness-managertypecheck clean;goalstsc --noEmitclean.packages/shift-manager: one failure incommand.test.tsbecause its pages are not built in this container ("the pages are not built at …/dist-client"); not related.🤖 Generated with Claude Code
https://claude.ai/code/session_0155MhTh7kAjLFSg9Wq6ggab
Generated by Claude Code
Note
Medium Risk
Changes filesystem/git isolation and requires org on every new run; migration logic must keep in-flight runs on legacy branches, and callers building
RunPrincipalmust supplyorgId.Overview
Coding-run checkout paths and git branches now include the organization the request was admitted under, so the same user working in two orgs on one host no longer shares a worktree or branch for the same board/issue-phase.
RunPrincipalrequiresorgId, resolved fromctx.request.identity(not user-scope identity); requests without a resolved org are refused like missing user id. Path/branch layout becomes<tenant>/<org>/<user>/…with matchingconductor/…refs.In-flight compatibility:
locationForkeeps the pre-change (orgless) derivation when the run record’s stored branch matches the old shape; the manager reads the record before deriving branch/place so open and provision steps stay aligned. Docs, goal checks, and tests (including neworg-place.spec.ts) reflect the layout and migration behavior.Reviewed by Cursor Bugbot for commit 90ed00b. Configure here.