# AFK Developer Runner: A Case Study in Bounded, Evidence-Driven Autonomy ## Executive summary AFK Developer is not built on the assumption that a coding model will carry a correct plan through an indefinitely long conversation. It is a **stochastic workflow engine**: its basic unit of work is an unreliable, stateful agent attempt. The runner therefore keeps the plan, attempt history, validation evidence, recovery budgets, and stop conditions as durable system state rather than facts a model must remember. This document records runner changes driven by live work, especially the Galemu Z80-core effort. The result is a more controlled system, not a claim that unattended software development is solved: - task attempts are bounded and their outcomes are persisted; - deterministic and independent checks decide whether an attempt is accepted; - recovery actions come from explicit, finite budgets; - a stuck task can be proposed for narrower decomposition rather than blindly retried; - worker transcript growth and repeated discovery are controlled; - supervisor decisions can correct an invalid task contract without erasing the history that invalidated it; and - campaigns stop at human checkpoints rather than inventing an unbounded next step. The important result is not that every autonomous run succeeds. It is that a failed premise, repeated failure, or non-progressing run becomes durable, inspectable evidence that changes the next permitted action. ## The failures that shaped the runner ### A green local mechanism can be unreachable end to end Galemu was deliberately used as a hard live run. Its early stuck `write-test-runner` task showed that foreman decomposition existed in code but was bypassed by several separate paths: 1. shell timeouts had no configuration override for a workload that needed an external test corpus; 2. decomposition considered only the most recent failure, although the persisted attempt history contained the real capability failure; 3. a saved plan did not refresh recovery policy when configuration changed before a later resume; and 4. a verification-policy rejection immediately escalated even when it was a retryable wrong command choice. Fixing one item did not make the feature usable. The runner needed all four paths connected before a real foreman call split a stuck task. Further live use exposed two lifecycle defects: a decomposed parent could be scheduled again on a later pass, and a parent did not roll up after subtasks passed through manual retry. Every defect received a targeted regression test, but the larger lesson matters more: recovery must be tested as a state transition through a real plan, not just as isolated policy helpers. ### Long context preserved the wrong work The OpenAI-compatible worker loop originally appended every tool result to its prompt. In both Galemu and an unrelated Textual editor project, the coder repeatedly reread reference material or framework internals, slightly varied the query, and exhausted its turn budget without writing code. This was not just a missing-fact problem: retaining the entire exploratory trail also preserved the tangent. The first correction was deterministic progressive transcript compaction: - keep the system prompt, original task, and a recent turn window; - replace older turns with a single recap built from real counters, not another model call; - compact only on clean turn boundaries so tool-call/result pairs remain valid; and - state explicitly when many turns have elapsed with no changed files. Later hardening added content-addressed discovery checkpoints, a bound on repeated source reads, explicit discovery-output boundaries, and a discovery-to-write progress governor. These solve different failure shapes: compaction limits stale conversational ballast; checkpoints avoid paying repeatedly for unchanged research; read bounds stop one large source becoming an endless attractor; and the governor makes lack of implementation progress visible to the worker. These are safeguards, not proof that every research-heavy task should edit quickly. Read-only work and real unknowns remain valid cases, so the system must retain explicit task contracts and escalation paths. ### Passing tests and lint were not a product witness The Geometry Dash prototype campaign closed with passing deterministic checks, but direct user feedback showed it was a renderer/replay prototype rather than a playable game. Source inspection found missing product semantics: no world-unit-to-pixel convention, no cube auto-run or jump loop, no vertical landing resolution, and no goal/finished lifecycle. This could not honestly be repaired by declaring more automated checks green. It established two constraints: 1. code-health gates verify only what they actually observe; and 2. interactive deliverables need an explicit product/release witness, normally involving a human observation, before they can be represented as product-complete. ## Current control model ### Durable state is the control plane Each saved plan records task contracts, dependencies, statuses, attempts, failure kinds, recovery budgets, evidence references, and branch/worktree state. Campaigns separately persist phase history, limits, leases, stop reason, and active-time accounting. The runner can resume after a process ends without asking a model to reconstruct the situation from a previous prompt. Durability alone is insufficient. State must be safely revisable when new evidence falsifies a premise. The supervisor-amendment model records typed, append-only actions such as accepting independently verified work, approving or rejecting a foreman proposal, replacing an unstarted queue, or retiring a bad task in favor of narrow replacements. The original task and its attempts remain durable; accepted work is not silently rewritten out of history. This is the practical distinction between **artifact caching** and **semantic invalidation**: - caching asks whether an input or artifact changed; - semantic invalidation asks whether the task contract, dependency edge, or completion claim remains justified by evidence. The second question is why AFK keeps failure history, explicit `not_applicable` reasons, amendment records, and human checkpoints rather than only storing a latest status. ### Bounded worker attempts and independent acceptance A task is not passed because a worker says it is done. Its normal route is: 1. take a ready task from the durable dependency graph; 2. establish isolation and persist the attempt lifecycle; 3. call the routed worker with a bounded context and turn budget; 4. run deterministic tests, lint, diff/scope, and required-artifact checks; 5. run optional source evidence and independent acceptance validation; and 6. merge and mark passed only after those gates pass. The verifier uses typed, read-only requests rather than executing arbitrary model-provided verification shell text. For high-risk corpus-backed work, a read-only researcher produces an immutable source-backed evidence packet and an independent validator checks the result before merge. This separates a worker's plausible explanation from the evidence needed to accept its change. ### Recovery is finite and evidence-sensitive Recovery is deliberately not an open retry loop. A saved `RecoverySettings` policy limits semantic repair, evidence supplements, high-reasoning repairs, and plan-wide decomposition. The next action depends on the classified failure: - a new validator finding can justify one high-reasoning semantic repair; - missing evidence can justify one read-only supplement against approved roots; - a task with genuine capability failures in its full attempt history can be offered to a foreman for a bounded split; and - repeated findings, exhausted budgets, provider faults, or an invalid premise become escalation points for a person. Foreman proposals and decomposed-parent coherence require supervisor approval. That friction is intentional: decomposition changes the meaning of a task and should not silently replace its contract merely because a model proposed smaller subtasks. ### Campaigns bound scope in time as well as topology A campaign stores ceilings for active hours, batches/phases, task count, retries, and recovery. Its phased mode drafts a roadmap, expands only the active phase's task DAG, reflects after a phase completes, and can revise the immediate future phase or stop for a human. Task leases and a campaign lock make short-lived `step` invocations resumable without duplicate dispatch. This gives long work a current frontier. The runner does not need a huge conversation describing six hours of history; it needs the latest durable plan, the evidence and attempts that justify it, and a finite next action. ## Field evidence | Trial | Observation | What it established | | --- | --- | --- | | Galemu recovery stress test | A real stuck task reached a foreman attempt and was split after the recovery-chain fixes. | Decomposition became reachable in the actual scheduler, not only in unit tests. | | Galemu Z80 implementation | The long plan exposed runner defects and a wrongly specified test-harness outcome contract. | Durable evidence can distinguish a worker failure from a runner or acceptance-semantics failure. | | Retro-editor | Compaction bounded message growth and helped a stuck task reach code, but later retries could still over-edit passing work. | Context compaction is necessary for one failure mode, not a general convergence proof. | | Geometry Dash campaign | Deterministic checks passed while manual use falsified the implicit product-completion claim. | Human acceptance/release evidence must remain a first-class gate for interactive products. | The Galemu result is especially useful because it separates two successes. AFK helped create the staged problem, surfaced recovery and harness defects under load, and left durable evidence. The later high-assurance Z80 core was completed through direct vector-oracle-driven implementation and independently validated by ZEXDOC and ZEXALL. The runner should receive credit for the control surface it exercised, not be credited as the sole author of every later implementation decision. ## What has improved The runner now has materially stronger mechanisms than the initial task-DAG-plus-retry version: - persisted recovery policy, budgets, fingerprints, and full attempt history; - durable task leasing, campaign locks, and atomic state writes; - per-task branch/worktree isolation with stale-branch recovery; - typed deterministic verification plus optional evidence/validator gates; - bounded repair, research, decomposition, best-of-N, and escalation paths; - progressive transcript compaction and discovery-progress controls; - structured run-event emission and read-only live status views; and - typed, auditable supervisor amendment operations rather than raw plan-file surgery. These changes make failures more observable and more recoverable. They also make the runner stricter about stopping: escalation, no progress, budget exhaustion, or a product claim outside available evidence is a result, not an invitation to burn tokens indefinitely. ## Boundaries and next proof obligations This report does **not** establish that AFK is state of the art, that long context is useless, or that a small model can autonomously complete arbitrary software projects. It records a design direction supported by concrete runs. Important remaining work includes: - measuring newer discovery governors across more live projects; - adding durable friction/audit data that explains turn and tool spend without retaining raw transcripts; - a principled stop/acceptance rule when the declared contract and tests already pass, so a worker does not keep "improving" correct code; - completing safe CLI workflows for supervisor amendment and release witnesses where needed; and - a broader real-backend integration matrix across concurrency, decomposition, acceptance, and campaign boundaries. The testable thesis is narrower: **externalized state plus explicit semantic invalidation and finite recovery can make inexpensive, imperfect workers more useful than either blind retries or long-context recall alone.** Future trials should measure recovery rate, repeated-read rate, turns-to-first-write, independent acceptance rate, supervisor interventions, and end-to-end product witnesses. ## Related records - [6502 Python round 2 experiment](6502-python-r2-experiment.md) — staged live trial of the postmortem-enriched-context and reduced-supervision thesis, with an intervention ledger and matched 151-opcode checkpoint. - [Scaling briefing](scaling-to-hours-phases-and-roles-briefing.md) — architecture, role model, and campaign mechanics. - [Evidence, acceptance, and bounded recovery](research-validation-recovery.md) — operating contract for high-risk tasks. - [Reliability and baseline-aware lint plan](reliability-and-baseline-lint-plan.md) — original auto-resume failure and durability work. - [Session 3 handoff](refactor-handoffs/03-tui-watch.md) — event seam and durable-state watch-view implementation record.