Project Figma File Collection
Overview
Collection for project โ Figma-file bookkeeping (moved off PostgreSQL โ AI-owned).
The plugin file-registration writes role/config_url via wf2des-api; component_sweep
writes the sync fields (components_synced_at / sweep_error), captures style_captures,
and holds the single-flight sweep_marker. The assemble phase reads style_captures
(source of the derived spec style_bindings) and config_url (the DESIGN-area rect).
Table Definition
| Logical Name | Physical Name | Column Name | Data Type | Primary Key | Relation | Unique | Nullable | Default Value | Remarks |
|---|---|---|---|---|---|---|---|---|---|
| Project Figma File | project_figma_file | _id | string | โฏ | uuid stored in DocumentDB _id. Project โ Figma file bookkeeping (moved off PG โ AI-owned) |
||||
| organization_id | number | organization:id | Tenant owner. Part of UNIQUE (organization_id, project_id, figma_file_key) | ||||||
| project_id | number | project:id | Project scope. Part of UNIQUE (organization_id, project_id, figma_file_key) | ||||||
| figma_file_key | string | Figma file key (verbatim; alphanumeric, no underscore). Part of UNIQUE (organization_id, project_id, figma_file_key) | |||||||
| role | number | File role โ plugin file-registration writes this via wf2des-api. 0: working (generation output file) 1: library (component/rule source) |
|||||||
| components_synced_at | datetime | Last successful component_sweep โ the freshness watermark, updated LAST after the sweep completes |
|||||||
| config_url | string | S3 key of the per-project ingest config.json (WF/DESIGN area patterns, memo markers). Home {org}/{proj}/wf2des/config.json; the assemble phase resolves the DESIGN-area rect from it |
|||||||
| sweep_error | string | โฏ | Latest component_sweep failure, else null |
||||||
| style_captures | object | { <token>: string } โ file-level local text styles + color variables, one per figma_file_key; each token maps to a Figma style/variable id. The derived spec style_bindings map is produced from this |
|||||||
| sweep_marker | object | โฏ | { token: string, acquired_at: datetime, expires_at: datetime } โ single-flight lock for component_sweep (crash-safe with stale-lock recovery; a lock past expires_at is reclaimable). NULL when no sweep is in flight |
||||||
| index_schema_version | number | Document schema version (schema-governance parity) | |||||||
| created_at | datetime | Creation timestamp | |||||||
| updated_at | datetime | Last-update timestamp |
Relations
- organization_id โ organization.id
- project_id โ project.id
figma_file_keyโ the Figma file key; joins to thedesign(type=component) rows anddesign_componentdocs of components swept from this file.- No direct relation is enforced inside DocumentDB; relations are logical and validated by application code.
Indexes
- PRIMARY KEY (_id)
- UNIQUE (organization_id, project_id, figma_file_key) โ one bookkeeping doc per project file
- Secondary index on
role(organization_id, project_id, role) โcomponent_sweepscopes its walk to a project's registered files (working + library roles)
Type Codes
role
- 0: working (generation output file)
- 1: library (component/rule source)
Notes
- Two disjoint writers, no conflict. The plugin file-registration writes
role/config_urlthrough wf2des-api;component_sweepwritescomponents_synced_at,sweep_error,style_captures, andsweep_markerdirectly. The writes are field-level and never overlap. sweep_markeris the single-flight guard forcomponent_sweepโ acquired at the start of a sweep and released/expired at the end; a marker pastexpires_atis reclaimable (crash-safe stale-lock recovery).components_synced_atis updated LAST, only after the sweep completes, so it doubles as the run-freshness signal for otherwise ledger-free internal runs.style_capturesis the single source of the derived specstyle_bindingsmap produced during the assemble phase; it was relocated here fromdesign_componentso there is exactly one capture set perfigma_file_key.config_urlpoints at the per-projectconfig.json; the assemble worker reads it to resolvedesign_generation_result.placement.design_area(the plugin never reads project config directly).- Only
created_at/updated_ataudit columns โ no soft-delete (nodeleted_at). Component removal is recorded on the platformdesignrow's status, not here. - This collection intentionally omits the shared
lineageenvelope that the other five wf2des collections carry: it has two disjoint writers and no single producing run, so provenance is per-field (components_synced_at/sweep_error) plusindex_schema_version, not a run-scoped envelope.