The plugin contracts: measure, reporter and runtime plugins, the archive, gate declarations.
@ac-bench/core/plugin
Functions
Classes
Constants
Types
collectConditions(snapshot: ConditionSnapshot): CollectedCondition[]
Groups a run’s case-result and case-execution data by the condition that
produced them, in the order the conditions started.
Two conditions of one measure, or two that declare a case with the same
title, stay two conditions. Data written outside any measured condition is
ignored.
collectedConditionFrame(plugin: MeasurePlugin, condition: CollectedCondition): DataFrame
The frame a reporter renders for one collected condition.
A condition with no case result — one that failed before any case reported —
is an empty table under its heading: none of the measure’s callbacks run, as
a measure owes no conclusion about nothing and may refuse to draw one.
collectedConditionInput(condition: CollectedCondition): {
results: unknown[];
title: string;
}
What a measure’s conditionFrame takes for one collected condition.
conditionFrame(plugin: MeasurePlugin, input: {
results: unknown[];
title: string;
}): DataFrame
The authoritative frame for a whole condition: one row per case result, the
columns the measure derives from the set, then the measure’s own last word.
The single construction path every renderer uses. A live view holding only
some of the rows calls caseRow/deriveFields itself with what it has and
skips the last step, because an unfinished condition has nothing to
conclude.
conditionHeading(condition: Pick<ConditionIdentity, "file" | "runtime" | "titles" | "conditionPath">): string
The heading of a condition on one line: its titles, then where it lives — the
file and the condition’s path in it, and the runtime when it is not the Node
default. Sibling conditions that share their titles differ by the path.
conditionKey(runtime: string, file: string, conditionPath: readonly number[], titles: readonly string[]): string
The cross-run identity of a condition: a JSON tuple, so no title or file name
can imitate another part.
countVerdicts(verdicts: readonly _ReadonlyObjectDeep<{
adjustedPValue: number | null;
degreesOfFreedom: number | null;
dispersion: number | null;
escalatedReplicates: number;
estimate: number | null;
estimator: "paired" | "unpaired" | "single" | null;
executions: number[];
id: string;
interval: {
level: number;
lower: number;
upper: number;
} | null;
kind: "ratio" | "difference" | "bound" | "baseline";
message: string;
metric: {
direction: "lower-is-better" | "higher-is-better";
name: string;
scale: "log" | "linear";
unit: {
scale: number;
symbol: string;
};
};
origin: "config" | "suite" | "cli";
pValue: number | null;
rationale?: string;
reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
runtime: string;
subjects: {
caseTitle: string;
conditionTitles: string[];
file: string;
runtime: string;
}[];
threshold: {
max?: number;
min?: number;
};
verdict: "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "error" | "incomparable";
}, never>[]): string
How many verdicts of each kind, most serious first, as one line.
defaultGateId(declaration: SuiteGateDeclaration | ConfigGateDeclaration): string
The id a declaration gets when it names none: <kind>:<titles>[@<metric>],
e.g. ratio:new/three, ratio:new/three,f64 against several denominators,
bound:fused, difference:a/b, baseline:<subjects> (* for every case).
The id is injective on what a declaration names: a title, a condition
segment, a file or a metric has \ / , @ > # ^ * ! escaped with a backslash,
so those characters only ever act as separators or markers. A reference reads
[file#]segment > … > case; a sibling { case } reads ^case; an object
reference with an empty condition (a case at the root, where a bare title
matches at any depth) reads [file#]>case; an empty list of references reads
!. A string reference and the object form naming the same segments give the
same id, since they name the same cases; any two declarations naming
different cases, metrics or kinds give different ids.
defineMeasurePlugin<TCase, TCondition>(spec: MeasurePluginSpec<TCase, TCondition>): MeasurePlugin
Builds the type-erased MeasurePlugin a MeasureRegistry stores, from
the fully-typed MeasurePluginSpec a measure package writes.
Every erased method re-validates its argument through parseCaseResult/
parseConditionResult before dispatching, rather than casting — a payload
that crossed a process boundary (or, in this slice, was merely grouped by
measure id from a shared event stream) is never trusted without that check.
toJsonCase/toJsonCondition each validate against their own shape rather
than guessing which one a value is from a member it happens to have.
defineReporterPlugin(spec: ReporterPluginSpec): ReporterPlugin
Brands a reporter spec as a ReporterPlugin.
A reporter carries no options of its own: whatever it needs is applied where
the plugin is constructed, so a package with options exports a factory
returning this, and one without exports the result directly.
describeCaseReference(reference: CaseReference): string
How a reference reads in a gate id or a message.
fallbackPlugin(id: string): MeasurePlugin
Plugin used for a measure id no registered plugin declares. A plugin id
typo must not lose a measurement that already cost minutes to produce: the
data is still shown, just without measure-specific formatting.
findConditionScope(scopeId: string | null, lookup: (id: string) => ScopeRecord | undefined): ScopeRecord | null
The nearest scope at or above scopeId that is a measured condition.
A child’s own scopes hang beneath the parent’s unit scope, so an execution is
attributed to its condition by ancestry.
formatThreshold(threshold: GateThreshold): string | null
A threshold as a reader states it: ≤ 1.2, ≥ 0.5, [0.5, 1.2], or null
when the gate only reports.
gateVerdictFrame(verdicts: readonly _ReadonlyObjectDeep<{
adjustedPValue: number | null;
degreesOfFreedom: number | null;
dispersion: number | null;
escalatedReplicates: number;
estimate: number | null;
estimator: "paired" | "unpaired" | "single" | null;
executions: number[];
id: string;
interval: {
level: number;
lower: number;
upper: number;
} | null;
kind: "ratio" | "difference" | "bound" | "baseline";
message: string;
metric: {
direction: "lower-is-better" | "higher-is-better";
name: string;
scale: "log" | "linear";
unit: {
scale: number;
symbol: string;
};
};
origin: "config" | "suite" | "cli";
pValue: number | null;
rationale?: string;
reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
runtime: string;
subjects: {
caseTitle: string;
conditionTitles: string[];
file: string;
runtime: string;
}[];
threshold: {
max?: number;
min?: number;
};
verdict: "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "error" | "incomparable";
}, never>[], options?: {
readonly title?: string | null;
}): DataFrame
The verdicts of a run as one frame every reporter renders the same way: the
gate, its runtime, the verdict, the estimate with its interval and level, the
threshold, the dispersion, the executions per subject and the reason. Rows
keep the order of verdicts.
isBrandedRuntimePlugin(value: unknown): value is BrandedRuntimePlugin
isMeasurePlugin(value: unknown): value is MeasurePlugin
Checks the MEASURE_PLUGIN_TAG brand rather than validating each member’s
shape — a dynamically-loaded module’s default export either went through
defineMeasurePlugin/fallbackAdapter, or it did not.
isReporterPlugin(value: unknown): value is ReporterPlugin
parseMeasureData(value: unknown): {
conditionTitle: string;
kind: "condition-result";
measure: string;
result: unknown;
} | {
arm: "shared" | "isolated";
caseTitle: string;
kind: "case-execution";
measure: string;
replicate: number;
result: unknown;
} | {
caseTitle: string;
kind: "case-result";
measure: string;
result: unknown;
} | {
file: string;
kind: "load-error";
message: string;
} | {
kind: "run-description";
machine: {
architecture: string;
availableParallelism: number;
cpuGovernor: string | null;
cpuModel: string;
kernelRelease: string;
logicalCores: number;
memoryGiB: number;
os: string;
physicalCores: number | null;
};
run: {
argv: string[];
id: string;
mode: string | null;
orderSeed: number;
plan: {
cooldown: boolean;
isolatedRuns: number;
maxReplicates: number;
replicates: number;
retryOnInstability: number;
rounds: number;
};
startedAt: string;
tool: {
name: "@ac-bench/lib";
version: string;
};
};
} | {
kind: "runtime-description";
runtime: {
capabilities: {
allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
cpuTime: boolean;
forcedCollection: boolean;
};
clock: {
readCostMs: number;
resolutionMs: number;
source: "performance.now";
};
crossOriginIsolated: boolean | null;
device: {
model: string;
os: string;
osVersion: string;
} | null;
engine: "v8" | "spidermonkey" | "javascriptcore";
flags: string[];
headless: boolean | null;
id: string;
isolation: "browser" | "process" | "context" | "reload";
kind: "node" | "browser";
product: string;
userAgent: string | null;
version: string;
};
} | {
gate: {
conditionPath: number[];
declaration: {
denominators: string[];
id?: string;
kind: "ratio";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
numerator: string;
rationale?: string;
runtimes?: string[];
} | {
id?: string;
kind: "difference";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
reference: string;
runtimes?: string[];
subject: string;
} | {
id?: string;
kind: "bound";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
runtimes?: string[];
subject: string;
};
file: string;
origin: "suite";
} | {
declaration: {
denominators: (string | {
case: string;
condition: string | ...[];
file?: string;
} | {
case: string;
})[];
id?: string;
kind: "ratio";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
numerator: string | {
case: string;
condition: string | string[];
file?: string;
} | {
case: string;
};
rationale?: string;
runtimes?: string[];
} | {
id?: string;
kind: "difference";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
reference: string | {
case: string;
condition: string | string[];
file?: string;
} | {
case: string;
};
runtimes?: string[];
subject: string | {
case: string;
condition: string | string[];
file?: string;
} | {
case: string;
};
} | {
id?: string;
kind: "bound";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
runtimes?: string[];
subject: string | {
case: string;
condition: string | string[];
file?: string;
} | {
case: string;
};
} | {
id?: string;
kind: "baseline";
maxDispersion?: number;
maxRegression?: number;
metric?: string;
normalizeBy?: string | {
case: string;
condition: string | string[];
file?: string;
} | {
case: string;
};
rationale?: string;
runtimes?: string[];
subjects?: (string | {
case: string;
condition: ... | ...;
file?: ... | ...;
} | {
case: string;
})[];
};
origin: "config" | "cli";
};
kind: "gate-declaration";
} | {
kind: "gate-verdict";
verdict: {
adjustedPValue: number | null;
degreesOfFreedom: number | null;
dispersion: number | null;
escalatedReplicates: number;
estimate: number | null;
estimator: "paired" | "unpaired" | "single" | null;
executions: number[];
id: string;
interval: {
level: number;
lower: number;
upper: number;
} | null;
kind: "ratio" | "difference" | "bound" | "baseline";
message: string;
metric: {
direction: "lower-is-better" | "higher-is-better";
name: string;
scale: "log" | "linear";
unit: {
scale: number;
symbol: string;
};
};
origin: "config" | "suite" | "cli";
pValue: number | null;
rationale?: string;
reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
runtime: string;
subjects: {
caseTitle: string;
conditionTitles: string[];
file: string;
runtime: string;
}[];
threshold: {
max?: number;
min?: number;
};
verdict: "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "error" | "incomparable";
};
} | {
completedUnits: number;
kind: "run-progress";
totalUnits: number;
} | {
cases: {
selected: boolean;
title: string;
}[];
conditionPath: number[];
file: string;
kind: "unit-declaration";
measure: string;
runtime: string;
titles: string[];
}
Validates a data payload that crossed the child/parent boundary.
partitionPlugins(plugins: readonly BenchPlugin[]): {
readonly measures: readonly MeasurePlugin[];
readonly reporters: readonly ReporterPlugin[];
readonly runtimes: readonly BrandedRuntimePlugin[];
}
Sorts a mixed plugin list into the typed lists the programmatic API takes,
preserving each kind’s declaration order.
Runtimes come back as their brand only: @ac-bench/lib’s isRuntimePlugin
narrows them to what it can create.
Throws An entry went through none of defineMeasurePlugin,
defineReporterPlugin and defineRuntimePlugin.
readConditionIdentity(scope: Pick<ScopeRecord, "attributes">): ConditionIdentity | null
The identity a unit scope carries, or null for any other scope.
validateGateDeclaration(declaration: SuiteGateDeclaration | ConfigGateDeclaration): void
Checks what a declaration says before any case is looked at.
Throws On min above max, a non-finite bound, a
ratio bound that is not positive, a ratio without denominator, a
non-positive maxDispersion, an empty id, or a negative or non-finite
maxRegression.
withConditionOrigin(frame: DataFrame, condition: CollectedCondition): DataFrame
A condition’s frame with two trailing columns, runtime and condition (its
heading), so rows of several conditions stay attributable once their tables
are read apart from their titles.
class ArchiveBuilder implements ISink<MeasureData>
A sink that folds a run’s events into a BenchArchive as they arrive.
Each case-execution is reduced to its identity and dropped, and each
case-result to the measure’s JSON form, so memory does not grow with the
samples a run collects.
- new (options: ArchiveBuilderOptions): ArchiveBuilder
- get described(): boolean
Whether a run-description arrived, so ArchiveBuilder.build can
answer.
- build(): BenchArchive
The archive of everything observed so far.
Throws When no run-description was written: an archive nobody
can place is worse than none.
- close(): void
- flush(): void
- settled(): ArchivedCondition[]
Every condition whose scope has ended since the last call, archived as
ArchiveBuilder.build will archive it: a writer that streams the
archive writes each once it settles, so a run that crashes keeps what it
measured.
- write(event: ReportEvent<{
conditionTitle: string;
kind: "condition-result";
measure: string;
result: unknown;
} | {
arm: "shared" | "isolated";
caseTitle: string;
kind: "case-execution";
measure: string;
replicate: number;
result: unknown;
} | {
caseTitle: string;
kind: "case-result";
measure: string;
result: unknown;
} | {
file: string;
kind: "load-error";
message: string;
} | {
kind: "run-description";
machine: {
architecture: string;
availableParallelism: number;
cpuGovernor: string | null;
cpuModel: string;
kernelRelease: string;
logicalCores: number;
memoryGiB: number;
os: string;
physicalCores: number | null;
};
run: {
argv: string[];
id: string;
mode: string | null;
orderSeed: number;
plan: {
cooldown: boolean;
isolatedRuns: number;
maxReplicates: number;
replicates: number;
retryOnInstability: number;
rounds: number;
};
startedAt: string;
tool: {
name: "@ac-bench/lib";
version: string;
};
};
} | {
kind: "runtime-description";
runtime: {
capabilities: {
allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
cpuTime: boolean;
forcedCollection: boolean;
};
clock: {
readCostMs: number;
resolutionMs: number;
source: "performance.now";
};
crossOriginIsolated: boolean | null;
device: {
model: string;
os: string;
osVersion: string;
} | null;
engine: "v8" | "spidermonkey" | "javascriptcore";
flags: string[];
headless: boolean | null;
id: string;
isolation: "browser" | "process" | "context" | "reload";
kind: "node" | "browser";
product: string;
userAgent: string | null;
version: string;
};
} | {
gate: {
conditionPath: number[];
declaration: {
denominators: string[];
id?: string;
kind: "ratio";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
numerator: string;
rationale?: string;
runtimes?: string[];
} | {
id?: string;
kind: "difference";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
reference: string;
runtimes?: string[];
subject: string;
} | {
id?: string;
kind: "bound";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
runtimes?: string[];
subject: string;
};
file: string;
origin: "suite";
} | {
declaration: {
denominators: (string | {
case: string;
condition: ... | ...;
file?: ... | ...;
} | {
case: string;
})[];
id?: string;
kind: "ratio";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
numerator: string | {
case: string;
condition: string | ...[];
file?: string;
} | {
case: string;
};
rationale?: string;
runtimes?: string[];
} | {
id?: string;
kind: "difference";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
reference: string | {
case: string;
condition: string | ...[];
file?: string;
} | {
case: string;
};
runtimes?: string[];
subject: string | {
case: string;
condition: string | ...[];
file?: string;
} | {
case: string;
};
} | {
id?: string;
kind: "bound";
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
runtimes?: string[];
subject: string | {
case: string;
condition: string | ...[];
file?: string;
} | {
case: string;
};
} | {
id?: string;
kind: "baseline";
maxDispersion?: number;
maxRegression?: number;
metric?: string;
normalizeBy?: string | {
case: string;
condition: string | ...[];
file?: string;
} | {
case: string;
};
rationale?: string;
runtimes?: string[];
subjects?: (string | {
case: ...;
condition: ...;
file?: ...;
} | {
case: ...;
})[];
};
origin: "config" | "cli";
};
kind: "gate-declaration";
} | {
kind: "gate-verdict";
verdict: {
adjustedPValue: number | null;
degreesOfFreedom: number | null;
dispersion: number | null;
escalatedReplicates: number;
estimate: number | null;
estimator: "paired" | "unpaired" | "single" | null;
executions: number[];
id: string;
interval: {
level: number;
lower: number;
upper: number;
} | null;
kind: "ratio" | "difference" | "bound" | "baseline";
message: string;
metric: {
direction: "lower-is-better" | "higher-is-better";
name: string;
scale: "log" | "linear";
unit: {
scale: number;
symbol: string;
};
};
origin: "config" | "suite" | "cli";
pValue: number | null;
rationale?: string;
reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
runtime: string;
subjects: {
caseTitle: string;
conditionTitles: string[];
file: string;
runtime: string;
}[];
threshold: {
max?: number;
min?: number;
};
verdict: "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "error" | "incomparable";
};
} | {
completedUnits: number;
kind: "run-progress";
totalUnits: number;
} | {
cases: {
selected: boolean;
title: string;
}[];
conditionPath: number[];
file: string;
kind: "unit-declaration";
measure: string;
runtime: string;
titles: string[];
}>): void
class GateDeclarationError extends Error
A gate declaration that cannot mean anything: contradictory or ill-formed.
- new (declaration: unknown, message: string): GateDeclarationError
- readonly declaration: unknown
class GateReferenceError extends Error
A gate names a case that does not resolve to exactly one: unknown, ambiguous
between an inherited and an own case, or a duplicate gate id in one fork
unit.
- new (declaration: LocatedGateDeclaration, reference: unknown, matches: readonly _ReadonlyObjectDeep<{
caseTitle: string;
conditionTitles: string[];
file: string;
runtime: string;
}, never>[], message: string): GateReferenceError
- readonly declaration: LocatedGateDeclaration
- readonly matches: readonly _ReadonlyObjectDeep<{
caseTitle: string;
conditionTitles: string[];
file: string;
runtime: string;
}, never>[]
Zero or more than one, as the message says.
- readonly reference: unknown
What was named: a title, a CaseReference or a gate id.
class MeasureRegistry
Registered MeasurePlugins, keyed by measure id. Mutates as plugins are
registered, so this is a class rather than a factory function.
- new (): MeasureRegistry
- has(id: string): boolean
- ids(): readonly string[]
- register(plugin: MeasurePlugin): void
- resolve(id: string): MeasurePlugin
Never throws. Unknown ids resolve to a generic fallback.
class MeasureResultValidationError extends Error
Thrown by an plugin’s parseCaseResult/parseConditionResult when a value
that crossed the process/plugin boundary does not match the measure’s
expected shape — e.g. a case result from a different measure.
- new (measureId: string, message: string): MeasureResultValidationError
- readonly measureId: string
const archivedCaseSchema: ZodMiniObject<{
executions: ZodMiniArray<ZodMiniObject<{
arm: ZodMiniEnum<{
isolated: "isolated";
shared: "shared";
}>;
attempt: ZodMiniInt;
disposition: ZodMiniEnum<{
discarded: "discarded";
kept: "kept";
}>;
observations: ZodMiniRecord<ZodMiniString<string>, ZodMiniObject<{
dispersion: ZodMiniNullable<ZodMiniNumber<number>>;
samples: ZodMiniNumber<number>;
value: ZodMiniNumber<number>;
variance: ZodMiniNumber<number>;
}, $strip>>;
processKey: ZodMiniNullable<ZodMiniString<string>>;
replicate: ZodMiniInt;
}, $strip>>;
result: ZodMiniUnknown;
selected: ZodMiniBoolean<boolean>;
status: ZodMiniEnum<{
failed: "failed";
measured: "measured";
not-run: "not-run";
unsupported: "unsupported";
}>;
title: ZodMiniString<string>;
}, $strip>
const archivedConditionSchema: ZodMiniObject<{
cases: ZodMiniArray<ZodMiniObject<{
executions: ZodMiniArray<ZodMiniObject<{
arm: ZodMiniEnum<{
isolated: "isolated";
shared: "shared";
}>;
attempt: ZodMiniInt;
disposition: ZodMiniEnum<{
discarded: "discarded";
kept: "kept";
}>;
observations: ZodMiniRecord<ZodMiniString<string>, ZodMiniObject<{
dispersion: ...;
samples: ...;
value: ...;
variance: ...;
}, $strip>>;
processKey: ZodMiniNullable<ZodMiniString<string>>;
replicate: ZodMiniInt;
}, $strip>>;
result: ZodMiniUnknown;
selected: ZodMiniBoolean<boolean>;
status: ZodMiniEnum<{
failed: "failed";
measured: "measured";
not-run: "not-run";
unsupported: "unsupported";
}>;
title: ZodMiniString<string>;
}, $strip>>;
conditionPath: ZodMiniArray<ZodMiniInt>;
file: ZodMiniString<string>;
key: ZodMiniString<string>;
measure: ZodMiniString<string>;
metrics: ZodMiniArray<ZodMiniObject<{
direction: ZodMiniEnum<{
higher-is-better: "higher-is-better";
lower-is-better: "lower-is-better";
}>;
name: ZodMiniString<string>;
scale: ZodMiniEnum<{
linear: "linear";
log: "log";
}>;
unit: ZodMiniObject<{
scale: ZodMiniNumber<number>;
symbol: ZodMiniString<string>;
}, $strip>;
}, $strip>>;
runtime: ZodMiniString<string>;
status: ZodMiniEnum<{
cancelled: "cancelled";
failed: "failed";
ok: "ok";
skipped: "skipped";
}>;
titles: ZodMiniArray<ZodMiniString<string>>;
}, $strip>
const archivedExecutionSchema: ZodMiniObject<{
arm: ZodMiniEnum<{
isolated: "isolated";
shared: "shared";
}>;
attempt: ZodMiniInt;
disposition: ZodMiniEnum<{
discarded: "discarded";
kept: "kept";
}>;
observations: ZodMiniRecord<ZodMiniString<string>, ZodMiniObject<{
dispersion: ZodMiniNullable<ZodMiniNumber<number>>;
samples: ZodMiniNumber<number>;
value: ZodMiniNumber<number>;
variance: ZodMiniNumber<number>;
}, $strip>>;
processKey: ZodMiniNullable<ZodMiniString<string>>;
replicate: ZodMiniInt;
}, $strip>
One process’s measurement of one case: the evidence, not the pooled answer.
const ATTR_BENCH_ATTEMPT: "bench.attempt"
On the parent’s attempt scope, present when the run retries unstable
machines.
const ATTR_BENCH_CASE: "benchCase"
On a case scope: the case’s title. Set by the child’s runner.
const ATTR_BENCH_CASE_INDEX: "benchCaseIndex"
On a case scope: the case’s declaration position in its fork unit.
const ATTR_BENCH_CONDITION_PATH: "benchConditionPath"
The condition’s position in its file’s tree: one index per level.
const ATTR_BENCH_FILE: "benchFile"
The bench file, relative to the run’s working directory, /-separated.
const ATTR_BENCH_RUNTIME: "benchRuntime"
The runtime a condition was measured in; absent means the Node default.
const ATTR_BENCH_TITLES: "benchTitles"
The condition’s title segments; the scope title joins them with " > ".
const ATTR_BENCH_UNSUPPORTED: "benchUnsupported"
On a condition scope the parent skipped without forking: why its measure does
not run in the condition’s runtime. Its cases are archived "unsupported".
const ATTR_CONDITION_MEASURE: "conditionMeasure"
The measure that owns the condition’s cases.
const BENCH_ARCHIVE_FORMAT: "ac-bench-archive"
const BENCH_ARCHIVE_VERSION: 1
const benchArchiveSchema: ZodMiniObject<{
conditions: ZodMiniArray<ZodMiniObject<{
cases: ZodMiniArray<ZodMiniObject<{
executions: ZodMiniArray<ZodMiniObject<{
arm: ...;
attempt: ...;
disposition: ...;
observations: ...;
processKey: ...;
replicate: ...;
}, $strip>>;
result: ZodMiniUnknown;
selected: ZodMiniBoolean<boolean>;
status: ZodMiniEnum<{
failed: "failed";
measured: "measured";
not-run: "not-run";
unsupported: "unsupported";
}>;
title: ZodMiniString<string>;
}, $strip>>;
conditionPath: ZodMiniArray<ZodMiniInt>;
file: ZodMiniString<string>;
key: ZodMiniString<string>;
measure: ZodMiniString<string>;
metrics: ZodMiniArray<ZodMiniObject<{
direction: ZodMiniEnum<{
higher-is-better: "higher-is-better";
lower-is-better: "lower-is-better";
}>;
name: ZodMiniString<string>;
scale: ZodMiniEnum<{
linear: "linear";
log: "log";
}>;
unit: ZodMiniObject<{
scale: ZodMiniNumber<...>;
symbol: ZodMiniString<...>;
}, $strip>;
}, $strip>>;
runtime: ZodMiniString<string>;
status: ZodMiniEnum<{
cancelled: "cancelled";
failed: "failed";
ok: "ok";
skipped: "skipped";
}>;
titles: ZodMiniArray<ZodMiniString<string>>;
}, $strip>>;
diagnostics: ZodMiniArray<ZodMiniObject<{
attributes: ZodMiniOptional<ZodMiniRecord<ZodMiniString<string>, ZodMiniUnknown>>;
code: ZodMiniOptional<ZodMiniString<string>>;
message: ZodMiniString<string>;
severity: ZodMiniEnum<{
error: "error";
info: "info";
warning: "warning";
}>;
source: ZodMiniOptional<ZodMiniType<SourceLocation, unknown, $ZodTypeInternals<SourceLocation, unknown>>>;
}, $strip>>;
format: ZodMiniLiteral<"ac-bench-archive">;
gates: ZodMiniArray<ZodMiniDiscriminatedUnion<[ZodMiniObject<{
conditionPath: ZodMiniArray<ZodMiniInt>;
declaration: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
denominators: ...;
id: ...;
kind: ...;
max: ...;
maxDispersion: ...;
metric: ...;
min: ...;
numerator: ...;
rationale: ...;
runtimes: ...;
}, $strip>, ZodMiniObject<{
id: ...;
kind: ...;
max: ...;
maxDispersion: ...;
metric: ...;
min: ...;
rationale: ...;
reference: ...;
runtimes: ...;
subject: ...;
}, $strip>, ZodMiniObject<{
id: ...;
kind: ...;
max: ...;
maxDispersion: ...;
metric: ...;
min: ...;
rationale: ...;
runtimes: ...;
subject: ...;
}, $strip>], "kind">;
file: ZodMiniString<string>;
origin: ZodMiniLiteral<"suite">;
}, $strip>, ZodMiniObject<{
declaration: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
denominators: ...;
id: ...;
kind: ...;
max: ...;
maxDispersion: ...;
metric: ...;
min: ...;
numerator: ...;
rationale: ...;
runtimes: ...;
}, $strip>, ZodMiniObject<{
id: ...;
kind: ...;
max: ...;
maxDispersion: ...;
metric: ...;
min: ...;
rationale: ...;
reference: ...;
runtimes: ...;
subject: ...;
}, $strip>, ZodMiniObject<{
id: ...;
kind: ...;
max: ...;
maxDispersion: ...;
metric: ...;
min: ...;
rationale: ...;
runtimes: ...;
subject: ...;
}, $strip>, ZodMiniObject<{
id: ...;
kind: ...;
maxDispersion: ...;
maxRegression: ...;
metric: ...;
normalizeBy: ...;
rationale: ...;
runtimes: ...;
subjects: ...;
}, $strip>], "kind">;
origin: ZodMiniEnum<{
cli: "cli";
config: "config";
}>;
}, $strip>], "origin">>;
machine: ZodMiniObject<{
architecture: ZodMiniString<string>;
availableParallelism: ZodMiniInt;
cpuGovernor: ZodMiniNullable<ZodMiniString<string>>;
cpuModel: ZodMiniString<string>;
kernelRelease: ZodMiniString<string>;
logicalCores: ZodMiniInt;
memoryGiB: ZodMiniInt;
os: ZodMiniString<string>;
physicalCores: ZodMiniNullable<ZodMiniInt>;
}, $strip>;
run: ZodMiniObject<{
argv: ZodMiniArray<ZodMiniString<string>>;
endedAt: ZodMiniISODateTime;
id: ZodMiniString<string>;
mode: ZodMiniNullable<ZodMiniString<string>>;
orderSeed: ZodMiniInt;
plan: ZodMiniObject<{
cooldown: ZodMiniBoolean<boolean>;
isolatedRuns: ZodMiniInt;
maxReplicates: ZodMiniInt;
replicates: ZodMiniInt;
retryOnInstability: ZodMiniInt;
rounds: ZodMiniInt;
}, $strip>;
startedAt: ZodMiniISODateTime;
tool: ZodMiniObject<{
name: ZodMiniLiteral<"@ac-bench/lib">;
version: ZodMiniString<string>;
}, $strip>;
}, $strip>;
runtimes: ZodMiniArray<ZodMiniObject<{
capabilities: ZodMiniObject<{
allocationCounter: ZodMiniNullable<ZodMiniEnum<{
browser-heap-growth: "browser-heap-growth";
gc-profiler: "gc-profiler";
heap-growth: "heap-growth";
v8-total-allocated: "v8-total-allocated";
}>>;
cpuTime: ZodMiniBoolean<boolean>;
forcedCollection: ZodMiniBoolean<boolean>;
}, $strip>;
clock: ZodMiniObject<{
readCostMs: ZodMiniNumber<number>;
resolutionMs: ZodMiniNumber<number>;
source: ZodMiniLiteral<"performance.now">;
}, $strip>;
crossOriginIsolated: ZodMiniNullable<ZodMiniBoolean<boolean>>;
device: ZodMiniNullable<ZodMiniObject<{
model: ZodMiniString<string>;
os: ZodMiniString<string>;
osVersion: ZodMiniString<string>;
}, $strip>>;
engine: ZodMiniEnum<{
javascriptcore: "javascriptcore";
spidermonkey: "spidermonkey";
v8: "v8";
}>;
flags: ZodMiniArray<ZodMiniString<string>>;
headless: ZodMiniNullable<ZodMiniBoolean<boolean>>;
id: ZodMiniString<string>;
isolation: ZodMiniEnum<{
browser: "browser";
context: "context";
process: "process";
reload: "reload";
}>;
kind: ZodMiniEnum<{
browser: "browser";
node: "node";
}>;
product: ZodMiniString<string>;
userAgent: ZodMiniNullable<ZodMiniString<string>>;
version: ZodMiniString<string>;
}, $strip>>;
verdicts: ZodMiniArray<ZodMiniObject<{
adjustedPValue: ZodMiniNullable<ZodMiniNumber<number>>;
degreesOfFreedom: ZodMiniNullable<ZodMiniNumber<number>>;
dispersion: ZodMiniNullable<ZodMiniNumber<number>>;
escalatedReplicates: ZodMiniInt;
estimate: ZodMiniNullable<ZodMiniNumber<number>>;
estimator: ZodMiniNullable<ZodMiniEnum<{
paired: "paired";
single: "single";
unpaired: "unpaired";
}>>;
executions: ZodMiniArray<ZodMiniInt>;
id: ZodMiniString<string>;
interval: ZodMiniNullable<ZodMiniObject<{
level: ZodMiniNumber<number>;
lower: ZodMiniNumber<number>;
upper: ZodMiniNumber<number>;
}, $strip>>;
kind: ZodMiniEnum<{
baseline: "baseline";
bound: "bound";
difference: "difference";
ratio: "ratio";
}>;
message: ZodMiniString<string>;
metric: ZodMiniObject<{
direction: ZodMiniEnum<{
higher-is-better: "higher-is-better";
lower-is-better: "lower-is-better";
}>;
name: ZodMiniString<string>;
scale: ZodMiniEnum<{
linear: "linear";
log: "log";
}>;
unit: ZodMiniObject<{
scale: ZodMiniNumber<number>;
symbol: ZodMiniString<string>;
}, $strip>;
}, $strip>;
origin: ZodMiniEnum<{
cli: "cli";
config: "config";
suite: "suite";
}>;
pValue: ZodMiniNullable<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
reason: ZodMiniEnum<{
baseline-case-missing: "baseline-case-missing";
baseline-environment-mismatch: "baseline-environment-mismatch";
case-failed: "case-failed";
case-filtered: "case-filtered";
decided: "decided";
dispersion-exceeds-limit: "dispersion-exceeds-limit";
interval-contains-threshold: "interval-contains-threshold";
metric-unavailable: "metric-unavailable";
multiplicity: "multiplicity";
no-threshold: "no-threshold";
non-positive-value: "non-positive-value";
runtime-unavailable: "runtime-unavailable";
runtime-unsupported: "runtime-unsupported";
too-few-executions: "too-few-executions";
}>;
runtime: ZodMiniString<string>;
subjects: ZodMiniArray<ZodMiniObject<{
caseTitle: ZodMiniString<string>;
conditionTitles: ZodMiniArray<ZodMiniString<string>>;
file: ZodMiniString<string>;
runtime: ZodMiniString<string>;
}, $strip>>;
threshold: ZodMiniObject<{
max: ZodMiniOptional<ZodMiniNumber<number>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
}, $strip>;
verdict: ZodMiniEnum<{
error: "error";
fail: "fail";
incomparable: "incomparable";
inconclusive: "inconclusive";
not-applicable: "not-applicable";
pass: "pass";
reported: "reported";
skipped: "skipped";
}>;
}, $strip>>;
version: ZodMiniLiteral<1>;
}, $strip>
Validates a document read back as a BenchArchive: offline evaluation
and baselines parse with it rather than trusting a file.
const caseKeySchema: ZodMiniObject<{
caseTitle: ZodMiniString<string>;
conditionTitles: ZodMiniArray<ZodMiniString<string>>;
file: ZodMiniString<string>;
runtime: ZodMiniString<string>;
}, $strip>
One case, wherever it ran.
const caseReferenceSchema: ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniObject<{
case: ZodMiniString<string>;
condition: ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniArray<ZodMiniString<string>>]>;
file: ZodMiniOptional<ZodMiniString<string>>;
}, $strip>, ZodMiniObject<{
case: ZodMiniString<string>;
}, $strip>]>
A case named from outside its suite. Every segment is a glob
(@ac-kit/format-glob): a string is "condition > … > case", split on " > "; the object form names titles that contain it; { case } alone names a
case of the same fork unit as the gate’s first subject.
const childEnvironmentSchema: ZodMiniObject<{
capabilities: ZodMiniObject<{
allocationCounter: ZodMiniNullable<ZodMiniEnum<{
browser-heap-growth: "browser-heap-growth";
gc-profiler: "gc-profiler";
heap-growth: "heap-growth";
v8-total-allocated: "v8-total-allocated";
}>>;
cpuTime: ZodMiniBoolean<boolean>;
forcedCollection: ZodMiniBoolean<boolean>;
}, $strip>;
clock: ZodMiniObject<{
readCostMs: ZodMiniNumber<number>;
resolutionMs: ZodMiniNumber<number>;
source: ZodMiniLiteral<"performance.now">;
}, $strip>;
crossOriginIsolated: ZodMiniNullable<ZodMiniBoolean<boolean>>;
engineVersion: ZodMiniString<string>;
userAgent: ZodMiniNullable<ZodMiniString<string>>;
}, $strip>
The half of a RuntimeDescription only a running child can measure:
what its hello carries.
const clockDescriptionSchema: ZodMiniObject<{
readCostMs: ZodMiniNumber<number>;
resolutionMs: ZodMiniNumber<number>;
source: ZodMiniLiteral<"performance.now">;
}, $strip>
const configGateDeclarationSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
denominators: ZodMiniArray<ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniObject<{
case: ZodMiniString<string>;
condition: ZodMiniUnion<readonly [..., ...]>;
file: ZodMiniOptional<ZodMiniString<...>>;
}, $strip>, ZodMiniObject<{
case: ZodMiniString<string>;
}, $strip>]>>;
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"ratio">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
numerator: ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniObject<{
case: ZodMiniString<string>;
condition: ZodMiniUnion<readonly [ZodMiniString<...>, ZodMiniArray<...>]>;
file: ZodMiniOptional<ZodMiniString<string>>;
}, $strip>, ZodMiniObject<{
case: ZodMiniString<string>;
}, $strip>]>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"difference">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
reference: ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniObject<{
case: ZodMiniString<string>;
condition: ZodMiniUnion<readonly [ZodMiniString<...>, ZodMiniArray<...>]>;
file: ZodMiniOptional<ZodMiniString<string>>;
}, $strip>, ZodMiniObject<{
case: ZodMiniString<string>;
}, $strip>]>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
subject: ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniObject<{
case: ZodMiniString<string>;
condition: ZodMiniUnion<readonly [ZodMiniString<...>, ZodMiniArray<...>]>;
file: ZodMiniOptional<ZodMiniString<string>>;
}, $strip>, ZodMiniObject<{
case: ZodMiniString<string>;
}, $strip>]>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"bound">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
subject: ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniObject<{
case: ZodMiniString<string>;
condition: ZodMiniUnion<readonly [ZodMiniString<...>, ZodMiniArray<...>]>;
file: ZodMiniOptional<ZodMiniString<string>>;
}, $strip>, ZodMiniObject<{
case: ZodMiniString<string>;
}, $strip>]>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"baseline">;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
maxRegression: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
normalizeBy: ZodMiniOptional<ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniObject<{
case: ZodMiniString<string>;
condition: ZodMiniUnion<readonly [..., ...]>;
file: ZodMiniOptional<ZodMiniString<...>>;
}, $strip>, ZodMiniObject<{
case: ZodMiniString<string>;
}, $strip>]>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
subjects: ZodMiniOptional<ZodMiniArray<ZodMiniUnion<readonly [ZodMiniString<string>, ZodMiniObject<{
case: ZodMiniString<...>;
condition: ZodMiniUnion<...>;
file: ZodMiniOptional<...>;
}, $strip>, ZodMiniObject<{
case: ZodMiniString<...>;
}, $strip>]>>>;
}, $strip>], "kind">
const GATE_VERDICT_FIELDS: readonly FieldDescriptor[]
const gateDeclarationDataSchema: ZodMiniObject<{
gate: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
conditionPath: ZodMiniArray<ZodMiniInt>;
declaration: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
denominators: ZodMiniArray<...>;
id: ZodMiniOptional<...>;
kind: ZodMiniLiteral<...>;
max: ZodMiniOptional<...>;
maxDispersion: ZodMiniOptional<...>;
metric: ZodMiniOptional<...>;
min: ZodMiniOptional<...>;
numerator: ZodMiniString<...>;
rationale: ZodMiniOptional<...>;
runtimes: ZodMiniOptional<...>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<...>;
kind: ZodMiniLiteral<...>;
max: ZodMiniOptional<...>;
maxDispersion: ZodMiniOptional<...>;
metric: ZodMiniOptional<...>;
min: ZodMiniOptional<...>;
rationale: ZodMiniOptional<...>;
reference: ZodMiniString<...>;
runtimes: ZodMiniOptional<...>;
subject: ZodMiniString<...>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<...>;
kind: ZodMiniLiteral<...>;
max: ZodMiniOptional<...>;
maxDispersion: ZodMiniOptional<...>;
metric: ZodMiniOptional<...>;
min: ZodMiniOptional<...>;
rationale: ZodMiniOptional<...>;
runtimes: ZodMiniOptional<...>;
subject: ZodMiniString<...>;
}, $strip>], "kind">;
file: ZodMiniString<string>;
origin: ZodMiniLiteral<"suite">;
}, $strip>, ZodMiniObject<{
declaration: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
denominators: ZodMiniArray<...>;
id: ZodMiniOptional<...>;
kind: ZodMiniLiteral<...>;
max: ZodMiniOptional<...>;
maxDispersion: ZodMiniOptional<...>;
metric: ZodMiniOptional<...>;
min: ZodMiniOptional<...>;
numerator: ZodMiniUnion<...>;
rationale: ZodMiniOptional<...>;
runtimes: ZodMiniOptional<...>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<...>;
kind: ZodMiniLiteral<...>;
max: ZodMiniOptional<...>;
maxDispersion: ZodMiniOptional<...>;
metric: ZodMiniOptional<...>;
min: ZodMiniOptional<...>;
rationale: ZodMiniOptional<...>;
reference: ZodMiniUnion<...>;
runtimes: ZodMiniOptional<...>;
subject: ZodMiniUnion<...>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<...>;
kind: ZodMiniLiteral<...>;
max: ZodMiniOptional<...>;
maxDispersion: ZodMiniOptional<...>;
metric: ZodMiniOptional<...>;
min: ZodMiniOptional<...>;
rationale: ZodMiniOptional<...>;
runtimes: ZodMiniOptional<...>;
subject: ZodMiniUnion<...>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<...>;
kind: ZodMiniLiteral<...>;
maxDispersion: ZodMiniOptional<...>;
maxRegression: ZodMiniOptional<...>;
metric: ZodMiniOptional<...>;
normalizeBy: ZodMiniOptional<...>;
rationale: ZodMiniOptional<...>;
runtimes: ZodMiniOptional<...>;
subjects: ZodMiniOptional<...>;
}, $strip>], "kind">;
origin: ZodMiniEnum<{
cli: "cli";
config: "config";
}>;
}, $strip>], "origin">;
kind: ZodMiniLiteral<"gate-declaration">;
}, $strip>
Emitted by the parent once per gate a bench file declares, when the file’s
conditions are discovered, so a reporter can keep every gate the run knew.
const gateMetricDescriptorSchema: ZodMiniObject<{
direction: ZodMiniEnum<{
higher-is-better: "higher-is-better";
lower-is-better: "lower-is-better";
}>;
name: ZodMiniString<string>;
scale: ZodMiniEnum<{
linear: "linear";
log: "log";
}>;
unit: ZodMiniObject<{
scale: ZodMiniNumber<number>;
symbol: ZodMiniString<string>;
}, $strip>;
}, $strip>
What a gate needs to know about a metric without reading a result.
const gateMetricScaleSchema: ZodMiniEnum<{
linear: "linear";
log: "log";
}>
"log" — positive, multiplicative noise: durations. Ratios are taken in
logs.
"linear" — may be zero; additive: bytes, counts. Ratios are refused.
const gateObservationSchema: ZodMiniObject<{
dispersion: ZodMiniNullable<ZodMiniNumber<number>>;
samples: ZodMiniNumber<number>;
value: ZodMiniNumber<number>;
variance: ZodMiniNumber<number>;
}, $strip>
What one execution says about one metric of one case: a value, the variance
of that value, the dispersion of the samples behind it.
const gateReasonSchema: ZodMiniEnum<{
baseline-case-missing: "baseline-case-missing";
baseline-environment-mismatch: "baseline-environment-mismatch";
case-failed: "case-failed";
case-filtered: "case-filtered";
decided: "decided";
dispersion-exceeds-limit: "dispersion-exceeds-limit";
interval-contains-threshold: "interval-contains-threshold";
metric-unavailable: "metric-unavailable";
multiplicity: "multiplicity";
no-threshold: "no-threshold";
non-positive-value: "non-positive-value";
runtime-unavailable: "runtime-unavailable";
runtime-unsupported: "runtime-unsupported";
too-few-executions: "too-few-executions";
}>
const gateSettingsSchema: ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
}, $strip>
const gateThresholdSchema: ZodMiniObject<{
max: ZodMiniOptional<ZodMiniNumber<number>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
}, $strip>
Bounds on the gated value. Neither bound: the gate only reports.
const gateVerdictDataSchema: ZodMiniObject<{
kind: ZodMiniLiteral<"gate-verdict">;
verdict: ZodMiniObject<{
adjustedPValue: ZodMiniNullable<ZodMiniNumber<number>>;
degreesOfFreedom: ZodMiniNullable<ZodMiniNumber<number>>;
dispersion: ZodMiniNullable<ZodMiniNumber<number>>;
escalatedReplicates: ZodMiniInt;
estimate: ZodMiniNullable<ZodMiniNumber<number>>;
estimator: ZodMiniNullable<ZodMiniEnum<{
paired: "paired";
single: "single";
unpaired: "unpaired";
}>>;
executions: ZodMiniArray<ZodMiniInt>;
id: ZodMiniString<string>;
interval: ZodMiniNullable<ZodMiniObject<{
level: ZodMiniNumber<number>;
lower: ZodMiniNumber<number>;
upper: ZodMiniNumber<number>;
}, $strip>>;
kind: ZodMiniEnum<{
baseline: "baseline";
bound: "bound";
difference: "difference";
ratio: "ratio";
}>;
message: ZodMiniString<string>;
metric: ZodMiniObject<{
direction: ZodMiniEnum<{
higher-is-better: "higher-is-better";
lower-is-better: "lower-is-better";
}>;
name: ZodMiniString<string>;
scale: ZodMiniEnum<{
linear: "linear";
log: "log";
}>;
unit: ZodMiniObject<{
scale: ZodMiniNumber<number>;
symbol: ZodMiniString<string>;
}, $strip>;
}, $strip>;
origin: ZodMiniEnum<{
cli: "cli";
config: "config";
suite: "suite";
}>;
pValue: ZodMiniNullable<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
reason: ZodMiniEnum<{
baseline-case-missing: "baseline-case-missing";
baseline-environment-mismatch: "baseline-environment-mismatch";
case-failed: "case-failed";
case-filtered: "case-filtered";
decided: "decided";
dispersion-exceeds-limit: "dispersion-exceeds-limit";
interval-contains-threshold: "interval-contains-threshold";
metric-unavailable: "metric-unavailable";
multiplicity: "multiplicity";
no-threshold: "no-threshold";
non-positive-value: "non-positive-value";
runtime-unavailable: "runtime-unavailable";
runtime-unsupported: "runtime-unsupported";
too-few-executions: "too-few-executions";
}>;
runtime: ZodMiniString<string>;
subjects: ZodMiniArray<ZodMiniObject<{
caseTitle: ZodMiniString<string>;
conditionTitles: ZodMiniArray<ZodMiniString<string>>;
file: ZodMiniString<string>;
runtime: ZodMiniString<string>;
}, $strip>>;
threshold: ZodMiniObject<{
max: ZodMiniOptional<ZodMiniNumber<number>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
}, $strip>;
verdict: ZodMiniEnum<{
error: "error";
fail: "fail";
incomparable: "incomparable";
inconclusive: "inconclusive";
not-applicable: "not-applicable";
pass: "pass";
reported: "reported";
skipped: "skipped";
}>;
}, $strip>;
}, $strip>
Emitted by the parent once the whole family of gates is decided: Holm needs
every hypothesis of the run, so verdicts come after every condition closed.
const gateVerdictKindSchema: ZodMiniEnum<{
error: "error";
fail: "fail";
incomparable: "incomparable";
inconclusive: "inconclusive";
not-applicable: "not-applicable";
pass: "pass";
reported: "reported";
skipped: "skipped";
}>
const gateVerdictSchema: ZodMiniObject<{
adjustedPValue: ZodMiniNullable<ZodMiniNumber<number>>;
degreesOfFreedom: ZodMiniNullable<ZodMiniNumber<number>>;
dispersion: ZodMiniNullable<ZodMiniNumber<number>>;
escalatedReplicates: ZodMiniInt;
estimate: ZodMiniNullable<ZodMiniNumber<number>>;
estimator: ZodMiniNullable<ZodMiniEnum<{
paired: "paired";
single: "single";
unpaired: "unpaired";
}>>;
executions: ZodMiniArray<ZodMiniInt>;
id: ZodMiniString<string>;
interval: ZodMiniNullable<ZodMiniObject<{
level: ZodMiniNumber<number>;
lower: ZodMiniNumber<number>;
upper: ZodMiniNumber<number>;
}, $strip>>;
kind: ZodMiniEnum<{
baseline: "baseline";
bound: "bound";
difference: "difference";
ratio: "ratio";
}>;
message: ZodMiniString<string>;
metric: ZodMiniObject<{
direction: ZodMiniEnum<{
higher-is-better: "higher-is-better";
lower-is-better: "lower-is-better";
}>;
name: ZodMiniString<string>;
scale: ZodMiniEnum<{
linear: "linear";
log: "log";
}>;
unit: ZodMiniObject<{
scale: ZodMiniNumber<number>;
symbol: ZodMiniString<string>;
}, $strip>;
}, $strip>;
origin: ZodMiniEnum<{
cli: "cli";
config: "config";
suite: "suite";
}>;
pValue: ZodMiniNullable<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
reason: ZodMiniEnum<{
baseline-case-missing: "baseline-case-missing";
baseline-environment-mismatch: "baseline-environment-mismatch";
case-failed: "case-failed";
case-filtered: "case-filtered";
decided: "decided";
dispersion-exceeds-limit: "dispersion-exceeds-limit";
interval-contains-threshold: "interval-contains-threshold";
metric-unavailable: "metric-unavailable";
multiplicity: "multiplicity";
no-threshold: "no-threshold";
non-positive-value: "non-positive-value";
runtime-unavailable: "runtime-unavailable";
runtime-unsupported: "runtime-unsupported";
too-few-executions: "too-few-executions";
}>;
runtime: ZodMiniString<string>;
subjects: ZodMiniArray<ZodMiniObject<{
caseTitle: ZodMiniString<string>;
conditionTitles: ZodMiniArray<ZodMiniString<string>>;
file: ZodMiniString<string>;
runtime: ZodMiniString<string>;
}, $strip>>;
threshold: ZodMiniObject<{
max: ZodMiniOptional<ZodMiniNumber<number>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
}, $strip>;
verdict: ZodMiniEnum<{
error: "error";
fail: "fail";
incomparable: "incomparable";
inconclusive: "inconclusive";
not-applicable: "not-applicable";
pass: "pass";
reported: "reported";
skipped: "skipped";
}>;
}, $strip>
const loadErrorDataSchema: ZodMiniObject<{
file: ZodMiniString<string>;
kind: ZodMiniLiteral<"load-error">;
message: ZodMiniString<string>;
}, $strip>
const locatedGateDeclarationSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
conditionPath: ZodMiniArray<ZodMiniInt>;
declaration: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
denominators: ZodMiniArray<ZodMiniString<string>>;
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"ratio">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
numerator: ZodMiniString<string>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<...>>>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"difference">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
reference: ZodMiniString<string>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<...>>>;
subject: ZodMiniString<string>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"bound">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<...>>>;
subject: ZodMiniString<string>;
}, $strip>], "kind">;
file: ZodMiniString<string>;
origin: ZodMiniLiteral<"suite">;
}, $strip>, ZodMiniObject<{
declaration: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
denominators: ZodMiniArray<ZodMiniUnion<readonly [..., ..., ...]>>;
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"ratio">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
numerator: ZodMiniUnion<readonly [ZodMiniString<...>, ZodMiniObject<..., ...>, ZodMiniObject<..., ...>]>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<...>>>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"difference">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
reference: ZodMiniUnion<readonly [ZodMiniString<...>, ZodMiniObject<..., ...>, ZodMiniObject<..., ...>]>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<...>>>;
subject: ZodMiniUnion<readonly [ZodMiniString<...>, ZodMiniObject<..., ...>, ZodMiniObject<..., ...>]>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"bound">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<...>>>;
subject: ZodMiniUnion<readonly [ZodMiniString<...>, ZodMiniObject<..., ...>, ZodMiniObject<..., ...>]>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"baseline">;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
maxRegression: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
normalizeBy: ZodMiniOptional<ZodMiniUnion<readonly [..., ..., ...]>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<...>>>;
subjects: ZodMiniOptional<ZodMiniArray<ZodMiniUnion<...>>>;
}, $strip>], "kind">;
origin: ZodMiniEnum<{
cli: "cli";
config: "config";
}>;
}, $strip>], "origin">
A declaration and where it came from.
const machineFingerprintSchema: ZodMiniObject<{
architecture: ZodMiniString<string>;
availableParallelism: ZodMiniInt;
cpuGovernor: ZodMiniNullable<ZodMiniString<string>>;
cpuModel: ZodMiniString<string>;
kernelRelease: ZodMiniString<string>;
logicalCores: ZodMiniInt;
memoryGiB: ZodMiniInt;
os: ZodMiniString<string>;
physicalCores: ZodMiniNullable<ZodMiniInt>;
}, $strip>
The host a run happened on. No host name and no user name, on purpose.
const MEASURE_PLUGIN_TAG: unique symbol
Brands a MeasurePlugin so isMeasurePlugin can check for it nominally
instead of validating every member’s shape — only defineMeasurePlugin and
fallbackAdapter ever attach it.
const measureCaseExecutionSchema: ZodMiniObject<{
arm: ZodMiniEnum<{
isolated: "isolated";
shared: "shared";
}>;
caseTitle: ZodMiniString<string>;
kind: ZodMiniLiteral<"case-execution">;
measure: ZodMiniString<string>;
replicate: ZodMiniNumber<number>;
result: ZodMiniUnknown;
}, $strip>
One case, as measured by one process. The evidence.
Emitted by the child as each case finishes, so a live view can fill in while
the run is still going. A case measured in several processes produces several
of these and exactly one MeasureCaseResult, which is the answer.
const measureCaseResultSchema: ZodMiniObject<{
caseTitle: ZodMiniString<string>;
kind: ZodMiniLiteral<"case-result">;
measure: ZodMiniString<string>;
result: ZodMiniUnknown;
}, $strip>
One case’s answer, pooled across every process that measured it.
Emitted by the parent, which is the only party that sees every execution.
With a single execution it carries that execution’s result unchanged.
const measureConditionInputSchema: ZodMiniObject<{
results: ZodMiniArray<ZodMiniUnknown>;
title: ZodMiniString<string>;
}, $strip>
The generic “whole condition” value the CLI builds by grouping case-result
events by measure id, before handing it to an plugin’s
parseConditionResult. This is what a real child-process boundary will
eventually carry as a condition-result event (§4.6, not yet emitted by any
measure); until then, the parent assembles it itself from the case results it
already collected.
const measureConditionResultSchema: ZodMiniObject<{
conditionTitle: ZodMiniString<string>;
kind: ZodMiniLiteral<"condition-result">;
measure: ZodMiniString<string>;
result: ZodMiniUnknown;
}, $strip>
const measureDataSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
conditionTitle: ZodMiniString<string>;
kind: ZodMiniLiteral<"condition-result">;
measure: ZodMiniString<string>;
result: ZodMiniUnknown;
}, $strip>, ZodMiniObject<{
arm: ZodMiniEnum<{
isolated: "isolated";
shared: "shared";
}>;
caseTitle: ZodMiniString<string>;
kind: ZodMiniLiteral<"case-execution">;
measure: ZodMiniString<string>;
replicate: ZodMiniNumber<number>;
result: ZodMiniUnknown;
}, $strip>, ZodMiniObject<{
caseTitle: ZodMiniString<string>;
kind: ZodMiniLiteral<"case-result">;
measure: ZodMiniString<string>;
result: ZodMiniUnknown;
}, $strip>], "kind">
const measureIdSchema: ZodMiniString<string>
A registered measure’s stable identifier, e.g. "duration".
const measurementArmSchema: ZodMiniEnum<{
isolated: "isolated";
shared: "shared";
}>
Which arm of the measurement plan an execution belongs to.
const measurementPlanSchema: ZodMiniObject<{
cooldown: ZodMiniBoolean<boolean>;
isolatedRuns: ZodMiniInt;
maxReplicates: ZodMiniInt;
replicates: ZodMiniInt;
retryOnInstability: ZodMiniInt;
rounds: ZodMiniInt;
}, $strip>
How many contexts a condition is measured in, and under what conditions.
Sampling (how many samples one case needs in one process) is the layer below
and is decided per case by the sampler. This is the layer above: how many
processes there are and what runs in each.
Parameters, not an intent: naming an intent (quick, rigorous) and turning
it into these numbers is configuration, and lives in @ac-bench/cli.
const NODE_RUNTIME_ID: "node"
The id of the runtime every run measures in unless another is selected. Its
conditions keep keys without a runtime prefix, so a Node-only run keys its
scopes as it always has.
const REPORTER_PLUGIN_TAG: unique symbol
Brands a ReporterPlugin so isReporterPlugin can check for it nominally
instead of validating every member’s shape — only defineReporterPlugin ever
attaches it.
const runDescriptionDataSchema: ZodMiniObject<{
kind: ZodMiniLiteral<"run-description">;
machine: ZodMiniObject<{
architecture: ZodMiniString<string>;
availableParallelism: ZodMiniInt;
cpuGovernor: ZodMiniNullable<ZodMiniString<string>>;
cpuModel: ZodMiniString<string>;
kernelRelease: ZodMiniString<string>;
logicalCores: ZodMiniInt;
memoryGiB: ZodMiniInt;
os: ZodMiniString<string>;
physicalCores: ZodMiniNullable<ZodMiniInt>;
}, $strip>;
run: ZodMiniObject<{
argv: ZodMiniArray<ZodMiniString<string>>;
id: ZodMiniString<string>;
mode: ZodMiniNullable<ZodMiniString<string>>;
orderSeed: ZodMiniInt;
plan: ZodMiniObject<{
cooldown: ZodMiniBoolean<boolean>;
isolatedRuns: ZodMiniInt;
maxReplicates: ZodMiniInt;
replicates: ZodMiniInt;
retryOnInstability: ZodMiniInt;
rounds: ZodMiniInt;
}, $strip>;
startedAt: ZodMiniISODateTime;
tool: ZodMiniObject<{
name: ZodMiniLiteral<"@ac-bench/lib">;
version: ZodMiniString<string>;
}, $strip>;
}, $strip>;
}, $strip>
Emitted once by the parent, first: what the run is and where it runs.
const runDescriptionSchema: ZodMiniObject<{
argv: ZodMiniArray<ZodMiniString<string>>;
id: ZodMiniString<string>;
mode: ZodMiniNullable<ZodMiniString<string>>;
orderSeed: ZodMiniInt;
plan: ZodMiniObject<{
cooldown: ZodMiniBoolean<boolean>;
isolatedRuns: ZodMiniInt;
maxReplicates: ZodMiniInt;
replicates: ZodMiniInt;
retryOnInstability: ZodMiniInt;
rounds: ZodMiniInt;
}, $strip>;
startedAt: ZodMiniISODateTime;
tool: ZodMiniObject<{
name: ZodMiniLiteral<"@ac-bench/lib">;
version: ZodMiniString<string>;
}, $strip>;
}, $strip>
What a run was asked to do and who ran it.
const runProgressDataSchema: ZodMiniObject<{
completedUnits: ZodMiniInt;
kind: ZodMiniLiteral<"run-progress">;
totalUnits: ZodMiniInt;
}, $strip>
Emitted by the parent once every file is discovered, then after each fork
unit: how much of the whole run is done. A unit counts once, whatever the
executions and replicates it took.
const RUNTIME_PLUGIN_TAG: unique symbol
Brands a runtime plugin so partitionPlugins can sort it from a mixed list
nominally. Only @ac-bench/lib’s defineRuntimePlugin attaches it: this
package knows the brand and the id, and @ac-bench/lib the rest.
const runtimeCapabilitiesSchema: ZodMiniObject<{
allocationCounter: ZodMiniNullable<ZodMiniEnum<{
browser-heap-growth: "browser-heap-growth";
gc-profiler: "gc-profiler";
heap-growth: "heap-growth";
v8-total-allocated: "v8-total-allocated";
}>>;
cpuTime: ZodMiniBoolean<boolean>;
forcedCollection: ZodMiniBoolean<boolean>;
}, $strip>
What a runtime can do for a measure, as the child itself observed it.
const runtimeDescriptionDataSchema: ZodMiniObject<{
kind: ZodMiniLiteral<"runtime-description">;
runtime: ZodMiniObject<{
capabilities: ZodMiniObject<{
allocationCounter: ZodMiniNullable<ZodMiniEnum<{
browser-heap-growth: "browser-heap-growth";
gc-profiler: "gc-profiler";
heap-growth: "heap-growth";
v8-total-allocated: "v8-total-allocated";
}>>;
cpuTime: ZodMiniBoolean<boolean>;
forcedCollection: ZodMiniBoolean<boolean>;
}, $strip>;
clock: ZodMiniObject<{
readCostMs: ZodMiniNumber<number>;
resolutionMs: ZodMiniNumber<number>;
source: ZodMiniLiteral<"performance.now">;
}, $strip>;
crossOriginIsolated: ZodMiniNullable<ZodMiniBoolean<boolean>>;
device: ZodMiniNullable<ZodMiniObject<{
model: ZodMiniString<string>;
os: ZodMiniString<string>;
osVersion: ZodMiniString<string>;
}, $strip>>;
engine: ZodMiniEnum<{
javascriptcore: "javascriptcore";
spidermonkey: "spidermonkey";
v8: "v8";
}>;
flags: ZodMiniArray<ZodMiniString<string>>;
headless: ZodMiniNullable<ZodMiniBoolean<boolean>>;
id: ZodMiniString<string>;
isolation: ZodMiniEnum<{
browser: "browser";
context: "context";
process: "process";
reload: "reload";
}>;
kind: ZodMiniEnum<{
browser: "browser";
node: "node";
}>;
product: ZodMiniString<string>;
userAgent: ZodMiniNullable<ZodMiniString<string>>;
version: ZodMiniString<string>;
}, $strip>;
}, $strip>
Emitted by the parent once per runtime a run measures in.
const runtimeDescriptionSchema: ZodMiniObject<{
capabilities: ZodMiniObject<{
allocationCounter: ZodMiniNullable<ZodMiniEnum<{
browser-heap-growth: "browser-heap-growth";
gc-profiler: "gc-profiler";
heap-growth: "heap-growth";
v8-total-allocated: "v8-total-allocated";
}>>;
cpuTime: ZodMiniBoolean<boolean>;
forcedCollection: ZodMiniBoolean<boolean>;
}, $strip>;
clock: ZodMiniObject<{
readCostMs: ZodMiniNumber<number>;
resolutionMs: ZodMiniNumber<number>;
source: ZodMiniLiteral<"performance.now">;
}, $strip>;
crossOriginIsolated: ZodMiniNullable<ZodMiniBoolean<boolean>>;
device: ZodMiniNullable<ZodMiniObject<{
model: ZodMiniString<string>;
os: ZodMiniString<string>;
osVersion: ZodMiniString<string>;
}, $strip>>;
engine: ZodMiniEnum<{
javascriptcore: "javascriptcore";
spidermonkey: "spidermonkey";
v8: "v8";
}>;
flags: ZodMiniArray<ZodMiniString<string>>;
headless: ZodMiniNullable<ZodMiniBoolean<boolean>>;
id: ZodMiniString<string>;
isolation: ZodMiniEnum<{
browser: "browser";
context: "context";
process: "process";
reload: "reload";
}>;
kind: ZodMiniEnum<{
browser: "browser";
node: "node";
}>;
product: ZodMiniString<string>;
userAgent: ZodMiniNullable<ZodMiniString<string>>;
version: ZodMiniString<string>;
}, $strip>
The engine a case ran in, as far as a reader needs to compare two runs.
const runtimeReferenceSchema: ZodMiniObject<{
id: ZodMiniString<string>;
kind: ZodMiniEnum<{
browser: "browser";
node: "node";
}>;
}, $strip>
Which runtime a child measures in: what a case can branch on.
const suiteGateDeclarationSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
denominators: ZodMiniArray<ZodMiniString<string>>;
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"ratio">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
numerator: ZodMiniString<string>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"difference">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
reference: ZodMiniString<string>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
subject: ZodMiniString<string>;
}, $strip>, ZodMiniObject<{
id: ZodMiniOptional<ZodMiniString<string>>;
kind: ZodMiniLiteral<"bound">;
max: ZodMiniOptional<ZodMiniNumber<number>>;
maxDispersion: ZodMiniOptional<ZodMiniNumber<number>>;
metric: ZodMiniOptional<ZodMiniString<string>>;
min: ZodMiniOptional<ZodMiniNumber<number>>;
rationale: ZodMiniOptional<ZodMiniString<string>>;
runtimes: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
subject: ZodMiniString<string>;
}, $strip>], "kind">
const unitDeclarationDataSchema: ZodMiniObject<{
cases: ZodMiniArray<ZodMiniObject<{
selected: ZodMiniBoolean<boolean>;
title: ZodMiniString<string>;
}, $strip>>;
conditionPath: ZodMiniArray<ZodMiniInt>;
file: ZodMiniString<string>;
kind: ZodMiniLiteral<"unit-declaration">;
measure: ZodMiniString<string>;
runtime: ZodMiniString<string>;
titles: ZodMiniArray<ZodMiniString<string>>;
}, $strip>
Emitted by the parent once per executable leaf it discovered, before
measuring anything: every case the leaf runs, and whether the run’s filter
selected it. What lets an archive list a case the run never measured.
type ArchiveBuilderOptions = unknown
type ArchivedCase = unknown
type ArchivedCondition = ConditionIdentity & {
readonly cases: readonly ArchivedCase[];
readonly metrics: readonly GateMetricDescriptor[];
readonly status: z.infer<typeof reportScopeStatusSchema>;
}
type ArchivedExecution = Readonly<z.infer<typeof archivedExecutionSchema>>
type BenchArchive = unknown
One document per run: what ran, where, and every condition’s answers.
Raw per-execution results are not kept, so the archive’s size follows the
number of cases and processes, never the number of samples.
type BenchPlugin = MeasurePlugin | ReporterPlugin | BrandedRuntimePlugin
Any kind of plugin, as a config file lists them together.
type BrandedRuntimePlugin = unknown
What this package knows of a runtime plugin: its brand and the id a config or
--runtime selects it by. @ac-bench/lib’s RuntimePlugin extends it with
how to create the runtime.
type CaseKey = ReadonlyDeep<z.infer<typeof caseKeySchema>>
type CaseReference = ReadonlyDeep<z.infer<typeof caseReferenceSchema>>
type ChildEnvironment = z.infer<typeof childEnvironmentSchema>
type ClockDescription = z.infer<typeof clockDescriptionSchema>
type CollectedCondition = ConditionIdentity & {
readonly caseResults: readonly MeasureCaseResult[];
readonly executions: readonly MeasureCaseExecution[];
readonly scopeId: ReportScopeId;
readonly status: ReportScopeStatus;
}
One measured condition with the evidence and answers that belong to it.
type ConditionIdentity = unknown
Where a measured condition sits, read off the scope the parent opened for it.
type ConditionSnapshot = unknown
type ConfigGateDeclaration = ReadonlyDeep<z.infer<typeof configGateDeclarationSchema>>
A gate declared in a config file, or built from a command-line flag.
type GateDeclarationData = z.infer<typeof gateDeclarationDataSchema>
type GateMetric = GateMetricDescriptor & {
readonly title: string;
observe(result: unknown): _ReadonlyObjectDeep<{
dispersion: number | null;
samples: number;
value: number;
variance: number;
}, never> | null;
}
type GateMetricDescriptor = ReadonlyDeep<z.infer<typeof gateMetricDescriptorSchema>>
type GateMetricScale = z.infer<typeof gateMetricScaleSchema>
type GateMetricSpec<TCase> = GateMetricDescriptor & {
readonly title: string;
observe(result: TCase): _ReadonlyObjectDeep<{
dispersion: number | null;
samples: number;
value: number;
variance: number;
}, never> | null;
}
One quantity of a measure a gate can read, declared by the measure so the
gate never reads a result shape.
type GateObservation = ReadonlyDeep<z.infer<typeof gateObservationSchema>>
type GateReason = z.infer<typeof gateReasonSchema>
type GateSettings = ReadonlyDeep<z.infer<typeof gateSettingsSchema>>
type GateThreshold = ReadonlyDeep<z.infer<typeof gateThresholdSchema>>
type GateVerdict = ReadonlyDeep<z.infer<typeof gateVerdictSchema>>
The decision for one gate instance.
type GateVerdictData = z.infer<typeof gateVerdictDataSchema>
type GateVerdictKind = z.infer<typeof gateVerdictKindSchema>
type JsonCaseOptions = unknown
What a JSON archive keeps of one case.
type LoadErrorData = z.infer<typeof loadErrorDataSchema>
type LocatedGateDeclaration = ReadonlyDeep<z.infer<typeof locatedGateDeclarationSchema>>
type MachineFingerprint = z.infer<typeof machineFingerprintSchema>
type MeasureCaseExecution = z.infer<typeof measureCaseExecutionSchema>
type MeasureCaseResult = z.infer<typeof measureCaseResultSchema>
type MeasureComparison = unknown
Which field orders the cases against each other, and which fields bound that
estimate’s uncertainty.
Read by the escalation policy, which asks whether two cases can be told
apart, and by any renderer marking a row better or worse than its peers.
Absent when the measure makes no ordered claim.
type MeasureConditionInput = z.infer<typeof measureConditionInputSchema>
type MeasureConditionResult = z.infer<typeof measureConditionResultSchema>
type MeasureData = z.infer<typeof measureDataSchema>
type MeasureExecution<TResult> = unknown
One execution’s result, tagged with the context that produced it.
type MeasureId = z.infer<typeof measureIdSchema>
type MeasurementArm = z.infer<typeof measurementArmSchema>
type MeasurementPlan = z.infer<typeof measurementPlanSchema>
type MeasurePlugin = unknown
Every method takes unknown and validates before dispatching.
type MeasurePluginSpec<TCase, TCondition> = unknown
type MeasureScheduling = unknown
How a measure constrains the scheduler, never the reverse.
type ReporterContext = unknown
Everything a reporter needs that belongs to the run rather than to the
reporter: the host’s streams, the run’s environment, and the registry that
turns an opaque result into something renderable.
Handing these in is what keeps a reporter package free of node: imports —
the host-bound half is assembled once, by whoever starts the run.
type ReporterPlugin = ReporterPluginSpec & {
readonly [REPORTER_PLUGIN_TAG]: true;
}
type ReporterPluginSpec = unknown
type RunDescription = z.infer<typeof runDescriptionSchema>
type RunDescriptionData = z.infer<typeof runDescriptionDataSchema>
type RunProgressData = z.infer<typeof runProgressDataSchema>
type RuntimeCapabilities = z.infer<typeof runtimeCapabilitiesSchema>
type RuntimeDescription = z.infer<typeof runtimeDescriptionSchema>
type RuntimeDescriptionData = z.infer<typeof runtimeDescriptionDataSchema>
type RuntimeReference = z.infer<typeof runtimeReferenceSchema>
type SuiteGateDeclaration = ReadonlyDeep<z.infer<typeof suiteGateDeclarationSchema>>
A gate declared in a suite, next to the cases it reads.
type UnitDeclarationData = z.infer<typeof unitDeclarationDataSchema>
@ac-bench/core/runner
Functions
Classes
Constants
Types
allOfPolicies<TSample, const TPolicies extends readonly StoppingPolicy<TSample, object>[]>(policies: TPolicies): StoppingPolicy<TSample, Simplify<UnionToIntersection<{ [K in string | number | symbol]: TPolicies[K] extends StoppingPolicy<TSample, TMetadata> ? TMetadata : never }[number]>>>
Satisfied once every policy is.
What a measure reporting both deterministic and noisy quantities needs:
neither a confidence interval on a counter that never moves nor a settling
test on a timing is correct alone, so the run continues until each quantity
is judged by the rule that fits it.
anyOfPolicies<TSample, const TPolicies extends readonly StoppingPolicy<TSample, object>[]>(policies: TPolicies): StoppingPolicy<TSample, Simplify<UnionToIntersection<{ [K in string | number | symbol]: TPolicies[K] extends StoppingPolicy<TSample, TMetadata> ? TMetadata : never }[number]>>>
Satisfied as soon as any policy is.
For a measure whose quantities are alternative readings of the same thing,
where the first one to settle answers for the case.
assembleForkUnitCases(chain: readonly BenchCondition[], path: readonly number[]): BenchCase[]
Assembles a fork unit’s case list in reading order.
chain runs outermost-first; every path entry after the first indexes the
nested condition that level descended into, so an enclosing level’s cases
split around it.
assembleForkUnitGates(chain: readonly BenchCondition[]): SuiteGateDeclaration[]
The gates a chain of conditions declares, outermost first.
boundGate(subject: string, settings: GateSettings): void
metric(subject) against an absolute bound.
Throws When the settings contradict each other.
caseScopeKey(file: string, conditionPath: readonly number[], conditionTitles: readonly string[], caseTitle: string, runtime?: string): string
The cross-run identity of a case within its fork unit, and the key of its
report scope: forkUnitKey’s tuple with the case title appended, so it
never equals a unit’s key either. file and runtime are as for
forkUnitKey.
checkForkUnitGates(unit: ForkUnit, context: GateReferenceContext): GateReferenceError[]
Checks every gate of unit against the cases the unit runs.
Done when the unit is assembled rather than when the gate is registered, so a
gate may precede the cases it names. A title must name exactly one case: none
is unknown, and two (an inherited case and an own one sharing a title) is
ambiguous. Two gates with one id in a unit are an error too, since the id is
what baselines and reports match on.
Returns One error per problem, in declaration order; empty when sound.
collectForkUnits(roots: readonly BenchCondition[], context?: GateReferenceContext): ForkUnit[]
Walks roots depth-first and returns every executable leaf.
A leaf’s case list is assembled in reading order: at each enclosing level,
the cases declared above the nested condition being descended into come
first, then that condition’s own list, then the cases declared below it. So
sibling leaves of one parent see the parent’s cases split around their own
declaration point, exactly as the file reads.
Throws The first gate whose reference does not name
exactly one case of its unit; checkForkUnitGates lists them all.
Parameters
contextThe file the roots came from, for the error a bad gate
reference raises. Default: no file name.
conditionCases(condition: BenchCondition): BenchCase[]
The cases condition declared directly, in declaration order.
conditionChildren(condition: BenchCondition): BenchCondition[]
The conditions condition declared directly, in declaration order.
createProjectedPolicy<TSample, TProjected, TMetadata>(select: (sample: TSample) => TProjected, policy: StoppingPolicy<TProjected, TMetadata>): StoppingPolicy<TSample, TMetadata>
Adapts a policy to a different sample type by projecting each sample onto the
quantity that policy judges.
A measure whose sample is a record of several quantities needs a different
rule per quantity. This is what lets each of those rules stay written against
a plain number and still compose under allOfPolicies.
createRelativeErrorPolicy(sampling: RelativeErrorSampling, autoK?: number): StoppingPolicy<number, RelativeErrorMetadata>
Stops once the interval around the estimate is tight enough relative to the
estimate itself.
Presumes noise, which is why a quantity that never varies needs
createStabilityPolicy instead: a confidence interval around a
deterministic counter is meaningless.
createStabilityPolicy<TSample>(select: (sample: TSample) => readonly number[], options?: StabilityOptions): StoppingPolicy<TSample, StabilityMetadata>
Stops once the watched quantities have stopped changing.
The counterpart to createRelativeErrorPolicy, for quantities that do
not vary: an allocation count is the same every run, so a confidence interval
around it says nothing, and “enough samples” means “it has settled” instead.
Each evaluation costs O(window × selected), independent of how many samples
have accumulated.
Returns A policy for Sampler.
Parameters
selectThe quantities to watch, in a fixed order. Every one of them
must settle; a single unsettled entry keeps sampling.
describeConditions(conditions: readonly BenchCondition[]): DiscoveredCondition[]
Projects a registered condition tree onto the wire shape, dropping every
hook.
differenceGate(subject: string, reference: string, settings?: _ReadonlyObjectDeep<{
id?: string;
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
runtimes?: string[];
}, never>): void
metric(subject) − metric(reference), on the metric’s own (linear) scale.
Throws When the settings contradict each other.
drainConditions(): BenchCondition[]
Returns the registered root conditions and resets the registry.
forkUnitKey(file: string, conditionPath: readonly number[], conditionTitles: readonly string[], runtime?: string): string
The cross-run identity of a fork unit: stable under re-ordering (the titles)
and unique across files and sibling groups (the path). A JSON tuple, so no
file name or title can imitate another part.
Parameters
fileThe bench file’s label: relative to the run’s working directory
and /-separated, as the archive records it, so the key is the same from
any checkout location. Never an absolute path.
runtimeThe runtime the unit is measured in. Any but
NODE_RUNTIME_ID leads the tuple, so one condition measured in two
runtimes has two keys, while a Node run keys its units as it always has.
parseChildMessage(value: unknown): {
environment: {
capabilities: {
allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
cpuTime: boolean;
forcedCollection: boolean;
};
clock: {
readCostMs: number;
resolutionMs: number;
source: "performance.now";
};
crossOriginIsolated: boolean | null;
engineVersion: string;
userAgent: string | null;
};
processId: string | number;
t: "hello";
version: number;
} | {
conditions: DiscoveredCondition[];
t: "conditions";
} | {
event: unknown;
seq: number;
t: "event";
} | {
count: number;
kinds: string[];
seq: number;
t: "dropped";
} | {
seq: number;
status: "skipped" | "failed" | "ok" | "cancelled";
t: "done";
} | {
error: unknown;
seq: number;
t: "fatal";
}
Throws When value is a child hello of
another protocol version, whatever else it carries.
Throws When value is not a valid child message.
parseParentMessage(value: unknown): {
artifactCacheRoot: string;
runId: string;
setupFiles?: string[];
t: "hello";
version: number;
} | {
file: string;
t: "list";
} | {
arm: "shared" | "isolated";
caseFilter?: string[];
conditionPath: number[];
conditionTitles: string[];
emitSamples: boolean;
file: string;
fileLabel: string;
hashSeed?: number;
measureOptions?: Record<string, unknown>;
orderSeed: number;
parentScopeId: string | null;
profile?: boolean;
replicate: number;
rounds: number;
runtime: {
id: string;
kind: "node" | "browser";
};
t: "start";
} | {
seq: number;
t: "ack";
} | {
reason: string;
t: "abort";
}
Throws When value is a parent hello of
another protocol version, whatever else it carries.
Throws When value is not a valid parent message.
probeClock(durationMs?: number, now?: () => number): {
readCostMs: number;
resolutionMs: number;
source: "performance.now";
}
Busy-loops the clock for durationMs and returns the median of its positive
steps (its resolution) and the mean cost of one read.
A child calls it once, before measuring anything, so a measure can size its
spans from the clock it actually runs under (a cross-origin-isolated page
steps by 5 µs, a page that is not by 100 µs) without probing again.
Parameters
durationMsHow long to read the clock for. Default
DEFAULT_CLOCK_PROBE_MS.
nowThe clock, performance.now() by default; injectable to test the
arithmetic on a scripted clock.
ratioGate(numerator: string, denominator: string | readonly string[], settings?: _ReadonlyObjectDeep<{
id?: string;
max?: number;
maxDispersion?: number;
metric?: string;
min?: number;
rationale?: string;
runtimes?: string[];
}, never>): void
metric(numerator) / metric(denominator). Several denominators mean “against
each of them”: the gate passes only if every ratio passes, which is the same
claim as “against the fastest of them” without choosing the fastest from
noisy data.
Throws When the settings contradict each other.
Parameters
numeratorA case title of this condition, inherited cases included.
denominatorOne or several case titles, same scope.
settingsBounds and options; neither bound makes the gate report only.
registerAfterAll(fn: BeforeAfterAllHookFn): void
registerAfterEach(fn: BeforeAfterEachHookFn): void
registerBeforeAll(fn: BeforeAfterAllHookFn): void
registerBeforeEach(fn: BeforeAfterEachHookFn): void
registerCase<TExecuteArgs extends unknown[] = []>(measure: string, title: string, execute: BenchCaseRunFn<TExecuteArgs>): void
registerCondition(measure: string, title: string, fn: () => void, options?: BenchConditionOptions): void
registerGate(declaration: SuiteGateDeclaration): void
Registers a gate in the condition whose body is open, like a case. A gate may
precede the cases it names: references are checked when a fork unit is
assembled.
Throws When the declaration is contradictory.
Throws Outside a condition body.
reportCaseFailure(context: BenchCaseRunContext, error: unknown, report: CaseFailureReport): Promise<void>
Ends a case that threw: runs its teardown, reports the measure’s failure
result, then rethrows so the runner closes the case’s scope as "failed".
The scope’s status is what says a case failed — the archive and the exit code
read it, never a measure’s result. A teardown that fails too is rethrown with
the case’s error as a SuppressedError. Once the run is aborted the error is
not rethrown, so the scope closes as "cancelled".
Throws The case’s error, unless context.signal is aborted.
resolveForkUnit(roots: readonly BenchCondition[], conditionPath: readonly number[], conditionTitles: readonly string[]): ForkUnit
Walks conditionPath through a freshly drained tree and checks the title at
every level, which is what catches a bench file that changed between
discovery and execution.
Throws At the first level that disagrees.
runCaseOnce(input: RunCaseOnceInput): Promise<void>
Invokes one case body once, reporting nothing.
For measures whose iteration is a whole process: the spawned process has no
sink and no IPC channel, and its result reaches the sampler as wall time and
an exit code. None of the condition chain’s hooks run — a fresh process holds
none of the state they would set up, and paying beforeAll per iteration is
exactly the cost this execution mode exists to measure honestly.
Throws If the unit has no case by that title.
runForkUnit(input: ForkUnitRunInput): Promise<ForkUnitOutcome>
Runs one fork unit: every case it inherited from its enclosing conditions
plus its own, wrapped in the beforeAll hooks of the whole chain, outermost
first.
Sibling fork units are run separately and, once isolation is on, in their own
processes — which is why an enclosing condition’s beforeAll runs here again
rather than once for the whole tree.
Never rethrows a case failure: a failed case closes its own scope as
"failed", is counted in ForkUnitOutcome.casesFailed, and the
condition continues. A failed beforeAll/afterAll closes the condition
scope as "failed" and reports every remaining case as "skipped".
runSamplingDefaults<TSampling extends object>(context: Pick<BenchCaseRunContext, "measureOptions">): Partial<TSampling>
The run’s default sampling options for the case’s measure — a config file’s
sampling[measureId], which the parent forwards as measureOptions.sampling
— or {}. A measure spreads its condition’s own options over these, and its
defaults under both.
Typed by the caller: the config validated the value as a record only, so a
key the measure does not know is ignored like any other.
serveChild(transport: ChildTransport, host: ChildHost, options?: ServeChildOptions): void
Serves the bench child protocol until host.finish: the hello handshake, a
list (discovery) or a start (one fork unit), acknowledgements and
aborts.
The one implementation every runtime’s child shares — a Node process and a
browser page differ only in their ChildTransport and ChildHost.
Never throws: whatever goes wrong is reported as fatal.
class ConditionIdentityMismatchError extends Error
The bench file changed between discovery and execution.
- new (level: number, expectedTitle: string, foundTitle: string | null): ConditionIdentityMismatchError
- readonly expectedTitle: string
- readonly foundTitle: string | null
- readonly level: number
class MalformedMessageError extends Error
A message that did not match its schema.
- new (origin: "parent" | "child", reason: string, value: unknown): MalformedMessageError
- readonly origin: "parent" | "child"
- readonly value: unknown
class ProtocolVersionMismatchError extends Error
- new (expected: number, received: number): ProtocolVersionMismatchError
- readonly expected: number
- readonly received: number
class Sampler<TSample = number, TMetadata = unknown>
Drives sampling without owning a clock, a loop, or an opinion about when
enough is enough.
Time is an input rather than something read from a clock inside, which is
what makes the whole apparatus testable from a scripted sequence with no fake
timers — and what lets a scheduler hand this case a slice, walk away to
another case, and come back.
- new <TSample = number, TMetadata = unknown>(policy: StoppingPolicy<TSample, TMetadata>, bounds: SamplingBounds, options?: SamplerOptions<TSample>): Sampler<TSample, TMetadata>
- nextBatch(): number | null
null once this case is done; otherwise the size of the next batch.
- observe(samples: readonly TSample[], activeMs: number): void
Feeds one batch back. activeMs is the wall time the scheduler spent on
this slice, including hooks and this recomputation.
- result(): SamplerResult<TSample, TMetadata>
Defined only once Sampler.nextBatch has returned null.
- stop(reason: "cancelled" | "failure"): void
Ends sampling early, keeping whatever was collected.
class UnsupportedInRuntimeError extends Error
Thrown by a measure’s case when the runtime it runs in lacks what the case
needs: a process to spawn, an event-loop monitor, a nanosecond clock. The
case fails with this message instead of the whole file failing to load, so a
suite mixing measures still bundles and runs what it can.
A measure that knows ahead of time declares it through supportsRuntime, and
the parent skips the condition without starting a child; this error is for
what only the running case can tell.
- new (what: string): UnsupportedInRuntimeError
- readonly code: "unsupported-in-runtime"
- readonly what: string
What the runtime lacks, as a phrase: "per-iteration processes".
const abortMessageSchema: ZodMiniObject<{
reason: ZodMiniString<string>;
t: ZodMiniLiteral<"abort">;
}, $strip>
const ackMessageSchema: ZodMiniObject<{
seq: ZodMiniNumber<number>;
t: ZodMiniLiteral<"ack">;
}, $strip>
const afterAll: (fn: BeforeAfterAllHookFn) => void
Registers a hook that runs once after all cases in the current condition.
const afterEach: (fn: BeforeAfterEachHookFn) => void
Registers a hook that runs after each case iteration in the current
condition.
const beforeAll: (fn: BeforeAfterAllHookFn) => void
Registers a hook that runs once before all cases in the current condition.
const beforeEach: (fn: BeforeAfterEachHookFn) => void
Registers a hook that runs before each case iteration in the current
condition.
const BENCH_PROTOCOL_VERSION: 3
Bumped whenever a message’s shape changes in a way an older peer cannot read.
A mismatch aborts that condition rather than the run.
3: the child’s hello names its processId (a pid or a page label) and
carries the environment it measured; start names the runtime.
const childHelloMessageSchema: ZodMiniObject<{
environment: ZodMiniObject<{
capabilities: ZodMiniObject<{
allocationCounter: ZodMiniNullable<ZodMiniEnum<{
browser-heap-growth: "browser-heap-growth";
gc-profiler: "gc-profiler";
heap-growth: "heap-growth";
v8-total-allocated: "v8-total-allocated";
}>>;
cpuTime: ZodMiniBoolean<boolean>;
forcedCollection: ZodMiniBoolean<boolean>;
}, $strip>;
clock: ZodMiniObject<{
readCostMs: ZodMiniNumber<number>;
resolutionMs: ZodMiniNumber<number>;
source: ZodMiniLiteral<"performance.now">;
}, $strip>;
crossOriginIsolated: ZodMiniNullable<ZodMiniBoolean<boolean>>;
engineVersion: ZodMiniString<string>;
userAgent: ZodMiniNullable<ZodMiniString<string>>;
}, $strip>;
processId: ZodMiniUnion<readonly [ZodMiniNumber<number>, ZodMiniString<string>]>;
t: ZodMiniLiteral<"hello">;
version: ZodMiniNumber<number>;
}, $strip>
const childMessageSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
environment: ZodMiniObject<{
capabilities: ZodMiniObject<{
allocationCounter: ZodMiniNullable<ZodMiniEnum<{
browser-heap-growth: ...;
gc-profiler: ...;
heap-growth: ...;
v8-total-allocated: ...;
}>>;
cpuTime: ZodMiniBoolean<boolean>;
forcedCollection: ZodMiniBoolean<boolean>;
}, $strip>;
clock: ZodMiniObject<{
readCostMs: ZodMiniNumber<number>;
resolutionMs: ZodMiniNumber<number>;
source: ZodMiniLiteral<"performance.now">;
}, $strip>;
crossOriginIsolated: ZodMiniNullable<ZodMiniBoolean<boolean>>;
engineVersion: ZodMiniString<string>;
userAgent: ZodMiniNullable<ZodMiniString<string>>;
}, $strip>;
processId: ZodMiniUnion<readonly [ZodMiniNumber<number>, ZodMiniString<string>]>;
t: ZodMiniLiteral<"hello">;
version: ZodMiniNumber<number>;
}, $strip>, ZodMiniObject<{
conditions: ZodMiniArray<ZodMiniType<DiscoveredCondition, unknown, $ZodTypeInternals<DiscoveredCondition, unknown>>>;
t: ZodMiniLiteral<"conditions">;
}, $strip>, ZodMiniObject<{
event: ZodMiniUnknown;
seq: ZodMiniNumber<number>;
t: ZodMiniLiteral<"event">;
}, $strip>], "t">
const conditionsMessageSchema: ZodMiniObject<{
conditions: ZodMiniArray<ZodMiniType<DiscoveredCondition, unknown, $ZodTypeInternals<DiscoveredCondition, unknown>>>;
t: ZodMiniLiteral<"conditions">;
}, $strip>
const DEFAULT_AUTO_K: 4
How many times tighter than the observed spread "auto" aims, per mode.
const DEFAULT_CLOCK_PROBE_MS: 50
const discoveredConditionSchema: z.ZodMiniType<DiscoveredCondition>
const doneMessageSchema: ZodMiniObject<{
seq: ZodMiniNumber<number>;
status: ZodMiniEnum<{
cancelled: "cancelled";
failed: "failed";
ok: "ok";
skipped: "skipped";
}>;
t: ZodMiniLiteral<"done">;
}, $strip>
const droppedMessageSchema: ZodMiniObject<{
count: ZodMiniNumber<number>;
kinds: ZodMiniArray<ZodMiniString<string>>;
seq: ZodMiniNumber<number>;
t: ZodMiniLiteral<"dropped">;
}, $strip>
const eventMessageSchema: ZodMiniObject<{
event: ZodMiniUnknown;
seq: ZodMiniNumber<number>;
t: ZodMiniLiteral<"event">;
}, $strip>
const fatalMessageSchema: ZodMiniObject<{
error: ZodMiniUnknown;
seq: ZodMiniNumber<number>;
t: ZodMiniLiteral<"fatal">;
}, $strip>
const listMessageSchema: ZodMiniObject<{
file: ZodMiniString<string>;
t: ZodMiniLiteral<"list">;
}, $strip>
const parentHelloMessageSchema: ZodMiniObject<{
artifactCacheRoot: ZodMiniString<string>;
runId: ZodMiniString<string>;
setupFiles: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
t: ZodMiniLiteral<"hello">;
version: ZodMiniNumber<number>;
}, $strip>
const parentMessageSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{
artifactCacheRoot: ZodMiniString<string>;
runId: ZodMiniString<string>;
setupFiles: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
t: ZodMiniLiteral<"hello">;
version: ZodMiniNumber<number>;
}, $strip>, ZodMiniObject<{
file: ZodMiniString<string>;
t: ZodMiniLiteral<"list">;
}, $strip>, ZodMiniObject<{
arm: ZodMiniEnum<{
isolated: "isolated";
shared: "shared";
}>;
caseFilter: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
conditionPath: ZodMiniArray<ZodMiniNumber<number>>;
conditionTitles: ZodMiniArray<ZodMiniString<string>>;
emitSamples: ZodMiniBoolean<boolean>;
file: ZodMiniString<string>;
fileLabel: ZodMiniString<string>;
hashSeed: ZodMiniOptional<ZodMiniNumber<number>>;
measureOptions: ZodMiniOptional<ZodMiniRecord<ZodMiniString<string>, ZodMiniUnknown>>;
orderSeed: ZodMiniNumber<number>;
parentScopeId: ZodMiniNullable<ZodMiniString<string>>;
profile: ZodMiniOptional<ZodMiniBoolean<boolean>>;
replicate: ZodMiniNumber<number>;
rounds: ZodMiniNumber<number>;
runtime: ZodMiniObject<{
id: ZodMiniString<string>;
kind: ZodMiniEnum<{
browser: "browser";
node: "node";
}>;
}, $strip>;
t: ZodMiniLiteral<"start">;
}, $strip>, ZodMiniObject<{
seq: ZodMiniNumber<number>;
t: ZodMiniLiteral<"ack">;
}, $strip>, ZodMiniObject<{
reason: ZodMiniString<string>;
t: ZodMiniLiteral<"abort">;
}, $strip>], "t">
const startMessageSchema: ZodMiniObject<{
arm: ZodMiniEnum<{
isolated: "isolated";
shared: "shared";
}>;
caseFilter: ZodMiniOptional<ZodMiniArray<ZodMiniString<string>>>;
conditionPath: ZodMiniArray<ZodMiniNumber<number>>;
conditionTitles: ZodMiniArray<ZodMiniString<string>>;
emitSamples: ZodMiniBoolean<boolean>;
file: ZodMiniString<string>;
fileLabel: ZodMiniString<string>;
hashSeed: ZodMiniOptional<ZodMiniNumber<number>>;
measureOptions: ZodMiniOptional<ZodMiniRecord<ZodMiniString<string>, ZodMiniUnknown>>;
orderSeed: ZodMiniNumber<number>;
parentScopeId: ZodMiniNullable<ZodMiniString<string>>;
profile: ZodMiniOptional<ZodMiniBoolean<boolean>>;
replicate: ZodMiniNumber<number>;
rounds: ZodMiniNumber<number>;
runtime: ZodMiniObject<{
id: ZodMiniString<string>;
kind: ZodMiniEnum<{
browser: "browser";
node: "node";
}>;
}, $strip>;
t: ZodMiniLiteral<"start">;
}, $strip>
type BeforeAfterAllHookFn = MaybeAsyncCallable<[signal: AbortSignal]>
type BeforeAfterEachHookFn = MaybeAsyncCallable<[signal: AbortSignal]>
type BenchCase = unknown
type BenchCaseId = unknown
Everything needed to reach one case again from a process that has only the
bench file.
A measure whose iteration is a whole process (cold-start measurement, an
external command) has to tell the process it spawns which case to run, and
the spawned process has no IPC channel to ask over. Re-importing the file and
replaying this identity is the only way back to the same case.
type BenchCaseRunContext = unknown
What a measure’s case runner reports through.
Every method returns void, never a promise: a case runner has nothing to
await, so no sink can be awaited from inside a timed region even by mistake.
type BenchCaseRunFn<TArgs extends unknown[] = unknown[]> = MaybeAsyncCallable<[runContext: BenchCaseRunContext, args: TArgs]>
type BenchCondition = unknown
A registered condition: its hooks, and the cases and nested conditions its
body declared, in declaration order.
Nesting is context specialization, not grouping. Only a condition with no
nested condition of its own is executed (a “fork unit”); it runs its
enclosing conditions’ cases as well as its own, under their hooks. So an
outer condition declaring the cases and two inner conditions declaring
nothing but a different beforeAll measures those same cases twice, once per
setup — which is the point of writing a hierarchy at all.
A condition that declares both cases and a nested condition therefore never
runs its cases on their own: they run inside each of its descendants.
type BenchConditionEndContext = unknown
What a condition’s onEnd hook can report.
type BenchConditionEntry = {
case: BenchCase;
kind: "case";
} | {
condition: BenchCondition;
kind: "condition";
}
One item of a condition body, in declaration order.
type BenchConditionOptions = unknown
type CaseCommonOptions = unknown
type CaseFailureReport = unknown
How a measure accounts for a case that threw.
type CentralEstimator = "mean" | "median"
type ChildHelloMessage = z.infer<typeof childHelloMessageSchema>
type ChildHost = unknown
Everything serveChild needs from the context it runs in.
type ChildMessage = z.infer<typeof childMessageSchema>
type ChildProfiler = unknown
type ChildTransport = unknown
How the protocol’s messages travel between a child and its parent.
type DiscoveredCondition = unknown
A node of the condition tree a discovery child reports back. entries
mirrors the registered body exactly, so an index into it is a valid
conditionPath step.
type DiscoveredEntry = {
kind: "case";
title: string;
} | {
condition: DiscoveredCondition;
kind: "condition";
}
One item of a discovered condition body, in declaration order.
type ForkUnit = unknown
One executable unit: a condition with no nested condition of its own,
together with the enclosing conditions whose hooks wrap it and the full case
list it runs.
Only such a leaf is executed. A condition that declares nested conditions
contributes its hooks and_its cases to each of them instead of running on its
own.
type ForkUnitOutcome = unknown
type ForkUnitRunInput = unknown
type ForkUnitRunOptions = unknown
type GateReferenceContext = unknown
Where a unit’s gates are checked: names the file and runtime in an error.
type MergedMetadata<TSample, TPolicies extends readonly StoppingPolicy<TSample, object>[]> = Simplify<UnionToIntersection<{ [K in keyof TPolicies]: TPolicies[K] extends StoppingPolicy<TSample, infer TMetadata> ? TMetadata : never }[number]>>
Every combined policy’s metadata in one record, since each contributes its
own fields to the sampler result.
type ParentHelloMessage = z.infer<typeof parentHelloMessageSchema>
type ParentMessage = z.infer<typeof parentMessageSchema>
type RelativeErrorMetadata = unknown
type RelativeErrorSampling = unknown
What createRelativeErrorPolicy reads from a measure’s own resolved
sampling record.
Structural rather than a base to extend, so a measure keeps naming its
sampling after what it measures and passes it straight in. Every field is
required: each measure resolves its own defaults first.
type RelativeErrorTarget = number | "auto" | "off"
type RunCaseOnceInput = unknown
type RunCaseOnceOptions = unknown
type SamplerOptions<TSample> = unknown
type SamplerResult<TSample = number, TMetadata = unknown> = unknown
type SamplingBounds = unknown
type ServeChildOptions = unknown
type StabilityMetadata = unknown
type StabilityOptions = unknown
type StartMessage = z.infer<typeof startMessageSchema>
type StoppingDecision = {
kind: "continue";
suggestedSamples?: number;
} | {
kind: "satisfied";
reason?: StopReason;
}
type StoppingPolicy<TSample = number, TMetadata = unknown> = unknown
The judgement half of sampling: when is this enough.
A policy never sees the bounds. It answers only “is the evidence good enough
yet”, and the driver reconciles that answer with the floors and ceilings —
which is what lets one driver serve a confidence-interval policy and a
deterministic-counter policy without knowing the difference.
type StopReason = "policy-satisfied" | "min-time" | "max-time" | "max-runs" | "cancelled" | "failure"
Why a case stopped taking samples.