Skip to content

feat(rules,guard): compile machine-readable note rules into deterministic PreToolUse checks (#240) - #251

Merged
CryptoJones merged 1 commit into
mainfrom
feat/240-note-rule-compiler
Aug 14, 2026
Merged

feat(rules,guard): compile machine-readable note rules into deterministic PreToolUse checks (#240)#251
CryptoJones merged 1 commit into
mainfrom
feat/240-note-rule-compiler

Conversation

@CryptoJones

Copy link
Copy Markdown
Owner

Implements #240: every rule a hook can decide never depends on model attention.

  • src/omind/rules.py: parser (PyYAML, already a dep), per-file (mtime_ns, size) cache, evaluate() with tool + glob match, when.repo_visibility/when.branch, except_repos; visibility via gh repo view with a 24h on-disk cache and fail-open UNKNOWN (logged, never denied).
  • Wired into guard.check_action ahead of decide(); denies log through the existing compliance path as note-rule:<id>, warns/unknowns log decision events without blocking; the whole layer never raises.
  • omind rules list CLI; README section; seed rule for the public-main-push incident class (note rules replace seeds by id so per-repo exceptions live in the vault). Repo-deletion was already a policy seed.
  • Two spec deviations, both deliberate: seed rules live in rules.py (cold-start safe, like policy.SEED_RULES) rather than provisioned vault notes; warn logs a compliance decision instead of injecting context (the PreToolUse bash adapter has no allow-with-context channel).

9 new tests; 966 passed; ruff clean. Version 8.6.0.

Closes #240

🤖 Generated with Claude Code

…stic PreToolUse checks (#240)

New omind.rules module: fenced omind-rule YAML blocks in vault notes
parse (per-file mtime/size cache, invalid blocks breadcrumbed) into
deny/warn checks evaluated in check_action before everything else.
v1 conditions: repo_visibility (gh, 24h cache, fail-open on unknown)
and branch; except_repos matches the origin repo name. omind rules list
prints the compiled table. One seed rule (public main/master push);
repo deletion was already covered by policy.SEED_RULES.

Closes #240

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

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 3 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

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

Plan: Pro Plus

Run ID: c5cbc589-6381-4e7b-a306-c3637efa50f1

📥 Commits

Reviewing files that changed from the base of the PR and between 191f49a and 2fe87b2.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • CHANGELOG.md
  • README.md
  • pyproject.toml
  • src/omind/__init__.py
  • src/omind/cli.py
  • src/omind/guard.py
  • src/omind/rules.py
  • tests/test_rules.py

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.

Comment thread src/omind/rules.py
try:
path.parent.mkdir(parents=True, exist_ok=True)
paths.atomic_write_text(path, json.dumps(cache) + "\n", mode=0o600)
except OSError:
@CryptoJones
CryptoJones merged commit 95cacf5 into main Aug 14, 2026
7 of 16 checks passed
@CryptoJones
CryptoJones deleted the feat/240-note-rule-compiler branch August 14, 2026 16:48
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.

feat(guard): compile machine-readable note rules into deterministic PreToolUse checks

2 participants