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:
Ysopwnable
2026-10-15 23:43:05 +08:00
committed by GitHub
parent 40f73f62bc
commit 9f8659e053
17 changed files with 1024 additions and 57 deletions
@@ -12,6 +12,7 @@ import {
} from "./JavaScriptSemanticGraphConstruction.js";
import { unknownSemanticEvidence } from "./JavaScriptSemanticGraphEvidence.js";
import type { SemanticFlowProjectionContext } from "./JavaScriptSemanticGraphFlowProjection.js";
import { semanticResourceLimitReason } from "../../domain/javascript/javascriptSemanticResourceLimits.js";
/** Project environment, argv, file, default, and precedence candidates. */
export const projectSemanticConfiguration = (
@@ -56,7 +57,17 @@ export const projectSemanticConfiguration = (
...(operation.kind === "default" ? (["overrides"] as const) : []),
],
location: operation.location,
detail: `Static ${operation.kind} configuration identity is partial.`,
...(operation.valueResourceLimit === undefined
? {
detail:
operation.kind === "default"
? "Static default configuration value is partial."
: `Static ${operation.kind} configuration identity is partial.`,
}
: {
reason: "resource-limit",
detail: semanticResourceLimitReason(operation.valueResourceLimit),
}),
candidateNodeIds: [],
});
}
@@ -80,6 +91,9 @@ const addConfigurationNode = (
key: operation.key,
source_kind: operation.kind,
value: operation.value,
...(operation.valueResourceLimit === undefined
? {}
: { value_resource_limit: operation.valueResourceLimit }),
},
});
@@ -279,6 +293,7 @@ const bindingOrOwner = (
: (context.callableNodes.get(callableId) ?? context.moduleNode));
interface DataUnknownInput {
readonly reason?: "ambiguous-target" | "resource-limit";
readonly context: SemanticFlowProjectionContext;
readonly node: JavaScriptSemanticGraphNode;
readonly family: "boundary" | "configuration" | "request";
@@ -317,7 +332,7 @@ const addDataUnknown = (input: DataUnknownInput): void => {
node_id: node.node_id,
family,
relation_kinds: relationKinds,
reason: "ambiguous-target",
reason: input.reason ?? "ambiguous-target",
detail,
candidate_node_ids: candidateNodeIds,
evidence: unknownSemanticEvidence(context.file, location),