paperclip/packages/db/src/migrations/meta
Dotta 705c1b8d81
[codex] Add routine env secrets support (#6212)
## Thinking Path

> - Paperclip orchestrates AI agents for zero-human companies.
> - Scheduled routines are the control-plane path for recurring agent
work.
> - Routines already had dispatch/history, but their runtime environment
did not carry routine-owned secret bindings through execution.
> - Operators need routine-specific secrets that can override
project/agent env without exposing secret values in history, logs, or
access events.
> - This pull request adds the routine env runtime contract, wires it
into execution, and makes the routine UI/history surfaces show safe
secret metadata.
> - The benefit is that routine executions can use scoped secret refs
predictably while preserving company boundaries and auditability.

## What Changed

- Added routine env persistence/runtime support, including
`routines.env`, `routine_runs.routine_revision_id`, revision snapshots,
and idempotent migration `0086_routine_env_runtime_contract`.
- Resolved routine env during heartbeat adapter config assembly with
precedence `agent < project < routine` and secret access events recorded
against the routine consumer.
- Added secret binding synchronization for routine create/update/restore
flows and guarded cross-company, missing, disabled, and deleted secret
cases.
- Added a Secrets tab to routine detail, env/secret history diff
rendering, and Storybook coverage for the new UI states.
- Added server/UI regression tests, including an embedded-Postgres QA
path for routine secret execution and restore behavior.
- Updated implementation/database docs for routine env and
secret-binding behavior.

## Verification

- `pnpm install --frozen-lockfile` after rebasing onto
`public-gh/master` to refresh workspace links for the newly-added
upstream Grok adapter package.
- `pnpm exec vitest run
server/src/__tests__/heartbeat-project-env.test.ts
server/src/__tests__/routines-service.test.ts
server/src/__tests__/secrets-service.test.ts
server/src/__tests__/qa-routine-secrets-e2e.test.ts
ui/src/components/RoutineHistoryTab.test.tsx` passed: 5 files, 92 tests.
- `pnpm -r typecheck` passed across the workspace.
- `pnpm build` passed. Vite emitted the existing
large-chunk/dynamic-import warnings.
- UI screenshots were captured locally during QA in
`artifacts/pap-9521/` and `artifacts/pap-9522/`; generated screenshots
are not committed to avoid adding binary artifacts to the repo.

## Risks

- Migration risk is limited by `IF NOT EXISTS` guards for the new
columns, FK, and index, and the migration is ordered as `0086`
immediately after upstream `0085`.
- Runtime behavior changes env precedence for routine executions by
adding routine env as the highest-precedence layer; tests cover
agent/project/routine precedence.
- Secret handling is security-sensitive; tests cover value-free
manifests/events/errors, disabled/missing/deleted secrets, and
cross-company rejection.
- UI history now renders routine env/secret diffs; tests and Storybook
stories cover the main rendering paths.

> 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 coding agent based on GPT-5, with shell/tool use and
medium reasoning effort.

## 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-05-17 16:30:34 -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
0073_snapshot.json [codex] Split backend control-plane QoL slice (#4700) 2026-04-28 16:46:45 -05:00
0074_snapshot.json [codex] Split backend control-plane QoL slice (#4700) 2026-04-28 16:46:45 -05:00
0075_snapshot.json [codex] Add issue monitor liveness controls (#4988) 2026-05-03 08:58:53 -05:00
0077_snapshot.json Add routine revision history and restore flow (#5285) 2026-05-05 11:54:52 -05:00
0078_snapshot.json Add recovery handoff system notices (#5289) 2026-05-06 06:05:58 -05:00
0081_snapshot.json Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
_journal.json [codex] Add routine env secrets support (#6212) 2026-05-17 16:30:34 -05:00