# M4-7: the "signal to qualified meeting" reference blueprint.
#
# This is a CONTRACT / acceptance artifact, not the execution spine (M4-0 ADR):
# the node engine executes real runs; this Arazzo document is the portable,
# operationId-resolved description of the reference outcome that M4-10 runs in
# sandbox under an ordinary customer key.
#
# Scope (plan 0a): it expresses WP5 steps 2..11 only. Two steps are dropped on
# purpose because Arazzo 1.1 has no construct for them:
#   * step 1  - signal intake: Arazzo has no trigger concept.
#   * step 6  - approval preview: Arazzo has no approval construct (that gate is
#               M4-2/M4-5/M4-12 on the platform side, not in the blueprint).
# It is also honestly NARROWER than the same customer's visual canvas: 11 of the
# 57 node types have no public operationId, and Arazzo defines no iteration while
# the executor supports for_each/while/times. This document does not fork to the
# node builder - it is a contract, and the node engine remains the substrate.
#
# Every operationId below resolves against ./openapi.json (the frozen release
# bundle). scripts/dev-foundation/tests/test_arazzo_blueprint.py fails the build
# if any operationId is dangling or the structure drifts.

arazzo: 1.1.0

info:
  title: Signal to Qualified Meeting
  version: 1.0.0
  description: >-
    Reference blueprint: from a set of candidate contacts, build and enrich an
    audience, launch outreach, and book a qualified meeting. Steps 2..11 of WP5.

sourceDescriptions:
  - name: graph8
    url: ./openapi.json
    type: openapi

workflows:
  - workflowId: signal-to-qualified-meeting
    summary: Build an audience, enrich it, launch outreach, and book a meeting.
    description: >-
      The developer-facing reference outcome. Each step resolves to a public
      operationId in the graph8 release contract; outputs chain into later steps.
    inputs:
      type: object
      properties:
        search_query:
          type: object
          description: Search filter for the candidate contacts (search/contacts body).
        audience_title:
          type: string
          description: Title for the audience/list to create.
        campaign_name:
          type: string
          description: Name for the outreach campaign.
        event_type_id:
          type: string
          description: Event type to book the qualified meeting against.
      required:
        - audience_title
        - campaign_name

    steps:
      - stepId: find-candidates
        description: WP5.2 - find the candidate contacts to work.
        operationId: search_contacts_search_contacts_post
        requestBody:
          contentType: application/json
          payload: $inputs.search_query
        successCriteria:
          - condition: $statusCode == 200
        outputs:
          contact_ids: $response.body#/data

      - stepId: create-audience
        description: WP5.3 - create the audience/list that scopes the run.
        operationId: create_list_lists_post
        requestBody:
          contentType: application/json
          payload:
            title: $inputs.audience_title
            type: static
        successCriteria:
          - condition: $statusCode == 201
        outputs:
          list_id: $response.body#/data/id

      - stepId: add-to-audience
        description: WP5.4 - add the found contacts to the audience.
        operationId: add_contacts_to_list_lists__list_id__contacts_post
        parameters:
          - name: list_id
            in: path
            value: $steps.create-audience.outputs.list_id
        requestBody:
          contentType: application/json
          payload:
            contact_ids: $steps.find-candidates.outputs.contact_ids
        successCriteria:
          - condition: $statusCode == 201

      - stepId: enrich-audience
        description: WP5.5 - enrich the audience so outreach has real data.
        operationId: start_enrichment_enrichment_enrich_post
        requestBody:
          contentType: application/json
          payload:
            list_id: $steps.create-audience.outputs.list_id
        successCriteria:
          - condition: $statusCode == 200

      - stepId: verify-deliverability
        description: WP5.7 - verify email deliverability before sending.
        operationId: verify_email_enrichment_verify_email_post
        requestBody:
          contentType: application/json
          payload:
            list_id: $steps.create-audience.outputs.list_id
        successCriteria:
          - condition: $statusCode == 200

      - stepId: create-campaign
        description: WP5.8 - create the outreach campaign against the audience.
        operationId: create_campaign_campaigns_post
        requestBody:
          contentType: application/json
          payload:
            name: $inputs.campaign_name
            audience_id: $steps.create-audience.outputs.list_id
        successCriteria:
          - condition: $statusCode == 201
        outputs:
          campaign_id: $response.body#/data/id

      - stepId: launch-campaign
        description: WP5.9 - launch outreach.
        operationId: launch_campaign_campaigns__campaign_id__launch_post
        parameters:
          - name: campaign_id
            in: path
            value: $steps.create-campaign.outputs.campaign_id
        successCriteria:
          - condition: $statusCode == 200

      - stepId: book-meeting
        description: WP5.11 - book the qualified meeting.
        operationId: create_booking_appointments_bookings_post
        requestBody:
          contentType: application/json
          payload:
            event_type_id: $inputs.event_type_id
        successCriteria:
          - condition: $statusCode == 201
        outputs:
          booking_id: $response.body#/data/uid

    outputs:
      list_id: $steps.create-audience.outputs.list_id
      campaign_id: $steps.create-campaign.outputs.campaign_id
      booking_id: $steps.book-meeting.outputs.booking_id
