@oasys/oecs 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/CHANGELOG.md +208 -14
  2. package/README.md +198 -145
  3. package/dist/core/ecs/access_check.d.cts +3 -3
  4. package/dist/core/ecs/access_check.d.ts +3 -3
  5. package/dist/core/ecs/archetype.d.cts +103 -43
  6. package/dist/core/ecs/archetype.d.ts +103 -43
  7. package/dist/core/ecs/archetype.d.ts.map +1 -1
  8. package/dist/core/ecs/archetype_graph.d.cts +8 -8
  9. package/dist/core/ecs/archetype_graph.d.ts +8 -8
  10. package/dist/core/ecs/archetype_graph.d.ts.map +1 -1
  11. package/dist/core/ecs/builtin_relations.d.cts +1 -1
  12. package/dist/core/ecs/builtin_relations.d.ts +1 -1
  13. package/dist/core/ecs/command_log.d.cts +4 -4
  14. package/dist/core/ecs/command_log.d.ts +4 -4
  15. package/dist/core/ecs/command_log.d.ts.map +1 -1
  16. package/dist/core/ecs/component.d.cts +4 -4
  17. package/dist/core/ecs/component.d.ts +4 -4
  18. package/dist/core/ecs/deferred_commands.d.cts +1 -1
  19. package/dist/core/ecs/deferred_commands.d.ts +1 -1
  20. package/dist/core/ecs/deferred_commands.d.ts.map +1 -1
  21. package/dist/core/ecs/ecs.d.cts +85 -43
  22. package/dist/core/ecs/ecs.d.ts +85 -43
  23. package/dist/core/ecs/ecs.d.ts.map +1 -1
  24. package/dist/core/ecs/ecs_memory.d.cts +15 -15
  25. package/dist/core/ecs/ecs_memory.d.ts +15 -15
  26. package/dist/core/ecs/ecs_memory.d.ts.map +1 -1
  27. package/dist/core/ecs/entity_allocator.d.cts +6 -6
  28. package/dist/core/ecs/entity_allocator.d.ts +6 -6
  29. package/dist/core/ecs/entity_allocator.d.ts.map +1 -1
  30. package/dist/core/ecs/event.d.cts +2 -2
  31. package/dist/core/ecs/event.d.ts +2 -2
  32. package/dist/core/ecs/event_registry.d.cts +1 -1
  33. package/dist/core/ecs/event_registry.d.ts +1 -1
  34. package/dist/core/ecs/event_registry.d.ts.map +1 -1
  35. package/dist/core/ecs/facades.d.cts +15 -15
  36. package/dist/core/ecs/facades.d.ts +15 -15
  37. package/dist/core/ecs/facades.d.ts.map +1 -1
  38. package/dist/core/ecs/frame_trace.d.cts +2 -2
  39. package/dist/core/ecs/frame_trace.d.ts +2 -2
  40. package/dist/core/ecs/host_commands.d.cts +12 -12
  41. package/dist/core/ecs/host_commands.d.ts +12 -12
  42. package/dist/core/ecs/host_commands.d.ts.map +1 -1
  43. package/dist/core/ecs/index.d.cts +1 -1
  44. package/dist/core/ecs/index.d.ts +1 -1
  45. package/dist/core/ecs/index.d.ts.map +1 -1
  46. package/dist/core/ecs/observer.d.cts +9 -9
  47. package/dist/core/ecs/observer.d.ts +9 -9
  48. package/dist/core/ecs/observer.d.ts.map +1 -1
  49. package/dist/core/ecs/query.d.cts +91 -70
  50. package/dist/core/ecs/query.d.ts +91 -70
  51. package/dist/core/ecs/query.d.ts.map +1 -1
  52. package/dist/core/ecs/ref.d.cts +53 -1
  53. package/dist/core/ecs/ref.d.ts +53 -1
  54. package/dist/core/ecs/ref.d.ts.map +1 -1
  55. package/dist/core/ecs/relation.d.cts +15 -15
  56. package/dist/core/ecs/relation.d.ts +15 -15
  57. package/dist/core/ecs/relation.d.ts.map +1 -1
  58. package/dist/core/ecs/relation_service.d.cts +14 -14
  59. package/dist/core/ecs/relation_service.d.ts +14 -14
  60. package/dist/core/ecs/relation_service.d.ts.map +1 -1
  61. package/dist/core/ecs/resource.d.cts +1 -1
  62. package/dist/core/ecs/resource.d.ts +1 -1
  63. package/dist/core/ecs/resource_registry.d.cts +2 -2
  64. package/dist/core/ecs/resource_registry.d.ts +2 -2
  65. package/dist/core/ecs/resume.d.cts +3 -3
  66. package/dist/core/ecs/resume.d.ts +3 -3
  67. package/dist/core/ecs/resume.d.ts.map +1 -1
  68. package/dist/core/ecs/schedule.d.cts +22 -9
  69. package/dist/core/ecs/schedule.d.ts +22 -9
  70. package/dist/core/ecs/schedule.d.ts.map +1 -1
  71. package/dist/core/ecs/snapshot_service.d.cts +3 -3
  72. package/dist/core/ecs/snapshot_service.d.ts +3 -3
  73. package/dist/core/ecs/sparse_store.d.cts +6 -6
  74. package/dist/core/ecs/sparse_store.d.ts +6 -6
  75. package/dist/core/ecs/sparse_store.d.ts.map +1 -1
  76. package/dist/core/ecs/store.d.cts +189 -110
  77. package/dist/core/ecs/store.d.ts +189 -110
  78. package/dist/core/ecs/store.d.ts.map +1 -1
  79. package/dist/core/ecs/store_layout_listener.d.cts +2 -2
  80. package/dist/core/ecs/store_layout_listener.d.ts +2 -2
  81. package/dist/core/ecs/system.d.cts +8 -8
  82. package/dist/core/ecs/system.d.ts +8 -8
  83. package/dist/core/ecs/system.d.ts.map +1 -1
  84. package/dist/core/ecs/utils/error.d.cts +7 -0
  85. package/dist/core/ecs/utils/error.d.ts +7 -0
  86. package/dist/core/ecs/utils/error.d.ts.map +1 -1
  87. package/dist/core/store/action_ring.d.cts +7 -8
  88. package/dist/core/store/action_ring.d.ts +7 -8
  89. package/dist/core/store/action_ring.d.ts.map +1 -1
  90. package/dist/core/store/allocator.d.cts +58 -35
  91. package/dist/core/store/allocator.d.ts +58 -35
  92. package/dist/core/store/allocator.d.ts.map +1 -1
  93. package/dist/core/store/buffer_backed_column.d.cts +5 -6
  94. package/dist/core/store/buffer_backed_column.d.ts +5 -6
  95. package/dist/core/store/buffer_backed_column.d.ts.map +1 -1
  96. package/dist/core/store/column_store.d.cts +23 -23
  97. package/dist/core/store/column_store.d.ts +23 -23
  98. package/dist/core/store/column_store.d.ts.map +1 -1
  99. package/dist/core/store/command_dispatch.d.cts +1 -1
  100. package/dist/core/store/command_dispatch.d.ts +1 -1
  101. package/dist/core/store/command_ring.d.cts +6 -7
  102. package/dist/core/store/command_ring.d.ts +6 -7
  103. package/dist/core/store/command_ring.d.ts.map +1 -1
  104. package/dist/core/store/descriptor.d.cts +2 -2
  105. package/dist/core/store/descriptor.d.ts +2 -2
  106. package/dist/core/store/entity_index.d.cts +3 -3
  107. package/dist/core/store/entity_index.d.ts +3 -3
  108. package/dist/core/store/event_ring.d.cts +7 -7
  109. package/dist/core/store/event_ring.d.ts +7 -7
  110. package/dist/core/store/extend.d.cts +2 -2
  111. package/dist/core/store/extend.d.ts +2 -2
  112. package/dist/core/store/extend.d.ts.map +1 -1
  113. package/dist/core/store/grow.d.cts +1 -1
  114. package/dist/core/store/grow.d.ts +1 -1
  115. package/dist/core/store/grow.d.ts.map +1 -1
  116. package/dist/core/store/header.d.cts +9 -9
  117. package/dist/core/store/header.d.ts +9 -9
  118. package/dist/core/store/header.d.ts.map +1 -1
  119. package/dist/core/store/layout_ops.d.cts +25 -7
  120. package/dist/core/store/layout_ops.d.ts +25 -7
  121. package/dist/core/store/layout_ops.d.ts.map +1 -1
  122. package/dist/core/store/state_hash.d.cts +3 -3
  123. package/dist/core/store/state_hash.d.ts +3 -3
  124. package/dist/extensions/editor/editor.d.cts +4 -4
  125. package/dist/extensions/editor/editor.d.ts +4 -4
  126. package/dist/extensions/editor/editor.d.ts.map +1 -1
  127. package/dist/extensions/editor/field_handle.d.cts +1 -1
  128. package/dist/extensions/editor/field_handle.d.ts +1 -1
  129. package/dist/extensions/editor/index.d.cts +2 -2
  130. package/dist/extensions/editor/index.d.ts +2 -2
  131. package/dist/extensions/editor/index.development.js +4 -4
  132. package/dist/extensions/editor/index.js +4 -4
  133. package/dist/extensions/reactive/ecs_sync.d.cts +4 -4
  134. package/dist/extensions/reactive/ecs_sync.d.ts +4 -4
  135. package/dist/extensions/reactive/index.d.cts +4 -4
  136. package/dist/extensions/reactive/index.d.ts +4 -4
  137. package/dist/extensions/reactive/index.development.js +3 -3
  138. package/dist/extensions/reactive/index.js +3 -3
  139. package/dist/extensions/solid/index.d.cts +1 -1
  140. package/dist/extensions/solid/index.d.ts +1 -1
  141. package/dist/extensions/solid/index.development.js +1 -1
  142. package/dist/extensions/solid/index.js +1 -1
  143. package/dist/extensions/solid/kernel_solid.d.cts +1 -1
  144. package/dist/extensions/solid/kernel_solid.d.ts +1 -1
  145. package/dist/extensions/solid/kernel_solid.d.ts.map +1 -1
  146. package/dist/{host_commands-BI8pEmjH.js → host_commands-BlR3oZ3x.js} +473 -393
  147. package/dist/host_commands-C2cpU3yC.cjs +1 -0
  148. package/dist/index.cjs +1 -1
  149. package/dist/index.d.cts +2 -2
  150. package/dist/index.d.ts +2 -2
  151. package/dist/index.d.ts.map +1 -1
  152. package/dist/index.development.cjs +1 -1
  153. package/dist/index.development.js +3345 -2963
  154. package/dist/index.js +1496 -1131
  155. package/dist/{internal-BMDgWZbt.js → internal-BoxWl4dG.js} +410 -330
  156. package/dist/internal-CGBEwfeB.cjs +2 -0
  157. package/dist/internal.cjs +1 -1
  158. package/dist/internal.development.cjs +1 -1
  159. package/dist/internal.development.js +1 -1
  160. package/dist/internal.js +1 -1
  161. package/dist/primitives.development.js +1 -1
  162. package/dist/primitives.js +1 -1
  163. package/dist/reactive/index.d.cts +2 -2
  164. package/dist/reactive/index.d.ts +2 -2
  165. package/dist/reactive/index.development.js +1 -1
  166. package/dist/reactive/index.js +1 -1
  167. package/dist/reactive/kernel.d.cts +5 -5
  168. package/dist/reactive/kernel.d.ts +5 -5
  169. package/dist/reactive/shallow.d.cts +1 -1
  170. package/dist/reactive/shallow.d.ts +1 -1
  171. package/dist/{shallow-DfnAm9vG.js → shallow-Bs39EPh1.js} +1 -1
  172. package/dist/{shallow-9S1pY_Iw.js → shallow-CiFC70Dz.js} +1 -1
  173. package/dist/{shared-BU1Cd40h.js → shared-B4v0L1cw.js} +41 -35
  174. package/dist/shared-DU78k0pU.cjs +1 -0
  175. package/dist/shared.cjs +1 -1
  176. package/dist/shared.d.cts +1 -1
  177. package/dist/shared.d.ts +1 -1
  178. package/dist/shared.development.cjs +1 -1
  179. package/dist/shared.development.js +1 -1
  180. package/dist/shared.js +1 -1
  181. package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +2 -2
  182. package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +2 -2
  183. package/dist/{typed_arrays-BcXcnzB4.js → typed_arrays-DIVwVy5_.js} +1 -1
  184. package/dist/version.d.cts +2 -2
  185. package/dist/version.d.ts +2 -2
  186. package/package.json +1 -1
  187. package/dist/host_commands-CxhpzMx9.cjs +0 -1
  188. package/dist/internal-LiTSB_tG.cjs +0 -2
  189. package/dist/shared-BymrGTyR.cjs +0 -1
@@ -99,8 +99,8 @@ export interface ComponentDef<S extends ComponentSchema = ComponentSchema> {
99
99
  export type SchemaOf<D> = D extends ComponentDef<infer S extends ComponentSchema> ? S : never;
100
100
  /**
101
101
  * `unknown` if `D` is one of the query's declared terms, else an error tuple —
102
- * the query-seam sibling of system.ts's `DeclaredRead` (§typestate,
103
- * POLISH_AUDIT #6). `Query.eachChunk`'s cursor and `ArchetypeView`'s column
102
+ * the query-seam sibling of system.ts's `DeclaredRead` (§typestate).
103
+ * `Query.eachChunk`'s cursor and `ArchetypeView`'s column
104
104
  * accessors intersect this into their `def` parameter so fetching a component
105
105
  * that is NOT a term of the iterating query fails to compile (previously
106
106
  * caught only by the dev-mode access check, and only when the system's
@@ -133,7 +133,7 @@ export type ComponentHandle = {
133
133
  * returned function produces a `Bundle` when called (`Pos({x,y})`) and carries
134
134
  * its numeric id on a non-enumerable `.id` (invisible to spreads / `JSON`).
135
135
  * The single cast bridges the function value to the branded handle type — the
136
- * `.id` is installed at runtime by `defineProperty` (§10c branded-ID boundary).
136
+ * `.id` is installed at runtime by `defineProperty` (the branded-ID boundary).
137
137
  */
138
138
  export declare function makeComponentDef<S extends ComponentSchema>(id: ComponentID): ComponentDef<S>;
139
139
  export interface Bundle<S extends ComponentSchema = ComponentSchema> {
@@ -180,7 +180,7 @@ export declare function bundleValues(item: BundleOrDef): Readonly<Record<string,
180
180
  *
181
181
  * **Advisory, not a runtime barrier:** the value behind this type is the live
182
182
  * mutable backing `TypedArray` (`Archetype.getColumnRead` returns
183
- * `.buf as unknown as ReadonlyColumn`), so a §10c-policed cast can still write
183
+ * `.buf as unknown as ReadonlyColumn`), so a deliberate cast can still write
184
184
  * through. For mutation use the mutable `Archetype.getColumn` (tick-bumping).
185
185
  * Enforced by the escape-hatch lint, not the runtime.
186
186
  */
@@ -11,7 +11,7 @@ export interface DeferredCommandHost {
11
11
  readonly applyRemoves: () => void;
12
12
  readonly applyDestroys: () => void;
13
13
  readonly applyToggles: () => void;
14
- /** Hot-path gates — live counts of observed components (#531 / #677).
14
+ /** Hot-path gates — live counts of observed components.
15
15
  * While both are 0 the flush takes the byte-for-byte fast path. */
16
16
  readonly structuralObserverCount: () => number;
17
17
  readonly toggleObserverCount: () => number;
@@ -11,7 +11,7 @@ export interface DeferredCommandHost {
11
11
  readonly applyRemoves: () => void;
12
12
  readonly applyDestroys: () => void;
13
13
  readonly applyToggles: () => void;
14
- /** Hot-path gates — live counts of observed components (#531 / #677).
14
+ /** Hot-path gates — live counts of observed components.
15
15
  * While both are 0 the flush takes the byte-for-byte fast path. */
16
16
  readonly structuralObserverCount: () => number;
17
17
  readonly toggleObserverCount: () => number;
@@ -1 +1 @@
1
- {"version":3,"file":"deferred_commands.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/deferred_commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AASxD;;oDAEoD;AACpD,MAAM,WAAW,mBAAmB;IACnC;yEACqE;IACrE,QAAQ,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC;IACnC,QAAQ,CAAC,YAAY,E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AM;IAC3C,SAAgB,UAAU,EAAE,YAAY,EAAE,CAAM;IAIhD,SAAgB,SAAS,EAAE,QAAQ,EAAE,CAAM;IAC3C,SAAgB,aAAa,EAAE,OAAO,EAAE,CAAM;IAE9C;;;0BAGsB;IACtB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsB;IAC3C;6EACyE;IACzE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;gBAEzC,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAE,wBAAwB;IAKnE,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI;IAIhC,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAM/E,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,GAAG,IAAI;IAKlD,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAKxD,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED,IAAW,eAAe,IAAI,MAAM,CAEnC;IAED,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED;;;4EAGwE;IACjE,cAAc,IAAI,IAAI;IAKtB,eAAe,IAAI,IAAI;CAyF9B"}
@@ -7,7 +7,7 @@ import { SCHEDULE, SystemEntry, SystemSet, SystemSetConfig } from './schedule.cj
7
7
  import { Archetype, ArchetypeID } from './archetype.cjs';
8
8
  import { SystemContext, Query, QueryBuilder, QueryCache, QueryResolver } from './query.cjs';
9
9
  import { EntityID } from './entity.cjs';
10
- import { ReadonlyComponentRef } from './ref.cjs';
10
+ import { ComponentCursor, ReadonlyComponentCursor, ReadonlyComponentRef } from './ref.cjs';
11
11
  import { ComponentDef, ComponentHandle, ComponentRegisterOptions, ComponentSchema, CompleteFieldValues, Bundle, BundleOrDef, StrictBundles, DefsOf } from './component.cjs';
12
12
  import { SparseComponentDef, SparseComponentID } from './sparse_store.cjs';
13
13
  import { RelationDef } from './relation.cjs';
@@ -23,41 +23,41 @@ export interface ECSOptions {
23
23
  * dropped-ordering-edge warning). Defaults to `console.warn`. Mirrors the
24
24
  * `FrameTraceSink` seam's injectable style — no global logger. */
25
25
  onWarn?: (message: string) => void;
26
- /** How the world's memory is sized and backed (#682) — the single
26
+ /** How the world's memory is sized and backed — the single
27
27
  * sizing surface, replacing the pre-release `initialCapacity` +
28
28
  * `bufferAllocator` pair. Express intent through exactly one arm:
29
29
  * `{ budget: { entities } }` (derive everything), `{ maxBytes }`
30
30
  * (explicit cap), `{ wasm: { memory } | { maximumPages } }` (the SAB
31
31
  * IS a WebAssembly.Memory — zero-copy with a WASM `ComputeBackend`), or
32
- * `{ allocator }` (expert escape hatch, in-place-typed per ADR-0008).
32
+ * `{ allocator }` (expert escape hatch, in-place-typed).
33
33
  * Omitted ⇒ growable backing with a 256 MiB cap and 1024-row columns.
34
34
  * The resolved plan is exposed as `ECS.memoryPlan`. */
35
35
  memory?: ECSMemoryOptions;
36
- /** Consumer-declared SAB regions (#623), forwarded to `Store`. Each
36
+ /** Consumer-declared SAB regions, forwarded to `Store`. Each
37
37
  * `StoreRegionSpec` carries an opaque `region_id`, a precomputed byte size,
38
38
  * and an `init` closure; the engine lays them out generically and exposes
39
39
  * them via `regionHandle(id)` / `regionOffset(id)`. A game (e.g.
40
40
  * `@internal/sim`'s region specs) supplies these — the engine ships no
41
41
  * game regions of its own. Replaces the eight game-named region options
42
42
  * (`terrain_map_radius`, `spatial_grid_*`, `army_*`, `flow_field_*`,
43
- * `actionRingCapacitySlots`) the ECS used to carry. (ADR-0018.) */
43
+ * `actionRingCapacitySlots`) the ECS used to carry. */
44
44
  regions?: readonly StoreRegionSpec[];
45
- /** Byte size of the opt-in sim-bindings region (#625), forwarded to `Store`.
45
+ /** Byte size of the opt-in sim-bindings region, forwarded to `Store`.
46
46
  * A consumer that attaches a WASM `ComputeBackend` passes its own size — for
47
47
  * this game, `@internal/sim`'s `SIM_BINDINGS_BYTES` (computed from the binding
48
48
  * manifest) — so the host can publish the `(component_id, field_id)` IDs the
49
49
  * accelerated systems read. Omitted / 0 ⇒ no region: a pure-TS world pays
50
50
  * nothing for the WASM seam. The size is a runtime input, not an engine ABI
51
- * constant, since #625 de-welded it from the generated ABI. */
51
+ * constant; it is de-welded from the generated ABI. */
52
52
  bindingsRegionBytes?: number;
53
- /** Opt into the **determinism surface** (#626 / ADR-0020), forwarded to
53
+ /** Opt into the **determinism surface**, forwarded to
54
54
  * `Store`. Default `false`. When `false`, the canonical-ordering methods
55
55
  * (`stateHash`, `snapshotSparse`, `restoreSparse`) throw
56
56
  * `DETERMINISM_DISABLED`; when `true`, today's replay/hash behavior is
57
57
  * reproduced bit-for-bit. Determinism is the implementer's choice — our
58
58
  * server match opts in (replay verification), the client stays off (it rolls
59
59
  * back via diffs, not re-sim). The flag gates ONLY that surface: memory-safety
60
- * invariants (the in-place SAB allocator, ADR-0008) and the `enabled_count`
60
+ * invariants (the in-place SAB allocator) and the `enabled_count`
61
61
  * partition are always-on regardless. */
62
62
  deterministic?: boolean;
63
63
  }
@@ -65,7 +65,7 @@ export declare class ECS implements QueryResolver {
65
65
  private readonly store;
66
66
  private readonly schedule;
67
67
  private readonly ctx;
68
- /** Component observers (#517 §1 / ADR-0013). Inert until `observe(...)` is
68
+ /** Component observers. Inert until `observe(...)` is
69
69
  * called — the structural-flush fast path is byte-for-byte unchanged. */
70
70
  private readonly _observers;
71
71
  /** Relations: register/add/remove/has, wildcard + traversal reads,
@@ -93,7 +93,7 @@ export declare class ECS implements QueryResolver {
93
93
  private readonly _layoutSubscribers;
94
94
  private _backend;
95
95
  private readonly _memory;
96
- /** What `ECSOptions.memory` resolved to (#682): backing allocator kind,
96
+ /** What `ECSOptions.memory` resolved to: backing allocator kind,
97
97
  * column capacity, entity-index reservation, byte cap, and a
98
98
  * human-readable derivation trace. Diagnostics surface — log it when
99
99
  * sizing questions come up instead of reverse-engineering the SAB. */
@@ -121,7 +121,7 @@ export declare class ECS implements QueryResolver {
121
121
  * code. A `ComputeBackend` is subscribed automatically by `attachBackend`,
122
122
  * so most consumers call that rather than this directly. */
123
123
  onStoreLayoutPublished(listener: StoreLayoutListener): () => void;
124
- /** Attach an opt-in compute backend (#622). Default is none: a bare `ECS`
124
+ /** Attach an opt-in compute backend. Default is none: a bare `ECS`
125
125
  * runs pure-TS systems and the schedule's dispatch is byte-for-byte the
126
126
  * no-backend path. Once attached, a scheduled system carrying a
127
127
  * `backendHandle` (its `SystemConfig`) is executed via `backend.run(handle)`
@@ -139,13 +139,13 @@ export declare class ECS implements QueryResolver {
139
139
  get fixedTimestep(): number;
140
140
  set fixedTimestep(value: number);
141
141
  get fixedAlpha(): number;
142
- /** Attach (or detach with `null`) a per-world frame-trace sink (ADR-0030):
142
+ /** Attach (or detach with `null`) a per-world frame-trace sink:
143
143
  * the engine then fires structured `FrameTraceSink` events at each system,
144
144
  * flush, command, observer firing, and event during `update()`, so a consumer
145
145
  * can reconstruct exactly what travelled through the ECS each frame. The sink
146
146
  * also receives a `phaseBoundary(phase)` at each phase's post-flush settle
147
147
  * point — the safe seam to read `stateHash()` between phases of one frame and
148
- * bisect a divergence to the exact phase (#797 / ADR-0032). The seam is
148
+ * bisect a divergence to the exact phase. The seam is
149
149
  * `DEV`-gated end to end — in a production build this setter keeps an empty
150
150
  * body and the world never retains a sink. The sink only observes; it does not
151
151
  * perturb `stateHash`, ordering, or any behaviour. */
@@ -153,8 +153,8 @@ export declare class ECS implements QueryResolver {
153
153
  /**
154
154
  * Register a dense component and get back its typed handle. Record syntax
155
155
  * gives per-field type control; the array shorthand types every field the
156
- * same (default `"f64"` — rejected on a `{ deterministic: true }` world
157
- * (#777), pass an explicit integer type there). An empty schema `{}` is a
156
+ * same (default `"f64"` — rejected on a `{ deterministic: true }` world,
157
+ * pass an explicit integer type there). An empty schema `{}` is a
158
158
  * tag. `opts.name` labels dev-mode diagnostics (`'Pos' (component 5)`
159
159
  * instead of `component 5`) — diagnostic only, no behavioural effect.
160
160
  *
@@ -230,7 +230,7 @@ export declare class ECS implements QueryResolver {
230
230
  *
231
231
  * `_updating` scopes the guard to THIS world: the accessCheck slot is
232
232
  * process-global, so without it a system of world A mutating world B (a
233
- * supported #785 pattern — B is not mid-iteration) would false-throw. */
233
+ * supported pattern — B is not mid-iteration) would false-throw. */
234
234
  private _assertHostMutationOutsideSystem;
235
235
  /** Immediately destroy an entity — `ecs.despawn(e); ecs.isAlive(e)` is
236
236
  * `false` on the next line, matching the immediacy of every other host
@@ -273,7 +273,7 @@ export declare class ECS implements QueryResolver {
273
273
  * O(columns) via TypedArray.set() instead of O(N×columns).
274
274
  *
275
275
  * Takes an `ArchetypeID` (from `ArchetypeView.id`) rather than a concrete
276
- * `Archetype` — the concrete type is internal (issue #378).
276
+ * `Archetype` — the concrete type is internal.
277
277
  */
278
278
  batchAddComponent(src: ArchetypeID, def: ComponentDef<Record<string, never>>): this;
279
279
  batchAddComponent<S extends ComponentSchema>(src: ArchetypeID, def: ComponentDef<S>, values: CompleteFieldValues<S>): this;
@@ -285,7 +285,7 @@ export declare class ECS implements QueryResolver {
285
285
  */
286
286
  batchRemoveComponent(src: ArchetypeID, def: ComponentDef): this;
287
287
  getField<S extends ComponentSchema>(entityId: EntityID, def: ComponentDef<S>, field: string & keyof S): number;
288
- /** Host-side parity with `SystemContext.refRead` (POLISH_AUDIT M7): a
288
+ /** Host-side parity with `SystemContext.refRead`: a
289
289
  * read-only whole-component view for tooling/tests, instead of reading
290
290
  * field-by-field. Same advisory-`readonly` semantics as the ctx variant;
291
291
  * no `_changedTick` bump. Dev-throws on a dead entity, or when the entity
@@ -298,7 +298,42 @@ export declare class ECS implements QueryResolver {
298
298
  * only valid until the next structural mutation; treat it as an immediate
299
299
  * single-expression read and re-create it after any structural change. */
300
300
  refRead<S extends ComponentSchema>(def: ComponentDef<S>, entityId: EntityID): ReadonlyComponentRef<S>;
301
- /** Total sibling of {@link getField} (POLISH_AUDIT #9): `undefined` when the
301
+ /**
302
+ * A re-pointable single-entity cursor over `def` — the by-id sweep accessor.
303
+ *
304
+ * `refRead` resolves an entity one time, and each field after that is almost
305
+ * free. But it allocates one accessor for each entity. That allocation is the
306
+ * largest part of the cost of a read of one field by id, because to make an
307
+ * accessor and to read through it costs much more than to move an accessor
308
+ * that exists. In a loop over a list of entities, the allocation is not
309
+ * necessary: the code discards each accessor, and it then makes an equal
310
+ * accessor for the next entity. You make a cursor one time, and you then
311
+ * point it again:
312
+ *
313
+ * const p = ecs.cursor(Pos);
314
+ * for (let i = 0; i < ids.length; i++) {
315
+ * p.at(ids[i]);
316
+ * p.x += p.y;
317
+ * }
318
+ *
319
+ * Reach for it when you touch **many entities** by id; reach for `refRead` /
320
+ * `ref` for a single entity, and for `eachChunk` whenever a query can express
321
+ * the set. A column walk resolves nothing for each row, so it stays quicker
322
+ * than a cursor — a cursor removes the allocation, not the resolution.
323
+ *
324
+ * Mutable — every `at()` stamps the component's change tick, like `ctx.ref`.
325
+ * See `cursorRead` for the read-only variant.
326
+ *
327
+ * **Staleness:** safer than a held ref, because `at()` re-resolves the
328
+ * archetype and row each time — a structural mutation between two `at()` calls
329
+ * cannot make it read the wrong entity. Only the window between one `at()` and
330
+ * the field accesses following it must be free of structural mutation.
331
+ */
332
+ cursor<S extends ComponentSchema>(def: ComponentDef<S>): ComponentCursor<S>;
333
+ /** Read-only {@link cursor}: no change-tick stamp on `at()`. Advisory only —
334
+ * same caveat as `refRead` (the setters exist on the shared prototype). */
335
+ cursorRead<S extends ComponentSchema>(def: ComponentDef<S>): ReadonlyComponentCursor<S>;
336
+ /** Total sibling of {@link getField}: `undefined` when the
302
337
  * entity is dead or doesn't hold the component, instead of a dev throw /
303
338
  * prod garbage read. The safe way to probe-and-read in one call:
304
339
  * `ecs.tryGetField(e, Health, "current") ?? 0`. */
@@ -327,7 +362,16 @@ export declare class ECS implements QueryResolver {
327
362
  */
328
363
  query<T extends ComponentDef[]>(...defs: T): Query<T>;
329
364
  _nextQueryId(): number;
330
- /** QueryResolver implementation — creates or retrieves a cached Query. */
365
+ /** QueryResolver implementation — creates or retrieves a cached Query.
366
+ *
367
+ * **Mask ownership: borrowed.** The three mask arguments are read, never
368
+ * retained — the mint path copies each one into the `Query`, into the dedup
369
+ * entry, and (via `Store.registerQuery`) into the registered-query record.
370
+ * So callers may pass a scratch mask they intend to reuse (`ecs.query`) or
371
+ * a live mask they still own (`Query.and` / `.without` / `.anyOf` pass
372
+ * `this._include` etc.). Do NOT add a caller-side `.copy()` "for safety":
373
+ * on the cache-hit path that is a per-call BitSet + `number[]` allocation
374
+ * for nothing. */
331
375
  _resolveQuery(include: BitSet, exclude: BitSet | null, anyOf: BitSet | null, defs: readonly ComponentDef[]): Query<any>;
332
376
  /**
333
377
  * Register a system and get its scheduling handle. The config form is the
@@ -392,7 +436,7 @@ export declare class ECS implements QueryResolver {
392
436
  * whole set in one `extendColumnStore` call. Observers carry the same
393
437
  * access shape systems do (a synthesized `SystemDescriptor`), so an
394
438
  * observer that spawns/transitions gets its target archetype prewarmed
395
- * too rather than first-touching lazily mid-tick (#768). Exposed as
439
+ * too rather than first-touching lazily mid-tick. Exposed as
396
440
  * `private` because the only caller is `startup()`; visible to tests via
397
441
  * the `archetype_count` delta on the public ECS facade. */
398
442
  private prewarmArchetypes;
@@ -414,7 +458,7 @@ export declare class ECS implements QueryResolver {
414
458
  */
415
459
  update(dt: number): void;
416
460
  dispose(): void;
417
- /** Register an archetype template (#462). Resolves the component set +
461
+ /** Register an archetype template. Resolves the component set +
418
462
  * default field values to a target archetype once (creating it if absent —
419
463
  * fits the prewarm model), so later `spawn` / `spawnMany` calls land
420
464
  * entities directly in that archetype with **zero archetype transitions**.
@@ -428,18 +472,17 @@ export declare class ECS implements QueryResolver {
428
472
  * store's entry shape, so it lives here with the other real logic, not in the
429
473
  * delegation band. The big win is multi-component entities and bulk spawns; a
430
474
  * single-component spawn is no faster than `spawn` + `addComponent`, which
431
- * already bump-allocates a fresh entity into the target archetype. See
432
- * ADR-0010. */
475
+ * already bump-allocates a fresh entity into the target archetype. */
433
476
  template<Items extends readonly BundleOrDef[]>(...items: StrictBundles<Items>): Template<DefsOf<Items>>;
434
477
  /** Resolve a consumer-declared SAB region's byte offset by `region_id`, or
435
- * 0 when absent. Generic, de-gamed replacement (#623) for the removed
478
+ * 0 when absent. Generic, de-gamed replacement for the removed
436
479
  * game-named accessors; pair with the consumer's own region module to
437
480
  * materialise a typed view. Delegates to `Store.regionOffset`. */
438
481
  regionOffset(regionId: number): number;
439
482
  /** A handle (`{ buffer, view, offset, bytes }`) to a consumer-declared SAB
440
483
  * region resolved by `region_id`, or `null` when absent. A consumer's
441
484
  * region module builds a TypedArray view over the region's span from this.
442
- * Re-fetch after a SAB grow. Delegates to `Store.regionHandle`. (#623) */
485
+ * Re-fetch after a SAB grow. Delegates to `Store.regionHandle`. */
443
486
  regionHandle(regionId: number): ColumnStoreRegionHandle | null;
444
487
  /** Look up the field index a component reserves for `fieldName`. The
445
488
  * index is assigned by `registerComponent` in insertion order and is
@@ -451,18 +494,17 @@ export declare class ECS implements QueryResolver {
451
494
  * A WASM system that drains events from the event ring as
452
495
  * `(archId, row, …)` payloads uses this to convert the (archId, row)
453
496
  * pair into the `EntityID` the `ctx.emit(...)` API expects.
454
- * Throws if the (archId, row) pair is out of range. (#250 / Phase 4
455
- * PR 4D) */
497
+ * Throws if the (archId, row) pair is out of range. */
456
498
  entityIdAtRow(archetypeId: number, row: number): EntityID;
457
499
  /** The single SAB backing every archetype's column views. Exposed for
458
500
  * snapshot/restore, `columnStoreStateHash`-based determinism checks, and
459
- * Phase 2+ WASM/worker hand-off paths. Mutation flows through the
501
+ * WASM/worker hand-off paths. Mutation flows through the
460
502
  * usual `addComponent` / `removeComponent` / `flush` APIs; readers
461
503
  * that hold a column view across a grow must consult
462
- * `header.view_stamp` to detect a republish (#171 §8.1). */
504
+ * `header.view_stamp` to detect a republish. */
463
505
  get columnStore(): ColumnStore;
464
506
  /** Count of live archetypes (including the empty one). Surfaces the
465
- * Store-side `archetype_count` so Phase C tests can assert the
507
+ * Store-side `archetype_count` so tests can assert the
466
508
  * pre-warmed closure was materialised; equally useful for diagnostics. */
467
509
  get archetypeCount(): number;
468
510
  registerTag(): ComponentDef<Record<string, never>>;
@@ -484,24 +526,24 @@ export declare class ECS implements QueryResolver {
484
526
  /** Current ECS write tick — the tick `eachChunk` stamps via `cols.mut` (§eachChunk). */
485
527
  _getCurrentTick(): number;
486
528
  _getQueryDirtyEpoch(): number;
487
- /** QueryResolver implementation — sparse-membership match path (#469). */
529
+ /** QueryResolver implementation — sparse-membership match path. */
488
530
  _forEachSparseMatch(include: BitSet, exclude: BitSet | null, anyOf: BitSet | null, sparseInclude: readonly SparseComponentID[], sparseExclude: readonly SparseComponentID[], denseArchetypes: readonly Archetype[], cb: (entityId: EntityID) => void, includeDisabled: boolean): void;
489
531
  /** QueryResolver implementation — backing sparse id of a relation, for the
490
- * `(R, *)` wildcard term (`Query.withRelation`, #579). */
532
+ * `(R, *)` wildcard term (`Query.withRelation`). */
491
533
  _relationBackingSparseId(def: RelationDef): SparseComponentID;
492
- /** QueryResolver implementation — `(*, T)` wildcard match path (#579). */
534
+ /** QueryResolver implementation — `(*, T)` wildcard match path. */
493
535
  _forEachRelationTargetMatch(target: EntityID, include: BitSet, exclude: BitSet | null, anyOf: BitSet | null, sparseInclude: readonly SparseComponentID[], sparseExclude: readonly SparseComponentID[], includeDisabled: boolean, cb: (entityId: EntityID) => void): void;
494
- /** QueryResolver implementation — depth-ordered hierarchy match path (#581). */
536
+ /** QueryResolver implementation — depth-ordered hierarchy match path. */
495
537
  _forEachHierarchyMatch(include: BitSet, exclude: BitSet | null, anyOf: BitSet | null, sparseInclude: readonly SparseComponentID[], sparseExclude: readonly SparseComponentID[], denseArchetypes: readonly Archetype[], relation: RelationDef, maxDepth: number, includeDisabled: boolean, cb: (entityId: EntityID) => void): void;
496
538
  addSystems(label: SCHEDULE, ...entries: (SystemDescriptor | SystemEntry)[]): this;
497
539
  /**
498
- * Configure a `SystemSet` (#576) — the shared run condition and/or ordering
540
+ * Configure a `SystemSet` — the shared run condition and/or ordering
499
541
  * every member inherits. Additive and order-independent with respect to
500
542
  * `addSystems`: see `Schedule.configureSet`. Returns `this` to chain.
501
543
  */
502
544
  configureSet(set: SystemSet, config: SystemSetConfig): this;
503
545
  /**
504
- * Register a per-component observer (#517 §1 / ADR-0013). Reactions that were
546
+ * Register a per-component observer. Reactions that were
505
547
  * hand-polled every tick — "on `Death` added → spawn corpse", "on `HexPos`
506
548
  * set → mark the spatial index" — become declarative.
507
549
  *
@@ -511,8 +553,8 @@ export declare class ECS implements QueryResolver {
511
553
  * cascades settle. Determinism: a `stateHash` replay reproduces regardless
512
554
  * of the order ops were queued.
513
555
  * - **`onDisable` / `onEnable`** `(eid, ctx)` fire at the same flush boundary
514
- * when an entity carrying the component is *disabled* / *enabled* (#577,
515
- * ADR-0023), once per net transition, for every component the entity carries
556
+ * when an entity carrying the component is *disabled* / *enabled*, once
557
+ * per net transition, for every component the entity carries
516
558
  * (a disable is a soft remove of the whole mask from default queries). Like
517
559
  * `onAdd`/`onRemove`, an *immediate* `ecs.disable()` does not fire — only
518
560
  * the deferred `ctx.commands.disable()` toggle does. `yieldExisting` seeds enabled
@@ -550,10 +592,10 @@ export declare class ECS implements QueryResolver {
550
592
  publishArchetypeRowCounts(): void;
551
593
  flush(): void;
552
594
  }
553
- /** Phase C of issue #213 — archetype closure from a descriptor set.
595
+ /** Archetype closure from a descriptor set.
554
596
  *
555
597
  * Each descriptor is a system or an observer's synthesized `SystemDescriptor`
556
- * (#768) — both carry `spawns` + `transitions`. Seeds the worklist with every
598
+ * — both carry `spawns` + `transitions`. Seeds the worklist with every
557
599
  * descriptor's `spawns`; iteratively applies every descriptor's `transitions`
558
600
  * to every discovered mask whose components cover the transition's `whenHas`.
559
601
  * Returns the union of seeds + reachable targets, deduplicated by hash-bucketed
@@ -566,7 +608,7 @@ export declare class ECS implements QueryResolver {
566
608
  * tiny — ~20 masks at most), the worklist is finite and we exit when it
567
609
  * empties.
568
610
  *
569
- * Liberal `whenHas` per design doc §6.6 — over-approximation is fine; an
611
+ * Liberal `whenHas` — over-approximation is fine; an
570
612
  * unreachable transition target costs one descriptor row at the SAB tail,
571
613
  * not column bytes. Empty `spawns` + `transitions` short-circuit to zero.
572
614
  */