Skip to content

Add configurable assertions - #288

Merged
krispya merged 3 commits into
canaryfrom
feat/set-membership-guard
Oct 4, 2026
Merged

krispya merged 3 commits into
canaryfrom
feat/set-membership-guard

Conversation

@krispya

@krispya krispya commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Builds an assertion layer that can be compiled in or out that validates design contracts are held at runtime. This assertion layer is composable and adds a small overhead of around 10% for the specific calls. This covers entity operations to enforce entities are alive, traits exist being written to or relation targets exist.

  • entity.add(...)
  • entity.remove(...)
  • entity.destroy()
  • entity.get(...)
  • entity.has(...)
  • entity.set(...) — including callback writeback
  • entity.changed(...)
  • entity.targetFor(...)
  • entity.targetsFor(...)

World spawn/add/remove/get/set reach the same checked core paths.

They are compiled in dev builds and out of prod builds by default. Define __KOOTA_ASSERTS__ as true to retain them in production, or false to remove them completely from the application bundle.

entity.set previously wrote the store silently for a trait the entity had not
been given. Every trait now throws instead, so a write can never land in a
column the entity does not own. The check reads the membership bit from the
trait instance that set already looks up, so it costs one mask read.
@krispya krispya changed the title ✨ (core): Add configurable entity and trait assertions Add configurable assertions Oct 4, 2026
@krispya
krispya merged commit 09c94f8 into canary Oct 4, 2026
1 check passed
@krispya
krispya deleted the feat/set-membership-guard branch October 4, 2026 16:02
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