Skip to content

test(cli): guard destructive action contracts (#1816) - #1946

Merged
Sinity merged 1 commit into
masterfrom
feature/test/action-contract-guards-1816
Jun 15, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/test/action-contract-guards-1816

Conversation

@Sinity

@Sinity Sinity commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Adds behavioral guard coverage for destructive/write CLI action contracts.

Problem

#1941 declared guards on public action contracts, but #1816 still needed public-behavior tests proving declared write/destructive guards are actually enforced instead of only documented in the registry.

Solution

Extended the CLI action-contract tests with guard-name assertions and public CLI behavior checks for delete and import. The tests bind behavior to declared contract guard names so contract drift is caught when a guard is declared but no longer enforced.

Issue slice: behavioral guard tests for write/destructive action contracts.
Files inspected: polylogue/cli/action_contracts.py, delete/mark/import command tests, verb-cardinality tests.
Files changed: tests/unit/cli/test_cli_action_contracts.py.
Old surface removed or retained: retained existing action-contract and output-assurance surfaces.
Contracts/tests added: guard-bound tests for delete (dry_run_or_yes_required, single_match_unless_all) and import (path_exists_or_demo).
Generated artifacts updated: none.
Known caveats / SPEC_MISMATCH: no SPEC_MISMATCH; broader guard coverage remains open.
Follow-up intentionally not included: mark guard coverage, daemon acceptance for import, config secret redaction, docs/help/completion metadata, and #1818 machine-envelope/schema checks.

Verification

  • devtools test tests/unit/cli/test_cli_action_contracts.py tests/unit/cli/test_import.py tests/unit/cli/test_verb_cardinality.py -q -> 54 passed, with two existing coroutine warnings in test_verb_cardinality.py.
  • devtools verify --quick -> exit_code 0.

Ref #1816

Problem: #1816 still needed behavioral coverage that ties declared write/destructive action guards to public CLI outcomes, not only registry shape checks. Without that, a guard name could stay declared while the command behavior drifted.

What changed: Add contract-bound CLI tests for delete confirmation/dry-run/cardinality behavior and import missing-path rejection. Each behavioral assertion first verifies the relevant CliActionContract guard name is still declared, so contract and behavior drift fail together.

Verification: devtools test tests/unit/cli/test_cli_action_contracts.py tests/unit/cli/test_import.py tests/unit/cli/test_verb_cardinality.py -q; devtools verify --quick.
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 24 minutes and 15 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 31aea5e2-c73e-49dd-84ab-b93ab7917c74

📥 Commits

Reviewing files that changed from the base of the PR and between 264e86b and f30de3c.

📒 Files selected for processing (1)
  • tests/unit/cli/test_cli_action_contracts.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/action-contract-guards-1816

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 and usage tips.

@Sinity
Sinity merged commit 8bcc7c8 into master Jun 15, 2026
11 checks passed
@Sinity
Sinity deleted the feature/test/action-contract-guards-1816 branch June 15, 2026 20:51
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