From a03f977c25949c3ca922a9536674db9bad0c65a7 Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Thu, 18 Jun 2026 16:09:09 +0000 Subject: [PATCH] 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) --- gitnexus/bench/impact-pdg/blast-radius.mjs | 6 ++++-- gitnexus/src/mcp/local/local-backend.ts | 9 ++------- gitnexus/src/mcp/local/pdg-impact.ts | 8 ++------ 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/gitnexus/bench/impact-pdg/blast-radius.mjs b/gitnexus/bench/impact-pdg/blast-radius.mjs index aefb26f9a..45cc3994f 100644 --- a/gitnexus/bench/impact-pdg/blast-radius.mjs +++ b/gitnexus/bench/impact-pdg/blast-radius.mjs @@ -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, diff --git a/gitnexus/src/mcp/local/local-backend.ts b/gitnexus/src/mcp/local/local-backend.ts index 8c6ace8d5..fcc3fa03d 100644 --- a/gitnexus/src/mcp/local/local-backend.ts +++ b/gitnexus/src/mcp/local/local-backend.ts @@ -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, diff --git a/gitnexus/src/mcp/local/pdg-impact.ts b/gitnexus/src/mcp/local/pdg-impact.ts index 74cd2bb96..fd9949776 100644 --- a/gitnexus/src/mcp/local/pdg-impact.ts +++ b/gitnexus/src/mcp/local/pdg-impact.ts @@ -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; - statementPreciseByDepthCounts?: Record; - statementPreciseImpactedCount?: number; - statementPrecision?: number | null; + // Statement-precise (proven) inter-procedural reach lives ONLY under + // `pdgInterprocedural` (the scoped namespace) — see PdgInterproceduralImpact. pdgInterprocedural?: PdgInterproceduralImpact; pdgEvidence?: PdgImpactEvidenceSummary; }