Repository navigation
Harden /loop with "loop engineering" operating rules (trust levels, denylist, run-log) #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Loop readiness checklist | ||
|
|
||
| Ship-rubric for any recurring `/loop` before you raise its trust level. Adapted for | ||
| this repo from the "loop engineering" loop-design checklist | ||
| (https://github.com/cobusgreyling/loop-engineering). Pair with `.claude/loop.md`. | ||
|
|
||
| ## Trust levels (what the loop may DO) | ||
| | Level | Scope | Requires | | ||
| |---|---|---| | ||
| | **L0 — Draft** | Intent documented | §1 | | ||
| | **L1 — Report** | Triage → run-log, no code changes | §1–3, §5 | | ||
| | **L2 — Assisted** | Small in-scope fixes + verifier; no auto-merge | §1–7 | | ||
| | **L3 — Unattended** | Acts without a human watching | all sections | | ||
|
|
||
| ## Checklist | ||
| **1. Purpose & scope** | ||
| - [ ] Single clear goal (one sentence) + explicit non-goals | ||
| - [ ] Watched scope defined (repos, branches, PRs, tickets, paths) | ||
| - [ ] Phased-rollout plan (report-only before acting) | ||
|
|
||
| **2. Scheduling** | ||
| - [ ] Cadence matches urgency; off-hours behavior defined | ||
| - [ ] First-run + restart-durability behavior specified | ||
| - [ ] Self-stops when the watchlist empties | ||
|
|
||
| **3. Skills** | ||
| - [ ] Triage step has a tight output format | ||
| - [ ] Action steps match project conventions; build/test commands known | ||
|
|
||
| **4. Maker/checker split** | ||
| - [ ] Implementer and verifier are separate passes | ||
| - [ ] Implementer cannot mark its own work "done" | ||
| - [ ] Verifier runs tests in isolation before approving | ||
|
|
||
| **5. State / memory** | ||
| - [ ] Run state documented (`.claude/memory/loop-run-log.md`) | ||
| - [ ] Prior state read at every iteration start | ||
| - [ ] Outcomes + timestamps written; resolved items pruned; human overrides recorded | ||
|
|
||
| **6. Human handoff** | ||
| - [ ] Escalation triggers explicit (max attempts, risk paths, ambiguity) | ||
| - [ ] Denylist paths identified (auth, payments, secrets, infra, CI config, migrations) | ||
| - [ ] Notify only when action is needed | ||
|
|
||
| **7. Connectors (MCP)** | ||
| - [ ] Minimum permissions; bot identity clear on comments | ||
| - [ ] Loop may open/update PRs or tickets only if acting (L2+) | ||
|
|
||
| **8. Cost & limits** | ||
| - [ ] Token/turn budget estimated; per-run cap + kill switch | ||
| - [ ] Append-only run log; remaining budget checked each iteration (against the per-run cap) | ||
| - [ ] Max iterations per item per run; max auto-PRs per day | ||
|
|
||
| **9. Observability** | ||
| - [ ] Each iteration logged (started, items found, actions, escalations) | ||
| - [ ] Success metric chosen; state inspectable without reading chat logs | ||
|
|
||
| **10. Safety** | ||
| - [ ] No auto-merge without an explicit allowlist | ||
| - [ ] Secrets/env in denylist | ||
| - [ ] Flakes handled by root-cause, not retry-only | ||
|
|
||
| ## Red flags (stop & fix before raising the level) | ||
| - Same PR/issue with >3 automated fix attempts without progress. | ||
| - Verifier is the same session as the implementer. | ||
| - No run-log (memory loss each iteration). | ||
| - Notifications on every run regardless of findings. | ||
| - Auto-merge without a path allowlist. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,79 @@ | ||
| You are running a recurring multi-agent development watchdog loop for this localhost web app. | ||
|
|
||
| On each loop iteration, act as Lead Agent and perform this process: | ||
|
|
||
| 1. Identify the current active task from the conversation. | ||
| 2. Check git status and changed files. | ||
| 3. Start or reuse the dev server. | ||
| 4. Open the relevant localhost page in Chrome or Playwright MCP. | ||
| 5. Check browser console errors. | ||
| 6. Check failed network requests. | ||
| 7. Run a critic round using these perspectives: | ||
|
|
||
| - First-Time User Critic | ||
| - UX Flow Critic | ||
| - Designer Critic | ||
| - Artistic Direction Critic | ||
| - Frontend Architecture Critic | ||
| - QA / E2E Critic | ||
| - Accessibility Critic | ||
| - Performance Critic | ||
| - Security Critic | ||
| - Regression Critic | ||
|
|
||
| 8. Produce a critic matrix. | ||
| 9. If blockers exist: | ||
| - fix only blockers directly related to the current task | ||
| - re-run the smallest relevant test | ||
| - re-check browser | ||
| 10. If important issues exist and are directly related: | ||
| - fix them only if low-risk and within scope | ||
| 11. Do not fix nice-to-have issues automatically. | ||
| 12. Do not start unrelated refactors. | ||
| 13. Do not push, deploy, delete data, or modify secrets. | ||
| 14. Stop when: | ||
| - no blockers remain | ||
| - browser verification passes | ||
| - relevant tests pass | ||
| - the current task has clear evidence of completion | ||
|
|
||
| Each loop report must include: | ||
|
|
||
| - current task | ||
| - localhost status | ||
| - critic matrix | ||
| - fixes applied | ||
| - browser evidence | ||
| - test evidence | ||
| - remaining risks | ||
| This loop is **hardened with "loop engineering" operating rules** (trust levels, | ||
| budget, denylist, escalation, stop conditions). Before running, fix the loop's | ||
| **trust level** and stay within it. | ||
|
|
||
| ## Trust level (declare it before the first iteration) | ||
| - **L1 — Report only.** Triage and report findings; make NO code changes, commits, | ||
| or PRs. The default when the level is unstated. | ||
| - **L2 — Assisted.** May apply small, in-scope, low-risk fixes with a verifier | ||
| (post-implementation critic) confirming; never auto-merge. | ||
| - **L3 — Unattended.** May act without a human watching; requires every section of | ||
| `.claude/loop-checklist.md` to be satisfied first. | ||
|
|
||
| ## Per-iteration process (act as Lead Agent) | ||
| 1. **Read state first:** open `.claude/memory/loop-run-log.md` (prior iterations, | ||
| outcomes, human overrides) and check **remaining budget** against the per-run cap | ||
| (turns or tokens — see *Budget & limits*) before doing anything; stop and | ||
| escalate if it is already exhausted. | ||
| 2. Identify the current active task from the conversation. | ||
| 3. Check git status and changed files. | ||
| 4. Start or reuse the dev server. | ||
| 5. Open the relevant localhost page in Chrome or Playwright MCP. | ||
| 6. Check browser console errors and failed network requests. | ||
| 7. Run a critic round (First-Time User, UX Flow, Designer, Artistic Direction, | ||
| Frontend Architecture, QA / E2E, Accessibility, Performance, Security, | ||
| Regression) and produce a critic matrix. | ||
| 8. **Maker/checker:** the critic that verifies a fix must be a *separate* pass from | ||
| the one that made it — the implementer never marks its own work "done". | ||
| 9. Act **only within the trust level**: | ||
| - L1: record findings only. | ||
| - L2/L3: fix blockers directly related to the current task; fix important issues | ||
| only if low-risk and in scope; re-run the smallest relevant test; re-check | ||
| browser. Never fix nice-to-haves automatically; never start unrelated refactors. | ||
| 10. **Append a run entry** to `.claude/memory/loop-run-log.md` (see format below). | ||
|
|
||
| ## Denylist — never touch autonomously (escalate instead) | ||
| Auth, payments, secrets/`.env`, infrastructure/deploy, CI workflow config, and | ||
| database migrations. Also: do not push, deploy, delete data, modify secrets, or | ||
| auto-merge without an explicit allowlist. | ||
|
|
||
| ## Escalate to a human (pause and ask) when | ||
| - A fix would touch a denylist path. | ||
| - An item hits the **max attempts** (see red flags) without progress. | ||
| - The right fix is ambiguous or architecturally significant (use AskUserQuestion). | ||
| - The budget is exhausted. | ||
| Notify only when action is needed — do not ping on a no-op run. | ||
|
|
||
| ## Red-flag stop conditions (halt and escalate) | ||
| - The same issue/PR has **>3 fix attempts** without forward progress. | ||
| - The verifier is the same pass/session as the implementer. | ||
| - There is no run-log/state (memory loss between runs). | ||
| - You'd notify on every run regardless of findings. | ||
| - Auto-merge is enabled without a path allowlist. | ||
|
|
||
| ## Budget & limits | ||
| - Declare a **per-run cap** with the trust level — a turn budget (e.g. 25 turns) or | ||
| a token ceiling — and record remaining budget in every run-log entry; stop and | ||
| escalate when reached. | ||
| - Max iterations per item per run: small (e.g. 3). Max auto-PRs per day: small. | ||
| - A loop with an empty watchlist should self-stop, not spin. | ||
|
|
||
| ## Stop when | ||
| - No blockers remain, browser verification passes, relevant tests pass, and the | ||
| current task has clear evidence of completion — or a stop condition above fires. | ||
|
|
||
| ## Run-log entry (append to `.claude/memory/loop-run-log.md`) | ||
| ``` | ||
| ## [YYYY-MM-DD HH:MM] L<level> | <task> | ||
| - found: <n blockers / n important / n nice-to-have> | ||
| - actions: <fixes applied, or "report only"> | ||
| - budget: <used>/<cap> (turns or tokens) | ||
| - escalations: <none | reason> | ||
| - evidence: <tests/browser> | ||
| - next: <stop | continue | awaiting human> | ||
| ``` | ||
|
|
||
| Each loop report must include: current task, trust level, localhost status, critic | ||
| matrix, fixes applied, browser evidence, test evidence, escalations, and remaining risks. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Loop Run Log | ||
|
|
||
| Append-only history of `/loop` runs (the loop's durable **state**, separate from | ||
| the wiki's `log.md` which records `/dream` operations). Read this at the start of | ||
| every loop iteration; write an entry at the end. Newest entries at the bottom. | ||
|
|
||
| Entry format (see `.claude/loop.md`): | ||
|
|
||
| ``` | ||
| ## [YYYY-MM-DD HH:MM] L<level> | <task> | ||
| - found: <n blockers / n important / n nice-to-have> | ||
| - actions: <fixes applied, or "report only"> | ||
| - budget: <used>/<cap> (turns or tokens) | ||
| - escalations: <none | reason> | ||
| - evidence: <tests/browser> | ||
| - next: <stop | continue | awaiting human> | ||
| ``` | ||
|
dominno marked this conversation as resolved.
|
||
|
|
||
| Rules: | ||
| - One entry per loop iteration; record outcomes, timestamps, and any human override. | ||
| - Prune resolved watchlist items; keep the decision trail. | ||
| - **Rotation:** when this file passes **500 lines**, roll older entries into | ||
| `.claude/memory/loop-run-log/<YYYY>.md` — **create that directory/file on demand** | ||
| if absent (same rule as `log.md`); the file is not `@imported`, so this is about | ||
| read/append cost only. | ||
|
|
||
| --- | ||
|
|
||
| _No loop runs recorded yet._ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.