Skip to content

fix(repos): forget remote-identity deadlines for removed repo locations - #14672

Merged
nwparker merged 2 commits into
mainfrom
nwparker/sta-4350-identity-deadlines
Aug 15, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/sta-4350-identity-deadlines

Conversation

@nwparker

@nwparker nwparker commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes STA-4350.

Problem

probeRetryAfterByLocation is keyed by connectionId\0path and written on both resolved and unresolved probes, but never pruned — only the test reset cleared it. A removed repo, a retired SSH host, or a repo whose path/connectionId changed kept its deadline for the life of the process.

isIdentityRefreshDue also seeds an entry for every resolved repo the first time it is seen, so the map grew with repository and host churn even with no probe activity at all.

The sharper statement of the defect: the map is not merely unpruned, it is process-global, while the repo list it describes belongs to a Store instance. Nothing tied its lifetime to the thing it was caching decisions about.

Change

The candidate sweep already enumerates every live repo, so it now reconciles the deadline map against those location keys — no new plumbing, O(n) on a list that was already being walked, and no exported signature changes.

Two things that make this safe:

  • No re-probe storm. getRepos() is a synchronous map over an already-in-memory array, and this.state is assigned exactly once, in the Store constructor — there is no in-place reload that could transiently shrink the list. A repo therefore cannot be absent from getRepos() mid-sweep and lose its 5-minute startup delay or its 6h backoff to a prune-then-reseed. (Both of those deadlines are suppressors in any case: dropping one costs another quiet interval, it never forces a probe.)
  • A probe still running for a dropped repo needs no exemption. It re-adds its own deadline when it settles, and only live repos are ever candidates, so nothing reads that entry in between. An earlier revision of this PR carried such an exemption; review showed it was a no-op whose comment named the very reason it was unnecessary, and that it would let a probe which never settles pin its deadline forever. It has been removed.

The prune must stay per-sweep rather than being hoisted to a one-shot at startup — that is what collects the orphan left behind when a repo is removed while its probe is still running.

Why reconcile rather than a bounded cache

The repo has a tested LRU (BoundedMap, src/shared/bounded-map.ts) and it is the wrong tool here. get() mutates recency, and capacity eviction can drop a live repo's deadline — which for an unresolved repo means an immediate extra git remote -v, reintroducing exactly the spurious-probe cost the TTL constants at the top of this file exist to prevent. A fixed cap also has nothing principled to be set to: the legitimate working set is "however many repos the user has", which is precisely what reconciling against live keys expresses and what any maxEntries would have to guess.

Severity

Honest assessment: this is hygiene, not a memory problem. Entries cost roughly 100-150 bytes (Map slot plus key string plus load factor), and cardinality is bounded by the repo store — keys are minted only from getRepos(), and the only writer to that array is Store.addRepo via user-initiated add/clone/create flows. No discovery loop auto-registers repos, and worktrees are not Repo records, so worktree churn contributes zero keys. Steady state is the live repo count (5-30 KB); orphans over a desktop process lifetime are realistically under 15 KB.

So this is P3/P4 rather than P2, and it is worth shipping mainly because the fix is six lines and the rest of this file reasons carefully about lifetimes — this was the one loose end.

Tests

  • A removed repo's deadline is forgotten, so the location is not immediately due when the repo comes back.
  • A surviving repo keeps its backoff when a sibling repo is removed (guards against over-pruning).

All 18 tests in the file pass.

Known adjacent gap (pre-existing, not fixed here)

probeGitRemoteIdentity runs git remote -v with no timeout (src/main/git/runner.ts:1082 only forwards a caller-supplied one). If that hangs on a wedged mount or SSH transport, its inFlightProbesByLocation entry never clears. That map self-clears on settle and is unaffected by this change, so it is out of scope — but a probe timeout would be a reasonable follow-up.

`probeRetryAfterByLocation` is keyed by connection and path and was
written for both resolved and unresolved probes, but never pruned — a
removed repo or a retired SSH host kept its deadline for the life of the
process. `isIdentityRefreshDue` also seeds an entry for every resolved
repo on first sight, so the map grew with repository and host churn even
with no probe activity.

The candidate sweep already enumerates every live repo, so it now
reconciles the deadline map against those location keys. `getRepos()`
reads a hydrated in-memory array, so a repo is never transiently absent
mid-sweep and cannot lose its startup delay or its backoff. Locations
with a probe still in flight are kept, since that probe re-adds its own
key when it settles.
@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7520cbde-13f6-4c47-926d-fd9aee69b661

📥 Commits

Reviewing files that changed from the base of the PR and between 7a4c82d and f4ba65f.

📒 Files selected for processing (1)
  • src/main/repo-git-remote-identity-enrichment.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/repo-git-remote-identity-enrichment.ts

📝 Walkthrough

Walkthrough

The enrichment scheduler now prunes retry deadlines for removed repository locations and retired hosts after it enumerates live non-folder repositories. It retains deadlines for locations with active probes. Tests cover re-adding a removed repository and preserving refresh backoff for a surviving repository when a sibling is removed.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, implementation, rationale, tests, and linked issue, but omits several required template sections and checklist details. Use the repository template headings and add ELI5, Visual Proof with N/A and a reason, testing checkboxes, AI disclosure, review notes, checklist, and author sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly summarizes the main change: pruning remote-identity retry deadlines for removed repository locations.
✨ Finishing Touches
📝 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.

… prune

The exemption's own comment named the reason it was unnecessary: a probe
re-adds its deadline when it settles, so skipping its key produced the
same map state as deleting it, and only live repos are ever candidates so
nothing read the entry in between.

Removing it also stops a probe that never settles from pinning its
deadline forever — the location's `git remote -v` can already hang with
no timeout, and the exemption turned that one stranded entry into two.
@nwparker
nwparker merged commit 3a4da06 into main Aug 15, 2026
44 checks passed
@nwparker
nwparker deleted the nwparker/sta-4350-identity-deadlines branch August 15, 2026 04:36
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ns (stablyai#14672)

* fix(repos): forget remote-identity deadlines for removed repo locations

`probeRetryAfterByLocation` is keyed by connection and path and was
written for both resolved and unresolved probes, but never pruned — a
removed repo or a retired SSH host kept its deadline for the life of the
process. `isIdentityRefreshDue` also seeds an entry for every resolved
repo on first sight, so the map grew with repository and host churn even
with no probe activity.

The candidate sweep already enumerates every live repo, so it now
reconciles the deadline map against those location keys. `getRepos()`
reads a hydrated in-memory array, so a repo is never transiently absent
mid-sweep and cannot lose its startup delay or its backoff. Locations
with a probe still in flight are kept, since that probe re-adds its own
key when it settles.

* refactor(repos): drop the no-op in-flight exemption from the deadline prune

The exemption's own comment named the reason it was unnecessary: a probe
re-adds its deadline when it settles, so skipping its key produced the
same map state as deleting it, and only live repos are ever candidates so
nothing read the entry in between.

Removing it also stops a probe that never settles from pinning its
deadline forever — the location's `git remote -v` can already hang with
no timeout, and the exemption turned that one stranded entry into two.
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