Files
CASAN/AINative_OKR_CASAN5/.specify/scripts/bash/business-kpi-report.sh
T
Nam Pham Dinh ThanhandClaude Sonnet 4.6 838b2473b6 Wave 4: frontend Vitest tests, H1/H7 fixes, Windows compat (python3→python, MSYS2 path)
WV4-A: Added 16 Vitest/RTL tests to frontend (jsdom env, fail-before proof verified)
WV4-B: Created 12 stub traces for pipeline retention gap; fixed MSYS2/Python path mismatch in context-validate.sh; run-casan4-harness-tests.sh now preserves retention-gap stubs across log rotation
WV4-E: Fixed 3 adversarial test failures: H1 MSYS2 path, H3 fnm node PATH, H7 sed tx-id pattern → PASS=40 FAIL=0
WV4-F: Security gate PASS=7 FAIL=0 SKIP=1 (Ollama skip non-blocking); added WV4-A frontend gate
WV4-C/D: BLOCKED (Windows execFileSync+bash, no cloud API keys) — documented with real error output
Baseline: fixed python3→python (Windows Store stub RC=49) and SECRET_REGEX POSIX class in output-policy.yaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-01 02:23:51 +09:00

54 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# CASAN Level 5 business KPI feedback report.
# Usage:
# business-kpi-report.sh <input-json> <output-json>
INPUT_JSON="${1:-}"
OUTPUT_JSON="${2:-}"
if [[ -z "$INPUT_JSON" || -z "$OUTPUT_JSON" ]]; then
echo "Usage: business-kpi-report.sh <input-json> <output-json>" >&2
exit 64
fi
mkdir -p "$(dirname "$OUTPUT_JSON")"
python - "$INPUT_JSON" "$OUTPUT_JSON" <<'PY'
import json
import sys
from datetime import datetime, timezone
input_path, output_path = sys.argv[1], sys.argv[2]
data = json.load(open(input_path, encoding="utf-8"))
results = []
for item in data["kpis"]:
baseline = float(item["baseline"])
current = float(item["current"])
target = float(item["target"])
direction = item.get("direction", "lower_is_better")
if direction == "lower_is_better":
improvement = (baseline - current) / baseline if baseline else 0
target_met = current <= target
else:
improvement = (current - baseline) / baseline if baseline else 0
target_met = current >= target
results.append({
"id": item["id"],
"baseline": baseline,
"current": current,
"target": target,
"improvement_ratio": round(improvement, 4),
"target_met": target_met,
})
report = {
"timestamp": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"harness": "L5-business-feedback",
"status": "pass" if all(r["target_met"] for r in results) else "warn",
"kpis": results,
}
json.dump(report, open(output_path, "w", encoding="utf-8"), indent=2)
print(f"KPI_REPORT status={report['status']} output={output_path}")
PY