Files
reverse-engineering-anything/scripts/lib/verifier-fixture.d.mts
T
morluto 3f88f69746 feat(verify): allocate kept verifier artifact directories through VerifierFixture (#11091)
The agent-client verifiers keep their lab directory as the run's artifact record (receipt, transcripts, profiles, Evidence) and name it as artifacts in the receipt, so it is not a fixture root that release should remove. VerifierFixture.keepArtifacts allocates such a directory canonically, never removes it, and names it on stderr at allocation so a run that fails before its receipt still reports where its artifacts are. The 11 client verifiers use it, and the verifier-fixture-root baseline shrinks by 11 sites.
2026-11-15 20:19:27 +08:00

67 lines
2.2 KiB
TypeScript

/** An allocated root the fixture owns; `close` removes it. */
export interface VerifierFixtureRoot {
readonly path: string;
close(): Promise<void>;
}
/** A directory the verifier keeps after the run; nothing removes it. */
export interface VerifierArtifactDirectory {
readonly path: string;
readonly kept: true;
}
/**
* One verifier fixture root and every cleanup that must confirm before the
* root may be removed. A failed cleanup retains the root and names it.
*/
export class VerifierFixture {
constructor(root: VerifierFixtureRoot);
/**
* Allocate a `PrivateRuntimeRoot` under `parent` (default: the OS temporary
* directory), or a plain temporary directory with `private: false`.
*/
static open(options?: {
readonly prefix?: string;
readonly parent?: string;
readonly private?: boolean;
}): Promise<VerifierFixture>;
/**
* Allocate a directory a verifier keeps for its artifacts (receipts,
* transcripts, profiles, Evidence). It is never removed; allocation names
* it on stderr.
*/
static keepArtifacts(options?: {
readonly prefix?: string;
readonly parent?: string;
}): Promise<VerifierArtifactDirectory>;
readonly path: string;
readonly released: boolean;
/** Register a cleanup that must confirm before the root may be removed. */
releaseAfter<T extends () => unknown>(cleanup: T): T;
/**
* Keep the root for good: something that may still use it cannot be
* confirmed stopped. Every later release fails with `reason`.
*/
retain(reason: string): void;
/**
* Run pending cleanups in order, then remove the root if all confirmed. A
* failure is an AggregateError whose `cleanupLeases` is `[this fixture]`.
*/
release(): Promise<void>;
}
/**
* Share one cleanup between fixtures that depend on it: a confirmed or
* in-flight attempt is reused; a failed attempt is retried by the next call.
*/
export function onceConfirmed(cleanup: () => unknown): () => Promise<void>;
/**
* Run a verifier and release its fixture, keeping both failures. When the
* fixture is retained, the thrown failure's `cleanupLeases` is `[fixture]`.
*/
export function withVerifierFixture<T>(
fixture: VerifierFixture,
operation: (fixture: VerifierFixture) => T | Promise<T>,
): Promise<T>;