Skip to content
Python

fix(auto-approve): the safe-write tier covers only documents and images (OPE-233)

Devika Verma7af498a0b401
diff --git a/coworker/workspace_safety.py b/coworker/workspace_safety.py
index 0fed5c73..f34a2e0b 100644
--- a/coworker/workspace_safety.py
+++ b/coworker/workspace_safety.py
@@ -1,9 +1,11 @@
"""What code can establish about a workspace write without asking a model (OPE-233).
Auto-Approve lets a write skip the reviewer when undoing it is easy and nothing about it
-can execute later: an inert file type, a name and content that don't look secret, and a
+can execute later: a plain document or raster image that no build, installer, test runner
+or other AI tool reads as instructions, a name and content that don't look secret, and a
target that is new, git-tracked with no uncommitted changes, or written by the agent
-earlier in this session. Every check fails toward "ask the reviewer": an unknown file type,
+earlier in this session. JSON and YAML are never eligible: tools read them to decide what
+to run, and no list of their names can be complete, so the reviewer sees that content. Every check fails toward "ask the reviewer": an unknown file type,
an unreadable git state or a doubtful name keeps today's behaviour.
"""
@@ -16,33 +18,44 @@ import subprocess
from pathlib import Path
from typing import Any, Callable, Optional
-# Plain documents, data and raster images: nothing here is loaded and run by a build,
-# test runner, package manager, shell or browser. Formats that can carry script are NOT
-# here, however document-like: .html/.htm and .svg run JavaScript when opened, .xml can
-# pull in a stylesheet that does, and .pdf supports JavaScript in many readers. A live
-# run showed why (2026-10-26): refused an upload, the agent wrote an .html page whose
-# script did the upload, then tried to open it.
+# Plain documents and raster images: nothing here is loaded and run by a build, test
+# runner, package manager, shell or browser. Formats that can carry script are NOT here,
+# however document-like: .html/.htm and .svg run JavaScript when opened, .xml can pull in
+# a stylesheet that does, and .pdf supports JavaScript in many readers. A live run showed
+# why (2026-10-26): refused an upload, the agent wrote an .html page whose script did the
+# upload, then tried to open it. JSON and YAML are not here either (Devika, 28 Oct 2026):
+# package managers, task runners, CI and deploy tools read them to decide what to run.
_DOCUMENT_SUFFIXES = frozenset({
".md", ".markdown", ".txt", ".rst", ".csv", ".tsv", ".log",
".png", ".jpg", ".jpeg", ".gif", ".webp",
})
-# Structured data is inert unless a tool reads it to decide what to run. Those files are
-# dotfiles (`.eslintrc.json`, `.gitpod.yml`) or have well-known names, listed below.
-_DATA_SUFFIXES = frozenset({".json", ".jsonl", ".yaml", ".yml"})
-_TOOL_CONFIG_NAMES = frozenset({
- # package managers and task runners: scripts, tasks, hooks
- "package.json", "package-lock.json", "composer.json", "deno.json", "deno.jsonc",
- "turbo.json", "nx.json", "lerna.json", "taskfile.yml", "taskfile.yaml",
- # build and transpile configs that load plugins
- "babel.config.json", "tsconfig.json", "jsconfig.json", "angular.json", "project.json",
- # containers and deploy targets
- "docker-compose.yml", "docker-compose.yaml", "compose.yml", "compose.yaml",
- "vercel.json", "now.json", "firebase.json", "app.json", "app.yaml", "serverless.yml",
- "serverless.yaml", "cloudbuild.yaml", "cloudbuild.yml", "fly.toml",
- # CI systems not covered by the protected list
- "azure-pipelines.yml", "bitbucket-pipelines.yml", "appveyor.yml", "codemagic.yaml",
- "mkdocs.yml", "renovate.json",
+# Text files that decide what gets built, installed or tested: CMake runs CMakeLists.txt,
+# pip installs what requirements and constraints files list (`requirements-dev.txt`,
+# `dev-requirements.txt`, `requirements/base.txt`), and pytest runs `test*.txt` as doctests
+# by default.
+_BUILD_INPUT_NAME = re.compile(
+ r"^cmakelists\.txt$|^test.*\.txt$|(requirements|constraints).*\.txt$", re.IGNORECASE
+)
+_BUILD_INPUT_FOLDERS = frozenset({"requirements"})
+# Instructions other AI coding tools read into their prompt on their next run, so a write
+# here steers a later agent. AGENTS.md is not listed: the protected list (permissions.py)
+# already keeps it human-only, before this tier is consulted.
+_AGENT_INSTRUCTION_NAME = re.compile(
+ r"^(claude|claude\.local|gemini|qwen|crush|warp|agent|agents\.override|conventions"
+ r"|copilot-instructions|skill)\.md$"
+ r"|\.(instructions|prompt|chatmode|agent)\.md$", # GitHub Copilot's per-topic files
+ re.IGNORECASE,
+)
+# Every file in these folders, at any depth: Claude Code, Cursor, Windsurf, Cline, Roo,
+# Kiro, Amazon Q, Continue, Junie, Augment, Gemini, Antigravity, OpenHands, Trae, Codex
+# and OpenCode keep rules, commands, prompts and skills there.
+_AGENT_FOLDERS = frozenset({
+ ".claude", ".cursor", ".windsurf", ".clinerules", ".roo", ".kiro", ".amazonq",
+ ".continue", ".junie", ".augment", ".gemini", ".agent", ".agents", ".openhands",
+ ".trae", ".codex", ".opencode",
})
+# Under .github/, only Copilot's folders: CONTRIBUTING.md and issue templates stay eligible.
+_GITHUB_AGENT_FOLDERS = frozenset({"instructions", "prompts", "chatmodes", "agents", "skills"})
_SENSITIVE_NAME = re.compile(
r"^\.env(\..*)?$"
@@ -73,13 +86,24 @@ UNKNOWN = "unknown"
def is_inert_name(name: str) -> bool:
- lowered = name.lower()
- suffix = os.path.splitext(lowered)[1]
- if suffix in _DOCUMENT_SUFFIXES:
- return True
- if suffix in _DATA_SUFFIXES:
- return not lowered.startswith(".") and lowered not in _TOOL_CONFIG_NAMES
- return False
+ if os.path.splitext(name.lower())[1] not in _DOCUMENT_SUFFIXES:
+ return False
+ return not (_BUILD_INPUT_NAME.search(name) or _AGENT_INSTRUCTION_NAME.search(name))
+
+
+def is_inert_path(path: Path) -> bool:
+ """`is_inert_name`, and not inside a folder that build tools or AI tools read from.
+ Folder names match in any letter case and anywhere in the path: a doubtful match only
+ sends the write to the reviewer."""
+ if not is_inert_name(path.name):
+ return False
+ folders = [part.casefold() for part in path.parts[:-1]]
+ if any(f in _AGENT_FOLDERS or f in _BUILD_INPUT_FOLDERS for f in folders):
+ return False
+ return not any(
+ parent == ".github" and child in _GITHUB_AGENT_FOLDERS
+ for parent, child in zip(folders, folders[1:])
+ )
def is_sensitive_name(name: str) -> bool:
@@ -171,7 +195,7 @@ def inert_write_check(
parts: list[str] = []
for target in targets:
name = target.name
- if not is_inert_name(name) or is_sensitive_name(name):
+ if not is_inert_path(target) or is_sensitive_name(name):
return False, ""
if not target.exists():
parts.append(f"new file {name}")
diff --git a/surfaces/gui/src/components/Transcript.test.tsx b/surfaces/gui/src/components/Transcript.test.tsx
index 8c73cc69..7b92c657 100644
--- a/surfaces/gui/src/components/Transcript.test.tsx
+++ b/surfaces/gui/src/components/Transcript.test.tsx
@@ -135,6 +135,7 @@ describe("origin chips — standing MCP trust names its source", () => {
expect(tier.text).toBe("safe change, no card");
expect(tier.title).toContain("without the reviewer");
expect(tier.title).toContain("can be undone");
+ expect(tier.title).toContain("a document or image"); // OPE-233: JSON/YAML left the tier
});
});
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index b474a222..8b26ec4a 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -249,7 +249,7 @@
"run_grant": "allowed for this request",
"run_grant_title": "you chose 'Allow for this request' earlier in this answer — this call ran without a card. Its full arguments are in this transcript and the audit log; the grant expired when the answer finished",
"gate_tier": "safe change, no card",
- "gate_tier_title": "Auto-approve let this run without the reviewer: an inert file (a document or data, not code) inside your folders that can be undone — a new file, a file unchanged in git, or one the agent wrote earlier. Its full arguments are in this transcript and the audit log"
+ "gate_tier_title": "Auto-approve let this run without the reviewer: an inert file (a document or image, not code or config) inside your folders that can be undone — a new file, a file unchanged in git, or one the agent wrote earlier. Its full arguments are in this transcript and the audit log"
},
"step": {
"raw": "raw",
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index 5e2f1970..0edd2a84 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -247,7 +247,7 @@
"run_grant": "本次请求内已允许",
"run_grant_title": "您在本次回答早些时候选择了“本次请求内允许”——此调用未显示审批卡片。完整参数保存在会话记录与审计日志中;回答结束后该授权已失效",
"gate_tier": "安全更改,无需审批卡片",
- "gate_tier_title": "自动批准未经审查模型即运行了此操作:这是您文件夹内可撤销的非执行文件(文档或数据,而非代码)——新文件、在 git 中未修改的文件,或智能体早先写入的文件。完整参数保存在会话记录与审计日志中"
+ "gate_tier_title": "自动批准未经审查模型即运行了此操作:这是您文件夹内可撤销的非执行文件(文档或图片,而非代码或配置)——新文件、在 git 中未修改的文件,或智能体早先写入的文件。完整参数保存在会话记录与审计日志中"
},
"step": {
"raw": "原始",
diff --git a/tests/test_inert_writes.py b/tests/test_inert_writes.py
index abb37e36..361a42a5 100644
--- a/tests/test_inert_writes.py
+++ b/tests/test_inert_writes.py
@@ -1,8 +1,9 @@
"""Auto-approve's inert-writes tier (OPE-233).
-A write inside the session's folders runs without a reviewer call when it is an inert
-file type, its name and content don't look secret, it isn't a protected file, and it can
-be undone: a new file, a git-tracked file with no uncommitted changes, or a file the agent
+A write inside the session's folders runs without a reviewer call when it is a plain
+document or raster image (not JSON or YAML, not a build or install input, not another AI
+tool's instruction file), its name and content don't look secret, it isn't a protected
+file, and it can be undone: a new file, a git-tracked file with no uncommitted changes, or a file the agent
itself wrote earlier in the session. Every other write reaches the reviewer exactly as
before. Behind `inert_writes`: "off" (default) → "audit" (decision unchanged, "would
allow" recorded) → "on"."""
@@ -87,13 +88,62 @@ def test_an_unknown_flag_value_means_off(tmp_path):
@pytest.mark.parametrize(
"path",
- ["notes.md", "out/report.txt", "data/rows.csv", "data/rows.tsv", "result.json", "cfg/settings.yaml",
- "chart.png", "docs/guide.rst", "run.log", "NOTES.MD"],
+ ["notes.md", "out/report.txt", "data/rows.csv", "data/rows.tsv", "chart.png", "docs/guide.rst",
+ "run.log", "NOTES.MD", "README.md", "CHANGELOG.md", "LICENSE.txt", "docs/design.markdown",
+ # names that only look like the exclusions below
+ "docs/claude-notes.md", "notes/agents-meeting.txt", "cursor-tips.md", "cmake-notes.txt"],
)
def test_inert_types_are_eligible(tmp_path, path):
assert _ran_without_reviewer(_gate(tmp_path).evaluate("write_file", _write(path)))
+ "path",
+ # Devika, 28 Oct 2026: JSON and YAML left the tier. Tools read them to decide what to
+ # run, and no list of tool-config names can be complete. The reviewer sees the content.
+ # result.json and cfg/settings.yaml were eligible before this change.
+ ["result.json", "cfg/settings.yaml", "data/rows.jsonl", "config.yml", "nodemon.json",
+ "docker-compose.override.yml", "deploy/playbook.yml", "buildspec.yml",
+ ".vscode/settings.json", ".vscode/launch.json", "package.json", ".eslintrc.json"],
+)
+def test_json_and_yaml_go_to_the_reviewer(tmp_path, path):
+ assert _goes_to_reviewer(_gate(tmp_path).evaluate("write_file", _write(path)))
+
+
+ "path",
+ # Text files that decide what gets built, installed or tested: CMake runs
+ # CMakeLists.txt, pip installs what requirements and constraints files list, and
+ # pytest runs test*.txt files as doctests by default.
+ ["CMakeLists.txt", "src/lib/cmakelists.TXT", "requirements.txt", "REQUIREMENTS.txt",
+ "requirements-dev.txt", "requirements_test.txt", "dev-requirements.txt",
+ "requirements/base.txt", "constraints.txt", "ci/constraints-py311.txt",
+ "test_examples.txt", "docs/testing.txt"],
+)
+def test_build_and_install_inputs_go_to_the_reviewer(tmp_path, path):
+ assert _goes_to_reviewer(_gate(tmp_path).evaluate("write_file", _write(path)))
+
+
+ "path",
+ # Instructions another AI coding tool reads into its prompt on its next run.
+ ["CLAUDE.md", "claude.MD", "sub/dir/CLAUDE.md", "CLAUDE.local.md", "GEMINI.md", "QWEN.md",
+ "CRUSH.md", "WARP.md", "AGENT.md", "AGENTS.override.md", "CONVENTIONS.md",
+ ".github/copilot-instructions.md", ".github/instructions/python.instructions.md",
+ "src/api.instructions.md", ".github/prompts/release.prompt.md",
+ ".github/chatmodes/plan.chatmode.md", ".github/agents/reviewer.agent.md",
+ ".claude/commands/deploy.md", ".claude/agents/helper.md", "tools/x/SKILL.md",
+ ".cursor/rules/style.md", ".Cursor/Rules/Style.md", ".windsurf/rules/rules.md",
+ ".clinerules/01-style.md", ".roo/rules/style.md", ".kiro/steering/product.md",
+ ".amazonq/rules/style.md", ".continue/rules/style.md", ".junie/guidelines.md",
+ ".augment/rules/style.md", ".gemini/styleguide.md", ".agent/rules/style.md",
+ ".agents/rules/style.md", ".openhands/microagents/repo.md", ".trae/rules/project_rules.md",
+ ".codex/notes.md", ".opencode/agent/review.md"],
+)
+def test_other_ai_tools_instruction_files_go_to_the_reviewer(tmp_path, path):
+ assert _goes_to_reviewer(_gate(tmp_path).evaluate("write_file", _write(path)))
+
+
@pytest.mark.parametrize(
"path",
["make_report.py", "build.sh", "run.ps1", "app.js", "main.ts", "lib.rb", "x.c", "Makefile",
@@ -107,8 +157,8 @@ def test_code_scripts_and_unknown_types_go_to_the_reviewer(tmp_path, path):
@pytest.mark.parametrize(
"path",
- [".env", ".env.local", "secrets/.ENV.production", "server.pem", "api_key.txt", "API-KEY.json",
- "credentials.json", "id_rsa.txt", "my_secrets.yaml", "token.txt", "password.txt"],
+ [".env", ".env.local", "secrets/.ENV.production", "server.pem", "api_key.txt", "API-KEY.md",
+ "credentials.txt", "id_rsa.txt", "my_secrets.md", "token.txt", "password.txt"],
)
def test_secret_looking_names_go_to_the_reviewer(tmp_path, path):
assert _goes_to_reviewer(_gate(tmp_path).evaluate("write_file", _write(path)))
@@ -199,8 +249,8 @@ def test_an_untracked_existing_file_goes_to_the_reviewer(tmp_path):
def test_an_ignored_existing_file_goes_to_the_reviewer(tmp_path):
_repo(tmp_path, {".gitignore": "out/\n"})
(tmp_path / "out").mkdir()
- (tmp_path / "out" / "result.json").write_text("{}", encoding="utf-8")
- d = _gate(tmp_path).evaluate("write_file", _write("out/result.json", overwrite=True))
+ (tmp_path / "out" / "result.csv").write_text("a,b", encoding="utf-8")
+ d = _gate(tmp_path).evaluate("write_file", _write("out/result.csv", overwrite=True))
assert _goes_to_reviewer(d)