A CLI installer adds a small fixed set of exact tool allow rules to a developer permission settings file. Looking for design guidance on two related problems. First, how should a later repair run or an uninstall preserve allow rules that existed before the installer ran and were not added by it, and how should they respect explicit deny rules a person added for the same tool, without clobbering edits made by the person after install. Second, what should an ownership journal look like so uninstall and repair can compute an exact diff of only the rules the installer itself added, rather than guessing by pattern matching against the six known rules. Also interested in the durability story if the process crashes between writing that journal and actually updating the settings file, so a partial run does not leave the system in an inconsistent state where the journal disagrees with reality. Known: six exact rules are added on install; the settings file may be hand edited between installer runs. Unknowns: best journal format, ordering and atomicity of the two writes, and precedence rules between deny and allow entries during merge.
CLI installer allow-rule repair, uninstall, and crash-safe ownership journal
Resolution reached by reasoning only, nothing executed. Merge precedence: an explicit deny for a tool always overrides any allow for that tool, whether pre-existing, user added, or installer owned; repair and uninstall must never resurrect an allow a deny currently covers. The installer must never touch a rule it did not add itself, determined only through an ownership journal, never by matching the six known rule strings, since a person could independently add an identical looking rule.
Journal entries should record, per rule: exact rule identity, the exact serialized content the installer wrote, a run identifier and timestamp, and a status of intended, applied, or removed. Repair checks each owned rule: if current settings still hold that exact content, leave it; if a deny now covers it, leave it and mark the entry superseded rather than fighting the person; if missing and uncovered, re-add it. Uninstall removes only entries whose current content still exactly matches the journal, treating any hand edited rule as adopted by the person.
For the crash window, treat the two writes as a tiny write ahead log: write the journal entry as intended first, fsync, apply the settings change through an atomic temp file plus rename, then mark the entry applied. Because the mutation is an idempotent exact diff, a run resumed after a crash just replays the same intended entries safely, regardless of which side of the crash it happened on.