Skip to content

refactor(runner, run_ledger): split the ledger loop into steps, no behaviour change - #62

Merged
blockmandev merged 3 commits into
mainfrom
refactor/runner-ledger
Oct 23, 2026
Merged

blockmandev merged 3 commits into
mainfrom
refactor/runner-ledger

Conversation

@blockmandev

Copy link
Copy Markdown
Member

Answers code-auditor findings 79ce9b9f808ee2a9, 7d477b9f9a609a95, ced02a72539a97d3, 79fed3ed553bd1f3 (runner.rs) and 12bc90cd8e17bb58, fcb5e284ad185b32, dc399e1d872b2641 (run_ledger.rs). No behaviour change.

What moved

src/runner.rs (4322 lines) is now src/runner/, with every crate::runner:: path re-exported unchanged:

file lines holds
mod.rs 219 the run → run_watched ladder, unanswered_questions, re-exports
ledger_loop.rs 324 work_the_ledger as a LedgerLoop (the state carried between rounds) whose round is named steps: cancel, budget, lanes, pick, drained, claim
escalation.rs 195 a task nobody can check, put to the owner, and what each verdict may do
attempt.rs 250 one attempt, then verify::verify decides: passed / failed / learn-and-replan
lanes.rs 431 run_lanes_if_useful as four steps (batch_worth_running, landing_for, settle_lane, remember_unmerged)
goals.rs, seams.rs, briefing.rs, stop.rs 130–312 moved verbatim
tests.rs, lane_tests.rs, owner_tests.rs, attribution_tests.rs 392–984 the existing tests, names unchanged

cli::run_ledger::run (324 lines, cc 29) is split into ledger_for_run/may_start, RunAgents::resolve, RunBackends (build, planner, into_worker), plan_ledger, LiveReplanner::for_run, CliLaneWorkers::for_run; the lane workers and their test move to cli/run_ledger/lanes.rs. Side effects keep their order.

The gate

The only edge into Done is still LedgerLoop::passed, reached only with a Verified from verify::verify (exit zero). The worker's report stays a labelled claim.

Evidence

  • Auditor static check: no function over 100 lines (largest: run_ledger::run, 91), no complexity over 20, no file over 1000; only fan-out remains.
  • 9 new tests. Four go through the public run API and also pass on the pre-split runner.rs (checked on fedb944): the last owner answer rides the next card; spend is ranked heaviest-first, ties by name, idle agents left out; a declining pool leaves the run sequential; lanes asked for review on a branch ahead of origin are merged here and the forge is never asked. Five unit tests cover the extracted helpers.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test: lib 2289 passed / 10 ignored (was 2280 / 10 on fedb944); the wiring ratchet holds.
  • #[allow(clippy::too_many_arguments)]: 3 → 1. The one left is on the existing public run_watched.

Co-Authored-By: Claude noreply@anthropic.com

blockmandev and others added 3 commits October 23, 2026 11:48
…haviour change

runner.rs (4322 lines) becomes src/runner/: the loop and its state
(ledger_loop), the owner escalation (escalation), one attempt and its
check (attempt), lanes, goals, seams, briefing and stop, re-exported so
every crate::runner:: path is unchanged. work_the_ledger is a LedgerLoop
whose rounds are named steps; run_lanes_if_useful is four steps.

cli::run_ledger::run is split into preflight, agent resolution, backends,
planning and worker steps; the lane workers move to run_ledger/lanes.rs.

The only edge into Done is still verify::verify exiting zero.

Co-Authored-By: Claude <noreply@anthropic.com>
…n API

The last owner answer riding the next card, spend ranked heaviest-first
with ties by name and idle agents left out, a pool that declines leaving
the run sequential, and lanes asked for review on a branch ahead of origin
being merged here without the forge being asked. Each also passes on the
pre-split runner.rs.

Co-Authored-By: Claude <noreply@anthropic.com>
…heir items

Comments only, from the independent review of #62. The split left four
comments describing the old single file: attempt.rs said the two failure
exits were arms "several hundred lines apart" (both now go through
LedgerLoop::failed), lanes.rs pointed at "the sequential loop below" and
ledger_loop.rs at "the push site", and lanes.rs/goals.rs linked
OwnerChannel, RoadmapGoals and WorkJournal by names those modules do not
import. Four were wrong before the split and moved with it: goals.rs
linked a non-existent unreached_goals, seams.rs a non-existent
run_with_replans, NoOwner's description sat on MAX_REPLANS, and
TaskWorker's sat on Handoff in briefing.rs. Each now names what it means.
@blockmandev
blockmandev merged commit d9ff92d into main Oct 23, 2026
12 checks passed
@blockmandev
blockmandev deleted the refactor/runner-ledger branch November 15, 2026 20:29
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.

1 participant