Skip to content

fix(tier3): end feedback chat URL spans where a path after them can start - #389

Merged
rng1995 merged 5 commits into
mainfrom
naren/fix-feedback-url-span-masking
Nov 9, 2026
Merged

rng1995 merged 5 commits into
mainfrom
naren/fix-feedback-url-span-masking

Conversation

@rng1995

@rng1995 rng1995 commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

#364 leaves a URL unchanged while tier3 feedback masks local paths, but its URL pattern ran to the next whitespace. In minified JSON, an escaped env dump or stderr, or a ,/; list, everything after a URL was kept, including the run's, the skill's and the home directory's local paths. 0.8.0 masked the run's path there. This PR ends a URL where a path after it can start, so those paths are masked again. The URL itself, including any path in its query or fragment, stays unchanged, as #364 intended.

Input (after a URL) main (#364) This PR
{"doc":"https://h/e","log":"<run>/a.log"} whole rest kept "log":"<id>/a.log"
"https://h/e\nHOME=/home/alice\nLOG=<run>/a.log" kept HOME=~, LOG=<id>/a.log
https://h/e,--find-links=file://<run>/w kept file:<id>/w
https://h/a;/home/alice/x, [https://h/e](/home/alice/x) kept ~/x
"https://h/e\nfile:///home/alice/x" kept file://~/x
"https://h/e\n\u001b[2m<copied run>/a.log" kept \u001b[2m<id>/a.log
pip install git+file:///home/alice/x kept git+file://~/x
300,000 characters of a.a.a minutes about 0.3 s

Where a URL now ends

  • at whitespace, " ' < > a backtick ^ { | }, or an ANSI escape (raw, \u001b or \x1b);
  • at a \n \r \t escape. The backslash may be doubled, as in JSON inside JSON. A Windows folder name made of letters, digits, _ . ~ $ % - and followed by as many backslashes (C:\Users\t\runs, C:\\Users\\t\\runs) is a folder, not an escape, unless an escaped character such as \u001b or \xa0 comes next and is not a folder name itself (\t\x64\runs stays a folder);
  • before an absolute-path root or another scheme after , or ;, also with a NAME= or --opt= in between, or after a Markdown ](.

, ; ( ) = and other backslashes inside a URL still belong to it. So https://h/a;jsessionid=x?v=1,2 and vscode://file/C:\Users\bob\t\runs\<id> are kept whole.

Where a copied run's path starts

  • at the first absolute-path root after whitespace or a quote, or at a later root after , ; : = ( [ { or a \n \r \t escape, as before. The escape or separator may now be followed by ANSI codes, so /opt/a.py\r\x1b[K/srv/ci/<id> keeps /opt/a.py;
  • also right after an ANSI code, raw or escaped: a color code such as ERROR\u001b[0m/srv/ci/<id> or \x1b[1;38;2;255;255;255m, or another one such as erase line in \r\x1b[K\\nas01\share\<id>, also before a drive letter (\x1b[KC:\ci\<id>). A path colored in parts (\u001b[34m/srv/ci\u001b[0m/runs/<id>) is masked whole;
  • the backslash of an escape or of an escaped ANSI code is never a root, and only the first backslash of a run can be one. So a relative path after an escape (\nevals/results/<id>, JSON \nevals\\results\\<id>) is kept, and so is an escape or ANSI code before a masked path;
  • an even run of backslashes, a name, half as many backslashes and a share name is a UNC server, not a doubled escape: \\nas01\share, \\tsclient\C, JSON \\\\nas01\\share. A server named only n, r or t before an escaped character is not one: \\n\u201c (JSON around repr text) is a doubled escape before a single one;
  • folders named only n, r or t in a row are read together, so \r\n\u001b[2m is three escapes. Folders named like escapes in a row are read together too, and may hold other characters: C:\Users\bob\t\x64\x86\<id>, \n\x64@2\;
  • a Windows or UNC path with a folder named n, r or t is masked whole, as in 0.8.0, also when the next folder looks like an escape (C:\Users\bob\t\u1234\runs\<id>, \t\x64\) or starts with an escaped letter in JSON (\\t\\\u00e9cole).

The CLI reference and the Unreleased #364 CHANGELOG entry describe the fixed behavior. The 0.8.0 section is unchanged.

Testing

  • tests/evaluation/test_tier3_feedback_chat.py: 144 new cases, 94 of which fail on main. The 50 that pass pin what main already gets right: 18 inputs that must stay unchanged (URLs, and a relative path after one), 23 Windows or UNC paths with a folder, server or share name that starts with n, r or t or looks like an escape, which must be masked whole, and 9 copied paths in JSON or repr encoder chains, which must be masked.
    • one end-to-end test through compact_run_context with minified JSON;
    • a parametrized URL-boundary and path-start test (escapes, nested JSON, NAME=+scheme, Windows and UNC n/r/t names, ANSI codes, URLs that must be kept), and tests for JSON and repr encoder chains;
    • two linear-time guards that run in a subprocess with a 60 s timeout: dotted text, and long backslash runs inside and outside a URL and long \t/\n chains.
  • Mutation testing: 43 mutants that remove or weaken a new rule each fail at least one test.
  • Full suite: 25,335 passed. The 15 failures fail the same way on main on this machine: 13 in tests/tier3/test_judge_failure_artifacts.py, whose generated scripts run under the host's Python 3.9 python3, and the 2 host-only test_sidecar_retains_* tests.
  • Adversarial review: nine rounds replayed saved inputs and generated corpora (more than a million inputs, including JSON, repr and bytes-repr encoder chains, CRLF text and ANSI progress output) against 0.8.0, main and this branch, under POSIX, Windows and UNC-share scrubbers. Wherever this branch keeps more path text than 0.8.0, it is inside a URL (fix(tier3): mask skill and home paths and keep more text in feedback chat evidence #364's design), a relative path (a root glued to a name, also right after an escape or ANSI code), an earlier list item kept by the documented separator rule, as in PATH=/usr/bin:/home/ci/results/<id>, or one of the gaps below.
  • Timing: 300,000-character adversarial inputs (backslash runs inside and outside URLs, UNC and n/r/t folder chains, CRLF chains, long and repeated ANSI codes) take at most about 1.2 s under POSIX and Windows scrubbers on a loaded machine; realistic shapes take well under 0.5 s. The time doubles when the input doubles.

Known gaps (left as is)

  • A path joined to a URL by any other character stays in the URL, as documented. Examples: &, [, !, @, *, +, a \f/\b/\u002f escape, \\ and a root, a glued short option ,-I/x, ,mailto:x@y/path, or an uppercase \X1B/\U001B, which is not an escape.
  • A URL right after an ANSI code (\u001b[0mhttps://...) is not recognized, so a path in its query is masked.
  • A path right after an ANSI escape that is not a control sequence, such as \x1b8 or \x1b(B, reads as glued to its last character and is kept.
  • A run ID that starts with n, r or t after a backslash inside a URL loses that backslash. This is cosmetic, and Tier 3 run IDs start with a digit (YYYYMMDD_HHMMSS).
  • A URI template {…} before the run ID in the same URL loses the text between them, because { ends a URL. This is cosmetic.
  • Mixed separators after a folder named n/r/t, or after a folder named like an escape that follows one (D:\cache\n/srv/<id>, C:\b\t\x64/<id>), keep that prefix. So do more than eight such folders in a row.
  • These were left from earlier review rounds: ANSI codes right before a skill or home path, and the JSON \/ slash spelling.

🤖 Generated with Claude Code

…tart

The feedback chat leaves a URL other than a file: URL unchanged while it
masks local paths (#364). Its URL pattern ran to the next whitespace, so
in minified JSON such as

  {"doc":"https://host/e","log":"/home/alice/skill/evals/results/<id>/a.log"}

everything after the URL, including the run's, the skill's and the home
directory's local paths, reached the provider unmasked. 0.8.0 replaced
the run's path there with the run ID.

A URL now ends:
- at whitespace, at a character a URL never holds unencoded
  (" < > ` ^ { | }), and at a single quote;
- at a \n \r or \t escape (JSON or repr text), so the next line of an
  escaped env dump or stderr (HOME=..., ERROR:..., --log=..., file://...)
  is masked;
- before an absolute-path root or another scheme that follows a , or ;
  (a list), a , or ; with an option or variable name and =
  (DOC=https://h/e;LOG=/x, ,--find-links=file:///x), or a Markdown ](,
  so a file: URL listed after one is masked.
Commas, semicolons, parentheses, = and other backslashes inside a URL
still belong to it, so a Windows path in a URL is kept, and a local path
in its query or fragment stays unchanged, as #364 intended.

A backslash, n, r or t is an escape even when its backslash is doubled,
as in JSON inside JSON. It is a Windows folder instead when a name and
as many backslashes follow: C:\Users\bob\t\runs\<id> has a folder t,
and so does its JSON spelling with doubled backslashes. So a copied
Windows or UNC run path with such a folder is masked whole, as in 0.8.0,
and a URL holding one is kept. A scheme starts after an escape, not
inside it, so \nfile:///x is a file: URL and is masked, not an nfile:
URL that is kept.

A +file: scheme such as git+file: names a local path, so it is masked
like file: instead of being kept as a remote URL; 0.8.0 masked the run
path there.

A skill or home path right after a \n, \r or \t escape counts as a whole
path and is masked. A copied run's path after one, or after a path-list
separator and one, keeps the escape and the earlier list item.

The scheme is now at most 64 characters. Unbounded, it was rescanned
from every word boundary, so 300,000 characters of a.a.a took minutes;
it now takes well under a second.

The CLI reference now says what a URL keeps and where it ends, and the
Unreleased #364 entry describes the fixed behavior.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at a33c416 across privacy, correctness, tests and docs, with each finding reproduced against main and v0.8.0.

1 P2 and 8 P3 inline comments. The P2 is over-masking: a relative path after a URL's \n escape is read as absolute. Of the P3s, two are narrow leaks: a \n escape followed by an ANSI color code, and \nfile://localhost/. The rest are test-coverage gaps and wording.

One note on the description: it says the 14 new cases that pass on main "are the keep-the-URL cases". Only 10 of them keep a URL. The other 4 are the copied Windows/UNC paths with an n/r/t folder (test lines 511–517), which main already masks whole. The totals (47 new, 33 failing on main) are correct.

Comment thread docs/cli-reference.mdx Resolved
Comment thread CHANGELOG.md Resolved
rng1995 and others added 3 commits November 9, 2026 19:47
- The backslash of a \n, \r or \t escape or of an escaped ANSI code is
  never an absolute-path root, and only the first backslash of a run can
  be one, so a relative path after an escape stays relative (also in
  JSON, evals\\results) and long runs are scanned once.
- A root right after an ANSI code (any CSI sequence: colors, erase line,
  cursor moves; up to 64 parameter characters) starts a path. ANSI codes
  after a line escape or separator, escaped at the same level, split
  paths, so /opt/a.py\r\x1b[K/srv/<id> keeps the earlier path; a path
  colored in parts is masked whole; a drive letter after a code is a
  drive.
- An even run of backslashes, a name, half as many backslashes and a
  share name is a UNC server (\\nas01\share, \\tsclient\C), not a doubled
  escape, unless the server is named only n, r or t and an escaped
  character follows (\\n\u201c from JSON around repr text).
- Folders named only n, r or t in a row (\r\n), and folders named like
  escapes after one (\t\x64\x86, \n\x64@2), are read together, up to
  eight steps; any \uXXXX or \xNN after such a folder is an escape unless
  it is a folder itself. In JSON a folder may start with an escaped
  letter (\\t\\\u00e9cole). The URL pattern mirrors the folder check.
- A URL ends at an ANSI escape; the URL's escape checks are
  case-sensitive and linear on long backslash runs.
- file://localhost may start right after an escape.
- Docs and the Unreleased CHANGELOG entry describe the rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant