* fix(test): name-floor guard for every destructive-SQL test + repo-wide coverage gate (#3485) Moves assertSafeE2eDatabaseUrl to leaf module test/helpers/db-guard.ts (re-exported from test/e2e/helpers.ts for existing call sites) and calls it before connect() in all ten files that run destructive SQL against the ambient URL — the eight from #3485, one newer offender (bootstrap-keyed-postgres.serial), and the raw-postgres()-client OAuth suite the original audit could not see. test/db-guard-coverage.test.ts is the static gate that keeps the class closed: walks every test file bun collects repo-wide (all naming patterns, fixtures included), detects ambient-URL reads at the assignment site (any binding name, both env vars, bracket notation), recognizes four connect idioms, treats env-var deletes as scrubs not reads, refuses comment-only guard mentions, and pins its own classifiers with positive controls so it can never pass vacuously. Patch for the ten files adopted from #3485 by @cheRoma (fork access blocked a PR) — thank you. * feat(test): refuse to start a test run while a database URL is ambient (#3485) A bunfig [test] preload (registered first) hard-fails any bun test invocation while DATABASE_URL or GBRAIN_DATABASE_URL is set, unless GBRAIN_TEST_ALLOW_DATABASE_URL=1 — refusing with instructions, never silently unsetting (a silent unset would turn DB-gated e2e tests into green skips). Boundaries: run-e2e.sh and the e2e/heavy workflows opt in at their own subprocess boundary (run-e2e.sh also keeps the opt-in vars past its hermetic GBRAIN_* scrub and drops GBRAIN_DATABASE_URL, which has no name floor on spawned-CLI paths); the unit/slow wrappers strip both vars instead — unit tests need no database — which keeps `bun run test:full` with a DB URL exported reaching its e2e leg. The phantom-redirect parity file rides the e2e lane and CI's jsonb-parity job so its Postgres arm stays reachable. Six subprocess tests spawn real bun test children against the actual bunfig registration: refuses each var, refuses both, strict override value, override allows, empty-string treated as unset, clean run. * fix(tests-heavy): shared database name floor for the heavy shell lane (#3485) The heavy lane runs schema drops, source-registry rewrites, migration replays, and parallel syncs against whatever the environment names — outside bun, where the preload guard cannot fire. tests/heavy/_db_floor.sh mirrors test/helpers/db-guard.ts: sourced by run-heavy.sh and by every script documented for direct invocation, it floors BOTH DATABASE_URL and GBRAIN_DATABASE_URL (the CLI these scripts shell out to prefers the latter) and strips query strings before extracting the name, so a ?host=/tmp/test-sockets parameter cannot smuggle a test-shaped segment past the check. * chore: bump version and changelog (v0.45.15.0) TESTING.md documents the four guard layers and the cwd caveat; TODOS.md files the disclosure-policy follow-up (P2). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: update project documentation for v0.45.15.0 Cross-reference pass after the #3485 test-safety wave (Wave -1): - docs/TESTING.md: complete the guard layers (heavy shell floor tests/heavy/_db_floor.sh, schema-drift's accepted inline floor), note the phantom-redirect Postgres arm riding the e2e lane in the file taxonomy + E2E inventory. - docs/architecture/KEY_FILES.md: scripts/run-e2e.sh entry updated to current behavior (no-args list carries phantom-redirect parity; #3485 opt-in boundary, GBRAIN_DATABASE_URL drop, GBRAIN_E2E_ALLOW_DB preserved through the env scrub). - CONTRIBUTING.md: heads-up that bare `bun test` refuses to start with a database URL ambient + the name floor for own-Postgres/Supabase e2e. - tests/heavy/README.md: database name floor section (which scripts source it, PGLite scripts unset instead, new-script rule). - .env.testing.example: Supabase's default "postgres" database name fails the floor — dedicated test DB or one-shot GBRAIN_E2E_ALLOW_DB. - CHANGELOG.md v0.45.15.0: three accuracy-of-wording touches (headline "silently", lane boundary phrasing, note the one accepted inline floor) — no entries removed or regenerated. Codex cross-model doc review ran; concrete gaps applied above. llms bundles regenerated (no byte changes — touched docs are link-only). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(test): keep the coverage gate's own scrub-pattern out of the R1 isolation lint's sight The gate detects 'delete process.env.X' as a scrub-not-read; the R1 lint greps the same token textually and flagged the gate's comment and classifier fixture as env mutations. Comment reworded; fixture built by concatenation so the classifier still receives the contiguous statement. * chore: re-slot as v0.45.17.0 (re-land of reverted #4126) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
18 lines
910 B
Plaintext
18 lines
910 B
Plaintext
# GBrain E2E Test Configuration
|
|
# Copy to .env.testing and fill in real values
|
|
#
|
|
# Tier 1 (required for E2E tests)
|
|
# Option A: Local Docker Postgres (default)
|
|
DATABASE_URL=postgresql://postgres:postgres@localhost:5433/gbrain_test
|
|
# Option B: Real Supabase instance (tests the actual production path)
|
|
# DATABASE_URL=postgresql://postgres.[project-ref]:[password]@aws-0-us-east-1.pooler.supabase.com:6543/postgres
|
|
# NOTE (#3485): destructive tests enforce a database-name floor — the name must
|
|
# carry "test" as a word segment (gbrain_test passes; Supabase's default
|
|
# "postgres" does not). Use a dedicated test project/database, or opt the exact
|
|
# name in one-shot: GBRAIN_E2E_ALLOW_DB=postgres bun run test:e2e
|
|
# (never a shell-profile export — that would permanently disarm the floor).
|
|
|
|
# Tier 2 (required for skill tests, optional for mechanical tests)
|
|
OPENAI_API_KEY=sk-...
|
|
ANTHROPIC_API_KEY=sk-ant-...
|