Skip to content

Commit b9058b0

Browse files
committed
docs(privacy): say which captured calls keep nothing, and what Write and MultiEdit copy (#737, slice 5)
PRIVACY.md said a Bash command line is copied "even when the command prints nothing useful", but process_event drops a write-class or Bash call whose normalized response is under _MIN_OUTPUT_LENGTH (50) before anything is built, command line included. It also did not say that _normalize_output keeps only the before/after strings of an Edit, while a Write or MultiEdit response (no oldString/newString) is stored as its whole JSON, nor that a tool in none of the three lists is dropped as low_value_tool. Four tests drive the real process_event for each sentence. Refs #737 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018kyZYtuteev5XnAE8yMDVY
1 parent 45da362 commit b9058b0

3 files changed

Lines changed: 57 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ adheres to [Semantic Versioning](https://semver.org/).
156156
project, that personal data is not redacted, and that an artifact can outlive a
157157
capture refused after hand-over (#737, slice 4). A test compares the tool lists
158158
and limits in that text with the hook's own constants.
159+
- `PRIVACY.md` now also says that a write-class or Bash call whose response is
160+
under 50 characters is not captured at all, command line included; that an Edit
161+
keeps its before and after strings while a Write or MultiEdit keeps its whole
162+
JSON response (written content and, when the host sends it, the previous file);
163+
and that a tool in none of the three lists (Task, TodoWrite, MCP tools) is never
164+
captured (#737, slice 5). Each sentence is checked against `process_event`.
159165

160166
- A resolver run that only waits (no verdict yet, no Pipeline yet, or a newer head)
161167
ends green with a notice instead of red, so a failed `Pipeline after merge` on

‎PRIVACY.md‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,25 @@ To build and retrieve memory, Cortex reads and processes:
2121
captured call copies depends on the tool:
2222
- Edit, Write, MultiEdit, NotebookEdit and Bash: the tool's response, when it
2323
is at least 50 characters long, plus the edited file's path or, for Bash, the
24-
first 200 characters of the command line. A pattern or name typed in a command
25-
is copied even when the command prints nothing useful.
24+
first 200 characters of the command line. A call whose response is shorter
25+
is not captured at all, its path or command line included. An Edit response
26+
is stored as its before and after strings; a Write or MultiEdit response is
27+
stored as its whole JSON, so the content written and, when the host sends
28+
it, the file's previous content are copied. A pattern or name typed in a
29+
captured command is copied even when the command prints nothing useful.
2630
- Read, NotebookRead, Glob and Grep: the path, glob or search pattern in the
2731
memory row, not the file contents or the matches. A Grep pattern made of
2832
names copies those names. A response longer than 3000 characters is the
2933
exception: its full text is written to an artifact file (below), and the row
3034
points to it, so a long file you read is copied whole.
3135
- WebFetch and WebSearch: the response, when it is at least 50 characters long.
3236

33-
For the other tools, a response longer than 3000 characters is stored as a
34-
short gist in the memory row. For every tool, its full text goes to a file
35-
under `~/.claude/methodology/artifacts/` (one file per distinct content and
36-
month, shared by every memory that captured that content in that month). A
37+
A tool in none of these three lists (Task, TodoWrite or an MCP tool, for
38+
example) is never captured. For the tools other than Read, NotebookRead, Glob
39+
and Grep, a response longer than 3000 characters is stored as a short gist
40+
in the memory row. For every tool, its full text goes to a file under
41+
`~/.claude/methodology/artifacts/` (one file per distinct content and month,
42+
shared by every memory that captured that content in that month). A
3743
capture that never leaves the hook removes the file it created. A capture
3844
handed to the capture worker or spool and then refused there can still leave
3945
that file on disk with no memory pointing to it; no sweep removes such files

‎tests_py/hooks/test_capture_privacy_disclosure.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,42 @@ def test_a_long_read_response_is_copied_whole_into_an_artifact(captured):
121121
assert files[0].read_text(encoding="utf-8") == contents
122122
assert "Alice Martin" not in captured[-1]
123123
assert str(files[0]) in captured[-1]
124+
125+
126+
def test_a_short_response_is_not_captured_nor_its_command(captured):
127+
assert "is not captured at all, its path or command line included" in _paragraph()
128+
hook.process_event(_event("Bash", {"command": "grep 'Alice Martin' a.csv"}, "ok"))
129+
assert captured == []
130+
131+
132+
def test_an_edit_keeps_before_and_after_and_not_the_previous_file(captured):
133+
assert "An Edit response is stored as its before and after strings" in _paragraph()
134+
response = {
135+
"filePath": "/p/clients.csv",
136+
"oldString": "Alice Martin",
137+
"newString": "Alice Dupont",
138+
"originalFile": "Bob Durand, 3 rue Haute, asthmatic\n" * 3,
139+
}
140+
hook.process_event(_event("Edit", {"file_path": "/p/clients.csv"}, response))
141+
assert "Alice Martin" in captured[-1] and "Alice Dupont" in captured[-1]
142+
assert "Bob Durand" not in captured[-1]
143+
144+
145+
@pytest.mark.parametrize("tool", ["Write", "MultiEdit"])
146+
def test_a_write_or_multiedit_response_is_stored_whole(captured, tool):
147+
assert "a Write or MultiEdit response is stored as its whole JSON" in _paragraph()
148+
response = {
149+
"type": "update",
150+
"filePath": "/p/clients.csv",
151+
"content": "Alice Martin, 12 rue des Lilas, diabetic",
152+
"originalFile": "Bob Durand, 3 rue Haute, asthmatic",
153+
}
154+
hook.process_event(_event(tool, {"file_path": "/p/clients.csv"}, response))
155+
assert "Alice Martin" in captured[-1] and "Bob Durand" in captured[-1]
156+
157+
158+
@pytest.mark.parametrize("tool", ["Task", "TodoWrite", "mcp__cortex__recall"])
159+
def test_a_tool_in_no_list_is_never_captured(captured, tool):
160+
assert "A tool in none of these three lists" in _paragraph()
161+
hook.process_event(_event(tool, {}, "Alice Martin, diabetic. " * 200))
162+
assert captured == []

0 commit comments

Comments
 (0)