mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-08-28 09:53:36 +00:00
renderDashboard issued three parseAllSessions calls (scan range, plan window,
durable headline). They often share a START and differ only in where they end —
end-of-day vs each caller's own `new Date()` — which the exact-key memo cannot
match, so a warm render paid for the discovery sweep, the cache read and the
parse two or three times over.
withSinglePassParse lets a caller declare the widest range it will ask for. A
later request that is a PURE NARROWING of it is served by slicing that parse
instead of running the pipeline again. Pure narrowing is deliberately strict:
same start, an end that is inside, and the same month shard scope. Both extra
conditions are load-bearing, because a parse's file set is a function of its
range:
- a changed file with `mtimeMs < range.start` is skipped without being parsed,
so an earlier start reads files a later start never sees;
- loadCache reads only the shards monthScopeForRange selects;
- either way the extra files seed seenKeys/seenMsgIds BEFORE the range slice,
and a seeded key suppresses the matching in-range turn in a provider parsed
later — usage the narrower parse would have counted.
Holding start and month scope equal makes both parses see an identical file set,
leaving the range slice as the only difference — the same trade burstReuse
already makes for the mirror-image case (same start, later end).
Independently, correlateCrossProviderPrSessions ran two O(n*m) scans: a
`sessions.filter` per subagent child (now a one-shot agentId index) and a full
`launches.filter` per candidate (now a sorted array plus a windowed scan). Both
preserve the exact match set; launch order was never observable because the
matches collapse into a Map keyed by the sorted ref list.
Warm, 21k-file corpus, isolated cache, median of 5 interleaved:
today 5.12s -> 3.81s (1.34x) 3 parses -> 2
month 5.46s -> 3.41s (1.60x) 2 parses -> 1
today --format json 4.11s -> 3.49s (1.18x, correlation hoist only)
vitest.config gains an explicit exclude so a .claude worktree's stale tests/
copy stops being swept into the run.
Refs #1106
16 lines
787 B
TypeScript
16 lines
787 B
TypeScript
import { defineConfig } from 'vitest/config'
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
// A worktree under .claude/ carries its own tests/ copy. They are stale by
|
|
// definition (another branch's checkout) and are not this run's subject.
|
|
exclude: ['**/node_modules/**', '**/dist/**', '**/.claude/worktrees/**'],
|
|
// Runs once per worker before any test. Scrubs the developer's shell so
|
|
// session-discovery env vars (CLAUDE_CONFIG_DIRS, HOME, XDG_*, every
|
|
// provider-specific *_HOME) don't bleed real local data into fixtures.
|
|
setupFiles: ['./tests/setup/env-isolation.ts'],
|
|
// Real-I/O tests (session parses, sqlite fixtures, worker pools) exceed the
|
|
// 5s default under CI runner load; a hung test still fails at 30s.
|
|
testTimeout: 30_000,
|
|
},
|
|
})
|