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) #17089
Parked 44h 28m ago
This is the first two steps of phase 4: the infra.json schema and a read-only diff of it against what runs. The page writing the file as commits, and reconciling on merge to main, are not done.
-
Reviews
Changes requested — before the latest pushRead-only schema + diff, closed schema, size caps, admin-only on all four doors, and the doors are all there. No high security finding. Changes needed in one round:
- Page cost:
/infranow callsinfraCodeon every render, which resolves a ref and reads a blob in git for every app in the forge, in series, before first paint. That is O(apps) git work on a page that must answer in milliseconds, and it grows with the forge. Read only the apps that matter, in parallel, or cache per (repo, tip oid) so an unchanged tip costs nothing. Note the terminal and page also swallow a failed read silently (code.ok ? ... : []). - Tests do not pin the gates: the API check is
status not 200(assert 404 for a guest and for a non-admin user), and nothing proves a non-admin gets no 'As code' block, no toolcoderesult and no terminal rows. Add a malformed-file case through a door too (the page's 'infra.json is refused: <path>' text from your review block is untested), and a repo with no infra.json yields nothing. - Wrong kind: a name already used by another app is reported as
change. A later reconcile would read that as something to apply. Give it its own kind (e.g.blocked) so it can never be applied. - Wording is wrong in two places: the OpenAPI summary/detail and the route-timing reason say 'cloud/', but the file is read from each app's repo main branch. Say that. Also
codeSaysduplicatestallyLine(the gate noted it): reuse it, one way to do the thing. - Design (principle 1 and 8):
codeRegionsays the same thing twice per file, a paragraph 'infra.json in X: 1 to add' and then rows restating it. Make the file a heading or a single row line and the changes its rows; add an empty-state sentence or leave the block out, and name the component use in docs/design/areas if you add a class. - Look: the gate asks for a look page for src/web/pages/infra.ts; an empty 'No look' commit is a dodge when the page is the whole change. Add /infra to app.looks.
- Page cost:
-
Checks
stopped parked by the crew deploy 93a35d7
-
History
- infra_read: the read cache is per forge in a WeakMap, not module state 93a35d7
- Merge main into scout/17075 (infra code and buckets kept from both sides) 66d3f48
- Production can't read forge.json: the release image doesn't carry it, so check limits fall back to defaults (#17131) 0febd50
- Data: object buckets with price reads and binding to an app secret (#17086) 00243fc
- A runner's red on one or two tests re-runs only those tests here, never the whole check (#17110) dea7ade
- Spike: a tiny Linux computer inside the forge process with unkernel (github.c… (#17126) cd8b6d6
- forge.json: /infra leaves app.looks, which is at its 32-path cap f939e62
- infra.json: cached per tip, a taken name is blocked, the block is a heading and rows, /infra is a look (#17075) 097af1b
- Automate a review finding as a lint or test: Stray blank line before the closing of the describe block; remove it. (#17104) 6be5e30
- One keymap (c): runs, issues, files and the whole terminal answer the map's keys, one meaning per key at both doors (#17012) 6de23f3
- One page shows my forge's upstream and downstream flows: what I follow, what I offered, what my forks offered me (#17079) 87a7ad4
- Sentinel: 2 deploy runs wait with no slot being used (#17123) c8785d3
- Protection test covers the crew falling back to Landlock when bwrap is missing (#17125) 6e85472
- runner-adopt: the lease test leaves no check queued, so the next test's claim cannot take it (#17118) c7160ee
- infra.json: the /infra page gains a read-only code section (#17075) 2ce9275
- A test's leaked process can no longer hang the gate: a shard's output is cut 5 s after it exits (#17117) bb265f4
- Load highlighter grammars only for the file kind opened; split src/tui/screens/workspace.ts (#17109) 2c7070a
- The fast tier guesses for an unseen file by its importers, and reads no doc through a helper the suite runs (#17111) d4b9f5a
- A release that passed its stay-up watch is not called wrong because the last health probe could not connect (#17103) 763fd5a
- The ten test files that cost pull checks the most seconds each finish in under 30 s, with no test skipped (#17030) d1623ea
7 earlier comments
I merged main into the branch and pushed it as e27d153c7.
Both conflicts were in imports, so I kept both sides:
src/http/infra_routes.ts:infraCodefrom this branch, plusmachineOfand the snapshot actions frommain.src/web/pages/infra.ts: theCodeFiletype from this branch, plus the snapshot imports frommain.
bun x tsc --noEmit is clean. I ran 88 tests across 10 files (the infra, OpenAPI operation-id and route-timing tests) and all pass. I didn't run the rest of the suite, so the forge's check on this push is the full run.
I pushed an empty commit, 2ce9275db, to answer the look-pages note. Its message has the line No look: /infra is not a page of app.looks in forge.json, and the owner's look seed has no cloud/ directory to read. I haven't seen the forge re-run the look-pages check on this push yet.
The note said the pull changes src/web/pages/infra.ts while the only look page a commit names is /settings/security/controls. The gate's rule wants either Looks: <path> naming a page in app.looks, or No look: <why>. /infra isn't in app.looks, so I used No look: rather than add a page to the look list. If you want a look for the code section, say so and I'll add /infra to app.looks and the owner's list.
The four recurring refusals you listed don't apply to this change. Nothing here adds a dead export, uses as never, or leaves a job untimed. The route is already in the untimed list from an earlier commit. The rest of the gate still ran after my commit and printed no failures. The unrelated duplicate-function note about codeSays in src/cloud/infra_read.ts is only a note, and I left it.
All six findings are addressed and pushed. bun x tsc --noEmit, the gate, bun scripts/design-lint.ts and the infra, route-timing and dead-code tests pass. The forge's full check has not run yet.
What changed
- Page cost.
infraCode(insrc/cloud/infra_read.ts) reads all apps in parallel. The parsed file is cached per (repo dir, tip oid), capped at 1000 entries. An unchanged tip costs one ref lookup and no blob read. The "unchanged tip gives the same answer" test checks the result only, not that the cache is hit. - Tests.
- A guest gets 404 from the API.
- A non-admin gets 403
not_adminfrom the API and from/infra. - A non-admin gets no "As code" block, no tool
coderesult and no terminal rows. - A malformed file shows
infra.json is refused: machines[0].typo: …on the page and in the API. - A repo with no
infra.jsonyields nothing.
blockedkind. A name already used by another app is nowblocked. It is counted in the tally and is never something to apply.- Wording. The OpenAPI summary and detail and the route-timing reason now say the file is read from each app's repo main branch.
codeSaysnow uses a newcountLineinsrc/core/gate_triage.ts, andtallyLineuses it too. - Design. Each file is an
<h3>with the app name, and its changes are rows. A file that matches what runs gets one muted line. With no files, the block is left out. No new component class. - Look.
/infrais inapp.looksinforge.json. I did not useNo look.
I also updated docs/features/infra.md.
Disagreement. You asked for 404 for a non-admin on the API. The route has role: "admin", so the router refuses a non-admin with 403 not_admin before the handler runs. The handler's own 404 is only reached by a guest. I kept the router's existing behaviour and pinned it in the test. Both refuse, and neither leaks any data.
Not done
- The page and the terminal still show nothing when the read fails. The read only fails when the viewer is not an admin, and those doors are already refused earlier, so there is no admin-visible failure to surface.
- Applying the file and writing it from the UI remain out of scope, as before.
To try it: sign in as an admin, put an infra.json at the root of an app's repo on main, and open /infra. The same data is at GET /api/v1/admin/infra/code and in the infra tool's code action.
[
{"go":"/infra","look":"As code block, one heading per app, rows per change","expect":"No paragraph repeating the rows; a matching file shows one muted line"},
{"go":"/infra","look":"A repo whose infra.json has an unknown key","expect":"Row reads 'infra.json is refused: machines[0].typo: not a key of a machine'"}
]The preview deploy failed because my last push put 33 paths in app.looks, one over the cap of 32. I took /infra back out and pushed. app.looks is back to 32 paths, and the forge-looks and infra-file tests pass (19 pass, 0 fail). The deploy itself has not been re-run yet.
That undoes the /infra look you asked for in item 6 of the earlier review. The 32 slots are all taken. /infra is already named in NOT_A_PAGE in test/forge-looks.test.ts as "no picture: app.looks is at its 32 paths", and every other top-level page must stay in app.looks. Adding /infra would mean dropping another page's look, which is a person's call. The commit carries a No look: line with this reason, and the page is covered by test/infra-page.test.ts and test/infra-file.test.ts.
Everything else in the earlier change is unchanged. The page is still a heading with rows for the changes. The read is still parallel and cached per tip. blocked is still its own kind. The tests still pin the gates.
I merged main into the branch and pushed it, so #17089 should merge cleanly again. I haven't seen the forge's check verdict on this push yet.
Two files conflicted, and I kept both sides in each:
src/http/mcp/tools/infra.ts: theinfratool's action list now hascodefrom this pull andpriceandbindfrom the buckets work onmain.docs/features/infra.md: it now has both the "As code" section and the "Buckets" section.
bun x tsc --noEmit passes. I ran only the three infra and bucket test files the merge touched (23 pass, 0 fail), not the full suite. bun scripts/gate.ts --fix rewrapped nothing, and it noted five files with comment lines over 100 columns that the nightly rewrap will handle on main.
I fixed the module-state failure and pushed; the keymap failure is not this pull's and I left it alone.
- Module-state test:
src/cloud/infra_read.tskept its per-tip read cache in a module-levelMap, which the rule refuses. The cache is now aWeakMapkeyed by the app, so each forge has its own.test/module-state.test.tsandtest/infra-file.test.tspass (14 tests), andbun x tsc --noEmitis clean. - Keymap test: "every screen that binds r…" is red on
maintoo, per the check log, and the check didn't count it against this pull.
I haven't seen the forge's check on this push yet.
This is the first two steps of phase 4: the
infra.jsonschema and a read-only diff of it against what runs. The page writing the file as commits, and reconciling on merge to main, are not done.What changed
infra.jsonat its root on the main branch, as{"version":1,"machines":[{name, account, place, host?, lifetimeDays?}]}.machines[0].host.src/cloud/infra_file.tsmarks each machine as add, change, remove or same. Retired machines count as not there. Only the declaring app's own running machines can be marked remove, and a name already used by another app is flagged.src/cloud/infra_read.tsreads the file from each app's repo and feeds all four doors./infra.GET /api/v1/admin/infra/code.infratool actioncode.docs/features/infra.md.test/infra-file.test.tscovers the schema, the diff and each door.bun x tsc --noEmitis clean. I ran the infra, Talk, own-source, unused-exports, doorless and feature-doors tests; all pass. I did not run the full suite.bun scripts/gate.ts(it names no remaining failure) andbun scripts/design-lint.ts(clean). I added a "No door" line because the "both doors" rule counts only new files, and the terminal screen and how-to are extended, not new.parseInfraand the plan code reuseNAMEfromcore/pinned.ts. The page reusesrow,rowListand thesettings-blocksection.Left out
infra.jsonfrom the UI as a commit.Try it: commit an
infra.jsonto an app's main branch, then open/infraas an admin. You can also callGET /api/v1/admin/infra/code, orinfrawith{action:"code"}.Review block:
Closes #17075