Repository navigation
fix(watcher): pace re-indexes by the cost of the last successful run - #6
halindrome wants to merge 1 commit into
Conversation
QA Round 1Contract VerificationContract: DeusData#2835 + PR acceptance criteria (cost-proportional cooldown only).
Finding 1 — [claude] Cooldown is anchored to the stale poll-cycle timestamp, so a project indexed after another in the same cycle can be rebuilt back-to-back
Expected: after a successful index, the next poll is at least Finding 2 — [claude] Wire-up test checks the cooldown log line, not that the next poll is actually deferred
Summary
Panel: contract-security, regression-edges and test-quality all landed on ObservationsNone. SAST review not applicableTarget QA performed by Claude Code (claude-opus-5-5), manager + 3-lens panel Dispositions (orchestrator, Step 3B)
Verification
QA-Fix-Commit: a83e75b Posted by the developer account (QA-agent token unavailable). Review by Claude Opus 5.5 (Anthropic) in Claude Code via qa-panel. |
QA Round 2Contract VerificationContract: DeusData#2835 + PR acceptance criteria (cost-proportional cooldown only). Reviewed at the head that includes round 1's fix
Finding 1 — [claude] Header doc and test comment say the cooldown is measured from the index start; the code measures from the index finish
Round 1's fix (
The header now contradicts both the code and the Expected: both comments say the delay counts from the index finish: indexing takes about 1/(K+1) ≈ 1/4 of wall time, and a 5-minute rebuild idles for 15 minutes. There is no runtime effect, but a maintainer who trusts the header could move the anchor back, and no test would catch it (see Observations). The fix is a two-comment edit. Summary
Panel: contract-security, regression-edges and test-quality all ran on Observations
SAST review not applicableTarget QA performed by Claude Code (claude-opus-5-5), manager + 3-lens panel Dispositions (orchestrator, Step 3B)
Cycle outcome: no critical or major findings remain after round 2. The round-1 major (cooldown anchor) is fixed and verified. Not approved: no QA-agent token is available, and approval is the human reviewer's call. QA-Fix-Commit: 40966a2 Posted by the developer account (QA-agent token unavailable). Review by Claude Opus 5.5 (Anthropic) in Claude Code via qa-panel. |
After a successful re-index the next poll waits max(interval, 3 x index duration), capped at 30 min, counted from when the index finished. A project whose full rebuild takes minutes no longer re-indexes back-to-back under continuous writes; indexing spends at most ~1/4 of wall time. Sub-second indexes keep the existing cadence; failure backoff and busy-skip are unchanged. Logs watcher.cooldown when the delay is extended. Refs DeusData#2835 Signed-off-by: Shane McCarron <shane.mccarron@corvexconnect.com>
40966a2 to
5c54201
Compare
Summary
Pace watcher re-indexes by how long the last successful one took, so a large project whose full rebuild takes minutes no longer re-indexes back-to-back while an agent session keeps writing files.
Upstream issue: DeusData#2835
Today the next poll after a successful re-index is the normal interval (5 s + 1 s per 500 files, max 60 s). Any write changes the dirty signature, and a new file forces a full rebuild, so on a large monorepo indexing becomes nearly continuous. It competes for CPU with interactive queries the whole time.
Change
cbm_watcher_success_delay_ms(interval_ms, index_ms)(src/watcher/watcher.c/.h) is a pure helper that returnsmax(interval, 3 × index duration), capped at 30 minutes. It never returns less than the interval, treats negative inputs as zero, and divides instead of multiplying so it cannot overflow.poll_projecttimes theindex_fncall withnow_ns()and, after a success, schedules the next poll atnow + success_delay. It logswatcher.cooldown(project,delay_ms) only when the delay is extended.INDEX_COOLDOWN_CEILING_MS(30 min), not the existingINDEX_FAIL_CEILING_MS(5 min). The delay counts from when the index starts, so with a 5-minute cap any rebuild longer than about 100 s would restart right after it finishes. That is the behaviour being fixed. The cap bounds how stale an index can get after one very slow run.Acceptance criteria
3 × index duration, and never less than the normal interval.Testing
tests/test_watcher.c: four unit tests for the helper (fast index, scaling, clamp/degenerate, monotonic) and one behavioural test,watcher_success_cooldown_measures_index_issue2835. The behavioural test uses a real git repo and a log sink. An instant index produces no cooldown line. A 1.8 s index produces exactly one, because 3 × 1800 ms exceeds the 5000 ms interval.scripts/test.sh --suites watcher,daemon,daemon_runtime,daemon_application,daemon_frontend,daemon_bootstrap,daemon_ipc,httpd,mcp: 841 passed, 0 failed, 7 skipped.🤖 Generated with Claude Code
https://claude.ai/code/session_01CDDUoWEZMNZ9fLvzp2pPGT