fix: rescan project files when category coverage changes

This commit is contained in:
muena
2026-10-19 12:34:07 +02:00
parent f71e46f735
commit 731c449c33
5 changed files with 33 additions and 3 deletions

View File

@@ -113,6 +113,7 @@ export async function reviseProjectRun(args: {
const { directory, run } = created;
run.origin = previous.origin;
run.revisedFrom = previous.id;
run.entityTypes = previous.entityTypes ? [...previous.entityTypes] : undefined;
run.commentAuthorCoverage = previous.commentAuthorCoverage;
run.reviewAuthorCoverage = previous.reviewAuthorCoverage;
run.mapping = plan.mapping;

View File

@@ -23,6 +23,8 @@ export type ProjectRun = {
projectName: string;
createdAt: string;
mapping: PlaceholderMapping;
/** Categories actually used to analyze the files in this snapshot. */
entityTypes?: EntityType[];
/** Hash of each live project file and its immutable output in this run. */
sourceState?: Record<string, { hash: string; output: string }>;
/** Generic replacement mode for placeholders embedded in code identifiers. */
@@ -472,6 +474,7 @@ export async function updateProjectMapping(projectPath: string,
run.origin = latest.run.origin;
run.revisedFrom = latest.run.id;
run.mapping = mapping;
run.entityTypes = latest.run.entityTypes ? [...latest.run.entityTypes] : undefined;
run.matchModes = { ...latest.run.matchModes };
run.files = latest.run.files.map((file) => ({ ...file }));
run.sourceState = latest.run.sourceState ? { ...latest.run.sourceState } : undefined;
@@ -614,6 +617,13 @@ export async function reusableProjectOutput(run: ProjectRun, directory: string,
return await matchesPreviousOutput(directory, relPath, currentHash) ? relPath : undefined;
}
/** Unknown or changed category coverage requires a new review of unchanged files. */
export function sameEntityTypeCoverage(run: ProjectRun, selected: readonly EntityType[]): boolean {
if (!Array.isArray(run.entityTypes)) return false;
const covered = new Set(run.entityTypes);
return covered.size === new Set(selected).size && selected.every((type) => covered.has(type));
}
/** Only an identical saved file can disambiguate a placeholder reused across runs. */
export async function mappingForMatchingSnapshots(relPath: string, currentHash: string,
earlier: Array<{ run: ProjectRun; directory: string }>): Promise<PlaceholderMapping> {