feat(observability): durable per-evaluation policy-audit summary + would-block rate (#3727)#3820
Merged
Merged
Conversation
…ate (#3727) The pipeline policy gate's durable dual-emit was gated on `violations.length > 0`, so a CLEAN evaluation wrote nothing — the durable log captured only the numerator (violations), and the would-block RATE had no denominator (total evaluations). The soak window (warn-mode default since #3769) was accumulating with no recoverable denominator. Fix (7/7 higher_order vote — Option A, SUPPLEMENT): emit ONE per-evaluation summary record (recordKind:'summary', violationCount) on EVERY evaluation incl clean ones, IN ADDITION to the per-violation records (now recordKind:'violation') — preserving the #3710 count-parity invariant (the parity assertion now scopes by recordKind). New computePolicyWouldBlockRate(events): denominator = summary records, numerator = summaries with violationCount>0. recordKind + violationCount round-trip through the audit bridge into the persisted record (extracted pipelinePolicyMetadata to keep mapPolicyGate under the complexity cap). The inputTrustTier:'4' the issue also flagged is BY DESIGN (pipeline policy has no single user tier; documented) — left unchanged. Live-routing use of the rate stays gated on #3769-enforce readiness. TDD: clean→1 summary+0 violation; N-violation→N violation+1 summary(count=N) with #3710 parity scoped by recordKind; bridge round-trip; rate over fixtures; empty→0. 1488 tests pass; typecheck/lint/governance/producer-consumer clean. Closes #3727. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…summary record The two runDevPipeline durable-policy-audit integration tests asserted one policy_gate record per evaluation; #3727 adds a per-evaluation summary record, so each warn-mode violation now persists 2 records (1 violation + 1 summary). Scope the per-violation parity assertions by metadata.recordKind and assert the summary record's violationCount. verifyChain still passes (chain integrity unaffected). Caught by CI (full suite); the policy-evaluator unit copies were already updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3727. Decided by a 7/7 higher_order vote (Option A — capture-now, supplement).
Bug
The pipeline policy gate's durable dual-emit was gated on
if (violations.length > 0)(policy-evaluator.ts:244) — a clean evaluation wrote nothing anywhere (no bus event, no durable record, no OutcomeStore; Contrarian-check confirmed). So the durable log captured only the numerator (violations); the would-block RATE had no denominator (total evaluations). The soak window (warn-mode default since #3769) was accumulating with the denominator non-backfillable.(The
inputTrustTier:'4'the issue also flagged is by design — pipeline policy is provenance/stage-driven with no single user tier; documented at line 305. Left unchanged.)Fix
evaluatePipelinePolicynow appends one per-evaluation summary record (recordKind:'summary',violationCount) on every evaluation including clean ones — in addition to the existing per-violation records (now taggedrecordKind:'violation'), preserving the observability: converge policy audit emission (emitPolicyEvent vs emitPolicyEvents) onto one durable sink #3710 count-parity invariant (the parity assertion now scopes byrecordKind).computePolicyWouldBlockRate(events): denominator = summary records; numerator = summaries withviolationCount > 0. Per-violation records are intentionally not counted (would double-count).recordKind+violationCountround-trip through the audit bridge into the persisted record (the readiness gate reads persisted records). ExtractedpipelinePolicyMetadatato keepmapPolicyGateunder the complexity cap.Live-routing use of the rate stays gated on the #3769-enforce soak-readiness gate.
Verification (TDD)
clean → 1 summary + 0 violation; N-violation → N violation + 1 summary(count=N) with #3710 parity scoped by
recordKind; bridge round-trip of the new fields; rate over fixtures; empty → 0. 1488 tests pass; typecheck, lint, governance, producer-consumer clean.🤖 Generated with Claude Code