# CHAOS — every idea from the three harness attempts **Stand: 2026-11-06.** Collected while planning a new agent harness of our own. Everything below was read out of the existing trees, not invented. Line counts and file references are what the trees actually contain at this date. ## Provenance — what was read | Tree | Location | Size / state | |---|---|---| | MikroAgent | `~/src/MikroAgent` (kitt) | 12,530 lines C99, 17 test binaries, `make check` green, 100,768 B binary, ~4 MB RSS, 0 CPU idle, 2 commits (`e21a11c` Phase 11, `b880a40` Phase 10) | | OpenITT | `~/src/OpenITT` (kontron) | single binary + `libopenitt.a`, 381 tests / 0 failures, docs ≈3,000 lines, **not a git repo** | | agentk | `~/src/agentk` (kitt) | **no code**: 852-line plan `refs/agentk-implementation-plan.md`, 15 skills under `.agents/skills/`, 26 research refs, 5 open tasks in `.tasks/` | Read in full: `MikroAgent/docs/{design.md,architecture.md,performance.md}`, `MikroAgent/AGENTS.md`, `OpenITT/OPENITT-OVERVIEW.md`, `OpenITT/specs/{compression-algorithm.md,long-input-design.md,notes-loop-pitch.md}`, `OpenITT/TOOLS.md`, `agentk/refs/agentk-implementation-plan.md` (selected sections), `agentk/.tasks/*.md`. --- # A. MikroAgent — the engine that already runs ## Transport layer 1. **Transport vtable**: `send() → {status, body}`, optional `send_stream()` handing **raw bytes** to a callback. The transport never parses JSON or SSE, so a mock, a libcurl adapter and any future provider share one seam. 2. **Deterministic mock transport**: replies queued FIFO; `send_stream()` replays a queued body in **caller-chosen chunk sizes**; records the last request body and a request count. This is how fragmented-argument handling is tested with no network and no paid endpoint. 3. **SSE framer is the only module that knows `\n\n`**: buffers partial lines across reads, ignores comments and non-`data` fields, strips an optional `\r`, reports an unterminated final event. 4. **Wire isolation**: only `model/openai.c` knows the OpenAI shape; tool-call fragments are merged by `index`, and **a fragment never yields a call until the stream finishes**. 5. **Raw `arguments` kept as a JSON string**, never parsed into an object at parse time — preserves exactly what the model sent for the audit trail and defers parsing to execution, because the API states arguments may be invalid JSON. ## Agent loop 6. Budget checked **before every request**; authorization callback before every non-read tool; **never a call without its result**. 7. **Authorization as a callback with fail-closed default**: with no callback, reads run and everything else is denied — the denial is delivered to the model *as the tool's observation*. Enforcement lives in the tool-execution layer, never in the system prompt (the prompt explains, it never decides). 8. **Three policies**: read-only, confirm-mutations (default), configured autonomous. The prompt shows tool name, class and the **exact `arguments` JSON**; anything but `y`/`yes` is denial; no stdin (`-p` plus a mutating tool) fails closed. ## Persistence 9. **One directory per session**: `meta` as `key = value`, written atomically (`meta.tmp` → `rename()`); `messages.jsonl` opened `O_APPEND`. 10. **Crash model**: a crash can only truncate the tail, so recovery replays complete lines and discards one partial line, reporting a `recovered` flag. A **complete** line that is not a valid message object is corruption and fails the load. 11. Session ids default to `sess-