carlos / platform Public

spec: console secrets, builder-check calls + review brief

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4a75816688f8c1a2dd1b34b42f83a243aa4afb8e parent 243da15
2 files changed, +70 −0
  • docs/superpowers/specs/2026-11-08-console-secrets-design.md +36 −0
  • docs/superpowers/specs/CODEX-REVIEW-BRIEF-console-secrets.md +34 −0

CI cancelled — superseded by a newer push — run details

Intent

Human

<task-notification> <task-id>a985a03792d03e50e</task-id> <tool-use-id>toolu_01Qw3gBxZSzV3qkLPa4PZh9P</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/a1de5273-c148-49b8-8267-3dee9d49c9c1/tasks/a985a03792d03e50e.output</output-file> <status>completed</status> <summary>Agent "Builder check on console secrets design" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Questions I'd still need answered, most important first. 1. **What does "the outcome per route as the CLI prints it (restarted, asleep, not reached, blocked)" mean?** - Neither restart door reports a per-route outcome. `handleAPIRestart` (`apicli.go:1517-1567`) and `writeRestartScope` (`apirestartscope.go:291`) only write a bucket request and return `requested`. The browser handler, `browserrestart.go:122-148`, only flashes "Restart requested". - The only per-route data is `configRestartNotice` (`apiconfig.go:745`), which feeds the CLI's `printRestartNotice`. It reports hosts awaiting restart, `Unresolved`, `Undelivered` and `Blocked` (`appconfig_cli.go:122-126`, `169-173`). There is no "restarted" or "asleep" state, and it only reads this box's own registry. - `carlos env set` itself never restarts; the CLI prints that notice and the person runs `carlos restart` separately. - I need to know whether the page shows the config-write notice plus "restart requested", or whether builders must add a result reader. That changes whether the work is one new handler or a new subsystem. 2. **Which restart scope does Save use?** - The spec says "what reads that environment". That is `release.RestartScopeEnvironment` through `writeRestartScope`. The browser has only the app-wide and host-scoped paths today (`browserrestart.go:65-129`), and the CLI's environment narrowing lives behind `handleAPIRestartScope`, which does selector resolution and refusals I would have to reuse. - Wrong guess: an app-wide restart (`requestAppRestart`) cycles every environment's routes. - Also open: an environment no route is bound to (only the store exists), where the scope door refuses (`apirestartscope.go:23-31`). Should the page save and skip the restart, or refuse? - Also open: what to do if the config write succeeds and the restart request fails. The page needs a "saved, not restarted" state. 3. **What is "the same role"?** - The CLI doors are `svcrole.Operate` for service credentials (`authcli.go:974-979`). - The browser restart handler has no role check. It takes `role` from `s.account()` and ignores it (`browserrestart.go:47-111`). I can't tell which person roles may edit. - Is the gate any account member, or a stricter check? Team-scoped credentials are not an issue here. 4. **Which envelope version and key does the browser seal with?** - The page must seal exactly as the GET door advertises. A platform app is v1 unless `BoundSealing()` is on, and a fleet app is always v2 (`sealkey.go:135`, `163`; `apiconfig.go:290`). - The spec says "v2 bound" unconditionally. If the deployment switch is off, a v2 envelope is refused by older boxes (`crypto.go:133-138`), and v1 skips the binding. - Is the page expected to follow the switch (v1 or v2), or to require v2? - When the console has no usable deployment key (`errNoDeploymentKey`, `apiconfig.go:295`), the CLI falls back to the terminal's own `CARLOS_SECRETS_PUBKEY`. The browser has nothing. I assume secrets are disabled there with a message; confirm. - A keyless fleet (`errFleetNoSecretsKey`) is also a refusal, not a seal. 5. **How do the key, binding and `sealed_to` reach the page?** - They are not in the settings view. `envCards` (`appsettings.go:524`) has none of them. The GET door builds them from `sealKeyFor`, whose inputs are SQLite and the registry, so there are no S3 reads. `envCards` already reads every bundle (S3) per page view, and its `m.Vars` already carries the ordinary values, so editing adds no new reads. - What I'd build: server-render `data-pubkey`, `data-account` (sqid, not name) and `data-sealed-to` (`KeyFingerprint`, `fingerprint.go:16`) into the form. - `sealed_to` is mandatory on a fleet (`apiconfig.go:683`). Confirm that approach, or whether the page should fetch via an API. 6. **Is there a script policy, and is the cookie-session page allowed to call the config PUT?** - `handleAPIConfigPut` is a bearer door (`cliRoute`, `readJSONLimit`, a JSON `Principal`). The page is cookie and CSRF based (`handleAppGate` pattern). - I assume the handler is a new form-POST that reuses extracted validation (`ValidVarName`, `ValidVarValue`, `CheckEnvelope`, `configCheckSealedTo`, the account lock) rather than calling the door. Refactoring the 270-line PUT body into a shared function is a sizeable piece of the plan. - Do the browser envelopes arrive as hidden form fields, or does JS post JSON? The spec says "form fields", so I'd use hidden fields. - I found no CSP on ordinary pages, only on demo and claim pages. Is an inline script acceptable, or does it need a served asset? 7. **What about concurrent and partial edits?** The CAS conflict ("config changed concurrently") would drop the staged form. Does Save re-render with the staged secrets lost (the browser holds only envelopes), or keep the page state? Staged unset of a secret that has since gone gives a 409 "nothing to unset" (`apiconfig.go:138`). Acceptable? 8. **Does the page show the default (unnamed) bundle?** The spec says "one card per environment". The default bundle holds the base vars, `carlos env set` without `--environment` writes it, and the restart notice differs for it (`writtenKeys` shadowing). Is it in scope? Not an issue: WebCrypto does ECDH P-256, HKDF-SHA256 and AES-GCM with AAD. Go's nil salt is the same as an empty salt. The raw x-coordinate matches `eph.ECDH`. The AAD is `len||"CSB2", len||account, len||app` (`crypto.go:80-89`), which is straightforward.</result> <usage><subagent_tokens>95386</subagent_tokens><tool_uses>19</tool_uses><duration_ms>85384</duration_ms></usage> </task-notification>

