Seal ignored-workspace routing at Domain startup

This commit is contained in:
ms2k 2026-07-30 00:52:58 +09:00
commit 1ad3b84db2

View file

@ -215,13 +215,13 @@ def classification_case(case_id, fixture):
require((fixture.isolated / "vendor/nested/target/item").is_file(), "nested policy not selected")
require((fixture.host / "vendor/nested/ordinary.cache").is_file(), "parent policy crossed repository boundary")
return
if case_id == "live-ignore-publication":
if case_id == "startup-sealed-ignore-mutation":
write(fixture.host / ".gitignore", b"different/\n")
write(fixture.host / "cache/item", b"host")
with fixture.start():
require((fixture.mount / "cache/item").read_bytes() == b"host", "initial host route missing")
write(fixture.host / ".gitignore", b"cache/\n")
require(not (fixture.mount / "cache/item").exists(), "published ignore did not hide host object")
require((fixture.mount / "cache/item").read_bytes() == b"host", "live ignore mutation changed the sealed route")
require((fixture.host / "cache/item").read_bytes() == b"host", "publication copied or removed host object")
return
raise AssertionError(f"classification case is not implemented: {case_id}")
@ -270,7 +270,7 @@ def migration_case(case_id, fixture):
require(not (fixture.host / "target").exists(), "isolated target was exported to host")
require((fixture.isolated / "target/CACHEDIR.TAG").read_bytes() == payload, "isolated target missing")
intents = fixture.isolated / ".lazaret-ignored-workspace-transactions"
require(not any(intents.iterdir()), "completed migration retained intent")
require(not list(intents.glob("*.json")), "completed migration retained intent")
def rename_exchange(source, destination):
@ -319,24 +319,23 @@ def policy_transition_case(case_id, fixture):
with fixture.start():
if case_id == "ignored-becomes-non-ignored":
require((fixture.mount / "cache/item").read_bytes() == b"isolated", "initial isolated route missing")
old_descriptor = os.open(fixture.mount / "cache/item", os.O_RDWR)
write(fixture.host / ".gitignore", b"different/\n")
require((fixture.mount / "cache/item").read_bytes() == b"host", "host route not selected")
os.pwrite(old_descriptor, b"old-isolated", 0)
os.close(old_descriptor)
require((fixture.isolated / "cache/item").read_bytes().startswith(b"old-isolated"), "old handle rebound from isolated backing")
else:
require((fixture.mount / "cache/item").read_bytes() == b"host", "initial host route missing")
old_descriptor = os.open(fixture.mount / "cache/item", os.O_RDWR)
write(fixture.host / ".gitignore", b"cache/\n")
require((fixture.mount / "cache/item").read_bytes() == b"isolated", "isolated route not selected")
os.pwrite(old_descriptor, b"old-host", 0)
os.close(old_descriptor)
require((fixture.host / "cache/item").read_bytes().startswith(b"old-host"), "old handle rebound from host backing")
write(
fixture.host / ".gitignore",
b"different/\n" if case_id == "ignored-becomes-non-ignored" else b"cache/\n",
)
with fixture.start():
if case_id == "ignored-becomes-non-ignored":
require((fixture.mount / "cache/item").read_bytes() == b"host", "host route not selected after restart")
require(not (fixture.isolated / "cache/item").exists(), "released isolated object was retained")
else:
require((fixture.mount / "cache/item").read_bytes() == b"host", "host clone not selected after restart")
require((fixture.isolated / "cache/item").read_bytes() == b"host", "host object was not cloned")
if case_id == "ignored-becomes-non-ignored":
require((fixture.host / "cache/item").read_bytes() == b"host", "transition copied to host")
require((fixture.host / "cache/item").read_bytes() == b"host", "transition changed the host")
else:
require((fixture.isolated / "cache/item").read_bytes() == b"isolated", "transition copied to isolated backing")
require((fixture.host / "cache/item").read_bytes() == b"host", "clone changed the host")
def index_case(case_id, fixture):
@ -353,21 +352,21 @@ def index_case(case_id, fixture):
require(not (fixture.host / "deps/lib").exists(), "refused force-add created a host object")
elif case_id == "host-established-tracked-cutover":
(fixture.host / "deps/lib").unlink()
old_descriptor = os.open(fixture.mount / "deps/lib", os.O_RDWR)
write(fixture.host / "deps/lib", b"independent-host")
command(["git", "add", "-f", "--", "deps/lib"], fixture.host)
new_descriptor = os.open(fixture.mount / "deps/lib", os.O_RDONLY)
require(os.read(new_descriptor, 64) == b"independent-host", "new handle did not select host object")
os.pwrite(old_descriptor, b"old-handle", 0)
os.close(old_descriptor)
os.close(new_descriptor)
require((fixture.host / "deps/lib").read_bytes() == b"independent-host", "old handle rebound to host")
require((fixture.isolated / "deps/lib").read_bytes().startswith(b"old-handle"), "old handle did not remain isolated")
require((fixture.mount / "deps/lib").read_bytes() == b"isolated", "host index mutation changed the sealed route")
else:
(fixture.host / "deps/lib").unlink()
command(["git", "update-index", "--add", "--cacheinfo", "100644", "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "deps/lib"], fixture.host)
expect_errno(errno.EIO, lambda: (fixture.mount / "deps/lib").read_bytes())
require((fixture.isolated / "deps/lib").read_bytes() == b"isolated", "inconsistent isolated object was lost")
require((fixture.mount / "deps/lib").read_bytes() == b"isolated", "host index mutation changed the sealed route")
if case_id == "host-established-tracked-cutover":
with fixture.start():
require((fixture.mount / "deps/lib").read_bytes() == b"independent-host", "restart did not select host object")
require(not (fixture.isolated / "deps/lib").exists(), "restart retained released isolated object")
elif case_id == "unmediated-inconsistent-index":
with fixture.start():
require(not (fixture.mount / "deps/lib").exists(), "tracked path without a host object did not become absent")
require(not (fixture.isolated / "deps/lib").exists(), "released isolated object was retained")
def open_handle_case(case_id, fixture):
@ -392,20 +391,17 @@ def open_handle_case(case_id, fixture):
iterator.close()
require("isolated-child" in names and "host-child" not in names, "old stream mixed snapshots")
new_names = {entry.name for entry in os.scandir(fixture.mount / "cache")}
require("host-child" in new_names and "isolated-child" not in new_names, "new stream did not use new snapshot")
require("isolated-child" in new_names and "host-child" not in new_names, "new stream changed the sealed route")
else:
descriptor = os.open(fixture.mount / "cache/pinned", os.O_RDWR)
fcntl.lockf(descriptor, fcntl.LOCK_EX | fcntl.LOCK_NB, 1)
write(fixture.host / ".gitignore", b"different/\n")
new_descriptor = os.open(fixture.mount / "cache/pinned", os.O_RDWR)
fcntl.lockf(new_descriptor, fcntl.LOCK_EX | fcntl.LOCK_NB, 1)
require(lock_attempt(fixture.isolated / "cache/pinned") == errno.EAGAIN, "old isolated lock was transferred or lost")
require(lock_attempt(fixture.host / "cache/pinned") == errno.EAGAIN, "new host lock was not established")
os.close(descriptor)
require(lock_attempt(fixture.isolated / "cache/pinned") == 0, "isolated lock remained after old handle closed")
require(lock_attempt(fixture.host / "cache/pinned") == errno.EAGAIN, "isolated unlock affected host lock")
require(lock_attempt(fixture.host / "cache/pinned") == 0, "host lock domain was not independent")
os.close(new_descriptor)
require(lock_attempt(fixture.host / "cache/pinned") == 0, "host lock remained after new handle closed")
os.close(descriptor)
require(lock_attempt(fixture.isolated / "cache/pinned") == 0, "isolated lock remained after handles closed")
def lock_attempt(path):
@ -682,7 +678,7 @@ CASE_GROUPS = {
**{name: classification_case for name in [
"non-utf8-ignore-match", "root-negation-precedence", "nested-ignore-precedence",
"info-exclude", "global-excludes", "ignore-case-folding", "nested-repository-boundary",
"live-ignore-publication",
"startup-sealed-ignore-mutation",
]},
**{name: atomic_case for name in ["cross-route-file-rename", "cross-route-directory-exchange", "cross-route-hard-link"]},
"cargo-target-host-to-isolated-rename": migration_case,