mirror of
https://github.com/morluto/rea.git
synced 2026-11-17 04:04:25 +00:00
Declare logical Evidence sources once and resolve exact retained inputs through shared application workflows across 20 composition tools. Preserve domain-owned authentication, source closure, caller choices, coverage and resource admission. Validation includes public CLI/MCP regressions, local Codex terra/high trials and fresh-import real-artifact workflows. Measurements, failed attempts and coverage limits are recorded in docs/verification/evidence-input-composition-2026-10-31.md. Fixes #8293. Fixes #8281. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
71 lines
2.5 KiB
TypeScript
71 lines
2.5 KiB
TypeScript
import type { EvidenceMcpServer } from "../EvidenceMcpServer.js";
|
|
import { runAdmittedToolOperation } from "../admittedToolOperation.js";
|
|
|
|
import {
|
|
importManagedReconstructionEvidenceResolved,
|
|
resolveManagedReconstructionEvidenceInput,
|
|
} from "../../application/managed/ManagedReconstructionService.js";
|
|
import { logToolExecution } from "../toolLogging.js";
|
|
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
|
import { toolContract } from "../../contracts/toolContracts.js";
|
|
import type { ManagedWorkflowToolRegistration } from "./types.js";
|
|
|
|
const reconstructionContract = toolContract("import_managed_reconstruction");
|
|
|
|
/** Register the managed reconstruction import workflow tool. */
|
|
export const registerImportManagedReconstruction = (
|
|
server: EvidenceMcpServer,
|
|
options: ManagedWorkflowToolRegistration,
|
|
): void => {
|
|
server.registerTool(
|
|
reconstructionContract.name,
|
|
toolRegistrationOptions(reconstructionContract),
|
|
async (input, context) =>
|
|
runAdmittedToolOperation(
|
|
server,
|
|
options.withAdmittedAnalysis,
|
|
reconstructionContract.name,
|
|
context.mcpReq.signal,
|
|
async () => {
|
|
const resolved = resolveManagedReconstructionEvidenceInput(
|
|
input,
|
|
options.session.evidenceForAnalysis.bind(options.session),
|
|
{ signal: context.mcpReq.signal },
|
|
);
|
|
if (!resolved.ok)
|
|
return server.delivery.toCallToolResult(
|
|
resolved,
|
|
reconstructionContract,
|
|
);
|
|
const result = await logToolExecution(
|
|
options.logger,
|
|
reconstructionContract.name,
|
|
() =>
|
|
Promise.resolve(
|
|
importManagedReconstructionEvidenceResolved(resolved.value),
|
|
),
|
|
);
|
|
if (!result.ok)
|
|
return server.delivery.toCallToolResult(
|
|
result,
|
|
reconstructionContract,
|
|
);
|
|
const recordedSource = options.recordEvidence?.(
|
|
resolved.value.staticEvidence,
|
|
);
|
|
if (recordedSource !== undefined && !recordedSource.ok)
|
|
return server.delivery.toCallToolResult(
|
|
recordedSource,
|
|
reconstructionContract,
|
|
);
|
|
const recorded = options.recordEvidence?.(result.value);
|
|
return server.delivery.toEvidenceToolResult(
|
|
result.value,
|
|
reconstructionContract,
|
|
recorded,
|
|
);
|
|
},
|
|
),
|
|
);
|
|
};
|