{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/logbrew/json-schema/logbrew-repository-component-discovery-response-schema.json",
  "title": "RepositoryComponentDiscoveryResponse",
  "description": "Complete response for one repository component discovery attempt.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/logbrew-projects-api-openapi.yml#/components/schemas/RepositoryComponentDiscoveryResponse",
  "properties": {
    "components": {
      "description": "Deterministic component candidates, sorted by repository path.",
      "items": {
        "$ref": "#/$defs/RepositoryComponentCandidateResponse"
      },
      "type": "array"
    },
    "contents_authorization": {
      "$ref": "#/$defs/RepositoryContentsAuthorizationResponse",
      "description": "Separate provider contents-read authorization state."
    },
    "coverage": {
      "anyOf": [
        {
          "$ref": "#/$defs/RepositoryComponentCoverageResponse"
        },
        {
          "type": "null"
        }
      ],
      "description": "Bounded discovery coverage, when provider content was read."
    },
    "limitations": {
      "description": "Stable limitations that explain partial or unavailable evidence.",
      "items": {
        "$ref": "#/$defs/RepositoryComponentLimitationCode"
      },
      "type": "array"
    },
    "next": {
      "description": "Display-safe next step.",
      "type": "string"
    },
    "next_action": {
      "$ref": "#/$defs/RepositoryComponentNextActionResponse",
      "description": "Stable next action for clients and agents."
    },
    "repository": {
      "anyOf": [
        {
          "$ref": "#/$defs/RepositoryComponentRepositoryResponse"
        },
        {
          "type": "null"
        }
      ],
      "description": "Selected repository identity, when the metadata grant resolved it."
    },
    "response_version": {
      "description": "Schema version for strict clients.",
      "format": "uint8",
      "maximum": 255,
      "minimum": 0,
      "type": "integer"
    },
    "snapshot": {
      "anyOf": [
        {
          "$ref": "#/$defs/RepositoryComponentSnapshotResponse"
        },
        {
          "type": "null"
        }
      ],
      "description": "Stable snapshot identity when discovery produced selectable components."
    },
    "status": {
      "$ref": "#/$defs/RepositoryComponentDiscoveryStatus",
      "description": "Overall outcome of this discovery attempt."
    }
  },
  "required": [
    "response_version",
    "status",
    "repository",
    "contents_authorization",
    "snapshot",
    "components",
    "coverage",
    "limitations",
    "next",
    "next_action"
  ],
  "type": "object",
  "$defs": {
    "RepositoryComponentCandidateResponse": {
      "description": "One deterministic component candidate returned by repository discovery.",
      "properties": {
        "evidence": {
          "description": "Bounded normalized evidence; raw manifest content is never returned.",
          "items": {
            "$ref": "#/$defs/RepositoryComponentEvidenceResponse"
          },
          "type": "array"
        },
        "framework": {
          "description": "Recognized framework key, when proven by bounded evidence.",
          "type": [
            "string",
            "null"
          ]
        },
        "id": {
          "description": "Snapshot-scoped component identifier.",
          "format": "uuid",
          "type": "string"
        },
        "kind": {
          "$ref": "#/$defs/RepositoryComponentKind",
          "description": "Best-effort deployable role classification."
        },
        "path": {
          "description": "Repository-relative component directory, or `.` for the root.",
          "type": "string"
        },
        "recommended": {
          "description": "Whether `LogBrew` recommends selecting this component for telemetry setup.",
          "type": "boolean"
        },
        "runtime": {
          "description": "Supported `LogBrew` runtime key.",
          "type": "string"
        },
        "service_name": {
          "description": "Stable telemetry service name derived without reading arbitrary source text.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "path",
        "service_name",
        "runtime",
        "framework",
        "kind",
        "recommended",
        "evidence"
      ],
      "type": "object"
    },
    "RepositoryComponentCoverageResponse": {
      "description": "Coverage receipt for a bounded repository discovery.",
      "properties": {
        "component_limit": {
          "description": "Maximum candidates returned.",
          "format": "uint16",
          "maximum": 65535,
          "minimum": 0,
          "type": "integer"
        },
        "components_detected": {
          "description": "Candidates detected before the response component limit.",
          "format": "uint16",
          "maximum": 65535,
          "minimum": 0,
          "type": "integer"
        },
        "entries_seen": {
          "description": "Provider tree entries observed before local filtering.",
          "format": "uint32",
          "minimum": 0,
          "type": "integer"
        },
        "entry_limit": {
          "description": "Maximum provider tree entries considered.",
          "format": "uint32",
          "minimum": 0,
          "type": "integer"
        },
        "manifest_bytes_read": {
          "description": "Total bytes read from bounded manifest bodies.",
          "format": "uint32",
          "minimum": 0,
          "type": "integer"
        },
        "manifest_limit": {
          "description": "Maximum supported manifests considered.",
          "format": "uint16",
          "maximum": 65535,
          "minimum": 0,
          "type": "integer"
        },
        "manifests_found": {
          "description": "Supported manifest candidates found within the path bounds.",
          "format": "uint16",
          "maximum": 65535,
          "minimum": 0,
          "type": "integer"
        },
        "manifests_read": {
          "description": "Manifest bodies successfully read within the byte budget.",
          "format": "uint16",
          "maximum": 65535,
          "minimum": 0,
          "type": "integer"
        },
        "manifests_unreadable": {
          "description": "Manifest bodies that could not be read or decoded.",
          "format": "uint16",
          "maximum": 65535,
          "minimum": 0,
          "type": "integer"
        },
        "max_depth": {
          "description": "Maximum repository path depth considered.",
          "format": "uint8",
          "maximum": 255,
          "minimum": 0,
          "type": "integer"
        },
        "provider_truncated": {
          "description": "Whether the provider listing or bounded provider pagination was truncated.",
          "type": "boolean"
        }
      },
      "required": [
        "max_depth",
        "entry_limit",
        "entries_seen",
        "manifest_limit",
        "manifests_found",
        "manifests_read",
        "manifests_unreadable",
        "manifest_bytes_read",
        "component_limit",
        "components_detected",
        "provider_truncated"
      ],
      "type": "object"
    },
    "RepositoryComponentDiscoveryStatus": {
      "description": "Overall repository component discovery outcome.",
      "oneOf": [
        {
          "const": "complete",
          "description": "Provider contents were read within every declared bound.",
          "type": "string"
        },
        {
          "const": "partial",
          "description": "Selectable components were returned with explicit coverage limitations.",
          "type": "string"
        },
        {
          "const": "authorization_required",
          "description": "The user must grant separate repository contents-read access.",
          "type": "string"
        },
        {
          "const": "permission_insufficient",
          "description": "A stored grant does not include the provider's required read permission.",
          "type": "string"
        },
        {
          "const": "unavailable",
          "description": "The provider integration is not configured for repository contents discovery.",
          "type": "string"
        },
        {
          "const": "temporarily_unavailable",
          "description": "The provider or network could not complete a bounded read at this time.",
          "type": "string"
        }
      ]
    },
    "RepositoryComponentEvidenceKind": {
      "description": "Repository evidence category.",
      "oneOf": [
        {
          "const": "manifest",
          "description": "Supported project manifest path.",
          "type": "string"
        },
        {
          "const": "framework_dependency",
          "description": "Known framework dependency in a bounded manifest read.",
          "type": "string"
        },
        {
          "const": "framework_configuration",
          "description": "Known framework or platform configuration path.",
          "type": "string"
        }
      ]
    },
    "RepositoryComponentEvidenceResponse": {
      "description": "Normalized evidence supporting one component classification.",
      "properties": {
        "kind": {
          "$ref": "#/$defs/RepositoryComponentEvidenceKind",
          "description": "Evidence category."
        },
        "path": {
          "description": "Repository-relative evidence path.",
          "type": "string"
        },
        "value": {
          "description": "Stable recognized marker, never raw file content.",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "path",
        "value"
      ],
      "type": "object"
    },
    "RepositoryComponentKind": {
      "description": "Best-effort repository component role.",
      "oneOf": [
        {
          "const": "application",
          "description": "User-facing application such as a website or native app.",
          "type": "string"
        },
        {
          "const": "service",
          "description": "Independently running backend, worker, or service.",
          "type": "string"
        },
        {
          "const": "library",
          "description": "Shared package or library that is not independently observable by default.",
          "type": "string"
        },
        {
          "const": "workspace",
          "description": "Monorepo or package-manager workspace root.",
          "type": "string"
        },
        {
          "const": "unknown",
          "description": "A supported runtime was found but its deployable role is not proven.",
          "type": "string"
        }
      ]
    },
    "RepositoryComponentLimitationCode": {
      "description": "Stable repository discovery limitation codes.",
      "oneOf": [
        {
          "const": "provider_tree_truncated",
          "description": "Provider listing or bounded pagination did not cover the entire repository tree.",
          "type": "string"
        },
        {
          "const": "entry_limit_reached",
          "description": "`LogBrew` stopped after the documented tree entry limit.",
          "type": "string"
        },
        {
          "const": "depth_limit_reached",
          "description": "Supported manifests existed below the documented depth limit.",
          "type": "string"
        },
        {
          "const": "manifest_limit_reached",
          "description": "`LogBrew` stopped after the documented manifest count limit.",
          "type": "string"
        },
        {
          "const": "manifest_byte_limit_reached",
          "description": "Manifest reads stopped at the documented aggregate byte budget.",
          "type": "string"
        },
        {
          "const": "manifest_unreadable",
          "description": "One or more bounded manifest bodies were unavailable or invalid.",
          "type": "string"
        },
        {
          "const": "component_limit_reached",
          "description": "Candidate components exceeded the documented response limit.",
          "type": "string"
        },
        {
          "const": "no_supported_components_detected",
          "description": "No supported deployable manifest was detected within the declared bounds.",
          "type": "string"
        },
        {
          "const": "contents_authorization_required",
          "description": "No separate repository contents-read grant is stored.",
          "type": "string"
        },
        {
          "const": "contents_permission_insufficient",
          "description": "The provider rejected the stored grant for insufficient permission.",
          "type": "string"
        },
        {
          "const": "provider_unavailable",
          "description": "Provider OAuth credentials are not configured for this deployment.",
          "type": "string"
        },
        {
          "const": "provider_temporarily_unavailable",
          "description": "Provider or network failure prevented a complete bounded read.",
          "type": "string"
        }
      ]
    },
    "RepositoryComponentNextActionCode": {
      "description": "Repository component discovery next-action codes.",
      "oneOf": [
        {
          "const": "authorize_repository_contents",
          "description": "Grant separate read-only repository contents access.",
          "type": "string"
        },
        {
          "const": "reauthorize_repository_contents",
          "description": "Reconnect a grant that lacks the required provider permission.",
          "type": "string"
        },
        {
          "const": "retry_repository_discovery",
          "description": "Retry a temporary provider read failure.",
          "type": "string"
        },
        {
          "const": "select_repository_components",
          "description": "Select one or more returned components when creating the project.",
          "type": "string"
        },
        {
          "const": "use_manual_project_setup",
          "description": "Continue with ordinary manual project setup when no component is detected.",
          "type": "string"
        }
      ]
    },
    "RepositoryComponentNextActionResponse": {
      "description": "Stable next action attached to repository component discovery.",
      "properties": {
        "code": {
          "$ref": "#/$defs/RepositoryComponentNextActionCode",
          "description": "Machine-readable action code."
        },
        "target": {
          "$ref": "#/$defs/RepositoryComponentNextActionTarget",
          "description": "Product surface or API family that owns the action."
        }
      },
      "required": [
        "code",
        "target"
      ],
      "type": "object"
    },
    "RepositoryComponentNextActionTarget": {
      "description": "Repository component discovery next-action targets.",
      "oneOf": [
        {
          "const": "repository_contents_authorization",
          "description": "Explicit provider contents authorization route.",
          "type": "string"
        },
        {
          "const": "repository_component_discovery",
          "description": "Repository component discovery endpoint.",
          "type": "string"
        },
        {
          "const": "project_creation",
          "description": "Project creation contract.",
          "type": "string"
        }
      ]
    },
    "RepositoryComponentRepositoryResponse": {
      "description": "Repository identity bound to a discovery snapshot.",
      "properties": {
        "default_branch": {
          "description": "Default branch used for discovery.",
          "type": "string"
        },
        "full_name": {
          "description": "Owner-qualified repository name.",
          "type": "string"
        },
        "id": {
          "description": "Provider-owned stable repository identifier.",
          "type": "string"
        },
        "provider": {
          "$ref": "#/$defs/RepositoryProvider",
          "description": "Source-control provider."
        }
      },
      "required": [
        "provider",
        "id",
        "full_name",
        "default_branch"
      ],
      "type": "object"
    },
    "RepositoryComponentSnapshotResponse": {
      "description": "Stable, expiring repository snapshot used by project creation.",
      "properties": {
        "discovered_at": {
          "description": "Time this exact snapshot was most recently discovered.",
          "format": "date-time",
          "type": "string"
        },
        "expires_at": {
          "description": "Last time project creation may select components from this snapshot.",
          "format": "date-time",
          "type": "string"
        },
        "id": {
          "description": "Deterministic snapshot identifier.",
          "format": "uuid",
          "type": "string"
        },
        "revision": {
          "description": "Provider revision or tree digest read by discovery.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "revision",
        "discovered_at",
        "expires_at"
      ],
      "type": "object"
    },
    "RepositoryContentsAuthorizationResponse": {
      "description": "Separate contents-read authorization state for one provider.",
      "properties": {
        "connect_href": {
          "description": "Same-origin authorization start path when user action can grant access.",
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "$ref": "#/$defs/RepositoryContentsAuthorizationStatus",
          "description": "Current contents-read capability."
        }
      },
      "required": [
        "status",
        "connect_href"
      ],
      "type": "object"
    },
    "RepositoryContentsAuthorizationStatus": {
      "description": "Provider contents-read capability state.",
      "oneOf": [
        {
          "const": "ready",
          "description": "A usable contents-read grant was proven by the discovery request.",
          "type": "string"
        },
        {
          "const": "authorization_required",
          "description": "No usable contents-read grant is stored.",
          "type": "string"
        },
        {
          "const": "permission_insufficient",
          "description": "The provider rejected the stored grant for insufficient permission.",
          "type": "string"
        },
        {
          "const": "unavailable",
          "description": "Provider OAuth credentials are unavailable in this deployment.",
          "type": "string"
        },
        {
          "const": "error",
          "description": "A stored grant could not currently be used or refreshed.",
          "type": "string"
        }
      ]
    },
    "RepositoryProvider": {
      "description": "Source-control provider supported by repository-assisted project setup.",
      "oneOf": [
        {
          "const": "github",
          "description": "GitHub repository.",
          "type": "string"
        },
        {
          "const": "gitlab",
          "description": "GitLab project repository.",
          "type": "string"
        },
        {
          "const": "bitbucket",
          "description": "Bitbucket repository.",
          "type": "string"
        }
      ]
    }
  }
}