Skip to content

Read a home reference that names home itself - #49

Open
johnl-amd wants to merge 2 commits into
mainfrom
bare-home-sweep
Open

johnl-amd wants to merge 2 commits into
mainfrom
bare-home-sweep

Conversation

@johnl-amd

Copy link
Copy Markdown
Collaborator

Why

_HOME expanded a ~ only where a / followed it. Home is itself a directory the skill sits under, and one _ancestors keeps, so every spelling that names home with nothing after it swept the skill up and came back a clean room:

call before after
find ~/ -name SKILL.md voided voided
find ~ -name SKILL.md clean room voided
grep -r pattern ~ clean room voided
find $HOME -name SKILL.md clean room voided
Grep(pattern=…, path="~") clean room voided

That lands on the baseline, the side whose emptiness the whole verdict rests on, so a baseline that found the skill this way was graded no_signal or harmful instead of being voided. grep -r <topic> ~ is a natural first move for an agent that has been told nothing.

Raised as a follow-up on #35.

What changes

Both anchors, not only the one the review named.

  • After the ~: a separator, a shell one included, or the end of the word. That reaches the four spellings above, and also cd ~; ls and (cd ~) && ....
  • Before the ~: whitespace, a quote, or the start of the string. This half is what makes the first one safe. (?<![\w/~$]) was enough while a / had to follow and stops being enough the moment the end of a word will do, because [[ $x =~ ^run ]], awk '$1 !~ /p/' and find . -name '*~' each put a ~ after punctuation, and each would expand to home and void a case that never went near it.
  • A word character after the ~ still rules out ~5 and ~user, and the lookbehind still keeps s/~/-/ a sed script.

The second commit deletes _swept. It lost its caller when the logic moved inline into _read_the_skill, so that a sweep word and a directory could be matched across separate arguments rather than within one string, and the two have drifted since: the inline version also treats a call to a search tool as a sweep whatever its arguments say, and _swept does not.

Verification

  • 898 tests pass. ruff --select F401,F841 is clean.
  • Each half of the rule is pinned on its own. Reverting the lookahead to (?=/) fails the new tests in 8 places. Loosening the lookbehind back to (?<![\w/~$]) while keeping the new lookahead fails the punctuation test. Neither mutation is caught by the other's test.
  • Four new tests, two positive and two negative. The negative ones use commands that already sweep, so the unexpanded ~ is the only thing keeping them clean and the assertion cannot pass vacuously.

Not verified: no live agent run. The behaviour is exercised through _inspect_room with recorded tool calls, as the surrounding tests are.

Scope

A bare ~ between spaces in text that was never a path, grep -r 'a ~ b' notes.txt, is still read as home. No anchoring catches that one: it is indistinguishable from a real sweep without knowing what the string meant. It voids a case rather than inverting a verdict, and it belongs to the standing question about the string matcher raised on #35 rather than to this change.

`_HOME` wanted a `/` after the `~`, so it expanded `find ~/ -name
SKILL.md` and left `find ~ -name SKILL.md` alone. Home is itself a
directory the skill sits under and one `_ancestors` keeps, so the second
spelling swept the skill up and was reported as a clean room -- on the
baseline, the side whose emptiness the whole verdict rests on. `grep -r
pattern ~`, `find $HOME -name SKILL.md`, `cd ~; ls` and `Grep(path="~")`
were the same miss.

What follows the `~` may now be a separator, a shell one included, or the
end of the word. What precedes it has to be whitespace, a quote or the
start of the string, which is what keeps the wider lookahead safe:
anything-but-a-word-character sufficed while a `/` had to follow, and
would now expand the `~` in `[[ $x =~ ^run ]]`, `awk '$1 !~ /p/'` and
`find . -name '*~'`, voiding cases that never went near home. A word
character after the `~` still rules out `~5` and `~user`.

A bare `~` between spaces in text that was never a path is still read as
home. That voids a case rather than inverting a verdict, and it is the
string matcher's standing limit rather than this rule's.

Signed-off-by: John Lybeck <john.lybeck@amd.com>
`_swept` lost its caller when the logic moved inline into
`_read_the_skill`, so that the sweep word and the directory could be
matched across separate arguments rather than within one string. The two
have drifted since: the inline version also treats a call to a search
tool as a sweep whatever its arguments say, and this one does not.

Signed-off-by: John Lybeck <john.lybeck@amd.com>
@johnl-amd
johnl-amd requested a review from rominf November 19, 2026 13:51
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