WI-012 · Platform & Contracts · validation-pipeline
done P0 medium risk Owner: Paul 100% · 8/8 tasks complete
| Code | WI-012 |
|---|---|
| Phase | Platform & Contracts |
| Order | 12 of 93 |
| Story points | 13 |
| Primary surface | Scan validation pipeline library (ProviderAttempt -> validated draft) |
| Retires | — |
| Depends on | Freeze scan I/O contract schemas + versioning |
| Blocks | Candidate ranking engine — deterministic features, fixed-point scoring, priority bands, tie-break, explainability, canonical hash, Scan recovery & salvage — orchestrator, cause-based matrix, retry/fallback (through P2), partial results, Sprint 4: Vision Contract POC - scan types, watchlists, overlays, appraisal routing |
Treat raw model output as untrusted: a validation pipeline catches malformed output and retries/falls back before anything downstream uses it (§19).
Spec (docs/specs/P3)
Build (validation)
Test (keyless)
Freeze (§29)
ScanValidationPipeline runs the 10 ordered stages deterministically; validates against the exact P1 schema by scan-type+result-schema+version; issue model carries stage/code/severity/retryability/salvageability/path/trust-effect; reference/coordinate/evidence/boundary validators + deterministic repair registry exist; only P3 mints TrustedScanResult; keyless stage/mutation/property tests pass. Per spec §26/§27 (validation rows). §29 reconciliations resolved before freeze.
No paid API / infra spend triggered by this item.
done Sprint: P&C Wave 2: Core Contracts
Edit status / sprint on the ★ Live Board → — changes are logged live with who / when / why.
No human tasks linked.
None recorded yet.
None recorded yet.
None recorded yet.
No files / artifacts recorded.
Built packages/scan-validation: issues.mjs (taxonomy+7 dims), trusted.mjs (branded result), validators.mjs (admissibility/contract-identity/coordinate-geometry/reference-integrity/boundary-safety/completeness + domain/evidence/scan-invariant subset), receipt.mjs, pipeline.mjs (ordered stages -> §18 disposition -> mint). 23 keyless tests green; ci:floor 5 suites. (A misplaced git worktree was recovered to main; solo work per D37.)
Added repair.mjs (§11 deterministic repair registry: derive_bbox_center, dedupe_warnings — idempotent, wired into the pipeline + recorded in the receipt). Expanded scan_invariants for item_scan/mark_scan/appraisal_prepare/appraisal_value (§7.3-§7.7). Added mutation tests (§23.10, 11 mutations) + coordinate property tests. 43 keyless tests pass; ci:floor 5 suites. Remaining: full JSON-Schema validation vs the P1 bundle.
Closed the last slice: stage 2 now runs full structural validation against the canonical P1 bundle (schema-validate.mjs: dependency-free Draft-2020-12 subset — type/required/properties/items/prefixItems/$ref/enum/const/min-max/minItems/pattern/minLength/additionalProperties), selecting the result-payload schema by scan-type. FINDING: the P3 core had been built against an invented draft shape (candidate_id, confidence 0-1, flat payload); the real P1 ScanResult is nested (result.{schema,status,payload}) with candidate.id, integer confidence 0-100, region.image_id, strongest_comps[] string ids. Added shape.mjs to normalize the real nested ScanResult/ScanRequest (input.images, profiles.watchlists) into the internal view, and realigned every validator (domain confidence 0-100, reference id/strongest_comps, scan-invariants raw_text/retake/currency) to real P1 field names. New shape.test.mjs proves the real nested ScanResult validates. 47 keyless tests pass; ci:floor 5 suites green.
Reversed the earlier flat-mint: P3 now NEVER reshapes. On accept it mints the canonical (safe-repaired) P1 ScanResult (result.{schema,status,payload}), branded — the same shape P1/P2 produce and P6/MCP store/project. normalizeDraft/Request stay an INTERNAL flat view the stages read (never emitted); safe-repairs mutate the canonical draft via payloadOf. shape.test.mjs now asserts nested input mints the canonical envelope (result.payload.candidates, envelope fields preserved, no flat leakage) + repair writes back into result.payload. 48 keyless tests; ci:floor 5 suites green.