Skip to content

feat(migrate): add native agent and cron import effects - #178768

Closed
Patrick-Erichsen wants to merge 3 commits into
mainfrom
migration-native-agents-cron
Closed

Patrick-Erichsen wants to merge 3 commits into
mainfrom
migration-native-agents-cron

Conversation

@Patrick-Erichsen

@Patrick-Erichsen Patrick-Erichsen commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Migration providers need to create additional agents and scheduled prompts without bypassing native lifecycle or scheduler ownership. This adds lazy migration SDK operations that require the admitted offline state owner and reject onboarding staging.

migration apply (final state, offline owner)
  createMigrationAgent → native createAgent → exact retry or conflict
  applyMigrationCronJob → native CronService.add → exact retry or conflict

Existing agents and changed jobs are preserved. Migration explicitly refuses held-store restoration; the exact agent reuse path runs after deletion/recovery gates; cron import does not start the scheduler. This is the lower capability layer for Grok configuration migration, tracked in CLAW-1180.

User Impact

Migration providers can preserve multi-agent setups and scheduled prompts through OpenClaw’s native owners. Existing agent creation behavior is unchanged unless the provider explicitly requests exact-state reuse.

Why This Change Was Made

Grok configuration migration needs agent creation and cron insertion after onboarding promotion, under the admitted offline state owner. These shared operations keep lifecycle and scheduler writes out of provider-specific code. The dependent provider is #178769.

Evidence

  • Before: the native migration boundary regression failed with createMigrationAgent is not a function.
    After: targeted agent creation, native migration-agent and cron tests pass, including stale/cancelled ownership, staging refusal, retries, conflicts, and no scheduler execution. Core/SDK/agent test typegraphs, targeted lint, formatting and SDK export checks pass; full candidate build passes.

  • The dependent provider's real-owner integration additionally exercises existing-state preservation and saved-plan recovery; its confirmed-only scope excludes credential copying. No unrelated agent or cron writer was introduced.

  • The exact committed Plugin SDK API comparison passes: migration-runtime remains an existing host-local-only facade, so the published compatibility surface is unchanged. Broad local gates report inherited line-count, shard-budget and agentsapi unused-export failures; all affected paths are unchanged against the captured base. No unrelated baseline was relaxed.

  • Hosted CI exposed a type-only back-edge in the existing-agent result helper and duplicate cron helper export names. The native-layer correction removes the back-edge, gives implementation functions distinct names, and tests cron through the provider facade. Both exact failing guards now pass locally, with 26 affected native tests, core types, formatting and scoped type-aware lint.

  • Recovery review regression: before the fix, an imported definition returned existing and cleared a recovery hold. With restorePaths: [], both matching and conflicting definitions preserve the hold, config, and held database bytes until explicit recovery. Agent/cron SDK tests pass (3 tests, 70.10s wrapper / 25.02s Vitest under host load), with SDK test types and two-file lint.

  • Final-effect authority proof: releasing the real offline owner while native workspace preparation is paused returns an SDK error and leaves config unchanged, with no agent/session database or provenance. Only the already-created empty directory remains. This proves the composed agent boundary; no new direct late-revocation cron case or published-driver upgrade was run.

  • Final combined head 12dcad3075c builds successfully in 4m22s (existing UI gzip warning retained). Native head: 73ca0a4d30b. The rebuilt CLI selects only stalk-setup by name, emits all six curated integration paths, and plans no secret actions. Real Stalk repeat apply completes with 25 migrated, 12 skipped, no errors/conflicts, and a verified backup; all 19 skill bodies, 9 exported memories, and instructions remain intact, with one memory import block.

Review coordination: the local stack owner handles repairs and propagation between these dependent branches. ClawSweeper's current contract says repair/merge execution lanes are retired. ClawSweeper review is requested on the updated heads; neither PR is claimed merge-ready while live-account qualification and hosted checks remain pending.

Merge Danger

Door: Two-way

Code can be reverted; completed migrations retain their created state and use the migration framework's backup for restoration.

Blast Radius: Migration

The new SDK operations admit effects only under the selected offline owner. Existing createAgent callers retain their current behavior; reuse is opt-in.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L labels Oct 20, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Adds migration helpers that create agents and scheduled prompts through OpenClaw’s native owners.

Example: Import agent imported-researcher and Morning summary at 09:15 on weekdays in America/Los_Angeles.

  • Before: Migration providers lack shared native operations for creating the agent and recurring prompt.
  • After: The native owners persist both, accept matching retries, reject conflicting definitions, and leave the scheduler stopped.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful native-owner implementation with the previous defect repaired, but incomplete authority and upgrade qualification.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Migration providers cannot preserve additional agents and scheduled prompts through shared native lifecycle operations.
Reason: The maintainer-authored direction has a concrete dependent consumer and follows the existing narrow capability boundary.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this PR supplies a useful shared migration capability, fixes the prior recovery finding, and introduces no newly confirmed code defect.

Priority: P2
Reviewed head: 73ca0a4d30b0020c9a3ae28e70c7729fed1673ae

