$schema: "https://json-schema.org/draft/2020-12/schema"
$id: "https://cfse.ai/schemas/artifacts/invariant_library.schema.yaml"
title: "CFSE Invariant Library Schema"
description: |
  Schema for Invariant Library YAML files - a canonical packaging format
  that contains many Predicate (P-*) and Invariant (INV-*) objects in a
  single YAML document.

type: object

required:
  - predicates
  - invariants

properties:
  cfse:
    type: object
    description: |
      Optional metadata about the library's CFSE version and intended
      system ownership. This metadata does not affect CFSE semantics.
    properties:
      version:
        type: string
        description: "CFSE spec version this library targets (e.g., 1.0.0)."
      system:
        type: string
        pattern: "^[A-Z0-9]{2,8}$"
        description: |
          Optional system identifier hint (e.g., SHOP, AWS, K8S). Implementations
          MAY use this to enforce naming conventions such as INV-<SYSTEM>-*.
    additionalProperties: false

  predicates:
    type: array
    minItems: 0
    items:
      $ref: "https://cfse.ai/schemas/artifacts/predicate.schema.yaml"
    description: |
      Predicate objects (P-*) defined in this library. Each entry must conform
      to the Predicate artifact schema.

  invariants:
    type: array
    minItems: 0
    items:
      $ref: "https://cfse.ai/schemas/artifacts/invariant.schema.yaml"
    description: |
      Invariant objects (INV-*) defined in this library. Each entry must conform
      to the Invariant artifact schema.

  metadata:
    type: object
    description: |
      Optional implementation-defined metadata. This field MUST NOT be used
      to encode security logic; only INV-* and P-* objects are normative.
    additionalProperties: true

additionalProperties: false
