Files
rea/tests/boundary/filesystem/cliJsonInputCancellation.test.ts
7a0c47bfa4 feat(environment): export an environment manifest as an agent environment bundle (#4999)
Export an authenticated capture and environment manifest as a pinned agentenv bundle with provenance, a replay verifier and smoke task.

Followups preserve immutable input ownership, bounded discovery, caller paths and numeric values; bind bundle writes and package copying to retained filesystem owners; verify POSIX modes; retain cleanup authority; and verify framework/npm executable selection. Default MCP remains stdio.

Validation: pinned Linux toolchain, typecheck/build/lint/format/docs/knip, 452 focused tests, ten product-catalog cases, real GitHub response replay in the generated non-root Docker image, and the real pinned agentenv framework smoke workflow. Platform and resource-measurement limits are recorded in the feature verification document.

Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-20 05:29:43 +08:00

46 lines
1.5 KiB
TypeScript

import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect, it } from "vitest";
import { parseCliJsonInput } from "../../../src/cliJsonInput.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
it("reports an already-cancelled inline JSON read as cancellation", async () => {
const controller = new AbortController();
controller.abort();
expect(
await parseCliJsonInput('{"value":1}', "test-input", controller.signal),
).toMatchObject({
ok: false,
error: { code: "cancelled", details: { operation: "test-input" } },
});
});
it("cancels a pending regular-file JSON read through the owning reader", async () => {
const root = await createTestTempDirectory("rea-json-input-cancel-");
const path = join(root, "input.json");
await writeFile(path, '{"value":1}');
const controller = new AbortController();
const result = parseCliJsonInput(path, "test-input", controller.signal);
controller.abort();
expect(await result).toMatchObject({
ok: false,
error: { code: "cancelled", details: { operation: "test-input" } },
});
});
it("cancels cooperative sealing of an owned inline Evidence input", async () => {
const controller = new AbortController();
const input = JSON.stringify(
Array.from({ length: 20000 }, () => ({ value: 1 })),
);
const pending = parseCliJsonInput(input, "test-input", controller.signal, {
snapshot: true,
});
controller.abort();
expect(await pending).toMatchObject({
ok: false,
error: { code: "cancelled" },
});
});