Skip to content

Open-source skills for designing and reviewing software with AI agents

test: require successful native persona read evidence

n3wtheca68ec2a77b
diff --git a/TESTING.md b/TESTING.md
index 6354dec..b0c6edb 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -109,3 +109,21 @@ Track open cloud verification gaps in [#105 (Cowork)](https://github.com/google/
- Verify sequential stage execution and persona lenses in addition to artifact existence.
- Distinguish fixture design findings from execution failures of the review workflow.
- Keep installation, execution, and transcript isolation results recorded separately.
+
+### Offline evidence checks
+
+Run `pytest tests/unit/test_claude_traces.py` to exercise the Claude probe's
+native child validator with synthetic records. A persona read request alone is
+not a successful read: require a matching, non-error, nonempty native tool
+result. Missing or unrelated results fail even when the child says `UNKNOWN`.
+These tests do not invoke models or establish cloud support. A successful tool
+result also does not by itself prove that the entire resource was read.
+
+For Cowork and ChatGPT Work, retain separate evidence for every reviewer:
+native launch arguments, canonical persona/target/standard paths, actual read
+results and coverage, completion, and stage timestamps. Child-written receipts
+and parent summaries cannot substitute for unavailable tool records. Inspect
+the actual isolation child's answer; test host-added context separately from
+parent-turn isolation. Keep raw account-bearing records private. Publish only
+sanitized findings and candidate identifiers. If the surface cannot expose the
+required evidence, record that boundary and leave the affected checks open.
diff --git a/tests/integration/test_claude.py b/tests/integration/test_claude.py
index 9d7df4b..8e94c21 100644
--- a/tests/integration/test_claude.py
+++ b/tests/integration/test_claude.py
@@ -25,6 +25,34 @@ def trace_directory(workspace: Path) -> Path:
return config / "projects" / project
+def assert_child_probe(raw: str, persona: Path, markers: list[str]) -> None:
+ """Check the native child's answer, tool restrictions, and completed read."""
+ assert all(marker not in raw for marker in markers)
+ answers = []
+ child_reads = []
+ successful = set()
+ for line in raw.split("\n"):
+ if not line.strip():
+ continue
+ event = json.loads(line)
+ content = event.get("message", {}).get("content", [])
+ for block in content if isinstance(content, list) else []:
+ if event.get("type") == "assistant":
+ if block["type"] == "tool_use":
+ assert block["name"] == "Read"
+ child_reads.append((block["id"], block["input"]["file_path"]))
+ if block["type"] == "text":
+ answers.append(block["text"])
+ if (event.get("type") == "user" and block["type"] == "tool_result"
+ and not block.get("is_error") and block.get("content")):
+ successful.add(block["tool_use_id"])
+ assert answers and answers[-1].strip() == "UNKNOWN"
+ assert [path for _, path in child_reads] == [str(persona)]
+ assert all(call_id in successful for call_id, _ in child_reads), (
+ "Persona read has no successful native tool result"
+ )
+
+
def test_native_reviewer_isolation(tmp_path: Path) -> None:
root = Path(__file__).resolve().parents[2]
plugin = tmp_path / "plugin"
@@ -90,19 +118,4 @@ Do not read other plugins or logs, use MCP, or modify files.
children = list((traces / session / "subagents").glob("agent-*.jsonl"))
assert len(children) == 1
raw = children[0].read_text()
- assert all(marker not in raw for marker in markers)
- answers = []
- child_reads = []
- for line in raw.split("\n"):
- if not line.strip():
- continue
- event = json.loads(line)
- if event.get("type") == "assistant":
- for block in event["message"]["content"]:
- if block["type"] == "tool_use":
- assert block["name"] == "Read"
- child_reads.append(block["input"]["file_path"])
- if block["type"] == "text":
- answers.append(block["text"])
- assert answers[-1].strip() == "UNKNOWN"
- assert child_reads == [str(plugin / "agents/zoom_out.md")]
+ assert_child_probe(raw, plugin / "agents/zoom_out.md", markers)
diff --git a/tests/unit/test_claude_traces.py b/tests/unit/test_claude_traces.py
index 5177eec..02b0eb1 100644
--- a/tests/unit/test_claude_traces.py
+++ b/tests/unit/test_claude_traces.py
@@ -4,6 +4,7 @@
"""Offline regression coverage for Claude's native transcript directory."""
from pathlib import Path, PurePosixPath, PureWindowsPath
+import json
import runpy
from unittest.mock import Mock
@@ -41,3 +42,56 @@ def test_trace_directory(
assert trace_directory(workspace) == (
config / "projects" / project_name
)
+
+
[email protected]("result", ["success", "error", "missing", "unrelated", "empty"])
+def test_child_probe_requires_successful_read(result: str) -> None:
+ check = runpy.run_path(str(ROOT / "tests/integration/test_claude.py"))[
+ "assert_child_probe"
+ ]
+ persona = Path("/plugin/agents/zoom_out.md")
+ events = [{"type": "assistant", "message": {"content": [{
+ "type": "tool_use", "id": "read-persona", "name": "Read",
+ "input": {"file_path": str(persona)},
+ }]}}]
+ if result != "missing":
+ events.append({"type": "user", "message": {"content": [{
+ "type": "tool_result",
+ "tool_use_id": "other-read" if result == "unrelated" else "read-persona",
+ "is_error": result == "error",
+ "content": "" if result == "empty" else "Persona text",
+ }]}})
+ events.append({"type": "assistant", "message": {"content": [{
+ "type": "text", "text": "UNKNOWN",
+ }]}})
+ raw = "\n".join(json.dumps(event) for event in events)
+ if result == "success":
+ check(raw, persona, ["parent-only-marker"])
+ else:
+ with pytest.raises(AssertionError, match="successful native tool result"):
+ check(raw, persona, ["parent-only-marker"])
+
+
[email protected]("separator", ["\u0085", "\u2028", "\u2029"])
+def test_child_probe_keeps_unicode_inside_json_records(separator: str) -> None:
+ check = runpy.run_path(str(ROOT / "tests/integration/test_claude.py"))[
+ "assert_child_probe"
+ ]
+ persona = Path("/plugin/agents/zoom_out.md")
+ events = [
+ {"type": "assistant", "message": {"content": [{
+ "type": "tool_use", "id": "read", "name": "Read",
+ "input": {"file_path": str(persona)},
+ }]}},
+ {"type": "user", "message": {"content": [{
+ "type": "tool_result", "tool_use_id": "read",
+ "content": f"Persona{separator}text",
+ }]}},
+ {"type": "assistant", "message": {"content": [{
+ "type": "text", "text": "UNKNOWN",
+ }]}},
+ ]
+ raw = "\n".join(json.dumps(event, ensure_ascii=False) for event in events)
+ check(raw, persona, ["parent-only-marker"])
+ with pytest.raises(AssertionError):
+ check(raw, persona, ["Persona"])