Skip to content

fix(tee): hash long recovery-file slugs to prevent collisions and shorten hints - #3266

Merged
KuSh merged 2 commits into
rtk-ai:developfrom
breisnerlopez:fix/tee-recovery-slug-collision
Aug 20, 2026
Merged

KuSh merged 2 commits into
rtk-ai:developfrom
breisnerlopez:fix/tee-recovery-slug-collision

Conversation

@breisnerlopez

Copy link
Copy Markdown
Contributor

Summary

  • fix(tee): recovery-file slugs (an embedded path that duplicates the command) are now hashed when long. This fixes a latent collision where two sibling paths truncated in the same second overwrote each other's recovery file, and it shortens the truncation hint by ~12 tokens.

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets && cargo test — clean on current develop.
  • Unit tests cover slug hashing and the sibling-path collision case (distinct recovery files for paths that previously collided).

Scope note: split out of the earlier bundled PR #3064 as its own focused PR (per the single-focus rule), rebased onto current develop. It is independent of the git show blob-filter feat (submitted separately).

…rten hints

The tee recovery filename embeds a command-derived slug (often a file path
that duplicates the command the LLM already issued), costing ~12 tokens in
every truncation hint. Long slugs (>24 chars) now collapse to a short
readable prefix plus a 6-hex SHA-256 tag.

This also fixes a latent collision in the old 40-char truncation: sibling
paths sharing a long common prefix (e.g. several `git show` blobs from the
same directory in the same second) truncated to an identical filename and
overwrote each other's recovery file. Hashing the full slug makes distinct
commands produce distinct filenames (~1-in-16M collision).

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi, LGTM except for some nitpicks

Comment thread src/core/tee.rs Outdated
Comment thread src/core/tee.rs Outdated
Address review nits on rtk-ai#3266:
- Collapse short_hash to format!("{:x}", Sha256::digest(..))[..6] per suggestion.
- Reword docs: 6 hex = 24 bits is not collision-resistant on its own (birthday
  bound ~few thousand slugs); safety here comes from also requiring the same
  readable prefix and epoch second.

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM thanks!

@KuSh
KuSh merged commit 983d0c9 into rtk-ai:develop Aug 20, 2026
10 of 11 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Aug 20, 2026
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
rtk 0.46.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## [0.46.0](rtk-ai/rtk@v0.45.0...v0.46.0) (2026-08-26)


### Features

- find: dispatch on find's grammar; compress find output for unmodeled predicates ([#3603](rtk-ai/rtk#3603))
- find: tee tail hint when rtk imposes the result cap ([#3603](rtk-ai/rtk#3603))

### Bug Fixes

- find: never-worse guard, recovery hint, and dispatch on find's grammar ([#3603](rtk-ai/rtk#3603))
- git: don't misdetect a value-taking option's argument as a patch flag ([#3575](rtk-ai/rtk#3575))
- cicd: stop benchmark.sh deleting the tracked scripts/benchmark harness ([#3595](rtk-ai/rtk#3595))
- tee: hash long recovery-file slugs to prevent collisions and shorten hints ([#3266](rtk-ai/rtk#3266))
- benchmark: avoid negative curl/cargo cases that fail the benchmark job ([#3430](rtk-ai/rtk#3430))
- test: accept both Ask and Allow verdicts in rewrite tests ([#3147](rtk-ai/rtk#3147)) — Closes [#3146](rtk-ai/rtk#3146)
- core: decode process output using Windows console code page ([#2717](rtk-ai/rtk#2717)) — Closes [#2452](rtk-ai/rtk#2452)
- git: preserve patch output from log commands ([#2951](rtk-ai/rtk#2951)) — Closes [#2944](rtk-ai/rtk#2944)
- discover: sanitize drive-letter colon so Windows discover finds sessions ([#2952](rtk-ai/rtk#2952)) — Closes [#2919](rtk-ai/rtk#2919)
- stream: decode lossily instead of dropping lines on invalid UTF-8 ([#2997](rtk-ai/rtk#2997)) — Closes [#2994](rtk-ai/rtk#2994)

### Other

- test(find): use the platform temp dir instead of /tmp ([#3717](https://github.com/rtk-ai/rtk/pull/3717))</pre>
  <p>View the full release notes at <a href="https://github.com/rtk-ai/rtk/releases/tag/v0.46.0">https://github.com/rtk-ai/rtk/releases/tag/v0.46.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!17826
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.

2 participants