# Catalog declaration for the `rename_ontology_node` operation —
# kind = 'NclTransform. Phase B per ADR-030: declarable today, executive
# backend trigger-deferred (awaits the NCL-interpreter spike with
# expressive-power proof for ≥3 real ops).
#
# Cross-project consumers can READ this declaration via ADR-028
# content-addressed catalog ontologies right now; invoking it against a
# stock daemon returns HTTP 501 `missing_executive_backend`.

let s = import "../schema-future.ncl" in

(
  {
    id          = "rename_ontology_node",
    description = "Rename a node in .ontology/core.ncl by id — declarative NCL data-transform; no Rust handler.",
    kind        = 'NclTransform,

    body = {
      target     = ".ontology/core.ncl",
      selector   = "$.nodes[?(@.id == $inputs.node_id)].name",
      operation  = 'Set,
      value_expr = "$inputs.new_name",
    },

    inputs = {
      node_id  = "String",
      new_name = "String",
    },

    constraints = {
      # ondaod-pre REQUIRED for non-Rust kinds (ADR-034). Renaming an
      # ontology node is architectural mutation — ondaod discipline
      # MUST evaluate which named tensions the rename engages BEFORE
      # the transform runs.
      pre    = ["evaluate_ondaod", "node_exists", "new_name_well_formed"],
      inline = [],
      post   = ["ontology_well_formed"],
    },

    validation_sla = 'Synchronous,

    effects = [
      {
        kind       = 'Update,
        entity     = "OntologyNode",
        attrs      = ["name"],
        dimensions = [],
      },
    ],

    witness_shape = {
      # In-process transform — same payload_kind treatment as the Rust
      # path. The host runtime applies the transform and signs the
      # canonical state delta.
      payload_kind = "ontology_node_renamed",
      proof_paths  = ["ontology_node/<node_id>/name"],
      signature    = { actor_id = "developer", algorithm = "Ed25519" },
    },

    actor_policy = { roles = ["developer", "admin"] },

    render_paths = [".ontology/core.ncl"],
  } | s.OperationDecl | s.OndaodPreRequired
)
