mirror of
https://github.com/morluto/rea.git
synced 2026-10-29 19:05:45 +00:00
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:
1 parent
40f73f62bc
commit
9f8659e053
17 files changed
+1024
-57
No files matched your search
@@ -14,7 +14,7 @@ import {
|
||||
export const semanticPrimitiveSet = (
|
||||
values: readonly JavaScriptSemanticPrimitive[],
|
||||
): JavaScriptSemanticValue => {
|
||||
const uniqueValues = new Set<JavaScriptSemanticPrimitive>();
|
||||
let uniqueValues: Set<JavaScriptSemanticPrimitive> | undefined;
|
||||
for (const value of values) {
|
||||
if (typeof value === "number" && !Number.isFinite(value))
|
||||
return {
|
||||
@@ -26,10 +26,19 @@ export const semanticPrimitiveSet = (
|
||||
status: "unknown",
|
||||
reason: "Negative zero cannot be preserved by JSON primitive evidence.",
|
||||
};
|
||||
// The common literal path needs validation, but no deduplication, sorting
|
||||
// or canonical-key allocation. Check strings before retaining the value.
|
||||
if (values.length === 1)
|
||||
return typeof value === "string" &&
|
||||
exceedsSemanticPrimitiveStringByteBudget([value])
|
||||
? semanticResourceLimitUnknown("primitive-bytes")
|
||||
: { status: "literal", value };
|
||||
uniqueValues ??= new Set<JavaScriptSemanticPrimitive>();
|
||||
uniqueValues.add(value);
|
||||
if (uniqueValues.size > SEMANTIC_PRIMITIVE_CANDIDATE_LIMIT)
|
||||
return semanticResourceLimitUnknown("primitive-candidates");
|
||||
}
|
||||
if (uniqueValues === undefined) return { status: "union", values: [] };
|
||||
if (
|
||||
exceedsSemanticPrimitiveStringByteBudget(
|
||||
[...uniqueValues].flatMap((value) =>
|
||||
|
||||
Reference in new issue
Block a user