@beehexa/hexasync-template-validate 2608.20.18 → 2608.20.31

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 (129) hide show
  1. package/dist/index.d.ts +39 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +39 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/validate/agentAnswers.d.ts +48 -0
  6. package/dist/validate/agentAnswers.d.ts.map +1 -0
  7. package/dist/validate/agentAnswers.js +84 -0
  8. package/dist/validate/agentAnswers.js.map +1 -0
  9. package/dist/validate/agentTools.d.ts +37 -0
  10. package/dist/validate/agentTools.d.ts.map +1 -0
  11. package/dist/validate/agentTools.js +141 -0
  12. package/dist/validate/agentTools.js.map +1 -0
  13. package/dist/validate/buildValidationModel.d.ts +31 -0
  14. package/dist/validate/buildValidationModel.d.ts.map +1 -0
  15. package/dist/validate/buildValidationModel.js +68 -0
  16. package/dist/validate/buildValidationModel.js.map +1 -0
  17. package/dist/validate/context.d.ts +117 -0
  18. package/dist/validate/context.d.ts.map +1 -0
  19. package/dist/validate/context.js +96 -0
  20. package/dist/validate/context.js.map +1 -0
  21. package/dist/validate/contextFromGraph.d.ts +70 -0
  22. package/dist/validate/contextFromGraph.d.ts.map +1 -0
  23. package/dist/validate/contextFromGraph.js +82 -0
  24. package/dist/validate/contextFromGraph.js.map +1 -0
  25. package/dist/validate/harvestPullerTaskIds.d.ts +60 -0
  26. package/dist/validate/harvestPullerTaskIds.d.ts.map +1 -0
  27. package/dist/validate/harvestPullerTaskIds.js +116 -0
  28. package/dist/validate/harvestPullerTaskIds.js.map +1 -0
  29. package/dist/validate/model.d.ts +14 -0
  30. package/dist/validate/model.d.ts.map +1 -0
  31. package/dist/validate/model.js +97 -0
  32. package/dist/validate/model.js.map +1 -0
  33. package/dist/validate/registry.d.ts +24 -0
  34. package/dist/validate/registry.d.ts.map +1 -0
  35. package/dist/validate/registry.js +105 -0
  36. package/dist/validate/registry.js.map +1 -0
  37. package/dist/validate/retrieve.d.ts +125 -0
  38. package/dist/validate/retrieve.d.ts.map +1 -0
  39. package/dist/validate/retrieve.js +272 -0
  40. package/dist/validate/retrieve.js.map +1 -0
  41. package/dist/validate/rule.d.ts +18 -0
  42. package/dist/validate/rule.d.ts.map +1 -0
  43. package/dist/validate/rule.js +2 -0
  44. package/dist/validate/rule.js.map +1 -0
  45. package/dist/validate/ruleCatalog.d.ts +22 -0
  46. package/dist/validate/ruleCatalog.d.ts.map +1 -0
  47. package/dist/validate/ruleCatalog.js +492 -0
  48. package/dist/validate/ruleCatalog.js.map +1 -0
  49. package/dist/validate/rules/apiShape.d.ts +51 -0
  50. package/dist/validate/rules/apiShape.d.ts.map +1 -0
  51. package/dist/validate/rules/apiShape.js +150 -0
  52. package/dist/validate/rules/apiShape.js.map +1 -0
  53. package/dist/validate/rules/arguments.d.ts +3 -0
  54. package/dist/validate/rules/arguments.d.ts.map +1 -0
  55. package/dist/validate/rules/arguments.js +301 -0
  56. package/dist/validate/rules/arguments.js.map +1 -0
  57. package/dist/validate/rules/connectorIdentity.d.ts +3 -0
  58. package/dist/validate/rules/connectorIdentity.d.ts.map +1 -0
  59. package/dist/validate/rules/connectorIdentity.js +347 -0
  60. package/dist/validate/rules/connectorIdentity.js.map +1 -0
  61. package/dist/validate/rules/context.d.ts +42 -0
  62. package/dist/validate/rules/context.d.ts.map +1 -0
  63. package/dist/validate/rules/context.js +92 -0
  64. package/dist/validate/rules/context.js.map +1 -0
  65. package/dist/validate/rules/dependencyIntegrity.d.ts +60 -0
  66. package/dist/validate/rules/dependencyIntegrity.d.ts.map +1 -0
  67. package/dist/validate/rules/dependencyIntegrity.js +296 -0
  68. package/dist/validate/rules/dependencyIntegrity.js.map +1 -0
  69. package/dist/validate/rules/duplicates.d.ts +27 -0
  70. package/dist/validate/rules/duplicates.d.ts.map +1 -0
  71. package/dist/validate/rules/duplicates.js +337 -0
  72. package/dist/validate/rules/duplicates.js.map +1 -0
  73. package/dist/validate/rules/flow.d.ts +57 -0
  74. package/dist/validate/rules/flow.d.ts.map +1 -0
  75. package/dist/validate/rules/flow.js +714 -0
  76. package/dist/validate/rules/flow.js.map +1 -0
  77. package/dist/validate/rules/missingInclude.d.ts +27 -0
  78. package/dist/validate/rules/missingInclude.d.ts.map +1 -0
  79. package/dist/validate/rules/missingInclude.js +29 -0
  80. package/dist/validate/rules/missingInclude.js.map +1 -0
  81. package/dist/validate/rules/overwriteLoss.d.ts +23 -0
  82. package/dist/validate/rules/overwriteLoss.d.ts.map +1 -0
  83. package/dist/validate/rules/overwriteLoss.js +40 -0
  84. package/dist/validate/rules/overwriteLoss.js.map +1 -0
  85. package/dist/validate/rules/pullerKind.d.ts +3 -0
  86. package/dist/validate/rules/pullerKind.d.ts.map +1 -0
  87. package/dist/validate/rules/pullerKind.js +92 -0
  88. package/dist/validate/rules/pullerKind.js.map +1 -0
  89. package/dist/validate/rules/querySelect.d.ts +24 -0
  90. package/dist/validate/rules/querySelect.d.ts.map +1 -0
  91. package/dist/validate/rules/querySelect.js +102 -0
  92. package/dist/validate/rules/querySelect.js.map +1 -0
  93. package/dist/validate/rules/reference.d.ts +44 -0
  94. package/dist/validate/rules/reference.d.ts.map +1 -0
  95. package/dist/validate/rules/reference.js +405 -0
  96. package/dist/validate/rules/reference.js.map +1 -0
  97. package/dist/validate/rules/referenceKind.d.ts +25 -0
  98. package/dist/validate/rules/referenceKind.d.ts.map +1 -0
  99. package/dist/validate/rules/referenceKind.js +235 -0
  100. package/dist/validate/rules/referenceKind.js.map +1 -0
  101. package/dist/validate/rules/retiredType.d.ts +149 -0
  102. package/dist/validate/rules/retiredType.d.ts.map +1 -0
  103. package/dist/validate/rules/retiredType.js +235 -0
  104. package/dist/validate/rules/retiredType.js.map +1 -0
  105. package/dist/validate/rules/stepData.d.ts +122 -0
  106. package/dist/validate/rules/stepData.d.ts.map +1 -0
  107. package/dist/validate/rules/stepData.js +249 -0
  108. package/dist/validate/rules/stepData.js.map +1 -0
  109. package/dist/validate/rules/stepIterations.d.ts +49 -0
  110. package/dist/validate/rules/stepIterations.d.ts.map +1 -0
  111. package/dist/validate/rules/stepIterations.js +156 -0
  112. package/dist/validate/rules/stepIterations.js.map +1 -0
  113. package/dist/validate/rules/tables.d.ts +8 -0
  114. package/dist/validate/rules/tables.d.ts.map +1 -0
  115. package/dist/validate/rules/tables.js +116 -0
  116. package/dist/validate/rules/tables.js.map +1 -0
  117. package/dist/validate/rules/variableDrift.d.ts +63 -0
  118. package/dist/validate/rules/variableDrift.d.ts.map +1 -0
  119. package/dist/validate/rules/variableDrift.js +132 -0
  120. package/dist/validate/rules/variableDrift.js.map +1 -0
  121. package/dist/validate/rules/variables.d.ts +12 -0
  122. package/dist/validate/rules/variables.d.ts.map +1 -0
  123. package/dist/validate/rules/variables.js +207 -0
  124. package/dist/validate/rules/variables.js.map +1 -0
  125. package/dist/validate/sourceLocator.d.ts +32 -0
  126. package/dist/validate/sourceLocator.d.ts.map +1 -0
  127. package/dist/validate/sourceLocator.js +166 -0
  128. package/dist/validate/sourceLocator.js.map +1 -0
  129. package/package.json +6 -6
@@ -0,0 +1,122 @@
1
+ /**
2
+ * STEP-1 — a step's `data` sets both of a one-or-the-other pair, or neither (Story 5.12).
3
+ *
4
+ * ### One rule, two surfaces, and that is the whole point
5
+ *
6
+ * The editor's diagnostics run this registry, and so does the composition report. So a rule learned in one place
7
+ * holds in the other **because it is the same computation**, not because two implementations were kept in step.
8
+ * The extension's `stepInputs.ts` reads the same relationships from the shipped asset for hover and completion; this
9
+ * is the assertive half of that pair.
10
+ *
11
+ * ### Why the pair is hardcoded here rather than read from the asset
12
+ *
13
+ * The asset ships with the EXTENSION and this package is consumed by both the extension and the CLI. A rule that
14
+ * needed an editor asset could not run in `hexasync compose`, which is where the report comes from — so the two
15
+ * relationships that exist today are stated here, and the asset carries the reader-facing prose for the same pair.
16
+ * ⚠️ That is a real duplication, and it is deliberate rather than overlooked: a test in the extension asserts the
17
+ * two agree, so drift fails a build rather than reaching an author.
18
+ *
19
+ * ### Measured before it was written
20
+ *
21
+ * `SAVE_TASK_DATA` keeps `items`; `DIRECT_INDEX` keeps `dataPath`. Neither raises anything — the loser is dropped in
22
+ * silence.
23
+ *
24
+ * ⛔ The figures first recorded here — *"604 use `dataPath` only, 27 use `items` only"* — do not reproduce under any
25
+ * basis. Re-measured 2026-08-13 and now asserted by `epic5Corpus.spec.ts` in the extension repo:
26
+ *
27
+ * | basis | dataPath only | items only | both | neither |
28
+ * | --- | --- | --- | --- | --- |
29
+ * | authored (excluding `output*.yaml`), PARSED — the figure `epic5Corpus.spec.ts` asserts | **423** | **23** | 0 | 0 |
30
+ * | every YAML | 847 | 48 | 0 | 0 |
31
+ *
32
+ * ⛔ A first correction here said **441**, which was a grep rather than a parse — the fourth figure for one query, added
33
+ * in the same change that criticised the previous three. 423 is what the gate runs.
34
+ *
35
+ * And `SAVE_TASK_DATA` occurs **ZERO** times in the corpus, so half this table has no corpus evidence at all — its
36
+ * winner and its exception come from the executor, not from usage. The load-bearing half holds: zero steps set both
37
+ * or neither, so this rule is preventative and fires on nothing the day it ships. Stated because "fires on nothing"
38
+ * and "is broken" look identical in a log.
39
+ */
40
+ import type { ValidationRule } from '../rule.js';
41
+ /**
42
+ * How a field counts as SET.
43
+ *
44
+ * ⛔ Not one rule. The Story 5.12 review read the executors and found the two checks inside ONE step disagree:
45
+ *
46
+ * ```csharp
47
+ * // DirectIndexStepExecutor.cs:53 — the guard that throws
48
+ * if ((Items == null || !Items.Any()) && string.IsNullOrWhiteSpace(DataPath)) throw new ArgumentException(...);
49
+ * // DirectIndexStepExecutor.cs:57 — the branch that decides the winner
50
+ * else if (DataPath != null) { ...SelectTokens(DataPath)... }
51
+ * ```
52
+ *
53
+ * So `dataPath: ""` is **absent** to the guard and **present** to the branch. A single "the key is there" reading
54
+ * got two real shapes wrong: `dataPath: ""` alone throws and was reported as fine, and `dataPath: "" , items: []`
55
+ * throws and was reported as *"`dataPath` is used and the other is ignored, with no error"* — telling an author
56
+ * nothing is wrong about a step that cannot run.
57
+ */
58
+ type Presence = 'non-null' | 'non-blank' | 'non-empty';
59
+ /**
60
+ * The one-or-the-other pairs, which field the runtime keeps, and what each check counts as set.
61
+ *
62
+ * Exported so the extension's drift guard can compare against THIS object rather than a hand-copied literal — the
63
+ * review flipped `wins` here and the extension's "drift guard" stayed green, which is the opposite of a guard.
64
+ */
65
+ export declare const EXCLUSIVE: readonly {
66
+ readonly displayType: string;
67
+ readonly fields: readonly [string, string];
68
+ readonly wins: string;
69
+ readonly throws: string;
70
+ /** How each field counts as set when deciding which one the runtime USES. */
71
+ readonly branch: Readonly<Record<string, Presence>>;
72
+ /** How each field counts as set for the guard that THROWS. */
73
+ readonly guard: Readonly<Record<string, Presence>>;
74
+ }[];
75
+ /**
76
+ * Fields a step type requires, and what the runtime does without them (Story 5.12 AC-1, extended by decision).
77
+ *
78
+ * ⛔ AC-1 says *"a step whose `data` omits a field its type requires"*, which is broader than the one-or-the-other
79
+ * pair. The review found the rest reported by the editor's JSON Schema and by NOTHING in `hexasync compose` — the
80
+ * same two-surface disagreement the missing-`data` case closed.
81
+ *
82
+ * ⚠️ **The authority differs per field, and that is recorded rather than smoothed over.** The `SLEEP` lesson from
83
+ * this epic is that a schema's `required` can simply be wrong, so a field is only described as throwing where the
84
+ * throw was read in the executor:
85
+ *
86
+ * | field | what actually happens | read in |
87
+ * | --- | --- | --- |
88
+ * | `SAVE_TASK_DATA.taskId` | throws `InvalidOperationException` | `SaveTaskDataStepExecutor.cs:48-51` |
89
+ * | `DIRECT_INDEX.objectIds` | **no throw** — defaults to an empty list, so the step indexes into no objects and does nothing | `DirectIndexStepExecutor.cs:26,51` |
90
+ *
91
+ * ⛔ **`API.url`/`type`/`method` and `SQL.sql` were in this table for one commit, sourced to the shipped schema's
92
+ * `required`, and the CORPUS falsified them immediately** — 59 authored API steps and 1 SQL step were reported.
93
+ * Looking at them settles it: they declare `displayType: API` with a `connectorId` and a SQL-shaped `data`
94
+ * (`sql`, `timeout`, `resultSets`). An API step's fields are read by its **connector provider**, not by
95
+ * `ApiStepExecutor`, so what it requires depends on which provider it routes to — which is precisely why that
96
+ * executor delegates and why the field could not be verified there.
97
+ *
98
+ * That is this epic's `SLEEP` lesson a third time: a schema's `required` is not the runtime's word. A field is
99
+ * listed here only where the behaviour was read in code that actually reads the field.
100
+ *
101
+ * ⚠️ It also means the EDITOR reports those 59 steps as broken today, from `apiData.required` — a real false error,
102
+ * left recorded rather than silently edited, because fixing it needs the connector provider read first.
103
+ *
104
+ * ⚠️ Scope: 2 step types. The rest belongs to Epic 10's sweep, and saying so is the point — an author must not read
105
+ * silence here as approval.
106
+ */
107
+ export declare const REQUIRED: readonly {
108
+ readonly displayType: string;
109
+ readonly field: string;
110
+ /** What the runtime does when it is missing, in the author's terms. */
111
+ readonly whenMissing: string;
112
+ /**
113
+ * Where the behaviour was established.
114
+ *
115
+ * `'executor'` is the only value in use. `'schema'` remains in the type as a warning: entries added on the
116
+ * schema's authority alone were falsified by the corpus within one commit — see the note above.
117
+ */
118
+ readonly authority: 'executor' | 'schema';
119
+ }[];
120
+ export declare const stepDataRule: ValidationRule;
121
+ export {};
122
+ //# sourceMappingURL=stepData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepData.d.ts","sourceRoot":"","sources":["../../../src/validate/rules/stepData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAuBvD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpD,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;CACpD,EAmBA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,UAAU,GAAG,QAAQ,CAAC;CAC3C,EAcA,CAAC;AAiBF,eAAO,MAAM,YAAY,EAAE,cAwK1B,CAAC"}
@@ -0,0 +1,249 @@
1
+ const isSet = (data, field, how) => {
2
+ const value = data?.[field];
3
+ if (value === undefined || value === null)
4
+ return false;
5
+ if (how === 'non-blank')
6
+ return typeof value === 'string' ? value.trim() !== '' : true;
7
+ if (how === 'non-empty') {
8
+ /**
9
+ * ⛔ A STRING counts, and a blank one does not.
10
+ *
11
+ * `items` is authored as a template string in 23 corpus steps (`items: "{{ rows }}"`), so returning `true` for
12
+ * every non-array — the first version — meant `items: ''` and `items: ' '` were "set" while the identical
13
+ * `dataPath: ' '` was reported. The review found the asymmetry invisible because the branch only asked
14
+ * `Array.isArray`.
15
+ */
16
+ if (Array.isArray(value))
17
+ return value.length > 0;
18
+ if (typeof value === 'string')
19
+ return value.trim() !== '';
20
+ return true;
21
+ }
22
+ return true;
23
+ };
24
+ /**
25
+ * The one-or-the-other pairs, which field the runtime keeps, and what each check counts as set.
26
+ *
27
+ * Exported so the extension's drift guard can compare against THIS object rather than a hand-copied literal — the
28
+ * review flipped `wins` here and the extension's "drift guard" stayed green, which is the opposite of a guard.
29
+ */
30
+ export const EXCLUSIVE = [
31
+ {
32
+ displayType: 'DIRECT_INDEX',
33
+ fields: ['dataPath', 'items'],
34
+ wins: 'dataPath',
35
+ throws: 'ArgumentException',
36
+ branch: { dataPath: 'non-null', items: 'non-empty' },
37
+ guard: { dataPath: 'non-blank', items: 'non-empty' },
38
+ },
39
+ {
40
+ // `SaveTaskDataStepExecutor.cs:136-148` uses `IsNullOrWhiteSpace(dataPath)` for the guard AND the branch, so a
41
+ // blank `dataPath` is uniformly absent here — the asymmetry above is DIRECT_INDEX's alone.
42
+ displayType: 'SAVE_TASK_DATA',
43
+ fields: ['items', 'dataPath'],
44
+ wins: 'items',
45
+ throws: 'InvalidOperationException',
46
+ branch: { items: 'non-null', dataPath: 'non-blank' },
47
+ guard: { items: 'non-null', dataPath: 'non-blank' },
48
+ },
49
+ ];
50
+ /**
51
+ * Fields a step type requires, and what the runtime does without them (Story 5.12 AC-1, extended by decision).
52
+ *
53
+ * ⛔ AC-1 says *"a step whose `data` omits a field its type requires"*, which is broader than the one-or-the-other
54
+ * pair. The review found the rest reported by the editor's JSON Schema and by NOTHING in `hexasync compose` — the
55
+ * same two-surface disagreement the missing-`data` case closed.
56
+ *
57
+ * ⚠️ **The authority differs per field, and that is recorded rather than smoothed over.** The `SLEEP` lesson from
58
+ * this epic is that a schema's `required` can simply be wrong, so a field is only described as throwing where the
59
+ * throw was read in the executor:
60
+ *
61
+ * | field | what actually happens | read in |
62
+ * | --- | --- | --- |
63
+ * | `SAVE_TASK_DATA.taskId` | throws `InvalidOperationException` | `SaveTaskDataStepExecutor.cs:48-51` |
64
+ * | `DIRECT_INDEX.objectIds` | **no throw** — defaults to an empty list, so the step indexes into no objects and does nothing | `DirectIndexStepExecutor.cs:26,51` |
65
+ *
66
+ * ⛔ **`API.url`/`type`/`method` and `SQL.sql` were in this table for one commit, sourced to the shipped schema's
67
+ * `required`, and the CORPUS falsified them immediately** — 59 authored API steps and 1 SQL step were reported.
68
+ * Looking at them settles it: they declare `displayType: API` with a `connectorId` and a SQL-shaped `data`
69
+ * (`sql`, `timeout`, `resultSets`). An API step's fields are read by its **connector provider**, not by
70
+ * `ApiStepExecutor`, so what it requires depends on which provider it routes to — which is precisely why that
71
+ * executor delegates and why the field could not be verified there.
72
+ *
73
+ * That is this epic's `SLEEP` lesson a third time: a schema's `required` is not the runtime's word. A field is
74
+ * listed here only where the behaviour was read in code that actually reads the field.
75
+ *
76
+ * ⚠️ It also means the EDITOR reports those 59 steps as broken today, from `apiData.required` — a real false error,
77
+ * left recorded rather than silently edited, because fixing it needs the connector provider read first.
78
+ *
79
+ * ⚠️ Scope: 2 step types. The rest belongs to Epic 10's sweep, and saying so is the point — an author must not read
80
+ * silence here as approval.
81
+ */
82
+ export const REQUIRED = [
83
+ {
84
+ displayType: 'SAVE_TASK_DATA',
85
+ field: 'taskId',
86
+ whenMissing: 'the step throws InvalidOperationException at run time',
87
+ authority: 'executor',
88
+ },
89
+ {
90
+ displayType: 'DIRECT_INDEX',
91
+ field: 'objectIds',
92
+ whenMissing: 'the step indexes into no objects and does nothing, without an error',
93
+ authority: 'executor',
94
+ },
95
+ ];
96
+ const STAGES = [
97
+ 'beforePullSteps',
98
+ 'pullSteps',
99
+ 'afterPullSteps',
100
+ 'steps',
101
+ 'onErrorSteps',
102
+ 'finalSteps',
103
+ 'beforePushSteps',
104
+ 'pushSteps',
105
+ 'afterPushSteps',
106
+ ];
107
+ const arr = (value, key) => Array.isArray(value?.[key]) ? value[key] : [];
108
+ export const stepDataRule = {
109
+ id: 'STEP',
110
+ family: 'STEP',
111
+ run(ctx) {
112
+ const cnf = ctx.tokenForm;
113
+ if (!cnf || typeof cnf !== 'object')
114
+ return [];
115
+ const issues = [];
116
+ const check = (step, parentKey, idOrKey) => {
117
+ const displayType = typeof step?.displayType === 'string' ? step.displayType : undefined;
118
+ const rule = EXCLUSIVE.find((entry) => entry.displayType === displayType);
119
+ const required = REQUIRED.filter((entry) => entry.displayType === displayType);
120
+ if (!rule && required.length === 0)
121
+ return;
122
+ /**
123
+ * A missing `data` block is the SAME state as a `data` with neither field, and it is reported.
124
+ *
125
+ * ⛔ This used to return early, on the reasoning that a missing block is the schema's business. The review
126
+ * showed that reasoning breaks AC-1's second clause: `hexasync compose` runs no JSON Schema at all, so the
127
+ * report said nothing while the editor's schema flagged it — the two surfaces disagreeing about the most
128
+ * likely authoring shape, which is the one thing this story exists to prevent. The runtime throws either way.
129
+ */
130
+ /**
131
+ * A key only counts when it is a scalar. `key: {a: 1}` produced `step "[object Object]"` in the message AND in
132
+ * `locateValue`, which the report then tried to find in the source.
133
+ */
134
+ const stepKey = typeof step?.key === 'string' || typeof step?.key === 'number'
135
+ ? String(step.key)
136
+ : '(step)';
137
+ const data = step?.data && typeof step.data === 'object' && !Array.isArray(step.data)
138
+ ? step.data
139
+ : {};
140
+ /**
141
+ * `data` written as something other than a block of fields is its OWN defect, and naming it as a missing
142
+ * field sends the author to the wrong place: told to add `dataPath` under `data: "oops"`, they cannot act.
143
+ */
144
+ const authored = step?.data;
145
+ if (authored != null &&
146
+ (typeof authored !== 'object' || Array.isArray(authored))) {
147
+ issues.push({
148
+ ruleId: 'STEP-1',
149
+ family: 'STEP',
150
+ severity: 'high',
151
+ parentKey,
152
+ idOrKey,
153
+ message: `step "${stepKey}" (${displayType}) writes "data" as ${Array.isArray(authored) ? 'a list' : `a ${typeof authored}`} — ` +
154
+ `it must be a block of fields`,
155
+ why: 'nothing in the step can be read, so it cannot run',
156
+ locateValue: stepKey,
157
+ });
158
+ return;
159
+ }
160
+ for (const entry of required) {
161
+ if (isSet(data, entry.field, 'non-blank'))
162
+ continue;
163
+ issues.push({
164
+ ruleId: 'STEP-1',
165
+ family: 'STEP',
166
+ severity: 'high',
167
+ parentKey,
168
+ idOrKey,
169
+ message: `step "${stepKey}" (${displayType}) does not set "${entry.field}", which it requires — ` +
170
+ entry.whenMissing,
171
+ why: entry.authority === 'executor'
172
+ ? 'the step cannot do its work'
173
+ : 'the editor already reports this; the composition report did not',
174
+ locateValue: stepKey,
175
+ });
176
+ }
177
+ if (!rule)
178
+ return;
179
+ const usable = rule.fields.filter((field) => isSet(data, field, rule.branch[field]));
180
+ const guarded = rule.fields.filter((field) => isSet(data, field, rule.guard[field]));
181
+ // The guard comes FIRST: a step that cannot run at all must not be reported as a step that silently drops a
182
+ // field. `dataPath: "", items: []` is both shapes at once, and only one of them is worth saying.
183
+ if (guarded.length === 0) {
184
+ issues.push({
185
+ ruleId: 'STEP-1',
186
+ family: 'STEP',
187
+ severity: 'high',
188
+ parentKey,
189
+ idOrKey,
190
+ message: `step "${stepKey}" (${displayType}) sets neither "${rule.fields[0]}" nor "${rule.fields[1]}" — ` +
191
+ `the step throws ${rule.throws} at run time`,
192
+ why: 'the step cannot run at all',
193
+ locateValue: stepKey,
194
+ });
195
+ }
196
+ else if (usable.length === 2) {
197
+ issues.push({
198
+ ruleId: 'STEP-1',
199
+ family: 'STEP',
200
+ severity: 'high',
201
+ parentKey,
202
+ idOrKey,
203
+ message: `step "${stepKey}" (${displayType}) sets both "${rule.fields[0]}" and "${rule.fields[1]}" — ` +
204
+ `"${rule.wins}" is used and the other is ignored, with no error`,
205
+ why: 'the step runs against data you did not mean, and nothing says so',
206
+ locateValue: stepKey,
207
+ });
208
+ }
209
+ };
210
+ for (const collection of ['pullers', 'pushers', 'objects']) {
211
+ for (const component of arr(cnf, collection)) {
212
+ const id = component?.id != null ? String(component.id) : undefined;
213
+ for (const stage of STAGES) {
214
+ for (const step of arr(component, stage))
215
+ check(step, collection, id);
216
+ }
217
+ }
218
+ }
219
+ /**
220
+ * ⛔ A webhook's steps are one level DEEPER, under a `targets` map — `webhooks[].targets.<TARGET>.pullSteps[]`.
221
+ *
222
+ * `webhooks` was in the flat loop above, which reads stage keys that never exist there: the whole collection was
223
+ * checked vacuously. The corpus has **26 `DIRECT_INDEX` steps inside webhook targets** (10 authored), so this was
224
+ * not a theoretical gap. `flow.ts` already walks it correctly; this rule did not copy that.
225
+ */
226
+ for (const webhook of arr(cnf, 'webhooks')) {
227
+ const id = webhook?.id != null ? String(webhook.id) : undefined;
228
+ const targets = webhook?.targets &&
229
+ typeof webhook.targets === 'object' &&
230
+ !Array.isArray(webhook.targets)
231
+ ? webhook.targets
232
+ : {};
233
+ for (const [targetKey, target] of Object.entries(targets)) {
234
+ /**
235
+ * The TARGET is carried into the id, as `flow.ts:776` already does. Without it two same-keyed steps under
236
+ * different targets produce byte-identical findings and `locateValue` cannot tell them apart.
237
+ *
238
+ * Only `pullSteps` is read: measured across the corpus, 245 targets declare exactly that one stage key, and
239
+ * looping the other eight would be inventing a schema.
240
+ */
241
+ for (const step of arr(target, 'pullSteps')) {
242
+ check(step, 'webhooks', id ? `${id} target ${targetKey}` : `target ${targetKey}`);
243
+ }
244
+ }
245
+ }
246
+ return issues;
247
+ },
248
+ };
249
+ //# sourceMappingURL=stepData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepData.js","sourceRoot":"","sources":["../../../src/validate/rules/stepData.ts"],"names":[],"mappings":"AA8DA,MAAM,KAAK,GAAG,CAAC,IAAS,EAAE,KAAa,EAAE,GAAa,EAAW,EAAE;IACjE,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,GAAG,KAAK,WAAW;QACrB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAChE,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;QACxB;;;;;;;WAOG;QACH,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,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gBACjB,CAAC,CAAC,EAAE,CAAC;YACT,KAAK,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAM,OAAO,CAAC,EAAE,CAAC;gBAC/D;;;;;;mBAMG;gBACH,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC;oBAC5C,KAAK,CACH,IAAI,EACJ,UAAU,EACV,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,SAAS,EAAE,CAAC,CAAC,CAAC,UAAU,SAAS,EAAE,CACzD,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * STEP-2 / STEP-3 — a step's per-run execution cap says something the runtime will not do (Epic 9).
3
+ *
4
+ * ### The field
5
+ *
6
+ * `StepIterator` bounds how many times ONE step (`key` + `displayType`) may execute within a single run. Exceeding it
7
+ * trips a terminal `PULL_MAX_STEP_ITERATIONS`. An author raises that ceiling for a deliberately deep in-run
8
+ * (backward-`next`) loop by declaring `maxStepIterations`, and the resolution is exactly:
9
+ *
10
+ * ```csharp
11
+ * // StepIterator.cs:281 — ResolvePerStepCap
12
+ * var token = step.SelectToken("$.maxStepIterations") ?? step.SelectToken("$.data.maxStepIterations");
13
+ * if (token != null && (token.Type == JTokenType.Integer || token.Type == JTokenType.Float))
14
+ * over = token.ToObject<int?>();
15
+ * return over is > 0 ? Math.Min(over.Value, totalBudget) : EngineMaxStepIterations; // default 1000
16
+ * ```
17
+ *
18
+ * Read off that, and nothing else: the ROOT wins over `data` (`??`, not a merge); a non-numeric value is ignored
19
+ * entirely; a value ≤ 0 is ignored; any surviving value is clamped to the whole-run budget, which is at most
20
+ * `EngineMaxIterations` (300,000) and may be smaller when the template declares its own.
21
+ *
22
+ * ### ⛔ A float is NOT ignored, though the epic's AC-1 says it is
23
+ *
24
+ * `JTokenType.Float` passes the type check and `ToObject<int?>()` converts it, so `maxStepIterations: 2.7` becomes
25
+ * **3** and is used. AC-1 lists a float among the values that are "ignored"; that is wrong, and core.api's own
26
+ * `StepIteratorPerStepCapTests` has no float case either way — absent, root, nested, root-wins, 0, -5, a string and
27
+ * the clamp are covered, so the behaviour is defined by the code alone. This rule reports what the code does and the
28
+ * AC was amended rather than the behaviour described from the spec. Getting this backwards is how this feature has
29
+ * repeatedly shipped a "requirement" the executor falsifies.
30
+ *
31
+ * ### Severity, earned rather than assumed (G-7)
32
+ *
33
+ * ⚠️ **Measured 2026-08-14: `maxStepIterations` appears ZERO times in the corpus**, as does `maxIterations`. The
34
+ * field is new in the runtime and no template has adopted it, so BOTH ids fire on nothing today. That is stated
35
+ * because "fires on nothing" and "is broken" look identical in a log — this is a guard for a capability as it is
36
+ * adopted, not a report on one in use.
37
+ *
38
+ * `STEP-2` is `medium`: the author believes they raised the ceiling and did not, so the run trips
39
+ * `PULL_MAX_STEP_ITERATIONS` at the old default with nothing anywhere explaining why. `STEP-3` is `low` — the value
40
+ * is honoured, just not at the number written, which is worth stating and is not a defect. Neither blocks a compose
41
+ * (G-10).
42
+ */
43
+ import type { ValidationRule } from '../rule.js';
44
+ /** `StepIterator.EngineMaxStepIterations` — the per-step ceiling when no usable override is declared. */
45
+ export declare const ENGINE_MAX_STEP_ITERATIONS = 1000;
46
+ /** `StepIterator.EngineMaxIterations` — the hard ceiling on TOTAL step executions, and so on any per-step cap. */
47
+ export declare const ENGINE_MAX_ITERATIONS = 300000;
48
+ export declare const stepIterationsRule: ValidationRule;
49
+ //# sourceMappingURL=stepIterations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepIterations.d.ts","sourceRoot":"","sources":["../../../src/validate/rules/stepIterations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD,yGAAyG;AACzG,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,kHAAkH;AAClH,eAAO,MAAM,qBAAqB,SAAU,CAAC;AA2C7C,eAAO,MAAM,kBAAkB,EAAE,cAgIhC,CAAC"}
@@ -0,0 +1,156 @@
1
+ /** `StepIterator.EngineMaxStepIterations` — the per-step ceiling when no usable override is declared. */
2
+ export const ENGINE_MAX_STEP_ITERATIONS = 1000;
3
+ /** `StepIterator.EngineMaxIterations` — the hard ceiling on TOTAL step executions, and so on any per-step cap. */
4
+ export const ENGINE_MAX_ITERATIONS = 300_000;
5
+ const FIELD = 'maxStepIterations';
6
+ /**
7
+ * `Convert.ToInt32(double)`, which is what `ToObject<int?>()` reaches for — **half-to-even**, not half-up.
8
+ *
9
+ * `2.5` becomes 2 and `3.5` becomes 4. Written out rather than using `Math.round` (half-UP, so it would answer 3 for
10
+ * `2.5`) because the whole point of this rule is to state the number the runtime will actually use.
11
+ */
12
+ const toInt32 = (value) => {
13
+ const floor = Math.floor(value);
14
+ const fraction = value - floor;
15
+ if (fraction > 0.5)
16
+ return floor + 1;
17
+ if (fraction < 0.5)
18
+ return floor;
19
+ return floor % 2 === 0 ? floor : floor + 1;
20
+ };
21
+ const STAGES = [
22
+ 'beforePullSteps',
23
+ 'pullSteps',
24
+ 'afterPullSteps',
25
+ 'steps',
26
+ 'onErrorSteps',
27
+ 'finalSteps',
28
+ 'beforePushSteps',
29
+ 'pushSteps',
30
+ 'afterPushSteps',
31
+ ];
32
+ const arr = (value, key) => Array.isArray(value?.[key]) ? value[key] : [];
33
+ /** How the value was written, in the author's terms, for a message that points at the right line. */
34
+ const describe = (value) => {
35
+ if (value === null)
36
+ return 'null';
37
+ if (Array.isArray(value))
38
+ return 'a list';
39
+ if (typeof value === 'string')
40
+ return `the text "${value}"`;
41
+ if (typeof value === 'boolean')
42
+ return `the true/false value ${value}`;
43
+ if (typeof value === 'object')
44
+ return 'a block';
45
+ return String(value);
46
+ };
47
+ export const stepIterationsRule = {
48
+ id: 'STEP-2',
49
+ family: 'STEP',
50
+ run(ctx) {
51
+ const cnf = ctx.tokenForm;
52
+ if (!cnf || typeof cnf !== 'object')
53
+ return [];
54
+ const issues = [];
55
+ /**
56
+ * The run's total budget, which is what an override is clamped to. A template may declare a SMALLER one
57
+ * (`SetLoopGuards` clamps down, never up), so read it when present and fall back to the engine ceiling.
58
+ */
59
+ const declared = cnf?.maxIterations;
60
+ const totalBudget = typeof declared === 'number' && Number.isFinite(declared) && declared > 0
61
+ ? Math.min(toInt32(declared), ENGINE_MAX_ITERATIONS)
62
+ : ENGINE_MAX_ITERATIONS;
63
+ const check = (step, parentKey, idOrKey) => {
64
+ /**
65
+ * ⛔ ROOT WINS, and it is `??` rather than a merge — `SelectToken("$.maxStepIterations")` is tried first and
66
+ * `$.data.maxStepIterations` is only consulted when the root token is absent. A step that sets both keeps the
67
+ * root and discards the other in silence.
68
+ */
69
+ const atRoot = step?.[FIELD];
70
+ const atData = step?.data && typeof step.data === 'object' && !Array.isArray(step.data)
71
+ ? step.data[FIELD]
72
+ : undefined;
73
+ const value = atRoot !== undefined ? atRoot : atData;
74
+ if (value === undefined)
75
+ return;
76
+ const where = atRoot !== undefined ? FIELD : `data.${FIELD}`;
77
+ const stepKey = typeof step?.key === 'string' || typeof step?.key === 'number'
78
+ ? String(step.key)
79
+ : '(step)';
80
+ const numeric = typeof value === 'number' && Number.isFinite(value);
81
+ const resolved = numeric ? toInt32(value) : undefined;
82
+ if (!numeric || resolved === undefined || resolved <= 0) {
83
+ issues.push({
84
+ ruleId: 'STEP-2',
85
+ family: 'STEP',
86
+ severity: 'medium',
87
+ parentKey,
88
+ idOrKey,
89
+ message: `step "${stepKey}" sets \`${where}\` to ${describe(value)}, which the runtime ignores — ` +
90
+ `the engine default of ${ENGINE_MAX_STEP_ITERATIONS} executions applies instead`,
91
+ why: `the cap is not raised, so the step still fails with PULL_MAX_STEP_ITERATIONS after ${ENGINE_MAX_STEP_ITERATIONS} executions`,
92
+ locateValue: FIELD,
93
+ });
94
+ return;
95
+ }
96
+ /**
97
+ * A float that survives is worth saying out loud: it is neither ignored nor used as written. Reported under
98
+ * STEP-2 because the author's number is not the runtime's number, which is the same defect this id names.
99
+ */
100
+ if (!Number.isInteger(value)) {
101
+ issues.push({
102
+ ruleId: 'STEP-2',
103
+ family: 'STEP',
104
+ severity: 'medium',
105
+ parentKey,
106
+ idOrKey,
107
+ message: `step "${stepKey}" sets \`${where}\` to ${value}, and the runtime rounds it to ${resolved} rather than ` +
108
+ 'ignoring it — whole numbers only',
109
+ why: 'the cap that applies is not the number written, and nothing reports the difference at run time',
110
+ locateValue: FIELD,
111
+ });
112
+ }
113
+ if (resolved > totalBudget) {
114
+ issues.push({
115
+ ruleId: 'STEP-3',
116
+ family: 'STEP',
117
+ severity: 'low',
118
+ parentKey,
119
+ idOrKey,
120
+ message: `step "${stepKey}" sets \`${where}\` to ${resolved}, which is clamped to the run's total budget of ${totalBudget}`,
121
+ why: 'a single step can never be allowed more executions than the whole run, so the larger number has no effect',
122
+ locateValue: FIELD,
123
+ });
124
+ }
125
+ };
126
+ for (const collection of ['pullers', 'pushers', 'objects']) {
127
+ for (const component of arr(cnf, collection)) {
128
+ const id = component?.id != null ? String(component.id) : undefined;
129
+ for (const stage of STAGES) {
130
+ for (const step of arr(component, stage))
131
+ check(step, collection, id);
132
+ }
133
+ }
134
+ }
135
+ /**
136
+ * A webhook keeps its steps under `targets.<TARGET>.pullSteps`, one level deeper — the hole `stepData.ts`
137
+ * shipped with over 26 real corpus steps. Unlike the CTX family this check needs no context alphabet, only the
138
+ * field, so a webhook target is checkable here without a position the engine does not model.
139
+ */
140
+ for (const webhook of arr(cnf, 'webhooks')) {
141
+ const id = webhook?.id != null ? String(webhook.id) : undefined;
142
+ const targets = webhook?.targets &&
143
+ typeof webhook.targets === 'object' &&
144
+ !Array.isArray(webhook.targets)
145
+ ? webhook.targets
146
+ : {};
147
+ for (const [targetKey, target] of Object.entries(targets)) {
148
+ for (const step of arr(target, 'pullSteps')) {
149
+ check(step, 'webhooks', id ? `${id} target ${targetKey}` : `target ${targetKey}`);
150
+ }
151
+ }
152
+ }
153
+ return issues;
154
+ },
155
+ };
156
+ //# sourceMappingURL=stepIterations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepIterations.js","sourceRoot":"","sources":["../../../src/validate/rules/stepIterations.ts"],"names":[],"mappings":"AA8CA,yGAAyG;AACzG,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C,kHAAkH;AAClH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C,MAAM,KAAK,GAAG,mBAAmB,CAAC;AAElC;;;;;GAKG;AACH,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;IAC/B,IAAI,QAAQ,GAAG,GAAG;QAAE,OAAO,KAAK,GAAG,CAAC,CAAC;IACrC,IAAI,QAAQ,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IACjC,OAAO,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG;IACb,iBAAiB;IACjB,WAAW;IACX,gBAAgB;IAChB,OAAO;IACP,cAAc;IACd,YAAY;IACZ,iBAAiB;IACjB,WAAW;IACX,gBAAgB;CACR,CAAC;AAEX,MAAM,GAAG,GAAG,CAAC,KAAU,EAAE,GAAW,EAAS,EAAE,CAC7C,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAEhD,qGAAqG;AACrG,MAAM,QAAQ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AAC,CAAC;gBACxE,CAAC;YACH,CAAC;QACH,CAAC;QAED;;;;WAIG;QACH,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC;YAC3C,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAChE,MAAM,OAAO,GACX,OAAO,EAAE,OAAO;gBAChB,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;gBACnC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC7B,CAAC,CAAC,OAAO,CAAC,OAAO;gBACjB,CAAC,CAAC,EAAE,CAAC;YACT,KAAK,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAM,OAAO,CAAC,EAAE,CAAC;gBAC/D,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC;oBAC5C,KAAK,CACH,IAAI,EACJ,UAAU,EACV,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,SAAS,EAAE,CAAC,CAAC,CAAC,UAAU,SAAS,EAAE,CACzD,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { ValidationRule } from '../rule.js';
2
+ /**
3
+ * Table & column integrity rule (TBL family). For each table that has a `columns`
4
+ * definition, checks the identity/index invariants the worker relies on for indexing
5
+ * and upsert. Reads the token-form; attributes issues to the table.
6
+ */
7
+ export declare const tableRule: ValidationRule;
8
+ //# sourceMappingURL=tables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../src/validate/rules/tables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAsBjD;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,cAiKvB,CAAC"}