## autonomous coding harness

chug

Given a spec and a goal, it keeps on chugging.

design rule #1 — the loop is code, not conversation. the model never decides whether to continue: the driver does.

live queue · tests · cycles → self-improving in public adversarial validation built in
$ chug run --spec SPEC.md \ --goal "Build X and make the check pass" chug <version> (<commit>) cwd=/srv/app spec=SPEC.md model=… ▪ iter 01 read SPEC.md · seeded LEDGER.md ▪ iter 07 edit_file src/api.rs · bash: cargo test ✓ ▪ iter 12 chug: budget low — 8 iteration(s) remain ✓ goal_complete accepted — check exited 0
one run, sketched — the real driver appends every event to .chug/events.jsonl

## 01 · how it works

The loop is code, not conversation

A run takes a spec file with a check: line and a goal, and drives a fixed loop until the check exits zero. Goal and progress live in files on disk, re-read every iteration — so context trimming can never kill the run.

SPEC + GOAL

SPEC.md with a check: line, plus --goal. Plain files — the driver re-reads them every iteration.

→

DRIVER LOOP

Continue/stop is the driver's call, never the model's. Anti-stall kick, stuck tripwire, budget-low warnings, same-cwd driver lock.

→

THE TOOLS

read_file, write_file, edit_file, bash, grep, tgrep, glob, list_dir, update_ledger, decision_log, delegate, web_fetch, goal_complete — sandboxed to --cwd.

→

GOAL_COMPLETE

Verified, not taken on faith: the spec's check: re-runs and the claim is accepted only on exit 0.

✗ check fails → keep chugging

The failure goes back to the model with the loop still in charge. It fixes, re-runs, re-claims. Rejected claims never end the run — the budget does, and a budget death prints a resume line and leaves the ledger intact.

LEDGER.md → external memory

Updated every iteration, injected into every turn, so transcript trimming never loses progress. A fresh run archives and reseeds it; --resume keeps it.

## 02 · proof it runs itself

Built by its own loop, measured by its own gates

chug improves chug. The loopd supervisor runs the self-improvement cycle back to back, and at every wrap the synced stats band below is regenerated from the repo's own ledgers — done rows in the queue ledger, gate counts in commit messages, the git log. Numbers live there, quoted and never rounded up; this section is the story behind them.

The tgrep arc: validation round after round

When the loop built its own token-budgeted context search, the adversarial validator refused to pass it — again and again: a merge-radius contradiction, symbols mode dropping declarations, vacuous pins, then one flaky perf pin with every mutant red. Each refusal forced a fix-up round; the final round closed it with a fresh mutant batch, all dead. A full artifact set came out of it, and the post-merge gates ran green — the counts are in the stats band.

The bug the pipeline existed to catch

Building its own hooks system, the implementer passed gates — and the validator still failed it. First refusal: PostToolUse was firing on calls that PreToolUse had vetoed, a real semantic bug no test had pinned. The fix-up swept the whole class — the sibling risk-gate-block path had the same hole — with killing tests proven red first. Second round: PASS, zero blocking findings.

Dogfood, verbatim

Its interactive chat mode: written for it, by it. Its delegate tool — a Rust module of its own, launching child chug runs in git worktrees: written by a child run, validated by another model family, then grown through wait_secs long-polling, resume, collect, and terminal-wait mode across later cycles. Its decision_log, hooks, plan mode, TUI, MCP client, Langfuse tracing: same story. And this very page — the one you are reading — was written by chug running its own loop, with this site's check gate re-running on every claim.

Honest failure books: one cycle hit its iteration ceiling mid-wrap and the wrap was lost — the next cycle reconstructed it from git history and ledgers alone. Failed validation rounds are the norm, not the exception; the tgrep arc alone logged refusal after refusal before its pass.

→ live counts: queue, tests, cycles — rewritten at every wrap

## latest release · synced from the repo's v* tags by scripts/site-sync.sh

v0.26.1latest release — tagged 2026-11-11 · notes on GitHub

