Skip to content

feat: add provider-free P2-P6 evaluation - #298

Merged
ictechgy merged 4 commits into
mainfrom
feature/p2-p6-provider-free
Aug 11, 2026
Merged

feat: add provider-free P2-P6 evaluation#298
ictechgy merged 4 commits into
mainfrom
feature/p2-p6-provider-free

Conversation

@ictechgy

@ictechgy ictechgy commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • add closed provider-free evaluators for P2 through P6 with exact unchanged fallback
  • ship recursively closed input/result schemas and an installed evaluate phase CLI
  • synchronize package integrity, release acceptance, roadmap, and Stage2 support boundaries

Safety boundary

  • no provider calls, host request mutation, runtime activation, public savings claim, or generalization authority
  • P1-F and phase-specific external authority remain required before any active promotion
  • npm next and latest remain out of scope

Verification

  • python3 scripts/prepublish_check.py (1,593 tests; 3 hosted-only skips)
  • offline package integrity and installed-package acceptance
  • release smoke, Gate-B, plugin mirror synchronization, and diff checks

Summary by CodeRabbit

  • New Features

    • Added provider-free phase evaluation for P2–P6 through context-guard-receipt evaluate phase --input <file|->.
    • Reports readiness, evidence, eligibility, metrics, and blockers from validated local records.
    • Preserves baseline fallback without activating runtime behavior or granting claim authority.
  • Documentation

    • Added schemas and guidance for evaluation inputs, results, safeguards, and limitations.
  • Bug Fixes

    • Rejects invalid, incomplete, stale, ambiguous, or uneconomic evaluation data with fail-closed results.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ictechgy, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ab95f69-a979-4eae-a6e5-5661878a3cfe

📥 Commits

Reviewing files that changed from the base of the PR and between 78ac88a and bcee38b.

📒 Files selected for processing (1)
  • tests/test_phase_evaluation.py
📝 Walkthrough

Walkthrough

The change adds provider-free P2–P6 phase schemas and evaluators, exposes them through a bounded CLI command, packages integrity metadata, and adds unit, contract, acceptance, documentation, and inventory coverage. Results remain advisory and preserve baseline fallback.

Changes

Provider-free phase evaluation

