#!/usr/bin/env bash
set -euo pipefail

COMMAND="${1:-help}"

case "$COMMAND" in
  help|--help|-h)
    cat <<'USAGE'
CORPIFORM — deterministic execution-control substrate

Usage:
  corpiform help
  corpiform doctor
  corpiform inspect
  corpiform execute
  corpiform freeze
  corpiform kill
  corpiform rotate-keys

Commands:
  help         Show this help surface
  doctor       Run non-invasive integrity checks
  inspect      Print current system inspection data
  execute      Run the canonical governed execution path
  freeze       Permanently freeze future execution
  kill         Permanently terminate the system
  rotate-keys  Record signing-key rotation event

Boundary:
  This package is a shell-based execution substrate.
  It is not a JS library API.
  It does not mint authority.
  It executes or refuses under explicit authority.
USAGE
    ;;
  doctor)
    exec tools/doctor.sh
    ;;
  inspect)
    exec tools/inspect.sh
    ;;
  execute)
    exec runtime/runner/run.sh
    ;;
  freeze)
    exec tools/freeze.sh
    ;;
  kill)
    exec tools/kill.sh
    ;;
  rotate-keys)
    exec tools/rotate_keys.sh
    ;;
  *)
    echo "REFUSE: unknown command '$COMMAND'" >&2
    echo "Use: corpiform help" >&2
    exit 1
    ;;
esac
