paperclip/packages/db/src/migrations/meta
Dotta 7a9b3a6037
[codex] Harden recovery issue handling (#4600)
## Thinking Path

> - Paperclip orchestrates AI agents for zero-human companies
> - The control plane must recover stranded agent work without creating
new operational loops
> - Stranded recovery issues can themselves fail, and exposing raw retry
errors in comments can leak sensitive adapter details
> - New local companies also should not force a hire-approval gate
unless operators enable that policy
> - This pull request hardens recovery issue handling, redacts retry
failure details in issue copy, preserves `maxConcurrentRuns: 1`, and
flips new-hire approval to an opt-in default
> - The benefit is safer automatic recovery and smoother default company
setup without hidden migration conflicts

## What Changed

- Added migration `0071_default_hire_approval_off` and updated company
schema/import/export/docs so hire approvals default off and serialize
only when enabled.
- Added migration `0072_large_sandman` with a partial unique index
preventing duplicate active stranded recovery issues for the same source
issue.
- Blocked failed `stranded_issue_recovery` issues in place instead of
creating nested recovery issues.
- Redacted latest retry failure details from recovery issue comments
while still linking reviewers to run evidence.
- Allowed `maxConcurrentRuns: 1` to be honored by heartbeat concurrency
normalization.
- Added focused regression coverage for recovery recursion, redaction,
migration ordering, and concurrency behavior.

## Verification

- `pnpm --filter @paperclipai/db run check:migrations`
- `pnpm exec vitest run --project @paperclipai/server
server/src/__tests__/recovery-classifiers.test.ts`
- `pnpm exec vitest run --project @paperclipai/server
server/src/__tests__/company-portability.test.ts --pool=forks
--poolOptions.forks.isolate=true`
- `pnpm exec vitest run --project @paperclipai/server
server/src/__tests__/agent-permissions-routes.test.ts --pool=forks
--poolOptions.forks.isolate=true`
- `pnpm --filter @paperclipai/server typecheck`
- `pnpm exec vitest run --project @paperclipai/server
server/src/__tests__/heartbeat-process-recovery.test.ts --pool=forks
--poolOptions.forks.isolate=true` exits 0, but this host skipped the
embedded Postgres tests with the existing init guard.
- `pnpm exec vitest run --project @paperclipai/server
server/src/__tests__/heartbeat-dependency-scheduling.test.ts
--pool=forks --poolOptions.forks.isolate=true` exits 0, but this host
skipped the embedded Postgres tests with the existing init guard.

## Risks

- Migration risk is low but this PR intentionally owns both new
migrations to avoid separate PR migration-journal conflicts.
- Recovery comments now require operators to inspect linked run evidence
for details instead of reading raw errors inline.
- The hire approval default changes behavior for newly created/imported
companies only; existing persisted company settings are not changed
except by the SQL default for future rows.

> 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, GPT-5 coding agent, tool-enabled terminal/GitHub
workflow, reasoning mode active. Context window not exposed in this
environment.

## 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 run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-27 15:02:47 -05:00
..
0000_snapshot.json Expand data model with companies, approvals, costs, and heartbeats 2026-02-17 09:07:22 -06:00
0001_snapshot.json Add agent runtime DB schemas and expand shared types 2026-02-17 12:24:38 -06:00
0002_snapshot.json Add agent runtime DB schemas and expand shared types 2026-02-17 12:24:38 -06:00
0003_snapshot.json Add issue identifiers, activity run tracking, and migration inspection 2026-02-19 09:09:26 -06:00
0005_snapshot.json Add agent config revisions, issue-approval links, and robust migration reconciliation 2026-02-19 13:02:14 -06:00
0006_snapshot.json Add agent config revisions, issue-approval links, and robust migration reconciliation 2026-02-19 13:02:14 -06:00
0007_snapshot.json Add agent task sessions table, session types, and programmatic DB backup 2026-02-19 14:01:40 -06:00
0008_snapshot.json Add secrets infrastructure: DB tables, shared types, env binding model, and migration improvements 2026-02-19 15:43:43 -06:00
0009_snapshot.json Add secrets infrastructure: DB tables, shared types, env binding model, and migration improvements 2026-02-19 15:43:43 -06:00
0010_snapshot.json chore: add assets/attachments DB migration, CLI docs, and lockfile 2026-02-20 10:33:36 -06:00
0011_snapshot.json feat: add project_goals many-to-many join table 2026-02-20 13:43:25 -06:00
0012_snapshot.json Implement issue execution lock with deferred wake promotion 2026-02-20 15:48:22 -06:00
0013_snapshot.json Implement issue execution lock with deferred wake promotion 2026-02-20 15:48:22 -06:00
0014_snapshot.json feat: add auth/access foundation - deps, DB schema, shared types, and config 2026-02-23 14:40:16 -06:00
0017_snapshot.json feat(db): enforce globally unique issue prefixes and identifiers 2026-02-23 16:08:10 -06:00
0018_snapshot.json feat: add issue labels (DB schema, API, and service) 2026-02-25 08:38:37 -06:00
0019_snapshot.json feat: add project workspaces (DB, API, service, and UI) 2026-02-25 08:38:46 -06:00
0020_snapshot.json feat: workspace improvements - nullable cwd, repo-only workspaces, and resolution refactor 2026-02-25 21:35:33 -06:00
0021_snapshot.json feat: per-issue assignee adapter overrides (model, effort, workspace) 2026-02-26 10:32:44 -06:00
0023_snapshot.json feat: join request claim secrets, onboarding API, and company branding 2026-02-26 16:33:20 -06:00
0024_snapshot.json Add touched/unread inbox issue semantics 2026-03-06 08:21:03 -06:00
0025_snapshot.json Persist issue read state and clear unread on open 2026-03-06 08:34:19 -06:00
0027_snapshot.json Add project-first execution workspace policies 2026-03-10 10:58:43 -05:00
0028_snapshot.json feat(issues): add issue documents and inline editing 2026-03-13 21:30:48 -05:00
0029_snapshot.json Merge remote-tracking branch 'public-gh/master' into paperclip-subissues 2026-03-14 12:24:40 -05:00
0030_snapshot.json Use asset-backed company logos 2026-03-16 09:25:39 -05:00
0031_snapshot.json Merge remote-tracking branch 'public-gh/master' into paperclip-subissues 2026-03-16 16:02:37 -05:00
0032_snapshot.json feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
0033_snapshot.json Fix budget incident resolution edge cases 2026-03-16 16:48:13 -05:00
0034_snapshot.json Fix budget incident resolution edge cases 2026-03-16 16:48:13 -05:00
0035_snapshot.json Merge remote-tracking branch 'public-gh/master' into paperclip-subissues 2026-03-16 17:19:55 -05:00
0036_snapshot.json Add instance experimental setting for isolated workspaces 2026-03-17 09:24:28 -05:00
0037_snapshot.json Add workspace operation tracking and fix project properties JSX 2026-03-17 09:36:35 -05:00
0038_snapshot.json Remove api trigger kind and mark webhook as coming soon 2026-03-20 06:54:03 -05:00
0039_snapshot.json Merge remote-tracking branch 'public-gh/master' into paperclip-routines 2026-03-20 15:04:55 -05:00
0040_snapshot.json Fix PR verify failures after merge 2026-03-20 13:40:53 -05:00
0041_snapshot.json Merge remote-tracking branch 'public-gh/master' into paperclip-routines 2026-03-20 15:04:55 -05:00
0044_snapshot.json Add browser-based board CLI auth flow 2026-03-23 08:46:05 -05:00
0045_snapshot.json Add the inbox mine tab and archive flow 2026-03-26 16:09:43 -05:00
0046_snapshot.json Merge public-gh/master into PAP-881-document-revisions-bulid-it 2026-03-31 07:31:17 -05:00
0047_snapshot.json Add feedback voting and thumbs capture flow 2026-04-02 09:11:49 -05:00
0048_snapshot.json feat(routines): add workspace-aware routine runs 2026-04-02 11:38:57 -05:00
0049_snapshot.json Add blocker relations and dependency wakeups 2026-04-06 09:03:13 -05:00
0050_snapshot.json Add project-level environment variables 2026-04-06 21:23:30 -05:00
0051_snapshot.json Speed up issue search 2026-04-06 21:25:41 -05:00
0052_snapshot.json Generate execution policy migration 2026-04-07 17:43:10 -05:00
0053_snapshot.json Persist non-issue inbox dismissals 2026-04-09 06:16:05 -05:00
0055_snapshot.json fix: harden heartbeat and adapter runtime workflows 2026-04-10 22:26:21 -05:00
0056_snapshot.json [codex] Improve workspace runtime and navigation ergonomics (#3680) 2026-04-14 12:57:11 -05:00
0057_snapshot.json feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
0058_snapshot.json [codex] Add run liveness continuations (#4083) 2026-04-20 06:01:49 -05:00
0060_snapshot.json Add first-class issue references (#4214) 2026-04-21 10:02:52 -05:00
0061_snapshot.json [codex] Harden heartbeat scheduling and runtime controls (#4223) 2026-04-21 12:24:11 -05:00
0072_snapshot.json [codex] Harden recovery issue handling (#4600) 2026-04-27 15:02:47 -05:00
_journal.json [codex] Harden recovery issue handling (#4600) 2026-04-27 15:02:47 -05:00