Repository navigation
fix(setup): deploy the system agent once /setup creates the admin (#3237) - #3261
Merged
Merged
Conversation
) On a browser-claimed install (every one-click / marketplace path) the only system-agent deploy runs at boot, before /setup has created the admin, and fails with "Admin user 'admin' not found". Nothing retried it, so trinity-system stayed absent until a backend restart. /setup now schedules ensure_deployed() as a background task after the admin row is written, ahead of first-run seeding (the boot order; the seeder hosts its alerts on trinity-system). The task never raises, since Starlette runs background tasks in sequence, and skips without Docker. Fixes #3237 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p flow (#3237) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
/setuphad created the admin, and failed withAdmin user 'admin' not found. Nothing retried it, sotrinity-systemstayed absent until a backend restart.POST /api/setup/admin-passwordnow schedules_deploy_system_agent_after_setupas a background task once the admin row exists. It calls the same idempotentsystem_agent_service.ensure_deployed()as boot, so the next restart is a no-op.ensure_first_run_seeded, which is the boot order. The seeder hosts its failure alerts ontrinity-system, and running the two in sequence keeps the system agent and Cornelius from racing for an SSH port.Changes
src/backend/routers/setup.py: the helper and theadd_taskcall. Imports are lazy, which keeps the router's import isolation.tests/unit/test_3237_system_agent_after_setup.py(new) and itstests/registry.jsonentry.docs/memory/feature-flows/internal-system-agent.md: the second deploy trigger.Trade-off
On a fresh install, Cornelius seeding now starts after the system-agent create, roughly 20–90s later (recreate plus readiness wait). Setup's response is unaffected because both are background tasks.
Out of scope
SYSTEM_AGENT_OWNER = "admin"is hard-coded, while/setupcreatesadmin_username(), which honoursADMIN_USERNAME. WithADMIN_USERNAMEset to anything else, the create still fails after this fix. That is a separate bug and gets its own issue.Test Plan
cd tests && pytest unit/test_3237_system_agent_after_setup.py: 5 passed. Before the fix, 4 of them failed (the refused-setup case passes either way).--randomly-seed=12345: 118 passed. With the seeding and lifespan-phase suites: 220 passed.ADMIN_PASSWORD):devcode: boot logscreate_failed - Admin user 'admin' not found; after/setup, noagent-trinity-systemfor 2 minutes./setupat 08:56:37,agent-trinity-systemcreated at 08:56:38 (routers.setup: "System agent after setup: created"), backend restart count 0./api/system-agent/status:running, owneradmin,is_system: true, base imagecurrent. First-run seeding started right after it.Fixes #3237
🤖 Generated with Claude Code