Repository navigation
fix(loop): stop losing worker lineage, orphaned leases and follow-throughs - #777
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 runwrites a worker'sparent_session_idonce 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 registerwas skipped at setup, while three sibling goals — registered right aftergoal init— had every worker attached. Two places now say so:loop runwarns 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 statusprints a⚠ supervisor: none registeredline next tonext, 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_reportand 16 other tests failed on it, which is what settled the question.worker stopleft the stopped worker's leases behindAn 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_donenever held and the goal could not reach terminal closure: bookkeeping nobody could satisfy. Recordingverified/failed/reworknow closes it, with the delivery as evidence. A freshdelivereddoes not — that starts a new cycle.Docs:
--blocksdirection--blocks Twas documented as "blocking todo ids", which reads both ways and was taken the wrong way twice in one session:--blocks Ameans 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 --checkandcargo clippy -p future-loop --all-targets -- -D warnings: clean.the claim came back: Some("worker-a")).console.rs.Withdrawn claim
An earlier report from the same session said
todo add --verifynever persists its validator. It does — 143 of 261 todos across the goals in this repo carry one. The earlier reading had picked up the wrongtodo_addedrecord (the onboarding todogoal initadds, which has no validator). Nothing was changed for it; recorded here so the finding is not repeated.