You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: harden setup wizard completion and status checks (#616)
## Summary
Three setup wizard hardening fixes from PR #584 review:
- **#588**: `needs_admin` now checks for CEO role explicitly via new
`count_by_role(HumanRole)` method on `UserRepository` protocol, SQLite
implementation, and fake test implementation -- instead of just checking
`user_count == 0`
- **#587**: `complete_setup` verifies company name and at least one
agent exist (via settings) before marking setup complete, in addition to
the existing provider check. Check order: company -> agents -> providers
- **#589**: `SetupStatusResponse` now includes `min_password_length`
from backend settings; `SetupAdmin.vue` reads it from the setup store
instead of the hardcoded `MIN_PASSWORD_LENGTH` constant, with fallback
to the constant if the server value is unavailable
## Changes
### Backend
- `UserRepository` protocol: added `count_by_role(role: HumanRole) ->
int`
- `SQLiteUserRepository`: parameterized `SELECT COUNT(*) WHERE role = ?`
implementation
- `setup.py` controller: `get_setup_status` uses `count_by_role(CEO)`
for `needs_admin`; `complete_setup` validates company + agents +
providers; status response includes `min_password_length`
- New observability events: `SETUP_NO_COMPANY`, `SETUP_NO_AGENTS`,
`PERSISTENCE_USER_COUNTED_BY_ROLE`,
`PERSISTENCE_USER_COUNT_BY_ROLE_FAILED`
### Frontend
- `SetupStatusResponse` type: added `min_password_length: number`
- `setup.ts` store: added `minPasswordLength` computed with
`MIN_PASSWORD_LENGTH` fallback
- `SetupAdmin.vue`: reads password length from store instead of
hardcoded constant
### Docs
- `CLAUDE.md` and `docs/design/operations.md`: clarified completion gate
prerequisites
## Test plan
- [x] `test_needs_admin_true_when_only_non_admin_exists` -- verifies
CEO-specific check
- [x] `test_needs_admin_false_when_ceo_exists` -- verifies default
fixture passes
- [x] `test_status_includes_min_password_length` -- verifies new field
in response
- [x] `test_complete_validates_all_prerequisites` -- walks through
agents -> providers -> success checks
- [x] All 9501 existing unit tests pass
- [x] mypy strict, ruff lint+format, vue-tsc, ESLint all pass
Pre-reviewed by 4 agents (code-reviewer, frontend+API-contract,
docs-consistency, issue-resolution-verifier). 2 doc findings addressed.
Closes#587Closes#588Closes#589
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Setup wizard now requires company info, at least one agent, and a
provider before completion.
* Setup status now exposes the system minimum password length; the admin
setup UI uses this value for validation and messaging.
* **Documentation**
* User and developer docs updated to reflect the new setup prerequisites
and displayed minimum password length.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/user_guide.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ After the containers are running, open the web dashboard at [http://localhost:30
68
68
3.**Create your company** -- name your synthetic organization and optionally start from a template.
69
69
4.**Hire your first agent** -- choose a role, model, and personality for the first AI agent.
70
70
71
-
After completing the wizard, the dashboard appears and the setup wizard is not shown again.
71
+
All four steps must be completed -- the backend validates that a company, at least one agent, and at least one provider exist before allowing setup to finish. After completing the wizard, the dashboard appears and the setup wizard is not shown again.
72
72
73
73
To re-run the wizard later, use `synthorg setup` (resets the flag and opens the browser) or delete the `api.setup_complete` setting via the settings API.
0 commit comments