feat: platform-agent participant kind (Phase 0) #2361
Reference in New Issue
Block a user
Delete Branch "feat/platform-agent-kind"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 0 of the org-level platform agent (RFC #2360 /
docs/design/rfc-platform-agent.md).Adds the
kindparticipant discriminator onworkspaces(workspacedefault |platform) — the foundation for the tenant-resident concierge. Backward-compatible and ships alone; no behavior change for existing workspaces (every row defaults tokind=workspace).What
20260606000000_workspaces_kind:kindcolumn (defaultworkspace),workspaces_kind_check, and a race-proofworkspaces_platform_root_check(kind=platform⇒parent_id IS NULL) which structurally guarantees one platform agent per org. CHECKs addedNOT VALIDthen validated — cannot fail on legacy data.KindonWorkspace+RegisterPayload,KindWorkspace/KindPlatform,IsValidKind.kind; carries it viaCOALESCE(NULLIF($6,'),…)so unspecified defaults toworkspaceon insert and never downgrades a platform row on re-register; maps the constraint violation to a friendly 409.Tests (comprehensive)
IsValidKind; Register invalid-kind → 400; Register platform-kind persists → 200 (sqlmock asserts the upsert carriesplatform).-tags=integration,^TestIntegration_PlatformKind): proves the constraint accepts a root platform agent and rejects a non-root one, default isworkspace, and bogus kind is rejected — verified locally against postgres:15 (all 71 migrations apply, test green) and gated by the handlers-postgres-integration workflow.Not in this PR
Platform-as-root re-parenting, provisioning, two-MCP runtime, approval gate — follow in Phases 1–4 per the RFC.
🤖 Generated with Claude Code
Introduce the 'kind' discriminator on workspaces ('workspace' default | 'platform') — the foundation for the org-level platform agent (RFC docs/design/rfc-platform-agent.md). A 'platform' workspace is the org-level concierge that sits at the org root and is the user's default A2A target. - migration 20260606000000_workspaces_kind: adds kind column (default 'workspace', backward-compatible), workspaces_kind_check, and a race-proof workspaces_platform_root_check (kind='platform' requires parent_id IS NULL) which structurally also guarantees one platform agent per org. - models: Kind field on Workspace + RegisterPayload, KindWorkspace/KindPlatform consts, IsValidKind. - Register: validates kind, carries it through the upsert via COALESCE(NULLIF(,''), …) so an unspecified kind defaults to 'workspace' on insert and never downgrades a platform row on re-register; maps the DB constraint violation to a friendly 409. - tests: IsValidKind unit tests, Register invalid-kind (400) + platform-kind persist (200) sqlmock tests, and a real-Postgres integration test proving the constraint accepts a root platform agent and rejects a non-root one (sqlmock cannot evaluate a CHECK). Backward-compatible and ships alone. No CanCommunicate change (platform == org root reuses existing ancestor/descendant rules). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>merge-queue: updated this branch with
mainate441def8b3a8. Waiting for CI on the refreshed head.merge-queue: updated this branch with
mainat31283a292a34. Waiting for CI on the refreshed head.merge-queue: updated this branch with
mainatd768d8667b0f. Waiting for CI on the refreshed head.Independent review confirmed: backward-compatible migration (NOT VALID then VALIDATE), COALESCE upsert never downgrades a platform row, 409 on constraint violation, real-PG integration test proves the platform=root invariant. Build+tests green. Approving.
Security review: parameterized SQL, DB-enforced platform-root invariant (race-proof CHECK), no backward-compat break, friendly 409 not 500. Approving.