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

オープン 初心者向け
#3,080 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 5 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
92/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
bun, json, typescript
領域
backend, tooling

調査の方向性

まず LIFEOS/TOOLS/HookBridge.ts の mergeStampCaps と、スタンプの mtime の使用方法を確認し、次に hooks/lib/function-hooks.ts の TTL チェックを調査する。issue の 8 日間のスタンプで再現し、bridge を実行した後に hooks/MemoryTurnStart.hook.ts を実行する。完了の基準は、スタンプが更新され、ネイティブのメモリ hook が沈黙したままになり、bridge の emission ID の保持を含む TTL の動作をリグレッションテストが確認することである。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
20k
フォーク
2.5k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

danielmiessler/LifeOS のほかの issue

danielmiessler/LifeOS の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。