refactor: extract named backup discovery#174
refactor: extract named backup discovery#174ndycode wants to merge 4 commits intorefactor/pr3-storage-path-state-modulefrom
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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 |
ca9f9a6 to
f3604f5
Compare
Summary
lib/storage.tsinto a dedicated helper moduleWhat Changed
lib/storage/named-backups.tswithcollectNamedBackups(...)and theNamedBackupSummarytypelib/storage.tsto call the extracted helper and re-export the summary type expected by the current public surfaceValidation
npm run test -- test/storage.test.tsnpm run lintnpm run typechecknpm run buildRisk and Rollback
45cda79to restore the inline named-backup discovery implementationAdditional Notes
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
clean slice extraction —
collectNamedBackupsandNamedBackupSummaryare moved fromlib/storage.tsinto a dedicatedlib/storage/named-backups.tshelper, andAccountIdentityRef/toAccountIdentityRefare promoted to public exports inlib/storage/identity.ts. behavior is fully preserved and the existingstorage-last-backup.test.tsintegration suite validates the key scenarios end-to-end.lib/storage/named-backups.ts— new module withCollectNamedBackupsDepsinterface enabling dependency injection forreadDir,stat,loadAccountsFromPath, and an optionallogDebug; logic is identical to what was instorage.tslib/storage.ts— drops the inline implementation, delegates tocollectNamedBackupswith realnode:fs/promisesdeps, and re-exportsNamedBackupSummaryto preserve the public surfacelib/storage/identity.ts—AccountIdentityRefandtoAccountIdentityRefmadeexportsostorage.tscan import them without re-declaringreadDirtype is overly broad:typeof import("node:fs").promises.readdircarries every overload; a narrower single-signature interface matching the one actual call would be easier to stub in unit testsstorage-last-backup.test.tscovers behavior via the real fs throughgetNamedBackups(), but no test exercisescollectNamedBackupswith injected mocks directly — worth a follow-uptest/storage/named-backups.test.tsto stay above the 80% coverage threshold and to cover thelogDebug-optional and unknown-error-rethrow branchesConfidence Score: 4/5
readDirtype will make future mocking friction-y.readDirtype breadth and missing unit tests for the DI surfaceImportant Files Changed
readDirtype is overly broad and no dedicated unit tests were added against the DI surfacecollectNamedBackupswith real fs deps, re-exportsNamedBackupSummary, and drops the now-redundant inline implementation; no logic changeAccountIdentityRefandtoAccountIdentityRefthat were previously private in storage.ts — no logic change, purely visibility promotionFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["getNamedBackups()"] -->|injects real fs deps| B["collectNamedBackups(storagePath, deps)"] B --> C["deps.readDir(backupRoot, {withFileTypes:true})"] C -->|ENOENT| D["return []"] C -->|other error| E["throw"] C -->|entries| F["filter: isFile + .json"] F --> G["deps.stat(candidatePath) — statsBefore"] G --> H["deps.loadAccountsFromPath(candidatePath)"] H -->|null or 0 accounts| I["skip entry"] H -->|valid accounts| J["deps.stat(candidatePath) — statsAfter"] J -->|mtime changed| K["deps.logDebug? stale mtime warning"] J --> L["push to candidates[]"] G -->|throws| M["deps.logDebug? skip + continue"] L --> N["sort by mtimeMs desc, then fileName asc"] N --> O["return NamedBackupSummary[]"]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "Merge main into refactor/pr3-storage-nam..." | Re-trigger Greptile