2026-07-18 17:40:05 +00:00
# heavy-duty-watcher
2026-07-22 23:23:33 +00:00
**Org-wide review agent** for the [heavy-duty ](https://github.com/heavy-duty ) organization
(GitHub by default; optional [Forgejo ](https://forgejo.heavyduty.builders ) backend via [stoke ](https://forgejo.heavyduty.builders/heavy-duty/stoke )).
2026-07-18 17:40:05 +00:00
Runs as bot ** `grok-bot-andresmgsl` **. Every 15 minutes it discovers open Issues/PRs where this bot is **assignee** or **requested reviewer** across **all** `heavy-duty/*` repos, reads the full discussion, and posts structured reviews until it **agrees** (Approve) or still has blockers (Request changes).
> Not a drive-by bot. No unsolicited comments. No merge/close/reassign unless an operator asks.
---
## Features
- **Org-wide scope** — one watcher for every repo under `heavy-duty`
2026-07-22 23:23:33 +00:00
- **Dual forge backends** — `FORGE_BACKEND=github` (default) or `forgejo`
2026-07-18 17:40:05 +00:00
- **Strict collaboration rules** — clear Verdict/Status, specific, non-redundant, blockers vs nits
- **Stateful de-dupe** — tracks per-item head SHA and last action (`owner/repo#pr:N`)
2026-07-22 23:23:33 +00:00
- **Deduped discovery** — PRs that are both review-requested and assigned appear once
2026-07-18 17:40:05 +00:00
- **Dual durability** — Grok durable schedulers **and** local tmux loops
- **Reboot recovery** — `scripts/restore.sh` rebuilds tmux + resumes the agent
2026-07-22 23:23:33 +00:00
- **Hourly health watchdog** — verifies poll loop, auth, freshness; self-heals
- **Offline self-test** — `scripts/self-test.sh` (`bash -n` + structure checks)
2026-07-18 17:40:05 +00:00
---
## Quick start
```bash
git clone https://github.com/grok-bot-andresmgsl/heavy-duty-watcher.git
2026-07-22 23:23:33 +00:00
# or from Forgejo: https://forgejo.heavyduty.builders/grok-reviewer-andresmgsl/heavy-duty-watcher.git
2026-07-18 17:40:05 +00:00
cd heavy-duty-watcher
2026-07-22 23:23:33 +00:00
gh auth status # bot account with org access (GitHub backend)
./scripts/self-test.sh # optional offline smoke
2026-07-18 17:40:05 +00:00
./scripts/install-live.sh
./scripts/restore.sh # after reboot: always this
```
2026-07-22 23:23:33 +00:00
### Forgejo backend
```bash
cp config/watcher.env.example config/watcher.env
# set FORGE_BACKEND=forgejo and BOT_LOGIN=<forgejo-bot>
stoke auth login
FORGE_BACKEND=forgejo ./scripts/discover.sh
```
2026-07-18 17:40:05 +00:00
Arm durable schedulers from a live Grok session using prompts in [`docs/SCHEDULER_PROMPTS.md` ](docs/SCHEDULER_PROMPTS.md ).
---
## Repository layout
```text
heavy-duty-watcher/
2026-07-22 23:23:33 +00:00
├── README.md
2026-07-18 17:40:05 +00:00
├── POLL_INSTRUCTIONS.md ← authoritative review rules (read every cycle)
├── config/
│ ├── state.template.json
│ └── watcher.env.example
├── scripts/
2026-07-22 23:23:33 +00:00
│ ├── lib/common.sh ← shared env + helpers
│ ├── discover.sh ← org-wide actionable list (github|forgejo)
2026-07-18 17:40:05 +00:00
│ ├── poll-once.sh ← one headless poll (Grok)
│ ├── poll-loop.sh ← every 15m
│ ├── health-check.sh
│ ├── health-loop.sh ← every 1h + self-heal
│ ├── restore.sh ← reboot recovery (tmux)
2026-07-22 23:23:33 +00:00
│ ├── install-live.sh ← deploy under ~/heavy-duty-watcher
│ └── self-test.sh ← offline smoke
2026-07-18 17:40:05 +00:00
├── docs/
│ ├── ARCHITECTURE.md
│ ├── OPERATIONS.md
2026-07-22 23:23:33 +00:00
│ ├── ORG_SCOPE.md
2026-07-18 17:40:05 +00:00
│ ├── SCHEDULER_PROMPTS.md
│ └── REVIEW_PLAYBOOK.md
└── logs/ ← runtime (gitignored)
```
---
## How a poll works
```text
2026-07-22 23:23:33 +00:00
discover (org search / forgejo API)
2026-07-18 17:40:05 +00:00
→ for each match
read ALL comments + reviews + diff + checks
compare head SHA / prior bot comments (state.json)
if material change:
post Verdict: Request changes | Comment | Approve
else:
silent
→ update state.json + logs/poll.log
```
Full rules: [`POLL_INSTRUCTIONS.md` ](POLL_INSTRUCTIONS.md ).
---
2026-07-22 23:23:33 +00:00
## Configuration
Copy `config/watcher.env.example` → `config/watcher.env` (gitignored):
| Variable | Default | Meaning |
|----------|---------|---------|
| `ORG` | `heavy-duty` | GitHub/Forgejo org |
| `BOT_LOGIN` | `grok-bot-andresmgsl` | Bot account login |
| `FORGE_BACKEND` | `github` | `github` or `forgejo` |
| `FORGEJO_URL` | `https://forgejo.heavyduty.builders` | Forge base URL |
| `POLL_INTERVAL_SEC` | `900` | tmux poll-loop sleep |
| `HEALTH_INTERVAL_SEC` | `3600` | health-loop sleep |
| `STALE_POLL_MINUTES` | `45` | health WARN threshold |
---
## Day-to-day commands
```bash
./scripts/discover.sh # JSON (default)
FORMAT=summary ./scripts/discover.sh # human table
./scripts/health-check.sh
./scripts/self-test.sh
tail -f logs/poll.log logs/health.log
tmux attach -t heavy-duty-watcher
```
---
2026-07-18 17:40:05 +00:00
## Documentation map
| Doc | Audience |
|-----|----------|
| [POLL_INSTRUCTIONS.md ](POLL_INSTRUCTIONS.md ) | Agent — must follow every cycle |
| [docs/ARCHITECTURE.md ](docs/ARCHITECTURE.md ) | Design / durability model |
| [docs/OPERATIONS.md ](docs/OPERATIONS.md ) | Humans operating the watcher |
| [docs/SCHEDULER_PROMPTS.md ](docs/SCHEDULER_PROMPTS.md ) | Copy-paste durable task prompts |
| [docs/REVIEW_PLAYBOOK.md ](docs/REVIEW_PLAYBOOK.md ) | Review style examples |
2026-07-22 23:23:33 +00:00
| [docs/ORG_SCOPE.md ](docs/ORG_SCOPE.md ) | Org repo notes |
2026-07-18 17:40:05 +00:00
---
## After reboot
```bash
~/heavy-duty-watcher/scripts/restore.sh
```
| Window | Role |
|--------|------|
| `grok` | Interactive agent (resume session when possible) |
| `poll-loop` | Headless 15m polls |
| `health-loop` | Hourly health + self-heal |
| `tools` | Manual shell |
---
## Safety
- Only comments when **assigned** or **review-requested**
- Never merges, closes, force-pushes, or reassigns by default
2026-07-22 23:23:33 +00:00
- Secrets are **not** stored in this repo — use `gh auth` / `stoke auth login` on the host
2026-07-18 17:40:05 +00:00
---
## License
MIT — see [LICENSE ](LICENSE ).