Skip to content

The agent that grows with you

test(identity): make the 0600 ledger test prove the mode under a permissive umask

teknium1f34933605a1c
diff --git a/tests/hermes_cli/test_process_identity.py b/tests/hermes_cli/test_process_identity.py
index 9e4f98325ca..5f9a85dfbeb 100644
--- a/tests/hermes_cli/test_process_identity.py
+++ b/tests/hermes_cli/test_process_identity.py
@@ -134,16 +134,20 @@ def test_register_self_writes_and_prunes_dead(tmp_path):
assert me["create_time"] == pytest.approx(50.0, abs=0.01)
[email protected](os.name == "nt", reason="POSIX mode bits are platform-specific")
def test_register_self_writes_ledger_with_0600(tmp_path):
ledger = tmp_path / "spawn-ledger.json"
fake = _fake_psutil({999: 50.0})
- with patch.dict(sys.modules, {"psutil": fake}), \
- patch.object(pi, "_ledger_path", return_value=ledger), \
- patch.object(pi.os, "getpid", return_value=999):
- assert pi.register_self("serve", project_root=Path("/x/install")) is True
-
- mode = stat.S_IMODE(os.stat(ledger).st_mode)
- assert mode == 0o600
+ old_umask = os.umask(0o022) # permissive umask: the mode must come from the writer, not the env
+ try:
+ with patch.dict(sys.modules, {"psutil": fake}), \
+ patch.object(pi, "_ledger_path", return_value=ledger), \
+ patch.object(pi.os, "getpid", return_value=999):
+ assert pi.register_self("serve", project_root=Path("/x/install")) is True
+ finally:
+ os.umask(old_umask)
+
+ assert stat.S_IMODE(os.stat(ledger).st_mode) == 0o600
def test_register_self_inherits_spawn_tag_lineage(tmp_path):