Skip to content

chore(dev): Add dev cluster seed bootstrap#2556

Merged
daryllimyt merged 2 commits intomainfrom
codex/dev-seed-default
Apr 22, 2026
Merged

chore(dev): Add dev cluster seed bootstrap#2556
daryllimyt merged 2 commits intomainfrom
codex/dev-seed-default

Conversation

@daryllimyt
Copy link
Copy Markdown
Contributor

@daryllimyt daryllimyt commented Apr 22, 2026

Summary

  • Seed local dev clusters with a platform superuser ([email protected]) and a tenant dev user ([email protected]).
  • Make dev-profile just cluster up seed by default, while --no-seed skips it and attached mode keeps compose logs attached immediately via a background seeder.
  • Add default-tier entitlement seeding with --default-tier-entitlements all|none|a,b, defaulting to all known entitlement enum values.
  • Prefix and colorize bootstrap output with [dev-seed] so it is distinguishable from app/container logs.

Why

Platform superusers can no longer enter tenant context, so local dev clusters need a first-class way to create both a platform SU and a normal tenant user without manually doing the tenant invite flow.

Validation

  • shellcheck -x scripts/cluster
  • bash -n scripts/cluster
  • uv run ruff check .
  • uv run basedpyright packages/tracecat-admin/tracecat_admin/services/bootstrap.py packages/tracecat-admin/tracecat_admin/commands/admin.py packages/tracecat-admin/tests/test_admin_commands.py packages/tracecat-admin/tests/test_cli.py
  • uv run pytest packages/tracecat-admin/tests/test_admin_commands.py::TestCreateDevUser packages/tracecat-admin/tests/test_cli.py::TestAdminCommands::test_admin_help

Pre-commit hooks also passed during commit.


Summary by cubic

Adds a dev cluster seeding flow that creates a platform superuser and a tenant dev user by default, plus a tracecat admin create-dev-user command to bootstrap local environments fast. Also scopes role assignment upserts to the organization to avoid cross-org matches during seeding.

  • New Features

    • scripts/cluster up (dev profile) now auto-seeds: superuser [email protected] and tenant [email protected]. Use --no-seed to skip. Supports --default-tier-entitlements all|none|a,b (default: all). Attached mode keeps logs; a background seeder waits for API readiness. Output is prefixed with [dev-seed].
    • New tracecat admin create-dev-user CLI command with options for user creds, superuser creds, entitlements, and role slugs. Enforces 12+ char passwords and prints colorized seed logs.
    • New tracecat_admin.services.bootstrap.create_dev_user flow: bypasses RLS to ensure default organization, default tier + entitlements, org/workspace memberships, and role assignments. Supports organization-owner and workspace-admin (configurable).
  • Bug Fixes

    • Role assignment lookup/upsert is now organization-scoped in _ensure_role_assignment to prevent cross-organization matches. Test coverage added.

Written for commit cd80139. Summary will update on new commits.

@daryllimyt daryllimyt marked this pull request as ready for review April 22, 2026 20:52
@zeropath-ai
Copy link
Copy Markdown

zeropath-ai Bot commented Apr 22, 2026

No security or compliance issues detected. Reviewed everything up to cd80139.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► packages/tracecat-admin/tests/test_admin_commands.py
    Add tests for create-dev-user command
► packages/tracecat-admin/tests/test_cli.py
    Add create-dev-user to admin help output
► packages/tracecat-admin/tracecat_admin/commands/admin.py
    Implement create-dev-user command
► packages/tracecat-admin/tracecat_admin/services/bootstrap.py
    Implement create_dev_user service function
    Add CreateDevUserResult dataclass
    Add resolve_default_tier_entitlements function
    Add helper functions for database operations (_get_role_by_slug, _get_default_workspace, _ensure_default_tier, _ensure_org_tier, _hash_password, _ensure_platform_superuser, _get_or_create_local_user, _ensure_org_membership, _ensure_workspace_membership, _ensure_role_assignment)
Refactor ► scripts/cluster
    Refactor up command arguments parsing
    Update seeding logic for dev profile

@daryllimyt daryllimyt changed the title [codex] Add dev cluster seed bootstrap chore(dev): Add dev cluster seed bootstrap Apr 22, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 5 files

Confidence score: 3/5

  • There is a concrete regression risk in packages/tracecat-admin/tracecat_admin/services/bootstrap.py: the upsert lookup ignores organization_id, which can match the wrong row and overwrite role assignments across organizations.
  • Because this is a medium-severity (6/10) issue with high confidence (8/10) and affects authorization-related data scoping, the merge risk is moderate rather than minimal.
  • This should be addressed before relying on bootstrap role assignment behavior in multi-organization environments.
  • Pay close attention to packages/tracecat-admin/tracecat_admin/services/bootstrap.py - ensure the WHERE clause includes organization_id so updates are correctly tenant-scoped.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/tracecat-admin/tracecat_admin/services/bootstrap.py">

<violation number="1" location="packages/tracecat-admin/tracecat_admin/services/bootstrap.py:385">
P2: The `organization_id` parameter is not used in the lookup query, so the upsert can match and overwrite a role assignment from a different organization. Add `organization_id` to the `WHERE` clause to scope the check correctly.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/tracecat-admin/tracecat_admin/services/bootstrap.py
@daryllimyt daryllimyt merged commit 4d90808 into main Apr 22, 2026
10 checks passed
@daryllimyt daryllimyt deleted the codex/dev-seed-default branch April 22, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants