Skip to content

Add backend-neutral three-way reconciliation - #191

Merged
chubes4 merged 6 commits into
mainfrom
feat/171-three-way-reconciliation-v2
Aug 14, 2026
Merged

Add backend-neutral three-way reconciliation#191
chubes4 merged 6 commits into
mainfrom
feat/171-three-way-reconciliation-v2

Conversation

@chubes4

@chubes4 chubes4 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add one bounded three-way reconciliation service for canonical Markdown, WordPress state, and durable baselines
  • expose deterministic plan/apply through wp markdown-db reconcile and the markdown-db/reconcile ability
  • execute mutations through the durable operation store from Add durable reconciliation operation store #190 with stale-plan, ownership, deletion-proof, recovery, and idempotency contracts
  • authenticate production continuations over the unprocessed suffix, including derived target paths, and use the active content-layout profile for both planning and storage writes

Closes #171.

Verification

  • all tests/smoke-*.php scripts pass
  • reconciliation contract: 36 assertions pass
  • durable operation contract: 68 assertions pass
  • production filesystem and real SQLite adapter coverage passes
  • PHP lint passes across all PHP files
  • git diff --check passes

Residual Risk

No live MySQL/MariaDB service was available. MySQL transaction and parameterized fencing behavior is covered by the existing protocol-faithful PDO double; SQLite behavior is covered against a real engine.

AI Assistance

OpenAI GPT-5.6 Sol via OpenCode was used to inspect the codebase, implement the reconciliation service and regressions, run verification, and address independent review findings. Chris Huber directed the architecture and remains responsible for every line.

@chubes4

chubes4 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Self-review findings have been addressed in 00e1c6c:

  • durably preplans every actionable resource in a page and recovers only the exact continuation cursor, including all reviewed siblings after a self-produced source change
  • rejects symlink traversal across legacy manifest, index, move, truncate, duplicate-cleanup, and direct reconciliation deletion paths; validated deletion rechecks the inode before unlink
  • removes mutation-path MySQL DDL, provisions fence state during initialization, and refuses caller-owned WPDB transactions
  • aligns reconciliation receipts with WordPress-writable round-trip fields and enforces per-resource capabilities for ability/web execution while retaining the trusted WP-CLI operator boundary
  • corrects continuation documentation

Verification:

  • all tests/smoke-*.php scripts pass
  • reconciliation suite: 38 assertions pass
  • durable operations suite: 68 assertions pass
  • production filesystem and real SQLite coverage pass
  • PHP lint across all PHP files passes
  • git diff --check passes

Residual limitation: no live MySQL/MariaDB service was available; MySQL protocol coverage remains double-based.

AI assistance: OpenAI GPT-5.6 Sol via OpenCode performed the self-review, implementation, repeated independent blocker reviews, and verification. Chris Huber directed the fixes and remains responsible for every line.

@chubes4

chubes4 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Validation evidence for 98504832c0a8c47cacf40dc85f72e6fb63e8fa48

  • Added tests/probe-native-mariadb-reconciliation.php, a WordPress-native probe intended for a disposable WP Codebox native-MariaDB runtime. It asserts $wpdb->dbh instanceof mysqli, SELECT VERSION() contains MariaDB, and production adapter selection is WP_Markdown_WPDB_Reconciliation_Adapter. It then uses only a dedicated temporary probe table and private runtime directory to verify dry-run has no mutation, fenced apply commits, repeat apply is idempotent, and an interrupted post-effect operation recovers without replay. Its finally block drops the table and recursively removes the private directory.
  • Full local MDI suite passed: for file in tests/smoke-*.php; do php "$file" || exit 1; done (all smoke scripts, including 38 reconciliation checks, 68 durable-operation checks, and 13 production-adapter checks).
  • Syntax gate passed: git ls-files 'tests/*.php' | xargs -n1 php -l.\n- Diff gates passed: git diff --check and git diff origin/main...HEAD --check.\n- Source package evidence (includes the pre-commit guarded-storage include diff):\n - /var/folders/lr/c_cmmt7s0592m4njz99v5yb40000gn/T/opencode/mdi-pr-191-head.tar.gz\n - /var/folders/lr/c_cmmt7s0592m4njz99v5yb40000gn/T/opencode/mdi-pr-191-working.diff\n - /var/folders/lr/c_cmmt7s0592m4njz99v5yb40000gn/T/opencode/mdi-pr-191-artifacts.sha256\n - Verified with shasum -a 256 -c .../mdi-pr-191-artifacts.sha256.\n\nNative-runtime residual gap: the only configured direct Lab target is lab, but it resolves to no hostname (ssh -o BatchMode=yes -o ConnectTimeout=15 lab ... -> Could not resolve hostname lab). The supplied WP Codebox worktree also has no node_modules, so npm run build fails before execution because node_modules/typescript/bin/tsc is absent. No production/local database was contacted, no Homeboy command was used, and no WP Codebox source was modified. Reproduce the final runtime gate on a Linux Lab with dependencies installed by packaging this commit plus the listed diff and running the probe through a disposable native-MariaDB Codebox recipe.\n\nAI assistance: OpenAI gpt-5.6-sol via OpenCode inspected existing tests, implemented the isolated probe, ran local gates, and prepared this evidence; Chris Huber remains responsible for the change.

