refactor(deadcode): privatize runtime test seams (#108338)

* refactor(sessions): privatize runtime test seams

* refactor(commitments): privatize extraction test seams

* refactor(flows): privatize doctor health seams

* refactor(tasks): privatize registry test seams

* build(commitments): bundle Docker test support

* chore(deadcode): shrink runtime export baseline
This commit is contained in:
Peter Steinberger
2026-07-15 07:27:10 -07:00
committed by GitHub
parent 8d5592548b
commit 3d76a4af92
78 changed files with 679 additions and 220 deletions
+15 -3
View File
@@ -91,12 +91,12 @@ function scheduleDrainSoon(debounceMs: number): void {
}
/** Installs runtime hooks for extraction tests or alternate batch extraction. */
export function configureCommitmentExtractionRuntime(next: CommitmentExtractionRuntime): void {
function configureCommitmentExtractionRuntime(next: CommitmentExtractionRuntime): void {
runtime = next;
}
/** Clears queued work, timers, and injected hooks for isolated tests. */
export function resetCommitmentExtractionRuntimeForTests(): void {
function resetCommitmentExtractionRuntimeForTests(): void {
if (timer) {
clearTimer(timer);
}
@@ -299,7 +299,7 @@ function takeAgentBatch(
}
/** Drains queued extraction work in batches and returns processed item count. */
export async function drainCommitmentExtractionQueue(): Promise<number> {
async function drainCommitmentExtractionQueue(): Promise<number> {
if (draining) {
return 0;
}
@@ -357,3 +357,15 @@ export async function drainCommitmentExtractionQueue(): Promise<number> {
draining = false;
}
}
if (
process.env.VITEST ||
process.env.NODE_ENV === "test" ||
process.env.OPENCLAW_COMMITMENTS_SAFETY_E2E === "1"
) {
(globalThis as Record<PropertyKey, unknown>)[Symbol.for("openclaw.commitmentRuntimeTestApi")] = {
configureCommitmentExtractionRuntime,
drainCommitmentExtractionQueue,
resetCommitmentExtractionRuntimeForTests,
};
}