instar 1.3.677 → 1.3.679

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.
@@ -28,6 +28,23 @@ import type { ComponentFrameworksConfig } from './IntelligenceRouter.js';
28
28
  * entry against the real `IntelligenceFramework` enum so an unknown name never ships.
29
29
  */
30
30
  export declare const INTERNAL_FRAMEWORK_PREFERENCE: readonly IntelligenceFramework[];
31
+ /**
32
+ * The LATENCY-SENSITIVE preference chain — used for the `gate` category ONLY.
33
+ *
34
+ * A `gate` is a SYNCHRONOUS, action-blocking check (the user-facing
35
+ * `MessagingToneGate` is the canonical one — a human is waiting for their reply).
36
+ * The general `INTERNAL_FRAMEWORK_PREFERENCE` puts `codex-cli` first by operator
37
+ * directive (spread background LOAD off Claude), but codex-cli is the SLOWEST
38
+ * off-Claude framework (~30s, which exceeds the 20s outbound-gate review budget
39
+ * and times the gate out — the 2026-06-25 silent-outbound class). For a
40
+ * latency-sensitive gate the right default is the FASTEST available off-Claude
41
+ * framework, not the load-spreading order. Ranked fastest→slowest, Claude last.
42
+ *
43
+ * This does NOT override the codex-first directive for the BACKGROUND categories
44
+ * (`sentinel` / `reflector`) — their latency does not block a human, so they keep
45
+ * the load-spreading order. Only `gate` (where a user waits) goes fastest-first.
46
+ */
47
+ export declare const LATENCY_SENSITIVE_FRAMEWORK_PREFERENCE: readonly IntelligenceFramework[];
31
48
  /**
32
49
  * Compute the default `componentFrameworks` from the active-framework set.
33
50
  *
@@ -35,8 +52,12 @@ export declare const INTERNAL_FRAMEWORK_PREFERENCE: readonly IntelligenceFramewo
35
52
  * agent, IN PREFERENCE ORDER (the caller filters `INTERNAL_FRAMEWORK_PREFERENCE`
36
53
  * by `buildProvider(fw) !== null`). MUST already be ordered + de-duplicated.
37
54
  * @returns the effective `ComponentFrameworksConfig`:
38
- * - `categories.{sentinel,gate,reflector}` = `active[0]` (first active off-Claude,
39
- * or claude-code if that's all that's active)
55
+ * - `categories.{sentinel,reflector}` = `active[0]` (first active off-Claude in the
56
+ * codex-first load-spreading order, or claude-code if that's all that's active)
57
+ * - `categories.gate` = the FASTEST active off-Claude framework
58
+ * (`LATENCY_SENSITIVE_FRAMEWORK_PREFERENCE`: pi → gemini → codex → claude) — the
59
+ * gate is synchronous + user-blocking, so it prefers speed over load-spreading.
60
+ * Equals `active[0]` when only one off-Claude framework is active (no-op then).
40
61
  * - `failureSwap` = `active.slice(1)` (the ordered tail, claude-code last)
41
62
  * - `fallback: 'default'`
42
63
  *
@@ -1 +1 @@
1
- {"version":3,"file":"internalFrameworkDefault.d.ts","sourceRoot":"","sources":["../../src/core/internalFrameworkDefault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,qBAAqB,EAKhE,CAAC;AAEX;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,+BAA+B,CAC7C,gBAAgB,EAAE,SAAS,qBAAqB,EAAE,GACjD,yBAAyB,CAqB3B"}
1
+ {"version":3,"file":"internalFrameworkDefault.d.ts","sourceRoot":"","sources":["../../src/core/internalFrameworkDefault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,qBAAqB,EAKhE,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sCAAsC,EAAE,SAAS,qBAAqB,EAKzE,CAAC;AAUX;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,+BAA+B,CAC7C,gBAAgB,EAAE,SAAS,qBAAqB,EAAE,GACjD,yBAAyB,CA6B3B"}
@@ -31,6 +31,32 @@ export const INTERNAL_FRAMEWORK_PREFERENCE = [
31
31
  'gemini-cli',
32
32
  'claude-code',
33
33
  ];
34
+ /**
35
+ * The LATENCY-SENSITIVE preference chain — used for the `gate` category ONLY.
36
+ *
37
+ * A `gate` is a SYNCHRONOUS, action-blocking check (the user-facing
38
+ * `MessagingToneGate` is the canonical one — a human is waiting for their reply).
39
+ * The general `INTERNAL_FRAMEWORK_PREFERENCE` puts `codex-cli` first by operator
40
+ * directive (spread background LOAD off Claude), but codex-cli is the SLOWEST
41
+ * off-Claude framework (~30s, which exceeds the 20s outbound-gate review budget
42
+ * and times the gate out — the 2026-06-25 silent-outbound class). For a
43
+ * latency-sensitive gate the right default is the FASTEST available off-Claude
44
+ * framework, not the load-spreading order. Ranked fastest→slowest, Claude last.
45
+ *
46
+ * This does NOT override the codex-first directive for the BACKGROUND categories
47
+ * (`sentinel` / `reflector`) — their latency does not block a human, so they keep
48
+ * the load-spreading order. Only `gate` (where a user waits) goes fastest-first.
49
+ */
50
+ export const LATENCY_SENSITIVE_FRAMEWORK_PREFERENCE = [
51
+ 'pi-cli',
52
+ 'gemini-cli',
53
+ 'codex-cli',
54
+ 'claude-code',
55
+ ];
56
+ /** The first framework in `order` that is also present in `active`, else undefined. */
57
+ function firstActiveIn(order, active) {
58
+ return order.find((fw) => active.includes(fw));
59
+ }
34
60
  /**
35
61
  * Compute the default `componentFrameworks` from the active-framework set.
36
62
  *
@@ -38,8 +64,12 @@ export const INTERNAL_FRAMEWORK_PREFERENCE = [
38
64
  * agent, IN PREFERENCE ORDER (the caller filters `INTERNAL_FRAMEWORK_PREFERENCE`
39
65
  * by `buildProvider(fw) !== null`). MUST already be ordered + de-duplicated.
40
66
  * @returns the effective `ComponentFrameworksConfig`:
41
- * - `categories.{sentinel,gate,reflector}` = `active[0]` (first active off-Claude,
42
- * or claude-code if that's all that's active)
67
+ * - `categories.{sentinel,reflector}` = `active[0]` (first active off-Claude in the
68
+ * codex-first load-spreading order, or claude-code if that's all that's active)
69
+ * - `categories.gate` = the FASTEST active off-Claude framework
70
+ * (`LATENCY_SENSITIVE_FRAMEWORK_PREFERENCE`: pi → gemini → codex → claude) — the
71
+ * gate is synchronous + user-blocking, so it prefers speed over load-spreading.
72
+ * Equals `active[0]` when only one off-Claude framework is active (no-op then).
43
73
  * - `failureSwap` = `active.slice(1)` (the ordered tail, claude-code last)
44
74
  * - `fallback: 'default'`
45
75
  *
@@ -58,10 +88,18 @@ export function resolveInternalFrameworkDefault(activeFrameworks) {
58
88
  return { failureSwap: [], fallback: 'default' };
59
89
  }
60
90
  const primary = active[0];
91
+ // The `gate` category is LATENCY-SENSITIVE: a synchronous, user-blocking check.
92
+ // It gets the FASTEST active off-Claude framework (pi → gemini → codex → claude),
93
+ // NOT the load-spreading codex-first order. `active` is in INTERNAL_FRAMEWORK_
94
+ // PREFERENCE order, so we re-rank it by the latency order to find the fastest.
95
+ // Falls back to `primary` if (somehow) no latency-ranked match — keeping the gate
96
+ // never worse than today. When only one off-Claude framework is active, gatePrimary
97
+ // === primary (byte-identical to the old behavior).
98
+ const gatePrimary = firstActiveIn(LATENCY_SENSITIVE_FRAMEWORK_PREFERENCE, active) ?? primary;
61
99
  return {
62
100
  categories: {
63
101
  sentinel: primary,
64
- gate: primary,
102
+ gate: gatePrimary,
65
103
  reflector: primary,
66
104
  // `job` and `other` are deliberately ABSENT (§4.1).
67
105
  },
@@ -1 +1 @@
1
- {"version":3,"file":"internalFrameworkDefault.js","sourceRoot":"","sources":["../../src/core/internalFrameworkDefault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAqC;IAC7E,WAAW;IACX,QAAQ;IACR,YAAY;IACZ,aAAa;CACL,CAAC;AAEX;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,+BAA+B,CAC7C,gBAAkD;IAElD,MAAM,MAAM,GAAG,gBAAgB,CAAC;IAEhC,iFAAiF;IACjF,8EAA8E;IAC9E,kFAAkF;IAClF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,EAAE,CAAC;QAChF,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,OAAO;QACL,UAAU,EAAE;YACV,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,OAAO;YAClB,oDAAoD;SACrD;QACD,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5B,QAAQ,EAAE,SAAS;KACpB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"internalFrameworkDefault.js","sourceRoot":"","sources":["../../src/core/internalFrameworkDefault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAqC;IAC7E,WAAW;IACX,QAAQ;IACR,YAAY;IACZ,aAAa;CACL,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAqC;IACtF,QAAQ;IACR,YAAY;IACZ,WAAW;IACX,aAAa;CACL,CAAC;AAEX,uFAAuF;AACvF,SAAS,aAAa,CACpB,KAAuC,EACvC,MAAwC;IAExC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAA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,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,kEAAkE;AAClE,wBAAgB,wBAAwB,IAAI,kBAAkB,CAO7D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,GAAE,sBAAyD,GACpE,eAAe,CAKjB"}
1
+ {"version":3,"file":"HostPressureSampler.d.ts","sourceRoot":"","sources":["../../src/monitoring/HostPressureSampler.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG3E,mFAAmF;AACnF,MAAM,WAAW,sBAAsB;IACrC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED,0GAA0G;AAC1G,eAAO,MAAM,gCAAgC,EAAE,sBAG9C,CAAC;AAEF,yFAAyF;AACzF,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,kEAAkE;AAClE,wBAAgB,wBAAwB,IAAI,kBAAkB,CAW7D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,GAAE,sBAAyD,GACpE,eAAe,CAKjB"}
@@ -17,6 +17,7 @@
17
17
  */
