mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 03:33:25 +00:00
fix(evidence): consolidate retained view and verifier ownership
This commit is contained in:
1 parent
e2d4c0dabb
commit
7d36d172ab
23 files changed
+457
-192
No files matched your search
@@ -8,7 +8,7 @@ import {
|
||||
type NativeFunctionMatching,
|
||||
} from "../native/functionMatching.js";
|
||||
import { isImmutableJsonSnapshot } from "../immutableJson.js";
|
||||
import { parseAnalysisViewResult } from "./analysisViewParent.js";
|
||||
import { createAnalysisViewResultReader } from "./analysisViewParent.js";
|
||||
import { analysisViewInputError } from "./analysisViewErrors.js";
|
||||
import {
|
||||
boundedViewMessages,
|
||||
@@ -94,25 +94,19 @@ interface Checked {
|
||||
recent?: { readonly key: string; readonly rows: readonly number[] };
|
||||
}
|
||||
const checked = new WeakMap<object, Checked>();
|
||||
const readReport = createAnalysisViewResultReader(nativeFunctionMatchingSchema);
|
||||
|
||||
type Request = z.output<typeof nativeFunctionMatchingViewRequestSchema>;
|
||||
const checkedReport = (
|
||||
parent: AnalysisViewParent,
|
||||
): Result<Checked, AnalysisError> => {
|
||||
const source = parent.normalizedResult;
|
||||
const reusable =
|
||||
typeof source === "object" &&
|
||||
source !== null &&
|
||||
parent.sealedResult === true &&
|
||||
isImmutableJsonSnapshot(source);
|
||||
const cached = reusable ? checked.get(source) : undefined;
|
||||
if (cached !== undefined) return ok(cached);
|
||||
const parsed = parseAnalysisViewResult(nativeFunctionMatchingSchema, parent);
|
||||
const parsed = readReport(parent);
|
||||
if (!parsed.ok) return parsed;
|
||||
const entry: Checked = {
|
||||
report: reusable ? (source as NativeFunctionMatching) : parsed.value,
|
||||
};
|
||||
if (reusable) checked.set(source, entry);
|
||||
const report = parsed.value;
|
||||
const cached = checked.get(report);
|
||||
if (cached !== undefined) return ok(cached);
|
||||
const entry: Checked = { report };
|
||||
if (isImmutableJsonSnapshot(report)) checked.set(report, entry);
|
||||
return ok(entry);
|
||||
};
|
||||
const functionRows = (entry: Checked): readonly FunctionRow[] => {
|
||||
|
||||
Reference in new issue
Block a user