arazzo: 1.0.1

info:
  title: MaterialGraph HTTP Workflows
  version: 0.2.0
  description: >
    Agent-readable workflows for the HTTP routes that MaterialGraph actually
    serves. Catalog ingestion itself runs through Mastra workflows, tRPC-backed
    operator actions, and the `mg` CLI.

sourceDescriptions:
  - name: materialgraph
    type: openapi
    url: ./openapi.yaml

workflows:
  - workflowId: source_crawl_start
    summary: Start a bounded brand source crawl
    description: >
      Submit a brand seed URL for source discovery. The result is a runtime
      crawl start response; downstream Mastra workflows use crawled sources to
      derive site zones, families, product models, variants, options, assets,
      and documents.
    parameters:
      - name: brandId
        in: body
        description: Canonical brand id.
      - name: seedUrl
        in: body
        description: Canonical brand root or seed URL.
      - name: maxUrls
        in: body
        description: Optional crawl URL limit.
    steps:
      - stepId: start_crawl
        operationId: materialgraph.start_source_crawl
        requestBody:
          contentType: application/json
          payload:
            brandId: $inputs.brandId
            seedUrl: $inputs.seedUrl
            maxUrls: $inputs.maxUrls
        successCriteria:
          - condition: $statusCode == 200
        outputs:
          crawl: $response.body
    outputs:
      crawl: $steps.start_crawl.outputs.crawl

  - workflowId: automation_activity_check
    summary: Check operator activity after an automation action
    description: >
      Fetch the current activity feed. Use this after a tRPC or Mastra-backed
      automation action when an agent needs to verify visible operator progress.
    parameters:
      - name: since
        in: query
        description: Optional cursor or timestamp.
    steps:
      - stepId: fetch_activity
        operationId: materialgraph.get_activity_feed
        parameters:
          - name: since
            in: query
            value: $inputs.since
        successCriteria:
          - condition: $statusCode == 200
        outputs:
          activity: $response.body
    outputs:
      activity: $steps.fetch_activity.outputs.activity

  - workflowId: api_discovery
    summary: Retrieve MaterialGraph API discovery metadata
    description: >
      Fetch the OpenAPI document before using the HTTP surface. This prevents
      agents from assuming old REST catalog endpoints exist.
    steps:
      - stepId: fetch_openapi
        operationId: materialgraph.get_openapi
        successCriteria:
          - condition: $statusCode == 200
        outputs:
          openapi: $response.body
    outputs:
      openapi: $steps.fetch_openapi.outputs.openapi
