Skip to content

Conversation

@jsell-rh
Copy link
Collaborator

@jsell-rh jsell-rh commented Feb 9, 2026

Summary by CodeRabbit

  • New Features

    • API key entity for managed access and revocation
    • Workspace hierarchies to support nested workspaces
    • Tenant membership model with member and admin roles
  • Updates

    • Permissions reworked: admin + member visibility, admin-managed edits and management
    • Tenant administrate capability added
  • Tests

    • Removed legacy checks for deprecated workspace relation and delete permission

…lembic

- Add SQLAlchemy 2.0 with asyncpg for async database operations
- Add Alembic for schema migrations
- Add python-ulid for ULID support instead of UUID
- Create read/write engine separation with connection pooling
- Create FastAPI dependency injection for database sessions
- Create SQLAlchemy declarative base with timestamp mixin
- Initialize Alembic with async migration support
- Create initial migration for teams table (ULID primary key)
- Add comprehensive unit tests for engines and dependencies
- Configure Alembic to use settings module for database URL
- Enable ruff post-write hook for migration formatting

Refs: AIHCM-121
- Add authzed library for SpiceDB integration
- Add python-ulid for ULID support
- Create ResourceType, RelationType, Permission enums (using Group not Team)
- Create AuthorizationProvider protocol for swappable implementations
- Implement SpiceDBClient with async methods for relationships and permissions
- Create SpiceDB schema (.zed) with Tenant→Workspace→Group hierarchy
- Create AuthorizationProbe for domain-oriented observability
- Move ObservationContext to shared_kernel (fix architectural boundary)
- Add 35 unit tests for types and probes
- All 410 tests passing

Refs: AIHCM-122
Resolved conflicts in authorization files by accepting remote changes:
- shared_kernel/authorization/types.py (docstring fix)
- shared_kernel/authorization/spicedb/client.py (_parse_reference helper)
jsell-rh and others added 18 commits January 29, 2026 12:21
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
…dd route documentation

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
…th TDD

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
Fix workspace definition in schema.zed and ConfigMap to match the
relationships actually created by the IAM outbox translator.

Schema changes (workspace definition):
- Add `relation tenant: tenant` for organizational ownership
- Change `relation parent: tenant` to `relation parent: workspace` for hierarchy
- Rename `owner` to `admin` for consistency with tenant/group definitions
- Rename `permission delete` to `permission manage` for consistency
- Add Phase 3 comments for member/permission usage

ConfigMap changes (full sync with schema.zed):
- Apply all workspace definition fixes above
- Add missing `relation member: user` to tenant definition
- Fix tenant `permission view = admin` to `permission view = admin + member`
- Add missing `permission administrate = admin` to tenant definition
- Add missing `api_key` definition (was in schema.zed but not ConfigMap)
- Add future resource type comments

Inconsistencies found and documented:
1. Schema had `relation parent: tenant` but translator writes
   `workspace#tenant@tenant` (relation name 'tenant') and
   `workspace#parent@workspace` (parent type 'workspace')
2. ConfigMap was missing tenant `member` relation, `administrate`
   permission, and entire `api_key` definition
3. RelationType.WORKSPACE enum exists but is unused by any translator
4. Permission.DELETE enum value corresponds to removed `permission delete`
   in workspace; may need cleanup in Phase 3
5. Schema `owner` relation on workspace renamed to `admin` to align with
   tenant and group naming conventions

All 970 unit tests pass (3 pre-existing SSL failures unrelated).

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
@jsell-rh jsell-rh self-assigned this Feb 9, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Walkthrough

The pull request updates SpiceDB schema and related types/tests. It adds a new public entity api_key with owner and tenant relations and view/revoke permissions; refactors workspace to replace owner with admin, add tenant and parent: workspace relations, and change permissions (view, edit, manage); updates tenant to add member relation and administrate permission; removes WORKSPACE and DELETE enum members from authorization types and deletes corresponding unit tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'workspace authz schema alignment' accurately reflects the main changes, which involve restructuring the workspace authorization schema with role-based access control improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jsell/feat/AIHCM-146-workspace-authz

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
deploy/apps/kartograph/base/spicedb-schema-configmap.yaml (1)

1-144: ⚠️ Potential issue | 🟠 Major

Schemas are out of sync; generate ConfigMap from source schema.

The ConfigMap and source schema differ in indentation (tabs vs. spaces), character encoding ( vs. -> in comments), and whitespace handling. Generate the ConfigMap from src/api/shared_kernel/authorization/spicedb/schema.zed to maintain consistency and prevent future drift.

🧹 Nitpick comments (2)
src/api/shared_kernel/authorization/spicedb/schema.zed (1)

124-127: Future commented code references removed owner relation.

The commented knowledge_graph definition references workspace->owner which no longer exists after the owner→admin migration. Update for consistency when this is implemented.

 *     permission view = viewer + editor + workspace->member
-*     permission edit = editor + workspace->owner
-*     permission delete = workspace->owner
+*     permission edit = editor + workspace->admin
+*     permission delete = workspace->admin
deploy/apps/kartograph/base/spicedb-schema-configmap.yaml (1)

131-134: Same inconsistency: future code references removed owner relation.

Update the commented knowledge_graph definition to reference workspace->admin instead of workspace->owner for consistency with the current schema.

jsell-rh and others added 3 commits February 9, 2026 17:06
Remove RelationType.WORKSPACE and Permission.DELETE which have no usage
in the codebase. Neither value corresponds to any relation or permission
in the current SpiceDB schema. They can be re-added when future resource
types (knowledge_graph, data_source) are implemented.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
…tion

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
…nshift-hyperfleet/kartograph into jsell/feat/AIHCM-146-workspace-authz
@jsell-rh jsell-rh enabled auto-merge (squash) February 9, 2026 22:14
@jsell-rh jsell-rh merged commit be1f258 into main Feb 10, 2026
12 of 15 checks passed
@jsell-rh jsell-rh deleted the jsell/feat/AIHCM-146-workspace-authz branch February 10, 2026 14:45
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.

1 participant