refactor: extract backup metadata helpers#175
refactor: extract backup metadata helpers#175ndycode wants to merge 3 commits intorefactor/pr3-storage-named-backups-helperfrom
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 (6)
✨ 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 |
Summary
lib/storage.tsinto a dedicated helper moduleWhat Changed
lib/storage/backup-metadata.tswithlatestValidSnapshot(...),buildMetadataSection(...), and the snapshot metadata types used by restore diagnosticslib/storage.tsto consume the extracted helpers and types while preserving current behaviorValidation
npm run test -- test/storage.test.tsnpm run lintnpm run typechecknpm run buildRisk and Rollback
eb10a1fto restore the inline backup-metadata helpersAdditional 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
this pr continues the incremental
lib/storage.tssplit by extracting two cohesive groups of helpers into dedicated modules:lib/storage/backup-metadata.ts(snapshot types +latestValidSnapshot/buildMetadataSection) andlib/runtime/metrics.ts(RuntimeMetrics,createRuntimeMetrics, header-parsing, and env helpers).index.tsgains consistently tab-indented, alphabetically-sorted imports in the same commit. no logic changes — this is a pure structural refactor.lib/storage/backup-metadata.tsexports the three snapshot types and two functions that were previously private tolib/storage.ts;storage.tsre-imports them with no behavioral changelib/runtime/metrics.tsadditionally promotesclampRetryHintMsto an export and adds an injectablenowparameter toparseRetryAfterHintMs, enabling the deterministic header-parsing tests intest/runtime-metrics.test.tstest/backup-metadata.test.tscoverslatestValidSnapshotwell (undefined return, tie-breaking, mixed-valid) but is missing abuildMetadataSectionhappy-path case wherelatestValidPathshould be populated — the all-invalid path is the onlybuildMetadataSectiontestConfidence Score: 5/5
parseRetryAfterHintMsgaining an injectablenowparam (purely additive), andclampRetryHintMsbecoming an export. the two p2 test gaps (missingbuildMetadataSectionhappy-path, imprecise mtime-zero assertion) don't affect correctness and are follow-up improvements rather than merge blockers.Important Files Changed
nowparam for deterministic testingnowparam; covers all header formats (ms, seconds, date string, epoch seconds, epoch ms) and the sanitize allowlistFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[lib/storage.ts] -->|imports types + helpers| B[lib/storage/backup-metadata.ts] B -->|BackupSnapshotKind\nBackupSnapshotMetadata\nBackupMetadataSection| A B -->|latestValidSnapshot\nbuildMetadataSection| A C[index.ts] -->|imports helpers| D[lib/runtime/metrics.ts] D -->|RuntimeMetrics\ncreateRuntimeMetrics\nparseFailoverMode\nparseEnvInt\nparseRetryAfterHintMs\nsanitizeResponseHeadersForLog| C E[test/backup-metadata.test.ts] -->|unit tests| B F[test/runtime-metrics.test.ts] -->|unit tests| D style B fill:#d4edda,stroke:#28a745 style D fill:#d4edda,stroke:#28a745 style E fill:#cce5ff,stroke:#004085 style F fill:#cce5ff,stroke:#004085Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "test: cover extracted backup metadata he..." | Re-trigger Greptile