## cost · synced from Langfuse by scripts/site-sync.sh

$0.00Langfuse spend yesterday (2026-11-17 UTC) · 7-day avg $2.45/day · TRUE streak 30 · as of 2026-11-18T18:04:37Z
▃█▆▂▂▃▃▂▁▁▁▁▁▁14-day spend shape, oldest → newest — daily total from Langfuse (chug project); per-day table on the docs page

## live stats · rewritten by scripts/site-sync.sh at every cycle wrap

360/361queue items landed — done rows in TODO.md, 361 item rows total
2289tests green at the newest full-suite gate count in a commit message (5d82c234)
1107cycles on record — cycle-*.log files in .chug/loopd/
2026-11-18last EVALUATION.md write (git log, chug repo)

No landed-item commits ("tNN: …" subjects) in the chug repo's git log yet.

## 03 · the timeline

Day one → chug.sh

Every date and hash below is quoted straight from git history — the harness repo and this site's own repo. The loop wrote this page too, so this timeline is the loop reading its own commit log back to you.

2026-09-20

Day one — the core harness f911488

First commit at 17:42: a driver-in-code loop, LEDGER.md as external memory, and goal completion that only counts when the check exits zero. Thirty-one commits land before midnight.

2026-09-20

The TUI, eight minutes later 76ac019

A ratatui dashboard at 17:50 — live activity stream, LEDGER panel, steering input, operator abort.

2026-09-20

The risk gate db6fea6

glob, list_dir and replace_all join the tools, and laya starts classifying every bash command before it runs — destructive calls are blocked with an error the model can route around.

2026-09-20

Chat mode, dogfooded fb842f2

Interactive mode lands with the claim in the commit message itself: "dogfooded by chug itself".

2026-09-20

The meta-loop era begins 7deb7f0

META-SPEC writes down chug-orchestrating-chug; SELF-SPEC makes improvement continuous. That evening "muse implements + kimi validates" becomes the default round policy (0611c33).

2026-09-21

MCP — stdio, then streamable HTTP 3386d2b

SPEC-7 merges: config discovery, handshake, tools/list registry, seven review fixes. The streamable-HTTP/SSE transport (SPEC-9) lands the same day — remote servers appear as mcp__name__tool too.

2026-09-21

Langfuse observability 25a36c1

SPEC-8 merges: a trace per run, a generation per LLM call, spans and scores per tool call. Fire-and-forget — telemetry never changes run behavior.

2026-09-21

The doctrine becomes code 672d04a · aac3629 · 3c795b3

Mutation testing enters the validation template — every landing must now prove its tests can fail. LOOP-SPEC writes the whole evaluate→queue→implement→validate→merge→push loop into one file. glm-5-3-flash takes the implementer seat; kimi-k3 keeps the verdicts.

…and 331 earlier milestones (T1–T345)

2026-09-25

loopd goes continuous 548d494

The supervisor lands after lunch and starts its first cycle the same minute — the first line of the loopd log. Cycles run back-to-back, each wrap the next cycle's input. It is still running today.

2026-09-25

delegate — chug spawns chug 1012dca

T23: launch and status for bounded child runs in git worktrees. Later cycles grow wait_secs long-polling, zombie reaping, resume, collect, and terminal-wait mode.

2026-09-26

Plan mode 87fe53f

chug plan (T73): read-only exploration under a five-tool contract — read_file, grep, glob, list_dir — with submit_plan as the single write and exit path.

2026-09-27

Per-phase model routing c1daaca

T81: glm orchestrates routine cycles, kimi takes the judgment calls — a mechanical freshness predicate in loopd.sh, never model vibes.

2026-09-27

Hooks ccb828a

PreToolUse veto + PostToolUse advisory (T83). The first validation round FAILED the merge — it caught PostToolUse firing on calls that never executed, a real bug — and the class sweep fixed the sibling risk-gate path with it.

2026-09-27

Permissions e9afed9

