## docs · machine-rendered from the repo at every sync

chug docs

How to use chug effectively — the quickstart and every runbook on one page, never stale: rendered from README.md and runbooks/ by scripts/site-sync.sh at every wrap.

## 01 · quickstart

Quickstart

The repo's own quickstart, verbatim from README.md — re-rendered at every sync.

One command installs the binary — platform detected, sha256 verified, no Rust toolchain, no sudo:

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

Then, in a repo of yours (no clone of chug needed), start the continuous loop:

cd <your-repo>
chug loop init      # scaffold LOOP-SPEC.md + TODO.md + .chug/ (idempotent; --force backs up)
chug loop run       # exec the loop supervisor against THIS repo

Wire up a model provider with --profile <name> at install time — the profile exports the provider contract (base URL, key, per-phase models); see docs/install-profiles.md. Zero setup also works if you have Claude Code configured: chug reads ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN / ANTHROPIC_API_KEY from ~/.claude/settings.json when the process env doesn't have them (process env always wins; default base URL is api.anthropic.com).

Single runs need no scaffolding: chug run takes a spec file with a check: line plus a goal and drives a fixed loop until the check exits 0.

chug run --spec SPEC.md --goal "Build X and make the check pass" \
  --model claude-sonnet-4-6 --max-iters 40 --max-minutes 120
# --model takes any name your provider resolves; provider-specific ids
# belong in a profile — see docs/install-profiles.md

chug run --tui ...   # same, with the live dashboard
chug run --resume    # continue an aborted run from .chug/transcript.jsonl
chug run --auto-spec --validate     # force FULL adversarial validation on this run (T189)
chug run --auto-spec --no-validate  # force the gates-only lane (operator override, recorded)
chug chat            # interactive mode (TUI)
chug ledger          # print current LEDGER.md
chug capabilities    # print the capability contract — features + versions this build supports (T339)
chug daemon --status # the judge daemon's lifecycle; T340 also serves GET /status/loop + /status/items on its socket (observation only)

Put a check: <shell command> line in your spec — goal_complete is only accepted when the check exits 0. The check (like every shell chug spawns) runs with CARGO_TARGET_DIR/CARGO_BUILD_TARGET_DIR scrubbed from its environment, so a bare cargo test builds the run cwd's own target/ — set the variable inside the check: line itself if you want a shared build cache (an explicit choice, never an inheritance accident).

No spec yet? chug run --goal "Fix the flaky login test" --auto-spec (or chug quick) drafts one for you: one read-only model call (plan mode's loop) writes .chug/auto-spec.md — concern, requirements, tests, acceptance, plus the check: and estimate: lines — and the draft's check is dry-run executed before the run starts. A check that can't exit 0 on the current tree is refused and redrafted once; a second refusal aborts with the draft and the failing output, never a loosened check. In chat mode the same flow is /auto-spec <request> then /auto-spec-approve (the approve gate re-runs the dry-run; editing the check to something vacuous is refused). Auto-spec is for task-class work — chores, small features; adversarial and loop work keeps hand-written specs. Auto-spec'd runs default to the low-stakes validation lane (T189): per item, a mechanical predicate computed from the diff (no core-list file touched, ≤ ~150 changed lines, no new tool/command surface, no CI/check:-line change) routes gates-only — the kimi validation child is skipped, never the gates (build + clippy + the full suite in the worktree, byte-clean review, and the scope check stay required). --validate forces full adversarial validation; --no-validate forces the gates-only lane; either operator override is recorded.

## runbook · README.md

Runbooks

One-page recipes for the recurring chug uses. Each names when to reach for it, gives copy-pasteable commands (real flags; <goal> and <N> are the only slots), and states its expected wall-clock arc so you can budget. Pick the line that sounds like your situation:

  • "I have one small chore and no spec" → quick-task.md
  • "I'm landing a real feature and want it validated" → feature.md
  • "Can chug drive some other repo? Evaluate it before committing a loop" → repo-eval.md
  • "The self-improvement loop: start it, read it, stop it, recover it" → loop-ops.md
  • "Get a second pair of eyes on this code or diff, then file the findings" → adversarial-review.md
  • "Host or consume an org-private laya judge fine-tune (org/token/endpoint, publish contract)" → laya-hf-hosting.md

## runbook · adversarial-review.md

Runbook: adversarial review of a repo or diff

Use when you want a second pair of eyes: correctness bugs in a snapshot or on a diff/commit — read-only work whose deliverable is a findings report. Arc: ~20–60 minutes. The reviewer is chug itself, or an external reviewer (the codex-review arc); intake is the same either way.

1. Run the review

chug run --spec review-spec.md \
  --goal "Source-level adversarial review per the spec: find correctness bugs; write findings-report.md; change nothing but that file" \
  --model anthropic-system.ai.kimi-k3 --max-iters 40 --max-minutes 60

Run it in the repo or worktree under review. The review spec pins shape, not scope creep: requirement 1 = graded findings with file:line evidence; a non-negotiation = no edits outside the report; the check: gates the report's existence and structure:

check: test -f findings-report.md && grep -q '^## 1\.' findings-report.md

estimate: ~1 changed line (the report)

Scope goes in the goal, concretely: "review HEAD", "review the last 3 commits", "review git diff main..HEAD". Start from a clean tree (or a dedicated worktree) so the nothing-else-changed constraint is auditable with git status afterwards.

2. What good findings look like

The codex-review shape (reviews/CODEX-REVIEW-20260928.md is the worked example):

  • A summary paragraph up top naming what the green suite misses — "the tests pass, and here is why that isn't enough".
  • Severity-graded sections: ## 1. CORRECTNESS BUGS → ### HIGH — <title>.
  • Each finding carries Evidence (src/foo.rs:817-style references), a concrete Trigger (or interleaving), and a suggested test when the bug is testable.

3. Intake: findings → TODO rows

Triage before filing: drop duplicates and out-of-scope nits, keep correctness bugs and integrity gaps.

  • One TODO row per finding, named for the reviewer — <finding> (<reviewer> review) — exactly how T140–T143 landed from the codex review (e.g. "goal_complete denial bypass (codex review)").
  • One spec per row: specs/t<N>-<reviewer>-<slug>.md, with a check: line that pins the fix's test and an estimate: line.
  • Claims validation couldn't kill become named follow-ups on the row — never silently dropped.

## runbook · feature.md

Runbook: spec'd feature work

Use when the change is a real feature — behavior worth pinning with tests, a check gate, and adversarial validation. Arc: 1–2 h per item (implementation, validation, a fix-up round if needed).

1. Write the spec

Hand-written specs live in specs/t<N>-<slug>.md; T191's own is a worked example:

# T<N> — <one-line what>

check: <command that exits 0 exactly when this work is verifiably done>

estimate: ~<lines> changed lines

## Concern
<why this exists>

## Requirements
1. ...

## Tests
- <named behaviors that must pass>

## Out of scope
- <explicitly not this item>

Gate rules: goal_complete is accepted only when the check: line exits 0 (it runs with CARGO_TARGET_DIR scrubbed from the env — set the variable inside the check line itself for a shared cache), and a spec on a todo TODO row carries estimate: ~N changed lines (T150).

2. Run it

chug run --spec specs/t<N>-<slug>.md \
  --goal "Implement this item ONLY per the spec; commit in this worktree; \
you own LEDGER.md bookkeeping" \
  --model anthropic-system.ai.kimi-k3 --max-iters 80 --max-minutes 120

The goal should say: which item ONLY, any env to export before cargo, and where to commit. The spec is re-read every iteration — you can sharpen it mid-run.

3. Validation and verdict

Core-logic items get adversarial validation — an independent run that re-derives requirements, re-runs gates, attacks with mutants. Handling:

  • PASS — merge, close the row, done.
  • FAIL — relaunch against the same worktree with the findings in the goal (a fix-up run starts fresh by design), then re-validate. One fix-up round is normal; three is a smell — re-scope the item.
  • Budget death, work complete-but-uncommitted — one --resume attempt on the same worktree (T63); a second death: finish by hand from LEDGER.md.
  • A surviving mutant gets a named follow-up on the row — never dropped.

## runbook · laya-hf-hosting.md

laya checkpoint hosting: org-private fine-tunes + the token path (T205)

When to reach for this: you are hosting or consuming a laya judge fine-tune for an internal machine fleet — the daemon's risk-gate model. One-page contract here; the code pins are src/hf_hosting.rs, src/judge_model.rs, and tests/no_secret_spill.rs.

The gating decision (already made)

A PRIVATE repo in the org's HF org: org-membership-gated, machines pull via a read-scoped HF_TOKEN. NOT HF's "gated" feature (public + approval workflow — wrong tool). Three artifact classes, three postures:

classwheregating
base laya (convaiinnovations/laya, Apache 2.0)public, upstreamnone — the chug default stays public so no public user hits an auth wall; mirroring to org/laya-base is OPTIONAL (availability pinning only)
stop-completion judge (tampajohn/…, trained on the operator's personal Claude Code transcripts)personal org todaymigrating it to the org's HF org is the operator's IP call — flagged, not decided here
F13 loop-decision fine-tunes (trained on chug decisions.jsonl)org-private from day onepublic-repo work is fine only while chug loops against public repos; against internal monorepos the logs encode internal structure/doctrine

Hosting decision — PENDING the operator's Monday 2026-10-05 call

NO org-side work (repo creation, membership, Vault tokens) happens before this. Ranked from the 2026-10-02 analysis:

  1. JFrog Artifactory HF repository — PREFERRED if available (the org runs JFrog; the HF repo type hosts models behind existing SSO/IAM; clients point HF_ENDPOINT at the Artifactory repo URL). VERIFY first: Artifactory version + HF repo type enabled. If present, it displaces the HF org.
  2. the org HF org private repo — works today, adds a second membership/token silo.
  3. Databricks Model Registry — REJECTED 2026-10-02: speaks ONLY the MLflow API; no HF-Hub-compatible endpoint exists; would mean a bespoke fetch backend.

Interim hosting (works today, no org steps): a LOCAL DIRECTORY (CHUG_LAYA_CHECKPOINT=<path>) or a PRIVATE tampajohn/* HF repo behind HF_TOKEN. New fine-tune repos are created PRIVATE at inception (contract below). The loop-side machinery in this runbook is required for the interim too — only the org steps wait.

Consumer config (the daemon's fetch path)

The judge daemon (T204) resolves its checkpoint from CHUG_LAYA_CHECKPOINT:

# local dir (interim; T204 req 2)
export CHUG_LAYA_CHECKPOINT="$HOME/models/laya/finetune/out"
# hub repo, pinned revision — REQUIRED SHAPE for policy-affecting artifacts
export CHUG_LAYA_CHECKPOINT="org/laya-stop-judge@9c6af39cdce45b570f0b7f8fad2b311c96019804"
export HF_TOKEN="<read-scoped-token-with-access-to-the-repo>"   # name only in this repo
# non-huggingface.co hosts (Artifactory or any HF-compatible endpoint):
export CHUG_HF_ENDPOINT="https://artifactory.example.com/hf"    # wins
export HF_ENDPOINT="https://artifactory.example.com/hf"         # fallback

Verified against hf-hub 0.4.3 (do not trust the crate to do this): it reads NEITHER HF_TOKEN from the env (only ~/.cache/huggingface/token, huggingface-cli login) NOR HF_ENDPOINT via Api::new(). chug applies both itself (hf_hosting::build_hub_api): CHUG_HF_ENDPOINT > HF_ENDPOINT > https://huggingface.co; a non-empty HF_TOKEN overrides the cached token file. Default stays public — public chug never requires a token.

Auth failure is honest: a 401/403 from a private repo produces ONE stderr line naming the fix — set HF_TOKEN to a read-scoped token with access to <repo> (missing) or HF_TOKEN is set but was rejected: check scope/expiry/membership (insufficient) — plus one judge_checkpoint_auth_error note in .chug/events.jsonl, then the daemon dies, the client latches, and the loop continues fail-open (T190 shape). No retry storm: one fetch attempt, max_retries=0.

loopd wiring (K7): the out-of-repo env file

The supervisor loads ONE env file at startup and every cycle (orchestrator, delegate children, spawned judge daemon) inherits the exports:

$HOME/.chug/loopd.env        # default; override with CHUG_LOOPD_ENV

Format: KEY=VALUE lines, # comments, optional export prefix and one pair of quotes. Values are LITERAL (no $() expansion — the file is parsed, never eval'd). ONLY three keys are applied — CHUG_LAYA_CHECKPOINT, HF_TOKEN, CHUG_HF_ENDPOINT — and only when the operator has not already exported them (explicit env wins). Rotation = edit the file + restart loopd (the T47 lesson: no env mutation inside the cycle loop).

Hygiene: the file lives OUTSIDE any repo (never committed), and its CONTENTS are never echoed or logged — loopd logs only the path and a skipped-line count. This is the hard rule from the operator's env-dump spill history; tests/no_secret_spill.rs pins the whole repo to the same rule (HF_TOKEN appears as a NAME, never a value).

Degrade: absent file → silent no-op (public base laya); unauthed daemon → the 401 line above + fail-open; the loop never stalls on the judge.

Publish contract (every org-bound fine-tune, before any consumer points at it)

  1. PRIVATE at creation — org-membership gating, not HF's "gated".
  2. Secret-scanned over the training corpus (gitleaks-class), scan result recorded in the model card. Hard gate, not advice.
  3. Revision-pinned by consumers — org/model@REV in every env file.
  4. Base laya mirroring to org/laya-base is OPTIONAL (availability pinning only).

Operator checklist — PENDING 2026-10-05, do NOT execute early

  1. Verify the Artifactory HF-repo option FIRST (version + repo type). If present it displaces the HF org.
  2. Else verify the org HF org exists (else create with IT).
  3. Create the private judge repo(s) — PRIVATE at inception.
  4. Set org membership / Artifactory perms (machines: read-scoped token only; humans: membership).
  5. Mint the read-scoped token INTO VAULT (never into this repo, never into .chug/*.json in git).
  6. Decide the stop-judge migration (personal-transcript-derived IP → org asset call).

Out of scope here: training/publishing the F13 fine-tunes (F13 phases), HF Enterprise/SSO, re-hosting base laya unless the mirror proves necessary.

## runbook · loop-ops.md

Runbook: loopd operations

Use when you run the continuous self-improvement loop — start it, read its state, stop it, recover from a HALT, clean up worktrees. Arc: a daemon (cycles of ~1–4 h each); the ops commands below are seconds.

Start / probe / status / stop

nohup ./loopd.sh > /dev/null 2>&1 &   # start (detached; plain ./loopd.sh = foreground)
./loopd.sh routing                    # what the NEXT cycle would run: mode + orchestrator model (launches nothing)
./loopd.sh status                     # liveness + recent activity + last cycle tail
./loopd.sh stop                       # graceful: touches .chug/STOP-LOOP, exits after the current cycle

State lives in gitignored .chug/loopd/: loopd.pid, loopd.log (supervisor events — routing decisions, build gate, verdicts), cycle-<UTC-timestamp>.log (one per cycle; raw orchestrator and child output), and HALTED when it gave up.

HALT recovery

Two triggers write .chug/loopd/HALTED and exit 1: 3 consecutive build failures (launching a stale binary is refused) and 3 consecutive cycles without goal complete.

cat .chug/loopd/HALTED                        # names the trigger + the last cycle log
tail -30 .chug/loopd/loopd.log                # the failures leading up to it
cargo build --release                         # build trigger: fix the tree first
grep -c "verdict: no goal complete" .chug/loopd/cycle-*.log   # cycle trigger: read the last cycle log
nohup ./loopd.sh > /dev/null 2>&1 &           # restart — startup clears the HALTED marker

A restart re-runs the release build gate; a still-broken tree halts again after three tries, so fix before restarting.

Worktree cleanup

Children work in /tmp/chug-loop-t<N> worktrees. git worktree remove deletes a worktree's untracked .chug/ silently — harvest first:

ls -d /tmp/chug-loop-t*                       # what exists
cp /tmp/chug-loop-t<N>/.chug/events.jsonl .chug/events-t<N>-impl-$(date -u +%Y%m%d-%H%M%S).jsonl
cp /tmp/chug-loop-t<N>/LEDGER.md .chug/LEDGER-t<N>-impl-$(date -u +%Y%m%d-%H%M%S).md
git worktree remove /tmp/chug-loop-t<N>       # then `git worktree prune` for stale rows
LOOP_REAPER_DRY_RUN=1 scripts/orphan-reaper.sh   # list leftover loop processes; kills nothing

The reaper also runs automatically before every cycle (SIGTERM only, fail-closed); LOOP_REAPER=0 opts out.

The judge daemon (T204/T215)

The risk gate's judge (CHUG_JUDGE=daemon, the default) is a host-scoped daemon: one per box, serving every run over ~/.chug/daemon.sock. On loop hosts it comes from the installed release binary — the release workflow builds --features daemon into ~/.local/bin/chug. The repo dev builds are CLIENTS ONLY (T204 keeps them feature-lean): their daemon subcommand is the fail-open stub, so never point the ensure at a repo build.

loopd.sh resolves the daemon binary ONCE per run (one startup line in .chug/loopd/loopd.log) and ensures it at every cycle start, best-effort:

  1. $CHUG_DAEMON_BIN — explicit override (wins when executable);
  2. ~/.local/bin/chug — when chug daemon --help exits 0 (a pre-T204 release refuses the subcommand: the dogfood upgrade hasn't landed — upgrade the install; loopd never self-upgrades);
  3. the repo release build — only when it hosts the judge (never loopd's own feature-lean build);

else the ensure is skipped for the whole run behind that one log line (fail-open: the judge client degrades per command exactly as it did when layad was down). LOOP_DAEMON_ENSURE=0 opts out entirely.

First run — pre-warm the weights (the pinned remedy, T215): the daemon loads the ~650 MB checkpoint BEFORE the socket binds, and the ensure's wait budget stays bounded, so a cold first load exceeds it: the first cycle runs fail-open while the detached daemon finishes downloading, and later cycles find it warm. To pay the download outside a cycle, pre-warm once:

~/.local/bin/chug daemon      # foreground; Ctrl-C after "judge model warm"

The HF cache then serves every later spawn in seconds. chug daemon --status reports running/starting/absent; chug daemon --stop stops the lock holder. Diagnostics: ~/.chug/daemon.log.

## runbook · quick-task.md

Runbook: one small task, zero setup

Use when you have a single chore — a failing test, a missing helper, a rename — and don't want to write a spec by hand. Arc: ~5–20 minutes. Headless only (for interactive use, chug chat).

Before you start: the chug binary on PATH (cargo install --path . from a checkout), model credentials in the env (ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN, or the ~/.claude/settings.json fallback), and your shell sitting in the repo you want changed.

Run it

chug quick --goal "<goal>" --model anthropic-system.ai.kimi-k3 \
  --max-iters 40 --max-minutes 60

What happens (T188): chug drafts the spec for you — one read-only plan session writes .chug/auto-spec.md (concern, requirements, tests, acceptance, check:, estimate:) — then dry-runs the draft's check: line. A check that can't pass on the current tree is refused and redrafted once; a second refusal aborts with the draft and the failing output. The check is never loosened to pass.

Budget flags (all optional; defaults 40 iters / 120 min / unlimited tokens): --max-iters 40 --max-minutes 60 --max-tokens 2000000 are all real values you can pass. Validation lane (T189): small diffs run gates-only by default — the adversarial-validation child is skipped, the gates are not. Override for this run: --validate forces full validation, --no-validate forces gates-only; either is recorded as an operator decision.

What you get

  • LEDGER.md — the model's external memory, ## Done / ## Next / ## Blockers; chug ledger prints it anytime.
  • .chug/transcript.jsonl — every message, append-only.
  • .chug/events.jsonl — the forensics surface, jq-mineable: jq -r '.type' .chug/events.jsonl | sort | uniq -c
  • Exit 0 = goal accepted (stdout carries a chug: goal complete block: summary: …, token cost, then the ledger dump). Exit 1 = budget or abort — stderr says chug: abort: <reason>, and stdout ends with a ready-to-paste resume: chug run … --resume hint. Exit 2 = stuck (repeated errors) — read the ledger and the transcript tail.

If it dies at budget (T63)

Same directory, ONE resume attempt:

chug run --auto-spec --resume --goal "<goal>"

--resume reloads .chug/transcript.jsonl and continues where it died; with --auto-spec it reuses the existing draft, never redrafts. Note the command: quick has no --resume, so the resume path is run. If the resume also dies at budget, stop resuming — read LEDGER.md; the work is usually complete-but-uncommitted, so finish the last gate by hand and commit.

## runbook · repo-eval.md

Runbook: feasibility eval of an external repo

Use when you want to know whether a loop harness can drive some other repository before committing one to it: build system, test gates, layout, and what would trip the harness up. This is the internal-monorepo pattern. Arc: ~30–90 minutes.

1. Clone, then aim chug at the clone

--cwd is the whole sandbox — every file/bash tool lands inside it — so the eval reads the external repo and writes its deliverable there, never touching your own checkout:

git clone --depth 1 https://github.com/owner/repo /tmp/eval-target
chug run --spec eval-spec.md \
  --goal "Evaluate this repo for loop-driven work per the spec; write CHUG-FEASIBILITY.md; change no file but it" \
  --cwd /tmp/eval-target \
  --model anthropic-system.ai.kimi-k3 --max-iters 40 --max-minutes 60

The eval spec is ~15 lines, written by hand in the repo that runs chug: requirement 1 = produce the deliverable; a non-negotiation = no writes outside it; tests = the deliverable names the build system, the test command, and measured gate cost. The check: gates the deliverable's existence and verdict line:

check: test -f CHUG-FEASIBILITY.md && grep -q '^verdict:' CHUG-FEASIBILITY.md

estimate: ~1 changed line (the deliverable)

2. Deliverable and verdict format

One file, first line machine-greppable:

verdict: FEASIBLE
blockers: none            # or the named gaps, each with evidence
build: <command + observed wall-clock>
test gate: <command + pass count + wall-clock>
layout: <where things live, one screenful>
risks: <what a loop would trip on — cold build times, flaky gates, ...>

FEASIBLE means a loop could run here with a sane cycle budget; NOT-FEASIBLE names the blockers precisely. Skim .chug/events.jsonl in the clone (jq -r '.type' .chug/events.jsonl | sort | uniq -c) to see where the eval's time actually went.

3. If FEASIBLE

One loop per repo is the repo-level lever (the dashboard/internal-monorepo pattern): give the repo its own TODO.md, specs/, and ./loopd.sh — don't merge it into another repo's cycle.

## risk gate · docs/risk-gate.md

Why it's safe to let the loop write code

The question this page answers is the one every engineering-leadership review asks first: what stops it from doing something bad? The answer here is not a promise. It is an inventory of mechanisms that already run, each cited by the file, feature id, or gate name that implements it — follow any citation to its source; the repo is public. Where a mechanism has a known hole (a fail-open leg, a lane that skips review), the hole is named next to the citation, because the reviewer looking for it will find it anyway.

This file is the source of truth; scripts/site-sync.sh renders it as a section of the docs page at every sync (T331, the T241 docs-page pipeline), and the adopt page's safety FAQ (docs/adopt/faq.md) links that section.

The gates

What runs on loop-written code before it lands. The implementation child is launched with "keep cargo build and cargo test green" in its goal text (the META-SPEC.md §6 round-protocol template), and the gates below are then re-run independently — "never trust a claim of green without seeing it" (LOOP-SPEC.md step 3).

GateCommandWhen
Full suitecargo nextest run --release when cargo nextest is on PATH, else cargo test --release -- --test-threads=4 — the T82 gate runner, whose fallback is unconditional (nextest is a host tool, never a hard dependency)every item's worktree (LOOP-SPEC.md step 3), again post-merge (step 5)
Lintcargo clippy --all-targets --release -- -D warningsbeside the suite, never through it (LOOP-SPEC.md step 3)
Python batterypython3 -m unittest scripts/test_wrap_assert.py and python3 -m unittest scripts.test_todo_flip — the unittest batteries behind scripts/wrap_assert.py (T273) and scripts/todo_flip.py (T279)each script's own check line; re-run beside the cargo gates on landing (the T289 row records "gates independently re-run python 56/56")
TODO row guardcargo test --release --test todo_consistencyafter every TODO.md edit (tests/todo_consistency.rs; the row-flip path itself goes through scripts/todo_flip.py, which asserts the row invariants before writing — the three-fire todo-flip census, LOOP-SPEC.md)
Docs-only floorthe same todo_consistency run, plus the affected pin file's testswhen the diff is *.md-only — the T80 classification is mechanical (git diff --name-only main...<branch> | grep -qvE '\.md$'), and any ambiguity defaults to full gates

Two properties of the lint leg are load-bearing, not incidental:

  • Zero warnings, not exit-0. nextest compiles cfg(test) code but never lints it, so a narrower clippy form lets test-only warnings through — the T176 semantics that define the bar (LOOP-SPEC.md step 3).
  • Release profile. The gates run --release (T78): the first build into a cold cache pays compile time, every later run is faster — the shared target dirs (T47/T52) amortize it.

What "green" means

  • Unpiped exits. A gate run is unpiped, or the chain begins set -o pipefail; — a piped gate whose filter exits 0 reports green on a red guard (the c06a555 lesson, LOOP-SPEC.md's todo_consistency rule).
  • Full-suite counts only. The public test count on chug.sh is parsed from commit messages by scripts/site-sync.sh, which accepts only provably-full-suite shapes — an equal-operand N/N pair at or above the 500 floor, or a "full suite N unit" label adjacent to the number. The T238 rule exists because a mid-run census ("nextest 113/1402") was once published as if it were the suite total.
  • Fail-closed publishing. The same sync refuses to publish anything when its repo inputs are unreadable — TODO.md missing, .chug/loopd absent, or empty git log is one named error and exit 4, nothing written (the T217 letter, scripts/site-sync.sh). Fallback zeros are byte-identical to a genuinely empty repo's first run, so they are never published with real data's authority.
  • Pins, not prose. Doctrine text is pinned by test files — tests/loop_spec_*.rs, tests/shared_target_dir.rs, tests/nextest_gate_runner.rs — so an edit that breaks a pinned clause goes red in the suite, not just in review (the T80 floor names them because that is the risk surface of a docs-only diff).

The validators

The author model never validates its own work. Implementation children run on glm; validation children run on kimi — different model families (META-SPEC.md §6) — and a glm-orchestrated cycle still launches the kimi validator (the T81 family-independence rule, LOOP-SPEC.md step 4: "glm implements, so a glm-orchestrated cycle never lets glm validate glm").

  • Adversarial validation (META-SPEC.md §6 step 6): the validator child reviews the diff against the spec for correctness bugs, missing spec requirements, and weak tests, and must end with a typed verdict — VERDICT: PASS or VERDICT: FAIL plus a numbered findings list. It writes the verdict to .chug/verdict.md in its worktree BEFORE any wrap-up, so a budget death loses nothing (the T209 doctrine: a written verdict IS the verdict). PASS merges; FAIL feeds the findings into the fix-up child's goal verbatim.
  • Mutation testing (META-SPEC.md §6 goal text): the validator deliberately breaks the new code — flip a condition, drop a check, corrupt a value — and confirms the tests catch it, because "green tests that survive mutations are vacuous (round 1 shipped dead code with 245/245 green until mutations exposed it)". Mutants run in parallel throwaway worktrees, one role-keyed target dir per leg, capped at 3 in flight; serial stays the default when mutants touch overlapping files; the main worktree must be byte-clean before the verdict (T79, META-SPEC.md §6).
  • RED-proven fixes. A fix-up round's killing test must be shown RED against the broken code, not asserted after the fact — and when a finding names one instance of a class, the goal requires EVERY instance swept with its own RED-proven killing test (the cycle-33 lesson: T69's run_start latch resets took three rounds one leg at a time; the sweep-the-family goal closed it in one — LOOP-SPEC.md step 4). Mutation legs for RED-proofs are applied inside the worktree via bash, because the confined file tools would silently produce false survivors (LOOP-SPEC.md step 4).
  • Survivor adjudication. A surviving mutant is a finding, not a shrug: the verdict record logs PASS/FAIL, findings count, and survivor count to the decision corpus (.chug/decisions.jsonl, classes validation-routing / validation-verdict — LOOP-SPEC.md step 4), and survivors kept as weak-test findings get named individually in the landing record (e.g. the T316 row: "6 mutants 4 killed, 2 low-impact survivors ... documented as weak-test findings").
  • The lane, and what it skips. Validation is REQUIRED for any item touching src/driver.rs, src/api.rs, src/tools.rs, src/events.rs, or the loop/spec doctrine. The low-stakes lane (T189) can skip the validator child — but the predicate is mechanical, computed from the diff and never the model's say-so: no core-list file, ≤ ~150 changed lines, no new tool/command surface, no CI or check: line change; any single flip forces full validation, and the lane skips the kimi child, never the gates (LOOP-SPEC.md step 4).

The decision gate

Consequential actions pass typed verdicts before they execute — the Laya/Jev precedent (F13/F15):

  • The runtime risk gate. Every bash command is classified destructive/risky/safe by a Laya judge before executing; destructive p≥0.5 is blocked with an error the model can see and route around; verdicts are logged to .chug/risk_verdicts.jsonl (README.md, ## Risk gate (--risk-gate); src/riskgate.rs). The hole, stated: the gate fails OPEN when the judge is down, and an allow destructive steering note disables it for the run — both pinned in that README section, which is why the policy layers below it exist.
  • The policy layers under it. .chug/permissions.json deny rules are evaluated in-process before every tool call: a rule match fails closed (it always denies), while a malformed rule is skipped with a warning (README.md, ## Permissions (.chug/permissions.json)). .chug/hooks.json PreToolUse hooks veto with [hook veto] — programmable, and therefore fail-open (README.md, ## Hooks (.chug/hooks.json)). Policy order is permissions → hooks → risk gate; a denied call never executes.
  • The judge itself is contested, not trusted. The T223 bake-off (docs/judge-parity.md, run by the fail-closed scripts/judge-parity.sh) measured Laya against the kev-0.8b and openJev-verdict-2.0 challengers over golden fixtures and a decision-log holdout; the recorded verdict is "Laya stays" with the honest gaps named — kev is candle-blocked (T222) and openJev's id returns 401 — rather than a fabricated comparison.
  • The baked-in judge daemon (F15): CHUG_JUDGE=daemon serves the same model over a 0600 unix socket at ~/.chug/daemon.sock — no TCP port, no network listener; filesystem permissions gate the policy surface (FEATURES.md F15, src/daemon.rs).
  • The decision-log corpus as evidence (F13): every loop judgment emits a structured record to .chug/decisions.jsonl — decision class, compact inputs, options considered, choice, model, confidence — with outcome labels backfilled from git (landed-clean / fixed-up / reverted). The triage layer (T259) records every would-be-launch classification the same way (class laya-triage, plus the backfilled outcome), so "the loop decided correctly" is a queryable corpus, not an anecdote.
  • The goal gate. A run ends when the spec's check: line — re-run by goal_complete verification — passes, never when a model claims done (src/driver.rs: "the spec's check: line still decides DONE"; LOOP-SPEC.md's check-line doctrine, including the T67 class: a spec check: line IS executable text and gets validated like code).

The cost guardrails

The loop cannot spend unboundedly while idle. Three mechanisms, all supervisor-computed from git and .chug/loopd/loopd.log — never from an LLM's say-so (LOOP-SPEC.md):

  • The cheap exit (T258). Before any launch the supervisor computes a mechanical predicate: no new TODO.md rows since the last evaluation, no child deaths, a bookkeeping-only delta (every commit an eval: commit touching nothing outside EVALUATION.md and TODO.md), and EVALUATION.md fresh (same UTC day). When all four hold it writes a one-line disposition and skips the cycle entirely — no LLM call. The disposition records the predicate inputs in .chug/loopd/loopd.log.
  • The valve (T247). The empty-delta chain is not self-sustaining: after ~3 consecutive empty-delta dispositions, the 4th empty cycle runs the real evaluation. The trip binds on the TRUE streak — human-counted from the wrap-notes chain for adjudication, machine-read (empty_wrap_streak, loopd's git walk) for the supervisor's gate — and the cycle-118 divergence (machine read 4 vs TRUE 3) is the recorded reason both readings exist (LOOP-SPEC.md, "The empty-delta chain (T247)").
  • Dormancy (T325). With an empty queue the loop is DORMANT: the cheap exit fires every cycle, the valve is suspended, and the weekly audit timer launches one READ-ONLY evaluation per week at most — gates green (build, clippy, test), pins verified, site-sync freshness, daemon liveness. It files TODO.md rows only on observed breakage, exactly one row each, zero on green, and MUST NOT file loop-tooling meta-work — "an empty backlog must make the loop nearly free; it must never make the loop invent meta-work" (LOOP-SPEC.md, "Dormant mode (T325)"; tests/loopd_dormant_mode.rs pins the battery).
  • Bounded children. Impl children launch at --max-iters 40 --max-minutes 35 (META-SPEC.md §6 step 4); validators at 60/50 — the LOOP-SPEC.md step-4 override, raised after 4 of 4 validator children died at budget in cycles 66–69. A wedge dies at budget, and the T237 backoff paces the skipped-eval chain. The T259 triage sits between the mechanical layer and System Two, fail-open to the T258 routing, with its one threshold (TRIAGE_HIGH 0.85) in one place in loopd.sh.

The history

The repo is public, and it has already failed this review once.

  • The 2026-10 scrub. On 2026-10-06 the operator reported "safety concerns (internal info shared about the org) in the repo, let's clean that up" — an internal proxy hostname in src comments and a spec, org HF-org names, org-private/fleet framings, and internal codenames across specs, runbooks, TODO, DEPENDENCIES, and test fixtures. The redaction pass landed as commit 47cd0d1 (specs/t249-internal-info-lint.md records the derivation).
  • The standing guard. tests/internal_info_lint.rs (T249) walks every tracked file (git ls-files) line by line against seven word-bounded pattern classes derived from that diff; any hit fails the suite, so the class cannot regrow through loop-authored content. The lint's own source composes its literals from pieces at runtime, so no tracked line carries a whole redaction literal. The site sync runs the same pattern classes over the composed adopt page before it may publish — a hit blocks the render and the previously published page rides (t249_scan in scripts/site-sync.sh, T329).
  • The secrets sibling. tests/no_secret_spill.rs (T205 req 5) is the credential-side twin of the same doctrine.

What this page does not claim

  • The risk gate is not a sandbox: it classifies and blocks, and fails open when the judge is down (README.md, ## Risk gate (--risk-gate)). The cwd confinement of the file tools (README.md, "All file-tool paths are sandboxed to --cwd") and the deny-rule layer above are the structural bounds; the gate is one policy source among several.
  • The low-stakes lane really does skip the kimi validator for small, non-core diffs (T189) — the citation above names the exact mechanical predicate, so the reviewer can audit what "small" means rather than trust it.
  • Fail-open and fail-closed are mixed deliberately, per mechanism, and the polarity is pinned per mechanism (permissions fail closed on a match, hooks fail open on a config problem — the two README.md sections cited above). The claim is not "nothing can fail"; it is that each failure mode is named, cited, and tested where this page says it is.

## shipped · TODO.md done rows

Shipped — the complete record

Every item the loop has flipped done (359 items), newest first — auto-fed from TODO.md at every sync. The curated feature grid on the home page is the flagship list; this feed is the complete shipped record.

## cost · Langfuse daily spend, chug project — baked at sync time by scripts/site-sync.sh

datecallskimiglmtotal
2026-11-18131$3.44$0.00$3.44
2026-11-1418$0.00$0.06$0.06
2026-11-112052$15.92$1.16$17.08
2026-11-106751$16.01$7.61$23.63
2026-11-099870$28.15$9.02$37.18
2026-11-087980$0.53$13.04$13.57
2026-11-076259$15.42$4.89$20.31
2026-11-065660$76.17$2.53$78.70
2026-11-054296$109.73$0.24$109.97
2026-11-041249$26.86$0.15$27.02