mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
refactor(analysis-view): break the analysis view hub cycle (#8061)
* 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>
This commit is contained in:
59 files changed
+2915
-2319
No files matched your search
@@ -5,12 +5,15 @@ import {
|
||||
import type { AnalysisError } from "../analysisErrorBase.js";
|
||||
import type { BinaryLayout } from "../native/binaryLayout.js";
|
||||
import { err, ok, type Result } from "../result.js";
|
||||
import type { AnalysisViewParent } from "./analysisViewParent.js";
|
||||
import type {
|
||||
AnalysisViewParent,
|
||||
AnalysisViewRequest,
|
||||
UnsignedAnalysisView,
|
||||
GroupingViewKind,
|
||||
} from "./analysisView.js";
|
||||
AdmittedView,
|
||||
FacetAnalysisView,
|
||||
ItemAnalysisView,
|
||||
PageAnalysisView,
|
||||
SummaryAnalysisView,
|
||||
} from "./analysisViewShape.js";
|
||||
import { assertOwnedView } from "./analysisViewShape.js";
|
||||
import {
|
||||
boundedViewMessages,
|
||||
completeWithinViewCoverage as completeCoverage,
|
||||
@@ -171,8 +174,8 @@ const layoutSummary = (layout: BinaryLayout) => ({
|
||||
export const projectBinaryLayoutView = (
|
||||
parent: AnalysisViewParent,
|
||||
layout: BinaryLayout,
|
||||
view: Exclude<AnalysisViewRequest, { kind: GroupingViewKind }>,
|
||||
): Result<UnsignedAnalysisView, AnalysisError> => {
|
||||
view: AdmittedView,
|
||||
) => {
|
||||
const shared = parentFields(parent, layout);
|
||||
if (view.kind === "native")
|
||||
return err(
|
||||
@@ -190,9 +193,10 @@ export const projectBinaryLayoutView = (
|
||||
return err(
|
||||
layoutIncompatible("EVM views require inspect_evm_interface Evidence."),
|
||||
);
|
||||
if (view.kind === "summary")
|
||||
if (view.kind === "summary") {
|
||||
assertOwnedView<SummaryAnalysisView>(view, "summary");
|
||||
return ok({
|
||||
kind: "summary",
|
||||
kind: "summary" as const,
|
||||
view,
|
||||
summary: layoutSummary(layout),
|
||||
coverage: completeCoverage(
|
||||
@@ -207,15 +211,19 @@ export const projectBinaryLayoutView = (
|
||||
),
|
||||
...shared,
|
||||
});
|
||||
if (view.kind === "facet")
|
||||
}
|
||||
if (view.kind === "facet") {
|
||||
assertOwnedView<FacetAnalysisView>(view, "facet");
|
||||
return ok({
|
||||
kind: "facet",
|
||||
kind: "facet" as const,
|
||||
view,
|
||||
facet: view.facet === "mitigations" ? layout.mitigations : layout.linkage,
|
||||
coverage: completeCoverage(1, 1),
|
||||
...shared,
|
||||
});
|
||||
}
|
||||
if (view.kind === "item") {
|
||||
assertOwnedView<ItemAnalysisView>(view, "item");
|
||||
if (view.collection === "modules")
|
||||
return err(
|
||||
layoutIncompatible(
|
||||
@@ -228,7 +236,7 @@ export const projectBinaryLayoutView = (
|
||||
: selectLayoutItem(view.collection, layout.symbols, view.selector);
|
||||
if (!selected.ok) return selected;
|
||||
return ok({
|
||||
kind: "item",
|
||||
kind: "item" as const,
|
||||
view,
|
||||
item: selected.value,
|
||||
coverage: completeCoverage(
|
||||
@@ -246,6 +254,7 @@ export const projectBinaryLayoutView = (
|
||||
"Layout views require summary, facet, item or page selections.",
|
||||
),
|
||||
);
|
||||
assertOwnedView<PageAnalysisView>(view, "page");
|
||||
if (view.collection === "modules")
|
||||
return err(
|
||||
layoutIncompatible(
|
||||
@@ -259,7 +268,7 @@ export const projectBinaryLayoutView = (
|
||||
? pageRows(layout.sections, view.offset, view.limit)
|
||||
: pageRows(layout.symbols, view.offset, view.limit);
|
||||
return ok({
|
||||
kind: "page",
|
||||
kind: "page" as const,
|
||||
view,
|
||||
items: [...items],
|
||||
coverage: pageCoverage(view.offset, items.length, rows.length),
|
||||
@@ -270,7 +279,7 @@ export const projectBinaryLayoutView = (
|
||||
const selectLayoutItem = <Row extends { readonly name: LayoutName }>(
|
||||
collection: "sections" | "symbols",
|
||||
rows: readonly Row[],
|
||||
selector: Extract<AnalysisViewRequest, { readonly kind: "item" }>["selector"],
|
||||
selector: ItemAnalysisView["selector"],
|
||||
): Result<Row, AnalysisError> => {
|
||||
if ("index" in selector)
|
||||
return selectIndexed(collection, rows, selector.index);
|
||||
|
||||
Reference in new issue
Block a user