Skip to content

feat: loops — repair runs verified by the daemon's own checks - #426

Merged
saucam merged 2 commits into
mainfrom
feat/loops
Oct 25, 2026
Merged

saucam merged 2 commits into
mainfrom
feat/loops

Conversation

@saucam

@saucam saucam commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

What

A loop pursues one objective until the daemon's own checks pass, then delivers the result as one commit on its own branch.
The worker agent never decides it is done: loop_report only asks for verification; the daemon snapshots the candidate, runs every check itself, records the evidence, and commits exactly the tree it verified.

codeoid loop start "Fix the failing checkout test" --workdir ~/src/shop --check "bun test src/checkout" --test --wait

User guide: docs/loops.md. Design: docs/loop-engineering-design.md.

How

  • Controller (src/daemon/loops/service.ts): compare-and-set transitions, attempts scheduled only through the dispatcher, pause / resume / steer / cancel, restart reconciliation, attempt and time budgets (daemon downtime and approval waits are not charged), a takeover prompt for replacement workers.
  • Verification (host.ts, materialize.ts):
    • The candidate is the run's base with the worktree laid over it; secret-looking files are withheld and setup's files excluded.
    • It is written out from hash-verified git objects into a daemon-made check directory, prepared once by the trusted setup recipe on the committed base, then sealed.
    • Every check runs in a fresh copy of the sealed directory at the same path, and whatever a check or setup leaves running is reaped before the next.
    • Delivery is one commit on the base holding the verified tree.
  • Hardening: every daemon git call is pinned to the run's repository (GIT_DIR / GIT_COMMON_DIR / GIT_WORK_TREE), with hooks, filter drivers, fsmonitor, replace refs and network off, and gets an agent's environment, never the daemon's credentials (git-env.ts, also adopted by forks, setup, fleet and packs). No session but the run's worker can get a working directory in its worktree (create, fork, import, dispatch, routines, pipelines, skill grants).
  • Surfaces: codeoid loop … CLI, web loops panel and run detail, TUI /loop and /loops, protocol loop.* messages with schemas.

Known limits (documented)

  • The worker and the checks run as the user, unsandboxed; reaping is best-effort (Linux), not a sandbox.
  • Repositories with files stored through a configured git filter (Git LFS, git-crypt) are refused; checkout conversions (eol, working-tree-encoding) aren't applied in the check directory.
  • Protected inputs, hidden checks and cannot_satisfy verification are the next milestone.

Review

Audited over 16 rounds by independent security and correctness reviewers until neither found anything significant; every finding has a regression test (src/daemon/loops/*.test.ts, src/tests/loops-e2e.test.ts, src/tests/git-env.test.ts, src/tests/kill-marked.test.ts).
Full suite: 4161 pass / 0 fail; web 732 pass.

Follow-up stacked on this: loop watches (CI-failure and review-comment triggers).

🤖 Generated with Claude Code

…red as one commit

A loop pursues one objective until the daemon's own checks pass, then
hands the result over as a commit on its own branch. The worker agent
never decides it is done: its loop_report tool only asks for
verification; the daemon snapshots the candidate, runs every check
itself, records the evidence, and commits exactly the tree it verified.

- LoopService: a controller with compare-and-set transitions, attempts
  scheduled only through the dispatcher, pause/resume/steer/cancel,
  restart reconciliation, time and attempt budgets (downtime and approval
  waits uncharged), and a takeover prompt for replacement workers.
- Verification: the candidate is the run's base with the worktree laid
  over it (secret-looking files withheld, setup files excluded); it is
  written out from hash-verified objects into a daemon-made check
  directory, prepared once by the trusted setup recipe on the base and
  sealed, and every check runs in a fresh copy of it at the same path;
  what a check or setup leaves running is reaped.
- Hardening: every daemon git runs pinned to the run's repository, with
  hooks, filters, fsmonitor, replace refs and network off and never the
  daemon's credentials; no session but the run's worker can get a working
  directory in its worktree.
- Surfaces: codeoid loop start|ls|show|cancel|pause|resume|steer, web
  loops panel and run detail, TUI /loop and /loops, protocol loop.*
  messages, docs/loops.md.

Audited over 16 security and correctness rounds; each finding has a
regression test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@saucam
saucam merged commit 8e62967 into main Oct 25, 2026
5 of 6 checks passed
@saucam
saucam deleted the feat/loops branch October 25, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants