opencode-self-improvement 0.15.27 → 0.15.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.15.27",
3
+ "version": "0.15.29",
4
4
  "description": "Durable memory for opencode: remember facts, decisions, and commands across sessions, plus a one-command per-repo setup (/repo-init).",
5
5
  "main": "index.ts",
6
6
  "exports": {
@@ -42,6 +42,18 @@ const ENGAGEMENT_TOOLS = new Set([
42
42
  ]);
43
43
 
44
44
  const RECENT_EVIDENCE_CALLS = 10;
45
+ // #224: the retained call tail. A resident server must not grow one session's
46
+ // ledger without bound; past the cap the OLDEST entries drop. Everything the
47
+ // pipeline needs past the cap is recorded on SessionState as it happens
48
+ // (callsTotal, reDerives, firstCallTs, sawEngagement, sawGateCheck), so
49
+ // telemetry counts, grounding signals and ms_to_tap keep their full-session
50
+ // meaning; attribution (callsFor) sees the retained tail.
51
+ // The cap sits ABOVE the 2,000-call scale pinned by write-evidence.test.ts
52
+ // (#163: the full ledger stays available at that scale), so that contract
53
+ // keeps holding; the bound is the point — a pathological resident session
54
+ // grows this to hundreds of thousands of entries, and 4,096 is where the
55
+ // tail is cut.
56
+ export const CALLS_CAP = 4096;
45
57
  // Pending recovery stores IDs only; the full attribution ledger stays in calls.
46
58
  function trackPending(s: SessionState, rec: ToolResult): void {
47
59
  const pending = s.pendingGate;
@@ -58,6 +70,12 @@ export const MAX_WRITE_EVIDENCE_REFS = RECENT_EVIDENCE_CALLS + 1 + 3 + 2;
58
70
 
59
71
  function trackCall(s: SessionState, rec: ToolResult): void {
60
72
  s.calls.push(rec);
73
+ s.callsTotal++;
74
+ if (["grep", "glob", "read"].includes(rec.tool)) s.reDerives++;
75
+ if (!s.firstCallTs) s.firstCallTs = rec.ts;
76
+ if (ENGAGEMENT_TOOLS.has(rec.tool)) s.sawEngagement = true;
77
+ if (rec.gateCheck) s.sawGateCheck = true;
78
+ if (s.calls.length > CALLS_CAP) s.calls.splice(0, s.calls.length - CALLS_CAP);
61
79
  s.writeEvidence ??= { recent: [] };
62
80
  const evidence = s.writeEvidence;
63
81
  if (ENGAGEMENT_TOOLS.has(rec.tool)) {
@@ -69,9 +87,10 @@ function trackCall(s: SessionState, rec: ToolResult): void {
69
87
 
70
88
  // True once the session has exercised the codebase (the FAIL->PASS signals use
71
89
  // the same whitelist, so engagement == "a tool_result was recorded for a code
72
- // tool").
90
+ // tool"). Sticky (#224): the CALLS_CAP tail dropping the original engagement
91
+ // call must not un-ground a session that demonstrably engaged.
73
92
  export function hasEngagement(sid: string): boolean {
74
- return session(sid).calls.some((c) => ENGAGEMENT_TOOLS.has(c.tool));
93
+ return session(sid).sawEngagement;
75
94
  }
76
95
 
77
96
  const GATE_CMDS: [RegExp, string][] = [
@@ -247,7 +266,7 @@ export async function onCompacting(input: AfterInput): Promise<void> {
247
266
  "t2_compaction",
248
267
  {
249
268
  session: sid,
250
- captured_calls: s.calls.length,
269
+ captured_calls: s.callsTotal,
251
270
  pending_gate: s.pendingGate ? s.pendingGate.call : "-",
252
271
  },
253
272
  false,
@@ -255,8 +274,9 @@ export async function onCompacting(input: AfterInput): Promise<void> {
255
274
  await finalizeSession(sid);
256
275
  }
257
276
 
258
- // Full IDs for callers that explicitly need the ledger. Production write
259
- // contexts use writeEvidence so they do not allocate this growing list.
277
+ // IDs for callers that explicitly need the ledger: the retained tail (capped
278
+ // at CALLS_CAP, oldest dropped first — #224). Production write contexts use
279
+ // writeEvidence so they do not allocate this growing list.
260
280
  export function evidenceCalls(sid: string): string[] {
261
281
  return session(sid).calls.map((c) => c.call);
262
282
  }
@@ -277,16 +297,18 @@ export function writeEvidence(sid: string): {
277
297
  ...(evidence?.gateCheck !== undefined ? [evidence.gateCheck] : []),
278
298
  ...(evidence?.recent ?? []),
279
299
  ]);
280
- return { evidenceCalls: [...refs], evidenceCallsCount: s.calls.length };
300
+ return { evidenceCalls: [...refs], evidenceCallsCount: s.callsTotal };
281
301
  }
282
302
 
283
- // The full per-session tool ledger, for memory attribution (src/attribution.ts).
303
+ // The per-session tool ledger for memory attribution (src/attribution.ts):
304
+ // the retained tail, capped at CALLS_CAP with the oldest calls dropped first
305
+ // (#224), so a resident server bounds memory instead of holding every call.
284
306
  export function callsFor(sid: string): ToolResult[] {
285
307
  return session(sid).calls;
286
308
  }
287
309
 
288
310
  export function hasGateCheck(sid: string): boolean {
289
- return session(sid).calls.some((c) => c.gateCheck === true);
311
+ return session(sid).sawGateCheck;
290
312
  }
291
313
 
292
314
  // ---- Session-convergence tracking (time-to-frontier) -----------------------
@@ -321,9 +343,9 @@ export async function finalizeSession(sid: string): Promise<void> {
321
343
  const s = session(sid);
322
344
  if (s.finalized) return;
323
345
  s.finalized = true;
324
- if (s.calls.length === 0 && s.turns === 0) return;
346
+ if (s.callsTotal === 0 && s.turns === 0) return;
325
347
  const tap = s.firstTap;
326
- const start = s.firstActivityTs ?? s.calls[0]?.ts;
348
+ const start = s.firstActivityTs ?? s.firstCallTs;
327
349
  const ms =
328
350
  tap && start
329
351
  ? Math.max(0, Date.parse(tap.ts) - Date.parse(start))
@@ -335,11 +357,9 @@ export async function finalizeSession(sid: string): Promise<void> {
335
357
  turns: s.turns,
336
358
  tap_at: tap ? tap.call : "-",
337
359
  turns_to_tap: tap ? tap.turn : undefined,
338
- re_derives: s.calls.filter((c) =>
339
- ["grep", "glob", "read"].includes(c.tool),
340
- ).length,
360
+ re_derives: s.reDerives,
341
361
  ms_to_tap: ms,
342
- calls: s.calls.length,
362
+ calls: s.callsTotal,
343
363
  },
344
364
  false,
345
365
  );
package/src/core/hooks.ts CHANGED
@@ -1,4 +1,24 @@
1
1
  // Fail-soft wrapper for plugin bookkeeping hooks (#168).
2
+ //
3
+ // Fail-soft must never mean invisible (#138): a plugin whose hook failed on
4
+ // EVERY turn looked identical to a healthy one in every artifact, because the
5
+ // only trace was a console.warn into the host log. setup() installs a failure
6
+ // reporter that mirrors each swallowed error into the evidence file; the
7
+ // reporter is optional so this module stays free of the evidence dependency
8
+ // and a broken reporter can never change the swallow contract.
9
+ export type GuardedFailure = (
10
+ name: string,
11
+ err: unknown,
12
+ ) => void | Promise<void>;
13
+
14
+ let failureReporter: GuardedFailure | undefined;
15
+
16
+ export function setGuardedFailureReporter(
17
+ reporter: GuardedFailure | undefined,
18
+ ): void {
19
+ failureReporter = reporter;
20
+ }
21
+
2
22
  export async function guarded(
3
23
  name: string,
4
24
  fn: () => Promise<void>,
@@ -10,5 +30,13 @@ export async function guarded(
10
30
  `[opencode-self-improvement] ${name} hook failed (ignored):`,
11
31
  err,
12
32
  );
33
+ // Report AFTER the warn, and await the reporter so a caller that awaits
34
+ // guarded() can observe the evidence line; any reporter failure is itself
35
+ // swallowed — the console line is the primary trace, evidence the mirror.
36
+ try {
37
+ await failureReporter?.(name, err);
38
+ } catch {
39
+ // a failing reporter is itself a swallowed failure — never a throw
40
+ }
13
41
  }
14
42
  }
package/src/core/lru.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  // recency list owns eviction so the maps are always dropped together: an
5
5
  // evicted session simply starts over (no block until its next prompt, then a
6
6
  // "first" epoch), which costs one recompute and never serves stale state.
7
- // Same cap as repokey.ts's session-scope cache.
7
+ // Single shared cap: repokey.ts's session-scope cache imports this constant,
8
+ // so the ledgers cannot drift (#224).
8
9
  export const SESSION_CAP = 64;
9
10
 
10
11
  export class SessionLru {
package/src/core/state.ts CHANGED
@@ -27,6 +27,14 @@ export interface FirstTap {
27
27
  export interface SessionState {
28
28
  sid: string;
29
29
  calls: ToolResult[];
30
+ // Lifetime facts that outlive the CALLS_CAP tail (#224): calls keeps only
31
+ // the most recent CALLS_CAP entries, so counts and ever-seen signals are
32
+ // recorded as they happen instead of being derived from the array.
33
+ callsTotal: number;
34
+ reDerives: number;
35
+ firstCallTs?: string;
36
+ sawEngagement: boolean;
37
+ sawGateCheck: boolean;
30
38
  // Last observed status per tool, so a FAIL->PASS transition is visible.
31
39
  lastByTool: Map<
32
40
  string,
@@ -104,12 +112,25 @@ export function setLastSeenSid(sid: string): void {
104
112
 
105
113
  const sessions = new Map<string, SessionState>();
106
114
 
115
+ // Bounded like every other session-keyed ledger (#224): a resident server must
116
+ // not retain a SessionState for every session it ever saw. An evicted session
117
+ // starts over — its retained call tail and lifetime counters are dropped, the
118
+ // same "starts over" cost lru.ts already accepts for the epoch caches.
119
+ const sessionOrder = new SessionLru(SESSION_CAP, (sid) => {
120
+ sessions.delete(sid);
121
+ });
122
+
107
123
  export function session(sid: string): SessionState {
124
+ sessionOrder.touch(sid);
108
125
  let s = sessions.get(sid);
109
126
  if (!s) {
110
127
  s = {
111
128
  sid,
112
129
  calls: [],
130
+ callsTotal: 0,
131
+ reDerives: 0,
132
+ sawEngagement: false,
133
+ sawGateCheck: false,
113
134
  lastByTool: new Map(),
114
135
  pendingGate: null,
115
136
  turns: 0,
@@ -17,6 +17,7 @@
17
17
  // everywhere — which keeps every upgrade non-breaking.
18
18
  import { createHash } from "node:crypto";
19
19
  import { lstatSync, realpathSync, statSync } from "node:fs";
20
+ import { SESSION_CAP } from "../core/lru.ts";
20
21
 
21
22
  export interface RepoScope {
22
23
  key: string;
@@ -183,9 +184,10 @@ export function resolveRepo(startDir: string): RepoScope {
183
184
  }
184
185
 
185
186
  // --- per-session identity -----------------------------------------------------
186
- // Learned from session events (created / execution.started / moved). Bounded:
187
- // a long-lived server must not grow this with every session ever seen.
188
- const SESSION_CAP = 64;
187
+ // Learned from session events (created / execution.started / moved). Bounded
188
+ // by the shared session cap imported from core/lru.ts, so the two caps cannot
189
+ // drift (#224): a long-lived server must not grow this with every session
190
+ // ever seen.
189
191
  const byDir = new Map<string, RepoScope>();
190
192
  const bySession = new Map<string, { dir: string; scope: RepoScope }>();
191
193
 
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  // src/command.ts. The default export `{ id, setup(ctx) }` is checked against
9
9
  // the SDK's Plugin type using a type-only import (see the note on `plugin`).
10
10
  import { registerHooks } from "./events.ts";
11
- import { guarded } from "./core/hooks.ts";
11
+ import { guarded, setGuardedFailureReporter } from "./core/hooks.ts";
12
12
  import type { PluginCtx } from "./core/host.ts";
13
13
  import type { Cleanup, Plugin } from "@opencode/plugin/promise/plugin";
14
14
  import { basename, join } from "node:path";
@@ -122,6 +122,23 @@ const impl = {
122
122
  // only as the gate's verification tree when no session location is known.
123
123
  const setupRoot = ctx?.location?.directory;
124
124
  const liveRoot = setupRoot ?? process.cwd();
125
+ // #138: mirror every swallowed guarded() failure into the evidence file.
126
+ // Hook name + error class ONLY — never the message, which can carry
127
+ // conversation content. Fire-and-forget: evidence must not add a failure
128
+ // to a path that already failed softly.
129
+ setGuardedFailureReporter((name, err) =>
130
+ record(
131
+ "hook_error",
132
+ {
133
+ hook: name,
134
+ error:
135
+ err instanceof Error
136
+ ? err.constructor?.name || "Error"
137
+ : typeof err,
138
+ },
139
+ false,
140
+ ).catch(() => {}),
141
+ );
125
142
  setRepoScope(setupRoot ? resolveRepo(setupRoot) : null);
126
143
  // THIS instance's own workspace. The module scope says who loaded last;
127
144
  // this says who I am. An unbound session that calls into THIS instance
@@ -285,7 +302,12 @@ const impl = {
285
302
  );
286
303
  });
287
304
  const captureState = !wantCapture
288
- ? "off"
305
+ ? // captureOnCompact alone is a distinct misconfiguration (the
306
+ // runtime warns about it and stays disabled) — name it, or "off
307
+ // (default)" and "wrong switch set" share one line (#138).
308
+ ctx.options?.captureOnCompact === true
309
+ ? "switch_mismatch"
310
+ : "off"
289
311
  : !modelOk
290
312
  ? "invalid_model"
291
313
  : capabilities.length < 3
@@ -5,6 +5,7 @@ import { isInjectable } from "../store/model/predicates.ts";
5
5
  import { readerFromSid, visibleTo } from "../store/model/visibility.ts";
6
6
  import { record } from "../evidence/record.ts";
7
7
  import { frontierBudget } from "../core/config/budgets.ts";
8
+ import { SESSION_CAP, SessionLru } from "../core/lru.ts";
8
9
  import { dateStr } from "../core/time.ts";
9
10
  import { bracketList } from "../core/logfmt/format.ts";
10
11
  import { recentConvergenceSummary } from "../capture/triggers.ts";
@@ -19,6 +20,12 @@ import { type TransformOutput } from "./pull.ts";
19
20
  const OPEN_THREAD_LIMIT = 3;
20
21
 
21
22
  const frontierInjectedSessions = new Set<string>();
23
+ // #224: the "once per process" set is bounded by the shared session cap. An
24
+ // evicted session is shown the frontier block once more on a later prompt —
25
+ // one extra evidence row, never unbounded growth.
26
+ const frontierOrder = new SessionLru(SESSION_CAP, (sid) => {
27
+ frontierInjectedSessions.delete(sid);
28
+ });
22
29
 
23
30
  export interface DigestOptions {
24
31
  // Rows the caller already loaded for this request (shared with the epoch).
@@ -78,6 +85,7 @@ export async function systemDigest(
78
85
 
79
86
  if (frontierInjectedSessions.has(sid)) return;
80
87
  frontierInjectedSessions.add(sid);
88
+ frontierOrder.touch(sid);
81
89
  const openMems = mems.filter((m) => m.status === "open");
82
90
  await record(
83
91
  "frontier_injected",
@@ -79,3 +79,92 @@ export async function captureLagLines(days = 30): Promise<string[]> {
79
79
  }
80
80
  return out;
81
81
  }
82
+
83
+ /**
84
+ * Capture health (#138): the answer to "is auto-capture off, misconfigured,
85
+ * armed-but-inert, or alive?" read from the evidence file ALONE — the
86
+ * `plugin_load` heartbeat names the configured state, `auto_capture_*` lines
87
+ * name the activity. The newest heartbeat wins (a reload with new options
88
+ * replaces the old state); activity is counted inside the trailing window.
89
+ */
90
+ export type CaptureHealthState =
91
+ | "unknown"
92
+ | "off"
93
+ | "switch_mismatch"
94
+ | "invalid_model"
95
+ | "no_capabilities"
96
+ | "on";
97
+
98
+ export interface CaptureHealth {
99
+ state: CaptureHealthState;
100
+ /** Promoted capture rows in the window. */
101
+ rows: number;
102
+ /** Blocked / refused / partial capture outcomes in the window. */
103
+ blocked: number;
104
+ /** Newest `auto_capture_*` line, or null when nothing fired. */
105
+ lastFired: string | null;
106
+ /**
107
+ * Newest `capture_lag` completion receipt in the window: proof the capture
108
+ * ran, independent of candidate outcome. A model response of `[]` writes
109
+ * only this line, so the inert verdict must consult it (#288 F1).
110
+ */
111
+ lastExecuted: string | null;
112
+ }
113
+
114
+ const CAPTURE_STATES: readonly CaptureHealthState[] = [
115
+ "off",
116
+ "switch_mismatch",
117
+ "invalid_model",
118
+ "no_capabilities",
119
+ "on",
120
+ ];
121
+
122
+ export function captureHealth(
123
+ lines: string[],
124
+ days = 30,
125
+ now = Date.now(),
126
+ ): CaptureHealth {
127
+ const cutoff = new Date(now - days * 86_400_000).toISOString();
128
+ let state: CaptureHealthState = "unknown";
129
+ let newestHeartbeat = "";
130
+ let rows = 0;
131
+ let blocked = 0;
132
+ let lastFired: string | null = null;
133
+ let lastExecuted: string | null = null;
134
+ for (const line of lines) {
135
+ const f = parseLine(line);
136
+ if (!f) continue;
137
+ const ev = String(f.ev ?? "");
138
+ const ts = typeof f.ts === "string" ? f.ts : "";
139
+ if (ev === "plugin_load") {
140
+ // Newest wins regardless of the order files were read in. A heartbeat
141
+ // whose capture field is missing or unrecognized names no state.
142
+ if (ts >= newestHeartbeat) {
143
+ newestHeartbeat = ts;
144
+ const c = String(f.capture ?? "");
145
+ state = (CAPTURE_STATES as readonly string[]).includes(c)
146
+ ? (c as CaptureHealthState)
147
+ : "unknown";
148
+ }
149
+ continue;
150
+ }
151
+ if (ev === "capture_lag") {
152
+ // Completion receipt: the model call finished whether or not it found
153
+ // candidates. Execution evidence on its own (#288 F1).
154
+ if (ts && ts >= cutoff && (!lastExecuted || ts > lastExecuted))
155
+ lastExecuted = ts;
156
+ continue;
157
+ }
158
+ if (!ev.startsWith("auto_capture_")) continue;
159
+ if (ts && ts < cutoff) continue;
160
+ if (ev.endsWith("promoted")) rows++;
161
+ else if (
162
+ ev.endsWith("blocked") ||
163
+ ev.endsWith("refused") ||
164
+ ev.endsWith("partial")
165
+ )
166
+ blocked++;
167
+ if (ts && (!lastFired || ts > lastFired)) lastFired = ts;
168
+ }
169
+ return { state, rows, blocked, lastFired, lastExecuted };
170
+ }
@@ -1,7 +1,12 @@
1
1
  // report — split from src/status.ts (#168 domain restructure). Declaration bodies are unchanged.
2
2
  import { join } from "node:path";
3
3
  import { cacheRate, estTok, fmtBytes, fmtCount, fmtMs } from "./format.ts";
4
- import { captureLag, ledgerIsYoung, rowsPerDay } from "./metrics.ts";
4
+ import {
5
+ type CaptureHealth,
6
+ captureLag,
7
+ ledgerIsYoung,
8
+ rowsPerDay,
9
+ } from "./metrics.ts";
5
10
  import {
6
11
  type BlockedRow,
7
12
  type StatusPayload,
@@ -136,6 +141,50 @@ export function attributionLines(p: StatusPayload): string[] {
136
141
  ];
137
142
  }
138
143
 
144
+ /**
145
+ * AUTO-CAPTURE line (#138): the chat-facing answer to "is capture off,
146
+ * misconfigured, armed-but-inert, or alive?" — the states the evidence file
147
+ * distinguishes, surfaced so a user never has to read a logfmt file to learn
148
+ * the pipeline never ran. `unknown` means no heartbeat was found at all, which
149
+ * is itself the answer the dead-pipeline bug needed.
150
+ */
151
+ export function captureLines(c: CaptureHealth): string[] {
152
+ switch (c.state) {
153
+ case "off":
154
+ return [" auto-capture: off (default)"];
155
+ case "invalid_model":
156
+ return [
157
+ " auto-capture: invalid_model — autoCapture is on but captureModel is malformed; nothing fires",
158
+ ];
159
+ case "no_capabilities":
160
+ return [
161
+ " auto-capture: no_capabilities — autoCapture is on but the host lacks event.subscribe/generate.text/session.context",
162
+ ];
163
+ case "switch_mismatch":
164
+ return [
165
+ " auto-capture: switch_mismatch — captureOnCompact is on but autoCapture is off; nothing fires",
166
+ ];
167
+ case "on": {
168
+ // Inert means NO execution evidence at all: no candidate line and no
169
+ // `capture_lag` completion receipt. A successful capture whose model
170
+ // returned `[]` writes only the receipt, and is alive, not inert
171
+ // (#288 F1).
172
+ if (!c.lastExecuted && c.rows === 0 && c.blocked === 0)
173
+ return [
174
+ " auto-capture: ARMED BUT NEVER FIRED — capture is on, no auto_capture_* or capture_lag lines in the last 30d",
175
+ ];
176
+ const fired = c.lastFired ?? c.lastExecuted;
177
+ return [
178
+ ` auto-capture: on, last fired ${fired ? ago(fired) : "now"}, ${c.rows} rows, ${c.blocked} refused`,
179
+ ];
180
+ }
181
+ default:
182
+ return [
183
+ " auto-capture: unknown — no plugin_load heartbeat in the evidence files (plugin never loaded here?)",
184
+ ];
185
+ }
186
+ }
187
+
139
188
  /**
140
189
  * Plain-text rendering shared by the memory_status tool (and any other chat
141
190
  * client). Sections match the terminal /memory panel one-for-one.
@@ -145,6 +194,7 @@ export function renderMemoryReport(input: {
145
194
  store: StoreCounts;
146
195
  blocked: BlockedRow[];
147
196
  quarantined?: { ts: string; patterns: string[] }[];
197
+ capture?: CaptureHealth;
148
198
  }): string {
149
199
  const { status, store, blocked } = input;
150
200
  const out: string[] = ["MEMORY STATUS", ""];
@@ -239,6 +289,13 @@ export function renderMemoryReport(input: {
239
289
  );
240
290
  }
241
291
  if (sizing.length) out.push(` ${sizing.join(" · ")}`);
292
+ if (input.capture) {
293
+ out.push(
294
+ "",
295
+ "AUTO-CAPTURE — is it off, misconfigured, armed, or alive?",
296
+ ...captureLines(input.capture),
297
+ );
298
+ }
242
299
  out.push(
243
300
  "",
244
301
  "Terminal (CLI/TUI) users: /memory opens this as a live panel; the footer shows a one-line badge.",
@@ -10,7 +10,12 @@ import {
10
10
  quarantineReasons,
11
11
  } from "../store/quarantine/quarantine.ts";
12
12
  import { EmptyArgs, validated } from "./schema.ts";
13
- import { captureLag, captureLagLines, rowsPerDay } from "../status/metrics.ts";
13
+ import {
14
+ captureHealth,
15
+ captureLag,
16
+ captureLagLines,
17
+ rowsPerDay,
18
+ } from "../status/metrics.ts";
14
19
  import { renderMemoryReport } from "../status/report.ts";
15
20
  import { blockedRecent } from "../status/write.ts";
16
21
  import { summarizeStore } from "../status/store-summary.ts";
@@ -50,7 +55,8 @@ export const register: ToolRegister = (editor, deps) => {
50
55
  ? Math.round(store.bytes / act.length)
51
56
  : 0;
52
57
  store.rowsPerDay = rowsPerDay(act) ?? undefined;
53
- store.captureLag = captureLag(await captureLagLines());
58
+ const evidenceLines = await captureLagLines();
59
+ store.captureLag = captureLag(evidenceLines);
54
60
  return {
55
61
  content: renderMemoryReport({
56
62
  status,
@@ -59,6 +65,9 @@ export const register: ToolRegister = (editor, deps) => {
59
65
  quarantined: act
60
66
  .filter((m) => isVisibleTo(m, reportReader) && isQuarantined(m))
61
67
  .map((m) => ({ ts: m.ts, patterns: quarantineReasons(m) })),
68
+ // #138: capture state read from the same evidence window, so the
69
+ // chat surface distinguishes off / misconfigured / inert / alive.
70
+ capture: captureHealth(evidenceLines),
62
71
  }),
63
72
  };
64
73
  },