Data Model: State Authority Subsystem
Data Model: State Authority Subsystem
Platform: Airtable Base: YFT-StateAuthority
Entity Tables
Users Table
Represents UserEntity - contract-bearing participants.
| Field | Type | Description | Constraints |
|---|---|---|---|
| user_id | Auto Number | Primary key | Unique |
| display_name | Single Line Text | User-friendly identifier | Required |
| operational_state | Single Select | Current contract state | Required |
| fit_profile_ref | Link to Records | Reference to fit profile (future) | Optional |
| weekly_anchor | Single Select | Day of week for cycle start | Required |
| address_id | Link to Records | Shipping address | Optional |
| payment_method_id | Link to Records | Payment reference | Optional |
| created_at | Created Time | Auto-generated | System |
| updated_at | Last Modified | Auto-generated | System |
operational_state Options:
Active- Cycles may be scheduled and committedPaused- Cycles not scheduled, state preservedHoldPayment- Payment issue blocks shippingHoldIdentity- Identity verification requiredHoldLogistics- Address/delivery issue blocks shippingClosed- Contract terminated
Garments Table
Represents GarmentEntity - stateful physical assets.
| Field | Type | Description | Constraints |
|---|---|---|---|
| garment_id | Auto Number | Primary key | Unique |
| sku | Single Line Text | Product identifier | Required |
| barcode | Single Line Text | Physical barcode | Unique |
| asset_state | Single Select | Current lifecycle state | Required |
| condition_grade | Single Select | Quality assessment | Required |
| wear_count | Number | Lifetime wear cycles | Default: 0 |
| wash_count | Number | Lifetime wash cycles | Default: 0 |
| repair_count | Number | Lifetime repairs | Default: 0 |
| max_wear_limit | Number | Lifecycle bound | Default: 50 |
| current_cycle_id | Link to Records | Reserved/active cycle | Optional |
| current_box_id | Link to Records | Packed box | Optional |
| created_at | Created Time | Auto-generated | System |
| retired_at | Date | When retired | Optional |
asset_state Options:
Available- Eligible for assignmentReserved- Selected for cycle, not yet packedPacked- Physically in a boxInTransitOutbound- Shipped to userDelivered- At user locationInUse- Wear window activeInTransitReturn- Returning from userReceivedReturn- Back at facility, pending inspectionQuarantine- Withheld due to hygiene/contaminationRefurbish- In cleaning/refresh processingRepair- In repair processingLost- Declared non-recoverableRetired- Lifecycle complete, ineligibleDisposed- Physically removed from system
condition_grade Options:
A- Like newB- Good, minor wearC- Acceptable, visible wearD- Below standard, needs repairF- Failed, retire or dispose
Computed Fields (Formulas):
lifecycle_remaining:max_wear_limit - wear_countover_limit:IF(wear_count >= max_wear_limit, TRUE(), FALSE())
Boxes Table
Represents BoxEntity - logistics containers.
| Field | Type | Description | Constraints |
|---|---|---|---|
| box_id | Auto Number | Primary key | Unique |
| box_barcode | Single Line Text | Physical barcode | Unique |
| container_state | Single Select | Current logistics state | Required |
| cycle_id | Link to Records | Associated cycle | Optional |
| planned_contents | Link to Records | Intended garments | Multiple |
| actual_contents | Link to Records | Scanned garments | Multiple |
| tracking_outbound | Single Line Text | Carrier tracking number | Optional |
| tracking_return | Single Line Text | Return tracking number | Optional |
| has_variance | Checkbox | Planned ≠ Actual | Computed |
| created_at | Created Time | Auto-generated | System |
container_state Options:
Created- Container existsPlanned- Contents committed logicallyPicking- Warehouse actions in progressPackedVerified- Contents confirmedShipped- Outbound in transitDelivered- At user locationReturnInitiated- Return expectedReturning- Inbound in transitReceived- Back at facilityReconciled- Contents verifiedClosed- Available for reuse
Computed Fields (Formulas):
has_variance: Compare planned_contents vs actual_contentsgarment_count:COUNTA(actual_contents)
Cycles Table
Represents CycleEntity - temporal contract instances.
| Field | Type | Description | Constraints |
|---|---|---|---|
| cycle_id | Auto Number | Primary key | Unique |
| user_id | Link to Records | Associated user | Required |
| week_id | Single Line Text | Derived week identifier | Required |
| cycle_state | Single Select | Current progression state | Required |
| box_id | Link to Records | Associated box | Optional |
| scheduled_at | Date | When cycle was scheduled | Optional |
| committed_at | Date | When inventory was locked | Optional |
| shipped_at | Date | When box shipped | Optional |
| delivered_at | Date | When delivered | Optional |
| return_initiated_at | Date | When return expected | Optional |
| return_received_at | Date | When box returned | Optional |
| settled_at | Date | When settlement computed | Optional |
| closed_at | Date | When cycle finalized | Optional |
cycle_state Options:
Scheduled- Planned but reversibleCommitted- Inventory lockedFulfillmentInProgress- Packing underwayOutboundInTransit- ShippedDelivered- At userWearWindowOpen- User wearingReturnWindowOpen- Return expectedReturnInTransit- Coming backCloseoutInspection- Inspecting returnsSettled- Charges computedClosed- Immutable record
Computed Fields (Formulas):
user_week_key:CONCATENATE(user_id, "-", week_id)(for uniqueness check)
Uniqueness Constraint: Automation rejects creation if user_week_key already exists in Active/Committed cycles.
Events Table
Append-only audit log for all state transitions.
| Field | Type | Description | Constraints |
|---|---|---|---|
| event_id | Auto Number | Primary key | Unique |
| entity_type | Single Select | User/Garment/Box/Cycle | Required |
| entity_id | Number | Reference to entity | Required |
| from_state | Single Line Text | Previous state | Required |
| to_state | Single Line Text | New state | Required |
| transition_type | Single Select | Normal/Compensating/Rejection | Required |
| timestamp | Created Time | When transition occurred | System |
| actor_id | Single Line Text | Who initiated (operator/system) | Required |
| cycle_id | Number | Associated cycle if applicable | Optional |
| metadata | Long Text | JSON additional data | Optional |
| idempotency_key | Single Line Text | Deduplication key | Optional |
| error_code | Single Line Text | If rejection, which error | Optional |
transition_type Options:
Normal- Standard state changeCompensating- Reversal/correction eventRejection- Invalid transition attempt
TransitionRules Table
Defines valid state transitions and their preconditions.
| Field | Type | Description | Constraints |
|---|---|---|---|
| rule_id | Auto Number | Primary key | Unique |
| entity_type | Single Select | User/Garment/Box/Cycle | Required |
| from_state | Single Line Text | Source state | Required |
| to_state | Single Line Text | Target state | Required |
| preconditions | Long Text | JavaScript condition expression | Optional |
| postconditions | Long Text | Actions to perform after | Optional |
| is_active | Checkbox | Rule is enforced | Default: true |
Example Rules:
| entity_type | from_state | to_state | preconditions |
|---|---|---|---|
| Garment | Available | Reserved | current_cycle_id == null |
| Garment | Reserved | Packed | current_box_id != null && box.state == 'Picking' |
| Garment | ReceivedReturn | Available | wear_count < max_wear_limit && condition_grade != 'F' |
| Garment | ReceivedReturn | Retired | wear_count >= max_wear_limit || condition_grade == 'F' |
| Cycle | Scheduled | Committed | user.state == 'Active' && box.state == 'Planned' |
| User | Active | HoldPayment | true (system-initiated) |
| User | HoldPayment | Active | payment_restored == true |
ErrorCodes Table
Lookup table for validation error definitions.
| Field | Type | Description |
|---|---|---|
| error_code | Single Line Text | Unique code (e.g., “E001”) |
| error_name | Single Line Text | Short name |
| error_message | Long Text | User-facing message |
| resolution_hint | Long Text | How to fix |
Example Error Codes:
| Code | Name | Message |
|---|---|---|
| E001 | GarmentAlreadyReserved | This garment is already reserved for another cycle |
| E002 | CycleDuplicate | A cycle already exists for this user/week |
| E003 | InvalidTransition | Cannot transition from {from} to {to} |
| E004 | UserNotActive | User must be in Active state to commit cycle |
| E005 | LifecycleExceeded | Garment has exceeded its lifecycle limit |
| E006 | BoxVarianceUnresolved | Packing variance must be resolved before shipping |
Relationships
Users (1) ──────< Cycles (many)
│
└── Box (1)
│
└──< Garments (many via actual_contents)
Garments ──> current_cycle_id ──> Cycles
Garments ──> current_box_id ──> Boxes
All Entities ──> Events (many)
Indexes / Views
Users Views:
Active Users- Filter: operational_state = ActiveUsers on Hold- Filter: operational_state IN (HoldPayment, HoldLogistics, HoldIdentity)
Garments Views:
Available Inventory- Filter: asset_state = AvailableIn Circulation- Filter: asset_state IN (Reserved, Packed, InTransitOutbound, Delivered, InUse, InTransitReturn)Pending Inspection- Filter: asset_state = ReceivedReturnNear Lifecycle Limit- Filter: lifecycle_remaining <= 5
Cycles Views:
Open Cycles- Filter: cycle_state NOT IN (Settled, Closed)This Week's Cycles- Filter: week_id = CURRENT_WEEKOverdue Returns- Filter: cycle_state = ReturnWindowOpen AND return_initiated_at < TODAY() - 7
Events Views:
Recent Events- Sort: timestamp DESC, Limit: 100Rejections- Filter: transition_type = RejectionBy Entity- Group by entity_type, entity_id