refactor(reference): declare the reference-source reader's contract as its entry files (#11577)

* refactor(reference): declare the reference-source reader's entry files for the import workflow

* refactor(reference): keep traversal state, symlink reconciliation and entry failure helpers out of the declared entry files
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 07:29:54 +08:00
1 parent 33557c4715
commit f40476265a
14 files changed
+227 -209

No files matched your search

@@ -1,8 +1,5 @@
import type { BigIntStats } from "node:fs";
import type { Result } from "../domain/result.js";
import type { AnalysisCleanupObservation } from "../domain/analysisErrorBase.js";
import type { ArtifactResourceScope } from "../resources/index.js";
export type ReferenceSourceEntryKind =
| "file"
@@ -95,42 +92,4 @@ export interface ReferenceSourceReaderError {
readonly cause?: unknown;
}
export type PendingDirectory = {
readonly path: string;
};
export type TraversalState = {
readonly resources: ArtifactResourceScope;
readonly root: string;
readonly rootIdentity: BigIntStats;
readonly signal?: AbortSignal;
/** Prepare policy after identity admission and opening, before enumeration; refusal closes the owned handle. */
readonly beforeDirectory?: (
path: string,
) => Promise<ReferenceSourceResult<undefined>>;
readonly shouldExclude?: (
path: string,
kind: ReferenceSourceExclusionKind,
) => boolean;
readonly entries: ReferenceSourceEntry[];
readonly exclusions: Array<{
readonly path: string;
readonly kind: ReferenceSourceExclusionKind;
}>;
readonly pending: PendingDirectory[];
rootFailure?: ReferenceSourceRootFailure;
rootFailureCause?: { readonly value: unknown };
bytesRead: number;
};
export type StableFileRequest = {
readonly resources: ArtifactResourceScope;
readonly root: string;
readonly rootIdentity: BigIntStats;
readonly absolute: string;
readonly path: string;
readonly expected: BigIntStats;
readonly signal?: AbortSignal;
};
export type ReferenceSourceResult<T> = Result<T, ReferenceSourceReaderError>;