Repository navigation
feat(file): the removal family splits by blast radius; tolerance covers absence only - #637
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 5 of any-entry-claims.md. Closes #621. Feature: #616.
file.remove(target, prune, boundary, on_missing)andfile.remove_all(...)now take the taxonomyinterface — identical signatures over one shared core, differing by the non-empty-directory guard alone.
file.unlinkis removed: it andremovewere one operation, differing only in the claim's type.file.backup(source, backup_suffix)claims its source, the surface's last unclaimed mutation. Policyparameters go last throughout.
The removal family now splits by blast radius, never by kind — the standard library's split, arrived
at for the same reasons:
os.Removetries unlink then rmdir rather than asking the kind, which is why Gonever needed an
Unlink, andos.RemoveAllopens by callingos.Remove.The finding, and it was nearly data loss
TestExecute_RefusesReplacedLinkpins a real safety property: a deployed link the user replaced with ahand-written file must be refused, not deleted. That came free from
unlink's kind check. Withremovekind-indifferent, the run succeeded — deleting the user's file.Claiming the deployed kind was the right instinct but not sufficient on its own:
writ decommissionrunsunder
on_missing=ignore(the ruled posture, so a hand-removed target decommissions as recordedhistory), and tolerance forgave the mismatch too.
Ruled: tolerance covers absence, never a kind mismatch.
Ignoremeans the goal already holds —coherent about an empty path, incoherent about a surprise.
op.ErrClaimKindMismatchand the optionalop.KindMismatcherseam carry the distinction, consulted only after a claim has already failed toverify, so it answers the one question a boolean predicate cannot: nothing is there or something else
is there. A kind mismatch now stops under every policy.
Writ decommission claims the kind it deployed — a link claims a link — which is what makes its tolerance
safe, and which extends the protection to copies, a case the old
unlink-based check never covered.Tests moved rather than died
The "not a symlink" dispatch check became a claim pin: a link claim over a regular file mismatches,
and over an empty path it does not. The non-empty-directory test now claims the directory honestly.
test_file_unlink.starbecametest_file_remove_link.star, asserting what proves nothing was lost — thelink goes and its target stays.
New:
test_judgment_remove_any_kind.starremoves a regular file, an empty directory, a link, and —through
remove_all— a link to a populated tree, asserting that neither removal followed; a followwould be unmistakable, since every file under it would vanish. Go pins cover the
mismatch-stops-under-Ignore rule at the executor and the mismatch-versus-absence distinction at the claim.
Gate:
make test103 ok / 0 fail;make vetclean under darwin, windows, and linux;gofmt -lclean.