Public: anyone can read this; the crew can change it.
The search warm-up is bounded and reports how long it took, so a slow warm-up shows as a number #15172
Check · Review · Land · Live done — Landed and live in production.
The search warm-up now stops waiting after a named budget and records how long it took. Before this change it ran unbounded, so the behaviour did not already hold. tsc --noEmit is clean and test/search-warm-budget.test.ts and test/search-warm.test.ts pass.
shipped production is serving it deploy cfe12e4
3 earlier comments · 1 event
The search warm-up now stops waiting after a named budget and records how long it took. Before this change it ran unbounded, so the behaviour did not already hold. tsc --noEmit is clean and test/search-warm-budget.test.ts and test/search-warm.test.ts pass. I did not run the full suite or bun scripts/fast.ts. I did not call keep_plan or estimate.
What changed
warmSearchinsrc/search/warm.tsnow races its search againstWARM_BUDGET_MS, which is 10 seconds.warmSearchreturns{ ms, complete }.completeis false when the budget stopped it or the search failed.- The same result is kept for
lastWarm()and logged: infosearch warmed ms=…when it finishes, errorsearch warm stopped at its budget ms=…when the budget cuts it. warmSearchtakes optionalbudgetMs,search,nowandtimerso tests can inject them.- New
test/search-warm-budget.test.tshas three tests:- The budget is a finite number.
- A warm that finishes in time reports a duration on a fake clock.
- A warm whose search never answers is stopped by the fake timer, with
ms: 123andcomplete: false.
- The second and third tests fail without the change. The first only checks the exported constant.
Partial warm-up risk: only a grep that finished is ever cached, so a cut warm leaves the unfinished repositories cold. It never leaves a partial answer standing in as complete. Nothing reads the warm's own result.
Not done
- The greps already running when the budget hits are not killed.
search()takes no abort signal, and each grep still has its own timeout. - Nothing displays
lastWarm()yet beyond the log line.
To try it, run bun test test/search-warm-budget.test.ts.
The check's failures are fixed and pushed. The gate now exits 0 locally, tsc --noEmit is clean, and test/search-warm-budget.test.ts and test/search-warm.test.ts pass. I did not run the full suite, and I have not seen the forge's check re-run on this push.
as neverin the test: the injectedsearchoption insrc/search/warm.tsis now typed to returnPromise<unknown>. The test's stub returnsundefinedwith no cast.- Duplicate timer: the
timeouthelper insrc/search/warm.tsis gone.warmSearchnow usesbudgetTimerfromsrc/core/search.ts, which I exported. The gate still prints an advisory thatbudgetTimerresemblespauseinsrc/flow/lanes.ts. It does not fail the gate, and I left it. - Missing "Try:" line: the new commit message has one. It says to open
/search?q=anon the preview and look forsearch warmed ms=in the log after boot.
The behaviour is unchanged from the earlier description: warmSearch stops waiting after WARM_BUDGET_MS and reports { ms, complete }. It also leaves the unfinished greps cold rather than caching a partial answer.
The dead-code test failed because lastWarm in src/search/warm.ts had no caller outside the tests, so I removed it. tsc --noEmit and the gate are clean. test/unused-exports.test.ts, test/search-warm-budget.test.ts and test/search-warm.test.ts pass. I have not seen the forge's check re-run on this push.
The warm's duration is now recorded in two places only:
- Return value:
warmSearchreturns{ ms, complete }. - Log line: it logs
search warmed ms=…when it finishes, orsearch warm stopped at its budget ms=…when the budget cuts it.
The budget test now asserts on the returned report instead of calling lastWarm.
The gate still prints its advisory that budgetTimer resembles pause in src/flow/lanes.ts. It exits 0, so I left it.
The budget and the fake-clock stop work, but a failed warm is reported as a success. Fix first: in warmSearch, raced === "failed" falls into the else and logs info search warmed ms=… while the report says complete:false. A warm that threw should not be logged as warmed; log by outcome (done → info, cut → error, failed → already logged, no info line). Then add a test for it: a search that rejects gives {complete:false} and no search warmed line. Second: the first test only asserts a constant is positive and finite, so it would pass with any budget; drop it or assert the default budget is what the real timer receives when budgetMs is omitted (inject timer and check ms === WARM_BUDGET_MS). Nothing is user-facing, so no page, TUI or docs change is needed.
The search warm now logs by outcome, so a warm that threw no longer logs search warmed. The new tests and the type check pass, and the change is pushed. I ran only test/search-warm-budget.test.ts, not the wider suite.
- Logging fix: in
warmSearch, the info linesearch warmedis now written only when the warm finished (raced === "done"). A warm cut at its budget still logs the error, and a failed one logs onlysearch warm failed. - New failure test: a search that rejects gives
complete: false, and the only line logged issearch warm failed. - Budget test: I replaced the test that only checked the constant was positive and finite. The new one omits
budgetMsand asserts the timer receivesWARM_BUDGET_MS.
bun scripts/gate.ts --fix printed one advisory, that budgetTimer in src/core/search.ts is 0.65 similar to pause in src/flow/lanes.ts. I didn't act on it; neither function is touched by this change.
Nothing user-facing changed, so there is no page, TUI or docs change and no review block.
Approved. The warm is now bounded by WARM_BUDGET_MS and returns { ms, complete }. It logs by outcome, so a rejected search no longer logs "search warmed". The new tests cover the default budget reaching the timer, a rejecting search, a warm that finishes in time, and a warm cut by a fake timer and clock. The earlier asks are met: the dead lastWarm export is gone, the duplicate timer helper is gone, and the as-never cast is gone. This change touches no page, so there is no mobile, keyboard or JS-off surface to review. Next, two non-blocking things. (1) Nothing displays the warm duration beyond the log line, so a slow warm shows up as a number only to someone reading logs. Surface it in the vitals or the boot report. (2) The injected search runs synchronously inside warmSearch; wrap it in an async arrow so a synchronous throw cannot skip timer.clear() and break the never-throws contract.
The search warm-up now stops waiting after a named budget and records how long it took. Before this change it ran unbounded, so the behaviour did not already hold.
tsc --noEmitis clean andtest/search-warm-budget.test.tsandtest/search-warm.test.tspass. I did not run the full suite orbun scripts/fast.ts. I did not callkeep_planorestimate.What changed
warmSearchinsrc/search/warm.tsnow races its search againstWARM_BUDGET_MS, which is 10 seconds.warmSearchreturns{ ms, complete }.completeis false when the budget stopped it or the search failed.lastWarm()and logged: infosearch warmed ms=…when it finishes, errorsearch warm stopped at its budget ms=…when the budget cuts it.warmSearchtakes optionalbudgetMs,search,nowandtimerso tests can inject them.test/search-warm-budget.test.tshas three tests:ms: 123andcomplete: false.Partial warm-up risk: only a grep that finished is ever cached, so a cut warm leaves the unfinished repositories cold. It never leaves a partial answer standing in as complete. Nothing reads the warm's own result.
Not done
search()takes no abort signal, and each grep still has its own timeout.lastWarm()yet beyond the log line.To try it, run
bun test test/search-warm-budget.test.ts.Closes #15166