refactor: return complete analysis results inline
This commit is contained in:
@@ -151,7 +151,7 @@ const evidenceValues = (
|
||||
);
|
||||
if (!inventory.success) return [];
|
||||
if (kind === "manifest") return [inventory.data.manifest.manifest_id];
|
||||
return inventory.data.occurrences.items.map(({ occurrence_id: id }) => id);
|
||||
return inventory.data.occurrences.map(({ occurrence_id: id }) => id);
|
||||
};
|
||||
|
||||
const isProcessCaptureEvidence = (evidence: LedgerEvidence): boolean => {
|
||||
|
||||
@@ -58,8 +58,8 @@ const registerCommitTool = (
|
||||
options.permissionAuthority,
|
||||
{
|
||||
path: input.workspace_path,
|
||||
readCapability: "investigation_workspace_read",
|
||||
writeCapability: "investigation_workspace_write",
|
||||
readCapability: "reconstruction_coverage_read",
|
||||
writeCapability: "reconstruction_coverage_write",
|
||||
operation: commitContract.name,
|
||||
},
|
||||
);
|
||||
@@ -104,7 +104,7 @@ const registerQueryTool = (
|
||||
const authorized = await authorizeRootPermission(
|
||||
options.permissionAuthority,
|
||||
{
|
||||
capability: "investigation_workspace_read",
|
||||
capability: "reconstruction_coverage_read",
|
||||
roots: [input.workspace_path],
|
||||
access: "read",
|
||||
operation: queryContract.name,
|
||||
|
||||
@@ -29,31 +29,29 @@ export const registerArtifactComparisonTool = (
|
||||
};
|
||||
const left = resolveSessionEvidenceIds(
|
||||
session,
|
||||
input.left_evidence_ids,
|
||||
[input.left_evidence_id],
|
||||
expected,
|
||||
);
|
||||
if (!left.ok) return toCallToolResult(left, contract);
|
||||
const right = resolveSessionEvidenceIds(
|
||||
session,
|
||||
input.right_evidence_ids,
|
||||
[input.right_evidence_id],
|
||||
expected,
|
||||
);
|
||||
if (!right.ok) return toCallToolResult(right, contract);
|
||||
const computed = await runDerivedOperation(context, contract.name, () =>
|
||||
compareArtifacts(left.value, right.value, input.offset, input.limit),
|
||||
compareArtifacts(left.value, right.value),
|
||||
);
|
||||
if (!computed.ok) return toCallToolResult(computed, contract);
|
||||
const comparison = computed.value;
|
||||
const leftEvidenceIds = input.left_evidence_ids;
|
||||
const rightEvidenceIds = input.right_evidence_ids;
|
||||
const leftEvidenceIds = [input.left_evidence_id];
|
||||
const rightEvidenceIds = [input.right_evidence_id];
|
||||
const evidence = createEvidence(undefined, ARTIFACT_COMPARISON_PROVIDER, {
|
||||
predicateType: "rea.artifact-comparison/v1",
|
||||
operation: contract.name,
|
||||
parameters: {
|
||||
left_evidence_ids: leftEvidenceIds,
|
||||
right_evidence_ids: rightEvidenceIds,
|
||||
offset: input.offset,
|
||||
limit: input.limit,
|
||||
},
|
||||
result: jsonValueSchema.parse(comparison),
|
||||
confidence: "derived",
|
||||
@@ -75,8 +73,8 @@ export const registerArtifactComparisonTool = (
|
||||
|
||||
const artifactUnknownInput = (
|
||||
input: {
|
||||
readonly left_evidence_ids: readonly string[];
|
||||
readonly right_evidence_ids: readonly string[];
|
||||
readonly left_evidence_id: string;
|
||||
readonly right_evidence_id: string;
|
||||
readonly unknown_registry_approved?: true | undefined;
|
||||
},
|
||||
status: ReturnType<typeof compareArtifacts>["status"],
|
||||
@@ -89,8 +87,8 @@ const artifactUnknownInput = (
|
||||
severity:
|
||||
status === "unknown" || status === "truncated" ? "high" : "medium",
|
||||
domain: "artifact-comparison",
|
||||
supporting_evidence_ids: [...input.left_evidence_ids],
|
||||
contradicting_evidence_ids: [...input.right_evidence_ids],
|
||||
supporting_evidence_ids: [input.left_evidence_id],
|
||||
contradicting_evidence_ids: [input.right_evidence_id],
|
||||
required_authority: "shipped-artifact",
|
||||
required_confidence: "observed",
|
||||
required_environment: null,
|
||||
|
||||
@@ -31,13 +31,7 @@ export const registerBundleComparisonTool = (
|
||||
if (!left.ok) return toCallToolResult(left, contract);
|
||||
if (!right.ok) return toCallToolResult(right, contract);
|
||||
const computed = await runDerivedOperation(context, contract.name, () =>
|
||||
compareBundles(
|
||||
left.value,
|
||||
right.value,
|
||||
input.record_pairs,
|
||||
input.offset,
|
||||
input.limit,
|
||||
),
|
||||
compareBundles(left.value, right.value, input.record_pairs),
|
||||
);
|
||||
if (!computed.ok) return toCallToolResult(computed, contract);
|
||||
const comparison = computed.value;
|
||||
@@ -48,8 +42,6 @@ export const registerBundleComparisonTool = (
|
||||
left_bundle_sha256: comparison.left_bundle_sha256,
|
||||
right_bundle_sha256: comparison.right_bundle_sha256,
|
||||
record_pairs: input.record_pairs,
|
||||
offset: input.offset,
|
||||
limit: input.limit,
|
||||
},
|
||||
result: jsonValueSchema.parse(comparison),
|
||||
confidence: "derived",
|
||||
|
||||
@@ -17,6 +17,7 @@ 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";
|
||||
|
||||
interface EvidenceToolRegistration {
|
||||
readonly logger: Logger;
|
||||
@@ -49,8 +50,15 @@ export const registerEvidenceTools = (
|
||||
message: "started",
|
||||
});
|
||||
const parameters = jsonObjectSchema.parse(input);
|
||||
const executionParameters =
|
||||
contract.name === "extract_artifact"
|
||||
? {
|
||||
...parameters,
|
||||
output_root: createArtifactExtractionDestination(),
|
||||
}
|
||||
: parameters;
|
||||
if (options.permissionAuthority !== undefined) {
|
||||
const request = permissionRequest(contract.name, parameters);
|
||||
const request = permissionRequest(contract.name, executionParameters);
|
||||
if (request !== undefined) {
|
||||
const authorized = await options.permissionAuthority.authorize(
|
||||
request,
|
||||
@@ -67,7 +75,7 @@ export const registerEvidenceTools = (
|
||||
options.logger,
|
||||
contract.name,
|
||||
() =>
|
||||
analysis.execute(contract.name, parameters, {
|
||||
analysis.execute(contract.name, executionParameters, {
|
||||
signal: context.mcpReq.signal,
|
||||
progress,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user