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

The template picker on New forge remembers nothing but shows each template's last-built date from the git log #16005

Merged opened this

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

Merged

Each repository template on /templates and in the New forge picker now says "updated " from its repository's head commit, and "stale" when that head is over 180 days old. The new tests pass, tsc is clean and bun scripts/gate.ts is green. I did not run the full suite.

Notes

shipped production is serving it deploy b03b44b

opened this

Each repository template on /templates and in the New forge picker now says "updated <date>" from its repository's head commit, and "stale" when that head is over 180 days old. The new tests pass, tsc is clean and bun scripts/gate.ts is green. I did not run the full suite.

What changed

  • Read: src/spawn/template_head.ts reads the default branch's head date with git log -1. It holds each read for 60 s per repository. The cache is capped at 500 entries and named in heldOf as "template heads read".
  • /templates: the row now says "updated 3d ago", with a bold "stale" after it past 180 days. This replaces the earlier source, the merge time of the newest landed pull.
  • New forge picker: each repository template's label ends "· updated 2026-11-17", plus "· stale" when old. readsFor in new-forge.ts is now async, so newForgePage and its callers await it.
  • Tests: test/template-head.test.ts makes two fixture templates, one 3 days old and one 400. It checks that both lines appear on /templates and in the picker, that "stale" shows only on the old one, and that the 60 s hold works. It also checks that "stale" starts after 180 days, not at 180.
  • Edited test: I removed one test from test/templates-alive.test.ts. It asserted the old merged-pull recency on the page, which this change replaces.

Not done

  • The terminal list (src/tui/screens/templates.ts) still uses the merged-pull recency. A keypress there must not touch disk, so it needs its own change.
  • I did not change which repositories count as templates.
  • I did not add a page-budget test. The page does one cached git log per template, run in parallel.

Notes

  • test/templates-tui.test.ts failed once in a combined run and passed on rerun, with and without my change. I did not touch that screen.
  • The "Releasing trevato/forge" hold on the desk did not touch this change.
  • The commits carry Try:, No look:, No door: and Direction: lines for the gate.

To try

  • Open /templates and /forges/new on the preview. Each repository template should read "updated <date>".
  • A template whose head is over 180 days old should also say "stale".

🤖 Generated with Claude Code

Closes #15983

5 earlier comments · 2 events
commented

Each repository template on /templates and in the New forge picker now says "updated <date>" from its repository's head commit, and "stale" when that head is over 180 days old. The new tests pass, tsc is clean and bun scripts/gate.ts is green. I did not run the full suite.

What changed

  • Read: src/spawn/template_head.ts reads the default branch's head date with git log -1. It holds each read for 60 s per repository. The cache is capped at 500 entries and named in heldOf as "template heads read".
  • /templates: the row now says "updated 3d ago", with a bold "stale" after it past 180 days. This replaces the earlier source, the merge time of the newest landed pull.
  • New forge picker: each repository template's label ends "· updated 2026-11-17", plus "· stale" when old. readsFor in new-forge.ts is now async, so newForgePage and its callers await it.
  • Tests: test/template-head.test.ts makes two fixture templates, one 3 days old and one 400. It checks that both lines appear on /templates and in the picker, that "stale" shows only on the old one, and that the 60 s hold works. It also checks that "stale" starts after 180 days, not at 180.
  • Edited test: I removed one test from test/templates-alive.test.ts. It asserted the old merged-pull recency on the page, which this change replaces.

Not done

  • The terminal list (src/tui/screens/templates.ts) still uses the merged-pull recency. A keypress there must not touch disk, so it needs its own change.
  • I did not change which repositories count as templates.
  • I did not add a page-budget test. The page does one cached git log per template, run in parallel.

Notes

  • test/templates-tui.test.ts failed once in a combined run and passed on rerun, with and without my change. I did not touch that screen.
  • The "Releasing trevato/forge" hold on the desk did not touch this change.
  • The commits carry Try:, No look:, No door: and Direction: lines for the gate.

To try

  • Open /templates and /forges/new on the preview. Each repository template should read "updated <date>".
  • A template whose head is over 180 days old should also say "stale".

🤖 Generated with Claude Code

Changes requested — before the latest push

The date line works on /templates and in the picker, but this is not ready. Fix these in one round.

  1. Both doors: the terminal templates screen (src/tui/screens/templates.ts) still shows the old merged-pull recency, so the terminal and the page now disagree about when a template changed. Give it the same head date. Read it through the cache, off the keypress path, if a keypress must not touch disk. Deferring it is not allowed by the both-doors rule.
  2. Docs: put the new behaviour (updated <date>, stale after 180 days) in docs/features/ (the templates how-to). I see no doc change in the diff.
  3. Budget (box 4): there is no test that the page stays under its budget. A cold /forges/new now awaits up to 50 parallel git log spawns on the hot path. Add a test that holds the cold and warm response within the budget, or bound the cold read.
  4. Design: <b class="stale"> is a new class that is not in docs/design/areas/templates.md. Use an existing muted text pattern, or document the class. Bold gives the word more weight than the muted sentence it sits in. Also check with bun scripts/design-lint.ts.
  5. Test coverage lost: you deleted the templates-alive test for NO_CHANGES_YET and for the built-in starter row having no line. Restore it against the new source, since a repository with no commit still needs to say 'no changes yet'.
  6. Wording: /templates says 3d ago and the picker says 2026-11-17. Pick one form for the same fact.
commented

Each repository template now says when its head commit was made, on all three surfaces: /templates, the New forge picker and the terminal templates screen. Past 180 days the line adds · stale. I ran the template tests, tsc, gate.ts --fix and design-lint; all pass. I didn't run the full suite, and the forge's check runs it on this push.

Changes for each of juniper's points:

  1. Terminal: src/tui/screens/templates.ts now reads the head dates from templateHeads, the same 60 s cache the web uses. It does this after the first paint, never on a keypress. The line stays blank until the read lands. It then shows updated 3d ago or no changes yet, with · stale when old. The merged-pull recency read is gone.
  2. Docs: docs/features/template-recency.md now describes the head-commit date, stale after 180 days, the cache, the cold-read bound, and all three surfaces.
  3. Budget: templateHeads waits at most 400 ms (HEAD_WAIT_MS). A repository not read by then shows no date for that load. Its read still finishes in the background and is kept for the next one. A new test checks that a zero wait returns at once. It also checks that cold and warm /forges/new and /templates answer within 1 s (the 400 ms bound plus 600 ms), with an empty-tree commit as the only cost. I did not measure 50 parallel git log spawns; the bound is what covers them.
  4. Design: the <b class="stale"> is gone. stale is now plain text in the muted sentence, so no new class needs documenting.
  5. Restored test: templates-alive is back against the new source. A repository with a commit shows 3d ago, one with no commit shows no changes yet, and the built-in starter row shows no line. I removed the now-unused templateRecency query and the test of it. template_recent.ts keeps only NO_CHANGES_YET.
  6. Wording: the picker now says updated 3d ago, matching /templates and the terminal. The exact date is still in the <time> title on /templates.

I changed test/template-head.test.ts expectations from updated <date> to relative words to match point 6.

Try it: open /templates and /forges/new on the preview, then /templates in the terminal. A repository template with an old head reads updated 1y ago · stale.

commented

I fixed the one failure this pull caused and pushed it. I haven't confirmed the other three. They pass or don't touch my code, but I haven't re-run them.

  • Cause: the cold-read bound in src/spawn/template_head.ts used a bare setTimeout. The "every server-side timer callback is wrapped in during or allowed by name" test in test/timers-named.test.ts refuses that. The bound now uses Promise.race([reads, Bun.sleep(waitMs)]), so no timer callback is left outside during. The 400 ms wait and everything else about the head read are as before.
  • Verified here: bun x tsc --noEmit is clean. test/timers-named.test.ts, test/template-head.test.ts, test/openapi-coverage.test.ts and test/openapi-covers-routes.test.ts all pass. I suspect openapi-coverage.test.ts and openapi-covers-routes.test.ts are what the NOT_YET_DESCRIBED failure comes from, but I didn't find the exact test file.
  • Other failures: the "reach proof" and "memory sampler" tests are timing-sensitive shard tests in code this pull doesn't change. I expect the next check run to show whether they were load flakes.
Changes requested — before the latest push

The date line, stale word, terminal screen and docs are in place. Two things block it.

  1. HIGH, denial of service: a cold read has no in-flight sharing, so a cache miss starts a git spawn per template for every concurrent request. /forges/new is open to strangers, so a burst of requests during the 60 s a read is cold or lapsed multiplies up to 50 git processes each. Keep the pending promise per id in the cache and share it. Also hold the failed-read result, so an unreadable repository is not re-spawned on every request.
  2. Box 4, budget: the test allows 400+600 ms per request, which is no budget, and expect(none.size).toBeLessThanOrEqual(2) cannot fail. Assert a real warm bound (the page budget, tens of ms) and that a zero wait returns no heads. Also add a terminal test that the head line appears after the first paint, because the TUI path changed and nothing covers it.

Smaller: the updated … · stale wording is built in three places (headWords in new-forge.ts, sentence in templates.ts, recencyLine in the TUI screen). Make it one function in template_head.ts. Bun.sleep(waitMs) keeps a 400 ms timer alive per request after the reads finish; cancel it or race on an abortable timer.

commented

Each template on /templates, in the New forge picker and on the terminal's templates screen now says updated <date>, taken from the date of its repository's head commit. It adds · stale when that date is more than 180 days old. Each read is kept for 60 s. This push deals with @sentinel's review.

  • Shared reads (the denial-of-service finding): templateHeads in src/spawn/template_head.ts now stores the read's promise in the cache before the read finishes. Concurrent requests during a cold or expired 60 s window share one git read per template instead of starting one each. A read that fails (missing repository, git error, no commit) is kept for the same 60 s, so it is not started again on every request.
  • Wait bound: the 400 ms wait is now a setTimeout that is cleared once the reads finish, the same pattern as src/git/offer_size.ts. It is listed with its reason in test/timers-named.test.ts. A zero wait skips the timer entirely.
  • One wording: headWords(at, date) in template_head.ts builds the updated … · stale text. The web page, the picker and the terminal screen now all call it; only the date formatting differs (a <time> element on the web, 3d ago elsewhere).
  • Tests (test/template-head.test.ts):
    • 20 concurrent callers over three templates start exactly 3 reads, and asking again for the unreadable one starts none. This uses a small headReadsStarted() counter added for the test.
    • A zero wait returns no heads at all, in under 20 ms.
    • With the cache warm, /forges/new and /templates each answer in under 50 ms.
    • The terminal's templates screen shows updated 1y ago · stale for the old template once the read lands.

bun scripts/gate.ts --fix (it rewrapped one comment), bun x tsc --noEmit, bun scripts/design-lint.ts and the template-head, timers-named, templates-tui, templates-alive and new-forge-template tests pass. The rest of the suite is left to the forge's check.

The desk hold "Releasing trevato/forge: production is rolling" was taken into account: this push only updates the pull's branch and preview, not production.

[{"go":"/templates","look":"a repository template's row","expect":"updated <date>, and · stale only when its head commit is over 180 days old"},{"go":"/forges/new","look":"the template picker","expect":"each repository template's label ends with · updated 3d ago (or similar), plus · stale for an old one; built-ins carry no date"}]

🤖 Generated with Claude Code

commented

Each template on /templates, in New forge and on the terminal's templates screen now shows updated <date>, taken from the commit date of the latest commit on its repository's default branch. A template whose last commit is more than 180 days old also gets · stale (#15983). Built-in templates have no repository, so they show no date.

What changed

  • src/spawn/template_head.ts reads each date with one git log -1 per repository and keeps the result for 60 s. All three surfaces use this one read and the same headWords wording.
    • Callers that arrive while a read is still running wait on that read; they don't start another.
    • If a repository can't be read, that answer is kept for the same 60 s.
    • The cache holds at most 500 repositories.
    • A page waits at most 400 ms for a first read. A slower repository shows no date on that response, and the date appears once the read finishes.
  • src/spawn/template_recent.ts loses the code these reads replace, and docs/features/template-recency.md is updated.

Fixes for the failed check

  • Stopwatch assertions: test/template-head.test.ts no longer times anything. It counts git processes with gitSpawns from test/helpers/work.ts. Twenty callers at once start exactly two reads (one per real repository), a repeat within 60 s starts none, and a second load of each page starts none.
  • Dead-code check: the headReadsStarted counter in template_head.ts existed only for that test, so it is removed.

Checks run: test/template-head, templates-alive, timers-named, unused-exports and flake pass, as do the gate script and tsc --noEmit.

Not done: the page doesn't fill in a date by itself once a slow first read finishes; it shows on the next load.

[
  {"go": "/templates", "look": "each repository template's row", "expect": "\"updated 3d ago\" style date; \"· stale\" only on templates whose head is over 180 days old; built-in templates show no date"},
  {"go": "/forges/new", "look": "the template picker labels", "expect": "the same \"updated … · stale\" wording as /templates"},
  {"go": "/forges/new", "look": "reload the page", "expect": "answers instantly; no layout shift where the date sits", "ask": "Is \"stale\" clear enough on its own?"}
]

🤖 Generated with Claude Code

commented

Each template on /templates, in New forge and on the terminal's templates screen now shows updated <date>, taken from the commit date of the latest commit on its repository's default branch. A template whose last commit is more than 180 days old also gets · stale (#15983). Built-in templates have no repository, so they show no date.

What changed

  • src/spawn/template_head.ts reads each date with one git log -1 per repository and keeps the result for 60 s. All three surfaces use this one read and the same headWords wording.
    • Callers that arrive while a read is still running wait on that read; they don't start another.
    • If a repository can't be read, that answer is kept for the same 60 s.
    • The cache holds at most 500 repositories.
    • A page waits at most 400 ms for a first read. A slower repository shows no date on that response, and the date appears once the read finishes.
  • src/spawn/template_recent.ts loses the code these reads replace, and docs/features/template-recency.md is updated.
  • Tests: test/template-head.test.ts checks its limits by counting git processes with gitSpawns, not by timing. Twenty callers at once start exactly two reads (one per real repository), a repeat within 60 s starts none, and a second load of each page starts none.

Merge with main

  • main now builds the template list with the usage counts it is ordered by (templateList(…, used)), and the New forge error page uses templateListUnsorted.
  • The resolution keeps both. The terminal screen reads head dates for that usage-aware list. /templates keeps main's single used read, followed by the timed heads read. New forge's error page uses templateListUnsorted and still awaits readsFor.

Checks run: after the merge, tsc --noEmit, the gate script and scripts/design-lint.ts pass. So do the 51 template and New forge test files, unused-exports and flake: 330 tests, all passing.

Not done: the page doesn't fill in a date by itself once a slow first read finishes; it shows on the next load.

[
  {"go": "/templates", "look": "each repository template's row", "expect": "\"updated 3d ago\" style date; \"· stale\" only on templates whose head is over 180 days old; built-in templates show no date"},
  {"go": "/forges/new", "look": "the template picker labels", "expect": "the same \"updated … · stale\" wording as /templates"},
  {"go": "/forges/new", "look": "reload the page", "expect": "answers instantly; no layout shift where the date sits", "ask": "Is \"stale\" clear enough on its own?"}
]

🤖 Generated with Claude Code

Approved

Every earlier ask is met. (1) Cold reads now share one in-flight promise per repository, and a failed read is held for the same 60 s (src/spawn/template_head.ts). (2) The tests count git spawns with gitSpawns instead of timing: 20 concurrent callers start 2 reads, a repeat starts 0, and warm /forges/new and /templates start 0. A zero wait is tested. (3) A terminal test covers the head line appearing after first paint. (4) The wording lives in one place, headWords, and all three surfaces use it. (5) The bound timer is cleared and named in timers-named. The docs live in docs/features/template-recency.md, not the README. stale is plain muted text, so no new component class.

Next, both non-blocking: (a) /forges/new is open to strangers and now waits up to 400 ms on a cold read. If the picker ever feels slow cold, pass a smaller wait there or warm the cache on boot. (b) A slow first read shows no date until the next load. A line saying the date is pending would be kinder than silence, but it is not needed to land.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs