@hyperscale0/udl 1.0.0-rc.1 → 2.0.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 (55) hide show
  1. package/CHANGELOG.md +24 -4
  2. package/README.md +24 -36
  3. package/conformance/invalid/invalid-journeys.expected.json +26 -0
  4. package/conformance/invalid/invalid-journeys.udl +79 -0
  5. package/conformance/valid/commerce-escrow.expected.json +1 -1
  6. package/conformance/valid/commerce-escrow.udl +1 -1
  7. package/conformance/valid/hand-edited.expected.json +1 -1
  8. package/conformance/valid/hand-edited.udl +1 -1
  9. package/conformance/valid/minimal.expected.json +1 -1
  10. package/conformance/valid/minimal.udl +23 -0
  11. package/dist/check-profiles.d.ts.map +1 -1
  12. package/dist/diagnostics.d.ts +31 -1
  13. package/dist/diagnostics.d.ts.map +1 -1
  14. package/dist/diagnostics.js +30 -0
  15. package/dist/diagnostics.js.map +1 -1
  16. package/dist/effects.d.ts.map +1 -1
  17. package/dist/evolution.js +30 -9
  18. package/dist/evolution.js.map +1 -1
  19. package/dist/finance.d.ts.map +1 -1
  20. package/dist/finance.js +37 -18
  21. package/dist/finance.js.map +1 -1
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/limits.d.ts +1 -1
  27. package/dist/limits.d.ts.map +1 -1
  28. package/dist/limits.js +7 -4
  29. package/dist/limits.js.map +1 -1
  30. package/dist/schema.d.ts +258 -147
  31. package/dist/schema.d.ts.map +1 -1
  32. package/dist/schema.js +33 -10
  33. package/dist/schema.js.map +1 -1
  34. package/dist/validation.d.ts +5 -1
  35. package/dist/validation.d.ts.map +1 -1
  36. package/dist/validation.js +176 -7
  37. package/dist/validation.js.map +1 -1
  38. package/docs/assets/udl.svg +18 -0
  39. package/docs/guide/03-laws.md +1 -1
  40. package/docs/guide/08-implementing.md +1 -1
  41. package/docs/llms-full.txt +62 -29
  42. package/docs/llms.txt +1 -1
  43. package/docs/reference/clauses.md +29 -1
  44. package/docs/reference/cli.md +1 -1
  45. package/docs/reference/diagnostics.md +32 -27
  46. package/package.json +6 -5
  47. package/spec/README.md +8 -16
  48. package/spec/udl.schema.json +83 -15
  49. package/src/diagnostics.ts +32 -0
  50. package/src/evolution.ts +31 -13
  51. package/src/finance.ts +53 -20
  52. package/src/index.ts +6 -0
  53. package/src/limits.ts +7 -4
  54. package/src/schema.ts +48 -10
  55. package/src/validation.ts +252 -6
@@ -0,0 +1,18 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1200" height="360" viewBox="0 0 1200 360" role="img" aria-labelledby="title desc">
2
+ <title id="title">UDL</title>
3
+ <desc id="desc">The contract between a product and its engine.</desc>
4
+ <rect width="1200" height="360" fill="#050505"/>
5
+ <path d="M48 48H1152M48 304H1152M944 48V304" fill="none" stroke="#303030"/>
6
+ <rect x="48" y="76" width="10" height="10" fill="#2f7dff"/>
7
+ <g font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace">
8
+ <text x="72" y="86" fill="#a3a3a3" font-size="14" letter-spacing="2">HYPERSCALE / DOCUMENTATION</text>
9
+ <text x="44" y="194" fill="#ffffff" font-size="76" letter-spacing="-4">UDL</text>
10
+ <text x="48" y="243" fill="#a3a3a3" font-size="20">The contract between a product and its engine.</text>
11
+ <text x="48" y="334" fill="#a3a3a3" font-size="12" letter-spacing="2">SUBJECTS / INSTRUMENTS / MONEY</text>
12
+ <text x="991" y="279" fill="#a3a3a3" font-size="12">SOURCE → CONTRACT</text>
13
+ </g>
14
+ <g fill="none" stroke="#2f7dff" stroke-width="2">
15
+ <path d="M990 110H1058V178H1126V246H1058V178H990Z"/>
16
+ <path d="M1058 110H1126V178H1058"/>
17
+ </g>
18
+ </svg>
@@ -15,4 +15,4 @@ The schema defines shape. These laws define meaning.
15
15
 
16
16
  A reconcile exception names the child fields that receive the unmatched amount and its reason. `exception.amountField` must be a required money field on the child. `exception.reasonField` must be a required plain text field. A plain text field has `type: "string"` and no `pattern`, `format`, or `enum`. Admission rejects a missing or optional field, the wrong type, or a child that does not belong to the declaring instrument.
17
17
 
18
- The [diagnostic reference](../reference/diagnostics.md) lists every stable `UDL####` refusal code. The [specification](../../spec/README.md) carries the normative prose for each law.
18
+ The [diagnostic reference](../reference/diagnostics.md) lists every stable refusal code. The [specification](../../spec/README.md) carries the normative prose for each law.
@@ -3,7 +3,7 @@
3
3
  A second implementation needs three independent checks.
4
4
 
5
5
  1. Validate JSON shape against `spec/udl.schema.json`.
6
- 2. Enforce the whole-document laws and report the matching `UDL####` code and JSON path.
6
+ 2. Enforce the whole-document laws and report the matching stable diagnostic code and JSON path.
7
7
  3. Serialize admitted documents under the canonical bytes law.
8
8
 
9
9
  Run every conformance level. Valid cases must admit and match their canonical bytes and SHA-256 digest. Invalid cases must report every listed code and path. Evolution pairs must produce the listed `UDL7xxx` issues. An implementation may report more issues, but it may not omit a listed issue.
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 1.0.0-rc.1. Edit the source, not llms-full.txt. -->
1
+ <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 2.0.0. Edit the source, not llms-full.txt. -->
2
2
 
3
3
  # UDL complete reference
4
4
 
@@ -104,7 +104,7 @@ The schema defines shape. These laws define meaning.
104
104
 
105
105
  A reconcile exception names the child fields that receive the unmatched amount and its reason. `exception.amountField` must be a required money field on the child. `exception.reasonField` must be a required plain text field. A plain text field has `type: "string"` and no `pattern`, `format`, or `enum`. Admission rejects a missing or optional field, the wrong type, or a child that does not belong to the declaring instrument.
106
106
 
107
- The [diagnostic reference](reference/diagnostics.md) lists every stable `UDL####` refusal code. The [specification](../spec/README.md) carries the normative prose for each law.
107
+ The [diagnostic reference](reference/diagnostics.md) lists every stable refusal code. The [specification](../spec/README.md) carries the normative prose for each law.
108
108
 
109
109
  <!-- source: guide/04-fees-and-remainder.md -->
110
110
 
@@ -169,7 +169,7 @@ Evolution does not invent defaults for executable clause fields. In particular,
169
169
  A second implementation needs three independent checks.
170
170
 
171
171
  1. Validate JSON shape against `spec/udl.schema.json`.
172
- 2. Enforce the whole-document laws and report the matching `UDL####` code and JSON path.
172
+ 2. Enforce the whole-document laws and report the matching stable diagnostic code and JSON path.
173
173
  3. Serialize admitted documents under the canonical bytes law.
174
174
 
175
175
  Run every conformance level. Valid cases must admit and match their canonical bytes and SHA-256 digest. Invalid cases must report every listed code and path. Evolution pairs must produce the listed `UDL7xxx` issues. An implementation may report more issues, but it may not omit a listed issue.
@@ -1051,6 +1051,34 @@ true
1051
1051
  "note"
1052
1052
  ```
1053
1053
 
1054
+ ## journeys
1055
+
1056
+ - Scope: instrument
1057
+ - UDL target: `journeys`
1058
+ - Cardinality: many
1059
+ - Linear outputs: none
1060
+ - Effects: none
1061
+ - Law: Requirements-as-data law and closure law
1062
+ - Conformance source: `hand-edited.udl`
1063
+
1064
+ ```json
1065
+ [
1066
+ {
1067
+ "id": "file_note",
1068
+ "label": "File a note",
1069
+ "steps": [
1070
+ {
1071
+ "bind": {},
1072
+ "example": "default",
1073
+ "id": "note",
1074
+ "operation": "note.create"
1075
+ }
1076
+ ],
1077
+ "summary": "File a note."
1078
+ }
1079
+ ]
1080
+ ```
1081
+
1054
1082
  ## nav
1055
1083
 
1056
1084
  - Scope: instrument
@@ -1190,32 +1218,37 @@ true
1190
1218
 
1191
1219
  Codes are stable. Titles and messages may become clearer without changing the code. Apply the listed fix, then validate the whole document again.
1192
1220
 
1193
- | Code | Family | Category | Title | Fix |
1194
- | --------- | --------- | ----------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
1195
- | `UDL1001` | admission | invalid_utf8 | Invalid UTF-8 | Encode the document as valid UTF-8. |
1196
- | `UDL1002` | admission | invalid_json | Invalid JSON | Repair the JSON syntax before validation. |
1197
- | `UDL1003` | admission | invalid_shape | Invalid document shape | Match the published UDL JSON Schema. |
1198
- | `UDL1004` | admission | resource_limit | Resource limit exceeded | Reduce the source size, nesting, values, strings, references, or financial paths named by the message. |
1199
- | `UDL2001` | document | invalid_semantics | Duplicate declaration | Give each declaration a unique name. |
1200
- | `UDL2002` | document | invalid_semantics | Document law violation | Repair the declaration, subject contract, or derived effects named by the message. |
1201
- | `UDL2005` | document | invalid_semantics | Derived effects mismatch | Regenerate the action effects from its clauses. |
1202
- | `UDL3001` | lifecycle | invalid_semantics | Lifecycle is not closed | Declare every state and action transition, and make every state reachable. |
1203
- | `UDL4001` | finance | invalid_semantics | Money graph violation | Balance every funded amount and close every hold on each lifecycle path. |
1204
- | `UDL5001` | gates | invalid_semantics | Reference gate violation | Point the gate at a declared instrument, action, state, field, and reference. |
1205
- | `UDL5002` | gates | invalid_semantics | Check requirement violation | Use a declared check with compatible evidence and recurrence. |
1206
- | `UDL5003` | gates | invalid_semantics | Exposure gate violation | Use declared account and money fields for the exposure gate. |
1207
- | `UDL5004` | gates | invalid_semantics | Aggregate law violation | Point the aggregate at compatible parent and child fields. |
1208
- | `UDL5005` | gates | invalid_semantics | Settlement or payout violation | Use a declared settlement account and a compatible payout statement line. |
1209
- | `UDL5006` | gates | invalid_semantics | Quote and commit violation | Declare one complete quote freeze set and one matching commit action. |
1210
- | `UDL5007` | gates | invalid_semantics | Reconcile exception child violation | Name a declared child whose reference points back to this instrument. |
1211
- | `UDL5008` | gates | invalid_semantics | Action clause violation | Repair the clause fields and keep incompatible clauses separate. |
1212
- | `UDL5009` | gates | invalid_semantics | Reconcile exception amount field is missing or optional | Name the exception child's required money field in amountField. |
1213
- | `UDL5010` | gates | invalid_semantics | Reconcile exception amount field has the wrong type | Point amountField at a money field declared by the exception child. |
1214
- | `UDL5011` | gates | invalid_semantics | Reconcile exception reason field is missing or optional | Name the exception child's required text field in reasonField. |
1215
- | `UDL5012` | gates | invalid_semantics | Reconcile exception reason field has the wrong type | Point reasonField at a required plain text field declared by the exception child. |
1216
- | `UDL6001` | schema | invalid_semantics | Unsupported JSON Schema | Use only the sealed UDL JSON Schema subset. |
1217
- | `UDL7001` | evolution | invalid_evolution | Stored contract changed | Keep stored identities and contracts unchanged, and add only allowed optional declarations. |
1218
- | `UDL7002` | evolution | invalid_evolution | Version was not increased | Increase the product version for every semantic change. |
1221
+ | Code | Family | Category | Title | Fix |
1222
+ | ---------------------------- | --------- | ----------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
1223
+ | `journey_duplicate_step_id` | journey | invalid_semantics | Journey step id is duplicated | Give every named step in the journey a unique id. |
1224
+ | `journey_invalid_transition` | journey | invalid_semantics | Journey lifecycle transition is invalid | Order the steps so each action starts from the state produced by earlier steps. |
1225
+ | `journey_unbound_reference` | journey | invalid_semantics | Journey reference is unbound or has the wrong kind | Bind every reference input to an earlier step that creates the required kind. |
1226
+ | `journey_unknown_example` | journey | invalid_semantics | Journey example does not exist | Name an authored example on the journey operation. |
1227
+ | `journey_unknown_operation` | journey | invalid_semantics | Journey operation is not in the composition | Name an operation in the composition closure. |
1228
+ | `UDL1001` | admission | invalid_utf8 | Invalid UTF-8 | Encode the document as valid UTF-8. |
1229
+ | `UDL1002` | admission | invalid_json | Invalid JSON | Repair the JSON syntax before validation. |
1230
+ | `UDL1003` | admission | invalid_shape | Invalid document shape | Match the published UDL JSON Schema. |
1231
+ | `UDL1004` | admission | resource_limit | Resource limit exceeded | Reduce the source size, nesting, values, strings, references, or financial paths named by the message. |
1232
+ | `UDL2001` | document | invalid_semantics | Duplicate declaration | Give each declaration a unique name. |
1233
+ | `UDL2002` | document | invalid_semantics | Document law violation | Repair the declaration, subject contract, or derived effects named by the message. |
1234
+ | `UDL2005` | document | invalid_semantics | Derived effects mismatch | Regenerate the action effects from its clauses. |
1235
+ | `UDL3001` | lifecycle | invalid_semantics | Lifecycle is not closed | Declare every state and action transition, and make every state reachable. |
1236
+ | `UDL4001` | finance | invalid_semantics | Money graph violation | Balance every funded amount and close every hold on each lifecycle path. |
1237
+ | `UDL5001` | gates | invalid_semantics | Reference gate violation | Point the gate at a declared instrument, action, state, field, and reference. |
1238
+ | `UDL5002` | gates | invalid_semantics | Check requirement violation | Use a declared check with compatible evidence and recurrence. |
1239
+ | `UDL5003` | gates | invalid_semantics | Exposure gate violation | Use declared account and money fields for the exposure gate. |
1240
+ | `UDL5004` | gates | invalid_semantics | Aggregate law violation | Point the aggregate at compatible parent and child fields. |
1241
+ | `UDL5005` | gates | invalid_semantics | Settlement or payout violation | Use a declared settlement account and a compatible payout statement line. |
1242
+ | `UDL5006` | gates | invalid_semantics | Quote and commit violation | Declare one complete quote freeze set and one matching commit action. |
1243
+ | `UDL5007` | gates | invalid_semantics | Reconcile exception child violation | Name a declared child whose reference points back to this instrument. |
1244
+ | `UDL5008` | gates | invalid_semantics | Action clause violation | Repair the clause fields and keep incompatible clauses separate. |
1245
+ | `UDL5009` | gates | invalid_semantics | Reconcile exception amount field is missing or optional | Name the exception child's required money field in amountField. |
1246
+ | `UDL5010` | gates | invalid_semantics | Reconcile exception amount field has the wrong type | Point amountField at a money field declared by the exception child. |
1247
+ | `UDL5011` | gates | invalid_semantics | Reconcile exception reason field is missing or optional | Name the exception child's required text field in reasonField. |
1248
+ | `UDL5012` | gates | invalid_semantics | Reconcile exception reason field has the wrong type | Point reasonField at a required plain text field declared by the exception child. |
1249
+ | `UDL6001` | schema | invalid_semantics | Unsupported JSON Schema | Use only the sealed UDL JSON Schema subset. |
1250
+ | `UDL7001` | evolution | invalid_evolution | Stored contract changed | Keep stored identities and contracts unchanged, and add only allowed optional declarations. |
1251
+ | `UDL7002` | evolution | invalid_evolution | Version was not increased | Increase the product version for every semantic change. |
1219
1252
 
1220
1253
  <!-- source: reference/cli.md -->
1221
1254
 
package/docs/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 1.0.0-rc.1. Edit the source, not llms.txt. -->
1
+ <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 2.0.0. Edit the source, not llms.txt. -->
2
2
 
3
3
  # UDL documentation
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 1.0.0-rc.1. Edit the source, not clauses.md. -->
1
+ <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 2.0.0. Edit the source, not clauses.md. -->
2
2
 
3
3
  # Clause reference
4
4
 
@@ -852,6 +852,34 @@ true
852
852
  "note"
853
853
  ```
854
854
 
855
+ ## journeys
856
+
857
+ - Scope: instrument
858
+ - UDL target: `journeys`
859
+ - Cardinality: many
860
+ - Linear outputs: none
861
+ - Effects: none
862
+ - Law: Requirements-as-data law and closure law
863
+ - Conformance source: `hand-edited.udl`
864
+
865
+ ```json
866
+ [
867
+ {
868
+ "id": "file_note",
869
+ "label": "File a note",
870
+ "steps": [
871
+ {
872
+ "bind": {},
873
+ "example": "default",
874
+ "id": "note",
875
+ "operation": "note.create"
876
+ }
877
+ ],
878
+ "summary": "File a note."
879
+ }
880
+ ]
881
+ ```
882
+
855
883
  ## nav
856
884
 
857
885
  - Scope: instrument
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 1.0.0-rc.1. Edit the source, not cli.md. -->
1
+ <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 2.0.0. Edit the source, not cli.md. -->
2
2
 
3
3
  # Command reference
4
4
 
@@ -1,32 +1,37 @@
1
- <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 1.0.0-rc.1. Edit the source, not diagnostics.md. -->
1
+ <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 2.0.0. Edit the source, not diagnostics.md. -->
2
2
 
3
3
  # Diagnostic reference
4
4
 
5
5
  Codes are stable. Titles and messages may become clearer without changing the code. Apply the listed fix, then validate the whole document again.
6
6
 
7
- | Code | Family | Category | Title | Fix |
8
- | --------- | --------- | ----------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
9
- | `UDL1001` | admission | invalid_utf8 | Invalid UTF-8 | Encode the document as valid UTF-8. |
10
- | `UDL1002` | admission | invalid_json | Invalid JSON | Repair the JSON syntax before validation. |
11
- | `UDL1003` | admission | invalid_shape | Invalid document shape | Match the published UDL JSON Schema. |
12
- | `UDL1004` | admission | resource_limit | Resource limit exceeded | Reduce the source size, nesting, values, strings, references, or financial paths named by the message. |
13
- | `UDL2001` | document | invalid_semantics | Duplicate declaration | Give each declaration a unique name. |
14
- | `UDL2002` | document | invalid_semantics | Document law violation | Repair the declaration, subject contract, or derived effects named by the message. |
15
- | `UDL2005` | document | invalid_semantics | Derived effects mismatch | Regenerate the action effects from its clauses. |
16
- | `UDL3001` | lifecycle | invalid_semantics | Lifecycle is not closed | Declare every state and action transition, and make every state reachable. |
17
- | `UDL4001` | finance | invalid_semantics | Money graph violation | Balance every funded amount and close every hold on each lifecycle path. |
18
- | `UDL5001` | gates | invalid_semantics | Reference gate violation | Point the gate at a declared instrument, action, state, field, and reference. |
19
- | `UDL5002` | gates | invalid_semantics | Check requirement violation | Use a declared check with compatible evidence and recurrence. |
20
- | `UDL5003` | gates | invalid_semantics | Exposure gate violation | Use declared account and money fields for the exposure gate. |
21
- | `UDL5004` | gates | invalid_semantics | Aggregate law violation | Point the aggregate at compatible parent and child fields. |
22
- | `UDL5005` | gates | invalid_semantics | Settlement or payout violation | Use a declared settlement account and a compatible payout statement line. |
23
- | `UDL5006` | gates | invalid_semantics | Quote and commit violation | Declare one complete quote freeze set and one matching commit action. |
24
- | `UDL5007` | gates | invalid_semantics | Reconcile exception child violation | Name a declared child whose reference points back to this instrument. |
25
- | `UDL5008` | gates | invalid_semantics | Action clause violation | Repair the clause fields and keep incompatible clauses separate. |
26
- | `UDL5009` | gates | invalid_semantics | Reconcile exception amount field is missing or optional | Name the exception child's required money field in amountField. |
27
- | `UDL5010` | gates | invalid_semantics | Reconcile exception amount field has the wrong type | Point amountField at a money field declared by the exception child. |
28
- | `UDL5011` | gates | invalid_semantics | Reconcile exception reason field is missing or optional | Name the exception child's required text field in reasonField. |
29
- | `UDL5012` | gates | invalid_semantics | Reconcile exception reason field has the wrong type | Point reasonField at a required plain text field declared by the exception child. |
30
- | `UDL6001` | schema | invalid_semantics | Unsupported JSON Schema | Use only the sealed UDL JSON Schema subset. |
31
- | `UDL7001` | evolution | invalid_evolution | Stored contract changed | Keep stored identities and contracts unchanged, and add only allowed optional declarations. |
32
- | `UDL7002` | evolution | invalid_evolution | Version was not increased | Increase the product version for every semantic change. |
7
+ | Code | Family | Category | Title | Fix |
8
+ | ---------------------------- | --------- | ----------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
9
+ | `journey_duplicate_step_id` | journey | invalid_semantics | Journey step id is duplicated | Give every named step in the journey a unique id. |
10
+ | `journey_invalid_transition` | journey | invalid_semantics | Journey lifecycle transition is invalid | Order the steps so each action starts from the state produced by earlier steps. |
11
+ | `journey_unbound_reference` | journey | invalid_semantics | Journey reference is unbound or has the wrong kind | Bind every reference input to an earlier step that creates the required kind. |
12
+ | `journey_unknown_example` | journey | invalid_semantics | Journey example does not exist | Name an authored example on the journey operation. |
13
+ | `journey_unknown_operation` | journey | invalid_semantics | Journey operation is not in the composition | Name an operation in the composition closure. |
14
+ | `UDL1001` | admission | invalid_utf8 | Invalid UTF-8 | Encode the document as valid UTF-8. |
15
+ | `UDL1002` | admission | invalid_json | Invalid JSON | Repair the JSON syntax before validation. |
16
+ | `UDL1003` | admission | invalid_shape | Invalid document shape | Match the published UDL JSON Schema. |
17
+ | `UDL1004` | admission | resource_limit | Resource limit exceeded | Reduce the source size, nesting, values, strings, references, or financial paths named by the message. |
18
+ | `UDL2001` | document | invalid_semantics | Duplicate declaration | Give each declaration a unique name. |
19
+ | `UDL2002` | document | invalid_semantics | Document law violation | Repair the declaration, subject contract, or derived effects named by the message. |
20
+ | `UDL2005` | document | invalid_semantics | Derived effects mismatch | Regenerate the action effects from its clauses. |
21
+ | `UDL3001` | lifecycle | invalid_semantics | Lifecycle is not closed | Declare every state and action transition, and make every state reachable. |
22
+ | `UDL4001` | finance | invalid_semantics | Money graph violation | Balance every funded amount and close every hold on each lifecycle path. |
23
+ | `UDL5001` | gates | invalid_semantics | Reference gate violation | Point the gate at a declared instrument, action, state, field, and reference. |
24
+ | `UDL5002` | gates | invalid_semantics | Check requirement violation | Use a declared check with compatible evidence and recurrence. |
25
+ | `UDL5003` | gates | invalid_semantics | Exposure gate violation | Use declared account and money fields for the exposure gate. |
26
+ | `UDL5004` | gates | invalid_semantics | Aggregate law violation | Point the aggregate at compatible parent and child fields. |
27
+ | `UDL5005` | gates | invalid_semantics | Settlement or payout violation | Use a declared settlement account and a compatible payout statement line. |
28
+ | `UDL5006` | gates | invalid_semantics | Quote and commit violation | Declare one complete quote freeze set and one matching commit action. |
29
+ | `UDL5007` | gates | invalid_semantics | Reconcile exception child violation | Name a declared child whose reference points back to this instrument. |
30
+ | `UDL5008` | gates | invalid_semantics | Action clause violation | Repair the clause fields and keep incompatible clauses separate. |
31
+ | `UDL5009` | gates | invalid_semantics | Reconcile exception amount field is missing or optional | Name the exception child's required money field in amountField. |
32
+ | `UDL5010` | gates | invalid_semantics | Reconcile exception amount field has the wrong type | Point amountField at a money field declared by the exception child. |
33
+ | `UDL5011` | gates | invalid_semantics | Reconcile exception reason field is missing or optional | Name the exception child's required text field in reasonField. |
34
+ | `UDL5012` | gates | invalid_semantics | Reconcile exception reason field has the wrong type | Point reasonField at a required plain text field declared by the exception child. |
35
+ | `UDL6001` | schema | invalid_semantics | Unsupported JSON Schema | Use only the sealed UDL JSON Schema subset. |
36
+ | `UDL7001` | evolution | invalid_evolution | Stored contract changed | Keep stored identities and contracts unchanged, and add only allowed optional declarations. |
37
+ | `UDL7002` | evolution | invalid_evolution | Version was not increased | Increase the product version for every semantic change. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperscale0/udl",
3
- "version": "1.0.0-rc.1",
3
+ "version": "2.0.0",
4
4
  "description": "The Universal Domain Language: format spec, parser, validator, canonical serializer, and evolution diff.",
5
5
  "keywords": [
6
6
  "udl",
@@ -73,15 +73,16 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "@cfworker/json-schema": "4.1.1",
76
- "zod": "4.4.3"
76
+ "zod": "4.5.4"
77
77
  },
78
78
  "devDependencies": {
79
- "@types/bun": "1.4.0",
80
- "typescript": "6.0.3"
79
+ "bun-types": "1.4.2",
80
+ "typescript": "7.0.2"
81
81
  },
82
82
  "contributors": [
83
83
  "Meshael AlBakaawi",
84
84
  "Amir Ayub",
85
85
  "Sara AlBakaawi"
86
- ]
86
+ ],
87
+ "gitHead": "092924e9cf7c89ab2fbff740c5d19e355a74007c"
87
88
  }
package/spec/README.md CHANGED
@@ -152,21 +152,13 @@ that exists.
152
152
  **Package version** is the semver of `@hyperscale0/udl`, declared in
153
153
  `package.json`.
154
154
 
155
- They move independently, under one rule: **format 1 freezes when the package
156
- reaches 1.0.0.** The release candidate may still change what format 1 accepts,
157
- and every change appears in `../CHANGELOG.md`.
158
-
159
- After 1.0.0, an incompatible grammar change uses a new format literal. Readers
160
- keep an explicit decoder and validator for each supported old literal. A
161
- stored format 1 document remains readable under the format 1 rules. It does
162
- not acquire new required fields from the current package. Passing an old
163
- document to an evolution comparison can raise the matching `UDL7xxx` removal,
164
- tightening, lifecycle, or executable-change code, but a package upgrade alone
165
- does not rewrite its bytes. A product migration must validate and store its new
166
- document as a separate version before switching instances to it.
167
-
168
- The evolution codes are explicit. `UDL7001` protects stored identities,
169
- subjects, instruments, fields, lifecycles, actions, money clauses, gates, and
170
- policy. `UDL7002` requires a version increase for a semantic change.
155
+ They move independently. In development mode, contract and schema shapes change
156
+ without deprecation paths or frozen compatibility promises.
157
+
158
+ The evolution diff API (`diffValidatedUdlEvolution` and `diffInstrumentEvolution`)
159
+ evaluates append-only rules between two admitted documents. The evolution codes
160
+ are explicit. `UDL7001` protects stored identities, subjects, instruments, fields,
161
+ lifecycles, actions, money clauses, gates, and policy against removal, renaming,
162
+ or tightening. `UDL7002` requires a version increase for a semantic change.
171
163
  Evolution comparison admits the previous document first. A stored document
172
164
  that fails admission is `invalid_previous`, not an evolution issue.
@@ -550,6 +550,62 @@
550
550
  "required": ["initial", "states", "transitions"],
551
551
  "additionalProperties": false
552
552
  },
553
+ "journeys": {
554
+ "minItems": 1,
555
+ "type": "array",
556
+ "items": {
557
+ "type": "object",
558
+ "properties": {
559
+ "id": {
560
+ "type": "string",
561
+ "pattern": "^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$"
562
+ },
563
+ "label": {
564
+ "type": "string"
565
+ },
566
+ "steps": {
567
+ "minItems": 1,
568
+ "type": "array",
569
+ "items": {
570
+ "type": "object",
571
+ "properties": {
572
+ "bind": {
573
+ "type": "object",
574
+ "propertyNames": {
575
+ "type": "string",
576
+ "pattern": "^[a-z][A-Za-z0-9]*(?:\\.[a-z][A-Za-z0-9]*)*$"
577
+ },
578
+ "additionalProperties": {
579
+ "type": "string",
580
+ "pattern": "^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$"
581
+ }
582
+ },
583
+ "example": {
584
+ "type": "string",
585
+ "pattern": "^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$"
586
+ },
587
+ "id": {
588
+ "type": "string",
589
+ "pattern": "^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$"
590
+ },
591
+ "operation": {
592
+ "type": "string",
593
+ "maxLength": 160,
594
+ "pattern": "^[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*)+$"
595
+ }
596
+ },
597
+ "required": ["bind", "example", "operation"],
598
+ "additionalProperties": false
599
+ }
600
+ },
601
+ "summary": {
602
+ "type": "string"
603
+ }
604
+ },
605
+ "required": ["id", "label", "steps", "summary"],
606
+ "additionalProperties": false
607
+ }
608
+ },
553
609
  "nav": {
554
610
  "minItems": 1,
555
611
  "type": "array",
@@ -559,21 +615,14 @@
559
615
  },
560
616
  "parties": {
561
617
  "type": "object",
562
- "properties": {
563
- "beneficiary": {
564
- "type": "string",
565
- "pattern": "^[a-z][A-Za-z0-9]*$"
566
- },
567
- "payer": {
568
- "type": "string",
569
- "pattern": "^[a-z][A-Za-z0-9]*$"
570
- },
571
- "subjectHolder": {
572
- "type": "string",
573
- "pattern": "^[a-z][A-Za-z0-9]*$"
574
- }
618
+ "propertyNames": {
619
+ "type": "string",
620
+ "pattern": "^[a-z][A-Za-z0-9_]*$"
575
621
  },
576
- "additionalProperties": false
622
+ "additionalProperties": {
623
+ "type": "string",
624
+ "pattern": "^[a-z][A-Za-z0-9]*$"
625
+ }
577
626
  },
578
627
  "partitions": {
579
628
  "minItems": 1,
@@ -1231,7 +1280,7 @@
1231
1280
  "type": "array",
1232
1281
  "items": {
1233
1282
  "type": "string",
1234
- "enum": ["payer", "beneficiary", "subjectHolder"]
1283
+ "pattern": "^[a-z][A-Za-z0-9_]*$"
1235
1284
  }
1236
1285
  }
1237
1286
  },
@@ -2054,6 +2103,25 @@
2054
2103
  "pattern": "^[a-z][A-Za-z0-9]*(?:\\.[a-z][A-Za-z0-9]*)*$"
2055
2104
  }
2056
2105
  },
2106
+ "dateComparison": {
2107
+ "type": "object",
2108
+ "properties": {
2109
+ "localPath": {
2110
+ "type": "string",
2111
+ "pattern": "^[a-z][A-Za-z0-9]*(?:\\.[a-z][A-Za-z0-9]*)*$"
2112
+ },
2113
+ "operator": {
2114
+ "type": "string",
2115
+ "enum": [">=", ">", "<=", "<", "=="]
2116
+ },
2117
+ "referencedPath": {
2118
+ "type": "string",
2119
+ "pattern": "^[a-z][A-Za-z0-9]*(?:\\.[a-z][A-Za-z0-9]*)*$"
2120
+ }
2121
+ },
2122
+ "required": ["localPath", "operator", "referencedPath"],
2123
+ "additionalProperties": false
2124
+ },
2057
2125
  "field": {
2058
2126
  "type": "string",
2059
2127
  "pattern": "^[a-z][A-Za-z0-9]*$"
@@ -12,6 +12,7 @@ export type UdlDiagnosticFamily =
12
12
  | "evolution"
13
13
  | "finance"
14
14
  | "gates"
15
+ | "journey"
15
16
  | "lifecycle"
16
17
  | "schema";
17
18
 
@@ -154,6 +155,37 @@ const diagnosticDefinitions = {
154
155
  fix: "Use only the sealed UDL JSON Schema subset.",
155
156
  },
156
157
 
158
+ journey_unknown_operation: {
159
+ category: "invalid_semantics",
160
+ family: "journey",
161
+ title: "Journey operation is not in the composition",
162
+ fix: "Name an operation in the composition closure.",
163
+ },
164
+ journey_unknown_example: {
165
+ category: "invalid_semantics",
166
+ family: "journey",
167
+ title: "Journey example does not exist",
168
+ fix: "Name an authored example on the journey operation.",
169
+ },
170
+ journey_invalid_transition: {
171
+ category: "invalid_semantics",
172
+ family: "journey",
173
+ title: "Journey lifecycle transition is invalid",
174
+ fix: "Order the steps so each action starts from the state produced by earlier steps.",
175
+ },
176
+ journey_unbound_reference: {
177
+ category: "invalid_semantics",
178
+ family: "journey",
179
+ title: "Journey reference is unbound or has the wrong kind",
180
+ fix: "Bind every reference input to an earlier step that creates the required kind.",
181
+ },
182
+ journey_duplicate_step_id: {
183
+ category: "invalid_semantics",
184
+ family: "journey",
185
+ title: "Journey step id is duplicated",
186
+ fix: "Give every named step in the journey a unique id.",
187
+ },
188
+
157
189
  UDL7001: {
158
190
  category: "invalid_evolution",
159
191
  family: "evolution",