{
  "id": "k-obs-01",
  "title": "Single-record sync observability: remote id + LastModified present and internal _System_OutboxEvent readable",
  "kind": "hubspot_sync",
  "linkedIssues": [],
  "provenance": {
    "businessScenario": "K-OBS-01 — a synced object must expose last-sync evidence agent-readably. This case takes the relaxed minimum: create an outbound Lead (Title control), poll HubSpot_Id__c writeback, then assert the remote id + LastModifiedDate are queryable as last-sync evidence, and that the internal _System_OutboxEvent audit table is readable over REST.",
    "reportedBy": "HubSpot sync spec K-OBS-01 (hubspot-nexuscrm-sync-CASE-EXEC-SELFCONTAINED)",
    "capturedAt": "2026-06-18",
    "calibrated": "[calibrated] removed the optional marker and the non-existent _System_Sync_Attempt__c probe; the audit step now queries _System_OutboxEvent (verified REST-readable on ksyun, returns 200 + records). Capped the writeback poll at 90s (intervalMs 6000)."
  },
  "steps": [
    {
      "id": "create",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Lead",
      "body": { "LastName": "Obs-{{__runId}}", "Company": "O-{{__runId}}", "Email": "obs-{{__runId}}@example.com", "Title": "ObsBase", "HubSpot_Sync_Enabled__c": true },
      "expectStatusRange": [200, 299],
      "assertions": [ { "path": "response.body.id", "exists": true } ]
    },
    {
      "id": "wait",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT HubSpot_Id__c FROM Lead WHERE Id='{{steps.create.response.body.id}}'",
      "expectStatus": 200,
      "poll": { "budgetMs": 90000, "intervalMs": 6000 },
      "onTimeout": "fail",
      "assertions": [
        { "path": "response.body.records[0].HubSpot_Id__c", "exists": true }
      ]
    },
    {
      "id": "evidence",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT HubSpot_Id__c,LastModifiedDate FROM Lead WHERE Id='{{steps.create.response.body.id}}'",
      "expectStatus": 200,
      "assertions": [
        { "path": "response.body.records[0].HubSpot_Id__c", "exists": true },
        { "path": "response.body.records[0].LastModifiedDate", "exists": true }
      ]
    },
    {
      "id": "audit",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT Id FROM _System_OutboxEvent LIMIT 1",
      "expectStatus": 200,
      "assertions": [
        { "path": "response.body.done", "exists": true }
      ]
    }
  ]
}
