Automattic / Automattic/markdown-database-integration

Preserve canonical content when a custom-layout move fails

Open
#260 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
5
Forks
1
Avg merge
2h 38m
Merged PRs (30d)
155

Description

## 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in inc/class-wp-markdown-storage.php at WP_Markdown_Storage::write_profile_post(), especially the custom-layout move sequence around lines 910-924. Trace staging, destination publication, old-path cleanup, path indexing, and changed-path receipts, then add deterministic failure coverage for publication, cleanup, and directory replacement. Done means the acceptance criteria hold without content loss, duplicates, or inconsistent terminal state.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.