Repository navigation
feat(systems): first-run seed of a default system manifest (trinity-enterprise#124) - #1764
Conversation
…oard skill + P-37 catalog entry Co-Authored-By: Claude Fable 5 <[email protected]>
…nterprise#124) On a genuinely fresh install, auto-deploy a bundled starter fleet once, right after first-time setup — the multi-agent generalization of the Cornelius seeder (ent#107), driven through the resilient deploy path (ent#125). - Extract the deploy orchestration verbatim from routers/systems.py into services/system_service.py::deploy_manifest (Invariant #1; router is a thin HTTP wrapper). Default create_agent_fn lazily resolves the routers/agents ws-broadcasting facade so agent_created broadcasts are preserved on every deploy path. - New services/system_seed_service.py: ensure_first_run_seeded() resolves a PERSISTED first-run verdict (first_run_fresh — computed once BEFORE Cornelius provisions; cornelius_seeded forces not-fresh) and runs both seeders under that one decision, closing the cross-pass count-poisoning bug. Durable default_system_seeded flag + seed-info JSON, SETNX lock, reserved-name existence backstop (the deploy path suffixes collisions instead of 409ing), flag policy deployed/partial=set failed/error=retry, operator-queue alerts (system-seed-* ids, #1632 reserved prefix) on partial/failed/error/unreadable-override/interrupted-converge. - cornelius_agent_service.ensure_seeded gains an optional precomputed fresh verdict (legacy count when None). - Bundled config/manifests/default-system.yaml: the in-tree acme trio (local:scout/sage/scribe) as the coherent team its content assumes — no schedules, no prompt. TRINITY_DEFAULT_SYSTEM_MANIFEST env override / disable sentinels; baked into the image AND dir-mounted in both compose files (the dev src mount shadows image COPYs). e2e stack pins the disabled sentinel to keep its zero-agent baseline. Refs trinity-enterprise#124 (closed manually at release — closing keywords don't cross repos). Co-Authored-By: Claude Fable 5 <[email protected]>
/review ReportBranch: Critical Findings (block merge)None. No new endpoints, no raw SQL, no unparameterized input, no credential path. Informational Findings[I1] Correctness: the persisted first-run verdict never re-validates, so every non-flag-burning skip path becomes a delayed trigger (Confidence: 8/10) Evidence — the verdict is computed once and stored forever: stored = db.get_setting_value(_FRESH_VERDICT_KEY, None)
if stored is not None:
return stored == "true"and the disable sentinel returns before the freshness check, deliberately not burning the flag: # 2. Operator disable sentinel. Deliberately does NOT set the flag —
# un-setting the sentinel on a still-fresh install seeds normally.
if override_raw.lower() in _DISABLE_SENTINELS:
return self._skip(result, "disabled", ...)Issue:
The existence backstop doesn't help: it only matches Why it's not trivially fixable: re-checking Suggestion: fix, or file the follow-up and say so in the docstring — right now the docstring reads as though the flag policy fully covers this. [I2] Observability: the honest-status alert fails silently (Confidence: 9/10) except Exception as e:
logger.debug("Seed operator alert failed (non-fatal): %s", e)The operator-queue alert is the only channel telling an operator the fleet seeded partially. [I3] Robustness: blind lock release can delete another worker's lock (Confidence: 7/10) [I4] Test gap: the CI insurance has never executed (Confidence: 10/10) [I5] Alert dedup is permanent across all statuses (Confidence: 8/10) [I6] Stale type hint on the facade (Confidence: 9/10) Clean Categories
Verification performed
Summary
Durable lesson worth adding to 🤖 Reviewed with |
Summary
First-run seed of a default system manifest (abilityai/trinity-enterprise#124): on a genuinely fresh install, Trinity now auto-deploys a bundled starter fleet once, right after first-time setup — the multi-agent generalization of the Cornelius seeder (ent#107), driven through the resilient deploy path (ent#125).
routers/systems.py::deploy_systemintoservices/system_service.py::deploy_manifest(); the router is now a thin HTTP wrapper (status=="failed"→ 500 JSONResponse; everything else — 400 parse, strict-abort status codes, dry-run — passes through unchanged). The defaultcreate_agent_fnlazily resolves therouters/agentsfacade (not crud), preservingagent_createdWS broadcasts on every deploy path.services/system_seed_service.py:ensure_first_run_seeded()(both call sites: setup-completion background task + lifespan safety-net with a strong task ref) resolves a persisted first-run verdict (first_run_fresh, computed once BEFORE Cornelius provisions;cornelius_seeded=="true"forces not-fresh) and runs both seeders under that one decision — without this, the first seeder's own agents poison every later pass's freshness count (a failed fleet deploy could never retry; a failed Cornelius would self-mark seeded after the fleet lands).default_system_seededflag +default_system_seed_infodiagnostics JSON; SETNX lock (system_seed:provision, fail-open); existence backstop — any already-reserved{system}-{short}name converges the flag without deploying (the deploy path suffixes name collisions instead of 409ing, so a fail-open lock race would otherwise double-seed). Flag policy:deployed/partial→ set (a partial fleet must never be re-deployed — suffix duplicates);failed(0 created)/exception → not set (retry-safe).TRINITY_DEFAULT_SYSTEM_MANIFESTenv — path to a private distribution manifest, ordisabled/none/off/0/falseto skip (no flag burn; set-but-empty ⇒ bundled, the Voice DOA on compose deploys: empty VOICE_MODEL from compose shadows code default → Gemini 'model is required' #1076 compose class). An explicitly-set-but-unreadable override fails loudly (ERROR + operator-queue alert) and never silently falls back. Partial/failed seeds also raise one deterministic-id operator alert (platform-path direct DB create, bug: operator-queue create path has no rate limit or size caps — flooding/operator-fatigue surface (blocking pull default-ON) #1632-exempt).config/manifests/default-system.yaml: the in-tree acme trio (local:scout/sage/scribe) deployed as the coherent team its CLAUDE.md content assumes (nameacme, shared folders, full-mesh) — no schedules (zero-credential installs must not accumulate failing crons), noprompt:(never mutates platform-widetrinity_prompt). Content is data: ent#137's curated public fleet swaps the manifest, not the mechanism. Baked into the backend image AND dir-mounted in both compose files (the dev./src/backend:/appmount shadows image COPYs — the mount is load-bearing locally).disabledsentinel explicitly to keep its zero-agent baseline (learnings 2026-07-08).Design notes for review
use_platform_api_key=1, so an install whose setup configuredANTHROPIC_API_KEYworks immediately). Thedisabledsentinel is the opt-out.trinity-system+ Cornelius + 3 starters (cpu/memory are limits, not reservations). Documented in requirements §16.5.1.Changes
src/backend/services/system_service.py—deploy_manifest()+_failure_reason+_default_create_agent_fn(moved/new)src/backend/routers/systems.py— deploy endpoint thinned to the HTTP wrappersrc/backend/services/system_seed_service.py— new seeder + orchestratorsrc/backend/services/cornelius_agent_service.py— optional precomputedfreshverdict (legacy behavior whenNone)src/backend/main.py,src/backend/routers/setup.py— call sites →ensure_first_run_seeded()config/manifests/default-system.yaml— bundled starter manifestdocker/backend/Dockerfile,docker-compose.yml,docker-compose.prod.yml,.env.example,.github/workflows/frontend-e2e.yml— packaging + env + CI sentineldocs/memory/requirements/roadmap.md(§16.5.1),docs/memory/architecture.md, feature flows (system-manifest.md,cornelius-default-agent.md)src/backend/services/operator_queue_service.py—system-seed-added to the bug: operator-queue create path has no rate limit or size caps — flooding/operator-fatigue surface (blocking pull default-ON) #1632 reserved id prefixes (an agent can't pre-create-and-silence the seed alerts)tests/unit/test_ent124_default_system_seed.py(30 new),test_ent125_resilient_system_deploy.py(patch targets migrated to the service),test_ent107_cornelius_seed.py(+3fresh-param tests),test_setup_operator_profile.py(call-site binding migrated),tests/registry.jsonReview provenance
Full pipeline ran: /autoplan (independent strategy + engineering voices; 25-decision audit trail) → /implement → adversarial diff review. All HIGH/MEDIUM review findings fixed in this PR: stale setup-test bindings; a never-raises hole on the admin lookup + an unbelted orchestrator call (the strong task ref would have suppressed the only diagnostic); seed alerts made un-silenceable via the reserved-prefix guard; a parse-broken override now alerts instead of silently retrying every boot; a crash-interrupted partial fleet detected by the converge backstop now alerts too. Known accepted residuals (LOW): a truly simultaneous fail-open lock race can still suffix-duplicate (boot-scoped);
system_serviceraising HTTPException is a documented verbatim-move tradeoff.Test Plan
pytest tests/unit/test_ent124_default_system_seed.py tests/unit/test_ent125_resilient_system_deploy.py tests/unit/test_ent107_cornelius_seed.py tests/unit/test_setup_operator_profile.py— 66 passedtests/unit -k "system or cornelius or setup"— 97 passed, 4 skippedlocal:template it references asserted to exist in-tree (learnings 2026-07-23 blank-agent trap)acme-scout/acme-sage/acme-scribeafter setup completes (needs a wiped local stack — not run against the live dev stack)Refs abilityai/trinity-enterprise#124 (private-tracker feature — closed manually at release, closing keywords don't cross repos)
🤖 Generated with Claude Code