mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 00:47:57 +00:00
7.7 KiB
7.7 KiB
name, description
| name | description |
|---|---|
| create-and-cleanup-migration | Use for end-to-end ClawHub Convex production migrations, backfills, destructive cleanups, and one-off maintenance functions that must be created, validated, shipped, run, verified, then removed after completion. |
Create And Cleanup Migration
Drive a ClawHub Convex migration from implementation through production cleanup, with explicit operator gates before destructive execution and before removing the temporary migration code.
When To Use
- A Convex production data migration, backfill, destructive cleanup, schema narrowing, table reshaping, or one-off maintenance function is needed.
- Temporary Convex code must be created, deployed, run, verified, and then removed after it is no longer useful.
- The user asks for the full lifecycle: implement migration, PR, deploy, dry run, apply, verify, cleanup PR, deploy cleanup.
Required Companion Guidance
- Start with
convex-migration-helper. - Read
convex/_generated/ai/guidelines.mdbefore editing Convex code. - Default to
@convex-dev/migrationsfor production data changes. - If not using
@convex-dev/migrations, write down why the component is unnecessary and provide equivalent:- dry-run support
- cursor batching
- resumable/progress behavior
- destructive confirmation token
- real Convex runtime validation
Safety Rules
- Never run a destructive production apply step until after presenting dry-run results and receiving explicit user confirmation in the current thread.
- Before implementing anything, classify the requested "migration" as one of:
code deploy, existing Convex function run, operator import/export command,
schema narrowing, data cleanup, or cleanup-code removal. Do not invent a new
Convex migration function when the issue or PR specifies an operator command
such as
convex import --replace. - Before any production migration apply, force the operator to visit
https://dashboard.convex.dev/, manually click Backup Now on the target deployment, wait for completion, and explicitly confirm in the thread. Do not automate dashboard backup creation. - Never remove migration code until after presenting apply/verification results and receiving explicit user confirmation in the current thread.
- Keep production commands pointed at the explicit deployment name when known;
do not rely on generic
--prodif this repo's guidance says to verify the actual deployment. - If the migration can affect visibility, moderation, ownership, billing, installability, or public API output, call that out before the apply gate.
- Preserve resume cursors, run IDs, PR URLs, deploy URLs, and final stats in the handoff.
Phase 1: Design The Migration
- Identify the intended data change and whether it is:
- schema widen/migrate/narrow
- field cleanup
- table cleanup
- ownership/relationship repair
- recurring maintenance
- Choose the implementation:
- Prefer
@convex-dev/migrationsfor non-trivial production data. - Use a hand-rolled internal function only for a clearly small or special case, and document the exception.
- Prefer
- Define done criteria:
- dry-run expected counts
- apply expected counts
- verification query/result proving no remaining targets
- cleanup PR scope
Phase 2: Implement
- Add or update the Convex migration/maintenance code.
- Include argument validators for every Convex function.
- Include dry-run support.
- Include batching and resume/progress state.
- Include a confirmation token for destructive writes.
- Keep apply logic idempotent where practical.
- Add targeted tests for business logic and safety gates.
- Add real Convex runtime validation for Convex semantics such as pagination, validators, internal/public function boundaries, scheduler behavior, and action/query/mutation interactions.
Phase 3: Local Validation
Run the smallest meaningful set first, then broaden before PR handoff:
- targeted unit tests for the migration logic
bunx convex codegenwhen Convex API/schema changedbunx tsc --noEmitor the repo's Convex deploy typecheck pathbun run ci:staticbun run ci:unitfor source/test changes unless explicitly waived- a real local Convex validation path, such as
bunx convex dev --once,convex run, HTTP smoke, or local-auth Playwright, covering the changed Convex behavior
If local real Convex validation is blocked, record the blocker and make the PR or deployment plan explicitly compensate with an equivalent runtime proof.
Phase 4: PR, Review, Merge, Deploy
- Open a focused PR containing the migration implementation.
- Include:
- summary
- migration strategy
- dry-run/apply safety gates
- tests and runtime validation
- cleanup plan
- Run the repo's review/CI workflow required by
AGENTS.md. - Address actionable review findings.
- Merge only after required checks are green or the user explicitly accepts a documented risk.
- Deploy the relevant production target from
main. - Wait for deployment success before starting the manual backup gate.
Phase 5: Manual Backup Gate
Before any production dry run or production migration apply:
- Tell the operator to open
https://dashboard.convex.dev/. - Tell the operator to select the target deployment and manually click Backup Now.
- Wait until the Convex dashboard shows that the backup completed.
- Require the operator to explicitly confirm in the thread that the dashboard backup completed for the target deployment.
- Do not automate this step and do not proceed on implied confirmation, partial screenshots, or "go ahead" messages that do not say the backup completed.
Phase 6: Production Dry Run
- Run only after explicit user confirmation from the manual backup gate.
- Run the production dry run with bounded batch settings.
- Resume until either:
isDone: true, or- a clearly documented safety cap is reached.
- Present results to the user before apply:
- deployment name
- command shape
dryRunisDone- done/progress fields
- scanned/matched/patched/deleted stats
- sample IDs
- resume cursors if incomplete
- known user-visible or operational implications
- Stop and wait for explicit user confirmation before applying.
Phase 7: Production Apply
- Run only after explicit user confirmation of the dry-run results and the completed manual backup gate.
- Use the destructive confirmation token.
- Resume in bounded batches until complete or until a documented safety cap.
- Present apply results:
- patched/deleted counts
- skipped/missing counts if tracked
- final cursors/progress
- any errors or partial completion
- Run verification:
- dry run or status command should show zero remaining targets, or
- explain why remaining targets are expected.
- Stop and wait for explicit user confirmation before cleanup-code removal.
Phase 8: Cleanup PR
- Remove temporary migration functions, tests, docs, scripts, and generated API entries that are no longer needed.
- Keep durable specs/docs only if they explain lasting behavior or invariants.
- Run targeted validation plus the repo-required gates for the touched surface.
- Open a cleanup PR with:
- apply results
- verification proof
- explanation of removed temporary code
- Merge after checks/review.
- Deploy the cleanup PR if removing Convex functions or schema/code that affects production.
Final Handoff
Report:
- implementation PR URL and merge SHA
- production deploy run URL and deployed SHA
- dry-run result
- manual Convex dashboard backup confirmation
- apply result
- verification result
- cleanup PR URL, merge SHA, and deploy run URL
- any remaining follow-up tasks or intentional retained migration code