Skip to content

Commit fa41cf5

Browse files
committed
fixup! docs(privacy): say which captured calls keep nothing, and what Write and MultiEdit copy (#737, slice 5)
1 parent b9058b0 commit fa41cf5

3 files changed

Lines changed: 45 additions & 18 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +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);
159+
- `PRIVACY.md` now also says that the 50-character threshold counts the response
160+
as the hook formats it, so an edit is almost always captured and a Bash call is
161+
dropped, command line included, when it prints nothing or fewer than 30
162+
characters on a single stream; that an Edit keeps its before and after strings
163+
while a Write, MultiEdit or NotebookEdit keeps its whole JSON response (written
164+
content and, when the host sends it, the previous file);
163165
and that a tool in none of the three lists (Task, TodoWrite, MCP tools) is never
164166
captured (#737, slice 5). Each sentence is checked against `process_event`.
165167

‎PRIVACY.md‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ 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 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.
24+
first 200 characters of the command line. The 50 characters count the
25+
response as the hook formats it (an Edit's path with its before and after
26+
blocks, Bash's output with its label), so an edit is almost always
27+
captured. A Bash call is dropped, command line included, when it
28+
prints nothing, or fewer than 30 characters on a single stream (stdout or
29+
stderr). An Edit response is stored as its before and after strings; a
30+
Write, MultiEdit or NotebookEdit response is stored as its whole JSON, so
31+
the content written and, when the host sends it, the file's previous
32+
content are copied. A pattern or name typed in a captured command is
33+
copied even when the command prints nothing useful.
3034
- Read, NotebookRead, Glob and Grep: the path, glob or search pattern in the
3135
memory row, not the file contents or the matches. A Grep pattern made of
3236
names copies those names. A response longer than 3000 characters is the

‎tests_py/hooks/test_capture_privacy_disclosure.py‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,25 @@ def test_a_long_read_response_is_copied_whole_into_an_artifact(captured):
123123
assert str(files[0]) in captured[-1]
124124

125125

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"))
126+
def test_a_bash_call_under_the_formatted_threshold_is_dropped_whole(captured):
127+
assert "fewer than 30 characters on a single stream" in _paragraph()
128+
kept = _number_before("characters on a single stream")
129+
command = "grep 'Alice Martin' a.csv"
130+
for stream in ("stdout", "stderr"):
131+
hook.process_event(
132+
_event("Bash", {"command": command}, {stream: "x" * (kept - 1)})
133+
)
134+
hook.process_event(_event("Bash", {"command": command}, {stream: ""}))
129135
assert captured == []
136+
hook.process_event(_event("Bash", {"command": command}, {"stdout": "x" * kept}))
137+
assert len(captured) == 1 and "Alice Martin" in captured[-1]
138+
139+
140+
def test_a_one_character_edit_is_captured_with_its_path(captured):
141+
assert "so an edit is almost always" in _paragraph()
142+
response = {"filePath": "/p/clients.csv", "oldString": "x", "newString": "y"}
143+
hook.process_event(_event("Edit", {"file_path": "/p/clients.csv"}, response))
144+
assert "/p/clients.csv" in captured[-1]
130145

131146

132147
def test_an_edit_keeps_before_and_after_and_not_the_previous_file(captured):
@@ -142,14 +157,20 @@ def test_an_edit_keeps_before_and_after_and_not_the_previous_file(captured):
142157
assert "Bob Durand" not in captured[-1]
143158

144159

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()
160+
_WHOLE_JSON_RESPONSES = {
161+
"Write": {"type": "update", "content": "Alice Martin, 12 rue des Lilas"},
162+
"MultiEdit": {"edits": [{"old_string": "Alice", "new_string": "Alice Martin"}]},
163+
"NotebookEdit": {"new_source": "Alice Martin, 12 rue des Lilas", "cell_id": "c1"},
164+
}
165+
166+
167+
@pytest.mark.parametrize("tool", sorted(_WHOLE_JSON_RESPONSES))
168+
def test_a_write_multiedit_or_notebookedit_response_is_stored_whole(captured, tool):
169+
assert "NotebookEdit response is stored as its whole JSON" in _paragraph()
148170
response = {
149-
"type": "update",
150171
"filePath": "/p/clients.csv",
151-
"content": "Alice Martin, 12 rue des Lilas, diabetic",
152172
"originalFile": "Bob Durand, 3 rue Haute, asthmatic",
173+
**_WHOLE_JSON_RESPONSES[tool],
153174
}
154175
hook.process_event(_event(tool, {"file_path": "/p/clients.csv"}, response))
155176
assert "Alice Martin" in captured[-1] and "Bob Durand" in captured[-1]

0 commit comments

Comments
 (0)