mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
58fb372071
Add opt-in retained inventory and WASM Evidence views with exact nested output contracts and a small static WASM descriptor. Preserve old complete CLI/MCP workflows, producer choices, original authenticated Evidence and cleanup ownership. Validated with real public applications, genuine old Evidence migration, 123 focused assertions, 11 synchronized description checks and 42 installed-package WABT cases. Detailed generated experiment JSON stays outside the final tree; concise findings and reproduction inputs remain. Main-existing completion/package CI failures are separately attributed and left unchanged. Refs #2016 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
100 lines
5.1 KiB
TypeScript
100 lines
5.1 KiB
TypeScript
import { API_SURFACE_EXAMPLE } from "./analysisViewApiSurfaceExample.js";
|
|
import {
|
|
analysisViewResultSchema,
|
|
inspectAnalysisViewInputSchema,
|
|
} from "../domain/analysisView/analysisView.js";
|
|
import type { ToolContract } from "./toolContractTypes.js";
|
|
import { toolContractMetadata } from "./toolEffects.js";
|
|
import { evidenceResultOf } from "./toolOutputSchemaPrimitives.js";
|
|
|
|
const RETAINED_EXAMPLE_ID = `ev_${"a".repeat(64)}`;
|
|
|
|
/** Selected views of completed layout, JavaScript, native, inventory, WASM and web network Evidence. */
|
|
export const ANALYSIS_VIEW_TOOL_CONTRACTS = [
|
|
{
|
|
name: "inspect_analysis_view",
|
|
...toolContractMetadata("inspect_analysis_view"),
|
|
kind: "application",
|
|
description:
|
|
'Inspect selected views of completed binary-layout, JavaScript application, native analyze_function, inspect_artifact, inventory_artifact, inspect_wasm_artifact or inspect_web_network_capture Evidence without repeating analysis. The api-surface view groups retained HAR requests by method, origin and format-rule path template; templated segments are inferences. It reads no headers or bodies and reports no query values. For a retained record use source: {kind: "retained-evidence", evidence_id: "<parent_evidence_id>"}. Use normalized_result.parent_evidence_id from a summary receipt. Source kind is required. Portable source uses {kind: "inline", evidence: <complete Evidence>}. For layout, JavaScript, native, inventory and WASM sources, request a summary with view: {kind: "summary"}; summary is a view kind and has no facet. The WASM summary gives validation, counts, WAT digest/length, tool profile and execution/network states without reading WAT text. Select a layout mitigations/linkage facet, one section/symbol/module, or a stable page. Module pages include assets, bundled and source modules; use node_id for ambiguous or unavailable paths. Inventory uses view: {kind: "inventory", collection: "occurrences", logical_paths: ["package.json"], offset: 0, limit: 64}. Inventory views page nodes, occurrences, edges or integrity contradictions; occurrence logical_paths matches exact recorded strings (omitted means all available, [] means none). source_complete distinguishes complete inventories from partial source records; page exhaustion does not prove absence in a partial source. WASM views use kind wasm and facet sections/imports/exports/candidates/glue/wat/headers/details/tool_profile; text facets use UTF-16 code units and source forms remain exact. Native views select procedure, pseudocode, assembly, basic blocks, comments, callers/callees, references, unresolved calls, referenced strings/names, native API and high-pcode. Use nonnegative offset and a positive caller-selected limit (defaults 0 and 64); pseudocode uses UTF-16 code units, other native pages use rows. Returns artifact identity, parent Evidence ID, a distinct view digest, coverage, limitations and unknowns. Actual serialized size determines MCP transport admission; choose a smaller page or export the complete retained Evidence if needed.',
|
|
inputSchema: inspectAnalysisViewInputSchema,
|
|
outputSchema: evidenceResultOf(analysisViewResultSchema),
|
|
examples: [
|
|
{
|
|
title: "Read exact inventory paths from retained inspection Evidence",
|
|
input: {
|
|
source: {
|
|
kind: "retained-evidence",
|
|
evidence_id: RETAINED_EXAMPLE_ID,
|
|
},
|
|
view: {
|
|
kind: "inventory",
|
|
collection: "occurrences",
|
|
logical_paths: ["package.json", "main.js"],
|
|
offset: 0,
|
|
limit: 32,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
title: "Group requests from retained HAR Evidence",
|
|
input: API_SURFACE_EXAMPLE.input,
|
|
},
|
|
{
|
|
title: "Summarize retained analysis Evidence, including WASM",
|
|
input: {
|
|
source: {
|
|
kind: "retained-evidence",
|
|
evidence_id: RETAINED_EXAMPLE_ID,
|
|
},
|
|
view: { kind: "summary" },
|
|
},
|
|
},
|
|
{
|
|
title: "Read one ELF section from retained layout Evidence",
|
|
input: {
|
|
source: {
|
|
kind: "retained-evidence",
|
|
evidence_id: RETAINED_EXAMPLE_ID,
|
|
},
|
|
view: {
|
|
kind: "item",
|
|
collection: "sections",
|
|
selector: { name: ".text" },
|
|
},
|
|
},
|
|
},
|
|
{
|
|
title: "Page native high-pcode operations from retained Evidence",
|
|
input: {
|
|
source: {
|
|
kind: "retained-evidence",
|
|
evidence_id: RETAINED_EXAMPLE_ID,
|
|
},
|
|
view: {
|
|
kind: "native",
|
|
facet: "value_flow_operations",
|
|
offset: 0,
|
|
limit: 32,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
title: "Page module identities from retained application Evidence",
|
|
input: {
|
|
source: {
|
|
kind: "retained-evidence",
|
|
evidence_id: RETAINED_EXAMPLE_ID,
|
|
},
|
|
view: {
|
|
kind: "page",
|
|
collection: "modules",
|
|
offset: 0,
|
|
limit: 32,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
] as const satisfies readonly ToolContract[];
|