Skip to content

fix(ecs): index inserted rows by stored values so defaultFactory columns are indexed - #216

Merged
krisnye merged 1 commit into
mainfrom
krisnye/indexing-bug
Oct 15, 2026
Merged

krisnye merged 1 commit into
mainfrom
krisnye/indexing-bug

Conversation

@krisnye

@krisnye krisnye commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

An index whose key or order.by reads a defaultFactory component did not contain rows whose insert omitted that component. The archetype minted and stored the value, but decorateArchetypeForIndexes passed the raw insert payload to indexRegistry.applyInsert, so the row was filed without it (and dropped from find() until a later update re-read the stored row).

Fix

applyInsert(entity, archetype) now reads the stored row (the same reader applyUpdate uses) instead of taking the payload. The read is skipped when no index applies to the archetype, so un-indexed inserts cost nothing extra.

Tests

Red/green in default-factory.test.ts: an index ordered by a minted guid, and one keyed by it, both include the minted row right after insert. Both fail before the fix and pass after it. Full monorepo pnpm run test / typecheck / lint pass.

Version bumped to 0.10.28.

🤖 Generated with Claude Code

…payload

An index keyed or ordered by a defaultFactory component missed rows whose
insert omitted it: the archetype minted the value but the index was fed the
raw payload. applyInsert now reads the stored row, like applyUpdate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@krisnye
krisnye merged commit 2c04034 into main Oct 15, 2026
3 checks passed
@krisnye
krisnye deleted the krisnye/indexing-bug branch October 15, 2026 17:16
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