The deny-list lands (T90): .chug/permissions.json, first-match-wins, fail-closed on match, first in the policy chain before hooks and the risk gate. Its FEATURES.md roadmap row flips to LANDED.

2026-09-27

The move to K7 — always-on com.tampajohn.chug-loopd.plist

loopd moves under launchd on the operator's host (K7HC2K125R): the plist wraps loopd.sh in caffeinate -dims with RunAtLoad. The improvement loop no longer lives in a terminal.

2026-09-27

chug.sh — this site e998d45

chug builds its own public site: eight commits in one evening, every section landed against the verify.sh check gate, GitHub Pages serving a CNAME. You are reading the dogfood.

2026-11-09

usage events emitter + model-identity stamping (model_served distinct from requested; additive) (65ee407f)

2026-11-09

RED-proven guard: every loopd-spawning test harness pins CHUG_LOOPD_ENV/CHUG_PROFILE_ENV to ABSENT… (97f4740d)

2026-11-09

release pipeline: every run since v0.17.28 cancelled; GitHub releases stuck at v0.17.27 — pilots… (dd4407c2)

2026-11-09

install.sh: release-staleness detection (--allow-stale gate) + --with-daemon/--with-loopd launchd… (9e737d90)

2026-11-09

features list auto-feed: site renders shipped work from TODO done rows + F17-F23 backfill (grid is… (52ff78e1)

2026-11-09

chug loop init/run --goal: seed the queue from the spawn goal (empty-queue spawns go uselessly… (39abe72b)

2026-11-09

chug update: self-update with version-floor protection + source-build fallback (T347-era) + opt-in… (0adf45c0)

2026-11-09

STATS cycles counter on durable source (cycle-*.log count, not rotating loopd.log lines) — site… (34d44201)

2026-11-09

loopd emits OSC 7501 status natively (TTY-gated, env-killable, blocked carries msg) — kills the… (7feef28f)

2026-11-09

loop terminal heartbeat: compact live status lines on stdout (TTY-gated, same source string as the… (ed67c584)

2026-11-10

OSC 7501 emission in loopd-pilot.sh (the embedded supervisor spawned loops actually run) — T354… (0e3d13d7)

2026-11-10

profile contract: CHUG_LANGFUSE_PROJECT is a no-op (0 consumers) — remove + document per-lane… (8d5d2468)

2026-11-10

README entry-path cleanup: install-first quickstart, chug loop leads continuous mode, generic model… (be7ab1b4)

2026-11-10

pin the site-sync cycles leg-2 subject anchor (eval: commits counted by SUBJECT only, never body)… (c15a6e17)

2026-11-10

loop verbose streaming: CHUG_LOOP_VERBOSE levels 0-3 (silent/compact/turn-detail/full-trace) for the… (9665f6b8)

2026-11-10

OSC 7501 blocked leg: emission scans newest cycle-*.log for failure patterns (blocked+msg, clears on… (653d8002)

2026-11-10

dormant release flush: tags must not wait on a dormant queue (release-only mechanical cycle when… (f71f6e02)

2026-11-11

orchestrator grind delegation: fixture/gate iteration to glm children; inline bash budget +… (cf278d59)

2026-11-11

T361 flush cut v0.26.0 but never pushed (local-only 9h, silent success claim) — flush must push +… (28ec5ee2)

2026-11-11

release workflow apt resilience: pin archive.ubuntu.com fallback + retry/backoff on DNS failure… (0b0c7ff4)

The quiet patch stays on the chart: zero commits between the last early-cycle landing and loopd's first start. Honest books include the blank pages.

## 04 · feature grid

What's in the box

Every capability below is quoted from the repo's README and FEATURES roadmap — including the phases still deferred with written reasons, because a harness that keeps honest books about what it hasn't done yet is the whole point.

Recently shipped — the newest 20 of 359 done rows in TODO.md, newest first; auto-fed from the loop's own flip record at every sync, never hand-edited:

The curated feature grid below is the flagship list; this feed is the complete shipped record.

builtin tools

read_file write_file edit_file bash grep tgrep glob list_dir update_ledger decision_log delegate web_fetch goal_complete — all paths sandboxed to the run's working directory.

delegate sub-agentslanded

Structured child result: goal_complete summary + commit refs + gates output returned to the caller (today: git/files archaeology). Makes delegate a real…

plan modelanded

chug plan / /plan in chat: read-only tool subset, model produces an implementation plan to stdout/file, exits. Optional --approve plan.md gate for `chug…

hookslanded

.chug/hooks.json (or settings): shell commands on PreToolUse / PostToolUse / Stop / GoalComplete events. Policy-as-config, no doctrine forks. Laya stop-hook…

permissionslanded

Per-tool allow/deny/ask rules (glob-scoped paths, command patterns) evaluated before execution; --risk-gate becomes one policy source among several.…

risk gate (Laya)landed

chug.sh/adopt.html — quickstart, mental model, first-feature walkthrough, FAQ — machine-rendered from docs/adopt/ (the front door for a curious engineer),…

MCP servers

Consumes tools from MCP servers over stdio or streamable HTTP with Claude Code-compatible config. Server tools appear as mcp__name__tool alongside the builtins; per-server fail-soft.

Langfuse observability

Optional tracing to self-hosted Langfuse v3: a trace per run, a generation per LLM call, a span per tool call, outcome and iteration scores. Fire-and-forget — off means zero cost, telemetry never changes run behavior.

TUI

--tui: live activity stream, LEDGER.md panel, and a status bar with model, iteration/budget, elapsed time, and cumulative tokens. i steers, q aborts gracefully.

web_fetch

Read-only HTTP(S) GET with hard bounds: 5 redirects, 10s connect / 30s total, output capped and HTML stripped to text, binary types refused. Bounded and audited where raw curl is neither.

tgrep

Token-budgeted ranked context search: ranked match clusters with tight context windows, quoted phrases, a symbols mode for Rust signatures. Deterministic scoring — no embeddings, no LLM.

chat

Interactive TUI sessions: @file attachments, tab autocomplete for commands and paths, slash commands, esc to interrupt. Steering notes pass into autonomous runs at iteration boundaries.

decision_loglanded

Every loop judgment emits a structured decision record (.chug/decisions.jsonl): decision class, compact inputs, options, choice, model, confidence — with…

loop hardening

Driver lock against concurrent runs, transcript trimming that keeps the cached prefix byte-stable, jq-mineable events.jsonl, budget-low warnings, a stuck tripwire, and an anti-stall kick.

Image inputlanded

read_file on png/jpg returns image blocks (vision); chat accepts pasted/dragged screenshots. UI work needs eyes.

Session forklanded

Clone transcript+ledger at iteration N into a new session id; explore two approaches from one state.

Streaming UXlanded

Text deltas to sinks as they arrive (TUI live typing, headless progress); watchdog gets byte-level liveness for free.

Structured todo toollanded

todo_add/update/list driver-visible tools (statuses enforced) as an alternative to freeform LEDGER edits — the orchestration ledger becomes queryable.

Slash-command packslanded

.chug/commands/*.md repo-local commands invocable from chat (/review, /triage) and as run goals. Community-extensible without code.

chug as MCP serverlanded

chug mcp-serve: expose run/delegate/status as MCP tools so Claude Code, the bridge fleet, or another chug can drive it. The fleet primitive.

MCP resources+promptslanded

Consume MCP resource/prompt capabilities (today: tools only).

Web searchlanded

Provider-pluggable search tool complementing web_fetch.

Context compactionlanded

Long autonomous cycles accumulate 0.8–1.2M non-cached input tokens per orchestrator stream (cycle-79/80 kimi streams measured); the events stream drops…

Baked-in Laya judge daemonlanded

On the loop's host — the external layad daemon is connection-refused dead: risk-gated runs silently lose the semantic layer, the notify layad sink is…

Dormant-mode cost programlanded

Empty queue = cheap-exit always + a weekly read-only audit eval; no manufactured meta-filings while idle. The dormant-era burn stays visible on the chug.sh cost…

Ideation lanelanded

The dormant loop proposes outward-facing features into a Proposed lane (specs/proposed/, TODO P-rows); the operator flips, the loop never self-flips —…

Loop subcommandlanded

chug loop init + run in ANY repo, no clone: scaffolds a generic LOOP-SPEC/TODO.md/.chug (idempotent, --force backups) and execs the supervisor against the…

Install profileslanded

install.sh --profile <name>: a profile contract for LLM-proxy config — company values ship out-of-band, the installer stays public and key-free.

Decision-model providers: local Laya + proxy Jevlanded

CHUG_DECISION_PROVIDER=auto,local,proxy (src/decision/): LocalDaemon (the baked-in Laya judge) + ProxySystem (a served OpenAI-compatible judge) — pilot…

Meta-harness packlanded

Harness surfaces for driving chug from outside, no scraping anywhere: chug capabilities versioned feature doc (T339), chugd typed status endpoints…

## 05 · the loop doctrine

One cycle, start to push

evaluate→ queue→ implement · glm→ validate · kimi + mutation testing→ merge→ push

The evaluator reads the corpus — events, ledgers, specs, code — and writes the assessment plus the next queue rows, each with its own spec before any child is dispatched. Children implement in git worktrees, one at a time, under iteration and token budgets; glm-5-3-flash implements. Then validation is always kimi-k3 — a different model family, so the verdict is an independent second opinion, and it is adversarial by design: gates re-run from a clean checkout, mutants are injected to prove the tests can actually fail, weak pins get called out. A FAIL verdict is not a crisis; it is the pipeline working. Only then: merge, flip the queue row, push. The doctrine is written down, versioned, and pinned by tests — the loop edits its own rules in the open, never by vibes.

The full protocol — phases, budgets, recovery recipes, hard rules — is one file: LOOP-SPEC.md.

## 06 · get started

Clone, build, chug

Everything below is the repo's own quickstart, verbatim. Put a check: line in your spec — goal_complete is only accepted when the check exits 0.

1 · INSTALL

$ curl -fsSL https://chug.sh/install.sh | sh

Prebuilt binaries for macos-arm64, linux-x86_64 and linux-aarch64 — detects your platform, verifies the sha256, installs to ~/.local/bin (never sudo). Read the script first if you like; the loop cuts v* releases from its own wrap. Or build from source ↓

2 · BUILD

$ git clone https://github.com/tampajohn/chug
$ cd chug
$ cargo build
$ cargo install --path .   # puts the chug binary on PATH (~/.cargo/bin)

Zero setup if you have Claude Code configured: chug reads its auth from ~/.claude/settings.json when the process env doesn't have it.

3 · RUN SOMETHING REAL

$ chug run --spec SPEC.md --goal "Build X and make the check pass" \
    --model anthropic-system.ai.kimi-k3 --max-iters 40 --max-minutes 120

$ chug run --tui ...   # same, with the live dashboard
$ chug run --resume    # continue an aborted run from .chug/transcript.jsonl
$ chug chat            # interactive mode (TUI)
$ chug ledger          # print current LEDGER.md

4 · RUN THE LOOP ON ITSELF

$ nohup ./loopd.sh > /dev/null 2>&1 &   # start (detached)
$ ./loopd.sh status                     # liveness + recent cycle activity
$ ./loopd.sh stop                       # exits after the current cycle

LOOP-SPEC.md is the one-command self-improvement loop; the loopd supervisor runs it continuously — cycle after cycle, no human per-phase prompting. The live count is in the stats band.

5 · DEVELOP

$ cargo build && cargo clippy --all-targets -- -D warnings && cargo test

All three must stay green — the loop's own gates enforce the same bar on every change it lands.

The full runbook corpus lives on the docs page, regenerated from the repo's runbooks/ at every sync.