package-review-debug.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env bash
  2. # Thin entrypoint for intermediate review-debug packages (process evidence included).
  3. # Does not rewrite package_for_agent_analysis.py — only selects --profile review-debug.
  4. # Fail-closed: exact-commit snapshot only; refuse dirty/untracked worktrees.
  5. set -euo pipefail
  6. unset LD_LIBRARY_PATH LD_PRELOAD QT_PLUGIN_PATH || true
  7. ROOT="$(cd "$(dirname "$0")/.." && pwd)"
  8. VENV="${PRODU2_VERIFY_VENV:-${XDG_CACHE_HOME:-$HOME/.cache}/prod2u/venvs/verify}"
  9. PY="${VENV}/bin/python"
  10. [[ -x "$PY" ]] || PY=python3
  11. OUT="${PRODU2_HANDOFF_DIR:-${TMPDIR:-/tmp}/prod2u-handoff}"
  12. SHORT="$(git -C "$ROOT" rev-parse --short=8 HEAD 2>/dev/null || date -u +%Y%m%dT%H%M%SZ)"
  13. STAGE="intermediate-review"
  14. ARGS=()
  15. while [[ $# -gt 0 ]]; do
  16. case "$1" in
  17. --package-stage)
  18. STAGE="${2:-}"
  19. shift 2
  20. ;;
  21. --package-stage=*)
  22. STAGE="${1#*=}"
  23. shift
  24. ;;
  25. *)
  26. ARGS+=("$1")
  27. shift
  28. ;;
  29. esac
  30. done
  31. # Exact-commit provenance: refuse dirty tracked/staged/untracked trees.
  32. # Review package snapshots exact HEAD only; commit or clean the intended changes first.
  33. if [[ -n "$(git -C "$ROOT" status --porcelain --untracked-files=all 2>/dev/null || echo DIRTY)" ]]; then
  34. echo "ERROR: review package snapshots exact HEAD only; commit or clean the intended changes first" >&2
  35. echo "dirty worktree (tracked/staged/untracked) blocks package-review-debug.sh" >&2
  36. git -C "$ROOT" status --short --branch --untracked-files=all >&2 || true
  37. exit 2
  38. fi
  39. # Allow PRODU2_PACKAGE_NAME / PRODU2_PACKAGE_TOPIC to name the current MSE round.
  40. TOPIC="${PRODU2_PACKAGE_TOPIC:-${PRODU2_RELEASE_TASK_SLUG:-mse-a1}}"
  41. export PRODU2_PACKAGE_TOPIC="${TOPIC}"
  42. export PRODU2_RELEASE_TASK_SLUG="${TOPIC}"
  43. NAME="${PRODU2_PACKAGE_NAME:-prod2u-${TOPIC}-intermediate-review-debug-${SHORT}}"
  44. mkdir -p "$OUT"
  45. exec "$PY" -B "$ROOT/package_for_agent_analysis.py" \
  46. --profile review-debug \
  47. --include-process-evidence \
  48. --source-root "$ROOT" \
  49. --output-dir "$OUT" \
  50. --package-name "$NAME" \
  51. --package-stage "$STAGE" \
  52. "${ARGS[@]}"