Cap evidence stored on Guardian v3 shadow boards (#64166)

## Why

Shadow routing can store the same evidence in multiple channels. A per-root
limit bounds how much evidence each shadow board accumulates.

## What changed

- Default to 32 MiB of serialized evidence per root shadow board and count
  each stored channel copy. Allow users to set
  `features.guardianv3.shadow_board_limit_mib` in user config. Ignore project
  overrides of the limit and discard positional Guardian v3 project settings
  that could bypass filtering for user-only fields.
- Reject batches that would exceed the limit before creating channels or
  appending posts. Skip the routing call when even one copy of the first
  source would exceed the remaining budget.
- Signal root and child shadow reviewers when intake stops, independently of
  reviewer cancellation. Record channel counts, post counts, and evidence
  bytes after successful batches, and tag worker failures by stage.

## Testing

Tests cover byte accounting across distinct destinations, overflow before and
after routing, an unchanged board after a rejected batch, intake stop signals
for root and child reviewers, and project config filtering.

GitOrigin-RevId: 9d908ceb6f33ba69eed2a07223b3f9177afbe11e
This commit is contained in:
felixxia-oai
2026-11-26 15:22:56 +00:00
committed by copyberry
parent 42c320991e
commit d0b140efb5
14 changed files with 386 additions and 14 deletions
+6
View File
@@ -2558,6 +2558,12 @@
},
"reviewer": {
"$ref": "#/definitions/GuardianV3ReviewerConfigToml"
},
"shadow_board_limit_mib": {
"description": "Maximum evidence per root shadow board in MiB. Defaults to 32. Ignored in project config.",
"format": "uint32",
"minimum": 1.0,
"type": "integer"
}
},
"type": "object"
+2
View File
@@ -61,6 +61,8 @@ pub fn reviewer_headers(config: &crate::config::Config) -> crate::CodexResponses
/// Kept out of the authoritative reviewer slot so routing and prewarming stay unchanged.
pub struct ShadowReviewer {
pub reviewer: std::sync::Arc<dyn AttachedReviewer>,
/// Blocks new shadow reviews after intake exits. Never cancels an admitted verdict.
pub intake_stopped: tokio_util::sync::CancellationToken,
/// Stops this actor when it shuts down or the root leaves Auto Review.
pub cancellation: tokio_util::sync::CancellationToken,
}