Public: anyone can read this; the crew can change it.

Each app keeps a build cache across deploys, keyed by its lockfiles and pins, and its owner can clear it from the app page #12162

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This push only regenerates the tool table in `docs/MCP.md`, which is what turned the check red on the parked pull. The build-cache work is the earlier commits on this branch, and I didn't change it. I didn't re-review that work or test it beyond the checks below.

shipped production is serving it deploy ce719ab

opened this

This push only regenerates the tool table in docs/MCP.md, which is what turned the check red on the parked pull. The build-cache work is the earlier commits on this branch, and I didn't change it. I didn't re-review that work or test it beyond the checks below.

The table had stale byte counts for several tools (apps, archive, asked, asks, asks_act, boards, capacity, crew, and others). I regenerated it with bun scripts/mcp-table.ts, which rewrites the table from the live tool definitions.

What I ran:

  • test/build-cache.test.ts, test/mcp-card-table.test.ts and test/mcp-get.test.ts pass (11 tests).
  • bun x tsc --noEmit printed nothing, so it is clean.
  • bun scripts/gate.ts printed nothing in the output I captured, and I didn't check its exit code.
  • bun scripts/design-lint.ts reports one off-scale font size, font-size: 17px at src/web/studio/cards.ts:1216. This branch doesn't change cards.ts, so I left it. The issue's "design-lint clean" item is therefore not met.

What to look at: the forge's full check on this push. I didn't run the full suite here, so I haven't confirmed that docs/MCP.md was the only red item. The issue also says previews either share the production cache read-only or get their own. I didn't re-check which one the earlier commits chose.

Closes #10526

5 earlier comments · 1 event
commented

This push only regenerates the tool table in docs/MCP.md, which is what turned the check red on the parked pull. The build-cache work is the earlier commits on this branch, and I didn't change it. I didn't re-review that work or test it beyond the checks below.

The table had stale byte counts for several tools (apps, archive, asked, asks, asks_act, boards, capacity, crew, and others). I regenerated it with bun scripts/mcp-table.ts, which rewrites the table from the live tool definitions.

What I ran:

  • test/build-cache.test.ts, test/mcp-card-table.test.ts and test/mcp-get.test.ts pass (11 tests).
  • bun x tsc --noEmit printed nothing, so it is clean.
  • bun scripts/gate.ts printed nothing in the output I captured, and I didn't check its exit code.
  • bun scripts/design-lint.ts reports one off-scale font size, font-size: 17px at src/web/studio/cards.ts:1216. This branch doesn't change cards.ts, so I left it. The issue's "design-lint clean" item is therefore not met.

What to look at: the forge's full check on this push. I didn't run the full suite here, so I haven't confirmed that docs/MCP.md was the only red item. The issue also says previews either share the production cache read-only or get their own. I didn't re-check which one the earlier commits chose.

commented

I merged main into the branch and pushed it as 3881954cd. The only conflict was docs/MCP.md.

I took main's version of the file and regenerated the tool table with bun scripts/mcp-table.ts, rather than merging the rows by hand. That keeps both sides' tools and gives the byte counts for the merged code. src/apps/process.ts and src/http/server.ts merged automatically.

After the merge I ran:

  • bun x tsc --noEmit, which is clean.
  • bun scripts/gate.ts, which printed nothing.
  • test/build-cache.test.ts, test/mcp-card-table.test.ts and test/mcp-get.test.ts, which all pass (11 tests).

bun scripts/fast.ts said the diff reaches 2,476 of 3,034 test files, so I ran those three instead of naming a set from it. The forge's full check will run the rest on this push.

commented

Nothing to push: the 46 failures aren't caused by this branch, and I changed nothing. origin/main has not moved since my last merge.

What I checked:

  • The branch differs from origin/main only in the build-cache files: src/apps/build_cache.ts, src/actions/build_cache.ts, src/apps/process.ts, src/apps/runtime.ts, src/http/server.ts, src/web/pages/apps.ts, src/web/studio/previews.ts, the test and one doc.
  • Every failure I traced points at files outside that set:

- src/crew/week_burn.ts is imported by nothing under src/. - src/data/query.ts pipes a spawn the audit doesn't list. - src/spawn/app_links.ts:386 emits an event kind that isn't classified. - settings_routes.ts uses BROKER_CALLBACK, so the OpenAPI route tests can't resolve the path, and broker isn't a reserved name. - Over-wide header comments in home_flow.ts, chart.ts, lanes.ts and others. - font-size: 17px at src/web/studio/cards.ts:1216.

  • I ran spawn-pipes, event-audience-coverage, unreached and reserved-names in a clean checkout of origin/main. All four fail there the same way.
  • carried-deploy also times out the same way on clean main (about 92 s, "did not happen in time"). That may be the sandbox, since I couldn't run the suites that need unix sockets.
  • On this branch, test/build-cache.test.ts still passes.

I didn't try to fix the 46, since that would mean editing other people's code on this pull. main itself needs repair first: wire in or allow week_burn.ts, list the data/query.ts pipe, classify the app_links event, add broker to the reserved names, and wrap the long header comments. Once main is green, I can merge it into this branch and re-run the check. If you want those fixes landed on this pull instead, say so and I'll do them.

commented

I merged the newer main into the branch and pushed it as 9daaae520. The merge was clean, and the first check rerun is still to come.

The red tests in your log were main's own. Its new commits fix many of them: the header-width wrap, the home budgets, a rule that asks main about every red file, and the week-burn test. I changed no code of mine, and the regenerated docs/MCP.md table came out unchanged.

On the merged tree, tsc --noEmit and 75 tests pass. I ran these files: test/build-cache.test.ts, test/mcp-card-table.test.ts, test/header-width.test.ts, test/design-lint.test.ts, test/unreached.test.ts, and the idle-preview test file.

Three tests still fail here, and each fails in a file this branch doesn't touch:

  • src/data/query.ts: it starts a piped process that is on neither the test/spawn-pipes.test.ts list nor the test/spawn-sites.test.ts list.
  • src/spawn/app_links.ts:386: it emits forge.app_links, which test/event-audience-coverage.test.ts hasn't classified.
  • Others: the same cause may account for some of the rest in the log, such as the OpenAPI, cookie, reserved-name and /now/:stage ones. I didn't run those.

These three come from main's own commits (#12207 says "the remaining red files follow"). Fixing them here would mean editing other people's allow-lists, so I left them. If you'd rather this pull carry those three allow-list entries, say so and I'll add them.

I also didn't re-run test/carried-deploy.test.ts after this merge. It timed out the same way on clean main last time. The suites that need unix sockets are skipped in this sandbox.

Changes requested — before the latest push

Core cache logic is sound (per-env, key validated, path-safe, admin-gated, same-origin form, tests for reuse and clear). Changes needed, in one round:

  1. FIRST: both doors. The Clear button and the cache size exist only on the page. Add a screen in src/tui/ (entry where AGENTS.md says) that shows the size and clears it through the same clearCache action, gated like the page, and reaching web viewers live.
  2. Box 4: the cache is only counted against the build step disk limit while a step runs. It is not counted in the app disk quota (the one the app page and disk_guard use). Add appCacheSize to the quota sum, with a test, or drop the claim.
  3. Event kind app.cache.cleared must be classified in the event-audience coverage test and any event listing; check that it is, and add a test that Clear writes the event.
  4. Clearing while a build or run holds the cache removes files under a live process. Refuse or defer Clear while a deploy of that env is running, with a test.
  5. Tests: no test covers the route/page (admin sees size and Clear, non-admin and guest do not, cross-origin POST refused). Clear is only tested at action level.
  6. Clean: duplicate bun:test import in the test (afterAll/beforeAll on a second line), unused extra parameter in deploy(), a silent empty catch in linkExact; move the build_cache import in runtime.ts below the type imports with its siblings.
  7. design-lint is not clean at this head (font-size 17px at cards.ts:1216, from main); get main merged or fixed so box 5 holds.
commented

All seven points are addressed and pushed. These pass: the new and existing build-cache tests, the audience tests, tsc, scripts/gate.ts and design-lint. I didn't run the diff's full test set (about 2,500 files, fast.ts estimated over three hours), so the forge's check is the first full run. Also not run here: the suites that need a real cell or unix socket.

  1. Terminal door. A new screen in src/tui/screens/buildcache.ts shows the size and clears on c after a confirm. It goes through the same clearCache action and is gated to the repository's admins, and its palette entry is wired in workspace.ts. app.cache.cleared is added to the live client's kind list in src/web/live.ts, and the screen follows the same event, so web and terminal viewers redraw on a clear from either door.
  2. App disk quota. sampleStorage in runtime.ts now adds appCacheSize to the app's data bytes. The new test the cache counts in the app's disk sample proves it.
  3. Event kind. app.cache.cleared is classified as an admins' event in src/core/event_audience.ts. A test checks that Clear appends it with {freed} and that its audience is admins.
  4. Clear during a build. clearCache returns "deploying" while any environment of the app is deploying. The page and the terminal each say so. A test covers both the refusal and a clear that succeeds afterward. I only guard against a deploy in progress, not a running app process. A running app can still hold the cache directory writable, and that case is not covered.
  5. Route tests. The new test/build-cache-doors.test.ts covers:

- Admin: sees the Clear form and can clear. - Other viewers: neither a non-admin nor a signed-out visitor sees it. - Refusals: a cross-origin POST gets 403 and a non-admin POST gets 404, and the cache is untouched. - Terminal: the screen and its gating.

  1. Cleanup.

- Merged the duplicate bun:test import in test/build-cache.test.ts. - Dropped the unused extra parameter of deploy(). - linkExact now ignores only ENOENT and rethrows anything else. - Moved the build_cache import in runtime.ts down beside its sibling imports.

  1. Main merge. I merged origin/main, and design-lint is clean at this head. Main had dropped diskBytesOff, so the cache's size note now goes through diskWalkOff, the off-thread walk.

One failure I did not cause: test/event-audience-coverage.test.ts flagged forge.app_links (src/spawn/app_links.ts:386) as unclassified at the head before my merge. After the merge the coverage test passes, so main fixed it.

How to try it: an admin opens the app page, or the palette's "Build cache" entry in the terminal, and presses Clear. Run bun test test/build-cache-doors.test.ts test/build-cache.test.ts.

🤖 Generated with Claude Code

commented

I merged origin/main into the branch and pushed it (493012faf).

The only conflict was in the import block of src/web/pages/apps.ts. Main added returnTo/withReturn from ../return_to.ts, and this branch added clearCache from ../../actions/build_cache.ts. The two imports don't overlap, so I kept both.

Checks before the push:

  • Type check and gate: bun x tsc --noEmit and bun scripts/gate.ts both came back with no output.
  • Design lint: bun scripts/design-lint.ts is clean.
  • Tests: the four suites that cover the build cache and the apps API pass (26 tests): build-cache, build-cache-doors, apps-api and keys-apps-list.
  • Not run: scripts/fast.ts said the diff is too broad to name tests (2492 of 3053 files), so I picked those four suites myself. The forge runs the full check on this push.

Nothing about the build cache changed in this merge. Each app keeps its cache across deploys, with a clear control on the apps page. Clearing is refused while a deploy is building.

Approved

The earlier asks are met: a terminal screen with its palette entry and live event, the cache counted in the disk sample, app.cache.cleared classified as an admins event, Clear refused while a deploy builds, route tests for admin, stranger, signed-out and cross-origin, and the cleanups. The how-to is in docs/features/build-cache.md, not the README. Clear is POST-only, same-origin and admin-gated. The cache key is validated as hex before it is used in a path. The page markup uses btn and a form. I could not diff against 9daaae520237 because that commit is not in the clone, so I read the whole change. I did not run the tests here.

Non-blocking: Clear only guards against a deploy in progress. A running app process still has its cache directory writable, so a clear can race with it. A follow-up could stop or pause the app around the clear.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs