mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
<!-- entire-trail-link-start --> https://entire.com/gh/paperclipai/-/trails/51/changes/paperclip/51 <!-- entire-trail-link-end --> ## Thinking Path > - Paperclip runs with embedded or external PostgreSQL. > - The CLI checks the database before it starts the server. > - The server uses `DATABASE_URL` before the saved connection string. > - Doctor checked only the saved database configuration. > - A valid environment-only setup could fail before startup. > - This change probes the effective server target instead. > - Operators can keep database credentials in the environment. ## Linked Issues or Issue Description Fixes: #11598 Refs: #11612. That predecessor is closed and unmerged. The defect remains on current master at `0cb3fc7db5`. This PR adds current precedence coverage, including a saved embedded mode and explicitly empty environment values. ## What Changed - Resolve the effective URL with the same nullish environment-first rule as the server. - Probe external PostgreSQL when the environment selects it, even if the saved mode is embedded. - Keep an explicitly empty environment value distinct from an unset value. Do not trim or replace the selected URL. - Add eight mocked transport regressions. Keep the three embedded storage checks. ## Verification - `node node_modules/vitest/vitest.mjs run --config cli/vitest.config.ts cli/src/__tests__/database-check.test.ts` — 11 passed. - Six new cases failed before the original fix. - Review exposed one ambient worktree-mode failure in the new embedded fallback test. That test now sets its worktree flag explicitly. - Both `env -u PAPERCLIP_IN_WORKTREE node node_modules/vitest/vitest.mjs run --config cli/vitest.config.ts cli/src/__tests__/database-check.test.ts` and `PAPERCLIP_IN_WORKTREE=true node node_modules/vitest/vitest.mjs run --config cli/vitest.config.ts cli/src/__tests__/database-check.test.ts` pass all 11 cases. - Tests cover environment-only configuration, environment precedence, embedded override, saved fallback, empty values, unchanged URL forwarding, and a failed effective-target probe. - The database factory and transport are mocked. No database is started or contacted. - PR CI passed full typecheck, build, and broad tests on the exact reviewed head. Broad local checks were not repeated while a separate live qualification run owned local resources. - Fresh Greptile review is 5/5 at `a042fb4a28f2e1574972798ed80de2e616daf9fc`. All review threads are resolved. All 55 successful checks for this exact head are green. Two conditional checks are skipped, and one review check is neutral. No checks are pending or failed. ## Risks - Doctor now probes the database that server startup will use, instead of an ignored saved target. - Empty `DATABASE_URL` follows the existing server rule. It masks a saved URL in Postgres mode and leaves embedded mode selected when no effective URL exists. - No schema, migration, startup resolver, or provider behavior changes. Existing environment support is already documented in the implementation spec and developing guide. ## Model Used OpenAI `gpt-6.1-sol`, with repository inspection, code editing, and offline test tools. No model or provider call was used in the regression. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with 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 and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>