ouro-loop 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ouro Loop Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,430 @@
1
+ Metadata-Version: 2.4
2
+ Name: ouro-loop
3
+ Version: 0.2.0
4
+ Summary: Give AI coding agents (Claude Code, Cursor, Aider, Codex) a structured autonomous loop with guardrails — boundaries, verification gates, self-healing, and autonomous remediation. Zero dependencies.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/VictorVVedtion/ouro-loop
7
+ Project-URL: Repository, https://github.com/VictorVVedtion/ouro-loop
8
+ Project-URL: Documentation, https://github.com/VictorVVedtion/ouro-loop#readme
9
+ Project-URL: Issues, https://github.com/VictorVVedtion/ouro-loop/issues
10
+ Keywords: ai-agent,autonomous-coding,guardrails,bounded-autonomy,claude-code,ai-safety,llm-agent,agent-framework,self-healing-code,vibe-coding
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Classifier: Topic :: Software Development :: Testing
20
+ Classifier: Operating System :: OS Independent
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Dynamic: license-file
25
+
26
+ # Ouro Loop
27
+
28
+ ![Ouro Loop — Autonomous AI Agent Development Framework](assets/banner.png)
29
+
30
+ > **"To grant an entity absolute autonomy, you must first bind it with absolute constraints."**
31
+
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
33
+ [![Python >=3.10](https://img.shields.io/badge/python->=3.10-blue.svg)](https://www.python.org/downloads/)
34
+ [![CI](https://github.com/VictorVVedtion/ouro-loop/actions/workflows/test.yml/badge.svg)](https://github.com/VictorVVedtion/ouro-loop/actions/workflows/test.yml)
35
+ [![Status: Experimental](https://img.shields.io/badge/status-experimental-orange.svg)]()
36
+
37
+ ## What is Ouro Loop?
38
+
39
+ **Ouro Loop** is an open-source framework that gives AI coding agents (Claude Code, Cursor, Aider, Codex) a structured autonomous loop with runtime-enforced guardrails. It implements **bounded autonomy** — the developer defines absolute constraints (DANGER ZONES, NEVER DO rules, IRON LAWS) using the BOUND system, then the agent loops autonomously through Build → Verify → Self-Fix cycles. When verification fails, the agent doesn't ask for help — it consults its remediation playbook, reverts, tries a different approach, and reports what it did. Constraints are enforced at the runtime level through Claude Code Hooks (exit 2 hard-block), not by relying on the agent's "good behavior." Inspired by Karpathy's [autoresearch](https://github.com/karpathy/autoresearch), extended from ML to general software engineering. Zero dependencies, pure Python 3.10+.
40
+
41
+ | | |
42
+ |---|---|
43
+ | **What it does** | Let AI agents code overnight without breaking things |
44
+ | **How it works** | Define boundaries (BOUND) → AI loops: Build → Verify → Self-Fix |
45
+ | **What you get** | `program.md` (method) + `framework.py` (runtime) + 4 hooks (enforcement) |
46
+ | **Requirements** | Python 3.10+, Git, any AI agent. Zero dependencies. |
47
+
48
+ ### Is Ouro Loop for you?
49
+
50
+ **This is for you if:**
51
+ - You want to let an AI agent run autonomously for hours (overnight builds, long refactors)
52
+ - Your project has files that must never be touched without review (payments, auth, consensus)
53
+ - You've experienced AI agents hallucinating paths, breaking constraints, or getting stuck in loops
54
+ - You want auditable, structured autonomous development — not "vibe and pray"
55
+
56
+ **This is NOT for you if:**
57
+ - You're building a quick prototype or hackathon project (BOUND setup overhead isn't worth it)
58
+ - You're writing single-file scripts (the methodology overhead exceeds the benefit)
59
+ - You want real-time interactive coding (Ouro Loop is designed for "set it and let it run")
60
+
61
+ ### The Problem with Unbound AI Agents
62
+
63
+ In the era of "vibe coding," unbound AI agents hallucinate file paths, break production constraints, regress architectural patterns, and get stuck in infinite fix-break loops. The current solution — pausing to ask humans — negates the promise of autonomous coding.
64
+
65
+ ### The Solution: Bounded Autonomy
66
+
67
+ Ouro Loop formally introduces **The Event Horizon**: the developer establishes absolute constraints (Iron Laws, Danger Zones). The AI Agent is granted full autonomy to continuously build, verify, and self-correct within that boundary — never crossing into catastrophic failure. When something breaks inside the boundary, the agent **doesn't ask for help** — it consults its remediation playbook, reverts, tries a different approach, and reports what it did.
68
+
69
+ ---
70
+
71
+ ## How It Works
72
+
73
+ The repo is deliberately kept small. Only three files matter:
74
+
75
+ - **`program.md`** — the methodology instructions. Defines the six-stage loop (BOUND, MAP, PLAN, BUILD, VERIFY, LOOP) and the autonomous remediation rules. Point your agent here and let it go. **This file is iterated on by the human**.
76
+ - **`framework.py`** — lightweight runtime for state tracking, verification gates, and logging. The agent uses this CLI to check its own work. **This file can be extended by the agent**.
77
+ - **`prepare.py`** — project scanning and initialization. Creates the `.ouro/` state directory. Not modified.
78
+
79
+ ```mermaid
80
+ graph TD
81
+ classDef default fill:#1e1e1e,stroke:#4a4a4a,stroke-width:1px,color:#d4d4d4;
82
+ classDef highlight fill:#2d3748,stroke:#63b3ed,stroke-width:2px,color:#fff;
83
+ classDef boundary fill:#4a1c40,stroke:#fc8181,stroke-width:2px,color:#fff;
84
+
85
+ BOUND(("Step 0<br/><b>BOUND</b><br/>(Set Constraints)")):::boundary
86
+ MAP["Step 1<br/><b>MAP</b><br/>(Understand)"]
87
+ PLAN["Step 2<br/><b>PLAN</b><br/>(Decompose)"]
88
+ BUILD["Step 3<br/><b>BUILD</b><br/>(Create)"]
89
+ VERIFY{"Step 4<br/><b>VERIFY</b><br/>(Judge)"}
90
+ REMEDIATE["<b>REMEDIATE</b><br/>(Autonomous Fix)"]:::highlight
91
+ NEXT(("Next<br/>Phase"))
92
+
93
+ BOUND --> MAP
94
+ MAP --> PLAN
95
+ PLAN --> BUILD
96
+ BUILD --> VERIFY
97
+ VERIFY -- "FAIL (inside BOUND)" --> REMEDIATE
98
+ REMEDIATE --> BUILD
99
+ VERIFY -- "PASS" --> NEXT
100
+ NEXT -.-> BUILD
101
+ ```
102
+
103
+ When verification fails, the agent does *not* ask for human help. It consults `modules/remediation.md`, decides on a fix, reverts/retries, and loops — so long as it hasn't breached the outer edge of the BOUND. Read [The Manifesto](MANIFESTO.md) for the deep-dive on Precision Autonomy.
104
+
105
+ ---
106
+
107
+ ## Quick Start
108
+
109
+ **Requirements:** Python 3.10+, Git, any AI coding agent.
110
+
111
+ ### 1. Clone Ouro Loop
112
+
113
+ ```bash
114
+ git clone https://github.com/VictorVVedtion/ouro-loop.git ~/.ouro-loop
115
+ ```
116
+
117
+ ### 2. Scan your project
118
+
119
+ ```bash
120
+ cd /path/to/your/project
121
+ python ~/.ouro-loop/prepare.py scan .
122
+ ```
123
+
124
+ This shows you what Ouro Loop sees:
125
+
126
+ ```
127
+ ============================================================
128
+ Ouro Loop — Project Scan
129
+ ============================================================
130
+ Project: my-payment-service
131
+ Types: Python
132
+ Files: 42 Lines: 3,200
133
+
134
+ Languages:
135
+ Python 35 files ###############
136
+ SQL 7 files #######
137
+
138
+ CLAUDE.md: Not found
139
+ BOUND: Not defined
140
+ Tests: Found
141
+ CI: Found
142
+
143
+ Recommendations:
144
+ 1. Define BOUND (DANGER ZONES, NEVER DO, IRON LAWS) before building
145
+ 2. Create CLAUDE.md with BOUND section
146
+ ============================================================
147
+ ```
148
+
149
+ ### 3. Initialize and draw the boundaries
150
+
151
+ ```bash
152
+ python ~/.ouro-loop/prepare.py init . # Creates .ouro/ state directory
153
+ python ~/.ouro-loop/prepare.py template claude . # Generates CLAUDE.md template
154
+ ```
155
+
156
+ Edit `CLAUDE.md` to define your project's actual boundaries. Here's what a real BOUND looks like:
157
+
158
+ ```markdown
159
+ ## BOUND
160
+
161
+ ### DANGER ZONES
162
+ - `src/payments/calculator.py` — financial calculations, penny-level precision
163
+ - `migrations/` — database schema, irreversible in production
164
+
165
+ ### NEVER DO
166
+ - Never use float for monetary values — always Decimal
167
+ - Never delete or rename migration files
168
+ - Never commit without running the test suite
169
+
170
+ ### IRON LAWS
171
+ - All monetary values use Decimal with 2-digit precision
172
+ - All API responses include request_id field
173
+ - Test coverage for payment module never drops below 90%
174
+ ```
175
+
176
+ See `examples/` for complete BOUND definitions and **real session logs** showing the methodology in action:
177
+
178
+ - [**Blockchain L1**](examples/blockchain-l1/) — BOUND for consensus/p2p, plus a [real session log](examples/blockchain-l1/session-log.md) where the agent tested 5 hypotheses, autonomously remediated 4 failures, and found a root cause that was architectural (HTTP routing), not code-level.
179
+ - [**Consumer Product**](examples/consumer-product/) — BOUND for audio/sync, plus a [real session log](examples/consumer-product/session-log.md) where ROOT_CAUSE gate caught a lazy fix and pushed the agent toward a genuinely better solution.
180
+ - [**Financial System**](examples/financial-system/) — DANGER ZONES around payments, Decimal precision IRON LAWS.
181
+ - [**ML Research**](examples/ml-research/) — autoresearch-style single-metric optimization reframed as BOUND.
182
+
183
+ ### 4. Point your AI agent and go
184
+
185
+ Spin up Claude Code, Cursor, Aider, or any AI coding agent in your project and prompt:
186
+
187
+ ```
188
+ Read program.md from ~/.ouro-loop/ and the CLAUDE.md in this project.
189
+ Let's start the Ouro Loop for this task: [describe your task].
190
+ ```
191
+
192
+ The `program.md` file is essentially a lightweight "skill" — it tells the agent how to work within your boundaries. The agent will read your BOUND, MAP the problem, PLAN phases, BUILD incrementally, VERIFY through multi-layer gates, and LOOP feedback back into BOUND.
193
+
194
+ ---
195
+
196
+ ## The Runtime CLI
197
+
198
+ `framework.py` is the state machine and verification gatekeeper. The agent calls these during the loop:
199
+
200
+ ```bash
201
+ python framework.py scan . # Scan project structure
202
+ python framework.py status . # Where are we in the loop?
203
+ python framework.py bound-check . # Are DANGER ZONES / IRON LAWS defined?
204
+ python framework.py verify . # Run all verification gates
205
+ python framework.py log PASS --path . --notes "phase 1 done" # Record result
206
+ python framework.py advance . # Move to next phase
207
+ ```
208
+
209
+ **Quick help:** Use `--help` to see all available commands:
210
+
211
+ ```bash
212
+ python framework.py --help # Show all commands
213
+ python framework.py status --help # Show status command options
214
+ python framework.py verify --help # Show verify command options
215
+ ```
216
+
217
+ **Verify** runs multi-layer gate checks and shows exactly what's healthy and what's not:
218
+
219
+ ```
220
+ ==================================================
221
+ Ouro Loop — Verification
222
+ ==================================================
223
+ Layer 1 — Gates:
224
+ [+] EXIST CLAUDE.md exists
225
+ [+] RELEVANCE 3 files changed
226
+ [!] ROOT_CAUSE Hot files: src/payments/calc.py
227
+ [+] MOMENTUM 5 recent commits
228
+
229
+ Layer 2 — Self-Assessment:
230
+ [+] bound_compliance BOUND section found
231
+ [+] tests_exist Test files found
232
+
233
+ Overall: PASS
234
+ ==================================================
235
+ ```
236
+
237
+ **When verification fails**, the agent autonomously remediates and reports what it did:
238
+
239
+ ```
240
+ [REMEDIATED] gate=ROOT_CAUSE action=revert_and_retry
241
+ was: editing src/payments/calc.py for the 4th time (same TypeError)
242
+ did: reverted to commit a1b2c3d, re-analyzed from scratch
243
+ now: trying middleware pattern instead
244
+ bound: no DANGER ZONE touched, no IRON LAW affected
245
+ ```
246
+
247
+ Results are logged to `ouro-results.tsv` for full auditability:
248
+
249
+ ```
250
+ phase verdict bound_violations notes
251
+ 1/3 PASS 0 transactions endpoint + tests
252
+ 2/3 RETRY 0 ROOT_CAUSE warning, fixing
253
+ 2/3 PASS 0 fixed after retry
254
+ 3/3 PASS 0 validation complete
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Claude Code Hooks — Automatic BOUND Enforcement
260
+
261
+ Ouro Loop includes 4 hooks that enforce BOUND constraints at the tool level. When installed, the agent **physically cannot** edit DANGER ZONE files without user approval — no matter what instructions it receives.
262
+
263
+ ```bash
264
+ # Install hooks in your project
265
+ cp ~/.ouro-loop/hooks/settings.json.template .claude/settings.json
266
+ # Edit paths in settings.json to point to your ouro-loop installation
267
+ ```
268
+
269
+ | Hook | Event | What it does |
270
+ |------|-------|-------------|
271
+ | `bound-guard.sh` | PreToolUse:Edit/Write | Parses CLAUDE.md DANGER ZONES, **blocks** edits to protected files (exit 2) |
272
+ | `root-cause-tracker.sh` | PostToolUse:Edit/Write | Tracks per-file edit count, warns at 3+, strongly warns at 5+ |
273
+ | `drift-detector.sh` | PreToolUse:Edit/Write | Warns when touching 5+ directories (scope drift) |
274
+ | `recall-gate.sh` | PreCompact | Re-injects BOUND into context before compression |
275
+
276
+ Verified in live Claude Code sessions:
277
+ - `framework.py` (DANGER ZONE): **BLOCKED** with exit 2, agent sees denial reason
278
+ - `hooks/bound-guard.sh` (DANGER ZONE): **BLOCKED** — hook protects itself
279
+ - `CONTRIBUTING.md` (safe): passed silently, zero overhead
280
+
281
+ This is what makes Ouro Loop different from instruction-only approaches: **BOUND is enforced by the runtime, not by the agent's good behavior.**
282
+
283
+ ---
284
+
285
+ ## Real Results from Autonomous Sessions
286
+
287
+ These results come from real Ouro Loop sessions on production codebases. Full session logs with methodology observations are available in `examples/`.
288
+
289
+ ### Blockchain L1 — Consensus Performance Under Load
290
+
291
+ An AI agent was tasked with investigating why `precommit` latency spiked from 4ms to 200ms under transaction load on a 4-validator PBFT blockchain. Working inside a DANGER ZONE (`consensus/`):
292
+
293
+ - **5 hypotheses tested, 4 autonomous remediations** — the ROOT_CAUSE gate fired 4 times, each time correctly identifying that the agent was fixing symptoms, not the cause
294
+ - After 3 consecutive failed hypotheses, the 3-failure step-back rule kicked in: "stop fixing symptoms, re-examine the architecture" — which led to discovering the real root cause
295
+ - **Root cause was architectural, not code-level** — a single-node HTTP bottleneck was causing consensus-wide delays. The fix was a Caddy reverse proxy, not a code change
296
+ - **The agent caught its own flawed experiment** — when testing an alternative, it ran 4x full stress instead of 1x distributed. It identified the flaw before drawing wrong conclusions
297
+
298
+ | Metric | Before | After | Delta |
299
+ |--------|--------|-------|-------|
300
+ | Precommit (under load) | 100-200ms | 4ms | **-98%** |
301
+ | Block time (under load) | 111-200ms | 52-57ms | **-53%** |
302
+ | TPS Variance | 40.6% | 1.6% | **-96%** |
303
+ | SysErr rate | 0.00% | 0.00% | = (IRON LAW) |
304
+ | Blocks/sec (soak load) | ~8.0 | ~18.5 | **+131%** |
305
+
306
+ ### Consumer Product — Lint Remediation in React/Next.js
307
+
308
+ A simpler session where the ROOT_CAUSE gate prevented a lazy fix: instead of suppressing ESLint errors, the agent was pushed toward genuinely better solutions (replacing `<a>` with Next.js `<Link>`, properly handling `useEffect` state patterns).
309
+
310
+ See the full session logs: [Blockchain L1](examples/blockchain-l1/session-log.md) | [Consumer Product](examples/consumer-product/session-log.md)
311
+
312
+ ---
313
+
314
+ ## Project Structure
315
+
316
+ ```
317
+ program.md — methodology instructions (human edits this)
318
+ framework.py — runtime CLI: state, verification, logging (agent uses this)
319
+ prepare.py — project scanning and initialization (not modified)
320
+ hooks/
321
+ bound-guard.sh DANGER ZONE enforcement (PreToolUse, exit 2 block)
322
+ root-cause-tracker.sh repeated-edit detection (PostToolUse)
323
+ drift-detector.sh scope drift warning (PreToolUse)
324
+ recall-gate.sh BOUND re-injection on context compaction (PreCompact)
325
+ settings.json.template ready-to-use hooks configuration
326
+ modules/
327
+ bound.md Stage 0: define DANGER ZONES, NEVER DO, IRON LAWS
328
+ map.md Stage 1: understand the problem space
329
+ plan.md Stage 2: decompose into severity-ordered phases
330
+ build.md Stage 3: RED-GREEN-REFACTOR-COMMIT
331
+ verify.md Stage 4: three-layer verification gates
332
+ loop.md Stage 5: feedback closure
333
+ remediation.md autonomous remediation playbook
334
+ templates/ starter templates for CLAUDE.md, phase plans, checklists
335
+ examples/ real-world BOUND definitions from four project types
336
+ ```
337
+
338
+ ## Design Choices
339
+
340
+ - **Boundaries before code.** Define what must never break before writing any code. A financial system's NEVER DO list prevents more bugs than any test suite.
341
+ - **Autonomous remediation.** Unlike monitoring tools that detect-and-alert, Ouro Loop agents detect-decide-act-report. Like `autoresearch` auto-reverts when val_bpb regresses, Ouro Loop auto-remediates when verification fails — inside BOUND, no human permission needed.
342
+ - **Three files that matter.** `program.md` (methodology), `framework.py` (runtime), `prepare.py` (init). Everything else is reference.
343
+ - **Zero dependencies.** Pure Python 3.10+. Works with any AI agent, any language, any project type.
344
+
345
+ ## Comparison with autoresearch
346
+
347
+ | | autoresearch | ouro-loop |
348
+ |--|-------------|-----------|
349
+ | Core idea | Give AI a training loop, let it experiment | Give AI a methodology, let it guard |
350
+ | Human programs | `program.md` (experiment strategy) | `program.md` (dev strategy) + `CLAUDE.md` (boundaries) |
351
+ | AI modifies | `train.py` (model code) | Target project code + `framework.py` |
352
+ | Fixed constraint | 5-minute training budget | BOUND (DANGER ZONES, NEVER DO, IRON LAWS) |
353
+ | Core metric | val_bpb (lower is better) | Multi-layer verification (gates + self-assessment) |
354
+ | On failure | Auto-revert, try next experiment | Auto-remediate, try alternative approach |
355
+ | Read-only | `prepare.py` | `prepare.py` + `modules/` |
356
+
357
+ ## Use Cases
358
+
359
+ Ouro Loop is designed for any scenario where you need an **AI agent to work autonomously for extended periods** without human babysitting:
360
+
361
+ - **Overnight autonomous development** — Define BOUND, start the agent, sleep. Wake up to a log of phases completed and verified, not a broken codebase.
362
+ - **Long-running refactoring** — Let the agent refactor a large codebase in phases, with verification gates ensuring nothing breaks between phases.
363
+ - **AI-assisted code review and remediation** — The agent identifies issues, fixes them, and verifies the fixes — all within defined safety boundaries.
364
+ - **Continuous integration with AI agents** — Plug Ouro Loop into your CI/CD pipeline to let agents handle build failures, test regressions, and dependency updates autonomously.
365
+ - **Multi-phase feature development** — Break complex features into severity-ordered phases. The agent handles CRITICAL changes first, then HIGH, then MEDIUM.
366
+ - **Production-safe AI coding** — For financial systems, blockchain infrastructure, medical software, and any domain where "move fast and break things" is unacceptable.
367
+
368
+ ## Works With
369
+
370
+ Ouro Loop is agent-agnostic. It works with any AI coding assistant that can read files and execute terminal commands:
371
+
372
+ - **[Claude Code](https://claude.ai/claude-code)** — Anthropic's CLI agent. Native `program.md` skill support.
373
+ - **[Cursor](https://cursor.sh)** — AI-powered IDE. Use `.cursorrules` to reference Ouro Loop modules.
374
+ - **[Aider](https://aider.chat)** — Terminal-based AI pair programmer.
375
+ - **[Codex CLI](https://github.com/openai/codex)** — OpenAI's coding agent.
376
+ - **[Windsurf](https://codeium.com/windsurf)** — Codeium's AI IDE.
377
+ - Any agent that can read Markdown instructions and run Python scripts.
378
+
379
+ ## Related Projects
380
+
381
+ - **[karpathy/autoresearch](https://github.com/karpathy/autoresearch)** — The inspiration. Autonomous ML experiment loop. Ouro Loop extends this paradigm to general software engineering.
382
+ - **[anthropics/claude-code](https://claude.ai/claude-code)** — The AI agent Ouro Loop was primarily developed with.
383
+ - **[everything-claude-code](https://github.com/anthropics/courses)** — Comprehensive Claude Code skills and agents collection.
384
+
385
+ ## FAQ
386
+
387
+ **Q: How is this different from just using `.cursorrules` or `CLAUDE.md`?**
388
+ A: `.cursorrules` and `CLAUDE.md` define static instructions that the agent can ignore. Ouro Loop adds a **runtime loop** — state tracking, multi-layer verification, autonomous remediation, and phase management. The agent doesn't just follow rules; it verifies compliance, detects drift, and self-corrects. Most importantly, BOUND constraints are enforced by runtime hooks (exit 2 hard-block), not by the agent's good behavior.
389
+
390
+ **Q: Can the agent really fix its own mistakes?**
391
+ A: Yes, within BOUND. When verification fails and the issue is inside the boundary (not a DANGER ZONE), the agent consults `modules/remediation.md` for a decision playbook: revert, retry with a different approach, or escalate. It reports what it did, not what it's thinking of doing. In a real blockchain session, the agent autonomously remediated 4 failures across 5 hypotheses and found a root cause that was architectural (HTTP routing), not code-level.
392
+
393
+ **Q: How do I add guardrails to Claude Code?**
394
+ A: Ouro Loop provides 4 Claude Code Hooks that enforce constraints at the tool level. Install them by copying `hooks/settings.json.template` to `.claude/settings.json` and editing the paths. The `bound-guard.sh` hook parses your CLAUDE.md DANGER ZONES and physically blocks edits to protected files. No agent can bypass exit code 2.
395
+
396
+ **Q: How do I let an AI agent code overnight?**
397
+ A: Define your BOUND (DANGER ZONES, NEVER DO, IRON LAWS) in CLAUDE.md, install the hooks, then tell the agent to read `program.md` and start the loop. The agent will iterate through Build → Verify → Self-Fix cycles autonomously. When verification fails, it remediates and retries. When it passes, it advances to the next phase. The loop continues until all phases are complete.
398
+
399
+ **Q: What is bounded autonomy in AI coding?**
400
+ A: Bounded autonomy is a paradigm where AI coding agents are granted full autonomous decision-making power within explicitly defined constraints. By defining the 20 things an agent cannot do (the BOUND), you implicitly authorize it to do the 10,000 things required to solve the problem. It's the middle path between human-in-the-loop (constant interruptions) and unbounded agents (unconstrained risk).
401
+
402
+ **Q: How to prevent AI agents from hallucinating file paths?**
403
+ A: Ouro Loop's EXIST verification gate checks whether referenced files, APIs, and modules actually exist before the agent proceeds. The `bound-guard.sh` hook also validates file paths against the project structure. If a file doesn't exist, the gate fails and triggers autonomous remediation — the agent corrects its reference instead of proceeding with hallucinated paths.
404
+
405
+ **Q: Can AI agents fix their own bugs autonomously?**
406
+ A: Yes — this is called autonomous remediation. When a verification gate fails, the agent doesn't alert a human. It reads its error logs, consults its remediation playbook, and takes action: revert, retry with a different approach, or escalate only if a DANGER ZONE is involved. The key constraint is BOUND — the agent can self-fix anything inside the boundary.
407
+
408
+ **Q: How to prevent context decay in long AI coding sessions?**
409
+ A: Ouro Loop addresses context decay through the RECALL verification gate and the `recall-gate.sh` hook. The gate monitors whether the agent can still recall key constraints. The hook fires before context compression (PreCompact event) and re-injects the BOUND section into the compressed context, preventing constraint amnesia during long sessions.
410
+
411
+ **Q: How long can the agent run autonomously?**
412
+ A: As long as phases remain. Each phase is independently verifiable, so the agent can run for hours across many phases. The NEVER STOP instruction in `program.md` keeps the loop going until all phases pass or an EMERGENCY-level issue is hit.
413
+
414
+ **Q: Do I need to install anything?**
415
+ A: No. Zero dependencies. Pure Python 3.10+ standard library. Clone the repo and point your agent at `program.md`. Optionally install hooks for runtime enforcement.
416
+
417
+ **Q: When should I NOT use Ouro Loop?**
418
+ A: Don't use Ouro Loop for quick prototypes, hackathon projects, or single-file scripts — the BOUND setup overhead isn't worth it. It's also not designed for real-time interactive coding sessions. Ouro Loop shines when you need to "set it and let it run" — overnight builds, long-running refactors, and multi-phase autonomous development on codebases with critical constraints.
419
+
420
+ ## Contributing
421
+
422
+ The most valuable contributions are **real-world bindings**. If you used Ouro Loop to bound an agent in a complex domain, submit a sanitized `CLAUDE.md` and `phase-plan.md` to `examples/`. See [CONTRIBUTING.md](CONTRIBUTING.md).
423
+
424
+ ## Philosophy
425
+
426
+ By explicitly defining the 20 things an agent can *never* do (the BOUND), you implicitly authorize it to autonomously do the 10,000 things required to solve the problem. The constraint space defines the creative space. Read [The Manifesto](MANIFESTO.md) for the full deep-dive.
427
+
428
+ ## License
429
+
430
+ MIT