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,793 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mark-brannan/colregs/schema/facts.schema.json",
4
+ "title": "data/facts.json",
5
+ "description": "The input vocabulary a fact record is evaluated against. Structure only -- see docs/adr/0006-json-schema-and-identifier-diff.md.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "axes"
10
+ ],
11
+ "$defs": {
12
+ "factKey": {
13
+ "type": "string",
14
+ "pattern": "^fact:[a-z0-9_]+$"
15
+ },
16
+ "factValue": {
17
+ "type": "string",
18
+ "pattern": "^[a-z][a-z0-9_]*:[a-z0-9_]+$"
19
+ },
20
+ "constraint": {
21
+ "oneOf": [
22
+ { "$ref": "#/$defs/factValue" },
23
+ { "type": "boolean" },
24
+ { "type": "number" },
25
+ {
26
+ "type": "array",
27
+ "minItems": 1,
28
+ "items": { "$ref": "#/$defs/factValue" }
29
+ },
30
+ { "$ref": "#/$defs/numericGate" },
31
+ {
32
+ "type": "object",
33
+ "additionalProperties": false,
34
+ "required": ["not"],
35
+ "properties": {
36
+ "not": { "$ref": "#/$defs/constraint" }
37
+ }
38
+ },
39
+ {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "required": ["any_of"],
43
+ "properties": {
44
+ "any_of": {
45
+ "type": "array",
46
+ "minItems": 1,
47
+ "items": { "$ref": "#/$defs/constraint" }
48
+ }
49
+ }
50
+ }
51
+ ]
52
+ },
53
+ "numericGate": {
54
+ "type": "object",
55
+ "additionalProperties": false,
56
+ "minProperties": 1,
57
+ "properties": {
58
+ "gte": {
59
+ "type": "number"
60
+ },
61
+ "gt": {
62
+ "type": "number"
63
+ },
64
+ "lte": {
65
+ "type": "number"
66
+ },
67
+ "lt": {
68
+ "type": "number"
69
+ }
70
+ }
71
+ },
72
+ "situationFact": {
73
+ "type": "object",
74
+ "additionalProperties": false,
75
+ "required": [
76
+ "type",
77
+ "cite",
78
+ "cite_pending",
79
+ "actuable"
80
+ ],
81
+ "properties": {
82
+ "type": {
83
+ "type": "string",
84
+ "enum": [
85
+ "number",
86
+ "boolean",
87
+ "enum",
88
+ "position"
89
+ ]
90
+ },
91
+ "unit": {
92
+ "type": "string"
93
+ },
94
+ "values": {
95
+ "type": "array",
96
+ "minItems": 1,
97
+ "items": {
98
+ "$ref": "#/$defs/factValue"
99
+ }
100
+ },
101
+ "cite": {
102
+ "type": [
103
+ "string",
104
+ "null"
105
+ ]
106
+ },
107
+ "cite_pending": {
108
+ "type": [
109
+ "string",
110
+ "null"
111
+ ]
112
+ },
113
+ "note": {
114
+ "type": "string"
115
+ },
116
+ "actuable": {
117
+ "type": "boolean"
118
+ },
119
+ "signalk": {
120
+ "type": [
121
+ "string",
122
+ "null"
123
+ ]
124
+ }
125
+ }
126
+ }
127
+ },
128
+ "properties": {
129
+ "note": {
130
+ "type": "string"
131
+ },
132
+ "axes": {
133
+ "type": "object",
134
+ "additionalProperties": false,
135
+ "patternProperties": {
136
+ "^fact:[a-z0-9_]+$": {
137
+ "type": "object",
138
+ "additionalProperties": false,
139
+ "required": [
140
+ "values"
141
+ ],
142
+ "properties": {
143
+ "values": {
144
+ "type": "array",
145
+ "minItems": 1,
146
+ "items": {
147
+ "$ref": "#/$defs/factValue"
148
+ }
149
+ },
150
+ "cites": {
151
+ "type": "object",
152
+ "additionalProperties": {
153
+ "type": "string",
154
+ "minLength": 1
155
+ }
156
+ },
157
+ "note": {
158
+ "type": "string"
159
+ }
160
+ }
161
+ }
162
+ }
163
+ },
164
+ "modifiers": {
165
+ "type": "object",
166
+ "additionalProperties": false,
167
+ "patternProperties": {
168
+ "^fact:[a-z0-9_]+$": {
169
+ "type": "object",
170
+ "additionalProperties": false,
171
+ "required": [
172
+ "type"
173
+ ],
174
+ "properties": {
175
+ "type": {
176
+ "type": "string",
177
+ "enum": [
178
+ "boolean",
179
+ "number",
180
+ "string"
181
+ ]
182
+ },
183
+ "refines": {
184
+ "type": "string"
185
+ },
186
+ "note": {
187
+ "type": "string"
188
+ },
189
+ "actuable": {
190
+ "type": "boolean"
191
+ }
192
+ }
193
+ }
194
+ }
195
+ },
196
+ "numerics": {
197
+ "type": "object",
198
+ "additionalProperties": false,
199
+ "patternProperties": {
200
+ "^fact:[a-z0-9_]+$": {
201
+ "type": "object",
202
+ "additionalProperties": false,
203
+ "required": [
204
+ "type",
205
+ "cite"
206
+ ],
207
+ "properties": {
208
+ "type": {
209
+ "type": "string",
210
+ "const": "number"
211
+ },
212
+ "unit": {
213
+ "type": "string"
214
+ },
215
+ "cite": {
216
+ "type": "string",
217
+ "minLength": 1
218
+ },
219
+ "note": {
220
+ "type": "string"
221
+ },
222
+ "actuable": {
223
+ "type": "boolean"
224
+ },
225
+ "signalk": {
226
+ "type": [
227
+ "string",
228
+ "null"
229
+ ]
230
+ }
231
+ }
232
+ }
233
+ }
234
+ },
235
+ "booleans": {
236
+ "type": "object",
237
+ "additionalProperties": false,
238
+ "patternProperties": {
239
+ "^fact:[a-z0-9_]+$": {
240
+ "type": "object",
241
+ "additionalProperties": false,
242
+ "required": [
243
+ "cite",
244
+ "actuable"
245
+ ],
246
+ "properties": {
247
+ "cite": {
248
+ "type": "string",
249
+ "minLength": 1
250
+ },
251
+ "actuable": {
252
+ "type": "boolean"
253
+ },
254
+ "note": {
255
+ "type": "string"
256
+ }
257
+ }
258
+ }
259
+ }
260
+ },
261
+ "enums": {
262
+ "type": "object",
263
+ "additionalProperties": false,
264
+ "patternProperties": {
265
+ "^fact:[a-z0-9_]+$": {
266
+ "type": "object",
267
+ "additionalProperties": false,
268
+ "required": [
269
+ "values",
270
+ "cite"
271
+ ],
272
+ "properties": {
273
+ "values": {
274
+ "type": "array",
275
+ "minItems": 1,
276
+ "items": {
277
+ "$ref": "#/$defs/factValue"
278
+ }
279
+ },
280
+ "cite": {
281
+ "type": "string",
282
+ "minLength": 1
283
+ },
284
+ "actuable": {
285
+ "type": "boolean"
286
+ }
287
+ }
288
+ }
289
+ }
290
+ },
291
+ "derived": {
292
+ "type": "object",
293
+ "additionalProperties": false,
294
+ "properties": {
295
+ "note": {
296
+ "type": "string"
297
+ }
298
+ },
299
+ "patternProperties": {
300
+ "^fact:[a-z0-9_]+$": {
301
+ "type": "object",
302
+ "additionalProperties": false,
303
+ "required": ["type", "derived", "cite", "decode", "actuable"],
304
+ "properties": {
305
+ "type": {
306
+ "type": "string",
307
+ "enum": ["number", "boolean", "enum"]
308
+ },
309
+ "derived": {
310
+ "const": true
311
+ },
312
+ "cite": {
313
+ "type": "string",
314
+ "minLength": 1
315
+ },
316
+ "unit": {
317
+ "type": "string"
318
+ },
319
+ "values": {
320
+ "type": "array",
321
+ "minItems": 1,
322
+ "items": { "$ref": "#/$defs/factValue" }
323
+ },
324
+ "cites": {
325
+ "type": "object",
326
+ "additionalProperties": {
327
+ "type": "string",
328
+ "minLength": 1
329
+ }
330
+ },
331
+ "actuable": {
332
+ "const": false
333
+ },
334
+ "signalk": {
335
+ "type": ["string", "null"]
336
+ },
337
+ "note": {
338
+ "type": "string"
339
+ },
340
+ "decode": {
341
+ "type": "array",
342
+ "minItems": 1,
343
+ "items": {
344
+ "type": "object",
345
+ "additionalProperties": false,
346
+ "required": ["when", "value"],
347
+ "properties": {
348
+ "when": {
349
+ "type": "object",
350
+ "minProperties": 1,
351
+ "additionalProperties": false,
352
+ "patternProperties": {
353
+ "^fact:[a-z0-9_]+$": { "$ref": "#/$defs/constraint" }
354
+ }
355
+ },
356
+ "value": {
357
+ "oneOf": [
358
+ { "$ref": "#/$defs/factValue" },
359
+ { "type": "boolean" },
360
+ { "type": "number" }
361
+ ]
362
+ },
363
+ "cite": {
364
+ "type": "string"
365
+ },
366
+ "note": {
367
+ "type": "string"
368
+ }
369
+ }
370
+ }
371
+ },
372
+ "undecodable": {
373
+ "type": "array",
374
+ "items": {
375
+ "type": "object",
376
+ "additionalProperties": false,
377
+ "required": ["case", "why"],
378
+ "properties": {
379
+ "case": { "type": "string" },
380
+ "why": { "type": "string" },
381
+ "cite": { "type": "string" }
382
+ }
383
+ }
384
+ }
385
+ }
386
+ }
387
+ }
388
+ },
389
+ "actuable_subset": {
390
+ "type": "object",
391
+ "additionalProperties": false,
392
+ "properties": {
393
+ "note": {
394
+ "type": "string"
395
+ },
396
+ "fields": {
397
+ "type": "array",
398
+ "items": {
399
+ "$ref": "#/$defs/factKey"
400
+ }
401
+ }
402
+ }
403
+ },
404
+ "signalk_navigation_state": {
405
+ "type": "object",
406
+ "additionalProperties": false,
407
+ "properties": {
408
+ "source": {
409
+ "type": "string"
410
+ },
411
+ "verified": {
412
+ "type": "string",
413
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
414
+ },
415
+ "decode": {
416
+ "type": "object",
417
+ "additionalProperties": {
418
+ "type": "object",
419
+ "additionalProperties": false,
420
+ "properties": {
421
+ "fact:propulsion": {
422
+ "$ref": "#/$defs/factValue"
423
+ },
424
+ "fact:activity": {
425
+ "$ref": "#/$defs/factValue"
426
+ },
427
+ "fact:position": {
428
+ "$ref": "#/$defs/factValue"
429
+ },
430
+ "fact:tow_length_m": {
431
+ "$ref": "#/$defs/numericGate"
432
+ },
433
+ "also_activity": {
434
+ "$ref": "#/$defs/factValue"
435
+ },
436
+ "annex_ii_signal": {
437
+ "type": "string"
438
+ }
439
+ }
440
+ }
441
+ },
442
+ "undecodable": {
443
+ "type": "array",
444
+ "items": {
445
+ "type": "string"
446
+ }
447
+ },
448
+ "lossy": {
449
+ "type": "array",
450
+ "items": {
451
+ "type": "object",
452
+ "additionalProperties": false,
453
+ "required": [
454
+ "what",
455
+ "why"
456
+ ],
457
+ "properties": {
458
+ "what": {
459
+ "type": "string"
460
+ },
461
+ "why": {
462
+ "type": "string"
463
+ },
464
+ "cite": {
465
+ "type": "string"
466
+ }
467
+ }
468
+ }
469
+ }
470
+ }
471
+ },
472
+ "situation": {
473
+ "type": "object",
474
+ "additionalProperties": false,
475
+ "required": [
476
+ "namespace",
477
+ "kinematics",
478
+ "geometry",
479
+ "history",
480
+ "record",
481
+ "environment"
482
+ ],
483
+ "properties": {
484
+ "note": {
485
+ "type": "string"
486
+ },
487
+ "constants": {
488
+ "type": "object",
489
+ "additionalProperties": false,
490
+ "properties": {
491
+ "note": {
492
+ "type": "string"
493
+ }
494
+ },
495
+ "patternProperties": {
496
+ "^(?!note$)[a-z][a-z0-9_]*$": {
497
+ "type": "object",
498
+ "additionalProperties": false,
499
+ "required": [
500
+ "value",
501
+ "fact",
502
+ "status",
503
+ "cite",
504
+ "cite_pending"
505
+ ],
506
+ "properties": {
507
+ "value": {
508
+ "type": "number"
509
+ },
510
+ "unit": {
511
+ "type": "string"
512
+ },
513
+ "fact": {
514
+ "type": "string"
515
+ },
516
+ "status": {
517
+ "type": "string",
518
+ "enum": [
519
+ "ink",
520
+ "pencil",
521
+ "open"
522
+ ]
523
+ },
524
+ "cite": {
525
+ "type": ["string", "null"]
526
+ },
527
+ "cite_pending": {
528
+ "type": ["string", "null"]
529
+ },
530
+ "note": {
531
+ "type": "string"
532
+ },
533
+ "settled_by": {
534
+ "type": "string"
535
+ }
536
+ }
537
+ }
538
+ }
539
+ },
540
+ "status": {
541
+ "type": "string",
542
+ "enum": [
543
+ "ink",
544
+ "pencil",
545
+ "open"
546
+ ]
547
+ },
548
+ "adr": {
549
+ "type": "string",
550
+ "pattern": "^[0-9]{4}$"
551
+ },
552
+ "requirements": {
553
+ "type": "array",
554
+ "items": {
555
+ "type": "string",
556
+ "pattern": "^REQ-[A-Z]+-[0-9]+$"
557
+ }
558
+ },
559
+ "pencil": {
560
+ "type": "string"
561
+ },
562
+ "namespace": {
563
+ "type": "object",
564
+ "additionalProperties": false,
565
+ "required": [
566
+ "form",
567
+ "subjects",
568
+ "classes"
569
+ ],
570
+ "properties": {
571
+ "form": {
572
+ "type": "string"
573
+ },
574
+ "doc": {
575
+ "type": "string"
576
+ },
577
+ "subjects": {
578
+ "type": "object",
579
+ "additionalProperties": false,
580
+ "required": [
581
+ "own",
582
+ "other",
583
+ "pair"
584
+ ],
585
+ "properties": {
586
+ "own": {
587
+ "type": "string"
588
+ },
589
+ "other": {
590
+ "type": "string"
591
+ },
592
+ "pair": {
593
+ "type": "string"
594
+ }
595
+ }
596
+ },
597
+ "classes": {
598
+ "type": "object",
599
+ "additionalProperties": false,
600
+ "required": [
601
+ "fact",
602
+ "kin",
603
+ "geo",
604
+ "hist",
605
+ "env"
606
+ ],
607
+ "properties": {
608
+ "fact": {
609
+ "type": "string"
610
+ },
611
+ "kin": {
612
+ "type": "string"
613
+ },
614
+ "geo": {
615
+ "type": "string"
616
+ },
617
+ "hist": {
618
+ "type": "string"
619
+ },
620
+ "env": {
621
+ "type": "string"
622
+ }
623
+ }
624
+ },
625
+ "bare_key": {
626
+ "type": "string"
627
+ },
628
+ "directional_note": {
629
+ "type": "string"
630
+ }
631
+ }
632
+ },
633
+ "kinematics": {
634
+ "type": "object",
635
+ "additionalProperties": false,
636
+ "properties": {
637
+ "note": {
638
+ "type": "string"
639
+ }
640
+ },
641
+ "patternProperties": {
642
+ "^kin:[a-z0-9_]+$": {
643
+ "$ref": "#/$defs/situationFact"
644
+ }
645
+ }
646
+ },
647
+ "geometry": {
648
+ "type": "object",
649
+ "additionalProperties": false,
650
+ "required": [
651
+ "directional",
652
+ "symmetric"
653
+ ],
654
+ "properties": {
655
+ "note": {
656
+ "type": "string"
657
+ },
658
+ "directional": {
659
+ "type": "object",
660
+ "additionalProperties": false,
661
+ "properties": {
662
+ "note": {
663
+ "type": "string"
664
+ }
665
+ },
666
+ "patternProperties": {
667
+ "^geo:[a-z0-9_]+$": {
668
+ "$ref": "#/$defs/situationFact"
669
+ }
670
+ }
671
+ },
672
+ "symmetric": {
673
+ "type": "object",
674
+ "additionalProperties": false,
675
+ "properties": {
676
+ "note": {
677
+ "type": "string"
678
+ }
679
+ },
680
+ "patternProperties": {
681
+ "^geo:[a-z0-9_]+$": {
682
+ "$ref": "#/$defs/situationFact"
683
+ }
684
+ }
685
+ },
686
+ "consistency": {
687
+ "type": "object"
688
+ }
689
+ }
690
+ },
691
+ "history": {
692
+ "type": "object",
693
+ "additionalProperties": false,
694
+ "properties": {
695
+ "note": {
696
+ "type": "string"
697
+ }
698
+ },
699
+ "patternProperties": {
700
+ "^hist:[a-z0-9_]+$": {
701
+ "$ref": "#/$defs/situationFact"
702
+ }
703
+ }
704
+ },
705
+ "record": {
706
+ "type": "object",
707
+ "additionalProperties": false,
708
+ "required": [
709
+ "shape"
710
+ ],
711
+ "properties": {
712
+ "note": {
713
+ "type": "string"
714
+ },
715
+ "shape": {
716
+ "type": "object",
717
+ "additionalProperties": false,
718
+ "required": [
719
+ "own",
720
+ "other",
721
+ "pair"
722
+ ],
723
+ "properties": {
724
+ "own": {
725
+ "type": "object",
726
+ "additionalProperties": false,
727
+ "properties": {
728
+ "fact": {
729
+ "type": "string"
730
+ },
731
+ "kin": {
732
+ "type": "string"
733
+ },
734
+ "geo": {
735
+ "type": "string"
736
+ },
737
+ "hist": {
738
+ "type": "string"
739
+ }
740
+ }
741
+ },
742
+ "other": {
743
+ "type": "object",
744
+ "additionalProperties": false,
745
+ "properties": {
746
+ "fact": {
747
+ "type": "string"
748
+ },
749
+ "kin": {
750
+ "type": "string"
751
+ },
752
+ "geo": {
753
+ "type": "string"
754
+ },
755
+ "hist": {
756
+ "type": "string"
757
+ }
758
+ }
759
+ },
760
+ "pair": {
761
+ "type": "object",
762
+ "additionalProperties": false,
763
+ "properties": {
764
+ "geo": {
765
+ "type": "string"
766
+ },
767
+ "env": {
768
+ "type": "string"
769
+ }
770
+ }
771
+ }
772
+ }
773
+ }
774
+ }
775
+ },
776
+ "environment": {
777
+ "type": "object",
778
+ "additionalProperties": false,
779
+ "properties": {
780
+ "note": {
781
+ "type": "string"
782
+ }
783
+ },
784
+ "patternProperties": {
785
+ "^env:[a-z0-9_]+$": {
786
+ "$ref": "#/$defs/situationFact"
787
+ }
788
+ }
789
+ }
790
+ }
791
+ }
792
+ }
793
+ }