Skip to content

tests: #808 — ≥300-module init-scale harness#823

Merged
proggeramlug merged 1 commit into
mainfrom
worktree-fix-808-init-scale
May 16, 2026
Merged

tests: #808 — ≥300-module init-scale harness#823
proggeramlug merged 1 commit into
mainfrom
worktree-fix-808-init-scale

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

  • Pre-rendered 300-module topological-import chain under test-files/multi/test_harness_init_scale/ reproducing the conditions of perry-codegen: Effect — (number).slice is not a function during Schema.ts__init (#680 follow-up, ~310th init) #684 (Effect's Schema.ts ~310th-init regression).
  • Each module exports VAL_NNN: number = 1000 + N and class Cls_NNN; index.ts imports all 300 and asserts per-module that:
    • typeof VAL_i === \"number\" AND VAL_i === 1000 + i (no NaN-box tag leak across inits).
    • new Cls_i().tag() === \"Cls_i\" (no class_id smear / vtable collision across 300 registrations).
  • On success prints a single init-scale: OK (300 modules) line; on failure pins the first failing probe.

Generator

generate.py is the source of truth for the module + index files — re-run with python3 generate.py 600 to push the ceiling once the current bug closes and we want a higher bar. Re-running is idempotent.

Verification on v0.5.912

./target/release/perry test-files/multi/test_harness_init_scale/index.ts -o /tmp/init_scale && /tmp/init_scaleinit-scale: OK (300 modules). Compiles + runs through the full 300-module chain on macOS arm64.

Why a Perry-only harness (no Node baseline)

Existing test-files/multi/* tests don't have .ts extensions in their import specifiers, so Node --experimental-strip-types doesn't resolve them — same as test_stress_cross_module. The harness is a Perry compile-and-run smoke; the CI hookup belongs in a separate compat-job issue (#802/#805 family).

Test plan

  • python3 generate.py 300 produces 300 modules + index.ts idempotently.
  • perry compile … -o /tmp/init_scale && /tmp/init_scale prints the OK line on v0.5.912.
  • Each module references VAL_{i-1} in a top-level expression so the import survives DCE and the predecessor init has to run first.

Diff size note

The PR adds 302 files (generator + index + 300 m*.ts) totalling ~7.6k inserts of mechanical, generator-emitted TypeScript. Diff is large but mechanical — review by spot-checking generate.py plus 2–3 generated modules.

Closes #808.

Reproduces the conditions of #684 (Effect's Schema.ts ~310th-init
regression) by forcing a 300-module topological-import chain and
checking per-module state isolation. Each module:

- Exports `VAL_NNN: number = 1000 + N` and `class Cls_NNN` with a
  `tag()` method returning `"Cls_NNN"`.
- Imports `VAL_{N-1}` from the predecessor and references it in a
  top-level expression so module-init order has to walk the chain
  end to end (no DCE escape hatch).

`index.ts` imports all 300 and asserts, for each `i`:

- `typeof VAL_i === "number"` AND `VAL_i === 1000 + i` (no NaN-box
  tag leak across inits).
- `new Cls_i().tag() === "Cls_i"` (no `class_id` smear / vtable
  collision after 300 distinct class registrations).

On success prints a single `init-scale: OK (300 modules)` line; on
failure pins the first failing probe so a regression is one grep away.

`generate.py` is the source of truth — it regenerates `m000.ts ...
m299.ts` and `index.ts` idempotently. Re-run with `python3 generate.py
600` to push past 300 once the current bug closes and we want a higher
ceiling.

Verified on v0.5.912: Perry compiles + runs the 300-module chain and
prints the OK line. Node won't run this multi/ harness directly (no
.ts-extension imports, by existing test-files/multi/* convention), so
it's a Perry-specific smoke — same shape as the existing
test_stress_cross_module under multi/.
@proggeramlug proggeramlug merged commit 74454c2 into main May 16, 2026
9 checks passed
@proggeramlug proggeramlug deleted the worktree-fix-808-init-scale branch May 16, 2026 03:07
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.

tests: harness for cross-module init at scale (≥300 inits)

1 participant