Skip to content

feat(hook): gate commits on an agent or hook validated diff - #675

Closed
ajianaz wants to merge 4 commits into
developfrom
feat/674-agent-commit-gate
Closed

ajianaz wants to merge 4 commits into
developfrom
feat/674-agent-commit-gate

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

What

  • A review of the staged diff (agent via cora.review_finalize, or cora review --staged) records a marker bound to that exact change set.
  • cora hook verify (exit 0 validated, 10 blocking, 11 not validated) and cora hook claude-guard (Claude Code PreToolUse: denies unreviewed/blocking commits and --no-verify).
  • Pre-commit hook v2: accepts a validated diff, otherwise falls back to cora review --staged --ci --severity major; tooling errors are reported as not a pass. Legacy v1 hooks are upgraded in place.
  • Skill, docs and changelog updated.

Why

Agents should always run the judge review before committing, with the hook as fallback, without a second LLM pass. Closes #674.

Testing

  • Unit tests for fingerprinting, marker store and command inspection.
  • 12 e2e tests in tests/commit_gate.rs with real temp git repos (agent verdict via MCP, hook, guard, upgrade).
  • fmt, clippy -D warnings and full test suite pass.

Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
)

Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
…commit (#674)

Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
@ajianaz

ajianaz commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded: split into smaller PRs because the Cora Review job exceeds its 10 minute limit on this size (three cancelled runs). The same review passes locally with no findings.

@ajianaz ajianaz closed this Oct 16, 2026
ajianaz added a commit that referenced this pull request Oct 16, 2026
)

## What

Part 1 of 3 for #674 (split from #675 so each PR fits the review time
limit).

- `engine/commit_gate.rs`: change-set fingerprint, marker store under
the git dir, `check`, and a fail-closed parser for agent `git commit`
command lines.
- `cora hook verify` (exit 0 validated, 10 blocking, 11 not validated)
and `cora hook claude-guard` (Claude Code PreToolUse).
- `cora review --staged` and `cora.review_finalize` record a verdict
marker for the exact staged diff.

## Why

Agents should always run the judge review before committing; the verdict
must be bound to the exact change set. Part of #674. Follow-ups: part 2
(pre-commit hook v2 and e2e tests), part 3 (skill, docs, changelog).

## Testing

- Unit tests for fingerprinting, marker store, bypass parsing
(`--no-verify` prefixes, `-c core.hooksPath`, chained commands,
pathspecs).
- fmt, clippy `-D warnings` and the full test suite pass locally.

---------

Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
Co-authored-by: ajianaz <ajianaz@users.noreply.github.com>
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(hook): agent-validated commit gate (agent judge → pre-commit hook → CI)

1 participant