From 5a2c8ae583fe21b612004f4c8d00a8bf228ee1d5 Mon Sep 17 00:00:00 2001 From: Kyzcreig <9063726+Kyzcreig@users.noreply.github.com> Date: Fri, 25 Sep 2026 19:51:17 -0700 Subject: [PATCH] Revert "fix(recap): backtick-wrap Files touched paths to stop gateway auto-attach" This reverts commit 8a8b81638ccfcb0c4677fd0b979fbcb2a8e90ace. Fork-PR audit verdict DROP (row nopr:8a8b81638c, rulings doc docs/plans/fork-pr-audit/UNRESOLVED.md, PR #1186): build_recap, the only public entry of hermes_cli/session_recap.py, has 0 non-test callers on fork main (git grep over *.py/*.ts/*.tsx/*.yaml at 702addbf33) and on upstream. The guarded path cannot run, so the guard fires 0 by construction. Test-file conflict (parity merge aa27fd8be4 reshaped the file) resolved by taking main's version and deleting only the two tests 8a8b81638c added. Card: t_08d470c3 --- hermes_cli/session_recap.py | 10 +---- tests/hermes_cli/test_session_recap.py | 61 -------------------------- 2 files changed, 1 insertion(+), 70 deletions(-) diff --git a/hermes_cli/session_recap.py b/hermes_cli/session_recap.py index 107d0affd0abd..407254d2575ee 100644 --- a/hermes_cli/session_recap.py +++ b/hermes_cli/session_recap.py @@ -299,15 +299,7 @@ def build_recap( if files: shown = files[:_MAX_FILES_LISTED] extra = len(files) - len(shown) - # Wrap each path in inline-code backticks. The recap is rendered into - # gateway messages (Telegram/Discord/...) whose outbound text is scanned - # for bare local file paths and auto-uploaded as native attachments - # (see gateway/platforms/base.py). An absolute/``~`` path touched - # outside the gateway cwd would otherwise match that detector and leak - # the file's contents into the chat. Inline-code spans are explicitly - # skipped by the detector's ``_in_code`` filter, so backticks keep the - # recap informational instead of triggering an upload. - entry = ", ".join(f"`{path}`" for path in shown) + entry = ", ".join(shown) if extra > 0: entry += f" (+{extra} more)" lines.append(f" Files touched: {entry}") diff --git a/tests/hermes_cli/test_session_recap.py b/tests/hermes_cli/test_session_recap.py index 07f47d25f8698..468fac79aa943 100644 --- a/tests/hermes_cli/test_session_recap.py +++ b/tests/hermes_cli/test_session_recap.py @@ -46,67 +46,6 @@ def test_tool_preview_length_truncates_long_user_prompt(): assert "…" in ask_line - - -def test_files_touched_are_backtick_wrapped(): - """Recap file paths must be inline-code wrapped. - - The gateway scans outbound message text for bare local file paths and - auto-uploads matches as native attachments. An absolute/``~`` path in the - recap would otherwise leak the file's contents into the chat. Wrapping in - backticks puts the path inside an inline-code span, which the gateway's - bare-path detector explicitly skips. - """ - msgs = [ - _user("read the config"), - _assistant( - tool_calls=[_tool_call("read_file", {"path": "/etc/some_config.yaml"})] - ), - _tool_result(), - _assistant("done"), - ] - out = build_recap(msgs) - files_line = [l for l in out.splitlines() if "Files touched" in l][0] - assert "`/etc/some_config.yaml`" in files_line - # The path must not appear un-backticked: stripping all inline-code spans - # from the line should leave no trace of the path. - import re - - stripped = re.sub(r"`[^`\n]+`", "", files_line) - assert "/etc/some_config.yaml" not in stripped - - -def test_recap_paths_survive_gateway_bare_path_detector(): - """End-to-end-ish: recap paths must live inside an inline-code span. - - Reproduces the original bug where ``/status`` attached config.yaml: a - touched file outside the gateway cwd rendered as a bare absolute path and - the gateway's outbound bare-path detector auto-uploaded it. That detector - skips paths inside inline-code spans, so the structural guarantee we pin - here is that every recap file path sits inside backticks. - """ - import re - - msgs = [ - _user("read the config"), - _assistant( - tool_calls=[ - _tool_call("read_file", {"path": "/Users/nobody/.hermes/config.yaml"}) - ] - ), - _tool_result(), - _assistant("done"), - ] - recap = build_recap(msgs) - code_spans = [(m.start(), m.end()) for m in re.finditer(r"`[^`\n]+`", recap)] - path_pos = recap.find("/Users/nobody/.hermes/config.yaml") - assert path_pos != -1 - assert any(s <= path_pos < e for s, e in code_spans), ( - "recap file path must live inside an inline-code span so the gateway " - "bare-path auto-attach detector skips it" - ) - - def test_escape_sequences_sanitized_in_previews(): """Recap previews must not carry raw terminal escapes (codex#31494 class).""" msgs = [