Repository navigation
FIX-1500 PR-B: kitchen-sink runs as one named organization - #2159
Conversation
One host-level resolvePrincipal in fsdev.config.ts: every flow without a resolver of its own (the assistant, every seat, every channel) runs as org "kitchen-sink" and user "devuser", both constants read from nothing on the request. - WORKFORCE_ADMIN_TOKENS accepts only entries naming kitchen-sink; any other org is refused at boot and logged. The shared-token collision rule runs first, so a secret shared with another org still drops entirely. - A store written before this change holds its channel sessions in the development org. The boot now moves each such session (and its requests) aside to "<channel>~<old org>" before opening the channels, so every file-declared channel opens and reads under kitchen-sink. Earlier history is left behind in the store, unread and not deleted. - E2E isolation moves from a per-test user to a per-test assistant session (?e2eSession=), since every caller is now the same user. - Admin and mara tests move off acme/bravo to the pinned org; new named-org.test.ts drives V18/V19/V22 through the app's real config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB
|
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: serverGenReqId_b2faa2f8-c65a-4523-9fe9-cf16cdf098e7) |
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: 189fbd4110
ℹ️ 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".
The product owner's call on #2159 (review comment 4097667270): no upgrade path. Remove lib/channel-org-upgrade.ts and its boot step. In its place, a read-only guard before openChannels: if any file-declared channel's session is stored under another organization, the boot throws naming each one and the fix (delete .fsdev/data, or point FSD_DB_URL at an empty database). It writes, moves and deletes nothing. The README says to wipe the store after upgrading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB
Resolve the kitchen-sink README: keep PR-B's pinned-token paragraph and fold in #2148's hired-seat paragraph re-keyed to kitchen-sink (kitchen-sink.~workforce-admin.support.bo; no token gets 401; the other-organization 404 no longer applies because such tokens are refused at boot). Move #2148's hired-seat-auth.test.ts off acme/bravo to the pinned organization; its other-org case becomes a token refused at boot, answered 401 at the seat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB
Brings in FIX-1500 PR-B (#2159) so VG can run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB
…chen-sink tokens (FIX-1563) #2184 (FIX-1552) merged catalog cases written against the pre-#2159 acme/bravo constants, which #2159 removed, so main fails kitchen-sink typecheck. The operator's leg now lists with the kitchen-sink admin token; the other-org leg uses the token whose entry was refused at boot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB
…chen-sink tokens (FIX-1563) #2184 (FIX-1552) merged catalog cases written against the pre-#2159 acme/bravo constants, which #2159 removed, so main fails kitchen-sink typecheck. The operator's leg now lists with the kitchen-sink admin token; the other-org leg uses the token whose entry was refused at boot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB
…chen-sink tokens (FIX-1563) #2184 (FIX-1552) merged catalog cases written against the pre-#2159 acme/bravo constants, which #2159 removed, so main fails kitchen-sink typecheck. The operator's leg now lists with the kitchen-sink admin token; the other-org leg uses the token whose entry was refused at boot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB
…chen-sink tokens (FIX-1563) #2184 (FIX-1552) merged catalog cases written against the pre-#2159 acme/bravo constants, which #2159 removed, so main fails kitchen-sink typecheck. The operator's leg now lists with the kitchen-sink admin token; the other-org leg uses the token whose entry was refused at boot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB
The problem
Kitchen-sink authenticates nobody, so it runs as the framework's development organization. That organization's name is not a legal seat address, so every hire in the app is refused. The rail can't hire (the PR-D door), and neither can mara from the app. The operator's admin door runs under whatever organization its token names (the README said
acme). So even when a hire succeeds, the rail and mara read one organization and the operator administers a different one.What this does
fsdev.config.tshandscreateFlowStateoneresolvePrincipal. It returns{ userId: "devuser", orgId: "kitchen-sink" }, both constants, and reads nothing from the request. Every flow without its own resolver runs as that principal: the assistant, every seat, every channel.workforce-adminandweekly-digestkeep their own resolvers.WORKFORCE_ADMIN_TOKENSaccepts onlykitchen-sink:<token>. An entry naming any other organization is refused at boot, and the refusal is logged by organization name, never by token. The shared-token rule still runs first: a secret shared with another organization drops every binding, including kitchen-sink's..fsdev/data, or pointFSD_DB_URLat an empty database. Without this guard the boot would fail with a bare 403 that names neither.What a user of a persistent deployment sees after upgrading: the app refuses to start until they wipe the store. After that it starts empty. None of the earlier data is carried over: assistant chats, seat chats, channel posts, and board rows. The kitchen-sink README says this.
What's asked of you
Nothing new. This implements the approved direction (#2137, D6), with your call on this PR that a pre-change store is wiped rather than upgraded. That replaces the spec's V19 and H1, and the spec amendment recording it is a separate draft PR (#2164). One item below needs an engineering fix, not a decision from you: with #2148 now merged, a seat hired from the rail or by mara refuses visitors whenever an admin token is configured. See Interplay.
Parts worth reviewing closely
fsdev.config.ts, just beforeopenChannels). It only reads: it looks up each file-declared channel's session and throws if any is stored under another organization. It writes, moves and deletes nothing, so two processes booting over one store can't race each other in it.e2e/fixtures.ts,app/page.tsx). Every caller is nowdevuser, so?e2eUserId=can't keep tests apart anymore. Each test now creates its own assistant session and opens/?e2eSession=<id>. That parameter is honoured only in test-mode builds. The page never auto-selects or auto-creates a different session when it is present. The organization still comes only from the constant.lib/workforce-admin-auth.ts: the order of the checks. Collision runs first, then the organization. V9b's red state shows why that order matters.fsdev runignores the app's resolver, so a hire from the CLI is still refused. That paragraph isn't in DOCS.md, because FIX-1527: kitchen-sink seat support.mara names hire and fire #2132 merged after the spec. The admin-fire sentence is left for PR-D, as the spec says.a-channel-holds-the-work-a-seat-drainsgoal hard-coded the development organization and parsedCHANNEL_OWNER = "…"ande2eUserId ?? "…". I changed it to read both names fromlib/kitchen-sink-principal.ts. It passes. Its V13 control ("open the channels as an id the pages don't call as") can't go red anymore, because the session owner now comes from the resolver. That is flagged below as a follow-up and not fixed here.Links: FIX-1500 · epic FIX-1455 · spec
specs/issues/FIX-1500/(PLAN S10, V18–V20, V22) · approved in #2137 · not for merge until reviewed. Hired-seat reachability for admin hires is owned by FIX-1548 / #2148, not by this PR.How to review this
This implements an approved spec. The approach and the numbered decisions in its
DECISIONS.mdare already signed off by a human, so please review the code against that direction, not the direction itself. The canonical set is retained atspecs/issues/FIX-1500/onmain. Linear links to it and to the original merged spec PR, which keeps the review history. Follow-up amendment PRs explain later direction changes. Current architecture docs remain the authority for shipped behavior (BP-037).Most valuable here: correctness on the second path (the legacy shape, the null boundary, the concurrent case, the cancel path), anything that derives an auth or routing decision from caller-controllable input, and any behaviour the tests assert around rather than on.
Already settled upstream: the approach and every decision in the spec's
DECISIONS.md(human-approved; if one is wrong, raise it as a spec finding and it gets folded back, rather than re-arguing it inline), and the conventions indocs/contributing/best-practices.md.Engineering calls
lib/kitchen-sink-principal.ts, andKITCHEN_SINK_ORG_ID,KITCHEN_SINK_USER_IDandresolveKitchenSinkPrincipalare exported from there. The page, the devtool page, the admin auth and the channel owner all import from it, so no copy of"devuser"is left to drift.?e2eUserId=override. The server resolves every caller todevuser, so a different label on the panel would be false.Evidence per check (red seen, then green)
All run in this worktree on the current head, with
FSDEV_DEFAULT_MODELandFSDEV_INTENT_*unset.apps/kitchen-sink/test/named-org.test.tsimports the realfsdev.config.tsand drives the router it builds. It substitutes only two things: the model (a scriptedagent-answer, through the config's own test-mode seam) and a stand-in rail flow that carries onlyhireSeat: createSeatHireBlocks(kitchenSinkSeatHireOptions).hire, because PR-D hasn't added that action tochat-agentyet.chat-agent,support.ada,support.maraandchannelbind tokitchen-sinkeven with a bodyorgId: "globex". The boot-openedsupport.deskreads 200 underkitchen-sink. A rail hire lands atkitchen-sink.support.pat, with nothing atglobex.support.pat. It reads back through the rail's session (hiredRoster/support.pat) and throughchat-agent'srosterref, and a visitor can open it (201). Mara'sdiscover, run in a separate request, lists itresolvePrincipalfromfsdev.config.ts:expected '__fsd_default_org__' to be 'kitchen-sink'on every binding, and the hire stream saysOrganization id "__fsd_default_org__" must be lowercase letters, digits, and single hyphens …. All 5 named-org tests went redopenChannelsthrough a router with no resolver, so every channel lands in the development organization. Booting the real config over the same location then rejects with[workforce] this store was written before kitchen-sink ran as organization "kitchen-sink", and its channels belong to another organization: "support.ada-wren" (organization "__fsd_default_org__"), … Delete the store and restart: for the dev profile (STORE_TYPE=filesystem) remove .fsdev/data; for the prod profile, point FSD_DB_URL at an empty database.All three channels are still under the old organization afterwards, so nothing was moved. After the store is deleted, the same location boots, andsupport.deskreads 200 underkitchen-sink. As a real boot:fsdev serveover a store written by origin/main's config exits 3 with that messageexpected … to throw error matching /written before kitchen-sink…/ but got 'channel "support.ada-wren" could not be opened — Request failed (403)'pnpm --filter @flow-state-dev/kitchen-sink test:e2eagainst aNEXT_PUBLIC_KITCHEN_SINK_TEST_MODE=1build: 12 passed. Server log: 42orgId: 'kitchen-sink', 0 of any other organization?e2eUserId=isolation): 5 failed, 7 passed.smoke-ask,mode-switching,session-resume,tool-call-renderinganddevtool-reflects-requesteach opened a shareddevusersessionWORKFORCE_ADMIN_TOKENS="acme:t1,kitchen-sink:t2". The boot log namesacme(refusing a WORKFORCE_ADMIN_TOKENS entry that names organization "acme"). Theacmetoken gets 401 onfire. Thekitchen-sinktoken'sfirereleases a rail hire (kitchen-sink.support.pat, through the stand-in rail door) and a mara hire (kitchen-sink.support.quinn, the realsupport.marafromworkforce/teams/, with a scripted model):"released":true, and both addresses are goneacmetoken returns 200 and its fire answersThis organization hired no seat …. Unit level (workforce-admin.test.tsV22):expected [Function] to throwandexpected true to be falsekitchen-sink:shared,elsewhere:sharedconfigures nothingexpected true to be false, and the shared token resolvesV22 coverage, stated exactly. The rail-hire leg ran through the stand-in rail flow, which uses the same
createSeatHireBlocks(kitchenSinkSeatHireOptions).hireblock PR-D will mount. It did not run throughchat-agent's own action, which doesn't exist yet: that waits for PR-D. The mara leg ran against the real merged mara seat (#2132).Suites run
After merging main (#2148), on the current head:
pnpm --filter @flow-state-dev/kitchen-sink test: 21 files, 152 tests passedpnpm --filter @flow-state-dev/kitchen-sink test:e2e: 12 passedpnpm typecheck: exit 0pnpm lint: 24 of 24 tasks successfulpnpm fsdev gen --check(kitchen-sink):workforce/workforce.gen.ts is up to dateworkforce-conventions/a-channel-holds-the-work-a-seat-drainsresourceState("org", "kitchen-sink", …)continue-interrupted-run,suspension/*(4)workforce-conventions/code-comes-from-files-aloneworkforce-conventions/durable-hire-survives-redeployacme/bravotokens, which are now refused, so no row is writtenNot verified here
prodprofile). The guard ran on the filesystem store only. It uses nothing butsession.get.state/org/__fsd_default_org__/kitchen-sink/…), as it does on every boot. The guard itself writes nothing. The store is wiped anyway.chat-agenthire action and the browserVG. Both belong to PR-D.workforce-adminwere unreachable before fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148 (pin{kitchen-sink, workforce-admin}, callerdevuser, answered404). With fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148 merged in, such a seat answers thekitchen-sinkadmin token (201) and refuses a request with no token (401). This is FIX-1548's fix, not this PR's.durable-hire-survives-redeploygoal. Its two-organization legs (body namesbravounderacme's token) can't be configured under the pin. Redesigning it belongs with FIX-1548 / fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148 or a follow-up. Not re-run since fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148 merged.acme) are still reloaded at boot, because the reload walks every stored organization. No token can fire them now, and no caller can reach them. They are inert, not harmful.Interplay with #2132 and #2148
kitchenSinkSeatHireOptionsis imported and not duplicated.manager-seat.test.tsis moved to the pinned organization, including its V7 admin legs (kitchen-sink:tok-ks, and addresses${ORG}.…).55c9581f4, and main is merged into this branch at71428172d. The README conflict is resolved: this PR's pinned-token paragraph is kept, and fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148's hired-seat paragraph is folded in with the addresskitchen-sink.~workforce-admin.support.boand "no token gets 401". Its "another organization's token gets 404" line is dropped, because such tokens are now refused at boot.hired-seat-auth.test.tsis moved offacme/bravotokitchen-sink. Its other-organization case is now "a token configured for another organization is refused at boot, and so gets 401 at the seat".withAdminAuthenticationcomposes with the pin: it wrapsadminPrincipalResolver(), which only acceptskitchen-sinktokens.pickPrincipalResolverchecks the instance first (packages/engine/src/transports/auth/pickPrincipalResolver.ts:27), so a seat that fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148 givesadminPrincipalResolverkeeps it.adminPrincipalResolverinsideregisterFromRoster. The rail's and mara's org-visible hires go through that same door (kitchenSinkSeatHireOptions.register). So whenever any admin token is configured, a visitor openingkitchen-sink.support.pat(rail hire) orkitchen-sink.support.quinn(mara hire) gets 401 "workforce-admin requires an admin credential". With no tokens configured this doesn't happen, because the resolver is thenundefined, and that is why V18 and PR-D's VG pass. A likely fix: attach the resolver only to user-owned pins (pin.userId !== undefined). It belongs to FIX-1548's owner or a follow-up, and I haven't widened this PR to cover it.🤖 Generated with Claude Code
https://claude.ai/code/session_01ANuyMVi3YS653fcghb9gtB