Before merge

  • Add real behavior proof - Authority-chain proof required: the real-owner agent harness demonstrates release during workspace preparation prevents substantive publication, resolving that part of the previous request. Cron coverage demonstrates allowed persistence and entry-time rejection, but not released, replaced, or cancelled authority after awaited preparation before persistence. Latest-stable upgrade preservation is also explicitly unclaimed; the inspected older screenshots cover a different flow. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security concern: Qualify retained cron ownership through persistence - The agent release scenario now exercises the composed native boundary, but it does not establish cron behavior when ownership changes during awaited scheduler preparation; this is unresolved qualification rather than a confirmed bypass.
  • Resolve merge risk - Cron import creates durable scheduled work under retained offline ownership; rejection after owner release, replacement, or cancellation during asynchronous preparation remains unqualified at the final persistence boundary.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [medium] Qualify retained cron ownership through persistence — src/plugin-sdk/migration-cron-runtime.ts:123

Tests

  • Missing end-to-end proof: Supply direct cron final-effect rejection evidence and a latest-stable upgrade run preserving existing settings and data; redact credentials and non-public endpoints.
Agent review details

How this fits together

Migration providers pass portable definitions through an offline-owner admission check into the existing agent lifecycle and cron scheduler, producing native configuration and database records.

flowchart TD
  A[Migration provider] --> B[Offline owner admission]
  B --> C[Native agent creation]
  B --> D[Native cron service]
  C --> E[Agent configuration and state]
  D --> F[Stored scheduled prompts]
Loading

Technical review

Best possible solution:

Keep migration effects in the existing lifecycle and scheduler owners, preserving exact retries and existing user state.

Do we have a high-confidence way to reproduce the issue?

This is an additive capability; current-main source lacks the helpers, and the reported before-fix failure matches that absence.

Is this the best way to solve the issue?

The adapters reuse the correct native owners, and the optional reuse path preserves lifecycle gates without introducing a competing writer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4213136ceea7.

Merge-risk options

Maintainer options:

  1. Qualify cron ownership before merge (recommended)
    Provide a production-owner scenario showing normal cron persistence and rejection without durable changes when offline ownership closes or changes during preparation.
  2. Hold the dependent stack
    Keep this PR and its dependent importer open until the cron authority boundary is qualified.

Provenance checked

  • Canonical agent lifecycle and exact reuse keeps the original intent (932e8be: Consolidate divergent creation paths into one service owning validation, workspace preparation, and exclusive configuration publication.)
  • Plugin-owned migration runtime keeps the original intent (1fc5b2b: Keep source-specific migration in providers while sharing safe runtime operations and configuration ownership.)
  • Deletion and recovery gates keeps the original intent (c6b21f6: Preserve held databases and require explicit recovery rather than silently replacing or restoring retained state.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete bypass was confirmed, but the cron ownership boundary still needs final-effect qualification.

Evidence

Security concerns:

  • [medium] Qualify retained cron ownership through persistence — src/plugin-sdk/migration-cron-runtime.ts:123
    The agent release scenario now exercises the composed native boundary, but it does not establish cron behavior when ownership changes during awaited scheduler preparation; this is unresolved qualification rather than a confirmed bypass.
    Confidence: 0.95

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 1fc5b2b adds src/plugin-sdk/migration-runtime.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1fc5b2b7032c; files: src/plugin-sdk/migration-runtime.ts)

PR surface

Source +298, Tests +286, Docs +17. Total +601 across 10 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 5 298 0 +298
Tests 4 292 6 +286
Docs 1 17 0 +17
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 607 6 +601

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove proof: 📸 screenshot: Current real behavior proof evidence kind is none.

Label justifications:

  • P2: A useful migration capability with limited scope and no established urgent user regression.
  • merge-risk: 🚨 security-boundary: The new adapter consumes offline ownership to authorize durable scheduled work; late ownership loss remains unqualified.
  • merge-risk: 🚨 compatibility: Native effects write existing agent configuration and scheduler state, while latest-stable upgrade preservation remains explicitly unclaimed.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof that released or replaced offline ownership, or cancellation during cron preparation, prevents durable cron changes.
  • Demonstrate migration after upgrading from the latest stable release with existing settings and data intact.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-20T21:08:42.257Z sha 9484c7f :: needs real behavior proof before merge. :: [P2] Refuse implicit recovery restoration during migration creation

Reviewed October 20, 2026, 7:51 PM ET / 23:51 UTC (Revision 2).

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

Fixed the concrete recovery bypass in 73ca0a4: createMigrationAgent now passes restorePaths: [] so migration cannot implicitly restore a held agent store. The real regression fails before the fix (returns existing and clears the hold); after the fix both matching and conflicting definitions preserve config, held database bytes, and recovery holds.

Added composed final-effect evidence: the real offline owner is released while native workspace preparation is paused. The SDK returns an error with unchanged config and no agent/session database or provenance; only the already-created empty directory remains. Three agent/cron SDK tests pass, along with SDK test types, scoped lint, and formatting. No new production authority abstraction or stored schema was added.

The dependent provider's real-owner integration also proves existing-state preservation and retry/recovery. A direct late-revocation cron case and a published-driver upgrade were not newly run. The older Claw-package screenshots are not claimed as proof of these native effects. Local ownership continues coordinating the stack; the current bot contract reports repair lanes retired.

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant