#!/usr/bin/env bash # lib/env.sh — proof harness environment. # # Sourced once by run_proof.sh and by every case script. Establishes: # - service URLs (gateway and direct ports) # - report directory paths # - run context (git SHA, hostname, timestamp) # - mode (contract|integration|performance) # # Cases read from these vars; never re-set them. # Repo root — every path the harness emits is anchored here so report # JSON is portable across reviewer machines. PROOF_REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" export PROOF_REPO_ROOT # Service endpoints. Match internal/shared/config.go defaults; every # binary binds 127.0.0.1 per the audit's R-007 mitigation. export PROOF_GATEWAY_URL="${PROOF_GATEWAY_URL:-http://127.0.0.1:3110}" export PROOF_STORAGED_URL="${PROOF_STORAGED_URL:-http://127.0.0.1:3211}" export PROOF_CATALOGD_URL="${PROOF_CATALOGD_URL:-http://127.0.0.1:3212}" export PROOF_INGESTD_URL="${PROOF_INGESTD_URL:-http://127.0.0.1:3213}" export PROOF_QUERYD_URL="${PROOF_QUERYD_URL:-http://127.0.0.1:3214}" export PROOF_VECTORD_URL="${PROOF_VECTORD_URL:-http://127.0.0.1:3215}" export PROOF_EMBEDD_URL="${PROOF_EMBEDD_URL:-http://127.0.0.1:3216}" # Mode + report directory — set by run_proof.sh before sourcing cases. # Defaulted here so cases sourced standalone for debug still work. export PROOF_MODE="${PROOF_MODE:-contract}" if [ -z "${PROOF_REPORT_DIR:-}" ]; then ts="$(date -u +%Y%m%d-%H%M%SZ)" export PROOF_REPORT_DIR="${PROOF_REPO_ROOT}/tests/proof/reports/proof-${ts}" fi mkdir -p \ "${PROOF_REPORT_DIR}/raw/http" \ "${PROOF_REPORT_DIR}/raw/logs" \ "${PROOF_REPORT_DIR}/raw/outputs" \ "${PROOF_REPORT_DIR}/raw/metrics" \ "${PROOF_REPORT_DIR}/raw/cases" # Run context — captured once per run by run_proof.sh, but recomputed # here as fallback if a case is invoked standalone. if [ ! -f "${PROOF_REPORT_DIR}/raw/context.json" ]; then git_sha="$(cd "$PROOF_REPO_ROOT" && git rev-parse HEAD 2>/dev/null || echo unknown)" git_dirty="$(cd "$PROOF_REPO_ROOT" && [ -n "$(git status --porcelain 2>/dev/null)" ] && echo true || echo false)" cat > "${PROOF_REPORT_DIR}/raw/context.json" </dev/null || echo unknown)"