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:
@@ -2,9 +2,17 @@ import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { expect, it } from "vitest";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { withArtifactResourceScope } from "../../fixtures/artifactInventory.js";
|
||||
import { execFileOutput } from "../../../src/process/ExecFileOutput.js";
|
||||
import { readReferenceSourceVcs } from "../../../src/application/ReferenceSourceVcsAdapter.js";
|
||||
|
||||
const readVcs = (root: string, signal?: AbortSignal) =>
|
||||
withArtifactResourceScope(async (resources) => {
|
||||
const result = await readReferenceSourceVcs(root, resources, signal);
|
||||
if (!result.ok) throw result.error;
|
||||
return result.value;
|
||||
});
|
||||
|
||||
it("reads a linked worktree's own branch and detached HEAD through shared Git refs", async () => {
|
||||
const root = await createTestTempDirectory("rea-reference-worktree-");
|
||||
const repository = join(root, "repository");
|
||||
@@ -49,18 +57,18 @@ it("reads a linked worktree's own branch and detached HEAD through shared Git re
|
||||
await execFileOutput("git", ["rev-parse", "HEAD"], { cwd: linked })
|
||||
).stdout.trim();
|
||||
expect(linkedHead).not.toBe(mainHead);
|
||||
expect(await readReferenceSourceVcs(repository)).toEqual({
|
||||
expect(await readVcs(repository)).toEqual({
|
||||
kind: "git",
|
||||
head: mainHead,
|
||||
dirty: null,
|
||||
});
|
||||
expect(await readReferenceSourceVcs(linked)).toEqual({
|
||||
expect(await readVcs(linked)).toEqual({
|
||||
kind: "git",
|
||||
head: linkedHead,
|
||||
dirty: null,
|
||||
});
|
||||
await git("pack-refs", "--all", "--prune");
|
||||
expect(await readReferenceSourceVcs(linked)).toEqual({
|
||||
expect(await readVcs(linked)).toEqual({
|
||||
kind: "git",
|
||||
head: linkedHead,
|
||||
dirty: null,
|
||||
@@ -68,7 +76,7 @@ it("reads a linked worktree's own branch and detached HEAD through shared Git re
|
||||
await execFileOutput("git", ["checkout", "--detach", mainHead], {
|
||||
cwd: linked,
|
||||
});
|
||||
expect(await readReferenceSourceVcs(linked)).toEqual({
|
||||
expect(await readVcs(linked)).toEqual({
|
||||
kind: "git",
|
||||
head: mainHead,
|
||||
dirty: null,
|
||||
@@ -79,7 +87,7 @@ it("reads a linked worktree's own branch and detached HEAD through shared Git re
|
||||
join(relativePointer, ".git"),
|
||||
"gitdir: ../repository/.git\r\n",
|
||||
);
|
||||
expect(await readReferenceSourceVcs(relativePointer)).toEqual({
|
||||
expect(await readVcs(relativePointer)).toEqual({
|
||||
kind: "git",
|
||||
head: mainHead,
|
||||
dirty: null,
|
||||
@@ -87,14 +95,14 @@ it("reads a linked worktree's own branch and detached HEAD through shared Git re
|
||||
// A non-regular loose ref must remain unknown even when packed-refs has
|
||||
// a readable value. The library's promise-API probe is not a source failure.
|
||||
await mkdir(join(repository, ".git", "refs", "heads", "main"));
|
||||
expect(await readReferenceSourceVcs(repository)).toEqual({
|
||||
expect(await readVcs(repository)).toEqual({
|
||||
kind: "unknown",
|
||||
head: null,
|
||||
dirty: null,
|
||||
});
|
||||
const controller = new AbortController();
|
||||
controller.abort();
|
||||
expect(await readReferenceSourceVcs(linked, controller.signal)).toEqual({
|
||||
expect(await readVcs(linked, controller.signal)).toEqual({
|
||||
kind: "unknown",
|
||||
head: null,
|
||||
dirty: null,
|
||||
|
||||
Reference in New Issue
Block a user