refactor(impact): single-source the statement-precise fields under pdgInterprocedural

statementPreciseByDepth / *Counts / *ImpactedCount / statementPrecision were
emitted both at the top level of the impact result and nested under
pdgInterprocedural, doubling the contract surface and risking incoherence if one
were mutated. Keep them only under pdgInterprocedural (the scoped namespace),
drop the top-level duplicates from PdgImpactBaseResult and the composer, and
point the blast-radius reader at the single nested path (no fallback chain).

Addresses PR #2227 tri-review finding (maintainability).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gergo Magyar 2026-06-18 16:09:09 +00:00
parent 7955a534e2
commit a03f977c25
3 changed files with 8 additions and 15 deletions

View file

@ -263,7 +263,7 @@ async function run() {
// from the criterion's dependence slice. Tighter than callgraph when the
// changed line reaches only some of the function's callees.
const preciseSyms = symbolSetFromByDepth(
pdg?.statementPreciseByDepth ?? pdg?.pdgInterprocedural?.statementPreciseByDepth ?? {},
pdg?.pdgInterprocedural?.statementPreciseByDepth ?? {},
);
const pdgOnly = [...pdgSyms].filter((x) => !cgSyms.has(x)).length;
const cgOnly = [...cgSyms].filter((x) => !pdgSyms.has(x)).length;
@ -280,7 +280,9 @@ async function run() {
pdgSymbols: pdgSyms.size,
statementPreciseSymbols: preciseSyms.size,
statementPrecision:
typeof pdg?.statementPrecision === 'number' ? round(pdg.statementPrecision) : null,
typeof pdg?.pdgInterprocedural?.statementPrecision === 'number'
? round(pdg.pdgInterprocedural.statementPrecision)
: null,
pdgOnly,
cgOnly,
epistemic: pdg?.epistemic ?? null,

View file

@ -5028,13 +5028,8 @@ export class LocalBackend {
byDepthCounts,
interproceduralByDepth,
interproceduralByDepthCounts,
// Statement-precise (proven) inter-procedural reach — additive; tighter than
// `interproceduralByDepth` for a line-seeded downstream slice, equal to it
// otherwise. `statementPrecision` = |proven| / |proven + unproven|.
statementPreciseByDepth,
statementPreciseByDepthCounts,
statementPreciseImpactedCount: provenBridgeCount,
statementPrecision,
// Statement-precise (proven) inter-procedural reach is emitted ONLY under
// `pdgInterprocedural` below — a single source, no top-level duplicate.
affected_processes: affectedProcesses,
affected_modules: affectedModules,
byDepth,

View file

@ -348,12 +348,8 @@ export interface PdgImpactBaseResult extends PdgImpactParityFields {
interproceduralEpistemic?: string;
interproceduralBoundaries?: unknown[];
interproceduralError?: string;
// Statement-precise (proven) inter-procedural reach, surfaced at the top level
// alongside interproceduralByDepth (also nested under pdgInterprocedural).
statementPreciseByDepth?: Record<number, unknown[]>;
statementPreciseByDepthCounts?: Record<number, number>;
statementPreciseImpactedCount?: number;
statementPrecision?: number | null;
// Statement-precise (proven) inter-procedural reach lives ONLY under
// `pdgInterprocedural` (the scoped namespace) — see PdgInterproceduralImpact.
pdgInterprocedural?: PdgInterproceduralImpact;
pdgEvidence?: PdgImpactEvidenceSummary;
}