# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
#
# Mustfile - declarative state contract for Evidence Graph (bofig)
# See: https://github.com/hyperpolymath/mustfile

version: 1

metadata:
  name: bofig-state-contract
  spec: v1.0.0
  description: "Invariant checks for bofig: compilation, tests, security, schema."

parameters:
  phoenix_port: "4000"
  arango_port: "8529"
  postgres_port: "5432"

checks:
  - name: compile-clean
    description: "Project must compile with zero warnings."
    run: "mix compile --warnings-as-errors"

  - name: tests-pass
    description: "All 257+ ExUnit tests must pass."
    run: "mix test"

  - name: credo-strict
    description: "Credo strict mode with zero issues."
    run: "mix credo --strict"

  - name: format-check
    description: "All Elixir code must be formatted."
    run: "mix format --check-formatted"

  - name: deps-audit
    description: "No known dependency vulnerabilities."
    run: "mix deps.audit"

  - name: spdx-headers
    description: "All lib/ files must have SPDX license headers."
    run: "bash -c '[ $(grep -rL \"SPDX-License-Identifier\" lib/ --include=\"*.ex\" | wc -l) -eq 0 ]'"

  - name: state-scm-exists
    description: "STATE.scm must exist in .machine_readable/."
    run: "test -f .machine_readable/STATE.scm"

  - name: health-endpoint
    description: "Health endpoint must be defined in router."
    run: "grep -q '/api/health' lib/evidence_graph_web/router.ex"
