# SPDX-License-Identifier: MPL-2.0
# Mustfile — declarative state contract (template)
# Fill in: replace placeholder checks with real invariants for THIS repo.
# See: https://github.com/hyperpolymath/mustfile
# See: standards/contractiles/CANONICAL-TEMPLATES.adoc

version: 1

metadata:
  name: "REPLACE-WITH-REPO-NAME"
  spec: v1.0.0
  description: "REPLACE with a real description of what this contract guards."

checks:
  - name: tests-pass
    description: "All declared tests must pass. Failing tests block grade D."
    run: "just test"

  - name: format-ok
    description: "Source must be correctly formatted per repo style."
    run: "just fmt"

  - name: license-present
    description: "LICENSE file must exist."
    run: "test -f LICENSE"

  - name: readme-present
    description: "README.adoc (or README.md) must exist."
    run: "test -f README.adoc || test -f README.md"

  - name: readme-md-glama-carveout
    description: "Glama carve-out: if glama.json is present (repo listed on the Glama MCP-server directory, glama.ai), README.md MUST also exist — Glama requires it and will not render README.adoc. README.adoc stays canonical; README.md is maintained solely for Glama. A Glama limitation, not a policy change. No glama.json => no requirement, so non-Glama repos are unaffected."
    run: "test ! -f glama.json || test -f README.md"

  - name: spdx-headers-present
    description: "Source files must carry SPDX-License-Identifier headers."
    run: "bash -uc '! rg --files . | xargs -r grep -rL SPDX-License-Identifier | rg -v \".gitkeep|.lock|LICENSE|NOTICE\" | head -1 | rg .'"

  - name: no-template-residue
    description: "No placeholder text from the contractiles template must remain."
    run: "bash -uc '! rg -rn \"REPLACE-WITH|PLMP-1.0-or-later\" --type-not binary . | rg .'"

  - name: tooling-version-integrity
    description: "Installed just must satisfy the import? floor (>= 1.19.0). Dependency-free; proves the running just is new enough — the burble#39 invariant an in-file guard cannot enforce. See standards TOOLING-VERSION-INTEGRITY-POLICY.adoc."
    run: "bash -uc 'command -v just >/dev/null 2>&1 || exit 0; jv=$(just --version 2>/dev/null | cut -d\" \" -f2); test -n \"$jv\" || { echo \"just present, version unreadable\"; exit 1; }; maj=${jv%%.*}; rest=${jv#*.}; min=${rest%%.*}; { [ \"$maj\" -gt 1 ] || { [ \"$maj\" -eq 1 ] && [ \"$min\" -ge 19 ]; }; } || { echo \"just $jv < 1.19.0 import? unsupported\"; exit 1; }'"