@chubes4

chubes4 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Native MariaDB/mysqli proof completed for 2c24db857586a85c42010db07ad862b32b1c777d.

This supersedes the prior residual-risk wording: the new proof is a real WordPress $wpdb/mysqli adapter transaction, fence, idempotency, recovery, and owned-resource-cleanup proof. It is intentionally not a production WP-post/files reconciliation-facade proof; its content adapter uses only the probe-owned table and private runtime directory.

Native result:

  • WP Codebox 0.19.0 ran an isolated WordPress PHP 8.4 runtime against Docker-managed MariaDB 11.4.12-MariaDB-ubu2404.
  • $wpdb->dbh instanceof mysqli passed and the runtime selected WP_Markdown_WPDB_Reconciliation_Adapter.
  • Passed: dry-run has no probe-table write; apply writes and reads back the real _mdi_resource_fences row in a MariaDB transaction; repeat apply has no second effect; recovery re-fences an expired operation and recognizes the committed effect without replay.
  • Passed teardown: deletes exactly the two fence rows owned by this run (key plus operation-id predicate), drops only the random table it created, and verifies all three removals.
  • The managed MariaDB service used tmpfs; its lifecycle is released, teardown is completed, and the runtime is destroyed. A post-run container check found no matching Codebox/MariaDB container.

Reviewer reproduction (from a Docker-capable Linux checkout of WP Codebox with built dependencies), with MDI checkout at the commit above staged as the extra plugin:

node packages/cli/dist/index.js recipe-run --recipe /path/to/recipe.json --artifacts /tmp/mdi-mariadb-artifacts --timeout 10m --json

The validated recipe uses runtime.phpVersion: 8.4, one kind: mysql service with { "engine": "mariadb", "rootAuthentication": "empty-password", "storage": "tmpfs" }, mounts the staged MDI archive as active plugin markdown-database-integration/markdown-database-integration.php, and runs:

require WP_PLUGIN_DIR . "/markdown-database-integration/tests/probe-native-mariadb-reconciliation.php";

Lab evidence is retained at /home/chubes/Developer/_lab_artifacts/mdi-pr191-ea3342e/:

  • source archive SHA-256: b0ef358f223b84d42c357530ee8384c6b897ac3589745dac107baf53db094d28
  • run: run_62fa8a1ac0b7405680447cd4767f7544
  • artifact bundle: runtime-msrvturt-4ll22v, SHA-256 0bcb94af5bbd829575820c3e890305fc3a3a4fe2a5fcc463a93f4426918040d5
  • JSON: result.json, validation.json, plus the bundle command/event/observation logs and manifests.

Local gates also passed before the run: every tests/smoke-*.php, PHP lint for every tracked PHP file, git diff --check, and git diff origin/main...HEAD --check.

AI assistance: OpenAI gpt-5.6-sol via OpenCode was used to tighten the probe ownership/fence assertions, execute the direct Lab SSH recipe, diagnose and correct the recovery-fence assertion, run gates, and capture evidence. Chris Huber remains responsible for every line.

@chubes4
chubes4 merged commit 4bb1653 into main Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant