Files
reverse-engineering-anything/src/domain/processTraceDimensionProjection.ts
T
morluto e07b81649e refactor!: simplify runtime tools and remove replay engines (#572)
* fix(hopper): report unavailable procedure body coverage

* refactor!: simplify runtime tools and remove replay engines

Keep direct inspection, capture, and comparison tools. Bind handlers to named contracts and let agents compose experiments with commands and local fixture servers.

BREAKING CHANGE: Remove controlled replay, Node characterization, finite replay-machine, managed runtime planning, and redundant string-tracing tools. Retire process replay, shims, reactive scenarios, custom checkpoints, and active browser replay and origin-scope inputs.
2026-10-05 21:15:04 +08:00

54 lines
1.8 KiB
TypeScript

import type { ProcessCapture } from "./processCapture.js";
import type { ProcessTraceSource } from "./processTraceSpecification.js";
export type ProcessComparisonDimension =
| "terminal"
| "interaction"
| "exit"
| "filesystem"
| "process";
/** Map declared trace sources to legacy process-comparison dimensions. */
export const dimensionsForTraceSources = (
sources: ReadonlySet<ProcessTraceSource>,
): ReadonlySet<ProcessComparisonDimension> => {
const dimensions = new Set<ProcessComparisonDimension>();
for (const source of sources) {
if (source.startsWith("terminal_")) dimensions.add("terminal");
else if (source === "interaction") dimensions.add("interaction");
else if (source === "lifecycle") dimensions.add("exit");
else if (source === "filesystem") dimensions.add("filesystem");
else if (source === "process") dimensions.add("process");
}
return dimensions;
};
/** Whether a trace specification covers every observed source in a dimension. */
export const traceCoversObservedDimension = (
dimension: ProcessComparisonDimension,
sources: ReadonlySet<ProcessTraceSource>,
left: ProcessCapture,
right: ProcessCapture,
): boolean => {
const any = <Value>(
leftValues: readonly Value[],
rightValues: readonly Value[],
): boolean => leftValues.length > 0 || rightValues.length > 0;
switch (dimension) {
case "terminal":
return (
(!any(left.frames, right.frames) || sources.has("terminal_raw")) &&
(!any(left.rendered_frames, right.rendered_frames) ||
sources.has("terminal_rendered"))
);
case "interaction":
return sources.has("interaction");
case "exit":
return sources.has("lifecycle");
case "filesystem":
return false;
case "process":
return sources.has("process");
}
};