@sharpee/if-domain 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/channels/index.d.ts +3 -1
  2. package/channels/index.d.ts.map +1 -1
  3. package/channels/index.js +2 -0
  4. package/channels/index.js.map +1 -1
  5. package/channels/types.d.ts +80 -2
  6. package/channels/types.d.ts.map +1 -1
  7. package/channels/types.js.map +1 -1
  8. package/endings.d.ts +8 -19
  9. package/endings.d.ts.map +1 -1
  10. package/endings.js +9 -20
  11. package/endings.js.map +1 -1
  12. package/grammar/grammar-builder.d.ts +162 -156
  13. package/grammar/grammar-builder.d.ts.map +1 -1
  14. package/grammar/grammar-builder.js +1 -1
  15. package/grammar/grammar-builder.js.map +1 -1
  16. package/grammar/grammar-engine.d.ts +8 -10
  17. package/grammar/grammar-engine.d.ts.map +1 -1
  18. package/grammar/grammar-engine.js +129 -182
  19. package/grammar/grammar-engine.js.map +1 -1
  20. package/grammar/index.d.ts +1 -0
  21. package/grammar/index.d.ts.map +1 -1
  22. package/grammar/index.js +1 -0
  23. package/grammar/index.js.map +1 -1
  24. package/grammar/pattern-compiler.d.ts +20 -16
  25. package/grammar/pattern-compiler.d.ts.map +1 -1
  26. package/grammar/pattern-compiler.js +6 -1
  27. package/grammar/pattern-compiler.js.map +1 -1
  28. package/grammar/rule-order.d.ts +53 -0
  29. package/grammar/rule-order.d.ts.map +1 -0
  30. package/grammar/rule-order.js +47 -0
  31. package/grammar/rule-order.js.map +1 -0
  32. package/grammar/scope-builder.d.ts +10 -3
  33. package/grammar/scope-builder.d.ts.map +1 -1
  34. package/grammar/scope-builder.js +12 -13
  35. package/grammar/scope-builder.js.map +1 -1
  36. package/language-provider.d.ts +10 -1
  37. package/language-provider.d.ts.map +1 -1
  38. package/package.json +3 -3
  39. package/parser-contracts/parser-internals.d.ts +0 -12
  40. package/parser-contracts/parser-internals.d.ts.map +1 -1
  41. package/parser-contracts/parser-internals.js.map +1 -1
  42. package/parser-contracts/parser-types.d.ts +0 -12
  43. package/parser-contracts/parser-types.d.ts.map +1 -1
  44. package/parser-language-provider.d.ts +28 -35
  45. package/parser-language-provider.d.ts.map +1 -1
  46. package/sound/types.d.ts +21 -0
  47. package/sound/types.d.ts.map +1 -1
  48. package/sound/types.js +21 -1
  49. package/sound/types.js.map +1 -1
  50. package/vocabulary-contracts/vocabulary-adapters.d.ts +6 -2
  51. package/vocabulary-contracts/vocabulary-adapters.d.ts.map +1 -1
  52. package/vocabulary-contracts/vocabulary-adapters.js +8 -33
  53. package/vocabulary-contracts/vocabulary-adapters.js.map +1 -1
  54. package/vocabulary-contracts/vocabulary-registry.d.ts +9 -23
  55. package/vocabulary-contracts/vocabulary-registry.d.ts.map +1 -1
  56. package/vocabulary-contracts/vocabulary-registry.js +10 -66
  57. package/vocabulary-contracts/vocabulary-registry.js.map +1 -1
  58. package/vocabulary-contracts/vocabulary-types.d.ts +22 -25
  59. package/vocabulary-contracts/vocabulary-types.d.ts.map +1 -1
  60. package/vocabulary-contracts/vocabulary-types.js.map +1 -1
@@ -21,15 +21,19 @@ class GrammarEngine {
21
21
  * Add a grammar rule.
22
22
  *
23
23
  * ADR-268: insertion is deliberately unsorted — registration order IS
24
- * definition order, the final tiebreak of the resolution order
25
- * (confidence → tier → literal specificity → definition order). Do not
24
+ * definition order, the last of the rule keys of the resolution order
25
+ * (items naming nothing → literal specificity → tier → definition order →
26
+ * names → exact names, `compareGrammarRank`, ADR-386 D5). Do not
26
27
  * reintroduce a sort here; it would erase the semantics of file order.
27
28
  */
28
29
  addRule(rule) {
29
- // Compile the pattern if not already compiled
30
+ // ADR-382 D4: compile from the rule's parts, never its display text,
31
+ // then settle each slot's type on the compiled record.
30
32
  if (!rule.compiledPattern) {
31
- rule.compiledPattern = this.compiler.compile(rule.pattern);
33
+ rule.compiledPattern = this.compiler.compile(rule.parts, rule.pattern);
32
34
  }
35
+ resolveSlotTypes(rule, rule.compiledPattern);
36
+ assignSeats(rule, rule.compiledPattern);
33
37
  this.rules.push(rule);
34
38
  // Index by action for faster lookup
35
39
  const actionRules = this.rulesByAction.get(rule.action) || [];
@@ -58,21 +62,22 @@ class GrammarEngine {
58
62
  }
59
63
  /**
60
64
  * ADR-270 D3: remove registered rules by shape — the alteration model's
61
- * removal primitive. Identity is (action id, pattern string, tier); rule
62
- * ids are nondeterministic and never part of identity.
65
+ * removal primitive. Identity is (action id, shape, tier); the shape test
66
+ * is the caller's (ADR-382 D6: Chord passes `samePatternShape` over the
67
+ * rule's parts). Rule ids are nondeterministic and never part of identity.
63
68
  *
64
69
  * Diagnostic-free by contract: returns the number of rules removed and
65
70
  * never throws — the CALLER owns the miss diagnostic (the Chord loader
66
71
  * raises its LoadError on 0; a TS story checks the return itself).
67
72
  *
68
73
  * @param action The action id whose rule is removed (e.g. 'if.action.taking').
69
- * @param pattern The exact registered pattern string (e.g. 'get :item').
74
+ * @param shapeMatches Whether a rule of that action and tier has the shape to remove.
70
75
  * @param tier The tier to remove from — 'standard' (default) targets the
71
76
  * platform grammar; story-tier rules are never touched unless asked.
72
77
  * @returns The number of rules removed (0 = no rule matched the shape).
73
78
  */
74
- removeRules(action, pattern, tier = 'standard') {
75
- const matches = (rule) => rule.action === action && rule.pattern === pattern && rule.tier === tier;
79
+ removeRules(action, shapeMatches, tier = 'standard') {
80
+ const matches = (rule) => rule.action === action && rule.tier === tier && shapeMatches(rule);
76
81
  const removed = this.rules.filter(matches).length;
77
82
  if (removed === 0)
78
83
  return 0;
@@ -112,9 +117,12 @@ class GrammarEngine {
112
117
  const engine = this;
113
118
  return {
114
119
  define(pattern) {
120
+ // ADR-382 D3: the text is parsed once, here; a malformed pattern
121
+ // throws at the definition that wrote it.
115
122
  const rule = {
116
123
  id: `rule_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
117
124
  pattern,
125
+ parts: engine.compiler.parse(pattern),
118
126
  slots: new Map(),
119
127
  tier
120
128
  };
@@ -137,32 +145,24 @@ class GrammarEngine {
137
145
  rule.slots.set(slot, slotConstraint);
138
146
  return builder;
139
147
  },
140
- mapsTo(action) {
141
- rule.action = action;
142
- return builder;
143
- },
144
- withSemanticVerbs(verbs) {
145
- if (!rule.semantics)
146
- rule.semantics = {};
147
- rule.semantics.verbs = verbs;
148
- return builder;
149
- },
150
- withSemanticPrepositions(prepositions) {
151
- if (!rule.semantics)
152
- rule.semantics = {};
153
- rule.semantics.prepositions = prepositions;
148
+ seat(slot, seat) {
149
+ const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
150
+ slotConstraint.seat = seat;
151
+ rule.slots.set(slot, slotConstraint);
154
152
  return builder;
155
153
  },
156
- withSemanticDirections(directions) {
157
- if (!rule.semantics)
158
- rule.semantics = {};
159
- rule.semantics.directions = directions;
154
+ mapsTo(action) {
155
+ rule.action = action;
160
156
  return builder;
161
157
  },
162
158
  withDefaultSemantics(defaults) {
163
159
  rule.defaultSemantics = defaults;
164
160
  return builder;
165
161
  },
162
+ when(predicate) {
163
+ rule.when = predicate;
164
+ return builder;
165
+ },
166
166
  // ADR-082: Typed Value Slots
167
167
  number(slot) {
168
168
  const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
@@ -239,159 +239,30 @@ class GrammarEngine {
239
239
  };
240
240
  return builder;
241
241
  },
242
- forAction(actionId) {
243
- // Accumulated configuration
244
- const verbList = [];
245
- const patternList = [];
246
- const fullPatternList = []; // ADR-271 D3: complete lines, verb included
247
- const directionMap = {};
248
- const slotConstraints = new Map();
249
- const slotTypes = new Map();
250
- let defaultSemantics;
251
- const actionBuilder = {
252
- verbs(verbs) {
253
- verbList.push(...verbs);
254
- return actionBuilder;
255
- },
256
- pattern(pattern) {
257
- patternList.push(pattern);
258
- return actionBuilder;
259
- },
260
- patterns(patterns) {
261
- patternList.push(...patterns);
262
- return actionBuilder;
263
- },
264
- fullPattern(pattern) {
265
- if (!pattern.trim()) {
266
- throw new Error('fullPattern() requires a non-empty pattern line');
267
- }
268
- fullPatternList.push(pattern);
269
- return actionBuilder;
270
- },
271
- directions(map) {
272
- Object.assign(directionMap, map);
273
- return actionBuilder;
274
- },
275
- where(slot, constraint) {
276
- const existing = slotConstraints.get(slot) || [];
277
- existing.push({ constraint });
278
- slotConstraints.set(slot, existing);
279
- return actionBuilder;
280
- },
281
- withDefaultSemantics(defaults) {
282
- defaultSemantics = defaults;
283
- return actionBuilder;
284
- },
285
- slotType(slot, type) {
286
- slotTypes.set(slot, type);
287
- return actionBuilder;
288
- },
289
- build() {
290
- // Apply a slot's declared type via the matching PatternBuilder method
291
- const applySlotType = (builder, slot, type) => {
292
- switch (type) {
293
- case grammar_builder_js_1.SlotType.TEXT:
294
- return builder.text(slot);
295
- case grammar_builder_js_1.SlotType.INSTRUMENT:
296
- return builder.instrument(slot);
297
- case grammar_builder_js_1.SlotType.NUMBER:
298
- return builder.number(slot);
299
- case grammar_builder_js_1.SlotType.ORDINAL:
300
- return builder.ordinal(slot);
301
- case grammar_builder_js_1.SlotType.TIME:
302
- return builder.time(slot);
303
- case grammar_builder_js_1.SlotType.DIRECTION:
304
- return builder.direction(slot);
305
- case grammar_builder_js_1.SlotType.MANNER:
306
- return builder.manner(slot);
307
- case grammar_builder_js_1.SlotType.TOPIC:
308
- // ADR-267 D11: `topic()` existed on PatternBuilder but was
309
- // missing here, so a declared TOPIC slot silently dropped.
310
- return builder.topic(slot);
311
- default:
312
- return builder;
313
- }
314
- };
315
- // Generate verb × pattern combinations
316
- if (verbList.length > 0 && patternList.length > 0) {
317
- for (const verb of verbList) {
318
- for (const patternTemplate of patternList) {
319
- // Combine verb with pattern template
320
- const fullPattern = patternTemplate.trim()
321
- ? `${verb} ${patternTemplate}`
322
- : verb;
323
- // Create the rule using the existing define() API
324
- let builder = engine.createBuilder(tier).define(fullPattern);
325
- builder = builder.mapsTo(actionId);
326
- if (defaultSemantics) {
327
- builder = builder.withDefaultSemantics(defaultSemantics);
328
- }
329
- // Apply slot constraints
330
- for (const [slot, constraints] of slotConstraints) {
331
- for (const { constraint } of constraints) {
332
- builder = builder.where(slot, constraint);
333
- }
334
- }
335
- // Apply slot types
336
- for (const [slot, type] of slotTypes) {
337
- builder = applySlotType(builder, slot, type);
338
- }
339
- builder.build();
340
- }
341
- }
342
- }
343
- // ADR-271 D3: complete pattern lines (verb included) — one rule
344
- // each, no verb cross-product. Slot-scoped configuration
345
- // (.where(), slotType) attaches only where the line carries the
346
- // slot (D2: a constraint gates the rules that have the slot,
347
- // never an unrelated line of the same action).
348
- for (const fullPattern of fullPatternList) {
349
- const lineSlots = new Set(fullPattern
350
- .split(/\s+/)
351
- .filter((w) => w.startsWith(':'))
352
- .map((w) => w.slice(1).replace(/\.\.\.$/, '')));
353
- let builder = engine.createBuilder(tier).define(fullPattern);
354
- builder = builder.mapsTo(actionId);
355
- if (defaultSemantics) {
356
- builder = builder.withDefaultSemantics(defaultSemantics);
357
- }
358
- for (const [slot, constraints] of slotConstraints) {
359
- if (!lineSlots.has(slot))
360
- continue;
361
- for (const { constraint } of constraints) {
362
- builder = builder.where(slot, constraint);
363
- }
364
- }
365
- for (const [slot, type] of slotTypes) {
366
- if (!lineSlots.has(slot))
367
- continue;
368
- builder = applySlotType(builder, slot, type);
369
- }
370
- builder.build();
371
- }
372
- // Generate standalone verb patterns (verb only, no template)
373
- if (verbList.length > 0 && patternList.length === 0) {
374
- for (const verb of verbList) {
375
- let builder = engine.createBuilder(tier).define(verb);
376
- builder = builder.mapsTo(actionId);
377
- if (defaultSemantics) {
378
- builder = builder.withDefaultSemantics(defaultSemantics);
379
- }
380
- builder.build();
381
- }
382
- }
383
- // Generate direction patterns
384
- for (const [canonical, aliases] of Object.entries(directionMap)) {
385
- for (const alias of aliases) {
386
- let builder = engine.createBuilder(tier).define(alias);
387
- builder = builder.mapsTo(actionId);
388
- builder = builder.withDefaultSemantics({ direction: canonical });
389
- builder.build();
390
- }
391
- }
392
- }
393
- };
394
- return actionBuilder;
242
+ rule(spec) {
243
+ if (!spec.action) {
244
+ throw new Error(`Grammar rule "${spec.pattern}" must have an action`);
245
+ }
246
+ const slots = new Map();
247
+ for (const [name, config] of Object.entries(spec.slots ?? {})) {
248
+ slots.set(name, {
249
+ name,
250
+ constraints: [...(config.constraints ?? [])],
251
+ slotType: config.type,
252
+ vocabularyCategory: config.vocabularyCategory,
253
+ ...(config.seat ? { seat: config.seat } : {}),
254
+ });
255
+ }
256
+ engine.addRule({
257
+ id: `rule_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
258
+ pattern: spec.pattern,
259
+ parts: spec.parts,
260
+ slots,
261
+ action: spec.action,
262
+ tier,
263
+ ...(spec.defaults ? { defaultSemantics: spec.defaults } : {}),
264
+ ...(spec.when ? { when: spec.when } : {}),
265
+ });
395
266
  },
396
267
  getRules() {
397
268
  return engine.getRules();
@@ -399,11 +270,87 @@ class GrammarEngine {
399
270
  clear() {
400
271
  engine.clear();
401
272
  },
402
- removeRules(action, pattern, tier = 'standard') {
403
- return engine.removeRules(action, pattern, tier);
273
+ removeRules(action, shapeMatches, tier = 'standard') {
274
+ return engine.removeRules(action, shapeMatches, tier);
404
275
  }
405
276
  };
406
277
  }
407
278
  }
408
279
  exports.GrammarEngine = GrammarEngine;
280
+ /**
281
+ * Settle each configured slot's type on the rule's compiled slot records
282
+ * (ADR-382 D4). A greedy slot is TEXT_GREEDY; a non-greedy slot takes the
283
+ * configured type, keeping the compiler's ENTITY when none is configured.
284
+ * @param rule The rule whose per-slot configuration is applied
285
+ * @param compiled The rule's compiled pattern; its slot records are updated
286
+ * @throws Error when configuration names a slot the pattern lacks, or types
287
+ * a greedy slot as anything but TEXT_GREEDY
288
+ */
289
+ function resolveSlotTypes(rule, compiled) {
290
+ for (const [name, config] of rule.slots) {
291
+ const slot = compiled.slotsByName.get(name);
292
+ if (!slot) {
293
+ throw new Error(`Grammar rule "${rule.pattern}" configures slot '${name}', which its pattern does not have`);
294
+ }
295
+ if (config.slotType === undefined)
296
+ continue;
297
+ if (slot.greedy && config.slotType !== grammar_builder_js_1.SlotType.TEXT_GREEDY) {
298
+ throw new Error(`Grammar rule "${rule.pattern}" types greedy slot '${name}' as ${config.slotType}; a greedy slot is always ${grammar_builder_js_1.SlotType.TEXT_GREEDY}`);
299
+ }
300
+ slot.slotType = config.slotType;
301
+ }
302
+ }
303
+ /** The seats an entity slot can take, in the order the positional default fills them. */
304
+ const SEATS = ['direct', 'indirect'];
305
+ /**
306
+ * Seat every ENTITY slot on the rule's compiled slot records (ADR-383 D1,
307
+ * D2), once types are settled. Declared seats are taken first; then each
308
+ * undeclared entity slot, in pattern order, takes the first seat still
309
+ * free. With nothing declared that is the positional rule: the first entity
310
+ * slot direct, the second indirect, optional slots counted. Every other
311
+ * slot type is seated by its type and carries no seat. Recomputed from
312
+ * scratch on each build, so a pre-compiled pattern added twice is seated
313
+ * the same way; the records are written only once every seat is settled,
314
+ * so a refused rule leaves its pattern's seats as they were.
315
+ * @param rule The rule whose per-slot seat declarations are applied
316
+ * @param compiled The rule's compiled pattern; its slot records are updated
317
+ * @throws Error when a seat is declared on a slot that is not an entity
318
+ * slot, when two entity slots hold one seat, or when an entity slot is
319
+ * left with no free seat (a third entity slot)
320
+ */
321
+ function assignSeats(rule, compiled) {
322
+ const seatOf = new Map();
323
+ const holder = new Map();
324
+ for (const [name, config] of rule.slots) {
325
+ if (config.seat === undefined)
326
+ continue;
327
+ const slot = compiled.slotsByName.get(name);
328
+ if (slot.slotType !== grammar_builder_js_1.SlotType.ENTITY) {
329
+ throw new Error(`Grammar rule "${rule.pattern}" seats slot '${name}' as ${config.seat}, but its type is ${slot.slotType}; only an entity slot takes a seat`);
330
+ }
331
+ const other = holder.get(config.seat);
332
+ if (other !== undefined) {
333
+ throw new Error(`Grammar rule "${rule.pattern}" seats both '${other}' and '${name}' as ${config.seat}`);
334
+ }
335
+ holder.set(config.seat, name);
336
+ seatOf.set(name, config.seat);
337
+ }
338
+ for (const slot of compiled.slots) {
339
+ if (slot.slotType !== grammar_builder_js_1.SlotType.ENTITY || seatOf.has(slot.name))
340
+ continue;
341
+ const free = SEATS.find((seat) => !holder.has(seat));
342
+ if (free === undefined) {
343
+ throw new Error(`Grammar rule "${rule.pattern}" has more entity slots than seats: '${slot.name}' has none left (direct and indirect are taken)`);
344
+ }
345
+ holder.set(free, slot.name);
346
+ seatOf.set(slot.name, free);
347
+ }
348
+ for (const slot of compiled.slots) {
349
+ const seat = seatOf.get(slot.name);
350
+ if (seat === undefined)
351
+ delete slot.seat;
352
+ else
353
+ slot.seat = seat;
354
+ }
355
+ }
409
356
  //# sourceMappingURL=grammar-engine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grammar-engine.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/grammar-engine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6DAY8B;AAe9B;;;GAGG;AACH,MAAsB,aAAa;IACvB,KAAK,GAAkB,EAAE,CAAC;IAC1B,aAAa,GAA+B,IAAI,GAAG,EAAE,CAAC;IACtD,QAAQ,CAAkB;IAEpC,YAAY,QAAyB;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,IAAiB;QACvB,8CAA8C;QAC9C,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEtB,oCAAoC;QACpC,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC9D,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,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,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gCACvD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gCACnC,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,SAA4C,EAAE,CAAC,CAAC;gCACpG,OAAO,CAAC,KAAK,EAAE,CAAC;4BAClB,CAAC;wBACH,CAAC;oBACH,CAAC;iBACF,CAAC;gBAEF,OAAO,aAAa,CAAC;YACvB,CAAC;YAED,QAAQ;gBACN,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC;YAED,KAAK;gBACH,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;YAED,WAAW,CAAC,MAAc,EAAE,OAAe,EAAE,OAAoB,UAAU;gBACzE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACnD,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AArdD,sCAqdC"}
1
+ {"version":3,"file":"grammar-engine.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/grammar-engine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6DAe8B;AAW9B;;;GAGG;AACH,MAAsB,aAAa;IACvB,KAAK,GAAkB,EAAE,CAAC;IAC1B,aAAa,GAA+B,IAAI,GAAG,EAAE,CAAC;IACtD,QAAQ,CAAkB;IAEpC,YAAY,QAAyB;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,IAAiB;QACvB,qEAAqE;QACrE,uDAAuD;QACvD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzE,CAA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AAC;IAED,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC;;YACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -5,6 +5,7 @@
5
5
  export * from './grammar-builder.js';
6
6
  export * from './pattern-compiler.js';
7
7
  export * from './grammar-engine.js';
8
+ export * from './rule-order.js';
8
9
  export * from './scope-builder.js';
9
10
  export * from './vocabulary-provider.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
package/grammar/index.js CHANGED
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  __exportStar(require("./grammar-builder.js"), exports);
22
22
  __exportStar(require("./pattern-compiler.js"), exports);
23
23
  __exportStar(require("./grammar-engine.js"), exports);
24
+ __exportStar(require("./rule-order.js"), exports);
24
25
  __exportStar(require("./scope-builder.js"), exports);
25
26
  __exportStar(require("./vocabulary-provider.js"), exports);
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,uDAAqC;AACrC,wDAAsC;AACtC,sDAAoC;AACpC,qDAAmC;AACnC,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,uDAAqC;AACrC,wDAAsC;AACtC,sDAAoC;AACpC,kDAAgC;AAChC,qDAAmC;AACnC,2DAAyC"}
@@ -1,31 +1,35 @@
1
1
  /**
2
2
  * @file Pattern Compiler Interface
3
- * @description Language-agnostic interface for compiling grammar patterns
3
+ * @description Language-agnostic interface for compiling grammar patterns.
4
+ *
5
+ * Public interface: PatternCompiler (parse, compile), PatternSyntaxError.
6
+ * Owner context: if-domain grammar contract. A rule's structure crosses as
7
+ * PatternElement parts (ADR-382 D1); text is parsed once, at the boundary,
8
+ * by `parse`, and nothing downstream reads pattern text again.
4
9
  */
5
- import { CompiledPattern } from './grammar-builder.js';
10
+ import { CompiledPattern, PatternElement } from './grammar-builder.js';
6
11
  /**
7
12
  * Pattern compiler interface
8
13
  * Language-specific implementations handle their own syntax
9
14
  */
10
15
  export interface PatternCompiler {
11
16
  /**
12
- * Compile a pattern string into tokens
13
- * @param pattern The pattern string (e.g., "put :item in|into :container")
14
- * @returns Compiled pattern with tokens and metadata
17
+ * Parse pattern text into structured parts — the `define(text)` front end
18
+ * (ADR-382 D3). The only place pattern text is read.
19
+ * @param pattern The pattern text (e.g., "put :item in|into :container")
20
+ * @returns The pattern's elements, in order
21
+ * @throws PatternSyntaxError, with the offending offset, on malformed text
15
22
  */
16
- compile(pattern: string): CompiledPattern;
23
+ parse(pattern: string): PatternElement[];
17
24
  /**
18
- * Validate a pattern string
19
- * @param pattern The pattern to validate
20
- * @returns True if valid, false otherwise
25
+ * Compile structured parts into the matcher's tokens and slot records.
26
+ * @param parts The pattern's elements
27
+ * @param source The rule's display text, quoted in error messages only
28
+ * @returns Compiled pattern with tokens and one record per slot
29
+ * @throws PatternSyntaxError on an empty pattern, an invalid or duplicate
30
+ * slot name, or an empty alternation
21
31
  */
22
- validate(pattern: string): boolean;
23
- /**
24
- * Extract slot names from a pattern
25
- * @param pattern The pattern string
26
- * @returns Array of slot names
27
- */
28
- extractSlots(pattern: string): string[];
32
+ compile(parts: readonly PatternElement[], source?: string): CompiledPattern;
29
33
  }
30
34
  /**
31
35
  * Pattern syntax error
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-compiler.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/pattern-compiler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAgB,MAAM,sBAAsB,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAC;IAE1C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAEnC;;;;OAIG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAGlC,OAAO,EAAE,MAAM;IACf,QAAQ,CAAC,EAAE,MAAM;gBAFxB,OAAO,EAAE,MAAM,EACR,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,YAAA;CAK3B"}
1
+ {"version":3,"file":"pattern-compiler.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/pattern-compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEvE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAAC;IAEzC;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;CAC7E;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAGlC,OAAO,EAAE,MAAM;IACf,QAAQ,CAAC,EAAE,MAAM;gBAFxB,OAAO,EAAE,MAAM,EACR,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,YAAA;CAK3B"}
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  /**
3
3
  * @file Pattern Compiler Interface
4
- * @description Language-agnostic interface for compiling grammar patterns
4
+ * @description Language-agnostic interface for compiling grammar patterns.
5
+ *
6
+ * Public interface: PatternCompiler (parse, compile), PatternSyntaxError.
7
+ * Owner context: if-domain grammar contract. A rule's structure crosses as
8
+ * PatternElement parts (ADR-382 D1); text is parsed once, at the boundary,
9
+ * by `parse`, and nothing downstream reads pattern text again.
5
10
  */
6
11
  Object.defineProperty(exports, "__esModule", { value: true });
7
12
  exports.PatternSyntaxError = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-compiler.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/pattern-compiler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+BH;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAGlC;IACA;IAHT,YACE,OAAe,EACR,OAAe,EACf,QAAiB;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAS;QAGxB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AATD,gDASC"}
1
+ {"version":3,"file":"pattern-compiler.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/pattern-compiler.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA6BH;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAGlC;IACA;IAHT,YACE,OAAe,EACR,OAAe,EACf,QAAiB;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAS;QAGxB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AATD,gDASC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @file Grammar rank comparator — the one ordering of grammar readings
3
+ * @description Orders the readings of grammar rules, and the failures the
4
+ * parser classifies, by their nouns and their rule: items naming nothing
5
+ * (fewer first), then literal specificity (more first), then tier (story
6
+ * before standard), then definition order (earlier first), then names (more
7
+ * first) and exact names (more first). Every reader that ranks readings
8
+ * calls this; no other ordering of grammar rules exists.
9
+ *
10
+ * Public interface: NounRank, GrammarRank, compareGrammarRank.
11
+ * Owner context: if-domain grammar contract (the English grammar engine and
12
+ * the parser's failure classifier are the callers).
13
+ *
14
+ * References: ADR-386 D4, D5 (the noun rank), ADR-384 D2 (supersedes
15
+ * ADR-268 D2; the rule keys), ADR-231 D2b (literal specificity).
16
+ */
17
+ import type { GrammarTier } from './grammar-builder.js';
18
+ /**
19
+ * How a reading's entity items resolve, counted: the parser ranks by it and
20
+ * the validator resolves, so no entity id leaves the rank.
21
+ */
22
+ export interface NounRank {
23
+ /** Items naming nothing in the world */
24
+ unnamed: number;
25
+ /** Distinct entities the items name */
26
+ named: number;
27
+ /** Items named at the exact tier */
28
+ exact: number;
29
+ }
30
+ /**
31
+ * What a reading is ranked by.
32
+ */
33
+ export interface GrammarRank {
34
+ /** How the reading's items resolve */
35
+ nounRank: NounRank;
36
+ /** Input words consumed by the rule's literal and alternate elements */
37
+ literalSpecificity: number;
38
+ /** The registration layer: story outranks standard at equal specificity */
39
+ tier: GrammarTier;
40
+ /** The rule's position in registration (definition) order */
41
+ definitionIndex: number;
42
+ }
43
+ /**
44
+ * Compare two ranks for sorting, best first. Only `unnamed` stands above the
45
+ * rule's own keys, so a literal line still beats a slot reading of the same
46
+ * words; `named` and `exact` decide between the readings of one rule.
47
+ * @param a The first rank
48
+ * @param b The second rank
49
+ * @returns Negative when `a` ranks first, positive when `b` does, zero only
50
+ * for the same noun rank, specificity, tier and definition index
51
+ */
52
+ export declare function compareGrammarRank(a: GrammarRank, b: GrammarRank): number;
53
+ //# sourceMappingURL=rule-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-order.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/grammar/rule-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,QAAQ,EAAE,QAAQ,CAAC;IACnB,wEAAwE;IACxE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2EAA2E;IAC3E,IAAI,EAAE,WAAW,CAAC;IAClB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,MAAM,CAiBzE"}