Skip to content

refactor: share execution preservation snapshots - #77

Merged
lezama merged 2 commits into
trunkfrom
codex/shared-preservation-helper
Oct 22, 2026
Merged

lezama merged 2 commits into
trunkfrom
codex/shared-preservation-helper

Conversation

@JasonTheAdams

Copy link
Copy Markdown
Member

The CLI fixtures repeated large before/after preservation blocks with generated no-op branches, making their grading boundaries difficult to review. This follow-up to #71 replaces those blocks with shared trusted snapshots and explicit per-record allowlists, addressing the implementation deferred in #71 (comment).

WPBench\Runtime\Preservation::capture_posts() captures every existing non-revision post; capture_users() captures every account. Snapshots retain private before-state in the verifier process and expose preserved($allow) plus count(). Allowlists use captured IDs and declare fields, exact meta keys, literal meta_prefixes, terms (category/post_tag), or deleted. Comparison retains strict stored metadata/type/multiplicity checks and detects unrelated modifications, deletions, and relationship changes. The helper is loaded for both PHP and CLI verification.

Migrates 25 content comparisons and 26 account comparisons across 26 CLI tests, removing about 59 KB of repeated JSON. All 27 retained IDs, model-facing prompts/requirements, reference scripts, authored exploits, assertion descriptions/weights, and task-specific checks are unchanged. Menu assertions keep their raw rows, record counts, and nav_menu checks; URL migration retains its specialized serialization/GUID/table checks. The core suite is untouched.

Allowances were carried over from the actual assertions after inspecting WordPress origin/7.1 source (dcc660c01a76f8fe46faed6850e5f8e22c88eb80), including WP_Post::to_array(), wp_insert_post(), wp_update_post(), _publish_post_hook(), WP_User::set_role(), and wp_delete_user(). Derived post_category/tags_input fields are checked via term IDs. There are no blanket timestamp or publishing-metadata exemptions; existing date/field/meta allowances stay scoped to their declared records. Regression cases exercise modified dates, draft date refreshes, _pingme/_encloseme, roles, reassignment/deletion, nested metadata types, duplicate values, metadata prefixes, relationship changes, and unrelated records through both PHP and CLI execution.

Validation uses real WordPress 7.1 + SQLite private containers (reset_per_test, CLI concurrency 4), without model API calls:

Check Trunk grader Refactored grader
Retained CLI reference scripts 27/27 pass 27/27 pass
Authored + generic shortcut candidates 127/127 rejected 127/127 rejected
Per-test reference scores and exploit audit outcomes Identical Identical

Additional checks: full Python suite with WP_BENCH_TEST_IMAGE=wp-bench-grader:dev (345 passed, including 38 helper regressions and the existing Docker isolation/CLI integration tests); ruff check python; mypy python; PHP syntax for all 10 runtime files and 116 CLI setup/assertion/teardown blocks; CLI dry run (27 tasks); dataset export (377 rows); git diff --check.

The helper only checks captured records: task assertions still verify intended new values and creation/count rules, and custom taxonomies/raw database contracts remain specialized. It is test infrastructure, not a PHP security boundary. Existing SQLite support, cache refresh, shell policy, and private-container isolation are unchanged. This does not include repeated model runs or saturation analysis. The original review thread was intentionally left open when this implementation was deferred.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: JasonTheAdams <jason_the_adams@git.wordpress.org>
Co-authored-by: lezama <migueluy@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

An empty prefix matches every metadata key, so it would silently allow any
meta change on that record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017dieY2m63AHakMQc6MZEM1
@lezama
lezama merged commit c6462e9 into trunk Oct 22, 2026
5 checks passed
@lezama
lezama deleted the codex/shared-preservation-helper branch October 22, 2026 18:29
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.

2 participants