Files
timmy-config/bin/perplexity-coverage.sh
Timmy Time 11dbd93a03
Some checks failed
Architecture Lint / Linter Tests (pull_request) Successful in 25s
Smoke Test / smoke (pull_request) Failing after 21s
Validate Config / YAML Lint (pull_request) Failing after 14s
Validate Config / JSON Validate (pull_request) Successful in 17s
Validate Config / Python Syntax & Import Check (pull_request) Failing after 54s
Validate Config / Python Test Suite (pull_request) Has been skipped
Validate Config / Cron Syntax Check (pull_request) Successful in 11s
Validate Config / Deploy Script Dry Run (pull_request) Successful in 10s
Validate Config / Playbook Schema Validation (pull_request) Successful in 21s
Validate Config / Shell Script Lint (pull_request) Failing after 54s
Architecture Lint / Lint Repository (pull_request) Failing after 14s
PR Checklist / pr-checklist (pull_request) Successful in 3m28s
feat(quality): establish Perplexity as standing quality gate
- bin/perplexity-quality-gate.sh: branch protection setter
- bin/perplexity-coverage.sh: coverage tracking + JSONL logs
- docs/QUALITY_GATES.md: full policy + usage
- agent-lanes.json: adds quality gate skill to Perplexity lane

Acceptance criteria:
1) Add branch protection requiring ≥1 review — quality-gate.sh
2) Configure Perplexity as default reviewer — same script sets required_reviewers
3) Track review coverage rate — coverage.sh + logs/
4) Document review standard — QUALITY_GATES.md refs #387

Closes #477
2026-04-26 06:11:04 -04:00

70 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="${SCRIPT_DIR%/bin}"
resolve_gitea_url() {
if [ -n "${GITEA_URL:-}" ]; then
printf '%s\n' "${GITEA_URL%/}"; return 0; fi
if [ -f "$HOME/.hermes/gitea_api" ]; then
python3 - "$HOME/.hermes/gitea_api" <<'PY'
from pathlib import Path; import sys
raw = Path(sys.argv[1]).read_text().strip().rstrip("/")
print(raw[:-7] if raw.endswith("/api/v1") else raw)
PY
return 0; fi
if [ -f "$HOME/.config/gitea/base-url" ]; then
tr -d '[:space:]' < "$HOME/.config/gitea/base-url"; return 0; fi
echo "ERROR: set GITEA_URL or token file" >&2; return 1
}
resolve_token() {
for f in "$HOME/.config/gitea/timmy-token" "$HOME/.hermes/gitea_token_vps" "$HOME/.hermes/gitea_token_timmy" "$HOME/.config/gitea/token"; do
[ -f "$f" ] && { tr -d '[:space:]' < "$f"; return 0; }
done; return 1
}
GITEA_URL="$(resolve_gitea_url)"
TOKEN="$(resolve_token)"
[ -n "$TOKEN" ] || { echo "ERROR: No Gitea token"; exit 1; }
AUTH="Authorization: token $TOKEN"
PERPLEXITY="perplexity"
CORE_REPOS=(
"Timmy_Foundation/the-nexus"
"Timmy_Foundation/timmy-home"
"Timmy_Foundation/timmy-config"
"Timmy_Foundation/hermes-agent"
"Timmy_Foundation/the-playground"
)
DAYS="${1:-30}"
echo "=== Perplexity Review Coverage (last $DAYS days) ==="
total_merged=0; total_with_perp=0
for REPO in "${CORE_REPOS[@]}"; do
JSON=$(curl -s -H "$AUTH" "$GITEA_URL/api/v1/repos/$REPO/pulls?state=closed&limit=100")
python3 - "$REPO" "$DAYS" "$PERPLEXITY" "$JSON" <<'PY'
import json, sys, datetime
repo, days, target = sys.argv[1], int(sys.argv[2]), sys.argv[3]
data = json.loads(sys.argv[4])
cutoff = datetime.datetime.now() - datetime.timedelta(days=days)
merged_total = reviewed = merged_with_perp = 0
for pr in data:
try:
created = datetime.datetime.fromisoformat(pr.get('created_at','').replace('Z','+00:00'))
except: continue
if created < cutoff: continue
if pr.get('state') != 'merged': continue
merged_total += 1
reviewers = pr.get('reviewers', []) or []
for r in reviewers:
if isinstance(r, dict) and r.get('login') == target:
merged_with_perp += 1; break
print(f"{repo}: {merged_total} merged, {merged_with_perp} with {target}")
PY
done
echo "Note: Detailed per-PR auditing via ops-review-queue."