let s = import "schema.ncl" in
let c = import "constraints.ncl" in

# Factory functions for reflection types.
# Pattern mirrors jpl_ontology/adrs/defaults.ncl: import schema + constraints, expose factories.

{
  # make_mode ActionContract data → validates structural contract + semantic constraints.
  # The Mode contract enforces DAG correctness (uniqueness + referential integrity).
  # Cycle detection runs separately in ontoref-reflection::dag::validate.
  make_mode = fun ActionContract => fun data =>
    let result | (s.Mode ActionContract) = data in
    let result | c.NonEmptySteps         = result in
    let result | c.ValidTrigger          = result in
    result,

  # make_step ActionContract data → validates a single step against the schema.
  make_step = fun ActionContract => fun data =>
    data | (s.ActionStep ActionContract),

  # Re-export raw types for consumers that apply contracts manually.
  Mode       = s.Mode,
  ActionStep = s.ActionStep,
  Dependency = s.Dependency,
  OnError    = s.OnError,
}
