colregs 0.1.1 → 0.2.2

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 (37) hide show
  1. package/LICENSE +194 -26
  2. package/PROVENANCE.md +45 -12
  3. package/README.md +222 -23
  4. package/data/applicability.json +1252 -190
  5. package/data/deprecated-identifiers.json +7 -0
  6. package/data/facts.json +556 -113
  7. package/data/geometry.json +33 -33
  8. package/data/images.json +51 -25
  9. package/data/lights.json +35 -35
  10. package/data/rules.json +787 -3
  11. package/docs/adr/0001-name-and-jurisdiction-model.md +119 -1
  12. package/docs/adr/0003-language-as-a-dimension.md +220 -0
  13. package/docs/adr/0004-licence-layering.md +78 -0
  14. package/docs/adr/0005-rule-categories-and-the-situation-record.md +323 -0
  15. package/docs/adr/0006-json-schema-and-identifier-diff.md +95 -0
  16. package/docs/adr/0007-rule26-overrides-and-aground.md +68 -0
  17. package/docs/adr/0008-mooring-buoy-modifier.md +87 -0
  18. package/docs/budgets.json +162 -0
  19. package/docs/conventions.md +27 -0
  20. package/docs/gates.json +84 -0
  21. package/docs/identifiers.md +435 -0
  22. package/docs/part-b-invariants.md +922 -0
  23. package/docs/requirements.md +1251 -23
  24. package/docs/verification/2026-08-30-q6-q8.md +278 -0
  25. package/docs/verification/2026-09-05-rule27f-rule28-anchor-scenarios.md +330 -0
  26. package/fixtures/applicability-fixtures.json +361 -227
  27. package/fixtures/situation-fixtures.json +3673 -0
  28. package/package.json +16 -4
  29. package/schema/applicability-fixtures.schema.json +49 -0
  30. package/schema/applicability.schema.json +401 -0
  31. package/schema/deprecated-identifiers.schema.json +29 -0
  32. package/schema/facts.schema.json +793 -0
  33. package/schema/geometry.schema.json +239 -0
  34. package/schema/images.schema.json +53 -0
  35. package/schema/lights.schema.json +131 -0
  36. package/schema/rules.schema.json +50 -0
  37. package/schema/situation-fixtures.schema.json +325 -0
@@ -0,0 +1,239 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mark-brannan/colregs/schema/geometry.schema.json",
4
+ "title": "data/geometry.json",
5
+ "description": "Annex I positioning, shapes, colour and intensity. Structure only -- see docs/adr/0006-json-schema-and-identifier-diff.md.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["jurisdiction", "vertical_positioning", "horizontal_positioning", "shapes", "colors", "intensity"],
9
+ "$defs": {
10
+ "predicateValue": {
11
+ "oneOf": [
12
+ {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "minProperties": 1,
16
+ "properties": {
17
+ "gte": { "type": "number" },
18
+ "gt": { "type": "number" },
19
+ "lte": { "type": "number" },
20
+ "lt": { "type": "number" }
21
+ }
22
+ },
23
+ { "type": "string", "pattern": "^[a-z][a-z0-9_]*:[a-z0-9_]+$" },
24
+ { "type": "boolean" },
25
+ {
26
+ "type": "array",
27
+ "minItems": 1,
28
+ "items": { "type": "string", "pattern": "^[a-z][a-z0-9_]*:[a-z0-9_]+$" }
29
+ }
30
+ ]
31
+ },
32
+ "when": {
33
+ "type": "object",
34
+ "minProperties": 1,
35
+ "additionalProperties": false,
36
+ "patternProperties": {
37
+ "^fact:[a-z0-9_]+$": { "$ref": "#/$defs/predicateValue" }
38
+ }
39
+ },
40
+ "range": {
41
+ "type": "object",
42
+ "additionalProperties": false,
43
+ "minProperties": 1,
44
+ "properties": {
45
+ "min": { "type": "number" },
46
+ "max": { "type": "number" }
47
+ }
48
+ },
49
+ "positioningEntry": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "required": ["cite", "text"],
53
+ "properties": {
54
+ "cite": { "type": "string", "minLength": 1 },
55
+ "light": { "type": "string", "pattern": "^light:[a-z_]+$" },
56
+ "which": { "type": "string" },
57
+ "when": { "$ref": "#/$defs/when" },
58
+ "datum": { "type": "string" },
59
+ "datum_secondary": { "type": "string" },
60
+ "constraint": { "type": "string" },
61
+ "combined": { "type": "boolean" },
62
+ "equal_spacing": { "type": "boolean" },
63
+ "min_m": { "type": ["number", "null"] },
64
+ "max_m": { "type": "number" },
65
+ "min_above_sidelights_m": { "type": "number" },
66
+ "min_below_m": { "type": "number" },
67
+ "min_spacing_m": { "type": "number" },
68
+ "min_multiple_of_pair_spacing": { "type": "number" },
69
+ "max_fraction_of_masthead_height": { "type": "number" },
70
+ "min_fraction_of_length": { "type": "number" },
71
+ "need_not_exceed_m": { "type": "number" },
72
+ "forward_light_max_fraction_of_length_from_stem": { "type": "number" },
73
+ "min_offset_from_centerline_m": { "type": "number" },
74
+ "also": {
75
+ "oneOf": [
76
+ { "type": "string" },
77
+ {
78
+ "type": "object",
79
+ "additionalProperties": false,
80
+ "properties": {
81
+ "when": { "$ref": "#/$defs/when" },
82
+ "datum": { "type": "string" },
83
+ "min_m": { "type": "number" }
84
+ }
85
+ }
86
+ ]
87
+ },
88
+ "lowest_light": {
89
+ "type": "object",
90
+ "additionalProperties": false,
91
+ "properties": {
92
+ "datum": { "type": "string" },
93
+ "min_m": { "type": "number" },
94
+ "except": { "type": "string" }
95
+ }
96
+ },
97
+ "applies_to_entries": {
98
+ "type": "array",
99
+ "minItems": 1,
100
+ "items": { "type": "string" }
101
+ },
102
+ "text": { "type": "string", "minLength": 1 }
103
+ }
104
+ }
105
+ },
106
+ "properties": {
107
+ "jurisdiction": { "type": "string", "pattern": "^[a-z]+(/[a-z]+)*$" },
108
+ "source": { "type": "string" },
109
+ "note": { "type": "string" },
110
+ "vertical_positioning": {
111
+ "type": "array",
112
+ "minItems": 1,
113
+ "items": { "$ref": "#/$defs/positioningEntry" }
114
+ },
115
+ "horizontal_positioning": {
116
+ "type": "array",
117
+ "minItems": 1,
118
+ "items": { "$ref": "#/$defs/positioningEntry" }
119
+ },
120
+ "direction_indicating": {
121
+ "type": "array",
122
+ "items": {
123
+ "type": "object",
124
+ "additionalProperties": false,
125
+ "required": ["cite", "text"],
126
+ "properties": {
127
+ "cite": { "type": "string", "minLength": 1 },
128
+ "applies_to_entries": {
129
+ "type": "array",
130
+ "minItems": 1,
131
+ "items": { "type": "string" }
132
+ },
133
+ "horizontal_from_identity_lights_m": { "$ref": "#/$defs/range" },
134
+ "horizontal_from_ram_lights_m": { "$ref": "#/$defs/range" },
135
+ "vertical": { "type": "string" },
136
+ "text": { "type": "string", "minLength": 1 }
137
+ }
138
+ }
139
+ },
140
+ "shapes": {
141
+ "type": "object",
142
+ "additionalProperties": false,
143
+ "required": ["cite", "color"],
144
+ "properties": {
145
+ "cite": { "type": "string" },
146
+ "color": { "type": "string" },
147
+ "ball": {
148
+ "type": "object",
149
+ "additionalProperties": false,
150
+ "properties": {
151
+ "min_diameter_m": { "type": "number" },
152
+ "cite": { "type": "string" }
153
+ }
154
+ },
155
+ "cone": {
156
+ "type": "object",
157
+ "additionalProperties": false,
158
+ "properties": {
159
+ "min_base_diameter_m": { "type": "number" },
160
+ "height_equals_diameter": { "type": "boolean" },
161
+ "cite": { "type": "string" }
162
+ }
163
+ },
164
+ "cylinder": {
165
+ "type": "object",
166
+ "additionalProperties": false,
167
+ "properties": {
168
+ "min_diameter_m": { "type": "number" },
169
+ "height_multiple_of_diameter": { "type": "number" },
170
+ "cite": { "type": "string" }
171
+ }
172
+ },
173
+ "diamond": {
174
+ "type": "object",
175
+ "additionalProperties": false,
176
+ "properties": {
177
+ "composition": { "type": "string" },
178
+ "cite": { "type": "string" }
179
+ }
180
+ },
181
+ "vertical_spacing_min_m": { "type": "number" },
182
+ "small_vessel_relief": {
183
+ "type": "object",
184
+ "additionalProperties": false,
185
+ "properties": {
186
+ "when": { "$ref": "#/$defs/when" },
187
+ "text": { "type": "string" }
188
+ }
189
+ }
190
+ }
191
+ },
192
+ "colors": {
193
+ "type": "object",
194
+ "additionalProperties": false,
195
+ "required": ["cite", "standard", "chromaticity_corners"],
196
+ "properties": {
197
+ "cite": { "type": "string" },
198
+ "standard": { "type": "string" },
199
+ "chromaticity_corners": {
200
+ "type": "object",
201
+ "additionalProperties": {
202
+ "type": "object",
203
+ "additionalProperties": false,
204
+ "required": ["x", "y"],
205
+ "properties": {
206
+ "x": { "type": "array", "items": { "type": "number" }, "minItems": 3 },
207
+ "y": { "type": "array", "items": { "type": "number" }, "minItems": 3 }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ },
213
+ "intensity": {
214
+ "type": "object",
215
+ "additionalProperties": false,
216
+ "required": ["cite", "formula", "terms", "table_cd_by_range_nm"],
217
+ "properties": {
218
+ "cite": { "type": "string" },
219
+ "formula": { "type": "string" },
220
+ "terms": { "type": "object", "additionalProperties": { "type": "string" } },
221
+ "table_cd_by_range_nm": {
222
+ "type": "object",
223
+ "additionalProperties": { "type": "number" }
224
+ }
225
+ }
226
+ },
227
+ "sectors": {
228
+ "type": "object",
229
+ "additionalProperties": false,
230
+ "properties": {
231
+ "cite": { "type": "string" },
232
+ "horizontal": {
233
+ "type": "object",
234
+ "additionalProperties": { "type": "string" }
235
+ }
236
+ }
237
+ }
238
+ }
239
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mark-brannan/colregs/schema/images.schema.json",
4
+ "title": "data/images.json",
5
+ "description": "Every catalogued image, its source and what it illustrates. Structure only -- see docs/adr/0006-json-schema-and-identifier-diff.md.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["count", "images"],
9
+ "properties": {
10
+ "note": { "type": "string" },
11
+ "count": { "type": "integer", "minimum": 0 },
12
+ "images": {
13
+ "type": "object",
14
+ "additionalProperties": {
15
+ "type": "object",
16
+ "additionalProperties": false,
17
+ "required": ["file", "bytes", "sha256", "pixels", "source_url", "source", "retrieved", "rights"],
18
+ "properties": {
19
+ "file": { "type": "string", "minLength": 1 },
20
+ "bytes": { "type": "integer", "minimum": 0 },
21
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
22
+ "pixels": {
23
+ "type": "array",
24
+ "items": { "type": "integer", "exclusiveMinimum": 0 },
25
+ "minItems": 2,
26
+ "maxItems": 2
27
+ },
28
+ "source_url": { "type": ["string", "null"], "minLength": 1 },
29
+ "source": { "type": "string", "minLength": 1 },
30
+ "retrieved": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
31
+ "rights": { "type": "string", "minLength": 1 },
32
+ "captions": {
33
+ "type": "array",
34
+ "minItems": 1,
35
+ "items": { "type": "string", "minLength": 1 }
36
+ },
37
+ "paragraphs": {
38
+ "type": "array",
39
+ "minItems": 1,
40
+ "items": { "type": "string", "minLength": 1 }
41
+ },
42
+ "entries": {
43
+ "type": "array",
44
+ "minItems": 1,
45
+ "items": { "type": "string", "minLength": 1 }
46
+ },
47
+ "provenance_status": { "type": "string" },
48
+ "unmapped_reason": { "type": "string", "minLength": 1 }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,131 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mark-brannan/colregs/schema/lights.schema.json",
4
+ "title": "data/lights.json",
5
+ "description": "The Rule 21 lights and Rule 22 visibility ranges. Structure only -- see docs/adr/0006-json-schema-and-identifier-diff.md.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["jurisdiction", "lights"],
9
+ "$defs": {
10
+ "predicateValue": {
11
+ "oneOf": [
12
+ {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "minProperties": 1,
16
+ "properties": {
17
+ "gte": { "type": "number" },
18
+ "gt": { "type": "number" },
19
+ "lte": { "type": "number" },
20
+ "lt": { "type": "number" }
21
+ }
22
+ },
23
+ { "type": "string" },
24
+ { "type": "boolean" },
25
+ { "type": "array", "items": { "type": "string" }, "minItems": 1 }
26
+ ]
27
+ },
28
+ "when": {
29
+ "type": "object",
30
+ "minProperties": 1,
31
+ "additionalProperties": false,
32
+ "patternProperties": {
33
+ "^fact:[a-z0-9_]+$": { "$ref": "#/$defs/predicateValue" }
34
+ }
35
+ }
36
+ },
37
+ "properties": {
38
+ "jurisdiction": { "type": "string", "pattern": "^[a-z]+(/[a-z]+)*$" },
39
+ "bearing_convention": {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "properties": {
43
+ "zero": { "type": "string" },
44
+ "direction": { "type": "string" },
45
+ "units": { "type": "string" },
46
+ "wrap": { "type": "string" }
47
+ }
48
+ },
49
+ "lights": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "patternProperties": {
53
+ "^light:[a-z_]+$": {
54
+ "type": "object",
55
+ "additionalProperties": false,
56
+ "required": ["name", "colregs_term", "cite", "character", "rule21"],
57
+ "properties": {
58
+ "name": { "type": "string", "minLength": 1 },
59
+ "colregs_term": { "type": "string", "minLength": 1 },
60
+ "cite": { "type": "string", "minLength": 1 },
61
+ "color": { "type": ["string", "null"] },
62
+ "color_note": { "type": "string" },
63
+ "character": { "type": "string", "minLength": 1 },
64
+ "arc_deg": { "type": ["number", "null"] },
65
+ "arc": {
66
+ "type": ["object", "null"],
67
+ "additionalProperties": false,
68
+ "required": ["from_deg", "to_deg"],
69
+ "properties": {
70
+ "from_deg": { "type": "number", "minimum": 0, "maximum": 360 },
71
+ "to_deg": { "type": "number", "minimum": 0, "maximum": 360 }
72
+ }
73
+ },
74
+ "placement": { "type": "string" },
75
+ "side": { "type": "string", "enum": ["port", "starboard"] },
76
+ "composite": { "type": "boolean" },
77
+ "components": {
78
+ "type": "array",
79
+ "items": { "type": "string", "pattern": "^light:[a-z_]+$" },
80
+ "minItems": 1
81
+ },
82
+ "combined_lantern_max_length_m": { "type": "number" },
83
+ "same_characteristics_as": { "type": "string", "pattern": "^light:[a-z_]+$" },
84
+ "flashes_per_minute_min": { "type": "number" },
85
+ "note": { "type": "string" },
86
+ "rule21": { "type": "boolean" }
87
+ }
88
+ }
89
+ }
90
+ },
91
+ "visibility": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "properties": {
95
+ "cite": { "type": "string" },
96
+ "note": { "type": "string" },
97
+ "bands": {
98
+ "type": "array",
99
+ "items": {
100
+ "type": "object",
101
+ "additionalProperties": false,
102
+ "required": ["cite"],
103
+ "properties": {
104
+ "cite": { "type": "string", "minLength": 1 },
105
+ "when": { "$ref": "#/$defs/when" },
106
+ "refines": { "type": "string" },
107
+ "ranges_nm": {
108
+ "type": "object",
109
+ "additionalProperties": false,
110
+ "patternProperties": {
111
+ "^light:[a-z_]+$": { "type": "number", "exclusiveMinimum": 0 }
112
+ }
113
+ },
114
+ "overrides_nm": {
115
+ "type": "object",
116
+ "additionalProperties": false,
117
+ "patternProperties": {
118
+ "^light:[a-z_]+$": { "type": "number", "exclusiveMinimum": 0 }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+ },
126
+ "colregs_vocabulary": {
127
+ "type": "array",
128
+ "items": { "type": "string", "minLength": 1 }
129
+ }
130
+ }
131
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mark-brannan/colregs/schema/rules.schema.json",
4
+ "title": "data/rules.json",
5
+ "description": "Verbatim rule text keyed by paragraph path. Structure only -- see docs/adr/0006-json-schema-and-identifier-diff.md.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["source", "paragraphs"],
9
+ "properties": {
10
+ "source": { "type": "string", "minLength": 1 },
11
+ "source_url": { "type": "string", "minLength": 1 },
12
+ "retrieved": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
13
+ "note": { "type": "string" },
14
+ "gaps": {
15
+ "type": "array",
16
+ "items": {
17
+ "type": "object",
18
+ "additionalProperties": false,
19
+ "required": ["path", "reason"],
20
+ "properties": {
21
+ "path": { "type": "string", "minLength": 1 },
22
+ "reason": { "type": "string", "minLength": 1 }
23
+ }
24
+ }
25
+ },
26
+ "paragraphs": {
27
+ "type": "object",
28
+ "additionalProperties": false,
29
+ "patternProperties": {
30
+ "^[0-9]+(\\([a-z]\\))?(\\([ivx]+\\))?$": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "required": ["path", "rule", "rule_title", "jurisdiction", "text"],
34
+ "properties": {
35
+ "path": { "type": "string", "pattern": "^[0-9]+(\\([a-z]\\))?(\\([ivx]+\\))?$" },
36
+ "rule": { "type": "string", "pattern": "^[0-9]+$" },
37
+ "rule_title": { "type": "string", "minLength": 1 },
38
+ "jurisdiction": { "type": "string", "pattern": "^[a-z]+(/[a-z]+)*$" },
39
+ "text": { "type": "string", "minLength": 1 },
40
+ "images": {
41
+ "type": "array",
42
+ "items": { "type": "string", "minLength": 1 },
43
+ "minItems": 1
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }