← back to Dw Signup Fulfillment

verification/e2e-proof.json

1399 lines

{
  "task_id": "TK11285-cycle0645-owner",
  "ticket": "TK-11285",
  "correlation_id": "M02037",
  "intent": "An approval is recorded only after successful Shopify writes, readback of trade_approved on the intended customer, and acknowledged emails; retries preserve completed email receipts.",
  "risk_tier": "R3 local external-integration simulation",
  "timestamp": "2026-09-05T07:04:45.802600+00:00",
  "environment": "Real trade and Shopify modules in VM; real retained temp JSONL; config entirely stubbed; fetch replaced; require allowlisted; no external network",
  "build": {
    "base_commit": "8a877d4ed47ea559582c0944a702e60a8a6d927a",
    "branch": "fix/tk11285-approval-verification",
    "source_sha256": {
      "lib/trade.js": "4861f25f8a74472dd18578d0c4866f54482dc360c988f0fb8944ece18aa884fd",
      "lib/shopify.js": "4cc0226a689e899a70bd5c1e133aab2806afcc8cebf023ec1c277a51cd03b6af",
      "scripts/selftest.js": "6e5a18941d55d3851a0f988af51f7968c25621636fd535c7d6ed861ac860fe8e",
      "scripts/trade-approval-test.js": "2637ff164cfcd5159a42a6d41e60e7c73c14d78011ace97b433d8d14988317a6"
    },
    "previous_increment": "d291ec9e62ff125cecb4a04420a00f6d1fcd9045"
  },
  "preconditions": {
    "main_checkout": "/Users/macstudio3/Projects/dw-signup-fulfillment",
    "isolated_worktree": "/private/tmp/tk11285-owner.URtJU0/worktree",
    "main_clean_at_start": true,
    "cost_mode": "ZERO_COST_REQUIRED",
    "DTD_ZERO_COST": "1",
    "real_config_loaded": false,
    "real_external_io": false,
    "resumed_child_DTD_ZERO_COST": null,
    "resumed_guard_verification": "ZERO_COST_REQUIRED file independently verified; installed panel.sh and post-decision-codex.sh force DTD_ZERO_COST=1 from canonical file even when child variable absent. Parent clarified continuation; no environment/control change or provider call."
  },
  "baseline": {
    "command": "node scripts/trade-approval-test.js --baseline",
    "verdict": "PASS",
    "meaning": "Reproduced original defect before editing production modules: HTTP500 returned/persisted approved and sent both fixture emails.",
    "report": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-9oeZ25/report.json",
    "checks": [
      {
        "name": "original HTTP500 falsely approves and sends both emails",
        "verdict": "PASS",
        "result": {
          "ok": true,
          "id": "TRADE-20260905-a05d4f",
          "status": "approved",
          "rep": {
            "id": "fixture-rep",
            "name": "Fixture Rep",
            "email": "rep@example.invalid"
          },
          "steps": [
            {
              "step": "assign_rep",
              "rep": {
                "id": "fixture-rep",
                "name": "Fixture Rep",
                "email": "rep@example.invalid"
              }
            },
            {
              "step": "resolve_customer",
              "customer": 123,
              "via": "application"
            },
            {
              "step": "tag_trade_approved",
              "customer": 123,
              "result": {
                "status": 500,
                "ok": false
              }
            },
            {
              "step": "set_metafield",
              "customer": 123,
              "result": {
                "status": 201,
                "ok": true
              }
            },
            {
              "step": "email_rep",
              "to": "rep@example.invalid",
              "subject": "Fixture rep",
              "dryRun": false
            },
            {
              "step": "email_applicant",
              "to": "fixture@example.invalid",
              "subject": "Fixture approval",
              "dryRun": false
            }
          ]
        },
        "persisted": {
          "id": "TRADE-20260905-a05d4f",
          "email": "fixture@example.invalid",
          "business_name": "Fixture",
          "resale_cert": "",
          "phone": "",
          "extra": {
            "shopify_customer_id": 123
          },
          "shopify_customer_id": 123,
          "status": "approved",
          "created_at": "2026-09-05T06:53:21.547Z",
          "decided_at": "2026-09-05T06:53:21.551Z",
          "decision": "approved",
          "assigned_rep": {
            "id": "fixture-rep",
            "name": "Fixture Rep",
            "email": "rep@example.invalid"
          }
        },
        "calls": [
          "GET",
          "PUT",
          "POST"
        ],
        "emails": [
          "trade-rep-notify",
          "trade-approved"
        ],
        "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-9oeZ25/baseline/data/trade-applications.jsonl"
      }
    ]
  },
  "commands": [
    {
      "command": "node scripts/trade-approval-test.js",
      "verdict": "PASS",
      "report": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/report.json",
      "passed": 27
    },
    {
      "command": "node --check lib/trade.js; node --check lib/shopify.js; node --check scripts/selftest.js",
      "verdict": "PASS"
    },
    {
      "command": "git diff --check",
      "verdict": "PASS"
    },
    {
      "command": "node <root-evidence>/parent-approval-probe.js /private/tmp/tk11285-owner.URtJU0/worktree <root-evidence>/owner-race-after.json --race",
      "verdict": "PASS",
      "result": "Approval blocked during held rejection; rejection completes once; newer application survives."
    }
  ],
  "boundaries": {
    "entry": "Actual trade.apply() persists a pending application in retained temp JSONL; actual approve() executes with real Shopify module under a transport adapter.",
    "api": "Fetch adapter handles actual Shopify HTTP method, URL, JSON envelope and readback; returns injected transport/API/schema failures.",
    "data": "Actual fs writes and newly loaded trade module read back status/progress; one-shot persistence failure tested.",
    "side_effects": "Injected email service receipts; failed entitlement sends none; completed rep receipt survives reload without duplicate send.",
    "retry": "Mutation failure/retry; email503 retry; ambiguous delivery is held; concurrent same-process calls; intake during await; final checkpoint failure/retry.",
    "consumer_contract": "Approval errors return ok:false/error and pending; existing GET/POST consumers therefore do not report approved for errors or dry-run.",
    "shared_decision_lock": "Approve and reject acquire the same per-application lock synchronously before first await; finally releases for success and exceptions. Rejection checkpoints its row against freshly read data."
  },
  "checks": [
    {
      "name": "http500 fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-1e1812",
        "status": "pending",
        "error": "shopify_http_error",
        "failedStep": "tag_trade_approved",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 500,
              "ok": false
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/http500/data/trade-applications.jsonl"
    },
    {
      "name": "mf500 fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-ec292b",
        "status": "pending",
        "error": "shopify_http_error",
        "failedStep": "set_metafield",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "set_metafield",
            "customer": "123",
            "result": {
              "status": 500,
              "ok": false
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT",
        "POST"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/mf500/data/trade-applications.jsonl"
    },
    {
      "name": "read500 fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-f8fb45",
        "status": "pending",
        "error": "shopify_http_error",
        "failedStep": "tag_trade_approved",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 500,
              "ok": false
            }
          }
        ]
      },
      "calls": [
        "GET"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/read500/data/trade-applications.jsonl"
    },
    {
      "name": "graphql_top fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-489ed7",
        "status": "pending",
        "error": "shopify_response_error",
        "failedStep": "tag_trade_approved",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/graphql_top/data/trade-applications.jsonl"
    },
    {
      "name": "graphql_user fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-f1ebd9",
        "status": "pending",
        "error": "shopify_response_error",
        "failedStep": "tag_trade_approved",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/graphql_user/data/trade-applications.jsonl"
    },
    {
      "name": "mf_user fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-ac0496",
        "status": "pending",
        "error": "shopify_response_error",
        "failedStep": "set_metafield",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "set_metafield",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT",
        "POST"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/mf_user/data/trade-applications.jsonl"
    },
    {
      "name": "malformed fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-dbec19",
        "status": "pending",
        "error": "shopify_response_error",
        "failedStep": "tag_trade_approved",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/malformed/data/trade-applications.jsonl"
    },
    {
      "name": "empty fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-7120e4",
        "status": "pending",
        "error": "invalid_tag_response",
        "failedStep": "tag_trade_approved",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/empty/data/trade-applications.jsonl"
    },
    {
      "name": "missing_tag fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-b52496",
        "status": "pending",
        "error": "entitlement_not_verified",
        "failedStep": "verify_entitlement",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "set_metafield",
            "customer": "123",
            "result": {
              "status": 201,
              "ok": true
            }
          },
          {
            "step": "verify_entitlement",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT",
        "POST",
        "GET"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/missing_tag/data/trade-applications.jsonl"
    },
    {
      "name": "wrong_id fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-e8c2aa",
        "status": "pending",
        "error": "entitlement_not_verified",
        "failedStep": "verify_entitlement",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "set_metafield",
            "customer": "123",
            "result": {
              "status": 201,
              "ok": true
            }
          },
          {
            "step": "verify_entitlement",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT",
        "POST",
        "GET"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/wrong_id/data/trade-applications.jsonl"
    },
    {
      "name": "missing_customer fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-97924a",
        "status": "pending",
        "error": "entitlement_not_verified",
        "failedStep": "verify_entitlement",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "set_metafield",
            "customer": "123",
            "result": {
              "status": 201,
              "ok": true
            }
          },
          {
            "step": "verify_entitlement",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          }
        ]
      },
      "calls": [
        "GET",
        "PUT",
        "POST",
        "GET"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/missing_customer/data/trade-applications.jsonl"
    },
    {
      "name": "throw fails closed",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-b8535c",
        "status": "pending",
        "error": "approval_exception",
        "failedStep": "tag_trade_approved",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          }
        ]
      },
      "calls": [
        "GET",
        "PUT"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/throw/data/trade-applications.jsonl"
    },
    {
      "name": "verified entitlement then persisted approval and reload",
      "verdict": "PASS",
      "result": {
        "ok": true,
        "id": "TRADE-20260905-8e7c72",
        "status": "approved",
        "rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "set_metafield",
            "customer": "123",
            "result": {
              "status": 201,
              "ok": true
            }
          },
          {
            "step": "verify_entitlement",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "email_rep",
            "to": "rep@example.invalid",
            "subject": "Fixture rep",
            "dryRun": false
          },
          {
            "step": "email_applicant",
            "to": "fixture@example.invalid",
            "subject": "Fixture approval",
            "dryRun": false
          }
        ]
      },
      "persisted": {
        "id": "TRADE-20260905-8e7c72",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": "123",
        "status": "approved",
        "created_at": "2026-09-05T07:04:15.770Z",
        "decided_at": "2026-09-05T07:04:15.773Z",
        "decision": "approved",
        "assigned_rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "approval_progress": {
          "customer_id": "123",
          "emails": {
            "rep": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.773Z",
              "status": 200
            },
            "applicant": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.773Z",
              "status": 200
            }
          },
          "entitlement_verified_at": "2026-09-05T07:04:15.772Z"
        },
        "approval_error": null
      },
      "calls": [
        "GET",
        "PUT",
        "POST",
        "GET"
      ],
      "emails": [
        "trade-rep-notify",
        "trade-approved"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/happy/data/trade-applications.jsonl"
    },
    {
      "name": "failed mutation can retry after reload",
      "verdict": "PASS",
      "persisted": {
        "id": "TRADE-20260905-736047",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": "123",
        "status": "approved",
        "created_at": "2026-09-05T07:04:15.783Z",
        "decided_at": "2026-09-05T07:04:15.789Z",
        "decision": "approved",
        "assigned_rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "approval_progress": {
          "customer_id": "123",
          "emails": {
            "rep": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.788Z",
              "status": 200
            },
            "applicant": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.789Z",
              "status": 200
            }
          },
          "entitlement_verified_at": "2026-09-05T07:04:15.787Z"
        },
        "approval_error": null
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/retry/data/trade-applications.jsonl"
    },
    {
      "name": "email partial success survives restart without duplicate rep send",
      "verdict": "PASS",
      "persisted": {
        "id": "TRADE-20260905-3985f4",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": "123",
        "status": "approved",
        "created_at": "2026-09-05T07:04:15.792Z",
        "decided_at": "2026-09-05T07:04:15.800Z",
        "decision": "approved",
        "assigned_rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "approval_progress": {
          "customer_id": "123",
          "emails": {
            "rep": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.794Z",
              "status": 200
            },
            "applicant": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.800Z",
              "status": 200
            }
          },
          "entitlement_verified_at": "2026-09-05T07:04:15.799Z"
        },
        "approval_error": null
      },
      "emails": [
        "trade-rep-notify",
        "trade-approved",
        "trade-approved"
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/mail-retry/data/trade-applications.jsonl"
    },
    {
      "name": "ambiguous email delivery blocks resend across restart",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-7b3979",
        "status": "pending",
        "error": "email_delivery_unknown",
        "failedStep": "email_applicant",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "set_metafield",
            "customer": "123",
            "result": {
              "status": 201,
              "ok": true
            }
          },
          {
            "step": "verify_entitlement",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "email_rep",
            "skipped": true,
            "reason": "already_sent",
            "sent_at": "2026-09-05T07:04:15.806Z"
          }
        ]
      },
      "persisted": {
        "id": "TRADE-20260905-7b3979",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": "123",
        "status": "pending",
        "created_at": "2026-09-05T07:04:15.804Z",
        "decided_at": null,
        "decision": null,
        "assigned_rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "approval_progress": {
          "customer_id": "123",
          "emails": {
            "rep": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.806Z",
              "status": 200
            },
            "applicant": {
              "state": "sending",
              "attempted_at": "2026-09-05T07:04:15.807Z"
            }
          },
          "entitlement_verified_at": "2026-09-05T07:04:15.811Z"
        },
        "approval_error": {
          "error": "email_delivery_unknown",
          "step": "email_applicant",
          "at": "2026-09-05T07:04:15.812Z"
        }
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/ambiguous-mail/data/trade-applications.jsonl"
    },
    {
      "name": "final checkpoint failure stays pending and retry skips completed emails",
      "verdict": "PASS",
      "first": {
        "ok": false,
        "id": "TRADE-20260905-2587ec",
        "status": "pending",
        "error": "approval_exception",
        "failedStep": "email_applicant",
        "steps": [
          {
            "step": "assign_rep",
            "rep": {
              "id": "fixture-rep",
              "name": "Fixture Rep",
              "email": "rep@example.invalid"
            }
          },
          {
            "step": "resolve_customer",
            "customer": "123",
            "via": "application"
          },
          {
            "step": "tag_trade_approved",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "set_metafield",
            "customer": "123",
            "result": {
              "status": 201,
              "ok": true
            }
          },
          {
            "step": "verify_entitlement",
            "customer": "123",
            "result": {
              "status": 200,
              "ok": true
            }
          },
          {
            "step": "email_rep",
            "to": "rep@example.invalid",
            "subject": "Fixture rep",
            "dryRun": false
          },
          {
            "step": "email_applicant",
            "to": "fixture@example.invalid",
            "subject": "Fixture approval",
            "dryRun": false
          }
        ]
      },
      "persisted": {
        "id": "TRADE-20260905-2587ec",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": "123",
        "status": "approved",
        "created_at": "2026-09-05T07:04:15.816Z",
        "decided_at": "2026-09-05T07:04:15.823Z",
        "decision": "approved",
        "assigned_rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "approval_progress": {
          "customer_id": "123",
          "emails": {
            "rep": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.818Z",
              "status": 200
            },
            "applicant": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.819Z",
              "status": 200
            }
          },
          "entitlement_verified_at": "2026-09-05T07:04:15.822Z"
        },
        "approval_error": null
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/checkpoint-failure/data/trade-applications.jsonl"
    },
    {
      "name": "same-process concurrent duplicate does not duplicate emails",
      "verdict": "PASS",
      "results": [
        {
          "ok": true,
          "id": "TRADE-20260905-6e7a55",
          "status": "approved",
          "rep": {
            "id": "fixture-rep",
            "name": "Fixture Rep",
            "email": "rep@example.invalid"
          },
          "steps": [
            {
              "step": "assign_rep",
              "rep": {
                "id": "fixture-rep",
                "name": "Fixture Rep",
                "email": "rep@example.invalid"
              }
            },
            {
              "step": "resolve_customer",
              "customer": "123",
              "via": "application"
            },
            {
              "step": "tag_trade_approved",
              "customer": "123",
              "result": {
                "status": 200,
                "ok": true
              }
            },
            {
              "step": "set_metafield",
              "customer": "123",
              "result": {
                "status": 201,
                "ok": true
              }
            },
            {
              "step": "verify_entitlement",
              "customer": "123",
              "result": {
                "status": 200,
                "ok": true
              }
            },
            {
              "step": "email_rep",
              "to": "rep@example.invalid",
              "subject": "Fixture rep",
              "dryRun": false
            },
            {
              "step": "email_applicant",
              "to": "fixture@example.invalid",
              "subject": "Fixture approval",
              "dryRun": false
            }
          ]
        },
        {
          "ok": false,
          "error": "approval_in_progress",
          "id": "TRADE-20260905-6e7a55"
        }
      ],
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/concurrent/data/trade-applications.jsonl"
    },
    {
      "name": "intake during approval await survives checkpoint rewrites",
      "verdict": "PASS",
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/intake-race/data/trade-applications.jsonl",
      "preservedApplication": "TRADE-20260905-4568a3"
    },
    {
      "name": "reject first blocks approval until rejection completes",
      "verdict": "PASS",
      "approval": {
        "ok": false,
        "error": "approval_in_progress",
        "id": "TRADE-20260905-971cc0"
      },
      "persisted": {
        "id": "TRADE-20260905-971cc0",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": 123,
        "status": "rejected",
        "created_at": "2026-09-05T07:04:15.845Z",
        "decided_at": "2026-09-05T07:04:15.847Z",
        "decision": "rejected",
        "assigned_rep": null
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/reject-first/data/trade-applications.jsonl"
    },
    {
      "name": "approve first blocks rejection and preserves approval receipts",
      "verdict": "PASS",
      "rejection": {
        "ok": false,
        "error": "approval_in_progress",
        "id": "TRADE-20260905-fc216e"
      },
      "persisted": {
        "id": "TRADE-20260905-fc216e",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": "123",
        "status": "approved",
        "created_at": "2026-09-05T07:04:15.852Z",
        "decided_at": "2026-09-05T07:04:15.856Z",
        "decision": "approved",
        "assigned_rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "approval_progress": {
          "customer_id": "123",
          "emails": {
            "rep": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.854Z",
              "status": 200
            },
            "applicant": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.855Z",
              "status": 200
            }
          },
          "entitlement_verified_at": "2026-09-05T07:04:15.854Z"
        },
        "approval_error": null
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/approve-first/data/trade-applications.jsonl"
    },
    {
      "name": "concurrent rejection attempts send only one rejection",
      "verdict": "PASS",
      "duplicate": {
        "ok": false,
        "error": "approval_in_progress",
        "id": "TRADE-20260905-7af14c"
      },
      "persisted": {
        "id": "TRADE-20260905-7af14c",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": 123,
        "status": "rejected",
        "created_at": "2026-09-05T07:04:15.859Z",
        "decided_at": "2026-09-05T07:04:15.860Z",
        "decision": "rejected",
        "assigned_rep": null
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/reject-reject/data/trade-applications.jsonl"
    },
    {
      "name": "intake during rejection survives final persistence",
      "verdict": "PASS",
      "newerId": "TRADE-20260905-05fc42",
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/reject-intake/data/trade-applications.jsonl"
    },
    {
      "name": "rejection template exception releases shared decision lock",
      "verdict": "PASS",
      "persisted": {
        "id": "TRADE-20260905-e45a80",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": "123",
        "status": "approved",
        "created_at": "2026-09-05T07:04:15.874Z",
        "decided_at": "2026-09-05T07:04:15.879Z",
        "decision": "approved",
        "assigned_rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "approval_progress": {
          "customer_id": "123",
          "emails": {
            "rep": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.877Z",
              "status": 200
            },
            "applicant": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.878Z",
              "status": 200
            }
          },
          "entitlement_verified_at": "2026-09-05T07:04:15.877Z"
        },
        "approval_error": null
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/reject-fail-template/data/trade-applications.jsonl"
    },
    {
      "name": "rejection send exception releases shared decision lock",
      "verdict": "PASS",
      "persisted": {
        "id": "TRADE-20260905-091da2",
        "email": "fixture@example.invalid",
        "business_name": "Fixture",
        "resale_cert": "",
        "phone": "",
        "extra": {
          "shopify_customer_id": 123
        },
        "shopify_customer_id": "123",
        "status": "approved",
        "created_at": "2026-09-05T07:04:15.883Z",
        "decided_at": "2026-09-05T07:04:15.888Z",
        "decision": "approved",
        "assigned_rep": {
          "id": "fixture-rep",
          "name": "Fixture Rep",
          "email": "rep@example.invalid"
        },
        "approval_progress": {
          "customer_id": "123",
          "emails": {
            "rep": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.887Z",
              "status": 200
            },
            "applicant": {
              "state": "sent",
              "sent_at": "2026-09-05T07:04:15.888Z",
              "status": 200
            }
          },
          "entitlement_verified_at": "2026-09-05T07:04:15.886Z"
        },
        "approval_error": null
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/reject-fail-send/data/trade-applications.jsonl"
    },
    {
      "name": "dry run reports simulated pending without external side effects",
      "verdict": "PASS",
      "result": {
        "ok": false,
        "id": "TRADE-20260905-e0447d",
        "status": "pending",
        "dryRun": true,
        "simulated": true,
        "error": "dry_run_simulated",
        "message": "Approval simulation only; no entitlement or email was changed.",
        "steps": []
      },
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/dryrun/data/trade-applications.jsonl"
    },
    {
      "name": "live missing token cannot be treated as approval",
      "verdict": "PASS",
      "store": "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq/no-token/data/trade-applications.jsonl"
    }
  ],
  "limitations": [
    "No live Shopify/customer/email operation or deployment performed; those require explicit deployment approval and a separate controlled live verification.",
    "Single-process in-flight guard only; multiple processes sharing this JSONL store remain unsupported.",
    "Crash or ambiguous email delivery leaves sending/unknown receipt for manual reconciliation; exactly-once delivery requires provider idempotency outside this increment.",
    "Legacy full npm selftest was not executed because it imports real config and mutates runtime data; only approval assertions updated and syntax checked. Focused test has no real config or network capability.",
    "The existing whole-file store is not redesigned; disk corruption/multi-process coordination are outside this scoped increment."
  ],
  "retained_test_state": [
    "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-9oeZ25",
    "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-Dh9eLY",
    "/var/folders/rq/j8g1f7nn6jv6_lr1cfmqym6w0000gn/T/tk11285-flow-AKX4Rq"
  ],
  "rollback": "Local branch/worktree retained; main checkout untouched. No merge, service restart, external writes, or deployment.",
  "verdict": "PASS for27 isolated local checks and owner rerun of parent race harness; final parent/Cody acceptance remains pending",
  "increment2": {
    "intent": "Fix parent/Cody independently reproduced reject-first decision race and rejection/intake lost write.",
    "dtd": "/private/tmp/dtd-cycle11285-final.GWFqzJ/codex-debate.txt FINAL KEEP",
    "before": "<root-evidence>/parent-race-before.json",
    "after": "<root-evidence>/owner-race-after.json",
    "scope": "Single service process only; no multi-process guarantee and no redesign of rejection email failure policy.",
    "new_checks": 6
  }
}