@spellkave/sdk 0.0.0-stage → 0.1.0

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 (144) hide show
  1. package/LICENSE +89 -0
  2. package/README.md +155 -2
  3. package/package.json +63 -4
  4. package/src/binding_rows.ts +186 -0
  5. package/src/connection.ts +964 -0
  6. package/src/core/actor.ts +62 -0
  7. package/src/core/actor_control.ts +193 -0
  8. package/src/core/actor_control_query_methods.ts +101 -0
  9. package/src/core/actor_control_reaction_methods.ts +79 -0
  10. package/src/core/actor_control_sense_methods.ts +81 -0
  11. package/src/core/actor_control_source.ts +57 -0
  12. package/src/core/actor_session_methods.ts +226 -0
  13. package/src/core/binding_drift.ts +301 -0
  14. package/src/core/credential.ts +259 -0
  15. package/src/core/driver_control.ts +54 -0
  16. package/src/core/effective_environment_state.ts +71 -0
  17. package/src/core/factored_manipulation_attempt.ts +158 -0
  18. package/src/core/ids.ts +60 -0
  19. package/src/core/interaction/canonical.ts +15 -0
  20. package/src/core/interaction/fingerprint.ts +118 -0
  21. package/src/core/interaction/index.ts +31 -0
  22. package/src/core/interaction/intent.ts +284 -0
  23. package/src/core/interaction/outcome.ts +67 -0
  24. package/src/core/interaction/rejection_ledger.ts +108 -0
  25. package/src/core/kernel_contract.generated.ts +10 -0
  26. package/src/core/log.ts +23 -0
  27. package/src/core/movement.ts +111 -0
  28. package/src/core/node-io.ts +208 -0
  29. package/src/core/paths.ts +220 -0
  30. package/src/core/profile.ts +270 -0
  31. package/src/core/profiles.ts +9 -0
  32. package/src/core/provenance_buffer.ts +102 -0
  33. package/src/core/readers/_helpers.ts +273 -0
  34. package/src/core/readers/action_description.ts +17 -0
  35. package/src/core/readers/action_economy_events.ts +149 -0
  36. package/src/core/readers/actor_body_swaps.ts +62 -0
  37. package/src/core/readers/actor_snapshot.ts +197 -0
  38. package/src/core/readers/actor_states.ts +163 -0
  39. package/src/core/readers/actors_and_bodies.ts +179 -0
  40. package/src/core/readers/affordance_cue.ts +59 -0
  41. package/src/core/readers/affordance_defaults.ts +158 -0
  42. package/src/core/readers/affordance_group_membership.ts +67 -0
  43. package/src/core/readers/affordance_input.ts +129 -0
  44. package/src/core/readers/affordance_reference.ts +41 -0
  45. package/src/core/readers/apply_consequences.ts +54 -0
  46. package/src/core/readers/audience_trace_presentation.ts +62 -0
  47. package/src/core/readers/bounded_collection.ts +29 -0
  48. package/src/core/readers/bundle_definitions.ts +74 -0
  49. package/src/core/readers/bundle_entities.ts +62 -0
  50. package/src/core/readers/co_location.ts +71 -0
  51. package/src/core/readers/combat_session.ts +124 -0
  52. package/src/core/readers/combat_session_active.ts +44 -0
  53. package/src/core/readers/combat_session_feedback.ts +37 -0
  54. package/src/core/readers/combat_session_grid.ts +117 -0
  55. package/src/core/readers/combat_session_roster.ts +98 -0
  56. package/src/core/readers/combat_session_types.ts +51 -0
  57. package/src/core/readers/condition_deltas.ts +53 -0
  58. package/src/core/readers/container_contents.ts +92 -0
  59. package/src/core/readers/dialogue_guide.ts +99 -0
  60. package/src/core/readers/dialogue_prompt_presentation.ts +90 -0
  61. package/src/core/readers/driver_control.ts +64 -0
  62. package/src/core/readers/entity_art.ts +219 -0
  63. package/src/core/readers/entity_containment.ts +119 -0
  64. package/src/core/readers/equipment.ts +99 -0
  65. package/src/core/readers/intervention_windows.ts +136 -0
  66. package/src/core/readers/inventory_query.ts +145 -0
  67. package/src/core/readers/item_detail.ts +198 -0
  68. package/src/core/readers/location_snapshot.ts +216 -0
  69. package/src/core/readers/manifest_apply_provenance.ts +32 -0
  70. package/src/core/readers/manifest_export.ts +81 -0
  71. package/src/core/readers/manipulation_context.ts +475 -0
  72. package/src/core/readers/map_layers.ts +49 -0
  73. package/src/core/readers/metadata_rows.ts +56 -0
  74. package/src/core/readers/object_state.ts +124 -0
  75. package/src/core/readers/observer_knowledge.ts +41 -0
  76. package/src/core/readers/observer_place_knowledge.ts +37 -0
  77. package/src/core/readers/observer_trace_knowledge.ts +45 -0
  78. package/src/core/readers/outcome_template.ts +41 -0
  79. package/src/core/readers/place_topology.ts +109 -0
  80. package/src/core/readers/reaction_options.ts +156 -0
  81. package/src/core/readers/resource_deltas.ts +47 -0
  82. package/src/core/readers/scene.ts +275 -0
  83. package/src/core/readers/seats.ts +33 -0
  84. package/src/core/readers/self.ts +245 -0
  85. package/src/core/readers/self_capabilities.ts +159 -0
  86. package/src/core/readers/self_economy.ts +101 -0
  87. package/src/core/readers/self_economy_budget.ts +93 -0
  88. package/src/core/readers/self_evaluations.ts +128 -0
  89. package/src/core/readers/self_identity.ts +104 -0
  90. package/src/core/readers/sense_context.ts +112 -0
  91. package/src/core/readers/session.ts +207 -0
  92. package/src/core/readers/session_detail.ts +211 -0
  93. package/src/core/readers/session_status.ts +68 -0
  94. package/src/core/readers/spatial_environment_state.ts +74 -0
  95. package/src/core/readers/spatial_niche_attachments.ts +28 -0
  96. package/src/core/readers/substrate_definitions.ts +27 -0
  97. package/src/core/readers/suggest_next_action.ts +72 -0
  98. package/src/core/readers/surface_membership.ts +78 -0
  99. package/src/core/readers/tag_reads.ts +54 -0
  100. package/src/core/readers/trace_query.ts +120 -0
  101. package/src/core/readers/trace_response.ts +80 -0
  102. package/src/core/readers/traces.ts +124 -0
  103. package/src/core/readers/travel_session.ts +88 -0
  104. package/src/core/readers/turn_state.ts +34 -0
  105. package/src/core/readers/world_events.ts +43 -0
  106. package/src/core/readers/world_status.ts +63 -0
  107. package/src/core/reducers/manipulation_args.ts +239 -0
  108. package/src/core/reducers/manipulation_receipt.ts +66 -0
  109. package/src/core/reducers/r_actor_wake_up.ts +32 -0
  110. package/src/core/reducers/r_inscribe_trace.ts +109 -0
  111. package/src/core/reducers/r_manipulate.ts +163 -0
  112. package/src/core/reducers/r_move.ts +155 -0
  113. package/src/core/reducers/r_react.ts +143 -0
  114. package/src/core/reducers/r_release_claim.ts +81 -0
  115. package/src/core/reducers/r_sense.ts +84 -0
  116. package/src/core/reducers/r_session_close.ts +130 -0
  117. package/src/core/reducers/r_session_move.ts +116 -0
  118. package/src/core/reducers/r_session_open.ts +91 -0
  119. package/src/core/reducers/session_lookup.ts +64 -0
  120. package/src/core/reducers/tick.ts +65 -0
  121. package/src/core/reducers/trace_lookup.ts +29 -0
  122. package/src/core/reducers/transport.ts +84 -0
  123. package/src/core/resolve.ts +228 -0
  124. package/src/core/shape_telemetry.ts +146 -0
  125. package/src/core/snapshot_rows.ts +109 -0
  126. package/src/core/tick_cadence.ts +61 -0
  127. package/src/core/types.ts +501 -0
  128. package/src/core/watch_provenance.ts +113 -0
  129. package/src/core/world-contract/classify.ts +38 -0
  130. package/src/core/world-contract/index.ts +12 -0
  131. package/src/core/world-contract/normalise.ts +574 -0
  132. package/src/core/world-contract/runtime.ts +144 -0
  133. package/src/core/world-contract/served.ts +173 -0
  134. package/src/core/world-contract/strict-reducers.ts +14 -0
  135. package/src/core/world-contract/typetext.ts +94 -0
  136. package/src/core/world_time.ts +22 -0
  137. package/src/index.ts +262 -0
  138. package/src/manifest-apply.ts +497 -0
  139. package/src/provenance.ts +568 -0
  140. package/src/reader-manifest.ts +338 -0
  141. package/src/readers.ts +392 -0
  142. package/src/replay.ts +515 -0
  143. package/src/watch-buffer.ts +438 -0
  144. package/src/world-events/builder.ts +1042 -0
@@ -0,0 +1,338 @@
1
+ // Host-neutral reader table manifests.
2
+ //
3
+ // Reader modules import this file at module load time to declare the tables they
4
+ // consume. Keep it free of live SpacetimeDB connection imports so pure replay
5
+ // bundles can use reader modules without pulling connection/reducer surfaces.
6
+
7
+ export type { SnapshotDb } from "./replay";
8
+
9
+ // Always-subscribed session singletons every reader implicitly depends on.
10
+ // Never declared by individual reader manifests — declaring them per-reader
11
+ // would be noise (D5, design.md:138-143).
12
+ export const CONNECTION_BASELINE = [
13
+ "config",
14
+ "world_time",
15
+ "directly_controlled_actor_spatial_location",
16
+ ] as const;
17
+
18
+ // Tables contributed by reader manifests (D2). Each reader that consumes one
19
+ // of these must declare it in its own `requiredTables` export. The D2
20
+ // completeness CI gate asserts every entry here has at least one declaring
21
+ // reader — silent dead subscriptions are a build error, not a runtime surprise.
22
+ export const READER_SCOPED_TABLES = [
23
+ // `world_event` is private (#915 PR-8); the per-caller
24
+ // `visible_world_event` dispatch view is the read model.
25
+ "visible_world_event",
26
+ // event_apply_consequence / event_resource_delta / event_actor_body_swapped
27
+ // are private (ADR-0120, #915); readers declare the visible_* views below.
28
+ "visible_event_apply_consequence",
29
+ "visible_event_resource_delta",
30
+ // event_condition_delta is private (ADR-0120, K-B Part B); the per-caller
31
+ // visible_event_condition_delta view is the read model (same shape as
32
+ // visible_event_resource_delta above).
33
+ "visible_event_condition_delta",
34
+ "visible_event_actor_body_swapped",
35
+ "event_channel_spend",
36
+ "event_boundary_fired",
37
+ "event_channel_window_refresh",
38
+ "event_action_recharge_fired",
39
+ "visible_condition_boundary_expiry",
40
+ // `economy_channel_spend` is private (ADR-0120, #915); the per-caller
41
+ // `visible_economy_channel_spend` view is the current-window standing read
42
+ // model (#2083/#2096) — cumulative `spent_ms`/`window_start_ms` per
43
+ // channel, distinct from `event_channel_spend`'s per-spend delta above.
44
+ "visible_economy_channel_spend",
45
+ "visible_economy_channel_budget",
46
+ "actor",
47
+ // `actor_identity` is private (#915 PR-5, ADR-0084 D-5 Family 1); the
48
+ // self-only view is what readers actually declare/subscribe.
49
+ "visible_actor_identity",
50
+ "visible_actor_driver_control",
51
+ "visible_actor_control_transition",
52
+ "visible_control_continuation",
53
+ "visible_control_continuation_refusal",
54
+ "visible_event_steering",
55
+ // `seat`: public playable-seat catalog (sk-pka5.4, ADR-0102 D-2) — playable /
56
+ // embodied / claimed per actor, never the occupant identity; declared by
57
+ // core/readers/seats.ts (readSeats).
58
+ "seat",
59
+ "visible_actor_spatial_location",
60
+ "entity",
61
+ "owned_object_state",
62
+ "visible_object_state",
63
+ "visible_target_condition",
64
+ "visible_manifest_authored_entity",
65
+ "visible_manifest_authored_entity_coverage",
66
+ "visible_place_node",
67
+ "visible_place_edge",
68
+ "visible_place_graph_definition",
69
+ "visible_map_layer",
70
+ // Public substrate catalog (indoor/outdoor class via coordinate_kind_id).
71
+ // Declared by core/readers/substrate_definitions.ts for OSM export (ADR-0123).
72
+ "substrate_definition",
73
+ // visible_turn_state: per-caller view over the private turn-scheduler
74
+ // singleton (sk-jay0.6.15.56.16.12.5.2.1; the raw `turn_state` moved here
75
+ // from REPLAY_PANEL_TABLES under ADR-0093 D-6) — `readTurnState`
76
+ // (core/readers/turn_state.ts) is its declaring reader. session_participant
77
+ // is private (ADR-0057, sk-2qt); clients subscribe visible_session_participant
78
+ // (session.ts, combat_session.ts).
79
+ "visible_turn_state",
80
+ "visible_session_participant",
81
+ // "item" / "item_location" / "entity_inventory" / "manifest_authored_item" —
82
+ // removed; dissolved in Phase 2 entity-unification (Items 3, 5, 13).
83
+ // Items are now entity rows accessed via "visible_manifest_authored_entity".
84
+ "action_definition",
85
+ // ADR-0141: per-perceiver lifecycle/readiness generation and independently
86
+ // disclosed action/target/participant facts for direct manipulation.
87
+ "visible_manipulation_context",
88
+ "visible_manipulation_available_action",
89
+ "visible_manipulation_observed_target",
90
+ "visible_manipulation_participant_context",
91
+ "visible_manipulation_participant_binding",
92
+ // ADR-0142 D-6: per-perceiver dialogue-prompt projection.
93
+ "visible_manipulation_prompt",
94
+ "visible_prompt_occurrence",
95
+ "affordance_template",
96
+ // `niche_definition` is public (actor-carried-verbs D1/D2); the `provider`
97
+ // column names WHO offers the niche (`place`/`entity`/`actor`, empty =
98
+ // `place` — `resolve_niche_provider`). Read for the affordances reader's
99
+ // `provider` join (ledger/designs/play-interaction-axioms.md W1).
100
+ "niche_definition",
101
+ // Provider flags are the authored, open classification used by direct
102
+ // manipulation-context readers to rank separately disclosed niche facts.
103
+ "niche_provider_definition",
104
+ // outcome_template: public Layer-3 definition table (like action_definition
105
+ // above), read for its `description` column — the authored source of the
106
+ // PLAYER manipulate/sensing observation narrative (#1968 B-9).
107
+ "outcome_template",
108
+ "visible_evaluation_provenance",
109
+ // `pending_resolution` and its reactor working-set are private (ADR-0120);
110
+ // subscribe the per-caller views.
111
+ "visible_pending_resolution",
112
+ "visible_pending_resolution_reactor",
113
+ // The frozen stochastic-draw extension row for a parked pending_resolution
114
+ // (post-roll intervention windows, #2058) — private, per-caller view.
115
+ "visible_pending_stochastic_resolution",
116
+ "reservation",
117
+ // `session` is private (ADR-0057, sk-2qt); the per-caller
118
+ // `visible_session` view is the participation-bounded read model.
119
+ "visible_session",
120
+ // Public authored turn semantics; runtime session state stays participant-scoped.
121
+ "session_definition",
122
+ // entity_tag / action_definition_tag: relational + action tags. Subscribed so
123
+ // a host can read author-given tags (faction:*, combat/attack:*) for NPC-bot
124
+ // decisioning without coupling to the raw binding accessor (world-explorer).
125
+ "visible_entity_tag",
126
+ "visible_entity_tag_coverage",
127
+ "action_definition_tag",
128
+ // `observer_knowledge` / `observer_place_knowledge` / `observer_trace_knowledge`
129
+ // are private (ADR-0120, #915 sweep PR-2); the per-caller `visible_*` views
130
+ // are the perception-bounded read models.
131
+ "visible_observer_knowledge",
132
+ "visible_observer_place_knowledge",
133
+ "visible_observer_trace_knowledge",
134
+ // `trace` is private (ADR-0120, #915); the per-caller `visible_trace` view is
135
+ // the perception-bounded read model.
136
+ "visible_trace",
137
+ "capability_definition",
138
+ // visible_capability: per-caller view (ADR-0120) over entity-bound
139
+ // capability grants — subscribed so a player can perceive their own
140
+ // trained capabilities (finding #11).
141
+ "visible_capability",
142
+ // `entity_equipment_slot` is private (ADR-0120, #915 PR-6); the per-caller
143
+ // `visible_entity_equipment_slot` view is the owner/DM-extent-bounded read
144
+ // model.
145
+ "visible_entity_equipment_slot",
146
+ "equipment_slot_definition",
147
+ "resource_definition",
148
+ // resource_definition_tag: authored tags on a pool definition (quest, currency,
149
+ // …). Subscribed so readActorStates can surface a pool's tags — letting a player
150
+ // perceive a `quest`-tagged objective on its own sheet (#1229).
151
+ "resource_definition_tag",
152
+ // entity_definition_tag: authored tags on an entity's definition (species,
153
+ // class, background, …). Subscribed so readSelfSummary can surface an
154
+ // actor's own identity tags — the SAME pattern as resource_definition_tag
155
+ // above, applied to the sibling entity-definition tag table (#2094).
156
+ "entity_definition_tag",
157
+ "tag_capability_grant",
158
+ // visible_entity_containment: post Phase 2 (entity-unification), items carried in
159
+ // actor inventory appear here. Subscribed so SDK readers can expose
160
+ // inventory state without coupling scripts to the raw binding accessor.
161
+ "visible_entity_containment",
162
+ "entity_description",
163
+ // spatial_environment_state: room/edge-topology env-state (ADR-0056), the
164
+ // carrier for the ActorReachableNodes N-hop fanout (ADR-0076). Private
165
+ // (ADR-0120, #915 sweep PR-4); the per-caller visible_* view is the
166
+ // bounded read model.
167
+ "visible_spatial_environment_state",
168
+ "visible_spatial_niche_attachment",
169
+ // metadata_attachment is private (ADR-0130 D-1); clients read through
170
+ // these two play views instead — `readMetadataAttachmentRows`
171
+ // (`core/readers/metadata_rows.ts`) unions them. Subscribed so
172
+ // `readSurfaceMembership` can join `ui.self_summary` slot/order
173
+ // membership onto `resource_definition` rows for `readSelfSummary`'s
174
+ // `vitals`/`quest` buckets (#2119) — the same "authored data, not a
175
+ // magic literal" pattern as `resource_definition_tag` above.
176
+ "public_metadata_attachment",
177
+ "visible_metadata_attachment",
178
+ // tag_value_definition: public bundle-authored catalog for exact tag
179
+ // values (prefix + description). Subscribed so `readSelfIdentity` can
180
+ // enrich an actor's own `entity_definition_tag` rows with authored
181
+ // discovery prose (#2119 identity-out-of-summary move) — the detailed
182
+ // "who am I" now living at `self_states kind=identity`.
183
+ "tag_value_definition",
184
+ ] as const;
185
+
186
+ // Known table names used by replay and panel manifests that are not part of the
187
+ // reader-scoped subscription baseline. Keep them out of READER_SCOPED_TABLES so
188
+ // the baseline-consumer gate still catches dead live subscriptions.
189
+ export const REPLAY_PANEL_TABLES = [
190
+ // Public AUTHOR explain vocabulary; opted in by its catalog reader manifest.
191
+ "role_definition",
192
+ "role_aggregation",
193
+ "visible_role_binding",
194
+ "grant_inventory",
195
+ "visible_place_seal",
196
+ "visible_place_seal_break",
197
+ "extent_kind_definition",
198
+ "area_shape_definition",
199
+ "visible_autonomy_job",
200
+ // Direct arbitration participants opt into their recipient-authorized payloads.
201
+ "visible_arbitration_request",
202
+ "visible_arbitration_response",
203
+ "visible_arbitration_rejection",
204
+ "visible_arbitration_fallback",
205
+ "coordinate_kind_definition",
206
+ "event_autonomy_job",
207
+ "place_edge_affordance",
208
+ "visible_entity_location",
209
+ "notable_events",
210
+ "visible_event_create_entity",
211
+ "visible_event_move",
212
+ "visible_event_take",
213
+ "visible_event_drop",
214
+ "mod_bundle",
215
+ // manifest_apply_digest / manifest_apply_outcome: drain-wait bookkeeping
216
+ // (`connectTestWorld`'s `MANIFEST_SETUP_READER_MANIFEST` in `test-lab/live.ts`
217
+ // plus sk/Pi/live-delta apply waiters, sk-0m4.45). Not a domain reader's
218
+ // dependency — kept here rather than READER_SCOPED_TABLES.
219
+ "manifest_apply_digest",
220
+ // Private baseline memory is exposed only through exact-publisher views.
221
+ "operator_manifest_applyset",
222
+ "operator_manifest_applyset_part",
223
+ "operator_manifest_applyset_export_hash",
224
+ "manifest_apply_outcome",
225
+ // Runtime-rendering DM seats validate authored deltas against these public
226
+ // definition catalogs through a live AuthorTarget. Item detail also requests
227
+ // entity/object-state definitions for authorized inventory prose and labels.
228
+ // Reader manifests opt into these catalogs; the static baseline is unchanged.
229
+ "entity_definition",
230
+ "object_state_definition",
231
+ // Authorized self-condition detail joins manifest-authored explanation text.
232
+ "condition_definition",
233
+ "modifier_target_definition",
234
+ "dsl_macro_definition",
235
+ // public_reference_metadata (ADR-0130 D-5/D-6): the `on_demand` public
236
+ // view — rules text, creation data, docs. Play sessions never subscribe
237
+ // it by default (D-4's whole point); reference consumers (character
238
+ // creation, advancement, authoring tools) opt in explicitly, same
239
+ // "reader manifests opt into these catalogs" pattern as the definition
240
+ // catalogs above.
241
+ "public_reference_metadata",
242
+ // Seeded namespace vocabulary for runtime author validation.
243
+ "metadata_namespace_definition",
244
+ // ADR-0149 export view. Known so the reader may declare it. Not in the
245
+ // strict baseline: connection.ts subscribes it only when the module lists it.
246
+ "visible_observed_container_content",
247
+ "visible_observed_container_coverage",
248
+ "visible_manifest_export_result",
249
+ "visible_manifest_apply_provenance",
250
+ // Applyset prune D-8: definition seeds for the expected-set of a retracted entity.
251
+ "entity_definition_initial_state",
252
+ "entity_definition_initial_capability",
253
+ "entity_definition_initial_condition",
254
+ "entity_definition_initial_containment",
255
+ "entity_definition_initial_equipment",
256
+ ] as const;
257
+
258
+ /** Full subscription union. Temporary compat export — will be removed once
259
+ * Session.connect() issues a single subscription from the manifest union. */
260
+ export const SUBSCRIBED_TABLES = [...CONNECTION_BASELINE, ...READER_SCOPED_TABLES] as const;
261
+
262
+ export const KNOWN_TABLES = [...SUBSCRIBED_TABLES, ...REPLAY_PANEL_TABLES] as const;
263
+
264
+ export const STRICT_TABLES = [...CONNECTION_BASELINE, ...READER_SCOPED_TABLES] as const;
265
+
266
+ /** Union of every subscribable table name known to this SDK. */
267
+ export type TableName = (typeof KNOWN_TABLES)[number];
268
+
269
+ /** Identity constraint: forces each entry in a `requiredTables` declaration
270
+ * to be a known `TableName`, catching typos at the declaration site. */
271
+ export type RequiredTables<T extends readonly TableName[]> = T;
272
+
273
+ export interface ReaderManifest {
274
+ requiredTables: readonly TableName[];
275
+ }
276
+
277
+ const _registeredManifests: ReaderManifest[] = [];
278
+
279
+ /** Register a reader's table manifest. Called at module load time by each
280
+ * reader file. Phase 2 per-reader files call this; Phase 1 registry is empty. */
281
+ export function registerReaderManifest(manifest: ReaderManifest): void {
282
+ _registeredManifests.push(manifest);
283
+ }
284
+
285
+ /** Union of all tables declared by registered reader manifests. */
286
+ export function getRegisteredReaderTables(): Set<string> {
287
+ const result = new Set<string>();
288
+ for (const m of _registeredManifests) {
289
+ for (const t of m.requiredTables) {
290
+ result.add(t);
291
+ }
292
+ }
293
+ return result;
294
+ }
295
+
296
+ /**
297
+ * The reader-table union `buildSubscribeSet()` (`connection.ts`) uses when a
298
+ * caller passes NO `readerManifests` at all: `READER_SCOPED_TABLES` (the
299
+ * hand-curated catalog the D2 completeness gate keeps in sync with every
300
+ * reader's own declaration) unioned with `getRegisteredReaderTables()` (which
301
+ * additionally carries tables a reader declares but that live outside that
302
+ * curated list, e.g. `place_edge_affordance` via `scene.ts`).
303
+ *
304
+ * Exported so a caller that DOES need its own `readerManifests` — to widen
305
+ * the subscription with a few extra tables on top of the default, e.g.
306
+ * `WATCH_BUFFER_REQUIRED_TABLES` — can start from this instead of hand-
307
+ * copying `READER_SCOPED_TABLES` (drifts silently) or, worse, supplying an
308
+ * array with ONLY its own extra tables: `buildSubscribeSet` treats ANY
309
+ * supplied `readerManifests` as a total REPLACEMENT of the default union, not
310
+ * an addition to it (see that function's own doc comment and its "uses an
311
+ * explicit reader-manifest set instead of the full reader-scoped union" test)
312
+ * — a caller that forgets this silently narrows its own subscription to only
313
+ * what it explicitly listed, plus `CONNECTION_BASELINE`. That is exactly what
314
+ * happened to Play (sk-jay0.1.1.14 investigation of #3487): its `readerManifests`
315
+ * carried only `WATCH_BUFFER_REQUIRED_TABLES`, so `visible_place_node`,
316
+ * `visible_place_edge`, `place_edge_affordance` and every other default
317
+ * reader-scoped table were never subscribed, leaving `readCurrentScene`
318
+ * (`scene.ts`) permanently unable to resolve a scene for ANY actor.
319
+ */
320
+ export function defaultReaderManifest(): ReaderManifest {
321
+ return {
322
+ requiredTables: Array.from(
323
+ new Set<TableName>([
324
+ ...READER_SCOPED_TABLES,
325
+ ...(getRegisteredReaderTables() as Set<TableName>),
326
+ ]),
327
+ ),
328
+ };
329
+ }
330
+
331
+ /**
332
+ * Returns the names of any READER_SCOPED_TABLES entries not present in
333
+ * `declaredTables`. Used by the baseline-consumer CI gate (tasks.md 1.4):
334
+ * any missing entry means a subscribed table has no declaring reader.
335
+ */
336
+ export function findUndeclaredBaselineTables(declaredTables: ReadonlySet<string>): string[] {
337
+ return READER_SCOPED_TABLES.filter((t) => !declaredTables.has(t));
338
+ }