18
18
  import os from 'node:os';
19
19
  import { computePressure } from './SessionReaper.js';
20
+ import { hostFreeMemPct } from './hostMemoryPressure.js';
20
21
  /** The reaper's historical defaults — an unconfigured caller is byte-identical to the old inline code. */
21
22
  export const DEFAULT_HOST_PRESSURE_THRESHOLDS = {
22
23
  cpuModerateLoadPerCore: 1.0,
@@ -24,8 +25,12 @@ export const DEFAULT_HOST_PRESSURE_THRESHOLDS = {
24
25
  };
25
26
  /** Sample the raw inputs from the OS. Pure read; never throws. */
26
27
  export function sampleHostPressureInputs() {
27
- const total = os.totalmem();
28
- const freePct = total > 0 ? (os.freemem() / total) * 100 : 100;
28
+ // freePct is the CORRECTED available-memory percentage (free + inactive +
29
+ // purgeable on macOS via vm_stat; MemAvailable on Linux) — NOT os.freemem(),
30
+ // which on macOS reports only raw free pages (~0.1%) and falsely registered as
31
+ // critical, over-reaping sessions + permanently blocking revival.
32
+ // Spec: macos-memory-pressure-metric.
33
+ const freePct = hostFreeMemPct();
29
34
  // CPU pressure: 1-min load average ÷ core count. cores unknown ⇒ memory-only.
30
35
  const cores = os.cpus()?.length ?? 0;
31
36
  const loadPerCore = cores > 0 ? os.loadavg()[0] / cores : null;
@@ -1 +1 @@
1
- {"version":3,"file":"HostPressureSampler.js","sourceRoot":"","sources":["../../src/monitoring/HostPressureSampler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,eAAe,EAAwB,MAAM,oBAAoB,CAAC;AAQ3E,0GAA0G;AAC1G,MAAM,CAAC,MAAM,gCAAgC,GAA2B;IACtE,sBAAsB,EAAE,GAAG;IAC3B,sBAAsB,EAAE,GAAG;CAC5B,CAAC;AAQF,kEAAkE;AAClE,MAAM,UAAU,wBAAwB;IACtC,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/D,8EAA8E;IAC9E,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC,CAAC;IACrC,MAAM,WAAW,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,aAAq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,14 +91,6 @@ export declare class MemoryPressureMonitor extends EventEmitter {
91
91
  * Read system memory — platform-aware.
92
92
  */
93
93
  private readSystemMemory;
94
- /**
95
- * macOS: parse vm_stat
96
- */
97
- private parseVmStat;
98
- /**
99
- * Linux: parse /proc/meminfo
100
- */
101
- private parseProcMeminfo;
102
94
  /**
103
95
  * Linear regression over recent readings.
104
96
  */
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryPressureMonitor.d.ts","sourceRoot":"","sources":["../../src/monitoring/MemoryPressureMonitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAEjF,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,KAAK,EAAE,WAAW,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,2EAA2E;IAC3E,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAyBD,qBAAa,qBAAsB,SAAQ,YAAY;IACrD,OAAO,CAAC,OAAO,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O,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAuB;gBAE3B,MAAM,GAAE,2BAAgC;IAepD,KAAK,IAAI,IAAI;IAQb,IAAI,IAAI,IAAI;IAOZ;;;;OAIG;IACH,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI;IAmBpG,OAAO,KAAK,kBAAkB,GAG7B;IAED,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,uBAAuB;IAmB/B;;OAEG;IACH,aAAa,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAIxE,QAAQ,IAAI,WAAW;IAcvB;;OAEG;IACH,eAAe,IAAI;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAoBxD,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,KAAK;IAkCb,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACH,OAAO,CAAC,WAAW;CA8BpB"}
@@ -13,10 +13,9 @@
13
13
  * Includes trend tracking via ring buffer + linear regression.
14
14
  */
15
15
  import { EventEmitter } from 'node:events';
16
- import { spawnSync } from 'node:child_process';
17
16
  import * as fs from 'node:fs';
18
- import os from 'node:os';
19
17
  import { DegradationReporter } from './DegradationReporter.js';
18
+ import { readSystemMemoryPressure } from './hostMemoryPressure.js';
20
19
  const DEFAULT_THRESHOLDS = {
21
20
  warning: 60,
22
21
  elevated: 75,
@@ -24,7 +23,6 @@ const DEFAULT_THRESHOLDS = {
24
23
  };
25
24
  const RING_BUFFER_SIZE = 20;
26
25
  const TREND_WINDOW = 6;
27
- const PAGE_SIZE_BYTES = 16384; // macOS Apple Silicon
28
26
  // Adaptive intervals
29
27
  const INTERVALS = {
30
28
  normal: 30_000,
@@ -234,66 +232,10 @@ export class MemoryPressureMonitor extends EventEmitter {
234
232
  * Read system memory — platform-aware.
235
233
  */
236
234
  readSystemMemory() {
237
- if (process.platform === 'darwin') {
238
- return this.parseVmStat();
239
- }
240
- else if (process.platform === 'linux') {
241
- return this.parseProcMeminfo();
242
- }
243
- else {
244
- // Fallback: use Node's process.memoryUsage (very rough)
245
- const mem = process.memoryUsage();
246
- const totalGB = os.totalmem() / (1024 ** 3);
247
- const usedGB = mem.rss / (1024 ** 3);
248
- return {
249
- pressurePercent: (usedGB / totalGB) * 100,
250
- freeGB: totalGB - usedGB,
251
- totalGB,
252
- };
253
- }
254
- }
255
- /**
256
- * macOS: parse vm_stat
257
- */
258
- parseVmStat() {
259
- const output = spawnSync('vm_stat', [], { encoding: 'utf-8', timeout: 5000 }).stdout ?? '';
260
- const pageSizeMatch = output.match(/page size of (\d+) bytes/);
261
- const pageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : PAGE_SIZE_BYTES;
262
- const parsePages = (label) => {
263
- const match = output.match(new RegExp(`${label}:\\s+(\\d+)`));
264
- return match ? parseInt(match[1], 10) : 0;
265
- };
266
- const freePages = parsePages('Pages free');
267
- const activePages = parsePages('Pages active');
268
- const inactivePages = parsePages('Pages inactive');
269
- const wiredPages = parsePages('Pages wired down');
270
- const compressorPages = parsePages('Pages occupied by compressor');
271
- const purgeablePages = parsePages('Pages purgeable');
272
- const totalPages = freePages + activePages + inactivePages + wiredPages + compressorPages;
273
- const totalBytes = totalPages * pageSize;
274
- const totalGB = totalBytes / (1024 ** 3);
275
- const availablePages = freePages + inactivePages + purgeablePages;
276
- const availableBytes = availablePages * pageSize;
277
- const freeGB = availableBytes / (1024 ** 3);
278
- const usedPages = totalPages - availablePages;
279
- const pressurePercent = totalPages > 0 ? (usedPages / totalPages) * 100 : 0;
280
- return { pressurePercent, freeGB, totalGB };
281
- }
282
- /**
283
- * Linux: parse /proc/meminfo
284
- */
285
- parseProcMeminfo() {
286
- const content = fs.readFileSync('/proc/meminfo', 'utf-8');
287
- const parseKB = (key) => {
288
- const match = content.match(new RegExp(`${key}:\\s+(\\d+)`));
289
- return match ? parseInt(match[1], 10) : 0;
290
- };
291
- const totalKB = parseKB('MemTotal');
292
- const availableKB = parseKB('MemAvailable') || (parseKB('MemFree') + parseKB('Buffers') + parseKB('Cached'));
293
- const totalGB = totalKB / (1024 * 1024);
294
- const freeGB = availableKB / (1024 * 1024);
295
- const pressurePercent = totalKB > 0 ? ((totalKB - availableKB) / totalKB) * 100 : 0;
296
- return { pressurePercent, freeGB, totalGB };
235
+ // Delegates to the ONE shared, platform-aware reader (macOS reads
236
+ // free+inactive+purgeable via vm_stat, Linux MemAvailable, never raw
237
+ // os.freemem). Spec: macos-memory-pressure-metric.
238
+ return readSystemMemoryPressure();
297
239
  }
298
240
  /**
299
241
  * Linear regression over recent readings.
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryPressureMonitor.js","sourceRoot":"","sources":["../../src/monitoring/MemoryPressureMonitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAoC/D,MAAM,kBAAkB,GAAG;IACzB,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAA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C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;QACtC,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAE3D,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;QAChD,MAAM,UAAU,GAAG,KAAK,GAAG,EAAE,CAAC;QAE9B,IAAI,KAAkB,CAAC;QACvB,IAAI,UAAU,GAAG,GAAG;YAAE,KAAK,GAAG,QAAQ,CAAC;aAClC,IAAI,UAAU,GAAG,CAAC,GAAG;YAAE,KAAK,GAAG,SAAS,CAAC;;YACzC,KAAK,GAAG,QAAQ,CAAC;QAEtB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ export interface SystemMemoryReading {
2
+ /** Used memory as a percentage (0-100). The inverse of available. */
3
+ pressurePercent: number;
4
+ freeGB: number;
5
+ totalGB: number;
6
+ }
7
+ /** Injectable IO so the parsers + reader unit-test without a real OS. */
8
+ export interface MemReadDeps {
9
+ platform?: string;
10
+ vmStat?: () => string;
11
+ procMeminfo?: () => string;
12
+ memoryUsage?: () => {
13
+ rss: number;
14
+ };
15
+ totalmem?: () => number;
16
+ }
17
+ /** Pure: parse `vm_stat` output → memory reading. Available = free + inactive + purgeable. */
18
+ export declare function parseVmStat(output: string): SystemMemoryReading;
19
+ /** Pure: parse `/proc/meminfo` content → memory reading (Linux MemAvailable). */
20
+ export declare function parseProcMeminfo(content: string): SystemMemoryReading;
21
+ /** Read host memory pressure, platform-aware. Bounded + never throws (fallback on any error). */
22
+ export declare function readSystemMemoryPressure(deps?: MemReadDeps): SystemMemoryReading;
23
+ /**
24
+ * Free/available host memory as a percentage (0-100) — the CORRECTED replacement
25
+ * for `os.freemem()/os.totalmem()*100`. Use this for any memory-pressure tier
26
+ * decision so macOS is read truthfully (free+inactive+purgeable), not as raw
27
+ * free pages.
28
+ */
29
+ export declare function hostFreeMemPct(deps?: MemReadDeps): number;
30
+ //# sourceMappingURL=hostMemoryPressure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostMemoryPressure.d.ts","sourceRoot":"","sources":["../../src/monitoring/hostMemoryPressure.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;CACzB;AAED,8FAA8F;AAC9F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAqB/D;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAWrE;AAED,iGAAiG;AACjG,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,WAAgB,GAAG,mBAAmB,CA2BpF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAE,WAAgB,GAAG,MAAM,CAG7D"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * hostMemoryPressure — THE one correct, platform-aware measure of host memory
3
+ * availability across the codebase. Spec: macos-memory-pressure-metric.
4
+ *
5
+ * THE BUG THIS FIXES: `os.freemem()` on macOS returns ONLY "Pages free" — which
6
+ * macOS keeps near-zero (it uses the rest for cache/compressor/purgeable), so
7
+ * `os.freemem()/totalmem()` reads ~0.1-0.4% on a healthy machine and falsely
8
+ * registers as "critical" memory pressure. That false-critical made the
9
+ * SessionReaper over-reap AND permanently blocked the ResumeQueueDrainer's
10
+ * "machine calm" gate (it can never reach a 'normal' tier), so reaped sessions
11
+ * never revived — silently. The CORRECT macOS available memory is
12
+ * free + inactive (reclaimable) + purgeable, exactly what `vm_stat` exposes and
13
+ * what MemoryPressureMonitor already computed for HealthChecker — this lifts that
14
+ * calculation into one shared, injectable, unit-tested helper.
15
+ */
16
+ import { spawnSync } from 'node:child_process';
17
+ import * as fs from 'node:fs';
18
+ import os from 'node:os';
19
+ import { withSyncOp } from '../core/InFlightSyncOpMarker.js';
20
+ const PAGE_SIZE_BYTES = 16384; // macOS Apple Silicon default; overridden by vm_stat's own page size
21
+ /** Pure: parse `vm_stat` output → memory reading. Available = free + inactive + purgeable. */
22
+ export function parseVmStat(output) {
23
+ const pageSizeMatch = output.match(/page size of (\d+) bytes/);
24
+ const pageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : PAGE_SIZE_BYTES;
25
+ const parsePages = (label) => {
26
+ const match = output.match(new RegExp(`${label}:\\s+(\\d+)`));
27
+ return match ? parseInt(match[1], 10) : 0;
28
+ };
29
+ const freePages = parsePages('Pages free');
30
+ const activePages = parsePages('Pages active');
31
+ const inactivePages = parsePages('Pages inactive');
32
+ const wiredPages = parsePages('Pages wired down');
33
+ const compressorPages = parsePages('Pages occupied by compressor');
34
+ const purgeablePages = parsePages('Pages purgeable');
35
+ const totalPages = freePages + activePages + inactivePages + wiredPages + compressorPages;
36
+ const totalGB = (totalPages * pageSize) / (1024 ** 3);
37
+ const availablePages = freePages + inactivePages + purgeablePages;
38
+ const freeGB = (availablePages * pageSize) / (1024 ** 3);
39
+ const usedPages = totalPages - availablePages;
40
+ const pressurePercent = totalPages > 0 ? (usedPages / totalPages) * 100 : 0;
41
+ return { pressurePercent, freeGB, totalGB };
42
+ }
43
+ /** Pure: parse `/proc/meminfo` content → memory reading (Linux MemAvailable). */
44
+ export function parseProcMeminfo(content) {
45
+ const parseKB = (key) => {
46
+ const match = content.match(new RegExp(`${key}:\\s+(\\d+)`));
47
+ return match ? parseInt(match[1], 10) : 0;
48
+ };
49
+ const totalKB = parseKB('MemTotal');
50
+ const availableKB = parseKB('MemAvailable') || (parseKB('MemFree') + parseKB('Buffers') + parseKB('Cached'));
51
+ const totalGB = totalKB / (1024 * 1024);
52
+ const freeGB = availableKB / (1024 * 1024);
53
+ const pressurePercent = totalKB > 0 ? ((totalKB - availableKB) / totalKB) * 100 : 0;
54
+ return { pressurePercent, freeGB, totalGB };
55
+ }
56
+ /** Read host memory pressure, platform-aware. Bounded + never throws (fallback on any error). */
57
+ export function readSystemMemoryPressure(deps = {}) {
58
+ const platform = deps.platform ?? process.platform;
59
+ try {
60
+ if (platform === 'darwin') {
61
+ // The real vm_stat read funnels through withSyncOp so the in-flight sync-op
62
+ // marker sees this blocking call (tmux-event-loop-resilience-spec). The
63
+ // injected `vmStat` (tests) is a pure stub and needs no funnel.
64
+ const out = deps.vmStat ? deps.vmStat() : withSyncOp(() => spawnSync('vm_stat', [], { encoding: 'utf-8', timeout: 5000 }).stdout ?? '');
65
+ if (out)
66
+ return parseVmStat(out);
67
+ }
68
+ else if (platform === 'linux') {
69
+ const content = deps.procMeminfo ? deps.procMeminfo() : fs.readFileSync('/proc/meminfo', 'utf-8');
70
+ if (content)
71
+ return parseProcMeminfo(content);
72
+ }
73
+ }
74
+ catch (err) {
75
+ // @silent-fallback-ok — a vm_stat/proc read failure falls back to the rough
76
+ // process.memoryUsage estimate below; an observability metric, never a gate
77
+ // that should wedge on a transient read error. NOT silent: the fallback is
78
+ // logged (No Silent Degradation — advisory degradation must be visible) so a
79
+ // genuinely-broken vm_stat surfaces instead of hiding behind a server-RSS
80
+ // estimate. The fallback biases toward LOW pressure (server RSS ≪ host RAM),
81
+ // the safe direction for a reaper (less aggressive) + revival (more available).
82
+ console.warn(`[hostMemoryPressure] ${platform} memory read failed; using rough RSS estimate: ${err instanceof Error ? err.message : String(err)}`);
83
+ }
84
+ // Fallback (other platforms or a read error): rough RSS-based estimate.
85
+ const totalGB = (deps.totalmem ? deps.totalmem() : os.totalmem()) / (1024 ** 3);
86
+ const usedGB = (deps.memoryUsage ? deps.memoryUsage() : process.memoryUsage()).rss / (1024 ** 3);
87
+ return { pressurePercent: totalGB > 0 ? (usedGB / totalGB) * 100 : 0, freeGB: totalGB - usedGB, totalGB };
88
+ }
89
+ /**
90
+ * Free/available host memory as a percentage (0-100) — the CORRECTED replacement
91
+ * for `os.freemem()/os.totalmem()*100`. Use this for any memory-pressure tier
92
+ * decision so macOS is read truthfully (free+inactive+purgeable), not as raw
93
+ * free pages.
94
+ */
95
+ export function hostFreeMemPct(deps = {}) {
96
+ const pct = 100 - readSystemMemoryPressure(deps).pressurePercent;
97
+ return Math.max(0, Math.min(100, pct));
98
+ }
99
+ //# sourceMappingURL=hostMemoryPressure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostMemoryPressure.js","sourceRoot":"","sources":["../../src/monitoring/hostMemoryPressure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,qEAAqE;AAkBpG,8FAA8F;AAC9F,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,aAAa,GAAG,MAAM,CAA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CAAC,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IACjG,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC;AAC5G,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAoB,EAAE;IACnD,MAAM,GAAG,GAAG,GAAG,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC;IACjE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.677",
3
+ "version": "1.3.679",
4
4
  "description": "Coherence infrastructure for self-evolving AI agents — on the Claude Code or Codex subscription you already have.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-06-26T13:12:48.410Z",
5
- "instarVersion": "1.3.677",
4
+ "generatedAt": "2026-06-26T20:21:36.405Z",
5
+ "instarVersion": "1.3.679",
6
6
  "entryCount": 202,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -5,6 +5,17 @@
5
5
 
6
6
  ## What Changed
7
7
 
8
+ The provider-fallback default policy routed every internal off-Claude category
9
+ (`sentinel`, `gate`, `reflector`) onto the same codex-first primary. But the
10
+ `gate` category includes the **user-facing tone gate** — a synchronous check a
11
+ human is waiting on — and `codex-cli` is the slowest off-Claude framework (~30s),
12
+ which exceeds the 20s outbound-review budget and times the gate out (a cause of
13
+ the 2026-06-25 silent-outbound incident). The `gate` category now resolves its
14
+ default primary from a separate speed-ranked order (`pi → gemini → codex →
15
+ claude`) — the fastest *active* off-Claude framework — while `sentinel`/`reflector`
16
+ keep the codex-first load-spreading order. `failureSwap`, the gate's verdict
17
+ logic, and the F4 degrade floor are all unchanged.
18
+
8
19
  The host spawn cap (the fork-bomb/OOM safety floor that bounds how many LLM
9
20
  subprocesses run at once) now reserves a little headroom for the user's reply. Under
10
21
  load, the user-facing tone gate used to wait in the same undifferentiated line as
@@ -27,6 +38,11 @@ treated as reachable), so it never cries wolf on a normal idle kill.
27
38
 
28
39
  ## What to Tell Your User
29
40
 
41
+ Your replies' safety check now runs on the fastest available engine instead of
42
+ the slowest, so it stops timing out under load — one fewer cause of slow or
43
+ missing replies. Background checks are unchanged. If only one non-Claude engine is
44
+ installed, nothing changes.
45
+
30
46
  When the machine is busy, your reply's safety check now jumps to a reserved slot instead
31
47
  of waiting behind background work — fewer slow/held replies under load. The crash
32
48
  protection is exactly as strong as before. Most setups see no change (it's off on the
@@ -41,6 +57,12 @@ follow-up. Off on the fleet for now.
41
57
 
42
58
  ## Summary of New Capabilities
43
59
 
60
+ - The latency-sensitive `gate` category defaults to the fastest active off-Claude
61
+ framework (`LATENCY_SENSITIVE_FRAMEWORK_PREFERENCE`), not the codex-first order.
62
+ - `sentinel`/`reflector`/`job`/`other` routing and `failureSwap` are unchanged.
63
+ - An explicit `categories.gate` in config always overrides the computed default.
64
+ - Single-off-Claude-framework agents and claude-only agents: byte-identical no-op.
65
+
44
66
  - `attribution.lane:'interactive'` requests reserved headroom — honored ONLY for an
45
67
  allowlisted, user-blocking seam (the operator-facing tone gate); everything else stays
46
68
  background.
@@ -58,6 +80,16 @@ follow-up. Off on the fleet for now.
58
80
 
59
81
  ## Evidence
60
82
 
83
+ - `internalFrameworkDefault.test.ts`: gate prefers fastest (pi) while sentinel
84
+ stays codex; pi-down→gemini (the gemini-serves-when-pi-down case); both-down→codex
85
+ (never worse than today); single-framework→no divergence. 17 unit tests pass.
86
+ - `provider-fallback-default-routing.test.ts` (integration): the gate component on
87
+ `GET /intelligence/routing` reports the fastest active framework. 3 pass.
88
+ - `provider-fallback-default-policy-lifecycle.test.ts` (e2e): route alive, policy
89
+ live. `tsc --noEmit` clean. 24 affected tests green.
90
+ - Side-effects review: `upgrades/side-effects/latency-sensitive-gate-framework.md`.
91
+ - Spec amendment: `docs/specs/provider-fallback-default-policy.md` §4.1.
92
+
61
93
  - `hostSpawnSemaphore-priority.test.ts` (10): symmetric reserve, OOM floor unconditional,
62
94
  garbage-lane→background-never-dropped, clamp (N=1/N=2/oversized/0), off=byte-identical.
63
95
  - `spawn-cap-provider-lane.test.ts` (7): allowlist downgrade (CoherenceReviewer→background),
@@ -0,0 +1,25 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ The agent measures how busy the machine's memory is to decide when to close idle sessions and when to bring them back. On macOS it was reading the wrong number — Node's raw "free memory," which macOS deliberately keeps near zero by using the rest for cache and compression. So a perfectly healthy Mac looked permanently out of memory. That made the cleanup close idle sessions too eagerly AND permanently blocked the revival queue from bringing them back — so a topic's session could vanish and never return, with no message to the user.
9
+
10
+ The fix reads real available memory the way macOS itself does (free plus the reclaimable inactive and purgeable memory, via vm_stat), and the same correct figure on Linux. The correct calculation already existed in the health checker; this lifts it into one shared, tested place and points the cleanup at it. On the machine where this broke, the old reading was 0.17% (false crisis) and the correct reading is about 20% available (healthy), so sessions revive again.
11
+
12
+ It can only make the cleanup less aggressive and revival more available on macOS — the safe direction — and a separate, larger guarantee (always keep at least one reachable session, and never silently deny a session for resource reasons) is coming next.
13
+
14
+ ## What to Tell Your User
15
+
16
+ If a topic ever went quiet — you sent messages and got nothing back — one cause was the agent mis-reading its own memory on a Mac and refusing to bring a closed session back. That false alarm is fixed: it now reads real available memory, so sessions get cleaned up and revived based on the true picture.
17
+
18
+ ## Summary of New Capabilities
19
+
20
+ - Correct, platform-aware host memory-availability measurement (free + reclaimable on macOS; MemAvailable on Linux) feeding the session reaper and revival queue — no more macOS false-critical from raw free pages.
21
+
22
+ ## Evidence
23
+
24
+ - `tests/unit/host-memory-pressure.test.ts` (13): includes REAL captured `vm_stat` from the incident machine — tiny raw free pages but correct available% reads healthy; a genuinely-critical shape reads low; platform-aware; never-throws fallback. 121 existing reaper/memory/resume-queue tests still green (no regression).
25
+ - Convergence (conformance gate + lessons-aware reviewer, no blockers): `docs/specs/reports/macos-memory-pressure-metric-convergence.md`.
@@ -0,0 +1,79 @@
1
+ # Side-Effects Review — Latency-Sensitive Gate Framework Default
2
+
3
+ **Version / slug:** `latency-sensitive-gate-framework`
4
+ **Date:** `2026-06-26`
5
+ **Author:** `Echo (instar-dev agent)`
6
+ **Tier:** 1 (small, localized; one pure resolver function + its tests + docs)
7
+
8
+ ## Summary
9
+
10
+ The provider-fallback default policy routes internal components off-Claude via a
11
+ single codex-first preference chain (`codex-cli → pi-cli → gemini-cli →
12
+ claude-code`). The `gate` category — which includes the **user-facing
13
+ `MessagingToneGate`**, a synchronous check a human is waiting on — inherited that
14
+ codex-first primary. But `codex-cli` is the SLOWEST off-Claude framework (~30s),
15
+ which exceeds the 20s outbound-gate review budget and times the gate out (the
16
+ 2026-06-25 silent-outbound class). This change gives the `gate` category a
17
+ SEPARATE, speed-ranked order (`LATENCY_SENSITIVE_FRAMEWORK_PREFERENCE = pi →
18
+ gemini → codex → claude`) so it defaults to the FASTEST active off-Claude
19
+ framework. `sentinel`/`reflector` (background) keep codex-first; `failureSwap` and
20
+ all other categories are unchanged.
21
+
22
+ ## The 8 questions
23
+
24
+ 1. **Over-block** — N/A. This is not a gate; it selects which backend computes the
25
+ tone-gate verdict. It rejects nothing.
26
+ 2. **Under-block** — N/A. The tone gate's block/allow logic and its deterministic
27
+ degrade floor (F4) are byte-identical; only the LLM backend that produces the
28
+ verdict changes. A faster backend means FEWER budget-timeout degrades, i.e.
29
+ *more* real verdicts, not fewer.
30
+ 3. **Level-of-abstraction fit** — Correct. The change lives in the one pure policy
31
+ resolver (`resolveInternalFrameworkDefault`) that already computes per-category
32
+ primaries; `ComponentFrameworksConfig.categories` is already a per-category map,
33
+ so no routing-engine change is needed. The router consumes the config unchanged.
34
+ 4. **Signal vs authority** — No authority added. The resolver is a pure function
35
+ (active-set → config); it holds no blocking power. The tone gate's authority
36
+ (hold/send) is untouched. Complies with `docs/signal-vs-authority.md`.
37
+ 5. **Interactions** — The gate's PRIMARY now differs from `sentinel`/`reflector`.
38
+ `failureSwap` is the shared tail (`active.slice(1)`, codex-first); for a gate
39
+ whose primary is `pi`, the tail may list `pi` first (the just-tried framework) —
40
+ harmless: the failure-swap walk is circuit-checked, so a just-failed/open
41
+ provider is skipped. When only one off-Claude framework is active, `gatePrimary
42
+ === active[0]` (byte-identical no-op). No double-fire, no shadowing.
43
+ 6. **External surfaces** — `GET /intelligence/routing` now reports the gate
44
+ component on a (possibly) different framework than sentinels. That is the
45
+ intended, visible effect. No new route, no schema change.
46
+ 7. **Multi-machine posture** — **Machine-local BY DESIGN.** The default policy is
47
+ computed per-agent at boot from that agent's own active-framework set (which
48
+ frameworks' CLIs are installed/configured on THAT machine). No replication, no
49
+ cross-machine coupling. Each machine independently resolves the fastest gate
50
+ backend it has. Correct — framework availability is inherently per-machine.
51
+ 8. **Rollback cost** — Trivial. Revert the commit (one source file + tests + one
52
+ doc amendment). No state, no migration. An operator who wants the gate back on
53
+ codex sets `categories.gate` explicitly (the explicit config always wins over
54
+ the computed default). A single-off-Claude-framework agent is unaffected.
55
+
56
+ ## What it does NOT do
57
+
58
+ - Does NOT change the tone gate's verdict/hold/send logic or the F4 degrade floor.
59
+ - Does NOT touch `sentinel`/`reflector`/`job`/`other` routing, or `failureSwap`.
60
+ - Does NOT introduce a measured latency model — the ranking (pi < gemini < codex)
61
+ is a documented static assertion from observed behavior (~6s / ~9-13s / ~30s),
62
+ owned in `LATENCY_SENSITIVE_FRAMEWORK_PREFERENCE` with a unit-tested enum guard.
63
+ - Does NOT revoke the codex-first operator directive — it narrows it to exclude the
64
+ one latency-sensitive, user-blocking category.
65
+
66
+ ## Second-pass note (outbound-path touch)
67
+
68
+ This touches the OUTBOUND tone-gate path, which is a Phase-5 trigger area. The
69
+ substantive review point: the change adds NO block/allow authority — it only
70
+ selects a faster backend for an existing gate, and the gate's safety behavior
71
+ (including the deterministic degrade floor on backend failure) is unchanged. The
72
+ decision boundary (gate diverges to fastest; background stays codex-first; single-
73
+ framework is a no-op) is covered by the new unit + integration tests. A full
74
+ independent reviewer was judged unnecessary for an authority-free routing-default
75
+ change; the PR is the review surface.
76
+
77
+ ## Rollback
78
+
79
+ Revert the commit. No migration, no state.
@@ -0,0 +1,15 @@
1
+ # Side-effects review — macos-memory-pressure-metric
2
+
3
+ Change: replace `os.freemem()`-based memory-pressure measurement with REAL available memory (free+inactive+purgeable via vm_stat on macOS; MemAvailable on Linux) in the SessionReaper's pressure input. New `src/monitoring/hostMemoryPressure.ts` (shared); `HostPressureSampler` + `MemoryPressureMonitor` use it. Files: hostMemoryPressure.ts (new), HostPressureSampler.ts, MemoryPressureMonitor.ts, tests + real fixtures.
4
+
5
+ 1. **Over-block:** REDUCES a false over-block — the reaper no longer reads a healthy macOS machine as memory-critical, so it stops over-reaping idle sessions and the resume queue's calm-gate can reach `normal` and revive reaped sessions.
6
+ 2. **Under-block:** None new. The corrected metric is conservative (excludes active + compressor from "available", the safe direction). On a genuinely memory-critical machine it correctly reads critical. A 5-12% `moderate` machine still holds revival (now for a REAL reason, not a false one) — tracked separately as the lifeline-floor follow-on (topic-28130).
7
+ 3. **Level-of-abstraction fit:** Correct. One shared, injectable memory reader feeds all consumers of the single host-pressure signal (reaper, resume-queue, cartographer-sweep). Removes a duplicate vm_stat parser (one definition).
8
+ 4. **Signal vs authority:** Not a gate — a measurement that FEEDS gates. The fix makes the signal truthful; it adds no blocking authority. Serves "No Silent Degradation to Brittle Fallback" (os.freemem was the brittle metric silently degrading availability).
9
+ 5. **Interactions:** The reaper's CPU side (1-min load ÷ cores) is unchanged. MemoryPressureMonitor delegation is byte-identical to its prior private parser (confirmed vs HEAD~1) — HealthChecker behavior preserved. The fallback (RSS estimate on read error) biases low-pressure (server RSS ≪ host RAM) → safe direction; now logged (Observability). ResumeQueueDrainer.safeTier() independently fails closed on error — backstop intact.
10
+ 6. **External surfaces:** No routes. `GET /sessions/reaper`'s `pressure.inputs.freePct` now reports real available% (was ~0.1% on macOS). A `[hostMemoryPressure]` warn on read-failure fallback.
11
+ 7. **Multi-machine posture:** Machine-local by design — each host measures its own memory. No replication/proxy surface.
12
+ 8. **Rollback cost:** Low. Pure measurement change; revert restores os.freemem. No data migration, no config. The change can only relax the reaper / free revival on macOS (the safe direction), so a bad outcome is bounded.
13
+
14
+ ## Second-pass review (touches the reaper pressure path)
15
+ The lessons-aware convergence reviewer audited fail-direction, the parent standard, the reused vm_stat calc (byte-identical, correct exclusions), delegation (behavior-preserving), and the no-threshold-change claim. No blockers; one minor (log the fallback — DONE), one tracked note (moderate-machine residual → lifeline-floor follow-on). Concur.