SettingsBackport + MergeSettings: a backported hook edit makes the overlay own `hooks`, and the next SessionStart merge drops every hook it does not list
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 15/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- developer-experience, tooling
Direzione di ricerca
Start by reading SettingsBackport.ts and MergeSettings.ts, especially INSTALLER_OWNED_KEYS and the mergeSettings annotation handling. Reproduce the loss in a throwaway CLAUDE_CONFIG_DIR using the SessionStart command, then verify that all three hook events survive backport plus merge. Done means a hook edit no longer lets the overlay own hooks, unknown flags are rejected, and the merge either preserves registrations or refuses explicitly with --allow-hook-drop.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The SessionStart hook runs SettingsBackport.ts; MergeSettings.ts --system … --user … --output settings.json. v8.761.0's settings.system.json ships no hooks key, and hooks is in MergeSettings.ts INSTALLER_OWNED_KEYS: mergeSettingsPreserving carries it from the existing settings.json only while neither layer defines it.
1. Silent hook loss (most serious). SettingsBackport.ts never consults INSTALLER_OWNED_KEYS. When anything edits part of live hooks, the backport writes that part into USER/CONFIG/settings.user.json, and from then on the overlay owns hooks. If the edit changes a group (a timeout, say), the drift counts as one element removed and one added, so it is backported as a whole array. That array verifies, and the next merge writes a settings.json holding only the backported event. Every other hook event is gone, and nothing reports the dropped events: the backport only warns that the one array is now pinned.
Repro, in a throwaway CLAUDE_CONFIG_DIR:
- the system layer has no
hooks; - the overlay is
{"model":"x"}; - the snapshot and live
settings.jsoncarrySessionStart,PreToolUseandStop; - change one
PreToolUsehook'stimeoutin live; - run SettingsBackport, then MergeSettings.
Expected: all three events in the output. Actual: only PreToolUse.
A tool that re-registers its own hooks at startup by removing its groups and appending them again (which moves them to the end) is enough to trigger the reorder form, § 2 below.
2. Nested annotations never resolve, so the chain wedges. This part is #2636 (and #2737), both closed as fixed for the next release; it is kept here because § 1 depends on it. In mergeSettings, a user key that the system layer lacks recurses as mergeSettings(undefined, user[key]). A plain object then falls through to cloneJsonValue(user), and any __merge annotation inside is copied out raw:
mergeSettings({}, { hooks: { X: { __merge: "append", values: [1] } } })
// → { hooks: { X: { __merge: "append", values: [1] } } } expected { hooks: { X: [1] } }
__merge: "remove" leaks the same way. The control is the same overlay merged against a system layer that has hooks: {}: it resolves to { hooks: { X: [1] } }.
In the chain:
- A reorder of live hook groups backports as append annotations, so SettingsBackport's verification fails, MergeSettings refuses to write ("backporting its hand edits failed"), and the merge snapshot never refreshes. Every later session start repeats it.
- Adding one spinner tip does the same, because the system layer has no
spinnerTipsOverride, so the backport appends onto a parent the merge cannot resolve.
Refusing is the safe outcome here, but it hides § 1. Fixing § 2 first, on an install whose overlay already holds a captured partial hooks, turns the wedge into the loss in § 1. That is the order the #2636 fix puts installs in: once it reaches them, a wedged chain stops refusing and the next session start writes settings.json with only the hooks the overlay captured. Shipping § 1's guard (fix 1 or 2 below) in the same release as the #2636 fix avoids that.
3. Smaller defects in the same chain.
- SettingsBackport writes
settings.user.jsonbefore it verifies, and does not roll back a failed non-deletion change. permissionsarrays are planned as sets (ORDER_FREE_ROOTS) but verified in order, so a reordered allow list plus one new rule plans an append that then fails verification.- An array drift onto a non-array system value plans an append, and the merge throws
__merge: "append" requires the system value to be an array or absent. - Verification compares the merge with the live file, so a permission the system layer added since the last snapshot, together with one added live in the same window, makes a correct append fail verification (system
["Read","Bash"], snapshot["Read"], live["Read","Write"]). The chain then refuses again on every later session start. - SettingsBackport ignores flags it does not know:
SettingsBackport.ts --helpruns a real backport, and writes the overlay if there is drift. Only--dry-runis recognised.
A possible fix.
- SettingsBackport drops drift under any
INSTALLER_OWNED_KEYSentry that neither layer defines. The merge already carries those keys from live, so a hand edit survives without a backport. - MergeSettings
--outputrefuses to write while the merge would remove any hook registration that the existingsettings.jsonhas, unless--allow-hook-dropis passed. A registration is counted with multiplicity and keyed by event, matcher, and the hook record apart fromtimeout. Keying onevent + commandalone misses a removed matcher group whose command still runs under another matcher. This catches § 1 whatever the cause, including a futuresettings.system.jsonthat starts shippinghooks. - SettingsBackport appends only when the system layer has the array's parent object and the leaf is an array or absent, and otherwise writes the array whole. Order-free roots verify as sets.
- With 1-3 in place, fixing § 2 is safe. Rejecting unknown flags fixes the last bullet of § 3.
Related. #2636 and #2737 (§ 2, closed); #2736 (SettingsBackport refuses on a missing system key, the same wedge from another trigger); #2759 (a fresh install's first merge drops all hooks, because InstallAll writes them into settings.json only). § 1 is a different path to the same loss as #2759: it needs no fresh install, only one backported hook edit.
- Lingua principale
- TypeScript
- Stelle
- 19.9k
- Fork
- 2.5k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di danielmiessler/LifeOS
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
danielmiessler/LifeOS#2894 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
danielmiessler/LifeOS#2891 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
danielmiessler/LifeOS#2888 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
danielmiessler/LifeOS#2886 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
danielmiessler/LifeOS#2848 ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di danielmiessler/LifeOS
Issue simili
-
[功能请求] 设置选项语言调整Aperta功能请求
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
antithesishq/bombadil#473 ·
I maintainer di solito rispondono entro 2 giorni
-
The structured output reference promises null results for refusals that carry validation detailsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
mattermost/mattermost-mobile#10358 ·
I maintainer di solito rispondono entro 1 giorno
-
ready-for-agent
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
LucasSantana-Dev/Lucky#3257 ·
I maintainer di solito rispondono entro 1 giorno