@spellkave/tool-contracts 0.0.0-bootstrap

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 (121) hide show
  1. package/LICENSE +89 -0
  2. package/package.json +50 -0
  3. package/src/admission.ts +62 -0
  4. package/src/authoring-schemas.ts +3491 -0
  5. package/src/authoring-tool-names.ts +46 -0
  6. package/src/contract-data.ts +37 -0
  7. package/src/contract-guard.ts +377 -0
  8. package/src/contracts-metadata.json +6940 -0
  9. package/src/docs-metadata.ts +42 -0
  10. package/src/exploration.ts +248 -0
  11. package/src/git-batch.ts +36 -0
  12. package/src/grant-schemas.ts +38 -0
  13. package/src/index.ts +10 -0
  14. package/src/metadata.ts +48 -0
  15. package/src/owner-instance-read.ts +123 -0
  16. package/src/personas.generated.json +47 -0
  17. package/src/personas.ts +19 -0
  18. package/src/roster.ts +13 -0
  19. package/src/scene-schemas.ts +29 -0
  20. package/src/schema-registry.ts +197 -0
  21. package/src/schemas.ts +786 -0
  22. package/src/snapshot-storage.ts +133 -0
  23. package/src/tool-contracts.breaking-acknowledged.json +392 -0
  24. package/src/tool-contracts.snapshot/index.json +104 -0
  25. package/src/tool-contracts.snapshot/rosters/AUTHOR.json +54 -0
  26. package/src/tool-contracts.snapshot/rosters/DM.json +19 -0
  27. package/src/tool-contracts.snapshot/rosters/PLAYER.json +25 -0
  28. package/src/tool-contracts.snapshot/tools/spellkave_acting_context.json +35 -0
  29. package/src/tool-contracts.snapshot/tools/spellkave_actor_principals.json +23 -0
  30. package/src/tool-contracts.snapshot/tools/spellkave_annotate_place.json +82 -0
  31. package/src/tool-contracts.snapshot/tools/spellkave_apply_manifest_delta.json +66 -0
  32. package/src/tool-contracts.snapshot/tools/spellkave_applyset_apply.json +131 -0
  33. package/src/tool-contracts.snapshot/tools/spellkave_applyset_diff.json +122 -0
  34. package/src/tool-contracts.snapshot/tools/spellkave_attach_map_layer.json +114 -0
  35. package/src/tool-contracts.snapshot/tools/spellkave_author_place.json +132 -0
  36. package/src/tool-contracts.snapshot/tools/spellkave_bind_actor.json +79 -0
  37. package/src/tool-contracts.snapshot/tools/spellkave_bind_edge_affordance.json +69 -0
  38. package/src/tool-contracts.snapshot/tools/spellkave_can_i.json +123 -0
  39. package/src/tool-contracts.snapshot/tools/spellkave_communicate.json +44 -0
  40. package/src/tool-contracts.snapshot/tools/spellkave_declare_inexpressible.json +33 -0
  41. package/src/tool-contracts.snapshot/tools/spellkave_define_action.json +133 -0
  42. package/src/tool-contracts.snapshot/tools/spellkave_define_action_verb.json +215 -0
  43. package/src/tool-contracts.snapshot/tools/spellkave_define_affordance.json +69 -0
  44. package/src/tool-contracts.snapshot/tools/spellkave_define_behavior.json +505 -0
  45. package/src/tool-contracts.snapshot/tools/spellkave_define_bundle.json +67 -0
  46. package/src/tool-contracts.snapshot/tools/spellkave_define_capability.json +64 -0
  47. package/src/tool-contracts.snapshot/tools/spellkave_define_condition.json +244 -0
  48. package/src/tool-contracts.snapshot/tools/spellkave_define_consequence.json +65 -0
  49. package/src/tool-contracts.snapshot/tools/spellkave_define_entity_type.json +199 -0
  50. package/src/tool-contracts.snapshot/tools/spellkave_define_niche.json +88 -0
  51. package/src/tool-contracts.snapshot/tools/spellkave_define_resource.json +93 -0
  52. package/src/tool-contracts.snapshot/tools/spellkave_define_roll_table.json +87 -0
  53. package/src/tool-contracts.snapshot/tools/spellkave_define_session.json +115 -0
  54. package/src/tool-contracts.snapshot/tools/spellkave_define_trace_kind.json +71 -0
  55. package/src/tool-contracts.snapshot/tools/spellkave_describe.json +73 -0
  56. package/src/tool-contracts.snapshot/tools/spellkave_diff.json +90 -0
  57. package/src/tool-contracts.snapshot/tools/spellkave_docs.json +104 -0
  58. package/src/tool-contracts.snapshot/tools/spellkave_end_turn.json +21 -0
  59. package/src/tool-contracts.snapshot/tools/spellkave_entity.json +32 -0
  60. package/src/tool-contracts.snapshot/tools/spellkave_entity_body.json +32 -0
  61. package/src/tool-contracts.snapshot/tools/spellkave_entity_container.json +32 -0
  62. package/src/tool-contracts.snapshot/tools/spellkave_equip_item.json +49 -0
  63. package/src/tool-contracts.snapshot/tools/spellkave_eval.json +87 -0
  64. package/src/tool-contracts.snapshot/tools/spellkave_events.json +30 -0
  65. package/src/tool-contracts.snapshot/tools/spellkave_explain.json +83 -0
  66. package/src/tool-contracts.snapshot/tools/spellkave_export.json +66 -0
  67. package/src/tool-contracts.snapshot/tools/spellkave_export_grants.json +50 -0
  68. package/src/tool-contracts.snapshot/tools/spellkave_get.json +87 -0
  69. package/src/tool-contracts.snapshot/tools/spellkave_grant_role.json +80 -0
  70. package/src/tool-contracts.snapshot/tools/spellkave_hand_over_role.json +89 -0
  71. package/src/tool-contracts.snapshot/tools/spellkave_intervention_windows.json +32 -0
  72. package/src/tool-contracts.snapshot/tools/spellkave_inventory.json +40 -0
  73. package/src/tool-contracts.snapshot/tools/spellkave_item_detail.json +37 -0
  74. package/src/tool-contracts.snapshot/tools/spellkave_link_places.json +84 -0
  75. package/src/tool-contracts.snapshot/tools/spellkave_list_grants.json +56 -0
  76. package/src/tool-contracts.snapshot/tools/spellkave_manipulate.json +84 -0
  77. package/src/tool-contracts.snapshot/tools/spellkave_manipulation_context.json +62 -0
  78. package/src/tool-contracts.snapshot/tools/spellkave_map.json +109 -0
  79. package/src/tool-contracts.snapshot/tools/spellkave_map_graph.json +143 -0
  80. package/src/tool-contracts.snapshot/tools/spellkave_move.json +75 -0
  81. package/src/tool-contracts.snapshot/tools/spellkave_note_doc_gap.json +43 -0
  82. package/src/tool-contracts.snapshot/tools/spellkave_observer_knowledge.json +32 -0
  83. package/src/tool-contracts.snapshot/tools/spellkave_observer_place_knowledge.json +32 -0
  84. package/src/tool-contracts.snapshot/tools/spellkave_observer_trace_knowledge.json +32 -0
  85. package/src/tool-contracts.snapshot/tools/spellkave_offer_control.json +30 -0
  86. package/src/tool-contracts.snapshot/tools/spellkave_orient.json +39 -0
  87. package/src/tool-contracts.snapshot/tools/spellkave_pace_time.json +59 -0
  88. package/src/tool-contracts.snapshot/tools/spellkave_place_actor.json +190 -0
  89. package/src/tool-contracts.snapshot/tools/spellkave_place_entity.json +190 -0
  90. package/src/tool-contracts.snapshot/tools/spellkave_prepare_hand_over.json +57 -0
  91. package/src/tool-contracts.snapshot/tools/spellkave_query.json +290 -0
  92. package/src/tool-contracts.snapshot/tools/spellkave_react_option.json +47 -0
  93. package/src/tool-contracts.snapshot/tools/spellkave_reaction_options.json +32 -0
  94. package/src/tool-contracts.snapshot/tools/spellkave_release_claim.json +32 -0
  95. package/src/tool-contracts.snapshot/tools/spellkave_remove_entity.json +39 -0
  96. package/src/tool-contracts.snapshot/tools/spellkave_render_scene.json +59 -0
  97. package/src/tool-contracts.snapshot/tools/spellkave_return_npc_control.json +59 -0
  98. package/src/tool-contracts.snapshot/tools/spellkave_revoke_role.json +55 -0
  99. package/src/tool-contracts.snapshot/tools/spellkave_scene.json +74 -0
  100. package/src/tool-contracts.snapshot/tools/spellkave_scene_detail.json +37 -0
  101. package/src/tool-contracts.snapshot/tools/spellkave_self_states.json +77 -0
  102. package/src/tool-contracts.snapshot/tools/spellkave_self_summary.json +21 -0
  103. package/src/tool-contracts.snapshot/tools/spellkave_sense.json +68 -0
  104. package/src/tool-contracts.snapshot/tools/spellkave_sense_context.json +28 -0
  105. package/src/tool-contracts.snapshot/tools/spellkave_session_close.json +71 -0
  106. package/src/tool-contracts.snapshot/tools/spellkave_session_move.json +38 -0
  107. package/src/tool-contracts.snapshot/tools/spellkave_session_open.json +36 -0
  108. package/src/tool-contracts.snapshot/tools/spellkave_session_status.json +41 -0
  109. package/src/tool-contracts.snapshot/tools/spellkave_set_metadata.json +205 -0
  110. package/src/tool-contracts.snapshot/tools/spellkave_set_movement_default.json +58 -0
  111. package/src/tool-contracts.snapshot/tools/spellkave_stage_scene.json +55 -0
  112. package/src/tool-contracts.snapshot/tools/spellkave_status.json +23 -0
  113. package/src/tool-contracts.snapshot/tools/spellkave_stow_item.json +55 -0
  114. package/src/tool-contracts.snapshot/tools/spellkave_suggest_next_action.json +32 -0
  115. package/src/tool-contracts.snapshot/tools/spellkave_tag_entity.json +61 -0
  116. package/src/tool-contracts.snapshot/tools/spellkave_take_npc_control.json +64 -0
  117. package/src/tool-contracts.snapshot/tools/spellkave_trace_detail.json +36 -0
  118. package/src/tool-contracts.snapshot/tools/spellkave_traces.json +55 -0
  119. package/src/tool-contracts.snapshot/tools/spellkave_wake_up.json +23 -0
  120. package/src/tool-contracts.snapshot/tools/spellkave_withdraw_control.json +30 -0
  121. package/src/tool-contracts.snapshot/tools/spellkave_write_rows.json +62 -0
@@ -0,0 +1,3491 @@
1
+ import { type Static, Type } from "typebox";
2
+ import { EXPLORE_PARAMS } from "./exploration";
3
+
4
+ export const PLACE_SUBSTRATE_DEFAULT = "outdoor";
5
+
6
+ export const TAGS_PARAM = Type.Array(Type.String(), {
7
+ description:
8
+ "One INSTANCE-level entity_tag row per tag ('this goblin is the leader / faction X') — NOT an " +
9
+ "entity_definition_tag. Tag-grammar membership (MF-VAL-300) and dedup are enforced by the shared " +
10
+ "validator at commit; an unknown-grammar tag is reported as a diagnostic, not persisted. When a tag " +
11
+ "has authored tag_capability_grant rows (workspace/live), the result surfaces 'tag X grants " +
12
+ "capability Y' so the author sees the consequence — informational, never blocking.",
13
+ });
14
+
15
+ export const DOCS_PARAMS = Type.Object({
16
+ query: Type.Optional(
17
+ Type.String({
18
+ description:
19
+ "Free-text question about how to author something, e.g. 'how do I express object decay over time'. Matched (keyword/heading) against the packaged authoring corpus. Omit to list the bounded corpus index instead of querying it.",
20
+ }),
21
+ ),
22
+ doc: Type.Optional(
23
+ Type.String({
24
+ description:
25
+ "Exact corpus id (a `rel` from the index or a hit, e.g. 'dm-oversight') — returns that ONE doc whole: its prose body, the worked-example walkthrough when the id has both halves, and the complete example manifest TOML when `has_example` is true. This is how you get something copyable rather than only readable. Mutually exclusive with `query`; takes precedence if both are set.",
26
+ }),
27
+ ),
28
+ section: Type.Optional(
29
+ Type.String({
30
+ description:
31
+ "Optional heading text or anchor within `doc` — returns only that section's markdown instead of the full body. Unknown section fails (does not silently return the whole doc). Ignored without `doc`.",
32
+ }),
33
+ ),
34
+ outline: Type.Optional(
35
+ Type.Boolean({
36
+ description:
37
+ "With `doc`, return title + summary + heading list only (no full body). Default for oversized docs when neither `section` nor `full` is set.",
38
+ }),
39
+ ),
40
+ full: Type.Optional(
41
+ Type.Boolean({
42
+ description:
43
+ "With `doc`, force the complete body even when oversized (tool-reference, long references). Prefer `section` instead. Default false.",
44
+ }),
45
+ ),
46
+ doc_paths: Type.Optional(
47
+ Type.Array(Type.String(), {
48
+ description:
49
+ "Optional corpus-id filter (substring match) restricting the search to specific packaged docs. Only applies with `query` set; can only narrow the corpus, never widen it.",
50
+ }),
51
+ ),
52
+ limit: Type.Optional(
53
+ Type.Number({
54
+ description: "Max number of doc slices to return when `query` is set (default 3).",
55
+ }),
56
+ ),
57
+ });
58
+
59
+ export const INEXPRESSIBLE_PARAMS = Type.Object({
60
+ reason: Type.String({
61
+ description:
62
+ "Precisely why no documented row kind / DSL form can express this intent within the validator's surface.",
63
+ }),
64
+ });
65
+
66
+ export const DOC_GAP_PARAMS = Type.Object({
67
+ doc: Type.String({
68
+ description: "Which corpus doc id you were working from, e.g. 'dsl-grammar'.",
69
+ }),
70
+ expected: Type.String({ description: "What the doc led you to expect." }),
71
+ actual: Type.String({ description: "What the validator actually did — the discrepancy." }),
72
+ });
73
+
74
+ export const EXPORT_MANIFEST_PARAMS = Type.Object({
75
+ bundle: Type.String({
76
+ description: "bundle_id to reconstruct via r_export_manifest (ADR-0086).",
77
+ }),
78
+ actor: Type.Optional(
79
+ Type.String({
80
+ description:
81
+ "entity_key of the hero to keep. When set, only that actor and what hangs off it remain.",
82
+ }),
83
+ ),
84
+ out: Type.Optional(Type.String({ description: "Write the rendered TOML to this file path." })),
85
+ out_dir: Type.Optional(
86
+ Type.String({
87
+ description: "Write <slug>.toml into this directory (slug from --actor, else the bundle id).",
88
+ }),
89
+ ),
90
+ });
91
+
92
+ export const GET_PARAMS = Type.Object({
93
+ kind: Type.String({
94
+ description:
95
+ "Instance row kind: entities, actors, actor_spatial_locations, actor_capabilities, actor_equipment_slots, entity_containment, entity_tag, or object_state.",
96
+ }),
97
+ key: Type.Optional(
98
+ Type.String({
99
+ description:
100
+ "Key field values joined with :: in schema natural- or storage-key order. Omit to list.",
101
+ }),
102
+ ),
103
+ bundle: Type.Optional(
104
+ Type.String({ description: "bundle_id. Omit when the authored key is unique." }),
105
+ ),
106
+ pattern: Type.Optional(
107
+ Type.String({ description: "Substring filter on key fields for listings." }),
108
+ ),
109
+ fields: Type.Optional(
110
+ Type.Array(Type.String(), {
111
+ description:
112
+ "Listing columns. Omit for the compact preferred set. Key fields are always kept. Keyed get ignores this (whole row).",
113
+ }),
114
+ ),
115
+ limit: Type.Optional(Type.Integer({ minimum: 0, description: "Listing cap (default 50)." })),
116
+ });
117
+
118
+ export const DESCRIBE_PARAMS = Type.Object({
119
+ kind: Type.String({ description: "Must be entities." }),
120
+ key: Type.String({
121
+ description: "Authored entity_key or numeric id of an authored entity.",
122
+ }),
123
+ bundle: Type.Optional(Type.String({ description: "bundle_id when the key is not unique." })),
124
+ limit: Type.Optional(
125
+ Type.Integer({ minimum: 0, description: "Belonging-list cap (default 50)." }),
126
+ ),
127
+ });
128
+
129
+ export const CAN_I_PARAMS = Type.Object({
130
+ action: Type.String({ description: "The action id." }),
131
+ as: Type.String({
132
+ description: "The body the question is about, as its authored entity key or its entity id.",
133
+ }),
134
+ target: Type.Union(
135
+ [
136
+ Type.String({ description: "An authored entity key, entity id, or world." }),
137
+ Type.Object({
138
+ kind: Type.Union([
139
+ Type.Literal("entity"),
140
+ Type.Literal("place_node"),
141
+ Type.Literal("place_edge"),
142
+ Type.Literal("location"),
143
+ Type.Literal("world"),
144
+ ]),
145
+ id: Type.Optional(Type.String()),
146
+ }),
147
+ ],
148
+ {
149
+ description: "The target of the attempt, as an authored key, entity id, or target reference.",
150
+ },
151
+ ),
152
+ args: Type.Optional(
153
+ Type.Record(Type.String(), Type.Unknown(), {
154
+ description:
155
+ "Literal manipulation arguments for the probe. Supply the same selected items and either fresh expected_participants or participant_context as the intended dispatch; can-i does not compose a participant context.",
156
+ }),
157
+ ),
158
+ expect: Type.Optional(
159
+ Type.Union([Type.Literal("admitted"), Type.Literal("refused")], {
160
+ description: "Closed-door expectation. A differing answer is a rejection.",
161
+ }),
162
+ ),
163
+ });
164
+
165
+ export const DIFF_MANIFEST_PARAMS = Type.Object({
166
+ left: Type.String({
167
+ description: "Reference manifest TOML (only-left rows are gaps).",
168
+ }),
169
+ right: Type.String({
170
+ description: "Compared manifest TOML (only-right rows are snapshot/play).",
171
+ }),
172
+ ignore_fields: Type.Optional(
173
+ Type.String({
174
+ description:
175
+ "Comma-separated extra field names to ignore on every kind (merged with the default snapshot/enrichment list).",
176
+ }),
177
+ ),
178
+ kinds: Type.Optional(
179
+ Type.String({
180
+ description: "Comma-separated row kinds to compare (default: every array-valued kind).",
181
+ }),
182
+ ),
183
+ only: Type.Optional(
184
+ Type.Union([Type.Literal("gaps"), Type.Literal("snapshot"), Type.Literal("changed")], {
185
+ description:
186
+ "Restrict the report: gaps = only-left, snapshot = only-right, changed = same key with field diffs.",
187
+ }),
188
+ ),
189
+ map_key: Type.Optional(
190
+ Type.Array(Type.String(), {
191
+ description:
192
+ "Repeatable from=to key-prefix maps (sk-0m4.54). Rewrites entity/actor keys and every string field that is or embeds that key before compare, so an export keyed candidate_1 can match a reference keyed hero_1.",
193
+ }),
194
+ ),
195
+ });
196
+
197
+ const APPLYSET_DIR = Type.String({
198
+ description:
199
+ "The applyset root: a directory holding manifest.toml, or the root manifest file itself. " +
200
+ "Its includes are read too; only the root's own rows are compared and sent.",
201
+ });
202
+
203
+ const APPLYSET_DEPS = Type.Optional(
204
+ Type.Array(Type.String(), {
205
+ description:
206
+ "Repeatable dependency root manifests (or their directories), loaded for validation only and never sent.",
207
+ }),
208
+ );
209
+
210
+ export const PORTABLE_SOURCE_PARAMS = Type.Object(
211
+ {
212
+ root_path: Type.String({
213
+ description:
214
+ "Stable logical relative root name recorded in applyset provenance; never a server file path.",
215
+ }),
216
+ root_toml: Type.String(),
217
+ fragments: Type.Array(
218
+ Type.Object({ path: Type.String(), toml: Type.String() }, { additionalProperties: false }),
219
+ ),
220
+ },
221
+ { additionalProperties: false },
222
+ );
223
+
224
+ export const APPLYSET_DIFF_PARAMS = Type.Object({
225
+ dir: Type.Optional(APPLYSET_DIR),
226
+ source: Type.Optional(PORTABLE_SOURCE_PARAMS),
227
+ dep: APPLYSET_DEPS,
228
+ prune: Type.Optional(
229
+ Type.Boolean({
230
+ description:
231
+ "Preview an apply with pruning: inspect world-added rows on each removed entity, without writing. Requires publisher closure to inspect entity contents; an unreadable candidate is reported as a refusal. Off by default.",
232
+ }),
233
+ ),
234
+ });
235
+
236
+ export const APPLYSET_APPLY_PARAMS = Type.Object({
237
+ dir: Type.Optional(APPLYSET_DIR),
238
+ source: Type.Optional(PORTABLE_SOURCE_PARAMS),
239
+ dep: APPLYSET_DEPS,
240
+ prune: Type.Optional(
241
+ Type.Boolean({
242
+ description:
243
+ "Also retract rows the applyset applied before and the files no longer name. Retracting an entity covers its authored containment, state, resource bound, equipment (the wearer side), actor, position, identity, and capability rows (those kinds cannot be removed alone); tag rows stay. Pruning an equipped item together with its slot row while the wearer stays is refused. A containment row the files replace with another containment for the same contained entity needs no retraction. Retracting an entity on which the world holds rows beyond what the files put there, or any entity prune when those rows cannot be read, is refused unless --force. Off by default.",
244
+ }),
245
+ ),
246
+ dry_run: Type.Optional(
247
+ Type.Boolean({
248
+ description: "Compute and report the difference; send nothing (same as diff).",
249
+ }),
250
+ ),
251
+ force: Type.Optional(
252
+ Type.Boolean({
253
+ description:
254
+ "Let the files win over observed world changes, let this root take over an applyset name recorded under another root path, and retract an entity with world-added rows or unreadable prune contents. The answer reports the meanings used as a force_used list containing world_changed, root_takeover, and/or world_added_rows.",
255
+ }),
256
+ ),
257
+ });
258
+
259
+ export const APPLY_MANIFEST_DELTA_PARAMS = Type.Object({
260
+ toml: Type.Optional(
261
+ Type.String({
262
+ description:
263
+ "Optional escape hatch: a full manifest-delta TOML string to flush. " +
264
+ "Omit to commit the active workspace scratch (workspace.readToml) — the normal " +
265
+ "transaction end after write verbs. Pass only when applying an external/ad-hoc delta " +
266
+ "that is not the scratch pad.",
267
+ }),
268
+ ),
269
+ });
270
+
271
+ export const QUERY_PARAMS = Type.Object({
272
+ explore: Type.Optional(EXPLORE_PARAMS),
273
+ kind: Type.Optional(
274
+ Type.String({
275
+ description:
276
+ "A manifest row-kind name (a ROW_KIND_NATURAL_KEY key — e.g. 'capability_definitions', " +
277
+ "'affordance_templates', 'action_definitions', 'outcome_templates', 'entity_definitions', " +
278
+ "'area_shape_definitions', 'resource_definitions'), the SAME vocabulary spellkave_write_rows " +
279
+ "and every define_* verb already use — not a closed enum. Also accepts a `*_tag` satellite kind " +
280
+ "(e.g. 'resource_definition_tag', 'capability_definition_tag') — these have a TWO-field composite " +
281
+ "key (parent id + tag) instead of a single natural key; see `schema: true` for the field order. " +
282
+ "Omit for a workspace/target summary (bundle ids + a row-kind -> count map) instead of listing " +
283
+ "one kind.",
284
+ }),
285
+ ),
286
+ id: Type.Optional(
287
+ Type.String({
288
+ description:
289
+ "An exact natural-key value within `kind` — returns the complete authored row (detail shape), " +
290
+ "its source, and (by default) its refs. For a composite-keyed `*_tag` satellite kind, this is its " +
291
+ "ordered key fields' values joined by '::' (e.g. 'srd/wis::ability_score' for " +
292
+ "resource_definition_tag's `{resource_definition_id, tag}` — get the exact ids from a `kind`-only " +
293
+ "list call first). Mutually exclusive with `pattern`; requires `kind`.",
294
+ }),
295
+ ),
296
+ pattern: Type.Optional(
297
+ Type.String({
298
+ description:
299
+ "A substring filter on `kind`'s ids (its natural-key value, or its '::'-joined composite-key " +
300
+ "value for a `*_tag` satellite kind) — returns a filtered list instead of the full catalog. " +
301
+ "Mutually exclusive with `id`; requires `kind`.",
302
+ }),
303
+ ),
304
+ bundle: Type.Optional(
305
+ Type.String({
306
+ description: "Restrict to rows stamped with this bundle_id (summary/list shapes only).",
307
+ }),
308
+ ),
309
+ fields: Type.Optional(
310
+ Type.Union(
311
+ [Type.Literal("preferred"), Type.Array(Type.String({ minLength: 1 }), { minItems: 1 })],
312
+ {
313
+ description:
314
+ "List shape only (`kind` without `id`; ignored for detail/summary/schema). " +
315
+ "Default (omit): token-safe catalog — each item is only `{ id, bundle_id? }`. " +
316
+ "`preferred`: project a small kind-specific field set (e.g. entities → name, " +
317
+ "place_node_id, kind, entity_def_id) so one list call can answer who-is-where " +
318
+ "without N detail round-trips. Explicit string[]: project exactly those column " +
319
+ "names from each row (unknown/missing names omitted; nested values skipped). " +
320
+ "`id` is always present; `bundle_id` is included when the row has it.",
321
+ },
322
+ ),
323
+ ),
324
+ refs: Type.Optional(
325
+ Type.Union([Type.Literal("none"), Type.Literal("outbound"), Type.Literal("both")], {
326
+ description:
327
+ "Detail shape only (`kind`+`id`; ignored otherwise). 'outbound': fields on this row pointing " +
328
+ "elsewhere (already-computed string-ref heuristic). 'both' additionally computes inbound_refs — " +
329
+ "every OTHER row anywhere in the resolved source whose own outbound ref points AT this row, " +
330
+ "grouped by referencing kind — so a caller traverses a chain (e.g. capability -> affordance -> " +
331
+ "action -> outcome) by re-calling spellkave_query with a ref's own {kind, id}, no separate " +
332
+ "traversal tool needed. Default: 'both' when `id` is set.",
333
+ }),
334
+ ),
335
+ target: Type.Optional(
336
+ Type.Union([Type.Literal("workspace"), Type.Literal("local"), Type.Literal("live")], {
337
+ description:
338
+ "#1968 connection-level target override (READ-only — no write verb offers this): 'workspace' " +
339
+ "reads ONLY the workspace scratch manifest, ignoring any connection-level target/live db this call " +
340
+ "would otherwise consult. 'local' reads ONLY the active local folder target — errors if none is " +
341
+ "configured. 'live' reads ONLY the active live target (or the legacy live db when no target is " +
342
+ "wired at all) — errors if neither is available. Omit for the default union: workspace + whatever " +
343
+ "is configured (result.source says which).",
344
+ }),
345
+ ),
346
+ schema: Type.Optional(
347
+ Type.Boolean({
348
+ description:
349
+ "Ask what a row of `kind` may CONTAIN instead of which rows exist (#1983): with `kind`, that " +
350
+ "row kind's required fields, field types, and natural/composite key; without `kind`, the " +
351
+ "row-kind vocabulary itself (every kind the manifest schema defines, flagged for whether this " +
352
+ "tool can also list its rows). Schema covers all 79 manifest row kinds — a superset of the ~53 " +
353
+ "`id`/`pattern` can address: the 40 with a single-column natural key, plus the `*_tag` satellite " +
354
+ "kinds and `tag_capability_grant` with a two-field composite key (finding #9; sk-bwd). Ignores " +
355
+ "`id`/`pattern`/`bundle`/`target`: a " +
356
+ "row kind's shape is the same everywhere, so no source is consulted.",
357
+ }),
358
+ ),
359
+ });
360
+
361
+ export const MAP_GRAPH_PARAMS = Type.Object({
362
+ graph: Type.Optional(
363
+ Type.String({
364
+ description:
365
+ "Optional place_graph_id filter — when set, draw that graph (any substrate). " +
366
+ "Omit to compose every outdoor positioned graph (world map).",
367
+ }),
368
+ ),
369
+ slice: Type.Optional(
370
+ Type.Union(
371
+ [
372
+ Type.Literal("elevation_band"),
373
+ Type.Literal("all_floors_offset"),
374
+ Type.Literal("topology_only"),
375
+ Type.Literal("metric"),
376
+ Type.Literal("h3_world"),
377
+ ],
378
+ {
379
+ description:
380
+ "How to project multi-floor / unpositioned graphs: elevation_band (one floor), " +
381
+ "all_floors_offset (floors side-by-side), topology_only (adjacency layout), metric (all z in one plane), " +
382
+ "h3_world (outdoor multi-graph from cell_res10 — same plane idea as web WorldMapView). " +
383
+ "Omit for auto (indoor multi-z → elevation_band at z=0; outdoor compose uses h3 when cells present).",
384
+ },
385
+ ),
386
+ ),
387
+ z: Type.Optional(
388
+ Type.Number({
389
+ description: "Elevation for slice=elevation_band (default 0). Matches pose_elevation.",
390
+ }),
391
+ ),
392
+ z_tolerance: Type.Optional(
393
+ Type.Number({
394
+ description: "Half-width of elevation_band in elevation units (default 0.5).",
395
+ }),
396
+ ),
397
+ lod: Type.Optional(
398
+ Type.Union([Type.Literal("structure"), Type.Literal("furnished")], {
399
+ description:
400
+ "structure = rooms/routes only (no occupancy badges); furnished = + actor counts (default).",
401
+ }),
402
+ ),
403
+ output_type: Type.Optional(
404
+ Type.Union(
405
+ [
406
+ Type.Literal("utf8"),
407
+ Type.Literal("ascii"),
408
+ Type.Literal("braille"),
409
+ Type.Literal("inventory"),
410
+ Type.Literal("svg"),
411
+ Type.Literal("jpg"),
412
+ ],
413
+ {
414
+ description:
415
+ "Which single artifact to render — the engine computes ONLY this one (bead sk-due: " +
416
+ "the old `terminal` param picked the text body while the engine rendered svg + " +
417
+ "utf8 + ascii + braille + inventory regardless, every call). 'svg' (default) — this " +
418
+ "tool's own interactive picture-first use case: the raw SVG in details.svg plus an " +
419
+ "ImageContent PNG for hosts that render tool images (Pi TUI / Ghostty Kitty). " +
420
+ "'utf8'/'ascii'/'braille' return that text variant in the like-named details field " +
421
+ "instead (no image). 'inventory' skips the graph picture entirely, details.inventory " +
422
+ "only. 'jpg' writes a backdrop-composed JPEG to output_dir/output_name and returns " +
423
+ "its path as details.jpg_path — no svg/ascii/utf8/braille text in the response.",
424
+ },
425
+ ),
426
+ ),
427
+ output_dir: Type.Optional(
428
+ Type.String({
429
+ minLength: 1,
430
+ description:
431
+ "output_type='jpg' only; ignored otherwise. Directory to write the map-art JPEG into " +
432
+ "— absolute, or RELATIVE to the host process's own cwd. Optional: omit for a fresh " +
433
+ "temp directory (mkdtemp). Resolves this graph's authored [[map_layers]] backdrop " +
434
+ "(unmasked — same drawn-in-full contract every backdrop render in this package " +
435
+ "follows), rasterizes via resvg then encodes via ffmpeg -q:v 4, skipping the rewrite " +
436
+ "when an unchanged render already sits there (deterministic churn guard).",
437
+ }),
438
+ ),
439
+ output_name: Type.Optional(
440
+ Type.String({
441
+ minLength: 1,
442
+ description:
443
+ "output_type='jpg' only; ignored otherwise. Base filename (no extension) for the JPEG " +
444
+ "written under output_dir. Optional: omit for a name derived from graph, or 'map' when " +
445
+ "graph itself is also omitted (a world-compose call).",
446
+ }),
447
+ ),
448
+ target: Type.Optional(
449
+ Type.Union([Type.Literal("workspace"), Type.Literal("local"), Type.Literal("live")], {
450
+ description:
451
+ "Same read-only source override as spellkave_query (`workspace` | `local` | `live`). Omit for the default workspace+configured-target union.",
452
+ }),
453
+ ),
454
+ });
455
+
456
+ export const PLACE_NODE_PARAMS = Type.Object({
457
+ id: Type.String({
458
+ description:
459
+ "Fully-qualified place-node id '<place_graph_id>/<local_id>' (e.g. 'aoe_blast/arena/center'). " +
460
+ "PoC boundary: bare local ids are not supported.",
461
+ }),
462
+ name: Type.Optional(
463
+ Type.String({ description: "display_name; defaults to a title-cased local id." }),
464
+ ),
465
+ x: Type.Optional(
466
+ Type.Number({
467
+ description:
468
+ "Optional metric graph-local pos_x (integer graph units). When any node omits x/y, " +
469
+ "author_place auto-layouts all nodes on a circle (n>=3) or a line (n=1..2).",
470
+ }),
471
+ ),
472
+ y: Type.Optional(
473
+ Type.Number({
474
+ description: "Optional metric graph-local pos_y (integer graph units). See `x`.",
475
+ }),
476
+ ),
477
+ elevation: Type.Optional(
478
+ Type.Number({
479
+ description:
480
+ "Optional graph-local pose_elevation (metres-ish via graph metres_per_unit). Use for floors/cellars " +
481
+ "(e.g. 0 ground, -3 cellar). Omit for 0 with pose_elevation_present=true.",
482
+ }),
483
+ ),
484
+ cell_res10: Type.Optional(
485
+ Type.String({
486
+ description:
487
+ "Optional outdoor H3 res10 cell as decimal u64 string (parents res7/res4 derived via h3-js). " +
488
+ "Prefer strings so values above MAX_SAFE_INTEGER stay exact.",
489
+ }),
490
+ ),
491
+ description: Type.Optional(
492
+ Type.String({
493
+ description:
494
+ "Sets THIS node's own `place_nodes.description` column (T5 follow-up, #1968 pattern: a " +
495
+ "first-class field, never a metadata_attachments detour — same shape as the top-level " +
496
+ "`description` param below, which sets the GRAPH's own description instead). Read by " +
497
+ "movement-observation tools (e.g. spellkave_move) as the arrival prose for THIS node; " +
498
+ "falls back to the graph's own description only on a graph-crossing move when omitted.",
499
+ }),
500
+ ),
501
+ extent_shape_id: Type.Optional(
502
+ Type.String({
503
+ description:
504
+ "place_nodes.extent_shape_id (place-node-extent D-2, sk-71u): an explicit spatial extent " +
505
+ "for THIS node — one of the KNOWN_AREA_SHAPE_IDS kernel shapes (e.g. 'core/area/sphere', " +
506
+ "'core/area/cube'). Overrides the bundle's own default_extent_shape_id (spellkave_define_bundle) " +
507
+ "for this node only. Pair with `extent_params_json`; omit both to fall back to the bundle default.",
508
+ }),
509
+ ),
510
+ extent_params_json: Type.Optional(
511
+ Type.String({
512
+ description:
513
+ "place_nodes.extent_params_json — the params_json paired with `extent_shape_id` (e.g. " +
514
+ "'{\"radius_m\": 2.5}' for core/area/sphere). Only meaningful alongside `extent_shape_id`.",
515
+ }),
516
+ ),
517
+ });
518
+
519
+ export const AUTHOR_PLACE_PARAMS = Type.Object({
520
+ bundle: Type.Optional(
521
+ Type.String({
522
+ description:
523
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
524
+ }),
525
+ ),
526
+ substrate: Type.Optional(
527
+ Type.String({
528
+ description:
529
+ "substrate_id for the graph and every node (core: outdoor | indoor | tactical). " +
530
+ `Default '${PLACE_SUBSTRATE_DEFAULT}'. Houses/interiors should use 'indoor'.`,
531
+ }),
532
+ ),
533
+ parent_graph_id: Type.Optional(
534
+ Type.String({
535
+ description:
536
+ "Composition parent place_graph_id (ADR-0029 / Item 25). Empty/omit = root. " +
537
+ "Nested outdoor graphs project into the parent frame on the world map.",
538
+ }),
539
+ ),
540
+ origin_cell_res10: Type.Optional(
541
+ Type.String({
542
+ description:
543
+ "Root outdoor H3 res10 anchor as decimal u64 string. Only composition roots should set this; " +
544
+ "res7/res4 parents are derived. Nested graphs omit (origin stays 0).",
545
+ }),
546
+ ),
547
+ bearing: Type.Optional(
548
+ Type.Number({
549
+ description:
550
+ "Clockwise rotation degrees relative to parent/world frame (ADR-0029). Default 0.",
551
+ }),
552
+ ),
553
+ metres_per_unit: Type.Optional(
554
+ Type.Number({
555
+ description: "Graph unit → metres (ADR-0029). Default 1. Outdoor world maps often use >1.",
556
+ }),
557
+ ),
558
+ display_name: Type.Optional(
559
+ Type.String({ description: "place_graph display_name; default title-cased graph local id." }),
560
+ ),
561
+ nodes: Type.Array(PLACE_NODE_PARAMS, {
562
+ description:
563
+ "One or more place nodes. Every id must share ONE common parent path (one place_graph per call — a " +
564
+ "PoC boundary); the FIRST node becomes the place_graph's anchor_node_id.",
565
+ }),
566
+ // Use min/maxItems array (not Type.Tuple): TypeBox tuples emit draft-04
567
+ // `items: [schema, schema]`, which xAI/OpenAI tool schema validation rejects.
568
+ edges: Type.Array(Type.Array(Type.String(), { minItems: 2, maxItems: 2 }), {
569
+ description:
570
+ "[from_node_id, to_node_id] pairs; both ends must be in `nodes`. Pass [] for disconnected nodes " +
571
+ "(e.g. two same-radius cells with no traversal edge between them, as the worked example does).",
572
+ }),
573
+ description: Type.Optional(
574
+ Type.String({
575
+ description:
576
+ "Sets the generated place_graph's own `description` column (#1968 — a first-class, never " +
577
+ "load-bearing authoring field, not a metadata_attachments row).",
578
+ }),
579
+ ),
580
+ });
581
+
582
+ export const RESOURCE_SEED_PARAMS = Type.Object({
583
+ resource: Type.String({
584
+ description: "A resource_definition_id (or any object_state state_id).",
585
+ }),
586
+ value: Type.Number({ description: "The per-instance value_int override." }),
587
+ });
588
+
589
+ export const PLACEMENT_PARAMS = Type.Object({
590
+ at: Type.String({
591
+ description:
592
+ "An already-authored place_node id (e.g. from spellkave_author_place) every instance in THIS " +
593
+ "placement is placed at.",
594
+ }),
595
+ count: Type.Optional(
596
+ Type.Number({ description: "How many identical instances at this placement (default 1)." }),
597
+ ),
598
+ resources: Type.Optional(
599
+ Type.Array(RESOURCE_SEED_PARAMS, {
600
+ description:
601
+ "Per-instance object_state overrides seeded on EVERY instance in THIS placement.",
602
+ }),
603
+ ),
604
+ key_prefix: Type.Optional(
605
+ Type.String({
606
+ description:
607
+ "#1968 workspace idempotency: THIS placement's own explicit identity stem — keys become " +
608
+ "'<bundle>/<key_prefix>_<n>' (n restarts at 1 for this placement's own prefix, EVERY call — never " +
609
+ "derived from what already exists in the workspace). A re-run with the SAME key_prefix therefore " +
610
+ "reproduces the SAME keys and UPSERTS the rows owned by the selected placement tool. Omit for an " +
611
+ "anonymous, additive placement (default " +
612
+ "'<bundle>/<slugified entity_def>_<n>', numbered onward from whatever already exists in the " +
613
+ "workspace so repeated calls never collide) — name placements for idempotent scripts. Mutually " +
614
+ "exclusive with `entity_key`.",
615
+ }),
616
+ ),
617
+ entity_key: Type.Optional(
618
+ Type.String({
619
+ description:
620
+ "sk-9ll.6: THIS placement's own explicit, LITERAL entity_key, used verbatim — NO bundle prefix and " +
621
+ "NO ordinal suffix minted (contrast `key_prefix`'s derived '<bundle>/<key_prefix>_<n>'). For a " +
622
+ "pre-known exact key a script/fixture depends on (e.g. 'fastlane/hero') that does not follow the " +
623
+ "'<bundle>/<stem>_<n>' convention — the escape hatch that let raw write_rows chains mint exact keys " +
624
+ "this verb previously could not reproduce. Re-running with the SAME entity_key upserts its owned " +
625
+ "rows, same as `key_prefix`. Mutually exclusive with `key_prefix`; only legal for a single instance " +
626
+ "— omit `count` or set it to 1.",
627
+ }),
628
+ ),
629
+ name: Type.Optional(
630
+ Type.String({
631
+ description:
632
+ "sk-ntz.1: THIS placement's own explicit, VERBATIM `entities.name`/`actors.name` override — used AS-IS " +
633
+ "on every instance in THIS placement, no ordinal suffix appended (contrast the default title-cased " +
634
+ "`kind`/`entity_def` naming, which DOES append an ordinal for multi-instance placements). Overrides " +
635
+ "the flat `name` when both are set (THIS placement's own `name` wins) — the escape hatch that let raw " +
636
+ "write_rows chains author a custom display name this verb previously could not reproduce (the fold " +
637
+ "this verb was widened for, sk-ntz.1, otherwise had no way to keep a fixture's own 'Fast-lane Hero' " +
638
+ "style name). Mutually exclusive with `name_prefix`. Omit for the existing default: title-cased " +
639
+ "`kind`/`entity_def`, ordinal-suffixed for multi-instance placements — unchanged.",
640
+ }),
641
+ ),
642
+ name_prefix: Type.Optional(
643
+ Type.String({
644
+ description:
645
+ "sk-jay0.7.15.3: THIS placement's own display-name STEM — replaces only the title-cased `kind`/" +
646
+ "`entity_def` half of the derived name and KEEPS the ordinal (`'<name_prefix> <n>'`). The group-" +
647
+ "placement counterpart to verbatim `name` (which is used AS-IS with no ordinal, so a count>1 batch " +
648
+ "would otherwise share one identical name). Overrides the flat `name_prefix` when both are set (THIS " +
649
+ "placement's own `name_prefix` wins). Mutually exclusive with `name`. Illegal with `entity_key` " +
650
+ "(no ordinal is minted — use `name` for a single literal key). Omit for the existing default — " +
651
+ "unchanged.",
652
+ }),
653
+ ),
654
+ quantity: Type.Optional(
655
+ Type.Integer({
656
+ minimum: 1,
657
+ description:
658
+ "sk-ntz.1: THIS placement's own explicit `entities.quantity` (stack size) override for every instance " +
659
+ "in THIS placement — spellkave_place_entity ONLY (a stackable item's own on-instance count, e.g. a " +
660
+ "10-credit purse); spellkave_place_actor rejects a set `quantity` outright (actors carry no stack — " +
661
+ "use spellkave_place_entity instead). Overrides the flat `quantity` when both are set (THIS " +
662
+ "placement's own `quantity` wins). Omit for the schema default (1) — unchanged.",
663
+ }),
664
+ ),
665
+ tags: Type.Optional(TAGS_PARAM),
666
+ });
667
+
668
+ export const PLACE_PARAMS = Type.Object({
669
+ bundle: Type.Optional(
670
+ Type.String({
671
+ description:
672
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
673
+ }),
674
+ ),
675
+ kind: Type.Union(
676
+ [Type.Literal("player"), Type.Literal("npc"), Type.Literal("item"), Type.Literal("place")],
677
+ {
678
+ description:
679
+ "Manifest entity kind accepted by the current authoritative schema. The placement tool controls " +
680
+ "whether actor steering rows exist; `kind` does not. The open-vocabulary migration is tracked by #2066.",
681
+ },
682
+ ),
683
+ entity_def: Type.Optional(
684
+ Type.String({
685
+ description:
686
+ "Optional fully-qualified catalog entity_def_id (contains '/', e.g. 'srd/monster/goblin') that " +
687
+ "must already resolve in the workspace or live world. `kind` remains explicit and independent.",
688
+ }),
689
+ ),
690
+ at: Type.Optional(
691
+ Type.String({
692
+ description:
693
+ "FLAT single-location shape: an already-authored place_node id every instance is placed at. " +
694
+ "Mutually exclusive with `placements` (FIX①, #1968) — set `at` (+ `count`/`resources`) for ONE " +
695
+ "location, or `placements` to split a batch across MULTIPLE locations in one call, never both.",
696
+ }),
697
+ ),
698
+ count: Type.Optional(
699
+ Type.Number({
700
+ description: "FLAT shape only: how many identical instances to place (default 1).",
701
+ }),
702
+ ),
703
+ resources: Type.Optional(
704
+ Type.Array(RESOURCE_SEED_PARAMS, {
705
+ description:
706
+ "FLAT shape only: per-instance object_state overrides seeded on EVERY placed entity in this " +
707
+ "call (e.g. a non-default starting pool value). Does NOT declare the resource_definitions row " +
708
+ "itself (use spellkave_define_resource first).",
709
+ }),
710
+ ),
711
+ tags: Type.Optional(TAGS_PARAM),
712
+ placements: Type.Optional(
713
+ Type.Array(PLACEMENT_PARAMS, {
714
+ description:
715
+ "MULTI-LOCATION shape (FIX①, #1968): one or more {at, count?, resources?, tags?} groups placing the " +
716
+ "SAME kind/entity_def split across DIFFERENT place_nodes in a single call (e.g. 3 targets at the " +
717
+ "blast center + 1 bystander at the fringe). Mutually exclusive with the flat `at`/`count`/" +
718
+ "`resources`/`tags` — set ONE shape or the other, never both.",
719
+ }),
720
+ ),
721
+ description: Type.Optional(
722
+ Type.String({
723
+ description:
724
+ "Sets EVERY placed entity's own `description` column (across every placement) — e.g. 'the guard " +
725
+ "with the limp' (#1968 — a first-class, never load-bearing authoring field, not a " +
726
+ "metadata_attachments row).",
727
+ }),
728
+ ),
729
+ key_prefix: Type.Optional(
730
+ Type.String({
731
+ description:
732
+ "FLAT shape only (mutually exclusive with `placements` — set `placements[].key_prefix` there " +
733
+ "instead). #1968 workspace idempotency: see `placements[].key_prefix`'s description for the full " +
734
+ "semantics — this is the same field, for the single-location flat shape. Mutually exclusive with " +
735
+ "`entity_key`.",
736
+ }),
737
+ ),
738
+ entity_key: Type.Optional(
739
+ Type.String({
740
+ description:
741
+ "FLAT shape only (mutually exclusive with `placements` — set `placements[].entity_key` there " +
742
+ "instead). sk-9ll.6: see `placements[].entity_key`'s description for the full semantics — this is " +
743
+ "the same field, for the single-location flat shape.",
744
+ }),
745
+ ),
746
+ name: Type.Optional(
747
+ Type.String({
748
+ description:
749
+ "sk-ntz.1: FLAT shape (also `placements[].name`, which wins when both are set): sets EVERY placed " +
750
+ "entity's own `entities.name`/`actors.name` verbatim (no ordinal suffix), instead of the default " +
751
+ "title-cased `kind`/`entity_def` naming. A first-class, never load-bearing authoring field, mirrors " +
752
+ "`description`'s own shared-across-every-placement convention. Mutually exclusive with `name_prefix`. " +
753
+ "Omit for the existing default — unchanged.",
754
+ }),
755
+ ),
756
+ name_prefix: Type.Optional(
757
+ Type.String({
758
+ description:
759
+ "sk-jay0.7.15.3: FLAT shape (also `placements[].name_prefix`, which wins when both are set): replaces " +
760
+ "only the title-cased `kind`/`entity_def` half of the derived name and KEEPS the ordinal " +
761
+ "(`'<name_prefix> <n>'`) across every placed instance. The group-placement counterpart to verbatim " +
762
+ "`name`. Mutually exclusive with `name`. Illegal with `entity_key`. Omit for the existing default — " +
763
+ "unchanged.",
764
+ }),
765
+ ),
766
+ quantity: Type.Optional(
767
+ Type.Integer({
768
+ minimum: 1,
769
+ description:
770
+ "sk-ntz.1: FLAT shape (also `placements[].quantity`, which wins when both are set): sets EVERY placed " +
771
+ "entity's own `entities.quantity` (stack size) — spellkave_place_entity ONLY; spellkave_place_actor " +
772
+ "rejects a set `quantity` (actors carry no stack — use spellkave_place_entity for a stackable item " +
773
+ "instance instead). Omit for the schema default (1) — unchanged.",
774
+ }),
775
+ ),
776
+ });
777
+
778
+ export const LINK_PLACES_PARAMS = Type.Object({
779
+ bundle: Type.Optional(
780
+ Type.String({
781
+ description:
782
+ "bundle_id stamped on generated edges. Omit to fall back to `context.defaultBundle`.",
783
+ }),
784
+ ),
785
+ from: Type.String({
786
+ description: "Fully-qualified place_node id (must already exist in workspace/target).",
787
+ }),
788
+ to: Type.String({
789
+ description: "Fully-qualified place_node id (must already exist in workspace/target).",
790
+ }),
791
+ bidirectional: Type.Optional(
792
+ Type.Boolean({
793
+ description: "Author reverse edge too (default true).",
794
+ }),
795
+ ),
796
+ substrate_crossing: Type.Optional(
797
+ Type.Boolean({
798
+ description:
799
+ "Force substrate_crossing. Omit to auto: true when the two nodes' substrates differ, " +
800
+ "or when they belong to different place_graphs (cross-graph portal).",
801
+ }),
802
+ ),
803
+ portal: Type.Optional(
804
+ Type.Boolean({
805
+ description:
806
+ "Attach a place_edge_affordance on each edge (default FALSE, ADR-0101 — ordinary " +
807
+ "edges inherit the bundle/graph movement_default instead, no per-edge row needed). " +
808
+ "Pass true only to attach a special affordance right at creation time; template " +
809
+ "defaults to core/affordance/traverse_open_portal unless affordance_template_id is set.",
810
+ }),
811
+ ),
812
+ affordance_template_id: Type.Optional(
813
+ Type.String({
814
+ description:
815
+ "place_edge_affordance.affordance_template_id when portal is true (portal defaults " +
816
+ 'to false — see that field). Default "core/affordance/traverse_open_portal" when ' +
817
+ 'portal is true and this is omitted. Self-sufficient packs pass e.g. "srd/affordance/step".',
818
+ }),
819
+ ),
820
+ bindings_json: Type.Optional(
821
+ Type.String({
822
+ description:
823
+ 'place_edge_affordance.bindings_json when portal is true (default ""). ' +
824
+ 'e.g. \'{"movement_reach_resource":"srd/speed-walk","long_running_move_session":"srd/long_running_move"}\' for srd Step.',
825
+ }),
826
+ ),
827
+ /** E-prep: stamp metadata door=true on edges (no lock mechanics yet). */
828
+ door: Type.Optional(
829
+ Type.Boolean({
830
+ description:
831
+ "If true, attach metadata namespace place.door on each edge_key (inert; locks later).",
832
+ }),
833
+ ),
834
+ description: Type.Optional(Type.String({ description: "Optional edge description." })),
835
+ cell_anchor: Type.Optional(
836
+ Type.String({
837
+ description:
838
+ "H3 res10 cell anchor as decimal u64 string for substrate_crossing edges (MF-VAL-102). " +
839
+ "Omit to use dummy 1 (legacy); outdoor portals should pass a real cell.",
840
+ }),
841
+ ),
842
+ });
843
+
844
+ export const BIND_EDGE_AFFORDANCE_PARAMS = Type.Object({
845
+ from: Type.String({
846
+ description:
847
+ "place_edges.from_node_id of an edge that ALREADY exists (workspace, live, or the active " +
848
+ "target) — this call never creates one. Author it first via spellkave_link_places / " +
849
+ "spellkave_author_place.",
850
+ }),
851
+ to: Type.String({
852
+ description: "place_edges.to_node_id of the same already-existing edge.",
853
+ }),
854
+ affordance_template_id: Type.String({
855
+ description:
856
+ "place_edge_affordance.affordance_template_id — must already resolve to an authored " +
857
+ "affordance_templates row (workspace, live, or the active target); this call does not " +
858
+ "auto-create it.",
859
+ }),
860
+ bindings_json: Type.Optional(
861
+ Type.String({
862
+ description:
863
+ 'place_edge_affordance.bindings_json (default ""). e.g. \'{"movement_reach_resource":' +
864
+ '"srd/speed-walk"}\' for srd Step.',
865
+ }),
866
+ ),
867
+ mode_id: Type.Optional(
868
+ Type.String({
869
+ description:
870
+ 'place_edge_affordance.mode_id (ADR-0101 D-1, default "" — the implicit default mode). ' +
871
+ 'An open author-chosen id (e.g. "fly", "swim") — rows sharing one (edge_key, mode_id) ' +
872
+ "AND-join (all must pass); distinct mode_ids on the SAME edge OR (the cheapest passing " +
873
+ "mode charges and supplies the long-running-move session). Upserts by " +
874
+ "(edge_key, affordance_template_id, mode_id) — the SAME template under two different " +
875
+ "mode_ids on one edge is a sibling row, not a replace.",
876
+ }),
877
+ ),
878
+ bidirectional: Type.Optional(
879
+ Type.Boolean({
880
+ description:
881
+ "Attach to both from->to and to->from edges (default true) — mirrors spellkave_link_places' " +
882
+ "own default. Both edges must already exist when true. Pass false to bind only the from->to " +
883
+ "direction.",
884
+ }),
885
+ ),
886
+ inherit_movement_default: Type.Optional(
887
+ Type.Boolean({
888
+ description:
889
+ "place_edges.inherit_movement_default (ADR-0101 D-1, schema default true) — REPLACES " +
890
+ "the flag on every already-existing edge this call targets (from->to, and to->from too " +
891
+ "when bidirectional). false means the edge owns its FULL mode set from its own " +
892
+ "place_edge_affordance rows alone (the fly-only-chasm idiom); true (or omitting this " +
893
+ "param) leaves/restores the resolved bundle/graph movement_default in play. Requires the " +
894
+ "edge to already be an authored [[place_edges]] row IN THIS WORKSPACE (not just live/" +
895
+ "target) — this is a whole-row re-author under the hood, so it needs the edge's other " +
896
+ "columns already in hand to avoid silently dropping them.",
897
+ }),
898
+ ),
899
+ });
900
+
901
+ export const SET_MOVEMENT_DEFAULT_PARAMS = Type.Object({
902
+ bundle: Type.Optional(
903
+ Type.String({
904
+ description:
905
+ "movement_defaults.bundle_id. Omit to fall back to `context.defaultBundle`. ALWAYS the " +
906
+ "scope owner, even when place_graph_id narrows the row to one graph.",
907
+ }),
908
+ ),
909
+ place_graph_id: Type.Optional(
910
+ Type.String({
911
+ description:
912
+ 'movement_defaults.place_graph_id (default "" — bundle scope, applies to every edge in ' +
913
+ "the bundle with no closer graph default). Set to scope this default to ONE place_graph " +
914
+ "instead (must already exist in workspace/live/target) — a graph-scoped default beats a " +
915
+ "bundle-scoped one for edges in that graph (D-2: edge > graph > bundle).",
916
+ }),
917
+ ),
918
+ mode_id: Type.Optional(
919
+ Type.String({
920
+ description:
921
+ 'movement_defaults.mode_id (default "" — the implicit default mode, same open ' +
922
+ 'author-chosen vocabulary as spellkave_bind_edge_affordance\'s mode_id, e.g. "fly"). ' +
923
+ "Rows sharing one (scope, mode_id) AND-join; a distinct mode_id under the same scope is " +
924
+ "an alternative the kernel OR-picks the cheapest passing one from.",
925
+ }),
926
+ ),
927
+ affordance_template_id: Type.String({
928
+ description:
929
+ "movement_defaults.affordance_template_id — must already resolve to an authored " +
930
+ "affordance_templates row (workspace, live, or the active target); this call does not " +
931
+ "auto-create it.",
932
+ }),
933
+ bindings_json: Type.Optional(
934
+ Type.String({
935
+ description:
936
+ 'movement_defaults.bindings_json (default ""). e.g. \'{"movement_reach_resource":' +
937
+ '"srd/speed-walk","long_running_move_session":"srd/long_running_move"}\' for srd Step.',
938
+ }),
939
+ ),
940
+ });
941
+
942
+ export const ATTACH_MAP_LAYER_PARAMS = Type.Object({
943
+ bundle: Type.Optional(Type.String()),
944
+ place_graph_id: Type.String({
945
+ description: "place_graph this backdrop belongs to.",
946
+ }),
947
+ asset_path: Type.String({
948
+ description:
949
+ 'Relative path under asset root, e.g. "maps/306 Fortified Hamlet.jpg" for ccc3-maps.',
950
+ }),
951
+ asset_module: Type.Optional(
952
+ Type.String({
953
+ description:
954
+ 'Asset root module id (default "ccc3-maps"). Also resolves FVTT_DATA_ROOT/<module>.',
955
+ }),
956
+ ),
957
+ display_name: Type.Optional(Type.String()),
958
+ map_layer_id: Type.Optional(
959
+ Type.String({ description: "Defaults to <place_graph_id>/backdrop." }),
960
+ ),
961
+ posture: Type.Optional(
962
+ Type.String({ description: 'License posture stamp (default "cc-by-4.0" for ccc3).' }),
963
+ ),
964
+ source_kind: Type.Optional(Type.String({ description: 'Default "elven-tower-ccc".' })),
965
+ grid_size_px: Type.Optional(Type.Number()),
966
+ grid_distance_m: Type.Optional(Type.Number()),
967
+ image_width_px: Type.Optional(Type.Number()),
968
+ image_height_px: Type.Optional(Type.Number()),
969
+ local_width_cells: Type.Optional(Type.Number()),
970
+ local_height_cells: Type.Optional(Type.Number()),
971
+ image_origin_x: Type.Optional(Type.Number()),
972
+ image_origin_y: Type.Optional(Type.Number()),
973
+ rotation_deg: Type.Optional(Type.Number()),
974
+ state: Type.Optional(
975
+ Type.String({
976
+ description: 'aligned | provisional | unmatched | template (default "template").',
977
+ }),
978
+ ),
979
+ /** Provenance metadata on the place_graph (default true). */
980
+ provenance: Type.Optional(Type.Boolean()),
981
+ map_id: Type.Optional(Type.String({ description: "Catalog map id for provenance payload." })),
982
+ license_url: Type.Optional(Type.String()),
983
+ source_url: Type.Optional(Type.String()),
984
+ });
985
+
986
+ export const ANNOTATE_PLACE_PARAMS = Type.Object({
987
+ bundle: Type.Optional(Type.String()),
988
+ target_kind: Type.Union(
989
+ [Type.Literal("place_graph"), Type.Literal("place_node"), Type.Literal("place_edge")],
990
+ { description: "What the annotation attaches to." },
991
+ ),
992
+ target_ref: Type.String({ description: "place_graph_id / node_id / edge_key." }),
993
+ /** terrain.hint payload — free tags for later niche wiring. */
994
+ terrain: Type.Optional(
995
+ Type.Array(Type.String(), {
996
+ description: 'Tags e.g. ["road","difficult","hazard_slime"] → namespace terrain.hint',
997
+ }),
998
+ ),
999
+ /** Optional free JSON object merged into payload (advanced). */
1000
+ payload: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
1001
+ namespace: Type.Optional(
1002
+ Type.String({
1003
+ description: 'Override namespace (default terrain.hint when terrain set, else "place.note").',
1004
+ }),
1005
+ ),
1006
+ /** E-prep: set origin_cell_res10 on a place_graph (safe integer demo H3). */
1007
+ h3_origin_res10: Type.Optional(
1008
+ Type.Number({
1009
+ description:
1010
+ "When target_kind=place_graph, stamp origin_cell_res10 (and anchor node cell_res10 if anchor known). " +
1011
+ "Must be within Number.MAX_SAFE_INTEGER. Real H3 encoding later.",
1012
+ }),
1013
+ ),
1014
+ });
1015
+
1016
+ export const BIND_ACTOR_CAPABILITY_PARAMS = Type.Object({
1017
+ capability_id: Type.String({
1018
+ description:
1019
+ "actor_capabilities.capability_id — must already resolve to an authored capability_definitions " +
1020
+ "row (workspace, live, or the active target); this call does not auto-create it. " +
1021
+ "Privileged frontier.* ids use spellkave_grant_role with an explicit role and extent.",
1022
+ }),
1023
+ source: Type.Optional(
1024
+ Type.String({
1025
+ description:
1026
+ "actor_capabilities.source. Omit for the schema default 'manifest' (mirrors `add-capability-grant`'s " +
1027
+ "own default). This is grant provenance, not authority over a role or extent.",
1028
+ }),
1029
+ ),
1030
+ visibility: Type.Optional(
1031
+ Type.String({
1032
+ description: "actor_capabilities.visibility (ADR-0120 read-visibility override).",
1033
+ }),
1034
+ ),
1035
+ extent_ref: Type.Optional(
1036
+ Type.String({ description: "actor_capabilities.extent_ref (ADR-0007 D-4 see-as scope)." }),
1037
+ ),
1038
+ extent_kind_ref: Type.Optional(
1039
+ Type.String({ description: "actor_capabilities.extent_kind_ref." }),
1040
+ ),
1041
+ });
1042
+
1043
+ export const BIND_ACTOR_PARAMS = Type.Object({
1044
+ bundle: Type.Optional(
1045
+ Type.String({
1046
+ description:
1047
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
1048
+ }),
1049
+ ),
1050
+ entity_key: Type.String({
1051
+ description:
1052
+ "entity_key of an already-placed actor (e.g. via spellkave_place_actor) — must already carry an " +
1053
+ "actor_spatial_locations row (workspace, live, or the active target); this call does not place one.",
1054
+ }),
1055
+ identity: Type.Optional(
1056
+ Type.String({
1057
+ description:
1058
+ "actor_identities.identity. Default '$sender' resolves to whoever submits the applying delta. Pass " +
1059
+ "a concrete identity hex string only when binding to a KNOWN, fixed identity instead.",
1060
+ }),
1061
+ ),
1062
+ role: Type.Optional(
1063
+ Type.String({
1064
+ description:
1065
+ "actor_identities.role. Default 'primary' (the corpus-dominant value; 'dm' is the one observed override). NOT a cosmetic label: r_claim_actor refuses every value but 'primary', so authoring 'dm' deliberately makes the seat un-self-claimable — right for a human DM anchor handed over by the operator, wrong for a programmatic seat that wants the self-claim path. It never affects visibility or write authority, which come from the capability grant alone.",
1066
+ }),
1067
+ ),
1068
+ capabilities: Type.Optional(
1069
+ Type.Array(BIND_ACTOR_CAPABILITY_PARAMS, {
1070
+ description:
1071
+ "actor_capabilities grants issued to the SAME entity_key, alongside the identity bind. Default " +
1072
+ "`[]` (identity-only bind — no grant). Ordinary capability rows are supported; " +
1073
+ "frontier.* capability requests are refused with a pointer to spellkave_grant_role.",
1074
+ }),
1075
+ ),
1076
+ });
1077
+
1078
+ export const TAG_ENTITY_PARAMS = Type.Object({
1079
+ bundle: Type.Optional(
1080
+ Type.String({
1081
+ description:
1082
+ "bundle_id stamped on every generated entity_tag row. Omit to fall back to " +
1083
+ "`context.defaultBundle` (#1968 smart default). NOTE: this is the bundle OWNING the new tag " +
1084
+ "row(s), not necessarily the bundle that placed `entity_key` — a cross-bundle caller stamps ITS " +
1085
+ "own bundle_id here (the elven-mini idiom this verb replaces: crypt-fight.ts/dm-npc.ts tag " +
1086
+ "the hero placed in hero.ts, all three sharing one bundle in that fixture, but nothing requires it).",
1087
+ }),
1088
+ ),
1089
+ entity_key: Type.String({
1090
+ description:
1091
+ "entity_key of an already-placed entity (e.g. via spellkave_place_entity/spellkave_place_actor, in " +
1092
+ "THIS bundle or another) — must already carry an entities row (workspace or the active target); " +
1093
+ "this call does not place one. Use this verb instead of re-invoking the placement tool when the " +
1094
+ "entity's placement call lives in a DIFFERENT file/call than the one adding this tag.",
1095
+ }),
1096
+ tags: Type.Array(Type.String(), {
1097
+ minItems: 1,
1098
+ description:
1099
+ "One INSTANCE-level entity_tag row per tag, mirroring spellkave_place_entity/spellkave_place_actor's " +
1100
+ "own `tags` param exactly (same row shape, same MF-VAL-300 grammar, same tag_capability_grant " +
1101
+ "diagnostic) — the difference is WHEN: this verb runs AFTER the entity already exists, against an " +
1102
+ "entity_key placed by a DIFFERENT call/file.",
1103
+ }),
1104
+ mode: Type.Optional(
1105
+ Type.Union([Type.Literal("add"), Type.Literal("replace")], {
1106
+ description:
1107
+ "Default 'add': upsert the listed tags, leaving every OTHER tag already on this entity_key " +
1108
+ "untouched (idempotent — re-listing an already-present tag is a no-op) — the safe default for a " +
1109
+ "cross-file caller that does not own the entity's full tag set (this verb's whole reason to exist: " +
1110
+ "REPLACING would clobber tags the entity's OWN placement call already authored elsewhere). Set " +
1111
+ "'replace' only when THIS call owns the entity's complete tag set: it clears EVERY existing " +
1112
+ "entity_tag row for `entity_key` first, then reseeds exactly `tags` (a re-run with fewer tags drops " +
1113
+ "the stale ones, mirroring spellkave_place_entity/spellkave_place_actor's own clear-and-reseed).",
1114
+ }),
1115
+ ),
1116
+ });
1117
+
1118
+ export const EQUIP_ITEM_PARAMS = Type.Object({
1119
+ bundle: Type.Optional(
1120
+ Type.String({
1121
+ description:
1122
+ "bundle_id stamped on the generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
1123
+ }),
1124
+ ),
1125
+ actor_entity_key: Type.String({
1126
+ description:
1127
+ "actor_equipment_slots.actor_entity_key — must already carry an actor_spatial_locations row " +
1128
+ "(workspace, live, or the active target); place it first via spellkave_place_actor.",
1129
+ }),
1130
+ item_entity_key: Type.String({
1131
+ description:
1132
+ "actor_equipment_slots.item_key — an already-authored entities row that entity_containment " +
1133
+ "already places inside actor_entity_key (stow it first via spellkave_stow_item).",
1134
+ }),
1135
+ slot_id: Type.String({
1136
+ description:
1137
+ "actor_equipment_slots.slot_id — must already resolve to an authored equipment_slot_definitions row.",
1138
+ }),
1139
+ });
1140
+
1141
+ export const STOW_ITEM_PARAMS = Type.Object({
1142
+ bundle: Type.Optional(
1143
+ Type.String({
1144
+ description:
1145
+ "bundle_id stamped on the generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
1146
+ }),
1147
+ ),
1148
+ actor_entity_key: Type.Optional(
1149
+ Type.String({
1150
+ description:
1151
+ "The actor stowing item_entity_key — must already carry an actor_spatial_locations row (workspace, " +
1152
+ "live, or the active target); place it first via spellkave_place_actor. Also the DEFAULT container " +
1153
+ "when container_entity_key is omitted. Omit it to put an item into a placed container with no " +
1154
+ "actor involved (a potion in a chest): then container_entity_key is required.",
1155
+ }),
1156
+ ),
1157
+ item_entity_key: Type.String({
1158
+ description:
1159
+ "entity_containment.entity_key — an already-placed entity (workspace or the active target) to move " +
1160
+ "into container_entity_key (or actor_entity_key when container_entity_key is omitted).",
1161
+ }),
1162
+ container_entity_key: Type.Optional(
1163
+ Type.String({
1164
+ description:
1165
+ "entity_containment.container_entity_key. Default actor_entity_key — the common 'give the actor this " +
1166
+ "item directly' case (a starter weapon straight into the hero's inventory). Pass a DIFFERENT " +
1167
+ "already-placed container (e.g. a field kit already stowed on the actor) to nest item_entity_key " +
1168
+ "inside IT instead (the torch-inside-the-field-kit idiom).",
1169
+ }),
1170
+ ),
1171
+ slot_id: Type.Optional(
1172
+ Type.String({
1173
+ description:
1174
+ "entity_containment.slot_id — machine-port slot id. Default '' (loose carriage — the common " +
1175
+ "item-in-backpack/actor-holding-item case, not a machine port).",
1176
+ }),
1177
+ ),
1178
+ direction: Type.Optional(
1179
+ Type.String({
1180
+ description:
1181
+ "entity_containment.direction — machine-port direction ('in'/'out'). Default '' (loose carriage).",
1182
+ }),
1183
+ ),
1184
+ });
1185
+
1186
+ export const DEFINE_RESOURCE_PARAMS = Type.Object({
1187
+ bundle: Type.Optional(
1188
+ Type.String({
1189
+ description:
1190
+ "bundle_id stamped on the generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
1191
+ }),
1192
+ ),
1193
+ id: Type.String({
1194
+ description:
1195
+ "Local resource stem; the full resource_definition_id is '<bundle>/<id>' (e.g. bundle='aoe_blast', " +
1196
+ "id='hp' -> 'aoe_blast/hp').",
1197
+ }),
1198
+ display_name: Type.Optional(
1199
+ Type.String({
1200
+ description:
1201
+ "resource_definitions.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
1202
+ }),
1203
+ ),
1204
+ min_value: Type.Number({ description: "resource_definitions.min_value." }),
1205
+ max_value: Type.Number({ description: "resource_definitions.max_value." }),
1206
+ initial_value: Type.Optional(
1207
+ Type.Number({
1208
+ description:
1209
+ "resource_definitions.initial_value — the object_state seed for an un-instantiated pool. Omit " +
1210
+ "to fall back to min_value at runtime (a charges/gold-shaped pool); set e.g. to max_value for an " +
1211
+ "HP-shaped pool that must start full.",
1212
+ }),
1213
+ ),
1214
+ recovery_rule: Type.Optional(
1215
+ Type.Union(
1216
+ [
1217
+ Type.Literal("none"),
1218
+ Type.Literal("persistent"),
1219
+ Type.Literal("long_rest"),
1220
+ Type.Literal("short_rest_partial_long_rest_full"),
1221
+ ],
1222
+ {
1223
+ description:
1224
+ "resource_definitions.recovery_rule (default 'none'). Closed PoC enum over the corpus's own " +
1225
+ "observed vocabulary — the field itself is open-string at the schema level (ADR-0018).",
1226
+ },
1227
+ ),
1228
+ ),
1229
+ value_kind: Type.Optional(
1230
+ Type.String({
1231
+ description:
1232
+ "resource_definitions.value_kind (default 'int' — the only value observed corpus-wide).",
1233
+ }),
1234
+ ),
1235
+ description: Type.Optional(
1236
+ Type.String({
1237
+ description:
1238
+ "Sets the generated resource_definitions row's own `description` column (#1968).",
1239
+ }),
1240
+ ),
1241
+ tags: Type.Optional(
1242
+ Type.Array(Type.String(), {
1243
+ description:
1244
+ "One resource_definition_tag row per tag (#1968 verb-UX round 2 — mirrors " +
1245
+ "spellkave_define_entity_type/_condition/_niche's own `tags` fold instead of a separate " +
1246
+ "spellkave_write_rows call).",
1247
+ }),
1248
+ ),
1249
+ });
1250
+
1251
+ export const COST_PARAMS = Type.Object({
1252
+ pool: Type.String({
1253
+ description: "resource_definition_id debited on cast (e.g. a spell-slot pool).",
1254
+ }),
1255
+ amount: Type.Number({ description: "How much to debit per cast." }),
1256
+ });
1257
+
1258
+ export const SHAPE_PARAMS = Type.Object({
1259
+ id: Type.Union([Type.Literal("core/area/node_ball"), Type.Literal("core/area/sphere")], {
1260
+ description:
1261
+ "Closed PoC enum: 'core/area/node_ball' (topological — radius = ball_radius graph-edge hops, 0 = same " +
1262
+ "node) or 'core/area/sphere' (metric — radius = radius_m). Other area shapes need direct authoring.",
1263
+ }),
1264
+ radius: Type.Number({
1265
+ description: "node_ball: integer edge-hop radius. sphere: metric radius_m.",
1266
+ }),
1267
+ });
1268
+
1269
+ export const WRITE_PARAMS = Type.Object({
1270
+ // This union deliberately spans two tiers: kernel write primitives
1271
+ // (ModifyResource/Spawn/Inscribe/ApplyStatus/RemoveCondition map onto
1272
+ // existing K-5-gated FrameWriteOp/EffectPrimitive arms) AND multi-row
1273
+ // content presets (EnvState/OutcomeGraph/ScheduledZone decompose via
1274
+ // compose.ts into those same primitives). None of these literals is a
1275
+ // kernel arm itself — the manifest columns stay open-string (ADR-0018).
1276
+ primitive: Type.Union(
1277
+ [
1278
+ Type.Literal("ModifyResource"),
1279
+ Type.Literal("Spawn"),
1280
+ Type.Literal("Inscribe"),
1281
+ Type.Literal("ApplyStatus"),
1282
+ Type.Literal("RemoveCondition"),
1283
+ Type.Literal("EnvState"),
1284
+ Type.Literal("OutcomeGraph"),
1285
+ Type.Literal("ScheduledZone"),
1286
+ Type.Literal("Clock"),
1287
+ ],
1288
+ {
1289
+ description:
1290
+ "Closed PoC enum — the REAL kernel primitive names (#1968 US9/srd-migration round, never invented; " +
1291
+ "verified against world-fixtures/srd/base/summon.toml + world-fixtures/core/base/affordances.toml + " +
1292
+ "world-fixtures/srd/base/hold-monster.toml + world-fixtures/srd/base/lesser-restoration.toml + " +
1293
+ "world-fixtures/srd/base/darkness.toml + world-fixtures/srd/base/acid-arrow.toml + " +
1294
+ "world-fixtures/srd/base/moonbeam.toml + world-fixtures/srd/base/death-saves.toml): " +
1295
+ "'ModifyResource' (a resource/state delta — the original fireball-wired primitive), 'Spawn' (Brief " +
1296
+ "26 EffectPrimitive::Spawn — instantiate an entity_def at the actor's own node, the find_familiar " +
1297
+ "shape; requires `offered_when.target`), 'Inscribe' (the raw FrameWriteOp::Inscribe trace idiom " +
1298
+ "core/mark/core/pickup/core/drop use — a durable typed footprint, NO ModifyResource delta and NO " +
1299
+ "companion definition row; requires `offered_when.target`), 'ApplyStatus' (lands a condition on the " +
1300
+ "single TargetActor — the B9 Hold-Person/Hold-Monster/Bless-family shape; single-target only, no " +
1301
+ "`offered_when.target`), 'RemoveCondition' (the INVERSE — deletes a matching target_condition row, " +
1302
+ "the Lesser-Restoration cleanse shape; single-target only, no `offered_when.target`), 'EnvState' " +
1303
+ "(#1968 verb-UX round 4 — the Darkness/Silence/Fog AMBIENT-EFFECT shape, compose.ts's 'env-state': " +
1304
+ "the cast's ONLY write is an Inscribe{kind:'spatial_environment_state'} bool marker on the caster's " +
1305
+ "cell (or the target cell — see `env_state_center`); this call auto-creates the backing " +
1306
+ "spatial_state_definitions row, mirroring `cost.pool`'s auto-create; a SEPARATELY-authored consumer " +
1307
+ "affordance reads target.state(env_state_id); single-target only, no `offered_when.target`), " +
1308
+ "'OutcomeGraph' (#1968 verb-UX round 4 — the branch-on-outcome shape, compose.ts's 'outcome-graph': " +
1309
+ "the action's outcome invokes a graph whose `branches` (see that field) each carry their OWN " +
1310
+ "ModifyResource(TargetActor, srd/hp, ...) consequence, selected by the first true edge guard in " +
1311
+ "array order — unlike a gated single-target write, EVERY branch can apply an effect (a Melf's Acid " +
1312
+ "Arrow miss still deals half damage); single-target only, no `offered_when.target`), 'ScheduledZone' " +
1313
+ "(#1968 verb-UX round 5 — the TRUE LINGERING hazard shape, compose.ts's 'scheduled-zone' (ADR-0054): " +
1314
+ "the cast's ONLY direct write is the SAME Inscribe{kind:'spatial_environment_state'} marker EnvState " +
1315
+ "uses (auto-creates the backing spatial_state_definitions row, `zone_state_id`/`zone_intensity`/ " +
1316
+ "`zone_visibility`/`zone_center` — see those fields); it ALSO schedules a subject-bound " +
1317
+ "ScheduleAutonomyJob (`schedule` — repeats/frequency/liveness/source) that re-fires a SEPARATE, " +
1318
+ "self-contained pulse consequence each round — a node-local ForEachActorInRadius (fixed radius, " +
1319
+ "ball_radius 0) wrapping `effect.write.pulse`, which REUSES this same closed enum's two " +
1320
+ "autonomy-clock-eligible bodies ('ModifyResource' damage/heal via `pulse.delta`, or 'ApplyStatus' " +
1321
+ "condition via `pulse.condition`) rather than inventing a third write vocabulary; " +
1322
+ "`effect.per_target_gate` (if set) gates the PULSE body per occupant (the save-negate seam — Stinking " +
1323
+ "Cloud), not the affordance; single-target-only, no `offered_when.target`), 'Clock' (#1968 finding C2 " +
1324
+ "— the SELF-TARGETED multi-ordinal clock shape, compose.ts's 'clock' (the death-saves death-and-dying " +
1325
+ "pattern): unlike every OTHER primitive above (each writes a TargetActor or a radius-selected OTHER " +
1326
+ "actor), a clock's every write targets the ACTING subject alone. `tallies` (see that field) — N bare " +
1327
+ "ModifyResource(actor='Actor', ...) ordinals, authored first, array order = ordinal order — followed " +
1328
+ "by `thresholds` (see that field) — M ForEachActorInRadius(node_ball, ball_radius 0) ordinals wrapping " +
1329
+ "an ApplyStatus/RemoveCondition on 'Actor', reading the tallies' just-written state; requires " +
1330
+ "`offered_when.target: 'self'` (a clock is inherently self-only — there is no 'hit others' reading of " +
1331
+ "it) and needs no separate `cost` (the tallies themselves satisfy MF-VAL-263's on_success ModifyResource " +
1332
+ "requirement); single-target-topology-only, no `effect.shape`/`effect.per_target_gate` (each threshold " +
1333
+ "carries its OWN `when` instead of one shared per-target gate — `effect.per_target_gate`, if set, " +
1334
+ "becomes the AFFORDANCE's own eligibility gate instead, e.g. \"actor.status('dying') == true && ...\", " +
1335
+ "the same seam single-target's attack-roll gate reuses)). " +
1336
+ "'Spawn'/'Inscribe' are NOT FrameWriteOp arms nestable inside a ForEachActorInRadius body — they " +
1337
+ "never combine with `effect.shape`/`effect.per_target_gate` (PoC boundary: only 'ModifyResource' " +
1338
+ "selects actors in a radius). 'ApplyStatus'/'RemoveCondition'/'EnvState'/'OutcomeGraph'/'ScheduledZone'/" +
1339
+ "'Clock' are single-target-only too (PoC boundary: no aoe condition/env-state/outcome-graph/scheduled-" +
1340
+ "zone-CAST/clock pulse is wired — the scheduled-zone shape's OWN pulse is always the fixed node_ball-0 " +
1341
+ "radius, never `effect.shape`) — they never combine with `effect.shape` either ('ScheduledZone' reuses " +
1342
+ "`effect.per_target_gate` for its pulse's per-occupant gate instead, 'Clock' reuses it for the " +
1343
+ "affordance's eligibility gate instead, see above).",
1344
+ },
1345
+ ),
1346
+ // ModifyResource-only fields (aoe AND single-target — see effect.shape).
1347
+ resource: Type.Optional(
1348
+ Type.String({
1349
+ description:
1350
+ "ModifyResource only: must already resolve to an authored resource_definitions row (workspace, " +
1351
+ "live, or the active target) — this PoC does not auto-create write-target resources (only " +
1352
+ "`cost.pool` auto-creates, see the tool description). aoe (effect.shape set): the resource every " +
1353
+ "selected actor's body write targets. single-target (effect.shape omitted, #1968 verb-UX round 2): " +
1354
+ "the resource the ONE TargetActor write targets — defaults to 'srd/hp'-shaped combat use but any " +
1355
+ "already-authored resource/state works (e.g. a non-HP disposition state).",
1356
+ }),
1357
+ ),
1358
+ delta: Type.Optional(
1359
+ Type.String({
1360
+ description:
1361
+ "ModifyResource only: authored Int DSL expression evaluated per target, e.g. '-d6'. aoe: applied " +
1362
+ "to every selected actor. single-target: applied once, to the ONE TargetActor. Ignored (may be " +
1363
+ "omitted) when `attacks` is set.",
1364
+ }),
1365
+ ),
1366
+ // MULTIATTACK (#1968 verb-UX round 3): ModifyResource + single-target ONLY (effect.shape
1367
+ // omitted) — N independent self-gating TargetActor writes in ONE action/consequence (a
1368
+ // monster's Multiattack, e.g. Polar Bear's two Rends; mirrors compose.ts's
1369
+ // `ActorBehavior.attacks` verbatim, the SAME builder every other define_behavior branch
1370
+ // already drives). Each entry's `delta` folds its OWN attack roll into the expression
1371
+ // (e.g. `cond(d20 >= 11, 0 - (1d8 + 5), 0)`), so a per-attack miss zeroes only THAT
1372
+ // attack — not the whole action. The server threads one reducer rng across the sibling
1373
+ // frame_writes (ADR-0045 COND-3 postscript), so N identical attacks still roll
1374
+ // INDEPENDENTLY. When set: `resource`/`delta` (the single top-level fields above) are
1375
+ // IGNORED — every attack write always targets `srd/hp`-shaped `resource` implicitly
1376
+ // (mirrors compose.ts's attacks-branch hardcode, `"srd/hp"`, byte-for-byte — there is no
1377
+ // per-attack resource override in this PoC). The affordance carries NO gate (each
1378
+ // sub-attack self-gates in its own frame_write) — `effect.per_target_gate` MUST be
1379
+ // omitted, and `effect.shape` (aoe) is unsupported (PoC boundary: Multiattack is
1380
+ // single-target only, like ApplyStatus/RemoveCondition above).
1381
+ attacks: Type.Optional(
1382
+ Type.Array(
1383
+ Type.Object({
1384
+ delta: Type.String({
1385
+ description:
1386
+ "This sub-attack's authored Int DSL expression, self-gating its OWN attack roll (e.g. " +
1387
+ "'cond(d20 >= 11, 0 - (1d8 + 5), 0)') — a miss on THIS roll must resolve to 0, not skip " +
1388
+ "the whole action (unlike the single-attack affordance-gated shape).",
1389
+ }),
1390
+ label: Type.Optional(
1391
+ Type.String({ description: "Human tag for this sub-attack (e.g. 'Rend'), report-only." }),
1392
+ ),
1393
+ }),
1394
+ {
1395
+ description:
1396
+ "One entry per sub-attack (2+ for an SRD Multiattack, but generalises to any N) — see this " +
1397
+ "field's own top-level description for the full shape.",
1398
+ },
1399
+ ),
1400
+ ),
1401
+ // Spawn-only field.
1402
+ entity_def: Type.Optional(
1403
+ Type.String({
1404
+ description:
1405
+ "Spawn only: the entity_definitions catalog id to instantiate at the actor's own node (e.g. " +
1406
+ "'srd/monster/cat', mirroring srd/cast_find_familiar) — must already resolve (workspace or live); " +
1407
+ "this PoC does not auto-create the blueprint.",
1408
+ }),
1409
+ ),
1410
+ // Inscribe-only fields (mirrors core/mark's frame_write.Inscribe: kind + payload_json).
1411
+ trace_kind: Type.Optional(
1412
+ Type.String({
1413
+ description:
1414
+ "Inscribe only: the trace's `kind` discriminant (e.g. 'puddle_mark') — an arbitrary authored " +
1415
+ "string; unlike `resource`, this is NEVER ref-checked against a definitions row (core/mark's own " +
1416
+ "'scrape_marks' has none either — FrameWriteOp::Inscribe's own doc: 'a durable typed footprint " +
1417
+ "without a resource delta').",
1418
+ }),
1419
+ ),
1420
+ content: Type.Optional(
1421
+ Type.String({
1422
+ description:
1423
+ "Inscribe only: the trace's `payload_json` content — a JSON-encodable string describing the mark " +
1424
+ '(e.g. \'{"action":"relieve"}\').',
1425
+ }),
1426
+ ),
1427
+ // ApplyStatus/RemoveCondition-only field (#1968 srd-migration round).
1428
+ condition: Type.Optional(
1429
+ Type.String({
1430
+ description:
1431
+ "ApplyStatus/RemoveCondition only: the condition_definitions condition_definition_id landed on " +
1432
+ "(ApplyStatus) or deleted from (RemoveCondition) the single TargetActor — must already resolve " +
1433
+ "(workspace, live, or the active target); this PoC does not auto-create the condition (use " +
1434
+ "spellkave_define_condition first).",
1435
+ }),
1436
+ ),
1437
+ // RemoveCondition-only field.
1438
+ remove_source: Type.Optional(
1439
+ Type.String({
1440
+ description:
1441
+ "RemoveCondition only: an exact source key to match (FrameWriteOp::RemoveCondition's " +
1442
+ "`source_match: Exact`). Omit for the default 'Any' — source-agnostic removal (matches ANY " +
1443
+ "target_condition row for `condition`, regardless of what applied it).",
1444
+ }),
1445
+ ),
1446
+ // EnvState-only fields (#1968 verb-UX round 4 — compose.ts's "env-state" shape).
1447
+ env_state_id: Type.Optional(
1448
+ Type.String({
1449
+ description:
1450
+ "EnvState only: the spatial_state_definitions id this write flips (e.g. 'srd/darkness') — auto-" +
1451
+ "created by this call as a BOOL state def with writer_policy 'world_interaction' (so the apply " +
1452
+ "path may write it at cast time) and a long freshness, mirroring `cost.pool`'s auto-create; this " +
1453
+ "PoC never requires it pre-authored. A separately-authored consumer affordance reads " +
1454
+ "target.state(env_state_id) — this call does not author the consumer.",
1455
+ }),
1456
+ ),
1457
+ env_state_value: Type.Optional(
1458
+ Type.Boolean({
1459
+ description: "EnvState only: the bool value the marker Inscribe writes. Default true ('on').",
1460
+ }),
1461
+ ),
1462
+ env_state_center: Type.Optional(
1463
+ Type.Union([Type.Literal("actor"), Type.Literal("target")], {
1464
+ description:
1465
+ "EnvState only: 'actor' (default) writes the CASTER'S OWN cell (ActorSpatialRef — follows the " +
1466
+ "caster, a Darkness-shaped ambient cast). 'target' anchors on the cast's TARGET cell " +
1467
+ "(TargetSpatialRef) instead.",
1468
+ }),
1469
+ ),
1470
+ // OutcomeGraph-only field (#1968 verb-UX round 4 — compose.ts's "outcome-graph" shape).
1471
+ branches: Type.Optional(
1472
+ Type.Array(
1473
+ Type.Object({
1474
+ node: Type.String({
1475
+ description:
1476
+ "This branch's outcome_graph node id (e.g. 'hit'/'miss'; also the outcome/consequence id stem).",
1477
+ }),
1478
+ guard: Type.String({
1479
+ description:
1480
+ "This branch's edge guard predicate, evaluated root→node in array order — the FIRST true " +
1481
+ "guard wins (e.g. 'd20 >= 13'); the LAST branch should carry a '1 == 1' fallthrough so some " +
1482
+ "branch always selects.",
1483
+ }),
1484
+ delta: Type.String({
1485
+ description:
1486
+ "This branch's authored Int DSL expression — the ModifyResource delta its terminal node's " +
1487
+ "consequence applies when selected (e.g. '0 - 4d4'), written against `subject`'s `resource`.",
1488
+ }),
1489
+ label: Type.Optional(
1490
+ Type.String({ description: "Human tag for this branch, report-only." }),
1491
+ ),
1492
+ subject: Type.Optional(
1493
+ Type.String({
1494
+ description:
1495
+ "This branch's own write subject — a kernel symbolic actor ref: 'TargetActor' (default, " +
1496
+ "the damage-against-target shape every prior branch authored) or 'Actor' (the CASTER, e.g. " +
1497
+ "a defeat-consequence XP credit back to the attacker — playable-fighter-l1-20 D-1). " +
1498
+ "Omit to keep today's byte-identical shape.",
1499
+ }),
1500
+ ),
1501
+ resource: Type.Optional(
1502
+ Type.String({
1503
+ description:
1504
+ "This branch's own write resource — must already resolve to an authored resource_definitions " +
1505
+ "row, same rule as the top-level `resource` field. Defaults to 'srd/hp'. Omit to keep today's " +
1506
+ "byte-identical shape.",
1507
+ }),
1508
+ ),
1509
+ }),
1510
+ {
1511
+ description:
1512
+ "OutcomeGraph only: one entry per branch arm (2+ — see this field's own top-level description). " +
1513
+ "Required, and must be non-empty, when effect.write.primitive is 'OutcomeGraph'.",
1514
+ },
1515
+ ),
1516
+ ),
1517
+ // ScheduledZone-only fields (#1968 verb-UX round 5 — compose.ts's "scheduled-zone" shape,
1518
+ // ADR-0054). `zone_state_id`/`zone_intensity`/`zone_visibility`/`zone_center` drive the
1519
+ // SAME marker-Inscribe machinery as EnvState's `env_state_id`/`env_state_value`/
1520
+ // `env_state_center` (a second field set instead of reusing those verbatim only because
1521
+ // the marker VALUE differs in kind — an int intensity here, a bool here EnvState — everything
1522
+ // else about "which cell, what visibility" is the identical concept).
1523
+ zone_state_id: Type.Optional(
1524
+ Type.String({
1525
+ description:
1526
+ "ScheduledZone only: the spatial_state_definitions id the marker Inscribe (and every pulse) reads/" +
1527
+ "writes (e.g. 'srd/hazard/cloudkill') — auto-created by this call as an INT state def with " +
1528
+ "writer_policy 'world_interaction' and a long freshness, mirroring EnvState's `env_state_id` auto-" +
1529
+ "create (and `cost.pool`'s). Required when effect.write.primitive is 'ScheduledZone'.",
1530
+ }),
1531
+ ),
1532
+ zone_intensity: Type.Optional(
1533
+ Type.Number({
1534
+ description:
1535
+ "ScheduledZone only: the documentary int value the marker Inscribe stamps (e.g. the spell's damage " +
1536
+ "magnitude — Cloudkill's 5d8 stamps 5). Default 0. Never read by the pulse itself (the pulse's own " +
1537
+ "damage/condition comes from `pulse.delta`/`pulse.condition`) — purely an observable marker value.",
1538
+ }),
1539
+ ),
1540
+ zone_visibility: Type.Optional(
1541
+ Type.String({
1542
+ description: "ScheduledZone only: the marker Inscribe's visibility class. Default 'Public'.",
1543
+ }),
1544
+ ),
1545
+ zone_center: Type.Optional(
1546
+ Type.Union([Type.Literal("actor"), Type.Literal("target")], {
1547
+ description:
1548
+ "ScheduledZone only: 'actor' (default) anchors the marker AND every pulse on the CASTER'S CURRENT " +
1549
+ "cell each fire (ActorSpatialRef — a mobile aura that follows the caster). 'target' anchors on the " +
1550
+ "cast's TARGET cell instead (TargetSpatialRef — the captured anchor_place_node_id stays FIXED even " +
1551
+ "if the caster moves; the faithful 'dropped at range' hazard every shipped scheduled-zone spell " +
1552
+ "today uses — Cloudkill/Moonbeam/Stinking Cloud/the scheduled-damage-zone batch). Mirrors EnvState's " +
1553
+ "`env_state_center` — same two-value anchor concept, kept as its own field because it is scoped to " +
1554
+ "a different write primitive.",
1555
+ }),
1556
+ ),
1557
+ schedule: Type.Optional(
1558
+ Type.Object(
1559
+ {
1560
+ repeats: Type.Optional(
1561
+ Type.Number({
1562
+ description:
1563
+ "How many rounds the pulse re-fires — bounds the duration (a subject-bound actor-reaching " +
1564
+ "autonomy job MUST be bounded, server fence + MF-VAL-249). Default 10 (SRD's common " +
1565
+ "'concentration up to 1 minute' → 10 one-tick rounds).",
1566
+ }),
1567
+ ),
1568
+ frequency_ms: Type.Optional(
1569
+ Type.Number({
1570
+ description:
1571
+ "Fiction-millisecond period between pulses. Default 6000 (fires every round).",
1572
+ }),
1573
+ ),
1574
+ requires_subject_alive: Type.Optional(
1575
+ Type.Boolean({
1576
+ description:
1577
+ "Whether the zone dissipates if the caster's entity is removed. Default false (the zone " +
1578
+ "lingers its full duration regardless — the SRD Cloudkill/Moonbeam behaviour). Set true for " +
1579
+ "a concentration-style hazard that ends with its caster.",
1580
+ }),
1581
+ ),
1582
+ source: Type.Optional(
1583
+ Type.String({
1584
+ description:
1585
+ "The cancel-by-source/provenance key stamped on the runtime autonomy_job — author with the " +
1586
+ "{Actor}/{ResponsibleSubject}/{tick} placeholders (ADR-0055 D-3), e.g. " +
1587
+ "'<bundle>/<id>/{Actor}/{tick}', so the scheduler interpolates a PER-CAST-UNIQUE job_id at " +
1588
+ "cast time (two concurrent casts never collide on the autonomy_job PK). Omit for the " +
1589
+ "compose.ts legacy default ('srd/<id>', UNqualified by `bundle` — pass this explicitly for " +
1590
+ "any non-'srd' bundle).",
1591
+ }),
1592
+ ),
1593
+ },
1594
+ {
1595
+ description:
1596
+ "ScheduledZone only: the ADR-0054 autonomy-pulse cadence + provenance. Every field optional — " +
1597
+ "omit the whole object for compose.ts's defaults (repeats 10, frequency_ms 6000, " +
1598
+ "requires_subject_alive false, source 'srd/<id>').",
1599
+ },
1600
+ ),
1601
+ ),
1602
+ pulse: Type.Optional(
1603
+ Type.Object(
1604
+ {
1605
+ primitive: Type.Union([Type.Literal("ModifyResource"), Type.Literal("ApplyStatus")], {
1606
+ description:
1607
+ "The scheduled pulse's OWN per-round frame_write body (wrapped in a fixed node-local " +
1608
+ "ForEachActorInRadius, ball_radius 0, by clusterRows — never `effect.shape`) — REUSES this " +
1609
+ "tool's two autonomy-clock-eligible write shapes rather than a new vocabulary: 'ModifyResource' " +
1610
+ "(a damage/heal delta on 'srd/hp', the Cloudkill/Moonbeam/scheduled-damage-zone-batch shape) or " +
1611
+ "'ApplyStatus' (lands a condition on each occupant, the Stinking Cloud save-or-condition shape " +
1612
+ "— #958 admits ApplyStatus to the subject-bound autonomy fence).",
1613
+ }),
1614
+ delta: Type.Optional(
1615
+ Type.String({
1616
+ description:
1617
+ "pulse.primitive 'ModifyResource' only: the authored Int DSL expression applied to EVERY " +
1618
+ "occupant's srd/hp each pulse (e.g. 'cond(d20 >= 13, 0 - (5d8 / 2), 0 - 5d8)' for save-for-" +
1619
+ "half — fold the save into the delta the same way single-target/aoe do). Required when " +
1620
+ "pulse.primitive is 'ModifyResource'.",
1621
+ }),
1622
+ ),
1623
+ condition: Type.Optional(
1624
+ Type.String({
1625
+ description:
1626
+ "pulse.primitive 'ApplyStatus' only: the condition_definitions id landed on every occupant " +
1627
+ "whose `effect.per_target_gate` passes (e.g. 'srd/poisoned') — must already resolve " +
1628
+ "(workspace, live, or the active target); this PoC does not auto-create it (use " +
1629
+ "spellkave_define_condition first). Required when pulse.primitive is 'ApplyStatus'.",
1630
+ }),
1631
+ ),
1632
+ },
1633
+ {
1634
+ description:
1635
+ "ScheduledZone only: the pulse's own write. Required when effect.write.primitive is " +
1636
+ "'ScheduledZone' — a zone with no pulse body would schedule a job that fires nothing.",
1637
+ },
1638
+ ),
1639
+ ),
1640
+ // Clock-only fields (#1968 finding C2 — compose.ts's "clock" shape, the death-saves
1641
+ // death-and-dying pattern). Both are REQUIRED, non-empty, when effect.write.primitive
1642
+ // is 'Clock' — array order IS ordinal order (tallies first, thresholds after).
1643
+ tallies: Type.Optional(
1644
+ Type.Array(
1645
+ Type.Object({
1646
+ resource: Type.String({
1647
+ description:
1648
+ "Clock only: the resource_definitions id this tally ordinal's bare ModifyResource(actor='Actor', " +
1649
+ "...) reads/writes — must already resolve (workspace, live, or the active target); this PoC does " +
1650
+ "not auto-create tally resources (use spellkave_define_resource first, same posture as " +
1651
+ "effect.write.resource).",
1652
+ }),
1653
+ predicate: Type.Optional(
1654
+ Type.String({
1655
+ description:
1656
+ "Clock only: an authored Bool DSL expression — when set, this ordinal's delta_source becomes " +
1657
+ "'cond(<predicate>, <delta ?? \"1\">, 0)', the increment-on-condition idiom every tally-split " +
1658
+ "ordinal needs (e.g. \"actor.stat('death_save_last_roll') >= 10\" to tally a success). Omit " +
1659
+ "for a raw (non-conditional) `delta` expression instead — the scratch-cell-capture idiom a " +
1660
+ "clock's FIRST ordinal often needs (e.g. \"d20 - actor.stat('death_save_last_roll')\", a " +
1661
+ "set-via-delta that lands exactly on a fresh roll). Exactly one of `predicate`/`delta` must " +
1662
+ "convey the real expression: set `predicate` alone for a plain +1-on-condition tally, `delta` " +
1663
+ "alone for a raw capture, or both when the increment amount is not 1.",
1664
+ }),
1665
+ ),
1666
+ delta: Type.Optional(
1667
+ Type.String({
1668
+ description:
1669
+ "Clock only: with `predicate` set, the increment amount (default '1') — the expression becomes " +
1670
+ "'cond(<predicate>, <delta>, 0)'. With `predicate` OMITTED, this is the WHOLE raw delta_source " +
1671
+ "expression verbatim (the scratch-cell-capture idiom — see `predicate`'s own doc). Required " +
1672
+ "when `predicate` is omitted.",
1673
+ }),
1674
+ ),
1675
+ }),
1676
+ {
1677
+ description:
1678
+ "Clock only: one entry per self-targeted tally ordinal, authored FIRST (array order = ordinal " +
1679
+ "order, before every `thresholds` entry) — see this field's own top-level description. Required, " +
1680
+ "non-empty, when effect.write.primitive is 'Clock'.",
1681
+ },
1682
+ ),
1683
+ ),
1684
+ thresholds: Type.Optional(
1685
+ Type.Array(
1686
+ Type.Object({
1687
+ when: Type.String({
1688
+ description:
1689
+ "Clock only: this threshold ordinal's own ForEachActorInRadius(node_ball, ball_radius 0) " +
1690
+ "predicate_source, evaluated against the POST-tally state (this ordinal runs after every " +
1691
+ "`tallies` entry) — e.g. \"actor.stat('death_save_failures') >= 3\", or an OR-branched short-" +
1692
+ "circuit like a nat-20 immediate-stabilize check. A bare ApplyStatus/RemoveCondition carries no " +
1693
+ "delta/predicate of its own to fold a `cond(...)` into, so this wrapper's own predicate_source " +
1694
+ "is the only way to gate one — safe here specifically because every `tallies` ordinal already " +
1695
+ "wrote 'Actor' alone (never a co-located bystander).",
1696
+ }),
1697
+ apply_status: Type.Optional(
1698
+ Type.String({
1699
+ description:
1700
+ "Clock only: the condition_definitions id this threshold lands on 'Actor' when `when` is " +
1701
+ "true — must already resolve (workspace, live, or the active target); this PoC does not " +
1702
+ "auto-create it (use spellkave_define_condition first). Exactly one of `apply_status`/" +
1703
+ "`remove_condition` must be set per threshold entry.",
1704
+ }),
1705
+ ),
1706
+ remove_condition: Type.Optional(
1707
+ Type.String({
1708
+ description:
1709
+ "Clock only: the condition_definitions id this threshold REMOVES from 'Actor' when `when` is " +
1710
+ "true (the inverse of `apply_status`) — must already resolve. Exactly one of `apply_status`/" +
1711
+ "`remove_condition` must be set per threshold entry.",
1712
+ }),
1713
+ ),
1714
+ remove_condition_source: Type.Optional(
1715
+ Type.String({
1716
+ description:
1717
+ "Clock + `remove_condition` only: an exact source key to match (RemoveCondition's " +
1718
+ "`source_match: Exact`). Omit for the default 'Any' — source-agnostic removal.",
1719
+ }),
1720
+ ),
1721
+ }),
1722
+ {
1723
+ description:
1724
+ "Clock only: one entry per self-targeted threshold ordinal, authored AFTER every `tallies` entry " +
1725
+ "(array order = ordinal order) — see this field's own top-level description. Required, non-empty, " +
1726
+ "when effect.write.primitive is 'Clock'.",
1727
+ },
1728
+ ),
1729
+ ),
1730
+ });
1731
+
1732
+ export const EFFECT_PARAMS = Type.Object({
1733
+ primitive: Type.Union([Type.Literal("ForEachActorInRadius")], {
1734
+ description: "Closed PoC enum — only 'ForEachActorInRadius' is wired.",
1735
+ }),
1736
+ // ModifyResource, present: the AoE-over-actors shape (a ForEachActorInRadius body
1737
+ // selecting every actor in `shape`). ModifyResource, OMITTED (#1968 verb-UX round 2):
1738
+ // the single-target shape — one bare ModifyResource(TargetActor) write, no area-shape
1739
+ // geometry, no actor-radius selection; reuses @spellkave/world-author's `clusterRows`
1740
+ // "single-target" shape (the SAME builder `author-spell-behavior.ts`/`author-monster-
1741
+ // actions.ts` drive directly) — the majority of committed srd spells/monster actions
1742
+ // use exactly this bare shape. MUST be omitted for 'Spawn'/'Inscribe' (#1968 US9 —
1743
+ // neither is a FrameWriteOp arm, so neither ever selects actors in a radius or writes
1744
+ // a single TargetActor either). Enforced at runtime, not in the schema.
1745
+ shape: Type.Optional(SHAPE_PARAMS),
1746
+ per_target_gate: Type.Optional(
1747
+ Type.String({
1748
+ description:
1749
+ "Authored Bool DSL expression gating the write, e.g. 'd20 < 13' (a failed save) or 'd20 >= 13' (a " +
1750
+ "hit). Omit for an ungated write. aoe (effect.shape set): gates the body PER SELECTED ACTOR. " +
1751
+ "single-target (effect.shape omitted): gates the AFFORDANCE itself (a miss/failed-check skips the " +
1752
+ "whole consequence — the attack-roll seam). ModifyResource only — MUST be omitted for " +
1753
+ "'Spawn'/'Inscribe'.",
1754
+ }),
1755
+ ),
1756
+ write: WRITE_PARAMS,
1757
+ });
1758
+
1759
+ export const DEFINE_BEHAVIOR_PARAMS = Type.Object({
1760
+ bundle: Type.Optional(
1761
+ Type.String({
1762
+ description:
1763
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
1764
+ }),
1765
+ ),
1766
+ id: Type.String({
1767
+ description:
1768
+ "Behavior key stem — derives capability_id '<bundle>/spell/<id>' and action_id '<bundle>/cast_<id>' " +
1769
+ "(+ its outcome/affordance/consequence siblings), unless overridden by `capability_id`.",
1770
+ }),
1771
+ capability_id: Type.Optional(
1772
+ Type.String({
1773
+ description:
1774
+ "#1968 verb-UX round 2: override the derived '<bundle>/spell/<id>' capability_id — e.g. for a " +
1775
+ "CATALOG spell whose entity_definitions.entity_def_id already exists under a different id shape " +
1776
+ "(mirrors compose.ts's ActorBehavior.capabilityId — for a catalog spell this MUST equal the " +
1777
+ "catalog entity_def_id so the capability IS the catalog identity, #835). `action_id` is never " +
1778
+ "touched by this — only the capability's own id changes.",
1779
+ }),
1780
+ ),
1781
+ action_prefix: Type.Optional(
1782
+ Type.String({
1783
+ description:
1784
+ "#1968 srd-migration round: override the derived action id's prefix — the full action id is " +
1785
+ "'<bundle>/<action_prefix><id>' (default 'cast_', e.g. id='fireball' -> " +
1786
+ "'<bundle>/cast_fireball'). Pass '' to derive a BARE '<bundle>/<id>' action id (e.g. the Hex/" +
1787
+ "Bless/Bardic-Inspiration condition-modified-roll family's WRITER/CONSUMER pair, whose action ids " +
1788
+ "are '<bundle>/<key>', not '<bundle>/cast_<key>') — mirrors compose.ts's " +
1789
+ "BehaviorConfig.actionPrefix verbatim; outcome/affordance/success ids all derive from the SAME " +
1790
+ "action id, so this affects all four.",
1791
+ }),
1792
+ ),
1793
+ emit_capability: Type.Optional(
1794
+ Type.Boolean({
1795
+ description:
1796
+ "#1968 srd-migration round: whether this call authors a capability_definitions row for " +
1797
+ "`capability_id`/the derived id. Default true. Pass false when the capability ALREADY exists " +
1798
+ "(authored by ANOTHER call/fragment, e.g. a feat grant that already created it) and this call " +
1799
+ "should REUSE it — `required_capability`/`actor_capabilities`/the niche all still key on " +
1800
+ "`capability_id` (which then MUST be set — omitting it AND setting false derives an id no prior " +
1801
+ "call could have authored), but no duplicate capability_definitions row is emitted (mirrors " +
1802
+ "compose.ts's ActorBehavior.emitCapability, a required field there, made an optional smart default " +
1803
+ "here since every prior verb caller wanted true).",
1804
+ }),
1805
+ ),
1806
+ display_name: Type.Optional(
1807
+ Type.String({
1808
+ description:
1809
+ "#1968 verb-UX round 2: overrides the derived 'Cast <TitleCase id>' display name stamped onto " +
1810
+ "every generated row that carries one (capability/action/affordance/outcome). Omit for the smart " +
1811
+ "default — naive per-word title-casing mangles a multi-word id containing a preposition (e.g. " +
1812
+ "'circle_of_death' -> 'Cast Circle Of Death' instead of 'Cast Circle of Death').",
1813
+ }),
1814
+ ),
1815
+ description: Type.Optional(
1816
+ Type.String({
1817
+ description:
1818
+ "Sets the generated capability_definitions row's own `description` column (#1968) — the " +
1819
+ "capability is this behavior's natural authoring-identity anchor, so that is where the " +
1820
+ "description lands (NOT the affordance/action/outcome/consequence/resource rows this verb also " +
1821
+ "generates).",
1822
+ }),
1823
+ ),
1824
+ observation: Type.Optional(
1825
+ Type.String({
1826
+ description:
1827
+ "#1968 B-9: authored PLAYER-facing prose for what a player perceives on a successful manipulate " +
1828
+ "or sensing outcome — distinct from `description` above, which stays operator-only on " +
1829
+ "capability_definitions. Sets the generated outcome_templates row's own `description` column (its " +
1830
+ "actual authoring/read home — see outcome_template.rs's doc comment for why that table, not " +
1831
+ "action_definitions/consequence_templates). May reference ONLY the frozen placeholders " +
1832
+ "`{target_name}`, `{actor_name}`, `{place_name}` (resolved from data the player already sees, " +
1833
+ "never a raw id) — a state-dereferencing value (HP, a resource, a condition) belongs in the DSL " +
1834
+ "outcome expression, not here, and an unknown placeholder or a description over 500 chars is " +
1835
+ "rejected at validation. Omit for the existing default: the tool result carries an honest " +
1836
+ "`observation: null` + `observation_gap`, byte-identical to today.",
1837
+ }),
1838
+ ),
1839
+ tags: Type.Optional(
1840
+ Type.Array(Type.String(), {
1841
+ description:
1842
+ "#1968 verb-UX round 2: the FULL capability_definition_tag AND action_definition_tag row set — " +
1843
+ "when set, REPLACES the single `action_class` tag as the authoritative list for BOTH satellites " +
1844
+ "(include `action_class`'s own value in `tags` too, if wanted — it is not auto-prepended). Omit " +
1845
+ "for the legacy default: `action_class` alone becomes the one action tag, no capability tags — " +
1846
+ "`action_class` itself is REQUIRED either way (no default of its own, #1968 finding A1): this " +
1847
+ "param only controls what ELSE joins it, never whether it is needed.",
1848
+ }),
1849
+ ),
1850
+ communication_speech_act_id: Type.Optional(
1851
+ Type.String({
1852
+ description:
1853
+ "#1968 verb-UX round 4 (SPEECH-ACT lens, Searle) — when set, the generated action's outcome_" +
1854
+ "templates row carries this `communication_speech_act_id`, so the affordance SURFACES as a " +
1855
+ "communication speech act while r_manipulate still EXECUTES the gated consequence normally via " +
1856
+ "`manipulation_action_id` (mirrors compose.ts's ActorBehavior.communicationSpeechActId — the " +
1857
+ "Persuasion 'directive' worked example). Omit for the legacy default: no speech-act framing.",
1858
+ }),
1859
+ ),
1860
+ grant_to: Type.Union([Type.String(), Type.Array(Type.String())], {
1861
+ description:
1862
+ "entity_key of the caster (already placed via spellkave_place_actor) granted the capability — or an " +
1863
+ "ARRAY of entity_keys to grant the SAME capability to several actors in one call (#1968 finding B4: " +
1864
+ "'author once, grant twice' — e.g. two mechanically-identical monsters sharing one scimitar). The " +
1865
+ "capability/action/affordance/outcome/consequence cluster is authored exactly ONCE regardless (keyed " +
1866
+ "off the FIRST entry, which also becomes `defaultCaster` for any `[[actors]]`/entities the shape " +
1867
+ "itself emits, e.g. Spawn's `def_instance`) — every entry gets its OWN `actor_capabilities` grant + " +
1868
+ "`spatial_niche_attachments` row (attached to ITS OWN node, resolved independently per entity_key, " +
1869
+ "exactly like the single-actor case). Each caster needs a nonblank place_node_id, resolved from " +
1870
+ "the workspace before the active target. If a live AUTHOR cannot read the caster's placement, " +
1871
+ "the call fails before writing scratch; supply its known current actor_spatial_locations workspace row. " +
1872
+ "#1968 workspace idempotency: re-authoring the SAME bundle+id " +
1873
+ "REPLACES the WHOLE grant set — an entity_key dropped from the array on a later call has its grant " +
1874
+ "and attachment rows cleared, not left behind (mirrors every other satellite this verb folds).",
1875
+ }),
1876
+ offered_when: Type.Object({
1877
+ reach: Type.Union([Type.Literal("same_node")], {
1878
+ description:
1879
+ "Closed PoC enum — only 'same_node' is wired (its own range_m default, see `range_m`).",
1880
+ }),
1881
+ // #1968 verb-UX round 3 — a melee/ranged attack (or any placement-range write,
1882
+ // ADR-0053) needs a NON-ZERO affordance `range_m` to reach an orthogonally-adjacent
1883
+ // grid cell (#1226 — range_m=0 means touch/same-node only, so a melee attacker on a
1884
+ // grid could never strike an enemy one square away). Overrides `reach: "same_node"`'s
1885
+ // own range_m=0 default (mirrors compose.ts's `ActorBehavior.rangeM`, author with the
1886
+ // `ft()` feet→metric helper — e.g. `ft(5)` for standard 5-ft melee reach — never a
1887
+ // raw metre literal). Omit for the unaffected legacy default (range_m=0, touch range).
1888
+ range_m: Type.Optional(
1889
+ Type.Number({
1890
+ description:
1891
+ "Affordance range_m (metres, ADR-0053 metric embedding) — author via the ft() feet→metric " +
1892
+ "helper (e.g. ft(5) for standard 5-ft melee reach), never a raw metre literal. Omit for the " +
1893
+ "default range_m=0 (touch/same-node only).",
1894
+ }),
1895
+ ),
1896
+ target: Type.Optional(
1897
+ Type.Union([Type.Literal("self"), Type.Literal("place")], {
1898
+ description:
1899
+ "#1968 US9 — a target concept beyond 'ForEachActorInRadius hits others in a radius'. Omit for " +
1900
+ "the legacy default (`effect.write.primitive` must be 'ModifyResource', wrapped in " +
1901
+ "`effect.shape`'s ForEachActorInRadius — unaffected by this param). 'self': the acting actor " +
1902
+ "targets ITSELF (action_definitions.self_eligible=true, mirrors srd/cast_find_familiar's " +
1903
+ "self_eligible=true) — MF-VAL-263 then requires SOME ModifyResource in the on_success chain; " +
1904
+ "`effect.write.primitive: 'ModifyResource'` satisfies it on its own, but 'Spawn'/'Inscribe' " +
1905
+ "need an explicit `cost` (else this tool errors BEFORE validation with a hint). 'place': the " +
1906
+ "write lands at the actor's OWN place_node with NO target-actor selection and NO self-" +
1907
+ "targeting at all (self_eligible stays false — MF-VAL-263 never engages, so no `cost` pool is " +
1908
+ "required or accepted); only 'Spawn'/'Inscribe' support 'place' (no fixture idiom modifies a " +
1909
+ "resource with neither an actor nor a self target).",
1910
+ }),
1911
+ ),
1912
+ }),
1913
+ action_class: Type.String({
1914
+ description:
1915
+ "action_definition_tag applied to the generated action (e.g. 'spell'). REQUIRED — has no default " +
1916
+ "(#1968 finding A1): omitting it throws a named-param error rather than silently authoring a " +
1917
+ "corrupt row. Overridden (not supplemented) by `tags` when that param is set.",
1918
+ }),
1919
+ cost: Type.Optional(COST_PARAMS),
1920
+ effect: EFFECT_PARAMS,
1921
+ // #1968 verb-UX round 3 — DEF-LEVEL capability binding (mirrors compose.ts's
1922
+ // `ActorBehavior.bindToDefinition`/`defInstance` verbatim, the SAME `clusterRows`
1923
+ // builder this verb already drives). When set, this call ALSO emits an
1924
+ // `entity_definition_initial_capability` row binding THIS behavior's capability (the
1925
+ // derived `<bundle>/spell/<id>`, or `capability_id` when overridden) to the named
1926
+ // `entity_definitions` catalog id — e.g. `srd/monster/polar-bear` or
1927
+ // `srd/species/dragonborn`. At instance birth (manifest placement OR runtime Spawn) the
1928
+ // server's `apply_definition_seeds` copies the capability onto the placed/spawned entity
1929
+ // (an entity-anchored `capability` row, ADR-0028 D-5) — so every instance of the
1930
+ // definition is born combat/trait-capable, with NO per-instance `actor_capabilities`
1931
+ // grant. This is the scale unlock the 385-strong `monsters.toml` catalog (and playable
1932
+ // species/class definitions) need to carry proven behaviors by DEFINITION, not by hand.
1933
+ bind_to_definition: Type.Optional(
1934
+ Type.String({
1935
+ description:
1936
+ "An already-authored entity_definitions catalog id (workspace, live, or the active target — " +
1937
+ "same 3-way resolution as the placement tools' `entity_def`) that inherits this call's capability " +
1938
+ "at instance birth via entity_definition_initial_capability. This PoC does not auto-create the " +
1939
+ "definition (use spellkave_define_entity_type first).",
1940
+ }),
1941
+ ),
1942
+ // #1968 verb-UX round 3 — the #728 PROOF instance (mirrors compose.ts's `defInstance`
1943
+ // verbatim): place a FRESH entity carrying `bind_to_definition` as its `entity_def_id`,
1944
+ // with a steering `[[actors]]` body (`entities` + `actors` + `actor_spatial_locations`
1945
+ // rows) but DELIBERATELY NO `actor_capabilities` row — r_manipulate's selection gates on
1946
+ // the caster actually HOLDING the capability (selection.rs distinguishes
1947
+ // "capability-not-held" from "niche-not-anchored"), so this instance can act ONLY if it
1948
+ // inherited the capability from the definition seed; a successful action against it is
1949
+ // therefore proof-POSITIVE of inheritance. REQUIRES `bind_to_definition` (else this tool
1950
+ // errors BEFORE validation naming `def_instance` — an instance with no bound definition
1951
+ // would carry an empty `entity_def_id`, breaking the very inheritance it exists to
1952
+ // prove). #1968 workspace idempotency: `entity_key` is the natural key for `entities`/
1953
+ // `actors` (ROW_KIND_NATURAL_KEY) so a re-run with the SAME `entity_key` upserts; its
1954
+ // `actor_spatial_locations` satellite is cleared+replaced the same way (scoped to
1955
+ // `entity_key`, mirroring the placement tools' own object_state satellite clear).
1956
+ def_instance: Type.Optional(
1957
+ Type.Object({
1958
+ entity_key: Type.String({
1959
+ description:
1960
+ "The proof instance's fully-qualified entity_key, e.g. 'srd/actor/polar-bear-def'.",
1961
+ }),
1962
+ name: Type.String({ description: "entities.name / actors.name for the proof instance." }),
1963
+ node: Type.Optional(
1964
+ Type.String({
1965
+ description:
1966
+ "An already-authored place_node id the proof instance is placed at. Omit to default to " +
1967
+ "the resolved caster node (`grant_to`'s own node) — the niche this behavior's capability " +
1968
+ "attaches is already anchored there.",
1969
+ }),
1970
+ ),
1971
+ }),
1972
+ ),
1973
+ });
1974
+
1975
+ export const INITIAL_STATE_PARAMS = Type.Object({
1976
+ state: Type.String({
1977
+ description:
1978
+ "object_state_definitions OR resource_definitions state_id (MF-VAL-253 accepts either catalog) " +
1979
+ "seeded as an object_state row onto every placed instance of this entity_def. Visibility " +
1980
+ "caveat: a resource-only id has no default_visibility authoring surface, so the seeded row " +
1981
+ "falls back to Public — author a parallel object_state_definitions row when Local/Hidden " +
1982
+ "visibility is wanted.",
1983
+ }),
1984
+ value_bool: Type.Optional(
1985
+ Type.Boolean({
1986
+ description:
1987
+ "Bool carrier (schema default true when neither value_int nor value_text is set). Carrier " +
1988
+ "precedence at commit: value_int > value_text > value_bool.",
1989
+ }),
1990
+ ),
1991
+ value_int: Type.Optional(
1992
+ Type.Number({ description: "Int carrier — highest commit precedence." }),
1993
+ ),
1994
+ value_text: Type.Optional(
1995
+ Type.String({
1996
+ description: "Text carrier — commit precedence between value_int and value_bool.",
1997
+ }),
1998
+ ),
1999
+ });
2000
+
2001
+ export const INITIAL_CAPABILITY_PARAMS = Type.Object({
2002
+ capability: Type.String({
2003
+ description:
2004
+ "capability_definitions capability_id granted unconditionally to every placed instance of this " +
2005
+ "entity_def (an entity_definition_initial_capability seed row).",
2006
+ }),
2007
+ extent_kind_ref: Type.Optional(
2008
+ Type.String({
2009
+ description:
2010
+ "Authored extent kind for this innate grant; preserve the same paired kind/ref contract as actor_capabilities. Omit both fields for an unscoped grant.",
2011
+ }),
2012
+ ),
2013
+ extent_ref: Type.Optional(
2014
+ Type.String({
2015
+ description:
2016
+ "Extent reference paired with extent_kind_ref, copied to every spawned instance's innate capability grant.",
2017
+ }),
2018
+ ),
2019
+ });
2020
+
2021
+ export const INITIAL_CONDITION_PARAMS = Type.Object({
2022
+ condition: Type.String({
2023
+ description:
2024
+ "condition_definitions condition_definition_id seeded onto every placed instance of this entity_def.",
2025
+ }),
2026
+ duration_ticks: Type.Optional(
2027
+ Type.Number({
2028
+ description: "Ticks until auto-expiry; 0 or omitted = permanent (schema default 0).",
2029
+ }),
2030
+ ),
2031
+ });
2032
+
2033
+ export const INITIAL_CONTAINMENT_PARAMS = Type.Object({
2034
+ contained_entity_def_id: Type.String({
2035
+ description:
2036
+ "entity_def_id of the child instance spawned and carried loose (entity_containment, slot_id = '') " +
2037
+ "on every placed/spawned instance of this entity_def (an entity_definition_initial_containment " +
2038
+ "seed row). Structural, not a flat-value copy: the child's OWN initial_* seeds apply to it first " +
2039
+ "(recursion). The containment/equipment graph is cycle-checked server-side (MF-VAL-314) at admission.",
2040
+ }),
2041
+ quantity: Type.Optional(
2042
+ Type.Number({
2043
+ description:
2044
+ "Stack-vs-instance-count rule (ADR-0028 D-6): when the contained definition is stackable, ONE " +
2045
+ "instance is spawned carrying this as its stack count; otherwise this many separate instances " +
2046
+ "are spawned. Default 1.",
2047
+ }),
2048
+ ),
2049
+ });
2050
+
2051
+ export const INITIAL_EQUIPMENT_PARAMS = Type.Object({
2052
+ equipped_entity_def_id: Type.String({
2053
+ description:
2054
+ "entity_def_id of the child instance spawned and equipped into `slot_id` on every placed/spawned " +
2055
+ "instance of this entity_def (an entity_definition_initial_equipment seed row) — a child, one slot, " +
2056
+ "implicit quantity 1. The containment/equipment graph is cycle-checked server-side (MF-VAL-314) at " +
2057
+ "admission, and the equipped definition's slot_compatibility_predicate is checked at commit " +
2058
+ "(MF-VAL-311/-312/-313).",
2059
+ }),
2060
+ slot_id: Type.String({
2061
+ description: "equipment_slot_definitions slot_id the spawned child is equipped into.",
2062
+ }),
2063
+ });
2064
+
2065
+ export const DEFINE_ENTITY_TYPE_PARAMS = Type.Object({
2066
+ bundle: Type.Optional(
2067
+ Type.String({
2068
+ description:
2069
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
2070
+ }),
2071
+ ),
2072
+ id: Type.String({
2073
+ description:
2074
+ "Local entity_def_id stem; the full id is '<bundle>/<id>' (e.g. bundle='core', id='item/sword' -> " +
2075
+ "'core/item/sword'). May itself contain '/' for sub-namespacing (matches the corpus convention, e.g. " +
2076
+ "'npc/caravan', 'class/barbarian').",
2077
+ }),
2078
+ display_name: Type.Optional(
2079
+ Type.String({
2080
+ description:
2081
+ "entity_definitions.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2082
+ }),
2083
+ ),
2084
+ description: Type.Optional(
2085
+ Type.String({
2086
+ description:
2087
+ "entity_definitions.description (#1968 first-class column). PLAYER-REACHABLE: " +
2088
+ "`readAuthorizedItemDetail` (@spellkave/sdk item_detail reader) falls back to this " +
2089
+ "column whenever a placed instance has no per-instance `entity_description` row, so " +
2090
+ "it must hold only what any observer may plausibly know on sight — never stat-block " +
2091
+ "numbers, hidden mechanics, or spoilers. Stat-block/rules prose belongs in an " +
2092
+ "`srd.text` `metadata_attachments` row instead, which keeps it out of description-" +
2093
+ "reading tool responses — but that is not an access-control boundary today (audience " +
2094
+ "enforcement doesn't exist yet, see metadata-attachments.md).",
2095
+ }),
2096
+ ),
2097
+ tags: Type.Optional(
2098
+ Type.Array(Type.String(), { description: "One entity_definition_tag row per tag." }),
2099
+ ),
2100
+ stackable: Type.Optional(
2101
+ Type.Boolean({
2102
+ description:
2103
+ "entity_definitions.stackable — may authored instances use quantity>1 (default false).",
2104
+ }),
2105
+ ),
2106
+ lineage_id: Type.Optional(
2107
+ Type.String({ description: "entity_definitions.lineage_id (default '')." }),
2108
+ ),
2109
+ affordance_seed_id: Type.Optional(
2110
+ Type.String({ description: "entity_definitions.affordance_seed_id (default '')." }),
2111
+ ),
2112
+ on_consume_consequence_id: Type.Optional(
2113
+ Type.String({ description: "entity_definitions.on_consume_consequence_id (default '')." }),
2114
+ ),
2115
+ on_destroy_consequence_id: Type.Optional(
2116
+ Type.String({ description: "entity_definitions.on_destroy_consequence_id (default '')." }),
2117
+ ),
2118
+ grants_capability_while_equipped: Type.Optional(
2119
+ Type.String({
2120
+ description:
2121
+ "CSV capability ids granted to the bearer while it equips an entity of this definition (default '').",
2122
+ }),
2123
+ ),
2124
+ grants_capability_while_present_in_location: Type.Optional(
2125
+ Type.String({
2126
+ description:
2127
+ "CSV capability ids granted to entities at locations where an entity of this definition is " +
2128
+ "present (default '').",
2129
+ }),
2130
+ ),
2131
+ slot_compatibility_predicate: Type.Optional(
2132
+ Type.String({
2133
+ description:
2134
+ "Closed three-form slot-compatibility grammar (not spellkave-dsl); '' or 'true' means any slot, 'false' means none, slot_id == <quoted id> means only that slot.",
2135
+ }),
2136
+ ),
2137
+ initial_states: Type.Optional(
2138
+ Type.Array(INITIAL_STATE_PARAMS, {
2139
+ description:
2140
+ "entity_definition_initial_state rows — seeded onto every placed instance at admission/spawn.",
2141
+ }),
2142
+ ),
2143
+ initial_capabilities: Type.Optional(
2144
+ Type.Array(INITIAL_CAPABILITY_PARAMS, {
2145
+ description: "entity_definition_initial_capability rows — innate capability grants.",
2146
+ }),
2147
+ ),
2148
+ initial_conditions: Type.Optional(
2149
+ Type.Array(INITIAL_CONDITION_PARAMS, {
2150
+ description:
2151
+ "entity_definition_initial_condition rows — conditions born active on every placed instance.",
2152
+ }),
2153
+ ),
2154
+ initial_containment: Type.Optional(
2155
+ Type.Array(INITIAL_CONTAINMENT_PARAMS, {
2156
+ description:
2157
+ "entity_definition_initial_containment rows — each spawns a child instance carried loose (no " +
2158
+ "equipment slot) on every placed/spawned instance. Structural, not a flat-value copy; MF-VAL-314 " +
2159
+ "cycle-checked server-side at admission (not duplicated here).",
2160
+ }),
2161
+ ),
2162
+ initial_equipment: Type.Optional(
2163
+ Type.Array(INITIAL_EQUIPMENT_PARAMS, {
2164
+ description:
2165
+ "entity_definition_initial_equipment rows — each spawns a child instance and equips it into the " +
2166
+ "named slot on every placed/spawned instance. Structural, not a flat-value copy; MF-VAL-314 " +
2167
+ "cycle-checked server-side at admission (not duplicated here).",
2168
+ }),
2169
+ ),
2170
+ });
2171
+
2172
+ export const ROLL_TABLE_ENTRY_PARAMS = Type.Object({
2173
+ result_ref: Type.String({
2174
+ description: "roll_table_entries.result_ref — the drawn value/reference text for this entry.",
2175
+ }),
2176
+ weight: Type.Optional(Type.Number({ description: "roll_table_entries.weight (default 1)." })),
2177
+ tags: Type.Optional(
2178
+ Type.Array(Type.String(), {
2179
+ description: "One roll_table_entry_tag row per tag, for THIS entry.",
2180
+ }),
2181
+ ),
2182
+ });
2183
+
2184
+ export const DEFINE_ROLL_TABLE_PARAMS = Type.Object({
2185
+ bundle: Type.Optional(
2186
+ Type.String({
2187
+ description:
2188
+ "bundle_id stamped on every generated row (roll_table_entries excepted — that row kind carries no " +
2189
+ "bundle_id column). Omit to fall back to `context.defaultBundle` (#1968 smart default).",
2190
+ }),
2191
+ ),
2192
+ id: Type.String({
2193
+ description:
2194
+ "Local roll_table_id stem; the full id is '<bundle>/<id>' (e.g. bundle='core', id='d20' -> 'core/d20').",
2195
+ }),
2196
+ display_name: Type.Optional(
2197
+ Type.String({
2198
+ description:
2199
+ "roll_tables.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2200
+ }),
2201
+ ),
2202
+ result_kind: Type.String({
2203
+ description:
2204
+ "roll_tables.result_kind — an open string (the corpus already uses more than one value, e.g. 'int', " +
2205
+ "'outcome_graph'); no closed PoC enum.",
2206
+ }),
2207
+ description: Type.Optional(
2208
+ Type.String({ description: "roll_tables.description (#1968 first-class column)." }),
2209
+ ),
2210
+ tags: Type.Optional(
2211
+ Type.Array(Type.String(), { description: "One roll_table_tag row per tag." }),
2212
+ ),
2213
+ entries: Type.Array(ROLL_TABLE_ENTRY_PARAMS, {
2214
+ description:
2215
+ "One row per entry, in AUTHORED order. `authored_order` (1-based) and `roll_table_entry_id` " +
2216
+ "('<roll_table_id>:<authored_order>') are BOTH derived from array position + the parent id, matching " +
2217
+ "the corpus convention verbatim — never hand-specified.",
2218
+ }),
2219
+ });
2220
+
2221
+ export const CONDITION_HOOK_PARAMS = Type.Object({
2222
+ event_kind: Type.String({
2223
+ description: "condition_definitions.hooks[].event_kind, e.g. 'Layer2.ApplyConsequence'.",
2224
+ }),
2225
+ detail_filter_source: Type.Optional(
2226
+ Type.String({
2227
+ description:
2228
+ "Inline-DSL Bool sub-expression gating which event instances this hook fires for. Passed through " +
2229
+ "verbatim (single-parse discipline is the server's job, not this verb's).",
2230
+ }),
2231
+ ),
2232
+ expression_source: Type.Optional(
2233
+ Type.String({
2234
+ description:
2235
+ "Inline-DSL Int sub-expression evaluated when the hook fires. Passed through verbatim.",
2236
+ }),
2237
+ ),
2238
+ });
2239
+
2240
+ export const REMOVE_POLICY_PARAMS = Type.Object({
2241
+ id: Type.String({
2242
+ description:
2243
+ "The FULL condition_remove_policy_definitions policy_id (cross-bundle vocabulary — e.g. " +
2244
+ "'core/remove_policy/independent_lifetime'; NOT bundle-prefixed by this verb, unlike `id`).",
2245
+ }),
2246
+ display_name: Type.Optional(
2247
+ Type.String({
2248
+ description:
2249
+ "condition_remove_policy_definitions.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2250
+ }),
2251
+ ),
2252
+ remove_predicate_source: Type.String({
2253
+ description:
2254
+ "DSL Bool expression; the removal path evaluates this instead of branching on the policy id.",
2255
+ }),
2256
+ });
2257
+
2258
+ export const STACKING_PARAMS = Type.Object({
2259
+ id: Type.String({
2260
+ description:
2261
+ "The FULL stacking_discipline_definitions discipline_id (cross-bundle vocabulary — e.g. " +
2262
+ "'core/stacking/single'; NOT bundle-prefixed by this verb, unlike `id`).",
2263
+ }),
2264
+ display_name: Type.Optional(
2265
+ Type.String({
2266
+ description:
2267
+ "stacking_discipline_definitions.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2268
+ }),
2269
+ ),
2270
+ stack_count_outcome_source: Type.String({
2271
+ description:
2272
+ "Int-valued DSL expression over the existing row state (facts: stack_count, expires_at_tick, world_tick).",
2273
+ }),
2274
+ expires_at_tick_outcome_source: Type.String({
2275
+ description: "Int-valued DSL expression; -1 means 'leave the existing expiry unchanged'.",
2276
+ }),
2277
+ });
2278
+
2279
+ export const MODIFIER_PARAMS = Type.Object({
2280
+ id: Type.String({ description: "Local modifier_templates id stem; full id '<bundle>/<id>'." }),
2281
+ display_name: Type.Optional(
2282
+ Type.String({
2283
+ description:
2284
+ "modifier_templates.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2285
+ }),
2286
+ ),
2287
+ applies_to: Type.String({
2288
+ description:
2289
+ "modifier_templates.applies_to — the composition-axis vocabulary id (an authored " +
2290
+ "modifier_target_definitions row, e.g. 'ResolutionCheck'; open string).",
2291
+ }),
2292
+ modifier_expression_source: Type.String({
2293
+ description: "DSL expression producing the modifier's magnitude.",
2294
+ }),
2295
+ predicate_source: Type.Optional(
2296
+ Type.String({ description: "DSL Bool gate; '' (default) means always-active." }),
2297
+ ),
2298
+ priority: Type.Optional(Type.Number({ description: "modifier_templates.priority (default 0)." })),
2299
+ delta_kind: Type.Optional(
2300
+ Type.Union(
2301
+ [
2302
+ Type.Literal("Advantage"),
2303
+ Type.Literal("Disadvantage"),
2304
+ Type.Literal("Plus"),
2305
+ Type.Literal("Times"),
2306
+ Type.Literal("FlatSet"),
2307
+ Type.Literal("Replace"),
2308
+ ],
2309
+ {
2310
+ description:
2311
+ "modifier_templates.delta_kind (default 'Plus') — the validator's OWN closed vocabulary " +
2312
+ "(MF-VAL-243), not a PoC-narrower enum.",
2313
+ },
2314
+ ),
2315
+ ),
2316
+ replace_template_id: Type.Optional(
2317
+ Type.String({
2318
+ description:
2319
+ "Required (by the validator) when delta_kind='Replace' — the modifier_template id this one replaces.",
2320
+ }),
2321
+ ),
2322
+ tags: Type.Optional(
2323
+ Type.Array(Type.String(), {
2324
+ description: "One modifier_template_tag row per tag, for THIS modifier.",
2325
+ }),
2326
+ ),
2327
+ });
2328
+
2329
+ export const DEFINE_CONDITION_PARAMS = Type.Object({
2330
+ bundle: Type.Optional(
2331
+ Type.String({
2332
+ description:
2333
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
2334
+ }),
2335
+ ),
2336
+ id: Type.String({ description: "Local condition_definition_id stem; full id '<bundle>/<id>'." }),
2337
+ display_name: Type.Optional(
2338
+ Type.String({
2339
+ description:
2340
+ "condition_definitions.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2341
+ }),
2342
+ ),
2343
+ description: Type.Optional(
2344
+ Type.String({ description: "condition_definitions.description (#1968 first-class column)." }),
2345
+ ),
2346
+ tags: Type.Optional(
2347
+ Type.Array(Type.String(), { description: "One condition_definition_tag row per tag." }),
2348
+ ),
2349
+ gate_predicate_source: Type.Optional(
2350
+ Type.String({
2351
+ description:
2352
+ "DSL Bool expression gating condition-triggered modifier application (default '').",
2353
+ }),
2354
+ ),
2355
+ observable: Type.Optional(
2356
+ Type.Boolean({ description: "condition_definitions.observable (default true)." }),
2357
+ ),
2358
+ grants_capability_while_active: Type.Optional(
2359
+ Type.Array(Type.String(), {
2360
+ description:
2361
+ "Capability ids GRANTED to the bearer while this condition is active (default []). Enforced in capability_ids_for_actor; use this rather than a status when the thing granted is an ability to act, because affordance_template.capability_id is a structural gate a status cannot reproduce.",
2362
+ }),
2363
+ ),
2364
+ suppresses_capability_while_active: Type.Optional(
2365
+ Type.Array(Type.String(), {
2366
+ description:
2367
+ "Capability ids SUPPRESSED on the bearer AS AN ACTOR while this condition is active (default []). Suppression beats a grant of the same id. Applies to the bearer's own attempts to act only — it never makes the bearer an illegal TARGET, so a spell like Speak with Dead stays authorable against a corpse that cannot itself speak.",
2368
+ }),
2369
+ ),
2370
+ implies: Type.Optional(
2371
+ Type.Array(Type.String(), {
2372
+ description:
2373
+ "condition_definitions.implies — cascade edges (each id is ALSO applied when this condition is applied).",
2374
+ }),
2375
+ ),
2376
+ hooks: Type.Optional(
2377
+ Type.Array(CONDITION_HOOK_PARAMS, { description: "condition_definitions.hooks[]." }),
2378
+ ),
2379
+ remove_time_policy: Type.Optional(
2380
+ Type.String({
2381
+ description:
2382
+ "condition_definitions.remove_time_policy — REFERENCE an existing policy id (default " +
2383
+ "'core/remove_policy/independent_lifetime'). Pass `remove_policy` instead to ALSO author the row.",
2384
+ }),
2385
+ ),
2386
+ remove_policy: Type.Optional(REMOVE_POLICY_PARAMS),
2387
+ stacking_rule: Type.Optional(
2388
+ Type.String({
2389
+ description:
2390
+ "condition_definitions.stacking_rule — REFERENCE an existing discipline id (default " +
2391
+ "'core/stacking/single'). Pass `stacking` instead to ALSO author the row.",
2392
+ }),
2393
+ ),
2394
+ stacking: Type.Optional(STACKING_PARAMS),
2395
+ modifier_template_id: Type.Optional(
2396
+ Type.String({
2397
+ description:
2398
+ "condition_definitions.modifier_template_id — REFERENCE an existing modifier (default ''). Omit " +
2399
+ "when `modifiers` has EXACTLY one entry (auto-wired to it); REQUIRED when `modifiers` has more " +
2400
+ "than one entry (which one is the FK, otherwise ambiguous).",
2401
+ }),
2402
+ ),
2403
+ modifiers: Type.Optional(
2404
+ Type.Array(MODIFIER_PARAMS, {
2405
+ description:
2406
+ "modifier_templates rows (+ their modifier_template_tag satellites) authored in this call.",
2407
+ }),
2408
+ ),
2409
+ });
2410
+
2411
+ export const NICHE_ATTACHMENT_PARAMS = Type.Object({
2412
+ node: Type.Optional(
2413
+ Type.String({
2414
+ description:
2415
+ "spatial_niche_attachments.place_node_id — an authored place_node id. EXACTLY ONE of `node`/`edge` " +
2416
+ "must be set per attachment (the two authored attachment shapes the corpus actually uses).",
2417
+ }),
2418
+ ),
2419
+ edge: Type.Optional(
2420
+ Type.Number({
2421
+ description:
2422
+ "spatial_niche_attachments.place_edge_id — a place_edge numeric id (0 is the SpacetimeDB 'every " +
2423
+ "edge' wildcard convention, e.g. a global passable-portal gate). EXACTLY ONE of `node`/`edge`.",
2424
+ }),
2425
+ ),
2426
+ visibility: Type.Optional(
2427
+ Type.String({ description: "spatial_niche_attachments.visibility (default 'Public')." }),
2428
+ ),
2429
+ condition_bool: Type.Optional(
2430
+ Type.Boolean({ description: "spatial_niche_attachments.condition_bool (default true)." }),
2431
+ ),
2432
+ ecological_invariant: Type.Optional(
2433
+ Type.Boolean({
2434
+ description: "spatial_niche_attachments.ecological_invariant (default false).",
2435
+ }),
2436
+ ),
2437
+ });
2438
+
2439
+ export const DEFINE_NICHE_PARAMS = Type.Object({
2440
+ bundle: Type.Optional(
2441
+ Type.String({
2442
+ description:
2443
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
2444
+ }),
2445
+ ),
2446
+ id: Type.String({ description: "Local niche_id stem; full id '<bundle>/<id>'." }),
2447
+ display_name: Type.Optional(
2448
+ Type.String({
2449
+ description:
2450
+ "niche_definitions.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2451
+ }),
2452
+ ),
2453
+ description: Type.String({
2454
+ description:
2455
+ "niche_definitions.description — REQUIRED (unlike every OTHER verb's optional `description?`): " +
2456
+ "NicheDefinitionRow kept its own PRE-EXISTING required description column through the #1968 " +
2457
+ "description-column decision (no `#[serde(default)]` in the schema); omitting it would author an " +
2458
+ "invalid row, not merely a less-documented one.",
2459
+ }),
2460
+ tags: Type.Optional(
2461
+ Type.Array(Type.String(), { description: "One niche_definition_tag row per tag." }),
2462
+ ),
2463
+ predicate_source: Type.Optional(
2464
+ Type.String({
2465
+ description:
2466
+ "DSL Bool predicate (default '' = trivially-true, matches any candidate target).",
2467
+ }),
2468
+ ),
2469
+ attachments: Type.Optional(
2470
+ Type.Array(NICHE_ATTACHMENT_PARAMS, {
2471
+ description: "spatial_niche_attachments rows binding this niche to place nodes/edges.",
2472
+ }),
2473
+ ),
2474
+ });
2475
+
2476
+ export const DEFINE_AFFORDANCE_PARAMS = Type.Object({
2477
+ bundle: Type.Optional(
2478
+ Type.String({
2479
+ description:
2480
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
2481
+ }),
2482
+ ),
2483
+ id: Type.String({
2484
+ description:
2485
+ "Local affordance key stem — derives template_id '<bundle>/<id>/affordance' and outcome_template_id " +
2486
+ "'<bundle>/<id>/outcome'.",
2487
+ }),
2488
+ niche_id: Type.String({
2489
+ description:
2490
+ "affordance_templates.niche_id — an ALREADY-authored niche_definitions id (workspace, live, or the " +
2491
+ "active target, e.g. via spellkave_define_niche) this call never creates — the trigger surface (a " +
2492
+ "trap/trigger niche, e.g. a pressure plate).",
2493
+ }),
2494
+ capability_id: Type.String({
2495
+ description:
2496
+ "affordance_templates.capability_id — an ALREADY-authored capability_definitions id (workspace, live, " +
2497
+ "or the active target, e.g. 'core/walk') this call never creates — the pre-existing capability any " +
2498
+ "qualifying actor already holds (no NEW grant is authored by this call).",
2499
+ }),
2500
+ display_name: Type.Optional(
2501
+ Type.String({
2502
+ description:
2503
+ "Overrides the derived title-cased `id` for BOTH the outcome and affordance rows.",
2504
+ }),
2505
+ ),
2506
+ predicate_source: Type.Optional(
2507
+ Type.String({
2508
+ description:
2509
+ "affordance_templates.predicate_source — the deterministic ELIGIBILITY gate for whether this " +
2510
+ "affordance offers (e.g. a capability/state check like 'target.stat(\"srd/ac\") >= 1'). A " +
2511
+ "stochastic comparison here (e.g. 'd20 >= 13') is treated as satisfied at materialise time and " +
2512
+ "never gates offer (#1891) — author dice on the action's resolution_predicate_source " +
2513
+ "(resolution_mode = 'Stochastic') instead. Omit for an ungated trigger (predicate_bool = true).",
2514
+ }),
2515
+ ),
2516
+ range_m: Type.Optional(
2517
+ Type.Number({
2518
+ description: "affordance_templates.range_m (ADR-0053 metric embedding). Default 0.",
2519
+ }),
2520
+ ),
2521
+ outcome_expression_source: Type.Optional(
2522
+ Type.String({
2523
+ description:
2524
+ "outcome_templates.outcome_expression_source — invokes a pre-authored effect (e.g. " +
2525
+ "\"invoke_outcome_graph('<bundle>/<id>/graph')\"). Exactly ONE of `outcome_expression_source`/" +
2526
+ "`manipulation_action_id` is required — an affordance with neither would trigger nothing.",
2527
+ }),
2528
+ ),
2529
+ manipulation_action_id: Type.Optional(
2530
+ Type.String({
2531
+ description:
2532
+ "outcome_templates.manipulation_action_id — executes a pre-authored action_definitions row " +
2533
+ "instead (the darkness-consumer idiom, packages/spellkave-srd/src/author/author-darkness.ts's `act_in_dark`). Exactly " +
2534
+ "ONE of `outcome_expression_source`/`manipulation_action_id` is required.",
2535
+ }),
2536
+ ),
2537
+ });
2538
+
2539
+ export const DEFINE_CAPABILITY_PARAMS = Type.Object({
2540
+ bundle: Type.Optional(
2541
+ Type.String({
2542
+ description:
2543
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
2544
+ }),
2545
+ ),
2546
+ id: Type.String({
2547
+ description:
2548
+ "Local capability_id stem; the full id is '<bundle>/<id>' (e.g. bundle='core', id='walk' -> " +
2549
+ "'core/walk'). A handful of corpus capability ids are DELIBERATELY cross-namespace (e.g. " +
2550
+ "'frontier.apply_manifest' under bundle_id='core') — this verb always derives '<bundle>/<id>', so a " +
2551
+ "cross-namespace id stays on spellkave_write_rows (mirrors spellkave_define_entity_type's own " +
2552
+ "cross-namespace carve-out).",
2553
+ }),
2554
+ actor_kind: Type.String({
2555
+ description:
2556
+ "capability_definitions.actor_kind — an open string (the corpus already uses more than one value, " +
2557
+ "e.g. 'entity', 'operator'); no closed PoC enum.",
2558
+ }),
2559
+ display_name: Type.Optional(
2560
+ Type.String({
2561
+ description:
2562
+ "capability_definitions.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2563
+ }),
2564
+ ),
2565
+ description: Type.String({
2566
+ description:
2567
+ "capability_definitions.description — REQUIRED (unlike every OTHER verb's optional `description?`): " +
2568
+ "CapabilityDefinitionRow kept its own PRE-EXISTING required description column through the #1968 " +
2569
+ "description-column decision (no `#[serde(default)]` in the schema); omitting it would author an " +
2570
+ "invalid row, not merely a less-documented one (same carve-out as spellkave_define_niche's own " +
2571
+ "required `description`).",
2572
+ }),
2573
+ default_visibility: Type.Optional(
2574
+ Type.String({
2575
+ description:
2576
+ "capability_definitions.default_visibility — the ADR-0120 read-visibility default concrete grants " +
2577
+ "inherit unless overridden. Omit to default 'Public' (#1968 smart default — matches the schema's " +
2578
+ "own `default_public()` serde default).",
2579
+ }),
2580
+ ),
2581
+ tags: Type.Optional(
2582
+ Type.Array(Type.String(), { description: "One capability_definition_tag row per tag." }),
2583
+ ),
2584
+ });
2585
+
2586
+ export const DEFINE_CONSEQUENCE_PARAMS = Type.Object({
2587
+ bundle: Type.Optional(
2588
+ Type.String({
2589
+ description:
2590
+ "bundle_id stamped on the consequence_templates row. Omit to fall back to `context.defaultBundle` " +
2591
+ "(#1968 smart default).",
2592
+ }),
2593
+ ),
2594
+ id: Type.String({
2595
+ description:
2596
+ "Local consequence_template_id stem; the full id is '<bundle>/<id>' (e.g. bundle='core', " +
2597
+ "id='pickup/success' -> 'core/pickup/success').",
2598
+ }),
2599
+ effect_ref: Type.Optional(
2600
+ Type.String({
2601
+ description:
2602
+ "consequence_templates.effect_refs_csv — an already-authored effect_definitions id this " +
2603
+ "consequence invokes (e.g. a scheduled-zone/summon effect). The corpus never joins more than one " +
2604
+ "id here despite the column's '_csv' name — a single ref, not a real CSV list. Omit for a " +
2605
+ "consequence with no effect_definitions reference.",
2606
+ }),
2607
+ ),
2608
+ description: Type.Optional(
2609
+ Type.String({ description: "consequence_templates.description (#1968 first-class column)." }),
2610
+ ),
2611
+ frame_writes: Type.Optional(
2612
+ Type.Array(
2613
+ Type.Union([Type.Record(Type.String(), Type.Unknown()), Type.Literal("BreakPlaceSeal")]),
2614
+ {
2615
+ description:
2616
+ "consequence_frame_writes rows, in AUTHORED order — each a raw FrameWriteOp body object or the unit string BreakPlaceSeal (e.g. " +
2617
+ "{Inscribe: {...}}, {ModifyResource: {...}}, {PickupTargetItem: {...}}), mirroring " +
2618
+ "spellkave_write_rows' own untyped row shape (the closed Rust FrameWriteOp enum is never modeled " +
2619
+ "in TypeBox here). `ordinal` (0-based) is derived from array position — never hand-specified.",
2620
+ },
2621
+ ),
2622
+ ),
2623
+ });
2624
+
2625
+ export const DEFINE_ACTION_PARAMS = Type.Object({
2626
+ bundle: Type.Optional(
2627
+ Type.String({
2628
+ description:
2629
+ "bundle_id stamped on the action_definitions row. Omit to fall back to `context.defaultBundle` " +
2630
+ "(#1968 smart default).",
2631
+ }),
2632
+ ),
2633
+ id: Type.String({
2634
+ description:
2635
+ "Local action_id stem; the full id is '<bundle>/<id>' (e.g. bundle='core', id='pickup' -> " +
2636
+ "'core/pickup').",
2637
+ }),
2638
+ required_capability: Type.String({
2639
+ description:
2640
+ "action_definitions.required_capability — an ALREADY-authored capability_definitions id (workspace, " +
2641
+ "live, or the active target, e.g. via spellkave_define_capability) this call never creates.",
2642
+ }),
2643
+ on_success: Type.String({
2644
+ description:
2645
+ "action_definitions.on_success — the consequence_templates id (e.g. via spellkave_define_consequence) " +
2646
+ "applied when this action resolves successfully.",
2647
+ }),
2648
+ on_failure: Type.Optional(
2649
+ Type.String({
2650
+ description:
2651
+ "action_definitions.on_failure — the consequence_templates id applied on failure. Omit for none " +
2652
+ "(schema default: empty string).",
2653
+ }),
2654
+ ),
2655
+ display_name: Type.Optional(
2656
+ Type.String({
2657
+ description:
2658
+ "action_definitions.display_name. Omit to derive a title-cased `id` (#1968 smart default).",
2659
+ }),
2660
+ ),
2661
+ cost_time_ms: Type.Optional(
2662
+ Type.Number({
2663
+ description:
2664
+ "action_definitions.cost_time_ms in fiction milliseconds. With spends_channel, omit or set 0 to spend one full channel pool; without a channel, 0 is unmetered.",
2665
+ }),
2666
+ ),
2667
+ resolution_mode: Type.Optional(
2668
+ Type.Union(
2669
+ [Type.Literal("Deterministic"), Type.Literal("Stochastic"), Type.Literal("Deferred")],
2670
+ {
2671
+ description:
2672
+ "action_definitions.resolution_mode. Omit for the schema default ('Deterministic').",
2673
+ },
2674
+ ),
2675
+ ),
2676
+ resolution_predicate_source: Type.Optional(
2677
+ Type.String({
2678
+ description:
2679
+ "action_definitions.resolution_predicate_source — authored boolean DSL for Stochastic resolution. Omit for empty (Deterministic/Deferred).",
2680
+ }),
2681
+ ),
2682
+ resolution_scope: Type.Optional(
2683
+ Type.String({
2684
+ description:
2685
+ "action_definitions.resolution_scope — open authored id selecting scoped actor-side roll modifiers. Omit for no narrow scope.",
2686
+ }),
2687
+ ),
2688
+ non_steering: Type.Optional(
2689
+ Type.Boolean({
2690
+ description:
2691
+ "Explicit author assertion that target effects are cooperative/non-steering and need no target claim. Omit/false for conservative automatic classification; marking a hostile effect true is a content bug.",
2692
+ }),
2693
+ ),
2694
+ session_def_id: Type.Optional(
2695
+ Type.String({
2696
+ description: "action_definitions.session_def_id. Omit for the schema default (empty string).",
2697
+ }),
2698
+ ),
2699
+ resumable: Type.Optional(
2700
+ Type.Boolean({
2701
+ description:
2702
+ "action_definitions.resumable (#2022) — interrupted long-running progress is credited on the next " +
2703
+ "matching promotion (same actor, action, target). Omit for the schema default (false).",
2704
+ }),
2705
+ ),
2706
+ self_eligible: Type.Optional(
2707
+ Type.Boolean({
2708
+ description: "action_definitions.self_eligible. Omit for the schema default (false).",
2709
+ }),
2710
+ ),
2711
+ self_only: Type.Optional(
2712
+ Type.Boolean({
2713
+ description: "action_definitions.self_only (ADR-0075). Omit for the schema default (false).",
2714
+ }),
2715
+ ),
2716
+ spends_channel: Type.Optional(
2717
+ Type.String({
2718
+ description:
2719
+ "action_definitions.spends_channel — an open FK into economy_channel_definitions.id " +
2720
+ "(action-economy budgeting). Omit for unmetered (schema default: absent).",
2721
+ }),
2722
+ ),
2723
+ reaction_eligibility: Type.Optional(
2724
+ Type.String({
2725
+ description:
2726
+ "action_definitions.reaction_eligibility — a DSL predicate over a candidate reactor (§8.4 WHO " +
2727
+ "axis). Omit for not-a-reaction-candidate (schema default: absent).",
2728
+ }),
2729
+ ),
2730
+ reaction_window_ms: Type.Optional(
2731
+ Type.Number({
2732
+ description:
2733
+ "action_definitions.reaction_window_ms. Omit for an implementation default when " +
2734
+ "`reaction_eligibility` is set.",
2735
+ }),
2736
+ ),
2737
+ reaction_trigger: Type.Optional(
2738
+ Type.String({
2739
+ description:
2740
+ "action_definitions.reaction_trigger — a DSL predicate over the triggering event (§8.4 WHAT " +
2741
+ "axis). Omit to provoke on every co-located trigger (schema default: absent).",
2742
+ }),
2743
+ ),
2744
+ description: Type.Optional(
2745
+ Type.String({ description: "action_definitions.description (#1968 first-class column)." }),
2746
+ ),
2747
+ tags: Type.Optional(
2748
+ Type.Array(Type.String(), { description: "One action_definition_tag row per tag." }),
2749
+ ),
2750
+ });
2751
+
2752
+ export const DEFINE_SESSION_PARAMS = Type.Object({
2753
+ bundle: Type.Optional(
2754
+ Type.String({
2755
+ description:
2756
+ "bundle_id stamped on the session_definitions row. Omit to fall back to " +
2757
+ "`context.defaultBundle` (#1968 smart default).",
2758
+ }),
2759
+ ),
2760
+ id: Type.String({
2761
+ description:
2762
+ "Local session_def_id stem; the full id is '<bundle>/<id>' (e.g. bundle='core', " +
2763
+ "id='long_running_action' -> 'core/long_running_action').",
2764
+ }),
2765
+ turn_rule: Type.Optional(
2766
+ Type.String({
2767
+ description:
2768
+ "session_definitions.turn_rule. Omit for 'Sequential' (smart default — the only rule " +
2769
+ "`r_session_open`/`r_advance_turn` schedule today; other values pass through verbatim).",
2770
+ }),
2771
+ ),
2772
+ round_duration_ms: Type.Optional(
2773
+ Type.Number({
2774
+ description:
2775
+ "session_definitions.round_duration_ms (ADR-0037 D-5). Omit for the schema default (0 = " +
2776
+ "unbound). Set 6000 for a default-tick-paced session whose termination_pred should be re-evaluated every " +
2777
+ "world tick (the `core/long_running_action` shape).",
2778
+ }),
2779
+ ),
2780
+ termination_pred: Type.Optional(
2781
+ Type.String({
2782
+ description:
2783
+ "session_definitions.termination_pred — DSL predicate evaluated after every turn advance; on " +
2784
+ "match the session terminates 'completed'. For a time-bound session use " +
2785
+ "\"world.tick - session.stat('opened_at') >= session.stat('promoted_duration_ticks')\". Omit " +
2786
+ "for none (schema default: empty).",
2787
+ }),
2788
+ ),
2789
+ winner_predicate: Type.Optional(
2790
+ Type.String({
2791
+ description: "session_definitions.winner_predicate. Omit for the schema default (empty).",
2792
+ }),
2793
+ ),
2794
+ on_terminate: Type.Optional(
2795
+ Type.String({
2796
+ description:
2797
+ "session_definitions.on_terminate — a consequence_templates id applied on 'completed' " +
2798
+ "termination, before the originating action's own on_success (#2022 binding order). Omit for " +
2799
+ "none (schema default: empty).",
2800
+ }),
2801
+ ),
2802
+ participants_pred: Type.Optional(
2803
+ Type.String({
2804
+ description:
2805
+ "session_definitions.participants_pred. Omit for the schema default (empty; currently not " +
2806
+ "validated at open — architecture Phase E/F).",
2807
+ }),
2808
+ ),
2809
+ busy_allow_pred: Type.Optional(
2810
+ Type.String({
2811
+ description:
2812
+ "session_definitions.busy_allow_pred (#2022) — actions matching this DSL predicate (attempted " +
2813
+ "action tags via target.has_tag(...), id via target.text('action_id')) stay ALLOWED while a " +
2814
+ "participant is busy in this session. Omit for none (with busy_break_pred also absent: full " +
2815
+ "block).",
2816
+ }),
2817
+ ),
2818
+ busy_break_pred: Type.Optional(
2819
+ Type.String({
2820
+ description:
2821
+ "session_definitions.busy_break_pred (#2022) — actions matching this predicate ABANDON the " +
2822
+ "session (abort semantics: on_failure + progress record), then proceed. Omit for none.",
2823
+ }),
2824
+ ),
2825
+ legal_moves_csv: Type.Optional(
2826
+ Type.String({
2827
+ description:
2828
+ "session_definitions.legal_moves_csv — comma-separated move-template ids `r_session_move` " +
2829
+ "accepts. Omit for the schema default (empty).",
2830
+ }),
2831
+ ),
2832
+ initial_state: Type.Optional(
2833
+ Type.String({
2834
+ description: "session_definitions.initial_state (JSON). Omit for the schema default (empty).",
2835
+ }),
2836
+ ),
2837
+ visibility_policy: Type.Optional(
2838
+ Type.String({
2839
+ description: "session_definitions.visibility_policy. Omit for 'Public' (smart default).",
2840
+ }),
2841
+ ),
2842
+ stakes_required: Type.Optional(
2843
+ Type.String({
2844
+ description: "session_definitions.stakes_required. Omit for the schema default (empty).",
2845
+ }),
2846
+ ),
2847
+ turn_scheduler_id: Type.Optional(
2848
+ Type.String({
2849
+ description:
2850
+ "session_definitions.turn_scheduler_id — FK into an ALREADY-authored turn_scheduler row " +
2851
+ "(ADR-0037 D-3/D-4, e.g. a RolledOrder d20 initiative). Omit for the world-active scheduler " +
2852
+ "(schema default: empty).",
2853
+ }),
2854
+ ),
2855
+ auto_join_on_targeting: Type.Optional(
2856
+ Type.Boolean({
2857
+ description:
2858
+ "session_definitions.auto_join_on_targeting (ADR-0037 D-7). Omit for the schema default " +
2859
+ "(false).",
2860
+ }),
2861
+ ),
2862
+ combat_grid_blueprint_id: Type.Optional(
2863
+ Type.String({
2864
+ description:
2865
+ "session_definitions.combat_grid_blueprint_id — FK into an ALREADY-authored " +
2866
+ "combat_grid_blueprint row (ADR-0045/0052 tactical grid). Omit for no automatic grid (schema " +
2867
+ "default: empty).",
2868
+ }),
2869
+ ),
2870
+ grid_edge_affordance_template_id: Type.Optional(
2871
+ Type.String({
2872
+ description:
2873
+ "session_definitions.grid_edge_affordance_template_id. Omit for the schema default (empty).",
2874
+ }),
2875
+ ),
2876
+ grid_edge_affordance_bindings_json: Type.Optional(
2877
+ Type.String({
2878
+ description:
2879
+ "session_definitions.grid_edge_affordance_bindings_json. Omit for the schema default (empty).",
2880
+ }),
2881
+ ),
2882
+ turn_eligibility_pred: Type.Optional(
2883
+ Type.String({
2884
+ description:
2885
+ "session_definitions.turn_eligibility_pred (ADR-0143) — Bool DSL predicate evaluated per " +
2886
+ "participant as `actor` when the turn advances; a false result skips that participant " +
2887
+ "without removing it (it stays targetable and counted). Actor-subject reads only " +
2888
+ "(MF-VAL-334), e.g. \"actor.status('<condition_id>') == false\" or a Bool macro. Omit to " +
2889
+ "hand every participant the turn.",
2890
+ }),
2891
+ ),
2892
+ description: Type.Optional(
2893
+ Type.String({ description: "session_definitions.description (#1968 first-class column)." }),
2894
+ ),
2895
+ });
2896
+
2897
+ export const DEFINE_ACTION_VERB_CONSEQUENCE_PARAMS = Type.Object({
2898
+ effect_ref: Type.Optional(
2899
+ Type.String({
2900
+ description:
2901
+ "consequence_templates.effect_refs_csv — an already-authored effect_definitions id this " +
2902
+ "consequence invokes. Omit for a consequence with no effect_definitions reference (the common case " +
2903
+ "for a check-shaped action).",
2904
+ }),
2905
+ ),
2906
+ description: Type.Optional(
2907
+ Type.String({ description: "consequence_templates.description (#1968 first-class column)." }),
2908
+ ),
2909
+ frame_writes: Type.Optional(
2910
+ Type.Array(
2911
+ Type.Union([Type.Record(Type.String(), Type.Unknown()), Type.Literal("BreakPlaceSeal")]),
2912
+ {
2913
+ description:
2914
+ "consequence_frame_writes rows, in AUTHORED order — each a raw FrameWriteOp body object or the unit string BreakPlaceSeal, mirroring " +
2915
+ "spellkave_define_consequence's own `frame_writes` param verbatim. Omit entirely for MF-VAL-222's " +
2916
+ "own documented no-op shape: a manipulation-dispatchable action needs a non-empty `on_success`, and " +
2917
+ "a consequence_templates row with NO frame_writes at all is the validator-sanctioned way to satisfy " +
2918
+ "that with no actual effect (both this verb's grounding call sites use exactly this shape for most " +
2919
+ "of their generated checks).",
2920
+ },
2921
+ ),
2922
+ ),
2923
+ });
2924
+
2925
+ export const DEFINE_ACTION_VERB_PARAMS = Type.Object({
2926
+ bundle: Type.Optional(
2927
+ Type.String({
2928
+ description:
2929
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
2930
+ }),
2931
+ ),
2932
+ id: Type.String({
2933
+ description:
2934
+ "Local id stem every derived id qualifies against '<bundle>/<id>': action_id itself, plus " +
2935
+ "'<action_id>/outcome' (outcome_templates), '<action_id>/affordance' (affordance_templates), and " +
2936
+ "'<action_id>/success' (consequence_templates, also `action_definitions.on_success`) — matches both " +
2937
+ "grounding call sites' own naming convention verbatim, never a caller override.",
2938
+ }),
2939
+ required_capability: Type.Optional(
2940
+ Type.String({
2941
+ description:
2942
+ "An ALREADY-authored capability_definitions id (workspace, live, or the active target, e.g. via " +
2943
+ "spellkave_define_capability) this call never creates — reused for BOTH " +
2944
+ "action_definitions.required_capability AND affordance_templates.capability_id (this verb's own " +
2945
+ "grounding call sites always use the SAME id in both places), UNLESS `affordance_capability_id` " +
2946
+ "overrides the affordance half (see that param). sk-9ll.6: omit (or pass '') for an UNGATED verb — " +
2947
+ "some authored chains (e.g. an always-hit attack with no gating capability at all) need no capability " +
2948
+ "row, matching the schema's own empty-string default; an empty value is never existence-checked — " +
2949
+ "only a non-empty value still requires a matching capability_definitions row.",
2950
+ }),
2951
+ ),
2952
+ affordance_capability_id: Type.Optional(
2953
+ Type.String({
2954
+ description:
2955
+ "actor-carried-verbs D6: overrides affordance_templates.capability_id independently of " +
2956
+ "action_definitions.required_capability — for the creature-carried-statblock shape, where the " +
2957
+ "ACTION stays keyed on a shared discriminator (e.g. 'srd/action/attack', an initiative-watch " +
2958
+ "read site) while the AFFORDANCE's actual admission gate is a per-creature capability " +
2959
+ "(e.g. 'srd/creature/black-bear/action') granted only to that creature. An ALREADY-authored " +
2960
+ "capability_definitions id (workspace, live, or the active target) this call never creates — " +
2961
+ "same existence-check posture as `required_capability` (a non-empty value is checked; '' is not). " +
2962
+ "Omit for the verb's original single-id posture (default: `required_capability`'s own value).",
2963
+ }),
2964
+ ),
2965
+ niche_id: Type.String({
2966
+ description:
2967
+ "affordance_templates.niche_id. NOT existence-checked against niche_definitions (see this verb's own " +
2968
+ "file-header note) — a bare entity_definition_tag value (e.g. 'creature') or the " +
2969
+ "'capability:<capability_id>' synthetic-niche convention are both LEGAL here despite authoring no " +
2970
+ "niche_definitions row of their own, but a bare entity_definition_tag with no niche_definitions row " +
2971
+ "resolves to the 'place' provider's fail-closed default (requires_spatial_attachment: true) and " +
2972
+ "REJECTS every dispatch with attachment_presence — an actor-carried tag has no place attachment to " +
2973
+ "satisfy it. Pair the tag with an explicit spellkave_write_rows niche_definitions " +
2974
+ "row (provider = 'entity') whenever the niche is entity-provided, not place-attached. An authored " +
2975
+ "niche_definitions id (via spellkave_define_niche) works too.",
2976
+ }),
2977
+ display_name: Type.Optional(
2978
+ Type.String({
2979
+ description:
2980
+ "Overrides the derived title-cased `id` for the action/outcome/affordance rows alike (mirrors " +
2981
+ "spellkave_define_affordance's own shared display_name). Omit for the smart default (#1968).",
2982
+ }),
2983
+ ),
2984
+ description: Type.Optional(
2985
+ Type.String({ description: "action_definitions.description (#1968 first-class column)." }),
2986
+ ),
2987
+ predicate_source: Type.Optional(
2988
+ Type.String({
2989
+ description:
2990
+ "affordance_templates.predicate_source — the deterministic ELIGIBILITY gate for whether this " +
2991
+ "affordance offers. A stochastic comparison here (e.g. 'd20 >= 13') is treated as satisfied at " +
2992
+ "materialise time and never gates offer (#1891) — use this verb's own resolution_predicate_source " +
2993
+ "(with resolution_mode = 'Stochastic') for dice instead. Omit for an ungated trigger " +
2994
+ "(predicate_bool = true) — mirrors spellkave_define_affordance's identical omit-for-ungated " +
2995
+ "convention.",
2996
+ }),
2997
+ ),
2998
+ range_m: Type.Optional(
2999
+ Type.Number({
3000
+ description: "affordance_templates.range_m (ADR-0053 metric embedding). Default 0.",
3001
+ }),
3002
+ ),
3003
+ accepts_global_storm: Type.Optional(
3004
+ Type.Boolean({
3005
+ description:
3006
+ "affordance_templates.accepts_global_storm — modder opt-in acknowledging this template's predicate " +
3007
+ "classifies as Global. Default false.",
3008
+ }),
3009
+ ),
3010
+ cost_time_ms: Type.Optional(
3011
+ Type.Number({
3012
+ description:
3013
+ "action_definitions.cost_time_ms in fiction milliseconds. With spends_channel, omit or set 0 to spend one full channel pool; without a channel, 0 is unmetered.",
3014
+ }),
3015
+ ),
3016
+ on_failure: Type.Optional(
3017
+ Type.String({
3018
+ description:
3019
+ "action_definitions.on_failure — the consequence_templates id applied on failure. Omit for none " +
3020
+ "(schema default: empty string) — this verb only ever AUTHORS the on_success consequence, never an " +
3021
+ "on_failure one (neither grounding call site needs one; author it separately, e.g. via " +
3022
+ "spellkave_define_consequence, if wanted).",
3023
+ }),
3024
+ ),
3025
+ outcome_expression_source: Type.Optional(
3026
+ Type.String({
3027
+ description:
3028
+ "outcome_templates.outcome_expression_source (playable-fighter-l1-20 D-1) — e.g. " +
3029
+ "\"invoke_outcome_graph('<bundle>/<id>/graph')\" to ALSO fire a pre-authored outcome graph, in " +
3030
+ "addition to this action's own `consequence` (independent, sequential — " +
3031
+ "the action runs first, followed by the expression in the same binding context). " +
3032
+ "Every prior corpus example (`srd/acid_arrow`, `srd/outcome_guard_state_branch`) sets this INSTEAD of " +
3033
+ "`consequence` (an empty-consequence, graph-only action) — setting BOTH on this verb's own generated " +
3034
+ "outcome row is new with this field, structurally supported (no validator or runtime exclusivity " +
3035
+ "found), used to bolt a defeat-consequence (e.g. an XP credit) onto an action whose own damage/ " +
3036
+ "condition writes are unchanged. Omit for '' (schema default) — today's byte-identical behavior.",
3037
+ }),
3038
+ ),
3039
+ resolution_mode: Type.Optional(
3040
+ Type.Union(
3041
+ [Type.Literal("Deterministic"), Type.Literal("Stochastic"), Type.Literal("Deferred")],
3042
+ {
3043
+ description:
3044
+ "action_definitions.resolution_mode. Omit for the schema default ('Deterministic').",
3045
+ },
3046
+ ),
3047
+ ),
3048
+ resolution_predicate_source: Type.Optional(
3049
+ Type.String({
3050
+ description:
3051
+ "action_definitions.resolution_predicate_source — authored boolean DSL for Stochastic resolution. Omit for empty (Deterministic/Deferred).",
3052
+ }),
3053
+ ),
3054
+ resolution_scope: Type.Optional(
3055
+ Type.String({
3056
+ description:
3057
+ "action_definitions.resolution_scope — open authored id selecting scoped actor-side roll modifiers. Omit for no narrow scope.",
3058
+ }),
3059
+ ),
3060
+ non_steering: Type.Optional(
3061
+ Type.Boolean({
3062
+ description:
3063
+ "Explicit author assertion that target effects are cooperative/non-steering and need no target claim. Omit/false for conservative automatic classification; marking a hostile effect true is a content bug.",
3064
+ }),
3065
+ ),
3066
+ session_def_id: Type.Optional(
3067
+ Type.String({
3068
+ description: "action_definitions.session_def_id. Omit for the schema default (empty string).",
3069
+ }),
3070
+ ),
3071
+ self_eligible: Type.Optional(
3072
+ Type.Boolean({
3073
+ description: "action_definitions.self_eligible. Omit for the schema default (false).",
3074
+ }),
3075
+ ),
3076
+ self_only: Type.Optional(
3077
+ Type.Boolean({
3078
+ description: "action_definitions.self_only (ADR-0075). Omit for the schema default (false).",
3079
+ }),
3080
+ ),
3081
+ spends_channel: Type.Optional(
3082
+ Type.String({
3083
+ description:
3084
+ "action_definitions.spends_channel — an open FK into economy_channel_definitions.id " +
3085
+ "(action-economy budgeting). Omit for unmetered (schema default: absent).",
3086
+ }),
3087
+ ),
3088
+ reaction_eligibility: Type.Optional(
3089
+ Type.String({
3090
+ description:
3091
+ "action_definitions.reaction_eligibility — a DSL predicate over a candidate reactor (§8.4 WHO " +
3092
+ "axis). Omit for not-a-reaction-candidate (schema default: absent).",
3093
+ }),
3094
+ ),
3095
+ reaction_window_ms: Type.Optional(
3096
+ Type.Number({
3097
+ description:
3098
+ "action_definitions.reaction_window_ms. Omit for an implementation default when " +
3099
+ "`reaction_eligibility` is set.",
3100
+ }),
3101
+ ),
3102
+ reaction_trigger: Type.Optional(
3103
+ Type.String({
3104
+ description:
3105
+ "action_definitions.reaction_trigger — a DSL predicate over the triggering event (§8.4 WHAT " +
3106
+ "axis). Omit to provoke on every co-located trigger (schema default: absent).",
3107
+ }),
3108
+ ),
3109
+ tags: Type.Optional(
3110
+ Type.Array(Type.String(), { description: "One action_definition_tag row per tag." }),
3111
+ ),
3112
+ consequence: Type.Optional(DEFINE_ACTION_VERB_CONSEQUENCE_PARAMS),
3113
+ outcome_id_suffix: Type.Optional(
3114
+ Type.String({
3115
+ description:
3116
+ "sk-9ll.6: the local suffix qualifying the generated outcome_templates id as " +
3117
+ "'<action_id>/<outcome_id_suffix>' (also `affordance_templates.outcome_template_id`). Omit for the " +
3118
+ "legacy default 'outcome'. Raw write_rows chains this verb is meant to fold use several different " +
3119
+ "suffixes here (e.g. 'hit') — set this to match an existing convention instead of falling back to " +
3120
+ "spellkave_write_rows.",
3121
+ }),
3122
+ ),
3123
+ consequence_id_suffix: Type.Optional(
3124
+ Type.String({
3125
+ description:
3126
+ "sk-9ll.6: the local suffix qualifying the generated consequence_templates id (and " +
3127
+ "`action_definitions.on_success`) as '<action_id>/<consequence_id_suffix>'. Omit for the legacy " +
3128
+ "default 'success'. Raw write_rows chains this verb is meant to fold use several different suffixes " +
3129
+ "here (e.g. 'consequence') — set this to match an existing convention instead of falling back to " +
3130
+ "spellkave_write_rows.",
3131
+ }),
3132
+ ),
3133
+ spends_channel_placement: Type.Optional(
3134
+ Type.Union([Type.Literal("affordance"), Type.Literal("action"), Type.Literal("both")], {
3135
+ description:
3136
+ "sk-9ll.6: where a set `spends_channel` value is written. Default 'both' (this verb's original " +
3137
+ "mirrored behavior) — the server reads `spends_channel` off BOTH rows for DIFFERENT purposes: an " +
3138
+ "on-turn action reads the resolved affordance template, while an off-turn reaction uses " +
3139
+ "the originating action definition. A reaction action with no " +
3140
+ "action-row spends_channel is UNMETERED (free). Pass 'affordance' to write it only on " +
3141
+ "affordance_templates (a non-reaction, on-turn-only verb where the action-row copy is genuinely dead), " +
3142
+ "or 'action' to write it only on action_definitions. Ignored when `spends_channel` itself is omitted.",
3143
+ }),
3144
+ ),
3145
+ composes: Type.Optional(
3146
+ Type.Array(Type.String(), {
3147
+ description:
3148
+ "sk-9ll.6: affordance_templates.composes — child affordance_template ids this template unrolls " +
3149
+ "into on a successful manipulate (the action-composition slice, `r_manipulate`'s own composition " +
3150
+ "unroll). Pass-through, verbatim, in AUTHORED order. Omit for the schema default (no composition, " +
3151
+ "this verb's own consequence fires alone).",
3152
+ }),
3153
+ ),
3154
+ communication_speech_act_id: Type.Optional(
3155
+ Type.String({
3156
+ description:
3157
+ "sk-9ll.6: outcome_templates.communication_speech_act_id — when set, the generated outcome " +
3158
+ "surfaces as a communication speech act (mirrors spellkave_define_behavior's own identical " +
3159
+ "pass-through) while r_manipulate still EXECUTES the gated consequence normally. Omit for the " +
3160
+ "legacy default: no speech-act framing.",
3161
+ }),
3162
+ ),
3163
+ });
3164
+
3165
+ export const WRITE_ROWS_PARAMS = Type.Object({
3166
+ bundle: Type.Optional(
3167
+ Type.String({
3168
+ description:
3169
+ "bundle_id stamped on the scaffolded `[[bundles]]` header (self-scaffolds if new) and defaulted onto " +
3170
+ "every row that doesn't already set its own `bundle_id` (only when the target kind's schema has that " +
3171
+ "column). Omit to fall back to `context.defaultBundle` (#1968 smart default) — an error names " +
3172
+ "`bundle` when neither is set.",
3173
+ }),
3174
+ ),
3175
+ kind: Type.String({
3176
+ description:
3177
+ "The exact Manifest row-kind name — a `[[kind]]` TOML table, e.g. 'extent_kind_definitions' or " +
3178
+ "'roll_table_entries'. The generic escape hatch for any row kind the other verbs " +
3179
+ "(author_place/spawn/define_resource/define_behavior) don't cover — validated at call time against " +
3180
+ "@spellkave/world-author's live schema surface (describeManifestSchema()), never a fixed list here; an " +
3181
+ "unsupported kind fails loudly naming the current valid set. See spellkave_docs (manifest-format) for " +
3182
+ "the full row/field reference.",
3183
+ }),
3184
+ rows: Type.Array(Type.Record(Type.String(), Type.Unknown()), {
3185
+ description:
3186
+ "One or more row objects in this kind's own field shape (see the manifest-format reference doc). Each " +
3187
+ "row is merged as-is into the scratch bundle and re-validated with everything else already authored — " +
3188
+ "nothing is persisted unless the WHOLE merged manifest is clean.",
3189
+ }),
3190
+ });
3191
+
3192
+ const OPEN_METADATA_OBJECT = Type.Record(Type.String(), Type.Unknown(), {
3193
+ description:
3194
+ "An open JSON-compatible metadata object. Values are authored unchanged: this shared tool does not reserve a docs, UI, or ruleset schema.",
3195
+ });
3196
+
3197
+ const METADATA_ATTACHMENT_TARGET = Type.Object(
3198
+ {
3199
+ kind: Type.String({
3200
+ description:
3201
+ "An admitted metadata target kind. The shared manifest validator owns the current vocabulary; unsupported values fail at commit.",
3202
+ }),
3203
+ ref: Type.String({ description: "The admitted target's stable id/ref." }),
3204
+ },
3205
+ { additionalProperties: false },
3206
+ );
3207
+
3208
+ const METADATA_BUNDLE = Type.Optional(
3209
+ Type.String({
3210
+ description:
3211
+ "Owning bundle for namespace and attachment updates. Omit to use context.defaultBundle; manifest updates need none.",
3212
+ }),
3213
+ );
3214
+
3215
+ /** A single ergonomic metadata update. `key` is a root metadata key or attachment namespace. */
3216
+ export const SET_METADATA_UPDATE = Type.Union([
3217
+ Type.Object(
3218
+ {
3219
+ target: Type.Literal("manifest"),
3220
+ key: Type.String({ description: "Top-level [metadata] key to replace." }),
3221
+ value: Type.Unknown({
3222
+ description:
3223
+ "A JSON-compatible scalar, array, or object. Open metadata has no shared docs/UI schema.",
3224
+ }),
3225
+ },
3226
+ { additionalProperties: false },
3227
+ ),
3228
+ Type.Object(
3229
+ {
3230
+ target: Type.Literal("namespace"),
3231
+ key: Type.String({ description: "Namespace to register, e.g. 'mymod.hints'." }),
3232
+ value: Type.Object(
3233
+ {
3234
+ audience: Type.String({
3235
+ description: "Explicit namespace audience; no implicit default.",
3236
+ }),
3237
+ description: Type.Optional(Type.String()),
3238
+ on_demand: Type.Optional(
3239
+ Type.Boolean({
3240
+ description:
3241
+ "ADR-0130: reference content (rules text, creation data, docs) delivered only " +
3242
+ "to a client that subscribes public_reference_metadata, never to a play " +
3243
+ "session on connect. Defaults to false (kernel default) when omitted.",
3244
+ }),
3245
+ ),
3246
+ },
3247
+ { additionalProperties: false },
3248
+ ),
3249
+ },
3250
+ { additionalProperties: false },
3251
+ ),
3252
+ Type.Object(
3253
+ {
3254
+ target: METADATA_ATTACHMENT_TARGET,
3255
+ key: Type.String({ description: "Registered metadata namespace for this annotation." }),
3256
+ value: OPEN_METADATA_OBJECT,
3257
+ source: Type.Optional(
3258
+ Type.String({ description: "Attachment source; defaults to 'manifest'." }),
3259
+ ),
3260
+ audience: Type.Optional(
3261
+ Type.String({
3262
+ description: "Registers an absent namespace in this atomic call; never defaults.",
3263
+ }),
3264
+ ),
3265
+ description: Type.Optional(
3266
+ Type.String({
3267
+ description: "Optional description when this call registers the namespace.",
3268
+ }),
3269
+ ),
3270
+ },
3271
+ { additionalProperties: false },
3272
+ ),
3273
+ ]);
3274
+
3275
+ export type SetMetadataUpdate = Static<typeof SET_METADATA_UPDATE>;
3276
+
3277
+ /**
3278
+ * One generic metadata authoring surface, in singleton or explicit atomic-batch
3279
+ * form. The root stays a single object because OpenAI-backed hosts reject a
3280
+ * union at a tool-parameter root (sk-jay0.7.90); the singleton/batch split and
3281
+ * every target-specific `value` shape are enforced at call time against
3282
+ * `SET_METADATA_UPDATE`, which remains the authority on an update's shape.
3283
+ */
3284
+ export const SET_METADATA_PARAMS = Type.Object(
3285
+ {
3286
+ bundle: METADATA_BUNDLE,
3287
+ target: Type.Optional(
3288
+ Type.Union(
3289
+ [Type.Literal("manifest"), Type.Literal("namespace"), METADATA_ATTACHMENT_TARGET],
3290
+ {
3291
+ description:
3292
+ "Singleton form: 'manifest' for a top-level [metadata] key, 'namespace' to register a namespace, " +
3293
+ "or {kind, ref} to attach metadata to an admitted target. Omit when passing updates[].",
3294
+ },
3295
+ ),
3296
+ ),
3297
+ key: Type.Optional(
3298
+ Type.String({
3299
+ description:
3300
+ "Singleton form: the top-level [metadata] key, or the metadata namespace for a registration or attachment.",
3301
+ }),
3302
+ ),
3303
+ value: Type.Optional(
3304
+ Type.Unknown({
3305
+ description:
3306
+ "Singleton form: a JSON-compatible scalar, array, or object for target 'manifest'; " +
3307
+ "{audience, description?} for target 'namespace'; an open metadata object for an attachment target.",
3308
+ }),
3309
+ ),
3310
+ source: Type.Optional(
3311
+ Type.String({
3312
+ description: "Attachment source for the singleton attachment form; defaults to 'manifest'.",
3313
+ }),
3314
+ ),
3315
+ audience: Type.Optional(
3316
+ Type.String({
3317
+ description:
3318
+ "Singleton attachment form: registers an absent namespace in this atomic call; never defaults.",
3319
+ }),
3320
+ ),
3321
+ description: Type.Optional(
3322
+ Type.String({
3323
+ description:
3324
+ "Singleton attachment form: optional description when this call registers the namespace.",
3325
+ }),
3326
+ ),
3327
+ updates: Type.Optional(
3328
+ Type.Array(SET_METADATA_UPDATE, {
3329
+ minItems: 1,
3330
+ description:
3331
+ "Explicit atomic batch. Do not combine with singleton target/key/value fields; every update is validated before anything persists.",
3332
+ }),
3333
+ ),
3334
+ },
3335
+ { additionalProperties: false },
3336
+ );
3337
+
3338
+ export type SetMetadataParams = Static<typeof SET_METADATA_PARAMS>;
3339
+
3340
+ export const DEFINE_BUNDLE_PARAMS = Type.Object({
3341
+ bundle_id: Type.String({
3342
+ description:
3343
+ "bundles.bundle_id — the bundle's own id (e.g. 'srd', 'core'). This verb authors the [[bundles]] " +
3344
+ "header row itself, so there is no separate `bundle` scoping param the way other define_* verbs have: " +
3345
+ "the row being defined IS the bundle.",
3346
+ }),
3347
+ depends_on: Type.Array(Type.String(), {
3348
+ description:
3349
+ "bundles.depends_on — REQUIRED and explicit on purpose (srd-cc executable finding #8): deliberateness " +
3350
+ "is the whole point of this verb over the auto-scaffold every other write verb falls back to (which " +
3351
+ "silently defaults to ['core']). Pass [] for a foundational, drop-in-identity bundle (mirroring " +
3352
+ "core's own depends_on = []), or the real dependency list otherwise.",
3353
+ }),
3354
+ display_name: Type.Optional(
3355
+ Type.String({
3356
+ description:
3357
+ "bundles.display_name. Omit to derive a title-cased `bundle_id` (#1968 smart default).",
3358
+ }),
3359
+ ),
3360
+ version: Type.Optional(Type.String({ description: "bundles.version (default '1.0.0')." })),
3361
+ author: Type.Optional(
3362
+ Type.String({ description: "bundles.author (default 'spellkave-verb-tools')." }),
3363
+ ),
3364
+ description: Type.Optional(
3365
+ Type.String({ description: "Sets the generated bundles row's own `description` column." }),
3366
+ ),
3367
+ default_extent_shape_id: Type.Optional(
3368
+ Type.String({
3369
+ description:
3370
+ "bundles.default_extent_shape_id (place-node-extent D-2): the shape a place_node in this bundle " +
3371
+ "resolves its extent from when it authors none of its own (an area_shape_definition.shape_id " +
3372
+ "reference, e.g. 'core/area/cube'). Omit to leave the bundle without a default — every place_node " +
3373
+ "then MUST author its own explicit extent or fail admission.",
3374
+ }),
3375
+ ),
3376
+ default_extent_params_json: Type.Optional(
3377
+ Type.String({
3378
+ description:
3379
+ "bundles.default_extent_params_json — the params_json paired with default_extent_shape_id (e.g. " +
3380
+ "'{\"extent_m\": 9}' for core/area/cube). Only meaningful alongside default_extent_shape_id.",
3381
+ }),
3382
+ ),
3383
+ });
3384
+
3385
+ export const DEFINE_TRACE_KIND_PLACE_PARAMS = Type.Object({
3386
+ node: Type.String({
3387
+ description:
3388
+ "place_node_traces.node_id — an already-authored place_node id (workspace, live, or the active " +
3389
+ "target) this call never creates. Rejected at commit if it does not resolve to a place_node " +
3390
+ "(sk-9ll.8: no more silent fallback to bundle 'core').",
3391
+ }),
3392
+ });
3393
+
3394
+ export const DEFINE_TRACE_KIND_PARAMS = Type.Object({
3395
+ bundle: Type.Optional(
3396
+ Type.String({
3397
+ description:
3398
+ "bundle_id stamped on every generated row. Omit to fall back to `context.defaultBundle` (#1968 smart default).",
3399
+ }),
3400
+ ),
3401
+ id: Type.String({ description: "Local trace-kind id stem; full id '<bundle>/<id>'." }),
3402
+ location_kinds: Type.Optional(
3403
+ Type.String({
3404
+ description:
3405
+ "trace_kind_definitions.location_kinds — comma-joined registered scopes this kind can attach " +
3406
+ 'to (e.g. "place_node", or "place_node,location_definition"). Default \'place_node\' — the ' +
3407
+ "scope every corpus trace kind uses today, and the only scope `places[]` (below) can target.",
3408
+ }),
3409
+ ),
3410
+ description: Type.Optional(
3411
+ Type.String({
3412
+ description:
3413
+ "trace_kind_definitions.description — human-readable, for authors and operator tooling. " +
3414
+ "Default ''.",
3415
+ }),
3416
+ ),
3417
+ schema_json: Type.Optional(
3418
+ Type.String({
3419
+ description:
3420
+ "trace_kind_definitions.schema_json — canonical JSON schema for the trace payload (flat " +
3421
+ "object mapping a required key to its type name, '?' suffix marks it optional, e.g. " +
3422
+ '\'{"text":"string","addressee":"integer?"}\'). Default \'\' (no contract — most trace kinds ' +
3423
+ "carry no structured payload).",
3424
+ }),
3425
+ ),
3426
+ perceptible_for_ticks: Type.Optional(
3427
+ Type.Number({
3428
+ description:
3429
+ "trace_kind_definitions.perceptible_for_ticks — how many ticks after inscription this kind " +
3430
+ "stays admissible to an ARRIVING observer (ADR-0040 seam B). Omit for unbounded (a standing " +
3431
+ "mark — footprints, a slime trail, a scorch); 0 = perceptible only at the moment of inscription " +
3432
+ "(an EVENT, not a mark — bead sk-n16).",
3433
+ }),
3434
+ ),
3435
+ places: Type.Optional(
3436
+ Type.Array(DEFINE_TRACE_KIND_PLACE_PARAMS, {
3437
+ description:
3438
+ "place_node_traces rows binding this trace kind to already-authored place nodes as a standing, " +
3439
+ "ambient trace. Omit to author only the vocabulary.",
3440
+ }),
3441
+ ),
3442
+ });
3443
+
3444
+ export const EVAL_PARAMS = Type.Object(
3445
+ {
3446
+ expression: Type.String({
3447
+ description: "DSL source text to evaluate offline.",
3448
+ }),
3449
+ kind: Type.Union([Type.Literal("predicate"), Type.Literal("int"), Type.Literal("text")], {
3450
+ description: "Expression result kind: 'predicate', 'int', or 'text'.",
3451
+ }),
3452
+ facts: Type.Optional(
3453
+ Type.Record(Type.String(), Type.Unknown(), {
3454
+ description:
3455
+ "The values the expression reads, grouped by subject (actor, target, location, session, world, actor.wielded_item, equipped items, bindings, event), plus roll_tables, item_sources, roll_modifier_bias, event_kind, occupants_at, peers_near_target, channel_pools. Validated strictly in Rust.",
3456
+ }),
3457
+ ),
3458
+ dice: Type.Optional(
3459
+ Type.Array(Type.Integer({ minimum: 1 }), {
3460
+ description:
3461
+ "Die faces in draw order consumed by stochastic roll operators and roll tables.",
3462
+ }),
3463
+ ),
3464
+ },
3465
+ { additionalProperties: false },
3466
+ );
3467
+
3468
+ export const EXPLAIN_PARAMS = Type.Object({
3469
+ kind: Type.Union([
3470
+ Type.Literal("verb"),
3471
+ Type.Literal("persona"),
3472
+ Type.Literal("role"),
3473
+ Type.Literal("binding"),
3474
+ Type.Literal("capability"),
3475
+ Type.Literal("extent-kind"),
3476
+ Type.Literal("place"),
3477
+ ]),
3478
+ id: Type.String(),
3479
+ target: Type.Optional(Type.Union([Type.Literal("files"), Type.Literal("live")])),
3480
+ });
3481
+
3482
+ export const REMOVE_ENTITY_PARAMS = Type.Object(
3483
+ {
3484
+ entity_key: Type.String({
3485
+ minLength: 1,
3486
+ description:
3487
+ "Exact authored key of the placed entity to remove from the local root and staged scratch, e.g. my_adventure/torch. This edits files only; preview and apply world pruning separately.",
3488
+ }),
3489
+ },
3490
+ { additionalProperties: false },
3491
+ );