fix(workspaces): default parent_id to the org's platform root + backfill orphans (core#2609) #2610
Reference in New Issue
Block a user
Delete Branch "fix/2609-default-parent-platform-root"
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?
Durable fix for core#2609 (CTO directive: no more hand-patching). Create defaults
parent_idto the org's single livekind='platform'root (fail-soft: bootstrap/no-root and ambiguous multi-root DBs keep NULL). Backfill migration reparents existing orphans, guarded + idempotent, no-op down. Also closes the #2601 mechanism (depth-1 placement). Tests included; full handlers pkg green.🤖 Generated with Claude Code
A create without an explicit parent landed as a parent_id-NULL orphan ROOT beside the org's kind='platform' root — outside the org subtree, so A2A denies the concierge ('workspaces cannot communicate per hierarchy rules') and the canvas renders it depth-1 beside the root (the #2601 mechanism). Live failure: the enter-os concierge provisioned its first two team workspaces and could not delegate to either. - Create now defaults parent_id to platformRootWorkspaceID() — the single live kind='platform' row. Best-effort fail-soft: no root (bootstrap) or >1 roots (multi-org self-host) leaves NULL intact. - Backfill migration reparents existing NULL-parent orphans under the platform root, guarded to DBs with exactly one platform root; idempotent; down is a deliberate no-op (re-orphaning re-breaks A2A). - Tests: default-to-root and no-root-keeps-NULL; existing explicit-parent test unchanged. Closes core#2609; fixes the #2601 mechanism. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>Approved from code review.
SOP / five-axis review:
Correctness: The create path now defaults a missing
parent_idto the single livekind='platform'root, which directly addresses core#2609 and the #2601 depth-1/orphan mechanism. Explicitparent_idremains untouched. The migration repairs existing NULL-parent non-platform workspaces under the same single-root guard.Robustness: The root lookup is fail-soft for bootstrap/no-root and ambiguous roots, so workspace creation does not gain a new hard dependency. The migration is guarded and idempotent, excludes the platform root and removed rows, and the no-op down migration is appropriate for an irreversible data repair.
Security: This preserves the existing hierarchy isolation model instead of weakening A2A rules. No new input trust, auth bypass, secrets, SSRF surface, or cross-workspace permission grant is introduced beyond placing previously orphaned same-org workspaces under the org root.
Performance: The create-time lookup is a bounded
LIMIT 2query onkind; the backfill is a one-time migration. No request-path N+1 or unbounded loop issue found.Readability: The comments explain the production failure and the fail-soft semantics clearly. Tests cover both the single-root default and no-root fallback.
Caveats: I could not run local Go tests because this runtime lacks the
gobinary. Current commit status is not fully green yet: several approval/gate checks are failing and some jobs are pending; those should be resolved before merge.