Sync Write Enforcement V1 (Lite)
Intent
Section titled “Intent”Define a lightweight enforcement baseline for syncable domain-table writes that is strong enough for early implementation, without heavy security engineering.
This document enforces one write path for syncable domain tables while keeping rollout cost low.
Non-Goals (For V1 Lite)
Section titled “Non-Goals (For V1 Lite)”- Full database privilege lockdown matrix
- Trigger-heavy write-path policing
- Cross-service cryptographic signing of mutation envelopes
- Formal policy engine integration
These can be added in later hardening phases.
V1 Lite Enforcement Policy
Section titled “V1 Lite Enforcement Policy”For syncable domain tables:
- Only
POST /api/mutationsto the supabase functions endpoind is an accepted write ingress. - Write backend must be pgxsinkit
bulk-plpgsql-artifact. - Per-route CRUD writes are disabled and treated as policy violations.
- Operations logging must remain enabled.
Minimal Required Controls
Section titled “Minimal Required Controls”1) Runtime Configuration Guard
Section titled “1) Runtime Configuration Guard”Require at startup:
WRITE_API_BACKEND=bulk-plpgsql-artifactWRITE_API_OPS_LOG_ENABLED=true
If either condition is not satisfied, startup should fail in environments handling syncable domain workloads.
Lightweight CI/Verification Gates
Section titled “Lightweight CI/Verification Gates”Run these gates in CI or pre-release checks:
- Artifact mode startup verification passes.
- Batch mutation contract test passes for create/update/delete.
- Operations log contains rows for successful and failed mutation attempts.
Lightweight Production Checks
Section titled “Lightweight Production Checks”At minimum, monitor:
- Write ingress error rate for
/api/mutations - operations_log status distribution (
succeeded,validation_failed,execution_failed)
Exception Policy
Section titled “Exception Policy”Emergency/manual data repair is allowed, but must be:
- Time-bounded
- Documented
- Followed by reconciliation verification
Use explicit runbook steps rather than silent ad hoc writes.
Planned Hardening (Later)
Section titled “Planned Hardening (Later)”When needed, add in this order:
- DB role-level DML restrictions for syncable tables
- Optional enforced FK linkage from syncable rows to operation log identifiers
- Automated bypass detection alerts and SLO gating
- Formal exception workflow tooling
Implementation Anchors
Section titled “Implementation Anchors”- Write ingress and backend mode:
apps/api(runs obligatorily via supabase functions at$SUPABASE_URL/functions/v1) - Sync integration and diagnostics:
packages/offline-data - Operation logging schema: external pgxsinkit server package
- Domain-table schema linkage fields:
packages/db