Layer / File(s) Summary
Phase contracts and P2–P3 evaluation
context-guard-kit/phase_evaluation.py, packages/context-guard-receipt/python/context_guard_receipt/phase_evaluation.py, packages/context-guard-receipt/schemas/phase-evaluation-p2.schema.json, packages/context-guard-receipt/schemas/phase-evaluation-p3.schema.json, research/p2-p6-provider-free-implementation.md
Adds strict P2–P3 input contracts, shared fail-closed result handling, and validation for recall, rehydration, matched evidence, retrievals, corrections, costs, fallback, and authority gates.
P4–P6 evaluation and result contracts
packages/context-guard-receipt/python/context_guard_receipt/phase_evaluation.py, packages/context-guard-receipt/schemas/phase-evaluation-p4.schema.json, packages/context-guard-receipt/schemas/phase-evaluation-p5.schema.json, packages/context-guard-receipt/schemas/phase-evaluation-p6.schema.json, packages/context-guard-receipt/schemas/phase-evaluation-result.schema.json, tests/test_phase_evaluation.py
Adds advisory router, adjunct, and frozen-track evaluation with structured result schemas and coverage for guardrails, fallback, privacy, rollback, cost, quality, and non-activation behavior.
Packaged CLI and distribution delivery
packages/context-guard-receipt/python/context_guard_receipt/cli.py, packages/context-guard-receipt/bin/launcher.cjs, packages/context-guard-receipt/package-files.json, packages/context-guard-receipt/dev/*, packages/context-guard-receipt/tests/contract/*, packages/context-guard-receipt/README.md, CHANGELOG.md, research/token-savings-roadmap.md, tests/test_contextguard_stage2_feasibility.py, context-guard-kit/bash_reference_policy.py, plugins/context-guard/bin/bash_reference_policy.py
Adds `evaluate phase --input <file

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant ReceiptCLI
  participant PhaseEvaluator
  participant BaselineFallback
  Operator->>ReceiptCLI: provide bounded canonical JSON
  ReceiptCLI->>PhaseEvaluator: dispatch p2 through p6 record
  PhaseEvaluator->>BaselineFallback: preserve unchanged baseline on blocked evidence
  PhaseEvaluator-->>ReceiptCLI: return structured advisory result
  ReceiptCLI-->>Operator: emit canonical JSON response
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.51% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding provider-free evaluation for phases P2–P6.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/p2-p6-provider-free

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
context-guard-kit/phase_evaluation.py (1)

710-717: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

confidence_basis_points omits malformed trials.

confidences.append(confidence) runs only inside the _exact_dict(trial, _P4_TRIAL) branch. A trial with unknown or missing keys contributes an entry to trials (line 774) but no entry to confidences. The two output arrays then have different lengths, and evaluated_trial_count matches neither.

Append the default 0 for malformed trials so the arrays stay index-aligned.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@context-guard-kit/phase_evaluation.py` around lines 710 - 717, Ensure the
trial-evaluation logic around _exact_dict and confidence_basis_points appends a
confidence value for every trial, including malformed records. Initialize
malformed trials’ confidence to 0 before appending, while preserving validation
and low-confidence checks for valid values so trials, confidences, and
evaluated_trial_count remain index-aligned.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/context-guard-receipt/python/context_guard_receipt/cli.py`:
- Around line 1455-1473: Restrict phase_id validation in the evaluator lookup
within the CLI evaluation flow to string values before calling the mapping’s get
method. Ensure objects, arrays, and other non-string JSON values return
evaluation_phase_rejected with exit 65, while valid string phase IDs retain the
existing evaluator dispatch.
- Around line 1474-1479: Update the evaluation result encoding near evaluator
and write_stdout to pass an explicit output limits object sized for the schema’s
maximum valid result, rather than relying on canonical_json_bytes defaults.
Import and catch CanonicalJSONError separately, returning the distinct
evaluation_result_rejected error with the appropriate non-internal failure
status; narrow the existing broad Exception handler to unexpected failures, and
extend the packaged CLI contract test if that error code is added.

In `@packages/context-guard-receipt/schemas/phase-evaluation-p4.schema.json`:
- Around line 102-110: Align all three validation sites with the result schema:
in packages/context-guard-receipt/schemas/phase-evaluation-p4.schema.json lines
102-110, set bypass_reasons item maxLength to 128 and use
^[a-z][a-z0-9_]{0,127}$; in context-guard-kit/phase_evaluation.py lines 719-726
and
packages/context-guard-receipt/python/context_guard_receipt/phase_evaluation.py
lines 719-726, replace _valid_identifier validation with an identical matcher
for that result pattern, keeping both Python copies byte-identical.

---

Nitpick comments:
In `@context-guard-kit/phase_evaluation.py`:
- Around line 710-717: Ensure the trial-evaluation logic around _exact_dict and
confidence_basis_points appends a confidence value for every trial, including
malformed records. Initialize malformed trials’ confidence to 0 before
appending, while preserving validation and low-confidence checks for valid
values so trials, confidences, and evaluated_trial_count remain index-aligned.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: edc14a42-45a4-41c1-9ff2-9cbba0d69ea0

📥 Commits

Reviewing files that changed from the base of the PR and between 2a6b5d6 and 359b602.

📒 Files selected for processing (23)
  • CHANGELOG.md
  • context-guard-kit/bash_reference_policy.py
  • context-guard-kit/phase_evaluation.py
  • packages/context-guard-receipt/README.md
  • packages/context-guard-receipt/bin/launcher.cjs
  • packages/context-guard-receipt/dev/package_check.py
  • packages/context-guard-receipt/dev/packaged_acceptance.py
  • packages/context-guard-receipt/package-files.json
  • packages/context-guard-receipt/python/context_guard_receipt/cli.py
  • packages/context-guard-receipt/python/context_guard_receipt/phase_evaluation.py
  • packages/context-guard-receipt/schemas/phase-evaluation-p2.schema.json
  • packages/context-guard-receipt/schemas/phase-evaluation-p3.schema.json
  • packages/context-guard-receipt/schemas/phase-evaluation-p4.schema.json
  • packages/context-guard-receipt/schemas/phase-evaluation-p5.schema.json
  • packages/context-guard-receipt/schemas/phase-evaluation-p6.schema.json
  • packages/context-guard-receipt/schemas/phase-evaluation-result.schema.json
  • packages/context-guard-receipt/tests/contract/test_g001_distribution_contract.py
  • packages/context-guard-receipt/tests/contract/test_g015_phase_evaluation_cli.py
  • plugins/context-guard/bin/bash_reference_policy.py
  • research/p2-p6-provider-free-implementation.md
  • research/token-savings-roadmap.md
  • tests/test_contextguard_stage2_feasibility.py
  • tests/test_phase_evaluation.py

Comment thread packages/context-guard-receipt/python/context_guard_receipt/cli.py
Comment thread packages/context-guard-receipt/python/context_guard_receipt/cli.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_phase_evaluation.py`:
- Around line 572-584: The malformed-identity test does not ensure any track
reports exist before validating their blockers. In
test_malformed_phase_identity_cannot_report_track_readiness, assert that
result["tracks"] contains at least one report before the all(...) check, keeping
the existing malformed_record assertions unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6faf8d99-e4cc-4b20-a294-50d68aa743c9

📥 Commits

Reviewing files that changed from the base of the PR and between 359b602 and 019e6fe.

📒 Files selected for processing (8)
  • context-guard-kit/bash_reference_policy.py
  • context-guard-kit/phase_evaluation.py
  • packages/context-guard-receipt/bin/launcher.cjs
  • packages/context-guard-receipt/package-files.json
  • packages/context-guard-receipt/python/context_guard_receipt/phase_evaluation.py
  • plugins/context-guard/bin/bash_reference_policy.py
  • tests/test_contextguard_stage2_feasibility.py
  • tests/test_phase_evaluation.py
🚧 Files skipped from review as they are similar to previous changes (6)
  • context-guard-kit/bash_reference_policy.py
  • plugins/context-guard/bin/bash_reference_policy.py
  • packages/context-guard-receipt/bin/launcher.cjs
  • tests/test_contextguard_stage2_feasibility.py
  • packages/context-guard-receipt/package-files.json
  • packages/context-guard-receipt/python/context_guard_receipt/phase_evaluation.py

Comment thread tests/test_phase_evaluation.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/context-guard-receipt/tests/contract/test_g015_phase_evaluation_cli.py`:
- Around line 184-188: The CLI contract test should validate stratum identities,
not just the count. In the assertions after parsing completed.stdout in
test_g015_phase_evaluation_cli, compare the returned strata’s stratum values
against the complete expected set s0 through s799, while preserving the existing
count and output-size checks.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 643b05fe-d6ff-40c4-9115-e44d582aa27b

📥 Commits

Reviewing files that changed from the base of the PR and between 019e6fe and 78ac88a.

📒 Files selected for processing (11)
  • context-guard-kit/bash_reference_policy.py
  • context-guard-kit/phase_evaluation.py
  • packages/context-guard-receipt/bin/launcher.cjs
  • packages/context-guard-receipt/package-files.json
  • packages/context-guard-receipt/python/context_guard_receipt/cli.py
  • packages/context-guard-receipt/python/context_guard_receipt/phase_evaluation.py
  • packages/context-guard-receipt/schemas/phase-evaluation-p4.schema.json
  • packages/context-guard-receipt/tests/contract/test_g015_phase_evaluation_cli.py
  • plugins/context-guard/bin/bash_reference_policy.py
  • tests/test_contextguard_stage2_feasibility.py
  • tests/test_phase_evaluation.py
🚧 Files skipped from review as they are similar to previous changes (10)
  • context-guard-kit/bash_reference_policy.py
  • plugins/context-guard/bin/bash_reference_policy.py
  • packages/context-guard-receipt/schemas/phase-evaluation-p4.schema.json
  • packages/context-guard-receipt/python/context_guard_receipt/cli.py
  • packages/context-guard-receipt/bin/launcher.cjs
  • packages/context-guard-receipt/package-files.json
  • tests/test_contextguard_stage2_feasibility.py
  • tests/test_phase_evaluation.py
  • context-guard-kit/phase_evaluation.py
  • packages/context-guard-receipt/python/context_guard_receipt/phase_evaluation.py

Comment on lines +184 to +188
completed = self.run_cli(canonical_json(record))

self.assertEqual(completed.returncode, 0, completed.stderr)
self.assertGreater(len(completed.stdout), 64 * 1024)
self.assertEqual(len(json.loads(completed.stdout)["strata"]), 800)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the returned stratum identities.

Line 188 checks only the number of strata. The evaluator can drop one input stratum and duplicate another, and this test still passes. Compare the returned stratum values with all s0 through s799 values.

Proposed test fix
         self.assertEqual(completed.returncode, 0, completed.stderr)
         self.assertGreater(len(completed.stdout), 64 * 1024)
-        self.assertEqual(len(json.loads(completed.stdout)["strata"]), 800)
+        result = json.loads(completed.stdout)
+        self.assertEqual(len(result["strata"]), 800)
+        self.assertEqual(
+            {entry["stratum"] for entry in result["strata"]},
+            {f"s{index}" for index in range(800)},
+        )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
completed = self.run_cli(canonical_json(record))
self.assertEqual(completed.returncode, 0, completed.stderr)
self.assertGreater(len(completed.stdout), 64 * 1024)
self.assertEqual(len(json.loads(completed.stdout)["strata"]), 800)
completed = self.run_cli(canonical_json(record))
self.assertEqual(completed.returncode, 0, completed.stderr)
self.assertGreater(len(completed.stdout), 64 * 1024)
result = json.loads(completed.stdout)
self.assertEqual(len(result["strata"]), 800)
self.assertEqual(
{entry["stratum"] for entry in result["strata"]},
{f"s{index}" for index in range(800)},
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/context-guard-receipt/tests/contract/test_g015_phase_evaluation_cli.py`
around lines 184 - 188, The CLI contract test should validate stratum
identities, not just the count. In the assertions after parsing completed.stdout
in test_g015_phase_evaluation_cli, compare the returned strata’s stratum values
against the complete expected set s0 through s799, while preserving the existing
count and output-size checks.

@ictechgy
ictechgy merged commit d4b6302 into main Aug 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant