{
  "ursId": "URS-049",
  "title": "Update inventory from Uniphar ASN on delivered status",
  "timestamp": "2026-09-29T02:30:50.521Z",
  "durationMs": 106909,
  "config": {
    "inboxUrl": "http://localhost:38233",
    "dbHost": "localhost",
    "dbPort": 38419,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Step 1: Pre-ASN inventory",
      "status": "pass",
      "description": "Step 1: Pre-ASN inventory",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z/screenshots/step-01-inventory-before-asn.png"
      ],
      "explanation": "Documents the inventory state at ROSS-001 before any ASN is processed. This baseline proves that inventory increases seen after Step 9 are caused by the ASN delivery, not by pre-existing stock. The full end-to-end screencast video (attached below) covers all steps from pre-ASN baseline through delivery confirmation and inventory materialization.",
      "startedAt": "2026-09-29T02:31:02.633Z",
      "finishedAt": "2026-09-29T02:31:02.633Z"
    },
    {
      "name": "Step 3: Intake email list (ASN received)",
      "status": "pass",
      "description": "Step 3: Intake email list (ASN received)",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z/screenshots/step-03-intake-email-list.png"
      ],
      "explanation": "Confirms the Uniphar/secure-wms.com ASN email appears in the email intake log (/settings/email_intake) with a \"processed\" status. The email arrived via the same SES → RustFS → Restate Import.processMail pipeline used in production — only the SES/SQS hops are replaced by a direct RustFS upload in the test environment.",
      "startedAt": "2026-09-29T02:31:09.080Z",
      "finishedAt": "2026-09-29T02:31:09.080Z"
    },
    {
      "name": "Step 4: Intake email detail (parsed ASN body)",
      "status": "pass",
      "description": "Step 4: Intake email detail (parsed ASN body)",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z/screenshots/step-04-intake-email-detail.png"
      ],
      "explanation": "Drills into the ASN email detail page, showing the sender (notifications@secure-wms.com), subject, HTML table body, and the shipping_package + import_job entities the pipeline produced. Proves the parser correctly extracted account code, carrier, tracking number, and all three SKU/lot/quantity rows from the secure-wms.com HTML table format.",
      "startedAt": "2026-09-29T02:31:12.786Z",
      "finishedAt": "2026-09-29T02:31:12.786Z"
    },
    {
      "name": "Step 5: Import job log (ASN parsed)",
      "status": "pass",
      "description": "Step 5: Import job log (ASN parsed)",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z/screenshots/step-05-import-job-log.png"
      ],
      "explanation": "Shows the shipping-notice import job log with the parsed SKU, LOT, and quantity rows from the ASN. Confirms the text-extraction import_config matched the URS-049 email rule and the import job completed with status=complete, packagesCreated=1, itemsAdded=3.",
      "startedAt": "2026-09-29T02:31:15.877Z",
      "finishedAt": "2026-09-29T02:31:15.877Z"
    },
    {
      "name": "Step 6: Shipping package detail (pre-delivery)",
      "status": "pass",
      "description": "Step 6: Shipping package detail (pre-delivery)",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z/screenshots/step-06-shipping-package-pre-delivery.png"
      ],
      "explanation": "Captures the shipping_packages detail page before the delivery webhook fires. Confirms the package was routed to the Vantis ROSS-001 destination location with the correct tracking number and three shipping_package_items matching the ASN quantities.",
      "startedAt": "2026-09-29T02:31:18.922Z",
      "finishedAt": "2026-09-29T02:31:18.922Z"
    },
    {
      "name": "Step 8: Shipping package detail (delivered)",
      "status": "pass",
      "description": "Step 8: Shipping package detail (delivered)",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z/screenshots/step-08-shipping-package-delivered.png"
      ],
      "explanation": "After the PackageTracker.mockUpdate webhook sets status=delivered, the package detail page is re-captured to show the updated status. This is the trigger that causes the auto-add-inventory hook to fire, materializing inventory_items at ROSS-001.",
      "startedAt": "2026-09-29T02:32:33.518Z",
      "finishedAt": "2026-09-29T02:32:33.518Z"
    },
    {
      "name": "Step 9: Inventory after ASN delivery (lots materialized)",
      "status": "pass",
      "description": "Step 9: Inventory after ASN delivery (lots materialized)",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z/screenshots/step-09-inventory-after-delivery.png"
      ],
      "explanation": "Documents the inventory state at ROSS-001 after the delivery event. The three ASN lots (NP019N1A, LL516SNA, VM2025MR) now appear with quantities matching the ASN exactly, proving the requirement: \"The system shall update inventory based on ASN information, upon receipt of delivered status from Uniphar.\"",
      "startedAt": "2026-09-29T02:32:35.857Z",
      "finishedAt": "2026-09-29T02:32:35.857Z"
    }
  ],
  "dbValidations": [
    {
      "name": "intake_emails row exists for the Uniphar ASN",
      "assertion": "intake_emails from notifications@secure-wms.com matched the URS-049 rule and was stored.",
      "query": "\n    SELECT id, \"from\", \"to\", subject, matched_rule_id, received_at\n      FROM intake_emails\n     WHERE matched_rule_id = $1 AND received_at >= $2\n     ORDER BY received_at DESC\n     LIMIT 1",
      "status": "pass",
      "rows": [
        {
          "id": "01a0eb00-5b23-7f95-96b4-6e35c6ed2824",
          "from": "notifications@secure-wms.com",
          "to": "vantis.asn@agent.getdeviceflow.com",
          "subject": "requested transaction notification",
          "matched_rule_id": "01950049-0049-7049-8049-000000000002",
          "received_at": "2026-09-29T02:31:04.350Z"
        }
      ]
    },
    {
      "name": "import_jobs row completed for the Uniphar ASN",
      "assertion": "import_jobs.status=complete with packagesCreated=1 and itemsAdded=3.",
      "query": "\n    SELECT id, status, info\n      FROM import_jobs\n     WHERE organization_id = $1 AND import_config_id = $2 AND created_at >= $3\n     ORDER BY created_at DESC\n     LIMIT 1",
      "status": "pass",
      "rows": [
        {
          "id": "01a0eb00-5bf6-75cc-9d8a-c354316dd35b",
          "status": "complete",
          "info": {
            "itemsAdded": 3,
            "missingContacts": [],
            "packagesCreated": 1,
            "missingLocations": [],
            "packagesReconciled": 0,
            "backorderedItemsAdded": 0,
            "unmatchedOrderNumbers": [
              "URS049-PKG-A"
            ],
            "fulfillmentOrdersLinked": 0
          }
        }
      ]
    },
    {
      "name": "shipping_packages row created for the Uniphar ASN",
      "assertion": "A shipping_packages row with the ASN tracking number was created, routed to ROSS-001.",
      "query": "\n    SELECT id, tracking_number, carrier, destination_location_id\n      FROM shipping_packages\n     WHERE organization_id = $1 AND created_at >= $2 AND tracking_number = $3",
      "status": "pass",
      "rows": [
        {
          "id": "01a0eb00-5d6d-7b05-b7f4-1178eb513135",
          "tracking_number": "391649050590",
          "carrier": "fedex",
          "destination_location_id": "f32fb2ae-664e-4507-8819-c5d1c09e3917"
        }
      ]
    },
    {
      "name": "shipping_package_items has 3 rows with correct quantities",
      "assertion": "Each ASN SKU line produced a shipping_package_items row with the expected quantity.",
      "query": "\n    SELECT spi.id, spi.quantity, spi.info\n      FROM shipping_package_items spi\n      JOIN shipping_packages sp ON sp.id = spi.package_id\n     WHERE sp.organization_id = $1 AND sp.created_at >= $2\n       AND sp.tracking_number = $3\n     ORDER BY spi.source_file_row ASC NULLS LAST, spi.id ASC",
      "status": "pass",
      "rows": [
        {
          "id": "01a0eb00-5d90-7f5a-bf29-8289fa1d2b36",
          "quantity": 3,
          "info": {
            "lot": "LOT-URS049-SP-A1",
            "sku": "NP019N1A"
          }
        },
        {
          "id": "01a0eb00-5d90-7f5a-bf29-828ad63b8cdc",
          "quantity": 5,
          "info": {
            "lot": "LOT-URS049-FL-B2",
            "sku": "LL516SNA"
          }
        },
        {
          "id": "01a0eb00-5d90-7f5a-bf29-828bec1c9e0a",
          "quantity": 2,
          "info": {
            "lot": "LOT-URS049-MR-C3",
            "sku": "VM2025MR"
          }
        }
      ]
    },
    {
      "name": "shipping_package was delivered",
      "assertion": "shipping_packages.status=delivered after PackageTracker.mockUpdate.",
      "query": "\n    SELECT id, status, delivered_at, destination_location_id\n      FROM shipping_packages\n     WHERE organization_id = $1 AND created_at >= $2 AND tracking_number = $3",
      "status": "pass",
      "rows": [
        {
          "id": "01a0eb00-5d6d-7b05-b7f4-1178eb513135",
          "status": "delivered",
          "delivered_at": "2026-09-29T02:31:20.236Z",
          "destination_location_id": "f32fb2ae-664e-4507-8819-c5d1c09e3917"
        }
      ]
    },
    {
      "name": "inventory_items materialized for each ASN line",
      "assertion": "One inventory_items row per ASN (productId, lot) at ROSS-001 with quantity_ready matching the ASN.",
      "query": "\n    SELECT ii.id, ii.product_id, ii.lot, ii.quantity_ready, ii.real_world_location_id\n      FROM inventory_items ii\n     WHERE ii.organization_id = $1\n       AND ii.product_id = ANY($2)\n       AND NOT (ii.id = ANY($3))",
      "status": "pass",
      "rows": [
        {
          "id": "01a0eb01-ae29-7155-8cd7-b442d70ddccb",
          "product_id": "01989ca2-6a54-7834-8376-06a0251bacd8",
          "lot": "LOT-URS049-SP-A1",
          "quantity_ready": 3,
          "real_world_location_id": "f32fb2ae-664e-4507-8819-c5d1c09e3917"
        },
        {
          "id": "01a0eb01-ae29-7155-8cd7-b4435d62d633",
          "product_id": "01989ca1-f2f8-7ab7-8269-7179342797cc",
          "lot": "LOT-URS049-FL-B2",
          "quantity_ready": 5,
          "real_world_location_id": "f32fb2ae-664e-4507-8819-c5d1c09e3917"
        },
        {
          "id": "01a0eb01-ae29-7155-8cd7-b444d36217a7",
          "product_id": "01984270-64c1-76da-aa82-eaf3f0a8326b",
          "lot": "LOT-URS049-MR-C3",
          "quantity_ready": 2,
          "real_world_location_id": "f32fb2ae-664e-4507-8819-c5d1c09e3917"
        }
      ]
    },
    {
      "name": "inventory_history rows recorded for the ASN delivery",
      "assertion": "3 inventory_history rows written during the run window for the ASN SKUs.",
      "query": "\n    SELECT ih.id, ih.item_id, ih.quantity, ih.status, ih.info\n      FROM inventory_history ih\n      JOIN inventory_items ii ON ii.id = ih.item_id\n     WHERE ih.organization_id = $1\n       AND ih.created_at >= $2\n       AND ii.product_id = ANY($3)",
      "status": "pass",
      "rows": [
        {
          "id": "01a0eb01-ae30-74cd-8a68-fee87fe887e6",
          "item_id": "01a0eb01-ae29-7155-8cd7-b442d70ddccb",
          "quantity": 3,
          "status": "ready",
          "info": {
            "action": "added",
            "reason": "auto_added_package",
            "packageId": "01a0eb00-5d6d-7b05-b7f4-1178eb513135"
          }
        },
        {
          "id": "01a0eb01-ae30-74cd-8a68-fee9ebacc5df",
          "item_id": "01a0eb01-ae29-7155-8cd7-b4435d62d633",
          "quantity": 5,
          "status": "ready",
          "info": {
            "action": "added",
            "reason": "auto_added_package",
            "packageId": "01a0eb00-5d6d-7b05-b7f4-1178eb513135"
          }
        },
        {
          "id": "01a0eb01-ae30-74cd-8a68-feea8bf0769d",
          "item_id": "01a0eb01-ae29-7155-8cd7-b444d36217a7",
          "quantity": 2,
          "status": "ready",
          "info": {
            "action": "added",
            "reason": "auto_added_package",
            "packageId": "01a0eb00-5d6d-7b05-b7f4-1178eb513135"
          }
        }
      ]
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z",
  "auditStartTime": "2026-09-29T02:30:48.692Z",
  "auditEventEvidence": [
    {
      "createdAt": "2026-09-29T02:30:59.043Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@vantismedical.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@vantismedical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-09-29T02:31:04.231Z",
      "eventType": "decision",
      "action": "imports.mail_intake.rule_matched_hardcoded",
      "userEmail": null,
      "userId": null,
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "01950049-0049-7049-8049-000000000002",
      "secondaryObjectId": "01a0eb00-5b23-7f95-96b4-6e35c6ed2824",
      "payload": {
        "reason": "matched_hardcoded_intake_rule",
        "performed": true,
        "entityType": "intake_email_rule"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-09-29T02:31:04.235Z",
      "eventType": "decision",
      "action": "imports.mail_intake.rule_matched_flexible",
      "userEmail": null,
      "userId": null,
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "01950049-0049-7049-8049-000000000002",
      "secondaryObjectId": "01a0eb00-5b23-7f95-96b4-6e35c6ed2824",
      "payload": {
        "reason": "matched_hardcoded_rule",
        "performed": false,
        "entityType": "intake_email_rule"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-09-29T02:31:04.238Z",
      "eventType": "decision",
      "action": "imports.mail_intake.no_rule_match",
      "userEmail": null,
      "userId": null,
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "01950049-0049-7049-8049-000000000002",
      "secondaryObjectId": "01a0eb00-5b23-7f95-96b4-6e35c6ed2824",
      "payload": {
        "reason": "actionable_rule_matched",
        "performed": false,
        "entityType": "intake_email_rule"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-09-29T02:31:04.375Z",
      "eventType": "decision",
      "action": "imports.mail_intake.link_email_ref_entity_to_ticket",
      "userEmail": null,
      "userId": null,
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "01a0eb00-5b23-7f95-96b4-6e35c6ed2824",
      "secondaryObjectId": null,
      "payload": {
        "reason": "no_ticket_for_email",
        "performed": false,
        "entityType": "intake_email"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-09-29T02:32:30.975Z",
      "eventType": "shipment",
      "action": "status_change",
      "userEmail": null,
      "userId": null,
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "01a0eb00-5d6d-7b05-b7f4-1178eb513135",
      "secondaryObjectId": null,
      "payload": {
        "reason": "Carrier tracking update",
        "toStatus": "delivered",
        "fromStatus": "unknown",
        "automatedAction": true
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-09-29T02:32:30.986Z",
      "eventType": "decision",
      "action": "enable_team_tracked_inventory_routing",
      "userEmail": null,
      "userId": null,
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "01a0eb00-5d6d-7b05-b7f4-1178eb513135",
      "secondaryObjectId": null,
      "payload": {
        "reason": "Package not linked to direct or dropship order",
        "performed": true,
        "entityType": "shipping_package"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-09-29T02:32:30.986Z",
      "eventType": "decision",
      "action": "auto_add_delivered_package_items",
      "userEmail": null,
      "userId": null,
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "01a0eb00-5d6d-7b05-b7f4-1178eb513135",
      "secondaryObjectId": null,
      "payload": {
        "reason": "Destination location auto-adds delivered package items",
        "performed": true,
        "entityType": "shipment"
      },
      "route": null,
      "traceId": null
    }
  ],
  "auditQuery": "SELECT\n    ae.created_at,\n    ae.event_type,\n    ae.action,\n    ae.user_id,\n    u.email AS user_email,\n    ae.organization_id,\n    o.name AS organization_name,\n    ae.object_id,\n    ae.secondary_object_id,\n    ae.payload,\n    ae.route,\n    ae.trace_id\n  FROM audit_events ae\n  LEFT JOIN users u ON u.id = ae.user_id\n  LEFT JOIN organizations o ON o.id = ae.organization_id\n  WHERE ae.created_at >= $1\n    AND ae.organization_id = ANY($2::uuid[])\n  ORDER BY ae.created_at ASC",
  "auditAssertions": [],
  "emailAssertions": [],
  "videoPaths": [
    "/home/runner/_work/code/code/validation_test_results/urs-049-uniphar-asn-parse-and-update-inventory/2026-09-29T02-30-50-520Z/videos/step-01-urs-049-uniphar-asn.webm"
  ]
}