Files
reverse-engineering-anything/src/application/ReconstructionCoverageService.ts
T
d734e6424d fix(cli): advertise parsed JSON documents in --schema
`--schema` for JSON-input CLI commands showed only an opaque
`inputJson` string, so callers could not see the document the command
actually parses. The argument now carries the decoded document as its
contentSchema, built from the same contract each command or its service
parses with (the Evidence input frame, or the ledger and coverage
request schemas). `$schema` is stripped, and a schema JSON Schema cannot
represent is refused rather than advertised as {}.

Fixes #9195
Supersedes #9283

Squashed from #9283 (with morluto's validation test) and rebased onto
main; the coverage test now expects boundary_id's stable-identifier
pattern from #9919. #9214 by 1052326311 took the same approach.

Co-Authored-By: morluto <76467478+morluto@users.noreply.github.com>
Co-Authored-By: 1052326311 <65798732+1052326311@users.noreply.github.com>
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-14 14:16:39 +01:00

35 lines
1.1 KiB
TypeScript

import { parseAnalysisInput } from "./AnalysisInput.js";
import { reconstructionCoverageRequestSchema } from "../domain/reconstructionCoverageInput.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import {
evaluateParsedReconstructionClosure,
readReconstructionCoverageData,
type ReconstructionClosureResult,
} from "../domain/reconstructionCoverage.js";
import type { Result } from "../domain/result.js";
const OPERATION = "evaluate_reconstruction_coverage";
/** Evaluate inline reconstruction coverage against a named boundary. */
export const evaluateReconstructionCoverage = (
rawInput: unknown,
nowEpochMs = Date.now(),
): Result<ReconstructionClosureResult, AnalysisError> => {
const parsed = parseAnalysisInput(
OPERATION,
rawInput,
reconstructionCoverageRequestSchema,
);
if (!parsed.ok) return parsed;
const coverage = readReconstructionCoverageData(parsed.value.coverage, [
"coverage",
]);
if (!coverage.ok) return coverage;
return evaluateParsedReconstructionClosure(
coverage.value,
parsed.value.boundary_id,
nowEpochMs,
);
};