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

Đang mở Phù hợp với người mới
#3,080 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
92/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bun, json, typescript
Lĩnh vực
backend, tooling

Hướng nghiên cứu

Bắt đầu với mergeStampCaps trong LIFEOS/TOOLS/HookBridge.ts và cách sử dụng mtime của stamp, sau đó kiểm tra việc kiểm tra TTL trong hooks/lib/function-hooks.ts. Tái hiện vấn đề bằng stamp 8 ngày của issue và chạy bridge, sau đó chạy hooks/MemoryTurnStart.hook.ts. Hoàn tất nghĩa là stamp đã được làm mới, hook bộ nhớ gốc vẫn im lặng và một bài kiểm thử hồi quy xác minh cả hành vi TTL lẫn việc giữ nguyên emission ID của bridge.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
20k
Fork
2.5k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của danielmiessler/LifeOS

Tất cả issue của danielmiessler/LifeOS

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.