MergeSettings leaks raw __merge append annotations into settings.json when settings.system.json has no hooks key

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

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

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

評価

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

調査の方向性

LifeOS/install/LIFEOS/TOOLS/MergeSettings.tsを読み、特に187行目付近のmergeSettings()を確認し、提供されたプローブを使ってoverlayのみに存在するhooksのケースを再現してください。システム設定にhooksがない場合に、appendアノテーションが配列になることを確認してください。プローブが正常終了し、生成されたsettings.jsonにhookイベントの配列が含まれれば完了です。

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

説明

Version

LifeOS 8.761.0. The buggy line is present in v8.761.0 and in current main (both at line 187, checked via the GitHub API). This install now carries the fix below, so attestation reports LIFEOS/TOOLS/MergeSettings.ts as modified.

What is broken

When settings.system.json has no hooks key (as shipped) and the overlay LIFEOS/USER/CONFIG/settings.user.json writes a hook event as an append annotation ({ "__merge": "append", "values": [...] }, the form SettingsBackport.ts produces), MergeSettings.ts copies the annotation object into settings.json unchanged instead of resolving it to an array. Claude Code then rejects each such event at startup (Hook event "Stop" must be an array of matchers; received object. This entry was ignored.) and every hook under it stops running. On this install that was PostToolUse, SessionStart, Stop and UserPromptSubmit (38 matcher entries). MergeSettings.ts --check reports "no differences" in that state, because it compares the file against the same merge.

Where (file:line)

LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts:187, in mergeSettings(): the object branch requires isObjectRecord(system) && isObjectRecord(user), so an overlay-only object key falls through to cloneJsonValue(user) and nested annotations are never resolved.

Repro on a clean tree
  1. Leave settings.system.json without a hooks key (the shipped default).
  2. In LIFEOS/USER/CONFIG/settings.user.json, set "hooks": { "Stop": { "__merge": "append", "values": [ { "hooks": [ { "type": "command", "command": "true" } ] } ] } }.
  3. Run bun LIFEOS/TOOLS/MergeSettings.ts --system settings.system.json --user LIFEOS/USER/CONFIG/settings.user.json --output settings.json.
  4. hooks.Stop in settings.json is the raw annotation object, and the next Claude Code launch reports it as ignored.

Minimal probe, run next to a copy of LIFEOS/TOOLS/ (plus LIFEOS/PULSE/lib/atomic-write.ts):

import { mergeSettings } from "./LIFEOS/TOOLS/MergeSettings.ts";
const merged = mergeSettings({}, {
  hooks: { Stop: { __merge: "append", values: [{ hooks: [{ type: "command", command: "true" }] }] } },
});
const ok = Array.isArray(merged.hooks.Stop);
console.log(`hooks.Stop -> ${ok ? "array" : JSON.stringify(merged.hooks.Stop)}`);
process.exit(ok ? 0 : 1);
Negative control

Unpatched v8.761.0 file, bun probe.ts, exit 1:

hooks.Stop -> {"__merge":"append","values":[{"hooks":[{"type":"command","command":"true"}]}]}
Suggested fix

Recurse whenever the user value is an object, treating an absent system side as {}. Overlay-only keys then get the same annotation handling as shared keys, so a nested append annotation resolves through applyArrayMerge(undefined, annotation) to its values array. The patch applies cleanly to main.

diff --git a/LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts b/LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts
--- a/LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts
+++ b/LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts
@@ -184,7 +184,11 @@ export function mergeSettings(system: any, user: any): any {
     );
   }
 
-  if (isObjectRecord(system) && isObjectRecord(user)) {
+  if (isObjectRecord(user)) {
+    // A user object whose system side is absent still recurses, so annotations nested under a key
+    // only the overlay defines resolve. settings.system.json omits `hooks`, and SettingsBackport
+    // writes hooks.<Event> as append annotations: cloning here leaked them raw into settings.json.
+    if (!isObjectRecord(system)) system = {};
     const merged: Record<string, any> = {};
 
     for (const key of Object.keys(system)) {
Verified after fix

Same probe, exit 0: hooks.Stop -> array. A real regeneration produces arrays for all four events.

Related: Report.ts cannot file this

This was written by hand because Tools/Report.ts could not produce it. Redact.ts swaps every configured name case-insensitively, and when the DA is named LifeOS every LifeOS/LIFEOS path, the repo name and the diff become <name>, and the send gate then refuses any body that still contains the name. Excluding the product name from the redaction list would fix it.

Environment
  • OS: macOS 27.3 (arm64)
  • Harness: claude-code
  • bun: 1.4.4
主要言語
TypeScript
スター
19.9k
フォーク
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 を短くまとめたダイジェスト。