Repository navigation
feat: bundle a Brain-Orb-enabled Cornelius in the default install (abilityai/trinity-enterprise#107) - #1515
Conversation
…tall (trinity-enterprise#107) Bundle Trinity's flagship "second brain" agent into the default install so a fresh Trinity comes up with a working, Brain-Orb-enabled Cornelius present — zero manual steps. Approach (autoplan-reviewed): Path B — a local bundled template, NOT github-native. The Brain Orb turned out to already be fully OSS (platform flag-gated, not entitlement-gated), so the issue's "de-gating" dependency was dropped. github-native-at-boot was rejected: create_agent_internal's dynamic github path hard-requires a system PAT even for a public repo, and a boot-time clone adds a network SPOF to startup. - config/agent-templates/cornelius/: bundled LOCAL template (from public github.com/Abilityai/cornelius) — template.yaml (capabilities:[brain-orb]), CLAUDE.md, .trinity/brain-orb/ hooks, a pre-generated resources/agent-visualization/data.json seed so the orb renders immediately, and a minimal seed Brain/ vault. - services/cornelius_agent_service.py: ensure_seeded() — first-run-only (durable cornelius_seeded flag; a deleted Cornelius is not resurrected), fresh-install-scoped (skipped when any non-system agent exists, so upgrades aren't surprised), Redis SETNX lock for the --workers 2 race (fail-open, mirrors #1464), provisions local:cornelius via create_agent_internal (no PAT/network/clone), existence-guarded enable of brain_orb_enabled (never clobbers an admin OFF). - Two triggers: routers/setup.py (fresh install — BackgroundTask right after the admin account is created, since no owner exists pre-setup) and a main.py lifespan safety-net (upgrades; gated on setup_completed && !cornelius_seeded, backgrounded). - create_agent_internal: request param widened to Optional[Request]=None (boot-time caller has no HTTP request; the param was never dereferenced). - db.count_non_system_agents() (db/agents.py + database.py facade) — the fresh-install signal. No migration (system_settings is free-form KV). - Tests: tests/unit/test_ent107_cornelius_seed.py (12 cases — gating, idempotency, fresh-install scoping, owner deferral, docker skip, flag-seed guard, 409 convergence, SETNX lock, local-template config, real-DB facade smoke); setup test updated for the new background task. Known deviation from the issue's decision #2: a local bundle has origin=local (no git upstream), so the default Cornelius won't auto-`git pull` upstream template updates; durable ownership is deferred to fork-to-own (trinity-enterprise#109). This was accepted at the autoplan gate. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Review: ✅ Approve with notes The seeding seam is well-gated and genuinely fail-open: docker → already-seeded → fresh-install (with flag convergence) → owner-exists (defers without setting the flag, which is why the two-trigger design is needed) → SETNX cross-worker lock → provision → existence-guarded Brain-Orb enable → mark done only on success. Notes (non-blocking):
CI green. Tests cover the gate matrix well (12 cases + facade smoke). |
Summary
create_agent_internal's dynamic-github path hard-requires a system PAT even for a public repo (crud.py:302), and a boot-time clone adds a network SPOF to startup.Changes
config/agent-templates/cornelius/— bundled LOCAL template (from publicgithub.com/Abilityai/cornelius):template.yaml(capabilities: [brain-orb]),CLAUDE.md,.trinity/brain-orb/hooks, a pre-generatedresources/agent-visualization/data.jsonseed so the orb renders immediately, and a minimal seedBrain/vault.services/cornelius_agent_service.py—ensure_seeded(): first-run-only (durablecornelius_seededflag — a deleted Cornelius is not resurrected), fresh-install-scoped (skipped when any non-system agent exists — established fleets aren't surprised on upgrade), Redis SETNX lock for the--workers 2race (fail-open, mirrors bug: fleet-health monitoring loop runs once per uvicorn worker — duplicate health checks and doubled circuit-breaker failure feed #1464), provisionslocal:cornelius(no PAT/network/clone), existence-guarded enable ofbrain_orb_enabled(never clobbers an admin OFF).routers/setup.py(fresh install: aBackgroundTaskright after the admin account is created, since no owner exists pre-setup) + amain.pylifespan safety-net (upgrades: gated onsetup_completed && !cornelius_seeded, backgrounded).create_agent_internal—requestwidened toOptional[Request] = None(boot-time caller has no HTTP request; the param was never dereferenced).db.count_non_system_agents()(db/agents.py+database.pyfacade) — the fresh-install signal. No migration (system_settingsis free-form KV).Test Plan
pytest tests/unit/test_ent107_cornelius_seed.py -v(12 cases: gating, idempotency, fresh-install scoping, owner-deferral, docker skip, flag-seed guard, 409 convergence, SETNX lock,local:corneliusconfig, real-DB facade smoke)Notes
origin=local(no git upstream), so the default Cornelius won't auto-git pullupstream template updates; durable ownership is deferred to fork-to-own (abilityai/trinity-enterprise#109). Accepted at the autoplan gate..gitignoreoverrides the monorepo root's.trinity/-prune and upstream'sdata.json-ignore so a plaingit addstages the hooks + seed graph (verified).Implements abilityai/trinity-enterprise#107 (private tracker — not auto-closed by this public PR; closed manually at release).
🤖 Generated with Claude Code