#!/usr/bin/env bash
# Validate a SWE-bench patch against the official harness
set -euo pipefail
INSTANCE_JSON="$1"
PATCH_PATH="$2"
if [ ! -f "$INSTANCE_JSON" ]; then
    echo "ERROR: Instance JSON not found: $INSTANCE_JSON"
    exit 1
fi
if [ ! -f "$PATCH_PATH" ]; then
    echo "ERROR: Patch file not found: $PATCH_PATH"
    exit 1
fi
echo "Validating $INSTANCE_JSON with patch $PATCH_PATH..."
# In dry-run mode, just verify files exist
if [ "${DRY_RUN:-}" = "1" ]; then
    echo "DRY RUN: Files exist. To run full evaluation, install swe-bench/harness."
    echo "PASS"
    exit 0
fi
# Full evaluation requires swe-bench/harness
python3 -m swebench.harness.run_evaluation \
    --instance_path "$INSTANCE_JSON" \
    --predictions_path "$PATCH_PATH" \
    --log_dir ./eval_logs \
    --timeout 1800