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

Merged opened this

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

Merged

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.

Notes

shipped production is serving it deploy cfe12e4

opened this

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

  • warmSearch in src/search/warm.ts now races its search against WARM_BUDGET_MS, which is 10 seconds.
  • warmSearch returns { ms, complete }. complete is false when the budget stopped it or the search failed.
  • The same result is kept for lastWarm() and logged: info search warmed ms=… when it finishes, error search warm stopped at its budget ms=… when the budget cuts it.
  • warmSearch takes optional budgetMs, search, now and timer so tests can inject them.
  • New test/search-warm-budget.test.ts has 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: 123 and complete: 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.

Closes #15166

3 earlier comments · 1 event
commented

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

  • warmSearch in src/search/warm.ts now races its search against WARM_BUDGET_MS, which is 10 seconds.
  • warmSearch returns { ms, complete }. complete is false when the budget stopped it or the search failed.
  • The same result is kept for lastWarm() and logged: info search warmed ms=… when it finishes, error search warm stopped at its budget ms=… when the budget cuts it.
  • warmSearch takes optional budgetMs, search, now and timer so tests can inject them.
  • New test/search-warm-budget.test.ts has 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: 123 and complete: 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.

commented

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 never in the test: the injected search option in src/search/warm.ts is now typed to return Promise<unknown>. The test's stub returns undefined with no cast.
  • Duplicate timer: the timeout helper in src/search/warm.ts is gone. warmSearch now uses budgetTimer from src/core/search.ts, which I exported. The gate still prints an advisory that budgetTimer resembles pause in src/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=an on the preview and look for search 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.

commented

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: warmSearch returns { ms, complete }.
  • Log line: it logs search warmed ms=… when it finishes, or search 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.

Changes requested — before the latest push

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.

commented

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 line search warmed is now written only when the warm finished (raced === "done"). A warm cut at its budget still logs the error, and a failed one logs only search warm failed.
  • New failure test: a search that rejects gives complete: false, and the only line logged is search warm failed.
  • Budget test: I replaced the test that only checked the constant was positive and finite. The new one omits budgetMs and asserts the timer receives WARM_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

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs