refactor(process): separate capture implementation from analyst workflows (#988)

* refactor(process): separate capture implementation from analyst workflows

* fix(ci): generate source catalog before shard tests
This commit is contained in:
Ysopwnable
2026-10-08 00:46:21 +08:00
committed by GitHub
parent 5b172b1042
commit 6aa9afb549
98 changed files with 214 additions and 141 deletions
@@ -0,0 +1,45 @@
import type {
FileState,
FilesystemCheckpoint,
} from "../../domain/process/processCapture.js";
/** Classify path-stable filesystem effects between two bounded states. */
export const classifyFilesystemEffects = (
before: readonly FileState[],
after: readonly FileState[],
): FilesystemCheckpoint["effects"] => {
const beforeByPath = new Map(before.map((file) => [file.path, file]));
const afterByPath = new Map(after.map((file) => [file.path, file]));
return [...new Set([...beforeByPath.keys(), ...afterByPath.keys()])]
.sort()
.map((path) => {
const beforeFile = beforeByPath.get(path) ?? null;
const afterFile = afterByPath.get(path) ?? null;
if (beforeFile === null) {
if (afterFile === null)
throw new TypeError(`Filesystem effect ${path} has no file state`);
return {
path,
status: "created",
before: null,
after: afterFile,
} as const;
}
if (afterFile === null)
return {
path,
status: "deleted",
before: beforeFile,
after: null,
} as const;
return {
path,
status:
JSON.stringify(beforeFile) === JSON.stringify(afterFile)
? "unchanged"
: "modified",
before: beforeFile,
after: afterFile,
} as const;
});
};