Skip to content

feat: expect value pins on probes (v0.1.1) - #9

Merged
Mhemd139 merged 3 commits into
mainfrom
feat/expect-value-pins
Jul 8, 2026
Merged

feat: expect value pins on probes (v0.1.1)#9
Mhemd139 merged 3 commits into
mainfrom
feat/expect-value-pins

Conversation

@Mhemd139

@Mhemd139 Mhemd139 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

Layer 3 gains value pins — the missing rung between the shape fingerprint and the advisory judge:

[[probes]]
tool = "get_account"
args = { account_id = "acct-001" }
expect = { balance_usd = 4210.0, currency = "USD" }

A pinned field that comes back missing or unequal at check time is BREAKING — schema and shape identical, meaning changed (dollars→cents, USD→ILS). Deterministic and exact by design: no tolerance, no regex, no auto-pinning. Opt-in — nothing is pinned unless you type it. Analogue: pip --require-hashes.

Detection ladder now: schema diff → shape fingerprint → value pins → LLM judge (advisory).

Also in this PR

  • README: pip install covenant-mcp everywhere (git+ CI snippet retired — package is live on PyPI), pins documented, severity table updated
  • CI: monthly scheduled run (freshness alarm for the badge), new job step asserting COVENANT_SEMANTIC_DRIFT=1 covenant check exits 1, checkout/setup-python bumped off Node 20
  • Version → 0.1.1

Verification

  • ruff + mypy --strict clean; 136 passed, 3 skipped (Postgres skips expected)
  • Exit-code contract intact: clean 0 / COVENANT_DRIFT 1 / COVENANT_BEHAVIOR_DRIFT 1 / COVENANT_SEMANTIC_DRIFT 1 (new)
  • covenant snapshot --force re-run: lock byte-identical (pins live in config, never in the lock)
  • Cold-machine stranger test: fresh clone + fresh venv + README quickstart verbatim → all four modes correct, pin mismatch named in output

After merge (release recipe)

tag v0.1.1 → release workflow builds + publishes to PyPI via trusted publishing.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for pinning expected output values in probe checks; exact mismatches are reported as breaking changes.
    • CI now includes a monthly scheduled run to detect runner/dependency drift earlier.
  • Bug Fixes

    • check now detects missing or changed pinned values even when the response structure matches.
  • Documentation

    • Updated setup and contract-drift documentation for pinned-value behavior and installation changes.
  • Tests

    • Added end-to-end and unit coverage for pinned value matching, mismatches, and config parsing.
  • Chores

    • Upgraded CI action versions and bumped the project version.

Layer 3 gains deterministic value pins: expect = { field = value } on a
[[probes]] entry makes exact output values part of the contract. A pinned
field that comes back missing or unequal at check time is BREAKING --
schema and shape identical, meaning changed -- closing the gap between
the shape fingerprint and the advisory judge. Opt-in, exact equality,
no tolerance, no auto-pinning.

Also: README installs from PyPI (git+ snippet retired), monthly scheduled
CI run as a freshness alarm, checkout/setup-python bumped off Node 20,
CI asserts COVENANT_SEMANTIC_DRIFT=1 exits 1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 55 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e274976-e9ef-4ea8-a58d-7d4a0d09a4e7

📥 Commits

Reviewing files that changed from the base of the PR and between edac75e and c2f6d7b.

📒 Files selected for processing (1)
  • docs/specs/2026-07-03-covenant-layer3-behavioral-probes-design.md
📝 Walkthrough

Walkthrough

This PR adds exact-value pinning for probe results, wires it through config loading, diffing, and CLI checks, and updates docs, tests, and CI to cover the new drift behavior.

Changes

Value Pin Drift Detection

Layer / File(s) Summary
Probe expect field and config validation
covenant/config.py
Probe gains an expect field; probe parsing now accepts and validates optional expect tables.
diff_expect classifier
covenant/diff.py
Adds diff_expect to compare pinned fields with live responses and emit breaking value-pin changes.
CLI integration of value pin checks
covenant/cli.py
_check_probes now imports and runs diff_expect for configured pins when live probe records are available.
Tests for pin config, diffing, and CLI drift detection
tests/test_probes.py, tests/test_cli.py
Adds coverage for expect parsing, pin diff outcomes, and an end-to-end semantic drift check.
Example config, docs, and version bump
covenant.toml, README.md, CLAUDE.md, pyproject.toml
Documents pinning behavior, updates the example probe config, and bumps the package version.
CI/release workflow updates
.github/workflows/ci.yml, .github/workflows/release.yml
Schedules monthly CI, upgrades GitHub Actions versions, and adds a value-drift verification step to contract checks.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant covenant_cli as covenant/cli.py
  participant covenant_config as covenant/config.py
  participant covenant_diff as covenant/diff.py
  participant live_probe as probe response

  covenant_cli->>covenant_config: load probes with expect pins
  covenant_cli->>live_probe: re-run configured probes
  covenant_cli->>covenant_diff: diff_expect(tool, expect, response)
  covenant_diff-->>covenant_cli: value_pin_missing / value_pin_mismatch changes