Attributed to this commit: 31.2 g CO₂e (3,933,245 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-console-secrets, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/superpowers/specs/2026-11-08-console-secrets-design.md b/docs/superpowers/specs/2026-11-08-console-secrets-design.md
index 3923d69e7..d76554f38 100644
--- a/docs/superpowers/specs/2026-11-08-console-secrets-design.md
+++ b/docs/superpowers/specs/2026-11-08-console-secrets-design.md
@@ -90,6 +90,42 @@ CSRF on every mutation (the star handler pattern), the same role gates as
the CLI doors, copy through the Luna pass (house rules), census and Astra
reviews as usual, console-only release through the agent manager.
+## Calls after the builder check (mine, 2026-11-08)
+
+1. **Outcome, honestly.** Neither restart door reports per-route results
+ today (`handleAPIRestart`, `writeRestartScope` only write a request). The
+ page shows the config write's own notice, as the CLI prints it
+ (`configRestartNotice`: hosts awaiting restart, unresolved, undelivered,
+ blocked), plus "Restart requested". It never claims "restarted"; the
+ app's activity view shows completion. No new result reader.
+2. **Restart scope = the environment** saved, through `writeRestartScope`
+ with `RestartScopeEnvironment`, reusing `handleAPIRestartScope`'s
+ resolution and refusals (not the app-wide restart). An environment no
+ route uses: save, skip the restart, say "Nothing running uses this
+ environment yet." Config saved but restart request failed: "Saved, not
+ restarted", with a Restart button that retries the same scope.
+3. **Who may edit: any account member**, as with the CLI doors for a
+ person token (svcrole.Operate applies to service credentials only).
+4. **Envelope version follows the GET door exactly**: v1 or v2 per
+ `BoundSealing()`, always v2 for a fleet app, with `sealed_to` whenever the
+ door would require it. No usable deployment key (`errNoDeploymentKey`)
+ or a keyless fleet (`errFleetNoSecretsKey`): secret entry is disabled with
+ a plain explanation; ordinary settings still work.
+5. **Key delivery:** server-rendered `data-pubkey`, `data-account` (sqid),
+ `data-app`, `data-sealed-to` from `sealKeyFor` (SQLite and registry, no
+ S3); the page already reads every bundle via `envCards`.
+6. **Handler:** a new cookie-session form POST (CSRF, account membership)
+ that calls validation extracted from `handleAPIConfigPut` into one shared
+ function both doors use (`ValidVarName`, `ValidVarValue`,
+ `CheckEnvelope`, `configCheckSealedTo`, the account lock, CAS), so the
+ rules cannot drift. Envelopes travel as hidden form fields; the sealing
+ script is inline (customer pages load no /static assets).
+7. **Concurrent change (CAS conflict):** re-render with staged plain values
+ kept and staged secrets dropped, with "Someone else saved first; re-enter
+ your secrets." Unsetting a variable that is already gone is a no-op.
+8. **The default (unnamed) bundle** is shown first, as "All environments",
+ then each named environment.
+
## Left to the builder
Template and handler structure, the credential-name heuristic's exact list,
diff --git a/docs/superpowers/specs/CODEX-REVIEW-BRIEF-console-secrets.md b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-console-secrets.md
new file mode 100644
index 000000000..9231a559c
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-console-secrets.md
@@ -0,0 +1,34 @@
+# Review brief: spec "Settings and secrets in the console", round 1 of 3
+
+Repo carlos/platform, branch `design-console-secrets`, commit: the commit
+that adds this file. Under review:
+`docs/superpowers/specs/2026-11-08-console-secrets-design.md`.
+Authorities: main's code (internal/console apiconfig.go, apirestartscope.go,
+apicli.go restart, browserrestart.go, appsettings.go, sealkey.go,
+templates/app_settings.html; internal/appconfig/crypto.go; the CLI's
+appconfig_cli.go).
+
+Fixed, do not re-argue: Paul's decisions (one section in app settings;
+immediate apply on save). The "secrets sealed in the browser" choice and
+the builder-check calls are the author's: challenge them on correctness and
+safety, not taste.
+
+Check:
+1. Secret confidentiality: can any path put a secret's plaintext on the
+ console, in a log, or back on the page? Is browser sealing (WebCrypto
+ ECDH P-256 + HKDF-SHA256 + AES-256-GCM, v1/v2 per the GET door, AAD
+ binding, sealed_to) specified tightly enough to be byte-compatible with
+ Go's Open, and safe against a tampered page (key substitution: where does
+ the public key come from, and can an attacker who can't read secrets
+ swap it)?
+2. Parity: does the shared-validation call really give the browser door the
+ same refusals as the CLI door, including size limits, name rules, fleet
+ keys, bound sealing, CAS?
+3. Restart: is environment-scoped restart via writeRestartScope correct for
+ every route kind, including asleep, remote and stamped routes; the
+ "saved, not restarted" path; no-route environments.
+4. Auth: CSRF, membership, role parity with the CLI person-token path.
+5. Anything that would not work or would add S3 reads per page view.
+
+Severity P1/P2/P3; end with exactly one verdict: READY, READY AFTER FIXES,
+NOT READY. Do not edit files. No subagents. No full test suites.