Commit 029a3b2
feat(ecs): add
* test(ecs): add plugin-composition type-complexity benchmark harness
Adds scripts/typeperf/ — a reproducible ruler for how Database.Plugin
composition scales the TypeScript type-checker. Generates synthetic
extends/imports chains at depths [2..32], type-checks each in isolation
with `tsc --extendedDiagnostics`, and reports Types / Instantiations /
Check time vs depth.
Baseline finding (TS 5.8.3): `extends` Instantiations grow ~quadratically
with chain depth (121K@2 -> 3.38M@32; inst/depth^2 flat ~2-3K), while
Types grow only linearly — i.e. the cost is repeated re-instantiation of
the full accumulated 9-bucket intersection, not distinct types. This is
the ruler we'll use to measure the additive `imports` property.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(ecs): add `imports` to Database.Plugin.create — consume types without re-export
`extends` re-exports all of a base plugin's types into the result, so a deep
chain accumulates the full 9-bucket intersection at every link — type-checker
Instantiations grow ~quadratically with depth (3.4M at depth 32) and deep
chains hit TS7056, forcing `db: any`.
`imports` is the additive complement: the imported plugins' types are visible
to local declarations (full type safety on their components / resources /
transactions — verified by imports-chain.type-test.ts, including @ts-expect-error
negative guards) but are NOT re-exported into the result type. Each link's
result stays O(local members), so the chain is linear; consumers reconstitute
the union once at the top via Database.Plugin.combine(...).
Measured via scripts/typeperf (TS 5.8.3): at depth 32 imports is 8.8x fewer
Instantiations (387K vs 3.41M) with a flat per-link marginal vs extends'
super-linear climb. `extends` is untouched: its result type still references
XP alone, and the new `& IP['x']` terms reduce to `& {}` when imports is unused
(within ~1% of baseline), so existing plugins pay nothing and no pre-existing
type check is weakened (full tsc -b + 226 ECS tests green).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore: bump to 0.9.64; ignore typeperf generated output in eslint
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(ecs): require `imports` before `extends` in plugin descriptor order
Reorders the descriptor property contract so dependency declarations
(`imports`) precede the re-exporting base (`extends`). Updates
validatePropertyOrder, the descriptor type field order, and the doc comment;
adds a regression test asserting `imports` must come before `extends`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>imports to Database.Plugin.create — consume types without re-export (#118)1 parent 20f2917 commit 029a3b2
21 files changed
Lines changed: 496 additions & 67 deletions
File tree
- packages
- data-lit-tictactoe
- data-lit-todo
- data-lit
- data-p2p-tictactoe
- data-persistence
- data-react-hello
- data-react-pixie
- data-react
- data-solid-dashboard
- data-solid
- data-sync
- data
- scripts/typeperf
- src/ecs/database
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments