LifeOSHooks stamp ages out in a live session: native hooks run beside the plugin again after 7 days

Open Beginner friendly
#3,080 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 5 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
92/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bun, json, typescript
Domain
backend, tooling

Research direction

Start with mergeStampCaps in LIFEOS/TOOLS/HookBridge.ts and its use of the stamp mtime, then inspect the TTL check in hooks/lib/function-hooks.ts. Reproduce with the issue’s 8-day stamp and run the bridge followed by hooks/MemoryTurnStart.hook.ts. Done means the stamp is refreshed, the native memory hook stays silent, and a regression test verifies both the TTL behavior and preservation of the bridge’s emission ID.

Written by the indexing model from the issue text.

Description

What happens

In an interactive session armed by the LifeOSHooks plugin, the native command hooks stand down only while hookCovers(sid, cap) is true (hooks/lib/function-hooks.ts). That needs the session stamp's file mtime to be younger than STAMP_TTL_MS (7 days).

LIFEOS/TOOLS/HookBridge.ts prompt-context calls mergeStampCaps(sid, PROMPT_MODULE_CAPS) on every covered prompt, but mergeStampCaps returns early when the caps are unchanged:

if (merged.length === have.length && merged.every((c, i) => have[i] === c)) return; // unchanged: leave the file alone

So the mtime freezes at the session's first prompt, which contradicts the function's own docstring ("mtime is refreshed (the TTL clock)"). Seven days after a session arms, in a session that stays open or is resumed, hookCovers goes false. From then on, every native hook that checks it runs again beside the plugin, which is the double path the stamp exists to prevent. For memory, the native MemoryTurnStart composes a second emission on each prompt, about 150 ms after the plugin's, and overwrites the memory queue's emissionId. An ack keyed to the plugin's emission then never matches, so the queue stops draining and re-sends its first chunks on every prompt.

Seen on v8.761.0; main at 94bd8f25 has the same code. On one install, three long-lived sessions stalled this way, each starting after its 7-day mark and not before.

Repro

With a temp config dir (CLAUDE_CONFIG_DIR=$(mktemp -d)):

  1. Write LIFEOS/MEMORY/STATE/function-hooks/S.json for session S with caps: ["prompt-context","turn-complete","band","voice"], and touch -t it 8 days back.
  2. Pipe a UserPromptSubmit input for S into bun LIFEOS/TOOLS/HookBridge.ts prompt-context. It exits 0 with covered: true, and the stamp's mtime is unchanged.
  3. Pipe the same input into bun hooks/MemoryTurnStart.hook.ts. It prints a full <lifeos-memory> block where it should print nothing, and MEMORY/STATE/memory-inject/S.queue.json now carries the native emission's id.

Suggested fix

Refresh the mtime on the unchanged path:

if (merged.length === have.length && merged.every((c, i) => have[i] === c)) {
  const now = new Date();
  utimesSync(p, now, now); // the bridge calls this every covered prompt, so a live session never ages out
  return;
}

A dead session or a crashed plugin stops calling the bridge, so the TTL still hands the work back to the native hooks for them. With this change step 2 refreshes the stamp and step 3 prints nothing. A test that plants an 8-day stamp, runs one turn through the bridge and then the native hook, and asserts the native hook stays silent and the queue keeps the bridge's emission fails without the line and passes with it.

Side note

The native hooks are covered even on the first prompt after a long idle: the plugin awaits prompt-context before next() runs them, and the bridge refreshes the stamp before it returns. The composers inside prompt-context run before that refresh, though, so on the first prompt after a lapse they still read the stale stamp and emit their fallback form once (for example the memory-delta block that asks the model to type the line). The next prompt is normal.

Dominant language
TypeScript
Stars
20k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from danielmiessler/LifeOS

All issues in danielmiessler/LifeOS

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.