mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
fix(javascript): isolate source analysis and retain bounded partial evidence (#1651)
* refactor(javascript): validate transferable file projections * test(javascript): consume decoded module and static facts * fix(javascript): isolate source analysis and retain bounded partial evidence * test(javascript): verify cleanup retention and repeated source paths
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
JAVASCRIPT_SEMANTIC_RELATION_FAMILIES,
|
||||
JAVASCRIPT_SEMANTIC_RELATION_FAMILY,
|
||||
javaScriptSemanticFingerprintInputSchema,
|
||||
javaScriptSemanticEvidenceContextSchema,
|
||||
javaScriptSemanticGraphInputSchema,
|
||||
javaScriptSemanticGraphRecordSchema,
|
||||
javaScriptSemanticNodeInputSchema,
|
||||
@@ -109,6 +110,33 @@ export class JavaScriptSemanticEvidenceContextRegistry {
|
||||
this.#contexts.clear();
|
||||
this.#idsByCanonicalContext.clear();
|
||||
}
|
||||
|
||||
/** Validate and intern provenance decoded in this realm from an analysis worker. */
|
||||
adopt(input: unknown): void {
|
||||
const context = javaScriptSemanticEvidenceContextSchema.parse(input);
|
||||
const { context_id: identifier, ...value } = context;
|
||||
if (identifier !== evidenceContextId(value))
|
||||
throw new TypeError(
|
||||
"Transferred semantic evidence context identifier is stale",
|
||||
);
|
||||
const canonical = canonicalJson(
|
||||
value,
|
||||
"JavaScript semantic evidence context",
|
||||
);
|
||||
const existing = this.#contexts.get(identifier);
|
||||
if (existing !== undefined) {
|
||||
const { context_id: _existingIdentifier, ...existingValue } = existing;
|
||||
if (
|
||||
canonical !==
|
||||
canonicalJson(existingValue, "JavaScript semantic evidence context")
|
||||
)
|
||||
throw new TypeError(
|
||||
"Transferred semantic evidence context digest collision",
|
||||
);
|
||||
}
|
||||
this.#contexts.set(identifier, context);
|
||||
this.#idsByCanonicalContext.set(canonical, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
/** Derive a semantic node ID from its kind and exact artifact identity. */
|
||||
|
||||
Reference in New Issue
Block a user