fix(javascript): converge cyclic aliases with explicit projection widening

Replace initializer-history and full-path enumeration with a finite projection
join at each source read. Retain conservative local returned-reference effects
and disclose precision loss through static, semantic and captured-web results.
Close full-binding callback cycles while preserving narrowed read semantics.

Fixes #4348
Fixes #5138
Refs #4349
Refs #4364

Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Fuxuan-CN <3072252442@qq.com>
This commit is contained in:
morluto
2026-10-19 12:26:54 +08:00
parent 9af0b6113c
commit e4c3d72396
19 changed files with 791 additions and 166 deletions
@@ -1,3 +1,4 @@
import type { JavaScriptSourceRange } from "./javascriptStaticAnalysisTypes.js";
import type { JavaScriptSemanticResourceLimit } from "./javascriptSemanticValueTypes.js";
import type { ApplicationCoverage } from "./javascriptApplicationEvidenceSchemas.js";
import {
@@ -21,26 +22,49 @@ export type JavaScriptSemanticCoverage =
readonly status: "complete";
readonly omittedCount: 0;
readonly resourceLimits?: readonly JavaScriptSemanticResourceLimit[];
readonly widenedReturnedReferences?: readonly JavaScriptSourceRange[];
}
| {
readonly status: "partial";
readonly omittedCount: 0 | null;
readonly resourceLimits?: readonly JavaScriptSemanticResourceLimit[];
readonly widenedReturnedReferences?: readonly JavaScriptSourceRange[];
}
| {
readonly status: "failed";
readonly omittedCount: null;
readonly resourceLimits?: readonly JavaScriptSemanticResourceLimit[];
readonly widenedReturnedReferences?: readonly JavaScriptSourceRange[];
};
/** Classify whole-file semantic coverage from parsing and value bounds. */
/** Source-local effect candidates broadened at a projection merge, without dropping targets. */
export const RETURNED_REFERENCE_WIDENING_LIMITATION =
"Local returned-reference projections were conservatively widened; effects include additional source-local candidates.";
/** Classify whole-file semantic coverage from parsing, value bounds and widened projections. */
export const semanticCoverage = (
parserPartial: boolean,
resourceLimits: readonly JavaScriptSemanticResourceLimit[] = [],
): JavaScriptSemanticCoverage =>
resourceLimits.length > 0
? { status: "partial", omittedCount: null, resourceLimits }
: { status: parserPartial ? "partial" : "complete", omittedCount: 0 };
widenedReturnedReferences: readonly JavaScriptSourceRange[] = [],
): JavaScriptSemanticCoverage => {
const widened =
widenedReturnedReferences.length > 0 ? { widenedReturnedReferences } : {};
if (resourceLimits.length > 0)
return {
status: "partial",
omittedCount: null,
resourceLimits,
...widened,
};
return {
status:
parserPartial || widenedReturnedReferences.length > 0
? "partial"
: "complete",
omittedCount: 0,
...widened,
};
};
/** Read typed resource-limit classifications from any coverage state. */
export const semanticCoverageResourceLimits = (