@mark1russell7/service 0.8.19 → 0.9.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.
- package/README.md +6 -2
- package/build/backoff.d.ts +44 -2
- package/build/{builder-zO48Vgoj.d.ts → builder.d.ts} +14 -101
- package/build/builder.js +499 -0
- package/build/builder.js.map +1 -0
- package/build/{call-context-DDhcVvn5.d.ts → call-context.d.ts} +3 -4
- package/build/channel.d.ts +1 -1
- package/build/channel.js.map +1 -1
- package/build/{core-BSzt4RI2.d.ts → client/core.d.ts} +32 -61
- package/build/{machine-BhVeHr_m.js → client/core.js} +4 -153
- package/build/client/core.js.map +1 -0
- package/build/{dial-ChwIcvd4.d.ts → client/dial.d.ts} +3 -4
- package/build/client/dial.js +52 -0
- package/build/client/dial.js.map +1 -0
- package/build/client/machine.js +29 -0
- package/build/client/machine.js.map +1 -0
- package/build/client/meets.d.ts +35 -0
- package/build/client/meets.js +78 -0
- package/build/client/meets.js.map +1 -0
- package/build/clock.d.ts +2 -2
- package/build/clock.js +1 -1
- package/build/conformance.d.ts +122 -0
- package/build/conformance.js +469 -0
- package/build/conformance.js.map +1 -0
- package/build/contract.d.ts +28 -0
- package/build/contract.js +184 -0
- package/build/contract.js.map +1 -0
- package/build/description.d.ts +161 -0
- package/build/description.js +11 -0
- package/build/description.js.map +1 -0
- package/build/drains.js +35 -0
- package/build/drains.js.map +1 -0
- package/build/events.d.ts +25 -0
- package/build/fakes.d.ts +43 -0
- package/build/fakes.js +93 -0
- package/build/fakes.js.map +1 -0
- package/build/grpc/client.d.ts +153 -0
- package/build/grpc/client.js +474 -0
- package/build/grpc/client.js.map +1 -0
- package/build/grpc/connection.d.ts +97 -0
- package/build/grpc/connection.js +59 -0
- package/build/grpc/connection.js.map +1 -0
- package/build/grpc/machine.d.ts +12 -0
- package/build/grpc/machine.js +149 -0
- package/build/grpc/machine.js.map +1 -0
- package/build/grpc/meets.d.ts +14 -0
- package/build/grpc/meets.js +105 -0
- package/build/grpc/meets.js.map +1 -0
- package/build/grpc/starting.d.ts +33 -0
- package/build/grpc/starting.js +89 -0
- package/build/grpc/starting.js.map +1 -0
- package/build/grpc.d.ts +9 -303
- package/build/grpc.js +7 -854
- package/build/health.d.ts +93 -0
- package/build/health.js +225 -0
- package/build/health.js.map +1 -0
- package/build/heartbeat.d.ts +6 -2
- package/build/heartbeat.js.map +1 -1
- package/build/host/discovery.d.ts +61 -0
- package/build/host/discovery.js +113 -0
- package/build/host/discovery.js.map +1 -0
- package/build/host/env.d.ts +14 -0
- package/build/host/env.js +57 -0
- package/build/host/env.js.map +1 -0
- package/build/host/fakes.d.ts +82 -0
- package/build/host/fakes.js +239 -0
- package/build/host/fakes.js.map +1 -0
- package/build/host/group.d.ts +142 -0
- package/build/host/group.js +524 -0
- package/build/host/group.js.map +1 -0
- package/build/host/install.d.ts +96 -0
- package/build/host/install.js +330 -0
- package/build/host/install.js.map +1 -0
- package/build/host/lock.d.ts +78 -0
- package/build/host/lock.js +190 -0
- package/build/host/lock.js.map +1 -0
- package/build/host/logs.d.ts +26 -0
- package/build/host/logs.js +48 -0
- package/build/host/logs.js.map +1 -0
- package/build/host/node.d.ts +14 -0
- package/build/host/node.js +309 -0
- package/build/host/node.js.map +1 -0
- package/build/{ports-B1ayTL-j.d.ts → host/ports.d.ts} +15 -16
- package/build/host/ports.js +17 -0
- package/build/host/ports.js.map +1 -0
- package/build/host/probes.d.ts +51 -0
- package/build/host/probes.js +139 -0
- package/build/host/probes.js.map +1 -0
- package/build/host/processes.d.ts +32 -0
- package/build/host/processes.js +63 -0
- package/build/host/processes.js.map +1 -0
- package/build/host/render.d.ts +84 -0
- package/build/host/render.js +235 -0
- package/build/host/render.js.map +1 -0
- package/build/host/watch.d.ts +90 -0
- package/build/host/watch.js +165 -0
- package/build/host/watch.js.map +1 -0
- package/build/host.d.ts +13 -671
- package/build/host.js +12 -2126
- package/build/http/answers.js +29 -0
- package/build/http/answers.js.map +1 -0
- package/build/http/fake-server.js +61 -0
- package/build/http/fake-server.js.map +1 -0
- package/build/http/outcome.d.ts +115 -0
- package/build/http/outcome.js +325 -0
- package/build/http/outcome.js.map +1 -0
- package/build/http/probes.d.ts +83 -0
- package/build/http/probes.js +232 -0
- package/build/http/probes.js.map +1 -0
- package/build/http/transport.d.ts +165 -0
- package/build/http/transport.js +518 -0
- package/build/http/transport.js.map +1 -0
- package/build/http-client/client.d.ts +121 -0
- package/build/http-client/client.js +330 -0
- package/build/http-client/client.js.map +1 -0
- package/build/http-client/connection.d.ts +78 -0
- package/build/http-client/connection.js +54 -0
- package/build/http-client/connection.js.map +1 -0
- package/build/http-client/machine.d.ts +14 -0
- package/build/http-client/machine.js +109 -0
- package/build/http-client/machine.js.map +1 -0
- package/build/http-client/meets.d.ts +11 -0
- package/build/http-client/meets.js +74 -0
- package/build/http-client/meets.js.map +1 -0
- package/build/http-client/session.d.ts +87 -0
- package/build/http-client/session.js +99 -0
- package/build/http-client/session.js.map +1 -0
- package/build/http-client/starting.d.ts +25 -0
- package/build/http-client/starting.js +65 -0
- package/build/http-client/starting.js.map +1 -0
- package/build/http-client.d.ts +9 -330
- package/build/http-client.js +8 -707
- package/build/http.d.ts +5 -353
- package/build/http.js +3 -1086
- package/build/identity.d.ts +16 -0
- package/build/identity.js +44 -0
- package/build/identity.js.map +1 -0
- package/build/index.d.ts +35 -412
- package/build/index.js +25 -3278
- package/build/knobs.d.ts +1 -0
- package/build/{knobs-BJcz6m01.js → knobs.js} +2 -34
- package/build/knobs.js.map +1 -0
- package/build/latch.d.ts +29 -0
- package/build/latch.js +122 -0
- package/build/latch.js.map +1 -0
- package/build/{rules-HyFCBStQ.d.ts → law.d.ts} +19 -37
- package/build/law.js +149 -0
- package/build/law.js.map +1 -0
- package/build/lifecycle.d.ts +144 -0
- package/build/lifecycle.js +411 -0
- package/build/lifecycle.js.map +1 -0
- package/build/limiter/machine.d.ts +40 -0
- package/build/limiter/machine.js +279 -0
- package/build/limiter/machine.js.map +1 -0
- package/build/{policy-CBcK2XGg.d.ts → limiter/policy.d.ts} +28 -29
- package/build/{policy-UYALkqVq.js → limiter/policy.js} +10 -9
- package/build/limiter/policy.js.map +1 -0
- package/build/{limiter-BNKnwzeY.d.ts → limiter/quota.d.ts} +32 -74
- package/build/{limiter-DrM0PQV9.js → limiter/quota.js} +3 -418
- package/build/limiter/quota.js.map +1 -0
- package/build/{store-DFwFKrsB.d.ts → limiter/store.d.ts} +10 -11
- package/build/limiter/store.js +145 -0
- package/build/limiter/store.js.map +1 -0
- package/build/limiter.d.ts +4 -3
- package/build/limiter.js +4 -2
- package/build/lint.d.ts +152 -0
- package/build/lint.js +576 -0
- package/build/lint.js.map +1 -0
- package/build/logger.d.ts +71 -0
- package/build/logger.js +183 -0
- package/build/logger.js.map +1 -0
- package/build/machines.d.ts +41 -0
- package/build/machines.js +451 -0
- package/build/machines.js.map +1 -0
- package/build/metrics.d.ts +53 -0
- package/build/metrics.js +111 -0
- package/build/metrics.js.map +1 -0
- package/build/mongodb/client.d.ts +131 -0
- package/build/mongodb/client.js +388 -0
- package/build/mongodb/client.js.map +1 -0
- package/build/mongodb/connection.d.ts +112 -0
- package/build/mongodb/connection.js +12 -0
- package/build/mongodb/connection.js.map +1 -0
- package/build/mongodb/machine.d.ts +14 -0
- package/build/mongodb/machine.js +122 -0
- package/build/mongodb/machine.js.map +1 -0
- package/build/mongodb/meets.d.ts +15 -0
- package/build/mongodb/meets.js +103 -0
- package/build/mongodb/meets.js.map +1 -0
- package/build/mongodb/starting.d.ts +29 -0
- package/build/mongodb/starting.js +77 -0
- package/build/mongodb/starting.js.map +1 -0
- package/build/mongodb.d.ts +8 -296
- package/build/mongodb.js +7 -682
- package/build/operation.d.ts +27 -0
- package/build/{operation-DF73RZOI.js → operation.js} +2 -2
- package/build/operation.js.map +1 -0
- package/build/otel.d.ts +2 -2
- package/build/pg/client.d.ts +96 -0
- package/build/pg/client.js +277 -0
- package/build/pg/client.js.map +1 -0
- package/build/pg/connection.d.ts +75 -0
- package/build/pg/connection.js +11 -0
- package/build/pg/connection.js.map +1 -0
- package/build/pg/machine.d.ts +13 -0
- package/build/pg/machine.js +111 -0
- package/build/pg/machine.js.map +1 -0
- package/build/pg/meets.d.ts +14 -0
- package/build/pg/meets.js +83 -0
- package/build/pg/meets.js.map +1 -0
- package/build/pg/starting.d.ts +26 -0
- package/build/pg/starting.js +62 -0
- package/build/pg/starting.js.map +1 -0
- package/build/pg.d.ts +8 -219
- package/build/pg.js +7 -525
- package/build/poller.d.ts +9 -0
- package/build/poller.js +154 -0
- package/build/poller.js.map +1 -0
- package/build/process.d.ts +114 -0
- package/build/process.js +170 -0
- package/build/process.js.map +1 -0
- package/build/profiles.d.ts +68 -0
- package/build/profiles.js +120 -0
- package/build/profiles.js.map +1 -0
- package/build/{queue-DXdw1vLO.d.ts → queue.d.ts} +16 -29
- package/build/queue.js +279 -0
- package/build/queue.js.map +1 -0
- package/build/rabbitmq/client.d.ts +144 -0
- package/build/rabbitmq/client.js +426 -0
- package/build/rabbitmq/client.js.map +1 -0
- package/build/rabbitmq/connection.d.ts +91 -0
- package/build/rabbitmq/connection.js +15 -0
- package/build/rabbitmq/connection.js.map +1 -0
- package/build/rabbitmq/machine.d.ts +13 -0
- package/build/rabbitmq/machine.js +159 -0
- package/build/rabbitmq/machine.js.map +1 -0
- package/build/rabbitmq/meets.d.ts +12 -0
- package/build/rabbitmq/meets.js +96 -0
- package/build/rabbitmq/meets.js.map +1 -0
- package/build/rabbitmq/starting.d.ts +27 -0
- package/build/rabbitmq/starting.js +67 -0
- package/build/rabbitmq/starting.js.map +1 -0
- package/build/rabbitmq.d.ts +8 -283
- package/build/rabbitmq.js +7 -742
- package/build/redis/client.d.ts +86 -0
- package/build/redis/client.js +285 -0
- package/build/redis/client.js.map +1 -0
- package/build/redis/connection.d.ts +57 -0
- package/build/redis/connection.js +11 -0
- package/build/redis/connection.js.map +1 -0
- package/build/redis/limiter.d.ts +43 -0
- package/build/redis/limiter.js +164 -0
- package/build/redis/limiter.js.map +1 -0
- package/build/redis/machine.d.ts +12 -0
- package/build/redis/machine.js +144 -0
- package/build/redis/machine.js.map +1 -0
- package/build/redis/meets.d.ts +11 -0
- package/build/redis/meets.js +75 -0
- package/build/redis/meets.js.map +1 -0
- package/build/redis/operations.d.ts +5 -0
- package/build/redis/operations.js +114 -0
- package/build/redis/operations.js.map +1 -0
- package/build/redis.d.ts +10 -207
- package/build/redis.js +9 -771
- package/build/requests.d.ts +66 -0
- package/build/requests.js +279 -0
- package/build/requests.js.map +1 -0
- package/build/retrier.d.ts +62 -0
- package/build/{retrier-Dnjhvxol.js → retrier.js} +2 -2
- package/build/retrier.js.map +1 -0
- package/build/routes.d.ts +35 -0
- package/build/routes.js +77 -0
- package/build/routes.js.map +1 -0
- package/build/rules.d.ts +19 -2
- package/build/stops.d.ts +51 -0
- package/build/stops.js +86 -0
- package/build/stops.js.map +1 -0
- package/build/testing.d.ts +8 -270
- package/build/testing.js +4 -1027
- package/build/testing.js.map +1 -1
- package/build/timing.d.ts +63 -0
- package/build/{timing-DZl36uXs.js → timing.js} +2 -2
- package/build/timing.js.map +1 -0
- package/build/units.d.ts +17 -0
- package/build/units.js +236 -0
- package/build/units.js.map +1 -0
- package/build/watchdog.d.ts +38 -0
- package/build/watchdog.js +57 -0
- package/build/watchdog.js.map +1 -0
- package/build/websocket/client.d.ts +136 -0
- package/build/websocket/client.js +422 -0
- package/build/websocket/client.js.map +1 -0
- package/build/websocket/connection.d.ts +83 -0
- package/build/websocket/connection.js +57 -0
- package/build/websocket/connection.js.map +1 -0
- package/build/websocket/machine.d.ts +12 -0
- package/build/websocket/machine.js +155 -0
- package/build/websocket/machine.js.map +1 -0
- package/build/websocket/meets.d.ts +14 -0
- package/build/websocket/meets.js +92 -0
- package/build/websocket/meets.js.map +1 -0
- package/build/websocket/starting.d.ts +25 -0
- package/build/websocket/starting.js +69 -0
- package/build/websocket/starting.js.map +1 -0
- package/build/websocket.d.ts +9 -264
- package/build/websocket.js +8 -774
- package/build/worker.d.ts +92 -0
- package/build/worker.js +153 -0
- package/build/worker.js.map +1 -0
- package/package.json +5 -4
- package/build/backoff-QTRGfkEK.d.ts +0 -45
- package/build/clock-DpVgpY4h.d.ts +0 -2
- package/build/grpc.js.map +0 -1
- package/build/host.js.map +0 -1
- package/build/http-client.js.map +0 -1
- package/build/http.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/knobs-BJcz6m01.js.map +0 -1
- package/build/lifecycle-D0J-zwZF.d.ts +0 -374
- package/build/limiter-DrM0PQV9.js.map +0 -1
- package/build/logger-B6drv9w0.d.ts +0 -488
- package/build/machine-BhVeHr_m.js.map +0 -1
- package/build/mongodb.js.map +0 -1
- package/build/operation-DF73RZOI.js.map +0 -1
- package/build/pg.js.map +0 -1
- package/build/policy-UYALkqVq.js.map +0 -1
- package/build/process-7R9M29wN.js +0 -437
- package/build/process-7R9M29wN.js.map +0 -1
- package/build/rabbitmq.js.map +0 -1
- package/build/redis.js.map +0 -1
- package/build/requests-DD2ALv0_.js +0 -583
- package/build/requests-DD2ALv0_.js.map +0 -1
- package/build/retrier-Dnjhvxol.js.map +0 -1
- package/build/timing-DZl36uXs.js.map +0 -1
- package/build/websocket.js.map +0 -1
package/build/knobs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@mark1russell7/quantity";
|
|
@@ -1,36 +1,4 @@
|
|
|
1
1
|
import { convertible, valueIn } from "@mark1russell7/quantity";
|
|
2
|
-
// src/drains.ts
|
|
3
|
-
const holds = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
/** This function adds the hold of a drain under its lifecycle. It gives the function that removes the hold. */
|
|
5
|
-
const holdLate = (life, hold) => {
|
|
6
|
-
const set = holds.get(life) ?? /* @__PURE__ */ new Set();
|
|
7
|
-
holds.set(life, set);
|
|
8
|
-
set.add(hold);
|
|
9
|
-
return () => {
|
|
10
|
-
set.delete(hold);
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
/** This function gives the hold of each drain under a lifecycle, as it is at this time. */
|
|
14
|
-
const lateHolds = (life) => [...holds.get(life) ?? []].map((hold) => hold());
|
|
15
|
-
const owners = /* @__PURE__ */ new WeakMap();
|
|
16
|
-
const outside = /* @__PURE__ */ new WeakMap();
|
|
17
|
-
/** This function records the lifecycle that made a stream, and gives the stream. A stream keeps its first owner. */
|
|
18
|
-
const ownStream = (stream, life) => {
|
|
19
|
-
if (!owners.has(stream)) owners.set(stream, life);
|
|
20
|
-
return stream;
|
|
21
|
-
};
|
|
22
|
-
/** This function gives the lifecycle that made a stream, or null for a stream outside each lifecycle. */
|
|
23
|
-
const ownerOf = (stream) => owners.get(stream) ?? null;
|
|
24
|
-
/** This function adds the count of streams outside a lifecycle that a drain found open at its deadline. */
|
|
25
|
-
const noteOutside = (life, count) => {
|
|
26
|
-
if (count > 0) outside.set(life, (outside.get(life) ?? 0) + count);
|
|
27
|
-
};
|
|
28
|
-
/** This function gives the count of streams outside a lifecycle that its drains found, and sets the count to zero. */
|
|
29
|
-
const takeOutside = (life) => {
|
|
30
|
-
const count = outside.get(life) ?? 0;
|
|
31
|
-
outside.delete(life);
|
|
32
|
-
return count;
|
|
33
|
-
};
|
|
34
2
|
// src/knobs.ts
|
|
35
3
|
/**
|
|
36
4
|
* This function gives a time knob in milliseconds, or infinity for a time without a bound. The
|
|
@@ -65,6 +33,6 @@ const countOf = (knobs, name, owner) => {
|
|
|
65
33
|
if (!(Number.isInteger(value) && value >= 1)) throw new Error(`the knob ${name} is ${value}, not a whole number above zero`);
|
|
66
34
|
return value;
|
|
67
35
|
};
|
|
68
|
-
export {
|
|
36
|
+
export { boundedMillisecondsOf, countOf, millisecondsOf };
|
|
69
37
|
|
|
70
|
-
//# sourceMappingURL=knobs
|
|
38
|
+
//# sourceMappingURL=knobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knobs.js","names":[],"sources":["../src/knobs.ts"],"sourcesContent":["import type { Extent } from \"@mark1russell7/quantity\";\nimport { convertible, valueIn } from \"@mark1russell7/quantity\";\n\n/** A knob record is the knobs of a part, by name. A knob that is absent is undefined. */\nexport type KnobRecord = Readonly<Record<string, Extent | undefined>>;\n\n/**\n * This function gives a time knob in milliseconds, or infinity for a time without a bound. The\n * runtime has no defaults, thus a knob that is absent throws. A knob that is not a time, or that is\n * less than zero, also throws.\n */\nexport const millisecondsOf = (knobs: KnobRecord, name: string, owner: string): number => {\n const amount = knobs[name];\n if (amount === undefined) throw new Error(`${owner} needs the knob ${name}: it has no defaults`);\n if (!convertible(amount.unit, \"s\")) throw new Error(`the knob ${name} is not a time`);\n if (amount.value === \"infinite\") return Number.POSITIVE_INFINITY;\n const value = valueIn(amount, \"ms\");\n if (!(value >= 0)) throw new Error(`the knob ${name} is less than zero`);\n return value;\n};\n\n/** This function gives a time knob in milliseconds, and it throws for a time without a bound. */\nexport const boundedMillisecondsOf = (knobs: KnobRecord, name: string, owner: string): number => {\n const value = millisecondsOf(knobs, name, owner);\n if (!Number.isFinite(value)) throw new Error(`the knob ${name} of ${owner} has no bound: it needs a time`);\n return value;\n};\n\n/**\n * This function gives a count knob (the unit `count`) as a whole number above zero, or infinity\n * for a count without a bound. A knob that is absent, not a count, or not a whole number above zero throws.\n */\nexport const countOf = (knobs: KnobRecord, name: string, owner: string): number => {\n const amount = knobs[name];\n if (amount === undefined) throw new Error(`${owner} needs the knob ${name}: it has no defaults`);\n if (!convertible(amount.unit, \"count\")) throw new Error(`the knob ${name} is not a count`);\n if (amount.value === \"infinite\") return Number.POSITIVE_INFINITY;\n const value = valueIn(amount, \"count\");\n if (!(Number.isInteger(value) && value >= 1)) throw new Error(`the knob ${name} is ${value}, not a whole number above zero`);\n return value;\n};\n"],"mappings":";;;;;;;AAWA,MAAa,kBAAkB,OAAmB,MAAc,UAA0B;CACxF,MAAM,SAAS,MAAM;CACrB,IAAI,WAAW,KAAA,GAAW,MAAM,IAAI,MAAM,GAAG,MAAM,kBAAkB,KAAK,qBAAqB;CAC/F,IAAI,CAAC,YAAY,OAAO,MAAM,GAAG,GAAG,MAAM,IAAI,MAAM,YAAY,KAAK,eAAe;CACpF,IAAI,OAAO,UAAU,YAAY,OAAO,OAAO;CAC/C,MAAM,QAAQ,QAAQ,QAAQ,IAAI;CAClC,IAAI,EAAE,SAAS,IAAI,MAAM,IAAI,MAAM,YAAY,KAAK,mBAAmB;CACvE,OAAO;AACT;;AAGA,MAAa,yBAAyB,OAAmB,MAAc,UAA0B;CAC/F,MAAM,QAAQ,eAAe,OAAO,MAAM,KAAK;CAC/C,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,MAAM,IAAI,MAAM,YAAY,KAAK,MAAM,MAAM,+BAA+B;CACzG,OAAO;AACT;;;;;AAMA,MAAa,WAAW,OAAmB,MAAc,UAA0B;CACjF,MAAM,SAAS,MAAM;CACrB,IAAI,WAAW,KAAA,GAAW,MAAM,IAAI,MAAM,GAAG,MAAM,kBAAkB,KAAK,qBAAqB;CAC/F,IAAI,CAAC,YAAY,OAAO,MAAM,OAAO,GAAG,MAAM,IAAI,MAAM,YAAY,KAAK,gBAAgB;CACzF,IAAI,OAAO,UAAU,YAAY,OAAO,OAAO;CAC/C,MAAM,QAAQ,QAAQ,QAAQ,OAAO;CACrC,IAAI,EAAE,OAAO,UAAU,KAAK,KAAK,SAAS,IAAI,MAAM,IAAI,MAAM,YAAY,KAAK,MAAM,MAAM,gCAAgC;CAC3H,OAAO;AACT"}
|
package/build/latch.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "./clock.js";
|
|
2
|
+
import "./timing.js";
|
|
3
|
+
/**
|
|
4
|
+
* An outcome is the result of one poll of a check. Only `"ok"` passes. An `"indeterminate"`
|
|
5
|
+
* outcome measured nothing: it does not pass, and it does not fail.
|
|
6
|
+
*/
|
|
7
|
+
export type Outcome = "ok" | "error" | "indeterminate";
|
|
8
|
+
/** A result is one poll of a check, as the runtime records it. */
|
|
9
|
+
export interface Result {
|
|
10
|
+
readonly outcome: Outcome;
|
|
11
|
+
/** This time is when the result came, on the monotonic clock, in milliseconds. */
|
|
12
|
+
readonly at: number;
|
|
13
|
+
/** This time is how long the poll took, in milliseconds. */
|
|
14
|
+
readonly took: number;
|
|
15
|
+
/** This text tells why the poll did not pass, or it is null. */
|
|
16
|
+
readonly cause: string | null;
|
|
17
|
+
/** This flag tells if the poll failed at its timeout. */
|
|
18
|
+
readonly timedOut: boolean;
|
|
19
|
+
/** This flag tells if the check threw. A throw is an error with a flag. */
|
|
20
|
+
readonly thrown: boolean;
|
|
21
|
+
/** This flag tells if the force-fail list made the poll fail. */
|
|
22
|
+
readonly forced: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A trace receives each transition of a machine of the runtime: the state before, the state after,
|
|
26
|
+
* and the event. The machine documents of the lifecycle name the same states and events, thus a
|
|
27
|
+
* test can replay a trace against its document.
|
|
28
|
+
*/
|
|
29
|
+
export type Trace = (from: string, to: string, on: string) => void;
|
package/build/latch.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { valueIn } from "@mark1russell7/quantity";
|
|
2
|
+
// src/latch.ts
|
|
3
|
+
const ms = (amount) => valueIn(amount, "ms");
|
|
4
|
+
/**
|
|
5
|
+
* This function makes a latch. `tripped` is its state at the start: a readiness latch starts
|
|
6
|
+
* tripped, and a liveness latch starts released. The latch starts `changed` each time it trips or
|
|
7
|
+
* releases, and it gives each transition to `trace`. A debounce has the states `released` and
|
|
8
|
+
* `tripped`. A window also has the states `failing` and `recovering`, while one of its timers runs.
|
|
9
|
+
*/
|
|
10
|
+
const latch = (timing, clock, tripped, changed, trace) => {
|
|
11
|
+
let state = tripped;
|
|
12
|
+
let since = clock.now();
|
|
13
|
+
let streak = 0;
|
|
14
|
+
let fails = 0;
|
|
15
|
+
let passes = 0;
|
|
16
|
+
let failingSince = null;
|
|
17
|
+
let passingSince = null;
|
|
18
|
+
let failTimer = null;
|
|
19
|
+
let passTimer = null;
|
|
20
|
+
/** This function gives the name of the state, as the machine documents name it. */
|
|
21
|
+
const named = () => state ? passingSince === null ? "tripped" : "recovering" : failingSince === null ? "released" : "failing";
|
|
22
|
+
/** This function does one step of the machine, and gives its transition to the trace. */
|
|
23
|
+
const step = (on, change) => {
|
|
24
|
+
const from = named();
|
|
25
|
+
change();
|
|
26
|
+
trace?.(from, named(), on);
|
|
27
|
+
};
|
|
28
|
+
const set = (next) => {
|
|
29
|
+
if (next === state) return;
|
|
30
|
+
state = next;
|
|
31
|
+
since = clock.now();
|
|
32
|
+
changed();
|
|
33
|
+
};
|
|
34
|
+
const stopFail = () => {
|
|
35
|
+
failTimer?.();
|
|
36
|
+
failTimer = null;
|
|
37
|
+
failingSince = null;
|
|
38
|
+
};
|
|
39
|
+
const stopPass = () => {
|
|
40
|
+
passTimer?.();
|
|
41
|
+
passTimer = null;
|
|
42
|
+
passingSince = null;
|
|
43
|
+
};
|
|
44
|
+
const debounce = (result) => {
|
|
45
|
+
if (timing.type !== "debounce") return;
|
|
46
|
+
if (result.outcome === "ok") {
|
|
47
|
+
passes += 1;
|
|
48
|
+
fails = 0;
|
|
49
|
+
if (state && passes >= timing.recoverAfter) set(false);
|
|
50
|
+
} else {
|
|
51
|
+
fails += 1;
|
|
52
|
+
passes = 0;
|
|
53
|
+
if (!state && fails >= timing.failAfter) set(true);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const windowed = (result) => {
|
|
57
|
+
if (timing.type !== "window") return;
|
|
58
|
+
if (result.outcome === "ok") {
|
|
59
|
+
stopFail();
|
|
60
|
+
if (!state) return;
|
|
61
|
+
if (timing.recoverAfter === void 0) {
|
|
62
|
+
set(false);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (passingSince !== null) return;
|
|
66
|
+
const wait = ms(timing.recoverAfter);
|
|
67
|
+
if (wait <= 0) {
|
|
68
|
+
stopPass();
|
|
69
|
+
set(false);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
passingSince = result.at;
|
|
73
|
+
passTimer = clock.after(wait, () => step("window.recovered", () => {
|
|
74
|
+
passTimer = null;
|
|
75
|
+
passingSince = null;
|
|
76
|
+
set(false);
|
|
77
|
+
}));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
stopPass();
|
|
81
|
+
if (state || failingSince !== null) return;
|
|
82
|
+
const wait = ms(timing.failAfter);
|
|
83
|
+
if (wait <= 0) {
|
|
84
|
+
stopFail();
|
|
85
|
+
set(true);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
failingSince = result.at;
|
|
89
|
+
failTimer = clock.after(wait, () => step("window.failed", () => {
|
|
90
|
+
failTimer = null;
|
|
91
|
+
failingSince = null;
|
|
92
|
+
set(true);
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
get tripped() {
|
|
97
|
+
return state;
|
|
98
|
+
},
|
|
99
|
+
get since() {
|
|
100
|
+
return since;
|
|
101
|
+
},
|
|
102
|
+
get streak() {
|
|
103
|
+
return streak;
|
|
104
|
+
},
|
|
105
|
+
record(result) {
|
|
106
|
+
if (result.outcome === "indeterminate") return;
|
|
107
|
+
const pass = result.outcome === "ok";
|
|
108
|
+
step(pass ? "poll.ok" : "poll.fail", () => {
|
|
109
|
+
streak = pass ? Math.max(0, streak) + 1 : Math.min(0, streak) - 1;
|
|
110
|
+
debounce(result);
|
|
111
|
+
windowed(result);
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
stop() {
|
|
115
|
+
stopFail();
|
|
116
|
+
stopPass();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export { latch };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=latch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latch.js","names":[],"sources":["../src/latch.ts"],"sourcesContent":["import { valueIn } from \"@mark1russell7/quantity\";\nimport type { Cancel, Clock } from \"./clock.ts\";\nimport type { Timing } from \"./timing.ts\";\n\n/**\n * An outcome is the result of one poll of a check. Only `\"ok\"` passes. An `\"indeterminate\"`\n * outcome measured nothing: it does not pass, and it does not fail.\n */\nexport type Outcome = \"ok\" | \"error\" | \"indeterminate\";\n\n/** A result is one poll of a check, as the runtime records it. */\nexport interface Result {\n readonly outcome: Outcome;\n /** This time is when the result came, on the monotonic clock, in milliseconds. */\n readonly at: number;\n /** This time is how long the poll took, in milliseconds. */\n readonly took: number;\n /** This text tells why the poll did not pass, or it is null. */\n readonly cause: string | null;\n /** This flag tells if the poll failed at its timeout. */\n readonly timedOut: boolean;\n /** This flag tells if the check threw. A throw is an error with a flag. */\n readonly thrown: boolean;\n /** This flag tells if the force-fail list made the poll fail. */\n readonly forced: boolean;\n}\n\n/**\n * A latch turns the results of one check into a verdict, by the timing of its policy. A debounce\n * counts polls in sequence. A window measures time on the monotonic clock from the first failure\n * of a sequence. A tripped latch fails its policy.\n */\nexport interface Latch {\n readonly tripped: boolean;\n /** This time is when the latch last tripped or released. */\n readonly since: number;\n /** This count is the sequence of the latest results: above zero for passes, below zero for failures. */\n readonly streak: number;\n record(result: Result): void;\n /** This method stops the timers of a window. */\n stop(): void;\n}\n\n/**\n * A trace receives each transition of a machine of the runtime: the state before, the state after,\n * and the event. The machine documents of the lifecycle name the same states and events, thus a\n * test can replay a trace against its document.\n */\nexport type Trace = (from: string, to: string, on: string) => void;\n\nconst ms = (amount: { readonly value: number; readonly unit: string }): number =>\n valueIn(amount, \"ms\");\n\n/**\n * This function makes a latch. `tripped` is its state at the start: a readiness latch starts\n * tripped, and a liveness latch starts released. The latch starts `changed` each time it trips or\n * releases, and it gives each transition to `trace`. A debounce has the states `released` and\n * `tripped`. A window also has the states `failing` and `recovering`, while one of its timers runs.\n */\nexport const latch = (\n timing: Timing,\n clock: Clock,\n tripped: boolean,\n changed: () => void,\n trace?: Trace,\n): Latch => {\n let state = tripped;\n let since = clock.now();\n let streak = 0;\n let fails = 0;\n let passes = 0;\n // the timers of a window: the time that a sequence of failures or passes started, and its timer\n let failingSince: number | null = null;\n let passingSince: number | null = null;\n let failTimer: Cancel | null = null;\n let passTimer: Cancel | null = null;\n // the owner gives the clock: a check of a service gives a clock whose timers do not keep the process alive (SYS-126)\n\n /** This function gives the name of the state, as the machine documents name it. */\n const named = (): string =>\n state\n ? passingSince === null\n ? \"tripped\"\n : \"recovering\"\n : failingSince === null\n ? \"released\"\n : \"failing\";\n /** This function does one step of the machine, and gives its transition to the trace. */\n const step = (on: string, change: () => void): void => {\n const from = named();\n change();\n trace?.(from, named(), on);\n };\n\n const set = (next: boolean): void => {\n if (next === state) return;\n state = next;\n since = clock.now();\n changed();\n };\n const stopFail = (): void => {\n failTimer?.();\n failTimer = null;\n failingSince = null;\n };\n const stopPass = (): void => {\n passTimer?.();\n passTimer = null;\n passingSince = null;\n };\n\n const debounce = (result: Result): void => {\n if (timing.type !== \"debounce\") return;\n if (result.outcome === \"ok\") {\n passes += 1;\n fails = 0;\n if (state && passes >= timing.recoverAfter) set(false);\n } else {\n fails += 1;\n passes = 0;\n if (!state && fails >= timing.failAfter) set(true);\n }\n };\n\n const windowed = (result: Result): void => {\n if (timing.type !== \"window\") return;\n if (result.outcome === \"ok\") {\n stopFail();\n if (!state) return;\n if (timing.recoverAfter === undefined) {\n set(false);\n return;\n }\n if (passingSince !== null) return;\n const wait = ms(timing.recoverAfter);\n if (wait <= 0) {\n stopPass();\n set(false);\n return;\n }\n passingSince = result.at;\n passTimer = clock.after(wait, () =>\n step(\"window.recovered\", () => {\n passTimer = null;\n passingSince = null;\n set(false);\n }),\n );\n return;\n }\n stopPass();\n if (state || failingSince !== null) return;\n const wait = ms(timing.failAfter);\n if (wait <= 0) {\n stopFail();\n set(true);\n return;\n }\n failingSince = result.at;\n failTimer = clock.after(wait, () =>\n step(\"window.failed\", () => {\n failTimer = null;\n failingSince = null;\n set(true);\n }),\n );\n };\n\n return {\n get tripped() {\n return state;\n },\n get since() {\n return since;\n },\n get streak() {\n return streak;\n },\n record(result) {\n // an indeterminate poll measured nothing: it moves no sequence and no streak\n if (result.outcome === \"indeterminate\") return;\n const pass = result.outcome === \"ok\";\n step(pass ? \"poll.ok\" : \"poll.fail\", () => {\n streak = pass ? Math.max(0, streak) + 1 : Math.min(0, streak) - 1;\n debounce(result);\n windowed(result);\n });\n },\n stop() {\n stopFail();\n stopPass();\n },\n };\n};\n"],"mappings":";;AAkDA,MAAM,MAAM,WACV,QAAQ,QAAQ,IAAI;;;;;;;AAQtB,MAAa,SACX,QACA,OACA,SACA,SACA,UACU;CACV,IAAI,QAAQ;CACZ,IAAI,QAAQ,MAAM,IAAI;CACtB,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,IAAI,SAAS;CAEb,IAAI,eAA8B;CAClC,IAAI,eAA8B;CAClC,IAAI,YAA2B;CAC/B,IAAI,YAA2B;;CAI/B,MAAM,cACJ,QACI,iBAAiB,OACf,YACA,eACF,iBAAiB,OACf,aACA;;CAER,MAAM,QAAQ,IAAY,WAA6B;EACrD,MAAM,OAAO,MAAM;EACnB,OAAO;EACP,QAAQ,MAAM,MAAM,GAAG,EAAE;CAC3B;CAEA,MAAM,OAAO,SAAwB;EACnC,IAAI,SAAS,OAAO;EACpB,QAAQ;EACR,QAAQ,MAAM,IAAI;EAClB,QAAQ;CACV;CACA,MAAM,iBAAuB;EAC3B,YAAY;EACZ,YAAY;EACZ,eAAe;CACjB;CACA,MAAM,iBAAuB;EAC3B,YAAY;EACZ,YAAY;EACZ,eAAe;CACjB;CAEA,MAAM,YAAY,WAAyB;EACzC,IAAI,OAAO,SAAS,YAAY;EAChC,IAAI,OAAO,YAAY,MAAM;GAC3B,UAAU;GACV,QAAQ;GACR,IAAI,SAAS,UAAU,OAAO,cAAc,IAAI,KAAK;EACvD,OAAO;GACL,SAAS;GACT,SAAS;GACT,IAAI,CAAC,SAAS,SAAS,OAAO,WAAW,IAAI,IAAI;EACnD;CACF;CAEA,MAAM,YAAY,WAAyB;EACzC,IAAI,OAAO,SAAS,UAAU;EAC9B,IAAI,OAAO,YAAY,MAAM;GAC3B,SAAS;GACT,IAAI,CAAC,OAAO;GACZ,IAAI,OAAO,iBAAiB,KAAA,GAAW;IACrC,IAAI,KAAK;IACT;GACF;GACA,IAAI,iBAAiB,MAAM;GAC3B,MAAM,OAAO,GAAG,OAAO,YAAY;GACnC,IAAI,QAAQ,GAAG;IACb,SAAS;IACT,IAAI,KAAK;IACT;GACF;GACA,eAAe,OAAO;GACtB,YAAY,MAAM,MAAM,YACtB,KAAK,0BAA0B;IAC7B,YAAY;IACZ,eAAe;IACf,IAAI,KAAK;GACX,CAAC,CACH;GACA;EACF;EACA,SAAS;EACT,IAAI,SAAS,iBAAiB,MAAM;EACpC,MAAM,OAAO,GAAG,OAAO,SAAS;EAChC,IAAI,QAAQ,GAAG;GACb,SAAS;GACT,IAAI,IAAI;GACR;EACF;EACA,eAAe,OAAO;EACtB,YAAY,MAAM,MAAM,YACtB,KAAK,uBAAuB;GAC1B,YAAY;GACZ,eAAe;GACf,IAAI,IAAI;EACV,CAAC,CACH;CACF;CAEA,OAAO;EACL,IAAI,UAAU;GACZ,OAAO;EACT;EACA,IAAI,QAAQ;GACV,OAAO;EACT;EACA,IAAI,SAAS;GACX,OAAO;EACT;EACA,OAAO,QAAQ;GAEb,IAAI,OAAO,YAAY,iBAAiB;GACxC,MAAM,OAAO,OAAO,YAAY;GAChC,KAAK,OAAO,YAAY,mBAAmB;IACzC,SAAS,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;IAChE,SAAS,MAAM;IACf,SAAS,MAAM;GACjB,CAAC;EACH;EACA,OAAO;GACL,SAAS;GACT,SAAS;EACX;CACF;AACF"}
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
* with a margin. A binding maps `symbol@hop` to seconds, or to "inf" for a timer that is absent.
|
|
7
7
|
*/
|
|
8
8
|
/** A term is a coefficient times one symbol, at a hop when it has one. */
|
|
9
|
-
interface Term {
|
|
9
|
+
export interface Term {
|
|
10
10
|
readonly knob: string;
|
|
11
11
|
readonly coef: number;
|
|
12
12
|
readonly at?: string | undefined;
|
|
13
13
|
}
|
|
14
14
|
/** A side is a sum of terms, plus a constant. */
|
|
15
|
-
interface Side {
|
|
15
|
+
export interface Side {
|
|
16
16
|
readonly terms: readonly Term[];
|
|
17
17
|
readonly const?: number | undefined;
|
|
18
18
|
}
|
|
19
19
|
/** An inequality compares two sides, with a margin. */
|
|
20
|
-
interface Inequality {
|
|
20
|
+
export interface Inequality {
|
|
21
21
|
readonly lhs: Side;
|
|
22
22
|
readonly op: "<" | "<=" | ">" | ">=";
|
|
23
23
|
readonly rhs: Side;
|
|
@@ -25,7 +25,7 @@ interface Inequality {
|
|
|
25
25
|
readonly margin?: number | string | undefined;
|
|
26
26
|
}
|
|
27
27
|
/** A rule is one or more inequalities, with their statement in words. */
|
|
28
|
-
interface Rule {
|
|
28
|
+
export interface Rule {
|
|
29
29
|
readonly id: string;
|
|
30
30
|
/** This text is the rule in words. */
|
|
31
31
|
readonly rule: string;
|
|
@@ -35,49 +35,49 @@ interface Rule {
|
|
|
35
35
|
readonly expr_more?: readonly Inequality[] | undefined;
|
|
36
36
|
}
|
|
37
37
|
/** A bound is in seconds, or it is "inf" for an absent timer, or "off" for a disabled feature. The last two have no limit. */
|
|
38
|
-
type Bound = number | "inf" | "off";
|
|
38
|
+
export type Bound = number | "inf" | "off";
|
|
39
39
|
/**
|
|
40
40
|
* A binding maps `symbol@hop` to its bound. Its "margin" replaces the margin of each inequality.
|
|
41
41
|
* Its "margins" replace them one by one, in sequence, as the binding of a chain can.
|
|
42
42
|
*/
|
|
43
|
-
type Binding = Readonly<Record<string, Bound | readonly number[] | undefined>> & {
|
|
43
|
+
export type Binding = Readonly<Record<string, Bound | readonly number[] | undefined>> & {
|
|
44
44
|
readonly margin?: number | undefined;
|
|
45
45
|
readonly margins?: readonly number[] | undefined;
|
|
46
46
|
};
|
|
47
47
|
/** A verdict is "holds", "violated", "unbounded" (it holds only because a timer is absent) or "depends" (nothing is bound). */
|
|
48
|
-
type Verdict = "holds" | "violated" | "unbounded" | "depends";
|
|
48
|
+
export type Verdict = "holds" | "violated" | "unbounded" | "depends";
|
|
49
49
|
/** An evaluation is the value of each side of one inequality, its margin, and if it holds. */
|
|
50
|
-
interface Evaluated {
|
|
50
|
+
export interface Evaluated {
|
|
51
51
|
readonly lhs: number | null;
|
|
52
52
|
readonly rhs: number | null;
|
|
53
53
|
readonly margin: number;
|
|
54
54
|
readonly holds: boolean | null;
|
|
55
55
|
}
|
|
56
56
|
/** This function gives the inequalities of a rule: its expr, then the others. */
|
|
57
|
-
declare const inequalities: (rule: Rule) => readonly Inequality[];
|
|
57
|
+
export declare const inequalities: (rule: Rule) => readonly Inequality[];
|
|
58
58
|
/** This function gives the symbols that a rule reads, as `symbol@hop`. */
|
|
59
|
-
declare const symbolsOf: (rule: Rule) => string[];
|
|
59
|
+
export declare const symbolsOf: (rule: Rule) => string[];
|
|
60
60
|
/**
|
|
61
61
|
* This function evaluates each inequality on one binding. "<" holds when lhs + margin < rhs, and
|
|
62
62
|
* ">" holds when lhs > rhs + margin. Only the inequalities with all their symbols bound apply.
|
|
63
63
|
* The others are null. Absent timers can leave no order: the same infinity on each side, or both
|
|
64
64
|
* signs of infinity on one side. Then the inequality holds only because a timer is absent.
|
|
65
65
|
*/
|
|
66
|
-
declare const evaluate: (rule: Rule, bind: Binding) => Evaluated[];
|
|
66
|
+
export declare const evaluate: (rule: Rule, bind: Binding) => Evaluated[];
|
|
67
67
|
/**
|
|
68
68
|
* This function gives the verdict of an evaluation. When an applicable inequality fails, the
|
|
69
69
|
* verdict is "violated". When all hold only because a timer is absent, the verdict is "unbounded",
|
|
70
70
|
* because nothing then limits the window. Otherwise the verdict is "holds". When no inequality
|
|
71
71
|
* applies, the arithmetic cannot decide, and the verdict is "depends".
|
|
72
72
|
*/
|
|
73
|
-
declare const verdictOf: (rule: Rule, bind: Binding, evaluated: readonly Evaluated[]) => Verdict;
|
|
73
|
+
export declare const verdictOf: (rule: Rule, bind: Binding, evaluated: readonly Evaluated[]) => Verdict;
|
|
74
74
|
/**
|
|
75
75
|
* A mark tells how a timer moves when a compression scales time by k (E10). A "scalable" timer
|
|
76
76
|
* becomes k times its value. A "fixed" timer keeps its value. A "stepped" timer takes only
|
|
77
77
|
* multiples of its step, thus it rounds up. A "floored" timer has a floor that a peer sets, for
|
|
78
78
|
* example the minimum retransmission timeout of the kernel. The step and the floor are in seconds.
|
|
79
79
|
*/
|
|
80
|
-
type TimerMark = {
|
|
80
|
+
export type TimerMark = {
|
|
81
81
|
readonly kind: "scalable";
|
|
82
82
|
} | {
|
|
83
83
|
readonly kind: "fixed";
|
|
@@ -90,21 +90,21 @@ type TimerMark = {
|
|
|
90
90
|
readonly by: string;
|
|
91
91
|
};
|
|
92
92
|
/** The marks map `symbol@hop` to a mark. A bare symbol marks the symbol at each hop. */
|
|
93
|
-
type TimerMarks = Readonly<Record<string, TimerMark | undefined>>;
|
|
93
|
+
export type TimerMarks = Readonly<Record<string, TimerMark | undefined>>;
|
|
94
94
|
/** A compressed binding, and the symbols that have no mark. */
|
|
95
|
-
interface Compressed {
|
|
95
|
+
export interface Compressed {
|
|
96
96
|
readonly bind: Binding;
|
|
97
97
|
/** These symbols have no mark. They keep their values, thus the compression proves nothing about them. */
|
|
98
98
|
readonly unmarked: readonly string[];
|
|
99
99
|
}
|
|
100
100
|
/** A change is a rule whose verdict a compression changes. */
|
|
101
|
-
interface Change {
|
|
101
|
+
export interface Change {
|
|
102
102
|
readonly rule: string;
|
|
103
103
|
readonly before: Verdict;
|
|
104
104
|
readonly after: Verdict;
|
|
105
105
|
}
|
|
106
106
|
/** The result of a compression: the rules whose verdict it changes, and the symbols of the rules that have no mark. */
|
|
107
|
-
interface Compression {
|
|
107
|
+
export interface Compression {
|
|
108
108
|
readonly changed: readonly Change[];
|
|
109
109
|
readonly unmarked: readonly string[];
|
|
110
110
|
}
|
|
@@ -113,28 +113,10 @@ interface Compression {
|
|
|
113
113
|
* "off") stays absent. A chain scales each value. The margins of the binding and the constants of
|
|
114
114
|
* the rules do not scale: they are tolerances, not timers. A symbol with no mark keeps its value.
|
|
115
115
|
*/
|
|
116
|
-
declare const compress: (bind: Binding, k: number, marks: TimerMarks) => Compressed;
|
|
116
|
+
export declare const compress: (bind: Binding, k: number, marks: TimerMarks) => Compressed;
|
|
117
117
|
/**
|
|
118
118
|
* This function tells which rules a compression by k changes. A compression keeps each ordering
|
|
119
119
|
* when no verdict changes. A change in either direction counts: a violation that the compression
|
|
120
120
|
* hides is as wrong as one that it makes. The unmarked symbols are the symbols that the rules read.
|
|
121
121
|
*/
|
|
122
|
-
declare const compression: (rules: readonly Rule[], bind: Binding, k: number, marks: TimerMarks) => Compression;
|
|
123
|
-
/**
|
|
124
|
-
* O04 with the hold of the service. The listener of a pod stays open through the preStop sleep and
|
|
125
|
-
* then through the hold of `fail readiness`. Thus the sum of the two must cover the propagation of
|
|
126
|
-
* the endpoints. The rule of the research is the case without a hold.
|
|
127
|
-
*/
|
|
128
|
-
declare const O04: Rule;
|
|
129
|
-
/** O09 is W8: readiness detection plus propagation is no longer than liveness detection plus the preStop sleep. */
|
|
130
|
-
declare const O09: Rule;
|
|
131
|
-
/** O10: the preStop sleep plus the drain of the process fits in the grace period. */
|
|
132
|
-
declare const O10: Rule;
|
|
133
|
-
/** O16: the cooperative window is shorter than the drain, which is shorter than the grace less the preStop sleep. */
|
|
134
|
-
declare const O16: Rule;
|
|
135
|
-
/**
|
|
136
|
-
* These are the rules of the drain. For each way that a pod stops, `lintStop()` applies only the
|
|
137
|
-
* rules of this set that guard that way. `DRAIN_RULE_IDS` gives their identifiers.
|
|
138
|
-
*/
|
|
139
|
-
declare const DRAIN_RULES: readonly Rule[];
|
|
140
|
-
export { symbolsOf as C, inequalities as S, TimerMarks as _, O16 as a, compression as b, Change as c, Evaluated as d, Inequality as f, TimerMark as g, Term as h, O10 as i, Compressed as l, Side as m, O04 as n, Binding as o, Rule as p, O09 as r, Bound as s, DRAIN_RULES as t, Compression as u, Verdict as v, verdictOf as w, evaluate as x, compress as y };
|
|
122
|
+
export declare const compression: (rules: readonly Rule[], bind: Binding, k: number, marks: TimerMarks) => Compression;
|
package/build/law.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// src/law.ts
|
|
2
|
+
const value = (bound) => bound === "inf" || bound === "off" ? Infinity : Number(bound);
|
|
3
|
+
const keyOf = (term) => term.at !== void 0 ? `${term.knob}@${term.at}` : term.knob;
|
|
4
|
+
/** This function gives the bound of a symbol, or undefined when the symbol has no bound. */
|
|
5
|
+
const boundOf = (bind, key) => {
|
|
6
|
+
const bound = bind[key];
|
|
7
|
+
return typeof bound === "number" || bound === "inf" || bound === "off" ? bound : void 0;
|
|
8
|
+
};
|
|
9
|
+
/** This function gives the inequalities of a rule: its expr, then the others. */
|
|
10
|
+
const inequalities = (rule) => [rule.expr, ...rule.expr_more ?? []];
|
|
11
|
+
/** This function gives the symbols that a rule reads, as `symbol@hop`. */
|
|
12
|
+
const symbolsOf = (rule) => {
|
|
13
|
+
const out = [];
|
|
14
|
+
for (const inequality of inequalities(rule)) for (const term of [...inequality.lhs.terms, ...inequality.rhs.terms]) {
|
|
15
|
+
const key = keyOf(term);
|
|
16
|
+
if (!out.includes(key)) out.push(key);
|
|
17
|
+
}
|
|
18
|
+
return out;
|
|
19
|
+
};
|
|
20
|
+
/** This function gives the value of a side, Σ coef × symbol + const, or null when a symbol has no bound. */
|
|
21
|
+
const sideOf = (side, bind) => {
|
|
22
|
+
let total = side.const ?? 0;
|
|
23
|
+
for (const term of side.terms) {
|
|
24
|
+
const bound = boundOf(bind, keyOf(term));
|
|
25
|
+
if (bound === void 0) return null;
|
|
26
|
+
total += term.coef * value(bound);
|
|
27
|
+
}
|
|
28
|
+
return total;
|
|
29
|
+
};
|
|
30
|
+
/** This function gives the margin of an inequality: from the binding (one for all, or one each), else from the rule, else 0. */
|
|
31
|
+
const marginOf = (inequality, index, bind) => {
|
|
32
|
+
if (Array.isArray(bind.margins)) return Number(bind.margins[index] ?? 0);
|
|
33
|
+
if (typeof bind.margin === "number") return bind.margin;
|
|
34
|
+
return typeof inequality.margin === "number" ? inequality.margin : 0;
|
|
35
|
+
};
|
|
36
|
+
/** This function tells if an inequality reads a symbol with no limit: "inf", "off" or an infinite number. */
|
|
37
|
+
const readsAbsent = (inequality, bind) => [...inequality.lhs.terms, ...inequality.rhs.terms].some((term) => {
|
|
38
|
+
const bound = boundOf(bind, keyOf(term));
|
|
39
|
+
return bound !== void 0 && value(bound) === Infinity;
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* This function evaluates each inequality on one binding. "<" holds when lhs + margin < rhs, and
|
|
43
|
+
* ">" holds when lhs > rhs + margin. Only the inequalities with all their symbols bound apply.
|
|
44
|
+
* The others are null. Absent timers can leave no order: the same infinity on each side, or both
|
|
45
|
+
* signs of infinity on one side. Then the inequality holds only because a timer is absent.
|
|
46
|
+
*/
|
|
47
|
+
const evaluate = (rule, bind) => inequalities(rule).map((inequality, index) => {
|
|
48
|
+
const lhs = sideOf(inequality.lhs, bind);
|
|
49
|
+
const rhs = sideOf(inequality.rhs, bind);
|
|
50
|
+
const margin = marginOf(inequality, index, bind);
|
|
51
|
+
if (lhs === null || rhs === null) return {
|
|
52
|
+
lhs,
|
|
53
|
+
rhs,
|
|
54
|
+
margin,
|
|
55
|
+
holds: null
|
|
56
|
+
};
|
|
57
|
+
if ((Number.isNaN(lhs) || Number.isNaN(rhs) || lhs === rhs && !Number.isFinite(lhs)) && readsAbsent(inequality, bind)) return {
|
|
58
|
+
lhs,
|
|
59
|
+
rhs,
|
|
60
|
+
margin,
|
|
61
|
+
holds: true
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
lhs,
|
|
65
|
+
rhs,
|
|
66
|
+
margin,
|
|
67
|
+
holds: inequality.op === "<" ? lhs + margin < rhs : inequality.op === "<=" ? lhs + margin <= rhs : inequality.op === ">" ? lhs > rhs + margin : lhs >= rhs + margin
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* This function gives the verdict of an evaluation. When an applicable inequality fails, the
|
|
72
|
+
* verdict is "violated". When all hold only because a timer is absent, the verdict is "unbounded",
|
|
73
|
+
* because nothing then limits the window. Otherwise the verdict is "holds". When no inequality
|
|
74
|
+
* applies, the arithmetic cannot decide, and the verdict is "depends".
|
|
75
|
+
*/
|
|
76
|
+
const verdictOf = (rule, bind, evaluated) => {
|
|
77
|
+
const applicable = evaluated.flatMap((entry, index) => entry.holds === null ? [] : [index]);
|
|
78
|
+
if (applicable.length === 0) return "depends";
|
|
79
|
+
if (applicable.some((index) => evaluated[index]?.holds === false)) return "violated";
|
|
80
|
+
const all = inequalities(rule);
|
|
81
|
+
return applicable.some((index) => readsAbsent(all[index], bind)) ? "unbounded" : "holds";
|
|
82
|
+
};
|
|
83
|
+
/** This function gives the mark of a symbol: its mark at its hop, else the mark of the bare symbol. */
|
|
84
|
+
const markOf = (marks, key) => marks[key] ?? marks[key.split("@")[0] ?? key];
|
|
85
|
+
const STEP_EPSILON = 1e-9;
|
|
86
|
+
const scaled = (seconds, k, mark) => {
|
|
87
|
+
switch (mark.kind) {
|
|
88
|
+
case "scalable": return seconds * k;
|
|
89
|
+
case "fixed": return seconds;
|
|
90
|
+
case "stepped": return Math.max(Math.ceil(seconds * k / mark.step - STEP_EPSILON), 0) * mark.step;
|
|
91
|
+
case "floored": return Math.max(seconds * k, mark.floor);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* This function scales each timer of a binding by k, by its mark (E10). An absent timer ("inf" or
|
|
96
|
+
* "off") stays absent. A chain scales each value. The margins of the binding and the constants of
|
|
97
|
+
* the rules do not scale: they are tolerances, not timers. A symbol with no mark keeps its value.
|
|
98
|
+
*/
|
|
99
|
+
const compress = (bind, k, marks) => {
|
|
100
|
+
if (!Number.isFinite(k) || k <= 0) throw new RangeError(`a compression scales time by a finite factor above 0, not ${k}`);
|
|
101
|
+
const out = {};
|
|
102
|
+
const unmarked = [];
|
|
103
|
+
for (const [key, bound] of Object.entries(bind)) {
|
|
104
|
+
if (key === "margin" || key === "margins") continue;
|
|
105
|
+
const mark = markOf(marks, key);
|
|
106
|
+
if (mark === void 0) {
|
|
107
|
+
if (bound !== void 0) unmarked.push(key);
|
|
108
|
+
out[key] = bound;
|
|
109
|
+
} else if (typeof bound === "number") out[key] = scaled(bound, k, mark);
|
|
110
|
+
else if (Array.isArray(bound)) out[key] = bound.map((seconds) => scaled(seconds, k, mark));
|
|
111
|
+
else out[key] = bound;
|
|
112
|
+
}
|
|
113
|
+
const margins = {
|
|
114
|
+
...bind.margin !== void 0 ? { margin: bind.margin } : {},
|
|
115
|
+
...bind.margins !== void 0 ? { margins: bind.margins } : {}
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
bind: {
|
|
119
|
+
...out,
|
|
120
|
+
...margins
|
|
121
|
+
},
|
|
122
|
+
unmarked
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* This function tells which rules a compression by k changes. A compression keeps each ordering
|
|
127
|
+
* when no verdict changes. A change in either direction counts: a violation that the compression
|
|
128
|
+
* hides is as wrong as one that it makes. The unmarked symbols are the symbols that the rules read.
|
|
129
|
+
*/
|
|
130
|
+
const compression = (rules, bind, k, marks) => {
|
|
131
|
+
const compressed = compress(bind, k, marks);
|
|
132
|
+
const changed = rules.flatMap((rule) => {
|
|
133
|
+
const before = verdictOf(rule, bind, evaluate(rule, bind));
|
|
134
|
+
const after = verdictOf(rule, compressed.bind, evaluate(rule, compressed.bind));
|
|
135
|
+
return before === after ? [] : [{
|
|
136
|
+
rule: rule.id,
|
|
137
|
+
before,
|
|
138
|
+
after
|
|
139
|
+
}];
|
|
140
|
+
});
|
|
141
|
+
const read = new Set(rules.flatMap(symbolsOf));
|
|
142
|
+
return {
|
|
143
|
+
changed,
|
|
144
|
+
unmarked: compressed.unmarked.filter((symbol) => read.has(symbol))
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export { compress, compression, evaluate, inequalities, symbolsOf, verdictOf };
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=law.js.map
|
package/build/law.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"law.js","names":[],"sources":["../src/law.ts"],"sourcesContent":["/**\n * This module is the evaluator of the timer-ordering law. Its decisions are the same as the\n * decisions of the research evaluator, except when absent timers leave no order (`evaluate`). The\n * rules are data, and the caller gives them. Each rule\n * is one or more linear inequalities over symbols at a hop (`readiness_detection_window@pod`),\n * with a margin. A binding maps `symbol@hop` to seconds, or to \"inf\" for a timer that is absent.\n */\n\n/** A term is a coefficient times one symbol, at a hop when it has one. */\nexport interface Term {\n readonly knob: string;\n readonly coef: number;\n readonly at?: string | undefined;\n}\n\n/** A side is a sum of terms, plus a constant. */\nexport interface Side {\n readonly terms: readonly Term[];\n readonly const?: number | undefined;\n}\n\n/** An inequality compares two sides, with a margin. */\nexport interface Inequality {\n readonly lhs: Side;\n readonly op: \"<\" | \"<=\" | \">\" | \">=\";\n readonly rhs: Side;\n /** The margin is in seconds, or it is words for a margin that no binding gives (\"a factor of several\"). Words count as 0. */\n readonly margin?: number | string | undefined;\n}\n\n/** A rule is one or more inequalities, with their statement in words. */\nexport interface Rule {\n readonly id: string;\n /** This text is the rule in words. */\n readonly rule: string;\n /** This text is the window that a violation opens. */\n readonly window?: string | undefined;\n readonly expr: Inequality;\n readonly expr_more?: readonly Inequality[] | undefined;\n}\n\n/** A bound is in seconds, or it is \"inf\" for an absent timer, or \"off\" for a disabled feature. The last two have no limit. */\nexport type Bound = number | \"inf\" | \"off\";\n\n/**\n * A binding maps `symbol@hop` to its bound. Its \"margin\" replaces the margin of each inequality.\n * Its \"margins\" replace them one by one, in sequence, as the binding of a chain can.\n */\nexport type Binding = Readonly<Record<string, Bound | readonly number[] | undefined>> & {\n readonly margin?: number | undefined;\n readonly margins?: readonly number[] | undefined;\n};\n\n/** A verdict is \"holds\", \"violated\", \"unbounded\" (it holds only because a timer is absent) or \"depends\" (nothing is bound). */\nexport type Verdict = \"holds\" | \"violated\" | \"unbounded\" | \"depends\";\n\n/** An evaluation is the value of each side of one inequality, its margin, and if it holds. */\nexport interface Evaluated {\n readonly lhs: number | null;\n readonly rhs: number | null;\n readonly margin: number;\n readonly holds: boolean | null;\n}\n\nconst value = (bound: Bound): number =>\n bound === \"inf\" || bound === \"off\" ? Infinity : Number(bound);\nconst keyOf = (term: Term): string =>\n term.at !== undefined ? `${term.knob}@${term.at}` : term.knob;\n/** This function gives the bound of a symbol, or undefined when the symbol has no bound. */\nconst boundOf = (bind: Binding, key: string): Bound | undefined => {\n const bound = bind[key];\n return typeof bound === \"number\" || bound === \"inf\" || bound === \"off\" ? bound : undefined;\n};\n\n/** This function gives the inequalities of a rule: its expr, then the others. */\nexport const inequalities = (rule: Rule): readonly Inequality[] => [\n rule.expr,\n ...(rule.expr_more ?? []),\n];\n\n/** This function gives the symbols that a rule reads, as `symbol@hop`. */\nexport const symbolsOf = (rule: Rule): string[] => {\n const out: string[] = [];\n for (const inequality of inequalities(rule)) {\n for (const term of [...inequality.lhs.terms, ...inequality.rhs.terms]) {\n const key = keyOf(term);\n if (!out.includes(key)) out.push(key);\n }\n }\n return out;\n};\n\n/** This function gives the value of a side, Σ coef × symbol + const, or null when a symbol has no bound. */\nconst sideOf = (side: Side, bind: Binding): number | null => {\n let total = side.const ?? 0;\n for (const term of side.terms) {\n const bound = boundOf(bind, keyOf(term));\n if (bound === undefined) return null;\n total += term.coef * value(bound);\n }\n return total;\n};\n\n/** This function gives the margin of an inequality: from the binding (one for all, or one each), else from the rule, else 0. */\nconst marginOf = (inequality: Inequality, index: number, bind: Binding): number => {\n if (Array.isArray(bind.margins)) return Number(bind.margins[index] ?? 0);\n if (typeof bind.margin === \"number\") return bind.margin;\n return typeof inequality.margin === \"number\" ? inequality.margin : 0;\n};\n\n/** This function tells if an inequality reads a symbol with no limit: \"inf\", \"off\" or an infinite number. */\nconst readsAbsent = (inequality: Inequality, bind: Binding): boolean =>\n [...inequality.lhs.terms, ...inequality.rhs.terms].some((term) => {\n const bound = boundOf(bind, keyOf(term));\n return bound !== undefined && value(bound) === Infinity;\n });\n\n/**\n * This function evaluates each inequality on one binding. \"<\" holds when lhs + margin < rhs, and\n * \">\" holds when lhs > rhs + margin. Only the inequalities with all their symbols bound apply.\n * The others are null. Absent timers can leave no order: the same infinity on each side, or both\n * signs of infinity on one side. Then the inequality holds only because a timer is absent.\n */\nexport const evaluate = (rule: Rule, bind: Binding): Evaluated[] =>\n inequalities(rule).map((inequality, index) => {\n const lhs = sideOf(inequality.lhs, bind);\n const rhs = sideOf(inequality.rhs, bind);\n const margin = marginOf(inequality, index, bind);\n if (lhs === null || rhs === null) return { lhs, rhs, margin, holds: null };\n const unordered = Number.isNaN(lhs) || Number.isNaN(rhs) || (lhs === rhs && !Number.isFinite(lhs));\n if (unordered && readsAbsent(inequality, bind)) return { lhs, rhs, margin, holds: true };\n const holds =\n inequality.op === \"<\"\n ? lhs + margin < rhs\n : inequality.op === \"<=\"\n ? lhs + margin <= rhs\n : inequality.op === \">\"\n ? lhs > rhs + margin\n : lhs >= rhs + margin;\n return { lhs, rhs, margin, holds };\n });\n\n/**\n * This function gives the verdict of an evaluation. When an applicable inequality fails, the\n * verdict is \"violated\". When all hold only because a timer is absent, the verdict is \"unbounded\",\n * because nothing then limits the window. Otherwise the verdict is \"holds\". When no inequality\n * applies, the arithmetic cannot decide, and the verdict is \"depends\".\n */\nexport const verdictOf = (rule: Rule, bind: Binding, evaluated: readonly Evaluated[]): Verdict => {\n const applicable = evaluated.flatMap((entry, index) => (entry.holds === null ? [] : [index]));\n if (applicable.length === 0) return \"depends\";\n if (applicable.some((index) => evaluated[index]?.holds === false)) return \"violated\";\n const all = inequalities(rule);\n const infinite = applicable.some((index) => readsAbsent(all[index]!, bind));\n return infinite ? \"unbounded\" : \"holds\";\n};\n\n/**\n * A mark tells how a timer moves when a compression scales time by k (E10). A \"scalable\" timer\n * becomes k times its value. A \"fixed\" timer keeps its value. A \"stepped\" timer takes only\n * multiples of its step, thus it rounds up. A \"floored\" timer has a floor that a peer sets, for\n * example the minimum retransmission timeout of the kernel. The step and the floor are in seconds.\n */\nexport type TimerMark =\n | { readonly kind: \"scalable\" }\n | { readonly kind: \"fixed\" }\n | { readonly kind: \"stepped\"; readonly step: number }\n | { readonly kind: \"floored\"; readonly floor: number; readonly by: string };\n\n/** The marks map `symbol@hop` to a mark. A bare symbol marks the symbol at each hop. */\nexport type TimerMarks = Readonly<Record<string, TimerMark | undefined>>;\n\n/** A compressed binding, and the symbols that have no mark. */\nexport interface Compressed {\n readonly bind: Binding;\n /** These symbols have no mark. They keep their values, thus the compression proves nothing about them. */\n readonly unmarked: readonly string[];\n}\n\n/** A change is a rule whose verdict a compression changes. */\nexport interface Change {\n readonly rule: string;\n readonly before: Verdict;\n readonly after: Verdict;\n}\n\n/** The result of a compression: the rules whose verdict it changes, and the symbols of the rules that have no mark. */\nexport interface Compression {\n readonly changed: readonly Change[];\n readonly unmarked: readonly string[];\n}\n\n/** This function gives the mark of a symbol: its mark at its hop, else the mark of the bare symbol. */\nconst markOf = (marks: TimerMarks, key: string): TimerMark | undefined =>\n marks[key] ?? marks[key.split(\"@\")[0] ?? key];\n\n// a step absorbs the error of the float product, thus 0.3 s at k = 10 stays 3 s with a step of 1 s\nconst STEP_EPSILON = 1e-9;\n\nconst scaled = (seconds: number, k: number, mark: TimerMark): number => {\n switch (mark.kind) {\n case \"scalable\":\n return seconds * k;\n case \"fixed\":\n return seconds;\n case \"stepped\":\n // Math.max keeps 0 s at 0 s, not at -0\n return Math.max(Math.ceil((seconds * k) / mark.step - STEP_EPSILON), 0) * mark.step;\n case \"floored\":\n return Math.max(seconds * k, mark.floor);\n }\n};\n\n/**\n * This function scales each timer of a binding by k, by its mark (E10). An absent timer (\"inf\" or\n * \"off\") stays absent. A chain scales each value. The margins of the binding and the constants of\n * the rules do not scale: they are tolerances, not timers. A symbol with no mark keeps its value.\n */\nexport const compress = (bind: Binding, k: number, marks: TimerMarks): Compressed => {\n if (!Number.isFinite(k) || k <= 0) throw new RangeError(`a compression scales time by a finite factor above 0, not ${k}`);\n const out: Record<string, Bound | readonly number[] | undefined> = {};\n const unmarked: string[] = [];\n for (const [key, bound] of Object.entries(bind)) {\n if (key === \"margin\" || key === \"margins\") continue;\n const mark = markOf(marks, key);\n if (mark === undefined) {\n if (bound !== undefined) unmarked.push(key);\n out[key] = bound;\n } else if (typeof bound === \"number\") out[key] = scaled(bound, k, mark);\n else if (Array.isArray(bound)) out[key] = bound.map((seconds) => scaled(seconds, k, mark));\n else out[key] = bound;\n }\n const margins = {\n ...(bind.margin !== undefined ? { margin: bind.margin } : {}),\n ...(bind.margins !== undefined ? { margins: bind.margins } : {}),\n };\n return { bind: { ...out, ...margins }, unmarked };\n};\n\n/**\n * This function tells which rules a compression by k changes. A compression keeps each ordering\n * when no verdict changes. A change in either direction counts: a violation that the compression\n * hides is as wrong as one that it makes. The unmarked symbols are the symbols that the rules read.\n */\nexport const compression = (rules: readonly Rule[], bind: Binding, k: number, marks: TimerMarks): Compression => {\n const compressed = compress(bind, k, marks);\n const changed = rules.flatMap((rule): Change[] => {\n const before = verdictOf(rule, bind, evaluate(rule, bind));\n const after = verdictOf(rule, compressed.bind, evaluate(rule, compressed.bind));\n return before === after ? [] : [{ rule: rule.id, before, after }];\n });\n const read = new Set(rules.flatMap(symbolsOf));\n return { changed, unmarked: compressed.unmarked.filter((symbol) => read.has(symbol)) };\n};\n"],"mappings":"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"}
|