@cotal-ai/delivery 0.141.4 → 0.141.5
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/dist/watchdog.d.ts +9 -37
- package/dist/watchdog.d.ts.map +1 -1
- package/dist/watchdog.js +11 -54
- package/dist/watchdog.js.map +1 -1
- package/package.json +3 -3
package/dist/watchdog.d.ts
CHANGED
|
@@ -92,46 +92,18 @@ export declare class LoopLagMeter {
|
|
|
92
92
|
* measurement of the local scheduler, never of the broker - a timer we own fired late, which says
|
|
93
93
|
* the runqueue did not reach us and says nothing at all about the server.
|
|
94
94
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* which. Neither method deduplicates, deliberately, because suppressing a charge on the guess
|
|
98
|
-
* that it overlaps discards real stalls. The sum is bounded instead, at the point of comparison,
|
|
99
|
-
* by {@link starvedMsWithin}. */
|
|
95
|
+
* This timer is the only source of lag charges. {@link starvedMsWithin} bounds the accumulated
|
|
96
|
+
* wall-clock union to the span the transport-health consumer compares it against. */
|
|
100
97
|
tick(now: number): number;
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* perfectly live server. Clamped at zero for the same reason `tick` is: a measurement that ran
|
|
106
|
-
* backwards must never credit time the process actually had. */
|
|
107
|
-
credit(lagMs: number, endedAt?: number): void;
|
|
108
|
-
/** Charge [from, to] as time this process was not running, UNIONED with what is already charged.
|
|
109
|
-
*
|
|
110
|
-
* This is the double-count repair, and it is why both call sites can stay. A stall observed by
|
|
111
|
-
* the interval timer and by a probe answering across it is ONE interval of wall-clock time seen
|
|
112
|
-
* by two instruments. Summing scalars charges it twice (measured: 17s for a 10s stall). Summing
|
|
113
|
-
* INTERVALS cannot, because the union of overlapping intervals is their extent.
|
|
114
|
-
*
|
|
115
|
-
* It also keeps what netting threw away. Two ADJACENT stalls (a timer late by one, a probe from
|
|
116
|
-
* the previous tick late by another) do not overlap, so the union is their sum and both are
|
|
117
|
-
* charged in full. Overlap is decided by the timestamps rather than guessed from the magnitudes,
|
|
118
|
-
* which is the thing neither scalar arithmetic nor a span clamp can do. */
|
|
98
|
+
/** Charge the union of measured wall-clock intervals. Tick charges are disjoint while the clock
|
|
99
|
+
* advances, but a backward step can make later charges overlap earlier ones. The consumer's
|
|
100
|
+
* elapsed time also loses that step; summing those charges would subtract overlapping wall time
|
|
101
|
+
* twice and postpone its broker-loss verdict. Disjoint stalls still accumulate in full. */
|
|
119
102
|
private chargeSpan;
|
|
120
|
-
/** Accumulated lag
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* arithmetic alone: whether a tick charge and a probe charge describe the same stall or two
|
|
124
|
-
* adjacent ones is not knowable from the two numbers. What IS knowable is that time the process
|
|
125
|
-
* did not have can never exceed time that passed. Overlap is removed by that bound and nothing
|
|
126
|
-
* else is discarded, so the sum stays as informative as its parts allow.
|
|
127
|
-
*
|
|
128
|
-
* Load-bearing, not hygiene: `DeliveryTransportHealth` SUBTRACTS this from elapsed time.
|
|
129
|
-
* Unclamped, a stall charged twice drives unstarved time negative, and NO amount of real outage
|
|
130
|
-
* can then clear the evidence clause - a genuinely dead broker stops being detectable by evidence
|
|
131
|
-
* and survives to the backstop instead. Measured: a 30s stall moved an exit from 44s to 62s. */
|
|
103
|
+
/** Accumulated lag bounded by a nonnegative comparison span. `DeliveryTransportHealth` subtracts
|
|
104
|
+
* it from elapsed time, which must not become negative when a clock adjustment or a tick spanning
|
|
105
|
+
* a reset makes the accumulated lag larger than that span. */
|
|
132
106
|
starvedMsWithin(spanMs: number): number;
|
|
133
|
-
/** Lag accumulated since the last {@link reset}. */
|
|
134
|
-
get starvedMs(): number;
|
|
135
107
|
/** Called when positive evidence arrives: the window restarts, so its lag budget does too. The
|
|
136
108
|
* firing baseline is deliberately KEPT, so a stall spanning a reset is still measured. */
|
|
137
109
|
reset(): void;
|
package/dist/watchdog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchdog.d.ts","sourceRoot":"","sources":["../src/watchdog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAa9D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAIzD;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAY;IAMX,OAAO,CAAC,QAAQ,CAAC,UAAU;IALvC,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,WAAW,CAAK;IACxB;yFACqF;IACrF,OAAO,CAAC,KAAK,CAA+B;gBACf,UAAU,EAAE,MAAM;IAE/C
|
|
1
|
+
{"version":3,"file":"watchdog.d.ts","sourceRoot":"","sources":["../src/watchdog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAa9D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAIzD;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAY;IAMX,OAAO,CAAC,QAAQ,CAAC,UAAU;IALvC,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,WAAW,CAAK;IACxB;yFACqF;IACrF,OAAO,CAAC,KAAK,CAA+B;gBACf,UAAU,EAAE,MAAM;IAE/C;;;;;;;;0FAQsF;IACtF,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAUzB;;;gGAG4F;IAC5F,OAAO,CAAC,UAAU;IAclB;;mEAE+D;IAC/D,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIvC;+FAC2F;IAC3F,KAAK,IAAI,IAAI;CAId"}
|
package/dist/watchdog.js
CHANGED
|
@@ -93,51 +93,22 @@ export class LoopLagMeter {
|
|
|
93
93
|
* measurement of the local scheduler, never of the broker - a timer we own fired late, which says
|
|
94
94
|
* the runqueue did not reach us and says nothing at all about the server.
|
|
95
95
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* which. Neither method deduplicates, deliberately, because suppressing a charge on the guess
|
|
99
|
-
* that it overlaps discards real stalls. The sum is bounded instead, at the point of comparison,
|
|
100
|
-
* by {@link starvedMsWithin}. */
|
|
96
|
+
* This timer is the only source of lag charges. {@link starvedMsWithin} bounds the accumulated
|
|
97
|
+
* wall-clock union to the span the transport-health consumer compares it against. */
|
|
101
98
|
tick(now) {
|
|
102
99
|
const previous = this.last;
|
|
103
100
|
this.last = now;
|
|
104
101
|
if (previous === undefined)
|
|
105
102
|
return 0; // first firing has no gap to measure
|
|
106
103
|
const lag = Math.max(0, now - previous - this.intervalMs);
|
|
107
|
-
//
|
|
108
|
-
// occupied [now - lag, now]. Recording WHEN lets an overlapping probe charge be unioned with it
|
|
109
|
-
// instead of added to it, which is the whole of the double-count repair.
|
|
104
|
+
// The dated interval stays on the same wall-clock timeline as the consumer's elapsed time.
|
|
110
105
|
this.chargeSpan(now - lag, now);
|
|
111
106
|
return lag;
|
|
112
107
|
}
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* perfectly live server. Clamped at zero for the same reason `tick` is: a measurement that ran
|
|
118
|
-
* backwards must never credit time the process actually had. */
|
|
119
|
-
credit(lagMs, endedAt = Date.now()) {
|
|
120
|
-
// BOTH MEASUREMENTS ARE KEPT. An earlier repair here netted this against the most recent interval
|
|
121
|
-
// gap, on the theory that the two always observe ONE stall. They do not, and a reviewer produced
|
|
122
|
-
// the separating case: over a 4000ms span a timer can fire 2000ms late (a stall happening NOW)
|
|
123
|
-
// while a probe issued at the PREVIOUS tick answers 2500ms late (the stall before it). Netting
|
|
124
|
-
// credited 2500ms there and threw away a 2000ms stall the process had actually measured - which
|
|
125
|
-
// is the very mechanism this method exists for, a process scheduled often enough to fire a timer
|
|
126
|
-
// but not to finish a handshake. I measured my own netting against that case and it produced the
|
|
127
|
-
// lossy answer, so it is gone.
|
|
128
|
-
this.chargeSpan(endedAt - Math.max(0, lagMs), endedAt);
|
|
129
|
-
}
|
|
130
|
-
/** Charge [from, to] as time this process was not running, UNIONED with what is already charged.
|
|
131
|
-
*
|
|
132
|
-
* This is the double-count repair, and it is why both call sites can stay. A stall observed by
|
|
133
|
-
* the interval timer and by a probe answering across it is ONE interval of wall-clock time seen
|
|
134
|
-
* by two instruments. Summing scalars charges it twice (measured: 17s for a 10s stall). Summing
|
|
135
|
-
* INTERVALS cannot, because the union of overlapping intervals is their extent.
|
|
136
|
-
*
|
|
137
|
-
* It also keeps what netting threw away. Two ADJACENT stalls (a timer late by one, a probe from
|
|
138
|
-
* the previous tick late by another) do not overlap, so the union is their sum and both are
|
|
139
|
-
* charged in full. Overlap is decided by the timestamps rather than guessed from the magnitudes,
|
|
140
|
-
* which is the thing neither scalar arithmetic nor a span clamp can do. */
|
|
108
|
+
/** Charge the union of measured wall-clock intervals. Tick charges are disjoint while the clock
|
|
109
|
+
* advances, but a backward step can make later charges overlap earlier ones. The consumer's
|
|
110
|
+
* elapsed time also loses that step; summing those charges would subtract overlapping wall time
|
|
111
|
+
* twice and postpone its broker-loss verdict. Disjoint stalls still accumulate in full. */
|
|
141
112
|
chargeSpan(from, to) {
|
|
142
113
|
if (!(to > from))
|
|
143
114
|
return; // zero or backwards: never credits time we had
|
|
@@ -156,31 +127,17 @@ export class LoopLagMeter {
|
|
|
156
127
|
this.spans = merged;
|
|
157
128
|
this.accumulated = merged.reduce((n, [s, e]) => n + (e - s), 0);
|
|
158
129
|
}
|
|
159
|
-
/** Accumulated lag
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* arithmetic alone: whether a tick charge and a probe charge describe the same stall or two
|
|
163
|
-
* adjacent ones is not knowable from the two numbers. What IS knowable is that time the process
|
|
164
|
-
* did not have can never exceed time that passed. Overlap is removed by that bound and nothing
|
|
165
|
-
* else is discarded, so the sum stays as informative as its parts allow.
|
|
166
|
-
*
|
|
167
|
-
* Load-bearing, not hygiene: `DeliveryTransportHealth` SUBTRACTS this from elapsed time.
|
|
168
|
-
* Unclamped, a stall charged twice drives unstarved time negative, and NO amount of real outage
|
|
169
|
-
* can then clear the evidence clause - a genuinely dead broker stops being detectable by evidence
|
|
170
|
-
* and survives to the backstop instead. Measured: a 30s stall moved an exit from 44s to 62s. */
|
|
130
|
+
/** Accumulated lag bounded by a nonnegative comparison span. `DeliveryTransportHealth` subtracts
|
|
131
|
+
* it from elapsed time, which must not become negative when a clock adjustment or a tick spanning
|
|
132
|
+
* a reset makes the accumulated lag larger than that span. */
|
|
171
133
|
starvedMsWithin(spanMs) {
|
|
172
134
|
return Math.min(this.accumulated, Math.max(0, spanMs));
|
|
173
135
|
}
|
|
174
|
-
/** Lag accumulated since the last {@link reset}. */
|
|
175
|
-
get starvedMs() {
|
|
176
|
-
return this.accumulated;
|
|
177
|
-
}
|
|
178
136
|
/** Called when positive evidence arrives: the window restarts, so its lag budget does too. The
|
|
179
137
|
* firing baseline is deliberately KEPT, so a stall spanning a reset is still measured. */
|
|
180
138
|
reset() {
|
|
181
139
|
this.accumulated = 0;
|
|
182
|
-
this.spans = []; // the intervals
|
|
183
|
-
// would let a pre-reset stall be re-charged by a later overlapping probe.
|
|
140
|
+
this.spans = []; // discard the old intervals as well as their measured extent
|
|
184
141
|
}
|
|
185
142
|
}
|
|
186
143
|
//# sourceMappingURL=watchdog.js.map
|
package/dist/watchdog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchdog.js","sourceRoot":"","sources":["../src/watchdog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAeH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAAC,OAAqB;IAC/C,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,6FAA6F;QAC7F,yDAAyD;QACzD,KAAK,MAAM,CAAC,CAAC,OAAO,cAAc,CAAC;QACnC,oFAAoF;QACpF,KAAK,MAAM,CAAC,CAAC,OAAO,WAAW,CAAC;QAChC,yEAAyE;QACzE,KAAK,OAAO,CAAC,CAAC,OAAO,MAAM,CAAC;QAC5B,8FAA8F;QAC9F,sEAAsE;QACtE,KAAK,SAAS,CAAC,CAAC,OAAO,cAAc,CAAC;IACxC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,UAAU,CAAC,OAAqB;IAC9C,8FAA8F;IAC9F,yBAAyB;IACzB,OAA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,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;IAED;;mEAE+D;IAC/D,eAAe,CAAC,MAAc;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACzD,CAAC;IAED;+FAC2F;IAC3F,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,CAAG,6DAA6D;IAClF,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cotal-ai/delivery",
|
|
3
3
|
"description": "Cotal delivery daemon: the server-side Plane-3 durable backstop (fan-out writer + trusted reader + membership/ACL authority), a scoped least-privilege NATS client co-located with the broker.",
|
|
4
|
-
"version": "0.141.
|
|
4
|
+
"version": "0.141.5",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@cotal-ai/core": "0.141.
|
|
22
|
-
"@cotal-ai/workspace": "0.141.
|
|
21
|
+
"@cotal-ai/core": "0.141.5",
|
|
22
|
+
"@cotal-ai/workspace": "0.141.5",
|
|
23
23
|
"@nats-io/jetstream": "^3.4.0"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|