fix(javascript): enforce semantic byte bounds for literals

Fixes #3933. Part of #4027.

Normalize exact literals and configuration defaults through the shared primitive owner. Preserve tagged limits through member/destructuring projection and record encountered bounds in per-analysis state independently of later selected values. Remove the retained-value rescan and duplicate default reader. Preserve source Evidence, bounded/null values, aggregate wire capacity and complete endpoint lookup identities for query/trace/comparison.

Validated 66 focused and 932 semantic tests on the restored identical runtime; final public selection 7/7 adds an augmented large-endpoint acceptance (67 distinct focused cases across invocations). Full static/docs and fresh real Obsidian controls passed. Compact measurements and rejected attempts remain recorded.

Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
YsopwnableandKaoru0822 authored and GitHub committed 2026-10-15 23:43:05 +08:00
1 parent 40f73f62bc
commit 9f8659e053
17 files changed
+1024 -57

No files matched your search

@@ -14,6 +14,10 @@ import type {
JavaScriptSemanticReference,
} from "./javascriptSemanticIr.js";
import type { JavaScriptModuleResolutionMode } from "./javascriptModuleResolutionMode.js";
import type {
JavaScriptSemanticResourceLimit,
JavaScriptSemanticValue,
} from "./javascriptSemanticValueTypes.js";
/** Internal initializer plus a destructuring/member projection. */
interface JavaScriptSemanticInitializer {
@@ -75,6 +79,8 @@ export interface JavaScriptSemanticAnalysisState {
readonly program: t.Program;
/** Effective loader for static imports in this source artifact. */
readonly staticImportResolutionMode: JavaScriptModuleResolutionMode;
/** Bounds encountered during this analysis, independent of later projections. */
readonly valueResourceLimits: Set<JavaScriptSemanticResourceLimit>;
readonly parentsByNode: WeakMap<t.Node, t.Node>;
readonly scopes: JavaScriptSemanticScopeState[];
readonly scopesById: Map<string, JavaScriptSemanticScopeState>;
@@ -110,6 +116,15 @@ export interface JavaScriptSemanticAnalysisState {
readonly ambientWriteEffects: JavaScriptSemanticMemberEffect[];
}
/** Record one producer outcome without traversing or retaining its value graph. */
export const recordSemanticValueLimit = (
state: JavaScriptSemanticAnalysisState,
value: JavaScriptSemanticValue,
): void => {
if (value.status === "unknown" && value.resourceLimit !== undefined)
state.valueResourceLimits.add(value.resourceLimit);
};
/** One parsed source owns its optional indexes and their per-source lifetime. */
export interface JavaScriptBindingIndex {
readonly sourceType: t.Program["sourceType"];