Files
Dragan Spiridonov dc6fce5e70 feat(contracts): ADR-103 structured verdict handoffs — RiskDecision et al
Versioned, additive-only verdict envelopes for agent/MCP handoffs:
RiskDecision (quality gates), FindingVerdict (review findings with
adversarial refutations), CoverageGap (risk-weighted gaps).

- src/contracts/verdicts.ts: dependency-free validators (source of
  truth) + mirrored draft-07 JSON Schemas; no zod/ajv runtime deps
  (light-install posture preserved)
- quality_assess MCP boundary now attaches a validated riskDecision
  envelope derived from the gate outcome (approve/block, escalate when
  indeterminate) — additive, existing payload unchanged; direct and
  wrapped handlers share the same mapToResult so MCP parity is inherent
- schemas/*.schema.json published via scripts/generate-verdict-schemas.mjs
  for external ajv validation and workflow agent({schema}) enforcement
  (consumed by improvement 5)

17 contract tests (goldens validate; mutations rejected with field-level
errors; builder always emits valid envelopes). E2E: envelope emitted by
the compiled boundary builder validates with stock ajv against the
published schema; mutated sample rejected. tsc + eslint clean.

Part of #520 (improvement 6/7, Tier 3).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 10:15:07 +00:00

26 lines
933 B
JavaScript

#!/usr/bin/env node
/**
* ADR-103 — Publish the verdict JSON Schemas from the compiled contracts
* module to schemas/*.schema.json. The TypeScript validators in
* src/contracts/verdicts.ts are the source of truth; run this after
* changing them (requires a prior `npx tsc` emit).
*
* Usage: node scripts/generate-verdict-schemas.mjs
*/
import { mkdirSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
const { VERDICT_SCHEMAS } = await import(join(root, 'dist', 'contracts', 'verdicts.js'));
const outDir = join(root, 'schemas');
mkdirSync(outDir, { recursive: true });
for (const [name, schema] of Object.entries(VERDICT_SCHEMAS)) {
const file = join(outDir, `${name}.schema.json`);
writeFileSync(file, JSON.stringify(schema, null, 2) + '\n');
console.log(`wrote ${file}`);
}