hclang 0.44.0 → 0.44.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.
- package/esm/cli/hc.js +4 -1
- package/esm/lib/bundle/hc-sources.js +469 -0
- package/esm/lib/frames/access-footprint.js +665 -0
- package/esm/lib/frames/bound-method.js +38 -0
- package/esm/lib/frames/dispatch-host.js +118 -0
- package/esm/lib/frames/effect-registry.js +21 -2
- package/esm/lib/frames/event-dispatch.js +192 -0
- package/esm/lib/frames/frame-array.js +41 -10
- package/esm/lib/frames/frame-expr.js +37 -6
- package/esm/lib/frames/frame-lazy.js +36 -4
- package/esm/lib/frames/frame-list.js +9 -2
- package/esm/lib/frames/frame.js +45 -6
- package/esm/lib/frames/reference-tracking.js +275 -0
- package/esm/lib/frames.js +6 -0
- package/esm/lib/version.js +1 -1
- package/package.json +1 -1
package/esm/cli/hc.js
CHANGED
|
@@ -10,7 +10,7 @@ import { runfile } from "./runfile.js";
|
|
|
10
10
|
import { Prompt } from "./prompt.js";
|
|
11
11
|
import { DenoFileStore } from "./resource-store.js";
|
|
12
12
|
import { withHCBundle } from "../lib/bundle/hc-bundle.js";
|
|
13
|
-
import { CLOCK_SCHEME, ClockHandler, Frame, FrameResource, RealClock, RESOURCE_ROOT_KEY, ResourceHandlers, } from "../lib/frames.js";
|
|
13
|
+
import { CLOCK_SCHEME, ClockHandler, DISPATCH_KEY, dispatchNamespace, Frame, FrameResource, RealClock, RESOURCE_ROOT_KEY, ResourceHandlers, } from "../lib/frames.js";
|
|
14
14
|
/**
|
|
15
15
|
* @module hc
|
|
16
16
|
*
|
|
@@ -65,6 +65,8 @@ export function getEval(env, out) {
|
|
|
65
65
|
*
|
|
66
66
|
* The root is a fresh temp directory with the bundled, read-only `hc/` files
|
|
67
67
|
* laid over it, so a program can import them without reaching anything else.
|
|
68
|
+
* The dispatcher is bound beside it (`$$.dispatch`), so a testdoc can hand
|
|
69
|
+
* its own closures to each dispatch policy (`hc/art-dispatch-vact.hc`).
|
|
68
70
|
*
|
|
69
71
|
* Exported so a test can run a source unit under the authority the CLI actually
|
|
70
72
|
* grants, rather than under an empty namespace that would make the resource
|
|
@@ -79,6 +81,7 @@ export function getHost(context = {}) {
|
|
|
79
81
|
// and nowhere else.
|
|
80
82
|
const host = new Frame({ ...context });
|
|
81
83
|
host.set(RESOURCE_ROOT_KEY, FrameResource.root(withHCBundle(new DenoFileStore()), getHandlers()));
|
|
84
|
+
host.set(DISPATCH_KEY, dispatchNamespace());
|
|
82
85
|
return host;
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
@@ -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
|
[
|