# Institutional Capability Lineage Architecture (ICLA)
# Reference Specification
#
# Copyright (c) 2026 Mariano Garralda-Barrio
#
# Licensed under the Creative Commons Attribution 4.0
# International License (CC BY 4.0).
#
# See LICENSE in the repository root.

$schema: https://json-schema.org/draft/2020-12/schema
title: Capability Proposal
description: Pre-institutional crystallization record; identity is assigned only by promotion.
type: object
required:
  - document_type
  - format_version
  - specification_version
  - id
  - artifact_status
  - normative
  - schema_ref
  - generated_from
  - status
  - proposed_responsibility
  - supporting_record_refs
  - recurrence_assessment
  - stable_assembly_rules
  - value_assessment
  - comparable_outcome_refs
  - candidate_owner
  - overlap_analysis
  - proposal_scoped_ckc_draft_ref
properties:
  document_type: {const: capability-proposal}
  format_version: {const: icla-artifact/0.1-draft}
  specification_version:
    type: object
    required: [icla-spec]
    properties:
      icla-spec: {const: 0.1.0}
    additionalProperties: false
  id: {type: string, pattern: "^PROP-[A-Z0-9-]+$"}
  artifact_status: {const: reference}
  normative: {const: false}
  schema_ref: {type: string}
  generated_from:
    type: object
    required: [supporting_records]
    properties:
      supporting_records:
        type: array
        minItems: 1
        items:
          type: object
          required:
            - record_ref
            - record_type
            - repository_ref
            - record_locator
            - record_version
            - provenance_refs
          properties:
            record_ref: {type: string, minLength: 1}
            record_type: {type: string, minLength: 1}
            repository_ref: {type: string, minLength: 1}
            record_locator: {type: string, minLength: 1}
            record_version:
              anyOf:
                - {type: string, minLength: 1}
                - {type: integer, minimum: 1}
            provenance_refs:
              type: array
              minItems: 1
              uniqueItems: true
              items: {type: string, minLength: 1}
          additionalProperties: true
    additionalProperties: true
  status: {enum: [candidate, submitted]}
  proposed_responsibility:
    type: object
    required: [name, outcome, domain]
    properties:
      name: {type: string, minLength: 1}
      outcome: {type: string, minLength: 1}
      domain: {type: string, minLength: 1}
    additionalProperties: true
  supporting_record_refs:
    type: array
    minItems: 1
    uniqueItems: true
    items: {type: string, minLength: 1}
  recurrence_assessment:
    type: object
    required: [basis, justified_expectation, declared_horizon, rationale]
    properties:
      basis:
        enum: [observed-recurrence, prospective-continuity, mixed]
      justified_expectation: {type: boolean}
      current_trace_sufficient: {type: boolean}
      declared_horizon: {type: string, minLength: 1}
      rationale: {type: string, minLength: 1}
      required_future_execution_types:
        type: array
        minItems: 1
        uniqueItems: true
        items: {type: string, minLength: 1}
    additionalProperties: true
  stable_assembly_rules:
    type: array
    minItems: 1
    uniqueItems: true
    items: {type: string, minLength: 1}
  value_assessment: {type: object, minProperties: 1}
  comparable_outcome_refs:
    type: array
    minItems: 1
    uniqueItems: true
    items: {type: string, minLength: 1}
  candidate_owner: {type: string, minLength: 1}
  overlap_analysis:
    type: array
    minItems: 1
    items:
      anyOf:
        - {type: string, minLength: 1}
        - {type: object, minProperties: 1}
  proposed_relations:
    description: Candidate relations to existing institutional capabilities; direction is relative to the proposed responsibility and does not assign it a CAP-* identity.
    type: array
    minItems: 1
    uniqueItems: true
    items:
      type: object
      required: [type, direction, other_capability_ref]
      properties:
        type:
          enum:
            - depends_on
            - composes_with
            - specializes
            - replaces
            - shares_knowledge
            - derived_from
            - conflicts_with
        direction: {enum: [outgoing, incoming]}
        other_capability_ref: {type: string, pattern: "^CAP-[A-Z0-9-]+$"}
        rationale: {type: string, minLength: 1}
      additionalProperties: false
  proposal_scoped_ckc_draft_ref:
    type: string
    pattern: "^PROP-[A-Z0-9-]+-CKC-DRAFT$"
allOf:
  - not:
      anyOf:
        - required: [assigned_identity]
        - required: [institutional_capability_id]
        - required: [capability_ref]
additionalProperties: true
