audit pipeline v1.2: canonical business record as diff baseline (owner-verified truth), website JSON-LD hours, single-command e2e with gate
This commit is contained in:
@@ -3,17 +3,15 @@ set -euo pipefail
|
||||
|
||||
# VeriPath Audit Pipeline
|
||||
# Usage: ./audit_pipeline.sh "Business Name" "City, ST" [output-dir]
|
||||
# Sequence: multi_scraper.py → audit_engine.py → findings + raw capture in target folder
|
||||
# Sequence: multi_scraper.py → audit_engine.py → findings + report in target folder
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
BUSINESS="${1:?Usage: ./audit_pipeline.sh \"Business Name\" \"City, ST\" [output-dir]}"
|
||||
LOCATION="${2:?Usage: ./audit_pipeline.sh \"Business Name\" \"City, ST\" [output-dir]}"
|
||||
BUSINESS="${1:?Usage: audit_pipeline.sh \"Business Name\" \"City, ST\" [output-dir]}"
|
||||
LOCATION="${2:?Usage: audit_pipeline.sh \"Business Name\" \"City, ST\" [output-dir]}"
|
||||
OUTPUT_DIR="${3:-}"
|
||||
# cwd-proof: resolve to absolute once, so relative output dirs can't break capture copy
|
||||
if [ -n "$OUTPUT_DIR" ]; then
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
OUTPUT_DIR="$(cd "$OUTPUT_DIR" && pwd)"
|
||||
fi
|
||||
|
||||
# Scraper deps live in a separate uv project (no pyproject in this dir)
|
||||
export UV_PROJECT="${UV_PROJECT:-$HOME/deps/google-maps-scraper}"
|
||||
|
||||
# Temporary working dir for this run
|
||||
WORK_DIR=$(mktemp -d /tmp/veripath.XXXXXX)
|
||||
@@ -23,43 +21,39 @@ ENGINE_ARGS=("--md")
|
||||
|
||||
echo "[$(date +%T)] Scraping: $BUSINESS @ $LOCATION"
|
||||
|
||||
# Step 1: Multi-surface extraction (3rd arg = output DIR; scraper writes <dir>/multi_surface.json/<file>.json)
|
||||
# Step 1: Multi-surface extraction (3rd arg is an output DIR)
|
||||
uv run python3 "$SCRIPT_DIR/multi_scraper.py" "$BUSINESS" "$LOCATION" "$WORK_DIR"
|
||||
SCRAPER_OUT=$(find "$WORK_DIR" -name "*multi_surface*.json" | head -1)
|
||||
if [ ! -s "$SCRAPER_OUT" ]; then
|
||||
if [ -z "$SCRAPER_OUT" ] || [ ! -s "$SCRAPER_OUT" ]; then
|
||||
echo "[FAIL] multi_scraper.py produced no output" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "[OK] Extraction complete: $SCRAPER_OUT"
|
||||
|
||||
# Persist the raw capture into the run dir (WORK_DIR is wiped on exit;
|
||||
# report_generate / report_gate need it for evidence validation)
|
||||
if [ -n "$OUTPUT_DIR" ]; then
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
cp "$SCRAPER_OUT" "$OUTPUT_DIR/$(basename "$SCRAPER_OUT")"
|
||||
fi
|
||||
|
||||
# Step 2: Audit engine
|
||||
if [ -n "$OUTPUT_DIR" ]; then
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
# Required artifact set (locked beta process v1.1): raw capture + findings in the run folder
|
||||
# Collision-safe: a re-run never overwrites the prior capture (temporal baseline, v1.1 §5)
|
||||
DEST="$OUTPUT_DIR/$(basename "$SCRAPER_OUT")"
|
||||
if [ -e "$DEST" ]; then
|
||||
BASE="$(basename "${DEST%.*}")"; EXT="${DEST##*.}"
|
||||
DEST="$OUTPUT_DIR/${BASE}__$(date +%Y%m%d-%H%M%S).$EXT"
|
||||
echo "[WARN] prior capture present — writing $DEST (baseline preserved)"
|
||||
fi
|
||||
cp "$SCRAPER_OUT" "$DEST"
|
||||
ENGINE_ARGS+=("--output-dir" "$OUTPUT_DIR")
|
||||
echo "[$(date +%T)] Auditing (output: $OUTPUT_DIR)"
|
||||
uv run python3 "$SCRIPT_DIR/audit_engine.py" "$SCRAPER_OUT" "${ENGINE_ARGS[@]}"
|
||||
|
||||
# Step 3: Report + validation (locked process v1.1 §3)
|
||||
echo "[$(date +%T)] Generating report + validation"
|
||||
uv run python3 "$SCRIPT_DIR/report_generate.py" "$OUTPUT_DIR"
|
||||
|
||||
# Step 4: Pre-delivery consistency gate (v1.1 §6) — FAIL blocks delivery
|
||||
echo "[$(date +%T)] Consistency gate"
|
||||
if ! uv run python3 "$SCRIPT_DIR/report_gate.py" "$OUTPUT_DIR"; then
|
||||
echo "[GATE FAIL] $OUTPUT_DIR — do NOT deliver; see GATE RESULT in VALIDATION.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "[DONE] Findings + raw capture + report + gate written to $OUTPUT_DIR/"
|
||||
echo "[DONE] Findings written to $OUTPUT_DIR/"
|
||||
else
|
||||
echo "[$(date +%T)] Auditing (stdout)"
|
||||
uv run python3 "$SCRIPT_DIR/audit_engine.py" "$SCRAPER_OUT" "${ENGINE_ARGS[@]}"
|
||||
fi
|
||||
|
||||
# Step 3: report + strict delivery gate (one-command e2e)
|
||||
if [ -n "$OUTPUT_DIR" ]; then
|
||||
echo "[$(date +%T)] Building report"
|
||||
uv run python3 "$SCRIPT_DIR/report_generate.py" "$OUTPUT_DIR"
|
||||
echo "[$(date +%T)] Running delivery gate (strict)"
|
||||
uv run python3 "$SCRIPT_DIR/report_gate.py" "$OUTPUT_DIR" --strict
|
||||
echo "[GATE DONE]"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user