Skip to content

feat(check): rule and check engine with a static forbid kind - #54

Merged
wenzowski merged 2 commits into
mainfrom
claude/next-ready-ticket-wko3ot
Aug 6, 2026
Merged

wenzowski merged 2 commits into
mainfrom
claude/next-ready-ticket-wko3ot

Conversation

@wenzowski

Copy link
Copy Markdown
Contributor

What

Stands up the declarative rule and check engine (CLOUD-12) — the substrate
the Phase 2 checks work builds on.

  • New [[rule]] table in batten.toml: each rule has id, kind, glob, pattern.
  • New batten check command (effect: read, so it joins the derived read-only allowlist).
  • An engine (rules.rs) that selects files by glob and applies a kind-specific predicate, mapping the outcome onto the exit-code contract: 0 clean, 1 on any finding, 2 for a malformed rule.
  • One static kind, forbid (a banned-shape literal check), emitting pointer-only path:line findings — never the matched bytes (non-negotiable rule 4) — and byte-stable across runs (§6).

Why this and not CLOUD-89 directly

CLOUD-89 ("add a command rule kind") presupposes a rule engine with a kind
dispatch to extend, but none existed — its parent CLOUD-12 was still Backlog.
Rather than smuggle a whole engine in under CLOUD-89, this PR lands the engine
first (as CLOUD-12) so command becomes a clean one-variant addition. The
RuleKind enum is #[non_exhaustive] and dispatch is a single match, so
CLOUD-89 adds a variant plus one arm.

Scope / deferrals

  • File selection is a working-tree walk skipping .git. Scoping it to the
    git change-set / protected / unlanded sets is deliberately deferred to
    CLOUD-36 and CLOUD-37; it layers on top of this walk without changing the
    rule model.
  • The forbid predicate is a literal substring match (no regex dependency
    added). Richer shapes can follow as their own kinds.
  • Dynamic command kind and output-string promotion remain with CLOUD-89 / CLOUD-117.

Tests

  • Unit tests for the glob matcher (*, **, ?), pointer-only findings,
    clean-tree, byte-stability, .git skip, non-UTF-8 files, and empty-glob usage error.
  • End-to-end tests over the compiled binary: clean → exit 0, violation → exit 1
    with pointer-only stdout, byte-stable output, and an unknown rule key → exit 2.
  • mise run ci green locally.

Refs CLOUD-12. Unblocks CLOUD-89.

Introduce the declarative rule/check engine (CLOUD-12): a [[rule]]
table in batten.toml, a `batten check` command, and an engine that
selects files by glob and reports pointer-only path:line findings,
byte-stable and mapped onto the exit-code contract (0 clean, 1 on any
finding, 2 for a malformed rule).

Ships one static kind, forbid (a banned-shape literal check), and is
shaped so further kinds slot in as new RuleKind variants — notably the
dynamic command kind (CLOUD-89). File selection is a working-tree walk
skipping .git; scoping it to the git change-set is deferred to CLOUD-36
and CLOUD-37.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U4v4gg2DRyfPAR2fXCQ3ZZ
@linear-code

linear-code Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
CLOUD-12 Rule and check engine

Port the acceptance runner and replace ad-hoc rule logic with a declarative rule/check engine.

Review in Linear

CARGO_TARGET_TMPDIR is defined only for integration-test crates, so the
library unit tests could not reference it under clippy --all-targets.
Use std::env::temp_dir() instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U4v4gg2DRyfPAR2fXCQ3ZZ
@wenzowski
wenzowski marked this pull request as ready for review August 6, 2026 21:50
@wenzowski
wenzowski marked this pull request as draft August 6, 2026 23:47
@wenzowski
wenzowski marked this pull request as ready for review August 6, 2026 23:47
@wenzowski

Copy link
Copy Markdown
Contributor Author

/fast-forward

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.

2 participants