Skip to content

FIX-1500 PR-B: kitchen-sink runs as one named organization - #2159

Merged
jhoffner merged 3 commits into
mainfrom
fix/FIX-1500-pr-b-named-org
Sep 24, 2026
Merged

jhoffner merged 3 commits into
mainfrom
fix/FIX-1500-pr-b-named-org

Conversation

@jhoffner

@jhoffner jhoffner commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • One organization and one user for the whole app. fsdev.config.ts hands createFlowState one resolvePrincipal. 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-admin and weekly-digest keep their own resolvers.
  • Admin tokens are pinned to that organization. WORKFORCE_ADMIN_TOKENS accepts only kitchen-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.
  • A persistent store written before this change is wiped, not upgraded. That is the product owner's decision on this PR (review comment, 2026-09-24). Booting over such a store stops with an error that names every channel stored under another organization and says how to fix it: delete .fsdev/data, or point FSD_DB_URL at 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

  • The wipe guard (fsdev.config.ts, just before openChannels). 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 isolation (e2e/fixtures.ts, app/page.tsx). Every caller is now devuser, 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.
  • The README's mara paragraph. It said "this app authenticates nobody, so every seat request runs under the development organization". That stopped being true here, so I corrected it to what still holds: fsdev run ignores 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.
  • The a-channel-holds-the-work-a-seat-drains goal hard-coded the development organization and parsed CHANNEL_OWNER = "…" and e2eUserId ?? "…". I changed it to read both names from lib/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.md are already signed off by a human, so please review the code against that direction, not the direction itself. The canonical set is retained at specs/issues/FIX-1500/ on main. 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 in docs/contributing/best-practices.md.

Engineering calls
  • The principal lives in lib/kitchen-sink-principal.ts, and KITCHEN_SINK_ORG_ID, KITCHEN_SINK_USER_ID and resolveKitchenSinkPrincipal are 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.
  • The devtool page drops its ?e2eUserId= override. The server resolves every caller to devuser, so a different label on the panel would be false.
  • Admin tests: one test removed. "Lets two organizations hold a seat of the same name" is gone, because two organizations can no longer be configured. FIX-1475's two-customer example goes for this app (EVOLUTION, review of spec(FIX-1500, FIX-1527): amend — kitchen-sink runs as one named organization #2137). "Refuses to fire another organization's seat" is kept, reframed as a row written under another organization before the pin existed.
Evidence per check (red seen, then green)

All run in this worktree on the current head, with FSDEV_DEFAULT_MODEL and FSDEV_INTENT_* unset. apps/kitchen-sink/test/named-org.test.ts imports the real fsdev.config.ts and drives the router it builds. It substitutes only two things: the model (a scripted agent-answer, through the config's own test-mode seam) and a stand-in rail flow that carries only hireSeat: createSeatHireBlocks(kitchenSinkSeatHireOptions).hire, because PR-D hasn't added that action to chat-agent yet.

Check Green Red state produced
V18 Sessions on chat-agent, support.ada, support.mara and channel bind to kitchen-sink even with a body orgId: "globex". The boot-opened support.desk reads 200 under kitchen-sink. A rail hire lands at kitchen-sink.support.pat, with nothing at globex.support.pat. It reads back through the rail's session (hiredRoster/support.pat) and through chat-agent's roster ref, and a visitor can open it (201). Mara's discover, run in a separate request, lists it Removed resolvePrincipal from fsdev.config.ts: expected '__fsd_default_org__' to be 'kitchen-sink' on every binding, and the hire stream says Organization id "__fsd_default_org__" must be lowercase letters, digits, and single hyphens …. All 5 named-org tests went red
V19 (now: wipe, guarded) A pre-change boot in a temp directory runs the same channel kinds and openChannels through 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, and support.desk reads 200 under kitchen-sink. As a real boot: fsdev serve over a store written by origin/main's config exits 3 with that message Guard removed: expected … to throw error matching /written before kitchen-sink…/ but got 'channel "support.ada-wren" could not be opened — Request failed (403)'
V20 pnpm --filter @flow-state-dev/kitchen-sink test:e2e against a NEXT_PUBLIC_KITCHEN_SINK_TEST_MODE=1 build: 12 passed. Server log: 42 orgId: 'kitchen-sink', 0 of any other organization This PR's resolver with main's page and fixtures (?e2eUserId= isolation): 5 failed, 7 passed. smoke-ask, mode-switching, session-resume, tool-call-rendering and devtool-reflects-request each opened a shared devuser session
V22 Real config with WORKFORCE_ADMIN_TOKENS="acme:t1,kitchen-sink:t2". The boot log names acme (refusing a WORKFORCE_ADMIN_TOKENS entry that names organization "acme"). The acme token gets 401 on fire. The kitchen-sink token's fire releases a rail hire (kitchen-sink.support.pat, through the stand-in rail door) and a mara hire (kitchen-sink.support.quinn, the real support.mara from workforce/teams/, with a scripted model): "released":true, and both addresses are gone Organization check dropped: the acme token returns 200 and its fire answers This organization hired no seat …. Unit level (workforce-admin.test.ts V22): expected [Function] to throw and expected true to be false
V9b (collision kept) kitchen-sink:shared,elsewhere:shared configures nothing Organization checked before collision: expected true to be false, and the shared token resolves

V22 coverage, stated exactly. The rail-hire leg ran through the stand-in rail flow, which uses the same createSeatHireBlocks(kitchenSinkSeatHireOptions).hire block PR-D will mount. It did not run through chat-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 passed
  • pnpm --filter @flow-state-dev/kitchen-sink test:e2e: 12 passed
  • root pnpm typecheck: exit 0
  • root pnpm lint: 24 of 24 tasks successful
  • pnpm fsdev gen --check (kitchen-sink): workforce/workforce.gen.ts is up to date
  • Model-free kitchen-sink goals, run before the wipe change and before fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148 merged:
Goal main this branch
workforce-conventions/a-channel-holds-the-work-a-seat-drains PASS PASS, now reading resourceState("org", "kitchen-sink", …)
continue-interrupted-run, suspension/* (4) PASS PASS
workforce-conventions/code-comes-from-files-alone FAIL FAIL, same text (it names kinds outside the generated module; unrelated)
workforce-conventions/durable-hire-survives-redeploy FAIL (FIX-1548: admin hires 404) FAIL, earlier: it configures acme/bravo tokens, which are now refused, so no row is written
Not verified here
Interplay with #2132 and #2148
  • FIX-1527: kitchen-sink seat support.mara names hire and fire #2132 (FIX-1527, mara) merged before this branch was cut. kitchenSinkSeatHireOptions is imported and not duplicated. manager-seat.test.ts is moved to the pinned organization, including its V7 admin legs (kitchen-sink:tok-ks, and addresses ${ORG}.…).
  • fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148 (FIX-1548) merged to main at 55c9581f4, and main is merged into this branch at 71428172d. 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 address kitchen-sink.~workforce-admin.support.bo and "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.ts is moved off acme/bravo to kitchen-sink. Its other-organization case is now "a token configured for another organization is refused at boot, and so gets 401 at the seat". withAdminAuthentication composes with the pin: it wraps adminPrincipalResolver(), which only accepts kitchen-sink tokens.
  • How the two resolvers compose. The host fallback covers only flows with no resolver of their own. pickPrincipalResolver checks 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 gives adminPrincipalResolver keeps it.
  • A conflict with D1/D6, confirmed on the merged code and not fixed here. fix(kitchen-sink): hired seats answer the admin credential that hired them (FIX-1548) #2148 attaches adminPrincipalResolver inside registerFromRoster. 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 opening kitchen-sink.support.pat (rail hire) or kitchen-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 then undefined, 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

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
@vercel

vercel Bot commented Sep 24, 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 Sep 24, 2026 7:47pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Sep 24, 2026 7:47pm UTC
flow-state-dev-ui Ignored Ignored Preview Sep 24, 2026 7:47pm UTC

Request Review

@linear-code

linear-code Bot commented Sep 24, 2026

Copy link
Copy Markdown

FIX-1500

@cursor

cursor Bot commented Sep 24, 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: serverGenReqId_b2faa2f8-c65a-4523-9fe9-cf16cdf098e7)

@jhoffner
jhoffner marked this pull request as ready for review September 24, 2026 19:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 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-09-24T19:38:41.191973Z 189fbd4 Draft marked ready
ℹ️ 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.

@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: 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
@jhoffner
jhoffner merged commit 5c57608 into main Sep 24, 2026
12 checks passed
@jhoffner
jhoffner deleted the fix/FIX-1500-pr-b-named-org branch September 24, 2026 20:18
jhoffner pushed a commit that referenced this pull request Sep 24, 2026
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
jhoffner pushed a commit that referenced this pull request Sep 24, 2026
…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
jhoffner pushed a commit that referenced this pull request Sep 24, 2026
…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
jhoffner pushed a commit that referenced this pull request Sep 24, 2026
…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
jhoffner pushed a commit that referenced this pull request Sep 24, 2026
…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
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