colregs 0.3.0 → 0.3.1

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 (39) hide show
  1. package/README.md +8 -6
  2. package/data/applicability.json +219 -244
  3. package/data/facts.json +4 -4
  4. package/data/geometry.json +8 -8
  5. package/data/i18n/en.json +27 -0
  6. package/data/i18n/fi.json +25 -0
  7. package/data/images.json +32 -32
  8. package/data/operations.json +79 -0
  9. package/data/rules.json +5 -0
  10. package/data/version.json +1 -1
  11. package/docs/adr/0006-json-schema-and-identifier-diff.md +2 -0
  12. package/docs/adr/0011-api-shape.md +1 -1
  13. package/docs/adr/0014-engine-interface-owned-by-colregs.md +103 -0
  14. package/docs/adr/0015-rule-ids-are-paragraph-keys.md +191 -0
  15. package/docs/budgets.json +5 -15
  16. package/docs/identifiers.md +49 -51
  17. package/docs/maritime-sources.md +58 -0
  18. package/docs/normative-language.md +103 -0
  19. package/docs/part-b-invariants.md +31 -29
  20. package/docs/requirements.md +80 -71
  21. package/fixtures/applicability-fixtures.json +190 -190
  22. package/fixtures/situation-fixtures.json +287 -287
  23. package/package.json +1 -1
  24. package/schema/applicability-fixtures.schema.json +4 -13
  25. package/schema/applicability.schema.json +27 -27
  26. package/schema/conduct-evaluation.schema.json +135 -0
  27. package/schema/display-evaluation.schema.json +146 -0
  28. package/schema/encounter-evaluation.schema.json +109 -0
  29. package/schema/evaluation.schema.json +149 -0
  30. package/schema/fact-record.schema.json +30 -0
  31. package/schema/i18n-catalog.schema.json +47 -0
  32. package/schema/operations.schema.json +124 -0
  33. package/schema/rule2-departure-finding.schema.json +72 -0
  34. package/schema/rule2-departure-model.schema.json +159 -0
  35. package/schema/situation-fixtures.schema.json +10 -146
  36. package/schema/situation.schema.json +72 -0
  37. package/schema/trace.schema.json +33 -0
  38. package/data/deprecated-identifiers.json +0 -7
  39. package/schema/deprecated-identifiers.schema.json +0 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "colregs",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "COLREGS 72 and its national amalgamations as language-neutral JSON — rule text, light definitions, and applicability predicates — with cross-implementation fixtures",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,14 +8,7 @@
8
8
  "additionalProperties": false,
9
9
  "required": ["jurisdiction", "cases"],
10
10
  "$defs": {
11
- "factValue": {
12
- "oneOf": [
13
- { "type": "string", "pattern": "^[a-z][a-z0-9_]*:[a-z0-9_]+$" },
14
- { "type": "number" },
15
- { "type": "boolean" }
16
- ]
17
- },
18
- "entryId": { "type": "string", "pattern": "^[0-9]+[a-z0-9]*(-[a-z0-9]+)?$" }
11
+ "ruleId": { "$ref": "applicability.schema.json#/$defs/ruleId" }
19
12
  },
20
13
  "properties": {
21
14
  "note": { "type": "string" },
@@ -31,16 +24,14 @@
31
24
  "name": { "type": "string", "minLength": 1 },
32
25
  "jurisdiction": { "type": "string", "pattern": "^[a-z]+(/[a-z]+)*$" },
33
26
  "facts": {
27
+ "$comment": "A FactRecord (schema/fact-record.schema.json, ADR 0014); a case asserts at least one fact.",
34
28
  "type": "object",
35
29
  "minProperties": 1,
36
- "additionalProperties": false,
37
- "patternProperties": {
38
- "^fact:[a-z0-9_]+$": { "$ref": "#/$defs/factValue" }
39
- }
30
+ "$ref": "fact-record.schema.json"
40
31
  },
41
32
  "expect": {
42
33
  "type": "array",
43
- "items": { "$ref": "#/$defs/entryId" }
34
+ "items": { "$ref": "#/$defs/ruleId" }
44
35
  }
45
36
  }
46
37
  }
@@ -7,7 +7,21 @@
7
7
  "additionalProperties": false,
8
8
  "required": ["entries"],
9
9
  "$defs": {
10
- "entryId": { "type": "string", "pattern": "^[0-9]+[a-z0-9]*(-[a-z0-9]+)*$" },
10
+ "ruleCategory": {
11
+ "type": "string",
12
+ "enum": [
13
+ "definition",
14
+ "standard",
15
+ "scope",
16
+ "display",
17
+ "classification",
18
+ "precedence",
19
+ "conduct",
20
+ "care",
21
+ "meta"
22
+ ]
23
+ },
24
+ "ruleId": { "type": "string", "pattern": "^rule:[0-9]+[a-z]?(_[ivx]+)*(:[a-z][a-z0-9_]*)?$" },
11
25
  "modality": {
12
26
  "type": "string",
13
27
  "enum": ["shall", "may", "shall-if-practicable", "conditional", "exempt", "shall-not", "shall-not-impede"]
@@ -174,20 +188,20 @@
174
188
  "one_of": {
175
189
  "type": "array",
176
190
  "minItems": 2,
177
- "items": { "$ref": "#/$defs/entryId" }
191
+ "items": { "$ref": "#/$defs/ruleId" }
178
192
  },
179
193
  "rel:includes": {
180
194
  "type": "array",
181
195
  "minItems": 1,
182
- "items": { "$ref": "#/$defs/entryId" }
196
+ "items": { "$ref": "#/$defs/ruleId" }
183
197
  },
184
198
  "cite": { "type": "string", "minLength": 1 }
185
199
  }
186
200
  },
187
- "entryIdList": {
201
+ "ruleIdList": {
188
202
  "type": "array",
189
203
  "minItems": 1,
190
- "items": { "$ref": "#/$defs/entryId" }
204
+ "items": { "$ref": "#/$defs/ruleId" }
191
205
  }
192
206
  },
193
207
  "properties": {
@@ -312,7 +326,7 @@
312
326
  "additionalProperties": false,
313
327
  "required": ["id", "jurisdiction", "cite", "category", "note"],
314
328
  "properties": {
315
- "id": { "$ref": "#/$defs/entryId" },
329
+ "id": { "$ref": "#/$defs/ruleId" },
316
330
  "jurisdiction": { "type": "string", "pattern": "^[a-z]+(/[a-z]+)*$" },
317
331
  "cite": { "type": "string", "minLength": 1 },
318
332
  "category": { "type": "string", "enum": ["care", "meta"] },
@@ -320,19 +334,6 @@
320
334
  }
321
335
  }
322
336
  },
323
- "retired_entry_ids": {
324
- "type": "object",
325
- "additionalProperties": false,
326
- "required": ["ids"],
327
- "properties": {
328
- "note": { "type": "string" },
329
- "ids": {
330
- "type": "object",
331
- "propertyNames": { "$ref": "#/$defs/entryId" },
332
- "additionalProperties": { "type": "string", "minLength": 1 }
333
- }
334
- }
335
- },
336
337
  "entries": {
337
338
  "type": "array",
338
339
  "minItems": 1,
@@ -341,12 +342,11 @@
341
342
  "additionalProperties": false,
342
343
  "required": ["id", "jurisdiction", "cite", "when", "modality"],
343
344
  "properties": {
344
- "id": { "$ref": "#/$defs/entryId" },
345
+ "id": { "$ref": "#/$defs/ruleId" },
345
346
  "jurisdiction": { "type": "string", "pattern": "^[a-z]+(/[a-z]+)*$" },
346
347
  "cite": { "type": "string", "minLength": 1 },
347
348
  "category": {
348
- "type": "string",
349
- "enum": ["definition", "standard", "scope", "display", "classification", "precedence", "conduct", "care", "meta"]
349
+ "$ref": "#/$defs/ruleCategory"
350
350
  },
351
351
  "subjects": { "type": "integer", "const": 2 },
352
352
  "when": { "$ref": "#/$defs/situationWhen" },
@@ -366,16 +366,16 @@
366
366
  "note": { "type": "string" },
367
367
  "gap": { "type": "string", "minLength": 1 },
368
368
  "no_gate_note": { "type": "string", "minLength": 1 },
369
- "rel:includes": { "$ref": "#/$defs/entryIdList" },
369
+ "rel:includes": { "$ref": "#/$defs/ruleIdList" },
370
370
  "rel:conditional_includes": {
371
371
  "type": "array",
372
372
  "minItems": 1,
373
373
  "items": { "$ref": "#/$defs/conditionalInclude" }
374
374
  },
375
- "rel:in_lieu_of": { "$ref": "#/$defs/entryIdList" },
376
- "rel:excludes": { "$ref": "#/$defs/entryIdList" },
377
- "rel:exempts": { "$ref": "#/$defs/entryIdList" },
378
- "rel:overrides": { "$ref": "#/$defs/entryIdList" }
375
+ "rel:in_lieu_of": { "$ref": "#/$defs/ruleIdList" },
376
+ "rel:excludes": { "$ref": "#/$defs/ruleIdList" },
377
+ "rel:exempts": { "$ref": "#/$defs/ruleIdList" },
378
+ "rel:overrides": { "$ref": "#/$defs/ruleIdList" }
379
379
  },
380
380
  "allOf": [
381
381
  {
@@ -0,0 +1,135 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mark-brannan/colregs/schema/conduct-evaluation.schema.json",
4
+ "title": "ConductEvaluation",
5
+ "description": "The result of evaluateConduct: one verdict per applied conduct entry per subject over the window the caller handed over, and the Rule 13(d)/17 phase changes seen (ADR 0012 §3, ADR 0014). Structure only.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "colregs",
10
+ "window",
11
+ "applied",
12
+ "verdicts",
13
+ "phases"
14
+ ],
15
+ "properties": {
16
+ "colregs": {
17
+ "$ref": "evaluation.schema.json#/$defs/colregs"
18
+ },
19
+ "window": {
20
+ "type": "object",
21
+ "additionalProperties": false,
22
+ "required": [
23
+ "from_s",
24
+ "to_s",
25
+ "samples"
26
+ ],
27
+ "properties": {
28
+ "from_s": {
29
+ "type": "number"
30
+ },
31
+ "to_s": {
32
+ "type": "number"
33
+ },
34
+ "samples": {
35
+ "type": "integer",
36
+ "minimum": 1
37
+ }
38
+ }
39
+ },
40
+ "applied": {
41
+ "$ref": "evaluation.schema.json#/$defs/ruleIds"
42
+ },
43
+ "verdicts": {
44
+ "type": "array",
45
+ "items": {
46
+ "$ref": "#/$defs/verdict"
47
+ }
48
+ },
49
+ "phases": {
50
+ "type": "array",
51
+ "items": {
52
+ "$ref": "#/$defs/phaseChange"
53
+ }
54
+ }
55
+ },
56
+ "$defs": {
57
+ "subject": {
58
+ "type": "string",
59
+ "enum": [
60
+ "own",
61
+ "other"
62
+ ]
63
+ },
64
+ "verdict": {
65
+ "$comment": "`pending`: the window ended before the duty could be judged. An entry that never attached is absent, not pending.",
66
+ "type": "object",
67
+ "additionalProperties": false,
68
+ "required": [
69
+ "id",
70
+ "subject",
71
+ "verdict"
72
+ ],
73
+ "properties": {
74
+ "id": {
75
+ "$ref": "evaluation.schema.json#/$defs/ruleId"
76
+ },
77
+ "subject": {
78
+ "$ref": "#/$defs/subject"
79
+ },
80
+ "verdict": {
81
+ "type": "string",
82
+ "enum": [
83
+ "kept",
84
+ "breached",
85
+ "pending"
86
+ ]
87
+ },
88
+ "attached_at_s": {
89
+ "type": "number"
90
+ },
91
+ "decided_at_s": {
92
+ "type": "number"
93
+ },
94
+ "robustness": {
95
+ "type": "object",
96
+ "additionalProperties": false,
97
+ "required": [
98
+ "value",
99
+ "unit"
100
+ ],
101
+ "properties": {
102
+ "value": {
103
+ "type": "number"
104
+ },
105
+ "unit": {
106
+ "type": "string",
107
+ "minLength": 1
108
+ }
109
+ }
110
+ }
111
+ }
112
+ },
113
+ "phaseChange": {
114
+ "$comment": "`phase` is a paragraph cite, never an entry id: several phases have no entry.",
115
+ "type": "object",
116
+ "additionalProperties": false,
117
+ "required": [
118
+ "subject",
119
+ "phase",
120
+ "at_s"
121
+ ],
122
+ "properties": {
123
+ "subject": {
124
+ "$ref": "#/$defs/subject"
125
+ },
126
+ "phase": {
127
+ "$ref": "evaluation.schema.json#/$defs/paragraphCite"
128
+ },
129
+ "at_s": {
130
+ "type": "number"
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
@@ -0,0 +1,146 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mark-brannan/colregs/schema/display-evaluation.schema.json",
4
+ "title": "DisplayEvaluation",
5
+ "description": "The result of evaluateDisplay: every complete lawful display for one vessel, alternatives unresolved (REQ-MODEL-8), with the data it was read against (ADR 0011 §1, ADR 0014). Structure only; the $defs shared with the other envelopes live in schema/evaluation.schema.json.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "colregs",
10
+ "applied",
11
+ "exempted",
12
+ "excluded",
13
+ "overridden",
14
+ "displays",
15
+ "optional_additions",
16
+ "modalities",
17
+ "categories",
18
+ "provenance"
19
+ ],
20
+ "properties": {
21
+ "colregs": {
22
+ "$ref": "evaluation.schema.json#/$defs/colregs"
23
+ },
24
+ "applied": {
25
+ "$ref": "evaluation.schema.json#/$defs/ruleIds"
26
+ },
27
+ "exempted": {
28
+ "$ref": "evaluation.schema.json#/$defs/byEntryList"
29
+ },
30
+ "excluded": {
31
+ "$ref": "evaluation.schema.json#/$defs/byEntryList"
32
+ },
33
+ "overridden": {
34
+ "$ref": "evaluation.schema.json#/$defs/byEntryList"
35
+ },
36
+ "displays": {
37
+ "type": "array",
38
+ "items": {
39
+ "$ref": "#/$defs/display"
40
+ }
41
+ },
42
+ "optional_additions": {
43
+ "type": "array",
44
+ "items": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "required": [
48
+ "id",
49
+ "lights",
50
+ "cite"
51
+ ],
52
+ "properties": {
53
+ "id": {
54
+ "$ref": "evaluation.schema.json#/$defs/ruleId"
55
+ },
56
+ "via": {
57
+ "$ref": "evaluation.schema.json#/$defs/ruleId"
58
+ },
59
+ "lights": {
60
+ "type": "array",
61
+ "items": {
62
+ "$ref": "#/$defs/displayLight"
63
+ }
64
+ },
65
+ "cite": {
66
+ "type": "string",
67
+ "minLength": 1
68
+ }
69
+ }
70
+ }
71
+ },
72
+ "optionalAdditions": {
73
+ "deprecated": true,
74
+ "$comment": "Renamed to optional_additions (ADR 0011 §4); an implementation may still emit both.",
75
+ "type": "array",
76
+ "items": {
77
+ "$ref": "#/properties/optional_additions/items"
78
+ }
79
+ },
80
+ "modalities": {
81
+ "$ref": "evaluation.schema.json#/$defs/modalities"
82
+ },
83
+ "categories": {
84
+ "$ref": "evaluation.schema.json#/$defs/categories"
85
+ },
86
+ "provenance": {
87
+ "$ref": "evaluation.schema.json#/$defs/provenance"
88
+ }
89
+ },
90
+ "$defs": {
91
+ "displayLight": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "required": [
95
+ "spec",
96
+ "source_entry",
97
+ "modality"
98
+ ],
99
+ "properties": {
100
+ "spec": {
101
+ "$ref": "applicability.schema.json#/$defs/lightRef"
102
+ },
103
+ "source_entry": {
104
+ "$ref": "evaluation.schema.json#/$defs/ruleId"
105
+ },
106
+ "sourceEntry": {
107
+ "deprecated": true,
108
+ "$comment": "Renamed to source_entry (ADR 0011 §4).",
109
+ "$ref": "evaluation.schema.json#/$defs/ruleId"
110
+ },
111
+ "via": {
112
+ "$ref": "evaluation.schema.json#/$defs/ruleId"
113
+ },
114
+ "modality": {
115
+ "$ref": "applicability.schema.json#/$defs/modality"
116
+ }
117
+ }
118
+ },
119
+ "display": {
120
+ "type": "object",
121
+ "additionalProperties": false,
122
+ "required": [
123
+ "entries",
124
+ "lights",
125
+ "chosen"
126
+ ],
127
+ "properties": {
128
+ "entries": {
129
+ "$ref": "evaluation.schema.json#/$defs/ruleIds"
130
+ },
131
+ "lights": {
132
+ "type": "array",
133
+ "items": {
134
+ "$ref": "#/$defs/displayLight"
135
+ }
136
+ },
137
+ "chosen": {
138
+ "type": "array",
139
+ "items": {
140
+ "type": "string"
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
@@ -0,0 +1,109 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mark-brannan/colregs/schema/encounter-evaluation.schema.json",
4
+ "title": "EncounterEvaluation",
5
+ "description": "The result of evaluateEncounter: two vessels at one instant -- scope, encounter class, risk of collision with its grounds, roles as a set per subject, overrides and modalities (ADR 0011 §4, ADR 0014). Structure only.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "colregs",
10
+ "applied",
11
+ "scope",
12
+ "risk_of_collision",
13
+ "roles",
14
+ "overridden",
15
+ "modalities",
16
+ "categories",
17
+ "provenance"
18
+ ],
19
+ "properties": {
20
+ "colregs": {
21
+ "$ref": "evaluation.schema.json#/$defs/colregs"
22
+ },
23
+ "applied": {
24
+ "$ref": "evaluation.schema.json#/$defs/ruleIds"
25
+ },
26
+ "scope": {
27
+ "$ref": "evaluation.schema.json#/$defs/ruleIds"
28
+ },
29
+ "encounter": {
30
+ "$comment": "Absent when no classification entry fired: cannot say, not none (Q-43).",
31
+ "type": "string",
32
+ "enum": [
33
+ "head-on",
34
+ "crossing",
35
+ "overtaking",
36
+ "none"
37
+ ]
38
+ },
39
+ "risk_of_collision": {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "required": [
43
+ "asserted",
44
+ "by"
45
+ ],
46
+ "properties": {
47
+ "asserted": {
48
+ "type": "boolean"
49
+ },
50
+ "by": {
51
+ "$ref": "evaluation.schema.json#/$defs/ruleIds"
52
+ }
53
+ }
54
+ },
55
+ "roles": {
56
+ "type": "object",
57
+ "additionalProperties": false,
58
+ "required": [
59
+ "own",
60
+ "other"
61
+ ],
62
+ "properties": {
63
+ "own": {
64
+ "$ref": "#/$defs/subjectRoles"
65
+ },
66
+ "other": {
67
+ "$ref": "#/$defs/subjectRoles"
68
+ }
69
+ }
70
+ },
71
+ "overridden": {
72
+ "$ref": "evaluation.schema.json#/$defs/byEntryList"
73
+ },
74
+ "modalities": {
75
+ "$ref": "evaluation.schema.json#/$defs/modalities"
76
+ },
77
+ "categories": {
78
+ "$ref": "evaluation.schema.json#/$defs/categories"
79
+ },
80
+ "provenance": {
81
+ "$ref": "evaluation.schema.json#/$defs/provenance"
82
+ }
83
+ },
84
+ "$defs": {
85
+ "subjectRole": {
86
+ "$comment": "Roles are a set per subject, each citing the entry that assigned it (Q-36).",
87
+ "type": "object",
88
+ "additionalProperties": false,
89
+ "required": [
90
+ "role",
91
+ "by"
92
+ ],
93
+ "properties": {
94
+ "role": {
95
+ "$ref": "applicability.schema.json#/$defs/effectRole"
96
+ },
97
+ "by": {
98
+ "$ref": "evaluation.schema.json#/$defs/ruleId"
99
+ }
100
+ }
101
+ },
102
+ "subjectRoles": {
103
+ "type": "array",
104
+ "items": {
105
+ "$ref": "#/$defs/subjectRole"
106
+ }
107
+ }
108
+ }
109
+ }