[Task] Define shared shadow and enforce governance decisions
Background
Parent #7949. This task defines the shared policy decision contract. MCP quotas and LLM budgets need the same explainable shadow and enforce decision semantics, rather than incompatible local switches.
Existing capabilities and reuse
Reuse trusted request context, bounded runtime metrics and audit records from #7950. Reuse existing Redis and limiter primitives in the later execution integrations. #7933 is HTTP shadow traffic replay and comparison and is unrelated to this non-executing policy evaluation mode.
Implementation scope
- Define a versioned decision contract with policy and configuration version, mode, allow or would-deny or deny result, bounded reason codes, correlation and effective time.
- Shadow mode must not reject otherwise permitted requests or debit real quotas. Use an isolated bounded shadow ledger and counters for continuous evaluation, while recording actual observed usage normally.
- Enforce mode acts at the real admission and settlement points in #7957 and #7958. Define mode transitions, in-flight reservations, expiry and comparison semantics without moving or double-debiting state between ledgers.
- Authentication, authorization and fundamental resource protection always remain enforced independently of policy shadow mode.
Non-goals
Duplicating audit or metrics implementations, bypassing security in shadow mode, traffic mirroring, or claiming a contract-only implementation completes #7957 or #7958 integration.
Acceptance criteria
- [ ] A common decision schema and reason vocabulary is consumed by metrics and audit; bounded labels exclude tenant and trace IDs as unbounded dimensions.
- [ ] Shadow evaluation preserves normal routing and production quota state, yet evaluates repeated calls against evolving isolated state.
- [ ] Mode changes and in-flight work have deterministic, documented semantics without double accounting or lost reservations.
- [ ] Security and resource rejections remain effective in both modes.
- [ ] Executable contract tests are supplied for both MCP quota and LLM budget consumers; real execution integrations are tracked by their respective issues.
Tests
Contract and state-transition tests; concurrent shadow and enforce isolation; configuration updates and stale policy versions; audit and metric correlation tests; failure, expiry and cancellation cases and tests proving authentication, authorization and resource limits cannot be bypassed.
Dependencies
Completed request/terminal-context and runtime-observability contracts, plus #7950. Define this contract before #7957 and #7958; those tasks must ship actual shadow and enforce integration with their first release.
/assign