encodeProjectDir renders a path the way the store names its project
directories:
return strings.ReplaceAll(strings.TrimSuffix(dir, "/"), "/", "-")
The store's actual rule replaces every character outside [A-Za-z0-9-], not
just the separator. Recovering all 730 project-root transcripts' directory names
from the cwd they record: 73 are reproduced by replacing slashes alone, and
657 need the wider substitution. None are unexplained.
So Discover(ctx, Query{Dir: <a session's own working directory>}) returns zero
refs for most sessions, with no error — which is indistinguishable from a
directory that genuinely holds no transcripts. Any path containing . or _ is
affected; on a macOS store the temporary-directory paths alone are a large
share.
Nothing caught it because TestDiscoverHonoursTheQuery only asserts the
negative direction: that /nowhere/at/all yields nothing.
A second, smaller defect sits on the same line — the comparison is
strings.Contains, so Dir: "/work" also matches a project directory named for
/workspace/other.
Fix
func encodeProjectDir(dir string) string {
return strings.Map(func(r rune) rune {
switch {
case r >= 'a' && r <= 'z', r >= 'A' && r <= 'Z', r >= '0' && r <= '9', r == '-':
return r
}
return '-'
}, strings.TrimSuffix(dir, "/"))
}
and compare for equality, or on a path boundary, rather than by substring.
Test
A positive case: a store whose project directory is named for a path containing
. and _ must be found by a Dir query naming that path.
encodeProjectDirrenders a path the way the store names its projectdirectories:
The store's actual rule replaces every character outside
[A-Za-z0-9-], notjust the separator. Recovering all 730 project-root transcripts' directory names
from the
cwdthey record: 73 are reproduced by replacing slashes alone, and657 need the wider substitution. None are unexplained.
So
Discover(ctx, Query{Dir: <a session's own working directory>})returns zerorefs for most sessions, with no error — which is indistinguishable from a
directory that genuinely holds no transcripts. Any path containing
.or_isaffected; on a macOS store the temporary-directory paths alone are a large
share.
Nothing caught it because
TestDiscoverHonoursTheQueryonly asserts thenegative direction: that
/nowhere/at/allyields nothing.A second, smaller defect sits on the same line — the comparison is
strings.Contains, soDir: "/work"also matches a project directory named for/workspace/other.Fix
and compare for equality, or on a path boundary, rather than by substring.
Test
A positive case: a store whose project directory is named for a path containing
.and_must be found by aDirquery naming that path.