Skip to content

test(service-datasource): the pool-support and driver-factory suites run under 10 s (two #23184 rows) - #23711

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-23184-test-budget-service-datasource
Oct 15, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-23184-test-budget-service-datasource

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Refs #23184 (service-datasource rows: datasource-pool-support, default-datasource-driver-factory)
Clause-②: no

Rows answered

Both rows of the card's @objectstack/service-datasource list:

  • src/__tests__/datasource-pool-support.test.ts, listed at 17.6 s (run 38294929860);
  • src/__tests__/default-datasource-driver-factory.test.ts, listed at 10.6 s (run 38217670691).

The pin is the next refresh PR's list: it should name neither file. The card stays open for its other rows: the three remaining plugin-auth rows (org-create-posture-gate, implicit-account-linking, dev-admin-seed-credential-gate) and the plugin-security and organizations rows.

The diff is tests only: 5 module-top side-effect import lines and their comments in the two test files, +44 / -0. No production file, option, constant, timeout or export changes. Every it(, describe( and expect( line in both files is byte-identical to the base and in the same order.

Where the time went

A probe at the base (temporary, deleted; two runs per file, each in a fresh vitest worker) timed every load the files' cases trigger, in the order they trigger them:

load, in case order pool-support order driver-factory order
@objectstack/core, first load 8.9 / 7.7 s 7.1 / 9.5 s
@objectstack/driver-sql (knex) 1.32 / 0.54 s 0.57 / 0.80 s
@objectstack/driver-memory, after core 0.46 / 0.25 s 0.26 / 0.32 s
@objectstack/driver-mongodb, after core 0.17 / 0.16 s 0.14 / 0.24 s
@objectstack/driver-sqlite-wasm, after driver-sql n/a 0.04 / 0.04 s
the behaviour itself: each create(), the wasm connect, sync and round trip 2 to 18 ms each about 0.1 s first, 10 ms after

So nearly all of each file's clocked wall was one module load. The factory reaches every driver through a lazy await import(), and every driver imports @objectstack/core. This package's vitest.config.ts aliases @objectstack/core to packages/core/src/index.ts, so the first case to build a real driver paid a cold vite transform of core's whole source graph inside its clocked window. In datasource-pool-support that was memory WITHOUT a pool still builds exactly as before (8.1 s of the file's 9.3 s). In default-datasource-driver-factory it was builds a file-backed SqliteWasmDriver that connects and round-trips (11.4 s of 12.4 s). No case waits on a timer, a retry back-off, an idle or acquire timeout, or a live database. Every postgres, mysql and mongodb case builds a driver without connecting.

What changed

Each file now pays that load at module top, in collection, following the AGENTS.md convention that clocked windows measure behaviour, never loading (the clocked-window rule of check-test-source-alias). The factory's own lazy imports stay where they are; the module cache hands them the instances already loaded.

  • datasource-pool-support.test.ts: import '@objectstack/core' and import '@objectstack/driver-sql'.
  • default-datasource-driver-factory.test.ts: the same two, plus import '@objectstack/driver-sqlite-wasm'.

Three drivers are left out on purpose, and each still loads inside its first case:

  • @objectstack/driver-memory (0.2 to 0.5 s once core is loaded): every module binding of it is a ruled census entry. A first cut that imported it here turned check:driver-memory-census red, because a new binding needs a maintainer ruling.
  • @objectstack/driver-mongodb (0.1 to 0.3 s): this package's tests reach it only through the factory, so a test-file import is a new unaliased artifact import. The same first cut turned check:test-source-alias red. Aliasing it would change a config file outside this card's surface.
  • @objectstack/driver-turso: the turso missing-package case stages its absence without vi.resetModules(), so the factory's own lazy import must be that package's first. The sqlite-wasm absence case resets the module registry before it mocks, so loading that package at module top is the same condition the construction suites already created for it.

Measurements

Each figure is vitest's per-file duration (JSON reporter endTime - startTime, the module-line duration the refresh reads): pnpm exec vitest run --maxWorkers=2 FILE --reporter=verbose --reporter=json, in packages/services/service-datasource, under os-verify-lock, on a shared 4-vCPU box. The final before and after runs were interleaved at the final head, with the before leg being the base file copied to a temporary name (deleted afterwards), so both legs saw the same load.

file before, base f1e21c4f45 alone (load 1.3 to 1.6) before, interleaved at a573f9c57a (load 1.6 to 3.0) after, interleaved at a573f9c57a median after
datasource-pool-support 9312 / 8973 / 9337 ms 8967 / 8577 / 8287 ms 611 / 572 / 704 ms 0.61 s
default-datasource-driver-factory 12412 / 9129 / 9501 ms 9082 / 10044 / 9393 ms 751 / 711 / 750 ms 0.75 s

The load is moved, not removed. vitest's whole-file Duration (collection plus run) is unchanged within noise: pool-support 12.70 / 11.50 / 11.73 s before against 12.05 / 12.18 / 12.38 s after, and driver-factory 12.48 / 13.40 / 13.06 s before against 13.19 / 12.48 / 13.44 s after. The import phase grew from about 3 s to about 11 to 12.5 s per file. What the change buys is that no test or hook clock contains a compiler run any more. It does not make the package's test job faster.

CI projection. The per-file CI captures of recent hourly runs are NOT MEASURED. The test-core-timing-table artifact of hourly run 38773780951 redirects to productionresultssa5.blob.core.windows.net, which this container's egress proxy refuses (CONNECT 403). The ratios therefore come from the card's own readings against the interleaved before medians: pool-support 17.6 s against 8.58 s is a ratio of 2.05, which projects to 1.25 s; driver-factory 10.6 s against 9.39 s is 1.13, which projects to 0.85 s. At a 4.0 ratio, the worst post-landing ratio an earlier slice of this card read, they project to 2.4 s and 3.0 s.

Proof that every case still runs and still asserts the same

  • Case lists: 72 of 72 and 50 of 50 passed in every run, before and after.
  • Static lines: the it( / it.each( / describe( / expect( lines are byte-identical to the base and in order: 72 / 0 / 8 / 177 for pool-support, and 45 / 1 / 10 / 105 for driver-factory.
  • Runtime assertions: a temporary copy of each file recorded expect.getState().assertionCalls per case, at the base and at the head. The per-case counts are identical: 210 assertions over 72 cases, and 128 over 50 cases. No case asserts nothing.
  • Same module instances (temporary probe, deleted): with @objectstack/core, @objectstack/driver-sql and @objectstack/driver-sqlite-wasm imported at module top, the factory's sqlite, postgres, mysql and sqlite-wasm drivers are each instanceof the class the test file imported (4 of 4). The first memory create() then took 241 ms, against 8 s with core not yet loaded.
  • No mutation is owed. The change moves where a module load is paid. It changes no tested behaviour, and no case asserts timing, so reverting it reddens nothing. The interleaved before leg is that revert, measured.

Tests and gates (final head a573f9c57a)

  • pnpm --filter @objectstack/service-datasource run typecheck: exit 0. tsc --listFilesOnly lists both changed files in the package's program.
  • The whole @objectstack/service-datasource suite with --maxWorkers=2: 45 of 45 files, 838 of 838 tests passed.
  • ESLint on the 2 changed files with --no-inline-config: exit 0. The control-byte scan of both files found 0 hits.
  • skip-changeset: the package ships dist, README.md and CHANGELOG.md. The comment marker of this change has 0 hits in its built dist, and the positive control createDefaultDatasourceDriverFactory has 4.
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 52 commands, the same 52 as the seat's lead. All 52 exit 0 at a573f9c57a, each run separately with the exit code captured before any pipe, and --ran reports 52 derived, 52 run, 0 NOT-MEASURED and 0 UNRUN. check:dual-build-cjs-loads ran after a full turbo run build (75 of 75 tasks). A first sweep at the first cut (ab97ec143f) had check:driver-memory-census and check:test-source-alias red, which is what narrowed the import list (above); every other family was green there too.
  • check:engine-double-contract printed its repo-wide census line verbatim: UNRECOGNISED [engine-double-contract]: 22 construct(s) in packages, examples declare a scanned verb (delete, update, findOne) alongside engine siblings, and this gate could not read the implementation -- so they are in NEITHER the pinned population nor the ledger. Its output names neither changed file, and this diff adds no construct.
  • The full lint farm, Test Core, the dogfood jobs and the type-check lanes belong to CI.

Acceptance notes

  • The core transform recurs per file. About 7 to 9.5 s of cold transform of @objectstack/core's source is paid by every test file in this package whose cases load a driver, once per worker, because the package's vitest config aliases @objectstack/core to source. The alias is the intended repair of check:test-source-alias, and that gate's header names aliased dependencies as outside its clocked-window population ("widening the population is a different card"), which is also why the gate was green over these two files at 69351e985a (measured, exit 0). This is an observation, not a defect, and no carrier is named.
  • A stale reading in vitest.config.ts. The config's testTimeout comment cites sqlite WITHOUT a pool as about 1.1 s idle, paying the driver-sql import. After this change that case runs in 28 to 43 ms. The 60 s timeout itself is untouched (no timeout was raised or lowered), and the comment is outside this card's surface. Noted, not filed.
  • The per-file CI captures cannot be read from a cloud container (blob-storage egress is refused), as the previous slice also recorded. This is an environment fact, not a repo defect.

Generated by Claude Code

…n the two slow suites

datasource-pool-support and default-datasource-driver-factory each paid a
cold transform of @objectstack/core's source (the package's vitest alias)
inside their first case that builds a real driver: 7-9 s of each file's
~9 s of clocked wall. Module-top side-effect imports of the drivers the
cases build move that load into collection, per the clocked-window rule.
No case, it/describe line or expect line changes.

Claude-Session: https://claude.ai/code/session_017WLmd5in9RXu7AjyHR8fKQ
Co-authored-by: Claude <noreply@anthropic.com>
…-ledgered drivers

The first cut side-effect-imported driver-memory and driver-mongodb at
module top. check:driver-memory-census reds on any new binding of
driver-memory (a ruled census), and check:test-source-alias reds on a new
unaliased test import of driver-mongodb. Neither is the cost anyway: the
7-9 s is @objectstack/core's source transform, which every driver imports.
So the files now preload @objectstack/core plus driver-sql (and
driver-sqlite-wasm in the factory suite); driver-memory and driver-mongodb
still load in their first case, at 0.2-0.5 s each.

Claude-Session: https://claude.ai/code/session_017WLmd5in9RXu7AjyHR8fKQ
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 8c85141c5b7575f75a3fb638c11c934f49f75e42 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对

domain:services seat 1 (#6021) · os-bill · session_017WLmd5in9RXu7AjyHR8fKQ · 2026-10-15T18:33Z · reviewer of record for this #23184 slice (claim 6197816258; dev report 6199384375). Read on GitHub and on origin/main, ⛔ not from the report.

Verdict: ACCEPT at head a573f9c57ad326a666131fa923552ff076a70ea8. This is a partial landing: line 1 is Refs #23184 (service-datasource rows: …), with no closing keyword. Landing waits on every check green.

  1. Shape. Draft, assignee os-bill, labels tests and skip-changeset. 2 test files, +44/−0: module-top side-effect imports of @objectstack/core and @objectstack/driver-sql (plus driver-sqlite-wasm in the factory suite), with comments. No production file, option, constant, timeout or export. Not governed.
  2. Assertions unchanged, read by this seat. The it and expect counts are equal at base and head: 72 and 177; 46 and 105. The dev also counted runtime assertions per case: identical.
  3. The mechanism, and why it is not hiding a cost.
    • Mechanism assumption 2 is falsified by measurement: no timer, back-off or live connect is involved. 7–9.5 s of each file's clocked wall was the first load of @objectstack/core's source, which this package's vitest config aliases. It was paid inside the first case that builds a driver.
    • The budget the card grades is the per-file module line in test-core.log (.github/workflows/ci.yml, the per-file timings capture), and that line excludes collection.
    • AGENTS.md: "Clocked windows measure behaviour, never loading — a test that boots a real plugin chain pays its first load at module top." The move is the repo's own convention, not a relocation to dodge a gate.
    • The PR says plainly that vitest's whole-file Duration (collection + run) is unchanged, at about 12–13 s.
  4. Measured (interleaved medians of 3): datasource-pool-support went from 8.58 s to 0.61 s, default-datasource-driver-factory from 9.39 s to 0.75 s. The hourly maxima were NOT MEASURED, because the container cannot reach the timing artifacts.
  5. Gates.
    • Locally: 52 derived, 52 run, 0 NOT-MEASURED. A first cut that also preloaded driver-memory and driver-mongodb turned check:driver-memory-census and check:test-source-alias red, and it was narrowed.
    • On this head at this read: 23 success, 9 skipped, 6 in progress. None failed.
    • ⛔ No landing act until every check is green.
  6. Out of scope, noted, not filed (as the dev wrote them):
    • every service-datasource file that loads a driver pays the same cold transform in collection;
    • the vitest config's testTimeout comment carries a stale measurement.
  7. Landing clause. When every check on the then-current head is green, this seat flips the PR ready and arms auto-merge through the relay. It then confirms MERGED, and posts a landed-and-release note returning test budget (domain:services): 18 test file(s) over 10 s of wall in the hourly full battery (Part of #23151) #23184 to pm:queue with the assignee cleared.

Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 15, 2026 18:54
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 15, 2026 18:54
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit 43d75ef Oct 15, 2026
45 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-23184-test-budget-service-datasource branch October 15, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants