Skip to content

Preserve canonical content when a custom-layout move fails #260

Description

@chubes4

Problem

The custom content-layout move path stages the replacement, deletes the old canonical file, and only then renames the staged file into place. If the final rename fails, the old file has already been removed and the staged file is discarded, leaving no canonical copy.

Relevant implementation: WP_Markdown_Storage::write_profile_post() in inc/class-wp-markdown-storage.php, around lines 910-924.

This violates the canonical durability contract required by the database-independent engine in #232.

Required outcome

  • Make custom-layout moves recoverable across the old-path and new-path publication boundary.
  • Preserve at least one complete canonical copy when publication or cleanup fails.
  • Bind staging and commit to the same verified destination directory identity.
  • Keep path indexing and changed-path receipts consistent with the terminal filesystem state.
  • Add deterministic failure injection around destination publication and old-path cleanup.

Acceptance criteria

  • A failed destination rename leaves the original canonical post intact.
  • A successful move leaves exactly one canonical post at the selected route and removes the stale route.
  • Retry after an interrupted move converges without content loss or duplicate durable identities.
  • Directory replacement between staging and commit fails closed.

AI assistance

GPT-5.6 Sol via OpenCode reviewed the custom-layout publication sequence, identified the delete-before-publish failure mode, and helped structure this issue and its acceptance criteria. Chris Huber directed the review and issue creation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions