mirror of
https://github.com/morluto/rea.git
synced 2026-10-11 21:39:55 +00:00
* fix(build): emit no runtime imports for type-only bindings
Under verbatimModuleSyntax, an import whose specifiers all carry inline
`type` modifiers compiles to `import {} from "..."`, a side-effect import
that still resolves and evaluates the module. 78 compiled modules carried
one, including `import {} from "playwright-core"` in the browser scenario
session, which loaded Playwright's module graph at MCP startup.
Use top-level `import type` for these bindings and enable oxlint's
typescript/no-import-type-side-effects rule so the pattern cannot return.
Refs #1685
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* perf(mcp): load Playwright when a scenario launches, not at startup
The browser scenario and Electron active providers are constructed before
the stdio server serves, and both bound Playwright's launchers at module
load. Resolve `chromium` and `_electron` from playwright-core when a
capture opens instead, as the web module resolver already does.
MCP startup now resolves 1,312 modules (4,902 resolutions) instead of
1,598 (6,076) before reading the first request, and no longer loads
playwright-core. Provider construction, the tool catalog, and capability
inventory are unchanged.
A boundary test spawns the stdio server, initializes, lists tools, and
asserts playwright-core and isomorphic-git were not resolved; the CLI
probe now exercises the real launch path to prove detection.
Closes #1685
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
91 lines
3.1 KiB
TypeScript
91 lines
3.1 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { AnalysisProtocolError } from "../../domain/analysisErrorCore.js";
|
|
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
|
import {
|
|
createEvidence,
|
|
type Evidence,
|
|
type EvidenceSubjectTarget,
|
|
} from "../../domain/evidence.js";
|
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
import {
|
|
managedApplicationGraphResultSchema,
|
|
projectManagedApplicationGraph,
|
|
projectManagedApplicationGraphInputSchema,
|
|
type ManagedApplicationGraphResult,
|
|
type ProjectManagedApplicationGraphInput,
|
|
} from "../../domain/managed/managedApplicationGraph.js";
|
|
import { err, ok, type Result } from "../../domain/result.js";
|
|
import { MANAGED_WORKFLOW_PROVIDER } from "../InvestigationProviders.js";
|
|
import {
|
|
requestInputError,
|
|
workflowInputError,
|
|
} from "../workflowInputError.js";
|
|
|
|
const OPERATION = "project_managed_application_graph" as const;
|
|
|
|
/** Project authenticated managed Evidence into a provider-neutral graph. */
|
|
export const projectManagedApplicationGraphEvidence = (
|
|
rawInput: unknown,
|
|
): Result<Evidence, AnalysisError> => {
|
|
const parsed = projectManagedApplicationGraphInputSchema.safeParse(rawInput);
|
|
if (!parsed.success)
|
|
return err(requestInputError(OPERATION, parsed.error, rawInput));
|
|
try {
|
|
const result = projectManagedApplicationGraph(parsed.data);
|
|
return ok(createManagedApplicationGraphEvidence(parsed.data, result));
|
|
} catch (cause: unknown) {
|
|
return err(
|
|
cause instanceof TypeError || cause instanceof z.ZodError
|
|
? workflowInputError(OPERATION, cause)
|
|
: new AnalysisProtocolError(
|
|
"Managed application graph projection produced an invalid result",
|
|
{ cause },
|
|
),
|
|
);
|
|
}
|
|
};
|
|
|
|
const createManagedApplicationGraphEvidence = (
|
|
input: ProjectManagedApplicationGraphInput,
|
|
result: ManagedApplicationGraphResult,
|
|
): Evidence =>
|
|
createEvidence(subjectTarget(input), MANAGED_WORKFLOW_PROVIDER, {
|
|
predicateType: "rea.managed-application-graph",
|
|
operation: OPERATION,
|
|
parameters: {
|
|
managed_artifact_evidence_id: input.managed_artifact?.evidence_id ?? null,
|
|
managed_members_evidence_id: input.managed_members?.evidence_id ?? null,
|
|
managed_native_boundaries_evidence_id:
|
|
input.managed_native_boundaries?.evidence_id ?? null,
|
|
},
|
|
result: jsonValueSchema.parse(
|
|
managedApplicationGraphResultSchema.parse(result),
|
|
),
|
|
rawResult: null,
|
|
confidence: "inferred",
|
|
authority: "analyst-inference",
|
|
environment: null,
|
|
limitations: result.limitations,
|
|
evidenceLinks: result.evidence_links,
|
|
});
|
|
|
|
const subjectTarget = (
|
|
input: ProjectManagedApplicationGraphInput,
|
|
): EvidenceSubjectTarget | undefined => {
|
|
const subject =
|
|
input.managed_artifact?.subject ??
|
|
input.managed_members?.subject ??
|
|
input.managed_native_boundaries?.subject;
|
|
if (subject === undefined || subject === null || subject.format !== "pe")
|
|
return undefined;
|
|
return {
|
|
path: subject.local_path,
|
|
sha256: subject.digest.sha256,
|
|
format: "pe",
|
|
...(subject.architecture === null
|
|
? {}
|
|
: { architecture: subject.architecture }),
|
|
};
|
|
};
|