Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

[bug] SessionStart runs SettingsBackport twice, which deadlocks MergeSettings after a…

Open IvanLeontev-stack opened this issue 1 week ago • 1 comments

What happened

SessionStart runs SettingsBackport twice, which deadlocks MergeSettings after a hand-deleted overlay key; settings.json stopped regenerating for 22 hours

Summary

bug: SessionStart's double SettingsBackport pass deadlocks MergeSettings after a hand-deleted overlay key (LifeOS 8.761.0)

What happens. A key that lives only in settings.user.json (no system default) is removed by hand from settings.json. From then on every SessionStart prints ... was DELETED in settings.json but is not an overlay key — remove it from settings.system.json by hand and MergeSettings: refusing to overwrite ... backporting its hand edits failed. settings.json is never regenerated again, so every later edit to settings.system.json or settings.user.json silently stops reaching sessions. Here it lasted about 22 hours (47 sessions) before we noticed.

Why (read in 8.761.0 code).

  1. The SessionStart hook runs SettingsBackport.ts, then MergeSettings.ts --output settings.json.
  2. Pass 1 (standalone backport) sees the key in the merge snapshot but not in settings.json, removes it from the overlay (SettingsBackport.ts:299-301) and exits 0. It does not touch the snapshot.
  3. MergeSettings.ts then calls backportBeforeOverwrite (MergeSettings.ts:612-624), which runs SettingsBackport.ts a second time. The snapshot still has the key and the overlay no longer does, so the deletion counts as un-backportable (SettingsBackport.ts:337-344, counted in failed at :353), exit 1, and MergeSettings refuses (:675-679).
  4. The snapshot is only written after a successful merge (:733-735), so it stays stale and the same refusal repeats on every start.

The hint in the message ("remove it from settings.system.json by hand") does not apply: the key was never in settings.system.json.

Repro (sandbox HOME). system {"theme":"dark"}, overlay {"x":1}, snapshot {"theme":"dark","x":1}, live settings.json {"theme":"dark"}. Run the SessionStart command: pass 1 prints verified and drops x from the overlay; pass 2 inside MergeSettings refuses, exit 1. Running it again gives the same refusal.

Workaround we used. Moving the stale MEMORY/STATE/settings-merge-snapshot.json aside, which the code already treats as safe (SettingsBackport.ts:21-22, :242-247 "No snapshot on disk → skip cleanly"). The next merge rewrote the snapshot, a second full SessionStart run was clean, and the overlay was byte-identical.

Related. #2736 (closed 19.11) covers the neighbouring case of a system key missing from settings.json and points to { "__merge": "remove" }. I could not tell from the public repo whether its fix also covers this overlay-only path and the double pass; SettingsBackport.ts and MergeSettings.ts in 8.761.0 are unchanged here.

Possible fixes (your call). Have the second pass skip deletions the first pass already applied (compare against the overlay as it is now, not only the snapshot), or refresh the snapshot after a successful standalone backport, or run the backport only once per SessionStart.

Details

  • Kind: bug
  • LifeOS version: 8.761.0

Filed with the LifeOS /feedback command. The reporter approved this exact text before it was sent; paths, secrets and personal details were stripped locally.

IvanLeontev-stack avatar Nov 24 '26 03:11 IvanLeontev-stack

[!NOTE] 🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

Thanks for reporting this. It's fixed in our tree, in a commit that landed after the 8.761.0 cut, so it ships in the next public release. Closing for now; reopen if you still see it on that release.

Fix: c2436b36ed SettingsBackport idempotent

danielmiessler avatar Dec 01 '26 10:12 danielmiessler