Files
CASAN/AINative_OKR_CASAN5/.specify/scripts/bash/import-provider-telemetry.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

40 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# CASAN Level 5 provider usage telemetry importer.
# Usage:
# import-provider-telemetry.sh <provider-usage-json>
INPUT_JSON="${1:-}"
if [[ -z "$INPUT_JSON" || ! -f "$INPUT_JSON" ]]; then
echo "Usage: import-provider-telemetry.sh <provider-usage-json>" >&2
exit 64
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
LOG_DIR="$PROJECT_ROOT/.specify/logs/level5"
OUT="$LOG_DIR/provider-usage.jsonl"
mkdir -p "$LOG_DIR"
python - "$INPUT_JSON" "$OUT" <<'PY'
import json
import sys
from datetime import datetime, timezone
src, out = sys.argv[1], sys.argv[2]
data = json.load(open(src, encoding="utf-8"))
required = ["provider", "model", "run_id", "step", "input_tokens", "output_tokens", "total_tokens", "cost_usd", "latency_ms", "status"]
missing = [key for key in required if key not in data]
if missing:
raise SystemExit(f"PROVIDER_USAGE_INVALID missing={missing}")
record = {
"timestamp": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"harness": "L5-provider-telemetry",
**data,
}
with open(out, "a", encoding="utf-8") as f:
f.write(json.dumps(record) + "\n")
print(f"PROVIDER_TELEMETRY_IMPORTED provider={data['provider']} model={data['model']} total_tokens={data['total_tokens']} cost_usd={data['cost_usd']} output={out}")
PY