Skip to content

fix(loop): stop losing worker lineage, orphaned leases and follow-throughs - #777

Merged
huichen merged 2 commits into
mainfrom
fix/loop-parent-guard
Sep 22, 2026
Merged

huichen merged 2 commits into
mainfrom
fix/loop-parent-guard

Conversation

@huichen

@huichen huichen commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Three defects found by reading back what an orchestration session actually produced, rather than what it reported at the time. Each has a test that fails without it, and each was also walked by hand through the real CLI in an isolated loop root.

Worker sessions were minted with no parent conversation

loop run writes a worker's parent_session_id once at creation, and nothing reparents it later. So a worker dispatched before the goal had a supervisor session registered is a root conversation forever — the session tree shows it beside the goal it belongs to instead of under it, and no retry repairs that.

In practice one goal's twelve workers all came out parentless because supervisor register was skipped at setup, while three sibling goals — registered right after goal init — had every worker attached. Two places now say so:

  • loop run warns on stderr where the session is minted, naming the command that fixes it and stating it cannot be reparented later. That lands in the dispatch log, which is where a supervisor looks after launching.
  • loop status prints a ⚠ supervisor: none registered line next to next, so the gap is visible before dispatching rather than after.

Warned rather than refused on purpose: a supervisor-less goal is a mode the loop supports (the worker runs, its reports are simply not pushed), and a hard stop would forbid a documented mode to protect a metadata field. A first version did refuse — agent_run_drive::run_without_supervisor_sends_no_report and 16 other tests failed on it, which is what settled the question.

worker stop left the stopped worker's leases behind

An aborted worker can neither renew nor complete its claim, so the todo stayed "in progress" for the rest of its TTL — up to hours — blocking every peer: the workspace guard refuses to hand those paths to anyone else, and only the owner may release, the owner being the worker just stopped.

Leases are now released for the agents whose abort actually landed, including the case with no live session at all ("nothing to stop" used to return before the lease was even considered). An abort that did not land (agent unreachable) releases nothing: that worker may still be mid-turn, and its lease is exactly what keeps a second agent off the same todo until the TTL lapses.

A side effect worth noting: clearing the claim also stops those todos from being reported as host_died.

Resolving a delivery did not close the follow-through todo it spawned

Each delivery left unverified past the threshold mints a coordination todo ("verify the delivery of X"). Recording the outcome is that verification — the operator action its text names — but nothing completed the todo.

On a finished goal seven of them stayed open, so closure_proof.all_todos_done never held and the goal could not reach terminal closure: bookkeeping nobody could satisfy. Recording verified / failed / rework now closes it, with the delivery as evidence. A fresh delivered does not — that starts a new cycle.

Docs: --blocks direction

--blocks T was documented as "blocking todo ids", which reads both ways and was taken the wrong way twice in one session: --blocks A means A blocks this todo, but the phrasing invites the opposite reading. The reversed edge then has to be untangled — once after it formed a dependency cycle that the update refused. The detail column now states the direction outright.

Verification

  • cargo test -p future-loop: 1003 passed, 0 failed across 69 test binaries.
  • cargo fmt -p future-loop --check and cargo clippy -p future-loop --all-targets -- -D warnings: clean.
  • Each fix's test was checked to fail without it (by disabling the change and watching the assertion go red; for the lease case it prints the exact observed symptom, the claim came back: Some("worker-a")).
  • No public API changes: the modified functions are private to console.rs.

Withdrawn claim

An earlier report from the same session said todo add --verify never persists its validator. It does — 143 of 261 todos across the goals in this repo carry one. The earlier reading had picked up the wrong todo_added record (the onboarding todo goal init adds, which has no validator). Nothing was changed for it; recorded here so the finding is not repeated.

…oughs

Three defects found by reading back what an orchestration session actually
produced, rather than what it reported at the time.

Worker sessions were minted with no parent conversation. `loop run` writes a
worker's `parent_session_id` once, at creation, and nothing reparents it later,
so a worker dispatched before the goal had a supervisor session registered is a
root conversation forever. In practice one goal's twelve workers all came out
parentless because `supervisor register` was skipped at setup, while three
sibling goals — registered right after `goal init` — had every worker attached.
Two things now say so:

- `loop run` warns on stderr, right where the session is minted, naming the
  command that fixes it and saying the session cannot be reparented later. It
  lands in the dispatch log, which is where a supervisor looks after launching.
- `loop status` prints a `⚠ supervisor: none registered` line next to `next`,
  so the gap is visible before dispatching rather than after.

Warned rather than refused on purpose: a supervisor-less goal is a mode the loop
supports (`agent_run_drive::run_without_supervisor_sends_no_report` asserts it —
the worker runs and its reports are simply not pushed), so a hard stop would
forbid a documented mode to protect a metadata field. (A first version did
refuse; it failed that test and 16 others, which is what settled the question.)

`worker stop` left the stopped worker's leases behind. A worker that was aborted
can neither renew nor complete its claim, so the todo stayed "in progress" for
the rest of its TTL — up to hours — blocking every peer: the workspace guard
refuses to hand those paths to anyone else ("retry after the holder releases its
lease") and only the owner may release, the owner being the worker just stopped.
Leases are now released for the agents whose abort actually landed, including the
case with no live session at all ("nothing to stop" used to return before the
lease was even considered). An abort that did *not* land releases nothing: that
worker may still be mid-turn, and its lease is exactly what keeps a second agent
off the same todo until the TTL lapses.

Releasing a delivery did not close the follow-through todo it spawned. Each
delivery left unverified past the threshold mints a coordination todo ("verify
the delivery of X"); recording the outcome IS that verification — the operator
action its text names — but nothing completed the todo. On a finished goal seven
of them stayed open, so `closure_proof.all_todos_done` never held and the goal
could not reach terminal closure: bookkeeping nobody could satisfy. Recording `verified` / `failed` / `rework` now closes it with the delivery as
evidence. A fresh `delivered` does not — that starts a new cycle.

Each fix has a test that fails without it (checked by disabling the change and
watching the assertion go red, which for the lease case prints the exact symptom:
`the claim came back: Some("worker-a")`). Verified: 1003 future-loop tests pass
across 69 test binaries, rustfmt and clippy (`--all-targets -D warnings`) are
clean, and the three paths were also walked by hand through the real CLI in an
isolated loop root.

One claim from that session is withdrawn: I reported that `todo add --verify`
never persists its validator. It does — 143 of 261 todos across the goals in this
repo carry one. I had read the wrong `todo_added` record (the onboarding todo
that `goal init` adds, which has no validator). Nothing was changed for it.
"blocking todo ids" reads both ways, and I took it the wrong way twice in one
session: `--blocks A` means A blocks *this* todo, but the phrasing invites the
opposite reading, and the reversed edge then has to be untangled (`todo update
--blocks ""` to clear it) — once after it formed a dependency cycle that the
update refused.

The detail column now states the direction outright.
@huichen
huichen enabled auto-merge (squash) September 22, 2026 09:23
@huichen
huichen merged commit a32aaea into main Sep 22, 2026
12 checks passed
@huichen
huichen deleted the fix/loop-parent-guard branch September 22, 2026 09:27
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