You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codify: Let the Real Operation Be the Check, and Close a Defect Class Through One Primitive #2431
Two patterns came out of hardening the host-safety installer for #2423. The work ran from #2424 through #2429, and the record is in each PR body. Both belong in governance prose, likely CODESTYLE.md General or GOVERNANCE.md "Verification Discipline".
Let the real operation be the check, not a prediction of it.
Successive local-review rounds found 5, then 5, then 4 cases the probe got wrong: a dangling link, a link loop, a read-only file that was already current, a Windows ACL, and a backup directory that couldn't be written.
The fix that converged moved the file step ahead of every other write. It attempted the real read, backup and write, skipped the write when nothing would change, and turned any OSError into a clean refusal.
A prediction can drift from the operation it predicts. The operation itself can't.
Close a defect class through one primitive, not with a check at each site.
Each per-site check also met platform differences of its own. On Python 3.14, Path.exists() and is_file() swallow OSError. On Windows, a file parent raises FileNotFoundError rather than NotADirectoryError.
read_regular_file() fixes it for good: open once with O_NONBLOCK, judge the open descriptor with fstat, and close it in a finally.
Once a class shows up a second time, the fix is the primitive plus moving every reader onto it.
Done means
The rule text sits in its home section.
Each skill that restates verification rules points at it.
A third principle of the same family, measured on #2455.
A failure message states the error, the path, and the remedy, and claims nothing about the state the failure left. The installer's write-failure messages first described the file afterwards: "nothing was installed", "this file is unchanged, so the hook is not registered", "new sessions load that partial file", "a re-run refuses it". Two local review rounds each found a state that reaches the message and makes its description false. Examples are a settings.json written in full but reported as unregistered, and a close error on a complete file reported as a partial one. Each rewording added another state claim, and the next round found another false case. A deletion-only round that kept just the error, the path, and "fix what it names, then re-run" was the first round with no introduced finding.
It is the message-side form of "let the real operation be the check". The error the operation raised is the one fact the code knows. A description of the aftermath is a prediction, and predictions about filesystem state did not converge here any more than the writability checks in #2427 did.
Activity
ptr727 commentedon Oct 6, 2026
A third principle of the same family, measured on #2455.
A failure message states the error, the path, and the remedy, and claims nothing about the state the failure left. The installer's write-failure messages first described the file afterwards: "nothing was installed", "this file is unchanged, so the hook is not registered", "new sessions load that partial file", "a re-run refuses it". Two local review rounds each found a state that reaches the message and makes its description false. Examples are a
settings.jsonwritten in full but reported as unregistered, and a close error on a complete file reported as a partial one. Each rewording added another state claim, and the next round found another false case. A deletion-only round that kept just the error, the path, and "fix what it names, then re-run" was the first round with no introduced finding.It is the message-side form of "let the real operation be the check". The error the operation raised is the one fact the code knows. A description of the aftermath is a prediction, and predictions about filesystem state did not converge here any more than the writability checks in #2427 did.
Model the Threat and Reuse Before Building, and Give Review a Design …