The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
v3 Review Security Fixes Implementation Plan
Task #4216. Written by the writing-plans skill as this project's Engineer works: one Engineer implements it task by task, test first, and the pull request's review is the one independent review.
Goal: Close the three findings of anh Dee's Buddy's review of main 0413586e that hold up when checked: a guest reading the owner's Claude and Codex allowances, a Can chat grant or decider seat coming back when a person rejoins, and Stripe, GitLab and npm tokens passing the chat's credential filter.
Architecture: Each fix sits where the rule already lives: the guest's default-deny list (cli/src/core/guestPolicy.ts), the Swarm's join and leave hooks that already settle project owners (backend/src/superTabs/projects.ts admitPerson and dismissPeople), and the credential rules (backend/src/superTabs/credentials.ts RULES).
Tech Stack: TypeScript, vitest.
Spec: the task brief (#4216). Verified on main 0413586e, 2026-11-07:
- guestPolicy.ts:22 is real.
usage_readis in the guest's ANY list, and services/usage.ts answers its default reading (this machine's Claude and Codex allowances, with their account key) to any asker. Its reason, "a guest's harness uses the owner's subscription through the relay", is gone: since 2026-11-07 a guest's harness runs on the guest's own sign-in and nothing spends the owner's subscription (lib/guestPaneCommand.ts, anh Dee). - boardRights.ts:28 is real.
project.canChatandproject.deciderhold a bare person id. Leaving the Swarm (dismissPeople) leaves both as they are, andreadsProjectis true for any member of a public project, so a person removed and invited back has Can chat and the decider's P0 and pause rights again, though owning (ownsProject) and listed membership (canReadProject) already end with the membership. - credentials.ts:105 is real. No rule matches a Stripe key (
sk_live_…: the OpenAI rule needssk-), a GitLab token (glpat-…) or an npm token (npm_…), so each is stored as pasted.
Global Constraints
- Test first: each failing test is its own commit before the code that passes it.
- Never read or print a secret or login: every token in a test is built at run time from fake parts (credentials.test.ts
noise). - Contracts only extend: a new credential kind adds a label; no client parses the kind (checked: no Dart or TS client reads
credentialsRemovedkinds). - No setting, no switch.
Review Focus
- A rejoining person's stale grant from before this fix (left before it shipped): cleared when they are admitted again.
- A grant of someone who is still in the Swarm survives another person leaving or joining.
- The credential filter takes no ordinary text: a docs placeholder (a Stripe prefix then one letter repeated) and prose that only
names
npm_config_variables orglpat-stay. - A guest's refused
usage_readsays so (GUEST_NOT_ALLOWED with its message), never a silent drop. - The owner's own apps and local callers still read usage (superTabs/start.ts inspectCapacity, machines.ts).
Task 1: A guest no longer reads the owner's allowances
Files:
Modify:
cli/src/core/guestPolicy.ts:21-22(dropusage_readfrom ANY)Modify:
cli/src/services/usage.ts:77-78(the comment that says the default reading is open to guests)Test:
cli/src/core/guestPolicy.spec.ts,cli/src/backendSocket.guest.spec.tsStep 1: Failing tests. guestPolicy.spec.ts:
verdict('usage_read')is{ allow: false, error: 'GUEST_NOT_ALLOWED' }, andusage_readleaves the allowed list. backendSocket.guest.spec.ts: a guest'susage_readnever reaches the service router and is answered GUEST_NOT_ALLOWED; the "may ask what is allowed" case usesguest_foldersinstead.Step 2: Run
npx vitest run src/core/guestPolicy.spec.ts src/backendSocket.guest.spec.tsin cli: FAIL on the new asserts.Step 3: Code. Remove
usage_readand its comment from ANY; usage.ts comment says only the owner reads a profile's account.Step 4: Run the same: PASS. Then
npm run test:core(CLI coverage gate for core/ and services/).Step 5: Commit test, then code.
Task 2: Board rights end with the membership
Files:
- Modify:
backend/src/superTabs/projects.ts(admitPerson, dismissPeople; newsettleBoardRights) - Test:
backend/src/superTabs/boardRights.test.ts
Interfaces:
Produces:
settleBoardRights(state: SuperTabState): voidin projects.ts — drops from every project'scanChatanddecidereach id not instate.people, deleting an emptycanChat. Called by dismissPeople after the people go and by admitPerson before the person is added (which clears a grant left from before this fix).Step 1: Failing test in boardRights.test.ts, "a person who leaves and is invited back gets no Board right back": boardFixture, switch on, grant
cCan chat, nameddecider;member.removeboth (Swarm owner);canChatanddeciderare gone from the project; invite and accept each again;canChat(state, project, 'c')andsteers(state, project, 'd')are false, andcposting in the project chat is refused CHAT_NOT_ALLOWED. A second case: a grant written before the fix (state edited socleft with the grant kept) is cleared whencis admitted again. A third:c's grant stays whendleaves.Step 2: Run
npx vitest run src/superTabs/boardRights.test.tsin backend: FAIL.Step 3: Code
settleBoardRightsand its two calls.Step 4: Run the same and
src/superTabs/projectOwners.test.ts: PASS.Step 5: Commit test, then code.
Task 3: Stripe, GitLab and npm tokens are removed
Files:
- Modify:
backend/src/superTabs/credentials.ts(CredentialKind, CREDENTIAL_LABELS, RULES) - Test:
backend/src/superTabs/credentials.test.ts
Interfaces:
- Produces: kinds
'stripe'("Stripe secret key"),'gitlab'("GitLab token"),'npm'("npm token").
Formats (the vendors' documented prefixes, one rule each, same boundaries and random check as the GitHub rule):
Stripe:
(?:sk|rk)_(?:live|test)_then 24 or more letters and digits (secret and restricted keys).GitLab:
gl(?:pat|oas|dt|rt|rtr|cbt|ptt|ft|imt|agent|soat|ffct)-then 20 or more of[A-Za-z0-9_-], with the routable suffix.xx.yyyyyyyyyof new tokens included when present.npm:
npm_then 36 letters and digits.Step 1: Failing tests. Add to the "every kind it removes" table: a live and a test Stripe secret key, a Stripe restricted key, a GitLab personal access token, a routable GitLab token, a GitLab deploy token, an npm token. Add to the ordinary texts: a Stripe live prefix followed by a run of one repeated letter (built at run time),
npm_config_registry=https://registry.npmjs.org, "set your glpat- token".Step 2: Run
npx vitest run src/superTabs/credentials.test.tsin backend: FAIL on the new kinds.Step 3: Code the three kinds, labels and rules.
Step 4: Run the same and the credential cases of
src/superTabs/commands.test.ts: PASS.Step 5: Commit test, then code.