Skip to content

fix: retire stale GitLab host cache generations - #21136

Merged
OrcaWin merged 1 commit into
mainfrom
np-oom-scan-gitlab-host-retirement
Sep 18, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
np-oom-scan-gitlab-host-retirement

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​171 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​171
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​642 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​631

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

  • Actual-source before/after proofs on Node 26 and Electron 43.7: 128 successful generation arrays become one current array; 16 remembered generations also become one. Explicit reset releases all original arrays.
  • Delayed old generations, explicit reset, abandoned same-generation probes, success/failure updates and five execution contexts are covered.
  • 32 tests pass, including eight new cases. The reconstructed baseline fails six cases and passes two controls. Node typecheck, focused lint and changed-code quality pass; root independently reran the 32 tests and portable proof.

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.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 62868513-1281-42da-bacf-1e3826f4671f

📥 Commits

Reviewing files that changed from the base of the PR and between 77cd61d and 9673578.

📒 Files selected for processing (9)
  • docs/audits/gitlab-known-host-retirement/README.md
  • docs/audits/gitlab-known-host-retirement/electron-results.json
  • docs/audits/gitlab-known-host-retirement/fix.patch
  • docs/audits/gitlab-known-host-retirement/original-source-hashes.json
  • docs/audits/gitlab-known-host-retirement/reproduce.cjs
  • docs/audits/gitlab-known-host-retirement/results.json
  • docs/audits/gitlab-known-host-retirement/sources.cjs
  • src/main/gitlab/gitlab-known-host-probe.ts
  • src/main/gitlab/gitlab-known-host-retirement.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The 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 96735

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 `Fixes #.… Update the description to include all required template sections. Add the linked issue in Fixes #... format, state N/A with a reason for Visual Proof if applicable, document manual and automated testing with tested platforms, complete t…
Docstring Coverage ⚠️ Warning 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… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: retiring stale GitLab host cache generations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

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 Fixes #... entry, Visual Proof or N/A, Testing checkboxes and platform details, Review, boundary confirmation, Notes, and Checklist.

Resolution

Update the description to include all required template sections. Add the linked issue in Fixes #... format, state N/A with a reason for Visual Proof if applicable, document manual and automated testing with tested platforms, complete the AI Disclosure and Agent skill upstream boundary sections as applicable, address the Notes items, and complete the Checklist.

Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Retire stale generations in the known-host cache — knownHostsCacheByExecutionContext is now keyed by a generation-less cacheKey (connection:${id}) and stores { key, hosts }, so a reconnect replaces the superseded array instead of retaining one per SSH generation; the new knownHostsCacheContext() deletes a mismatched-generation entry on access.
  • Guard late probe publications — probeGlabKnownHosts writes only when ownsKey() 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 51f809a into main Sep 18, 2026
29 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
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