mirror of
https://github.com/morluto/rea.git
synced 2026-10-12 02:19:24 +00:00
Require a caller-owned artifact resource scope for source traversal and Git metadata reads. Preserve cancellation, filesystem reasons, partial entries and bytes, and cleanup observations through import and the CLI. Transfer exact failed file owners at regular-file admission and close boundaries, including multiple failures encountered by Git reference resolution. Validation: 169 focused tests passed across 26 files; two Windows-only cases skipped. Build, typecheck, lint, formatting, knip, architecture guards, discovery and docs checks passed. BREAKING CHANGE: Reference source readers and imports require an ArtifactResourceScope. VCS metadata reads return Result, and CLI import failures include observed details and partial evidence.
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { execFileSync } from "node:child_process";
|
|
import { lstat, unlink, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
const [modulePath, root] = process.argv.slice(2);
|
|
if (modulePath === undefined || root === undefined)
|
|
throw new Error("Reference reader FIFO probe requires module and root paths");
|
|
|
|
const { readStableFile } = await import(pathToFileURL(modulePath));
|
|
const { ArtifactResourceScope } = await import(
|
|
new URL("../artifacts/ArtifactResourceScope.js", pathToFileURL(modulePath))
|
|
);
|
|
const resources = new ArtifactResourceScope();
|
|
try {
|
|
const absolute = join(root, "source.txt");
|
|
await writeFile(absolute, "observed regular file\n");
|
|
const expected = await lstat(absolute, { bigint: true });
|
|
await unlink(absolute);
|
|
execFileSync("mkfifo", [absolute]);
|
|
|
|
// Capture the directory after replacement to reach the file-open boundary.
|
|
// The owning test bounds this child if an O_RDONLY FIFO open blocks again.
|
|
const rootIdentity = await lstat(root, { bigint: true });
|
|
const result = await readStableFile({
|
|
resources,
|
|
root,
|
|
rootIdentity,
|
|
absolute,
|
|
path: "source.txt",
|
|
expected,
|
|
});
|
|
assert.equal(result.cleanup, undefined);
|
|
assert.equal(result.entry.status, "failed");
|
|
assert.equal(result.entry.kind, "file");
|
|
assert.equal(result.entry.code, "changed");
|
|
} finally {
|
|
await resources.close();
|
|
}
|
|
process.stdout.write("changed\n");
|