Skip to content

feat(agent): minimal quota gate and single-flight lock for agy review (#221) - #223

Merged
rebuildup merged 2 commits into
release/rex-remotefrom
221
Nov 23, 2026
Merged

rebuildup merged 2 commits into
release/rex-remotefrom
221

Conversation

@rebuildup

Copy link
Copy Markdown
Owner

Summary

Stacked on #222 (219 head). Implements Issue #221 at the reduced scope agreed in review: admission control only — no queue, scheduler, quota DB, or new Herdr worker management.

  • --min-remaining <0..1>: runs agy -p "/quota" before the model call; worst-bucket remaining fraction below threshold (or unreadable) → quota-exhausted without invoking the model. Fail-closed.
  • Single-flight lock $AGENT_STATE_DIR/agy-review/.single-flight.lock: atomic O_EXCL, 30 min staleness, ID-checked release, --no-exclusive opt-out → deferred on contention.
  • Both gates wrap local and --executor herdr; inner run-file skips them (outer dispatch owns admission).
  • agent review quota subcommand prints normalized buckets.
  • New classifications quota-exhausted / deferred; exit 0 still only for review-completed.
  • ADR-0023 §5 updated; shared scheduling explicitly deferred until observed contention.

Test plan

  • bun test script/agent.agy-review.test.ts — 28 pass (gate, lock, stale/foreign lock, run-file skip)
  • tsc --noEmit, ./script/test, ./script/test-workflow, ./script/check-secrets — pass
  • Real device (agy 1.5.14, macOS arm64, Keychain auth, SSH markers stripped): review quota returns live buckets; --min-remaining 0.999 → quota-exhausted with quota snapshot, model not called
  • pc-setup PR feat(agent): review結果へ model と spec 識別子を記録する #231 still OPEN — full mise-managed reproduction pending human merge + machine apply

Generated with Devin

…221)

Scope reduced per review: admission control only, no scheduler/queue.
--min-remaining probes /quota before the model call and fails closed as
quota-exhausted; a default O_EXCL single-flight lock serializes reviews
(deferred on contention, 30min staleness, --no-exclusive opt-out). Both
gates wrap local and Herdr executors; run-file skips them.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Next included review available in 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e918eb7 and dd1aa1b.

Files selected for processing: 5

  • docs/adr/ADR-0023.md
  • script/agent.agy-review.test.ts
  • script/agent/agy-review.ts
  • script/agent/commands.ts
  • script/agent/help.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Pre-merge review findings on #221:
- minQuotaFraction now drops buckets only when their group names a
  different known quota family, so --model no longer gates on unrelated
  exhausted groups; unrecognized names still fail closed on all buckets.
- The single-flight lock mtime is refreshed while the holder runs, so the
  30min staleness reclaim only fires for dead/hung holders and cannot
  steal the lock from a legitimately long --timeout run.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@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.

1 participant