instar 1.3.407 → 1.3.408
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/core/SleepWakeDetector.d.ts +16 -0
- package/dist/core/SleepWakeDetector.d.ts.map +1 -1
- package/dist/core/SleepWakeDetector.js +27 -1
- package/dist/core/SleepWakeDetector.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +2 -2
- package/upgrades/1.3.408.md +37 -0
- package/upgrades/side-effects/sleepwake-drift-burst-suppression.md +42 -0
|
@@ -57,6 +57,14 @@ export interface SleepWakeDetectorConfig {
|
|
|
57
57
|
* recovery storms. Long sleeps bypass the cooldown. Default: 60000 (1 min).
|
|
58
58
|
*/
|
|
59
59
|
minWakeIntervalMs?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Number of BACK-TO-BACK drift ticks at/above which a drift is treated as a CPU-
|
|
62
|
+
* starvation burst and suppressed — regardless of duration or the (lagging) load
|
|
63
|
+
* ratio. A genuine sleep is a single isolated drift (the next tick is on-time, which
|
|
64
|
+
* resets the counter); sustained starvation produces consecutive drifts. Default: 2
|
|
65
|
+
* (the 2nd consecutive drift is already a storm). Set 0 to disable.
|
|
66
|
+
*/
|
|
67
|
+
driftBurstSuppressFloor?: number;
|
|
60
68
|
/** Injectable system-load source (testing). Default: os.loadavg. */
|
|
61
69
|
loadAvgProvider?: () => number[];
|
|
62
70
|
/** Injectable CPU-count source (testing). Default: os.cpus().length. */
|
|
@@ -94,6 +102,14 @@ export declare class SleepWakeDetector extends EventEmitter {
|
|
|
94
102
|
private maxLoadRatio;
|
|
95
103
|
private longSleepFloorSeconds;
|
|
96
104
|
private minWakeIntervalMs;
|
|
105
|
+
private driftBurstSuppressFloor;
|
|
106
|
+
/** Count of BACK-TO-BACK drift ticks (reset by any on-time tick). A real sleep is
|
|
107
|
+
* ONE isolated drift; sustained CPU starvation produces consecutive drifts. The
|
|
108
|
+
* Nth+ consecutive drift is a storm, not a sleep, and is suppressed regardless of
|
|
109
|
+
* the (lagging, fluctuating) 1-min load ratio — the gap maxLoadRatio alone missed
|
|
110
|
+
* (2026-06-07: tunnel-restart storm from 10-42s drifts firing whenever loadRatio
|
|
111
|
+
* momentarily dipped below maxLoadRatio). */
|
|
112
|
+
private consecutiveDrifts;
|
|
97
113
|
private loadAvgProvider;
|
|
98
114
|
private cpuCountProvider;
|
|
99
115
|
private now;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SleepWakeDetector.d.ts","sourceRoot":"","sources":["../../src/core/SleepWakeDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,WAAW,uBAAuB;IACtC,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,MAAM,EAAE,CAAC;IACjC,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,MAAM,MAAM,CAAC;IAChC,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,S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AS;IACxC;;;;;kDAK8C;IAC9C,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,gBAAgB,CAAe;IACvC,OAAO,CAAC,GAAG,CAAe;IAC1B,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,kBAAkB,CAA6B;gBAE3C,MAAM,GAAE,uBAA4B;IAchD,KAAK,IAAI,IAAI;IAoEb,IAAI,IAAI,IAAI;IAOZ;qFACiF;IACjF,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,CAAC,iBAAiB;IAezB;;;;;;;;;;;;;;OAcG;IACH,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAanE,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc;CAkB3C"}
|
|
@@ -44,6 +44,14 @@ export class SleepWakeDetector extends EventEmitter {
|
|
|
44
44
|
maxLoadRatio;
|
|
45
45
|
longSleepFloorSeconds;
|
|
46
46
|
minWakeIntervalMs;
|
|
47
|
+
driftBurstSuppressFloor;
|
|
48
|
+
/** Count of BACK-TO-BACK drift ticks (reset by any on-time tick). A real sleep is
|
|
49
|
+
* ONE isolated drift; sustained CPU starvation produces consecutive drifts. The
|
|
50
|
+
* Nth+ consecutive drift is a storm, not a sleep, and is suppressed regardless of
|
|
51
|
+
* the (lagging, fluctuating) 1-min load ratio — the gap maxLoadRatio alone missed
|
|
52
|
+
* (2026-06-07: tunnel-restart storm from 10-42s drifts firing whenever loadRatio
|
|
53
|
+
* momentarily dipped below maxLoadRatio). */
|
|
54
|
+
consecutiveDrifts = 0;
|
|
47
55
|
loadAvgProvider;
|
|
48
56
|
cpuCountProvider;
|
|
49
57
|
now;
|
|
@@ -56,6 +64,7 @@ export class SleepWakeDetector extends EventEmitter {
|
|
|
56
64
|
this.maxLoadRatio = config.maxLoadRatio ?? 1.5;
|
|
57
65
|
this.longSleepFloorSeconds = config.longSleepFloorSeconds ?? 300;
|
|
58
66
|
this.minWakeIntervalMs = config.minWakeIntervalMs ?? 60000;
|
|
67
|
+
this.driftBurstSuppressFloor = config.driftBurstSuppressFloor ?? 2;
|
|
59
68
|
this.loadAvgProvider = config.loadAvgProvider ?? (() => os.loadavg());
|
|
60
69
|
this.cpuCountProvider = config.cpuCountProvider ?? (() => os.cpus().length);
|
|
61
70
|
this.now = config.nowProvider ?? (() => Date.now());
|
|
@@ -69,11 +78,28 @@ export class SleepWakeDetector extends EventEmitter {
|
|
|
69
78
|
const now = this.now();
|
|
70
79
|
const elapsed = now - this.lastTick;
|
|
71
80
|
this.lastTick = now;
|
|
72
|
-
if (elapsed <= this.driftThresholdMs)
|
|
81
|
+
if (elapsed <= this.driftThresholdMs) {
|
|
82
|
+
this.consecutiveDrifts = 0;
|
|
73
83
|
return;
|
|
84
|
+
} // on-time tick → not starving
|
|
74
85
|
const sleepDuration = Math.round((elapsed - this.checkIntervalMs) / 1000);
|
|
75
86
|
const isLongSleep = sleepDuration >= this.longSleepFloorSeconds;
|
|
76
87
|
const loadRatio = this.currentLoadRatio();
|
|
88
|
+
this.consecutiveDrifts += 1;
|
|
89
|
+
// Consecutive-drift burst = sustained CPU starvation, not sleep. A genuine sleep
|
|
90
|
+
// is ONE isolated drift (the next on-time tick resets the counter); the 2nd+
|
|
91
|
+
// back-to-back SHORT drift is a storm. Suppress it regardless of the (lagging,
|
|
92
|
+
// fluctuating) load ratio — this catches the drifts maxLoadRatio missed when the
|
|
93
|
+
// 1-min average momentarily dipped below the threshold (2026-06-07 tunnel-restart
|
|
94
|
+
// storm). A genuine LONG sleep (>= longSleepFloorSeconds) is exempt — it always
|
|
95
|
+
// emits (real-sleep recovery is essential), and the FIRST short drift still falls
|
|
96
|
+
// through to the checks below, so an isolated real wake is unaffected.
|
|
97
|
+
if (!isLongSleep && this.driftBurstSuppressFloor > 0 && this.consecutiveDrifts >= this.driftBurstSuppressFloor) {
|
|
98
|
+
this.recordSuppression('cpu-starvation', sleepDuration, loadRatio, now);
|
|
99
|
+
console.warn(`[SleepWakeDetector] Drift ~${sleepDuration}s — consecutive drift #${this.consecutiveDrifts} ` +
|
|
100
|
+
`(>= ${this.driftBurstSuppressFloor}) = starvation burst, suppressing wake`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
77
103
|
// Short drift under heavy CPU load = event-loop starvation, not sleep.
|
|
78
104
|
if (!isLongSleep && loadRatio > this.maxLoadRatio) {
|
|
79
105
|
this.recordSuppression('cpu-starvation', sleepDuration, loadRatio, now);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SleepWakeDetector.js","sourceRoot":"","sources":["../../src/core/SleepWakeDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SleepWakeDetector.js","sourceRoot":"","sources":["../../src/core/SleepWakeDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AAkEzB,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IACzC,QAAQ,GAA0C,IAAI,CAAC;IACvD,QAAQ,CAAS;IACjB,mBAAmB,GAAkB,IAAI,CAAC;IAC1C,eAAe,CAAS;IACxB,gBAAgB,CAAS;IACzB,YAAY,CAAS;IACrB,qBAAqB,CAAS;IAC9B,iBAAiB,CAAS;IAC1B,uBAAuB,CAAS;IACxC;;;;;kDAK8C;IACtC,iBAAiB,GAAG,CAAC,CAAC;IACtB,eAAe,CAAiB;IAChC,gBAAgB,CAAe;IAC/B,GAAG,CAAe;IAClB,WAAW,GAAgB,EAAE,CAAC;IAC9B,kB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E,CAAC,CAAC;YAC/E,mBAAmB,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrG,eAAe,EAAE,UAAU,CAAC,MAAM;YAClC,kBAAkB;YAClB,gBAAgB,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;SAC7F,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./builtin-manifest.schema.json",
|
|
3
3
|
"schemaVersion": 1,
|
|
4
|
-
"generatedAt": "2026-06-07T20:
|
|
5
|
-
"instarVersion": "1.3.
|
|
4
|
+
"generatedAt": "2026-06-07T20:16:47.651Z",
|
|
5
|
+
"instarVersion": "1.3.408",
|
|
6
6
|
"entryCount": 199,
|
|
7
7
|
"entries": {
|
|
8
8
|
"hook:session-start": {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Upgrade Guide — vNEXT
|
|
2
|
+
|
|
3
|
+
<!-- assembled-by: assemble-next-md -->
|
|
4
|
+
<!-- bump: patch -->
|
|
5
|
+
|
|
6
|
+
## What Changed
|
|
7
|
+
|
|
8
|
+
The SleepWakeDetector mistook event-loop lag for sleep when the 1-min load average
|
|
9
|
+
momentarily dipped below its starvation threshold (which lags + fluctuates), firing
|
|
10
|
+
false wakes → a tunnel-restart storm every 1-3 min on a load-churning box. Adds a
|
|
11
|
+
load-independent consecutive-drift guard: a real sleep is one isolated drift, but
|
|
12
|
+
sustained starvation produces back-to-back drifts — so the 2nd+ consecutive SHORT drift
|
|
13
|
+
is suppressed regardless of the load reading. Genuine long sleeps (≥5min) are exempt.
|
|
14
|
+
|
|
15
|
+
New `driftBurstSuppressFloor` (default 2; 0 disables).
|
|
16
|
+
|
|
17
|
+
## What to Tell Your User
|
|
18
|
+
|
|
19
|
+
Nothing required — internal stability fix. If they saw the tunnel/dashboard flapping or
|
|
20
|
+
frequent restarts under load, this calms it.
|
|
21
|
+
|
|
22
|
+
## Summary of New Capabilities
|
|
23
|
+
|
|
24
|
+
- `SleepWakeDetectorConfig.driftBurstSuppressFloor` — suppress the Nth+ back-to-back
|
|
25
|
+
drift as a CPU-starvation burst (load-independent). Default 2.
|
|
26
|
+
|
|
27
|
+
## Evidence
|
|
28
|
+
|
|
29
|
+
`tests/unit/sleep-wake-starvation-guard.test.ts`: 2nd consecutive short drift suppressed
|
|
30
|
+
under normal load + past cooldown; floor-0 contrast proves the guard; on-time tick resets;
|
|
31
|
+
long sleep exempt. 13/13 green. `tsc --noEmit` clean.
|
|
32
|
+
|
|
33
|
+
## Scope (honest)
|
|
34
|
+
|
|
35
|
+
Fix B of the operator's A+B pair (A = durable reaper candidacy). B reduces the restart
|
|
36
|
+
churn; A makes the reaper survive whatever churn remains. Targets the SHORT-drift storm;
|
|
37
|
+
genuine long sleeps still emit. Does not change the existing load-ratio or cooldown guards.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Side effects — SleepWake drift-burst suppression
|
|
2
|
+
|
|
3
|
+
## Change
|
|
4
|
+
|
|
5
|
+
`SleepWakeDetector` gains a load-independent consecutive-drift guard. It counts
|
|
6
|
+
back-to-back drift ticks (`consecutiveDrifts`); any on-time tick resets the count. The
|
|
7
|
+
Nth+ consecutive SHORT drift (N = `driftBurstSuppressFloor`, default 2) is suppressed as
|
|
8
|
+
a CPU-starvation burst regardless of the (lagging, fluctuating) 1-min load ratio — closing
|
|
9
|
+
the gap the `maxLoadRatio` guard alone missed when load momentarily dipped below threshold.
|
|
10
|
+
|
|
11
|
+
## Behavioral surface
|
|
12
|
+
|
|
13
|
+
- **New config field** `SleepWakeDetectorConfig.driftBurstSuppressFloor` (number, default 2;
|
|
14
|
+
0 disables). Absent → default 2, so the burst guard is ON by default.
|
|
15
|
+
- **What changes at runtime**: on a load-churning box, the 2nd-and-onward back-to-back short
|
|
16
|
+
drift no longer emits a `wake` event → no tunnel/recovery restart for it. Suppressions are
|
|
17
|
+
counted under the existing `cpu-starvation` reason in `getStats()` and excluded from
|
|
18
|
+
cumulative-sleep accounting (same path as the load-ratio suppression).
|
|
19
|
+
- **What does NOT change**: the first drift in any burst still falls through to the existing
|
|
20
|
+
load-ratio + cooldown checks; a genuine LONG sleep (≥ `longSleepFloorSeconds`, default 300s)
|
|
21
|
+
is exempt and always emits; an isolated real short wake still emits.
|
|
22
|
+
|
|
23
|
+
## Migration / compatibility
|
|
24
|
+
|
|
25
|
+
- No migration needed. The field is optional with an in-code default; existing callers that
|
|
26
|
+
never set it get the (safe, more-suppressing) default-2 behavior. No config-schema change is
|
|
27
|
+
shipped to agents — the default lives in the constructor.
|
|
28
|
+
- No API route, no persisted state, no on-disk format change.
|
|
29
|
+
- Rollback: set `driftBurstSuppressFloor: 0` to restore the exact pre-change behavior (load-ratio
|
|
30
|
+
+ cooldown guards only).
|
|
31
|
+
|
|
32
|
+
## Risk
|
|
33
|
+
|
|
34
|
+
Low. The guard only ever suppresses MORE false wakes, and only the 2nd+ back-to-back short
|
|
35
|
+
drift. Worst case is a delayed reconnect after a genuine short sleep that lands mid-starvation-
|
|
36
|
+
burst (rare; self-heals on the next on-time tick / activity). Long-sleep recovery is untouched.
|
|
37
|
+
|
|
38
|
+
## Tests
|
|
39
|
+
|
|
40
|
+
`tests/unit/sleep-wake-starvation-guard.test.ts` — 4 new cases (2nd consecutive short drift
|
|
41
|
+
suppressed under NORMAL load; floor-0 contrast proves the guard fired; on-time tick resets the
|
|
42
|
+
counter; long sleep exempt). 13/13 file-green; `tsc --noEmit` clean.
|