#!/usr/bin/env bash
# Verification gate for the master-copywriter harness.
# The agent MUST run this before claiming any feature is done, and it MUST
# be re-run every session โ never trust a prior "done" claim.
#
# THE ANTI-THEATER GATE: this script proves the linter (verify_copywriting.py)
# actually enforces the rubric, not just prints green. It runs the linter
# against samples/good/* (must PASS, exit 0) AND samples/bad/* (must FAIL,
# nonzero). If the gate passes a bad sample or fails a good one, this script
# exits nonzero and the harness is considered broken.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
echo "== master-copywriter harness :: init.sh =="
# --- toolchain check -------------------------------------------------------
if ! command -v python3 >/dev/null 2>&1; then
echo "FAIL: python3 not found on PATH" >&2
exit 1
fi
LINTER="./verify_copywriting.py"
if [ ! -f "$LINTER" ]; then
echo "FAIL: $LINTER not found" >&2
exit 1
fi
GATE_OK=1
# --- anti-theater gate: good sample MUST pass -------------------------------
echo
echo "-- gate 1/2: samples/good/sales-page.md MUST pass --"
if python3 "$LINTER" sales-page samples/good/sales-page.md; then
echo "PASS: good sample passed as expected"
else
echo "FAIL: the linter rejected a KNOWN-EXCELLENT sample โ the gate is broken (too strict / buggy)" >&2
GATE_OK=0
fi
# --- anti-theater gate: bad sample MUST fail --------------------------------
echo
echo "-- gate 2/2: samples/bad/sales-page.md MUST fail --"
if python3 "$LINTER" sales-page samples/bad/sales-page.md; then
echo "FAIL: the linter PASSED a KNOWN-BROKEN sample โ the gate is theater, not real enforcement" >&2
GATE_OK=0
else
echo "PASS: bad sample was correctly rejected"
fi
echo
if [ "$GATE_OK" -ne 1 ]; then
echo "RESULT: FAIL โ the anti-theater gate itself is broken. Fix verify_copywriting.py before doing anything else." >&2
exit 1
fi
echo "RESULT: anti-theater gate PASS โ the linter genuinely discriminates good from bad."
# --- optional: verify any workspace artifacts that already exist -----------
# For each feature in feature_list.json, if its workspace deliverable exists,
# run its verify command and report status. This does NOT block init.sh โ
# workspace artifacts are expected to be absent until the agent builds them โ
# but it gives an honest read of current state every session.
echo
echo "-- workspace artifact status (informational) --"
# Plain-bash pairs (macOS ships bash 3.2 โ no associative arrays available).
FEATURE_PAIRS=(
"sales-page:workspace/sales-page.md"
"vsl-script:workspace/vsl-script.md"
"ad-set:workspace/ad-set.md"
"email-subject-bank:workspace/email-subject-bank.md"
"landing-hero-variants:workspace/landing-hero-variants.md"
)
for pair in "${FEATURE_PAIRS[@]}"; do
feature="${pair%%:*}"
f="${pair#*:}"
if [ -f "$f" ]; then
echo " $feature -> $f exists, verifying:"
if python3 "$LINTER" "$feature" "$f" >/dev/null 2>&1; then
echo " PASS"
else
echo " FAIL (not gate-passing yet โ feature stays in_progress)"
fi
else
echo " $feature -> $f not built yet"
fi
done
exit 0