{
  "id": "opportunity-deal-delayed-parent-company-association",
  "title": "Opportunity Deal parent-company association contract stays explicit",
  "kind": "hubspot_contract",
  "linkedIssues": [],
  "externalEffects": "none",
  "provenance": {
    "businessScenario": "An Opportunity Deal push must resolve the Account's finalized HubSpot company link and create or update the Deal with the exact Account-to-company association contract. This is a committed-pack inspection because exercising the old pending-versus-processing queue assertion would create CRM records and can send a real Deal through Xiaopeng's database connector credential.",
    "reportedBy": "Amber",
    "capturedAt": "2026-08-08",
    "acceptanceBoundary": "PASS proves the outbound Flow and connector push contract require the Account company association. It does not prove L0 queue-state labels or a live Deal write; those require an isolated sandbox-only connector credential and endpoint."
  },
  "contractChecks": [
    {
      "id": "opportunity-outbound-is-after-save-and-sync-gated",
      "type": "flow_start",
      "flow": "HubSpot_Opportunity_Deal_Outbound_Update.flow.json",
      "expect": {
        "object": "Opportunity",
        "triggerType": "RecordAfterSave",
        "recordTriggerType": "CreateAndUpdate",
        "filters": [
          {"field": "HubSpot_Sync_Enabled__c", "operator": "EqualTo", "value": true}
        ],
        "connector": {"targetReference": "PushOpportunityToHubSpotDeal"}
      }
    },
    {
      "id": "opportunity-outbound-targets-the-deal-slot",
      "type": "flow_action",
      "flow": "HubSpot_Opportunity_Deal_Outbound_Update.flow.json",
      "action": "PushOpportunityToHubSpotDeal",
      "expect": {
        "actionName": "PushToConnector",
        "actionType": "PushToConnector",
        "inputParameters": {
          "profileOwnerPack": {"stringValue": "hubspot-crm-connector"},
          "profileName": {"stringValue": "hubspot-crm-deal-company-write"},
          "sourceObject": {"stringValue": "Opportunity"},
          "targetObject": {"stringValue": "deals"},
          "destinationSlotId": {"stringValue": "hubspot-deal"},
          "remoteId": {"elementReference": "$Record.HubSpot_Id__c"},
          "updatePathTemplate": {"stringValue": "/crm/v3/objects/deals/{remoteId}"}
        }
      }
    },
    {
      "id": "deal-push-contract-requires-account-company-link",
      "type": "connector_push_contract",
      "contract": "opportunity_deal_outbound.json",
      "expect": {
        "flowDeveloperName": "HubSpot_Opportunity_Deal_Outbound_Update",
        "flowActionName": "PushOpportunityToHubSpotDeal",
        "sourceObject": "Opportunity",
        "destinationSlotId": "hubspot-deal",
        "targetObject": "deals",
        "createPathTemplate": "/crm/v3/objects/deals",
        "associations": [
          {
            "sourceLookupField": "AccountId",
            "sourceObject": "Account",
            "remoteIdField": "HubSpot_Id__c",
            "targetActionSlotId": "hubspot-company",
            "targetDestinationSlotId": "hubspot-company",
            "targetObject": "companies",
            "payloadField": "associations",
            "payloadMergeMode": "append",
            "inlinePhases": ["create"],
            "payloadTemplate": {
              "to": {"id": "{toId}"},
              "types": [
                {"associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 5}
              ]
            },
            "associationPath": "/crm/v3/objects/deals/{fromId}/associations/companies/{toId}/5",
            "associationMethod": "PUT",
            "calloutPhases": ["update"]
          }
        ]
      }
    }
  ]
}
