mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 06:55:55 +00:00
* feat(evidence): paginate retained evidence discovery summaries Let callers page summary metadata in canonical Evidence ID order without loading record payloads into the response. Keep filter and link totals global to all matches and preserve the unpaged response for existing clients. * test(evidence): use the supported compact schema profile * docs(evidence): explain the summary pagination request default * test: align verification fixtures with current public contracts Keep the production changes from upstream and update the verification consumers that still asserted their retired contracts: - assert unknown workflow identity structurally and retain the bounded provider caveats; - observe the process capture's partial-error delivery while preserving live cleanup ownership assertions; - use the package's declared imports in the isolated release controller; - refresh the replay card digest after the Evidence subject identity migration; - use the supported compact Kimi profile while testing case-insensitive environment keys; - assert each public interface's own capture issue path. These are shared test and verifier compatibility repairs. The evidence summary pagination and config-printer feature changes remain separate. * test: observe the session close result in Kuna retry coverage * test: follow the persisted DOL snapshot target identity * test: align CLI and progress fixtures with shared owners Reuse the core registrar for decompile-all instead of registering it twice after upstream #11680. Assert the outer MCP start/completion notifications separately from provider cleanup progress introduced by #11637, retaining cleanup, rate, timeout, cancellation, and evidence assertions. * docs: link CLI paging guidance to its canonical contract
127 lines
5.1 KiB
TypeScript
127 lines
5.1 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { inspectAnalysisView } from "../application/analysisView/AnalysisViewService.js";
|
|
import { ArtifactResourceScope } from "../resources/index.js";
|
|
import { ANALYSIS_VIEW_PROVIDER } from "../domain/investigationProviders.js";
|
|
import { inspectEvidenceBundleCommand } from "../application/EvidenceBundleCommands.js";
|
|
import { ANALYSIS_VIEW_TOOL_CONTRACTS } from "../contracts/analysisViewToolContracts.js";
|
|
import {
|
|
getEvidenceBundleInputSchema,
|
|
importEvidenceBundleInputSchema,
|
|
} from "../contracts/sessionToolSchemas.js";
|
|
import { CLI_COMMANDS } from "../contracts/cliCommandNames.js";
|
|
import { parseCliJsonInput } from "./cliJsonInput.js";
|
|
import { logCliCommand } from "../cliLogging.js";
|
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
|
import type { Logger } from "pino";
|
|
import { registerCliCommand } from "./commandRegistry.js";
|
|
import type { CliInstance } from "./types.js";
|
|
import { localPathStringSchema } from "../domain/localPath.js";
|
|
import { withCommandCancellation } from "./commandCancellation.js";
|
|
import { contractNamed } from "./contractCliDescription.js";
|
|
import { registerContractDocumentCommand } from "./contractCommand.js";
|
|
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
|
|
import { jsonInputArgument } from "./jsonInputArgument.js";
|
|
|
|
const inspectEvidenceBundleCliInputSchema =
|
|
getEvidenceBundleInputSchema.safeExtend({
|
|
path: importEvidenceBundleInputSchema.shape.path,
|
|
});
|
|
|
|
/** Project selected views of completed analysis Evidence through the CLI. */
|
|
export const registerAnalysisViewCommands = (
|
|
cli: CliInstance,
|
|
logger: Logger,
|
|
): void => {
|
|
registerCliCommand(cli, CLI_COMMANDS.inspectEvidenceBundle, {
|
|
description:
|
|
"Inspect a local Evidence bundle completely, as optionally paged discovery metadata, as a page of selected complete records, or as direct-link and retained-closure membership.",
|
|
args: z.object({
|
|
inputJson: jsonInputArgument(
|
|
"JSON or JSON file with absolute path, detail, optional record filters, summary/records/links offset/limit, and links traversal/link_status",
|
|
inspectEvidenceBundleCliInputSchema,
|
|
),
|
|
}),
|
|
run: ({ args }) =>
|
|
withCommandCancellation((signal) =>
|
|
logCliCommand(logger, CLI_COMMANDS.inspectEvidenceBundle, async () => {
|
|
const input = await parseCliJsonInput(
|
|
args.inputJson,
|
|
CLI_COMMANDS.inspectEvidenceBundle,
|
|
signal,
|
|
);
|
|
if (!input.ok) return input.error;
|
|
const parsed = inspectEvidenceBundleCliInputSchema.safeParse(
|
|
input.value,
|
|
);
|
|
if (!parsed.success)
|
|
return {
|
|
error: "Evidence bundle inspection failed",
|
|
...projectAnalysisError(
|
|
analysisInputErrorFromIssues(
|
|
CLI_COMMANDS.inspectEvidenceBundle,
|
|
parsed.error.issues,
|
|
input.value,
|
|
),
|
|
),
|
|
};
|
|
const result = await inspectEvidenceBundleCommand(
|
|
parsed.data,
|
|
signal,
|
|
);
|
|
return result.ok
|
|
? result.value
|
|
: {
|
|
error: "Evidence bundle inspection failed",
|
|
...projectAnalysisError(result.error),
|
|
};
|
|
}),
|
|
),
|
|
});
|
|
registerContractDocumentCommand(
|
|
cli,
|
|
logger,
|
|
contractNamed(ANALYSIS_VIEW_TOOL_CONTRACTS, "inspect_analysis_view"),
|
|
{
|
|
description:
|
|
"Project a selected view of completed Evidence JSON for a supported analysis operation. For inventory rows, use --format csv or --format tsv with --filter-output normalized_result.items and --columns logical_path,artifact_id (if those fields are included in the view).",
|
|
document: "Inline workflow JSON or JSON file path",
|
|
// An evidence-file path is resolved against the operator's working directory.
|
|
callerPaths: [["source", "path"]],
|
|
cliOptions: {
|
|
evidenceBundle: localPathStringSchema
|
|
.optional()
|
|
.describe(
|
|
"Read the exact retained-evidence source ID from this local Evidence bundle without reopening the target; omit for inline Evidence",
|
|
),
|
|
},
|
|
},
|
|
async (document, { signal, operation, cliOptions }) => {
|
|
const resources = new ArtifactResourceScope();
|
|
const bundlePath = cliOptions.evidenceBundle;
|
|
const result = await finishAnalysisCommand(
|
|
() =>
|
|
inspectAnalysisView(document, undefined, {
|
|
signal,
|
|
resources,
|
|
...(bundlePath === undefined
|
|
? {}
|
|
: { evidenceBundlePath: bundlePath }),
|
|
}),
|
|
resources,
|
|
ANALYSIS_VIEW_PROVIDER.id,
|
|
operation,
|
|
signal,
|
|
);
|
|
// Preserve the inline command's existing error label without copying
|
|
// the authenticated completed Evidence or its partial observation.
|
|
return result.ok
|
|
? result.value
|
|
: bundlePath === undefined
|
|
? { error: "Application workflow failed", ...result.error }
|
|
: result.error;
|
|
},
|
|
);
|
|
};
|