Skip to content

feat: on_violation config + --ci mode for hard gating - #152

Merged
ajianaz merged 3 commits into
developfrom
feat/hook-violation-ci-mode
Jun 3, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/hook-violation-ci-mode

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes #149
Ref: #151

Changes

File Change
src/config/schema.rs Add on_violation: warn|disallow to HookConfig + HookSection + merge
src/commands/review.rs CI-aware size check + hard gate on any findings in CI mode
src/main.rs Add --ci CLI flag
install.sh New: curl-install script with OS/arch detection
README.md Rewrite Installation section + document --ci + on_violation

Problem

Pre-commit hook skips review on oversized diffs (262K > 50K limit) with only a warning. Commits pass without code review.

Solution

1. on_violation: disallow — new hook config option

hook:
  max_diff_size: 51200
  on_violation: disallow  # NEW: exit 2 (block commit) instead of exit 1 (warn)
  • Default: warn (backward compatible)
  • When disallow: oversized diff → exit 2 → hook denies commit
  • Escape hatch: git commit --no-verify

2. --ci flag — for CI workflows

# .github/workflows/ci.yml
- run: cora review --ci --base ${{ github.base_ref }}
  • Skips max_diff_size check (CI always reviews full PR diff)
  • Hard gate: any finding → exit 2 (CI fails)
  • Independent of on_violation config

3. install.sh — one-line install

curl -fsSL https://raw.githubusercontent.com/codecoradev/cora-cli/main/install.sh | sh

Tests

  • 352 tests pass, 0 failures
  • cargo clippy clean (0 warnings)
  • cargo fmt clean
  • All existing HookConfig struct literals updated

Co-Authored-By: codecoradev noreply@github.com

- Add on_violation: warn|disallow to hook config
- disallow blocks commit on oversized diff (exit 2)
- Add --ci flag: skip max_diff_size, hard gate on any findings
- Default on_violation: warn (backward compatible)

Closes #149
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Comment thread src/commands/review.rs
let max_size = opts.max_diff_size.unwrap_or(config.hook.max_diff_size);
if diff.len() > max_size {
if !opts.ci && diff.len() > max_size {
if config.hook.on_violation == "disallow" {
@github-actions

github-actions Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (1)

  • src/commands/review.rs:90 — When opts.ci is true, the diff size check is bypassed entirely (if !opts.ci && diff.len() > max_size). This means a CI job could send an arbitrarily large diff to the LLM API, potentially causing extremely long processing times, high costs, or API rate limit errors. There should at least be a reasonable upper bound even in CI mode.

Review powered by cora-cli · BYOK · MIT

CTO Hermes added 2 commits June 3, 2026 16:26
…docs

- Add install.sh (curl | sh) with OS/arch detection, path traversal check
- README: prioritize Quick Install over Cargo
- README: add --ci flag to review command examples
- README: add on_violation to hook config docs
- README: add Windows binary install note

Ref: #151
@ajianaz
ajianaz merged commit 397cbe5 into develop Jun 3, 2026
7 of 8 checks passed
@ajianaz
ajianaz deleted the feat/hook-violation-ci-mode branch June 4, 2026 06:03
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: Disallow large diffs + CI gate mode

2 participants