Skip to content

Add backend-neutral three-way reconciliation with plan/apply #171

Description

@chubes4

Problem

MDI records source paths and hashes during import/export, but it does not expose a backend-neutral three-way reconciliation contract. Supporting file-primary content over SQLite and MySQL requires deterministic planning when files, WordPress rows, or both have changed since their last common state.

This is a child of #57 and builds on the extracted canonical persistence layer.

Desired Contract

Add one reconciliation service shared by CLI, abilities, backend adapters, and external trigger surfaces. It compares:

  • current canonical file identity/hash;
  • current normalized WordPress resource identity/hash;
  • last common baseline identity/hash.

The plan reports at least:

  • created;
  • updated_from_file;
  • written_from_wordpress;
  • deleted_from_file;
  • deleted_from_wordpress;
  • moved;
  • unchanged;
  • conflicts.

Conflicts produce no mutation by default. MDI reports evidence; GitSync or another caller owns remote merge and publication policy.

Public Surface

Expose the same service through:

wp markdown-db reconcile --dry-run
wp markdown-db reconcile
markdown-db/reconcile ability

Inputs cover direction, managed scope, deletion policy, conflict policy, bounded batch size, and continuation identity. Apply requires a plan/source identity that still matches current state.

Acceptance Criteria

  1. File-only, WordPress-only, identical, moved, deleted, and divergent changes produce deterministic plans.
  2. Dry-run performs no database or filesystem mutation.
  3. Apply refuses stale plans and concurrent ownership.
  4. Deletion is opt-in and limited to resources previously managed by the selected canonical root.
  5. Repeated apply is idempotent and does not duplicate posts or rewrite unchanged files.
  6. Interrupted bounded reconciliation resumes without replaying completed mutations.
  7. The contract runs against both SQLite and MySQL content backends.
  8. Conflict reports contain resolvable source paths, resource IDs, and all compared identities without leaking secrets.

Related Work

AI Assistance

OpenAI GPT-5.6 Sol via OpenCode was used to inspect current import/export source metadata and synchronization behavior and draft this issue. Chris Huber directed the architecture and remains responsible for the reconciliation contract.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions