refactor(mcp): simplify evidence and workflows

This commit is contained in:
morluto
2026-09-29 13:58:26 +08:00
parent abf7c1142e
commit 6740ed5215
23 changed files with 79 additions and 83 deletions
+2 -2
View File
@@ -501,9 +501,9 @@
"mcp_prompts": 6
},
"digests": {
"tools_sha256": "6eac3435923bf1fe85d527bbe2ad169a9c861b25fd027372fcb55a71e8548c96",
"tools_sha256": "623e9fd65a117626fe8e3cc4715a8ab8ba694120202ea6413103552b5f5bfefb",
"prompts_sha256": "7f7f15d84efdce3487412ea64fdf4b83d3d6cf01b42c7fadc3e046799a2b0b15",
"combined_sha256": "0d31bc37c4c2971ca92923cd903735c04fef253677928274c79e834b2e78874c",
"combined_sha256": "d37c2bd4930e6065896ba8085f03681c2b376d9d236a6798d55b466ba42749d9",
"providers_sha256": "7247eece8fad09c8023af8d5c682d223d7ed7ebd68eac79e9154962a7e03b66b"
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ import, and publishes 19 operation-level capabilities after the authenticated
post-analysis handshake.
The provider-neutral target, provider registry, deterministic target binding,
analysis-profile commitment, Evidence provenance, snapshot v2, and bounded
analysis-profile commitment, Evidence provenance, snapshot caching, and bounded
provider-process lifecycle foundations are implemented. The Ghidra launcher,
packaged Java bridge, doctor/setup projection, bounded client lifecycle, and
multi-target real Linux verifier, curated Windows CI, and controlled real
@@ -1,102 +1,102 @@
{
"ledger_id": "ecl_578e5853b332ae050e69dc1a2c72fc98be527371311d6a98a9ae3bf28a24fa6c",
"ledger_id": "ecl_b01c0b28362b48128765d176113471a5a82637fca0acfcd3182971155942e0d4",
"records": [
{
"claim_id": "managed.application-graph-projection",
"status": "pass",
"evidence_ids": [
"ev_a09c9014515baea9a709c1d5c0ae32d343a1f1b6e4da498ce5afe14eaab0ddbb"
"ev_b061a5a559acb3748cb9784c637f6693f74faeb564ba2b11d6fc32619e757459"
]
},
{
"claim_id": "managed.decompiler-reconstruction-import",
"status": "pass",
"evidence_ids": [
"ev_14052dcba244a91019c042feae78440d800570dde163c991931d9c09b7e6bbdd"
"ev_13f3401a3aaddc3f6d087ad160fa928374e142cdb9861254359b46865b8c992e"
]
},
{
"claim_id": "managed.dotnet-framework-x86-pinvoke",
"status": "pass",
"evidence_ids": [
"ev_c11aa40e3fbc2de8bb11d6b5783ee3a74d4d79fe16ea7f6ddd85d4b253c6d769"
"ev_6f026216826ca06e080b77ff608f02634fa945fbd2e151b4cd261c1444f8bbb1"
]
},
{
"claim_id": "managed.ilspy-reconstruction-oracle",
"status": "unsupported",
"evidence_ids": [
"ev_76ca183c167d63e6c58b65e2f9b3bef3e569669dc66abb0b8b850948878a70e3"
"ev_65a94c4de03f9c6ebdaff3f381cca377821f349d3ca6dfad47a31cc586fae939"
]
},
{
"claim_id": "managed.malformed-metadata",
"status": "pass",
"evidence_ids": [
"ev_99e1185da1fcbf1330b4b86beca27e0abeef10f95870b1982da39827278e16e8"
"ev_deae4259ea4395623176de40d06c2abcbc2b3a77f0bfb068d76e568d801f45a8"
]
},
{
"claim_id": "managed.managed-native-verification",
"status": "pass",
"evidence_ids": [
"ev_9d1c5bc641c0da1551c8fbae4507d7719847cfb40edf73c13e2bdf5fb670ec9e"
"ev_0edcbbcaa1191a4e5324a437f739957b77f9ac45e7897724337f2d6d06b3f9d1"
]
},
{
"claim_id": "managed.modern-dotnet-anycpu",
"status": "pass",
"evidence_ids": [
"ev_7f959cb9642a2c52da0cce0d3c9c888b889240ee7697c5fdb5390d7578634782"
"ev_d1af50e8dc04cd589385769efd8758e82095425f6e9c1cc4bf2f530c6b434c93"
]
},
{
"claim_id": "managed.mvid-and-token-drift",
"status": "pass",
"evidence_ids": [
"ev_dd6c3e3fbe115f1b9b38ee06f720d5efb7dd6ef693a1b9555e9ff73babdaea9f"
"ev_5493f40bc875535488d789a490361abcc1f76bfbdf52536d09ff127442a8e854"
]
},
{
"claim_id": "managed.not-managed",
"status": "pass",
"evidence_ids": [
"ev_ca183a8f4159136df29d9d5e44a88239c996d6e758b71ad023289871875a9367"
"ev_03ce0cc0183ee0710f8120e837565129559ab3bc41927df326066370c2341699"
]
},
{
"claim_id": "managed.operator-local-manifest",
"status": "unsupported",
"evidence_ids": [
"ev_4173365e113f71b28fd1f3f1c583557a487e36ec6a6d0e63b1249eb7a4334b8c"
"ev_9d3e50da1d372c55f46649e69eae702cbe8f0ba6a81d1e46afc3e1a284c81757"
]
},
{
"claim_id": "managed.operator-manifest-self-test",
"status": "pass",
"evidence_ids": [
"ev_063c68b649379811e56c7788ab6b01891f1dd78abfe3008c6bf06a1c0727a095"
"ev_f974f4b9d039cda841894c6173cae86427ecef48f4e7a4d6c73edf7b23af2b2a"
]
},
{
"claim_id": "managed.runtime-correlation-admission-plan",
"status": "pass",
"evidence_ids": [
"ev_530ff114b2f05f85b6baeaa56df60a60a927f1de3b07bbbe86aa462faad71772"
"ev_3e546c20493faf9696502171a5cfe9504569cffb22f0561ee3000f0027b9bbd8"
]
},
{
"claim_id": "managed.unicode-obfuscated-identifiers",
"status": "pass",
"evidence_ids": [
"ev_17f9013d5ce058be847c1f3efec19688c268fa2feecf974bbc18428cd87144e5"
"ev_c4f38ce76d8359d92ee8e9442503e47b7913550442349a0df688bd274a3def67"
]
},
{
"claim_id": "managed.x64-ready-to-run-native-body",
"status": "pass",
"evidence_ids": [
"ev_60dc353ad66b83ee50163ab55fb0f4c7caefd06e08ccc2e0ebb5d2a7a23cb55b"
"ev_3e05ef1d6a796d3d4cb3372fe8e549efec759c59bf09d8ff660059a2e448cbc0"
]
}
],
@@ -1,5 +1,5 @@
{
"manifest_id": "ecm_53f423ba916e5cba6baa0f9dc2e02bd7cded55c0053b554f828bb2e74be85b13",
"manifest_id": "ecm_0107a34d5c39457fbb22d1b86983e97ef618787d676300664cb2bb8c9efa738b",
"verifier": {
"id": "rea-managed-conformance",
"version": "1"
@@ -13,7 +13,7 @@
"skill_digests": [
{
"skill_id": "reverse-engineer-anything",
"sha256": "2c7dbdc04071f073b87ffcec9c742bb50f8c1c27aa5c2063337fa224baf84081"
"sha256": "dad216a904af18f4eb364995c5d70ff691aa2ff2e841a169f583f50bec03530d"
}
],
"claims": [
+1 -1
View File
@@ -4,7 +4,7 @@ description: Reverse engineer native, managed, Electron/JavaScript, packaged, an
metadata:
version: "23"
tool_count: 111
catalog_digest: "0d31bc37c4c2971ca92923cd903735c04fef253677928274c79e834b2e78874c"
catalog_digest: "d37c2bd4930e6065896ba8085f03681c2b376d9d236a6798d55b466ba42749d9"
---
# REA
+1 -1
View File
@@ -226,7 +226,7 @@ export abstract class BinarySessionRecords {
): Result<ResidualUnknown, AnalysisError> {
const target = this.activeAnalysisBinding()?.target;
const evidence = createEvidence(target, UNKNOWN_REGISTRY_PROVIDER, {
predicateType: "rea.residual-unknown-mutation/v1",
predicateType: "rea.residual-unknown-mutation",
operation: "update_unknown",
parameters: {
unknown_id: input.unknown_id,
+2 -2
View File
@@ -91,7 +91,7 @@ describe("evidence ledger recording", () => {
it("retains Evidence alongside unknown revisions without a record quota", () => {
const ledger = new EvidenceLedger();
const mutation = createEvidence(undefined, PROVIDER, {
predicateType: "rea.residual-unknown-mutation/v1",
predicateType: "rea.residual-unknown-mutation",
operation: "record_unknown",
parameters: {},
result: { action: "record" },
@@ -155,7 +155,7 @@ describe("evidence bundle imports", () => {
result: { status: "unknown" },
});
const mutation = createEvidence(undefined, PROVIDER, {
predicateType: "rea.residual-unknown-mutation/v1",
predicateType: "rea.residual-unknown-mutation",
operation: "record_unknown",
parameters: {},
result: { action: "record" },
+1 -1
View File
@@ -21,7 +21,7 @@ export const FUNCTION_COMPARISON_EVIDENCE = createEvidence(
version: "1",
},
{
predicateType: "rea.function-comparison/v1",
predicateType: "rea.function-comparison",
operation: "compare_functions",
parameters: {
left_evidence_id: FUNCTION_COMPARISON_EXAMPLE.left.evidence_id,
+5 -5
View File
@@ -270,7 +270,7 @@ export const OFFICIAL_TOOL_CONTRACTS = [
),
official(
"set_current_document",
"Select an already-open Hopper document by exact document name. This changes subsequent default-document routing; call list_documents first and prefer explicit document inputs where reproducibility matters.",
"Select an already-open Hopper document by exact document name. This changes subsequent default-document routing; list_documents can supply names when needed, while explicit document inputs keep calls reproducible.",
z.object({ document: z.string() }),
),
official(
@@ -327,7 +327,7 @@ export const ENHANCED_TOOL_CONTRACTS = [
),
enhanced(
"binary_overview",
"Use after opening a native binary for target metadata, every segment with its length, and exhaustive procedure/string counts. To choose a function, follow with search_procedures or list_procedures, then pass a returned name or address to analyze_function for a complete dossier.",
"Return native-binary metadata, every segment with its length, and exhaustive procedure/string counts. Use search_procedures, list_procedures, or analyze_function directly when you already know which procedure to inspect.",
enhancedInputSchemas.binary_overview,
),
...FUNCTION_WORKFLOW_TOOL_CONTRACTS,
@@ -358,7 +358,7 @@ export const exportEvidenceBundleInputSchema = z.strictObject({
export const SESSION_TOOL_CONTRACTS = [
session(
"open_binary",
"Open a local executable, application bundle, archive, JavaScript, source map, plist, or analysis database after validation. provider_id selects one deep provider or deterministic auto selection; the binding remains stable until close or an explicit switch, with no failure fallback. An optional snapshot v2 is imported atomically and must match the binary identity, concrete provider, and canonical analysis profile exactly.",
"Open a local executable, application bundle, archive, JavaScript, source map, plist, or analysis database after validation. provider_id selects one deep provider or deterministic auto selection; the binding remains stable until close or an explicit switch, with no failure fallback. An optional analysis snapshot is imported atomically and must match the binary identity, concrete provider, and canonical analysis profile exactly.",
openBinaryInputSchema,
),
session(
@@ -458,12 +458,12 @@ export const SESSION_TOOL_CONTRACTS = [
),
session(
"get_navigation_context",
"Compose the selected document, current address, and containing/current procedure into one provider-neutral result. The result reflects sequential provider observations, not an atomic cursor snapshot; a cursor outside any procedure returns procedure: null. Scalar navigation getters remain available for evaluation and compatibility.",
"Return the selected document, current address, and containing/current procedure in one provider-neutral result. The result reflects sequential provider observations, not an atomic cursor snapshot; a cursor outside any procedure returns procedure: null.",
navigationContextInputSchema,
),
session(
"inspect_address_context",
"Inspect one explicit reproducible address for its analyzed name, containing procedure, regular and inline comments, and matching bookmarks. Each unsupported facet returns a typed unavailable outcome; xrefs, assembly, and pseudocode remain separate bounded follow-ups.",
"Inspect one explicit reproducible address for its analyzed name, containing procedure, regular and inline comments, and matching bookmarks. Each unsupported facet returns a typed unavailable outcome; use xrefs, assembly, or pseudocode for those deeper views.",
addressContextInputSchema,
),
] as const satisfies readonly ToolContract[];
+1 -1
View File
@@ -166,7 +166,7 @@ it("derives byte-stable bundle manifests independent of record order", () => {
undefined,
{ id: "process", name: "Process capture", version: "1" },
{
predicateType: "rea.process-capture/v1",
predicateType: "rea.process-capture",
operation: "capture_process_scenario",
parameters: {},
result: { exit: 0 },
+1 -1
View File
@@ -261,7 +261,7 @@ export const createEvidence = (
...(observation.analysisProfile === undefined
? {}
: { analysis_profile: observation.analysisProfile }),
predicate_type: observation.predicateType ?? "rea.analysis/v2",
predicate_type: observation.predicateType ?? "rea.analysis",
operation: observation.operation,
parameters: observation.parameters,
raw_result: observation.rawResult ?? null,
+3 -3
View File
@@ -93,7 +93,7 @@ export const createEvidenceBundle = (
: [],
),
captures: sortedRecords.flatMap((evidence) =>
evidence.predicate_type.startsWith("rea.process-capture/")
evidence.predicate_type === "rea.process-capture"
? [
{
evidence_id: evidence.evidence_id,
@@ -134,7 +134,7 @@ export const evidenceBundleForTarget = (
record?.subject?.digest.sha256 === sha256 ||
(unknown.mutation_evidence_ids.includes(id) &&
record?.subject === null &&
record.predicate_type === "rea.residual-unknown-mutation/v1")
record.predicate_type === "rea.residual-unknown-mutation")
);
}),
);
@@ -248,7 +248,7 @@ const validateVerifiedResolution = (
return (
unknown.supporting_evidence_ids.includes(evidenceId) &&
evidence !== undefined &&
evidence.predicate_type !== "rea.residual-unknown-mutation/v1" &&
evidence.predicate_type !== "rea.residual-unknown-mutation" &&
evidenceQualifies(unknown, evidence)
);
});
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -96,7 +96,7 @@ export const registerElectronTools = (
[
{
operation: "list_electron_targets",
predicate: "rea.electron-target-list/v1",
predicate: "rea.electron-target-list",
},
],
);
+5 -10
View File
@@ -17,7 +17,10 @@ import { mcpProgressReporter } from "./mcpProgress.js";
import { logToolExecution } from "./toolLogging.js";
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
import { toCallToolResult } from "./toolResult.js";
import { createArtifactExtractionDestination } from "../application/ArtifactExtractionDestination.js";
import {
artifactExtractionPermissionRequest,
createArtifactExtractionDestination,
} from "../application/ArtifactExtractionDestination.js";
interface EvidenceToolRegistration {
readonly logger: Logger;
@@ -127,15 +130,7 @@ const permissionRequest = (
operation === "extract_artifact" &&
typeof parameters.output_root === "string"
)
return {
capability: "artifact_extract" as const,
roots: [parameters.output_root],
executables: [],
environment_names: [],
network: "none" as const,
mount: false,
operation_identity: `extract_artifact:${parameters.output_root}`,
};
return artifactExtractionPermissionRequest();
if (
operation === "inspect_artifact" &&
parameters.native_mount_approved === true
+4 -4
View File
@@ -63,7 +63,7 @@ const registerChangedBehavior = (
if (!computed.ok) return toCallToolResult(computed, contract);
const result = computed.value;
const evidence = createEvidence(undefined, CHANGED_BEHAVIOR_PROVIDER, {
predicateType: "rea.changed-behavior/v1",
predicateType: "rea.changed-behavior",
operation: contract.name,
parameters: {
comparison_evidence_ids: input.comparisons.map(
@@ -121,7 +121,7 @@ const registerCallPath = (
if (!computed.ok) return toCallToolResult(computed, contract);
const result = computed.value;
const evidence = createEvidence(undefined, CALL_PATH_PROVIDER, {
predicateType: "rea.call-path/v1",
predicateType: "rea.call-path",
operation: contract.name,
parameters: {
start: input.start.address,
@@ -181,7 +181,7 @@ const registerStaticRuntime = (
if (!computed.ok) return toCallToolResult(computed, contract);
const result = computed.value;
const evidence = createEvidence(undefined, STATIC_RUNTIME_PROVIDER, {
predicateType: "rea.static-runtime-correlation/v1",
predicateType: "rea.static-runtime-correlation",
operation: contract.name,
parameters: {
mapping_count: input.mappings.length,
@@ -237,7 +237,7 @@ const registerReconstruction = (
if (!closure.ok) return toCallToolResult(closure, contract);
const links = closure.value;
const evidence = createEvidence(undefined, RECONSTRUCTION_PROVIDER, {
predicateType: "rea.reconstruction-verification/v1",
predicateType: "rea.reconstruction-verification",
operation: contract.name,
parameters: {
specification_sha256: result.specification_sha256,
+21 -20
View File
@@ -82,12 +82,7 @@ const argumentSchema = (
argument: PromptArgumentContract,
completion: PromptCompletionSource,
): z.ZodType => {
const value = z
.string()
.trim()
.min(1)
.max(4_096)
.describe(argument.description);
const value = z.string().trim().min(1).describe(argument.description);
const kind = argument.completion;
const completed =
kind === undefined
@@ -98,18 +93,24 @@ const argumentSchema = (
return argument.required ? completed : completed.optional();
};
const promptResult = (contract: PromptContract, arguments_: unknown) => ({
description: contract.description,
messages: [
{
role: "user" as const,
content: {
type: "text" as const,
text: renderGuidedPrompt(
contract,
promptValuesSchema.parse(arguments_),
),
const promptResult = (contract: PromptContract, arguments_: unknown) => {
const values = promptValuesSchema.parse(arguments_);
for (const [name, argument] of Object.entries(contract.arguments))
if (
argument.required &&
(values[name] === undefined || values[name]?.trim().length === 0)
)
throw new TypeError(`Invalid arguments: ${name} must not be empty`);
return {
description: contract.description,
messages: [
{
role: "user" as const,
content: {
type: "text" as const,
text: renderGuidedPrompt(contract, values),
},
},
},
],
});
],
};
};
@@ -33,7 +33,7 @@ describe("reconstruction obligation ledger CLI parity", () => {
);
expect(JSON.parse(stdout)).toMatchObject({
operation: "build_reconstruction_obligation_ledger",
predicate_type: "rea.reconstruction-obligation-ledger/v1",
predicate_type: "rea.reconstruction-obligation-ledger",
normalized_result: {
schema: "ReconstructionObligationLedger",
status: "unknown",
@@ -53,7 +53,7 @@ describe("Node runtime characterization", () => {
output_format: "commonjs-factory",
},
transformation_evidence: {
predicate_type: "rea.javascript-export-transformation/v1",
predicate_type: "rea.javascript-export-transformation",
authority: "shipped-artifact",
},
replay: { phase: "plan" },
@@ -84,7 +84,7 @@ describe("Node runtime characterization", () => {
evidence: { authority: "controlled-replay" },
},
evidence: {
predicate_type: "rea.runtime-characterization/v1",
predicate_type: "rea.runtime-characterization",
authority: "controlled-replay",
},
});
+2 -1
View File
@@ -1,4 +1,5 @@
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { tmpdir } from "node:os";
import { describe, expect, it } from "vitest";
import type { AnalysisOperationPort } from "../../../src/application/AnalysisProvider.js";
@@ -37,7 +38,7 @@ describe("MCP permission preflight", () => {
code: "permission_required",
details: {
capability: "artifact_extract",
missing: { roots: [expect.stringMatching(/rea-extracted-/u)] },
missing: { roots: [tmpdir()] },
},
remediation: {
restart_required: true,
+5 -6
View File
@@ -126,12 +126,11 @@ describe("guided prompts over MCP", () => {
arguments: { feature: " " },
}),
).rejects.toThrow(/Invalid arguments/u);
await expect(
client.getPrompt({
name: "investigate_feature",
arguments: { feature: "x".repeat(4_097) },
}),
).rejects.toThrow(/Invalid arguments/u);
const longPrompt = await client.getPrompt({
name: "investigate_feature",
arguments: { feature: "x".repeat(4_097) },
});
expect(longPrompt.messages[0]?.content).toMatchObject({ type: "text" });
await expect(client.getPrompt({ name: "missing_prompt" })).rejects.toThrow(
/not found/u,
);
+1 -1
View File
@@ -59,7 +59,7 @@ it("advertises the native function discovery-to-dossier workflow", async () => {
(await client.listTools()).tools.map((tool) => [tool.name, tool]),
);
expect(tools.get("binary_overview")?.description).toContain(
"follow with search_procedures or list_procedures, then pass a returned name or address to analyze_function",
"Use search_procedures, list_procedures, or analyze_function directly when you already know which procedure to inspect",
);
expect(tools.get("analyze_function")?.description).toContain(
"typically selected from search_procedures or list_procedures",
+1 -1
View File
@@ -108,7 +108,7 @@ describe("tool result projection", () => {
evidence: {
provider: { id: "fixture", name: "Fixture", version: "1" },
operation: "fixture",
predicate_type: "rea.analysis/v2",
predicate_type: "rea.analysis",
parameters: {},
raw_result: null,
confidence: "observed",