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]>
94 lines
3.1 KiB
TypeScript
94 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 } from "../../domain/evidence.js";
|
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
import {
|
|
importManagedReconstruction,
|
|
managedReconstructionImportInputSchema,
|
|
type ManagedReconstructionImportInput,
|
|
type ManagedReconstructionImportResult,
|
|
} from "../../domain/managed/managedReconstruction.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 = "import_managed_reconstruction" as const;
|
|
|
|
/** Authenticate and import managed decompiler reconstruction as Evidence. */
|
|
export const importManagedReconstructionEvidence = (
|
|
rawInput: unknown,
|
|
): Result<Evidence, AnalysisError> => {
|
|
const parsed = managedReconstructionImportInputSchema.safeParse(rawInput);
|
|
if (!parsed.success)
|
|
return err(requestInputError(OPERATION, parsed.error, rawInput));
|
|
return importManagedReconstructionEvidenceValidated(parsed.data);
|
|
};
|
|
|
|
/** Import reconstruction from input parsed by a trusted adapter. */
|
|
export const importManagedReconstructionEvidenceValidated = (
|
|
input: ManagedReconstructionImportInput,
|
|
): Result<Evidence, AnalysisError> => {
|
|
try {
|
|
const result = importManagedReconstruction(input);
|
|
return ok(createManagedReconstructionEvidence(input, result));
|
|
} catch (cause: unknown) {
|
|
return err(
|
|
cause instanceof TypeError || cause instanceof z.ZodError
|
|
? workflowInputError(OPERATION, cause)
|
|
: new AnalysisProtocolError(
|
|
"Managed reconstruction import produced an invalid result",
|
|
{ cause },
|
|
),
|
|
);
|
|
}
|
|
};
|
|
|
|
const createManagedReconstructionEvidence = (
|
|
input: ManagedReconstructionImportInput,
|
|
result: ManagedReconstructionImportResult,
|
|
): Evidence =>
|
|
createEvidence(
|
|
{
|
|
path: result.static_observation.artifact_path,
|
|
sha256: result.static_observation.artifact_sha256,
|
|
format: "pe",
|
|
},
|
|
MANAGED_WORKFLOW_PROVIDER,
|
|
{
|
|
predicateType: "rea.managed-reconstruction-import",
|
|
operation: OPERATION,
|
|
parameters: {
|
|
static_members_evidence_id: input.static_members.evidence_id,
|
|
decompiler: jsonValueSchema.parse(result.decompiler),
|
|
method_locks: jsonValueSchema.parse(
|
|
input.methods.map(
|
|
({ token, signature_sha256, normalized_il_sha256 }) => ({
|
|
token,
|
|
signature_sha256,
|
|
normalized_il_sha256,
|
|
}),
|
|
),
|
|
),
|
|
notes: jsonValueSchema.parse(input.notes),
|
|
},
|
|
result: jsonValueSchema.parse(result),
|
|
rawResult: null,
|
|
confidence: "inferred",
|
|
authority: "analyst-inference",
|
|
environment: null,
|
|
limitations: result.limitations,
|
|
locations: [
|
|
{
|
|
kind: "artifact-path",
|
|
path: result.static_observation.artifact_path,
|
|
},
|
|
],
|
|
evidenceLinks: result.evidence_links,
|
|
},
|
|
);
|