You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if [ -n"$PROXY_PID" ] &&kill -0 "$PROXY_PID"2>/dev/null;then
kill"$PROXY_PID"2>/dev/null ||true
wait"$PROXY_PID"2>/dev/null ||true
fi
PROXY_PID=""
}
# wait_for_tools polls until EXPECTED_TOOLS is reached (echoes the count and
# returns 0) or WAIT_SECS elapses (echoes the last stable count, returns 1).
wait_for_tools() {
local waited=0 count=0
while [ "$waited"-lt"$WAIT_SECS" ];do
count="$(tool_count)"
if [ "$count"-ge"$EXPECTED_TOOLS" ];then
echo"$count"
return 0
fi
sleep 5
waited=$((waited +5))
done
echo"$count"
return 1
}
# Attempt 1 (+ one full retry for transient npx/uvx download failures).
ATTEMPT=1
COUNT=0
DATA_DIR=""
while:;do
log "Booting snapshot proxy on ${BASE_URL} (attempt ${ATTEMPT}, waiting up to ${WAIT_SECS}s for ${EXPECTED_TOOLS} tools)"
DATA_DIR="$WORK/data-${ATTEMPT}"
start_proxy "$DATA_DIR"
if COUNT="$(wait_for_tools)";then
log "All ${COUNT} tools indexed"
break
fi
if [ "$ATTEMPT"-ge 2 ];then
if [ "$COUNT"-eq 0 ];then
echo"error: no tools appeared after ${ATTEMPT} attempts — proxy log tail:">&2
tail -30 "$WORK/proxy.log">&2
exit 1
fi
echo"::warning:: only ${COUNT}/${EXPECTED_TOOLS} tools after ${ATTEMPT} attempts — proceeding with the REDUCED corpus. Record the reduced count + the missing server in datasets/README.md.">&2
break
fi
echo"::warning:: ${COUNT}/${EXPECTED_TOOLS} tools after ${WAIT_SECS}s — restarting proxy once (transient npx/uvx download failures)">&2
stop_proxy
ATTEMPT=$((ATTEMPT +1))
done
# Stop the proxy BEFORE the export: the dump helper opens the Bleve index
# directly (single-writer lock) and reads the authoritative ParamsJSON.
stop_proxy
log "Exporting + canonicalizing corpus_v2 (${COUNT} tools) from the index at ${DATA_DIR}"
CAPTURE_DATE="$(date -u +%Y-%m-%d)"
mkdir -p "$(dirname "$OUT")"
go run ./scripts/gen-corpus-v2-dump -data-dir "$DATA_DIR" \
| jq -S --arg version "corpus_v2@${CAPTURE_DATE}" --arg date "$CAPTURE_DATE"'{
version: $version,
generated_from: {
note: "Spec 083 D4 schema-bearing frozen corpus: the 7 no-auth Spec-065 reference servers (filesystem, git, memory, sqlite, fetch, time, sequential-thinking) via snapshot-servers.config.json, exported WITH full JSON input schemas.",
source: "Bleve index ParamsJSON via scripts/gen-corpus-v2-dump (GET /api/v1/tools serves stub schemas — see header comment)",
echo"error: corpus_v2 must be schema-bearing — the tools above have empty/missing schemas">&2
exit 1
fi
if [ "$TOOLS_IN_FILE"-lt"$EXPECTED_TOOLS" ];then
echo"::warning:: reduced corpus (${TOOLS_IN_FILE}/${EXPECTED_TOOLS} tools) — note this explicitly in specs/083-discovery-profiler/datasets/README.md">&2
fi
log "Wrote ${OUT} (${TOOLS_IN_FILE} tools, capture date ${CAPTURE_DATE})"
echo"Next: record tool count + provenance in specs/083-discovery-profiler/datasets/README.md and commit both."