fix(workflows): retain staged output ownership and cancellation semantics
Give atomic Evidence and snapshot writes an explicit resource owner, preserve primary failures and completed publication receipts, and retry retained staging cleanup at the owning lifecycle. Verify inode identity before publishing or deleting; unknown path disappearance remains a cleanup failure. Keep snapshot admission reusable when a session closes and reopens. Consolidate JavaScript source-scope classification so cancellation cannot fabricate failures for unselected files. Classify configuration failures as invalid input. Remove stale assertions and reuse shared test cleanup ownership. Validation: 266 focused tests before final ownership tightening, 108 affected tests afterward, static and documentation checks, actual invalid-configuration CLI behavior, and isolated test temporary-directory hygiene. Refs #1968
This commit is contained in:
@@ -15,14 +15,14 @@ import {
|
||||
isManagedToolName,
|
||||
type ManagedToolName,
|
||||
} from "../contracts/managed/managedToolContracts.js";
|
||||
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
||||
import {
|
||||
EvidenceFileError,
|
||||
EvidenceIntegrityError,
|
||||
} from "../domain/evidenceErrors.js";
|
||||
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
||||
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import { access } from "node:fs/promises";
|
||||
import {
|
||||
readAnalysisSnapshot,
|
||||
writeAnalysisSnapshot,
|
||||
} from "./binary/AnalysisSnapshotFiles.js";
|
||||
import { readAnalysisSnapshot } from "./binary/AnalysisSnapshotFiles.js";
|
||||
import { parseBinaryTarget } from "./BinaryTargetResolver.js";
|
||||
import type { BinaryTarget } from "../domain/binaryTargetTypes.js";
|
||||
import {
|
||||
@@ -334,13 +334,19 @@ const runAnalysis = async (
|
||||
const snapshot = session.exportAnalysisSnapshot();
|
||||
if (!snapshot.ok)
|
||||
return cliError(snapshot.error.retainPartialObservation(evidence));
|
||||
const written = await writeAnalysisSnapshot(
|
||||
const written = await session.writeAnalysisSnapshot(
|
||||
snapshot.value,
|
||||
snapshotPath,
|
||||
true,
|
||||
);
|
||||
if (!written.ok)
|
||||
return cliError(written.error.retainPartialObservation(evidence));
|
||||
if (!written.ok) {
|
||||
const recovered =
|
||||
written.error instanceof EvidenceFileError &&
|
||||
written.error.published !== undefined &&
|
||||
(await session.closeWriteResources()).ok;
|
||||
if (!recovered)
|
||||
return cliError(written.error.retainPartialObservation(evidence));
|
||||
}
|
||||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
||||
import {
|
||||
EvidenceFileError,
|
||||
EvidenceIntegrityError,
|
||||
} from "../domain/evidenceErrors.js";
|
||||
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import type { EvidenceBundle } from "../domain/evidenceBundle.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import { compareBundles } from "../domain/bundleComparison.js";
|
||||
import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
|
||||
import {
|
||||
readEvidenceBundle,
|
||||
writeEvidenceBundle,
|
||||
@@ -31,10 +35,33 @@ export const exportEvidenceBundleCommand = async (
|
||||
): Promise<Result<JsonValue, AnalysisError>> => {
|
||||
const loaded = await readEvidenceBundle(sourcePath);
|
||||
if (!loaded.ok) return loaded;
|
||||
return projectWrite(
|
||||
const resources = new ArtifactResourceScope();
|
||||
const written = await writeEvidenceBundle(
|
||||
loaded.value,
|
||||
await writeEvidenceBundle(loaded.value, outputPath, overwrite),
|
||||
outputPath,
|
||||
overwrite,
|
||||
resources,
|
||||
);
|
||||
if (written.ok) return projectWrite(loaded.value, written);
|
||||
|
||||
let cleanupSucceeded = false;
|
||||
try {
|
||||
await resources.close();
|
||||
cleanupSucceeded = true;
|
||||
} catch {
|
||||
// The original error cause retains the same staged-output owner for diagnostics.
|
||||
}
|
||||
if (
|
||||
cleanupSucceeded &&
|
||||
written.error instanceof EvidenceFileError &&
|
||||
written.error.published
|
||||
) {
|
||||
return projectWrite(loaded.value, {
|
||||
ok: true,
|
||||
value: written.error.published,
|
||||
});
|
||||
}
|
||||
return written;
|
||||
};
|
||||
|
||||
/** Compare two validated canonical Evidence bundles without session state. */
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from "../domain/jsonSerialization.js";
|
||||
import { readJsonFile, writeTextParts } from "./JsonFiles.js";
|
||||
import { RegularFileCleanupFailure } from "./RegularFileRead.js";
|
||||
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
|
||||
|
||||
type EvidenceReadFailure =
|
||||
| EvidenceFileError
|
||||
@@ -105,6 +106,7 @@ export const writeEvidenceBundle = async (
|
||||
bundle: EvidenceBundle,
|
||||
path: string,
|
||||
overwrite: boolean,
|
||||
resources: ArtifactResourceScope,
|
||||
signal?: AbortSignal,
|
||||
): Promise<
|
||||
Result<
|
||||
@@ -128,6 +130,7 @@ export const writeEvidenceBundle = async (
|
||||
bufferedJsonParts(canonicalJsonParts(checked)),
|
||||
path,
|
||||
overwrite,
|
||||
resources,
|
||||
signal === undefined
|
||||
? undefined
|
||||
: { signal, operation: "export_evidence_bundle" },
|
||||
|
||||
+123
-16
@@ -5,12 +5,14 @@ import {
|
||||
open,
|
||||
realpath,
|
||||
rename,
|
||||
rm,
|
||||
type FileHandle,
|
||||
} from "node:fs/promises";
|
||||
import { basename, dirname, resolve } from "node:path";
|
||||
|
||||
import { EvidenceFileError } from "../domain/evidenceErrors.js";
|
||||
import {
|
||||
EvidenceFileError,
|
||||
type PublishedEvidenceFile,
|
||||
} from "../domain/evidenceErrors.js";
|
||||
import {
|
||||
AnalysisCancelledError,
|
||||
AnalysisResourceConstraintError,
|
||||
@@ -22,6 +24,10 @@ import {
|
||||
type JsonObjectMemberReader,
|
||||
} from "./JsonInputFile.js";
|
||||
import { NonRegularFileReadError } from "../filesystem/RegularFile.js";
|
||||
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
|
||||
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
|
||||
import { OwnedFileHandle } from "../filesystem/OwnedFileHandle.js";
|
||||
import { OwnedStagedOutput } from "../filesystem/OwnedStagedOutput.js";
|
||||
|
||||
/** Request control and its owning operation for an interruptible atomic write. */
|
||||
export interface TextWriteCancellation {
|
||||
@@ -119,28 +125,57 @@ export const writeTextFile = async (
|
||||
encoded: string,
|
||||
path: string,
|
||||
overwrite: boolean,
|
||||
resources: ArtifactResourceScope,
|
||||
): Promise<TextWriteResult<EvidenceFileError>> =>
|
||||
writeTextParts([encoded], path, overwrite);
|
||||
writeTextParts([encoded], path, overwrite, resources);
|
||||
|
||||
/** Publish streamed text atomically unless cancellation wins before publication. */
|
||||
export function writeTextParts(
|
||||
parts: Iterable<string>,
|
||||
path: string,
|
||||
overwrite: boolean,
|
||||
resources: ArtifactResourceScope,
|
||||
): Promise<TextWriteResult<EvidenceFileError>>;
|
||||
/** Pass request control to stop streamed generation before atomic publication. */
|
||||
export function writeTextParts(
|
||||
parts: Iterable<string>,
|
||||
path: string,
|
||||
overwrite: boolean,
|
||||
resources: ArtifactResourceScope,
|
||||
cancellation: TextWriteCancellation | undefined,
|
||||
): Promise<TextWriteResult>;
|
||||
export async function writeTextParts(
|
||||
export function writeTextParts(
|
||||
parts: Iterable<string>,
|
||||
path: string,
|
||||
overwrite: boolean,
|
||||
resources: ArtifactResourceScope,
|
||||
cancellation?: TextWriteCancellation,
|
||||
): Promise<TextWriteResult> {
|
||||
return resources
|
||||
.run(() =>
|
||||
writeTextPartsOwned(parts, path, overwrite, resources, cancellation),
|
||||
)
|
||||
.catch((cause: unknown) => {
|
||||
const cleanup =
|
||||
cause instanceof ArtifactReaderFailure && cause.cleanup !== undefined
|
||||
? cause.cleanup
|
||||
: undefined;
|
||||
return err(
|
||||
new EvidenceFileError("write", "io", {
|
||||
cause,
|
||||
path: resolve(path),
|
||||
...(cleanup === undefined ? {} : { cleanup }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const writeTextPartsOwned = async (
|
||||
parts: Iterable<string>,
|
||||
path: string,
|
||||
overwrite: boolean,
|
||||
resources: ArtifactResourceScope,
|
||||
cancellation?: TextWriteCancellation,
|
||||
): Promise<TextWriteResult> => {
|
||||
const requestedPath = resolve(path);
|
||||
try {
|
||||
assertWriteActive(cancellation);
|
||||
@@ -165,10 +200,40 @@ export async function writeTextParts(
|
||||
destination,
|
||||
parts,
|
||||
overwrite,
|
||||
resources,
|
||||
cancellation,
|
||||
);
|
||||
return ok({ path: requestedPath, bytes });
|
||||
} catch (cause: unknown) {
|
||||
if (cause instanceof StagedOutputCleanupFailure) {
|
||||
const cleanup = {
|
||||
reason: failureMessage(cause.cleanupCause),
|
||||
resources: [cause.owner.directory],
|
||||
};
|
||||
if (cause.outcome.ok)
|
||||
return err(
|
||||
new EvidenceFileError("write", "io", {
|
||||
cause,
|
||||
path: requestedPath,
|
||||
cleanup,
|
||||
published: { ...cause.outcome.value, path: requestedPath },
|
||||
}),
|
||||
);
|
||||
if (cause.outcome.error instanceof AnalysisCancelledError)
|
||||
return err(
|
||||
new AnalysisCancelledError(cause.outcome.error.operation, {
|
||||
cause,
|
||||
cleanup,
|
||||
}),
|
||||
);
|
||||
return err(
|
||||
new EvidenceFileError("write", missingOrIo(cause.outcome.error), {
|
||||
cause,
|
||||
path: requestedPath,
|
||||
cleanup,
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (
|
||||
cancellation?.signal.aborted === true &&
|
||||
cause instanceof AnalysisCancelledError &&
|
||||
@@ -189,7 +254,7 @@ export async function writeTextParts(
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** A missing path or parent is a selection error, not a permission failure. */
|
||||
const missingOrIo = (cause: unknown): "missing" | "io" => {
|
||||
@@ -201,33 +266,75 @@ const publishFile = async (
|
||||
destination: string,
|
||||
parts: Iterable<string>,
|
||||
overwrite: boolean,
|
||||
resources: ArtifactResourceScope,
|
||||
cancellation?: TextWriteCancellation,
|
||||
): Promise<number> => {
|
||||
const stagingDirectory = await mkdtemp(
|
||||
resolve(dirname(destination), ".rea-write-"),
|
||||
);
|
||||
const owner = await OwnedStagedOutput.create(stagingDirectory);
|
||||
let outcome: Result<PublishedEvidenceFile, unknown>;
|
||||
const staged = resolve(stagingDirectory, "content");
|
||||
try {
|
||||
const staged = resolve(stagingDirectory, "content");
|
||||
const file = await open(staged, "wx", 0o600);
|
||||
let bytes = 0;
|
||||
await owner.setFile(new OwnedFileHandle(file));
|
||||
let written: Result<number, unknown>;
|
||||
try {
|
||||
bytes = await writeStagedParts(file, parts, cancellation);
|
||||
const bytes = await writeStagedParts(file, parts, cancellation);
|
||||
assertWriteActive(cancellation);
|
||||
await file.sync();
|
||||
} finally {
|
||||
await file.close();
|
||||
written = ok(bytes);
|
||||
} catch (cause: unknown) {
|
||||
written = err(cause);
|
||||
}
|
||||
// Once submitted, the atomic publication can win a later cancellation race.
|
||||
try {
|
||||
await owner.closeFile();
|
||||
} catch (cause: unknown) {
|
||||
if (written.ok) written = err(cause);
|
||||
}
|
||||
if (!written.ok) throw written.error;
|
||||
// Once submitted, atomic publication can win a later cancellation race.
|
||||
assertWriteActive(cancellation);
|
||||
if (overwrite) await rename(staged, destination);
|
||||
await owner.assertReadyForPublication(staged);
|
||||
assertWriteActive(cancellation);
|
||||
if (overwrite) {
|
||||
await rename(staged, destination);
|
||||
owner.recordPublishedRename();
|
||||
}
|
||||
// A hard link publishes complete bytes atomically and cannot replace an existing name.
|
||||
else await link(staged, destination);
|
||||
return bytes;
|
||||
} finally {
|
||||
await rm(stagingDirectory, { recursive: true, force: true });
|
||||
outcome = ok({ path: destination, bytes: written.value });
|
||||
} catch (cause: unknown) {
|
||||
outcome = err(cause);
|
||||
}
|
||||
|
||||
// One cleanup phase owns both the open descriptor (if any) and its staging directory.
|
||||
const released = await resources.release({
|
||||
kind: "staged-output",
|
||||
resource: owner.directory,
|
||||
output: owner,
|
||||
});
|
||||
if (released.kind === "failed")
|
||||
throw new StagedOutputCleanupFailure(outcome, released.cause, owner);
|
||||
if (!outcome.ok) throw outcome.error;
|
||||
return outcome.value.bytes;
|
||||
};
|
||||
|
||||
class StagedOutputCleanupFailure extends Error {
|
||||
constructor(
|
||||
readonly outcome: Result<PublishedEvidenceFile, unknown>,
|
||||
readonly cleanupCause: unknown,
|
||||
readonly owner: OwnedStagedOutput,
|
||||
) {
|
||||
super("Staged output cleanup failed", {
|
||||
cause: outcome.ok ? cleanupCause : outcome.error,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const failureMessage = (cause: unknown): string =>
|
||||
cause instanceof Error ? cause.message || cause.name : String(cause);
|
||||
|
||||
const writeStagedParts = async (
|
||||
file: FileHandle,
|
||||
parts: Iterable<string>,
|
||||
|
||||
@@ -16,6 +16,7 @@ import type { AnalysisResourceConstraintError } from "../../domain/analysisError
|
||||
import { AnalysisCancelledError } from "../../domain/analysisErrorCore.js";
|
||||
import { readJsonObjectMembersFile, writeTextFile } from "../JsonFiles.js";
|
||||
import type { JsonObjectMemberReader } from "../JsonInputFile.js";
|
||||
import type { ArtifactResourceScope } from "../../artifacts/ArtifactResourceScope.js";
|
||||
|
||||
type SnapshotFailure = EvidenceFileError | EvidenceIntegrityError;
|
||||
|
||||
@@ -118,6 +119,7 @@ export const writeAnalysisSnapshot = async (
|
||||
snapshot: AnalysisSnapshot,
|
||||
path: string,
|
||||
overwrite: boolean,
|
||||
resources: ArtifactResourceScope,
|
||||
): Promise<
|
||||
Result<{ readonly path: string; readonly bytes: number }, SnapshotFailure>
|
||||
> => {
|
||||
@@ -129,7 +131,7 @@ export const writeAnalysisSnapshot = async (
|
||||
new EvidenceIntegrityError(snapshotValidationMessage(cause), { cause }),
|
||||
);
|
||||
}
|
||||
return writeTextFile(encoded, path, overwrite);
|
||||
return writeTextFile(encoded, path, overwrite, resources);
|
||||
};
|
||||
|
||||
const snapshotValidationMessage = (cause: unknown): string =>
|
||||
|
||||
@@ -24,7 +24,6 @@ import type {
|
||||
BinarySessionPort,
|
||||
SavedAnalysisSnapshot,
|
||||
} from "./BinarySessionPort.js";
|
||||
import { writeAnalysisSnapshot } from "./AnalysisSnapshotFiles.js";
|
||||
import {
|
||||
SessionProviderRouter,
|
||||
type SessionProviderRoute,
|
||||
@@ -376,7 +375,7 @@ export class BinarySession
|
||||
await this.#drainCalls(admittedThrough);
|
||||
const snapshot = this.exportAnalysisSnapshot();
|
||||
if (!snapshot.ok) return snapshot;
|
||||
const written = await writeAnalysisSnapshot(
|
||||
const written = await this.writeAnalysisSnapshot(
|
||||
snapshot.value,
|
||||
path,
|
||||
overwrite,
|
||||
@@ -421,7 +420,16 @@ export class BinarySession
|
||||
);
|
||||
this.clearSessionRecords();
|
||||
this.#clearRuntimeAvailability();
|
||||
return closed;
|
||||
const fileResources = await this.closeWriteResources();
|
||||
if (!closed.ok && !fileResources.ok)
|
||||
return err(
|
||||
analysisErrorWithCleanupFailure(
|
||||
closed.error,
|
||||
fileResources.error,
|
||||
"close_binary",
|
||||
),
|
||||
);
|
||||
return closed.ok ? fileResources : closed;
|
||||
}
|
||||
|
||||
async #retireClient(
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { EvidenceBundle } from "../../domain/evidenceBundle.js";
|
||||
import type { JsonValue } from "../../domain/jsonValue.js";
|
||||
import { evidenceBundleForTarget } from "../../domain/evidenceBundle.js";
|
||||
import {
|
||||
EvidenceFileError,
|
||||
EvidenceIntegrityError,
|
||||
AnalysisSnapshotMismatchError,
|
||||
} from "../../domain/evidenceErrors.js";
|
||||
@@ -24,6 +25,9 @@ import type {
|
||||
} from "../AnalysisProvider.js";
|
||||
import { AnalysisSnapshotCache } from "./AnalysisSnapshotCache.js";
|
||||
import { InvestigationRecords } from "../investigation/InvestigationRecords.js";
|
||||
import { ArtifactResourceScope } from "../../artifacts/ArtifactResourceScope.js";
|
||||
import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
||||
import { writeAnalysisSnapshot as writeSnapshotFile } from "./AnalysisSnapshotFiles.js";
|
||||
|
||||
const SNAPSHOT_MUTATION_RECOVERY =
|
||||
"Export session observations through export_evidence_bundle if needed. Close the active target without saving a snapshot, then reopen it before importing or saving a snapshot.";
|
||||
@@ -45,6 +49,7 @@ export interface WorkflowSnapshotRecordInput {
|
||||
/** Own binary snapshots and coordinate the composed investigation records. */
|
||||
export abstract class BinarySessionRecords {
|
||||
readonly #records: InvestigationRecords;
|
||||
readonly #writeResources = new ArtifactResourceScope();
|
||||
readonly #snapshot = new AnalysisSnapshotCache();
|
||||
#snapshotInvalidated = false;
|
||||
readonly #snapshotListeners = new Set<() => void | Promise<void>>();
|
||||
@@ -89,6 +94,39 @@ export abstract class BinarySessionRecords {
|
||||
return this.#records.evidenceBundleForSerialization();
|
||||
}
|
||||
|
||||
/** Persist one provider-neutral snapshot under this session's resource owner. */
|
||||
writeAnalysisSnapshot(
|
||||
snapshot: AnalysisSnapshot,
|
||||
path: string,
|
||||
overwrite: boolean,
|
||||
): Promise<
|
||||
Result<{ readonly path: string; readonly bytes: number }, AnalysisError>
|
||||
> {
|
||||
return writeSnapshotFile(snapshot, path, overwrite, this.#writeResources);
|
||||
}
|
||||
|
||||
/** Retry and release staged snapshot files at the owning session shutdown. */
|
||||
async closeWriteResources(): Promise<Result<null, AnalysisError>> {
|
||||
try {
|
||||
await this.#writeResources.retryCleanup();
|
||||
return ok(null);
|
||||
} catch (cause: unknown) {
|
||||
const observation = ArtifactReaderFailure.cleanupObservation(
|
||||
cause,
|
||||
"analysis snapshot staging",
|
||||
);
|
||||
return err(
|
||||
new EvidenceFileError("write", "io", {
|
||||
cause,
|
||||
cleanup: {
|
||||
reason: observation.reason,
|
||||
resources: observation.resources,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
importEvidenceBundle(
|
||||
bundle: unknown,
|
||||
): Result<number, EvidenceIntegrityError> {
|
||||
|
||||
@@ -146,22 +146,17 @@ export const analyzeAndAdoptJavaScriptArtifactFiles = async (
|
||||
for (const file of fileSet.files) {
|
||||
try {
|
||||
await setImmediate();
|
||||
if (signal?.aborted === true)
|
||||
throw new AnalysisCancelledError("analyze_javascript_application");
|
||||
if (
|
||||
!file.text.included &&
|
||||
file.text.reason === "outside-analysis-scope"
|
||||
) {
|
||||
state.files.push({ file, javascript: null, semantic: null });
|
||||
if (file.kind === "javascript")
|
||||
projection.recordUnavailableFile(
|
||||
file,
|
||||
"Source was not analyzed because it is outside the caller-selected source_paths.",
|
||||
null,
|
||||
"incomplete-module",
|
||||
if (classifyOutsideAnalysisScope(file, state, projection)) {
|
||||
if (signal?.aborted === true) {
|
||||
interruption = new AnalysisCancelledError(
|
||||
"analyze_javascript_application",
|
||||
);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (signal?.aborted === true)
|
||||
throw new AnalysisCancelledError("analyze_javascript_application");
|
||||
await beforeFile(file, selectedFileIndex++, selectedFileCount);
|
||||
if (file.kind !== "javascript" || !file.text.included) {
|
||||
const steps = analyzeArtifactFileSteps(file, {
|
||||
@@ -287,20 +282,7 @@ export const analyzeAndAdoptJavaScriptArtifactFiles = async (
|
||||
};
|
||||
for (const file of fileSet.files) {
|
||||
if (analyzedPaths.has(file.path)) continue;
|
||||
if (
|
||||
!file.text.included &&
|
||||
file.text.reason === "outside-analysis-scope"
|
||||
) {
|
||||
state.files.push({ file, javascript: null, semantic: null });
|
||||
if (file.kind === "javascript")
|
||||
projection.recordUnavailableFile(
|
||||
file,
|
||||
"Source was not analyzed because it is outside the caller-selected source_paths.",
|
||||
null,
|
||||
"incomplete-module",
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (classifyOutsideAnalysisScope(file, state, projection)) continue;
|
||||
state.files.push({
|
||||
file,
|
||||
javascript: null,
|
||||
@@ -370,10 +352,7 @@ function* analyzeArtifactFileSteps<
|
||||
context: ArtifactAnalysisContext<SemanticIr>,
|
||||
): Generator<void, void> {
|
||||
const { state } = context;
|
||||
if (!file.text.included && file.text.reason === "outside-analysis-scope") {
|
||||
state.files.push({ file, javascript: null, semantic: null });
|
||||
return;
|
||||
}
|
||||
if (classifyOutsideAnalysisScope(file, state)) return;
|
||||
addStructuredObservations(file, state);
|
||||
if (file.kind === "html" && file.text.included)
|
||||
state.htmlScripts.push(...parseHtmlScripts(file.path, file.text.value));
|
||||
@@ -421,6 +400,26 @@ function* analyzeArtifactFileSteps<
|
||||
if (analysis.parse_status === "failed") state.parseFailures += 1;
|
||||
}
|
||||
|
||||
const classifyOutsideAnalysisScope = <
|
||||
SemanticIr extends JavaScriptModuleSemanticIr,
|
||||
>(
|
||||
file: JavaScriptArtifactFile,
|
||||
state: MutableArtifactAnalysis<SemanticIr>,
|
||||
projection?: JavaScriptSemanticGraphProjection,
|
||||
): boolean => {
|
||||
if (file.text.included || file.text.reason !== "outside-analysis-scope")
|
||||
return false;
|
||||
state.files.push({ file, javascript: null, semantic: null });
|
||||
if (file.kind === "javascript")
|
||||
projection?.recordUnavailableFile(
|
||||
file,
|
||||
"Source was not analyzed because it is outside the caller-selected source_paths.",
|
||||
null,
|
||||
"incomplete-module",
|
||||
);
|
||||
return true;
|
||||
};
|
||||
|
||||
const addSourceMap = (
|
||||
file: JavaScriptArtifactFile,
|
||||
context: ArtifactAnalysisContext<JavaScriptModuleSemanticIr>,
|
||||
|
||||
Reference in New Issue
Block a user