Skip to content

Run source-compatible unit tests without a build - #3199

Draft
kriszyp wants to merge 20 commits into
claude/typestrip-modefrom
claude/typestrip-unit-tests
Draft

kriszyp wants to merge 20 commits into
claude/typestrip-modefrom
claude/typestrip-unit-tests

Conversation

@kriszyp

@kriszyp kriszyp commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

⊙ Problem

Ordinary tests need build-free source execution; export-rewriting fixtures need mutable compiled modules.

Stacked on #562; merge that foundation first.

🤔 Retain legacy mutation fixtures?

Keep legacy mutation coverage compiled; #js declares it.

💡 Solution

package.json makes #src select source under typestrip, including JavaScript, and denies #js there. Both aliases select dist under ordinary Mocha. The launcher partitions Mocha's selection into separate processes.

⚖️ Alternatives

Automatic helper selection favors the launcher over fixed lists.

🔧 Changes

Product and architecture tour

Choose the runtime

Command Selection Build
npm run test:unit:typestrip Source-compatible core suites No
npm run test:unit:typestrip:resources Source-compatible resource suites No
npm run test:unit:typestrip:main Complete core selection, source then compiled Yes
Ordinary Mocha commands Complete compiled selection Yes

typeStripSuites.mts recognizes #js, local helpers and static child fixtures. runTypeStripTests.mts keeps Mocha's options, rejects ambient native conditions for mixed runs, and preserves compiled global --file setup in one process. Source-only refuses to omit compiled setup. Watch and parallel mode use project Mocha; file and external reporters run per lane.

Exports stay compiled; speed is unmeasured.

Completion and storage

mocha.init.js records completion, totals and files; missing completion and signals fail. --fail-zero checks the combined total.

perFileDatabaseTeardown.js observes cached ESM databases, preserving initial directories and removing reopened residue. nativeModules.mts rejects compiled cache entries at file boundaries and completion. Utility-only suites leave storage unloaded. packageBindings.mts preserves core's blob extensions and addon identity. rocksdbBindings.mts delegates to it. testUtils.js uses real native initialization; compiled keeps its stub. .mts avoids rewire's .ts hook.

Additional changes

alasqlFunctionImporter.ts default-imports the CommonJS date-helper object; a native namespace import did not expose its date functions. DESIGN.md records that boundary. unit-test.yml adds Node 22.18.0/24.0.0 and current 22/24/26 source CI with no build or Harper install and type-checks the harness. tsconfig.harness.json scopes that check.

AGENTS.md maps the source subset and built complete selection; CONTRIBUTING.md documents commands and limits; DESIGN.md records the lane contract; DESIGN.md indexes both notes. hnsw-real-store.cjs uses its existing source family consistently; no benchmark was run.

✅ Verification

Build, types, lint, formatting and 28 harness tests pass. Mixed core: 3,829 source + 3,207 compiled, 207 pending. Windows selection on Linux: 5,008 passed. All five hosted native jobs passed.

Broad validation and CI limits

Without dist, core 3,829/26 pending, resources 3,234/36 and indexes 645/7 pass on Node 22.18/24.0/26. Compiled core 7,036/207 passed before the final backup fixture fix; all 78 backup tests pass with a relative root. Compiled resources: RocksDB 4,283/54; LMDB 3,255/722. Integration: 2,389 passed, 18 skipped, one TODO before later harness-only fixes. Deployment timing assertion passed the repeat.

CI Bun shard 6, Next.js adapters (20/22/24) and Windows runtime/admission failures match #562's logs. Windows passes on current main; these are parent-branch failures. Other jobs are still running.

Focused regression evidence

typeStripSuites covers selection/completion, inheritance, reporters, workers, late storage and interrupts. preTestPrepNative checks real initialization/isolation. perFileDatabaseTeardown tests guarded completion, both engines, closed residue and prior data. branchDatabase and closeLoadedDatabases use the shared named schema handler. longLivedTransactions resolves its worker helper absolutely.

schema.test.js scopes its PID stub; declaration-time mutation split database roots. pidInvariant.cjs fails without the PID fix.

gitSSHMaterialization restores its root and retains compiled logger mutation. storageExhaustion drains loader warnings before its fatal-console oracle. rocksdbBackup.test.js pins its child's canonical backup key and absolute parent path. logConfigFixture.js rewrites the compiled logger.

🤔 Local command deadlines

CI bounds steps. Local per-test timeouts are disabled; use --timeout or interrupt.

🤔 Final review tradeoffs

Source-only covers compatible suites. Use project Mocha; separate file reporters. Five helpers are pinned native; other marker changes appear in skip counts.

Review limits

Optional Composer output failed format repair; prompt truncation carries. Native coverage remains an accepted policy nit.

PR QA: Do legacy SQL date functions agree across cold HTTP and export workers in both runtimes? — queued @ 357adfb, qa-pr-harper-3199-357adfb

Developer docs are included; public API and storage format are unchanged.

Remaining test and fixture files

Import groups: source=#src; compiled=#js; bindings match core; JS is retained. Paths: unitTests; bridge=dataLayer/harperBridge.

🤖 Generated by OpenAI Codex; posted via @kriszyp.

Release target: v5.4 — stacked on #562.

Related PRs: #562 overlaps (stacked foundation), #1835 overlaps (blob bindings), #2155 overlaps (eviction bindings), #3121 overlaps (backup fixtures), #3137 overlaps (subscription logger), #3187 overlaps (handler aliases)

Complexity: complicated — worker completion and module identity.

Deferred findings

Review-Coverage: authored=codex; ran=gemini,claude; adjudicated=domain; blocked=cursor-composer(failed); declined=cursor-grok,cursor-kimi,cursor-muse,muse; rounds=9; full=1 @ 357adfb

Review-Attention: study ~14m (sensitive: unit-test.yml; decisions: do-less-alternative, mutable-export-fixtures, completion-interception) @ 357adfb

kriszyp and others added 20 commits October 13, 2026 09:13
Run source-compatible suites without a build and retain compiled exports for legacy mutation fixtures. Preserve Mocha selection, completion and database isolation across both lanes, and cover native execution without dist in CI.

Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Resolve worker helpers absolutely, classify built artifacts and cache mutation precisely, and bind result reporting to the owning run after teardown and reporter completion. Preserve ordinary parallel workers and add regression coverage for unfinished completion and physical database removal.

Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Codex <noreply@openai.com>
@kriszyp kriszyp added this to the v5.4 milestone Oct 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request establishes a dual-lane unit testing architecture that separates native source-compatible tests (utilizing Node.js native type stripping via the typestrip condition) from legacy compiled tests. It introduces a custom test launcher (runTypeStripTests.mts) to partition suites, updates package.json imports and scripts, and implements a nativeCoreGuard to prevent source processes from loading the compiled core. Additionally, the database teardown and Mocha initialization processes are refactored to support ESM-only environments. No review comments were provided, so there is no further feedback to address.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant