Problem
Operators need a deliberate way to recreate one exact live managed task from its current compiled Agent Spec without deleting its workspace or durable st2 state. Neither host-wide st2 down nor backend-level pty restart expresses that boundary: a raw restart may replay an older persisted process contract instead of the current declaration.
The operation is generic. Core st2 does not choose a harness-specific fresh or resume method. Axe and its harness driver compile that decision into the declaration under #124 before st2 is asked to recreate the task.
Proposed command shape
Non-normative:
st2 task recreate \
--task <exact-task-id> \
--expect-runtime <runtime-generation> \
--expect-desired <launch-generation>
Required contract
- Select one exact canonical task under an explicit catalog, host, effective runtime root, bus identity, runtime incarnation, and desired launch generation.
- Re-read the declaration and recheck both fences immediately before disruption.
- A stale runtime, changed or retired declaration, wrong root, target disappearance, or ambiguous backend state fails closed without touching the live process.
- Capture an immutable effective launch contract and persist a bounded operation record before stopping the task.
- Stop and reap only the fenced runtime incarnation.
- Launch the captured compiled contract exactly once and persist a terminal receipt containing the prior runtime, desired generation, stop result, launch result, and resulting runtime/Run ID.
- If st2 stops after teardown or launch, ordinary reconciliation resumes the same recorded operation rather than adopting an intervening declaration or replacing a successor again.
- Preserve workspace files and the durable bus/state anchor: inbox, archive, context, decisions, linked resources, status path, and declaration.
- Reconcile derived tasks, including DING companions, with the canonical task without duplicates or leaks.
- Do not infer recreation from command drift, generation drift, catalog edits, compaction, crash, or supervisor restart. Drift remains observational until this explicit operation is authorized.
- Emit a machine-readable terminal result distinguishing replaced, target-not-live, fence-conflict, retired-or-changed, backend-unknown, stop-failed, and launch-failed.
Acceptance
- A matching request changes the runtime incarnation exactly once and launches the captured compiled contract.
- An unrelated task keeps its PID and runtime generation.
- Workspace and every durable resource byte survive unchanged.
- Stale runtime, changed desired generation, retired declaration, wrong root, missing/dead target, and backend-error controls fail closed.
- A crash before the durable stop phase leaves the original process untouched.
- A crash after teardown resumes the recorded operation without selecting newer unrelated bytes or launching duplicates.
- A crash after launch does not replace the successor a second time.
- Provider-specific prompt construction and session selection remain outside core lifecycle code.
Relationships
Problem
Operators need a deliberate way to recreate one exact live managed task from its current compiled Agent Spec without deleting its workspace or durable st2 state. Neither host-wide
st2 downnor backend-levelpty restartexpresses that boundary: a raw restart may replay an older persisted process contract instead of the current declaration.The operation is generic. Core st2 does not choose a harness-specific fresh or resume method. Axe and its harness driver compile that decision into the declaration under #124 before st2 is asked to recreate the task.
Proposed command shape
Non-normative:
Required contract
Acceptance
Relationships