Planning sessions run in the task's own worktree with the coding tool
surface, but the spec path handed to the planner is relative
(.fusion/tasks/<id>/PROMPT.md) while finalization reads it against
rootDir. A planner using the generic write tool instead of
fn_task_prompt_write stranded the spec inside the worktree, where
finalization could not see it and worktree disposal destroyed it.
project.tasks also has no `prompt` column, so PROMPT.md was
filesystem-only and the project checkout was the sole durable copy of
every plan.
Add plan-artifact-writeback.ts:
- reconcileWorktreePlanArtifact copies a worktree-stranded PROMPT.md
back into the main project .fusion folder through
store.updateTask({ prompt }), keeping File Scope validation, the root
write, and the task.json sync atomic. Empty, absent, and identical
worktree copies are no-ops so a correct spec is never clobbered.
- mirrorPlanToProjectDb mirrors the authoritative plan into the `plan`
task document, which triage already reads as a planning-draft
fallback, making that recovery path DB-backed. Identical content is
skipped so revisions do not churn.
Both are best-effort: a failure never turns a good planning pass into an
error. Wired at the reconcile-before-finalize-read seam, at finalization
with the post-hygiene accepted content, and inside fn_task_prompt_write.
Covers the invariant rather than the repro: tests assert worktree-
stranded, root-only, empty worktree file, absent file, identical
content, persistence failure, redundant-mirror skip, and mirror failure.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
843 B
@runfusion/fusion
| @runfusion/fusion |
|---|
| patch |
summary: Plans written inside a task worktree are now saved to the main project and stored in the database.
category: fix
dev: New packages/engine/src/plan-artifact-writeback.ts exposes reconcileWorktreePlanArtifact, mirrorPlanToProjectDb, and persistPlanArtifact. Planning sessions run in the task worktree with the coding tool surface, so a planner using the generic write tool resolved the relative .fusion/tasks/<id>/PROMPT.md against the worktree; triage finalization reads <rootDir>/<promptPath> and saw nothing. Triage now reconciles the worktree copy through store.updateTask({ prompt }) before the finalize read. project.tasks has no prompt column, so the authoritative plan is also mirrored into the plan task document from triage finalization and from fn_task_prompt_write.