Files
AutopilotMonitor/src
Oliver Kieselbach 44f0e44b72 feat(backend): M5.c.3 GET /api/sessions/{id}/reducer-verification — structural audit
Third and final V2 Inspector read endpoint. Admin-only (not tenant-exposed)
structural health check over a session's persisted SignalLog +
DecisionTransitions journal. Closes the M5 read-endpoint trio.

- Shared DTO ReducerVerificationReport + VerificationIssue: counts,
  ordinal / step-index contiguity, ReducerVersion drift, orphaned-reference
  count, human-readable issue stream for the Inspector's verification panel.
- ReducerVerifier.Verify — pure function, zero IO. Five detectors:
  empty-session (Info), signal ordinal gaps (Warning, capped at 20 issues +
  overflow summary to keep reports bounded), step-index gaps (Warning, same
  cap), orphaned transitions whose SignalOrdinalRef falls outside the loaded
  signal set (Warning, capped), and ReducerVersion drift (Info — known
  condition per plan §2.10, not an error).
- GetSessionReducerVerificationFunction — reads signals + transitions for
  the session, loads the live DecisionEngine.ReducerVersion, runs the
  verifier, returns the report. Global-Admin cross-tenant fallback via
  SessionsIndex when the effective tenant has no data. Truncation flag when
  either the 5000-signal or 5000-transition cap is hit.
- Endpoint gated by EndpointPolicy.GlobalAdminOnly — the plan explicitly
  scopes this to adminMode/ops access. The fail-closed catalog policy
  completeness test enforces the registration.

Scope boundary explicitly documented on the function: full engine replay
(DecisionEngine.Reduce over reconstructed DecisionSignals with per-step diff)
is NOT implemented in this commit. It would require polymorphic
deserialisation of SignalRecord.PayloadJson back into DecisionSignal with its
Evidence abstract type, which is a non-trivial refactor. The structural
checks land today catch the realistic release-gate failure modes (corruption,
drift, orphan refs) and give ops a usable tool. Full replay is a dedicated
follow-up once the Evidence deserialisation contract is pinned down.

9 new tests cover all five detectors plus happy path, shuffled input, and
the issue-cap overflow message. 636/636 backend green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 10:56:18 +02:00
..