paperclip/cli/src/__tests__
Dotta 7cfb655f60
fix(worktree): disable automatic database backups (#10520)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip creates isolated instances for linked git worktrees so
development does not affect the primary instance
> - Those instances inherited the source instance's automatic
database-backup setting and also repaired older configs without
overriding it
> - As worktrees accumulated, each isolated instance could schedule its
own backup stream, producing redundant backup churn for disposable
database clones
> - This pull request makes backup disablement an invariant of worktree
config creation and repair
> - The benefit is that automatic backups remain focused on the durable
primary instance while isolated development instances stop accumulating
redundant backup files

## Linked Issues or Issue Description

No public GitHub issue exists for this bug, so the report is included
here. The closest related open change is Refs #10266, which hardens
where worktree config repair may write; this PR changes the backup
policy applied by that repair and by worktree initialization.

### What happened?

Isolated worktree instances copied `database.backup.enabled` from their
source config. When the source instance enabled automatic backups (the
normal default), every linked worktree also enabled a scheduled backup
stream. Existing worktree configs kept that state during startup repair,
so the redundant backups continued after the policy changed.

### Expected behavior

Automatic database backups are disabled for isolated worktree instances
created by `paperclipai worktree init` or `paperclipai worktree:make`,
and legacy worktree configs are migrated to that policy during normal
startup repair. The durable primary/default instance keeps its existing
backup behavior.

### Steps to reproduce

1. Start from a Paperclip instance whose database backup setting is
enabled.
2. Create or initialize a linked worktree with `paperclipai worktree
init`.
3. Inspect the generated worktree config and environment.
4. Before this change, the config retained `database.backup.enabled:
true` and the environment had no disabling override; after this change,
the config is false and `PAPERCLIP_DB_BACKUP_ENABLED=false` is
persisted.

### Paperclip version, deployment mode, and environment

- Reproduced against `master` before commit `ea5e0a0269`.
- Deployment mode: local trusted development with linked git worktrees
and embedded PostgreSQL.
- Environment: Node.js 22, pnpm workspace install.

## What Changed

- Always generate isolated worktree configs with automatic backups
disabled.
- Persist `PAPERCLIP_DB_BACKUP_ENABLED=false` in generated worktree
environments.
- Repair existing isolated worktree configs and environments that still
enable backups.
- Add CLI and server regression coverage for creation and legacy repair
paths.
- Document the worktree-specific backup policy and primary-instance
exception.

## Verification

- `pnpm exec vitest run cli/src/__tests__/worktree.test.ts
server/src/__tests__/worktree-config.test.ts` — 52 tests passed.
- `pnpm -r typecheck` — passed.
- `pnpm build` — passed.
- All repository commands above were run with inherited worktree runtime
identity variables removed.

## Risks

- Low operational risk: the change is limited to explicitly isolated
worktree instances.
- Operators who intentionally relied on automatic backups of disposable
worktree databases will now need to run a manual backup or explicitly
manage those files outside the scheduled worktree runtime.
- No schema, migration, API, UI, lockfile, or workflow changes.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- OpenAI Codex based on GPT-5 (the runtime does not expose a more
specific snapshot ID or context-window value), using reasoning, tool
use, local code execution, and GitHub CLI integration.

## 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>
2026-07-30 17:35:04 -07:00
..
helpers Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
access-parity.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
activity-parity.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
admin-asset-skill-parity.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
agent-jwt-env.test.ts fix(cli): quote env values with special characters 2026-03-13 15:07:49 -05:00
agent-lifecycle.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
allowed-hostname.test.ts feat: implement app-side telemetry sender 2026-04-02 10:47:29 -05:00
auth-command-registration.test.ts fix(cli): handle headless browser-open failure in board auth (#8328) 2026-06-19 08:58:17 -07:00
board-auth.test.ts Add browser-based board CLI auth flow 2026-03-23 08:46:05 -05:00
common.test.ts test(cli): cover API path construction (#9254) 2026-07-21 09:57:11 -05:00
company-delete.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
company-export-force.test.ts feat(cli): add --force to company export for non-interactive runs (#10054) 2026-07-22 15:36:54 -07:00
company-import-export-e2e.test.ts [codex] Add built-in agents and Reflection Coach bundle (#9206) 2026-07-09 16:29:30 -05:00
company-import-url.test.ts refactor: rename URL validators to looksLikeRepoUrl 2026-04-01 23:21:22 +00:00
company-import-zip.test.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
company.test.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
configure.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
connect.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
context.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
data-dir.test.ts feat(cli): add --data-dir flag to isolate local state 2026-03-02 14:20:37 -06:00
doctor.test.ts feat: implement app-side telemetry sender 2026-04-02 10:47:29 -05:00
env-lab.test.ts Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
feedback.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
home-paths.test.ts [codex] Add LLM Wiki plugin host support (#5597) 2026-05-10 07:34:12 -05:00
http.test.ts test(cli): clean API client fetch stubs (#9253) 2026-07-20 20:35:03 -05:00
issue-subresources.test.ts fix(cli): send X-Paperclip-Run-Id so agents can mutate their issues via the CLI (#7642) 2026-06-06 15:55:55 -07:00
network-bind.test.ts Fix wrapped company issue prefix conflicts (#6423) 2026-05-22 15:27:54 -05:00
onboard.test.ts feat(mcp) [split 5/8]: integrate adapters and deployment runtime (#9560) 2026-07-14 15:15:43 -05:00
open-url.test.ts fix(cli): handle headless browser-open failure in board auth (#8328) 2026-06-19 08:58:17 -07:00
operations-parity.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
pipelines.test.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
plugin-init.test.ts feat(cli): surface plugin install target host + add `plugin target` (#8575) 2026-06-25 01:07:35 -07:00
project-goal.test.ts feat(mcp) [split 5/8]: integrate adapters and deployment runtime (#9560) 2026-07-14 15:15:43 -05:00
prompt.test.ts test(cli): cover board prompt handoff (#9137) 2026-07-21 10:00:28 -05:00
routine-plugin-parity.test.ts feat(mcp) [split 5/8]: integrate adapters and deployment runtime (#9560) 2026-07-14 15:15:43 -05:00
routines.test.ts feat(routines): add workspace-aware routine runs 2026-04-02 11:38:57 -05:00
run.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
secrets.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
skills.test.ts refactor(deps-dev): bump vitest from 3.2.4 to 4.1.8 (#7581) 2026-06-05 21:11:32 -07:00
teams.test.ts refactor(deps-dev): bump vitest from 3.2.4 to 4.1.8 (#7581) 2026-06-05 21:11:32 -07:00
telemetry.test.ts test: make cli telemetry test deterministic in CI 2026-04-02 10:47:30 -05:00
token.test.ts test(cli): cover board token commands (#9138) 2026-07-21 10:01:15 -05:00
worktree-merge-history.test.ts Add merge-history project import option 2026-03-23 08:14:51 -05:00
worktree.test.ts fix(worktree): disable automatic database backups (#10520) 2026-07-30 17:35:04 -07:00
zip-codec.test.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00