fix(reference)!: retain source and metadata cleanup owners
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.
This commit is contained in:
@@ -6,18 +6,12 @@ import { describe, expect } from "vitest";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
||||
const invalidRootOutput = {
|
||||
error: "Import failed",
|
||||
category: "invalid_input",
|
||||
message:
|
||||
"Reference source directory could not be opened. Check that the path exists, is readable, and points to a directory.",
|
||||
};
|
||||
|
||||
const unsupportedHostOutput = {
|
||||
error: "Import failed",
|
||||
category: "unsupported_host",
|
||||
message:
|
||||
"Safe no-follow file opens are unavailable on this host. Import the source tree with REA on Linux (including WSL) or macOS.",
|
||||
message: expect.stringContaining(
|
||||
"Safe no-follow file opens are unavailable on this host.",
|
||||
),
|
||||
};
|
||||
|
||||
const permissionChecksUnavailable =
|
||||
@@ -105,6 +99,15 @@ describe("compiled reference-source import preflight failures", () => {
|
||||
...(scenario.logging ? { REA_LOG_LEVEL: "info" } : {}),
|
||||
},
|
||||
});
|
||||
const rootReason =
|
||||
scenario.rootKind === "missing"
|
||||
? "Reference source root could not be resolved"
|
||||
: "Reference source root is not a directory";
|
||||
const invalidRootOutput = {
|
||||
error: "Import failed",
|
||||
category: "invalid_input",
|
||||
message: expect.stringContaining(rootReason),
|
||||
};
|
||||
if (scenario.fullOutput) {
|
||||
// Incur's legacy wrapper remains unchanged; operation status is
|
||||
// conveyed by the exit code and command log, not this `ok` field.
|
||||
@@ -113,8 +116,12 @@ describe("compiled reference-source import preflight failures", () => {
|
||||
data: invalidRootOutput,
|
||||
});
|
||||
} else {
|
||||
expect(result.json).toEqual(invalidRootOutput);
|
||||
expect(result.json).toMatchObject(invalidRootOutput);
|
||||
}
|
||||
expect(JSON.stringify(result.json)).toContain(
|
||||
"Check that the path exists, is readable, and points to a directory.",
|
||||
);
|
||||
expect(JSON.stringify(result.json)).toContain(root);
|
||||
expect.soft(result.exitCode).toBe(1);
|
||||
if (scenario.logging) {
|
||||
const records: unknown[] = result.stderr
|
||||
@@ -157,12 +164,15 @@ describe("compiled reference-source import preflight failures", () => {
|
||||
XDG_CACHE_HOME: directory,
|
||||
},
|
||||
});
|
||||
expect(result.json).toEqual({
|
||||
expect(result.json).toMatchObject({
|
||||
error: "Import failed",
|
||||
category: "execution_failure",
|
||||
message:
|
||||
"Reference source files could not be read. Check directory permissions and try again.",
|
||||
message: expect.stringContaining("EACCES: permission denied"),
|
||||
});
|
||||
expect(JSON.stringify(result.json)).toContain(root);
|
||||
expect(JSON.stringify(result.json)).toContain(
|
||||
"Check directory permissions and try again.",
|
||||
);
|
||||
expect(result.exitCode).toBe(1);
|
||||
} finally {
|
||||
await chmod(parent, 0o700);
|
||||
|
||||
Reference in New Issue
Block a user