Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

SettingsBackport writes whole arrays into the user overlay, permanently pinning permissions.allow against future upstream changes

Open xmasyx opened this issue 4 months ago • 2 comments

Summary

SettingsBackport.ts writes divergent arrays into the user overlay as whole-array replacements. MergeSettings.ts supports an append annotation, but the backport tool never emits it. The result: once any array has been backported, the user overlay pins that array forever and every future upstream change to it is silently dropped.

For permissions.allow this means a shipped permission added or removed in a later release never reaches the install.

Evidence (read from main)

LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts supports both forms:

* Scalars and arrays replace by default, with user values winning conflicts.
* Arrays can opt into append via { "__merge": "append", "values": [...] }.

and honours the annotation:

if (Array.isArray(systemValue)) {
  return [...cloneJsonValue(systemValue), ...cloneJsonValue(userValue.values)];
}

LifeOS/install/LIFEOS/TOOLS/SettingsBackport.ts states its own limit:

*   - Arrays backport as whole-array replacements into the user overlay.

and grep -n "__merge" over that file returns nothing — the append form is never produced.

How it bites

  1. A user accepts a permission at runtime; the harness writes it into the generated settings.json.
  2. SettingsBackport sees permissions.allow diverge and copies the entire array into settings.user.json.
  3. From then on, MergeSettings lets that overlay array replace the system one wholesale.

Observed on an install: the user overlay carried a byte-identical copy of the full shipped permissions.allow. Adding a rule to settings.system.json and regenerating produced no change at all in settings.json — the merge reported the overlay applying, and the new rule was silently absent. The only way to make it effective was to add the same rule to the overlay too.

This is the same class of failure as #1527 (empty deny: [] in the overlay wiping system deny rules), but arrived at through normal use rather than a hand-edit: no one has to write anything wrong for it to happen.

Proposed fix

In SettingsBackport.ts, when an array's divergence is pure addition (every system element still present, plus new ones), emit only the additions in the annotated form the merger already understands:

"allow": { "__merge": "append", "values": ["Bash(cd:*)"] }

When elements were removed, append cannot express that, so keep the whole-array replacement — but warn loudly at that point, the same way the tool already warns that key deletions cannot be backported.

That change keeps the user's additions surviving every merge (the current guarantee) while letting upstream edits to the rest of the array keep flowing through.

Related

  • #1527 — empty deny: [] in user overlay wipes system deny rules
  • #1721 — cd && <trusted tool> declared safe in autoMode.allow with no deterministic permissions.allow rule (found while hitting this bug)

xmasyx avatar Aug 01 '26 22:08 xmasyx

This is Shiva, Eugene's AI Assistant, reporting on Eugene's behalf.

Confirmed the failure mode: any array field drift (even a pure addition upstream) gets written back as a full replacement, permanently pinning permissions.allow against future upstream changes. Fix: SettingsBackport now diffs array drift by element — pure additions emit a {__merge:"append", values:[...]} annotation instead of a whole-array overwrite; a real removal still replaces the array but now warns instead of silently pinning. Verified with synthetic add/remove/mixed test cases, all producing the correct drift classification.

waveman2020-sudo avatar Aug 05 '26 03:08 waveman2020-sudo

Good catch, @xmasyx — SettingsBackport pinned arrays wholesale. Fixed in source (SettingsBackport.ts now emits __merge:append for pure additions), ships next release. Closing since the public repo is generated from that source.

danielmiessler avatar Aug 06 '26 05:08 danielmiessler