mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 09:55:46 +00:00
* 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.
83 lines
3.0 KiB
TypeScript
83 lines
3.0 KiB
TypeScript
import { chmod, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { createCli } from "./cli.js";
|
|
import { createSystemDoctorHost } from "./doctorRuntime.js";
|
|
import { captureProcessScenarioFile } from "./application/ProcessCli.js";
|
|
import { runCapabilityStatus } from "./application/DirectAnalysisStatus.js";
|
|
import { probeProcessCaptureCapability } from "./application/ProcessHarness.js";
|
|
import { parseEvidence } from "./domain/evidence.js";
|
|
import { parseProcessCapture } from "./domain/processCapture.js";
|
|
|
|
describe("the CLI takes its environment as an input", () => {
|
|
it("builds from an explicitly supplied environment", () => {
|
|
expect(createCli({ REA_LOG_LEVEL: "debug" })).toBeDefined();
|
|
expect(createCli({})).toBeDefined();
|
|
});
|
|
|
|
it("still builds with no environment supplied", () => {
|
|
// The default keeps production behaviour identical.
|
|
expect(createCli()).toBeDefined();
|
|
expect(createSystemDoctorHost()).toBeDefined();
|
|
});
|
|
|
|
it("resolves from injected PATH and inherits injected env with scenario overrides", async ({
|
|
skip,
|
|
}) => {
|
|
const capability = await probeProcessCaptureCapability();
|
|
if (!capability.available) {
|
|
skip("Process capture is unavailable on this host");
|
|
return;
|
|
}
|
|
|
|
const root = await mkdtemp(join(tmpdir(), "rea-cli-env-process-"));
|
|
const bin = join(root, "bin");
|
|
const executable = join(bin, "rea-injected-process-probe");
|
|
const scenarioPath = join(root, "scenario.json");
|
|
try {
|
|
await mkdir(bin);
|
|
await writeFile(
|
|
executable,
|
|
[
|
|
"#!/bin/sh",
|
|
'printf "%s|%s\\n" "$REA_CAPTURE_INJECTED_MARKER" "$REA_CAPTURE_SCENARIO_OVERRIDE"',
|
|
].join("\n"),
|
|
);
|
|
await chmod(executable, 0o755);
|
|
await writeFile(
|
|
scenarioPath,
|
|
JSON.stringify({
|
|
executable: "rea-injected-process-probe",
|
|
working_directory: root,
|
|
environment: { REA_CAPTURE_SCENARIO_OVERRIDE: "scenario-value" },
|
|
}),
|
|
);
|
|
|
|
const result = await captureProcessScenarioFile(scenarioPath, {
|
|
PATH: bin,
|
|
REA_CAPTURE_INJECTED_MARKER: "injected-value",
|
|
REA_CAPTURE_SCENARIO_OVERRIDE: "host-value",
|
|
});
|
|
const evidence = parseEvidence(result);
|
|
const capture = parseProcessCapture(evidence.normalized_result);
|
|
expect(capture.frames.map(({ data }) => data).join("")).toContain(
|
|
"injected-value|scenario-value",
|
|
);
|
|
} finally {
|
|
await rm(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("reports session status from a supplied environment", async () => {
|
|
// An invalid configuration must surface through the caller's supplied
|
|
// environment rather than whatever the process happens to carry.
|
|
const result = await runCapabilityStatus(undefined, {
|
|
REA_LOG_LEVEL: "not-a-level",
|
|
});
|
|
expect(result).toMatchObject({ error: expect.anything() });
|
|
});
|
|
});
|