Repository navigation
fix(FIX-2161): keep a legacy task's project, refuse a session of another worker - #3829
Conversation
…her worker A row filed before rows carried the project stamp now falls back to the project its conversation had then, which can't have come from workProjectId, else the project its input names. A follow-up of such a task stays in that project after the conversation changes project, instead of erroring on the root's task session (key-occupied on filingProjectId); a waiting one is handed it. setWorkProject now sends its worker, and the action refuses a session running another worker, storing nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qsh48df8qzrorsfaCXn1X7
|
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. |
jhoffner
left a comment
There was a problem hiding this comment.
Second look + architecture pass on #3829.
Approach: sound and proportionate. Resolving a legacy row's project at read time (BP-030) is the right shape; no migration or rewrite of stored rows is needed. The refusal belongs in the action, not the client.
Worth doing in this PR (the refactor opportunity is right here):
- Collapse the two legacy-project readers (
legacyProjectOfandhandedProjectOf). They disagree on the input-named fallback, and theworkProjectIdstrip is duplicated. See inline. - Add a test for the hand-over (waiting legacy row) half. Reverting
handedProjectOfcurrently fails nothing. See inline.
Optional: state the limit of the optional worker guard (an intent check, not an enforcement boundary), and rewrap the README paragraph. See inline.
No broader refactor is warranted. Nothing else in the diff is an opportunity beyond the helper unification above.
Generated by Claude Code
There was a problem hiding this comment.
Simplify review (FIX-2161)
Verdict: The behavioral fixes look right and the test matrix matches the spec (legacy follow-up, waiting, other worker). I’m approving; the notes below are about a smaller surface area for the worker guard and one place for the “ignore workProjectId” legacy rule—not blockers.
What’s working
- Stripping
workProjectIdbefore resolving an unstamped row is the minimal BP-030 fix for “conversation as it stood at filing,” without a migration. - The legacy follow-up test (
unstamp+setWorkProject+ follow-up) is the right regression for pre-stamp rows. - Worker mismatch refusal closes the real footgun (
lead/mainsharing a coordinator flow +sessionId).
Where complexity crept in
1. Worker binding via optional action input
setWorkProjectInputSchema grows an optional worker, and the block only refuses when input.worker !== undefined. The workforce client always passes worker, so the client API is fixed, but the declared action still accepts { project } alone—same cross-session mistake remains for anything that invokes the action directly without worker (tools, custom hosts, Error Reporter act, etc.).
Cleaner alternative (I’d lean this way): keep the action input as { project } only and enforce binding in createWorkforceClient.setWorkProject: after resolving sessionId, read the session’s WORKER_ID_STATE_KEY (trusted server state) and refuse if it !== the worker argument before runIn. No public schema change, no optional field, no README line about worker? on the action.
If you prefer defense-in-depth in the block, make worker required in the schema (and update every action entry point), not optional—optional reads as “sometimes we check.”
2. Two legacy paths that almost share logic
legacyProjectOf (strip → filingProjectAddressOf → input.project) and unstamped handedProjectOf (strip → filingProjectOf only) duplicate the omit pattern and differ on address vs string ref and on whether row input counts.
Cleaner alternative: one helper in filing-session.ts, e.g. conversationProjectBeforeWorkProject(state, row?), used by both filedProjectFor and handedProjectOf. For hand-over, I’d consider legacyProjectOf + projectRef so unstamped waiting rows filed with only input.project behave like follow-ups (I’m not sure production has that shape—worth a one-line invariant or a test if you keep the split).
3. Nits
unstampcould useFILED_PROJECTfromboard-entrieslikeconversation-board-filing.test.ts.- Doc on the schema says the session “must” run the worker while the field is optional—small mismatch.
Skipped (larger than this PR)
- Backfilling
filedInProjecton read to drop the permanent!isStampedbranch. - Deduplicating ledger reads in
handedProjectOf/sessionSettingOf(perf reviewer: fine to ship).
Performance
No concerns for hot paths; duplicate ledger fetch on hand-over is optional future dedupe.
Nice tight changeset overall—main follow-up I’d consider for a follow-up PR is client-side worker binding instead of optional action worker.
Sent by Cursor Automation: Review For Best Approach
|
Engineering review: FIX-2161 follow-up (worker mismatch + legacy-row project) at Verdict: good to merge once the remaining CI jobs finish. No blockers. What I checked:
Notes (none blocking):
CI at
— FSD Head of Engineering |
There was a problem hiding this comment.
Code Snob — already tight. No POC.
I read packages/workforce/src/conversation-board/board.ts (filedProjectFor, legacyProjectOf, handedProjectOf), filing-session.ts (filingProjectOf, filingProjectAddressOf), held-task.ts (isStamped, filedProjectOf, filingProjectStampOf), projects/work-project.ts, workers/client.ts, projects/run-project.ts (namedProjectOf), and test/work-project.test.ts.
The two workProjectId omits stay one line each. Filing needs an address (filingProjectAddressOf, workstream first, then the project the row names). Hand-over needs the string filingProjectOf already writes on the session, and stops there: a waiting row with no conversation project is handed nothing, and the run still reads input.project. A helper around the omit is longer than those two lines. Sending hand-over through legacyProjectOf would write that named project onto filingProjectId.
legacyProjectOf stays a function. Inlining it into the early return in filedProjectFor drops the name and not a step. That return is what keeps an unstamped root off the session's current project. namedProjectOf is the run's three-way read (none, named, malformed). This path only wants an address or nothing.
The worker refusal stays the three lines beside the no-worker check. lead and main share a flow, so the action sees worker, and the client passes it. unstamp is the one store write the legacy test needs; inlining it moves those lines into the test.
The doc on legacyProjectOf is why the key comes out: workProjectId is a later set, and the input fallback is what the run read. Folding the schema comment back to one line is the only shorter wording, and the check stays the same length. The README sentence, the docs table row, and the changeset are the caller-visible line each.
Sent by Cursor Automation: Code Snob
The two legacy readers share stateBeforeWorkProject. Hand-over keeps handing only the conversation's pre-workProjectId project, not the one a row's input names: a legacy root's task session already exists with that value in its readonly filingProjectId, and the doc comment now says so. Adds the waiting-row leg, moves the unstamp fixture to the projects harness, notes that the worker check is the caller's intent and not a boundary, and rewraps the README paragraph. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qsh48df8qzrorsfaCXn1X7
…the conversation's project Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qsh48df8qzrorsfaCXn1X7
|
@codex review 7b52ca5 adds one test leg for the head of engineering's second note. It covers Please look closely at Generated by Claude Code |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |


Requested by Jake · project thread
The problem
Two gaps in FIX-2161 (#3821, merged) were found after it landed.
key-occupied … readonly state field "filingProjectId"). A legacy task still waiting on the board would also be handed the new project.setWorkProject(worker, project, { sessionId })accepted a session of another worker. The head of engineering raised this on agent-mailbox Add governance and publishing configuration #46, and the architect agreed it is the spec's meaning.workeronly picked the flow, so namingleadwith amainsession setmain's project.What this does
filedInProjectabsent) now resolves to the project it was filed in. That is the conversation's project as it stood then, read withoutworkProjectId(the field didn't exist before the stamp), and failing that, the project the row's input names. A follow-up of such a row stamps and normalizes to that project. Hand-over of a waiting legacy row uses the same pre-workProjectIdread (BP-030).workerwith the action. The action refuses withRefused: this session runs "<x>", not "<worker>"before anything is stored.workeris optional in the input, so an older caller keeps working.What's asked of you
Nothing. This is a bug fix to the approved FIX-2161 spec.
Parts worth reviewing closely
legacyProjectOfinconversation-board/board.ts. Can a row filed after the stamp shipped ever reach it unstamped? Steps live on the plan ledger, not this board, so they don't.handedProjectOf's fallback now ignoresworkProjectId. That is right for legacy rows, because every row filed since feat(FIX-2161): a user's own conversation with a worker opens on a project #3821 is stamped.Fixes FIX-2161 (follow-up) · Goal check:
packages/workforce/test/work-project.test.ts, 13/13 PASS.Verification
New legs and their controls:
legacy follow-up: an unstamped root naming Apollo, conversation moved to Beta, follow-up must run in Apolloboard.tsas onmainkey-occupiedonfilingProjectId), so no run happens. The other 11 passother worker:setWorkProject("lead", …, { sessionId: <main's> })must reject, andmainmust still have no projectworkerSuites. The conversation-board, follow-up, split, steer, project-coordinator, workstream, Error Reporter and work-project suites pass: 17 files, 243 tests (
FSDEV_DEFAULT_MODEL=empty, because this container sets it in an old format).tsc --noEmiton the package reports no errors. ESLint is clean. The Process guards scripts (retired terms, changeset refs, spec folder, publish set, NUL bytes, model strings, reserved names, isolation) all pass.Docs. The README and
apps/docs/docs/workforce/projects.mdgain the refusal and the "run that worker" rule. Changeset: workforcepatch.Generated by Claude Code