Repository navigation
feat: streamline first-time setup wizard (abilityai/trinity-enterprise#49) - #1313
Conversation
…e#49) Drop the log-copied setup token, require an admin email, and rebuild the first-run page as a welcoming animated welcome screen. Backend (routers/setup.py, main.py): - Remove the setup-token machinery entirely (ensure_setup_token / clear_setup_token / Redis-shared token + the main.py startup emission). Setup no longer depends on Redis — the admin write goes straight to SQLite. - Make admin email REQUIRED (sign-in identity): missing -> 422 at the model layer; blank/typo -> 400, validated before any write so setup never half-completes. Password complexity (OWASP ASVS 2.1) still enforced. - get_setup_status keeps setup_available:true for frontend back-compat. Frontend (SetupPassword.vue): - Full redesign: dark branded hero with an animated orbiting fleet constellation (Trinity mark core + agent nodes on three rings), split layout (stacks on mobile), prefers-reduced-motion aware. - No setup-token field; email required; order email -> password (+confirm) -> company -> updates opt-in. Removed the Redis-wait panel + polling. Security tradeoff (chosen: accept + document): removing the token leaves the unauthenticated first-run window with no proof-of-control. Documented as an operator responsibility (deploy behind a tunnel/VPN until setup completes) in docs/DEPLOYMENT.md Security Recommendations; endpoint still self-disables after first success. See docs/security-reports/cso-diff-2026-06-23.md (F1). Docs: DEPLOYMENT.md security note, architecture.md, requirements.md (§15.2/§43), feature-flows/first-time-setup.md. Tests: remove obsolete test_1165_setup_token_shared.py; update test_setup.py (no token, email required) and test_setup_operator_profile.py (email required, model-layer + blank/invalid rejection). 7 operator-profile unit tests pass; new contract verified live (422/400 negative paths). Fixes abilityai/trinity-enterprise#49 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The redesigned first-run page used `position:fixed; inset:0` for its root. On wider viewports this left a band of the light `#app` (bg-gray-100) background showing through on the right/bottom — a fixed root is clipped to the nearest transformed/contained ancestor instead of the viewport, so its coverage isn't guaranteed. Switch the root to the original component's proven normal-flow approach (`position:relative; width:100%; min-height:100vh`), which fills the full-width `#app`, and make the decorative aurora/grid `position:absolute` within it. Verified covering the full viewport at 2560x1440 (light mode, the repro case) and stacking correctly at 430px. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
/review — automated review of #1313Reviewed the diff against 🔴 Blocker —
|
| side | total | pass | fail | error |
|---|---|---|---|---|
| base | 2749 | 2712 | 6 | 8 |
| head | 2 | 0 | 0 | 1 |
The head pytest jobs report "pass" but ran in 39s collecting 2 tests (vs base 4m30s / 2749) — a false green. The 1 error is in the PR-modified tests/test_setup.py, which is an integration/smoke test that hits a live backend (unauthenticated_client → real HTTP; it fails connect_tcp/connection-refused when no backend is up).
So either the regression-diff "head" job runs the diff-scoped tests without a backend (and your smoke-test edits now error there), or the head suite genuinely under-collected. Please:
- get the gate green (don't merge on a 2-test head run), and
- confirm
tests/test_setup.pyruns against a live backend in CI (or port the assertions tofastapi.testclient.TestClientso they're hermetic).
🟠 Security tradeoff — setup-token removal (F1 HIGH, accepted) — needs a conscious approver sign-off
This is a deliberate, documented decision and CSO --diff recorded it as F1 (HIGH, accepted). I verified the load-bearing pieces:
- ✅ Self-disable intact:
setup_completedis set (setup.py:156) and the endpoint 403s once set (:108) — exposure is the pre-setup window only. - ✅ Email required at the model layer (
email: str = Field(...)→ 422) + shape check (400); password complexity retained. - ✅ One fewer secret in logs (token no longer printed).
The residual risk is real: in the pre-setup window the only barrier is now network reachability + a docs note ("deploy behind a tunnel/VPN"). That's a procedural mitigation replacing a technical one (#1165/SEC-177). I'm not relitigating the accepted decision, but two asks:
- An approver should consciously sign off on the accepted HIGH (don't let it pass silently).
- Optional hardening that keeps the UX win without a docs-only control: bind the setup endpoints to loopback / a host-readable
/datasetup file untilsetup_completed, so a purely-remote attacker still can't reachPOST /admin-passwordpre-setup. Worth a follow-up issue even if not in this PR.
🟡 Scope notes
VERSIONbumped 0.6.1 → 0.7.0 in a feature PR. Version bumps belong to the release cut (/release), not a feature branch — and a minor bump for one feature is aggressive. Recommend dropping the VERSION change here to avoid colliding with the release process / other PRs.- CSO
--diffreport committed to the public repo (docs/security-reports/cso-diff-2026-06-23.*). Unlike a full open-vuln audit this is an accepted/documented tradeoff, so transparency is arguably the point — just flagging the public-disclosure pattern for awareness.
✅ Verified good
- feat(setup): first-run operator intake + admin email login (trinity-enterprise#38, #82) #1307 (just merged) preserved: admin-email sign-in kept and now required; operator-intake (
consent_updates) retained. - Setup no longer depends on Redis; validation happens before any write (no half-completed setup).
Summary
- Blocker: 1 — green the
regression diffgate (head ran 2 tests;test_setup.pyerrors without a live backend). - Sign-off needed: the accepted F1 HIGH (setup-token removal) — consider loopback/host-file hardening as a follow-up.
- Scope: drop the
VERSIONbump.
Automated /review (correctness · CI · auth-boundary · scope). Security-critical paths verified live.
…rrupted The CI backend-unit regression gate runs `cd tests && pytest unit/` (the whole unit suite). test_setup_operator_profile.py imported `routers.setup` at module (collection) time; that import — pulling in database/dependencies/services and their many `utils.*` leaves — failed/perturbed sys.modules during collection and INTERRUPTED the entire `unit/` collection (head collected ~2 of 2734 → the diff gate flagged it as a new failure). Defer the `import routers.setup` to a cached `_get_setup()` accessor used inside the tests, so module collection imports only stdlib/pytest/fastapi/pydantic and can never corrupt the suite. `_get_setup()` also spec-preloads the backend `utils.*` leaves (helpers/errors/credential_sanitizer/password_validation/ url_validation/image_optimize) the same way conftest preloads `utils.helpers`, without touching `sys.modules["utils"]`, so the import resolves cleanly at run time regardless of harness utils state. Verified with the exact CI command (`cd tests && pytest unit/ --co`): the full suite now collects 2734 items with no interruption, and the 7 setup tests pass. No conftest changes. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…lint) The previous commit's `_get_setup()` spec-preloaded backend utils leaves via `sys.modules[...] = …` / `.pop`, which tests/lint_sys_modules.py (#762) bans outside conftest. It's also unnecessary: in the backend-unit gate (`cd tests && pytest unit/`), tests/unit/conftest.py already installs src/backend/utils as the canonical `utils` package, so a plain lazy `import routers.setup` resolves the backend `utils.*` leaves natively. Simplify `_get_setup()` to a cached plain lazy import — no sys.modules mutation. Verified: lint clean (no new violations), `pytest unit/ --co` collects 2734 with no interruption, and the 7 setup tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Removing the setup token (trinity-enterprise#49) deleted `routers/setup.py::ensure_setup_token` and the lifespan token emission, so two #858 regression guards asserted gone behavior and failed in the backend-unit gate: - test_ensure_setup_token_logs_token_via_logger_warning - test_lifespan_emits_setup_token_via_logger_before_event_bus The #858 invariant itself is intact: the lifespan still emits the first-run notice via `logger.warning` (not print), after setup_logging() and before event_bus.start(). Replace the token-specific guard with one that matches the new FIRST-TIME SETUP warning by content + ordering, drop the now-obsolete ensure_setup_token guard, and remove the unused BACKEND_SETUP constant. The Dockerfile PYTHONUNBUFFERED parity checks and the no-print-in-lifespan guard are unchanged. 4 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
/review — re-review (head
|
| side | total | pass | fail | error | skip |
|---|---|---|---|---|---|
| base | 2749 | 2712 | 6 | 8 | 23 |
| head | 2741 | 2704 | 6 | 8 | 23 |
Head pytest went from 39s / 2 tests to 4m31s / 2741 — the suite collects again. The −8 delta is exactly the obsolete test_1165_setup_token_shared.py (token machinery removed), and fail/error/skip are identical to base — no new failures, no silently-dropped coverage.
Root cause was real and the fix is clean: tests/test_setup.py imported routers.setup at collection time, flipping sys.modules["utils"] and corrupting collection for the rest of the suite (the #762 pollution class). Fixed by deferring to a lazy _get_setup() that doesn't touch sys.modules["utils"] (and it passes the #762 lint). The #858 guard was correctly updated — kept the lifespan flush-ordering assertion, just swapped token→"first-run notice".
Still outstanding (not blockers)
- 🟠 F1 (HIGH, accepted) — setup-token removal is unchanged: no technical control was added, so the pre-setup window is still gated only by network reachability + the docs note. That's the deliberate decision — it just needs a conscious approver sign-off, and ideally a follow-up issue for the optional loopback/host-file hardening.
- 🟡
VERSIONis still bumped to0.7.0in this feature PR (my earlier scope note). Recommend the release cut owns version bumps; leaving it risks a collision with/release. Minor — drop it or confirm it's intentional.
Verdict: the correctness/CI blocker is cleared and the fix is sound. Merge-ready once an approver signs off on the accepted F1 HIGH and decides on the VERSION bump.
Automated /review re-review.
Summary
docker compose logs backend. The token machinery (ensure_setup_token/clear_setup_token/Redis-shared token + themain.pystartup emission) is removed entirely; setup no longer depends on Redis (the admin write goes straight to SQLite).prefers-reduced-motionaware. Field order: email → password (+confirm) → company (optional) → updates opt-in.Implements
abilityai/trinity-enterprise#49.Security tradeoff (deliberate, documented)
Removing the setup token leaves the unauthenticated first-run window with no proof-of-control — on an internet-reachable instance, an attacker reaching
/api/setup/admin-passwordbefore the operator finishes setup could claim the admin account. The chosen approach (per the issue's "pick one before implementing") is accept + document:docs/DEPLOYMENT.md→ Security Recommendations, plus the code docstrings, themain.pystartup log,architecture.md, andrequirements.md.setup_completed), so exposure is the pre-setup window only; localhost/trusted-LAN is a non-issue./cso --diffran on this branch and recorded it as F1 (HIGH, accepted/documented) — seedocs/security-reports/cso-diff-2026-06-23.md. No other findings; the change removes one secret (the token) from the logs.Changes
src/backend/routers/setup.py— token machinery removed; email required;set_admin_passwordrewrittensrc/backend/main.py— startup token emission → plain first-run log line; import cleanupsrc/frontend/src/views/SetupPassword.vue— full redesign (constellation animation, new field order, no token, no Redis-wait panel)docs/—DEPLOYMENT.mdsecurity note,architecture.md,requirements.md(§15.2/§43),feature-flows/first-time-setup.mdtests/— removed obsoletetest_1165_setup_token_shared.py; updatedtest_setup.py+test_setup_operator_profile.pydocs/security-reports/cso-diff-2026-06-23.{md,json}— security audit of this diffTest Plan
tests/unit/test_setup_operator_profile.py— 7 passed (email required, blank/invalid rejection, model-layer required, no-token-field, intake gating)SetupPassword.vueverified rendering athttp://localhost/setup(constellation + new form)test_setup.pyintegration smoke tests (require a completed-setup instance; can't run against the local pre-setup instance without locking it)🤖 Generated with Claude Code