mirror of
https://github.com/morluto/rea.git
synced 2026-10-11 21:39:55 +00:00
* feat(browser): trace captured website module imports Compose verified exported scripts, inert native import syntax and a narrow Chromium resolution port. Preserve query/fragment identity, import-map context, all reported capture candidates and explicit unknown execution. Share named CLI/MCP contracts and retain native reports, diagnostics and cleanup failures. Add focused boundary regressions and a real module-loading oracle to the existing conditional Chrome lane. No captured application code is executed by module tracing, and no selected website asset is refetched. Refs #851, #774 Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) * fix(browser): preserve module contexts and source bindings Keep capture completeness inline, validate actual source text against its digest, and separate unsupported URL contexts from malformed input. Use the importer origin for native module resolution and the selected map base independently, including mixed HTTP/HTTPS and escaped HTML attributes. Refs #851, #774 Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import { createHash } from "node:crypto";
|
|
import type {
|
|
WebModuleArtifacts,
|
|
WebModuleResolutionPort,
|
|
} from "../../src/application/WebModulePorts.js";
|
|
import { webScriptExportManifestSchema } from "../../src/domain/webScriptExport.js";
|
|
import { ok } from "../../src/domain/result.js";
|
|
|
|
/** Pure source-owned artifact fixture; no runtime loading is asserted. */
|
|
export const webModuleArtifactsFixture = (
|
|
source = 'import "./dep.js"; import(name);',
|
|
): WebModuleArtifacts => {
|
|
const path = "/analysis/modules/main.js";
|
|
const sha256 = createHash("sha256").update(source).digest("hex");
|
|
const bytes = Buffer.byteLength(source);
|
|
const manifest = webScriptExportManifestSchema.parse({
|
|
capture_path: "/capture.json",
|
|
capture_sha256: "a".repeat(64),
|
|
capture_kind: "browser-scenario",
|
|
source_evidence_id: null,
|
|
capture_completeness: {
|
|
status: "complete",
|
|
equality_eligible: true,
|
|
missing_sections: [],
|
|
truncated_sections: [],
|
|
},
|
|
output_directory: "/analysis",
|
|
analysis_input: { input_path: "/analysis", format: "directory" },
|
|
limitations: [],
|
|
scripts: [
|
|
{
|
|
url: "https://app.test/main.js?build=1#entry",
|
|
source: {
|
|
kind: "scenario-response",
|
|
transaction_id: "txn",
|
|
request_sequence: 1,
|
|
response_sequence: 2,
|
|
status: 200,
|
|
},
|
|
content: {
|
|
state: "exported",
|
|
relative_path: "modules/main.js",
|
|
layout: "isolated",
|
|
layout_reason: "fixture",
|
|
sha256,
|
|
bytes,
|
|
media_type: "text/javascript",
|
|
redacted: false,
|
|
representation: "browser-decoded-response-bytes",
|
|
},
|
|
},
|
|
],
|
|
});
|
|
return {
|
|
source,
|
|
manifest,
|
|
manifestFile: {
|
|
path: "/analysis/manifest.json",
|
|
sha256: "b".repeat(64),
|
|
bytes: 100,
|
|
},
|
|
sourceFile: { path, sha256, bytes },
|
|
importMap: null,
|
|
};
|
|
};
|
|
|
|
/** Deterministic port seam for orchestration/schema tests, not native engine proof. */
|
|
export const webModuleResolverFixture: WebModuleResolutionPort = {
|
|
resolve: (input) =>
|
|
Promise.resolve(
|
|
ok({
|
|
engine: { id: "fixture", version: "1" },
|
|
resolutions: input.specifiers.map((specifier) => ({
|
|
state: "resolved",
|
|
url: new URL(specifier, input.importerUrl).href,
|
|
})),
|
|
diagnostics: [],
|
|
rawResult: { fixture: true },
|
|
}),
|
|
),
|
|
};
|