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:
authored and GitHub committed 2026-10-30 05:41:58 +08:00
1 parent 4a8d8f72b3
commit 940d71a45a
59 files changed
+2915 -2319

No files matched your search

@@ -1,5 +1,6 @@
import { createEmptyIl2cppMetadataFixture } from "../il2cpp/il2cppMetadata.fixture.js";
import { afterEach, expect, it, vi } from "vitest";
import { z } from "zod";
import {
il2cppMetadataParentSchema,
type Il2cppMetadata,
@@ -7,7 +8,22 @@ import {
import { createEvidence } from "../evidence.js";
import { freezeJsonSnapshot } from "../immutableJson.js";
import { jsonObjectSchema } from "../jsonValue.js";
import { projectIl2cppMetadataView } from "./il2cppMetadataView.js";
import type { AdmittedView, SummaryAnalysisView } from "./analysisViewShape.js";
import {
il2cppMetadataViewRequestSchema,
projectIl2cppMetadataView as projectAdmittedIl2cppMetadataView,
} from "./il2cppMetadataView.js";
type Il2cppMetadataViewInput =
| SummaryAnalysisView
| z.input<typeof il2cppMetadataViewRequestSchema>;
/** Check a caller selection against the closed request, then pass the admitted view. */
const projectIl2cppMetadataView = (
parent: Parameters<typeof projectAdmittedIl2cppMetadataView>[0],
view: Il2cppMetadataViewInput,
): ReturnType<typeof projectAdmittedIl2cppMetadataView> =>
projectAdmittedIl2cppMetadataView(parent, view satisfies AdmittedView);
afterEach(() => {
vi.restoreAllMocks();
@@ -638,7 +654,15 @@ const genericLinked = (): Il2cppMetadata => {
it("pages generic method instances by definition, state, address, name and field", () => {
const source = parent(freezeJsonSnapshot(genericLinked()), true);
const view = (filters: Record<string, unknown>) => {
const view = (
filters: Omit<
Extract<
Il2cppMetadataViewInput,
{ collection: "generic_method_instances" }
>,
"kind" | "collection" | "offset" | "limit"
>,
) => {
const result = projectIl2cppMetadataView(source, {
kind: "il2cpp-metadata",
collection: "generic_method_instances",
@@ -649,7 +673,15 @@ it("pages generic method instances by definition, state, address, name and field
if (!result.ok) throw result.error;
return result.value;
};
const items = (filters: Record<string, unknown>) => {
const items = (
filters: Omit<
Extract<
Il2cppMetadataViewInput,
{ collection: "generic_method_instances" }
>,
"kind" | "collection" | "offset" | "limit"
>,
) => {
const value = view(filters);
return "items" in value ? value.items : undefined;
};