mirror of
https://github.com/garrytan/gbrain.git
synced 2026-08-16 09:52:22 +00:00
Addresses four user-filed regressions after v0.13.0 plus three adjacent footgun closures. * #170 — CREATE INDEX [CONCURRENTLY] IF NOT EXISTS idx_pages_updated_at_desc on pages (updated_at DESC). Engine-aware migration v12 with invalid-index cleanup on Postgres, plain CREATE on PGLite. ~700x on 30k+ row brains. Contributed by @fuleinist (#215). * #219 — Minions schema default max_stalled 1 -> 5. v13 migration ALTERs the default and UPDATEs existing non-terminal rows (waiting/active/ delayed/waiting-children/paused) so live queues get rescued on upgrade. Adds MinionJobInput.max_stalled with [1,100] clamp. New --max-stalled CLI flag on `jobs submit`. Reported by @macbotmini-eng. * #218 — package.json postinstall surfaces errors instead of silencing. trustedDependencies whitelists @electric-sql/pglite. doctor schema_version check fails loudly when migrations never ran and links to #218. README + INSTALL_FOR_AGENTS warn against `bun install -g`. Reported by @gopalpatel. * #223 — @electric-sql/pglite pinned to exactly 0.4.3 (was ^0.4.4). PGLiteEngine.connect() wraps PGlite.create() errors with a message pointing at the issue + gbrain doctor. Does NOT suggest 'missing migrations' as a cause (create-time abort happens before migrations run). Pin is unverified against macOS 26.3; error-wrap is the safety net. Reported by @AndreLYL. * Scope: `gbrain jobs submit` gains --backoff-type/--backoff-delay/ --backoff-jitter/--timeout-ms/--idempotency-key (MinionJobInput audit). * Scope: `gbrain jobs smoke --sigkill-rescue` regression case (opt-in, CI-only) that simulates a killed worker and asserts the new default rescues. * Scope: `gbrain doctor --index-audit` reports zero-scan Postgres indexes as drop candidates (informational; no auto-drop). Infrastructure: * Migration interface extended with sqlFor: { postgres?, pglite? } and transaction: boolean. Runner picks the engine-specific branch and bypasses engine.transaction() when transaction:false (required for CONCURRENTLY). BrainEngine.kind readonly discriminator added. * scripts/check-jsonb-pattern.sh CI guard extended to block `max_stalled DEFAULT 1` from regressing. Tests: * 15 new unit tests: v12/v13 structural + behavioral assertions, max_stalled default/clamp/backfill, PGLite error-wrap source guard, engine kind discriminator. * 3 regression tests pinned by IRON RULE. * Full unit suite: 1416 pass. * Full E2E suite against Postgres 16 + pgvector: 126 pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
47 lines
2.0 KiB
Bash
Executable File
47 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# CI guard: fail if any source file uses the buggy `${JSON.stringify(x)}::jsonb`
|
|
# template-string pattern instead of postgres.js's `sql.json(x)`.
|
|
#
|
|
# This is best-effort static analysis. It catches the common copy-paste form
|
|
# that caused the v0.12.0 silent-data-loss bug (JSONB columns stored as
|
|
# string literals on Postgres while PGLite hid the bug). Multi-line and
|
|
# helper-wrapped variants are NOT caught here — those are covered by
|
|
# test/e2e/postgres-jsonb.test.ts which round-trips actual writes through
|
|
# real Postgres and asserts `frontmatter->>'k'` returns objects, not strings.
|
|
#
|
|
# Usage: scripts/check-jsonb-pattern.sh
|
|
# Exit: 0 when no matches, 1 when matches found.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
cd "$ROOT"
|
|
|
|
# Match the interpolated form: ${JSON.stringify(...)}::jsonb
|
|
# Using grep -P for Perl-compatible regex (lookahead-free pattern is enough here).
|
|
PATTERN='\$\{JSON\.stringify\([^)]*\)\}::jsonb'
|
|
|
|
if grep -rEn "$PATTERN" src/ 2>/dev/null; then
|
|
echo
|
|
echo "ERROR: Found JSON.stringify(...)::jsonb pattern in src/."
|
|
echo " postgres.js v3 stringifies again, producing JSONB string literals."
|
|
echo " Use sql.json(x) instead. See feedback_postgres_jsonb_double_encode.md."
|
|
exit 1
|
|
fi
|
|
|
|
echo "OK: no JSON.stringify(x)::jsonb interpolation pattern in src/"
|
|
|
|
# v0.13.1 #219: guard against max_stalled DEFAULT 1 regressing in any schema
|
|
# source file. DEFAULT 1 dead-lettered any SIGKILL'd job on first stall, making
|
|
# the "10/10 rescued" claim false for out-of-the-box users. Default is 5 now.
|
|
MAX_STALLED_PATTERN='max_stalled\s+INTEGER\s+NOT\s+NULL\s+DEFAULT\s+1\b'
|
|
|
|
if grep -rEn "$MAX_STALLED_PATTERN" src/schema.sql src/core/migrate.ts src/core/pglite-schema.ts src/core/schema-embedded.ts 2>/dev/null; then
|
|
echo
|
|
echo "ERROR: max_stalled DEFAULT 1 reintroduced in schema."
|
|
echo " Must be DEFAULT 5 to preserve SIGKILL-rescue guarantee. See #219."
|
|
exit 1
|
|
fi
|
|
|
|
echo "OK: max_stalled defaults are 5 in all schema sources"
|