Skip to content

feat: Phase 11 organization admin console and migration plan - #750

Merged
Ayinkx merged 5 commits into
AyinkxLab:mainfrom
Gbolahan088:feat/phase11-org-admin
Nov 22, 2026
Merged

Ayinkx merged 5 commits into
AyinkxLab:mainfrom
Gbolahan088:feat/phase11-org-admin

Conversation

@Gbolahan088

Copy link
Copy Markdown
Contributor

Summary

Phase 11 organization admin console for the workspace-based organization model.

This repo has no separate organization table — a workspace is the organization (as already documented in app/models/workspace_domain.py and app/models/audit_log.py). So instead of adding a parallel model and permission system, this adds a thin app/services/organizations.py layer: the workspace owner is the organization owner, and an active WorkspaceMember with role owner/admin is an organization admin. Every console route resolves authorization through one helper (app/admin/organizations_common.py::resolve_organization), which fails closed with structured forbidden / not_found / invalid_input errors.

Closes #626
Closes #627
Closes #633
Closes #636

Per issue

#626 — organization admin dashboard

  • GET /admin/organizations/<id> renders member count, workspace count, estimated usage for a selectable window (1–365 days), and open high/critical security findings.
  • Owner/admin only, structured errors, owner/admin link added on the workspace detail page.
  • Files: app/admin/organization_dashboard.py, app/services/organizations.py, app/templates/admin/organization_dashboard.html, tests.

#627 — member management UI

  • GET/POST /admin/organizations/<id>/members: invite, suspend, restore, remove, and change role.
  • Destructive actions are server-enforced (confirm field) and disabled client-side while submitting (app/static/js/org-admin.js, aria-busy).
  • Invites reuse the existing hashed-token invitation flow; suspends/removes reuse WorkspaceMember.mark_removed() and cancel pending invitations on remove.
  • Empty member and invitation states included.
  • Files: app/admin/organization_members.py, app/templates/admin/organization_members.html, tests.

#633 — usage and billing rollups

  • GET /admin/organizations/<id>/usage reuses the Phase 10 usage_ledger summary and budget evaluations, scoped to the organization's workspaces.
  • Cost is always labelled an estimate (cost_is_estimate, usage_is_estimated) and no provider invoice is implied.
  • Files: app/admin/organization_usage.py, app/templates/admin/organization_usage.html, tests.

#636 — enterprise migration plan

  • scripts/organization_migration.py with idempotent --dry-run (default), --apply, --verify, --rollback for scoping existing workspaces to an owner without copying data.
  • docs/organization-migration.md documents backfill, rollback, verification SQL, expected output, and the explicit no-data-loss model.
  • Tests: no-write dry run, idempotent apply, verification, scoped rollback.

Verification

python -m ruff check .                -> All checks passed!
python -m black --check .             -> 545 files would be left unchanged.
python -m flask --app wsgi db heads   -> 590a1b2c3d4e (head)
python -m pytest tests/test_org_admin_dashboard.py tests/test_org_admin_usage.py \
  tests/test_org_admin_members.py tests/test_organization_migration.py \
  tests/test_admin_actions.py tests/test_docs_links.py tests/test_template_hygiene.py \
  -o addopts="" -q                    -> 166 passed

No schema changes were needed, so the migration head is unchanged.

Notes and limitations

  • suspend and remove share the existing removed membership status (remove additionally cancels pending invitations); the UI distinguishes them but the stored status is shared. Adding a distinct suspended status would need a migration, so it was left alone.
  • The organization admin role is console-only and deliberately does not widen app/services/permissions.py capabilities.
  • Console errors return the structured JSON catalog even for HTML pages, matching the existing /admin behaviour; successes use flash + redirect.
  • tests/test_admin_usage_report.py::TestAdminUsageReportAccess::test_admin_navigation_link_is_visible_only_to_admins fails on a clean origin/main too (translation catalog embeds the string) and is unrelated.
  • Full test suite was not run; two budget/usage-ledger failures already exist on main.
  • One commit (16208f0) only applies Black to two pre-existing files required for the repo-wide black --check gate; no behaviour change.

@vercel

vercel Bot commented Nov 22, 2026

Copy link
Copy Markdown

@Gbolahan088 is attempting to deploy a commit to the Ayinkx Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 22, 2026

Copy link
Copy Markdown

@Gbolahan088 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Ayinkx
Ayinkx merged commit 2731849 into AyinkxLab:main Nov 22, 2026
14 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants