forked from lance-format/lance-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodec_sweep.sh
More file actions
executable file
·88 lines (75 loc) · 2.97 KB
/
Copy pathcodec_sweep.sh
File metadata and controls
executable file
·88 lines (75 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
#
# codec_sweep.sh — curl-driven lab iteration for codec sweeps.
#
# Reads a YAML config under configs/codec/, converts to JSON via yq, POSTs
# to the running shader-lab's /v1/shader/sweep endpoint, pretty-prints the
# WireSweepResponse.
#
# Prereqs: yq (mikefarah/yq ≥ v4), curl, jq, a running shader-lab binary
# on SHADER_LAB_URL (default http://localhost:3001).
#
# Usage:
# scripts/codec_sweep.sh configs/codec/00_pr220_baseline.yaml
# SHADER_LAB_URL=http://10.0.0.5:3001 scripts/codec_sweep.sh configs/codec/10_wider_codebook.yaml
#
# Output: JSON WireSweepResponse with per-grid-point stub results (until
# D2.2 lands real decode-and-compare). Every result row has stub:true.
set -euo pipefail
SHADER_LAB_URL="${SHADER_LAB_URL:-http://localhost:3001}"
ENDPOINT="${SHADER_LAB_URL}/v1/shader/sweep"
if [[ $# -lt 1 ]]; then
echo "usage: $0 <yaml-config>"
echo " example: $0 configs/codec/00_pr220_baseline.yaml"
exit 2
fi
CONFIG="$1"
if [[ ! -f "$CONFIG" ]]; then
echo "config not found: $CONFIG" >&2
exit 2
fi
if ! command -v yq >/dev/null 2>&1; then
echo "yq not installed — install mikefarah/yq (https://github.com/mikefarah/yq)" >&2
exit 2
fi
# Convert YAML → JSON; POST to endpoint; pretty-print response.
json_body=$(yq -o=json '.' "$CONFIG")
echo "=== POST $ENDPOINT ==="
echo "--- request ---"
echo "$json_body" | jq '.'
echo
echo "--- response ---"
response=$(curl -sS -X POST "$ENDPOINT" \
-H "Content-Type: application/json" \
-d "$json_body")
echo "$response" | jq '.'
echo
echo "=== Stub honesty check ==="
# Per EPIPHANIES.md 2026-04-20 "D0.2 stub flag is anti-#219 defense at
# the type level" — the check MUST fail the script (not just log) when
# the flag is absent or false. Until D2.2 lands real decode-and-compare,
# Phase 0/2 runs return stub:true. A non-stub response here means
# either the wrong endpoint was hit, the response was malformed, or
# (worst case) the server silently shipped non-stub code and this
# script is now pretending synthetic numbers are real.
stub_flag=$(echo "$response" | jq -r '.results[0].stub // "missing"')
echo "results[0].stub = $stub_flag"
case "$stub_flag" in
true)
echo "OK — Phase 0 stub honored. (D2.2 will flip this to false when real decode lands;"
echo " at that point, flip this check too.)"
;;
false)
echo "FAIL — results[0].stub is false but D2.2 has not landed." >&2
echo " This script refuses to treat non-stub output as real during Phase 0." >&2
echo " Either the server is running non-scaffold code (update this check)," >&2
echo " or the request hit the wrong endpoint / unexpected handler." >&2
exit 3
;;
*)
echo "FAIL — results[0].stub missing or unparseable (got: $stub_flag)." >&2
echo " Response may be malformed or an error payload." >&2
echo " Inspect the --- response --- section above." >&2
exit 3
;;
esac