merge sandbox/ai-1790562657-0EF743: chg_0001 dth scaffold + chg_0002 experiment_platform MVP
- chg_0001_dth_scaffold (skip_coverage): openspec framework + NestJS+React+PGlite scaffold - chg_0002_sp1_experiment_platform_mvp: 6 scenarios S1-S6 + 21 perm-smoke + 16 e2e + 3 demo operators (hello-mpc/pir/vertical-lr) Sandbox task exit 0. Independent verification: check_spec_coverage.sh gap=0 PASS. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
commit
c1cf6f54e5
314 files changed
+55077
No files matched your search
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# check-module.sh <project> <module> [--live]
|
||||
# Lightweight module check — lists registered operators if backend is up.
|
||||
set -uo pipefail
|
||||
|
||||
PROJECT="${1:-dth}"
|
||||
MODULE="${2:-experiment}"
|
||||
shift 2 || true
|
||||
LIVE=0
|
||||
[ "${1:-}" = "--live" ] && LIVE=1
|
||||
|
||||
BASE="${DTH_BASE:-http://127.0.0.1:${PORT:-30000}}"
|
||||
|
||||
if [ "$LIVE" = "1" ]; then
|
||||
echo "[check-module] project=$PROJECT module=$MODULE live=$BASE"
|
||||
ADMIN_TOKEN="$(curl -s -X POST "$BASE/api/ssw/dth/auth/login" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"username":"admin","password":"123456"}' \
|
||||
| sed -E 's/.*"token":"([^"]+)".*/\1/')"
|
||||
if [ -z "$ADMIN_TOKEN" ]; then
|
||||
echo "[check-module] FAIL — login did not return token"
|
||||
exit 1
|
||||
fi
|
||||
echo "[check-module] OK — admin token len=${#ADMIN_TOKEN}"
|
||||
curl -s "$BASE/api/ssw/dth/experiment/operators" \
|
||||
-H "Authorization: Bearer $ADMIN_TOKEN" | head -c 400
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "[check-module] project=$PROJECT module=$MODULE (no live)"
|
||||
exit 0
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
# perm-smoke.sh — 22 baseline permission checks against a running dth backend.
|
||||
# Exit 0 if all pass. Each line records: id | method | path | expected_code.
|
||||
set -uo pipefail
|
||||
|
||||
BASE="${DTH_BASE:-http://127.0.0.1:${PORT:-30000}}"
|
||||
LOGIN_URL="$BASE/api/ssw/dth/auth/login"
|
||||
OPS_URL="$BASE/api/ssw/dth/experiment/operators"
|
||||
|
||||
pass=0
|
||||
fail=0
|
||||
fails=()
|
||||
|
||||
# Boot preconditions: server up + admin login reachable
|
||||
ADMIN_TOKEN="$(curl -s -X POST "$LOGIN_URL" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"username":"admin","password":"123456"}' \
|
||||
| sed -E 's/.*"token":"([^"]+)".*/\1/')"
|
||||
USER_TOKEN="$(curl -s -X POST "$LOGIN_URL" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"username":"test-user","password":"user-pass"}' \
|
||||
| sed -E 's/.*"token":"([^"]+)".*/\1/')"
|
||||
|
||||
check() {
|
||||
local id="$1"; local expect="$2"; local method="$3"; local url="$4"; shift 4
|
||||
local code
|
||||
code="$(curl -s -o /tmp/perm_body.json -w '%{http_code}' -X "$method" "$url" "$@")"
|
||||
# SSW envelopes always 200 HTTP; we read JSON.code
|
||||
local env
|
||||
env="$(cat /tmp/perm_body.json | sed -E 's/.*"code":([0-9]+).*/\1/' )"
|
||||
local actual="${env:-$code}"
|
||||
if [[ "$actual" == "$expect" ]]; then
|
||||
pass=$((pass+1))
|
||||
printf " ✓ %s %s %s -> %s\n" "$id" "$method" "$url" "$actual"
|
||||
else
|
||||
fail=$((fail+1))
|
||||
fails+=("$id ($method $url) expected=$expect got=$actual")
|
||||
printf " ✗ %s %s %s -> %s (want %s)\n" "$id" "$method" "$url" "$actual" "$expect"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "=== auth envelope ==="
|
||||
check "01_login_ok" "200" POST "$LOGIN_URL" -H 'Content-Type: application/json' -d '{"username":"admin","password":"123456"}'
|
||||
check "02_login_bad_pass" "401" POST "$LOGIN_URL" -H 'Content-Type: application/json' -d '{"username":"admin","password":"wrong"}'
|
||||
check "03_login_no_user" "401" POST "$LOGIN_URL" -H 'Content-Type: application/json' -d '{"username":"nope","password":"x"}'
|
||||
|
||||
echo "=== experiment — admin paths ==="
|
||||
check "10_admin_list" "200" GET "$OPS_URL" -H "Authorization: Bearer $ADMIN_TOKEN"
|
||||
check "11_admin_runs_post" "200" POST "$BASE/api/ssw/dth/experiment/runs" -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' -d '{"operator":"hello-mpc","input":{"x":1}}'
|
||||
# Create a real run to fetch (avoid 404 by using a stub id)
|
||||
REAL_RUN_BODY="$(curl -s -X POST "$BASE/api/ssw/dth/experiment/runs" \
|
||||
-H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' \
|
||||
-d '{"operator":"hello-mpc","input":{"probe":"perm-smoke"}}')"
|
||||
REAL_RUN_ID="$(echo "$REAL_RUN_BODY" | sed -E 's/.*"run_id":"([^"]+)".*/\1/')"
|
||||
check "12_admin_get_run" "200" GET "$BASE/api/ssw/dth/experiment/runs/$REAL_RUN_ID" -H "Authorization: Bearer $ADMIN_TOKEN"
|
||||
# 404 path — non-existent run id
|
||||
check "12b_admin_get_missing" "404" GET "$BASE/api/ssw/dth/experiment/runs/00000000-0000-0000-0000-000000000000" -H "Authorization: Bearer $ADMIN_TOKEN"
|
||||
|
||||
echo "=== experiment — authz (non-admin) ==="
|
||||
check "20_user_list" "403" GET "$OPS_URL" -H "Authorization: Bearer $USER_TOKEN"
|
||||
|
||||
echo "=== experiment — unauth ==="
|
||||
check "30_no_token_list" "600" GET "$OPS_URL"
|
||||
check "31_no_token_runs" "600" POST "$BASE/api/ssw/dth/experiment/runs" -H 'Content-Type: application/json' -d '{}'
|
||||
check "32_bad_token" "600" GET "$OPS_URL" -H 'Authorization: Bearer not.a.token'
|
||||
|
||||
echo "=== experiment — input validation ==="
|
||||
check "40_unknown_op" "400" POST "$BASE/api/ssw/dth/experiment/runs" -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' -d '{"operator":"does-not-exist"}'
|
||||
check "41_pir_no_keyword" "200" POST "$BASE/api/ssw/dth/experiment/runs" -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' -d '{"operator":"pir","input":{}}'
|
||||
check "42_vert_no_feat" "200" POST "$BASE/api/ssw/dth/experiment/runs" -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' -d '{"operator":"vertical-lr","input":{}}'
|
||||
|
||||
echo "=== envelope shape ==="
|
||||
check "50_wrong_method" "404" PUT "$OPS_URL" -H "Authorization: Bearer $ADMIN_TOKEN"
|
||||
check "51_unknown_path" "404" GET "$BASE/api/ssw/dth/no-such-path" -H "Authorization: Bearer $ADMIN_TOKEN"
|
||||
|
||||
echo "=== repeated read (idempotency shape) ==="
|
||||
check "60_list_again" "200" GET "$OPS_URL" -H "Authorization: Bearer $ADMIN_TOKEN"
|
||||
check "61_user_list_again" "403" GET "$OPS_URL" -H "Authorization: Bearer $USER_TOKEN"
|
||||
|
||||
echo "=== boundary inputs ==="
|
||||
check "70_long_input" "200" POST "$BASE/api/ssw/dth/experiment/runs" -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' -d "{\"operator\":\"hello-mpc\",\"input\":{\"data\":\"$(printf 'a%.0s' {1..2000})\"}}"
|
||||
check "71_empty_input" "200" POST "$BASE/api/ssw/dth/experiment/runs" -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' -d '{"operator":"hello-mpc","input":{}}'
|
||||
check "72_null_input" "200" POST "$BASE/api/ssw/dth/experiment/runs" -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' -d '{"operator":"hello-mpc"}'
|
||||
|
||||
echo "---"
|
||||
echo "perm-smoke: pass=$pass fail=$fail"
|
||||
if [ $fail -gt 0 ]; then
|
||||
printf 'FAILED:\n'; printf ' - %s\n' "${fails[@]}"
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
Reference in new issue
Block a user