// SPDX-License-Identifier: BSD-2-Clause
//
// cispec.proto — Protocol Buffers schema for the org.cispec
// Change Item attribution namespace.
// Canonical governance: https://cispec.org/
// Validation toolkit:   https://cimatrix.org/
// IANA PEN:             42387
// Spec version:         1.0
//
// Generated code usage:
//   protoc --go_out=. cispec.proto      # Go
//   protoc --python_out=. cispec.proto  # Python
//   protoc --java_out=. cispec.proto    # Java
//   protoc --js_out=. cispec.proto      # JavaScript
//
// The CISpecLabelSet message encodes a complete label set for one CI.
// All fields except core identity fields are optional.

syntax = "proto3";

package org.cispec;

option java_package         = "org.cispec";
option java_outer_classname = "CISpecProto";
option go_package           = "cispec.org/proto";

// ============================================================
// Core label set — required for Declared conformance
// ============================================================

// The four required terms for Declared conformance.
// Any CISpecLabelSet missing any of these fields is non-conformant.
message CISpecCoreLabels {

  // org.cispec.organization — owning organisation slug.
  // X.500/X.520 organizationName (O) lineage — RFC 4514.
  // docOid: 1.3.6.1.4.1.42387.2.1
  string organization = 1;

  // org.cispec.orgunit — organisational unit slug.
  // X.500/X.520 organizationalUnitName (OU) lineage — RFC 4514.
  // docOid: 1.3.6.1.4.1.42387.2.1.1
  string orgunit = 2;

  // org.cispec.owner — accountable individual or role.
  // Bare email, GPG-key-ID@domain, or role:identity colon-qualified form.
  // docOid: 1.3.6.1.4.1.42387.2.1.2
  string owner = 3;

  // org.cispec.version — semver 2.0 version of the Change Item.
  // Universal: software, firmware, document revision, policy amendment.
  // docOid: 1.3.6.1.4.1.42387.2.4
  string version = 4;
}

// ============================================================
// Extension term — open namespace for implementor-minted terms
// ============================================================

// An implementor-minted org.cispec.* extension term.
// The term_name MUST resolve at a public TLS-verified domain
// per https://cispec.org/#minting-new-terms
message CISpecExtension {
  // Fully-qualified term name, e.g. "org.cispec.shift-supervisor"
  string term_name  = 1;
  // Bare string value
  string term_value = 2;
}

// ============================================================
// Conformance level
// ============================================================

enum CISpecConformanceLevel {
  // Unspecified — do not use
  CONFORMANCE_UNSPECIFIED = 0;

  // All required core keys present and well-formed; self-asserted
  DECLARED = 1;

  // Mechanically verified by cimatrix; terms resolve at public TLS domain
  VERIFIED = 2;

  // SLSA provenance attestation exists and has been verified
  ATTESTED = 3;
}

// ============================================================
// Full label set message
// ============================================================

message CISpecLabelSet {

  // Required core — Declared conformance
  CISpecCoreLabels core = 1;

  // Registry terms

  // org.cispec.oid — relational pointer to the client's own OID arc.
  // NOT DPS's 42387 arc — the customer or owning party's registered PEN.
  // docOid: 1.3.6.1.4.1.42387.2.2
  string oid = 2;

  // org.cispec.duns — D&B DUNS in OID notation: iso.org.duns.<9-digit>
  // Externally verifiable against the D&B registry.
  // docOid: 1.3.6.1.4.1.42387.2.2.1
  string duns = 3;

  // Financial terms

  // org.cispec.customer
  // docOid: 1.3.6.1.4.1.42387.2.3
  string customer = 4;

  // org.cispec.costcenter
  // docOid: 1.3.6.1.4.1.42387.2.3.1
  string costcenter = 5;

  // Lifecycle terms

  // org.cispec.specversion — spec version labels were authored against
  // docOid: 1.3.6.1.4.1.42387.2.4.1
  string specversion = 6;

  // org.cispec.environment — bare slug or purdue-level:<n> for ICS
  // docOid: 1.3.6.1.4.1.42387.2.4.2
  string environment = 7;

  // Custody terms — evidence CI type

  // org.cispec.custody-chain — bare pointer to external custody record
  // Not the record itself — a case ID, hash, or URI.
  // docOid: 1.3.6.1.4.1.42387.2.5
  string custody_chain = 8;

  // org.cispec.checksum — algorithm:hexdigest colon-separated
  // REQUIRED for evidence CIs (ISO/IEC 27037:2012);
  // recommended for software, hardware, and ICS CIs.
  // docOid: 1.3.6.1.4.1.42387.2.5.1
  string checksum = 9;

  // Software CI type terms

  // org.cispec.application
  // docOid: 1.3.6.1.4.1.42387.2.6.1.1
  string application = 10;

  // org.cispec.role — functional role slug
  // docOid: 1.3.6.1.4.1.42387.2.6.1.2
  string role = 11;

  // Extension terms — implementor-minted org.cispec.* terms
  repeated CISpecExtension extensions = 12;

  // Conformance level (informational)
  CISpecConformanceLevel conformance_level = 13;
}
