Repository navigation
Observe consented shadow policies before promotion - #99
Conversation
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideThis PR introduces a bounded, consented shadow-deployment workflow for comparing an inert candidate lookup policy with the active policy, persists immutable dual-arm observations and receipts, and requires the validated comparison to pass through the existing transactional evaluation and generation-promotion gate before switching. Sequence diagram for consented shadow observation and promotionsequenceDiagram
actor Operator
participant SDK as Typed SDK or CLI
participant Store as PM SDK Store
participant Eval as Evaluation Plan
participant Gate as Generation Promotion Transaction
Operator->>SDK: registerShadowDeployment(deployment, plan)
SDK->>Store: Verify immutable consent and creation history
SDK->>Store: Reserve active and candidate call allowances
SDK->>Eval: registerEvaluationPlan(plan with shadow digest)
Operator->>SDK: observeShadow(candidate, input)
SDK->>Store: Read sealed deployment and certified generations
SDK->>SDK: Evaluate bounded active and candidate lookup tables
SDK->>Store: Seal per-member observation receipt
Note over SDK: Return active_action only
Operator->>SDK: compareShadow(candidate)
SDK->>Store: Read complete frozen cohort
SDK->>Eval: evaluatePlan(paired observations)
SDK->>Store: Seal comparison receipt
Operator->>Gate: Promote candidate
Gate->>Store: Verify sealed shadow comparison
Gate->>Eval: Enforce existing evaluation and approval checks
Gate-->>Operator: Promote or refuse with stable code
Flow diagram for fail-closed shadow policy deploymentflowchart TD
A[Consent exact deployment, generation pair, inputs and budgets] --> B[Register shadow deployment and predeclared evaluation plan]
B --> C[Observe each frozen input with active and candidate lookup tables]
C --> D{Candidate decision and outcome valid?}
D -->|Yes| E[Seal immutable paired observation]
D -->|No| F[Seal candidate failure and preserve active_action]
E --> G{Complete cohort?}
F --> G
G -->|No| H[Refuse comparison or promotion]
G -->|Yes| I[compareShadow and evaluate paired outcomes]
I --> J{Validated comparison receipt?}
J -->|No| K[Refuse promotion; consume reserved candidate attempt]
J -->|Yes| L[Existing transactional promotion gate]
L --> M{Approval, contamination, score and budget checks pass?}
M -->|No| N[Keep active generation]
M -->|Yes| O[Promote candidate in the same lineage]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
unbraind
left a comment
There was a problem hiding this comment.
VERDICT: BLOCK
FINDINGS:
- [blocking] shadow.ts:165 — Individual receipts are trusted without validating actions, rewards or disagreement against the policies — correctly hashed original receipts claiming rewards 0 and 1 for identical active/candidate actions can produce a promotable comparison.
- [blocking] shadow.ts:127 — Loaded manifests omit the registration-time cohort and budget checks — a shadow-tagged evaluation plan plus an original consented manifest with zero allowances can observe ten members and authorize promotion despite exceeding both budgets.
SUMMARY: The PR adds consented shadow observations and comparison receipts required for online promotion. The inspected tests cover failures, retries, concurrency and non-Git promotion, but miss these original-record validation bypasses; tests were not executed.
Review by a read-only codex review agent (gpt-6.1-sol), posted by the orchestrator; the PR returns to its author agent for the fixes.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
unbraind
left a comment
There was a problem hiding this comment.
Orchestrator review (built-in Claude review agent, verified by the orchestrator; bots are not waited for since 2026-10-22):
VERDICT: MERGE
Orchestrator re-review of the fix delta (9a6a39f → 3d6e1f8): APPROVE. Both blocking findings from the codex review are resolved.
- Receipts: every observation passes one
validateObservationbefore it is sealed, on retries and whenever it is read back (comparison, promotion gate). The recorded active/candidate actions must equal what the declared policies produce for the consented input, identical actions cannot carry different rewards, rewards stay within the plan bounds, and the disagreement flag, failure code and outcome digest are recomputed rather than trusted. A tampered receipt is a typedshadow_driftnaming the receipt and field. - Manifests: registration, reload and resume all run one
validateDeployment: consent for the exact deployment digest, generation/incumbent binding, frozen cohort membership, both budget allowances against the cohort, the actual sealed observation count against each allowance, and only cohort-derived receipt ids. A zero-allowance manifest, or a cohort that grows after registration, is refused before promotion. - Revert proofs: each of the 4 regressions fails alone when its fix is reverted; CI npm (22, 26) and bun 744/744 each, coverage 100%. Public-data replay unchanged (20 observations, 40 charged calls); promotion correctly refused.
Observe a candidate alongside the active policy on explicitly consented inputs without giving the candidate tool or mutation authority. The typed SDK and
pm rl shadow register/observe/comparepin policy artifacts, consent, a frozen cohort and both-arm allowances; existing generation promotion and the recursive controller require a validated shadow comparison throughout online-bound lineages.Correctly hashed original records previously could pass history checks while claiming inconsistent outcomes, and manifest reload omitted registration-time cohort/budget checks. The promotion gate now revalidates the evidence with the same validators used by registration and live observation.
Every shadow validation mismatch refuses with the exact receipt in
context.item_id, the invalidcontext.field, and an actionable message. Invalid receipts never authorize promotion. Verification remains read-only inside the existing authoritative promotion transaction; contamination, score, approval and promotion-budget checks remain required. No parallel promotion path or autonomous switching API is added. SDK/dev dependency pins and all gate thresholds are unchanged.Four requested real-SDK reproductions cover identical-action rewards, an original zero-budget manifest, a tampered disagreement flag, and a manifest cohort expanded after plan registration. Each fails 1/1 when only the corresponding shared validator's behavior is reverted; failures are
Missing expected rejection, proving prior admission rather than a test/setup error. Restoring validation passes 4/4 with Git absent from PATH and an explicit discovery ceiling. The complete focused suite passes 25/25 at 100% shadow lines/branches/functions. Additional original-record tests cover action identity, reward bounds, failure/digest fields, slot identity, actual extra charges, both aggregate charge fields, post-registration edits, prototype-like action names and native SDK workflow-policy refusal. No SDK methods are mocked and no history records are rewritten. Typecheck, test typecheck, lint, zero duplication, docstrings, changelog checks and linked PM execution (1/1) pass.Repacked public acceptance reuses the existing read-only, non-Git MIT
unbraind/pm-contexttracker copy at commitf55cdbbcf2447dae29df789e133fdbe5521a47b6and reproducesdocs/shadow-evidence.jsonbyte-for-byte: 84 certified items, first 20 sorted IDs selected without outcome filtering (17 closed, 3 other), 20/20 active actions preserved, 20 disagreements, 0 candidate failures, 20 active + 20 candidate calls, and all 175 source files unchanged. The single repository is one independent unit, so promotion correctly refuses despite empirical means 0.15 active and 0.85 candidate. Observation JSON is 548 bytes; comparison JSON 1,278 bytes, TOON 1,127 bytes. This measures observation/gating, not learned-policy improvement. Seedocs/shadow-policy.mdandtest/shadow.acceptance.tsfor reproduction.Current-head complete CI passes at
3d6e1f8ec6487a5e949c61c93170688cd0533d00:npm run release:checknpm run release:checkbun run release:checkAll three completed job logs were independently downloaded and checked: zero failures, skips, cancellations or todos; all 50 authored source files measured; 358 declarations documented. Fresh strict tracker health, typecheck/build, lint, zero duplication, isolated identity, production audit, publish attestation, packaging, changelog and Bun graph installation pass. Current-head CodeQL passes. Previous-head gate evidence is historical only. No local full gate is claimed on the saturated host.
PM: pm-rl-shadow, under pm-rl-apvf. Revert proofs are recorded on the item; its claim is released and it remains in progress for orchestrator verification. Drafts #95 and #98 remain unchanged. No review-thread replies, mentions, merge or release. Automated reviewer skips/unavailable access are not approval.
Summary by Sourcery
Require consented, fail-closed shadow observation evidence before promoting online policy successors.
New Features:
pm rl shadow register/observe/comparecommands.Bug Fixes:
Enhancements:
Build:
CI:
Documentation:
Tests:
Chores:
Summary by cubic
Adds a shadow observation mode that lets a candidate policy see the same explicitly consented inputs as the active policy without gaining tool or tracker mutation authority. Online candidates now need a sealed, validated shadow outcome comparison, revalidated against evidence and budgets, through the existing promotion transaction before they can replace the incumbent in that lineage.
New Features
pm rl shadow register/observe/compareand typed SDK exportsregisterShadowDeployment,observeShadow, andcompareShadowfor bounded declarative lookup policies.Behavior
Written for commit 3d6e1f8. Summary will update on new commits.