Skip to content
Python

OPE-113: fix reviewer prompt shell scoping claim

Devika Vermae1dcdcfc59db
diff --git a/coworker/reviewer.py b/coworker/reviewer.py
index 0aa28561..07940d30 100644
--- a/coworker/reviewer.py
+++ b/coworker/reviewer.py
@@ -82,8 +82,13 @@ CONTEXT YOU ARE GIVEN
It is a boundary, NOT a safety claim - deleting the entire workspace happens
inside these folders and is still wrong, and a file being in scope says
nothing about whether touching it is part of what the user asked for.
- Writes outside these folders are already blocked before you are consulted,
- so you will never be asked to judge one; do not spend the verdict on that.
+ For file tools, writes outside these folders are blocked before you are
+ consulted. Shell commands are different: nothing scopes what a command
+ touches. A command can read, write, or send anything the user's account can
+ reach - your verdict is the only check on where it reaches. A command that
+ touches anything outside these folders - the home directory, credential
+ files, shell profiles, system paths - is "unsure" at best, and "allow" only
+ when the user themselves named that exact destination.
Git remotes the remotes configured when this session started, with their URLs. A push
or fetch aimed at a remote that is not one of these is going somewhere the
user was not working with - weigh that against what they actually asked for.
diff --git a/tests/test_auto_approve.py b/tests/test_auto_approve.py
index 2ec9fe33..bccc1659 100644
--- a/tests/test_auto_approve.py
+++ b/tests/test_auto_approve.py
@@ -161,6 +161,23 @@ def test_messages_are_cache_shaped_one_action_last():
assert "PROPOSED ACTION" in user and user.count("PROPOSED ACTION") == 1
+def test_prompt_never_claims_shell_writes_are_pre_blocked():
+ # OPE-113: the prompt once told the reviewer "writes outside these folders are already
+ # blocked before you are consulted" — true for WRITE_LOCAL tools, false for run_shell
+ # (root scoping is gated on is_write; EXEC never enters it). That sentence biased the
+ # reviewer toward allowing out-of-root shell effects. Guard both directions: the blanket
+ # claim must stay gone, and the shell caveat must stay present.
+ # The prompt is hard-wrapped, so collapse whitespace before matching phrases.
+ text = " ".join(reviewer_mod.INSTRUCTIONS.split())
+ assert "you will never be asked to judge one" not in text
+ assert "do not spend the verdict on that" not in text
+ # The per-tool-class split: file tools keep the true guarantee...
+ assert "For file tools, writes outside these folders are blocked" in text
+ # ...and shell is named as unscoped, with the reviewer as the only check.
+ assert "nothing scopes what a command touches" in text
+ assert "your verdict is the only check" in text
+
+
def test_history_is_clipped_hard_with_marker():
long = "paste " * 200
rendered = reviewer_mod.render_history([{"text": long}])