Skip to content

feat(git-shim): alert on sustained ScopeCheckError audit events (#493) - #529

Merged
getappz merged 1 commit into
masterfrom
task/493-git-shim-alert-on-sustained-scopechecker
Aug 16, 2026
Merged

feat(git-shim): alert on sustained ScopeCheckError audit events (#493)#529
getappz merged 1 commit into
masterfrom
task/493-git-shim-alert-on-sustained-scopechecker

Conversation

@getappz

@getappz getappz commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #493. The git shim fails OPEN when agentflare git scope-check crashes mid-run (PR #513 / item #472): the git op passes through with a stderr warning, and each crash is audited as Disposition::ScopeCheckError in ~/.agentflare/audit/git.jsonl. A persistently crashing binary therefore disables scope enforcement silently while every git op still succeeds.

This adds detection in agentflare git doctor (the periodic-check option from the ask's open questions):

  • doctor::sustained_scope_check_failure(events, window, threshold) scans the most recent window commit/push audit events (the only subcommands that invoke scope-check) and flags the run when >= threshold of them are ScopeCheckError — sustained breakage, not a one-off.
  • doctor::append_scope_check_violation reads git.jsonl and appends a violation to the doctor report (silent-skip on missing/unreadable log, honors AGENTFLARE_HOME_OVERRIDE).
  • doctor_cmd in src/cli/git.rs wires it in; a hit renders in text/json/markdown output and exits nonzero, matching the existing dirty/stale violation thresholds.

Design decisions (resolved open questions)

  • Where it lives: agentflare git doctor, not a daemon-side watcher — zero new infrastructure, surfaces where agents already look, and a one-off crash deliberately stays silent (blocking on every isolated crash would just train agents to ignore doctor output).
  • What counts as sustained: 3+ of the last 10 commit/push invocations (SCOPE_CHECK_HEALTH_THRESHOLD / SCOPE_CHECK_HEALTH_WINDOW, exported consts). A mid-upgrade binary swap is one crash; 3 in 10 means enforcement is effectively off.
  • Alert surface: doctor violation + nonzero exit (same as dirty/stale), not a channel notification.

Test plan

  • 5 new unit tests in doctor.rs: no events healthy; single isolated crash does not alert; crashes at/above threshold within window alert (asserts "effectively OFF" message); crashes outside window ignored; non-scope-checked subcommands (status/fetch) don't dilute the window.
  • cargo test -p flare-git-core: 187 passed.
  • cargo build --bin agentflare: clean.
  • cargo clippy --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic: clean.
  • cargo fmt --check: clean.

agentflare git doctor now reads git.jsonl and flags scope-check crashes
that hit 3+ of the last 10 commit/push invocations as a violation
(nonzero exit, same as existing dirty/stale thresholds) -- an isolated
crash (e.g. mid-upgrade binary swap) stays silent, since blocking on
every one-off would just retrain agents to ignore doctor output.

Agentflare-Agent: claude-code
Agentflare-Branch: task/493-git-shim-alert-on-sustained-scopechecker
Agentflare-Item: 493
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 6 minutes

Limit details: You’ve used all 1 included review currently available under your plan. You completed 70 included PR reviews in the past 7 days; at that activity level, included reviews refill at 1 review per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 088183b3-7086-4e28-bc96-d8f8b36420e5

📥 Commits

Reviewing files that changed from the base of the PR and between a97d50b and 0373456.

📒 Files selected for processing (2)
  • crates/flare-git-core/src/doctor.rs
  • src/cli/git.rs

Comment @coderabbitai help to get the list of available commands.

@getappz
getappz merged commit 9bfb69a into master Aug 16, 2026
17 checks passed
@getappz
getappz deleted the task/493-git-shim-alert-on-sustained-scopechecker branch August 16, 2026 15:35
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