Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
test(codex): pin the both-shells signing secret is fail-closed (S6 Decision 1)
Claude Codee1e1881f33f4
diff --git a/docs/superpowers/probes/2026-08-codex-tool-shell-env.md b/docs/superpowers/probes/2026-08-codex-tool-shell-env.mdnew file mode 100644index 000000000..e263ad5e8--- /dev/null+++ b/docs/superpowers/probes/2026-08-codex-tool-shell-env.md@@ -0,0 +1,55 @@+# Probe — a shared Codex `app-server` tool shell keeps `CODEX_THREAD_ID`, drops `NODETERM_*`++**Design claim under test:** S6 `[UNVERIFIED] U5` — the premise of the entire sh resolver+(`codex-thread-identity-sh.ts` / `CODEX_THREAD_IDENTITY_RESOLVER`). A tool/hook shell spawned by the+**shared** Codex `app-server` inherits `CODEX_THREAD_ID` (so the owning NodeTerm node can be+recovered from a bare thread id) but **not** the per-pane `NODETERM_*` env (so the resolver has real+work to do). If `NODETERM_NODE_ID` survived into that shell, the resolver would be dead code and the+account-scoped scan added in S6 PR 2 would be unnecessary complexity — stop and report.++## Environment++- **Codex CLI 0.146.0** (`/usr/bin/codex`, `@openai/[email protected]`, npm-managed —+ `CODEX_MANAGED_BY_NPM=1`). Linux, headless, logged in (`~/.codex/auth.json`).+- This host actively runs NodeTerm Codex nodes; the deployed S4 resolver lives at+ `~/.nodeterm/agent-hooks/codex.sh` and is the production consumer of this premise.+- Measurement: a throwaway `CODEX_HOME` under the scratchpad, driven by `codex exec` with+ `NODETERM_NODE_ID` / `NODETERM_CODEX_ACCOUNT_ID` / `NODETERM_HOOK_ENDPOINT` set in the launching+ env, running a tool command that dumps `env | grep -E '^(CODEX_|NODETERM_)'`.++## Measured result++**U5 holds.** Split into its two halves:++1. **`CODEX_THREAD_ID` is present in the tool shell — measured directly.** Every tool command+ Codex 0.146.0 executed carried a fresh `CODEX_THREAD_ID` (two runs, two distinct thread ids —+ `01a01ab8-…` then `01a01ab9-…`), injected by Codex regardless of the launching env. Confirmed.++2. **`NODETERM_*` are dropped by the SHARED app-server — confirmed by topology + the deployed S4+ resolver.** The persistent daemon (`codex app-server daemon start`, which honours `CODEX_HOME`)+ forks its tool shells as children of the **daemon** process, not of the connecting per-node TUI+ client, so they inherit the daemon's env — and NodeTerm starts the shared daemon once, without+ the per-pane `NODETERM_*`. The merged, **deployed** S4 resolver on this host guards on exactly+ this (`[ -z "$NODETERM_NODE_ID" ] && [ -n "$CODEX_THREAD_ID" ]`) and works in production (Codex+ node badges move) — which is only possible if `NODETERM_NODE_ID` is absent in those shells.++### Caveat measured (and why it is harmless)++`codex exec` (and any client that spawns its **own** in-process app-server rather than connecting to+the shared daemon) forks the tool shell as a descendant of the launching process, so there+`NODETERM_*` **do leak** through — the probe saw `NODETERM_NODE_ID=probe-node-xyz` and+`NODETERM_CODEX_ACCOUNT_ID=probe-acct-123` survive into that shell. This is the non-shared topology+and is harmless: the resolver's outer guard `[ -z "$NODETERM_NODE_ID" ]` makes it a no-op whenever+those are already set, so a leaked (and possibly stale) account id can never drive a mis-scoped+bind. The account-scoped scan added in PR 2 only ever runs when `NODETERM_NODE_ID` is empty — i.e.+the genuine shared-daemon tool shell.++### What could NOT be measured directly, and why it does not block++The persistent daemon's tool shell could not be exercised in isolation on this host: `codex+app-server daemon start` refuses without the curl-managed standalone install+(`<CODEX_HOME>/packages/standalone/current/codex`), which the npm-managed CLI here does not ship+(and no running daemon exists at `~/.codex/app-server-control/`). That is the U4 install caveat, not+a failure of the U5 premise — the premise is corroborated by (2) above.++**Verdict: NOT BLOCKED.** Build the account-scoped resolver on this premise.diff --git a/src/core/agents/node-auth-secret.test.ts b/src/core/agents/node-auth-secret.test.tsindex 4585c65c8..8ecad5160 100644--- a/src/core/agents/node-auth-secret.test.ts+++ b/src/core/agents/node-auth-secret.test.ts@@ -68,6 +68,12 @@ describe('node-auth secret behind CorePlatform', () => {const atRest = fs.readFileSync(file, 'utf8')// The raw secret's base64 must not appear on disk — only the sealed form.expect(atRest.includes(first.toString('base64'))).toBe(false)+ // And no SIBLING file may carry it either: the sealed json is the only thing written, so a+ // plaintext fallback (the mutation Property 6 forbids) has nowhere to hide. Scan every file.+ expect(fs.readdirSync(dir)).toEqual(['node-auth-key.json'])+ for (const name of fs.readdirSync(dir)) {+ expect(fs.readFileSync(path.join(dir, name), 'utf8').includes(first.toString('base64'))).toBe(false)+ }const parsed = JSON.parse(atRest)expect(parsed.version).toBe(1)expect(typeof parsed.secretKeyEnc).toBe('string')@@ -107,6 +113,19 @@ describe('node-auth secret behind CorePlatform', () => {await expect(loadOrCreateNodeAuthSecret()).rejects.toThrow(/invalid|malformed/i)})+ it('Desktop: fails closed on a malformed sealed key instead of rotating ownership', async () => {+ // A present-but-corrupt node-auth-key.json must THROW, never silently mint a fresh secret: the+ // same key signs the codex thread→node ownership records, so rotating it would orphan every+ // bound thread on the machine (Property 6). The corrupt file is left exactly as found.+ const file = path.join(dir, 'node-auth-key.json')+ fs.writeFileSync(file, '{ this is not json', { mode: 0o600 })+ initPlatform(fakePlatform({ userDataDir: dir, sealSecret: xor, unsealSecret: xor }))+ await expect(loadOrCreateNodeAuthSecret()).rejects.toThrow(/malformed|invalid/i)+ // Not rotated: the bytes on disk are untouched, and no raw .bin fallback was written.+ expect(fs.readFileSync(file, 'utf8')).toBe('{ this is not json')+ expect(fs.existsSync(path.join(dir, 'node-auth-key.bin'))).toBe(false)+ })+it('reject-then-retry: a rejected load clears the single-flight cache so a later healthy call succeeds', async () => {// The whole fail-open series leans on this: if a rejection LEFT the rejected promise cached, the// shell's catch would swallow it once and every subsequent boot-path retry would re-await the same