Repository navigation
fix(seed): converge the Cornelius flag on a 409 only when the agent exists (#1790) - #1837
Merged
Merged
Conversation
…xists (#1790) The seeder read any HTTP 409 from create_agent_internal as "Cornelius already exists" and durably set cornelius_seeded=true. But the create path raises 409 for several conditions under which NOTHING was created — a leftover unclaimed workspace volume (#1667), volumes still owned by a renamed agent (#1664), a fork destination already bound. On those, the flag suppressed every later attempt, so the install stayed permanently Cornelius-less while reporting that it had seeded, and system_seed_service then read the install as not-fresh. The reachable path is the ordinary "let me start over": `docker compose down -v` destroys the DB but NOT the agent volumes (they are not compose-managed), so the next setup hits the leftover agent-cornelius-workspace, 409s, and burns the flag. Recovery required hand-editing system_settings. Verify by fact, not by status code: on a 409 the handler now re-checks whether anything actually claims the name and converges only then; otherwise it leaves the flag unset, returns create_blocked, and logs the cause, so the next boot retries. The usual blocker is reclaimed unattended by the #1581 orphan-volume sweep, so the retry converges without intervention. The predicate is the create path's own — `_check_name_availability`'s existence check, extracted as `crud.agent_name_is_taken` and shared rather than re-derived, so the two cannot drift when a claim source is added. This is deliberately broader than typing the one #1667 refusal: every present and future non-existence 409 is handled, since the seeder now asks the question it actually cares about. Mirrors the fact-based 409 handling already used for Docker name conflicts in lifecycle.py (#1809). The probe fails toward retry — a wrong "absent" costs one redundant create attempt, a wrong "present" is the unrecoverable direction. Tests: 3 new cases in the ent107 suite (409-with-no-agent leaves the flag unset; probe failure fails toward retry; the shared predicate reads every claim source), plus the existing 409-convergence case tightened to assert presence. Verified failing 2/2 against the pre-fix handler. Full unit suite: 4993 passed, 4 pre-existing environmental failures (missing tzdata, admin-email-login) reproduced identically on an untouched checkout. Related to #1790
|
Resolve by running |
vybe
approved these changes
Jul 28, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validated via /validate-pr: shared claim predicate (no drift), fail-toward-retry asymmetry is right, regression tests named to #1790 cover both 409 branches + probe failure + all claim sources, feature-flow doc updated. Approving.
pull Bot
pushed a commit
to bryanwills/trinity
that referenced
this pull request
Jul 28, 2026
…xists (Abilityai#1790) (Abilityai#1837) The seeder read any HTTP 409 from create_agent_internal as "Cornelius already exists" and durably set cornelius_seeded=true. But the create path raises 409 for several conditions under which NOTHING was created — a leftover unclaimed workspace volume (Abilityai#1667), volumes still owned by a renamed agent (Abilityai#1664), a fork destination already bound. On those, the flag suppressed every later attempt, so the install stayed permanently Cornelius-less while reporting that it had seeded, and system_seed_service then read the install as not-fresh. The reachable path is the ordinary "let me start over": `docker compose down -v` destroys the DB but NOT the agent volumes (they are not compose-managed), so the next setup hits the leftover agent-cornelius-workspace, 409s, and burns the flag. Recovery required hand-editing system_settings. Verify by fact, not by status code: on a 409 the handler now re-checks whether anything actually claims the name and converges only then; otherwise it leaves the flag unset, returns create_blocked, and logs the cause, so the next boot retries. The usual blocker is reclaimed unattended by the Abilityai#1581 orphan-volume sweep, so the retry converges without intervention. The predicate is the create path's own — `_check_name_availability`'s existence check, extracted as `crud.agent_name_is_taken` and shared rather than re-derived, so the two cannot drift when a claim source is added. This is deliberately broader than typing the one Abilityai#1667 refusal: every present and future non-existence 409 is handled, since the seeder now asks the question it actually cares about. Mirrors the fact-based 409 handling already used for Docker name conflicts in lifecycle.py (Abilityai#1809). The probe fails toward retry — a wrong "absent" costs one redundant create attempt, a wrong "present" is the unrecoverable direction. Tests: 3 new cases in the ent107 suite (409-with-no-agent leaves the flag unset; probe failure fails toward retry; the shared predicate reads every claim source), plus the existing 409-convergence case tightened to assert presence. Verified failing 2/2 against the pre-fix handler. Full unit suite: 4993 passed, 4 pre-existing environmental failures (missing tzdata, admin-email-login) reproduced identically on an untouched checkout. Related to Abilityai#1790
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.
What
The Cornelius seeder converged its durable
cornelius_seededflag on any 409 from the create path. Now it converges only when something actually claims the name.Related to #1790
Why it mattered
Three of the create path's 409s mean nothing was created:
_check_name_availability→ "Agent already exists"_guard_leftover_workspace_volume(#1667)is_volume_base_reserved(#1664)FORK_DESTINATION_IN_USEOn the bottom three the flag suppressed every later attempt, so the install stayed permanently Cornelius-less while reporting seeded — and
system_seed_service.ensure_first_run_seeded()then read the install as not-fresh. Recovery meant hand-editingsystem_settings.Reachable via the ordinary "start over":
docker compose down -vdestroys the DB but not the agent volumes (not compose-managed), so re-setup hits the leftoveragent-cornelius-workspace.Approach
Verify by fact, not by status code. On a 409 the handler asks whether anything claims the name; converges only then, otherwise leaves the flag unset, returns
create_blocked, logs the cause, and the next boot retries. The common blocker is reclaimed unattended by the #1581 orphan-volume sweep, so the retry converges with no operator action.Two deliberate choices worth reviewing:
_check_name_availabilityis extracted ascrud.agent_name_is_takenand reused by the seeder. That covers every non-existence 409 — including the two the issue didn't name and any added later — and it keepsdetaila plain string, so no 409 response shape changes for the UI. Sharing beats copying here: a duplicated predicate would drift the moment a new claim source lands in the create path.Precedent:
lifecycle.py(#1809) already handles a Docker 409 the same way — catch, then confirm the container is really there before adopting.Note one preserved behaviour: a container-only leftover with no ownership row still counts as taken, because that's what the create path itself refuses on. It converges as before.
Verification
New cases, run against the pre-fix handler (fix stashed, tests kept) — both fail, so they pin the actual defect:
Full unit suite:
All 4 failures are pre-existing and environmental —
ModuleNotFoundError: No module named 'tzdata'(test_1472) and 3 intest_admin_email_login.py— reproduced identically on an untouched checkout at the same commit. Crud-adjacent files (test_1484,test_1664,test_1581,test_fork_to_own,test_1646) pass 144/144, covering the predicate extraction.Not done: no operator-queue alert for a blocked seed. Retry + an ERROR log naming the cause is the fix for the reported defect; an alert is a separate call.
🤖 Generated with Claude Code
Fixes #1790