Skip to main content
WorkspaceIdentityExtraction is an evidence ledger that the self-invoice consensus mechanism uses to identify the workspace owner’s own business identity from processed invoices. Each row captures one (field, value) pair extracted from a single invoice that was determined to originate from or be addressed to the workspace owner, classified by the signal that triggered that determination. The service WorkspaceSelfIdentityService reads these rows to check whether N≥2 independent invoices agree on a given identity field value before committing it to WorkspaceAccountingSettings. The table is workspace-scoped and soft-deleted; both foreign keys cascade on hard delete of the parent workspace or source invoice.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

Data model

Attributes

Relationships

System-computed

  • workspace_identity_extraction_id — generated by gen_random_uuid() at row creation via defaultRaw; client never supplies this value
  • created_at — set by @Property onCreate hook; no updated_at on this entity (it is append-only evidence; rows are never mutated after insert)
  • deleted_at — soft-delete; set by the pipeline when an evidence row is invalidated, not by user action
  • pk — internal auto-increment serial primary key; never exposed via the API
  • Partial UNIQUE constraint uq_wie_workspace_field_invoice (workspace_pk, field_name, source_invoice_pk) WHERE deleted_at IS NULL — enforced by the migration, not expressible in ORM decorators; prevents double-insert race during concurrent registerOne calls for the same invoice
  • Partial index idx_wie_workspace_field (workspace_pk, field_name) WHERE deleted_at IS NULL — hot-path index for the consensus query in WorkspaceSelfIdentityService.checkConsensusAndAct
  • Rows are created exclusively by WorkspaceSelfIdentityService (extraction pipeline); no user-facing PATCH endpoint exists for this entity
  • tax_id_type is conditionally populated: only the extraction service sets it, and only when field_name === ‘tax_id_value’

Example

Source: /Users/maximechampoux/platform/apps/api/src/database/entities/WorkspaceIdentityExtraction.ts · domain: ingestion · tier: Infrastructure