Commit eaea427
fix(v1.100 PR-22A): uninstall dry-run boundary repair
Independent audit of merged PR #480 found three concrete violations of
the PR-22 contract Stop Condition ("no writes under /var/lib/nftban/"):
1. os.WriteFile(<stateDir>/uninstall_plan.json, …) on every dry-run
2. sf.Transition(StateUninstallPlanning, …) persisted install_state
3. unconditional writeHistory() recorded a successful plan preview as
"install_fail" in update-history.json — silently poisoning every
operator dashboard that alerts on install_fail
Plus one classifier false-negative:
4. partial nftban (table OR daemon, not both) WITHOUT external
firewall fell through to AuthorityNone — PR-23 release logic would
skip kernel cleanup of the orphan table
Plus CI blind spot:
5. G3-UN-NO-MUTATION grep missed os.WriteFile/Create/MkdirAll/Rename;
snapshot step did not cover /var/lib/nftban/ at all
This PR is BOUNDARY REPAIR ONLY. It does not add uninstall mutation,
does not change purge/remove semantics, does not expand prior-authority
logic, does not begin PR-23. Scope locked to R1-R5 from the repair
contract seed.
R1 (uninstall_dryrun.go): remove os.WriteFile + sf.Transition. Plan
renders to stdout only. Option B — no installer-state persistence
during dry-run.
R2 (main.go): guard writeHistory with cfg.mode != "uninstall" so a
successful plan preview is not recorded as install_fail.
R3 (authority.go): explicit case nftbanPartial && !extPresent →
AuthorityAmbiguous with diagnostic note; tighten the AuthorityNone
case with !nftbanPartial. Regression test added
(TestClassify_PartialNFTBan_NoExternal_IsAmbiguous) plus symmetric
daemon-up-no-table case.
R4 (uninstall_dryrun_test.go): new falsifiable purity test calls
runUninstallDryRun with MockExecutor + real tempdir and asserts:
- zero executor writes (WriteFileAtomic)
- zero directory creates
- zero mutation commands (nft add/flush/delete, systemctl lifecycle,
ufw/firewall-cmd, package-manager removal)
- zero files on disk under temp stateDir
Two tests: no-authority host and ambiguous host.
R5 (ci-uninstall-canonization.yml):
- extend grep patterns: os.WriteFile/Create/MkdirAll/Mkdir/Rename,
sf.Transition, nft create, apt-get purge, dnf erase
- widen E2E snapshot to include /var/lib/nftban/ (was only
/etc/nftban + /usr/lib/nftban + /usr/sbin/nftban*)
- new G3-UN-HISTORY-PURITY gate: seeds realistic update-history.json,
runs dry-run twice (explicit + implicit), asserts byte-identical
hash — catches the exact class that escaped PR #480
- run the new orchestrator purity test in CI
Acceptance criteria (all pass by construction):
- uninstall dry-run no longer writes misleading plan/history
artifacts under /var/lib/nftban/
- successful uninstall dry-run does not create install_fail
- partial nftban without external returns AuthorityAmbiguous
- purity test exists and would fail on regression
- CI would fail on the exact write-pattern class that escaped in
PR #480 (os.WriteFile + history pollution + snapshot blind spot)
- no uninstall mutation capability added
- scope remains boundary repair only
Depends on: 547aa08 (PR #480)
Refs: V1100_LIFECYCLE_COMPLETION_CONTRACT.md §13 (frozen 2026-04-19)
Refs: internal/installer/uninstall/contract.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 547aa08 commit eaea427
6 files changed
Lines changed: 428 additions & 29 deletions
File tree
- .github/workflows
- cmd/nftban-installer
- internal/installer/uninstall
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
| 120 | + | |
115 | 121 | | |
| 122 | + | |
116 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
117 | 129 | | |
118 | | - | |
| 130 | + | |
| 131 | + | |
119 | 132 | | |
120 | 133 | | |
121 | 134 | | |
122 | 135 | | |
123 | | - | |
124 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
125 | 143 | | |
126 | 144 | | |
127 | 145 | | |
| |||
145 | 163 | | |
146 | 164 | | |
147 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
148 | 177 | | |
149 | 178 | | |
150 | 179 | | |
| |||
172 | 201 | | |
173 | 202 | | |
174 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
175 | 210 | | |
176 | 211 | | |
177 | 212 | | |
| |||
182 | 217 | | |
183 | 218 | | |
184 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
185 | 233 | | |
186 | 234 | | |
187 | 235 | | |
| |||
212 | 260 | | |
213 | 261 | | |
214 | 262 | | |
215 | | - | |
216 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
217 | 269 | | |
218 | 270 | | |
219 | 271 | | |
220 | 272 | | |
221 | 273 | | |
222 | | - | |
| 274 | + | |
223 | 275 | | |
224 | | - | |
| 276 | + | |
225 | 277 | | |
226 | 278 | | |
227 | 279 | | |
228 | 280 | | |
229 | 281 | | |
230 | 282 | | |
231 | 283 | | |
232 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
233 | 312 | | |
234 | 313 | | |
235 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
103 | 112 | | |
104 | 113 | | |
105 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
48 | 70 | | |
49 | 71 | | |
50 | 72 | | |
| |||
86 | 108 | | |
87 | 109 | | |
88 | 110 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
92 | 115 | | |
93 | 116 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
109 | 124 | | |
110 | 125 | | |
111 | 126 | | |
| |||
0 commit comments