Files
CASAN/packages/casan-harness/scripts/bash/harness-preflight.sh
T
thanhnvandClaude Opus 4.8 36a4812ef3 refactor(structure): promote app to repo root + remove redundant workspace cruft
Standard production layout: the OKR app (was nested under AINative_OKR_CASAN5/) is now
the repository root. No more wrapper directory.

- Promote AINative_OKR_CASAN5/* -> repo root (backend/ frontend/ packages/ apps/
  .specify/ docs/ infra/ nginx/ scripts/ + configs). Merge tool dirs: .gitea (kept the
  active deploy ci.yml, added harness-ci.yml + runbooks), .claude (agents/commands +
  launch.json), .github moved up.
- Remove redundant: 00_SUBMISSION_PACKAGE, scattered root notes (FPT_CASAN_Full.md,
  tu-tuong-casan.md, casan-tu-sinh..., casan_harness_assessment.md, source-review...,
  README_CASAN5_REFINED.md), casan-next-plans/ and optimize-docs/ (competition/planning
  artifacts — roadmap + design history preserved in git log / commit messages).
- Update all references to the old layout:
  - .gitea/workflows/{ci,harness-ci}.yml, .github/workflows/{ci,deploy}.yml:
    working-directory .; drop AINative_OKR_CASAN5/ prefix; .specify/{tests,scripts}
    -> packages/casan-harness/... (.specify/logs state kept)
  - .claude/launch.json, .gitea/*-runbook.md: path prefixes
  - CLAUDE.md, README.md: docs/input -> apps/okr/domain/input
  - policy-bundle.yaml: 8 policy paths -> packages/casan-harness/...; manifest re-signed
- secrets-scan.sh: fixture excludes -> new package/domain paths.

Full gate from the new root: PASS=64 FAIL=0 SKIP=3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 13:26:36 +09:00

47 lines
1.5 KiB
Bash

#!/usr/bin/env bash
set -uo pipefail
# CASAN harness preflight (Plan-15/13 enforcement wiring).
# Runs governance cores BEFORE a model call. Currently enforces RAI data
# governance: a prompt classified PII/confidential must not go to a CLOUD model
# without approval. Opt-in via CASAN_PREFLIGHT=1 so existing flows are unchanged.
#
# Args mirror model-router: <prompt-file> <out-json> [--role R] [--model M]
# Env: CASAN_MODEL_APPROVAL (approval token for sending sensitive data to cloud)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROMPT="${1:-}"
# SEC-20 (ARCH-04/09): fail closed if the required toolchain is missing or a
# required binary is PATH-shadowed by a planted copy (default checks only refuse on
# missing / in-workspace binaries; prod can set CASAN_TOOLCHAIN_TRUSTED_DIRS).
if [[ -f "$SCRIPT_DIR/toolchain-verify.sh" ]]; then
if ! bash "$SCRIPT_DIR/toolchain-verify.sh" >/dev/null 2>&1; then
echo "PREFLIGHT_BLOCK toolchain-verify (missing/shadowed binary)" >&2
exit 1
fi
fi
MODEL=""
while [[ $# -gt 0 ]]; do
case "$1" in
--model) MODEL="${2:-}"; shift 2 ;;
*) shift ;;
esac
done
case "$MODEL" in
openai:*|anthropic:*)
if [[ -n "$PROMPT" && -f "$PROMPT" ]]; then
if ! python3 "$SCRIPT_DIR/rai-guard.py" check-cloud --input "$PROMPT" --target cloud \
--approval "${CASAN_MODEL_APPROVAL:-}" >/dev/null 2>&1; then
echo "PREFLIGHT_BLOCK rai-check-cloud model=$MODEL" >&2
exit 1
fi
fi
;;
esac
echo "PREFLIGHT_OK model=${MODEL:-local}"
exit 0