mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## Thinking Path > - The health endpoint reports database backup status. > - Backup directories and marker files may live on slow storage. > - Synchronous filesystem reads hold Node's event loop during each check. > - Other requests wait behind that filesystem work. > - Await filesystem operations and preserve the existing health response. ## Linked Issues or Issue Description **What happened?** A backup-health check scans and reads files synchronously on the HTTP event loop. **Expected behavior:** Filesystem work yields so unrelated timers and requests can proceed. **Steps to reproduce:** Enable database backup health with a slow backup directory, request `/api/health`, and observe unrelated event-loop work waiting for synchronous filesystem calls. The regression deterministically holds an asynchronous directory read and verifies another timer can run before it completes. **Paperclip version or commit:** `master` at `a027f76a7`. **Deployment mode:** Built from source; tested using temporary backup files and controlled filesystem responses. Related PRs #13308 (empty archive health) and #10736 (backup retention) address different backup behavior. This change leaves archive validation and retention policy alone; those branches may need small textual reconciliations if merged first. ## What Changed - Use `node:fs/promises` for directory enumeration, file metadata and failure markers. - Scan archive metadata in batches of at most four reads to bound filesystem work while allowing parallel I/O. - Await the result in the health route. - Treat only missing files as absent, including files removed by retention during enumeration. - Preserve warnings for actual filesystem failures and existing newest-file/marker behavior. - Add coverage for freshness, missing directories, marker text, read errors, retention races, bounded scan concurrency and event-loop progress. ## Verification - Backup-health and health route suites (4 files): 35 passed. - The event-loop regression fails with the original synchronous service. - The archive-only concurrency regression also fails against the sequential scan; optional marker reads cannot mask that failure. - `pnpm --filter @paperclipai/server typecheck`: passed. - `git diff --check`: passed. - Refreshed with upstream `master` at `7d59de6113caf5219d34d65e1fb5f0c1a7fbdc2a`, which includes the Runner qualified-command fixture fix. The fresh branch diff remains limited to this fix and its tests. - Re-ran all four focused suites on `8e96930537774ac4623cd493ba065b8a6f5d3269`: 35 passed. The first [refreshed CI run](https://github.com/paperclipai/paperclip/actions/runs/37038481259) passed every test gate except the touch-picker browser shard. The failure screenshot shows the last option already visible at the scroll boundary. The source-identical retry at `eeaeb752a36e0acd5129b6c6bce40e24fdefe1bd` [passed all CI](https://github.com/paperclipai/paperclip/actions/runs/37040261790), including the touch-picker shard, both Runner shards, build, typecheck, server suites, canary dry run and the final aggregate. - Greptile is 5/5 and all review threads are resolved. ## Risks The internal inspection helper now returns a Promise; its route caller awaits it. The response schema and freshness threshold are unchanged. No database migration or cache is introduced. ## Model Used OpenAI GPT-6 through Codex, with reasoning, Git and code execution tools. The exact deployment identifier and context-window size are not exposed in this session. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used, including the available version and capability details - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs - [x] I have described the issue using the bug report fields - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal ticket ID - [x] I have run tests locally and they pass - [x] I have added a regression test - [x] I have documented the affected request behavior and risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open findings - [x] I will address reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>