---
id: WF-MBR-STR-007
title: 'Provision, reset and purge a workspace''s structure'
trigger: >-
  Platform invokes the structural participant for provisioning, verification, reset, purge, inventory or
  export.
product_area: membership
module: structure
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
source_sha:
  services-membership: 5994c270e8a37a30f848e99ba5b5ee6b87c08893
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
inference: []
implements:
  - CAP-MBR-STR-020
moves: []
crosses:
  - SVC-PFM-TNL-membership-tenant-lifecycle
  - SVC-MBR-STR-structure
idempotency: >-
  The seed ledger skips previously applied purposes. Removal processes remaining rows in batches until done,
  and export advances from its supplied cursor. These local contracts support resumed calls without proving
  Platform's retry policy.
concurrency: >-
  Lifecycle state is checked separately from removal batches. The participant neither stops ordinary traffic
  nor serializes complete lifecycle runs; Platform coordination of those conditions is outside this source
  scope.
hops:
  - 'n': 1
    actor_or_service: Platform workspace lifecycle
    action: Invoke provisioning for a new workspace or initialization for an earlier workspace.
    anchor: 'services-membership:modules/structure/services/lifecycle/structure-participant.ts:structureParticipant'
    seam: sync
    on_failure: The participant can fail its call; Platform transport and retry guarantees are unknown here.
    left_inconsistent: Provisioning remains incomplete until standard purposes have been applied.
    observer: Platform's lifecycle status and verify answer
    provenance: unknown
    source: FND-MBR-STR-051
  - 'n': 2
    actor_or_service: Structure participant
    action: >-
      Apply missing legal-entity, operating, beneficiary and recipient purpose seeds and record their ledger
      keys.
    anchor: >-
      services-membership:modules/structure/services/lifecycle/structure-participant.ts:RELATIONSHIP_TYPES_SEED_SET
    seam: sync
    on_failure: Return a failure for the incomplete call; already applied seeds are skipped on a later invocation.
    left_inconsistent: Verification can report missing seed keys until provisioning completes.
    observer: verify reports the missing seeds
    provenance: test
    source: >-
      services-membership:modules/structure/tests/integration/services/lifecycle/structure-participant.integration.spec.ts#the
      structure participant in the database › writes nothing on a second provisioning
  - 'n': 3
    actor_or_service: Structure participant
    action: >-
      For reset, accept deleting or loading state and remove structural data and versions in batches while
      preserving kinds and relationship purposes.
    anchor: 'services-membership:modules/structure/services/lifecycle/structure-participant.ts:resetStructure'
    seam: sync
    on_failure: Reject disallowed lifecycle state before removal; batch errors stop progress.
    left_inconsistent: 'Between batches data is incomplete; ancestry is removed before units, and retained kinds remain.'
    observer: Platform's lifecycle progress
    provenance: test
    source: >-
      services-membership:modules/structure/tests/integration/services/lifecycle/structure-participant.integration.spec.ts#the
      structure participant in the database › resets the tree of a tenant being reset and keeps its unit and
      relationship types
  - 'n': 4
    actor_or_service: Structure participant
    action: >-
      For purge, require deleting state and remove structural data, kind configuration and finally versions
      through the owner's function.
    anchor: 'services-membership:modules/structure/services/lifecycle/structure-participant.ts:structureParticipant'
    seam: sync
    on_failure: Reject an invalid state or stop at the failed batch.
    left_inconsistent: The workspace remains partly purged until further calls finish.
    observer: Platform's lifecycle progress; inventory counts
    provenance: test
    source: >-
      services-membership:modules/structure/tests/integration/services/lifecycle/structure-participant.integration.spec.ts#the
      structure participant in the database › purges every table of a tenant being deleted, versions included,
      and leaves another tenant whole
  - 'n': 5
    actor_or_service: Structure participant
    action: 'Stream unit, kind and version export datasets using the caller''s cursor; omit derived ancestry.'
    anchor: 'services-membership:modules/structure/services/lifecycle/structure-participant.ts:structureParticipant'
    seam: sync
    on_failure: Return export failure; external retry and staging behavior are not established by this participant.
    left_inconsistent: The staged export may remain incomplete until remaining batches are collected.
    observer: Platform's export job
    provenance: observed
    source: 'services-membership:modules/structure/services/lifecycle/structure-participant.ts:structureParticipant'
branches:
  - 'Purge does not clear seed-ledger entries, so reusing a workspace identity does not reapply those seeds.'
  - >-
    Development seeds converge on five kinds and eight fixed-identity units through ordinary tree services
    without deleting added records.
  - Configuration tables are declared by the memberships lifecycle participant.
waits:
  - Another invocation is required to continue batched removal or export.
evidence:
  - >-
    services-membership at 5994c270: modules/structure/services/lifecycle/structure-participant.ts;
    services/persistence/structure-tenant-rows.ts; services/well-known/well-known-structure.ts;
    modules/tenant-lifecycle/services/lifecycle/participants.ts; docs/migrations/structure/README.md (tenant
    lifecycle).
controls: [TC-AVL-002, TC-AVL-003, TC-AVL-004, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-CHG-001, TC-CHG-002, TC-CHG-003, TC-CHG-004, TC-CRY-001, TC-CRY-002, TC-CRY-003, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-DAT-004, TC-DAT-005, TC-DAT-007, TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-MON-001, TC-MON-002, TC-MON-004, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-PRV-001, TC-PRV-002, TC-SEC-001, TC-SEC-004, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-TEN-004]
---

# Provision, reset and purge a workspace's structure

## What It Does

The participant supplies Membership's structural part of workspace lifecycle. Provisioning applies standard relationship purposes, reset preserves kind configuration, purge removes the full structure and export streams source data and versions without derived ancestry.

## The Flow

```mermaid
sequenceDiagram
  participant Platform
  participant Structure
  participant Database
  Platform->>Structure: provision or initialize
  Structure->>Database: apply missing seeds with ledger
  Structure-->>Platform: applied and skipped
  Platform->>Structure: reset or purge batch
  Structure->>Database: check allowed lifecycle state
  Structure->>Database: remove next batch, versions last
  Structure-->>Platform: more or done
  Platform->>Structure: export with cursor
  Structure-->>Platform: dataset batch
```

## When Something Fails

Batches can leave partially removed data until the coordinator continues. The local state check prevents removal calls in disallowed states but is separate from the deletion transaction. Platform retries, traffic exclusion and whole-run serialization remain unknown here; seed-ledger retention also matters if an identity is reused.

## Open Design Questions

Product and Architecture must settle seed retention on purge and coordination guarantees during removal. Development convergence should have an explicit policy for units a developer has repositioned.
