paperclip/packages/db/src/migrations
Devin Foley 1f70fd9a22
PAPA-430: workspace finalize gates + no-remote-git enforcement (#6969)
## Thinking Path

> - Paperclip orchestrates AI agents across isolated execution
workspaces; the local cwd is the only persistence boundary between runs.
> - Workspace lifecycle (worktree_prepare → execute →
workspace_finalize) and the wake/accept flow are what guarantee that
dependent issues see a consistent worktree.
> - PAPA-380 / PAPA-431 / PAPA-432 / PAPA-440 surfaced three holes in
that contract: silent env reuse across assignees, dependent wakes firing
before finalize, and `issue.interaction.accept` advancing before
finalize landed.
> - PAPA-441 / PAPA-442 then needed to document the "no remote git"
contract and prevent future adapter/runtime code from quietly
reintroducing `git push` as a backdoor sync.
> - This pull request lands those server fixes, the static
`check-no-git-push` enforcement, the AUTHORING.md cross-link, and the
Cody-review follow-ups on the PAPA-430 thread.
> - The benefit is that finalize is a real barrier — board accepts,
dependent wakes, and operator-set env all respect it — and adapter code
can't bypass it via raw `git push`.

## What Changed

- **server (PAPA-380, PAPA-431):** `execution-workspace-policy` refuses
silent env reuse when the assignee's resolved env disagrees with the
workspace it would inherit. The inheritance protection is now scoped to
the actual inheritance signal — explicit issue-level `environmentId` is
honored even when the agent's default env is `null`.
- **server (PAPA-432):** `heartbeat.ts` gates dependent wakes on
`listUnfinalizedExecutionWorkspaceIds`, and writes a
`workspace_finalize` row on the succeeded path. Write failures now
surface instead of being swallowed so dependents aren't silently
stranded behind a missing row.
- **server (PAPA-440):** `issue-thread-interactions.acceptInteraction`
adds a workspace_finalize precondition for `request_confirmation` (not
`suggest_tasks`). Accept returns 409 if finalize hasn't succeeded for
the latest workspace operation.
- **ci (PAPA-442):** new `scripts/check-no-git-push.mjs` static check
scans `packages/adapters/`, `packages/adapter-utils/`, `server/src/`,
and `cli/src/` for any `git push` invocation (string or args-array).
Wired into the `policy` PR job and `test:release-registry`. Operators
can opt in per-call with `// paperclip:allow-git-push: <reason>`.
Release scripts are out of scope by design.
- **docs (PAPA-441):** `AUTHORING.md` documents the no-remote-git
contract and cross-links the static check so adapter authors learn the
rule and the enforcement together.
- **review follow-up (PAPA-430, Cody):** three fixes — env resolver bug,
accept-gate scope (request_confirmation only), and finalize record write
on the succeeded path.

## Verification

- `pnpm exec vitest run
server/src/__tests__/execution-workspace-policy.test.ts
server/src/__tests__/issue-thread-interactions-service.test.ts` → 33/33
pass
- `node scripts/check-no-git-push.test.mjs` → check covers string form,
args-array form, comment exclusions, and per-line allow-comment.
- Manual: server compiles; the policy job runs the check in <1s before
heavier jobs.

## Risks

- **Behavioral shift in accept:** boards accepting
`request_confirmation` while finalize is in-flight now get 409s. This is
intentional — they can retry — but it changes timing on a hot path.
`suggest_tasks` is unaffected.
- **Workspace policy:** the env-reuse refusal is a new error path.
Issues that previously silently reused an env from a different-assignee
workspace will now fail-loud; the resolver still honors explicit
issue-level `executionWorkspaceSettings.environmentId`.
- **CI rule:** any future legitimate `git push` in scoped dirs must be
marked with the allow-comment, which is the intended ergonomic.

## Model Used

- Claude Opus 4.7 (`claude-opus-4-7`, extended thinking), via Claude
Code in the Paperclip executor adapter.

## 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
- [ ] If this change affects the UI, I have included before/after
screenshots (N/A — server/CI/docs only)
- [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

Closes related issues: PAPA-430, PAPA-380, PAPA-431, PAPA-432, PAPA-440,
PAPA-441, PAPA-442

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-05-29 08:25:29 -07:00
..
meta PAPA-430: workspace finalize gates + no-remote-git enforcement (#6969) 2026-05-29 08:25:29 -07:00
0000_mature_masked_marvel.sql Expand data model with companies, approvals, costs, and heartbeats 2026-02-17 09:07:22 -06:00
0001_fast_northstar.sql Add agent runtime DB schemas and expand shared types 2026-02-17 12:24:38 -06:00
0002_big_zaladane.sql Add agent runtime DB schemas and expand shared types 2026-02-17 12:24:38 -06:00
0003_shallow_quentin_quire.sql Add issue identifiers, activity run tracking, and migration inspection 2026-02-19 09:09:26 -06:00
0004_issue_identifiers.sql Add issue identifiers, activity run tracking, and migration inspection 2026-02-19 09:09:26 -06:00
0005_chief_luke_cage.sql Add agent config revisions, issue-approval links, and robust migration reconciliation 2026-02-19 13:02:14 -06:00
0006_overjoyed_mister_sinister.sql Add agent config revisions, issue-approval links, and robust migration reconciliation 2026-02-19 13:02:14 -06:00
0007_new_quentin_quire.sql Add agent task sessions table, session types, and programmatic DB backup 2026-02-19 14:01:40 -06:00
0008_amused_zzzax.sql Add secrets infrastructure: DB tables, shared types, env binding model, and migration improvements 2026-02-19 15:43:43 -06:00
0009_fast_jackal.sql Add secrets infrastructure: DB tables, shared types, env binding model, and migration improvements 2026-02-19 15:43:43 -06:00
0010_stale_justin_hammer.sql chore: add assets/attachments DB migration, CLI docs, and lockfile 2026-02-20 10:33:36 -06:00
0011_windy_corsair.sql feat: add project_goals many-to-many join table 2026-02-20 13:43:25 -06:00
0012_perpetual_ser_duncan.sql Implement issue execution lock with deferred wake promotion 2026-02-20 15:48:22 -06:00
0013_dashing_wasp.sql Implement issue execution lock with deferred wake promotion 2026-02-20 15:48:22 -06:00
0014_many_mikhail_rasputin.sql feat: add auth/access foundation - deps, DB schema, shared types, and config 2026-02-23 14:40:16 -06:00
0015_project_color_archived.sql feat: foldable PROJECTS section in sidebar with color support 2026-02-23 09:14:08 -06:00
0016_agent_icon.sql feat: add agent icons with picker and collapsible sidebar section 2026-02-23 12:25:13 -06:00
0017_tiresome_gabe_jones.sql fix(db): cast REPEAT count to integer in migration 0017 2026-02-23 16:25:23 -06:00
0018_flat_sleepwalker.sql feat: add issue labels (DB schema, API, and service) 2026-02-25 08:38:37 -06:00
0019_public_victor_mancha.sql feat: add project workspaces (DB, API, service, and UI) 2026-02-25 08:38:46 -06:00
0020_white_anita_blake.sql feat: workspace improvements - nullable cwd, repo-only workspaces, and resolution refactor 2026-02-25 21:35:33 -06:00
0021_chief_vindicator.sql feat: per-issue assignee adapter overrides (model, effort, workspace) 2026-02-26 10:32:44 -06:00
0022_company_brand_color.sql feat: join request claim secrets, onboarding API, and company branding 2026-02-26 16:33:20 -06:00
0023_fair_lethal_legion.sql feat: join request claim secrets, onboarding API, and company branding 2026-02-26 16:33:20 -06:00
0024_far_beast.sql Add touched/unread inbox issue semantics 2026-03-06 08:21:03 -06:00
0025_nasty_salo.sql Persist issue read state and clear unread on open 2026-03-06 08:34:19 -06:00
0026_lying_pete_wisdom.sql Add worktree-aware workspace runtime support 2026-03-10 10:58:38 -05:00
0027_tranquil_tenebrous.sql Add project-first execution workspace policies 2026-03-10 10:58:43 -05:00
0028_harsh_goliath.sql feat(issues): add issue documents and inline editing 2026-03-13 21:30:48 -05:00
0029_plugin_tables.sql Merge public-gh/master into feature/plugin-runtime-instance-cleanup 2026-03-14 10:46:19 -05:00
0030_rich_magneto.sql Use asset-backed company logos 2026-03-16 09:25:39 -05:00
0031_zippy_magma.sql feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
0032_pretty_doctor_octopus.sql feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
0033_shiny_black_tarantula.sql Harden budget enforcement and migration startup 2026-03-16 15:11:34 -05:00
0034_fat_dormammu.sql Fix budget incident resolution edge cases 2026-03-16 16:48:13 -05:00
0035_marvelous_satana.sql Merge remote-tracking branch 'public-gh/master' into paperclip-subissues 2026-03-16 17:19:55 -05:00
0036_cheerful_nitro.sql Add instance experimental setting for isolated workspaces 2026-03-17 09:24:28 -05:00
0037_friendly_eddie_brock.sql Add workspace operation tracking and fix project properties JSX 2026-03-17 09:36:35 -05:00
0038_careless_iron_monger.sql Improve orphaned local heartbeat recovery 2026-03-20 06:05:15 -05:00
0039_fat_magneto.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0040_eager_shotgun.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0041_curly_maria_hill.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0042_spotty_the_renegades.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0043_reflective_captain_universe.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0044_illegal_toad.sql Address Greptile review on board CLI auth 2026-03-23 08:46:05 -05:00
0045_workable_shockwave.sql Add the inbox mine tab and archive flow 2026-03-26 16:09:43 -05:00
0046_smooth_sentinels.sql fix(db): make document revision migration replay-safe 2026-03-31 08:09:00 -05:00
0047_overjoyed_groot.sql fix: make feedback migration replay-safe after rebase 2026-04-02 10:54:56 -05:00
0048_flashy_marrow.sql feat(routines): add workspace-aware routine runs 2026-04-02 11:38:57 -05:00
0049_flawless_abomination.sql fix: address greptile feedback for blocker dependencies 2026-04-06 09:03:13 -05:00
0050_stiff_luckman.sql Add project-level environment variables 2026-04-06 21:23:30 -05:00
0051_young_korg.sql Speed up issue search 2026-04-06 21:25:41 -05:00
0052_mushy_trauma.sql Generate execution policy migration 2026-04-07 17:43:10 -05:00
0053_sharp_wild_child.sql Persist non-issue inbox dismissals 2026-04-09 06:16:05 -05:00
0054_draft_routines.sql Add draft routine defaults and run-time overrides 2026-04-09 10:19:52 -05:00
0055_kind_weapon_omega.sql fix: harden heartbeat and adapter runtime workflows 2026-04-10 22:26:21 -05:00
0056_spooky_ultragirl.sql [codex] Improve workspace runtime and navigation ergonomics (#3680) 2026-04-14 12:57:11 -05:00
0057_tidy_join_requests.sql feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
0058_wealthy_starbolt.sql [codex] Add run liveness continuations (#4083) 2026-04-20 06:01:49 -05:00
0059_plugin_database_namespaces.sql [codex] Add plugin orchestration host APIs (#4114) 2026-04-20 08:52:51 -05:00
0060_orange_annihilus.sql Add first-class issue references (#4214) 2026-04-21 10:02:52 -05:00
0061_lively_thor_girl.sql [codex] Harden heartbeat scheduling and runtime controls (#4223) 2026-04-21 12:24:11 -05:00
0062_routine_run_dispatch_fingerprint.sql [codex] Harden heartbeat scheduling and runtime controls (#4223) 2026-04-21 12:24:11 -05:00
0063_issue_thread_interactions.sql [codex] Add structured issue-thread interactions (#4244) 2026-04-21 20:15:11 -05:00
0064_issue_thread_interaction_idempotency.sql [codex] Add structured issue-thread interactions (#4244) 2026-04-21 20:15:11 -05:00
0065_environments.sql Add local environment lifecycle (#4297) 2026-04-22 20:07:41 -07:00
0066_issue_tree_holds.sql [codex] Add issue subtree pause, cancel, and restore controls (#4332) 2026-04-23 14:51:46 -05:00
0067_agent_default_environment.sql Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
0068_environment_local_driver_unique.sql Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
0069_liveness_recovery_dedupe.sql [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
0070_active_run_output_watchdog.sql [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
0071_default_hire_approval_off.sql [codex] Harden recovery issue handling (#4600) 2026-04-27 15:02:47 -05:00
0072_large_sandman.sql [codex] Harden recovery issue handling (#4600) 2026-04-27 15:02:47 -05:00
0073_shiny_salo.sql [codex] Split backend control-plane QoL slice (#4700) 2026-04-28 16:46:45 -05:00
0074_striped_genesis.sql [codex] Split backend control-plane QoL slice (#4700) 2026-04-28 16:46:45 -05:00
0075_cultured_sebastian_shaw.sql [codex] Add issue monitor liveness controls (#4988) 2026-05-03 08:58:53 -05:00
0076_useful_elektra.sql Expand plugin host surface (#5205) 2026-05-05 07:42:57 -05:00
0077_unusual_karnak.sql Add routine revision history and restore flow (#5285) 2026-05-05 11:54:52 -05:00
0078_white_darwin.sql Show workspace changes and stale notices in issue threads (#5356) 2026-05-06 09:00:54 -05:00
0079_company_search_document_indexes.sql Add full company search page (#5293) 2026-05-06 06:32:37 -05:00
0080_company_search_fuzzystrmatch.sql Add full company search page (#5293) 2026-05-06 06:32:37 -05:00
0081_optimal_dormammu.sql Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
0082_dry_vision.sql Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
0083_company_secret_provider_configs.sql Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
0084_issue_recovery_actions.sql [codex] Add source-scoped recovery actions (#5599) 2026-05-12 09:37:15 -05:00
0085_tranquil_the_executioner.sql [codex] Add issue document locking (#6009) 2026-05-15 08:54:55 -05:00
0086_routine_env_runtime_contract.sql [codex] Add routine env secrets support (#6212) 2026-05-17 16:30:34 -05:00
0087_backfill_environment_manage_human_defaults.sql [codex] Add agent permissions and controls plan (#6386) 2026-05-22 08:12:52 -05:00
0088_backfill_principal_access_compatibility.sql [codex] Add agent permissions and controls plan (#6386) 2026-05-22 08:12:52 -05:00
0089_cloud_upstreams.sql [codex] Add local Cloud Upstream sync (#6548) 2026-05-22 09:56:22 -05:00
0090_resource_memberships.sql [codex] Add resource membership controls (#6677) 2026-05-25 13:12:41 -05:00
0091_old_swarm.sql [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
0092_mighty_puma.sql Add accepted-plan decomposition exact-once guards and UI state (#6831) 2026-05-28 23:30:18 -07:00
0093_giant_green_goblin.sql PAPA-430: workspace finalize gates + no-remote-git enforcement (#6969) 2026-05-29 08:25:29 -07:00