Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

MemoryHealthCheck CHECK 3b: the delta-surface liveness check cannot fail when the surface and its writer die together, and emits nothing when there are no writes

Open selinium opened this issue 2 months ago • 1 comments

Summary

CHECK 3b in LIFEOS/TOOLS/MemoryHealthCheck.ts decides whether MemoryDeltaSurface is alive by comparing its heartbeat file against the newest MemorySystem.add row in memory-writes.jsonl, and reports delta-surface-dead only when the newest write is more than 24h newer than the heartbeat.

Both quantities are produced by the same subsystem. The reviewer produces the writes; the surface touches the heartbeat. Any fault that stops both at once freezes the two timestamps a few minutes apart, the difference stays under the threshold for ever, and the check reports the surface alive indefinitely, on data that stopped moving weeks earlier.

Checked against main at 5e2f2e8c, LIFEOS/VERSION 7.40.4. The code is unchanged from when this was first observed.

The code

if (lastWriteTs > 0) {
  const hbTs = existsSync(HEARTBEAT_FILE)
    ? Date.parse(readFileSync(HEARTBEAT_FILE, "utf-8").trim())
    : 0;
  if (!hbTs || lastWriteTs - hbTs > 24 * 60 * 60 * 1000) {
    add("delta-surface-dead", "critical", ...);

The comparison is purely relative. It never asks whether the heartbeat is recent in wall-clock terms.

Not hypothetical

On a 7.40.4 install, the fork-flag bug in #1911 stopped every consumer of isSubagentContext() in the same minute. For the following 18 days the health report said the delta surface was alive on every run, while the cursor and the heartbeat both sat frozen at the timestamp of the last healthy turn.

Second, smaller issue in the same block

The whole comparison is inside if (lastWriteTs > 0). When no qualifying write is found — a fresh install, a rotated log, or a curation loop that has never run — the check emits nothing at all: no ok, no warning. A missing input reads identically to a healthy result.

Suggested shape

  1. Add an absolute arm: if the heartbeat is older than some wall-clock threshold, report it dead regardless of what the writes say. Two frozen clocks should not agree their way to a pass.
  2. When there is no qualifying write, emit an explicit no-data finding rather than falling through silently.

More generally, a liveness check whose reference point is produced by the subsystem it is checking can only detect faults that hit one side. The failures worth catching tend to hit both.

Notes

Related to #1911 and #2075 only as the trigger that exposed it. The weakness is independent of that bug and would hide any fault that stops curation and surfacing together.

selinium avatar Sep 20 '26 19:09 selinium

Thanks @selinium. Both parts landed in LIFEOS/TOOLS/MemoryHealthCheck.ts. A wall-clock arm now flags the heartbeat once it is more than 72 hours old, whatever the write log says. When there are no qualifying writes, the check emits an explicit no-data finding. Next release carries it.

danielmiessler avatar Oct 03 '26 04:10 danielmiessler