Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

verify: run check-jsonb-params and check-image-decoders over the real tree (F1, F2)

garrytan3fd650d9a6b8
diff --git a/docs/architecture/key-files/tooling-and-tests.md b/docs/architecture/key-files/tooling-and-tests.md
index db8b83ab34..16cc394203 100644
--- a/docs/architecture/key-files/tooling-and-tests.md
+++ b/docs/architecture/key-files/tooling-and-tests.md
@@ -25,7 +25,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `scripts/check-getpage-scoped-write.mjs` — CI scanner for the unscoped-check/scoped-write source-isolation bug class: flags any non-test src file containing BOTH a `getPage(` call with no second argument (or the `X ? {sourceId} : undefined` any-source-when-unset ternary) AND a write-path call (`putPage(`/`importFromContent(`/`importFromFile(`). Fix pattern: `getPage(slug, { sourceId: x ?? 'default' })` (mirror the write's schema default); opt-out marker `gbrain-allow-unscoped-getpage: <reason>` for documented read-only first-match sites (span, preceding lines, or trailing same-line comment). Grandfathered allowlist is EMPTY. Comment/string-aware balanced-paren span walker (same skeleton as check-jsonb-params.mjs); argv-overridable roots; wired as `check:getpage-scope` in verify CHECKS + guards-manifest + `test/fixtures/guards/check-getpage-scoped-write.mjs/{bad,good}/` + `test/check-getpage-scoped-write.test.ts`.
-- `scripts/check-jsonb-params.mjs` — AST-lite CI guard for the POSITIONAL jsonb double-encode form the template grep above misses: an `executeRaw`/`executeRawDirect`/`.unsafe()` call whose balanced arg span binds `JSON.stringify(x)` into a bare `$N::jsonb` cast. Walks each call's balanced span respecting strings/templates/comments, handles generic-typed calls (`executeRaw<T>(`), and allows the sanctioned forms (`$N::text::jsonb`, `$N::text[]`, `executeRawJsonb`, `sql.json`, an inline `jsonb-guard-ok` comment). PGLite's native `db.query` is deliberately not scanned (it parses text→jsonb, so the bug can't occur there). Heuristic by design (whole-span correlation; can't see a `JSON.stringify` assigned to a variable before the call) — the real backstop is the DATABASE_URL-gated e2e parity tests. Scan roots overridable via argv for its self-test (`test/check-jsonb-params.test.ts`).
+- `scripts/check-jsonb-params.mjs` — AST-lite CI guard for the POSITIONAL jsonb double-encode form the template grep above misses: an `executeRaw`/`executeRawDirect`/`.unsafe()` call whose balanced arg span binds `JSON.stringify(x)` into a bare `$N::jsonb` cast. Walks each call's balanced span respecting strings/templates/comments, handles generic-typed calls (`executeRaw<T>(`), and allows the sanctioned forms (`$N::text::jsonb`, `$N::text[]`, `executeRawJsonb`, `sql.json`, an inline `jsonb-guard-ok` comment). PGLite's native `db.query` is deliberately not scanned (it parses text→jsonb, so the bug can't occur there). Heuristic by design (whole-span correlation; can't see a `JSON.stringify` assigned to a variable before the call) — the real backstop is the DATABASE_URL-gated e2e parity tests. Runs over the real tree in `bun run verify` (`check:jsonb-params`); scan roots overridable via argv for its self-test (`test/check-jsonb-params.test.ts`).
- `scripts/check-jsonb-pattern.sh` — CI grep guard. Fails the build if any source contains (a) the `${JSON.stringify(x)}::jsonb` interpolation pattern (postgres.js v3 double-encodes it), or (b) `max_stalled INTEGER NOT NULL DEFAULT 1` in any schema source file (must be DEFAULT 5 to preserve SIGKILL-rescue). It also invokes `scripts/check-jsonb-params.mjs` and propagates its exit code. Wired into `bun test`.
diff --git a/package.json b/package.json
index 7151cc9d00..2a7fb8eace 100644
--- a/package.json
+++ b/package.json
@@ -80,6 +80,7 @@
"check:plugin-tree": "bash scripts/check-plugin-tree.sh",
"check:wasm": "bash scripts/check-wasm-embedded.sh",
"check:pglite-embedded": "bash scripts/check-pglite-embedded.sh",
+ "check:image-decoders": "bash scripts/check-image-decoders-embedded.sh",
"check:newlines": "bash scripts/check-trailing-newline.sh",
"test:compile-smoke": "bun test test/binary-self-update-compiled.serial.test.ts",
"test:agent-voice": "bash scripts/test-agent-voice.sh",
@@ -96,6 +97,7 @@
"ci:select-e2e": "bun run scripts/select-e2e.ts",
"typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/gbrain-typecheck.tsbuildinfo",
"check:jsonb": "bash scripts/check-jsonb-pattern.sh",
+ "check:jsonb-params": "node scripts/check-jsonb-params.mjs",
"check:search-path": "bash scripts/check-search-path.sh",
"check:no-double-retry": "bash scripts/check-no-double-retry.sh",
"check:batch-audit-site": "bash scripts/check-batch-audit-site.sh",
diff --git a/scripts/check-image-decoders-embedded.sh b/scripts/check-image-decoders-embedded.sh
index c10fcab2b1..9084efcf41 100755
--- a/scripts/check-image-decoders-embedded.sh
+++ b/scripts/check-image-decoders-embedded.sh
@@ -20,7 +20,13 @@ cd "$REPO_ROOT"
OUT_BIN="$(mktemp /tmp/gbrain-img-decoders-check.XXXXXX)"
trap 'rm -f "$OUT_BIN"' EXIT
-bun build --compile --no-compile-autoload-bunfig --outfile "$OUT_BIN" scripts/image-decoders-smoketest.ts >/dev/null 2>&1
+if ! BUILD_LOG="$(bun build --compile --no-compile-autoload-bunfig --outfile "$OUT_BIN" scripts/image-decoders-smoketest.ts 2>&1)"; then
+ echo "[check-image-decoders-embedded] FAIL: bun build --compile of scripts/image-decoders-smoketest.ts failed:" >&2
+ echo "$BUILD_LOG" | tail -20 >&2
+ echo "Why: the HEIC/AVIF decoder imports (heic-decode, @jsquash/avif's avif_dec.wasm via type: 'file') must resolve inside a compiled binary, or image import breaks in the shipped gbrain binary." >&2
+ echo "Fix: correct the import path above in scripts/image-decoders-smoketest.ts and mirror it in src/core/import-file.ts, then re-run: bun run check:image-decoders" >&2
+ exit 1
+fi
OUTPUT="$("$OUT_BIN" 2>&1 || true)"
diff --git a/scripts/guards-manifest.tsv b/scripts/guards-manifest.tsv
index 76058ce82d..a3c8032d07 100644
--- a/scripts/guards-manifest.tsv
+++ b/scripts/guards-manifest.tsv
@@ -17,7 +17,7 @@
# guard class selftest notes
check-no-double-retry.sh scanner yes regex hole fixed in W0 (could not match `() =>`); perl multi-line pass replaces never-installed pcregrep
check-jsonb-pattern.sh scanner yes nested-paren hole fixed in W0; safe ::text::jsonb spelling stays unflagged
-check-jsonb-params.mjs scanner yes positional $N::jsonb AST-lite scanner; argv/env root override; not in verify CHECKS: exercised by its unit test + self-test fixtures
+check-jsonb-params.mjs scanner yes positional $N::jsonb AST-lite scanner; argv/env root override; in verify CHECKS (check:jsonb-params) over the real tree
check-batch-audit-site.sh scanner todo
check-bun-test-timeout.sh scanner todo not in verify CHECKS: runs directly as a test.yml verify-job step
check-fixture-privacy.sh scanner todo
@@ -54,7 +54,7 @@ check-bootstrap-templates.sh buildfresh exempt regenerates template tree + diffs
check-plugin-tree.sh buildfresh exempt regenerates the plugin tree + diffs (curation record validated by the generator)
check-eval-glossary-fresh.sh buildfresh exempt regenerates + diffs
check-fuzz-purity.sh buildfresh exempt executes fuzz corpus
-check-image-decoders-embedded.sh buildfresh exempt binary embed check; not in verify CHECKS: own bun build --compile too heavy per-verify
+check-image-decoders-embedded.sh buildfresh exempt binary embed check; in verify CHECKS (check:image-decoders); its smoketest compile bundles a handful of modules (~0.6s)
check-pglite-embedded.sh buildfresh exempt binary embed check
check-skills-manifest-fresh.sh buildfresh exempt regenerates + diffs
check-tool-catalog-fresh.sh buildfresh exempt regenerates + diffs
diff --git a/scripts/run-verify-parallel.sh b/scripts/run-verify-parallel.sh
index 4088edb681..c438b1c592 100755
--- a/scripts/run-verify-parallel.sh
+++ b/scripts/run-verify-parallel.sh
@@ -52,6 +52,9 @@ CHECKS=(
"check:admin-build"
"check:wasm"
"check:pglite-embedded"
+ # HEIC + AVIF decoders survive bun build --compile (~0.6s: the smoketest
+ # bundles a handful of modules, not the CLI).
+ "check:image-decoders"
"check:fuzz-purity"
# W0 fix-wave (Tier-1 #11): guard self-tests — every scanner guard proves it
# can fail (bad fixture → exit 1) before it counts as coverage. Registry:
@@ -93,6 +96,8 @@ CHECKS=(
# ── light tail (sub-second greps; historical order) ──
"check:proposal-pii"
"check:jsonb"
+ # Positional $N::jsonb + JSON.stringify double-encode (AST-lite, ~0.2s).
+ "check:jsonb-params"
"check:search-path"
"check:source-id-projection"
"check:source-config-leak"
diff --git a/test/scripts/run-verify-parallel.test.ts b/test/scripts/run-verify-parallel.test.ts
index e5a445e49b..267ac6dc70 100644
--- a/test/scripts/run-verify-parallel.test.ts
+++ b/test/scripts/run-verify-parallel.test.ts
@@ -72,12 +72,8 @@ describe("guard registration ⇒ execution coverage", () => {
const EXECUTION_EXEMPT: Record<string, string> = {
"check-bun-test-timeout.sh":
"runs directly as a test.yml verify-job step (not via CHECKS — avoids a package.json edit)",
- "check-jsonb-params.mjs":
- "exercised by test/check-jsonb-params.test.ts + guard self-test fixtures",
"check-admin-embedded.sh":
"duplicates check:admin-build's vite+tsc build; embed freshness covered there",
- "check-image-decoders-embedded.sh":
- "runs its own bun build --compile — too heavy for per-verify cadence",
"check-bash32.sh":
"needs Docker or a native bash 3.2: runs as a test.yml verify-job step (bash:3.2 image) and in macos-validation.yml (/bin/bash), never in verify",
"check-test-discriminates.sh":