Loading

Possibly related PRs

  • Mhemd139/Covenant#2: Establishes the probe diffing pipeline that this PR extends with expect-based value pin checks.
  • Mhemd139/Covenant#8: Shares the release-workflow update path where actions/checkout and actions/setup-python were upgraded.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 expect-based value pins to probes, with the version bump as a minor detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/expect-value-pins

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.

❤️ Share

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: 1

🧹 Nitpick comments (2)
.github/workflows/release.yml (1)

11-12: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Same credential-persistence hardening applies here.

Static analysis flags this actions/checkout step for missing persist-credentials: false, same as in ci.yml.

🔒️ Proposed fix
       - uses: actions/checkout@v5
+        with:
+          persist-credentials: false
       - uses: actions/setup-python@v6
🤖 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 @.github/workflows/release.yml around lines 11 - 12, The release workflow’s
actions/checkout step has the same credential persistence issue as ci.yml.
Update the checkout invocation in the release workflow to disable credential
persistence by setting persist-credentials to false on the actions/checkout
step, keeping the rest of the job unchanged.

Source: Linters/SAST tools

.github/workflows/ci.yml (1)

30-31: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Consider disabling credential persistence on checkout.

Static analysis flags both actions/checkout steps for not setting persist-credentials: false. The default persists the GitHub token in the local git config for the remainder of the job, which is exploitable if later steps execute untrusted code (e.g., third-party actions, dependency installs).

🔒️ Proposed fix
       - uses: actions/checkout@v5
+        with:
+          persist-credentials: false
       - uses: actions/setup-python@v6

Also applies to: 46-47

🤖 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 @.github/workflows/ci.yml around lines 30 - 31, The workflow’s
actions/checkout steps are persisting the GitHub token in git config by default,
which should be disabled. Update each checkout invocation in the CI workflow to
set persist-credentials to false on the actions/checkout usages so later steps
cannot reuse the token. Use the checkout step entries in the CI workflow as the
target locations.

Source: Linters/SAST tools

🤖 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_cli.py`:
- Line 89: The snapshot step in this test is not being checked, so a silent
failure can surface later as an unrelated check failure; update the test around
the `runner.invoke(app, ["snapshot"])` call to capture the result and assert it
succeeded before continuing with the `check` assertions, matching the pattern
used in `test_probes_catch_behavioral_drift`.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 30-31: The workflow’s actions/checkout steps are persisting the
GitHub token in git config by default, which should be disabled. Update each
checkout invocation in the CI workflow to set persist-credentials to false on
the actions/checkout usages so later steps cannot reuse the token. Use the
checkout step entries in the CI workflow as the target locations.

In @.github/workflows/release.yml:
- Around line 11-12: The release workflow’s actions/checkout step has the same
credential persistence issue as ci.yml. Update the checkout invocation in the
release workflow to disable credential persistence by setting
persist-credentials to false on the actions/checkout step, keeping the rest of
the job unchanged.
🪄 Autofix (Beta)

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3fc4a60-d55b-4f90-b62a-7584cd43c19a

📥 Commits

Reviewing files that changed from the base of the PR and between 58ceaf2 and 3b05fb9.

📒 Files selected for processing (11)
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • CLAUDE.md
  • README.md
  • covenant.toml
  • covenant/cli.py
  • covenant/config.py
  • covenant/diff.py
  • pyproject.toml
  • tests/test_cli.py
  • tests/test_probes.py

Comment thread tests/test_cli.py Outdated
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Mhemd139

Mhemd139 commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

@CodeRabbit

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@Mhemd139 Hi! I see you tagged me but didn't include a specific request. How can I help with PR #9? For example, I can:

  • Review the changes in this PR
  • Answer questions about the value pins / expect feature, CI updates, or README changes
  • Help with configuration questions
  • Create follow-up issues

Just let me know what you'd like, or use @coderabbitai review to trigger a full review of the current changes.

(๑•̀ᴗ•́)و ✧

@Mhemd139

Mhemd139 commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

@CodeRabbit Review the pr please

@Mhemd139

Mhemd139 commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

@Mhemd139 Sure, I'll review the PR now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…ever, scope fence)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Mhemd139
Mhemd139 merged commit df8e93e into main Jul 8, 2026
5 checks passed
@Mhemd139
Mhemd139 deleted the feat/expect-value-pins branch July 8, 2026 20:21
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