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
Check · Review · Land · Live done — Landed and live in production.
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.
shipped production is serving it deploy b03b44b
5 earlier comments · 2 events
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.tsreads the default branch's head date withgit log -1. It holds each read for 60 s per repository. The cache is capped at 500 entries and named inheldOfas "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.
readsForinnew-forge.tsis now async, sonewForgePageand its callers await it. - Tests:
test/template-head.test.tsmakes two fixture templates, one 3 days old and one 400. It checks that both lines appear on/templatesand 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 logper template, run in parallel.
Notes
test/templates-tui.test.tsfailed 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:andDirection:lines for the gate.
To try
- Open
/templatesand/forges/newon 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
The date line works on /templates and in the picker, but this is not ready. Fix these in one round.
- 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.
- 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.
- 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 logspawns on the hot path. Add a test that holds the cold and warm response within the budget, or bound the cold read. - 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 withbun scripts/design-lint.ts. - Test coverage lost: you deleted the templates-alive test for NO_CHANGES_YET and for the built-in
starterrow having no line. Restore it against the new source, since a repository with no commit still needs to say 'no changes yet'. - Wording: /templates says
3d agoand the picker says2026-11-17. Pick one form for the same fact.
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:
- Terminal:
src/tui/screens/templates.tsnow reads the head dates fromtemplateHeads, 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 showsupdated 3d agoorno changes yet, with· stalewhen old. The merged-pull recency read is gone. - Docs:
docs/features/template-recency.mdnow describes the head-commit date,staleafter 180 days, the cache, the cold-read bound, and all three surfaces. - Budget:
templateHeadswaits 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/newand/templatesanswer within 1 s (the 400 ms bound plus 600 ms), with an empty-tree commit as the only cost. I did not measure 50 parallelgit logspawns; the bound is what covers them. - Design: the
<b class="stale">is gone.staleis now plain text in the muted sentence, so no new class needs documenting. - Restored test:
templates-aliveis back against the new source. A repository with a commit shows3d ago, one with no commit showsno changes yet, and the built-instarterrow shows no line. I removed the now-unusedtemplateRecencyquery and the test of it.template_recent.tskeeps onlyNO_CHANGES_YET. - Wording: the picker now says
updated 3d ago, matching/templatesand 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.
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.tsused a baresetTimeout. The "every server-side timer callback is wrapped induringor allowed by name" test intest/timers-named.test.tsrefuses that. The bound now usesPromise.race([reads, Bun.sleep(waitMs)]), so no timer callback is left outsideduring. The 400 ms wait and everything else about the head read are as before. - Verified here:
bun x tsc --noEmitis clean.test/timers-named.test.ts,test/template-head.test.ts,test/openapi-coverage.test.tsandtest/openapi-covers-routes.test.tsall pass. I suspectopenapi-coverage.test.tsandopenapi-covers-routes.test.tsare what theNOT_YET_DESCRIBEDfailure 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.
The date line, stale word, terminal screen and docs are in place. Two things block it.
- 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.
- 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.
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):
templateHeadsinsrc/spawn/template_head.tsnow 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
setTimeoutthat is cleared once the reads finish, the same pattern assrc/git/offer_size.ts. It is listed with its reason intest/timers-named.test.ts. A zero wait skips the timer entirely. - One wording:
headWords(at, date)intemplate_head.tsbuilds theupdated … · staletext. 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 agoelsewhere). - 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/newand/templateseach answer in under 50 ms. - The terminal's templates screen shows
updated 1y ago · stalefor the old template once the read lands.
- 20 concurrent callers over three templates start exactly 3 reads, and asking again for the unreadable one starts none. This uses a small
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
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.tsreads each date with onegit log -1per repository and keeps the result for 60 s. All three surfaces use this one read and the sameheadWordswording.- 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.tsloses the code these reads replace, anddocs/features/template-recency.mdis updated.
Fixes for the failed check
- Stopwatch assertions:
test/template-head.test.tsno longer times anything. It counts git processes withgitSpawnsfromtest/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
headReadsStartedcounter intemplate_head.tsexisted 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
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.tsreads each date with onegit log -1per repository and keeps the result for 60 s. All three surfaces use this one read and the sameheadWordswording.- 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.tsloses the code these reads replace, anddocs/features/template-recency.mdis updated.- Tests:
test/template-head.test.tschecks its limits by counting git processes withgitSpawns, 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
mainnow builds the template list with the usage counts it is ordered by (templateList(…, used)), and the New forge error page usestemplateListUnsorted.- The resolution keeps both. The terminal screen reads head dates for that usage-aware list. /templates keeps
main's singleusedread, followed by the timedheadsread. New forge's error page usestemplateListUnsortedand still awaitsreadsFor.
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
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.
Each repository template on
/templatesand 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,tscis clean andbun scripts/gate.tsis green. I did not run the full suite.What changed
src/spawn/template_head.tsreads the default branch's head date withgit log -1. It holds each read for 60 s per repository. The cache is capped at 500 entries and named inheldOfas "template heads read".readsForinnew-forge.tsis now async, sonewForgePageand its callers await it.test/template-head.test.tsmakes two fixture templates, one 3 days old and one 400. It checks that both lines appear on/templatesand 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.test/templates-alive.test.ts. It asserted the old merged-pull recency on the page, which this change replaces.Not done
src/tui/screens/templates.ts) still uses the merged-pull recency. A keypress there must not touch disk, so it needs its own change.git logper template, run in parallel.Notes
test/templates-tui.test.tsfailed once in a combined run and passed on rerun, with and without my change. I did not touch that screen.Try:,No look:,No door:andDirection:lines for the gate.To try
/templatesand/forges/newon the preview. Each repository template should read "updated <date>".🤖 Generated with Claude Code
Closes #15983