From 69424a1911e9d270fcb28425b9430e6550aae5c1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Sep 2026 12:42:44 +0000 Subject: [PATCH 1/2] test(driver-sql): budget the live-DDL work outside #13902's scoping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four it() blocks that build a live-Postgres SqlDriver outside a declareDialectCell(...) callback, and the two beforeAll hooks in sql-driver-backend-fault-envelope.test.ts that open a live driver, run initObjects(...) and insert rows, all inherited vitest's 5000ms default. Each now carries an explicit 60_000, per-site — no package-level testTimeout, and the 39 embedded-SQLite sites are left on the fast default. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Q5WBDtaUnoz5XuJ6jk8pQ5 --- .../src/live-dialect-matrix.isolation.test.ts | 12 ++++++++++ .../sql-driver-autonumber-cold-race.test.ts | 11 ++++++++++ .../sql-driver-backend-fault-envelope.test.ts | 22 +++++++++++++++++-- ...ql-driver-json-binding-without-ddl.test.ts | 12 +++++++++- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/packages/drivers/driver-sql/src/live-dialect-matrix.isolation.test.ts b/packages/drivers/driver-sql/src/live-dialect-matrix.isolation.test.ts index bb5491a4d9..8d6141d688 100644 --- a/packages/drivers/driver-sql/src/live-dialect-matrix.isolation.test.ts +++ b/packages/drivers/driver-sql/src/live-dialect-matrix.isolation.test.ts @@ -278,6 +278,16 @@ describe('live-dialect matrix — the driver can SEE its own isolated schema (#9 driver = undefined; }); + // ── Why the two it() blocks below carry an explicit 60_000 budget (#14100) ── + // Both construct a FRESH `new SqlDriver(PG_CELL.config())` against the live + // Postgres cell inside their own body and then drive `initObjects(...)`, so + // the connect cycle plus schema-sync DDL and catalog read-back are paid PER + // TEST rather than once in a beforeAll. With no third argument vitest applies + // its own 5000ms default — a number nobody chose for that work, and one that + // reddens unrelated PRs when the runner is merely a bit slow. Sized to match + // this package's live-DDL siblings (#13902 / #13688). ⛔ NOT a claim that + // these tests are known to be slow: they were found by an AST walk over the + // package, never by a measured timeout here. it.skipIf(!PG_CELL.available)( 'postgres: index introspection reports the indexes that exist in the file’s schema', async () => { @@ -309,6 +319,7 @@ describe('live-dialect matrix — the driver can SEE its own isolated schema (#9 expect(seen.some((i: any) => i.primary)).toBe(true); expect(seen.some((i: any) => i.unique && !i.primary)).toBe(true); }, + 60_000, ); it.skipIf(!PG_CELL.available)( @@ -320,5 +331,6 @@ describe('live-dialect matrix — the driver can SEE its own isolated schema (#9 const introspected = await driver.introspectSchema(); expect(Object.keys(introspected.tables ?? {})).toContain(TABLE); }, + 60_000, ); }); diff --git a/packages/drivers/driver-sql/src/sql-driver-autonumber-cold-race.test.ts b/packages/drivers/driver-sql/src/sql-driver-autonumber-cold-race.test.ts index 65e5033ae7..da5fef4079 100644 --- a/packages/drivers/driver-sql/src/sql-driver-autonumber-cold-race.test.ts +++ b/packages/drivers/driver-sql/src/sql-driver-autonumber-cold-race.test.ts @@ -156,6 +156,16 @@ describe(`sql-driver — attemptWithoutPoisoning (${pgCell.available ? 'live pos // The mechanism itself, pinned directly: this is what makes the SECOND // speculative site (`SELECT … FOR UPDATE`, which has no `ON CONFLICT` form) // safe as well. Postgres-only for the same reason as above. + // ── Why the it() below carries an explicit 60_000 budget (#14100) ── + // It constructs a FRESH `new SqlDriver(pgCell.config())` against the live + // Postgres cell inside its own body, then creates and drops a probe table, so + // the connect cycle and its DDL are paid PER TEST rather than once in a hook. + // With no third argument vitest applies its own 5000ms default — a number + // nobody chose for that work, and one that reddens unrelated PRs when the + // runner is merely a bit slow. Sized to match this package's live-DDL + // siblings (#13902 / #13688). ⛔ NOT a claim that this test is known to be + // slow: it was found by an AST walk over the package, never by a measured + // timeout here. it.skipIf(!pgCell.available)( 'leaves the surrounding transaction usable after a statement error', async () => { @@ -195,5 +205,6 @@ describe(`sql-driver — attemptWithoutPoisoning (${pgCell.available ? 'live pos await driver.disconnect(); } }, + 60_000, ); }); diff --git a/packages/drivers/driver-sql/src/sql-driver-backend-fault-envelope.test.ts b/packages/drivers/driver-sql/src/sql-driver-backend-fault-envelope.test.ts index 32f79bd2c7..c3e36fb62a 100644 --- a/packages/drivers/driver-sql/src/sql-driver-backend-fault-envelope.test.ts +++ b/packages/drivers/driver-sql/src/sql-driver-backend-fault-envelope.test.ts @@ -157,6 +157,19 @@ function declareSweep(cell: DialectCell): void { describe(`[#8931] driver-sql — the terminal backend-fault envelope (${cell.label})`, () => { let driver: SqlDriver; + // ── Why this beforeAll carries an explicit 60_000 budget (#14100) ── + // The it() blocks in this file are deliberately NOT budgeted: each only sends + // a query or two down a connection this hook already opened, so their cost + // model really is the fast one. But the live cost did not disappear — it + // lives HERE: a full connect cycle, two drops, `initObjects(...)` schema-sync + // DDL and two inserts, all against the cell's live server, on vitest's + // inherited 5000ms default. Budgeting the it() blocks would have been wrong; + // leaving the hook unbudgeted just moved the exposure one scope outward. + // Budgeting hooks is established practice in this package (see the beforeAll + // hooks in sql-driver-diagnostic-value-probe, sql-driver-12380-json-roundtrip, + // sql-driver-13567-audit-stamp-materialisation and + // sql-driver-value-roundtrip-conformance). ⛔ NOT a claim that this hook is + // known to time out: it was found by an AST walk, never by a measured red. beforeAll(async () => { driver = new SqlDriver(cell.config()); await driver.execute(`drop table if exists ${TABLE}`).catch(() => {}); @@ -166,7 +179,7 @@ describe(`[#8931] driver-sql — the terminal backend-fault envelope (${cell.lab ]); await driver.create(TABLE, { id: 't1', title: 'Design', rank: 1 }, { bypassTenantAudit: true }); await driver.create(TABLE, { id: 't2', title: 'Build', rank: 2 }, { bypassTenantAudit: true }); - }); + }, 60_000); afterAll(async () => { await driver.execute(`drop table if exists ${TABLE}`).catch(() => {}); @@ -340,6 +353,11 @@ declareDialectCell(PG, 'backend-fault envelope — the pg-only rows', (cell) => describe('[#8931] postgres — the dotted route and the value-bearing diagnostic', () => { let driver: SqlDriver; + // ── Why this beforeAll carries an explicit 60_000 budget (#14100) ── + // Same reasoning as the hook in `declareSweep` above, on the Postgres-only + // pair: a live connect, a drop, `initObjects(...)` DDL and an insert, none of + // which the two it() blocks below repeat. ⛔ NOT a claim that this hook is + // known to time out — found structurally, not by a measured red. beforeAll(async () => { driver = new SqlDriver(cell.config()); await driver.execute(`drop table if exists ${TABLE}_pg`).catch(() => {}); @@ -347,7 +365,7 @@ describe('[#8931] postgres — the dotted route and the value-bearing diagnostic { name: `${TABLE}_pg`, fields: { title: { type: 'string' }, rank: { type: 'integer' } } }, ]); await driver.create(`${TABLE}_pg`, { id: 't1', title: 'Design', rank: 1 }, { bypassTenantAudit: true }); - }); + }, 60_000); afterAll(async () => { await driver.execute(`drop table if exists ${TABLE}_pg`).catch(() => {}); diff --git a/packages/drivers/driver-sql/src/sql-driver-json-binding-without-ddl.test.ts b/packages/drivers/driver-sql/src/sql-driver-json-binding-without-ddl.test.ts index defaf4a5a4..670b54dc10 100644 --- a/packages/drivers/driver-sql/src/sql-driver-json-binding-without-ddl.test.ts +++ b/packages/drivers/driver-sql/src/sql-driver-json-binding-without-ddl.test.ts @@ -170,6 +170,16 @@ describe.skipIf(!PG_URL)('#10995 — live Postgres, driver told about the object // ── §3 The other posture with the same empty registry: DDL REFUSED ─────── + // ── Why the it() below carries an explicit 60_000 budget (#14100) ── + // Unlike §1–§2, which reuse the connection the beforeAll opened, §3 builds a + // SECOND live driver (`guest`) inside its own body and runs an out-of-band + // `create table` through it — a full connect cycle plus DDL, paid by this + // test alone. With no third argument vitest applies its own 5000ms default — + // a number nobody chose for that work, and one that reddens unrelated PRs + // when the runner is merely a bit slow. Sized to match this package's + // live-DDL siblings (#13902 / #13688). ⛔ NOT a claim that this test is known + // to be slow: it was found by an AST walk over the package, never by a + // measured timeout here. it('§3 a datasource we are a guest in registers its objects even though DDL is refused', async () => { // `schemaMode !== 'managed'` (ADR-0015): `initObjects` must still refuse the // DDL — and must no longer leave the driver ignorant of the objects it was @@ -188,7 +198,7 @@ describe.skipIf(!PG_URL)('#10995 — live Postgres, driver told about the object } finally { await guest.disconnect(); } - }); + }, 60_000); }); // ── §4 The SQLite path is unchanged ──────────────────────────────────────── From 193b345f746f7a652aecda6dbdda672d9090b695 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Sep 2026 12:46:24 +0000 Subject: [PATCH 2/2] test(driver-sql): state the measured hook ceiling, not the it() one An unbudgeted beforeAll inherits hookTimeout (measured: 10000ms in this package's config), not testTimeout's 5000ms. Ablation legs B1/B3/B4 in the PR body. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Q5WBDtaUnoz5XuJ6jk8pQ5 --- .../src/sql-driver-backend-fault-envelope.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/drivers/driver-sql/src/sql-driver-backend-fault-envelope.test.ts b/packages/drivers/driver-sql/src/sql-driver-backend-fault-envelope.test.ts index c3e36fb62a..5b442e9efe 100644 --- a/packages/drivers/driver-sql/src/sql-driver-backend-fault-envelope.test.ts +++ b/packages/drivers/driver-sql/src/sql-driver-backend-fault-envelope.test.ts @@ -162,8 +162,12 @@ describe(`[#8931] driver-sql — the terminal backend-fault envelope (${cell.lab // a query or two down a connection this hook already opened, so their cost // model really is the fast one. But the live cost did not disappear — it // lives HERE: a full connect cycle, two drops, `initObjects(...)` schema-sync - // DDL and two inserts, all against the cell's live server, on vitest's - // inherited 5000ms default. Budgeting the it() blocks would have been wrong; + // DDL and two inserts, all against the cell's live server. ⚠️ A hook inherits + // `hookTimeout`, NOT `testTimeout` — measured in this package's config, an + // unbudgeted hook dies at 10000ms ("Hook timed out in 10000ms"), not at the + // 5000ms an unbudgeted it() gets. Ten seconds is still the wrong ceiling for + // this much live work, and the third argument does lift it (measured). + // Budgeting the it() blocks would have been wrong; // leaving the hook unbudgeted just moved the exposure one scope outward. // Budgeting hooks is established practice in this package (see the beforeAll // hooks in sql-driver-diagnostic-value-probe, sql-driver-12380-json-roundtrip,