Skip to content

fix(repo): let the Lore-id index rebuild after a failed build - #77

Merged
Ian-stetsenko merged 1 commit into
mainfrom
fix/lore-index-retry-after-failure
Nov 3, 2026
Merged

Ian-stetsenko merged 1 commit into
mainfrom
fix/lore-index-retry-after-failure

Conversation

@TommyC81

@TommyC81 TommyC81 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

getLoreIdIndex memoized its build promise with ??=: a fulfilled build caches forever (correct), but a rejected build also cached forever, so one transient git failure (lock contention, I/O hiccup) poisoned every later getLoreIdIndex call on that AtomRepository instance - the same rejection replayed, no retry.

Practical impact in the shipped CLI is low (one repository instance per process, and no caller retries today), but the class is exported for programmatic use where instances can be long-lived, and the trap hardens into API contract if left.

Fix: keep the ??= memoization and clear the cache slot on rejection, so the next call rebuilds. The rejection still propagates to every current awaiter; a fulfilled build stays memoized for the instance lifetime.

Merge-compatibility: the diff is a pure insertion between })(); and return this.loreIndex; - the IIFE body is untouched - so this merges cleanly with #75 (which rewrites that body) in any order; both orders verified locally (clean auto-merge, combined suite green).

Test: first build's authoritative --all pass throws; the rejection reaches the caller; the second call rebuilds (four git passes total) instead of returning the memoized rejection. Fails under the old code. Typecheck clean, full suite 507/507 on Windows.

getLoreIdIndex memoized its build promise with ??=: a fulfilled build caches forever (correct), but a REJECTED build also cached forever, so one transient git failure (lock contention, I/O hiccup) poisoned every later getLoreIdIndex call on that AtomRepository instance - the same rejection replayed with no retry. Practical impact in the shipped CLI is low (one repository instance per process, no caller retries today), but the class is exported for programmatic use where instances can be long-lived, and the trap hardens into API contract if left. The fix keeps the ??= memoization and adds a rejection handler that clears the cache slot, so the next call rebuilds; the rejection itself still propagates to every current awaiter, and the derived promise from the handler is intentionally discarded. The diff deliberately touches only the function's closing lines (byte-identical on the in-flight delta-pass branch), so the two PRs merge cleanly in any order. Test: the first build's authoritative --all pass throws, the rejection reaches the caller, and the second call rebuilds (four git passes total) instead of returning the memoized rejection.

Lore-id: a942e3e8
Constraint: A fulfilled build stays memoized for the instance lifetime (one build per instance remains the steady-state contract).
Constraint: The rejection must propagate to every current awaiter; only the cache slot resets.
Constraint: The diff must not touch the IIFE body, keeping it merge-compatible with the in-flight delta-pass change to the same function.
Tested: npm run typecheck: clean
Tested: Full suite on Windows: 507 tests in 34 files, all passing
Tested: Unit: first build rejects on the --all pass, second call rebuilds (log called 4 times) and returns the atom
Related: d181468e
Confidence: high
Scope-risk: narrow
Reversibility: clean
@Ian-stetsenko
Ian-stetsenko merged commit f4eb997 into main Nov 3, 2026
3 checks passed
@TommyC81
TommyC81 deleted the fix/lore-index-retry-after-failure branch November 3, 2026 14:28
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