instar 1.3.828 → 1.3.830
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/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +51 -32
- package/dist/commands/server.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +29 -1
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/RopeRecoveryProber.d.ts +9 -1
- package/dist/core/RopeRecoveryProber.d.ts.map +1 -1
- package/dist/core/RopeRecoveryProber.js +4 -4
- package/dist/core/RopeRecoveryProber.js.map +1 -1
- package/dist/messaging/TelegramAdapter.d.ts +10 -1
- package/dist/messaging/TelegramAdapter.d.ts.map +1 -1
- package/dist/messaging/TelegramAdapter.js +6 -4
- package/dist/messaging/TelegramAdapter.js.map +1 -1
- package/dist/monitoring/MachineCoherenceSentinel.d.ts +49 -0
- package/dist/monitoring/MachineCoherenceSentinel.d.ts.map +1 -1
- package/dist/monitoring/MachineCoherenceSentinel.js +73 -5
- package/dist/monitoring/MachineCoherenceSentinel.js.map +1 -1
- package/dist/monitoring/RopeHealthMonitor.d.ts.map +1 -1
- package/dist/monitoring/RopeHealthMonitor.js +12 -0
- package/dist/monitoring/RopeHealthMonitor.js.map +1 -1
- package/dist/monitoring/machineCoherenceAnchors.d.ts +152 -0
- package/dist/monitoring/machineCoherenceAnchors.d.ts.map +1 -0
- package/dist/monitoring/machineCoherenceAnchors.js +296 -0
- package/dist/monitoring/machineCoherenceAnchors.js.map +1 -0
- package/dist/monitoring/machineCoherenceEffectsExecutor.d.ts +50 -0
- package/dist/monitoring/machineCoherenceEffectsExecutor.d.ts.map +1 -0
- package/dist/monitoring/machineCoherenceEffectsExecutor.js +56 -0
- package/dist/monitoring/machineCoherenceEffectsExecutor.js.map +1 -0
- package/dist/monitoring/machineCoherenceEpisode.d.ts +30 -0
- package/dist/monitoring/machineCoherenceEpisode.d.ts.map +1 -1
- package/dist/monitoring/machineCoherenceEpisode.js.map +1 -1
- package/dist/monitoring/machineCoherenceEpisodeManager.d.ts +65 -3
- package/dist/monitoring/machineCoherenceEpisodeManager.d.ts.map +1 -1
- package/dist/monitoring/machineCoherenceEpisodeManager.js +275 -15
- package/dist/monitoring/machineCoherenceEpisodeManager.js.map +1 -1
- package/dist/monitoring/ropeSinkRouter.d.ts +60 -0
- package/dist/monitoring/ropeSinkRouter.d.ts.map +1 -0
- package/dist/monitoring/ropeSinkRouter.js +66 -0
- package/dist/monitoring/ropeSinkRouter.js.map +1 -0
- package/dist/scaffold/templates.js +2 -2
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +19 -19
- package/src/scaffold/templates.ts +2 -2
- package/upgrades/1.3.829.md +26 -0
- package/upgrades/1.3.830.md +16 -0
- package/upgrades/side-effects/calm-transient-episode-alerting.md +57 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-coherence ANCHORS — the durable, identity-independent clock layer
|
|
3
|
+
* (calm-transient-episode-alerting spec, M-P0).
|
|
4
|
+
*
|
|
5
|
+
* WHY: the confirmation engine's rowState is keyed on the N1 row identity,
|
|
6
|
+
* which EMBEDS every participant's value class — so a version advance mints a
|
|
7
|
+
* new row and wipes the clocks. The grace/ceiling/flap arms of the calm design
|
|
8
|
+
* must survive exactly that churn (plus <2-online clears, sentinel restarts,
|
|
9
|
+
* warmup, and raiser handoff), so their state lives HERE: keyed per
|
|
10
|
+
* `(dimension|key)` (NO value classes), persisted as an additive block in the
|
|
11
|
+
* episode manager's existing durable file, computed on every machine from the
|
|
12
|
+
* shared adverts.
|
|
13
|
+
*
|
|
14
|
+
* Clock model (spec M-P0): `activeSkewMs` accumulates
|
|
15
|
+
* `clamp(now − anchorLastEvaluatedAtMs, 0, K × tickMs)` and credits ONLY
|
|
16
|
+
* reconciles where the key is observed divergent AND every skew participant is
|
|
17
|
+
* present in the compared set — a suspended anchor (participant departed)
|
|
18
|
+
* freezes both the clear and the accumulator; gaps beyond K ticks are
|
|
19
|
+
* retroactively suspended time. Grace and the stall ceiling compare against
|
|
20
|
+
* `activeSkewMs`, never wall-clock-since-onset; advances can never reset it.
|
|
21
|
+
*
|
|
22
|
+
* Pure + deterministic: no I/O, no Date.now() — callers pass `nowMs`.
|
|
23
|
+
* Supervision tier: Tier 0 (deterministic bookkeeping, no LLM anywhere).
|
|
24
|
+
*/
|
|
25
|
+
export function emptyAnchors() {
|
|
26
|
+
return { entries: {}, calmOnsetTimestamps: [] };
|
|
27
|
+
}
|
|
28
|
+
export function anchorKey(dimension, key) {
|
|
29
|
+
return `${dimension}|${key}`;
|
|
30
|
+
}
|
|
31
|
+
const DAY_MS = 24 * 3_600_000;
|
|
32
|
+
const FLAP_HISTORY_CLAMP = 64;
|
|
33
|
+
/** Parse the numeric `major.minor.patch` triplet; prerelease/build ignored; null = unparseable. */
|
|
34
|
+
export function parseVersionTriplet(v) {
|
|
35
|
+
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(String(v ?? '').trim());
|
|
36
|
+
if (!m)
|
|
37
|
+
return null;
|
|
38
|
+
return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
39
|
+
}
|
|
40
|
+
/** Numeric triplet comparison: negative a<b, 0 equal, positive a>b. */
|
|
41
|
+
export function compareTriplets(a, b) {
|
|
42
|
+
for (let i = 0; i < 3; i++)
|
|
43
|
+
if (a[i] !== b[i])
|
|
44
|
+
return a[i] - b[i];
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The gap-narrowing advance predicate (spec M-P0): an advance counts ONLY when
|
|
49
|
+
* the machine's version moves strictly toward the pool's max observed version —
|
|
50
|
+
* `next > prev AND next <= poolMax`. Regression, lateral, unparseable, or a
|
|
51
|
+
* jump PAST the pool max never counts.
|
|
52
|
+
*/
|
|
53
|
+
export function isGapNarrowingAdvance(prev, next, poolMax) {
|
|
54
|
+
if (prev === undefined)
|
|
55
|
+
return false; // first observation is a baseline, not an advance
|
|
56
|
+
const p = parseVersionTriplet(prev);
|
|
57
|
+
const n = parseVersionTriplet(next);
|
|
58
|
+
const max = parseVersionTriplet(poolMax);
|
|
59
|
+
if (!p || !n || !max)
|
|
60
|
+
return false;
|
|
61
|
+
return compareTriplets(n, p) > 0 && compareTriplets(n, max) <= 0;
|
|
62
|
+
}
|
|
63
|
+
/** Max observed parseable version across the compared machines ('' if none parse). */
|
|
64
|
+
export function poolMaxVersion(versionsByMachine) {
|
|
65
|
+
let best = '';
|
|
66
|
+
let bestT = null;
|
|
67
|
+
for (const v of Object.values(versionsByMachine)) {
|
|
68
|
+
const t = parseVersionTriplet(v);
|
|
69
|
+
if (!t)
|
|
70
|
+
continue;
|
|
71
|
+
if (!bestT || compareTriplets(t, bestT) > 0) {
|
|
72
|
+
bestT = t;
|
|
73
|
+
best = v;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return best;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Advance the anchor block one reconcile tick. Pure: returns the (mutated-in-
|
|
80
|
+
* place) block, whether a MATERIAL change occurred (the persist dirty-check —
|
|
81
|
+
* accumulator-only drift under the 5-min bucket is NOT material), and events.
|
|
82
|
+
*/
|
|
83
|
+
export function reconcileAnchors(block, input) {
|
|
84
|
+
const { nowMs, tickMs, kTicks, rows, comparedMachines, versionsByMachine, resolveTicks, retireAfterMs } = input;
|
|
85
|
+
const events = [];
|
|
86
|
+
let changed = false;
|
|
87
|
+
const compared = new Set(comparedMachines);
|
|
88
|
+
const divergentByKey = new Map();
|
|
89
|
+
for (const r of rows) {
|
|
90
|
+
const k = anchorKey(r.dimension, r.key);
|
|
91
|
+
const arr = divergentByKey.get(k) ?? [];
|
|
92
|
+
arr.push(r);
|
|
93
|
+
divergentByKey.set(k, arr);
|
|
94
|
+
}
|
|
95
|
+
// ── 1. Onset / participant-union for keys divergent THIS tick ──
|
|
96
|
+
for (const [k, keyRows] of divergentByKey) {
|
|
97
|
+
let e = block.entries[k];
|
|
98
|
+
const rowParticipants = new Set();
|
|
99
|
+
for (const r of keyRows)
|
|
100
|
+
for (const p of r.participants)
|
|
101
|
+
rowParticipants.add(p);
|
|
102
|
+
if (!e) {
|
|
103
|
+
e = {
|
|
104
|
+
dimension: keyRows[0].dimension,
|
|
105
|
+
key: keyRows[0].key,
|
|
106
|
+
skewOnsetAtMs: nowMs,
|
|
107
|
+
activeSkewMs: 0,
|
|
108
|
+
anchorLastEvaluatedAtMs: nowMs,
|
|
109
|
+
participants: [...rowParticipants].sort(),
|
|
110
|
+
clearStreakTicks: 0,
|
|
111
|
+
flapHistory: [],
|
|
112
|
+
perMachine: {},
|
|
113
|
+
};
|
|
114
|
+
block.entries[k] = e;
|
|
115
|
+
changed = true;
|
|
116
|
+
events.push({ kind: 'onset', anchorKey: k });
|
|
117
|
+
}
|
|
118
|
+
else if (e.skewOnsetAtMs === 0) {
|
|
119
|
+
// Re-skew of a cleared-but-not-retired entry: fresh onset, latches + flap history survive.
|
|
120
|
+
e.skewOnsetAtMs = nowMs;
|
|
121
|
+
e.activeSkewMs = 0;
|
|
122
|
+
e.anchorLastEvaluatedAtMs = nowMs;
|
|
123
|
+
e.participants = [...rowParticipants].sort();
|
|
124
|
+
e.clearStreakTicks = 0;
|
|
125
|
+
e.absentSinceMs = undefined;
|
|
126
|
+
changed = true;
|
|
127
|
+
events.push({ kind: 'onset', anchorKey: k });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// Ongoing skew: union any newly-participating machines; clear absence.
|
|
131
|
+
const before = e.participants.length;
|
|
132
|
+
const union = new Set(e.participants);
|
|
133
|
+
for (const p of rowParticipants)
|
|
134
|
+
union.add(p);
|
|
135
|
+
e.participants = [...union].sort();
|
|
136
|
+
if (e.participants.length !== before)
|
|
137
|
+
changed = true;
|
|
138
|
+
if (e.absentSinceMs !== undefined) {
|
|
139
|
+
e.absentSinceMs = undefined;
|
|
140
|
+
changed = true;
|
|
141
|
+
}
|
|
142
|
+
e.clearStreakTicks = 0;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// ── 2. Per-entry clock credit / clear-streak / retirement ──
|
|
146
|
+
const poolMax = poolMaxVersion(versionsByMachine);
|
|
147
|
+
for (const [k, e] of Object.entries(block.entries)) {
|
|
148
|
+
const divergentNow = divergentByKey.has(k);
|
|
149
|
+
const allParticipantsPresent = e.participants.length > 0 && e.participants.every((p) => compared.has(p));
|
|
150
|
+
const activeEpisode = e.skewOnsetAtMs !== 0;
|
|
151
|
+
// Accumulator: credit ONLY divergent-observed + all-participants-present ticks.
|
|
152
|
+
if (activeEpisode && divergentNow && allParticipantsPresent) {
|
|
153
|
+
const rawDelta = nowMs - e.anchorLastEvaluatedAtMs;
|
|
154
|
+
const credit = Math.min(Math.max(rawDelta, 0), kTicks * tickMs);
|
|
155
|
+
if (credit > 0)
|
|
156
|
+
e.activeSkewMs += credit;
|
|
157
|
+
// Dirty-check: accumulator drift persists on ≥5-min bucket boundaries only.
|
|
158
|
+
if (Math.floor((e.activeSkewMs - credit) / 300_000) !== Math.floor(e.activeSkewMs / 300_000))
|
|
159
|
+
changed = true;
|
|
160
|
+
}
|
|
161
|
+
e.anchorLastEvaluatedAtMs = nowMs;
|
|
162
|
+
// Participant-aware clear: NOT divergent + every participant present + ≥2 compared.
|
|
163
|
+
if (activeEpisode && !divergentNow) {
|
|
164
|
+
if (allParticipantsPresent && compared.size >= 2) {
|
|
165
|
+
e.clearStreakTicks += 1;
|
|
166
|
+
if (e.clearStreakTicks >= resolveTicks) {
|
|
167
|
+
if (e.pendingFlapConfirm) {
|
|
168
|
+
e.flapHistory.push(nowMs);
|
|
169
|
+
e.flapHistory = e.flapHistory.filter((t) => nowMs - t < DAY_MS).slice(-FLAP_HISTORY_CLAMP);
|
|
170
|
+
e.pendingFlapConfirm = undefined;
|
|
171
|
+
events.push({ kind: 'flap-cycle-completed', anchorKey: k, cyclesIn24h: e.flapHistory.length });
|
|
172
|
+
}
|
|
173
|
+
e.skewOnsetAtMs = 0;
|
|
174
|
+
e.activeSkewMs = 0;
|
|
175
|
+
e.clearStreakTicks = 0;
|
|
176
|
+
e.absentSinceMs = nowMs;
|
|
177
|
+
changed = true;
|
|
178
|
+
events.push({ kind: 'cleared', anchorKey: k });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// participant departed or <2 compared ⇒ suspended: streak frozen, never vacuous-clear.
|
|
182
|
+
}
|
|
183
|
+
// Retirement: sustained absence only (latches survive until then).
|
|
184
|
+
if (!activeEpisode && e.absentSinceMs !== undefined && nowMs - e.absentSinceMs >= retireAfterMs && !divergentNow) {
|
|
185
|
+
delete block.entries[k];
|
|
186
|
+
changed = true;
|
|
187
|
+
events.push({ kind: 'retired', anchorKey: k });
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
// Progress tracking (version dimension): update per-machine from adverts.
|
|
191
|
+
if (e.dimension === 'version') {
|
|
192
|
+
for (const m of comparedMachines) {
|
|
193
|
+
const v = versionsByMachine[m];
|
|
194
|
+
if (v === undefined)
|
|
195
|
+
continue;
|
|
196
|
+
const pm = (e.perMachine[m] ??= {});
|
|
197
|
+
if (pm.lastSeenVersion !== v) {
|
|
198
|
+
if (isGapNarrowingAdvance(pm.lastSeenVersion, v, poolMax)) {
|
|
199
|
+
pm.lastAdvanceAtMs = nowMs;
|
|
200
|
+
changed = true; // an observed version change is a material change
|
|
201
|
+
}
|
|
202
|
+
pm.lastSeenVersion = v;
|
|
203
|
+
changed = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// Machines gone from the registry/compared set entirely for the retirement
|
|
207
|
+
// window ride the entry's own retirement; individual pruning is not needed
|
|
208
|
+
// for correctness (bounded by pool size).
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// ── 3. Wave-backstop onset history pruning (24 h) ──
|
|
212
|
+
const beforeLen = block.calmOnsetTimestamps.length;
|
|
213
|
+
block.calmOnsetTimestamps = block.calmOnsetTimestamps.filter((t) => nowMs - t < DAY_MS);
|
|
214
|
+
if (block.calmOnsetTimestamps.length !== beforeLen)
|
|
215
|
+
changed = true;
|
|
216
|
+
return { changed, events };
|
|
217
|
+
}
|
|
218
|
+
/** Sentinel → anchors: a confirm transition happened on this key while skewed. */
|
|
219
|
+
export function recordConfirmTransition(block, dimension, key) {
|
|
220
|
+
const e = block.entries[anchorKey(dimension, key)];
|
|
221
|
+
if (!e || e.skewOnsetAtMs === 0)
|
|
222
|
+
return false;
|
|
223
|
+
if (e.pendingFlapConfirm)
|
|
224
|
+
return false;
|
|
225
|
+
e.pendingFlapConfirm = true;
|
|
226
|
+
return true; // material change
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Decide confirm-vs-extend for patch-only version skew (spec M-P1). Laggards =
|
|
230
|
+
* participants whose version parses BELOW the pool max; the extension applies
|
|
231
|
+
* only when EVERY laggard advanced within the window (any stalled laggard ⇒
|
|
232
|
+
* confirm — the conservative, louder direction). No anchor ⇒ fall back to the
|
|
233
|
+
* legacy grace path (fail toward today's behavior).
|
|
234
|
+
*/
|
|
235
|
+
export function decidePatchSkew(block, key, cfg, nowMs, versionsByMachine) {
|
|
236
|
+
const e = block.entries[anchorKey('version', key)];
|
|
237
|
+
if (!e || e.skewOnsetAtMs === 0)
|
|
238
|
+
return { confirm: false, reason: 'no-anchor' };
|
|
239
|
+
if (e.activeSkewMs < cfg.graceMs)
|
|
240
|
+
return { confirm: false, reason: 'grace' };
|
|
241
|
+
if (e.activeSkewMs >= cfg.ceilingMs)
|
|
242
|
+
return { confirm: true, reason: 'ceiling' };
|
|
243
|
+
if (!cfg.progressExtensionEnabled)
|
|
244
|
+
return { confirm: true, reason: 'no-progress' };
|
|
245
|
+
const poolMax = poolMaxVersion(versionsByMachine);
|
|
246
|
+
const maxT = parseVersionTriplet(poolMax);
|
|
247
|
+
if (!maxT)
|
|
248
|
+
return { confirm: true, reason: 'no-progress' }; // unreadable ⇒ louder
|
|
249
|
+
const laggards = e.participants.filter((m) => {
|
|
250
|
+
const t = parseVersionTriplet(versionsByMachine[m] ?? '');
|
|
251
|
+
return !t || compareTriplets(t, maxT) < 0; // unparseable counts as lagging (louder)
|
|
252
|
+
});
|
|
253
|
+
if (laggards.length === 0)
|
|
254
|
+
return { confirm: true, reason: 'no-progress' }; // divergent yet no laggard — confirm (loud)
|
|
255
|
+
const allAdvancing = laggards.every((m) => {
|
|
256
|
+
const pm = e.perMachine[m];
|
|
257
|
+
return pm?.lastAdvanceAtMs !== undefined && nowMs - pm.lastAdvanceAtMs <= cfg.progressWindowMs;
|
|
258
|
+
});
|
|
259
|
+
return allAdvancing ? { confirm: false, reason: 'extend' } : { confirm: true, reason: 'no-progress' };
|
|
260
|
+
}
|
|
261
|
+
/** Durable 24 h once-latch check + arm for the derived escalation raises. */
|
|
262
|
+
export function tryArmDerivedLatch(block, dimension, key, which, nowMs) {
|
|
263
|
+
const e = block.entries[anchorKey(dimension, key)];
|
|
264
|
+
if (!e)
|
|
265
|
+
return false;
|
|
266
|
+
const last = which === 'stalled' ? e.lastStalledFireAtMs : e.lastRecurringFireAtMs;
|
|
267
|
+
if (last !== undefined && nowMs - last < DAY_MS)
|
|
268
|
+
return false;
|
|
269
|
+
if (which === 'stalled')
|
|
270
|
+
e.lastStalledFireAtMs = nowMs;
|
|
271
|
+
else
|
|
272
|
+
e.lastRecurringFireAtMs = nowMs;
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
/** Flap-brake trigger check: ≥threshold completed cycles in 24 h (latch NOT consumed here). */
|
|
276
|
+
export function flapBrakeEligible(block, dimension, key, threshold, nowMs) {
|
|
277
|
+
const e = block.entries[anchorKey(dimension, key)];
|
|
278
|
+
if (!e)
|
|
279
|
+
return false;
|
|
280
|
+
const recent = e.flapHistory.filter((t) => nowMs - t < DAY_MS).length;
|
|
281
|
+
return recent >= threshold;
|
|
282
|
+
}
|
|
283
|
+
/** Record a NON-reopen calm-class onset; returns true when the wave backstop should fire (and arms its latch). */
|
|
284
|
+
export function recordCalmOnsetAndCheckWave(block, nowMs, threshold) {
|
|
285
|
+
block.calmOnsetTimestamps.push(nowMs);
|
|
286
|
+
block.calmOnsetTimestamps = block.calmOnsetTimestamps.filter((t) => nowMs - t < DAY_MS);
|
|
287
|
+
if (threshold <= 0)
|
|
288
|
+
return false;
|
|
289
|
+
if (block.calmOnsetTimestamps.length < threshold)
|
|
290
|
+
return false;
|
|
291
|
+
if (block.lastWaveNoticeAtMs !== undefined && nowMs - block.lastWaveNoticeAtMs < DAY_MS)
|
|
292
|
+
return false;
|
|
293
|
+
block.lastWaveNoticeAtMs = nowMs;
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=machineCoherenceAnchors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machineCoherenceAnchors.js","sourceRoot":"","sources":["../../src/monitoring/machineCoherenceAnchors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AA4CH,MAAM,UAAU,YAAY;IAC1B,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,SAAwB,EAAE,GAAW;IAC7D,OAAO,GAAG,SAAS,IAAI,GAAG,EAAE,CAAC;AAC/B,CAAC;AAED,MAAM,MAAM,GAAG,EAAE,GAAG,SAAS,CAAC;AAC9B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,mGAAmG;AACnG,MAAM,UAAU,mBAAmB,CAAC,CAAS;IAC3C,MAAM,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9D,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM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CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC;IACtE,OAAO,MAAM,IAAI,SAAS,CAAC;AAC7B,CAAC;AAED,kHAAkH;AAClH,MAAM,UAAU,2BAA2B,CAAC,KAAmB,EAAE,KAAa,EAAE,SAAiB;IAC/F,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IACxF,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,KAAK,CAAC,mBAAmB,CAAC,MAAM,GAAG,SAAS;QAAE,OAAO,KAAK,CAAC;IAC/D,IAAI,KAAK,CAAC,kBAAkB,KAAK,SAAS,IAAI,KAAK,GAAG,KAAK,CAAC,kBAAkB,GAAG,MAAM;QAAE,OAAO,KAAK,CAAC;IACtG,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC;IACjC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-coherence effects executor (calm-transient-episode-alerting M-P2).
|
|
3
|
+
*
|
|
4
|
+
* Extracted from the server.ts boot closure — the exact site of the original
|
|
5
|
+
* hardcoded-`priority: 'HIGH'` bug — into an injectable, unit-testable module.
|
|
6
|
+
* The executor is a PASS-THROUGH: priority / silent / copy decisions live in
|
|
7
|
+
* the episode manager (where dimension/stall/flap/interacted context lives);
|
|
8
|
+
* this module only carries them to the Telegram chokepoints.
|
|
9
|
+
*
|
|
10
|
+
* Fail-toward-silence: every effect executes fire-and-forget with its own
|
|
11
|
+
* catch — a Telegram fault must never crash the shared presence tick; the next
|
|
12
|
+
* reconcile re-derives from durable episode state.
|
|
13
|
+
*/
|
|
14
|
+
import type { EpisodeEffect } from './machineCoherenceEpisodeManager.js';
|
|
15
|
+
/** The Telegram surface the executor needs (structural subset of TelegramAdapter). */
|
|
16
|
+
export interface EffectsTelegram {
|
|
17
|
+
createAttentionItem(item: {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
summary: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
category: string;
|
|
23
|
+
priority: string;
|
|
24
|
+
sourceContext?: string;
|
|
25
|
+
silent?: boolean;
|
|
26
|
+
}): Promise<unknown>;
|
|
27
|
+
getAttentionItem(itemId: string): {
|
|
28
|
+
topicId?: number;
|
|
29
|
+
} | undefined;
|
|
30
|
+
sendToTopic(topicId: number, text: string, options?: {
|
|
31
|
+
silent?: boolean;
|
|
32
|
+
}): Promise<unknown>;
|
|
33
|
+
updateAttentionStatus(itemId: string, status: string, opts?: {
|
|
34
|
+
silent?: boolean;
|
|
35
|
+
}): Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
export interface EffectsExecutorDeps {
|
|
38
|
+
/** The live adapter (null when Telegram is unavailable — effects are best-effort). */
|
|
39
|
+
telegram: () => EffectsTelegram | null;
|
|
40
|
+
/** `execute-fix` handler (the atomic config funnel lives server-side). */
|
|
41
|
+
onExecuteFix?: (eff: Extract<EpisodeEffect, {
|
|
42
|
+
kind: 'execute-fix';
|
|
43
|
+
}>) => Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execute one batch of episode effects. Each effect runs independently
|
|
47
|
+
* (fire-and-forget, own catch) — one fault never blocks the rest.
|
|
48
|
+
*/
|
|
49
|
+
export declare function executeMachineCoherenceEffects(effects: EpisodeEffect[], deps: EffectsExecutorDeps): void;
|
|
50
|
+
//# sourceMappingURL=machineCoherenceEffectsExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machineCoherenceEffectsExecutor.d.ts","sourceRoot":"","sources":["../../src/monitoring/machineCoherenceEffectsExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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AG,IAAI,CA8BxG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-coherence effects executor (calm-transient-episode-alerting M-P2).
|
|
3
|
+
*
|
|
4
|
+
* Extracted from the server.ts boot closure — the exact site of the original
|
|
5
|
+
* hardcoded-`priority: 'HIGH'` bug — into an injectable, unit-testable module.
|
|
6
|
+
* The executor is a PASS-THROUGH: priority / silent / copy decisions live in
|
|
7
|
+
* the episode manager (where dimension/stall/flap/interacted context lives);
|
|
8
|
+
* this module only carries them to the Telegram chokepoints.
|
|
9
|
+
*
|
|
10
|
+
* Fail-toward-silence: every effect executes fire-and-forget with its own
|
|
11
|
+
* catch — a Telegram fault must never crash the shared presence tick; the next
|
|
12
|
+
* reconcile re-derives from durable episode state.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Execute one batch of episode effects. Each effect runs independently
|
|
16
|
+
* (fire-and-forget, own catch) — one fault never blocks the rest.
|
|
17
|
+
*/
|
|
18
|
+
export function executeMachineCoherenceEffects(effects, deps) {
|
|
19
|
+
for (const eff of effects) {
|
|
20
|
+
void (async () => {
|
|
21
|
+
try {
|
|
22
|
+
const tg = deps.telegram();
|
|
23
|
+
if (eff.kind === 'raise') {
|
|
24
|
+
await tg?.createAttentionItem({
|
|
25
|
+
id: eff.itemId, title: eff.title, summary: eff.summary, description: eff.description,
|
|
26
|
+
category: 'machine-coherence',
|
|
27
|
+
// M-P2 pass-through: the manager decides; absent = legacy HIGH.
|
|
28
|
+
priority: eff.priority ?? 'HIGH',
|
|
29
|
+
silent: eff.silent === true,
|
|
30
|
+
sourceContext: 'machine-coherence-guard',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (eff.kind === 'append') {
|
|
34
|
+
const item = tg?.getAttentionItem(eff.itemId);
|
|
35
|
+
if (item?.topicId !== undefined)
|
|
36
|
+
await tg?.sendToTopic(item.topicId, eff.text, { silent: eff.silent === true });
|
|
37
|
+
}
|
|
38
|
+
else if (eff.kind === 'resolve') {
|
|
39
|
+
const item = tg?.getAttentionItem(eff.itemId);
|
|
40
|
+
if (item?.topicId !== undefined)
|
|
41
|
+
await tg?.sendToTopic(item.topicId, eff.note, { silent: eff.silent === true });
|
|
42
|
+
await tg?.updateAttentionStatus(eff.itemId, 'DONE', { silent: eff.silent === true });
|
|
43
|
+
}
|
|
44
|
+
else if (eff.kind === 'resolve-status') {
|
|
45
|
+
// Orphan self-closeout arm: status-only DONE, no message ever.
|
|
46
|
+
await tg?.updateAttentionStatus(eff.itemId, 'DONE', { silent: true });
|
|
47
|
+
}
|
|
48
|
+
else if (eff.kind === 'execute-fix') {
|
|
49
|
+
await deps.onExecuteFix?.(eff);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch { /* @silent-fallback-ok: episode effect execution is best-effort; a Telegram send/create fault must never crash the presence tick — the next reconcile re-derives from durable episode state */ }
|
|
53
|
+
})();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=machineCoherenceEffectsExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machineCoherenceEffectsExecutor.js","sourceRoot":"","sources":["../../src/monitoring/machineCoherenceEffectsExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAsBH;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,OAAwB,EAAE,IAAyB;IAChG,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,IAAI,CAAC;gBACH,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC3B,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBACzB,MAAM,EAAE,EAAE,mBAAmB,CAAC;wBAC5B,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,GAA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MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBACxE,CAAC;qBAAM,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;oBACtC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;gBACjC,CAAC;YACH,CAAC;YAAC,MAAM,CAAC,CAAC,8LAA8L,CAAC,CAAC;QAC5M,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;AACH,CAAC"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* Supervision tier (N6): Tier 0 — deterministic file I/O, no LLM anywhere.
|
|
19
19
|
*/
|
|
20
20
|
import type { SkewDimension } from './machineCoherenceEvaluate.js';
|
|
21
|
+
import type { AnchorsBlock } from './machineCoherenceAnchors.js';
|
|
21
22
|
/** The pendingFix three-state lifecycle (§4.2.1-i, R3-M6 / R4-M2). */
|
|
22
23
|
export type PendingFixState = 'proposed' | 'approved-holding' | 'executing-verifying';
|
|
23
24
|
/**
|
|
@@ -83,6 +84,10 @@ export interface RecurrenceBlock {
|
|
|
83
84
|
};
|
|
84
85
|
/** When the per-day-cap give-up note last fired (once per rolling 24 h). */
|
|
85
86
|
capGiveupAtMs?: number;
|
|
87
|
+
/** calm-alerting M-P2 resolve-note bounding: last resolve NOTE per item id
|
|
88
|
+
* (at most one per reopenWindowMs; latched-flapping closes are jsonl-only).
|
|
89
|
+
* Additive. */
|
|
90
|
+
resolveNoteAtByItem?: Record<string, number>;
|
|
86
91
|
}
|
|
87
92
|
/** A §4.3 close reason — only `restored` may ever claim restoration. */
|
|
88
93
|
export type EpisodeCloseReason = 'restored' | 'suspended-peer-offline' | 'suspended-peer-unverifiable' | 'expired-peer-gone' | 'superseded-by-takeover' | 'resolved-after-reenable' | 'manifest-changed' | 'state-rebaselined';
|
|
@@ -110,6 +115,24 @@ export interface EpisodeState {
|
|
|
110
115
|
escalationAppended?: boolean;
|
|
111
116
|
/** Re-open count carried on the episode (§4.5 damper). */
|
|
112
117
|
reopenCount?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Derived escalation item ids raised for this episode (`<itemId>:stalled` /
|
|
120
|
+
* `<itemId>:recurring`) — the close path resolves EVERY one (calm-alerting
|
|
121
|
+
* M-P2 derived-item lifecycle); doubles as the restart-proof per-episode
|
|
122
|
+
* once-per-class raise record. Additive.
|
|
123
|
+
*/
|
|
124
|
+
derivedItemIds?: string[];
|
|
125
|
+
/** calm-alerting: episode classified calm at open (all rows patch-only version
|
|
126
|
+
* skew under the calm gate) — drives silent narration + close mode. Additive. */
|
|
127
|
+
calmClass?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Durable operator-interaction bit (calm-alerting M-P2): set ONLY by
|
|
130
|
+
* evidence-carrying operator actions (fix approval / explicit ack), NEVER
|
|
131
|
+
* derived from pendingFix presence (auto-created at raise, cleared on every
|
|
132
|
+
* fix path). Interacted episodes close with a notifying resolve note; a
|
|
133
|
+
* reopen does NOT carry it. Additive.
|
|
134
|
+
*/
|
|
135
|
+
operatorInteracted?: boolean;
|
|
113
136
|
recurrence: RecurrenceBlock;
|
|
114
137
|
}
|
|
115
138
|
/** The on-disk file shape: the open episode (or null) + the outliving recurrence. */
|
|
@@ -119,6 +142,13 @@ export interface EpisodeFile {
|
|
|
119
142
|
episode: EpisodeState | null;
|
|
120
143
|
/** Outlives episode close — the reopen window's memory (R2-N2). */
|
|
121
144
|
recurrence: RecurrenceBlock;
|
|
145
|
+
/**
|
|
146
|
+
* The M-P0 identity-independent clock layer (calm-transient-episode-alerting
|
|
147
|
+
* spec) — STRICTLY ADDITIVE: `version` stays 1, the reader is lenient to it,
|
|
148
|
+
* and a binary rollback treats it as inert. Absent on files written before
|
|
149
|
+
* the calm-alerting feature.
|
|
150
|
+
*/
|
|
151
|
+
anchors?: AnchorsBlock;
|
|
122
152
|
}
|
|
123
153
|
/** The result of a durable read — absent / ok / corrupt (§4.6 re-baseline gate). */
|
|
124
154
|
export type EpisodeReadResult = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machineCoherenceEpisode.d.ts","sourceRoot":"","sources":["../../src/monitoring/machineCoherenceEpisode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"machineCoherenceEpisode.d.ts","sourceRoot":"","sources":["../../src/monitoring/machineCoherenceEpisode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,sEAAsE;AACtE,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;AAEtF;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,eAAe,CAAC;IACvB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,aAAa,CAAC;IACzB,6EAA6E;IAC7E,eAAe,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;6EACyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;qFACiF;IACjF,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,iBAAiB,EAAE,MAAM,EAAE,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AAI,CAM1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machineCoherenceEpisode.js","sourceRoot":"","sources":["../../src/monitoring/machineCoherenceEpisode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"machineCoherenceEpisode.js","sourceRoot":"","sources":["../../src/monitoring/machineCoherenceEpisode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AA+I7B,0EAA0E;AAC1E,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,MAAM,UAAU,EAAE,CAAC;AAC5B,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,gCAAgC,CAAC,CAAC;AACxE,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe;IAC7B,OAAO,EAAE,iBAAiB,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,MAAM,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;YAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QACnD,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,MAAM,EAAE,SAAS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S,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;QACxD,CAAC;IACH,CAAC;IACD,MAAM,GAAG,GAAG,GAAG,CAAC,UAAqC,CAAC;IACtD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QAChF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAA6B,EAAE,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,IAAiB;IAClE,MAAM,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACrC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IACpD,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5D,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -21,25 +21,39 @@
|
|
|
21
21
|
* (reply recognition, when it lands in b3, lives in the CONVERSATIONAL agent,
|
|
22
22
|
* never here — D17 intact).
|
|
23
23
|
*/
|
|
24
|
-
import type { SkewRow } from './machineCoherenceEvaluate.js';
|
|
24
|
+
import type { SkewRow, SkewDimension } from './machineCoherenceEvaluate.js';
|
|
25
25
|
import type { MachineCoherenceResolvedConfig } from './MachineCoherenceSentinel.js';
|
|
26
26
|
import { type EpisodeCloseReason, type EpisodeState, type PendingFixState } from './machineCoherenceEpisode.js';
|
|
27
|
+
import { type AnchorsBlock, type PatchSkewDecision } from './machineCoherenceAnchors.js';
|
|
27
28
|
/** One effect the sentinel/server executes (the manager never does I/O beyond
|
|
28
|
-
* its own durable file + jsonl — telegram effects are the caller's).
|
|
29
|
+
* its own durable file + jsonl — telegram effects are the caller's).
|
|
30
|
+
* calm-alerting M-P2: `priority` + `silent` ride the effect (the consumer is a
|
|
31
|
+
* pass-through — the decision lives HERE, where dimension/stall/flap/interacted
|
|
32
|
+
* context lives); absent fields mean legacy behavior (HIGH, notifying). */
|
|
29
33
|
export type EpisodeEffect = {
|
|
30
34
|
kind: 'raise';
|
|
31
35
|
itemId: string;
|
|
32
36
|
title: string;
|
|
33
37
|
summary: string;
|
|
34
38
|
description: string;
|
|
39
|
+
priority?: 'NORMAL' | 'HIGH';
|
|
40
|
+
silent?: boolean;
|
|
35
41
|
} | {
|
|
36
42
|
kind: 'append';
|
|
37
43
|
itemId: string;
|
|
38
44
|
text: string;
|
|
45
|
+
silent?: boolean;
|
|
39
46
|
} | {
|
|
40
47
|
kind: 'resolve';
|
|
41
48
|
itemId: string;
|
|
42
49
|
note: string;
|
|
50
|
+
silent?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** Status-only DONE (no message) — the orphan self-closeout arm: every machine
|
|
53
|
+
* transitions its OWN items on every close reason, regardless of speaks(). */
|
|
54
|
+
| {
|
|
55
|
+
kind: 'resolve-status';
|
|
56
|
+
itemId: string;
|
|
43
57
|
} | {
|
|
44
58
|
kind: 'execute-fix';
|
|
45
59
|
itemId: string;
|
|
@@ -72,6 +86,11 @@ export interface EpisodeReconcileInput {
|
|
|
72
86
|
/** machineId → operator-facing nickname (registry display label; escaped at render). */
|
|
73
87
|
nicknameOf: (machineId: string) => string;
|
|
74
88
|
now: number;
|
|
89
|
+
/** calm-alerting M-P0 feed (consumed only under cfg.calmEnabled): this tick's
|
|
90
|
+
* POST-M6-suppression raw divergent rows + raw advertised versions + cadence. */
|
|
91
|
+
rawRows?: SkewRow[];
|
|
92
|
+
versionsByMachine?: Record<string, string>;
|
|
93
|
+
tickMs?: number;
|
|
75
94
|
}
|
|
76
95
|
/** Observability counters (surfaced on the sentinel status snapshot / route). */
|
|
77
96
|
export interface EpisodeManagerCounters {
|
|
@@ -107,6 +126,38 @@ export declare class MachineCoherenceEpisodeManager {
|
|
|
107
126
|
* the effects the caller executes; the durable file + jsonl are written here.
|
|
108
127
|
*/
|
|
109
128
|
reconcile(input: EpisodeReconcileInput): EpisodeEffect[];
|
|
129
|
+
/** The last raw versions seen (derived-raise laggard naming + calm decisions). */
|
|
130
|
+
private lastVersionsByMachine;
|
|
131
|
+
/** M-P1 patch-only confirmation decision over the durable anchors. */
|
|
132
|
+
decidePatchSkewConfirmation(key: string, nowMs: number, versionsByMachine: Record<string, string>): PatchSkewDecision;
|
|
133
|
+
/** Sentinel → flap accounting: a confirm transition on (dimension, key). */
|
|
134
|
+
noteConfirmTransition(dimension: SkewDimension, key: string): void;
|
|
135
|
+
/** Read-only anchors view (status route / tests). */
|
|
136
|
+
anchorsView(): AnchorsBlock | null;
|
|
137
|
+
/** An episode is calm-class iff EVERY row is patch-only version skew (set at
|
|
138
|
+
* open; a joined non-calm row upgrades the episode to loud via joinRows). */
|
|
139
|
+
private classifyCalm;
|
|
140
|
+
/**
|
|
141
|
+
* M-P2 derived escalations on an OPEN episode: the stall ceiling (`:stalled`)
|
|
142
|
+
* and the flap brake (`:recurring`). Both are notifying HIGH raises under
|
|
143
|
+
* derived ids — cap-exempt by construction (≤1 per key per 24 h via the
|
|
144
|
+
* durable anchor latches + ≤1 per class per episode via derivedItemIds).
|
|
145
|
+
* The fail-loud invariant: an armed latch whose raise cannot be emitted
|
|
146
|
+
* (no base item id) increments escalationRaiseFailed and logs.
|
|
147
|
+
*/
|
|
148
|
+
private maybeDerivedEscalations;
|
|
149
|
+
/** calm-alerting observability counters (surfaced on the status route). */
|
|
150
|
+
readonly countersCalm: {
|
|
151
|
+
progressExtensions: number;
|
|
152
|
+
ceilingConfirms: number;
|
|
153
|
+
flapBrakeFires: number;
|
|
154
|
+
calmRaises: number;
|
|
155
|
+
calmRaisesSilent: number;
|
|
156
|
+
silentResolves: number;
|
|
157
|
+
resolveNotesSuppressed: number;
|
|
158
|
+
waveBackstopFires: number;
|
|
159
|
+
escalationRaiseFailed: number;
|
|
160
|
+
};
|
|
110
161
|
private episodeParticipants;
|
|
111
162
|
/** A row's manifest key retired from the intersection (only meaningful for flag rows). */
|
|
112
163
|
private rowKeyRetired;
|
|
@@ -166,13 +217,24 @@ export declare class MachineCoherenceEpisodeManager {
|
|
|
166
217
|
private applyResume;
|
|
167
218
|
private maybeEscalate;
|
|
168
219
|
private closeEpisode;
|
|
220
|
+
/** Any version key on these rows already past the stall ceiling (anchors read). */
|
|
221
|
+
private anyVersionKeyPastCeiling;
|
|
222
|
+
/**
|
|
223
|
+
* Calm-copy body (calm-alerting M-P2): the observed skew + self-heal-in-
|
|
224
|
+
* progress + will-escalate-if-stalled. Deliberately NO fix-it/leave-it prompt
|
|
225
|
+
* — a decision prompt on a self-healing notice is the contradictory UX the
|
|
226
|
+
* round-1 review flagged; the prompt arrives with the stall/flap escalation.
|
|
227
|
+
*/
|
|
228
|
+
private renderCalmBody;
|
|
169
229
|
private closeNote;
|
|
170
230
|
/**
|
|
171
231
|
* Set (or clear) the durable operator "leave it" ack (§4.2 / R4-N2). Called by
|
|
172
232
|
* the conversational reply path. Suppresses the §4.4 escalation for this
|
|
173
233
|
* episode; cleared on a genuine §4.5 recurrence re-open (b2).
|
|
174
234
|
*/
|
|
175
|
-
setOperatorAck(ack: boolean
|
|
235
|
+
setOperatorAck(ack: boolean, opts?: {
|
|
236
|
+
verifiedOperator?: boolean;
|
|
237
|
+
}): void;
|
|
176
238
|
/** A suspended episode past the expiry closes `expired-peer-gone` (§4.3). Called each tick by the sentinel. */
|
|
177
239
|
expireIfStale(now: number, nicknameOf: (m: string) => string): EpisodeEffect[];
|
|
178
240
|
status(): {
|