> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supermodeltools.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Impact analysis

> Compute blast radius — what breaks if a given file or function changes. Uses reverse-reachability BFS on call graph and dependency graph, enriched with LLM-powered domain classification to detect cross-domain impact.

**Three usage modes:**
1. **With diff** — upload a unified diff (`git diff` output) alongside the repo zip.
   Changed files are automatically extracted as targets. Best for CI/CD pipelines.

2. **With targets** — specify files or file:function pairs via query parameter.
   Best for ad-hoc analysis of specific functions.

3. **Neither** — analyzes the entire codebase and returns a global coupling/risk map
   with the most critical files ranked by dependent count.


**CI Integration (GitHub Actions):**
```yaml - name: Impact Analysis
  run: |
    git diff origin/main...HEAD > changes.diff
    git archive --format=zip HEAD -o repo.zip
    curl -s -X POST "$SUPERMODEL_API_URL/v1/analysis/impact" \
      -H "Idempotency-Key: ${{ github.run_id }}-impact" \
      -H "X-Api-Key: ${{ secrets.SUPERMODEL_API_KEY }}" \
      -F "file=@repo.zip;type=application/zip" \
      -F "diff=@changes.diff;type=text/plain" \
      -o impact.json
```

**CI Integration (GitLab CI):**
```yaml impact_analysis:
  script:
    - git diff origin/main...HEAD > changes.diff
    - git archive --format=zip HEAD -o repo.zip
    - >-
      curl -s -X POST "$SUPERMODEL_API_URL/v1/analysis/impact"
      -H "Idempotency-Key: $CI_PIPELINE_IID-impact"
      -H "X-Api-Key: $SUPERMODEL_API_KEY"
      -F "file=@repo.zip;type=application/zip"
      -F "diff=@changes.diff;type=text/plain"
      -o impact.json
```

**Standalone usage (no CI):**
```bash # Analyze specific targets curl -X POST '.../v1/analysis/impact?targets=src/services/billing.ts:calculateTotal' \
  -H 'Idempotency-Key: my-key' -H 'X-Api-Key: ...' \
  -F 'file=@repo.zip;type=application/zip'

# Analyze from a diff git diff main > changes.diff && git archive --format=zip HEAD -o repo.zip curl -X POST '.../v1/analysis/impact' \
  -H 'Idempotency-Key: my-key' -H 'X-Api-Key: ...' \
  -F 'file=@repo.zip;type=application/zip' \
  -F 'diff=@changes.diff;type=text/plain'

# Global coupling map (no targets, no diff) curl -X POST '.../v1/analysis/impact' \
  -H 'Idempotency-Key: my-key' -H 'X-Api-Key: ...' \
  -F 'file=@repo.zip;type=application/zip'
```



## OpenAPI

````yaml /openapi.yaml post /v1/analysis/impact
openapi: 3.0.0
info:
  title: Supermodel
  description: Code Graphing & Analysis API
  version: 0.9.6
  license:
    name: Supermodel API Terms of Service
    url: https://supermodeltools.com/legal/api-terms
servers:
  - url: https://api.supermodeltools.com
    description: Production server
security: []
tags:
  - name: Data Plane
    description: >-
      Calls the data plane to retrieve Supermodel analysis artifacts derived
      from repositories.
paths:
  /v1/analysis/impact:
    post:
      tags:
        - Data Plane
      summary: Impact analysis
      description: >-
        Compute blast radius — what breaks if a given file or function changes.
        Uses reverse-reachability BFS on call graph and dependency graph,
        enriched with LLM-powered domain classification to detect cross-domain
        impact.


        **Three usage modes:**

        1. **With diff** — upload a unified diff (`git diff` output) alongside
        the repo zip.
           Changed files are automatically extracted as targets. Best for CI/CD pipelines.

        2. **With targets** — specify files or file:function pairs via query
        parameter.
           Best for ad-hoc analysis of specific functions.

        3. **Neither** — analyzes the entire codebase and returns a global
        coupling/risk map
           with the most critical files ranked by dependent count.


        **CI Integration (GitHub Actions):**

        ```yaml - name: Impact Analysis
          run: |
            git diff origin/main...HEAD > changes.diff
            git archive --format=zip HEAD -o repo.zip
            curl -s -X POST "$SUPERMODEL_API_URL/v1/analysis/impact" \
              -H "Idempotency-Key: ${{ github.run_id }}-impact" \
              -H "X-Api-Key: ${{ secrets.SUPERMODEL_API_KEY }}" \
              -F "file=@repo.zip;type=application/zip" \
              -F "diff=@changes.diff;type=text/plain" \
              -o impact.json
        ```


        **CI Integration (GitLab CI):**

        ```yaml impact_analysis:
          script:
            - git diff origin/main...HEAD > changes.diff
            - git archive --format=zip HEAD -o repo.zip
            - >-
              curl -s -X POST "$SUPERMODEL_API_URL/v1/analysis/impact"
              -H "Idempotency-Key: $CI_PIPELINE_IID-impact"
              -H "X-Api-Key: $SUPERMODEL_API_KEY"
              -F "file=@repo.zip;type=application/zip"
              -F "diff=@changes.diff;type=text/plain"
              -o impact.json
        ```


        **Standalone usage (no CI):**

        ```bash # Analyze specific targets curl -X POST
        '.../v1/analysis/impact?targets=src/services/billing.ts:calculateTotal'
        \
          -H 'Idempotency-Key: my-key' -H 'X-Api-Key: ...' \
          -F 'file=@repo.zip;type=application/zip'

        # Analyze from a diff git diff main > changes.diff && git archive
        --format=zip HEAD -o repo.zip curl -X POST '.../v1/analysis/impact' \
          -H 'Idempotency-Key: my-key' -H 'X-Api-Key: ...' \
          -F 'file=@repo.zip;type=application/zip' \
          -F 'diff=@changes.diff;type=text/plain'

        # Global coupling map (no targets, no diff) curl -X POST
        '.../v1/analysis/impact' \
          -H 'Idempotency-Key: my-key' -H 'X-Api-Key: ...' \
          -F 'file=@repo.zip;type=application/zip'
        ```
      operationId: generateImpactAnalysis
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
        - name: targets
          in: query
          required: false
          schema:
            type: string
          description: >-
            Comma-separated list of file paths or file:functionName pairs to
            analyze. If omitted, analyzes all files and returns a global
            coupling/risk map. Examples: 'src/services/billing.ts',
            'src/services/billing.ts:calculateTotal,src/auth/login.ts'.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: Zipped repository archive containing the code to analyze.
                diff:
                  type: string
                  format: binary
                  description: >-
                    Optional unified diff (output of `git diff`). When provided,
                    changed files are automatically extracted and used as
                    analysis targets. This is the recommended input for CI/CD
                    pipelines. If both `diff` and `targets` are provided, the
                    targets from both are merged.
      responses:
        '200':
          description: Impact analysis (job completed)
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
            X-API-Version:
              $ref: '#/components/headers/X-API-Version'
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            X-Usage-Units:
              $ref: '#/components/headers/X-Usage-Units'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImpactAnalysisResponseAsync'
              example:
                status: completed
                jobId: abc-123-def
                result:
                  metadata:
                    totalFiles: 142
                    totalFunctions: 891
                    targetsAnalyzed: 1
                    analysisMethod: reverse_reachability_call_graph
                    analysisStartTime: '2026-02-09T12:00:00Z'
                    analysisEndTime: '2026-02-09T12:00:45Z'
                  impacts:
                    - target:
                        file: src/services/billing.ts
                        name: calculateTotal
                        line: 45
                        type: function
                      blastRadius:
                        directDependents: 8
                        transitiveDependents: 31
                        affectedFiles: 12
                        affectedDomains:
                          - Billing
                          - Checkout
                          - Notifications
                        riskScore: high
                        riskFactors:
                          - High fan-in (8 direct callers)
                          - Deep dependency chain (5 levels)
                          - Crosses 3 domain boundaries
                      affectedFunctions:
                        - file: src/handlers/checkout.ts
                          name: processCheckout
                          line: 12
                          type: function
                          distance: 1
                          relationship: direct_caller
                      affectedFiles:
                        - file: src/handlers/checkout.ts
                          directDependencies: 3
                          transitiveDependencies: 7
                      entryPointsAffected:
                        - file: src/routes/checkout.ts
                          name: POST /checkout
                          type: route_handler
                  globalMetrics:
                    mostCriticalFiles:
                      - file: src/services/billing.ts
                        dependentCount: 31
                        riskScore: high
                    crossDomainDependencies:
                      - from: Billing
                        to: Checkout
                        edgeCount: 5
                      - from: Billing
                        to: Notifications
                        edgeCount: 2
        '202':
          description: Job accepted and processing
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
            X-API-Version:
              $ref: '#/components/headers/X-API-Version'
            Retry-After:
              description: Recommended wait time in seconds before polling again.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImpactAnalysisResponseAsync'
              example:
                status: processing
                jobId: abc-123-def
                retryAfter: 10
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
        '502':
          description: Bad Gateway
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: cURL
          label: With diff (CI)
          source: |
            git diff origin/main...HEAD > changes.diff
            git archive --format=zip HEAD -o repo.zip
            curl -X POST 'https://api.supermodeltools.com/v1/analysis/impact' \
              -H 'Idempotency-Key: <idempotency-key>' \
              -H 'X-Api-Key: <api-key>' \
              -F 'file=@repo.zip;type=application/zip' \
              -F 'diff=@changes.diff;type=text/plain'
        - lang: cURL
          label: With targets
          source: >
            curl -X POST
            'https://api.supermodeltools.com/v1/analysis/impact?targets=src/services/billing.ts'
            \
              -H 'Idempotency-Key: <idempotency-key>' \
              -H 'X-Api-Key: <api-key>' \
              -F 'file=@/path/to/your/repo-snapshot.zip;type=application/zip'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: Unique identifier for this request for idempotency and tracing.
      schema:
        type: string
  headers:
    X-Request-Id:
      description: Unique request identifier echoed back from the Idempotency-Key header.
      schema:
        type: string
    X-API-Version:
      description: Semantic version of the API service handling the request.
      schema:
        type: string
    RateLimit-Limit:
      description: Maximum number of requests allowed in the current rate limit window.
      schema:
        type: integer
        format: int32
    RateLimit-Remaining:
      description: Remaining number of requests available in the current rate limit window.
      schema:
        type: integer
        format: int32
    RateLimit-Reset:
      description: UTC epoch seconds when the current rate limit window resets.
      schema:
        type: integer
        format: int64
    X-Usage-Units:
      description: Metered usage units consumed by this request.
      schema:
        type: number
        format: float
  schemas:
    ImpactAnalysisResponseAsync:
      allOf:
        - $ref: '#/components/schemas/JobStatus'
        - type: object
          description: Async response envelope for impact analysis operations.
          properties:
            result:
              $ref: '#/components/schemas/ImpactAnalysisResponse'
              description: The result (present when status is completed).
    Error:
      type: object
      description: Standardized error payload returned by the API.
      required:
        - status
        - code
        - message
        - timestamp
      properties:
        status:
          type: integer
          format: int32
          description: HTTP status code associated with the error.
          minimum: 100
          maximum: 599
        code:
          type: string
          description: Stable, machine-readable error identifier.
        message:
          type: string
          description: Human-readable description of the error.
        timestamp:
          type: string
          format: date-time
          description: ISO-8601 timestamp indicating when the error occurred.
        requestId:
          type: string
          description: Correlation identifier for tracing the failing request.
        details:
          type: array
          description: Optional list of contextual error details.
          items:
            type: object
            required:
              - field
              - issue
            properties:
              field:
                type: string
                description: Name of the field or parameter related to the error.
              issue:
                type: string
                description: Description of the specific issue encountered.
              location:
                type: string
                description: Where the field resides (e.g., query, path, body).
    JobStatus:
      type: object
      description: Common fields for async job status tracking.
      required:
        - status
        - jobId
      properties:
        status:
          type: string
          description: Current status of the job.
          enum:
            - pending
            - processing
            - completed
            - failed
        jobId:
          type: string
          description: Unique identifier for the job.
        retryAfter:
          type: integer
          format: int32
          description: Recommended seconds to wait before polling again.
        error:
          type: string
          description: Error message (present when status is failed).
    ImpactAnalysisResponse:
      type: object
      description: >-
        Impact analysis result containing blast radius and affected
        functions/files.
      required:
        - metadata
        - impacts
        - globalMetrics
      properties:
        metadata:
          $ref: '#/components/schemas/ImpactAnalysisMetadata'
        impacts:
          type: array
          description: Impact results for each analyzed target.
          items:
            $ref: '#/components/schemas/ImpactResult'
        globalMetrics:
          $ref: '#/components/schemas/ImpactGlobalMetrics'
    ImpactAnalysisMetadata:
      type: object
      description: Summary statistics for the impact analysis.
      required:
        - totalFiles
        - totalFunctions
        - targetsAnalyzed
        - analysisMethod
      properties:
        totalFiles:
          type: integer
          format: int64
          description: Total number of files in the repository.
        totalFunctions:
          type: integer
          format: int64
          description: Total number of functions analyzed.
        targetsAnalyzed:
          type: integer
          format: int32
          description: Number of targets analyzed.
        analysisMethod:
          type: string
          description: Method used for impact analysis.
        analysisStartTime:
          type: string
          format: date-time
          description: Timestamp when analysis started.
        analysisEndTime:
          type: string
          format: date-time
          description: Timestamp when analysis completed.
    ImpactResult:
      type: object
      description: Impact analysis result for a single target.
      required:
        - target
        - blastRadius
        - affectedFunctions
        - affectedFiles
        - entryPointsAffected
      properties:
        target:
          $ref: '#/components/schemas/ImpactTarget'
        blastRadius:
          $ref: '#/components/schemas/BlastRadius'
        affectedFunctions:
          type: array
          description: Functions affected by changes to this target.
          items:
            $ref: '#/components/schemas/AffectedFunction'
        affectedFiles:
          type: array
          description: Files affected by changes to this target.
          items:
            $ref: '#/components/schemas/AffectedFile'
        entryPointsAffected:
          type: array
          description: Entry points (route handlers, exports) affected by this target.
          items:
            $ref: '#/components/schemas/AffectedEntryPoint'
    ImpactGlobalMetrics:
      type: object
      description: Global metrics across all analyzed targets.
      properties:
        mostCriticalFiles:
          type: array
          description: Files with the highest dependent counts.
          items:
            $ref: '#/components/schemas/CriticalFile'
        crossDomainDependencies:
          type: array
          description: Dependencies that cross domain boundaries (scaffolded, empty in v1).
          items:
            $ref: '#/components/schemas/CrossDomainDependency'
    ImpactTarget:
      type: object
      description: The target file or function being analyzed for impact.
      required:
        - file
        - type
      properties:
        file:
          type: string
          description: File path relative to repository root.
        name:
          type: string
          description: Function or method name (if targeting a specific function).
        line:
          type: integer
          format: int32
          description: Line number of the target declaration.
        type:
          type: string
          description: Type of the target element.
          enum:
            - file
            - function
            - method
            - class
    BlastRadius:
      type: object
      description: Blast radius metrics for a target.
      required:
        - directDependents
        - transitiveDependents
        - affectedFiles
        - riskScore
      properties:
        directDependents:
          type: integer
          format: int32
          description: Number of direct callers/dependents.
        transitiveDependents:
          type: integer
          format: int32
          description: Number of transitive (indirect) dependents.
        affectedFiles:
          type: integer
          format: int32
          description: Number of files affected.
        affectedDomains:
          type: array
          description: Domains affected by this change (scaffolded, empty in v1).
          items:
            type: string
        riskScore:
          type: string
          description: Risk level based on blast radius analysis.
          enum:
            - low
            - medium
            - high
            - critical
        riskFactors:
          type: array
          description: Human-readable explanations for the risk score.
          items:
            type: string
    AffectedFunction:
      type: object
      description: A function affected by changes to the target.
      required:
        - file
        - name
        - type
        - distance
        - relationship
      properties:
        file:
          type: string
          description: File path relative to repository root.
        name:
          type: string
          description: Name of the affected function.
        line:
          type: integer
          format: int32
          description: Line number of the function declaration.
        type:
          type: string
          description: Type of code element.
          enum:
            - function
            - method
            - class
        distance:
          type: integer
          format: int32
          description: Number of hops from the target in the call graph.
        relationship:
          type: string
          description: Relationship type to the target.
          enum:
            - direct_caller
            - transitive_caller
    AffectedFile:
      type: object
      description: A file affected by changes to the target.
      required:
        - file
        - directDependencies
        - transitiveDependencies
      properties:
        file:
          type: string
          description: File path relative to repository root.
        directDependencies:
          type: integer
          format: int32
          description: Number of direct dependencies in this file.
        transitiveDependencies:
          type: integer
          format: int32
          description: Number of transitive dependencies in this file.
    AffectedEntryPoint:
      type: object
      description: An entry point affected by changes to the target.
      required:
        - file
        - name
        - type
      properties:
        file:
          type: string
          description: File path relative to repository root.
        name:
          type: string
          description: Name or route of the entry point.
        type:
          type: string
          description: Type of entry point.
          enum:
            - route_handler
            - module_export
            - main_function
            - event_handler
    CriticalFile:
      type: object
      description: A file identified as critical due to high dependent count.
      required:
        - file
        - dependentCount
        - riskScore
      properties:
        file:
          type: string
          description: File path relative to repository root.
        dependentCount:
          type: integer
          format: int32
          description: Total number of transitive dependents.
        riskScore:
          type: string
          description: Risk level based on dependent count.
          enum:
            - low
            - medium
            - high
            - critical
    CrossDomainDependency:
      type: object
      description: A dependency that crosses domain boundaries.
      required:
        - from
        - to
        - edgeCount
      properties:
        from:
          type: string
          description: Source domain.
        to:
          type: string
          description: Target domain.
        edgeCount:
          type: integer
          format: int32
          description: Number of cross-domain edges.
  responses:
    BadRequest:
      description: The request could not be processed because of a client error.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
        X-API-Version:
          $ref: '#/components/headers/X-API-Version'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-Usage-Units:
          $ref: '#/components/headers/X-Usage-Units'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: 400
            code: invalid_request
            message: Missing required query parameter 'repo'.
            timestamp: '2025-02-05 16:35:12.000000000 Z'
            requestId: req_01HZYJ9CE0ABCDEF1234
            details:
              - field: repo
                issue: This field is required.
                location: query
    Unauthorized:
      description: Authentication failed or was not provided.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
        X-API-Version:
          $ref: '#/components/headers/X-API-Version'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-Usage-Units:
          $ref: '#/components/headers/X-Usage-Units'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: 401
            code: unauthorized
            message: Provide a valid OAuth token to access this resource.
            timestamp: '2025-02-05 16:35:12.000000000 Z'
            requestId: req_01HZYJ9CE0ABCDEFXYZ1
    Forbidden:
      description: The authenticated principal lacks the required permissions.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
        X-API-Version:
          $ref: '#/components/headers/X-API-Version'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-Usage-Units:
          $ref: '#/components/headers/X-Usage-Units'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: 403
            code: forbidden
            message: The token lacks the required keys:write scope.
            timestamp: '2025-02-05 16:35:12.000000000 Z'
            requestId: req_01HZYJ9CE0ABCDEFFORB
    TooManyRequests:
      description: The rate limit for the resource has been exceeded.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
        X-API-Version:
          $ref: '#/components/headers/X-API-Version'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-Usage-Units:
          $ref: '#/components/headers/X-Usage-Units'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: 429
            code: rate_limit_exceeded
            message: Too many requests. Try again after the reset window.
            timestamp: '2025-02-05 16:35:12.000000000 Z'
            requestId: req_01HZYJ9CE0ABCDEFRATE
    InternalError:
      description: The server encountered an unexpected condition.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
        X-API-Version:
          $ref: '#/components/headers/X-API-Version'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-Usage-Units:
          $ref: '#/components/headers/X-Usage-Units'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: 500
            code: internal_error
            message: Unexpected error processing request. Please retry.
            timestamp: '2025-02-05 16:35:12.000000000 Z'
            requestId: req_01HZYJ9CE0ABCDEFFAIL
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: API key issued by the control plane for accessing data plane resources.

````