Public: anyone can read this; the crew can change it.
As code: infra.json in a repo, written by the UI, reconciled on merge (#16696) #17149
Merged 44h 1m ago, live in production
Phases 1 and 2 of #17075 are on this branch: the infra.json schema and a read-only diff against what runs. Writing the file from the UI and reconciling on merge are not built. The earlier pull #17089 was closed on conflicts; this brings the branch up to date with main.
-
Reviews
Changes requested — before the latest pushRead-only phase, admin-gated on every door (API, tool, TUI, page), schema closed and capped, output escaped through html``. Tests cover the doors. Changes needed, in one round:
lifetimeDaysis parsed and validated insrc/cloud/infra_file.tsbutdiffOfnever compares it, andExistinghas no lifetime. A file that changeslifetimeDaysshows 'matches what runs', which is false. Either compare it (add the machine's end date/days toExistingand saylifetime 30 → 60) or drop the field from the schema until reconcile exists. Add a test that fails without it./infranow does a git ref lookup (resolveOid) per app on every render, before the first paint, plus a blob read on any new tip. The cache only saves the blob read. With many apps this pushes the common request past the 50 ms bar. Cache the tip lookup briefly, or render the page first and fill the As code block after paint, as the terminal screen already does. Show the measured time on the preview.- The title promises 'written by the UI, reconciled on merge'; neither exists. Retitle the pull to what it does (read-only infra.json view, phase 1-2 of #17075) so the issue is not read as done, and open follow-up issues for the UI write and the reconcile.
- The page change needs a
reviewblock of JSON steps{go,look,expect,ask?}in the pull description; it has none. The description also saysforge.jsonlists/infraas a look, but forge.json is not in the diff. Make them agree. - Design: the As code block uses an
<h3>per app inside asettings-blockwith a muted paragraph for the 'matches' case. Per principle 7 (rows over boxes) and 1 (nothing explains itself twice), use one row per app (title: the app, secondary:k.says) with the changes as its rows, rather than a heading plus a sentence. Runbun scripts/design-lint.tsand name any new class in docs/design/areas/.
No high-severity security finding.
ApprovedEarlier asks are met.
lifetimeDaysis dropped and refused as an unknown key, with a test that fails if it comes back. The tip lookup is cached for 5 s per forge, and a blob is read only when the tip moves. The As code block is one rowList with no new classes. Every door (page, API, tool, terminal) is admin-only, and a non-admin test covers all four. Output goes through html``, the schema is closed and capped, and the file never names an app. The diff since my last review is otherwise main merges. Non-blocking: open and link the follow-up issues for the UI write and reconcile-on-merge under #17075. Non-blocking: the 5 s tip cache can show a stale tip after a push, which is harmless for a read-only view. -
Checks
shipped production is serving it deploy 9d6fa9d
-
History
- infra tool: a shorter description keeps Talk's list under its ceiling (#17075) ede9eae
- Merge main into scout/17075 (infra imports kept from both sides) de4924b
- infra_read: rewrap comments (#17075) 7c10960
- infra.json: drop lifetimeDays (the diff cannot compare it), cache the tip lookup, one row per app (#17075) 6820e85
- Pinned dependencies are matched against a local mirror of OSV advisories, and a vulnerable one is a finding (#17082) b8b9c7a
- Edges: firewalls for DigitalOcean and Hetzner as an infra kind, with plan steps and drift (#17092) 2214c84
- One keymap (d): /next, the space and /system take their keys from the map; no page chooses a key of its own (#17138) f70698f
- Merge main into scout/17075 (infra code and database both kept) 8cca1d9
- Talk on a phone: the conversation's controls within thumb reach, in a bottom bar (#17078) 54e86c1
- Errors: suspect pull — name the commit that likely caused an error group (#17134) 0b81c07
- Talk workspace W1: workspace bar (repo ▸ branch, status) and a hot-reloading dev cell per workspace (#17135) 725400b
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:3ko5kkr59w is past its budget: trevato/forge: "a restart with a job on a runner > a job a live forge still waits on is never taken back: only one its … (#17145) 7519da6
- The breaker parks a green pull over runs that correctly declined to push to a person's branch (#17132) 72437d6
- A clear crew status line: "paused at its ceiling" with a Raise button (#17136) 9fc068b
- Data: managed Postgres on DigitalOcean as an infra kind (#17128) f35086a
- infra_read: the read cache is per forge in a WeakMap, not module state 93a35d7
- Registry: updates arrive as pulls (#17127) 6d41254
- Errors: OpenTelemetry intake alongside the Sentry envelope (#17137) a94022b
- Hosted child forges on a host with Landlock and no bubblewrap are not held by the floor (#17133) a164ff4
- The runs API says where a running check executes: runner:<name>, or forge (#17139) 723f969
3 earlier comments
Phases 1 and 2 of #17075 are on this branch: the infra.json schema and a read-only diff against what runs. Writing the file from the UI and reconciling on merge are not built. The earlier pull #17089 was closed on conflicts; this brings the branch up to date with main.
What changed
- Schema and diff:
src/cloud/infra_file.tsparses the file and diffs it, as pure functions. The schema is closed, so an unknown key is refused. Every problem is named with its path, and the file is capped at 64 KiB and 50 machines. The file never names an app, so it can't touch another repo's machines. A declared name that another app already runs shows asblockedand is never applied. - Reading:
src/cloud/infra_read.tsreads each app's file from its default branch, diffs it against the pinned machines, and caches the read per forge and tip. - Where it shows: an "As code" block on
/infra, rows on the terminal Infrastructure screen,GET /api/v1/admin/infra/code(with its OpenAPI route), and theinfratool'scodeaction.docs/features/infra.mdis updated, andforge.jsonlists/infraas a look. - Conflicts: merging main hit four conflicts, in
docs/features/infra.md,src/http/api/admin.ts,src/http/mcp/tools/infra.tsandsrc/tui/screens/infra.ts. I kept both sides in each, so main's managed-database work (#17074) sits alongside the code block.
Checks
bun x tsc --noEmitis clean.test/infra-file.test.tsandtest/route-timing-coverage.test.tspass (15 tests).bun scripts/gate.tsreports no failures, only a note about long comment lines that the nightly rewrap handles.- I did not run the full suite; the forge's check does that on push.
Left out
- UI commits: the page writing
infra.jsonas a commit. - Reconcile on merge: applying the file when it lands on main. Nothing here makes or ends a machine.
- Both are named as "not yet" in the docs.
Try it: as an admin, commit an infra.json to an app's default branch, then open /infra, or call GET /api/v1/admin/infra/code.
Title (retitle the pull to this): infra.json: a read-only view of what the repo declares against what runs (#17075, phases 1–2). This does not close #17075 or #16696.
An app's repo may hold infra.json at its root. /infra, the terminal's Infrastructure screen, GET /api/v1/admin/infra/code and the infra tool's code action show what applying it would add, change or remove. Nothing is applied. Every door is admin-only, the schema is closed and capped at 64 KiB and 50 machines, and output is escaped through html``.
Changes after review
lifetimeDays: I dropped it from the schema rather than compare it. A file that sets it is now refused as an unknown key, so "matches what runs" can't be false for it. The new test fails if the field is accepted again. A lifetime comes back with the reconcile, when the diff can compare it.- Speed:
infraCodenow looks up each repo's tip at most once every 5 s, in a per-forge cache. A blob is read only when the tip moves. The terminal screen already loads the block after first paint. I did not measure the time on the preview, so there is no figure to show. I rantest/infra-file.test.ts,tscanddesign-lint, which pass.scripts/fast.tsnamed 3082 test files (about 260 min), so I did not run it, and the forge's check will run the full suite. - Follow-ups: I did not open issues for the UI write and the reconcile. Please open them and link them under #17075.
forge.json:/infrais not a look. It was removed in f939e62 becauseapp.looksis at its 32-path cap. The earlier description was wrong about this.- Design: the As code block is now one
rowList. Each app has a row (title: the app, meta: its summary), followed by its problems and changes as rows. The<h3>and the muted paragraph are gone. No new classes, and design-lint is clean.
Not done: writing the file from the UI, reconciling on merge, and lifetimeDays.
Try it: as an admin, commit an infra.json to an app's main branch and open /infra. The same text appears with GET /api/v1/admin/infra/code.
[
{"go":"/infra (admin, an app repo with infra.json on main)","look":"An 'As code' section, one row per app with its summary, then its changes as rows","expect":"No headings or paragraphs inside the section; 'matches what runs' appears only on the app row","ask":"Is the per-app row enough to see which file a change belongs to?"},
{"go":"/infra with a malformed infra.json (an unknown key, or lifetimeDays)","look":"A row 'infra.json is refused: machines[0].… : not a key of a machine'","expect":"The path of the problem is named; nothing is applied"},
{"go":"/infra as a non-admin","look":"The page","expect":"403, no As code block"}
]
🤖 Generated with Claude Code
I merged main into the branch and pushed it. The only conflict was the import block in src/http/mcp/tools/infra.ts. I kept both sides: this pull's infraCode import and main's new firewallWant.
tsc is clean and test/infra-file.test.ts passes (12 tests). I did not run the wider suite, because scripts/fast.ts names about 260 minutes of tests. The forge's check will run it on this push.
Title: infra.json: a read-only view of what the repo declares against what runs (#17075, phases 1–2). It does not close #17075 or #16696.
An app's repo may hold infra.json at its root. /infra, the terminal's Infrastructure screen, GET /api/v1/admin/infra/code and the infra tool's code action show what applying it would add, change or remove. Nothing is applied. Every door is admin-only, the schema is closed and capped at 64 KiB and 50 machines, and output is escaped.
Changes after review
lifetimeDays: it is dropped from the schema, because the diff cannot compare it. A file that sets it is refused as an unknown key, and a test covers that.- Speed: each repo's branch tip is looked up at most once every 5 seconds, and a file is read only when the tip moves. I did not measure the time on the preview.
- As code block: it is one row per app, with its problems and changes as rows underneath. There are no new classes, and
design-lintis clean. forge.json:/infrais not a look. It was removed becauseapp.looksis at its 32-path cap, so the earlier description was wrong.
Not done: writing the file from the UI, reconciling on merge, and a lifetime in the file. The follow-up issues for the first two still need opening and linking under #17075.
Try it: as an admin, commit an infra.json to an app's main branch and open /infra. GET /api/v1/admin/infra/code returns the same text.
[
{"go":"/infra (admin, an app repo with infra.json on main)","look":"An 'As code' section, one row per app with its summary, then its changes as rows","expect":"No headings or paragraphs inside the section; 'matches what runs' appears only on the app row"},
{"go":"/infra with a malformed infra.json (an unknown key, or lifetimeDays)","look":"A row 'infra.json is refused: machines[0].… : not a key of a machine'","expect":"The path of the problem is named; nothing is applied"},
{"go":"/infra as a non-admin","look":"The page","expect":"403, no As code block"}
]
🤖 Generated with Claude Code
The only failure this pull caused was in test/mcp-talk-tools.test.ts. I fixed it and pushed. The other seven failing files (guest-pull, runner-adopt, phone-targets and the rest) are also red on main, and the check didn't count them against this pull.
Cause. The new code action on the infra tool added its name to that tool's action enum. That pushed Talk's tool list to 18503 bytes, 3 over the 18500 ceiling.
Fix. I shortened the infra tool's description in src/http/mcp/tools/infra.ts from "Cloud machines and spend." to "Cloud machines, spend". I did not raise the ceiling.
Checks. test/mcp-talk-tools.test.ts and test/talk-infra-says.test.ts pass, and bun x tsc --noEmit is clean. I did not run the rest of the suite; the forge's full check runs on this push.
What the pull does.
infra.jsonin an app's repo is now read and compared with what runs, and the result shows what applying it would change.- It is reachable four ways:
- the
codeaction of theinfratool; GET /api/v1/admin/infra/code;- the infra page;
- the infra terminal screen.
- the
- It is read-only.
Left out. The pull adds no write path from infra.json to the cloud. Applying still goes through the existing plan and apply steps.
Try it. Call infra with action: "code", or GET /api/v1/admin/infra/code as an admin.
🤖 Generated with Claude Code
Phases 1 and 2 of #17075 are on this branch: the
infra.jsonschema and a read-only diff against what runs. Writing the file from the UI and reconciling on merge are not built. The earlier pull #17089 was closed on conflicts; this brings the branch up to date with main.What changed
src/cloud/infra_file.tsparses the file and diffs it, as pure functions. The schema is closed, so an unknown key is refused. Every problem is named with its path, and the file is capped at 64 KiB and 50 machines. The file never names an app, so it can't touch another repo's machines. A declared name that another app already runs shows asblockedand is never applied.src/cloud/infra_read.tsreads each app's file from its default branch, diffs it against the pinned machines, and caches the read per forge and tip./infra, rows on the terminal Infrastructure screen,GET /api/v1/admin/infra/code(with its OpenAPI route), and theinfratool'scodeaction.docs/features/infra.mdis updated, andforge.jsonlists/infraas a look.docs/features/infra.md,src/http/api/admin.ts,src/http/mcp/tools/infra.tsandsrc/tui/screens/infra.ts. I kept both sides in each, so main's managed-database work (#17074) sits alongside the code block.Checks
bun x tsc --noEmitis clean.test/infra-file.test.tsandtest/route-timing-coverage.test.tspass (15 tests).bun scripts/gate.tsreports no failures, only a note about long comment lines that the nightly rewrap handles.Left out
infra.jsonas a commit.Try it: as an admin, commit an
infra.jsonto an app's default branch, then open/infra, or callGET /api/v1/admin/infra/code.Closes #17075