mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
* refactor(analysis-view): break the analysis view hub cycle Move request fragments, the request union, and the result union out of analysisView.ts so projectors no longer import the module that imports them. The dispatcher re-exports the public schemas and seals projector results. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(analysis-view): check inferred projector results Require each projector result to match the unsigned result union before sealing it, and parse the cycle guard's imports with Babel so comments and side-effect imports are not misread. * fix(analysis-view): close IL2CPP and Android symbol view inputs Admit those projectors through AdmittedView and check test selections against their request schemas, so misspelled fields fail at the call site. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import { z } from "zod";
|
|
import { AnalysisInputError } from "../analysisErrorCore.js";
|
|
import { byteEntropySchema, type ByteEntropy } from "../native/byteEntropy.js";
|
|
import { err, ok } from "../result.js";
|
|
import type { AnalysisViewParent } from "./analysisViewParent.js";
|
|
import {
|
|
assertOwnedView,
|
|
type AdmittedView,
|
|
type SummaryAnalysisView,
|
|
} from "./analysisViewShape.js";
|
|
import { completeWithinViewCoverage } from "./analysisViewCoverage.js";
|
|
|
|
export const byteEntropySummarySchema = byteEntropySchema
|
|
.omit({ blocks: true, runs: true, limitations: true })
|
|
.extend({
|
|
block_count: z.number().int().nonnegative(),
|
|
run_count: z.number().int().nonnegative(),
|
|
top_runs: byteEntropySchema.shape.runs,
|
|
});
|
|
|
|
/** Rank ten longest runs for triage; the full series remains in parent Evidence. */
|
|
export const projectByteEntropyView = (
|
|
parent: AnalysisViewParent,
|
|
report: ByteEntropy,
|
|
view: AdmittedView,
|
|
) => {
|
|
if (view.kind !== "summary")
|
|
return err(
|
|
new AnalysisInputError("inspect_analysis_view", undefined, [
|
|
{
|
|
path: ["view"],
|
|
reason: "invalid_value",
|
|
message:
|
|
"Byte entropy Evidence supports the summary view; retrieve parent Evidence for the complete block series.",
|
|
},
|
|
]),
|
|
);
|
|
assertOwnedView<SummaryAnalysisView>(view, "summary");
|
|
return ok({
|
|
kind: "summary" as const,
|
|
view,
|
|
parent_evidence_id: parent.evidenceId,
|
|
parent_operation: "inspect_byte_entropy" as const,
|
|
parent_digest: parent.evidenceId.slice(3),
|
|
artifact: { path: report.artifact.path, sha256: report.artifact.sha256 },
|
|
summary: {
|
|
artifact: report.artifact,
|
|
block_size: report.block_size,
|
|
window: report.window,
|
|
file_entropy: report.file_entropy,
|
|
thresholds: report.thresholds,
|
|
block_count: report.blocks.length,
|
|
run_count: report.runs.length,
|
|
top_runs: [...report.runs]
|
|
.sort((a, b) => b.length - a.length || a.offset - b.offset)
|
|
.slice(0, 10),
|
|
},
|
|
coverage: completeWithinViewCoverage(
|
|
report.blocks.length,
|
|
report.blocks.length,
|
|
),
|
|
limitations: [
|
|
...new Set([...parent.limitations, ...report.limitations]),
|
|
].sort(),
|
|
unknowns: [] as string[],
|
|
});
|
|
};
|