Skip to content

Commit 8ae887c

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

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ adheres to [Semantic Versioning](https://semver.org/).
158158
and limits in that text with the hook's own constants.
159159
- `PRIVACY.md` now also says that the 50-character threshold counts the response
160160
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
161+
kept, command line included, once its stdout, stderr and interrupted marker add
162+
up to 50 formatted characters (one stream alone: 30 characters); that an Edit keeps its before and after strings
163163
while a Write, MultiEdit or NotebookEdit keeps its whole JSON response (written
164164
content and, when the host sends it, the previous file);
165165
and that a tool in none of the three lists (Task, TodoWrite, MCP tools) is never

‎PRIVACY.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ To build and retrieve memory, Cortex reads and processes:
2424
first 200 characters of the command line. The 50 characters count the
2525
response as the hook formats it (an Edit's path with its before and after
2626
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
27+
captured. A Bash call is kept, command line included, as soon as its
28+
stdout, its stderr and its interrupted marker, formatted and added up,
29+
reach 50 characters. A call that prints nothing is always dropped; one
30+
that is not interrupted and prints on one stream only is dropped below 30
31+
characters of output; two streams or an interrupted marker can reach 50
32+
with less. An Edit response is stored as its before and after strings; a
3033
Write, MultiEdit or NotebookEdit response is stored as its whole JSON, so
3134
the content written and, when the host sends it, the file's previous
3235
content are copied. A pattern or name typed in a captured command is

‎tests_py/hooks/test_capture_privacy_disclosure.py‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,29 @@ 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_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"
126+
_BASH = {"command": "grep 'Alice Martin' a.csv"}
127+
128+
129+
def _capture_bash(captured, response: dict) -> bool:
130+
before = len(captured)
131+
hook.process_event(_event("Bash", _BASH, response))
132+
return len(captured) > before and "Alice Martin" in captured[-1]
133+
134+
135+
def test_a_bash_call_on_one_stream_is_kept_from_the_stated_length(captured):
136+
assert "A call that prints nothing is always dropped" in _paragraph()
137+
kept = _number_before("characters of output; two streams")
130138
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: ""}))
135-
assert captured == []
136-
hook.process_event(_event("Bash", {"command": command}, {"stdout": "x" * kept}))
137-
assert len(captured) == 1 and "Alice Martin" in captured[-1]
139+
assert not _capture_bash(captured, {stream: "x" * (kept - 1)})
140+
assert _capture_bash(captured, {stream: "x" * kept})
141+
assert not _capture_bash(captured, {"stdout": " ", "stderr": ""})
142+
assert not _capture_bash(captured, {"stdout": "", "interrupted": True})
143+
144+
145+
def test_two_streams_or_an_interruption_are_kept_with_less_output(captured):
146+
assert "two streams or an interrupted marker can reach 50" in _paragraph()
147+
assert _capture_bash(captured, {"stdout": "ok", "stderr": "warn: x"})
148+
assert _capture_bash(captured, {"stdout": "12345678", "interrupted": True})
138149

139150

140151
def test_a_one_character_edit_is_captured_with_its_path(captured):

0 commit comments

Comments
 (0)