Docs Index
sync error assist.md

Proof Card: Sync Error AI Assist

Status: beta Last verified: 2026-05-12 · git sha cbad5ec6 (watermark-race recovery follow-up)

Claim

A NetSuite-side User Event SuiteScript POSTs sync-error records to /api/sync-error-assist/ingest with HMAC-signed payload; the server returns 202 Accepted after the synchronous claim row insert, then runs the AI suggestion pipeline in a setImmediate fire-and-forget worker. The 30-minute polling reconcile continues to run alongside (PR 17a path) as a back-stop for missed webhooks. Per-tenant opt-in via tenant_configurations.sync_error_assist.enabled='true' AND sync_error_assist.webhook_enabled='true'. PR 17a shipped data + service core; PR 17b shipped operator review UI; PR 17c wires the real-time webhook ingest.

Source

Tests

Live vs Fixture

Known Gaps

Verification (60-second AI-reviewer recipe)

# Unit + integration tests (PR 17a + 17b + 17c)
npx jest tests/unit/services/syncErrorAssist tests/unit/middleware/syncErrorAssistWebhook.test.ts tests/unit/routes/syncErrorAssistWebhookSchema.test.ts tests/unit/routes/syncErrorAssistIngestRoute.test.ts tests/integration/syncErrorAssist.fixture.test.ts tests/integration/syncErrorAssistMiddleware.integration.test.ts tests/integration/syncErrorAssistWebhook.integration.test.ts

# Sanity check — confirm the per-record timeout is wired
grep -n "PER_RECORD_TIMEOUT_MS\|withTimeout" src/services/syncErrorAssist/SyncErrorAssistService.ts

# Confirm OCC guard on update methods
grep -n "where('status', '=', 'processing')" src/services/syncErrorAssist/SyncErrorAssistRepository.ts

# Confirm webhook HMAC verifier is constant-time
grep -n "timingSafeEqual" src/middleware/syncErrorAssistWebhook.ts

# Confirm atomic watermark gate (single-statement INSERT-with-NOT-EXISTS-and-CONFLICT-WHERE)
grep -n "tryAdvanceWatermark" src/services/syncErrorAssist/SyncErrorAssistRepository.ts