Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions hermes_cli/write_approval_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
HOUSEHOLD_PROFILES = frozenset({"family", "home", "partner", "kid-1", "kid-2"})


def approval_toggle_allowed(profile_name: str) -> bool:
def approval_toggle_allowed(profile_name: str | None) -> bool:
"""Return whether a profile may change its durable-write approval gates."""
return (profile_name or "").strip().lower() not in HOUSEHOLD_PROFILES
normalized = (profile_name or "").strip().lower()
# Missing profile identity must fail closed. In a multiplexed gateway, an
# unstamped route must never inherit toggle permission from an unknown
# process/default profile.
return bool(normalized) and normalized not in HOUSEHOLD_PROFILES


def approval_profile_name(source_profile: str | None, active_profile: str | None) -> str:
Expand Down
2 changes: 1 addition & 1 deletion tests/gateway/test_household_approval_toggle_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def test_routed_profile_wins_over_active_profile(
):
resolved = approval_profile_name(source_profile, active_profile)
assert resolved == expected
assert approval_toggle_allowed(resolved) is (expected != "family")
assert approval_toggle_allowed(resolved) is (bool(expected) and expected != "family")
2 changes: 2 additions & 0 deletions tests/tools/test_write_approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def test_household_profiles_cannot_toggle_approval_gate():

for profile in ("family", "home", "partner", "kid-1", "kid-2"):
assert approval_toggle_allowed(profile) is False
assert approval_toggle_allowed("") is False
assert approval_toggle_allowed(None) is False
assert approval_toggle_allowed("dev") is True
assert approval_toggle_allowed("rescue") is True

Expand Down
Loading