Add benchmark results and tests for LSP graph builder and staged search

- Introduced a new benchmark results file for performance comparison on 2026-02-09.
- Added a test for LspGraphBuilder to ensure it does not expand nodes at maximum depth.
- Created a test for the staged search pipeline to validate fallback behavior when stage 1 returns empty results.
This commit is contained in:
catlog22
2026-02-09 21:43:13 +08:00
parent 4344e79e68
commit 362f354f1c
25 changed files with 2613 additions and 51 deletions

View File

@@ -12,6 +12,7 @@ import {
type CliSessionResumeStrategy
} from './cli-session-command-builder.js';
import { getCliSessionPolicy } from './cli-session-policy.js';
import { appendCliSessionAudit } from './cli-session-audit.js';
export interface CliSession {
sessionKey: string;
@@ -147,10 +148,29 @@ export class CliSessionManager {
private projectRoot: string;
private emitter = new EventEmitter();
private maxBufferBytes: number;
private idleTimeoutMs: number;
private reaperTimer: NodeJS.Timeout | null = null;
constructor(projectRoot: string) {
this.projectRoot = projectRoot;
this.maxBufferBytes = getCliSessionPolicy().maxBufferBytes;
const policy = getCliSessionPolicy();
this.maxBufferBytes = policy.maxBufferBytes;
this.idleTimeoutMs = policy.idleTimeoutMs;
if (this.idleTimeoutMs > 0) {
this.reaperTimer = setInterval(() => {
const reaped = this.closeIdleSessions(this.idleTimeoutMs);
for (const sessionKey of reaped) {
appendCliSessionAudit({
type: 'session_idle_reaped',
timestamp: nowIso(),
projectRoot: this.projectRoot,
sessionKey,
});
}
}, 60_000);
this.reaperTimer.unref?.();
}
}
listSessions(): CliSession[] {
@@ -354,14 +374,14 @@ export class CliSessionManager {
return () => this.emitter.off('output', handler);
}
closeIdleSessions(idleTimeoutMs: number): number {
if (idleTimeoutMs <= 0) return 0;
closeIdleSessions(idleTimeoutMs: number): string[] {
if (idleTimeoutMs <= 0) return [];
const now = Date.now();
let closed = 0;
const closed: string[] = [];
for (const s of this.sessions.values()) {
if (now - s.lastActivityAt >= idleTimeoutMs) {
this.close(s.sessionKey);
closed += 1;
closed.push(s.sessionKey);
}
}
return closed;