refactor(server): admit complete evidence workflows and share handlers

Validation: integrated changes passed formatting, typecheck, lint, resolved module-boundary verification and git diff --check. Tests and real-provider workflows were not run.
This commit is contained in:
morluto
2026-10-11 00:03:24 +08:00
parent 5f30ea6ff2
commit c1b5ccf0a4
43 changed files with 1482 additions and 915 deletions
@@ -1,4 +1,5 @@
import type { EvidenceMcpServer } from "../EvidenceMcpServer.js";
import { runAdmittedToolOperation } from "../admittedToolOperation.js";
import { recordSessionEvidenceSources } from "../sessionEvidence.js";
import {
@@ -23,27 +24,40 @@ export const registerReconstructionObligationLedgerTool = (
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
async (input) => {
const resolved = resolveReconstructionObligationLedgerRequest(input);
if (!resolved.ok)
return server.delivery.toCallToolResult(resolved, contract);
const result = await logToolExecution(options.logger, contract.name, () =>
Promise.resolve(
buildReconstructionObligationLedgerEvidenceValidated(resolved.value),
),
);
if (!result.ok) return server.delivery.toCallToolResult(result, contract);
const recorded = recordSessionEvidenceSources(
options.recordEvidence,
resolved.value.evidence_bundle.records,
);
if (!recorded.ok)
return server.delivery.toCallToolResult(recorded, contract);
return recordResult(
{ ...options, delivery: server.delivery },
contract,
result.value,
);
},
async (input, context) =>
runAdmittedToolOperation(
server,
options.withAdmittedAnalysis,
contract.name,
context.mcpReq.signal,
async () => {
const resolved = resolveReconstructionObligationLedgerRequest(input);
if (!resolved.ok)
return server.delivery.toCallToolResult(resolved, contract);
const result = await logToolExecution(
options.logger,
contract.name,
() =>
Promise.resolve(
buildReconstructionObligationLedgerEvidenceValidated(
resolved.value,
),
),
);
if (!result.ok)
return server.delivery.toCallToolResult(result, contract);
const recorded = recordSessionEvidenceSources(
options.recordEvidence,
resolved.value.evidence_bundle.records,
);
if (!recorded.ok)
return server.delivery.toCallToolResult(recorded, contract);
return recordResult(
{ ...options, delivery: server.delivery },
contract,
result.value,
);
},
),
);
};