Phase 5: Judgment policy engine (D-0026, D-0027) #8
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/policy-engine"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What does this PR do?
Implements the Judgment policy engine per D-0027 (posture, evaluation structure, provisional thresholds) and D-0026 (protected addresses).
DefaultPolicyEngine(viegard-defaultv0.1-provisional): evaluates every classification through the D-0027 chain: emergency stop -> protected-address list -> allowlists -> threshold gates (AI confidence x severity for model-backed, normalized-confidence bands for deterministic; AI can never override a deterministic Deny) -> rate caps -> circuit breaker -> dry-run/manual-approval overlay. Every stage appends aGuardrailEvaluation, pass or fail, so eachDecisioncarries its complete explainability chain.ProtectedAddressList: the D-0026 default CIDRs (IPv4 + IPv6) baked in as configurable defaults; fail-closed: unparseable addresses are treated as protected; IPv4-mapped IPv6 checks the embedded IPv4.PolicyOptionsatViegard:Policywith all D-0027 provisional numbers as configurable defaults, plus a startup validator (CIDR parseability, band ordering, positive durations).IGuardrailStateStoreport + in-memory implementation: rolling hour/day action counters, consecutive-failure tracking, circuit breaker, repeat-offender lookback. Postgres implementation deferred (TODO.md).Fixes #
How was this tested?
dotnet build Viegard.slnx- 0 errors, 0 warningsdotnet test Viegard.slnx- 232/232 pass including 18 live PostgreSQL integration tests (independent re-run after agent implementation)Implementation drafted by a coding agent against the D-0026/D-0027 spec, independently reviewed (protected-list fail-closed and IPv4-mapped handling spot-checked) and re-verified.
Checklist