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

{
  id      = "generate-mdbook",
  trigger = "Generate navigable mdBook documentation from ontology, ADRs, modes, and crates",

  preconditions = [
    "nickel is available in PATH",
    ".ontology/core.ncl exists and exports without error",
  ],

  steps = [
    {
      id     = "generate-mdbook",
      action = "Extract all project data and generate docs/src/ + SUMMARY.md + build mdBook",
      actor  = 'Both,
      cmd    = "nu -c \"use ${ONTOREF_ROOT}/reflection/modules/generator.nu *; docs generate --fmt mdbook\"",
      verify = "test -d docs/src && test -f docs/src/SUMMARY.md",
      depends_on = [],
      on_error   = { strategy = 'Stop },
    },
  ],

  postconditions = [
    "docs/src/SUMMARY.md exists with chapter structure",
    "docs/src/architecture/overview.md reflects current .ontology/core.ncl",
    "docs/src/decisions/ contains one page per ADR",
    "docs/book/ contains navigable HTML if mdbook is installed",
  ],
} | s.Mode std.string.NonEmpty
