fix(itg): encode remotes in filesystem-safe cache keys (audit #13) - #252
Conversation
|
|
|
ITG local cache is designed for disk path lookup. |
…motes toStorageKey used filepath.Join to construct cache keys, which collapses double slashes in URL-style remotes (e.g. "https://github.com/x" becomes "https:/github.com/x") and uses platform-dependent separators. FloorKey used string concatenation preserving the original remote. This mismatch meant FloorKey could never discover entries written for URL-style remotes. Replace filepath.Join with explicit string concatenation in toStorageKey so both paths produce identical key prefixes. Pre-fix URL-remote entries were already undiscoverable by FloorKey, so nothing is lost. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
28783de to
f53448d
Compare
Nothing in the ITG cache contract says that. The very general ITG cache needs to be distributed, with local caching as an optimization. |
|
|
||
| // encodeRemote returns a filesystem-safe, reversible remote key component. | ||
| func encodeRemote(remote string) string { | ||
| return base64.RawURLEncoding.EncodeToString([]byte(remote)) |
There was a problem hiding this comment.
encode so that when name characters can be preserved, they are preserved, base64 hides the name
There was a problem hiding this comment.
Switched remote encoding from Base64 to URL path escaping in 1e95661. This preserves recognizable remote characters while escaping each slash as %2F, so the remote remains one reversible path component. The tests now assert the exact readable encoding and round-trip decoding.
[addressed by agent]
Summary
Encode repository remotes into a slash-free component before constructing ITG cache keys. This lets
toStorageKeyandFloorKeyuse the samepath.Joinlayout without URL or SSH remotes accidentally creating filesystem path segments.Intent
Make ITG cache keys portable across storage backends, including filesystem-based implementations, while ensuring writes, reads, and prefix listings derive identical keys for URL, path, and SSH remotes.
Changes
path.Join.Test Plan
go test ./core/itg/cache/..../tools/bazel test //core/itg/cache:cache_test --test_output=errorsmake gazelleaifx verifygo test ./...passes outside integration tests; integration requiresTANGO_REPO_REMOTERevert Plan
Revert the commits from this PR to restore the previous ITG cache-key format.
Jira Issues
None.