Skip to content

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.

Security fixes from the v3 review: guest quota, chat rights on rejoin, secret patterns (#4216) (#3467)

0xken15478f10072bac
diff --git a/backend/src/superTabs/boardRights.test.ts b/backend/src/superTabs/boardRights.test.ts
index 66d401938..ac2f3fac1 100644
--- a/backend/src/superTabs/boardRights.test.ts
+++ b/backend/src/superTabs/boardRights.test.ts
@@ -98,6 +98,50 @@ describe('a project\'s Board settings', () => {
})
})
+describe('Board rights after a person leaves', () => {
+ // Task #4216: owning a project and being listed in it end with the membership (#3073); Can chat and the decider's seat end too.
+ const leaveAndReturn = (f: ReturnType<typeof boardFixture>, person: Actor & { kind: 'person' }) => {
+ f.run({ type: 'member.remove', userId: person.userId }, swarmOwner)
+ const invited = f.run({ type: 'invite.create', email: person.email, role: 'collaborator', conversationId: f.app.conversationId }, swarmOwner)
+ f.run({ type: 'invite.accept', inviteId: invited.inviteId as string }, person)
+ }
+
+ it('gives a person who left and was invited back no Can chat and no decider seat', () => {
+ const f = boardFixture()
+ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: true })
+ f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'c', granted: true })
+ f.run({ type: 'project.decider', projectId: f.app.projectId, personId: 'd' })
+ leaveAndReturn(f, granted as Actor & { kind: 'person' })
+ leaveAndReturn(f, member as Actor & { kind: 'person' })
+ expect(f.project().canChat).toBeUndefined()
+ expect(f.project().decider).toBeUndefined()
+ expect(canChat(f.state, f.project(), 'c')).toBe(false)
+ expect(steers(f.state, f.project(), 'd')).toBe(false)
+ expect(() => f.run({ type: 'message.send', conversationId: f.app.conversationId, text: 'Back', replyTo: null, recipientIds: [] }, granted))
+ .toThrow(expect.objectContaining({ code: 'CHAT_NOT_ALLOWED' }))
+ })
+
+ it('clears a right kept from before this fix when its person comes back', () => {
+ const f = boardFixture()
+ f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'c', granted: true })
+ f.run({ type: 'project.decider', projectId: f.app.projectId, personId: 'c' })
+ // Stored as a Swarm that lost them before the fix shipped: gone from the people, still named in the project.
+ f.state.people.splice(f.state.people.findIndex(person => person.id === 'c'), 1)
+ const invited = f.run({ type: 'invite.create', email: '[email protected]', role: 'collaborator', conversationId: f.app.conversationId }, swarmOwner)
+ f.run({ type: 'invite.accept', inviteId: invited.inviteId as string }, granted)
+ expect(canChat(f.state, f.project(), 'c')).toBe(false)
+ expect(steers(f.state, f.project(), 'c')).toBe(false)
+ })
+
+ it('keeps the rights of those who stay', () => {
+ const f = boardFixture()
+ f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'c', granted: true })
+ f.run({ type: 'project.decider', projectId: f.app.projectId, personId: 'c' })
+ leaveAndReturn(f, member as Actor & { kind: 'person' })
+ expect(f.project()).toMatchObject({ canChat: ['c'], decider: 'c' })
+ })
+})
+
describe('Can chat in a switched project', () => {
const say = (conversationId: string, text = 'Hello') => ({ type: 'message.send', conversationId, text, replyTo: null, recipientIds: [] }) as Command
const switchedFixture = () => {
diff --git a/backend/src/superTabs/credentials.test.ts b/backend/src/superTabs/credentials.test.ts
index 025ae3005..db4920a89 100644
--- a/backend/src/superTabs/credentials.test.ts
+++ b/backend/src/superTabs/credentials.test.ts
@@ -31,6 +31,11 @@ const fake = {
awsSecret: () => noise(40, B64, 18),
slack: (kind = 'b') => [`xox${kind}`, '1234567890', '9876543210', noise(24, ALNUM, 19)].join('-'),
google: () => ['AI', 'za', noise(35, B64URL, 20)].join(''),
+ // Stripe: sk_ (secret) or rk_ (restricted), live_ or test_, then the key.
+ stripe: (kind = 'sk', mode = 'live') => [kind, mode, noise(99, ALNUM, 25)].join('_'),
+ // GitLab: a type prefix (glpat personal, gldt deploy, …), then the token, with a routable .xx.yyyyyyyyy suffix on new ones.
+ gitlab: (prefix = 'glpat', routable = false) => [prefix, `${noise(routable ? 27 : 20, B64URL, 26)}${routable ? `.01.${noise(9, 'abcdefghijklmnopqrstuvwxyz0123456789', 27)}` : ''}`].join('-'),
+ npm: () => ['npm', noise(36, ALNUM, 28)].join('_'),
pem: (kind = 'RSA PRIVATE') => [`-----BEGIN ${kind} KEY-----`, noise(64, B64, 21), noise(64, B64, 22), `${noise(20, B64, 23)}==`, `-----END ${kind} KEY-----`].join('\n'),
password: () => `Fx${noise(16, ALNUM, 24)}`,
}
@@ -63,6 +68,14 @@ describe('findCredentials: every kind it removes', () => {
['slack', 'a Slack user token', fake.slack('p')],
['slack', 'a Slack app token', fake.slack('a')],
['google', 'a Google API key', fake.google()],
+ ['stripe', 'a Stripe live secret key', fake.stripe()],
+ ['stripe', 'a Stripe test secret key', fake.stripe('sk', 'test')],
+ ['stripe', 'a Stripe restricted key', fake.stripe('rk')],
+ ['gitlab', 'a GitLab personal access token', fake.gitlab()],
+ ['gitlab', 'a routable GitLab token', fake.gitlab('glpat', true)],
+ ['gitlab', 'a GitLab deploy token', fake.gitlab('gldt')],
+ ['gitlab', 'a GitLab runner token', fake.gitlab('glrt')],
+ ['npm', 'an npm token', fake.npm()],
['private-key', 'a PEM RSA private key', fake.pem()],
['private-key', 'a PKCS#8 private key', fake.pem('PRIVATE')],
['private-key', 'an OpenSSH private key', fake.pem('OPENSSH PRIVATE')],
@@ -187,7 +200,8 @@ describe('findCredentials: what it leaves alone', () => {
'def get_secret(name: str) -> str:\n return vault.read(name)', 'SELECT id, password_reset_at FROM users WHERE token_id = $1',
'for (const token of tokens) count += token.length', '<input type="password" name="password" autocomplete="current-password">',
// Placeholders and redacted values
- 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'sk-...', 'sk-your-key-here', 'sk-learn and scikit-learn', 'AKIAXXXXXXXXXXXXXXXX',
+ 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', ['sk', 'live', 'x'.repeat(24)].join('_'), ['glpat', 'x'.repeat(20)].join('-'),
+ ['npm', '0'.repeat(36)].join('_'), 'npm_config_registry=https://registry.npmjs.org', 'Set your glpat- token in CI.', 'sk-...', 'sk-your-key-here', 'sk-learn and scikit-learn', 'AKIAXXXXXXXXXXXXXXXX',
'xoxb-your-token-here', 'password=changeme', 'password: ********', 'token: <redacted>', 'secret=${SECRET}', 'API_KEY=<your key>',
'password=test-password-123', 'token: e2e-token-agent-client', 'apiKey: gridkey-abc123', `token: ${CREDENTIAL_MARKER}`, 'hna_short',
'Bearer tokens expire after an hour.', 'Basic authentication is disabled.', 'Authorization: Bearer test-access-token',
diff --git a/backend/src/superTabs/credentials.ts b/backend/src/superTabs/credentials.ts
index c90c6e911..a46c5b61d 100644
--- a/backend/src/superTabs/credentials.ts
+++ b/backend/src/superTabs/credentials.ts
@@ -13,7 +13,7 @@ import {
* secret without holding one, and ordinary prose in any language pass unchanged.
*/
export type CredentialKind = 'private-key' | 'jwt' | 'harness' | 'github' | 'anthropic' | 'openai' | 'aws-key-id' | 'aws-secret'
- | 'slack' | 'google' | 'password'
+ | 'slack' | 'google' | 'stripe' | 'gitlab' | 'npm' | 'password'
/** What the sender is told was removed. */
export const CREDENTIAL_LABELS: Record<CredentialKind, string> = {
@@ -27,6 +27,9 @@ export const CREDENTIAL_LABELS: Record<CredentialKind, string> = {
'aws-secret': 'AWS secret access key',
slack: 'Slack token',
google: 'Google API key',
+ stripe: 'Stripe secret key',
+ gitlab: 'GitLab token',
+ npm: 'npm token',
password: 'password or secret',
}
@@ -111,6 +114,13 @@ const RULES: Rule[] = [
{ kind: 'slack', pattern: /(?<![A-Za-z0-9_-])xox[abprs]-\d{6,}-[A-Za-z0-9-]{8,}(?![A-Za-z0-9_-])/dg, accept: token => random(token) },
// Base64 data cannot be next to it, so a long image never holds one by chance.
{ kind: 'google', pattern: /(?<![A-Za-z0-9_\-+/])AIza[A-Za-z0-9_-]{35}(?![A-Za-z0-9_\-+/])/dg, accept: token => random(token.slice(4)) },
+ // Secret and restricted keys, live and test: a test key still reads and writes the account's test data.
+ { kind: 'stripe', pattern: /(?<![A-Za-z0-9_])[sr]k_(?:live|test)_[A-Za-z0-9]{24,}(?![A-Za-z0-9_])/dg, accept: token => random(token.slice(8)) },
+ // GitLab's token prefixes (personal, OAuth, deploy, runner, CI job, trigger, feed, incoming mail, agent, service account,
+ // feature flags), and the routable .xx.yyyyyyyyy suffix of new tokens.
+ { kind: 'gitlab', accept: token => random(token.slice(token.indexOf('-') + 1)),
+ pattern: /(?<![A-Za-z0-9_-])gl(?:pat|oas|dt|rt|rtr|cbt|ptt|ft|imt|agent|soat|ffct)-[A-Za-z0-9_-]{20,}(?:\.[0-9a-z]{2}\.[0-9a-z]{9})?(?![A-Za-z0-9_-])/dg },
+ { kind: 'npm', pattern: /(?<![A-Za-z0-9_])npm_[A-Za-z0-9]{36}(?![A-Za-z0-9_])/dg, accept: token => random(token.slice(4)) },
// Authorization: Bearer|Basic|Token …, which may be letters only (Basic is base64 of user:password).
{ kind: 'password', group: 1, accept: value => secretValue(value, 12, true),
pattern: /(?<![A-Za-z0-9_-])Authorization["']?\s*[:=]\s*["']?(?:Bearer|Basic|Token|Bot)\s+([A-Za-z0-9._~+/=-]{12,})/dgi },
diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.ts
index 0a095f79e..1ff0fc72b 100644
--- a/backend/src/superTabs/projects.ts
+++ b/backend/src/superTabs/projects.ts
@@ -239,6 +239,7 @@ export function settleOwners(state: SuperTabState): Array<{ projectId: string; f
* a project from before ownerGeneration whose owner left is never matched to them again (security reviews of #3082). */
export function admitPerson(state: SuperTabState, member: Person): void {
settleOwners(state)
+ settleBoardRights(state)
state.people.push(member)
}
@@ -247,6 +248,22 @@ export function admitPerson(state: SuperTabState, member: Person): void {
export function dismissPeople(state: SuperTabState, leaving: ReadonlySet<string>): void {
state.people = state.people.filter(p => !leaving.has(p.id))
settleOwners(state)
+ settleBoardRights(state)
+}
+
+/** Takes everyone no longer in the Swarm out of each project's Can chat and decider seat (task #4216). Both name a person by
+ * id only, and any member reads a public project, so without this a person removed and invited back had them again. Run
+ * before a person is admitted too, which clears a right kept from before this ran on leaving. */
+function settleBoardRights(state: SuperTabState): void {
+ const people = new Set(state.people.map(p => p.id))
+ for (const project of state.projects ?? []) {
+ if (project.canChat) {
+ const kept = project.canChat.filter(id => people.has(id))
+ if (kept.length) project.canChat = kept
+ else delete project.canChat
+ }
+ if (project.decider && !people.has(project.decider)) delete project.decider
+ }
}
/** Whose active work other projects' Leads see and are alerted about. A private project's work stays with its own people. */
diff --git a/cli/src/backendSocket.guest.spec.ts b/cli/src/backendSocket.guest.spec.ts
index b250fb334..5e36dcd08 100644
--- a/cli/src/backendSocket.guest.spec.ts
+++ b/cli/src/backendSocket.guest.spec.ts
@@ -51,10 +51,19 @@ describe('a guest session', () => {
const { socket, ask } = session('[email protected]')
const askers: unknown[] = []
socket.serviceRouter = (_type, _payload, asker, reply) => { askers.push(asker); reply({ ok: true }); return true }
- await ask('usage_read')
+ await ask('guest_folders')
expect(askers).toEqual([expect.objectContaining({ owner: false, guest: '[email protected]' })])
})
+ it('never hears the owner\'s plan allowances: the usage service is not asked', async () => {
+ const { socket, ask, answered } = session('[email protected]')
+ const routed = vi.fn(() => true)
+ socket.serviceRouter = routed
+ await ask('usage_read')
+ expect(routed).not.toHaveBeenCalled()
+ expect(answered()).toEqual([{ type: 'usage_read', payload: expect.objectContaining({ error: 'GUEST_NOT_ALLOWED' }) }])
+ })
+
it('lists only its own harnesses, and opens only their terminals', async () => {
const { socket, ask, answered } = session('[email protected]')
const lists: unknown[] = []
diff --git a/cli/src/core/guestPolicy.spec.ts b/cli/src/core/guestPolicy.spec.ts
index b7d56a0d0..4f95e8bb7 100644
--- a/cli/src/core/guestPolicy.spec.ts
+++ b/cli/src/core/guestPolicy.spec.ts
@@ -9,7 +9,7 @@ describe('what a guest may ask', () => {
const verdict = (type: string, payload: Record<string, unknown> = {}, guest = '[email protected]') => guestVerdict(type, payload, guest, guestOf)
it('may list and start its own harnesses, and use its terminals', () => {
- for (const type of ['agents_list', 'agent_create', 'agent_create_status', 'agent_create_cancel', 'engines_probe', 'theme_set', 'usage_read', 'guest_folders',
+ for (const type of ['agents_list', 'agent_create', 'agent_create_status', 'agent_create_cancel', 'engines_probe', 'theme_set', 'guest_folders',
'terminal_capabilities', 'terminal_alive', 'terminal_ack', 'terminal_input', 'terminal_resize', 'terminal_paste', 'terminal_paste_image',
'terminal_paste_file', 'terminal_chunked_upload_begin', 'terminal_chunked_upload_cancel', 'terminal_scroll', 'terminal_resync', 'terminal_close']) {
expect(verdict(type, type === 'agent_create' ? { engine: 'claude' } : {}), type).toEqual({ allow: true })
@@ -34,6 +34,11 @@ describe('what a guest may ask', () => {
}
})
+ it('reads none of the owner\'s plan allowances: its harnesses run on its own sign-in (anh Dee, 2026-11-07)', () => {
+ expect(verdict('usage_read')).toEqual({ allow: false, error: 'GUEST_NOT_ALLOWED' })
+ expect(verdict('usage_read', { profile: { engine: 'claude', id: 'default' } })).toEqual({ allow: false, error: 'GUEST_NOT_ALLOWED' })
+ })
+
it('a guest whose account was never recorded owns nothing', () => {
expect(guestVerdict('terminal_open', { agentId: 'unrecorded' }, '', () => '')).toEqual({ allow: false, error: 'NOT_YOUR_HARNESS' })
})
diff --git a/cli/src/core/guestPolicy.ts b/cli/src/core/guestPolicy.ts
index cd182e397..4331d4aa8 100644
--- a/cli/src/core/guestPolicy.ts
+++ b/cli/src/core/guestPolicy.ts
@@ -18,8 +18,8 @@ const ANY: ReadonlySet<string> = new Set([
'agent_create', 'agent_create_status', 'agent_create_cancel',
'engines_probe',
'theme_set',
- // The owner's plan limits, which a guest's harness uses through the subscription relay.
- 'usage_read',
+ // Not `usage_read`: those are the owner's plan allowances, and a guest's harness runs on the guest's own sign-in
+ // (lib/guestPaneCommand.ts, anh Dee 2026-11-07).
// Where it may start a harness: its workspace and the folders the owner shares with guests.
'guest_folders',
// Stream-scoped: a stream answers only the connection that opened it (lib/terminalStreamManager.ts), and
diff --git a/cli/src/gateway/gateway.spec.ts b/cli/src/gateway/gateway.spec.ts
index 07d59c833..237615e6b 100644
--- a/cli/src/gateway/gateway.spec.ts
+++ b/cli/src/gateway/gateway.spec.ts
@@ -114,12 +114,12 @@ describe('a remote client, as the core hears it', () => {
// A colleague the machine is shared with is a guest (core/guestPolicy.ts): never the owner, whatever it says. Its
// `dsh_list` is refused before any service hears it; what a guest may ask is asked as that guest.
await dispatchDown(socket, colleague.seal('dsh_list', { requestId: 'c', owner: true, local: true, accountOwner: true }), 'colleague')
- await dispatchDown(socket, colleague.seal('usage_read', { requestId: 'u', owner: true, local: true, accountOwner: true }), 'colleague')
+ await dispatchDown(socket, colleague.seal('guest_folders', { requestId: 'u', owner: true, local: true, accountOwner: true }), 'colleague')
// With the connection and the request id it asked under, which a service keys a connection's own work by.
expect(asked).toEqual([
{ type: 'dsh_list', asker: { local: false, owner: true, accountOwner: true, connection: 'phone-1', requestId: 'p' } },
{ type: 'dsh_list', asker: { local: false, owner: false, accountOwner: false, connection: 'dial-1', requestId: 'd' } },
- { type: 'usage_read', asker: expect.objectContaining({ local: false, owner: false, accountOwner: false, connection: 'colleague', requestId: 'u' }) },
+ { type: 'guest_folders', asker: expect.objectContaining({ local: false, owner: false, accountOwner: false, connection: 'colleague', requestId: 'u' }) },
])
await socket.stop()
})
diff --git a/cli/src/services/usage.ts b/cli/src/services/usage.ts
index d4778822f..0c7bb6fa1 100644
--- a/cli/src/services/usage.ts
+++ b/cli/src/services/usage.ts
@@ -74,8 +74,8 @@ export function startUsage(core: CoreApi, deps: UsageDeps = DEPS): ServiceReques
return {
// Codex's read starts its app-server (up to 10s, lib/codexRateLimits.ts). Answered when it settles, never in the
// connection's line: it is asked on connect beside the requests the terminal needs.
- // With a profile it answers for that one account only, and only to the machine's owner: the default reading is
- // already open to guests, a second account's is not.
+ // With a profile it answers for that one account only, and only to the machine's owner. A guest never asks: its
+ // policy refuses usage_read (core/guestPolicy.ts).
usage_read: internalOnThrow('usage_read', (payload, asker) => {
const wanted = (payload as { profile?: { engine?: unknown; id?: unknown } } | undefined)?.profile
let only: Wanted = {}
diff --git a/docs/plans/2026-11-07-v3-review-security-fixes-plan.md b/docs/plans/2026-11-07-v3-review-security-fixes-plan.md
new file mode 100644
index 000000000..2c8382942
--- /dev/null
+++ b/docs/plans/2026-11-07-v3-review-security-fixes-plan.md
@@ -0,0 +1,105 @@
+# 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:
+
+1. guestPolicy.ts:22 is real. `usage_read` is 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).
+2. boardRights.ts:28 is real. `project.canChat` and `project.decider` hold a bare person id. Leaving the Swarm
+ (dismissPeople) leaves both as they are, and `readsProject` is 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.
+3. credentials.ts:105 is real. No rule matches a Stripe key (`sk_live_…`: the OpenAI rule needs `sk-`), 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
+ `credentialsRemoved` kinds).
+- No setting, no switch.
+
+## Review Focus
+
+1. A rejoining person's stale grant from before this fix (left before it shipped): cleared when they are admitted again.
+2. A grant of someone who is still in the Swarm survives another person leaving or joining.
+3. 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 or `glpat-` stay.
+4. A guest's refused `usage_read` says so (GUEST_NOT_ALLOWED with its message), never a silent drop.
+5. 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` (drop `usage_read` from 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.ts`
+
+- [ ] **Step 1: Failing tests.** guestPolicy.spec.ts: `verdict('usage_read')` is `{ allow: false, error: 'GUEST_NOT_ALLOWED' }`,
+ and `usage_read` leaves the allowed list. backendSocket.guest.spec.ts: a guest's `usage_read` never reaches the service
+ router and is answered GUEST_NOT_ALLOWED; the "may ask what is allowed" case uses `guest_folders` instead.
+- [ ] **Step 2: Run** `npx vitest run src/core/guestPolicy.spec.ts src/backendSocket.guest.spec.ts` in cli: FAIL on the new asserts.
+- [ ] **Step 3: Code.** Remove `usage_read` and 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; new `settleBoardRights`)
+- Test: `backend/src/superTabs/boardRights.test.ts`
+
+**Interfaces:**
+- Produces: `settleBoardRights(state: SuperTabState): void` in projects.ts — drops from every project's `canChat` and
+ `decider` each id not in `state.people`, deleting an empty `canChat`. 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 `c` Can chat, name `d` decider; `member.remove` both (Swarm owner); `canChat` and `decider`
+ are gone from the project; invite and accept each again; `canChat(state, project, 'c')` and `steers(state, project, 'd')`
+ are false, and `c` posting in the project chat is refused CHAT_NOT_ALLOWED. A second case: a grant written before the fix
+ (state edited so `c` left with the grant kept) is cleared when `c` is admitted again. A third: `c`'s grant stays when `d` leaves.
+- [ ] **Step 2: Run** `npx vitest run src/superTabs/boardRights.test.ts` in backend: FAIL.
+- [ ] **Step 3: Code** `settleBoardRights` and 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.yyyyyyyyy` of 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.ts` in 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.