Update README.md#41
Merged
Merged
Conversation
|
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.