{
  "schema": "ouro-send-and-log-repair-receipt/1.0",
  "generated_at": "2026-08-23T15:05:24Z",
  "handler": "coils/send-and-log (canonical, repaired 2026-08-23)",
  "adapters": "fully mocked Resend + mocked Ouro datasets; zero real sends, zero real CRM mutations",
  "sanitization": "all contacts synthetic *.invalid; controller CCs resolved from runtime config and verified in the mock; no real message ids or thread content",
  "summary": {
    "cases_total": 8,
    "cases_passed": 8,
    "all_passed": true,
    "mock_sends_dry_run": 0,
    "mock_sends_duplicate_retry_total": 1
  },
  "cases": [
    {
      "case_id": "T1-first-send",
      "passed": true,
      "sends": 1,
      "idempotency_key": "hermes:c1a00000-0000-4000-8000-000000000001:cold:first",
      "crm_status": "sent",
      "first_send_detected": true,
      "errors": []
    },
    {
      "case_id": "T2-follow-up",
      "passed": true,
      "sends": 1,
      "idempotency_key": "hermes:c1a00000-0000-4000-8000-000000000001:followup:followup-mock-1001",
      "follow_up_sent": "true",
      "write_once_preserved": true,
      "errors": []
    },
    {
      "case_id": "T3-live-thread-reply",
      "passed": true,
      "sends": 1,
      "idempotency_key": "hermes:c1a00000-0000-4000-8000-000000000001:reply:mock-in-3001",
      "write_once_preserved": true,
      "errors": []
    },
    {
      "case_id": "T4-deterministic-retry",
      "passed": true,
      "total_sends_across_attempts": 1,
      "message_id": "mock-2001",
      "crm_status": "sent",
      "first_send_fields_complete": true,
      "errors": []
    },
    {
      "case_id": "T5-daily-cap-block",
      "passed": true,
      "sends": 0,
      "crm_unchanged": true,
      "errors": []
    },
    {
      "case_id": "T6-malformed-sql-fallback",
      "passed": true,
      "subcases": [
        {
          "backend_mode": "unresolved_placeholder",
          "sends": 1,
          "crm_status": "sent",
          "fallback_used": true
        },
        {
          "backend_mode": "raise_always",
          "sends": 1,
          "crm_status": "sent",
          "fallback_used": true
        }
      ],
      "errors": []
    },
    {
      "case_id": "T7-dry-run-zero-side-effects",
      "passed": true,
      "sends": 0,
      "crm_mutations": 0,
      "first_send_preview": true,
      "followup_preview": true,
      "errors": []
    },
    {
      "case_id": "T8-second-followup-guard",
      "passed": true,
      "sends": 0,
      "crm_unchanged": true,
      "errors": []
    }
  ],
  "live_verification": {
    "description": "The repaired canonical handler was additionally executed in dry_run mode against the REAL Ouro CRM (read-only lookup; stubbed resend module that raises if called). No email was sent and no CRM row was mutated.",
    "case": "existing sent row (real CRM row, name withheld in public artifacts): first_send_detected=false, sparse preview upsert containing only last-outbound/email_id/next_action, write-once fields absent; sends=0, crm_updated=false.",
    "case_2": "synthetic absent contact id: first_send_detected=true, full six-field first-send preview; sends=0, crm_updated=false.",
    "sends": 0,
    "crm_mutations": 0
  },
  "handler_repairs": [
    "CRM table reference resolved before SQL: literal {{table}} token, single-brace residue guard, client-side pandas fallback when the SQL path fails (unresolved placeholder or backend error)",
    "zero-side-effect dry_run path (no Resend call, no CRM write; read-only lookup for first-send detection)",
    "deterministic idempotency keys preserved (hermes:{contact_id}:{intent}:{trigger}, <=256 chars)",
    "both required controller CCs preserved on every send (cc field, never bcc)",
    "new guards: second-follow-up refusal (follow_up_already_sent), daily-cap refusal at >=8 outbound for cold/followup/nudge (reply may still go out and counts), follow_up_sent lowercase-string validation"
  ],
  "coil_inputs_added": [
    "dry_run",
    "daily_outbound_count",
    "reply_received"
  ]
}