Skip to content

feat(review): configurable bot reviewers via REVIEW_BOTS - #85

Merged
zxkane merged 2 commits into
mainfrom
feat/configurable-review-bots
May 10, 2026
Merged

feat(review): configurable bot reviewers via REVIEW_BOTS#85
zxkane merged 2 commits into
mainfrom
feat/configurable-review-bots

Conversation

@zxkane

@zxkane zxkane commented May 10, 2026

Copy link
Copy Markdown
Owner

Summary

Replace the hardcoded /q review enforcement in autonomous-review.sh with a per-project REVIEW_BOTS setting. Built-in registry: q, codex, claude. Custom bots via REVIEW_BOTS_<NAME>_TRIGGER and REVIEW_BOTS_<NAME>_LOGIN env vars. Empty REVIEW_BOTS disables bot enforcement entirely.

Why

The dev/review pipeline previously assumed every consuming repo had Amazon Q Developer installed. Projects without Q (or with Codex/Claude instead) had no way to opt out or swap bots — the wrapper would force /q review and block the review on a Q response that never came. This PR makes bot enforcement project-driven.

Design

  • Design canvas: docs/designs/configurable-review-bots.md
  • New library: skills/autonomous-dispatcher/scripts/lib-review-bots.sh — registry + parse_review_bots / get_bot_trigger / get_bot_login / render_bot_review_section helpers. Fail-fast validation rejects unknown bots so a typo in autonomous.conf surfaces immediately rather than silently dropping the bot.
  • Two-layer validation (added in second commit):
    1. dispatcher-tick.sh startup precheck — runs before any GitHub API call or label transition. A bad value aborts the whole tick with exit 1. Without this, a typo would let the tick swap an issue's label to reviewing and spawn the wrapper, which exits 1 — burning a retry slot every tick until MAX_RETRIES. Multi-project wrapper unchanged: it already handles per-project failures.
    2. autonomous-review.sh startup validation — defense in depth, since the wrapper can be invoked outside the dispatcher.
  • autonomous-review.sh sources the lib, computes REVIEW_BOTS_VALIDATED once at startup, and replaces the hardcoded Q-review heredoc with $(render_bot_review_section ...). The E2E report-table iterates over the validated list.
  • autonomous.conf.example defaults to REVIEW_BOTS="q" to preserve prior behavior — existing projects see no change unless they edit the config.
  • autonomous-dev SKILL + references and autonomous-review SKILL now condition bot triggers on REVIEW_BOTS membership and list all 3 built-ins. Critical detail: Claude uses @claude review (NOT /claude review) per the anthropics/claude-code-action docs.

Test Plan

  • Unit tests: 33 cases in tests/unit/test-lib-review-bots.sh covering parse happy/empty/unknown/custom-via-env, case normalization, helper lookups, render output for empty/single/multi-bot configs, and a @claude review regression guard.
  • Integration: 11 source-of-truth grep cases in tests/unit/test-autonomous-review-prompt.sh verifying the wrapper sources the lib, validates fail-fast, embeds render_bot_review_section in the prompt, drops the hardcoded Q block, and passes bash -n.
  • Dispatcher precheck: 9 cases in tests/unit/test-dispatcher-tick-review-bots.sh — bad value → rc != 0, gh shim records zero calls (precheck aborts before side-effects), error contents, empty REVIEW_BOTS clears precheck, source-of-truth grep + line-position check that precheck precedes any dispatch call.
  • bash -n clean on lib-review-bots.sh, autonomous-review.sh, dispatcher-tick.sh
  • Full unit suite (35 / 35 files pass)
  • code-reviewer agent run on both commits: zero blocking findings
  • CI checks pass

Backwards Compatibility

autonomous.conf.example defaults to REVIEW_BOTS="q", which renders the same 5-step trigger/poll/fail flow the wrapper used before — only the local var name changed (Q_COUNTCOUNT, scoped to the rendered prompt). Existing deployments that copy from the example see identical behavior.

Checklist

  • Design canvas created (docs/designs/configurable-review-bots.md)
  • Test cases documented (covered by 3 new test files)
  • Build passes (no compiled artifacts; bash -n clean)
  • Unit tests pass (53 / 53 cases across 3 new test files; 35 / 35 unit test files)
  • Code simplification review passed
  • PR review agent review passed (zero blocking findings on each commit)
  • CI checks pass
  • Reviewer bot findings addressed

Replace the hardcoded /q review enforcement in autonomous-review.sh
with a per-project REVIEW_BOTS setting. Built-in registry: q, codex,
claude. Custom bots via REVIEW_BOTS_<NAME>_TRIGGER and _LOGIN env vars.
Empty REVIEW_BOTS disables bot enforcement entirely.

- New skills/autonomous-dispatcher/scripts/lib-review-bots.sh: registry
  + parse_review_bots / get_bot_trigger / get_bot_login /
  render_bot_review_section helpers. Fail-fast validation rejects
  unknown bots at wrapper startup.
- autonomous-review.sh sources the lib, validates REVIEW_BOTS at
  startup (REVIEW_BOTS_VALIDATED), and replaces the hardcoded Q-review
  heredoc with $(render_bot_review_section ...). Report-table section
  iterates over the validated list.
- autonomous.conf.example documents the new setting and defaults to
  REVIEW_BOTS="q" to preserve prior behavior.
- autonomous-dev SKILL + references and autonomous-review SKILL now
  condition bot triggers on REVIEW_BOTS membership and list all 3
  built-ins (Claude uses @claude review, NOT /claude review).
- Tests: 33 unit cases for the lib + 11 source-of-truth grep cases
  against the wrapper. All pass.
@zxkane zxkane added the pipeline-docs:none Attests this PR has no observable pipeline behavior change, exempting it from the docs-update gate label May 10, 2026

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR successfully implements configurable review bots with a well-designed abstraction layer. The implementation replaces hardcoded Amazon Q enforcement with a flexible, registry-based system supporting multiple bots (Q, Codex, Claude) plus custom bots via environment variables.

Strengths:

  • Clean separation of concerns with lib-review-bots.sh library
  • Fail-fast validation prevents silent config errors
  • Comprehensive test coverage (44 test cases)
  • Backward compatible - defaults to REVIEW_BOTS="q" preserving existing behavior
  • Proper handling of Claude's @claude review trigger (not /claude review)
  • Well-documented with design canvas and inline comments

Code Quality:

  • Bash syntax validated with bash -n
  • Proper error handling and return codes
  • Security-conscious (validates input, uses proper quoting)
  • Clear function contracts and documentation

All acceptance criteria appear to be met. The implementation is production-ready.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Validate REVIEW_BOTS at the start of dispatcher-tick.sh, alongside the
existing EXECUTION_BACKEND precheck. A typo (e.g. REVIEW_BOTS="q codx")
would otherwise let the tick swap an issue's label to `reviewing` and
spawn autonomous-review.sh, which exits 1 at startup — burning a retry
slot on every tick until MAX_RETRIES marks the issue stalled.

The precheck aborts the whole tick with a clear error before any gh
API call or label transition. Multi-project wrapper unchanged: it
already runs each project's tick in a subshell and continues past
per-project failures.

- skills/autonomous-dispatcher/scripts/dispatcher-tick.sh: source
  lib-review-bots.sh and call parse_review_bots after the
  EXECUTION_BACKEND case statement, before any side-effects.
- tests/unit/test-dispatcher-tick-review-bots.sh: 9 cases — bad value
  exits non-zero, gh shim records zero calls, error message references
  the bad bot name and autonomous.conf, empty REVIEW_BOTS clears the
  precheck, source-of-truth grep + line-position check that the
  precheck runs before any dispatch().
- docs/designs/configurable-review-bots.md: document the two-layer
  validation (dispatcher precheck + wrapper defense-in-depth).
@zxkane
zxkane merged commit 5b16ba2 into main May 10, 2026
3 checks passed
@zxkane
zxkane deleted the feat/configurable-review-bots branch May 10, 2026 09:46
zxkane added a commit that referenced this pull request May 10, 2026
## Summary

One-line README update: the "Amazon Q integration" row in the Review
Agent capability table was stale after #85 generalized bot enforcement
to all configured bots. Replace it with a row that names the
`REVIEW_BOTS` setting plus the three built-in bots (`/q`, `/codex`,
`@claude`) and mentions the custom-bot extension.

## Test Plan

- [x] Markdown renders cleanly (table cell, no formatting changes
outside the row)
- [ ] CI checks pass

## Checklist

- [x] No code changes — single-row update in `README.md`
- [x] Build/tests not affected
- [x] PR review skipped (trivial copy change in a documentation table)
zxkane added a commit that referenced this pull request May 10, 2026
…87)

## Summary

Three docs-only changes to README.md:

1. **New "For AI Agents — Install and Configure" top-level section.**
Six-step walkthrough (`npx skills add ... -a claude-code -y`, symlinks,
required plugins, `autonomous.conf` variable table, GitHub label setup,
smoke tests) plus a copy-paste prompt block agents can execute
end-to-end on the user's behalf.

2. **Option B Step 3 generalized.** The dispatcher tick is
host-agnostic; OpenClaw is the recommended host but plain cron +
`dispatcher-tick.sh`, Claude Cowork, and GitHub Actions schedules all
work. Replaced the OpenClaw-only instruction with a 3-row host table and
a two-example cron block.

3. **Supported Agent CLIs table refreshed.** Verified each CLI against
current upstream docs (May 2026):
- **Codex CLI** marked code-side broken — `lib-agent.sh` uses `-p`, but
current Codex parses that as `--profile`. Headless invocation is now
`codex exec "<prompt>"`. Follow-up `fix(dispatcher)` PR pending.
- **Kiro CLI** binary corrected from `kiro` to `kiro-cli`; headless
pattern is `chat --no-interactive [--agent <name>]`.
- **Cursor Agent** and **Gemini CLI** rows added (both work via the
generic `<cli> -p <prompt>` fallback).
- Documented `AGENT_TIMEOUT` (default `4h`) and `AGENT_DEV_MODEL` /
`AGENT_REVIEW_MODEL`, which ship in `autonomous.conf.example` but were
missing from the README.

## Why

After the configurable-review-bots PR (#85) and an upstream Codex CLI
breaking change, the existing README was both incomplete (no
agent-driven install path, no `AGENT_TIMEOUT` / `REVIEW_BOTS` doc) and
inaccurate (Codex `-p` flag, Kiro `kiro` binary, OpenClaw-only
dispatcher framing). This PR doesn't change behavior — it just stops
shipping wrong instructions.

## Code-review findings addressed

The code-reviewer agent flagged five issues on the first draft; all
resolved:

1. ❌ `claude --skill autonomous-dispatcher` — that flag doesn't exist. →
Replaced with `bash dispatcher-tick.sh` (which is what every host calls
anyway).
2. ❌ Copy-paste prompt's Step 5 ran `setup-labels.sh "$REPO"` without
sourcing `autonomous.conf` first → `$REPO` would be empty. → Wrapped in
`( source scripts/autonomous.conf && ... )` subshell.
3. Missing `AGENT_TIMEOUT` / `AGENT_DEV_MODEL` / `AGENT_REVIEW_MODEL`
rows in the variable table. → Added.
4. Codex contradiction (variable table said `codex` works; agent-CLI
table said it's broken). → Tightened the variable table to mark `codex`
as currently broken with a back-reference.
5. `dispatcher-tick.sh` referenced in Step 6 without prior introduction.
→ Added inline annotations to the smoke-test commands.

## Test Plan

- [x] `claude --help` confirmed: no `--skill` flag (verified the broken
example was actually broken)
- [x] `codex --help` and `codex exec --help` confirmed: `-p` is
`--profile`, prompts are positional
- [x] All 5 code-review findings addressed before push
- [ ] CI checks pass

## Follow-ups (not in this PR)

- `fix(dispatcher)`: switch `lib-agent.sh` codex branch from `-p
"$prompt"` to `codex exec "$prompt"`, and add a codex case to
`resume_agent` using `codex exec resume`. Will also evaluate adding an
`opencode` branch (provider-agnostic, but session ID is opencode-minted,
not caller-provided — needs adapter work).

## Checklist

- [x] No code changes — README only
- [x] Build/tests not affected
- [x] PR review agent run; all blocking findings resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pipeline-docs:none Attests this PR has no observable pipeline behavior change, exempting it from the docs-update gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant