2.5 KiB
2.5 KiB
Phase 1 — Data Model (096 Ops Polish Bundle)
No new tables are required. The feature reuses existing operational ledger and seed data structures.
Entity: operation_runs (tenant-scoped and workspace-scoped)
Purpose: Canonical ledger for background operations (status, timestamps, outcomes, counters, failures).
Key fields (existing):
id(PK)workspace_id(FK, required)tenant_id(FK, nullable)- Tenant-scoped operations: non-null
- Workspace-scoped operations (housekeeping): null
user_id(FK, nullable) — initiator user when applicableinitiator_name(string) — stored label for system/usertype(string) — operation type (e.g.,assignments.fetch,assignments.restore,ops.reconcile_adapter_runs)status(string) —queued|running|completed(seeOperationRunStatus)outcome(string) —pending|succeeded|failed(seeOperationRunOutcome)run_identity_hash(string) — deterministic identity hashsummary_counts(json/jsonb array) — normalized counters (keys constrained byOperationCatalog::allowedSummaryKeys())failure_summary(json/jsonb array) — entries like{ code: string, message: string }(sanitized, stable)context(json/jsonb object) — non-secret context, may include selection metadatastarted_at,completed_at(timestamps)created_at,updated_at
Constraints / indexes (existing):
- Active-run dedupe is enforced at the DB layer using partial unique indexes:
- Tenant runs: unique on
(tenant_id, run_identity_hash)for active statuses. - Workspace runs: unique on
(workspace_id, run_identity_hash)whentenant_id IS NULLfor active statuses.
- Tenant runs: unique on
Feature usage:
- Assignment jobs: ensure a stable
run_identity_hashbased on the clarified identity rule; persistsummary_countsat terminal completion. - Reconcile housekeeping job: create/reuse a workspace-scoped run (tenant_id null) and persist success/failure + summary counts.
Entity: tenants
Purpose: Tenant scope boundary; owns tenant-scoped operation_runs and policies.
Field (in scope):
external_id(string)
Feature requirement:
- Seeded tenants must have
external_idset to a UUID v4 string.
Notes on validation / sanitization
- Summary counters must be normalized/sanitized before persistence (existing
OperationRunServicebehavior). - Failure summaries must store stable reason codes + sanitized messages (no secrets/tokens/PII/raw payload dumps).