refactor!: enforce canonical evidence and provider boundaries
Deliver complete Evidence directly through MCP with required nullable analysis profiles and immutable per-server delivery settings. Bind selected environments at construction and require typed cleanup outcomes with retained retry ownership. Remove test-only routing, duplicate session and snapshot metadata, producer-field repairs, and ambiguous provider arguments. Separate artifact byte identity from occurrence classification and retain typed source-map and partial native facts across CLI, MCP, and verifier consumers. BREAKING CHANGE: obsolete Evidence envelopes, session aliases, incomplete snapshots, and missing normalized producer facts are no longer accepted.
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
import { safeParseJson } from "./domain/safeJson.js";
|
||||
|
||||
const SAFE_VALIDATION_MESSAGE =
|
||||
"REA could not read the command arguments. Run `rea --help`, correct the arguments, then try again.";
|
||||
const UNSUPPORTED_OUTPUT_COMBINATION_MESSAGE =
|
||||
"Token windows cannot preserve structured output. Remove --token-limit/--token-offset and use --filter-output or command pagination.";
|
||||
|
||||
@@ -17,8 +13,6 @@ export type CliOutputArgumentValidation =
|
||||
readonly message: string;
|
||||
};
|
||||
|
||||
type JsonRecord = Record<string, unknown>;
|
||||
|
||||
interface ParsedCliOutputArguments {
|
||||
readonly filterOutput: string | undefined;
|
||||
readonly format: string;
|
||||
@@ -28,16 +22,6 @@ interface ParsedCliOutputArguments {
|
||||
readonly tokenWindow: boolean;
|
||||
}
|
||||
|
||||
const isRecord = (value: unknown): value is JsonRecord =>
|
||||
typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
|
||||
const validationError = (value: JsonRecord): JsonRecord | undefined => {
|
||||
if (value.code === "VALIDATION_ERROR") return value;
|
||||
if (value.ok === false && isRecord(value.error))
|
||||
return value.error.code === "VALIDATION_ERROR" ? value.error : undefined;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/** Read effective Incur output controls at the executable boundary. */
|
||||
export const parseCliOutputArguments = (
|
||||
arguments_: readonly string[],
|
||||
@@ -145,32 +129,3 @@ export const renderCliOutputArgumentError = (
|
||||
return `ok: false\nerror:\n code: ${error.code}\n message: ${JSON.stringify(error.message)}\n`;
|
||||
return `${JSON.stringify(value)}\n`;
|
||||
};
|
||||
|
||||
/** Remove validator internals from Incur's caller-visible CLI output. */
|
||||
export const sanitizeCliOutput = (output: string): string => {
|
||||
const trimmed = output.trimStart();
|
||||
if (trimmed.startsWith("{")) {
|
||||
const decoded = safeParseJson(trimmed);
|
||||
if (!decoded.ok) return output;
|
||||
const parsed: unknown = decoded.value;
|
||||
if (!isRecord(parsed)) return output;
|
||||
const error = validationError(parsed);
|
||||
if (error !== undefined) {
|
||||
const safeError = {
|
||||
code: "VALIDATION_ERROR",
|
||||
message: SAFE_VALIDATION_MESSAGE,
|
||||
};
|
||||
if (error === parsed) return `${JSON.stringify(safeError)}\n`;
|
||||
return `${JSON.stringify({ ...parsed, error: safeError })}\n`;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
if (
|
||||
/^ok: false\r?\nerror:\r?\n code: VALIDATION_ERROR(?:\r?\n|$)/u.test(
|
||||
trimmed,
|
||||
)
|
||||
)
|
||||
return `ok: false\nerror:\n code: VALIDATION_ERROR\n message: "${SAFE_VALIDATION_MESSAGE}"\n`;
|
||||
if (!/^code: VALIDATION_ERROR(?:\r?\n|$)/u.test(trimmed)) return output;
|
||||
return `code: VALIDATION_ERROR\nmessage: "${SAFE_VALIDATION_MESSAGE}"\n`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user