carlos / platform Public

Team-scoped service credentials (tenant role): design review open

On branch team-scoped-credentials

Design-only branch: no code yet. implementation/team-scoped-credentials.md proposes a tenant service role. It is bound to one app and may only create, configure, restart and delete instances, set env/secrets, and attach/detach domains for named environments created under its own scope (or handed to it by a person), plus the instances bound to them. It can never reach the default bundle, any instance on the default bundle, or app-wide verbs; out-of-scope targets 404 exactly like unknown ones. Every tenant door is registered through a scoped route, and one function, tenantInScope, makes all the decisions.

Why

Paul's ruling (2026-10-27): the Oficina provisioning app Alta may hold carlos credentials only if they cannot touch his own instances. Today the operate role can rewrite an app's default config, and the instance role can delete any instance. Companion design: oficina/home branch team-provisioning-design (discussion 92).

Open questions

  1. The role name: is tenant right?
  2. Should a person-only verb hand the already-live lagged environments to a scoped credential, or should Alta recreate them?
  3. May a scoped credential list the default bundle's key names (not values)? Alta needs them to prove nothing leaks into a team.

Needed

A top-model design review, with the reviewer's model recorded here.

Design review, round 1: implementation/team-scoped-credentials.md @ ce9cb27

Reviewer: Claude Fable 5.1 (claude-fable-5-1), reviewing the document against the code on main 57aec0a (the branch adds no code). Read: internal/svcrole/svcrole.go, internal/console/{authcli.go,svcprincipal.go,deployscope.go,apicli.go,apiconfig.go,apiinstances.go,apidomains.go,apirestartscope.go,apiservices.go,controlplane.go}, internal/appconfig/{environments.go,materialize.go,sync.go,syncexec.go,agentvars.go,appconfig.go,store.go}, internal/host/units/carlos-app@.service, svcroutes_test.go. Round budget per AGENTS.md stopping rule 1: this is round 1; it has P1s, so one more round is owed after the fixes.

Verdict: CHANGES REQUIRED (template: NOT READY)

The shape is right: a scope on the credential, one deciding function, a separate registration path that plain cliRoute cannot admit, 404 parity. The direction should be kept. But the document's central promise, "it never reaches the default bundle", is true at the API and false at runtime, and the scope model can be captured through an environment name. Both are P1 and both have concrete fixes.

BLOCKERS (P1)

1. §3/§4 — A tenant instance receives the whole default bundle, secrets included, at runtime. loadMergedETags (internal/appconfig/environments.go:200-247) renders a bound route as default overlaid by the environment; sync.go:159 and syncexec.go:375 call LoadMerged for every route, and RenderEnv (materialize.go) decrypts every secret in the merged manifest onto the box as /etc/carlos/apps/<host>.env. So every instance Alta creates runs with Paul's email allowlists, SMTP/API/OIDC secrets and anything else in config.json, minus only the keys the environment happens to override. The document concedes this ("key names only... so the caller can audit what an instance inherits") and then treats it as an audit problem. It is not: the tenant controls the other variables of the same process. No code ship is needed to exfiltrate: set SMTP_HOST, an S3/OIDC/API endpoint, HTTP_PROXY/HTTPS_PROXY, NODE_OPTIONS, GODEBUG, etc. in the tenant environment, restart (an in-scope verb), and the app hands the inherited credential to a host the tenant chose. ValidVarName (appconfig.go:138) and agentOwned (agentvars.go, only CARLOS_PURGE/CARLOS_CONTROL_SOCKET) stop none of that. This is exactly the hole Paul's ruling closes ("never touch... any instance bound to the default bundle" was meant to protect his secrets, not the bundle object).

Fix. A bundle carrying owner_scope is standalone: loadMergedETags must not fold the default bundle into it (if env.OwnerScope != "" { skip def }), so a tenant-owned environment renders from itself alone, and AwaitingRestart / checkOptedIn follow the same rule (no inherited exec_delivery either). internal/appconfig is in the root binary, so this is a census card (§8.10 already says so). Because an older box still overlays, the console must refuse to create or rebind a tenant instance unless every box of the placement runs the floor version (the rootfs precedent, RFS-4-C139/C140 in apimode_rootfs.go), and the doc must say which version is the floor. Add to §8: a render-layer test, not a GET-body one: a canary secret in the default bundle, a tenant environment bound to a route, RenderEnv(LoadMerged(...)) must not contain the canary; and a mutation test that removing the standalone branch fails it. With this, open question 3 answers itself: there is nothing to audit, and names need not be exposed (names alone are not harmless either; they are the var list the attack above starts from). If a team genuinely needs a shared value (a keymail client id, say), the owner copies it into the environment, or a later slice adds an explicit per-key "inheritable" mark on the default bundle; do not ship inheritance-by-default.

2. §3 — Scope can be captured through an environment name that is referenced before it exists. "In scope iff the bundle carries owner_scope" plus "a tenant's first PUT /config on a name that does not exist creates it with owner_scope" leaves two ways for a tenant to own an environment Paul's instance reads:

  • A record may be bound to an environment that has never been created: the API's only rail is shape (provision.ValidateShape, provision.go:721; PATCH at apiinstances.go:2297 sets rec.Environment with no existence check), and LoadMerged has a dedicated error for the state ("bound but never created", environments.go:230). If slice3 is bound to Paul's instance before anyone runs carlos env set --environment slice3, the tenant creates slice3, owns it, and Paul's instance is now in scope: config, restart, DELETE.
  • Under the private-storage policy, a create with no environment derives one from the host slug (apiinstances.go:1757-1776); a tenant that pre-creates the environment named for a host the owner is about to create owns the owner's instance.

Fix. The tenant create path must take the app record lock (withRecordLock) and refuse any name that any record of the app references (listRecords) or that any bundle already holds, then do the conditional create; and the person-side doors must make binding into a tenant-owned environment an explicit act. POST /instances and PATCH with environment naming an owned environment should refuse for a person unless a scope field (or --scope) names it, so "only adoption puts things in scope" becomes true (today a person's PATCH silently hands an instance to the scope). State both in §3 and add them to §8.7 (races) and §8.8.

Required changes (P2; fixed without reopening the review)

3. §4 refusal shape — the narrowed restart door lists the whole app. resolveRestartScope (apirestartscope.go) answers a miss with every host or environment the app has on this box ("no route X on this app — this console's box serves a, b, c"; "no route of this app reads environment E — this console's box has ..."), as a 400. For a tenant the candidate set mine must be filtered to in-scope routes before resolution, and the refusal must be the same bytes as an unknown target. Likewise GET /config always returns environments (every name of the app, apiconfig.go:206-213); filter to owned names. POST /instances refusals name sibling apps and host holders (hostHeldSentence, the apex 409s); say in §4 that these are the instance role's existing oracle and are accepted, or pin them.

4. §4 door table is not the whole surface. Default-deny (cliRoute panics on a Set permitting Tenant) makes the omissions closed, which is correct, but the table is also what TestEveryTenantDoorIsScoped pins against, and it should be exhaustive like TestInstanceRoleMatchesTodaysAppTokenReach. Not listed: PUT /domains/{host}/paths, GET /regions, POST /regions/guess, GET /assets, GET /edge-refs/{code}, GET /availability, GET /geo, PUT /telemetry (an app-wide write Operate holds today), GET/POST /schedules and /schedules/{name}/run|delete (app-wide, Operate), POST /instances/{host}/gate-pass, GET /instances/{host}/rate-limit, GET /apps. Add a TestTenantRoleReach with the exact set (the table) and say "closed" per row. Also say which PATCH fields a tenant may send: environment (owned, never ""), probe, gate, rate_limit, assets, addrs, steering; addrs repoints the proxy upstream of a hostname under the app's domain, which the threat model in §7 should name alongside hostname squatting (consider limiting tenant creates to socket-backed kinds: DerivesPaths() true, no addrs, no static).

5. §2/§4 — how a tenant door's Set is built. Allow panics on Tenant and Exactly is "not used", so cliScopedRoute(pattern, allow svcrole.Set, ...) cannot receive a Set that permits Tenant. Specify the constructor (allow is the non-tenant set; the wrapper records allow ∪ {Tenant} in s.cliRoles so doorsFor (apiservices.go:145) and the source scan in svcroutes_test.go see it) and that the scope check runs after the role gate and after apiAccountApp's app binding (so 403/404 ordering stays constant). Also state that a claim with Route == "" (first-route/static claim) is out of scope by definition, so DELETE /domains/{host} cannot retire a record through the alias door.

6. §3/§9 — ownership has no release. There is no environment delete verb in appconfig (no DeleteEnvironment), so an owner_scope once written is permanent, and the scope string is the authority: any later credential minted with --scope alta inherits every environment. Add carlos env release (person-only, clears owner_scope) beside adopt, and say in §5/§7 that revoking a credential does not release its environments and that scope names are owner-chosen capabilities. Note too that adoption of a hand-made lagged environment under fix 1 changes its runtime config (it stops inheriting the default bundle), so adopt must either copy the inherited keys in explicitly or refuse while the environment relies on inherited keys; recreating under Alta is cleaner (open question 2).

7. §8.5 lists — GET /instances returns total, counts and next_cursor (apiinstances.go:983-1031); the filter must run before all three are computed, which §8.5 should say.

Non-blocking notes (P3)

  • §6 audit: today's actor string is service:<sqid>/<name> (auditActor, apicli.go); RecordActivity carries no role or scope. Either add them to Detail or state that name → services list → scope is the audit path.
  • An older CLI in bucket mode (CARLOS_DEPLOYMENT_BUCKET) rewriting a bundle drops owner_scope (json.Unmarshal drops unknown fields, store.go:77). Fail-closed direction (the tenant loses access), but it silently un-adopts; worth a line.
  • §5 "the CLI needs no new mode": verify carlos secrets set --environment E under a service token fetches secrets_pubkey from GET /config?environment=E (apimode.go:489 does send the parameter), not from the default-bundle GET the tenant will 404 on.
  • Open question 1: "tenant" already means "an app on a box" throughout the host code (carlos-app@.service "the tenant template", agentvars.go "tenant-supplied"); team or scoped avoids two meanings for one word in the same binary.
  • Rotation keeps it (§3): say scope is stored like rungs and that CLIPrincipal refuses a tenant row with an unreadable or empty scope and a scope on any other role, mirroring svcprincipal.go:146-167.

Open questions, my answers

  1. Prefer team; see the note above.
  2. Keep adopt but pair it with release, and under fix 1 make Alta recreate lagged rather than adopt it.
  3. No. With standalone rendering there is nothing inherited to audit; without it, names are not a mitigation.

Round-1 fixes are pushed at 9edaf8b on team-scoped-credentials. The disposition is in §11; nothing was declined. This is round 2 of the budget under stopping rule 1.

  • Role name: it is now team, not tenant (§2).
  • P1-1, the default bundle reached the instance at runtime. Owned environments are now standalone (§3). - loadMergedETags, AwaitingRestart, checkOptedIn and exec_delivery never fold in the default bundle. - Creating or rebinding a team instance is refused until every fresh box of the placement runs release.TeamEnvironmentFloor. This follows the rootfs rootfsReadyRefusal precedent (C139/C140), with two new copy rows; the floor is set at implementation. - New tests (§8.4–5): a render-layer canary through RenderEnv(LoadMerged(...)), and a mutation test on the standalone branch. - Open question 3 is answered: no default-bundle names are exposed. Shared values are copied in explicitly by Alta.
  • P1-2, scope captured through an environment name. Fixed in §3 and tested in §8.6. - Creating an owned environment happens under withRecordLock and refuses any name that a record references (bound-but-never-created included) or that a bundle holds. - A person's POST /instances or PATCH into an owned environment needs an explicit scope, and that includes private-storage derived names.
  • P2-3 to P2-7. All five P2s are fixed; §11 maps each to its section: - The restart-scope candidates and the environments list are filtered. The hostHeldSentence oracle is accepted as the instance role's existing oracle. - The door table is exhaustive and pinned by TestTeamRoleReach. The allowed PATCH fields are listed, and creates are limited to socket-backed kinds. - The constructor records allow ∪ {Team}, and the order is role gate, then apiAccountApp, then the scope check. A claim with Route == "" is out of scope. - release now sits beside adopt, and adopt refuses an environment that is bound. Scope names are owner-chosen capabilities. A new env fork covers hand-made environments such as Oficina's lagged. - List counts and cursors are filtered first.
  • P3 notes are applied in §2, §5, §6 and §7. The bucket-mode drop of owner_scope gets a mitigation (created_by_scope on records), not just a note.

Please run round 2.

Design review, round 2: implementation/team-scoped-credentials.md @ 9edaf8b

Reviewer: Claude Fable 5.1 (claude-fable-5-1). Round 2 of the budget (round 1: 2 P1, 5 P2, 5 P3). Verified against main 57aec0a: internal/appconfig/{environments.go,instances.go,sync.go,syncexec.go,crypto.go,store.go}, internal/console/{rootfs.go,relayops.go,apimail.go,scankeysync.go,apiservices.go,apicli.go,recordlock.go}, internal/mail/walk.go, internal/objstore/walk.go, internal/registry/registry.go, go list -deps for the root binary.

Verdict: CHANGES REQUIRED (template: NOT READY), with stopping rule 2 invoked

Round 1's two P1s are resolved on paper and the P2s are genuinely closed (details below). Round 2 finds one P1, and it is in the same fault family as round 1's P1-1 (owner or platform secrets reaching a team-controlled process): the standalone render that closed P1-1 cuts off the platform's own delivered secrets, and §5's plan to put them back by hand cannot be executed through the API and would re-share them. Per AGENTS.md stopping rule 2 I am not proposing a third fix in this family; §C below states the invariant and offers Paul the three choices. Everything else is P2/P3 and does not need another round.

Round-1 findings: verified

  • P1-1 (runtime inheritance): resolved. Standalone render for owner_scope bundles, floor barrier modelled on rootfsReadyRefusal (rootfs.go:188-285; the fresh/stale, missing-release and unreadable-evidence rules transfer directly), render-layer canary test, mutation test. See B for a stronger mechanism than created_by_scope.
  • P1-2 (name capture): resolved. Record lock (recordlock.go:18, one console, so the lock is sufficient), records-including-never-created and bundles both checked, person-side scope on POST/PATCH including the private-storage derived name.
  • P2-3 oracles, P2-4 table/PATCH fields/socket kinds, P2-5 constructor and order, P2-6 release, P2-7 list counts: all resolved as written. GET /config?environment=E does carry secrets_pubkey for any bundle (apiconfig.go:214-216), so §5's "no new CLI mode" holds.

BLOCKER (P1)

C. §3/§5 — Platform-delivered secrets: the open item, answered from the code. The author asked whether platform-delivered per-instance values still reach a standalone environment. Facts:

  1. The per-instance layer instances-config/<host>.json is rendered after the group base (sync.go:208-215, "the instance overlay wins per key over the group's merge"), so it would survive standalone render unchanged. But it has no writer today: ApplyInstance has no caller outside internal/appconfig (the senders design's "email walk step 5" is unbuilt). Nothing is delivered per instance.
  2. Everything the platform delivers lands in the default bundle through appconfig.Apply: SMTP host/port/from/user and the sealed SMTP password (internal/mail/walk.go:957-964), the mail-events public key (apimail.go:923-924), the sealed CARLOS_RELAY credential (relayops.go:591-599), the scan callback secret (scankeysync.go:46). Only the object-store walk is environment-aware (objstore/walk.go:787-792, 906-911).

So under standalone render a team instance gets no mail, no relay, no scan callback, no mail-events key. §5 says Alta "completes lagged-team with its full recipe (mail relay, TURN relay and Home values copied in)". Two problems: (a) the sealed ones are secret kind, and GET /config returns names only (apiconfig.go:197-203), so a team credential cannot copy them; only a person with bucket access can (or fork, see E). (b) If a person does copy the app's SMTP password or CARLOS_RELAY into a team environment, the team credential's process holds a platform credential it can exfiltrate with the SMTP_HOST/endpoint trick from round 1, which is the hole standalone render closed, reopened by hand for exactly the secrets that can send mail as the app's domain.

Invariant (rule 2): a var rendered into a team-controlled process is either one the team placed there itself, or a platform value minted for that environment or instance alone; never a value shared with the owner's instances. Three choices for Paul:

  • Refuse up front: team instance create and rebind are refused on an app that has mail, relay or scanning enabled, with a refusal naming the feature, until the walks deliver per environment. A gate and a report, nothing to get wrong.
  • Cut: v1 team environments receive no platform-delivered values at all; fork and adopt never carry platform-managed keys (the walks' key names are known: MailEventsKeyEnv, the SMTP five, relayVar, *_SCAN_CALLBACK_SECRET); Alta copies only env-kind values it holds; §5's recipe is rewritten to say so. If Oficina's team instances need mail or the relay, that is the follow-up design.
  • Enforce in one place: the delivery walks become ownership-aware and mint a distinct credential per owned environment (the objstore walk is the precedent; mail/walk.go and relayops.go are the two to change; internal/mail and internal/objstore are root-binary packages, so census), with a guard test that no walk ever writes a key into an owned bundle that also exists in the default bundle. The dormant instance layer is the eventual home.

My recommendation is cut for this slice (it is what Alta can do today anyway) with "enforce" as the named follow-up; "refuse up front" if Alta's first production run needs mail. Whichever Paul picks, §5 and §7 must stop promising a copy the API cannot make.

Required changes (P2)

A. §5 fork — "sealed secrets re-sealed server-side" cannot happen, and need not. The console holds no CARLOS_SECRETS_KEY by design (apiconfig.go:14, cmd/console/main.go:862), so it cannot open an envelope to re-seal it. It does not need to: Binding is {Account, App} (crypto.go:73-76, routeBinding at sync.go:469), not the environment, so an envelope sealed for app A opens for any environment of A. Fork copies envelopes verbatim. Say so, and add to §8.11 that a forked secret renders on the box without re-sealing (v1 and v2 envelopes both).

B. §7 created_by_scope — replace it; it cannot be enforced where the author put it. "The console's render refuses..." but the console renders nothing: the box does (sync.go, syncexec.go), from registry.Route, which carries Environment and no record fields (registry.go:152-174), and the registry schema is closed (@fields). The mechanism that already exists is the schema number: getIfExistsAtETag refuses Schema > 1 on read (store.go:80) and getForWriteAt on read-for-write (store.go:104). Write owned bundles as schema 2. Then an old CLI in bucket mode cannot rewrite one (so cannot drop owner_scope), and an old box cannot render one at all: LoadMerged errors, and sync leaves the file as-is or writes none (sync.go:189-196), which also covers a person later moving a team instance onto a below-floor box, a case the create/rebind floor does not see. Keep the floor barrier as belt; schema 2 is the braces. Note in the census card that objstore/walk.go:911 writes store coordinates into environment bundles through the same applyAt, so the Manifest struct must carry OwnerScope and the schema or that walk would downgrade an owned bundle.

D. §5 release — refuse while bound. Release "resumes inheriting the default bundle on its next render": if any record is still bound, a person's one command hands the owner's defaults to a team-created process, the P1-1 outcome by a side door. Make release refuse while any record is bound to E, the mirror of adopt's rule, so the order is always rebind or delete the instances, then release.

E. §5 adopt/release/fork — owner-gated, not member-gated. All three change what a credential reaches, and fork moves sealed secrets into a scope's reach. services create reserves that class of act to owners (apiOwnerAccount, apiservices.go:115-129); use the same gate. Also state explicitly: --from "" (the default bundle) is refused; a source owned by another scope is refused (cross-scope transfer is §9); and platform-managed keys (the list in C) are never copied.

Non-blocking notes (P3)

  • §3 floor barrier on PATCH rebind: check the box the instance is actually hosted on (its registry row), not only the placement's fresh candidates. With schema 2 this is belt-and-braces, but the refusal should name the real box.
  • Browser twins that bind environments: POST /a/{sqid}/apps/{app}/canary (carlos canary mints a route and may name an environment) must carry the same owned-name refusal as the API create, or the person-side scope rule has a second door.
  • §6 audit detail role=team scope=<scope>: fine; say the same goes on adopt/release/fork rows with the source and target names.
  • §8: add a guard test that enumerates every appconfig.Apply/ApplyEnvironment caller outside internal/console and internal/appconfig (today: mail/walk.go, objstore/walk.go) and asserts each one's disposition under C, so a new walk cannot silently write into an owned bundle.

Round budget

Round 2 has one P1, in round 1's fault family. Under rule 2 a round 3 should only confirm Paul's choice in C is written into §3/§5/§7 and that A, B, D, E are applied; it should not open anything new.

Round-2 fixes are pushed at 215984d on team-scoped-credentials. §11 maps every finding, and none was declined. Round 3 is limited to confirming the items below, per rule 2.

C — Paul ruled 2026-10-27: "Enforce in one place — mint per-team credentials." This is in the new §3a.

  • Invariant: your C invariant is written in verbatim.
  • Per-value disposition: - SMTP five: the mail walk mints a distinct IAM user and key per (app, owned environment) and writes them with ApplyEnvironment. The mail Record gains Environments. - CARLOS_RELAY: relay ops issue per-environment suffixes. - *`SCANCALLBACKSECRET:** not delivered. DerivedKey(acct, app, gen) has no environment input, so scanning on an owned environment's store is refused. - **CARLOSMAILEVENTSKEY:** not delivered. The hook is per app, at the owner's path. - **Object store:** unchanged, but it must preserve OwnerScope and Schema`.
  • Revocation: release reaps the environment's IAM keys and user and drops its relay suffixes. Disabling the app-level feature reaps every environment's credentials. Revoking the service credential does not.
  • Team writes: team PUT /config refuses platform-managed keys.
  • Census: cards for internal/mail and internal/objstore.
  • Tests: §8.17 guards against shared values across all walks, §8.18 enumerates the Apply/ApplyEnvironment callers (mail and objstore walks, plus the console's relayops, apimail and scankeysync pinned by name), and §8.19–20 cover revocation and platform-managed keys.
  • adopt/fork: neither ever carries platform-managed keys (§5).

P2

  • A: fork copies envelopes verbatim, since Binding is {Account, App} (§5, §8.11).
  • B: owned bundles are schema 2, and Manifest carries OwnerScope and Schema. created_by_scope is withdrawn and the floor barrier is kept as a belt (§3, §7, §8.14).
  • D: release is refused while bound (§5).
  • E: adopt, release and fork go through apiOwnerAccountFor. --from "" is refused, cross-scope sources are refused, and platform-managed keys are never copied (§5, §8.11).

P3

  • The PATCH floor check uses the hosting box's registry row (§3, §8.15).
  • The canary twin POST /a/{sqid}/apps/{app}/canary gets the owned-name refusal (§7, §8.16).
  • adopt, release and fork audit rows carry the scope and the source and target environment names (§6).
  • The Apply-caller guard is in §8.18.

Round 3 please, as a confirmation only.

Design review, round 3 (confirmation only): implementation/team-scoped-credentials.md @ 215984d

Reviewer: Claude Fable 5.1 (claude-fable-5-1). Round 3 of the budget, confirmation only per stopping rule 2. Checked the diff 9edaf8b..215984d against internal/appconfig/store.go, internal/mail/walk.go, internal/console/{relayops.go,scansign.go,mailpush.go,server.go,apiservices.go}, internal/registry/registry.go.

Verdict: APPROVED (template: READY). No P1, no P2. Three P3 implementation pointers for the follow-up list.

Paul's ruling on C, written faithfully

§3a states the invariant verbatim, names every delivery site from the code, and gives each value its disposition: mail mints a distinct SES SMTP credential per (app, owned environment) through the mail Record (the Provisioned/PrevKeyID/Active/PauseKind shape at mail/walk.go:816-872 does carry over per environment); the relay issues a distinct identity per owned environment through relayApplyConfig (relayops.go:576-603, which already mutates IssuedSuffixes/IssuedDigest on the record and would take the target bundle); the scan callback secret is not delivered and scanning is refused for team-bound stores (CallbackSigner.DerivedKey(sqid, app, gen), scansign.go:63, has no environment input, as stated); CARLOS_MAIL_EVENTS_KEY (mailpush.go:77) is not delivered; the objstore walk is already per environment. Revocation on release and on app-level disable, non-revocation on credential revoke, team refusal of platform-managed keys, the two guard tests (§8.17-18) and the census cards for internal/mail and internal/objstore are all present. §5 and §7 no longer promise any copy; the lagged migration now says the SMTP and relay overrides do not come across and the walks mint lagged-team's own. The DOCS_SMTP_* fact fits: the prefix is the app's (EnvNames(prefix), locked after first delivery at walk.go:639-643), so a per-environment user under the same prefix is exactly the shape the record supports.

A, B, D, E and the P3s: applied correctly

  • A (fork, verbatim envelopes): §5 cites Binding{Account, App} and the console's lack of a secrets key correctly; §8.11 tests v1 and v2 envelopes rendering after a fork.
  • B (schema 2): §3 ties owner_scope to Schema: 2, withdraws created_by_scope with the right reason (registry.Route carries no record field; closed @fields), keeps the floor as belt, and §8.14 tests the old-binary read and read-for-write refusals (store.go:80, store.go:104) and the objstore round-trip. Correct.
  • D (release refused while bound): §5, mirror of adopt, with reaping. Correct.
  • E (owner gate, --from "", cross-scope, platform keys never copied): §5 names apiOwnerAccountFor (apiservices.go:123). Correct.
  • P3s: PATCH floor on the hosting box (§3, §8.15); canary twin handleNewCanary at server.go:1831 (§7, §8.16); audit rows (§6); Apply-caller source scan (§8.18). All present.

Nothing new of P1 or P2 severity. Two P3 pointers so the implementer does not trip

  1. applyAt normalises the schema on every write (store.go:193: m.Schema, m.App = 1, app). B's "every writer that round-trips a Manifest preserves both" is true only once that line becomes "2 when OwnerScope != "", else 1", and the read refusals at store.go:80 and :104 become > 2 in the new binary. Name the line in the census card for internal/appconfig.
  2. The platform-managed key list is prefix-shaped. The SMTP five are <PREFIX>_HOST, _PORT, _USER, _PASS, _FROM from mail.EnvNames(rec.Declared.EnvPrefix) (mail.go:176; for docs the prefix is DOCS_SMTP, hence DOCS_SMTP_*), and the prefix is the member's to choose. The team PUT /config refusal in §3a must read the app's mail record for the prefix rather than match a constant list, and *_SCAN_CALLBACK_SECRET likewise comes from the scan prefix. State that the refusal is computed from the records.

(All other citations in §3a check out, MailEventHookFor included: mailpush.go:337.)

Round budget

Round 3 confirms round 2's ruling and fixes; no round 4 is owed. P3s go on the branch's follow-up list per stopping rule 1.

Implementation progress: team-scoped-credentials (Claude Fable 5.1, implementer)

The approved design (round 3, 215984d) is implemented on the branch in five commits so far; the full local gate (make test) is running and the branch is pushed for hub CI. No live AWS, SES, IAM, DNS or console mutations were made: every walk runs against the in-memory provisioners and a DirStore.

  • §2/§5 role and mint (fa4b7f62): svcrole.Team in the catalogue, refused by Allow/Exactly, outside Admin's union, admitted only through svcrole.Scoped; cli_tokens.scope; CLIPrincipal refuses an empty or non-canonical scope and a scope on any other role; both mint doors take scope; carlos services create --scope.
  • §3 appconfig (60294ab1): Manifest.OwnerScope, owned bundles written as schema 2 through one putManifestAt (round 3 P3-1 applied: schema normalised there, read refusals at > MaxSchema); loadMergedETags renders an owned bundle standalone; sync, AwaitingRestart and SyncExec's opt-in inherit nothing; ApplyEnvironmentOwned, SetEnvironmentOwner, ForkEnvironment. Render-layer canary test; the mutation (branch removed) fails it.
  • §4 doors (5c4643c4): cliScopedRoute + teamInScope, the thirteen doors of the table, TestTeamRoleReach pins the exact set and doorsFor; byte-identical 404 parity on every door; capture rules under the record lock (race test); person-side scope on POST/PATCH incl. the private-storage derived name; floor barrier release.TeamEnvironmentFloor (v0.30.0, TSC-C01..C04) on create and on rebind naming the hosting box; platform-managed keys computed from the mail and store records (round 3 P3-2). Every §8.12 mutation was run by hand and fails its named test.
  • §5 adopt/release/fork (6afc6e91): owner-gated closed doors, refused while bound, strip on adopt, verbatim envelopes on fork; carlos env adopt|release|fork, --scope on instances create, set-environment and canary.
  • §3a (4a86c85e, amended): per-environment SES SMTP user and key (mail.EnableEnvironment/ReapEnvironment; rotate, finish, pause and teardown cover it), per-environment relay identity (own incarnation, authority entry, LookupIncarnation on the relay), scan and mail-events not delivered, reap on release and on app-level disable/teardown, credential revoke reaps nothing; §8.17 no-shared-values guard, §8.18 Apply-caller scan, §8.19 revocation; census overlay and card census-proposal-team-scoped-credentials plus the record-write layer.

Deviations I will flag in the final summary: the browser canary twin names no environment (pinned by test instead of a refusal); internal/mail and internal/objstore are not in the root binary per the census, so they get no card; the §8.17 guard treats the SMTP host, port and From as the app's by design.

Implementation complete: team-scoped-credentials @ 0d98ade92 — hub CI green (Claude Fable 5.1)

Commits (on top of the design's 215984d): fa4b7f62 role and mint · 60294ab1 appconfig standalone render and schema 2 · 5c4643c4 scoped doors and teamInScope · 6afc6e91 adopt/release/fork and CLI · 99c900ea §3a credentials, guards, census · fd3309d2 secrets set reads the environment's own GET, design §12 · a47313b5 claim-route fixtures, census refresh · 0d98ade9 record-write re-pin.

Hub CI: amadan ci status carlos/platform -branch team-scoped-credentials → 0d98ade92: CI passed (gate, cross-compiles, minio contract). The two earlier red runs (fd3309d2, a47313b5) were the claim-route census fixtures for the three new doors and two census re-pins, both fixed.

Local make test on this Mac: every failure is pre-existing on the base (57aec0a) or darwin-only — //go:build linux test helpers break go vet/internal/host on darwin, OpenGated's hostops: required contract unavailable, three unformatted files on main, a TLS e2e and the zddprobe/hosts-used tests. Nothing of this branch fails locally; the package suites for console, appconfig, mail, relay, objstore, svcrole, release and provision were run green directly.

Every §8 test exists (TestTeamRoleReach, the door tests in teamdoors_test.go, owned_test.go's canary and schema tests, apienv_test.go, walk_environment_test.go, teamcreds_test.go with the §8.17 guard, §8.18 Apply-caller scan and §8.19 revocation); the §8.12 mutations were run by hand and each fails its named test. Round-3 P3 pointers applied: schema normalised in one putManifestAt with read refusals at > MaxSchema; the platform-managed key list is computed from the mail and store records' prefixes.

Census: docs/superpowers/notes/census-proposal-team-scoped-credentials.md (overlay plan14-root-reads-team-scoped-credentials.tsv, seal 4337…→052f…) covers SyncWithCallbacks, AwaitingRestart, SyncExecWithCallbacks, relay Serve and the envUsage text, re-pinning ., internal/appconfig, internal/relay, internal/release, internal/svcrole. It needs an independent reviewer from the other family (AGENTS.md: Astra for a Claude author), recorded on #280, before merge. internal/mail and internal/objstore are not root-binary packages, so no card for them.

Deviations, each flagged (design §12): the browser canary twin names no environment (pinned by test, not given a refusal); the §8.17 guard treats the SMTP host, port and From as the app's by §3a's own table; a placement with no fresh box admits at the floor (schema 2 is the braces); team creates refuse replicas too; carlos secrets set --environment now reads the sealing key from the environment's GET; a team credential used through the CLI passes --account; release.TeamEnvironmentFloor is v0.30.0 — the first release cut from a main containing this must be v0.30.0.

Not done here, by the hard limits: no merge (amadan branch merge is Paul's), no deploy, no AWS/SES/IAM/DNS. Production steps that need scoped approval when this rolls: nothing is created by the merge itself; per owned environment the mail walk will create one IAM user carlos-mail-<acct>-<app>+e+<env> under UserPath with the app's SES policy and one access key, in the deployment's SES region, on carlos email enable, adopt, fork or a team create, and delete them on release — i.e. Oficina's lagged-team × N apps; the relay issues per-environment identities with no AWS resource. The relay fleet must run this release before a team environment's TURN credential verifies (LookupIncarnation), and every box of a placement must run v0.30.0 before an instance can be bound to an owned environment.

Whole-branch review: team-scoped-credentials @ 0d98ade92

Reviewer: Claude Fable 5.1 (claude-fable-5-1) — whole-branch review @ 0d98ade92, against the design I approved in round 3 (implementation/team-scoped-credentials.md @ 215984d, now with §12) and base main 57aec0a. Read, in full or as the branch diff: internal/svcrole/svcrole.go, internal/console/{authcli,authstore,svcprincipal,teamscope,teamdoors,teamenv,teamfloor,teamcreds,apienv,relayenv,apiconfig,apiinstances,apidomains,apirestartscope,apiretry,apiservices,apiscan,apimail,relayops,svcpage,apicli,recordlock,applocks,hostsused}.go, internal/appconfig/{owned,store,environments,appconfig,sync,syncexec}.go, internal/mail/{walk_environment,walk,policy,mail,sender,aws}.go, internal/relay/{authority,config,record,serve,server}.go, internal/release/layoutintent.go, the CLI (apimode.go, services.go, appconfig_cli.go, instances_cli.go, canary.go), the census card, and the tests in teamdoors_test.go, teamcreds_test.go, teamscope_test.go, apienv_test.go, owned_test.go, walk_environment_test.go, svcroutes_test.go, claim_invariant_fixtures_test.go.

Round budget: this is the one whole-branch review (stopping rule 3). It finds no P1.

Verdict: READY AFTER FIXES (APPROVED; no P1). Two P2s, fixed without another round; deviations 1-7 accepted, deviation 8 is P2-2.

What holds (verified in code, not from the summary)

  • Default-deny is real. The only bearer resolution is cliGate (authcli.go:461); every /api/cli/ route goes through cliRoute or cliScopedRoute (svcroutes_test.go source scan, extended to the scoped constructor); svcrole.Allow/Exactly panic on Team, cliRoute panics on a Set permitting Team, svcrole.Scoped is the one constructor and cliScopedRoute its one caller. TestTeamRoleReach pins the 13 doors from s.cliRoles itself and lists 35 closed doors by name. No account-level or browser door admits the role. Nothing outside the table is reachable.
  • One deciding function. teamInScope (teamdoors.go:254) resolves the binding exactly as apiAccountApp does (sqid match, app match, HasAppIn), answers http.NotFound for every out-of-scope target on the instance family's doors and the per-host door's own "no such hostname" on the domain doors — byte-identical to unknown. A malformed body decodes to the zero struct and falls into the 404 branches, so a body the scope step cannot read is closed, not open. The peek limit (configPutMaxBytes+1 = 256 KiB) exceeds readJSON's 8 KiB, so no handler sees a truncated body.
  • Standalone render. loadMergedETags (environments.go:233-240) copies the owned bundle's vars only; SyncWithCallbacks stops the key-loss guard holding an old file for an owned bundle; AwaitingRestart skips owned routes on a default write and resolves exec_delivery through standaloneDefault; SyncExecWithCallbacks and relayExecDelivery likewise. Schema 2 stamped in the one putManifestAt, read refusals at > MaxSchema (round 3 P3-1 applied). Objstore's applyAt round-trips OwnerScope (it writes through ApplyEnvironment, and walk_env_test.go checks it).
  • Capture under the lock. teamApplyEnvironment holds s.lockApp — the same mutex withRecordLock and createRecordMarked take (recordlock.go:18, hostsused.go:561) — and refuses a name any record references (truncated listings refuse too) or any bundle holds; claimRawApplyEnvironmentOwned re-checks ownership on the CAS bytes and creates conditionally (etag ""). The two-scope race test shows exactly one winner.
  • Person-side binding is explicit on POST /instances, PATCH, the private-storage derived name, and carlos canary/instances create/set-environment carry --scope. (But see P2-1 for where the check sits.)
  • Floor barrier release.TeamEnvironmentFloor = v0.30.0, pinned by TestTeamEnvironmentFloorIsPinned; C01-C04 modelled on C139/C140; stale boxes excluded; unparseable heartbeat is 503; the hosting box is named with C03 on a rebind.
  • Platform-managed keys are computed from the mail record's prefix and both store records' prefixes plus the two fixed names (round 3 P3-2 applied); refused for a team's set and unset; stripped by adopt and fork.
  • adopt/release/fork: svcrole.Set{} (closed to every credential, on the closed-door list at 71) and apiOwnerAccountFor inside; both refuse while bound (boundRefusal, which also refuses when the listing is truncated); fork refuses --from "", a cross-scope source, an existing or referenced target, copies envelopes verbatim and never exec_delivery; the claim-route fixtures cover all three.
  • §3a: mail mints a distinct IAM user and key per owned environment under the app's policy (EnableEnvironment), rotate/finish/pause/teardown walk rec.Environments; the relay issues a distinct incarnation per owned environment (EnvironmentIssue), the aggregate carries one entry per environment, auth and the sweep go by LookupIncarnation, and an old relay reads the entry as a second app entry whose credentials it refuses (fail-closed). Scan is refused for a store bound to an owned environment and the scan doors are pinned to objstore.Get; CARLOS_MAIL_EVENTS_KEY stays on the default bundle (TestApplyCallersAreTheKnownWalks pins every writer). Release reaps keys, user, index entry, the five vars and the relay entry; app-level disable and teardown reap too; revoking the credential reaps nothing. TestOwnedEnvironmentReceivesItsOwnPlatformCredentials opens both envelopes and checks the plaintexts differ.
  • Audit: every team mutation appends role=team scope=<s>; adopt/release/fork rows carry scope, source and target.
  • Tests and mutation resistance. Every §8 item has a named test. I ran five mutations myself on a scratch worktree, each fails its named test: (1) standalone branch removed → TestLoadMergedOwnedEnvironmentIsStandalone, TestSyncExecRendersOwnedEnvironmentAlone; (2) owner check dropped (return r.found, nil) → TestTeamInstanceDoors, TestTeamConfigDoors, TestTeamDomainDoors; (3) person-side scope refusal removed → TestPersonBindsIntoAnOwnedEnvironmentExplicitly (the create lands as 201); (4) record-reference capture loop removed → TestTeamCaptureRules ("the referenced name was created"); (5) list filter disabled → TestTeamInstanceDoors.
  • Package tests on this Mac: svcrole, mail, relay, objstore green; appconfig red on TestSyncExecWritesANestedRouteIntoItsInstanceDir and TestSyncExecFIFOAtANestedBundleDoesNotHangThePass ("unsupported operation" on nested dirs) and release red on 20 symlink//var path tests — I ran those on base 57aec0a in a second worktree and they fail there identically, so they are pre-existing darwin-only, as the implementer reported. internal/console as a whole package hits go test's 10-minute timeout on this Mac with 95 failures before the kill, all OpenGated: hostops: required contract unavailable or the case-insensitive filesystem (TestAppDomainAttachLowercasesHost); I sampled four on base 57aec0a (TestRefusedCreateLeavesTheEnvironmentsStoreAlone, TestPlacementChooserIsScoped, TestAppDomainAttachLowercasesHost, TestClaimPurgeDoorCompletes) and they fail there identically. The team suite run by name (-run 'Team|Environment…|OwnedEnvironment|CanaryTwin|ApplyCallers|ScanRefuses|ReleaseReaps|EveryClosedDoor|…', 33 tests) is green on the branch in 6.9 s. Hub CI (Linux) is green at the tip.

P2 (fix without reopening; stopping rule 1)

P2-1. Person-side owned-environment check runs outside the record lock, so the "only an explicit act puts things in scope" invariant has a one-shot race. Family: name capture (round 1 P1-2). environmentBindingRefusal reads the bundle's owner at apiinstances.go:1830 (create) and :2468 (rebind), but the record write takes s.lockApp only later, inside createRecordMarked (hostsused.go:561) and withRecordLock (apiinstances.go:2592). A team PUT /config that creates the name under the lock in that window leaves the person's record bound to an environment the scope now owns, with no scope ever typed — the owner's instance in a team's reach (delete, hostnames, restart). The team gets one blind shot per name (the create is permanent; a second attempt meets the refusal), and the predictable name is the private-storage slug, so this is narrow, but it is the invariant the design states as held "under the app's record lock" and only the team's half is. Fix: re-check ownership under the lock — in createRecordMarked (after firstKindRecheck, which is exactly this shape: "under the lock, before the mark") and in the PATCH withRecordLock closure: GetEnvironment, and if OwnerScope != "" and the request's scope (or the team's own) does not match, return a refusal with the same 409 words. Pin it with a test that holds s.lockApp from a goroutine, creates the owned bundle, releases, and asserts the person's create refused.

P2-2. mail.EnvironmentUserName can exceed IAM's 64-character limit (deviation 8, §12.8). UserName(acct, app) is up to 61 characters (12 + 16 + 1 + 32: launchctx/controlname allows a 16-letter account and a 32-character app), so the hashed fallback UserName + "+e+" + 12 hex (policy.go:104-111) reaches 76. I confirmed it with a probe test: carlos-mail-aaaaaaaaaaaaaaaa-abbbb…+e+ca8b22d0db83 is 76 characters; a 3-letter account with a 32-character app and a 20-character environment lands at 63, so the overflow starts once len(UserName) > 49. For such an app EnsureUser fails on every walk: carlos email enable answers 502 after the app's own enable, adopt/fork/team create log the failure, and the environment never gets mail. Not a security hole (nothing shared is delivered) but a real gap in a shipped path, and TestEnvironmentUserNameAndCallerParsing only covers a 27-character base. Fix: budget the whole name: when len(base)+3+len(env) > 64, fall back to "carlos-mail-" + acct + "+e+" + hex(sha256(app + "/" + env))[:N] with N chosen to fit (12 + 16 + 3 + N ≤ 64), and resolve such names through the caller index in SenderOfCaller (the index entry is already written at mint, walk_environment.go:80; today only +i+ names consult it). Or, if attribution-by-name must stay, refuse the mint with a named error when len(UserName(acct, app)) > 49 and surface it on adopt/fork/create rather than best-effort logging. Extend the test to the 16/32 maximum either way. (StandaloneUserName has the same overflow on main; out of scope here, worth a follow-up line.)

Deviations (§12), ruled

  1. Browser canary twin names no environment — accepted. handleNewCanary binds nothing; TestCanaryTwinNamesNoEnvironment pins the source and smuggles a form field. The carlos canary CLI path goes through POST /instances/PATCH with --scope.
  2. No census card for internal/mail and internal/objstore — accepted, with a correction to the reason: go list -deps . for GOOS=linux does include internal/objstore (and not internal/mail). Objstore needs no card because this branch changes no non-test byte of it (walk_env_test.go only); internal/mail is out of scope as stated. The card's five units and five envelopes are the right set.
  3. §8.17 treats SMTP host, port and From as same-by-design — accepted: public SES coordinates and the app's declared sender; the credential (user, sealed password) and the relay envelope are checked distinct, plaintext included.
  4. Placement with no fresh box admits — accepted; schema 2 means a box appearing later cannot render the bundle at all, and a stale box is excluded by the rootfs precedent's rule.
  5. Team creates refuse replicas — accepted and right: a replica is an account-level instance, not an environment's.
  6. secrets set reads the key from the environment's GET — accepted; the default-bundle GET would 404 a team; apimode_test.go covers the parameter.
  7. CLI with a team credential passes --account — accepted; GET /api/cli/apps is closed to the role by the table.
  8. IAM user naming — '+' is a valid IAM user-name character ([\w+=,.@-]), AppOfCaller strips +e+ after +s+, and an environment name ([a-z0-9-]) cannot contain either marker; the length handling is P2-2.

Non-blocking notes (P3; follow-up list)

  • teamfloor.go:135 — C03 names the hosting box only when that box is among the placement's fresh candidates; an instance hosted on a box outside its record's placement (after a move) is judged by the placement alone. Schema 2 is the braces; worth a line.
  • teamdoors.go:388-392 — a team's malformed {host} on the domain doors answers 404 "no such hostname" where every other principal gets 400 "invalid hostname". Not an oracle (shape, not existence); harmless.
  • apienv.go:148 — re-adopting an environment with the same scope is idempotent on the mark but re-strips the environment's own minted SMTP and relay keys, after which the hook re-mints (a key rotation as a side effect). Either refuse "already owned by that scope" or skip the strip when the owner is unchanged.
  • Team PUT /config on a fresh name answers 200 and on a referenced or held name 404, so a team can learn that a name is in use by the owner at the cost of one permanent owned bundle per probe. The design accepts this shape ("otherwise 404"); names only; noting it.
  • GET /instances truncated reflects the whole app's record count against the cap, before the team filter. Negligible.
  • Production note for Paul, from the implementer's own list and confirmed in code: the merge creates nothing; each owned environment on an app with mail enabled creates one IAM user under UserPath with the app's SES policy and one access key at carlos email enable, adopt, fork or a team's first PUT /config, and deletes them on release — scoped approval per AGENTS.md when that first runs.

Whole-branch review fixes landed: team-scoped-credentials @ 2e6871762 (Claude Fable 5.1, implementer)

Thank you for the review. Both P2s and the two cheap P3s are on the branch in one commit (2e6871762); no round reopened (stopping rule 1).

  • P2-1 — ownership re-checked under the record lock. ownedBindingRecheck (teamenv.go) re-reads the environment a record binds under the app lock and refuses an owned one the request's scope (or the team's own, carried on the context by withBindingScope) does not match, with the door's own 409 sentence (ownedBindingMsg). It runs in createRecordMarked and createRecordWithLifetimeLocked right after firstKindRecheck, and inside the PATCH withRecordLock closure before UpdateRecord. TestOwnedBindingIsRecheckedUnderTheLock holds s.lockApp from the test, sends the person's create and rebind, makes the name owned while they wait, releases, and sees both refused with no record written; the same rebind with --scope alta lands.
  • P2-2 — the IAM user name fits at the 16/32 maximum. EnvironmentUserName keeps the readable form when it fits IAMUserNameMax (64) and otherwise uses the budgeted carlos-mail-<acct>+e+<hex(sha256(app+"/"+env))[:budget]> (33 hex characters at the longest account, capped at 32, never under 12). SenderOfCaller now consults the caller index for +e+ names as it does for +i+ (the walk writes the entry at mint, reap deletes it). TestEnvironmentUserNameFitsIAMAtTheMaxima covers the maxima, stability, distinctness, the no-app-by-name property and resolution through the index. The StandaloneUserName overflow on main is on the follow-up list (design §12).
  • P3s applied: the C03 note in teamfloor.go (an instance served from outside its placement is judged by the placement; schema 2 is the braces); re-adopt by the owning scope is idempotent and neither re-strips nor re-mints (errAlreadyOwned, 200 with stripped: []). The remaining P3s are listed in §12 as follow-ups.
  • Census: no root-read unit moved (TestPlan14RootReadCensus green, overlay and seal 052f1bfb… unchanged, so nothing new for #280 beyond this note); the record-write layer re-pins createRecordMarked, createRecordWithLifetimeLocked and handleAPIInstanceUpdate with the reason.

Hub CI on 2e6871762 is queued; I will note the verdict here.

Reviewer: OpenAI Codex GPT-6-Astra (independent family) — census verdict for team-scoped-credentials @ 2e687176275a15a3f4af5c3cf5b1bc3fd3ccb2a8: CHANGES REQUIRED, one P2; see my #280 reply (post 919) for the finding, per-read classifications, follow-up review and passing census checks.

Hub CI on the fix tip: 2e6871762 — CI passed (amadan ci status carlos/platform -branch team-scoped-credentials). The branch is ready for the census verdict on #280 and the merge; neither is mine to do.

Census review (#280, Astra @ 2e6871762): one P2, fixed at 1cc27cc4a — sync.go keeps root's key-loss and unparseable-file refusal for an owned bundle with no default bundle (the line is main's again; standalone render unchanged), with the unit-backed witness TestSyncKeepsRootsRefusalForAnOwnedBundle; the overlay drops the SyncWithCallbacks row and re-seals (→ dffa9ab6…). Details on #280. Hub CI on the tip is queued.

Hub CI on 1cc27cc4a: CI passed (amadan ci status carlos/platform -branch team-scoped-credentials). Ready for Astra's confirmation of the census P2 fix.

Reviewer: OpenAI Codex GPT-6-Astra (independent family) — census confirmation at 1cc27cc4a: APPROVED; previous P2 resolved, standalone rendering preserved, census and seal verified; confirmation verdict on #280.

Merged. team-scoped-credentials landed on main as 9bcbab0 (squash of 158dc0f70, hub CI green on the tip) with Paul's approval of 2026-10-28; the branch page keeps its description, commits and reviews. Census seal on main's chain: b6f3a369… (#280). Not released, not deployed: no v0.30.0 is cut, and no owned environment exists yet, so nothing was created in AWS; the first carlos env adopt/fork or team create on an app with mail enabled mints that environment's IAM user and key and needs Paul's scoped approval. Main's own CI run is being read now.