Skip to content

Update README.md#41

Merged
muellerberndt merged 1 commit into
mainfrom
muellerberndt-patch-3
Oct 7, 2025
Merged

Update README.md#41
muellerberndt merged 1 commit into
mainfrom
muellerberndt-patch-3

Conversation

@muellerberndt

Copy link
Copy Markdown
Collaborator

No description provided.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@muellerberndt muellerberndt merged commit 1f8d105 into main Oct 7, 2025
6 checks passed
zcor added a commit to zcor/hound that referenced this pull request Jun 1, 2026
…g#41)

* feat(team): schema + event listener for tenant-wide teams (firepan-5o8)

Foundation for v1 team management UI. Introduces the tenant-wide team
model without touching any existing code paths.

- database/models.py:
  - Tenant.team_id (nullable FK, unique-per-tenant via the relationship)
  - Team.github_repo_id / github_repo_name relaxed to nullable so tenant
    teams can leave them NULL while per-repo teams keep them populated
  - @event.listens_for(Tenant, "after_insert") auto-creates a Team row
    for every new Tenant — uses raw connection.execute per SQLAlchemy
    event best practice
  - ensure_schema(): ALTER teams to drop NOT NULL, ADD tenants.team_id,
    index, and idempotent backfill that creates a Team + admin TeamMember
    (earliest-joined user) for every existing tenant
- server/team_bootstrap.py (new):
  - attach_admin_if_empty(db, tenant, user_id): idempotent helper called
    at OAuth signup + first-user login. Re-queries tenant.team_id from DB
    because the after_insert listener writes via the raw connection and
    does not hydrate the in-memory ORM attribute.

Smoke tested: event listener fires on flush, stale ORM attr is handled
by the helper, idempotent on repeat. Existing 27 database + teams tests
pass unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(team): tenant-team API endpoints + admin gating (firepan-5o8)

Implements the backend surface for v1 team management. The dashboard's
new Settings > Team page will build against these endpoints.

Endpoints (all under /team/*, distinct from legacy /teams/{id}/members):
- GET  /team                       -> team + members + viewer_role
- POST /team/sync-from-github      -> admin: refresh per-repo collaborators
                                      (phase 1), then merge unique users
                                      into tenant team as role="member"
                                      (phase 2); skip cross-tenant users
                                      and report in cross_tenant_conflicts
- PATCH /team/members/{id}         -> admin: change role (admin|member|viewer)
- DELETE /team/members/{id}        -> admin: remove member (TeamMember row only;
                                      User.tenant_id untouched)

Auth:
- require_team_admin dependency placed alongside get_current_user in
  api.py (no separate module — avoids the circular-import risk a leaf
  module with lazy imports would still carry)
- Self-role-change / self-removal rejected with 409
- Last-admin demotion / removal rejected with 409 (defensive guard)
- GitHub admin perms are NEVER escalated to tenant-team admin

Auth integration:
- attach_admin_if_empty() called in the GitHub + Google OAuth callbacks
  (both new-user and existing-user branches) — first-user-wins bootstrap
  for webhook-created tenants that had no users when the event listener
  created their Team

Refactor:
- Existing /repositories/{id}/sync-team GitHub fetch + per-repo-team
  upsert extracted into _sync_repo_collaborators() so the tenant-wide
  sync can fan out across all connected projects

New DTO (_TenantTeamMemberDTO) tolerates Google-only users (no
github_login) — distinct from the legacy per-repo response shape.

22 new tests in tests/test_team_api.py + 63 existing tests green.
Ruff clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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