hclang 0.44.0 → 0.45.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.
@@ -887,6 +887,475 @@ export const HC_SOURCES = new Map([
887
887
  "",
888
888
  ].join("\n"),
889
889
  ],
890
+ [
891
+ "hc/art-dispatch-vact.hc",
892
+ [
893
+ "#!/usr/bin/env hc",
894
+ "```",
895
+ "ART dispatch soundness: VACT witness for the footprint policy (occurrence/figure 015.24j, 015.24l)",
896
+ "",
897
+ "Construction → specified observation → vacted fact → interpretation.",
898
+ "Run from the repository root: `deno task hc hc/art-dispatch-vact.hc -t`.",
899
+ "",
900
+ "This testdoc constructs HC state and closures in ordinary file scope, hands",
901
+ "them to the dispatcher under test through the host bridge `$$.dispatch`, and",
902
+ "asserts what each policy does to them. The dispatcher is the library's own",
903
+ "(`lib/frames/event-dispatch.ts`); the bridge only turns an array of closures",
904
+ "into events and prints the report. `lib/frames/event-dispatch.vact.test.ts`",
905
+ "reads this file, re-runs it, and dispatches the same construction from the",
906
+ "host side with the finer observers (versions, certificates, refusals).",
907
+ "",
908
+ "The fragment. An event is one call of a closure written here, with nil as its",
909
+ "argument unless a pair `[closure, argument]` is given. The unit of",
910
+ "interleaving is the statement: a `;`-separated step of a sequenced body; a",
911
+ "nested call, and every arrow callback a commit fires, is inside its",
912
+ "statement. The observable of a dispatch is the tuple of the events' results,",
913
+ "in program order, failures included, followed by the state observer read",
914
+ "afterwards from the same scope (`state ()`, or the scenario's own). An arrow",
915
+ "callback is observed by what it does: the ones here count their firings in",
916
+ "shared state. The `trace`, `waited` and `escapes` properties record the",
917
+ "schedule the policy chose; they are instrumentation, not part of the",
918
+ "observable the claim is about.",
919
+ "",
920
+ "The claim the witnesses bear on (spec a12 §Soundness): every `footprint`",
921
+ "dispatch is observably equal to the `certified-sequential` run of the same",
922
+ "events, which runs them alone in program order, each under the certificate",
923
+ "inferred when it starts, so that an event whose actual access leaves its",
924
+ "certificate stops there, refused, keeping what it committed before (its",
925
+ "certified prefix). Where nothing is refused that run is the `sequential`",
926
+ "one. The `interleave` policy is the uncoordinated counterexample. The claim",
927
+ "is conditional on the events staying inside the fragment the guard sees: a",
928
+ "host native that reads state without a seam is outside it, and the",
929
+ "companion test exhibits that boundary.",
930
+ "",
931
+ "Arrow callbacks registered here persist, as every registration does, so",
932
+ "each arrow scenario re-arms a fresh managed value first (`rearm ()`).",
933
+ "",
934
+ "Construction: two mutable identities, aliases of x, and the closures.",
935
+ "```",
936
+ "; .x_ [.n 5; .set_ {@n _;}];",
937
+ "; .y_ [.n 10; .set_ {@n _;}];",
938
+ "; .y-of-x_ x_;",
939
+ "; .z x_;",
940
+ "; .t_ x_;",
941
+ "; .incr-x {.a x_.n; x_.set_ (a + 1); x_.n};",
942
+ "; .incr-y {.a y_.n; y_.set_ (a + 1); y_.n};",
943
+ "; .read-x {x_.n};",
944
+ "; .via-alias {.a y-of-x_.n; y-of-x_.set_ (a + 1); y-of-x_.n};",
945
+ "; .functional {(z.set_ 0).n};",
946
+ "; .move {.v x_.n; x_.set_ (v - 1); y_.set_ (y_.n + 1); x_.n + y_.n};",
947
+ "; .sum-slow {.a x_.n; .pad 0; a + y_.n};",
948
+ "; .retarget {@t_ y_; t_.n};",
949
+ "; .via-t {.a t_.n; t_.set_ (a + 1); t_.n};",
950
+ "; .mk {incr-x};",
951
+ "; .via-mk {(mk ()) ()};",
952
+ "; .getters [read-x];",
953
+ "; .setters [{x_.set_ _; x_.n}];",
954
+ "; .hidden-incr-x {.a (getters & {_ ()}); (setters & {_ ((a .0) + 1)}) .0};",
955
+ "; .each {_ & {_ ()}};",
956
+ "; .hidden-write-x {.a x_.n; (setters & {_ (a + 1)}) .0};",
957
+ "; .log_ [.count 0; .tick_ {@count (count + 1);}; .set-count_ {@count _;}];",
958
+ "; .cell_ [.v 1; .put_ {@v _;}];",
959
+ "; cell_ -> {log_.tick_ ()};",
960
+ "; .cell-twice {cell_.put_ 1; cell_.put_ 2; cell_.v};",
961
+ "; .log-slow {.c log_.count; log_.set-count_ (c + 10); log_.count};",
962
+ "; .ghost {Nothing <- './nothing.hc'; x_.set_ 0;};",
963
+ "; .reset {x_.set_ 5; y_.set_ 10; @t_ x_;};",
964
+ "; .state {[x_.n, y_.n]};",
965
+ "; .ygetters [{y_.n}];",
966
+ "; .prefix-x {x_.set_ 6; .b (ygetters & {_ ()}); b .0};",
967
+ "; .fired_ [.n 0; .tick_ {@n (n + 1);}; .set_ {@n _;}];",
968
+ "; .w_ [.n 0; .set_ {@n _;}];",
969
+ "; .armers [{w_ -> {fired_.tick_ ()}}];",
970
+ "; .arm-hidden {.p 0; (armers & {_ ()}) .0; fired_.n};",
971
+ "; .arm {.w w_; w -> {fired_.tick_ ()}; fired_.n};",
972
+ "; .poke {w_.set_ 1; fired_.n};",
973
+ "; .poke-late {.p 0; w_.set_ 1; fired_.n};",
974
+ "; .rearm {@w_ [.n 0; .set_ {@n _;}]; fired_.set_ 0;};",
975
+ "; .watch {[w_.n, fired_.n]};",
976
+ "; .cell2_ [.v 0; .put_ {@v _;}];",
977
+ "; .log2_ [.count 0; .tick_ {@count (count + 1);}; .set_ {@count _;}];",
978
+ "; cell2_ -> {(ygetters & {_ ()}) .0};",
979
+ "; cell2_ -> {log2_.tick_ ()};",
980
+ "; .poke2 {cell2_.put_ 1; cell2_.v};",
981
+ "; .b1 [.k 1];",
982
+ "; .b2 [.k 2];",
983
+ "; .obj_ [.^ b1; .rebase_ {.^ _;}];",
984
+ "; .objs [{obj_.k}];",
985
+ "; .peek-k {.p 0; .q (b1.k + b2.k); .r (objs & {_ ()}); r .0};",
986
+ "; .peek-k-open {.p 0; obj_.k};",
987
+ "; .rebase {obj_.rebase_ b2; 0};",
988
+ "; .holder_ [.t_ x_; .set-t_ {@t_ _;}];",
989
+ "; .ys [{y_}];",
990
+ "; .retarget-holder {.p 0; .v (ys & {_ ()}); holder_.set-t_ (v .0); 0};",
991
+ "; .via-holder {.a holder_.t_.n; holder_.t_.set_ (a + 1); holder_.t_.n};",
992
+ "; .nested {$$.dispatch.sequential [read-x]};",
993
+ "; state ()",
994
+ "# [5, 10]",
995
+ "```",
996
+ "W1. Shared x, two read-then-write events. The sequential baseline is the",
997
+ "observation every coordinated policy must reproduce.",
998
+ "```",
999
+ "; $$.dispatch.sequential [incr-x, incr-x]",
1000
+ "# [.trace “0:1 0:2 0:3 1:1 1:2 1:3”; .waited [[], []]; .escapes [0, 0]; 6, 7]",
1001
+ "; state ()",
1002
+ "# [7, 10]",
1003
+ "; reset ();",
1004
+ "; $$.dispatch.footprint [incr-x, incr-x]",
1005
+ "# [.trace “0:1 0:2 0:3 1:1 1:2 1:3”; .waited [[], [0]]; .escapes [0, 0]; 6, 7]",
1006
+ "; state ()",
1007
+ "# [7, 10]",
1008
+ "; reset ();",
1009
+ "; $$.dispatch.interleave [incr-x, incr-x]",
1010
+ "# [.trace “0:1 1:1 0:2 1:2 0:3 1:3”; .waited [[], []]; .escapes [0, 0]; 6, 6]",
1011
+ "; state ()",
1012
+ "# [6, 10]",
1013
+ "; reset ();",
1014
+ "```",
1015
+ "W2. The conflict is on the identity, not the name: a write through a mutable",
1016
+ "alias of x is the same conflict.",
1017
+ "```",
1018
+ "; $$.dispatch.footprint [incr-x, via-alias]",
1019
+ "# [.trace “0:1 0:2 0:3 1:1 1:2 1:3”; .waited [[], [0]]; .escapes [0, 0]; 6, 7]",
1020
+ "; state ()",
1021
+ "# [7, 10]",
1022
+ "; reset ();",
1023
+ "```",
1024
+ "W3. Disjoint x and y: the events interleave statement by statement and the",
1025
+ "observation is the baseline's.",
1026
+ "```",
1027
+ "; $$.dispatch.sequential [incr-x, incr-y]",
1028
+ "# [.trace “0:1 0:2 0:3 1:1 1:2 1:3”; .waited [[], []]; .escapes [0, 0]; 6, 11]",
1029
+ "; state ()",
1030
+ "# [6, 11]",
1031
+ "; reset ();",
1032
+ "; $$.dispatch.footprint [incr-x, incr-y]",
1033
+ "# [.trace “0:1 1:1 0:2 1:2 0:3 1:3”; .waited [[], []]; .escapes [0, 0]; 6, 11]",
1034
+ "; state ()",
1035
+ "# [6, 11]",
1036
+ "; reset ();",
1037
+ "```",
1038
+ "W4. A reader of x against a writer of x, both orders: the reader is given one",
1039
+ "committed version, the one program order puts before it.",
1040
+ "```",
1041
+ "; $$.dispatch.footprint [incr-x, read-x]",
1042
+ "# [.trace “0:1 0:2 0:3 1:1”; .waited [[], [0]]; .escapes [0, 0]; 6, 6]",
1043
+ "; $$.dispatch.footprint [read-x, incr-x]",
1044
+ "# [.trace “0:1 1:1 1:2 1:3”; .waited [[], [0]]; .escapes [0, 0]; 6, 7]",
1045
+ "; state ()",
1046
+ "# [7, 10]",
1047
+ "; reset ();",
1048
+ "```",
1049
+ "W5. A mutating method through an immutable alias is a functional update: it",
1050
+ "writes nothing shared, so a reader of x need not wait, and x is untouched.",
1051
+ "```",
1052
+ "; $$.dispatch.footprint [functional, read-x]",
1053
+ "# [.trace “0:1 1:1”; .waited [[], []]; .escapes [0, 0]; 0, 5]",
1054
+ "; state ()",
1055
+ "# [5, 10]",
1056
+ "```",
1057
+ "W6. A multi-value invariant, x + y. Uncoordinated statements let a slow reader",
1058
+ "observe a sum that never existed and two transfers lose the conservation;",
1059
+ "footprint keeps both.",
1060
+ "```",
1061
+ "; $$.dispatch.sequential [move, sum-slow]",
1062
+ "# [.trace “0:1 0:2 0:3 0:4 1:1 1:2 1:3”; .waited [[], []]; .escapes [0, 0]; 15, 15]",
1063
+ "; state ()",
1064
+ "# [4, 11]",
1065
+ "; reset ();",
1066
+ "; $$.dispatch.interleave [move, sum-slow]",
1067
+ "# [.trace “0:1 1:1 0:2 1:2 0:3 1:3 0:4”; .waited [[], []]; .escapes [0, 0]; 15, 16]",
1068
+ "; state ()",
1069
+ "# [4, 11]",
1070
+ "; reset ();",
1071
+ "; $$.dispatch.footprint [move, sum-slow]",
1072
+ "# [.trace “0:1 0:2 0:3 0:4 1:1 1:2 1:3”; .waited [[], [0]]; .escapes [0, 0]; 15, 15]",
1073
+ "; state ()",
1074
+ "# [4, 11]",
1075
+ "; reset ();",
1076
+ "; $$.dispatch.interleave [move, move]",
1077
+ "# [.trace “0:1 1:1 0:2 1:2 0:3 1:3 0:4 1:4”; .waited [[], []]; .escapes [0, 0]; 16, 16]",
1078
+ "; state ()",
1079
+ "# [4, 12]",
1080
+ "; reset ();",
1081
+ "; $$.dispatch.footprint [move, move]",
1082
+ "# [.trace “0:1 0:2 0:3 0:4 1:1 1:2 1:3 1:4”; .waited [[], [0]]; .escapes [0, 0]; 15, 15]",
1083
+ "; state ()",
1084
+ "# [3, 12]",
1085
+ "; reset ();",
1086
+ "```",
1087
+ "W7. A dynamically rebound name. `retarget` rebinds `t_` from x to y; `via-t`",
1088
+ "writes through `t_`. Its footprint is read when it starts, after `retarget`,",
1089
+ "so it names y and `incr-y` waits for it.",
1090
+ "```",
1091
+ "; $$.dispatch.sequential [retarget, via-t, incr-y]",
1092
+ "# [.trace “0:1 0:2 1:1 1:2 1:3 2:1 2:2 2:3”; .waited [[], [], []]; .escapes [0, 0, 0]; 10, 11, 12]",
1093
+ "; state ()",
1094
+ "# [5, 12]",
1095
+ "; reset ();",
1096
+ "; $$.dispatch.footprint [retarget, via-t, incr-y]",
1097
+ "# [.trace “0:1 0:2 1:1 1:2 1:3 2:1 2:2 2:3”; .waited [[], [0], [0, 1]]; .escapes [0, 0, 0]; 10, 11, 12]",
1098
+ "; state ()",
1099
+ "# [5, 12]",
1100
+ "; reset ();",
1101
+ "```",
1102
+ "W8. A closure returned by a call and then called. The walk reaches the",
1103
+ "returned closure's body through the name it was written under, so the event",
1104
+ "is seen to write x and is serialized: conservative admission, no refusal.",
1105
+ "```",
1106
+ "; $$.dispatch.footprint [via-mk, incr-x]",
1107
+ "# [.trace “0:1 1:1 1:2 1:3”; .waited [[], [0]]; .escapes [0, 0]; 6, 7]",
1108
+ "; state ()",
1109
+ "# [7, 10]",
1110
+ "; reset ();",
1111
+ "```",
1112
+ "W9. Hostile: a call reached only through data. `hidden-incr-x` reads x and",
1113
+ "writes x through closures held as elements of `getters` and `setters`, which",
1114
+ "the walk reads as aggregates without walking the closures inside. Its",
1115
+ "certificate therefore names neither a read nor a write of x, and the",
1116
+ "dispatcher admits it beside `incr-x`. Uncoordinated, that is a lost update",
1117
+ "with an escape reported after the fact. Under footprint the guard refuses",
1118
+ "the first access outside the certificate, the read of x, before it happens:",
1119
+ "the event ends with `$!.uncertified-read`, nothing it would have written",
1120
+ "lands, and `incr-x` completes alone.",
1121
+ "```",
1122
+ "; $$.dispatch.interleave [hidden-incr-x, incr-x]",
1123
+ "# [.trace “0:1 1:1 0:2 1:2 1:3”; .waited [[], []]; .escapes [1, 0]; 6, 6]",
1124
+ "; state ()",
1125
+ "# [6, 10]",
1126
+ "; reset ();",
1127
+ "; $$.dispatch.footprint [hidden-incr-x, incr-x]",
1128
+ "# [.trace “1:1 1:2 1:3”; .waited [[], []]; .escapes [0, 0]; $!.uncertified-read, 6]",
1129
+ "; state ()",
1130
+ "# [6, 10]",
1131
+ "; reset ();",
1132
+ "```",
1133
+ "W10. Hostile: closures handed in inside a data argument. `each` applies every",
1134
+ "element of its argument; the walk sees the argument as an aggregate and the",
1135
+ "element closures stay unwalked. Refused before the first uncertified access.",
1136
+ "`hidden-write-x` reads x in the open and writes it through the hidden setter:",
1137
+ "its certificate reads x, so a reader of x is admitted beside it, and the",
1138
+ "hidden write is refused at the commit point, before it lands: x keeps the",
1139
+ "value the reader saw.",
1140
+ "```",
1141
+ "; $$.dispatch.footprint [[each, setters], incr-x]",
1142
+ "# [.trace “1:1 1:2 1:3”; .waited [[], []]; .escapes [0, 0]; $!.uncertified-read, 6]",
1143
+ "; state ()",
1144
+ "# [6, 10]",
1145
+ "; reset ();",
1146
+ "; $$.dispatch.footprint [hidden-write-x, read-x]",
1147
+ "# [.trace “0:1 1:1”; .waited [[], []]; .escapes [0, 0]; $!.uncertified-write, 5]",
1148
+ "; state ()",
1149
+ "# [5, 10]",
1150
+ "```",
1151
+ "W11. A hidden effect that is inferable: the arrow `cell_ -> {log_.tick_ ()}`",
1152
+ "registers a callback that writes `log_` whenever `cell_` commits a write. The",
1153
+ "walk reads the registered callbacks of every identity the event may write,",
1154
+ "so `cell-twice` is seen to write `log_` and is serialized against `log-slow`.",
1155
+ "```",
1156
+ "; $$.dispatch.sequential [cell-twice, log-slow]",
1157
+ "# [.trace “0:1 0:2 0:3 1:1 1:2 1:3”; .waited [[], []]; .escapes [0, 0]; 2, 12]",
1158
+ "; [cell_.v, log_.count]",
1159
+ "# [2, 12]",
1160
+ "; log_.set-count_ 0;",
1161
+ "; $$.dispatch.footprint [cell-twice, log-slow]",
1162
+ "# [.trace “0:1 0:2 0:3 1:1 1:2 1:3”; .waited [[], [0]]; .escapes [0, 0]; 2, 12]",
1163
+ "; [cell_.v, log_.count]",
1164
+ "# [2, 12]",
1165
+ "; log_.set-count_ 0;",
1166
+ "```",
1167
+ "W12. A failing event. `ghost` imports a resource, which the walk cannot read,",
1168
+ "so it is opaque and serialized against everything; it fails at its first",
1169
+ "statement as a call would, writes nothing, and the other event runs after it.",
1170
+ "```",
1171
+ "; $$.dispatch.footprint [ghost, incr-y]",
1172
+ "# [.trace “0:1 1:1 1:2 1:3”; .waited [[], [0]]; .escapes [0, 0]; $!.resource-absent './nothing.hc', 11]",
1173
+ "; state ()",
1174
+ "# [5, 11]",
1175
+ "; reset ();",
1176
+ "```",
1177
+ "W13. A refused event keeps its certified prefix. `prefix-x` writes x, which",
1178
+ "its certificate allows, then reads y through a closure held in data, which",
1179
+ "it does not: it is refused at that read, and x keeps the 6 it committed.",
1180
+ "`read-x` waits for it and reads 6. The baseline that matches is the",
1181
+ "certified serial run, prefix and failure included; the serial run of the",
1182
+ "completed event alone (`read-x`) would read 5, and the plain serial run, in",
1183
+ "which nothing is refused, completes `prefix-x`.",
1184
+ "```",
1185
+ "; $$.dispatch.footprint [prefix-x, read-x]",
1186
+ "# [.trace “0:1 1:1”; .waited [[], [0]]; .escapes [0, 0]; $!.uncertified-read, 6]",
1187
+ "; state ()",
1188
+ "# [6, 10]",
1189
+ "; reset ();",
1190
+ "; $$.dispatch.certified-sequential [prefix-x, read-x]",
1191
+ "# [.trace “0:1 1:1”; .waited [[], []]; .escapes [0, 0]; $!.uncertified-read, 6]",
1192
+ "; state ()",
1193
+ "# [6, 10]",
1194
+ "; reset ();",
1195
+ "; $$.dispatch.sequential [read-x]",
1196
+ "# [.trace “0:1”; .waited [[]]; .escapes [0]; 5]",
1197
+ "; $$.dispatch.sequential [prefix-x, read-x]",
1198
+ "# [.trace “0:1 0:2 0:3 1:1”; .waited [[], []]; .escapes [0, 0]; 10, 6]",
1199
+ "; state ()",
1200
+ "# [6, 10]",
1201
+ "; reset ();",
1202
+ "```",
1203
+ "W14. Arrow registration is a write of the managed value: the subscriber list",
1204
+ "decides what every later write of the value fires. Both orders, each from a",
1205
+ "fresh `w_`. Registered through a closure held in data (`arm-hidden`), the",
1206
+ "registration is outside the certificate and refused before it lands, so no",
1207
+ "callback is added and none fires, in the footprint run and in the certified",
1208
+ "serial run alike; the plain serial run registers and, after it, `poke`",
1209
+ "fires the callback once. Registered by name, even through an immutable",
1210
+ "alias (`arm`), the arrow is in the certificate as a write of w, so the pair",
1211
+ "serializes in program order and fires exactly what the serial run fires.",
1212
+ "```",
1213
+ "; rearm ();",
1214
+ "; $$.dispatch.footprint [arm-hidden, poke]",
1215
+ "# [.trace “0:1 1:1 1:2”; .waited [[], []]; .escapes [0, 0]; $!.uncertified-write, 0]",
1216
+ "; watch ()",
1217
+ "# [1, 0]",
1218
+ "; rearm ();",
1219
+ "; $$.dispatch.certified-sequential [arm-hidden, poke]",
1220
+ "# [.trace “0:1 1:1 1:2”; .waited [[], []]; .escapes [0, 0]; $!.uncertified-write, 0]",
1221
+ "; watch ()",
1222
+ "# [1, 0]",
1223
+ "; rearm ();",
1224
+ "; $$.dispatch.sequential [arm-hidden, poke]",
1225
+ "# [.trace “0:1 0:2 0:3 1:1 1:2”; .waited [[], []]; .escapes [1, 0]; 0, 1]",
1226
+ "; watch ()",
1227
+ "# [1, 1]",
1228
+ "; rearm ();",
1229
+ "; $$.dispatch.footprint [poke-late, arm-hidden]",
1230
+ "# [.trace “0:1 1:1 0:2 0:3”; .waited [[], []]; .escapes [0, 0]; 0, $!.uncertified-write]",
1231
+ "; watch ()",
1232
+ "# [1, 0]",
1233
+ "; rearm ();",
1234
+ "; $$.dispatch.certified-sequential [poke-late, arm-hidden]",
1235
+ "# [.trace “0:1 0:2 0:3 1:1”; .waited [[], []]; .escapes [0, 0]; 0, $!.uncertified-write]",
1236
+ "; watch ()",
1237
+ "# [1, 0]",
1238
+ "; rearm ();",
1239
+ "; $$.dispatch.footprint [arm, poke]",
1240
+ "# [.trace “0:1 0:2 0:3 1:1 1:2”; .waited [[], [0]]; .escapes [0, 0]; 0, 1]",
1241
+ "; watch ()",
1242
+ "# [1, 1]",
1243
+ "; rearm ();",
1244
+ "; $$.dispatch.sequential [arm, poke]",
1245
+ "# [.trace “0:1 0:2 0:3 1:1 1:2”; .waited [[], []]; .escapes [0, 0]; 0, 1]",
1246
+ "; watch ()",
1247
+ "# [1, 1]",
1248
+ "; rearm ();",
1249
+ "; $$.dispatch.footprint [poke-late, arm]",
1250
+ "# [.trace “0:1 0:2 0:3 1:1 1:2 1:3”; .waited [[], [0]]; .escapes [0, 0]; 0, 0]",
1251
+ "; watch ()",
1252
+ "# [1, 0]",
1253
+ "; rearm ();",
1254
+ "; $$.dispatch.sequential [poke-late, arm]",
1255
+ "# [.trace “0:1 0:2 0:3 1:1 1:2 1:3”; .waited [[], []]; .escapes [0, 0]; 0, 0]",
1256
+ "; watch ()",
1257
+ "# [1, 0]",
1258
+ "; rearm ();",
1259
+ "```",
1260
+ "W15. A refusal inside an arrow callback ends the event there. `cell2_` has",
1261
+ "two callbacks: the first reads y through data, outside the certificate; the",
1262
+ "second ticks `log2_`. Writing `cell2_` commits (the certified prefix), the",
1263
+ "first callback is refused, and the second does not run: `log2_` stays 0. The",
1264
+ "plain serial run, with no guard, runs both.",
1265
+ "```",
1266
+ "; $$.dispatch.footprint [poke2]",
1267
+ "# [.trace “”; .waited [[]]; .escapes [0]; $!.uncertified-read]",
1268
+ "; [cell2_.v, log2_.count]",
1269
+ "# [1, 0]",
1270
+ "; cell2_.put_ 0;",
1271
+ "; log2_.set_ 0;",
1272
+ "; $$.dispatch.certified-sequential [poke2]",
1273
+ "# [.trace “”; .waited [[]]; .escapes [0]; $!.uncertified-read]",
1274
+ "; [cell2_.v, log2_.count]",
1275
+ "# [1, 0]",
1276
+ "; cell2_.put_ 0;",
1277
+ "; log2_.set_ 0;",
1278
+ "; $$.dispatch.sequential [poke2]",
1279
+ "# [.trace “0:1 0:2”; .waited [[]]; .escapes [0]; 1]",
1280
+ "; [cell2_.v, log2_.count]",
1281
+ "# [1, 1]",
1282
+ "; cell2_.put_ 0;",
1283
+ "; log2_.set_ 0;",
1284
+ "```",
1285
+ "W16. A lookup that misses is a read. `obj_` declares no `k`; `obj_.k` falls",
1286
+ "through to its parent. `peek-k` reads b1 and b2 by name and `obj_.k`",
1287
+ "through data, so its certificate reads neither `obj_` nor its parent edge,",
1288
+ "and `rebase` (which re-parents `obj_` to b2) is admitted beside it. The",
1289
+ "miss on `obj_` is refused before the lookup falls through, whichever parent",
1290
+ "is current, so the answer does not depend on the schedule. Looked up by",
1291
+ "name (`peek-k-open`), the miss is in the certificate and the pair",
1292
+ "serializes.",
1293
+ "```",
1294
+ "; $$.dispatch.footprint [peek-k, rebase]",
1295
+ "# [.trace “0:1 1:1 0:2 1:2”; .waited [[], []]; .escapes [0, 0]; $!.uncertified-read, 0]",
1296
+ "; obj_.k",
1297
+ "# 2",
1298
+ "; obj_.rebase_ b1;",
1299
+ "; $$.dispatch.certified-sequential [peek-k, rebase]",
1300
+ "# [.trace “0:1 0:2 1:1 1:2”; .waited [[], []]; .escapes [0, 0]; $!.uncertified-read, 0]",
1301
+ "; obj_.k",
1302
+ "# 2",
1303
+ "; obj_.rebase_ b1;",
1304
+ "; $$.dispatch.footprint [peek-k-open, rebase]",
1305
+ "# [.trace “0:1 0:2 1:1 1:2”; .waited [[], [0]]; .escapes [0, 0]; 1, 0]",
1306
+ "; obj_.k",
1307
+ "# 2",
1308
+ "; obj_.rebase_ b1;",
1309
+ "; $$.dispatch.sequential [peek-k-open, rebase]",
1310
+ "# [.trace “0:1 0:2 1:1 1:2”; .waited [[], []]; .escapes [0, 0]; 1, 0]",
1311
+ "; obj_.k",
1312
+ "# 2",
1313
+ "; obj_.rebase_ b1;",
1314
+ "```",
1315
+ "W17. Admission is in program order. `retarget-holder` points `holder_.t_` at",
1316
+ "y through data its certificate does not follow; `via-holder` waits for it",
1317
+ "and, when it starts, is seen to write y. `incr-y` must not start before",
1318
+ "`via-holder` has: had it run ahead, `via-holder` would increment the y it",
1319
+ "had already written, and the two results would swap.",
1320
+ "```",
1321
+ "; $$.dispatch.sequential [retarget-holder, via-holder, incr-y]",
1322
+ "# [.trace “0:1 0:2 0:3 0:4 1:1 1:2 1:3 2:1 2:2 2:3”; .waited [[], [], []]; .escapes [0, 0, 0]; 0, 11, 12]",
1323
+ "; state ()",
1324
+ "# [5, 12]",
1325
+ "; holder_.set-t_ x_;",
1326
+ "; reset ();",
1327
+ "; $$.dispatch.footprint [retarget-holder, via-holder, incr-y]",
1328
+ "# [.trace “0:1 0:2 0:3 0:4 1:1 1:2 1:3 2:1 2:2 2:3”; .waited [[], [0], [1]]; .escapes [0, 0, 0]; 0, 11, 12]",
1329
+ "; state ()",
1330
+ "# [5, 12]",
1331
+ "; holder_.set-t_ x_;",
1332
+ "; reset ();",
1333
+ "```",
1334
+ "W18. A dispatch inside an event. The host namespace `$$` is state the walk",
1335
+ "does not follow, so under a guard an event that reaches for `$$.dispatch` is",
1336
+ "refused at that read, before any inner event runs; unguarded, it nests. A",
1337
+ "nested dispatch reached from the host is covered by the companion test: a",
1338
+ "refusal belongs to the guard that refused it.",
1339
+ "```",
1340
+ "; $$.dispatch.footprint [nested]",
1341
+ "# [.trace “”; .waited [[]]; .escapes [0]; $!.uncertified-read]",
1342
+ "; $$.dispatch.sequential [nested]",
1343
+ "# [.trace “0:1”; .waited [[]]; .escapes [0]; [.trace “0:1”; .waited [[]]; .escapes [0]; 5]]",
1344
+ "```",
1345
+ "Refusals of the bridge itself: an element that is not a callable, and a bare",
1346
+ "policy, which is a value.",
1347
+ "```",
1348
+ "; $$.dispatch.footprint [5]",
1349
+ "# $!.dispatch-event 0 FrameCount",
1350
+ "; $$.dispatch.footprint",
1351
+ "# $$.dispatch.footprint",
1352
+ "```",
1353
+ "Importing skips the examples and ends on a native true value.",
1354
+ "```",
1355
+ "[] = []",
1356
+ "",
1357
+ ].join("\n"),
1358
+ ],
890
1359
  [
891
1360
  "hc/class-support.hc",
892
1361
  [
@@ -2266,6 +2735,401 @@ export const HC_SOURCES = new Map([
2266
2735
  "",
2267
2736
  ].join("\n"),
2268
2737
  ],
2738
+ [
2739
+ "hc/denum.hc",
2740
+ [
2741
+ "#!/usr/bin/env hc",
2742
+ "```",
2743
+ "Denum (occurrence/figure 007.31, 007.32, 007.32b)",
2744
+ "",
2745
+ "A Denum is a constructed state of the binary Cayley–Dickson step ladder: a",
2746
+ "schema `CD[n]`, a retained application Count, and a nonnegative integer load on",
2747
+ "every signature channel. It is not a conventional number. Its conventional",
2748
+ "algebraic value is an observation, `d.observe ()`, and opposite channels stay",
2749
+ "separately counted after every operation, so `X + Opp X` is a present, nonempty",
2750
+ "Denum that merely observes as zero.",
2751
+ "",
2752
+ "`x.#n` answers a Denum of rank n for n from 0 to 5, and there is no `#n=`",
2753
+ '(see "The ranked hash" below). `Denum [rank, count, loads]` builds one directly.',
2754
+ "`Denum` is an ordinary HC class, like `Demi`; its arithmetic is the Cayley–Dickson",
2755
+ "recurrence `(a,b)(c,d) = (ac − d̄b, da + bc̄)`, computed by the one pure native",
2756
+ "seam `denum-engine` (`lib/ops/denum.ts`, over the typed reference in",
2757
+ "`lib/frames/denum.ts`), so no multiplication table is written in HC or in",
2758
+ "TypeScript. Everything else a Denum does is in this file.",
2759
+ "",
2760
+ "**Ranks and channels.** Rank n is the schema `CD[n]`, the rung of the step",
2761
+ "ladder, not the arity. Rank 0 has one unsigned channel, `e_ε`. Rank n of 1 or",
2762
+ "more has 2ⁿ channels, `±e_b` for every direction `b` of n−1 bits, positives",
2763
+ "first and then negatives, each in direction order:",
2764
+ "",
2765
+ " CD[0] e_ε",
2766
+ " CD[1] e_ε, -e_ε",
2767
+ " CD[2] e_0, e_1, -e_0, -e_1",
2768
+ " CD[3] e_00, e_01, e_10, e_11, -e_00, -e_01, -e_10, -e_11",
2769
+ " CD[4] ±e_b for b in {0,1}³ 16 channels",
2770
+ " CD[5] ±e_b for b in {0,1}⁴ 32 channels",
2771
+ "",
2772
+ "A minus names a *signature*, never a negative load: every load is a Count.",
2773
+ "`d.signatures ()` lists the native names in channel order.",
2774
+ "",
2775
+ "**State.** `d.rank`, `d.schema` (the text `CD[n]`), `d.count` (the full",
2776
+ "application Count, kept apart from the loads) and `d.loads` (one Count per",
2777
+ "channel). Anything that is not a rank from 0 to 5, a Count, and exactly the",
2778
+ "rank's number of Counts is refused with `$!!.invalid-denum`. `Denum [0, 0, [0]]`,",
2779
+ "an explicit zero-load D0, is present: it is neither the missing host that",
2780
+ "`[].#0` leaves nil nor a nonempty Denum that observes as zero.",
2781
+ "",
2782
+ "**Arithmetic.** `+`, `-` and `*` take another Denum, and only a Denum: the",
2783
+ "right operand is reconstructed from its `rank`, `count` and `loads` through the",
2784
+ "shipped constructor and must be `=` to that reconstruction, the same test `x.#n`",
2785
+ "applies to a source. A lookalike aggregate with the same fields, a Count, text",
2786
+ "or a list is `$!!.invalid-denum`. Operands of different",
2787
+ "rank are both promoted to the larger rank first (`promote`), and the result is a",
2788
+ "fresh Denum of that rank:",
2789
+ "",
2790
+ "- `a + b` adds corresponding loads and keeps opposite channels separate.",
2791
+ "- `a * b` is the ordered Cartesian product of weighted signatures: loads",
2792
+ " multiply, the signed destination is the recurrence's, and only identical full",
2793
+ " signatures aggregate. Operand order and parentheses are kept, and from",
2794
+ " rank 4 the product is not associative.",
2795
+ "- `a - b` is `a + b.opp ()`: subtraction is addition of the opposite, observed,",
2796
+ " never erased.",
2797
+ "- `d.opp ()` swaps the loads of `+e_b` and `-e_b`; a D0 is promoted to D1 first.",
2798
+ "- `d.conj ()` keeps the scalar signatures and swaps every other pair.",
2799
+ "- `d.promote k` embeds into rank k by the old-summand map, `±e_b ↦ ±e_(0b)`,",
2800
+ " keeping Count and loads and starting new channels at zero. A lower k is",
2801
+ " `$!.denum-demotion`.",
2802
+ "- `d.observe ()` is the algebraic observation: the signed coordinate of each",
2803
+ " direction, positive load minus negative load. It is a list of integers, and",
2804
+ " not the Denum.",
2805
+ "",
2806
+ "**Count.** The candidate laws of 007.32 section 6 hold for these new operations",
2807
+ "only: `C(a+b) = C(a)+C(b)`, `C(a*b) = C(a)·C(b)` and `C(Opp a) = C(a)`, and",
2808
+ "promotion and conjugation keep Count. Count is carried, never derived from the",
2809
+ "loads, and it is not the application phase `C mod arity`. `Demi` and its `+`,",
2810
+ "`-`, `*` and `./` are unchanged. This is a software construction of a supplied",
2811
+ "recurrence, not a derivation of it from bare counting.",
2812
+ "",
2813
+ "**Observers.** A Denum declares its own Count (`d.#`), Size (`d.##`, the total",
2814
+ "load) and residual (`d.###`, positive minus negative total, 0 at rank 0). Its",
2815
+ "`.####` is therefore the ordinary derived Demi of those three, which is binary",
2816
+ "and forgets the directions; `d.#n` is the Denum.",
2817
+ "",
2818
+ "**The ranked hash.** For any Frame x, `x.#n` for n from 0 to 5 answers the",
2819
+ "Denum of rank n, `nil` when x has no Count or Count zero, as `x.####` does.",
2820
+ "For an ordinary or binary host `x.#1` has the Count and the left and right",
2821
+ "loads of `x.####`. A `RotorRouter` of more than two channels is the exception:",
2822
+ "`.####` answers its channel Demi, and `.#n` does not special-case it, so it is",
2823
+ "the two-channel projection of the router's Count, Size and residual.",
2824
+ "Bare `x.#` is still the Count. The host is built from the three observers it",
2825
+ "answers, Count C, Size s and residual r: rank 0 keeps the load s, and rank",
2826
+ "n ≥ 1 puts (s+r)/2 on `e_0…0` and (s−r)/2 on `-e_0…0`, the two channels the",
2827
+ "fourth hash reads as left and right, with every other channel zero. A host's",
2828
+ "applications carry no higher signature, so none is routed to them. That is",
2829
+ "construction, and it is not promotion. A Denum instance answers `x.#n` by",
2830
+ "promotion to rank n (and `$!.denum-demotion` below its own rank), keeping Count",
2831
+ "and loads, and a forged lookalike is not recognized. A rank above 5 is",
2832
+ "`$!.denum-rank`.",
2833
+ "",
2834
+ "The class is evaluated from the compiled-in bundle the first time a ranked hash",
2835
+ "needs it, in a namespace of its own (`lib/execute/denum-prologue.ts`), so this",
2836
+ "file must not import.",
2837
+ "```",
2838
+ ".denum-state {.r (_ .0); .c (_ .1); .l (_ .2); .s (denum-engine [9, r, c, l]); [",
2839
+ " .rank r;",
2840
+ " .schema s;",
2841
+ " .count c;",
2842
+ " .loads l;",
2843
+ " .# {_^.count};",
2844
+ " .## {(_^ .loads).##};",
2845
+ " .### {denum-engine [10, (_^ .rank), (_^ .count), (_^ .loads)]};",
2846
+ " .+ {.o (_^^ .operand _); .me _^; .f (_^^ .finish);",
2847
+ " (f (denum-engine [1, (me .rank), (me .count), (me .loads), (o .rank), (o .count), (o .loads)]))};",
2848
+ " .- {.o (_^^ .operand _); .me _^; .f (_^^ .finish);",
2849
+ " (f (denum-engine [2, (me .rank), (me .count), (me .loads), (o .rank), (o .count), (o .loads)]))};",
2850
+ " .* {.o (_^^ .operand _); .me _^; .f (_^^ .finish);",
2851
+ " (f (denum-engine [3, (me .rank), (me .count), (me .loads), (o .rank), (o .count), (o .loads)]))};",
2852
+ " .promote {.k _; .me _^; .f (_^^ .finish);",
2853
+ " (f (denum-engine [6, (me .rank), (me .count), (me .loads), k]))};",
2854
+ " .opp {.u ((_ = ()) ? {1} : {0}); .me _^; .f (_^^ .finish);",
2855
+ " (u = 1) ? {(f (denum-engine [4, (me .rank), (me .count), (me .loads)]))} : {$!!.unary-observation}};",
2856
+ " .conj {.u ((_ = ()) ? {1} : {0}); .me _^; .f (_^^ .finish);",
2857
+ " (u = 1) ? {(f (denum-engine [5, (me .rank), (me .count), (me .loads)]))} : {$!!.unary-observation}};",
2858
+ " .observe {.u ((_ = ()) ? {1} : {0}); .me _^;",
2859
+ " (u = 1) ? {denum-engine [7, (me .rank), (me .count), (me .loads)]} : {$!!.unary-observation}};",
2860
+ " .signatures {.u ((_ = ()) ? {1} : {0}); .me _^;",
2861
+ " (u = 1) ? {denum-engine [8, (me .rank), (me .count), (me .loads)]} : {$!!.unary-observation}};",
2862
+ " .toText {“Denum(” (_^ .schema) “, C=” (_^ .count) “, W=” (_^ .loads) “)”}",
2863
+ " ]};",
2864
+ ".operand {.o _; .r (Denum [(o .rank), (o .count), (o .loads)]); (o = r) ? {o} : {$!!.invalid-denum}};",
2865
+ ".finish {.s _; ((s ~ ([].<>)) ? {denum-state s} : {s})};",
2866
+ ".Denum {.a _; ((a ~ ([].<>)) ? {(a .#) = 3}) ? {.s (denum-engine [0, (a .0), (a .1), (a .2)]);",
2867
+ " (s ~ ([].<>)) ? {denum-state s} : {$!!.invalid-denum}} : {$!!.invalid-denum}};",
2868
+ "```",
2869
+ "## Construction",
2870
+ "",
2871
+ "A Denum holds its schema, its Count and one load per channel. The rank-0 seed",
2872
+ "has one unsigned channel, and an explicit zero-load D0 is present",
2873
+ "```",
2874
+ "; .z (Denum [0, 0, [0]]);",
2875
+ "; [z.rank, z.schema, z.count, z.loads, z.#, z.##, z.###, “” z]",
2876
+ "# [0, “CD[0]”, 0, [0], 0, 0, 0, “Denum(CD[0], C=0, W=[0])”]",
2877
+ "```",
2878
+ "The loads are Counts, one per channel, and the Count is kept apart from them: a",
2879
+ "Denum may hold loads at Count zero, or a Count over zero loads. A rank beyond 5,",
2880
+ "a negative Count or load, a fractional load, the wrong number of loads and a",
2881
+ "non-list (a bare Count or text for the loads included) are all refused",
2882
+ "```",
2883
+ "; [“” (Denum [2, 7, [3, 2, 0, 1]]), “” (Denum [1, 0, [4, 0]]), “” (Denum [1, 5, [0, 0]])]",
2884
+ "# [“Denum(CD[2], C=7, W=[3, 2, 0, 1])”, “Denum(CD[1], C=0, W=[4, 0])”, “Denum(CD[1], C=5, W=[0, 0])”]",
2885
+ "; [Denum [6, 0, [0]], Denum [1, (0 - 1), [0, 0]], Denum [1, 0, [0, (0 - 1)]], Denum [1, 0, [0, 1.5]], Denum [2, 0, [0, 0, 0]], Denum [0, 0, [0, 0]], Denum 5, Denum [1, 0], Denum [1, 0, [0, 0], 9], Denum [0, 0, 5], Denum [1, 0, 5], Denum [0, 0, “x”]]",
2886
+ "# [$!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum]",
2887
+ "```",
2888
+ "## Signatures",
2889
+ "",
2890
+ "The native spelling has no sign bit: the direction is a bitstring of rank − 1",
2891
+ "bits, and a minus names the opposite signature. Rank 0 has only `e_ε`",
2892
+ "```",
2893
+ "; [(Denum [0, 0, [0]]).signatures (), (Denum [1, 0, [0, 0]]).signatures (), (Denum [2, 0, [0, 0, 0, 0]]).signatures ()]",
2894
+ "# [[“e_ε”], [“e_ε”, “-e_ε”], [“e_0”, “e_1”, “-e_0”, “-e_1”]]",
2895
+ "; (Denum [3, 0, [0, 0, 0, 0, 0, 0, 0, 0]]).signatures ()",
2896
+ "# [“e_00”, “e_01”, “e_10”, “e_11”, “-e_00”, “-e_01”, “-e_10”, “-e_11”]",
2897
+ "; (Denum [4, 0, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]).signatures () .# ",
2898
+ "# 16",
2899
+ "; ((Denum [5, 0, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]).signatures ()) .# ",
2900
+ "# 32",
2901
+ "```",
2902
+ "## Rank 0 and rank 1: Size and signed integers",
2903
+ "",
2904
+ "D0 adds and multiplies unsigned Size, and Counts add and multiply with it. D1",
2905
+ "has the two signatures `e_ε` and `-e_ε`, and the product of two minus signatures",
2906
+ "is the plus signature, `(-e_ε)(-e_ε) = e_ε`, while every load stays a Count",
2907
+ "```",
2908
+ "; .a (Denum [0, 2, [3]]); .b (Denum [0, 5, [4]]);",
2909
+ "; [(a + b).loads, (a + b).count, (a * b).loads, (a * b).count]",
2910
+ "# [[7], 7, [12], 10]",
2911
+ "; .p (Denum [1, 1, [1, 0]]); .m (Denum [1, 1, [0, 1]]);",
2912
+ "; [(m * m).loads, (m * p).loads, (p * m).loads, (p * p).loads]",
2913
+ "# [[1, 0], [0, 1], [0, 1], [1, 0]]",
2914
+ "; [((Denum [1, 1, [0, 2]]) * (Denum [1, 1, [0, 3]])).loads, ((Denum [1, 1, [0, 2]]) * (Denum [1, 1, [0, 3]])).observe ()]",
2915
+ "# [[6, 0], [6]]",
2916
+ "```",
2917
+ "Opposite swaps the two channels and subtraction adds the opposite. The balanced",
2918
+ "result observes as zero yet is a present, nonempty Denum with both loads",
2919
+ "```",
2920
+ "; .x (Denum [1, 1, [5, 2]]); .y (Denum [1, 1, [3, 0]]);",
2921
+ "; [x.observe (), (x.opp ()).loads, (x - y).loads, (x - y).observe (), (x - y).count]",
2922
+ "# [[3], [2, 5], [5, 5], [0], 2]",
2923
+ "; .s (Denum [1, 1, [4, 4]]);",
2924
+ "; [s.observe (), s.loads, s.#, s.##, s.###]",
2925
+ "# [[0], [4, 4], 1, 8, 0]",
2926
+ "```",
2927
+ "A D0 has no negative signature, so its opposite is promoted to D1 first",
2928
+ "```",
2929
+ "; ((Denum [0, 3, [4]]).opp ()).loads",
2930
+ "# [0, 4]",
2931
+ "; ((Denum [0, 3, [4]]).opp ()).schema",
2932
+ "# “CD[1]”",
2933
+ "```",
2934
+ "## Operands are Denums only",
2935
+ "",
2936
+ "`+`, `-` and `*` refuse a right operand that is not a Denum, even when it carries",
2937
+ "the same `rank`, `count` and `loads` fields, as `x.#n` refuses a forged source",
2938
+ "```",
2939
+ "; .dp (Denum [1, 1, [1, 0]]); .lookalike [.rank 1; .count 1; .loads [1, 0]];",
2940
+ "; [dp + lookalike, dp - lookalike, dp * lookalike, dp + [1, 1, [1, 0]], dp * 2]",
2941
+ "# [$!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum, $!!.invalid-denum]",
2942
+ "; [(dp + dp).loads, (dp * (dp + dp)).loads, (dp + (dp.opp ())).loads]",
2943
+ "# [[2, 0], [2, 0], [1, 1]]",
2944
+ "```",
2945
+ "## Rank 2: J² = −1 and the four-step cycle",
2946
+ "",
2947
+ "`e_1` is the direction bit of J. Its square is the opposite scalar `-e_0`, and",
2948
+ "the fourth power is back at `e_0`, observed",
2949
+ "```",
2950
+ "; .j (Denum [2, 1, [0, 1, 0, 0]]);",
2951
+ "; [(j * j).loads, (j * j).observe (), ((j * j) * (j * j)).loads, ((j * j) * (j * j)).observe ()]",
2952
+ "# [[0, 0, 1, 0], [-1, 0], [1, 0, 0, 0], [1, 0]]",
2953
+ "```",
2954
+ "## Rank 3: order matters",
2955
+ "",
2956
+ "With J = `e_01`, I = `e_10` and K = `e_11`, J·I = K and I·J = −K",
2957
+ "```",
2958
+ "; .J (Denum [3, 1, [0, 1, 0, 0, 0, 0, 0, 0]]); .I (Denum [3, 1, [0, 0, 1, 0, 0, 0, 0, 0]]);",
2959
+ "; [(J * I).loads, (I * J).loads]",
2960
+ "# [[0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1]]",
2961
+ "```",
2962
+ "## Rank 4: the octonion associator",
2963
+ "",
2964
+ "`(e_001 e_010) e_100` is `+e_111` and `e_001 (e_010 e_100)` is `-e_111`. The",
2965
+ "Denum keeps the parentheses, so the two groupings differ",
2966
+ "```",
2967
+ "; .o1 (Denum [4, 1, [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); .o2 (Denum [4, 1, [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); .o4 (Denum [4, 1, [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]);",
2968
+ "; [((o1 * o2) * o4).loads, (o1 * (o2 * o4)).loads]",
2969
+ "# [[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]",
2970
+ "; [((o1 * o2) * o4).observe () = (o1 * (o2 * o4)).observe ()]",
2971
+ "# [()]",
2972
+ "```",
2973
+ "Through rank 3 the product is associative, so the same three directions in the",
2974
+ "quaternions agree",
2975
+ "```",
2976
+ "; [(J * I) * J = (J * (I * J)), ((J * I) * J).observe ()]",
2977
+ "# [<>, [0, 0, 1, 0]]",
2978
+ "```",
2979
+ "## Rank 5: sedenion zero divisors",
2980
+ "",
2981
+ "`(e_0001 + e_1010)(e_0100 − e_1111)` observes as zero though neither factor does.",
2982
+ "The product is not an empty Denum: it holds four loads, in cancelling pairs",
2983
+ "```",
2984
+ "; .u (Denum [5, 1, [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); .v (Denum [5, 1, [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]);",
2985
+ "; [u.observe (), v.observe ()]",
2986
+ "# [[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]]",
2987
+ "; .w (u * v);",
2988
+ "; [w.observe (), w.count, w.##, w.###, w.loads]",
2989
+ "# [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1, 4, 0, [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]]",
2990
+ "```",
2991
+ "## Promotion across the ladder",
2992
+ "",
2993
+ "Promotion embeds a lower rung into a higher one as the old summand,",
2994
+ "`±e_b ↦ ±e_(0b)`, keeping the Count and every load and starting the new channels",
2995
+ "at zero. D0 goes to the positive scalar, so the new minus channel is empty, and",
2996
+ "the map is path independent",
2997
+ "```",
2998
+ "; .t (Denum [0, 4, [6]]);",
2999
+ "; [(t.promote 1).loads, (t.promote 2).loads, ((t.promote 1).promote 2).loads = (t.promote 2).loads, (t.promote 3).count]",
3000
+ "# [[6, 0], [6, 0, 0, 0], <>, 4]",
3001
+ "; .k (Denum [1, 3, [2, 5]]);",
3002
+ "; [(k.promote 2).loads, (k.promote 3).loads, ((k.promote 2).promote 3).loads = (k.promote 3).loads, k.loads, k.rank]",
3003
+ "# [[2, 0, 5, 0], [2, 0, 0, 0, 5, 0, 0, 0], <>, [2, 5], 1]",
3004
+ "; [((Denum [2, 1, [0, 1, 0, 0]]).promote 3).loads, ((Denum [2, 1, [0, 0, 0, 1]]).promote 3).loads]",
3005
+ "# [[0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0]]",
3006
+ "```",
3007
+ "A lower rank is refused, and so is a rank above 5 or something that is not a",
3008
+ "Count. The source is never changed",
3009
+ "```",
3010
+ "; [(Denum [3, 1, [0, 0, 0, 0, 0, 0, 0, 0]]).promote 2, k.promote 6, k.promote (0 - 1), k.promote “x”]",
3011
+ "# [$!.denum-demotion, $!.denum-rank, $!.denum-rank, $!.denum-rank]",
3012
+ "```",
3013
+ "Mixed ranks promote to the larger one before the operation, and the product keeps",
3014
+ "its operand order. A rank 2 and a rank 3 Denum multiply as two rank 3 Denums",
3015
+ "```",
3016
+ "; .c2 (Denum [2, 2, [0, 1, 0, 0]]); .c3 (Denum [3, 3, [0, 0, 1, 0, 0, 0, 0, 0]]);",
3017
+ "; [(c2 * c3).schema, (c2 * c3).loads, (c3 * c2).loads, (c2 * c3).loads = ((c2.promote 3) * c3).loads, (c2 + c3).schema, (c2 + c3).count]",
3018
+ "# [“CD[3]”, [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], <>, “CD[3]”, 5]",
3019
+ "; [((c3.promote 5) * (Denum [5, 1, [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])).loads = ((c3 * (Denum [3, 1, [0, 1, 0, 0, 0, 0, 0, 0]])).promote 5).loads]",
3020
+ "# [<>]",
3021
+ "```",
3022
+ "## Conjugation",
3023
+ "",
3024
+ "Conjugation fixes the scalar signatures and swaps the two channels of every",
3025
+ "other direction. It keeps the Count and the loads. A product conjugates in",
3026
+ "reverse order, observed",
3027
+ "```",
3028
+ "; .g (Denum [2, 4, [1, 2, 3, 4]]);",
3029
+ "; [(g.conj ()).loads, (g.conj ()).count, (g.conj ()).observe (), g.observe ()]",
3030
+ "# [[1, 4, 3, 2], 4, [-2, 2], [-2, -2]]",
3031
+ "; [(((J * I).conj ()).observe ()) = (((I.conj ()) * (J.conj ())).observe ()), ((Denum [0, 1, [4]]).conj ()).loads]",
3032
+ "# [<>, [4]]",
3033
+ "```",
3034
+ "## Count",
3035
+ "",
3036
+ "Count is carried and never derived from the loads. For these Denum operations",
3037
+ "it adds under `+`, multiplies under `*`, and survives the opposite, conjugation",
3038
+ "and promotion. A Count of zero may hold nonzero loads",
3039
+ "```",
3040
+ "; .e (Denum [2, 3, [1, 0, 0, 2]]); .f (Denum [2, 4, [0, 5, 1, 0]]);",
3041
+ "; [(e + f).count, (e * f).count, (e.opp ()).count, (e.conj ()).count, (e.promote 4).count, (e - f).count]",
3042
+ "# [7, 12, 3, 3, 3, 7]",
3043
+ "; .odd (Denum [2, 0, [3, 0, 0, 0]]);",
3044
+ "; [odd.count, odd.##, (odd * f).count, (odd * f).loads, (odd + f).count]",
3045
+ "# [0, 3, 0, [0, 15, 3, 0], 4]",
3046
+ "```",
3047
+ "## The ranked hash",
3048
+ "",
3049
+ "`x.#n` is the Denum of rung n for n from 0 to 5, and bare `x.#` is still the",
3050
+ "Count. A host answers its Count C, Size s and residual r, so `[1, 2, 3]` has",
3051
+ "C = 3, s = 6 and r = 2. Rank 0 keeps the one load s, rank 1 puts (s+r)/2 on",
3052
+ "`e_ε` and (s−r)/2 on `-e_ε`, which are the Demi's left and right loads, and a",
3053
+ "higher rank puts the same two on `e_0…0` and `-e_0…0`",
3054
+ "```",
3055
+ "; .xs [1, 2, 3];",
3056
+ "; [xs.#, xs.##, xs.###, “” (xs.####)]",
3057
+ "# [3, 6, 2, “Demi(3,4,2)”]",
3058
+ "; [“” (xs.#0), “” (xs.#1), “” (xs.#2)]",
3059
+ "# [“Denum(CD[0], C=3, W=[6])”, “Denum(CD[1], C=3, W=[4, 2])”, “Denum(CD[2], C=3, W=[4, 0, 2, 0])”]",
3060
+ "; [(xs.#3).loads, (xs.#4).##, (xs.#5).schema, (xs.#5).loads .#, (xs.#5).observe ()]",
3061
+ "# [[4, 0, 0, 0, 2, 0, 0, 0], 6, “CD[5]”, 32, [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]",
3062
+ "; [xs.#1.loads = xs.####.loads, xs.#1.count = xs.####.count]",
3063
+ "# [<>, <>]",
3064
+ "```",
3065
+ "A router of more than two channels keeps its channel Demi under `.####`, and",
3066
+ "`.#1` is the binary projection of the same three observers, which is what the",
3067
+ "fourth hash derives for a binary router. Both answers are pinned",
3068
+ "```",
3069
+ "; Routers <- './hc/rotor-router.hc';",
3070
+ "; .RotorRouter Routers.RotorRouter;",
3071
+ "; .r3 (RotorRouter [[5, 8], [6], [7]]); .r2 (RotorRouter [[5], [6]]);",
3072
+ "; [r3.#, r3.##, r3.###, “” r3.####, “” r3.#1, “” r3.#2, (r3.#1).count = r3.####.count]",
3073
+ "# [4, 26, 14, “Demi(4,[13, 6, 7])”, “Denum(CD[1], C=4, W=[20, 6])”, “Denum(CD[2], C=4, W=[20, 0, 6, 0])”, <>]",
3074
+ "; [“” r2.####, “” r2.#1, (r2.#1).loads = [(r2.####).left, (r2.####).right]]",
3075
+ "# [“Demi(2,5,6)”, “Denum(CD[1], C=2, W=[5, 6])”, <>]",
3076
+ "```",
3077
+ "It is construction, not promotion. Promotion of an existing Demi-shaped host",
3078
+ "adds nothing, because a host's applications carry no higher signature. Each",
3079
+ "observer is read once, and a Frame without a Count has no Denum, as it has no",
3080
+ "Demi. An empty host, zero Count and nil answer nil at every rank",
3081
+ "```",
3082
+ "; [[].#0, [].#1, [].#5, ().#2, 0.#3]",
3083
+ "# [(), (), (), (), ()]",
3084
+ "; [“”.#1, “” (“a”.#0), ({5 + 3}.#1).loads = ({5 + 3}.####).loads, ({5 + 3}.#1).count]",
3085
+ "# [(), “Denum(CD[0], C=1, W=[1])”, <>, 3]",
3086
+ "```",
3087
+ "Application to a zero Size still counts, so a Denum of zero loads can have a",
3088
+ "positive Count, and it is present. It is not the missing host",
3089
+ "```",
3090
+ "; .zs [0, 0];",
3091
+ "; [“” (zs.#0), “” (zs.#1), zs.#0 = (), (Denum [0, 0, [0]]) = ()]",
3092
+ "# [“Denum(CD[0], C=2, W=[0])”, “Denum(CD[1], C=2, W=[0, 0])”, (), ()]",
3093
+ "```",
3094
+ "A Denum answers the ranked hash by promotion of its own state, at every Count",
3095
+ "including zero, and `$!.denum-demotion` below its rank. Nothing the source",
3096
+ "declares can steer it: a lookalike aggregate with the same fields is an",
3097
+ "ordinary host and is measured like any other",
3098
+ "```",
3099
+ "; .dn (Denum [1, 0, [3, 1]]);",
3100
+ "; [“” (dn.#1), “” (dn.#3), (dn.#2).loads, (dn.#5).count, dn.#0]",
3101
+ "# [“Denum(CD[1], C=0, W=[3, 1])”, “Denum(CD[3], C=0, W=[3, 0, 0, 0, 1, 0, 0, 0])”, [3, 0, 1, 0], 0, $!.denum-demotion]",
3102
+ "; .fake [.rank 1; .count 9; .loads [3, 1]; .# {99}; .## {99}; .### {99}];",
3103
+ "; [“” (fake.#1), “” (fake.#0), fake.#]",
3104
+ "# [“Denum(CD[1], C=99, W=[99, 0])”, “Denum(CD[0], C=99, W=[99])”, 99]",
3105
+ "; [xs.#6, xs.#7, xs.#99]",
3106
+ "# [$!.denum-rank, $!.denum-rank, $!.denum-rank]",
3107
+ "```",
3108
+ "The derived hash of a Denum is the ordinary derived Demi of its three",
3109
+ "observers, which is binary and forgets directions. `d.#n` is the Denum, and its",
3110
+ "algebraic value is an observation, never the return of `#n`",
3111
+ "```",
3112
+ "; [dn.####, “” ((Denum [2, 5, [1, 2, 3, 4]]).####)]",
3113
+ "# [(), “Demi(5,3,7)”]",
3114
+ "```",
3115
+ "`Demi` keeps its own contracts. Its `+`, `-`, `*` and `./` are not Denum",
3116
+ "arithmetic, and a Denum is not a Demi",
3117
+ "```",
3118
+ "; .d (xs.####);",
3119
+ "; [“” (d + 5), “” (d * 2), “” (d ./ 3), xs.#1 + 5]",
3120
+ "# [“Demi(3,4,7)”, “Demi(3,8,4)”, “Demi(3,[2, 2, 2])”, $!!.invalid-denum]",
3121
+ "```",
3122
+ "## Syntax boundaries",
3123
+ "",
3124
+ "The ranked hash is `.#` followed directly by decimal digits. A space ends it,",
3125
+ "and `.##` and `.###` are unchanged. A plain `#` still starts a comment, and the",
3126
+ "lexer cases are pinned in `lib/frames/frame-name.test.ts`",
3127
+ "```",
3128
+ "; [xs.# 2, xs.##, xs.###, xs.##]",
3129
+ "# [6, 6, 2, 6]",
3130
+ "",
3131
+ ].join("\n"),
3132
+ ],
2269
3133
  [
2270
3134
  "hc/division.hc",
2271
3135
  [