File size: 5,346 Bytes
aa89cb5
 
 
 
 
 
 
0ccd578
aa89cb5
 
0ccd578
aa89cb5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -euo pipefail

repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# file: dependencies resolve the package's dist entry points, not TypeScript source.
# Rebuild here so examples can never silently validate stale checked-in output.
(cd "$repo" && npm run build)
bash "$repo/examples/object-storage/verify.sh"
(cd "$repo" && npm test -- --runInBand tests/sql-relation-membership.test.ts)
mkdir -p "$repo/.local"
expected=(browser-sqlite conformance ensure-schema-bootstrap facet-trace object-storage order-management school-management task-board trace-chain)
mapfile -t actual < <(find "$repo/examples" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort)
if [[ "${actual[*]}" != "${expected[*]}" ]]; then
  echo "example inventory changed; update scripts/verify-examples.sh: ${actual[*]}" >&2
  exit 1
fi
if rg -n --glob '*.ts' --glob '!**/node_modules/**' --glob '!**/dist/**' \
    '\b(executeForPage|ExecuteForPage|execute_for_page)\b' "$repo/examples"; then
  echo 'FAIL: an example still exposes or calls a retired page terminal; regenerate its library' >&2
  exit 1
fi

for example in conformance ensure-schema-bootstrap school-management; do
  (
    cd "$repo/examples/$example"
    npm install
    npm run build
    if [[ "$example" == school-management ]]; then
      npx ts-node app.ts
    else
      npm start
    fi
  )
done
(cd "$repo/examples/order-management" && npm install && npm run build && npm start)
(cd "$repo/examples/task-board" && npm install && npm run build)
(cd "$repo/examples/browser-sqlite" && npm install && npm run build && npm run smoke && npm run smoke:orders)
(
  cd "$repo/examples/trace-chain"
  npm install
  npm run build
  for attempt in 1 2; do
    graph_log="$(mktemp -t teaql-ts-graph.XXXXXX.log)"
    npm start | tee "$graph_log"
    rg -Fxq 'PASS TypeScript graph identity controls: duplicate, missing and equal-ID type collapse rejected' "$graph_log"
    rg -Fq 'GRAPH IDENTITY EVIDENCE ' "$graph_log"
    rg -Fxq 'PASS TypeScript generated trace-chain example: 7 checks' "$graph_log"
    [[ "$(rg -c '^PRIVATE_LINEAGE_OBSERVED ' "$graph_log")" == 8 ]]
    [[ "$(rg -c '^PASS TypeScript complete private lineage:' "$graph_log")" == 8 ]]
  done
  env -u TEAQL_TELEMETRY_ENABLED -u TEAQL_TELEMETRY_SERVICE_NAME -u TEAQL_TELEMETRY_OTLP_ENDPOINT npm run test:standard-telemetry
  env -u TEAQL_TELEMETRY_ENABLED -u TEAQL_TELEMETRY_SERVICE_NAME -u TEAQL_TELEMETRY_OTLP_ENDPOINT npm run test:standard-telemetry
  env -u TEAQL_TELEMETRY_ENABLED -u TEAQL_TELEMETRY_SERVICE_NAME -u TEAQL_TELEMETRY_OTLP_ENDPOINT npm run test:standard-telemetry-graph
  env -u TEAQL_TELEMETRY_ENABLED -u TEAQL_TELEMETRY_SERVICE_NAME -u TEAQL_TELEMETRY_OTLP_ENDPOINT npm run test:standard-telemetry-graph
  response_directory="$(mktemp -d -t teaql-ts-response-example.XXXXXXXX)"
  for attempt in 1 2; do
    response_log="$response_directory/round-$attempt.log"
    env -u TEAQL_TELEMETRY_ENABLED -u TEAQL_TELEMETRY_SERVICE_NAME -u TEAQL_TELEMETRY_OTLP_ENDPOINT \
      TEAQL_STANDARD_RESPONSE_DB="$response_directory/graphs.sqlite" \
      node node_modules/ts-node/dist/bin.js standard-export-responses.ts | tee "$response_log"
    rg -Fxq 'PASS TypeScript standard response graph: create, rollback, retry, update, delete, Q/E, committed audit' "$response_log"
    rg -Fq "\"firstSeedAudits\":$((2-attempt)),\"repeatSeedAudits\":0" "$response_log"
  done
  env -u TEAQL_TRACE_CHAIN_SCENARIO npm run test:shared-reference
  env -u TEAQL_TRACE_CHAIN_SCENARIO npm run test:shared-reference
  npm run test:page
  npm run test:page
  npm run test:stream-capture
  npm run test:stream-capture
)
for attempt in 1 2; do
  aggregate_log="$(mktemp -t teaql-ts-aggregate.XXXXXX.log)"
  (cd "$repo/examples/trace-chain" && npm run test:relation-aggregate) | tee "$aggregate_log"
  rg -Fq 'FORWARD_NOTLOADED_OBSERVED {"logging":true' "$aggregate_log"
  rg -Fq 'FORWARD_NOTLOADED_OBSERVED {"logging":false' "$aggregate_log"
done
bash "$repo/scripts/verify-current-aggregate.sh"
for attempt in 1 2; do
  checker_log="$(mktemp -t teaql-ts-checker.XXXXXX.log)"
  TEAQL_TRACE_CHAIN_CHECKER_RUN="verify-examples-$attempt" \
    bash "$repo/scripts/run-checker-overlap.sh" "$checker_log"
done
for attempt in 1 2; do
  plan_log="$(mktemp -t teaql-ts-plan-items.XXXXXX.log)"
  (cd "$repo/examples/trace-chain" && timeout --kill-after=5s 90s npm run test:plan-item-lineage) | tee "$plan_log"
  rg -Fxq 'PASS TypeScript generated plan item lineage: 4 scenarios; one plan, ordered same-type items, sibling privacy, independent next request' "$plan_log"
done
bash "$repo/examples/facet-trace/verify.sh"
bootstrap_directory="$(mktemp -d -t teaql-ts-bootstrap.XXXXXXXX)"
for attempt in 1 2; do
  bootstrap_log="$bootstrap_directory/round-$attempt.log"
  (cd "$repo/examples/trace-chain" && TEAQL_TRACE_CHAIN_BOOTSTRAP_DB="$bootstrap_directory/bootstrap.sqlite" \
    timeout --kill-after=5s 90s npm run test:bootstrap-intent) | tee "$bootstrap_log"
  rg -Fxq 'PASS TypeScript generated bootstrap intent: logging off/on, committed audit, repeat no writes, unchanged generated library' "$bootstrap_log"
  for logging in false true; do
    rg -Fq "\"path\":\"generated default bootstrap\",\"logging\":$logging,\"firstWrites\":$((2-attempt)),\"repeatWrites\":0" "$bootstrap_log"
  done
done
echo "PASS: all TypeScript examples"