feat(dotnet): import managed reconstructions

This commit is contained in:
N0zoM1z0
2026-07-16 20:37:42 +09:00
committed by N0zoM1z0
parent 798631ade6
commit c506664744
88 changed files with 1251 additions and 212 deletions
+32 -2
View File
@@ -69,7 +69,7 @@ const evidence = (result: ManagedMemberInspection) =>
const runtimeMembers = (): ManagedMemberInspection => {
const result = emptyManagedMembers(
"2".repeat(64),
"11112222-3333-4444-5555-666677778888",
"11112222-3333-4444-9555-666677778888",
);
return {
...result,
@@ -131,7 +131,7 @@ export const MANAGED_MEMBER_COMPARISON_EXAMPLE = {
emptyManagedMembers("0".repeat(64), "00112233-4455-6677-8899-aabbccddeeff"),
),
right: evidence(
emptyManagedMembers("1".repeat(64), "ffeeddcc-bbaa-9988-7766-554433221100"),
emptyManagedMembers("1".repeat(64), "ffeeddcc-bbaa-4988-9766-554433221100"),
),
limits: {
max_method_matches: 100,
@@ -142,6 +142,36 @@ export const MANAGED_MEMBER_COMPARISON_EXAMPLE = {
const runtimeExampleEvidence = evidence(runtimeMembers());
/** Minimal valid managed decompiler reconstruction import request. */
export const MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE = {
static_members: runtimeExampleEvidence,
decompiler: {
name: "ilspycmd",
version: "9.1.0.7988",
family: "ilspy",
executable_sha256: null,
options: ["--disable-updatecheck", "--type", "Example.Program"],
},
methods: [
{
token: "0x06000001",
signature_sha256: "3".repeat(64),
normalized_il_sha256: "5".repeat(64),
reconstruction: {
kind: "decompiled-csharp",
language: "csharp",
text: "internal static void Main() { }",
source_path: "/examples/Example.Program.cs",
start_line: 1,
end_line: 1,
},
},
],
notes: [
"Synthetic example only; decompiler output is imported as inference.",
],
};
/** Minimal valid managed runtime-correlation planning request. */
export const MANAGED_RUNTIME_CORRELATION_EXAMPLE = {
static_members: runtimeExampleEvidence,
@@ -1,9 +1,11 @@
import { compareManagedMembersInputSchema } from "../domain/managedMemberComparison.js";
import { managedReconstructionImportInputSchema } from "../domain/managedReconstruction.js";
import { managedRuntimeCorrelationInputSchema } from "../domain/managedRuntimeCorrelation.js";
import type { ToolContract } from "./toolContracts.js";
import { managedWorkflowOutputSchemas } from "./toolOutputSchemas.js";
import {
MANAGED_MEMBER_COMPARISON_EXAMPLE,
MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE,
MANAGED_RUNTIME_CORRELATION_EXAMPLE,
} from "./managedWorkflowExamples.js";
@@ -19,6 +21,12 @@ if (runtimeOutputSchema === undefined)
throw new Error(
"Missing managed workflow output schema for plan_managed_runtime_correlation",
);
const reconstructionOutputSchema =
managedWorkflowOutputSchemas.import_managed_reconstruction;
if (reconstructionOutputSchema === undefined)
throw new Error(
"Missing managed workflow output schema for import_managed_reconstruction",
);
/** Provider-neutral managed-code workflow contracts. */
export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
@@ -42,6 +50,26 @@ export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
},
],
},
{
name: "import_managed_reconstruction",
description:
"Import decompiler-produced managed reconstruction against authenticated inspect_managed_members Evidence. The workflow locks each method to artifact SHA-256, MVID, metadata token, signature hash, and normalized IL hash, records the decompiler identity and options, and marks C# or pseudocode as analyst inference rather than canonical byte observation.",
kind: "application",
inputSchema: managedReconstructionImportInputSchema,
outputSchema: reconstructionOutputSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
examples: [
{
title: "Import a decompiler reconstruction for one managed method",
input: MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE,
},
],
},
{
name: "plan_managed_runtime_correlation",
description:
+4
View File
@@ -30,6 +30,7 @@ import {
managedNativeBoundaryInspectionSchema,
} from "../domain/managedArtifact.js";
import { managedMemberComparisonResultSchema } from "../domain/managedMemberComparison.js";
import { managedReconstructionImportResultSchema } from "../domain/managedReconstruction.js";
import { managedRuntimeCorrelationResultSchema } from "../domain/managedRuntimeCorrelation.js";
import { artifactComparisonResultSchema } from "../domain/artifactComparison.js";
import { functionComparisonResultSchema } from "../domain/functionComparison.js";
@@ -550,6 +551,9 @@ export const managedWorkflowOutputSchemas: Readonly<
Record<string, z.ZodObject>
> = {
compare_managed_members: resultOf(managedMemberComparisonResultSchema),
import_managed_reconstruction: resultOf(
managedReconstructionImportResultSchema,
),
plan_managed_runtime_correlation: resultOf(
managedRuntimeCorrelationResultSchema,
),