Repository navigation
fix: retire stale GitLab host cache generations - #21136
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change updates GitLab known-host caching to associate host lists with execution generations and connection scopes. Stale entries are removed when generations change. Coalesced probes publish results only while they retain ownership and the execution key remains current. Tests cover resets, delayed probes, remembered hosts, failures, and scope isolation. New audit scripts and artifacts compare baseline and fixed retention behavior. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The cache retirement change preserves connection isolation and does not retain hosts for recreated connections. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, implementation, scope, and validation results. However, it omits most required template sections, including ELI5, What Changed, Why, Linked Issue with a Resolution Update the description to include all required template sections. Add the linked issue in Full details: Docstring CoverageExplanation Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 4 files. (5 skipped: 5 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Retire stale generations in the known-host cache —
knownHostsCacheByExecutionContextis now keyed by a generation-lesscacheKey(connection:${id}) and stores{ key, hosts }, so a reconnect replaces the superseded array instead of retaining one per SSH generation; the newknownHostsCacheContext()deletes a mismatched-generation entry on access. - Guard late probe publications —
probeGlabKnownHostswrites only whenownsKey()and the current provider generation still match the probe's captured key, so an abandoned, reset, or new-generation probe cannot repopulate the cache, while its original caller still receives the completed result. - Coverage — 8 new retention/lifecycle/scope tests, plus committed reproduction evidence under
docs/audits/gitlab-known-host-retirement/.
I verified this run: the focused suites (27 tests across the new file and the three existing probe/coalescer suites) pass; reverting gitlab-known-host-probe.ts to the base makes the new test file fail 6/8 with the 2 expected controls passing, matching the PR's claim; pnpm run typecheck:node exits 0. Every interleaving of generation change, coalescer stale-replacement, and explicit _resetKnownHostsCache() is covered by the two write guards, and the read paths guard with cached?.key === key; since generations are monotonic, the lazy deletion can only drop strictly older data. For connectionId null/undefined, cacheKey === key, so ownsKey() alone carries supersession and the generation clause is a fail-closed no-op.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Co-authored-by: m4air <[email protected]>

Problem and change
Every successful GitLab host probe after an SSH provider reconnect leaves an array cached under the old generation. Keep only the latest successful generation for each observed execution identity. Reuse the existing coalescer ownership check and current provider generation to prevent late results from repopulating a reset cache or overwriting a replacement probe.
Original callers can still receive their completed result. Remembered hosts, native/WSL/connection isolation, command routing and probe timeouts are preserved.
Validation
Source hashes and runnable proof. This is small metadata retention. Distinct historical connection identities can still retain one entry each until reset; no new cache cap is imposed. The demonstrated SSH generation growth cannot explain the reported all-local session in #19831.