Skip to content
Open
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
4 changes: 4 additions & 0 deletions coworker/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def _is_prefix_eligible(argv: list[str]) -> bool:
"create_scheduled_task",
"update_scheduled_task",
"delete_scheduled_task",
# These mutations persist beyond the current session.
"remember",
"memory_update",
"memory_forget",
}


Expand Down
21 changes: 21 additions & 0 deletions tests/test_permissions_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

EXTERNAL_META = SimpleNamespace(requires_approval=True, category="connector")
PLAIN_META = SimpleNamespace(requires_approval=False)
MEMORY_META = SimpleNamespace(
requires_approval=False, category="memory", risk_level="low", capabilities=["remember"]
)


# -- classify -------------------------------------------------------------------
Expand Down Expand Up @@ -94,6 +97,24 @@ def test_external_asks_in_interactive_allows_in_auto(tmp_path):
assert d.allowed


@pytest.mark.parametrize("mode", list(Mode))
@pytest.mark.parametrize(
"name,args",
[
("remember", {"content": "a durable fact", "scope": "global"}),
("memory_update", {"memory_id": 1, "content": "corrected fact"}),
("memory_forget", {"memory_id": 1}),
],
)
def test_memory_mutations_are_human_only_in_every_mode(tmp_path, mode, name, args):
eng = PermissionEngine(workspace_root=tmp_path, mode=mode)
decision = eng.evaluate(name, args, MEMORY_META)
assert not decision.allowed
assert decision.needs_user
assert decision.human_only
assert "outlives the session" in decision.reason


def test_write_local_path_scoped(tmp_path):
eng = PermissionEngine(workspace_root=tmp_path, mode=Mode.BYPASS_APPROVALS)
assert eng.evaluate("write_file", {"path": "ok.py", "content": "x"}, None).allowed
Expand Down