ConnectorSyncDiagnostic

ConnectorSyncDiagnostic is an infrastructure-layer audit log that captures structured failure and informational signals emitted by SyncConfigService during MCP connector sync execution. Each row records the exact tool invoked, the target entity model being synced, the reason the sync event was notable (a failure class or an informational signal such as jury telemetry or pipeline degradation), and a free-text detail message. Rows are tenant-scoped to a Workspace and linked to the specific WorkspaceConnector that triggered the sync. Retention is opportunistic: ConnectorSyncDiagnosticService.write() prunes rows older than 30 days for the current connector on approximately 1-in-20 writes โ€” no separate scheduled job is needed.

NamingValue
ObjectConnectorSyncDiagnostic
Resource type (JSON:API type)connector_sync_diagnostic
Collection / records rootโ€” (not a records root)
REST base/v1/connector-sync-diagnostics
Entity classConnectorSyncDiagnostic

Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

OperationMethod & pathStatus
ListGET /v1/connector-sync-diagnostics๐ŸŸก Planned
RetrieveGET /v1/connector-sync-diagnostics/{id}๐ŸŸก Planned
CreatePOST /v1/connector-sync-diagnostics๐ŸŸก Planned
UpdatePATCH /v1/connector-sync-diagnostics/{id}๐ŸŸก Planned
DeleteDELETE /v1/connector-sync-diagnostics/{id}๐ŸŸก Planned

Data model

Attributes

FieldTypeRequiredConstraintsAllowed valuesDescription
diagnostic_idstring (UUID)โœ… Yesunique; default gen_random_uuid()โ€”Public-facing UUID for this diagnostic row. Generated by the database on insert; never set by the caller.
target_modelenum (TargetModelEnum) โ€” native DB enum target_model_enumโœ… YesNOT NULL; values are the native DB enumcompany | people | invoice | transaction | account | ledger_account | journal | journal_entry | email | payment_means | invoice_transaction | documentThe Well entity model the connector was attempting to sync when this diagnostic was recorded.
tool_namestring (text)โšช Nonullableโ€”Name of the MCP tool that was selected or attempted (e.g. pennylane_get_invoices). Null when the failure occurred before tool selection.
reasonenum (SyncFailureReasonEnum) โ€” native DB enum sync_failure_reason_enumโœ… YesNOT NULL; values are the native DB enumno_suitable_tool | tool_not_found | auth_scope_insufficient | tool_execution_failed | empty_result | jsonata_generation_failed | schema_drift_detected | jury_run | jury_partial | jury_disagreement | jury_quorum_lost | blueprint_persistence_failed | mapped_entities_dropped | mapped_entities_partial_drop | fk_parent_missing | entity_persist_failed | sync_fk_dag_cycle | regression_reverted | target_skipped | structured_pipeline_degraded | structured_pipeline_fell_back_to_legacy | mapping_generation_hard_fail | tool_selection_pinnedTaxonomy code classifying the sync event. Values in INFORMATIONAL_REASONS (jury_run, jury_disagreement, schema_drift_detected, target_skipped, structured_pipeline_degraded, structured_pipeline_fell_back_to_legacy, tool_selection_pinned) are non-blocking signals; all others are FAILURE class.
http_statusintegerโšช Nonullableโ€”HTTP status code returned by the upstream MCP tool call, when available. Absent for failures that occur before an HTTP round-trip (e.g. mapping generation failures).
detailstring (text)โœ… YesNOT NULLโ€”Human-readable description of the failure or informational event. Written by SyncConfigService at the point of detection; not machine-parsed.
occurred_attimestamp with time zoneโœ… YesNOT NULL; default now(); set by onCreate hookโ€”Wall-clock timestamp at which the sync event occurred. Set once on insert; not updated. Distinct from created_at to support future back-dated ingestion of diagnostic events.
created_attimestamp with time zoneโœ… YesNOT NULL; default now(); set by onCreate hookโ€”Row creation timestamp. Set once by the MikroORM onCreate hook.
updated_attimestamp with time zoneโšช Noset by onCreate and onUpdate hooksโ€”Row last-updated timestamp. Maintained automatically by MikroORM.
deleted_attimestamp with time zoneโšช Nonullableโ€”Soft-delete timestamp. When non-null the row is logically deleted. Pruning in ConnectorSyncDiagnosticService.write() hard-deletes rows older than 30 days for the current connector.

Relationships

NameTypeRequiredDescription
workspaceto-one (ManyToOne)โœ… YesThe tenant workspace that owns this diagnostic. FK column workspace_pk references core_api.workspaces(pk) with ON UPDATE CASCADE ON DELETE CASCADE. Used to scope diagnostic queries per tenant.
workspaceConnectorto-one (ManyToOne)โœ… YesThe specific WorkspaceConnector instance (provider + auth config) whose sync run produced this diagnostic. FK column workspace_connector_pk references core_api.workspace_connectors(pk) with ON UPDATE CASCADE ON DELETE CASCADE. Retention pruning is scoped to this connector's rows.

System-computed

  • diagnostic_id โ€” generated by gen_random_uuid() at DB level; never supplied by the caller
  • occurred_at โ€” set to now() by MikroORM onCreate hook at insert time
  • created_at โ€” set to now() by MikroORM onCreate hook at insert time
  • updated_at โ€” set to now() by MikroORM onCreate and onUpdate hooks
  • deleted_at โ€” set by application-level soft-delete; also used as the threshold for opportunistic hard-delete pruning (rows older than 30 days for the current connector are pruned inside ConnectorSyncDiagnosticService.write() on approximately 1-in-20 writes)
  • pk (internal) โ€” serial auto-increment; not exposed via the public API

Example

{
  "data": {
    "type": "connector_sync_diagnostic",
    "id": "a3f7e812-0c2e-4d1b-9b4a-001122334455",
    "attributes": {
      "diagnostic_id": "a3f7e812-0c2e-4d1b-9b4a-001122334455",
      "target_model": "invoice",
      "tool_name": "pennylane_get_invoices",
      "reason": "mapped_entities_dropped",
      "http_status": 200,
      "detail": "Validator rejected 12/12 mapped entities: required field 'issue_date' null after JSONata mapping for tool pennylane_get_invoices",
      "occurred_at": "2026-06-01T14:32:07.000Z",
      "created_at": "2026-06-01T14:32:07.000Z",
      "updated_at": "2026-06-01T14:32:07.000Z",
      "deleted_at": null
    },
    "relationships": {
      "workspace": {
        "data": { "type": "workspace", "id": "wsp_abc123" }
      },
      "workspace_connector": {
        "data": { "type": "workspace_connector", "id": "wsc_xyz789" }
      }
    }
  }
}
Source: apps/api/src/database/entities/ConnectorSyncDiagnostic.ts ยท domain: ingestion ยท tier: Infrastructure