Public: anyone can read this; the crew can change it.
resolveAppHostname asks the database once per hostname, not once per call #17833
Merged 4h 44m ago, live in production
resolveAppHostname now keeps its answer for each host, so asking about the same host again no longer re-reads the app, repository and owner rows (#17824). The callers. No loop calls it once per row.
-
Reviews
ApprovedApproved. The memo reuses Stamped and the write clock, reads the stamp before computing, caches nothing inside a transaction, is bounded (1,024 entries, 5 s), and is per database. The suspension and slug-rename tests prove the next lookup sees a change, and the query-count test fails without the memo. No page or action changed, so no door or docs change is owed. Two things I would do next: (1) the clock is forge-wide, so on a write-heavy forge the hit rate may fall. Log memo.hits and memo.misses in the route timings and look at the real ratio before adding anything finer. (2) Callers get the same AppRecord object on every hit. Freeze it or add a one-line note that callers must not mutate the result, so no caller can change what the next request sees.
-
Checks
waiting merged; waiting for the forge to restart on it deploy 5fa2c54
-
History
- resolveAppHostname keeps its answer per host while the write clock stands (#17824) eeab3d4
- Talk's Stop stays for the whole answer, with words in the box too (#17819) b51ab2e
- The changelog credits a model only when a run backs it (#17807) e780a4e
- The decider can be compared with SubQ Snap in the background, off by default, and decides nothing (#17795) c0cee92
- small: the '+ New forge' page has one primary next action, with phone and desktop looks on the pull (#17818) 6cc8e61
- GET pulls/:number runs an uncapped diff and renders it on the serving thread (#17812) 153cbb3
- Full suite red: 2 files in check run 01m8wzswcz0vr3fz25ryd619jz (#17814) 8f7dfc4
- A Talk build's version strip is in sight when its preview opens, on a phone and at 1000 px (#17810) bdc702e
- Talk says what a long turn is doing and how long since its last step, across every stream (#17808) dcfa7ed
- A Talk build starts no crew run and no review, and only a person publishes it (#17803) cd1d5b7
- Only a check writes a retry decision's outcome, and it says which one (#17796) c2d976e
- A crew run that hits the turn limit wraps up, and says so in its run and its pull (#17809) b35dca2
- app-home-batched boots one forge for the file, and each test has its own account and repositories (#17805) 4763617
- A follow-up in Talk always carries what the person asked; tool steps are what gets cut (#17804) 7af0ffd
- A crew run can spend a granted OpenAI-type account, on the OpenAI runner, per run (#17787) b43bdad
- Talk: the model is a button beside Send, with a list you can type in, and plain names (#17794) 191cbc2
- A release asks scripts/return-check.ts before it promotes (#17793) 7618050
- A fresh start or a redone Talk answer sends the history once (#17802) d184914
- The contributor's walk of Talk's tools makes the calls that can run, not a thousand refused ones (#17806) 791b76f
- Games: /forge status and /forge servers (#17799) d20decc
resolveAppHostname now keeps its answer for each host, so asking about the same host again no longer re-reads the app, repository and owner rows (#17824).
The callers. No loop calls it once per row. It is called from:
src/http/server.ts:1059andsrc/spawn/host.ts:1104, throughresolveAppHostsrc/apps/here.ts,src/apps/preview_view.ts,src/web/pages/apps.ts(/apps/open) andsrc/http/routes/operations.ts(/__forge/domains/ask), each once per call
The 2,104 queries a minute come from src/http/server.ts:1059. It runs on every request to every app host, assets included. Requests to the forge's own host go through the same call and look up a verified custom domain.
The fix. It reuses the existing Stamped memo (src/kernel/stamped.ts) and the write clock (src/core/write_clock.ts), as src/web/map_snapshot.ts and src/actions/explore.ts already do. Each database gets one memo, keyed by the apps domain and the host. An entry is used only while the write clock hasn't moved. Any write that could change the answer moves the clock: a suspension, a slug change or a domain verified or removed. So the next lookup sees it, and #831 still holds. Entries also expire after 5 s, and the memo holds at most 1,024 hosts. Inside a transaction there is no stamp, so nothing is cached. Each lookup still runs one cheap write-clock read (total_changes() plus data_version), which reads no table.
Not done.
- Callers aren't handed a resolved value; the memo makes that unnecessary.
- The clock is forge-wide, so any write that isn't telemetry empties the memo. That costs some cache hits but never gives a stale answer.
Test. test/app-host-memo.test.ts:
- 51 lookups of one host run the app, repo, domain and user queries only once. This fails when the memo is switched off.
- A suspended owner's app is "unknown" at once and comes back at once after the suspension is lifted.
- A renamed slug is seen at once.
Checks run. bun x tsc --noEmit and bun scripts/gate.ts (0 rules failed) pass. These suites pass: app-host-memo, suspended-hidden, app-variants, apps-adversarial, apps-proxy-overhead, app-domains, domains, core-domains, apps-pill-where and archived-hidden-everywhere. One test was skipped, a socket-bound case this sandbox can't run. scripts/fast.ts named 2,990 test files because proxy.ts is imported nearly everywhere, so those weren't run here. The forge's check runs the whole suite.
How to try it. bun test test/app-host-memo.test.ts.
🤖 Generated with Claude Code
resolveAppHostnamenow keeps its answer for each host, so asking about the same host again no longer re-reads the app, repository and owner rows (#17824).The callers. No loop calls it once per row. It is called from:
src/http/server.ts:1059andsrc/spawn/host.ts:1104, throughresolveAppHostsrc/apps/here.ts,src/apps/preview_view.ts,src/web/pages/apps.ts(/apps/open) andsrc/http/routes/operations.ts(/__forge/domains/ask), each once per callThe 2,104 queries a minute come from
src/http/server.ts:1059. It runs on every request to every app host, assets included. Requests to the forge's own host go through the same call and look up a verified custom domain.The fix. It reuses the existing
Stampedmemo (src/kernel/stamped.ts) and the write clock (src/core/write_clock.ts), assrc/web/map_snapshot.tsandsrc/actions/explore.tsalready do. Each database gets one memo, keyed by the apps domain and the host. An entry is used only while the write clock hasn't moved. Any write that could change the answer moves the clock: a suspension, a slug change or a domain verified or removed. So the next lookup sees it, and #831 still holds. Entries also expire after 5 s, and the memo holds at most 1,024 hosts. Inside a transaction there is no stamp, so nothing is cached. Each lookup still runs one cheap write-clock read (total_changes()plusdata_version), which reads no table.Not done.
Test.
test/app-host-memo.test.ts:Checks run.
bun x tsc --noEmitandbun scripts/gate.ts(0 rules failed) pass. These suites pass: app-host-memo, suspended-hidden, app-variants, apps-adversarial, apps-proxy-overhead, app-domains, domains, core-domains, apps-pill-where and archived-hidden-everywhere. One test was skipped, a socket-bound case this sandbox can't run.scripts/fast.tsnamed 2,990 test files becauseproxy.tsis imported nearly everywhere, so those weren't run here. The forge's check runs the whole suite.How to try it.
bun test test/app-host-memo.test.ts.🤖 Generated with Claude Code
Closes #17824