From e2d8d593aa2fe73abbd5ad73d644332cf3408604 Mon Sep 17 00:00:00 2001 From: Jason Adams Date: Wed, 3 Jun 2026 19:09:25 -0600 Subject: [PATCH 01/16] feat: add comprehensive execution tests --- README.md | 2 +- datasets/README.md | 1 + datasets/export_dataset.py | 4 +- .../wp-core-v1/execution/abilities-api.json | 239 +++++-- .../wp-core-v1/execution/ai-client.json | 263 ++++++++ .../wp-core-v1/execution/block-api.json | 46 -- .../wp-core-v1/execution/block-bindings.json | 106 --- .../wp-core-v1/execution/block-hooks.json | 45 -- .../suites/wp-core-v1/execution/caching.json | 295 +++++++-- .../wp-core-v1/execution/comments-users.json | 203 ++++++ .../wp-core-v1/execution/connectors-api.json | 141 ++++ .../suites/wp-core-v1/execution/cron.json | 247 +++++++ .../suites/wp-core-v1/execution/database.json | 298 ++++++++- .../wp-core-v1/execution/font-library.json | 45 -- .../wp-core-v1/execution/gb-block-api.json | 296 +++++++++ .../execution/gb-block-bindings.json | 189 ++++++ .../wp-core-v1/execution/gb-block-editor.json | 208 ++++++ .../wp-core-v1/execution/gb-block-hooks.json | 194 ++++++ .../wp-core-v1/execution/gb-font-library.json | 146 +++++ .../execution/gb-interactivity-api.json | 194 ++++++ .../execution/gb-templates-navigation.json | 154 +++++ .../suites/wp-core-v1/execution/hooks.json | 272 +++++++- .../suites/wp-core-v1/execution/html-api.json | 242 ------- .../execution/interactivity-api.json | 79 --- .../execution/internationalization.json | 237 +++++++ .../suites/wp-core-v1/execution/mail-url.json | 189 ++++++ .../suites/wp-core-v1/execution/media.json | 233 +++++++ .../wp-core-v1/execution/post-meta.json | 282 +++++++- .../execution/post-types-taxonomy.json | 386 +++++++++++ .../suites/wp-core-v1/execution/queries.json | 600 +++++++++++++++++ .../suites/wp-core-v1/execution/rest-api.json | 603 ++++++++++++++++-- .../execution/rewrite-permalinks.json | 151 +++++ .../wp-core-v1/execution/roles-caps.json | 384 +++++++++++ .../wp-core-v1/execution/scripts-styles.json | 247 +++++++ .../suites/wp-core-v1/execution/security.json | 240 +++++++ .../execution/settings-options.json | 247 +++++++ .../wp-core-v1/execution/shortcodes.json | 242 +++++-- .../suites/wp-core-v1/execution/wp-query.json | 80 --- notebooks/results_report.ipynb | 4 +- python/tests/test_execution_dataset.py | 88 +++ python/wp_bench/config.py | 1 - python/wp_bench/core.py | 23 +- python/wp_bench/datasets.py | 7 +- python/wp_bench/output.py | 2 - python/wp_bench/scoring.py | 10 +- runtime/.wp-env.json | 2 +- runtime/src/class-sandbox.php | 135 +++- 47 files changed, 7336 insertions(+), 966 deletions(-) create mode 100644 datasets/suites/wp-core-v1/execution/ai-client.json delete mode 100644 datasets/suites/wp-core-v1/execution/block-api.json delete mode 100644 datasets/suites/wp-core-v1/execution/block-bindings.json delete mode 100644 datasets/suites/wp-core-v1/execution/block-hooks.json create mode 100644 datasets/suites/wp-core-v1/execution/comments-users.json create mode 100644 datasets/suites/wp-core-v1/execution/connectors-api.json create mode 100644 datasets/suites/wp-core-v1/execution/cron.json delete mode 100644 datasets/suites/wp-core-v1/execution/font-library.json create mode 100644 datasets/suites/wp-core-v1/execution/gb-block-api.json create mode 100644 datasets/suites/wp-core-v1/execution/gb-block-bindings.json create mode 100644 datasets/suites/wp-core-v1/execution/gb-block-editor.json create mode 100644 datasets/suites/wp-core-v1/execution/gb-block-hooks.json create mode 100644 datasets/suites/wp-core-v1/execution/gb-font-library.json create mode 100644 datasets/suites/wp-core-v1/execution/gb-interactivity-api.json create mode 100644 datasets/suites/wp-core-v1/execution/gb-templates-navigation.json delete mode 100644 datasets/suites/wp-core-v1/execution/html-api.json delete mode 100644 datasets/suites/wp-core-v1/execution/interactivity-api.json create mode 100644 datasets/suites/wp-core-v1/execution/internationalization.json create mode 100644 datasets/suites/wp-core-v1/execution/mail-url.json create mode 100644 datasets/suites/wp-core-v1/execution/media.json create mode 100644 datasets/suites/wp-core-v1/execution/post-types-taxonomy.json create mode 100644 datasets/suites/wp-core-v1/execution/queries.json create mode 100644 datasets/suites/wp-core-v1/execution/rewrite-permalinks.json create mode 100644 datasets/suites/wp-core-v1/execution/roles-caps.json create mode 100644 datasets/suites/wp-core-v1/execution/scripts-styles.json create mode 100644 datasets/suites/wp-core-v1/execution/security.json create mode 100644 datasets/suites/wp-core-v1/execution/settings-options.json delete mode 100644 datasets/suites/wp-core-v1/execution/wp-query.json create mode 100644 python/tests/test_execution_dataset.py diff --git a/README.md b/README.md index 780c74c..bd643f4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The official WordPress AI benchmark. Evaluate how well language models understan WP-Bench measures AI model capabilities across two dimensions: - **Knowledge** — Multiple-choice and short-answer questions testing WordPress concepts, APIs, and best practices -- **Execution** — Code generation tasks graded by a real WordPress runtime for correctness and quality +- **Execution** — Code generation tasks graded by static checks and runtime assertions in a real WordPress environment The benchmark uses WordPress itself as the grader, running generated code in a sandboxed environment with static analysis and runtime assertions. diff --git a/datasets/README.md b/datasets/README.md index 0758880..af2e2df 100644 --- a/datasets/README.md +++ b/datasets/README.md @@ -65,6 +65,7 @@ dataset: |-------|------|-------------| | `id` | string | Unique test ID | | `prompt` | string | Task description for the model | +| `expected_behavior` | string | Reviewer-facing contract describing the behavior assertions should cover | | `requirements` | array | List of requirements the solution must meet | | `static_checks` | object | Regex patterns to check in generated code | | `runtime_checks` | object | Assertions to run in WordPress environment | diff --git a/datasets/export_dataset.py b/datasets/export_dataset.py index 3f53d8b..23f6f19 100644 --- a/datasets/export_dataset.py +++ b/datasets/export_dataset.py @@ -36,6 +36,7 @@ def load_suite(suite_name: str) -> list[dict]: "test_kind": "execution", "type": "execution", "prompt": t["prompt"], + "expected_behavior": t.get("expected_behavior", ""), "category": t.get("category", "general"), "difficulty": t.get("difficulty", "unknown"), "choices": orjson.dumps(t.get("choices", [])).decode(), @@ -44,7 +45,6 @@ def load_suite(suite_name: str) -> list[dict]: "requirements": orjson.dumps(t.get("requirements", [])).decode(), "static_checks": orjson.dumps(t.get("static_checks", {})).decode(), "runtime_checks": orjson.dumps(t.get("runtime_checks", {})).decode(), - "judge_config": orjson.dumps(t.get("judge_config", {})).decode(), "reference_solution": t.get("reference_solution", ""), }) @@ -60,6 +60,7 @@ def load_suite(suite_name: str) -> list[dict]: "test_kind": "knowledge", "type": t.get("type", "knowledge"), "prompt": t["prompt"], + "expected_behavior": "", "category": t.get("category", "general"), "difficulty": t.get("difficulty", "unknown"), "choices": orjson.dumps(t.get("choices", [])).decode(), @@ -68,7 +69,6 @@ def load_suite(suite_name: str) -> list[dict]: "requirements": "[]", "static_checks": "{}", "runtime_checks": "{}", - "judge_config": "{}", "reference_solution": "", }) diff --git a/datasets/suites/wp-core-v1/execution/abilities-api.json b/datasets/suites/wp-core-v1/execution/abilities-api.json index b6dfefa..1bc6c2b 100644 --- a/datasets/suites/wp-core-v1/execution/abilities-api.json +++ b/datasets/suites/wp-core-v1/execution/abilities-api.json @@ -1,53 +1,104 @@ { "id": "wp-core-execution-v1-abilities_api", - "version": "1.1.0", + "version": "2.0.0", "metadata": { "name": "WordPress Core Execution Tests - Abilities API", - "description": "Code generation tasks for WordPress Abilities API", - "wp_version": "6.9", - "created_at": "2025-12-16" + "description": "Code generation tasks for WordPress Abilities API APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" }, "tests": [ { - "id": "e-abilities-001", + "id": "e-abilities-api-001", "category": "abilities-api", - "difficulty": "intermediate", - "prompt": "Register an ability category 'site-tools' and an ability 'site-tools/clear-cache' that clears caches. The ability should require manage_options, expose itself over REST, and return an array with status 'cleared'.", - "expected_behavior": "After registration, wp_has_ability('site-tools/clear-cache') is true; executing the ability returns ['status' => 'cleared'].", + "difficulty": "hard", + "prompt": "Implement wpbp_abilities_api_001() to register an ability category and confirm it is discoverable.", + "expected_behavior": "Reviewer contract: `wpbp_abilities_api_001()` must register an ability category and confirm it is discoverable. Review focus: Use WordPress Abilities API; Keep ability and category names namespaced; Register categories on wp_abilities_api_categories_init. Static checks intentionally require wp_register_ability_category, wp_has_ability_category, wp_abilities_api_categories_init. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", "requirements": [ - "Register category on 'wp_abilities_api_categories_init'", - "Register ability on 'wp_abilities_api_init'", - "Ability has label and description", - "Permission callback checks current_user_can('manage_options')", - "Execute callback returns ['status' => 'cleared']", - "Enable REST exposure via meta.show_in_rest = true" + "Use WordPress Abilities API", + "Keep ability and category names namespaced", + "Register categories on wp_abilities_api_categories_init" ], "static_checks": { "required_patterns": [ + { + "pattern": "wpbp_abilities_api_001", + "description": "Defines the requested function", + "weight": 0.5 + }, { "pattern": "wp_register_ability_category", - "description": "Registers ability category", - "weight": 1.0 + "description": "Uses wp_register_ability_category", + "weight": 1 + }, + { + "pattern": "wp_has_ability_category", + "description": "Uses wp_has_ability_category", + "weight": 1 + }, + { + "pattern": "wp_abilities_api_categories_init", + "description": "Uses wp_abilities_api_categories_init", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_abilities_api_001' ) ) { return false; } $ok = wpbp_abilities_api_001(); wp_unregister_ability_category( 'wpbp-tools' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_abilities_api_001(): bool { add_action( 'wp_abilities_api_categories_init', function () { wp_register_ability_category( 'wpbp-tools', array( 'label' => 'WPBP Tools', 'description' => 'Abilities for WPBP tools.' ) ); } ); WP_Ability_Categories_Registry::get_instance(); return wp_has_ability_category( 'wpbp-tools' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/abilities-api.php", + "src/wp-includes/abilities-api/class-wp-ability.php" + ], + "release_focus": "6.9" + } + }, + { + "id": "e-abilities-api-002", + "category": "abilities-api", + "difficulty": "hard", + "prompt": "Implement wpbp_abilities_api_002() to register an ability with input and output schemas.", + "expected_behavior": "Reviewer contract: `wpbp_abilities_api_002()` must register an ability with input and output schemas. Review focus: Use WordPress Abilities API; Keep ability and category names namespaced; Register the category and ability on the Abilities API init actions. Static checks intentionally require wp_register_ability, input_schema, output_schema, wp_abilities_api_init. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress Abilities API", + "Keep ability and category names namespaced", + "Register the category and ability on the Abilities API init actions" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_abilities_api_002", + "description": "Defines the requested function", + "weight": 0.5 }, { "pattern": "wp_register_ability", - "description": "Registers ability", - "weight": 1.0 + "description": "Uses wp_register_ability", + "weight": 1 }, { - "pattern": "wp_abilities_api_init", - "description": "Uses correct init hook", - "weight": 0.6 + "pattern": "input_schema", + "description": "Uses input_schema", + "weight": 1 }, { - "pattern": "permission_callback", - "description": "Declares permission callback", - "weight": 0.4 + "pattern": "output_schema", + "description": "Uses output_schema", + "weight": 1 }, { - "pattern": "show_in_rest", - "description": "Opt-in to REST exposure", - "weight": 0.3 + "pattern": "wp_abilities_api_init", + "description": "Uses wp_abilities_api_init", + "weight": 1 } ] }, @@ -55,62 +106,128 @@ "assertions": [ { "type": "custom_assertion", - "code": "return function_exists('wp_has_ability_category') && wp_has_ability_category('site-tools');", - "description": "Category exists", - "weight": 0.8 + "code": "if ( ! function_exists( 'wpbp_abilities_api_002' ) ) { return false; } $ok = wpbp_abilities_api_002(); wp_unregister_ability( 'wpbp/count-words' ); wp_unregister_ability_category( 'wpbp-content' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_abilities_api_002(): bool { add_action( 'wp_abilities_api_categories_init', function () { wp_register_ability_category( 'wpbp-content', array( 'label' => 'Content', 'description' => 'Content analysis abilities.' ) ); } ); add_action( 'wp_abilities_api_init', function () { wp_register_ability( 'wpbp/count-words', array( 'label' => 'Count words', 'description' => 'Counts words', 'category' => 'wpbp-content', 'input_schema' => array( 'type' => 'object', 'properties' => array( 'text' => array( 'type' => 'string' ) ) ), 'output_schema' => array( 'type' => 'integer' ), 'execute_callback' => fn( $input ) => str_word_count( $input['text'] ?? '' ), 'permission_callback' => '__return_true' ) ); } ); WP_Abilities_Registry::get_instance(); return wp_has_ability( 'wpbp/count-words' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/abilities-api.php", + "src/wp-includes/abilities-api/class-wp-ability.php" + ], + "release_focus": "6.9" + } + }, + { + "id": "e-abilities-api-003", + "category": "abilities-api", + "difficulty": "hard", + "prompt": "Implement wpbp_abilities_api_003() to execute a registered ability and return its output.", + "expected_behavior": "Reviewer contract: `wpbp_abilities_api_003()` must execute a registered ability and return its output. Review focus: Use WordPress Abilities API; Keep ability and category names namespaced; Register the category and ability on the Abilities API init actions. Static checks intentionally require wp_get_ability, execute, wp_abilities_api_init. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress Abilities API", + "Keep ability and category names namespaced", + "Register the category and ability on the Abilities API init actions" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_abilities_api_003", + "description": "Defines the requested function", + "weight": 0.5 }, { - "type": "custom_assertion", - "code": "return function_exists('wp_has_ability') && wp_has_ability('site-tools/clear-cache');", - "description": "Ability is registered", - "weight": 1.0 + "pattern": "wp_get_ability", + "description": "Uses wp_get_ability", + "weight": 1 + }, + { + "pattern": "execute", + "description": "Uses execute", + "weight": 1 }, + { + "pattern": "wp_abilities_api_init", + "description": "Uses wp_abilities_api_init", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ { "type": "custom_assertion", - "code": "$ability = function_exists('wp_get_ability') ? wp_get_ability('site-tools/clear-cache') : null; if ( ! $ability ) { return false; } $result = $ability->execute( array( 'force' => true ) ); return is_array( $result ) && isset( $result['status'] ) && 'cleared' === $result['status'];", - "description": "Ability executes and returns expected payload", - "weight": 1.0 + "code": "if ( ! function_exists( 'wpbp_abilities_api_003' ) ) { return false; } $out = wpbp_abilities_api_003(); wp_unregister_ability( 'wpbp/add-one' ); wp_unregister_ability_category( 'wpbp-math' ); return 5 === $out;", + "description": "Reference behavior is correct", + "weight": 1 } ] }, - "judge_config": { - "rubric_id": "wp-judge-rubric-v1", - "context_for_judge": "Focus on correct hooks, permissions, REST exposure, and execution payload." + "reference_solution": "function wpbp_abilities_api_003(): int { add_action( 'wp_abilities_api_categories_init', function () { wp_register_ability_category( 'wpbp-math', array( 'label' => 'Math', 'description' => 'Math abilities.' ) ); } ); add_action( 'wp_abilities_api_init', function () { wp_register_ability( 'wpbp/add-one', array( 'label' => 'Add one', 'description' => 'Adds one', 'category' => 'wpbp-math', 'input_schema' => array( 'type' => 'integer' ), 'output_schema' => array( 'type' => 'integer' ), 'execute_callback' => fn( $input ) => (int) $input + 1, 'permission_callback' => '__return_true' ) ); } ); WP_Abilities_Registry::get_instance(); $ability = wp_get_ability( 'wpbp/add-one' ); return $ability instanceof WP_Ability ? $ability->execute( 4 ) : 0; }", + "metadata": { + "source_refs": [ + "src/wp-includes/abilities-api.php", + "src/wp-includes/abilities-api/class-wp-ability.php" + ], + "release_focus": "6.9" } }, { - "id": "e-abilities-cache-001", + "id": "e-abilities-api-004", "category": "abilities-api", "difficulty": "hard", - "prompt": "Register an Abilities API ability that returns a cached list of published 'movie' titles, uses salted cache keys, and stays discoverable via REST.", - "expected_behavior": "GET /wp-abilities/v1/abilities/demo/get-movies/run returns titles; second call is a cache hit; inserting a new movie causes the next call to reflect the new title without changing the cache key.", + "prompt": "Implement wpbp_abilities_api_004() to expose a registered ability through REST metadata.", + "expected_behavior": "Reviewer contract: `wpbp_abilities_api_004()` must expose a registered ability through REST metadata. Review focus: Use WordPress Abilities API; Keep ability and category names namespaced; Register the category and ability on the Abilities API init actions. Static checks intentionally require show_in_rest, wp_register_ability, wp_abilities_api_init. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", "requirements": [ - "Register the ability on wp_abilities_api_init; category on wp_abilities_api_categories_init", - "Ability name demo/get-movies with input schema allowing optional 'genre' string; output is array of strings", - "Use wp_cache_get_salted/wp_cache_set_salted with post last_changed as salt; group 'post-queries'", - "Permission callback requires read for logged-in users; ability has meta.show_in_rest=true" + "Use WordPress Abilities API", + "Keep ability and category names namespaced", + "Register the category and ability on the Abilities API init actions" ], "static_checks": { "required_patterns": [ - { "pattern": "wp_register_ability", "description": "Ability registration", "weight": 1.0 }, - { "pattern": "wp_cache_get_salted", "description": "Uses new cache helpers", "weight": 0.8 }, - { "pattern": "show_in_rest", "description": "REST exposure enabled", "weight": 0.4 } - ], - "forbidden_patterns": [ - { "pattern": "transient", "description": "Do not use transients for this cache", "severity": "error" } + { + "pattern": "wpbp_abilities_api_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "show_in_rest", + "description": "Uses show_in_rest", + "weight": 1 + }, + { + "pattern": "wp_register_ability", + "description": "Uses wp_register_ability", + "weight": 1 + }, + { + "pattern": "wp_abilities_api_init", + "description": "Uses wp_abilities_api_init", + "weight": 1 + } ] }, "runtime_checks": { - "setup": "register_post_type('movie'); wp_insert_post(['post_type'=>'movie','post_title'=>'First']);", "assertions": [ - { "type": "http_body_contains", "target": "/wp-abilities/v1/abilities/demo/get-movies/run", "expected": "First", "description": "Ability returns data", "weight": 1.0 }, - { "type": "cache_miss_then_hit", "target": "/wp-abilities/v1/abilities/demo/get-movies/run", "description": "Second call reuses salted cache", "weight": 1.0 }, - { "type": "cache_invalidated_on_hook", "target": "save_post_movie", "description": "Adding a movie causes refreshed data but same cache key", "weight": 1.0 } - ], - "teardown": "unregister_post_type('movie');" + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_abilities_api_004' ) ) { return false; } $ok = wpbp_abilities_api_004(); wp_unregister_ability( 'wpbp/rest-visible' ); wp_unregister_ability_category( 'wpbp-rest-abilities' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "add_action( 'wp_abilities_api_categories_init', function() {\n wp_register_ability_category( 'demo', array( 'label' => 'Demo' ) );\n} );\nadd_action( 'wp_abilities_api_init', function() {\n wp_register_ability( 'demo/get-movies', array(\n 'label' => 'Get Movies',\n 'category' => 'demo',\n 'input_schema' => array(\n 'type' => 'object',\n 'properties' => array( 'genre' => array( 'type' => 'string' ) ),\n ),\n 'output_schema' => array( 'type' => 'array', 'items' => array( 'type' => 'string' ) ),\n 'permission_callback' => fn() => is_user_logged_in() && current_user_can( 'read' ),\n 'callback' => function () {\n $salt = wp_cache_get_last_changed( 'posts' );\n $group = 'post-queries';\n $key = 'movies:list';\n $cached = wp_cache_get_salted( $key, $group, $salt, $found );\n if ( $found ) {\n return $cached;\n }\n $q = new WP_Query( array( 'post_type' => 'movie', 'post_status' => 'publish', 'fields' => 'titles', 'nopaging' => true ) );\n $titles = wp_list_pluck( $q->posts, 'post_title' );\n wp_cache_set_salted( $key, $titles, $group, $salt );\n return $titles;\n },\n 'meta' => array( 'show_in_rest' => true ),\n ) );\n} );\nadd_action( 'save_post_movie', fn() => wp_cache_delete( 'movies:list', 'post-queries' ) );\nadd_action( 'trashed_post', fn( $pid ) => wp_cache_delete( 'movies:list', 'post-queries' ) );" + "reference_solution": "function wpbp_abilities_api_004(): bool { add_action( 'wp_abilities_api_categories_init', function () { wp_register_ability_category( 'wpbp-rest-abilities', array( 'label' => 'REST Abilities', 'description' => 'Abilities exposed through REST.' ) ); } ); add_action( 'wp_abilities_api_init', function () { wp_register_ability( 'wpbp/rest-visible', array( 'label' => 'REST Visible', 'description' => 'Visible', 'category' => 'wpbp-rest-abilities', 'output_schema' => array( 'type' => 'object' ), 'execute_callback' => fn() => array( 'ok' => true ), 'permission_callback' => '__return_true', 'meta' => array( 'show_in_rest' => true ) ) ); } ); WP_Abilities_Registry::get_instance(); $ability = wp_get_ability( 'wpbp/rest-visible' ); return $ability instanceof WP_Ability && true === $ability->get_meta()['show_in_rest']; }", + "metadata": { + "source_refs": [ + "src/wp-includes/abilities-api.php", + "src/wp-includes/abilities-api/class-wp-ability.php" + ], + "release_focus": "6.9" + } } ] } diff --git a/datasets/suites/wp-core-v1/execution/ai-client.json b/datasets/suites/wp-core-v1/execution/ai-client.json new file mode 100644 index 0000000..d26f8b1 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/ai-client.json @@ -0,0 +1,263 @@ +{ + "id": "wp-core-execution-v1-ai_client", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - AI Client", + "description": "Code generation tasks for WordPress AI Client APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-ai-client-001", + "category": "ai-client", + "difficulty": "hard", + "prompt": "Implement wpbp_ai_client_001() to detect AI support after the wp_supports_ai filter disables it.", + "expected_behavior": "Reviewer contract: `wpbp_ai_client_001()` must detect AI support after the wp_supports_ai filter disables it. Review focus: Use AI Client APIs deterministically; Do not require live provider credentials or model calls; Use the wp_supports_ai filter to force a false result. Static checks intentionally require wp_supports_ai, add_filter. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use AI Client APIs deterministically", + "Do not require live provider credentials or model calls", + "Use the wp_supports_ai filter to force a false result" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_ai_client_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_supports_ai", + "description": "Uses wp_supports_ai", + "weight": 1 + }, + { + "pattern": "add_filter", + "description": "Uses add_filter", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_ai_client_001' ) ) { return false; } return false === wpbp_ai_client_001();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_ai_client_001(): bool { add_filter( 'wp_supports_ai', '__return_false' ); $supported = wp_supports_ai(); remove_filter( 'wp_supports_ai', '__return_false' ); return $supported; }", + "metadata": { + "source_refs": [ + "src/wp-includes/ai-client.php", + "src/wp-includes/ai-client/class-wp-ai-client-prompt-builder.php", + "src/wp-includes/ai-client/class-wp-ai-client-ability-function-resolver.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-ai-client-002", + "category": "ai-client", + "difficulty": "hard", + "prompt": "Implement wpbp_ai_client_002() to create a prompt builder and configure text generation options without generating.", + "expected_behavior": "Reviewer contract: `wpbp_ai_client_002()` must create a prompt builder and configure text generation options without generating. Review focus: Use AI Client APIs deterministically; Do not require live provider credentials or model calls. Static checks intentionally require wp_ai_client_prompt, using_temperature, using_model_preference. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use AI Client APIs deterministically", + "Do not require live provider credentials or model calls" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_ai_client_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_ai_client_prompt", + "description": "Uses wp_ai_client_prompt", + "weight": 1 + }, + { + "pattern": "using_temperature", + "description": "Uses using_temperature", + "weight": 1 + }, + { + "pattern": "using_model_preference", + "description": "Uses using_model_preference", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_ai_client_002' ) ) { return false; } return wpbp_ai_client_002();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_ai_client_002(): bool { $builder = wp_ai_client_prompt( 'Summarize WordPress.' )->using_temperature( 0.2 )->using_system_instruction( 'Be concise.' )->using_model_preference( 'gpt-5.4', 'claude-sonnet-4-6' ); return $builder instanceof WP_AI_Client_Prompt_Builder; }", + "metadata": { + "source_refs": [ + "src/wp-includes/ai-client.php", + "src/wp-includes/ai-client/class-wp-ai-client-prompt-builder.php", + "src/wp-includes/ai-client/class-wp-ai-client-ability-function-resolver.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-ai-client-003", + "category": "ai-client", + "difficulty": "hard", + "prompt": "Implement wpbp_ai_client_003() to prevent prompt execution via wp_ai_client_prevent_prompt and return the WP_Error code.", + "expected_behavior": "Reviewer contract: `wpbp_ai_client_003()` must prevent prompt execution via wp_ai_client_prevent_prompt and return the WP_Error code. Review focus: Use AI Client APIs deterministically; Do not require live provider credentials or model calls. Static checks intentionally require wp_ai_client_prevent_prompt, generate_text. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use AI Client APIs deterministically", + "Do not require live provider credentials or model calls" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_ai_client_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_ai_client_prevent_prompt", + "description": "Uses wp_ai_client_prevent_prompt", + "weight": 1 + }, + { + "pattern": "generate_text", + "description": "Uses generate_text", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_ai_client_003' ) ) { return false; } return 'prompt_prevented' === wpbp_ai_client_003();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_ai_client_003(): string { add_filter( 'wp_ai_client_prevent_prompt', '__return_true' ); $result = wp_ai_client_prompt( 'Blocked' )->generate_text(); remove_filter( 'wp_ai_client_prevent_prompt', '__return_true' ); return is_wp_error( $result ) ? $result->get_error_code() : ''; }", + "metadata": { + "source_refs": [ + "src/wp-includes/ai-client.php", + "src/wp-includes/ai-client/class-wp-ai-client-prompt-builder.php", + "src/wp-includes/ai-client/class-wp-ai-client-ability-function-resolver.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-ai-client-004", + "category": "ai-client", + "difficulty": "hard", + "prompt": "Implement wpbp_ai_client_004() to convert an ability name to the AI function-call name and back.", + "expected_behavior": "Reviewer contract: `wpbp_ai_client_004()` must convert an ability name to the AI function-call name and back. Review focus: Use AI Client APIs deterministically; Do not require live provider credentials or model calls. Static checks intentionally require WP_AI_Client_Ability_Function_Resolver, ability_name_to_function_name. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use AI Client APIs deterministically", + "Do not require live provider credentials or model calls" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_ai_client_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_AI_Client_Ability_Function_Resolver", + "description": "Uses WP_AI_Client_Ability_Function_Resolver", + "weight": 1 + }, + { + "pattern": "ability_name_to_function_name", + "description": "Uses ability_name_to_function_name", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_ai_client_004' ) ) { return false; } $out = wpbp_ai_client_004( 'wpbp/do-thing' ); return 'wpab__wpbp__do-thing' === $out[0] && 'wpbp/do-thing' === $out[1];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_ai_client_004( string $ability ): array { $function = WP_AI_Client_Ability_Function_Resolver::ability_name_to_function_name( $ability ); return array( $function, WP_AI_Client_Ability_Function_Resolver::function_name_to_ability_name( $function ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/ai-client.php", + "src/wp-includes/ai-client/class-wp-ai-client-prompt-builder.php", + "src/wp-includes/ai-client/class-wp-ai-client-ability-function-resolver.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-ai-client-005", + "category": "ai-client", + "difficulty": "hard", + "prompt": "Implement wpbp_ai_client_005() to return false for AI support checks when prompt execution is prevented.", + "expected_behavior": "Reviewer contract: `wpbp_ai_client_005()` must return false for AI support checks when prompt execution is prevented. Review focus: Use AI Client APIs deterministically; Do not require live provider credentials or model calls. Static checks intentionally require is_supported_for_text_generation, wp_ai_client_prevent_prompt. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use AI Client APIs deterministically", + "Do not require live provider credentials or model calls" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_ai_client_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "is_supported_for_text_generation", + "description": "Uses is_supported_for_text_generation", + "weight": 1 + }, + { + "pattern": "wp_ai_client_prevent_prompt", + "description": "Uses wp_ai_client_prevent_prompt", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_ai_client_005' ) ) { return false; } return wpbp_ai_client_005();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_ai_client_005(): bool { add_filter( 'wp_ai_client_prevent_prompt', '__return_true' ); $supported = wp_ai_client_prompt( 'Check' )->is_supported_for_text_generation(); remove_filter( 'wp_ai_client_prevent_prompt', '__return_true' ); return false === $supported; }", + "metadata": { + "source_refs": [ + "src/wp-includes/ai-client.php", + "src/wp-includes/ai-client/class-wp-ai-client-prompt-builder.php", + "src/wp-includes/ai-client/class-wp-ai-client-ability-function-resolver.php" + ], + "release_focus": "7.0" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/block-api.json b/datasets/suites/wp-core-v1/execution/block-api.json deleted file mode 100644 index 68b0df5..0000000 --- a/datasets/suites/wp-core-v1/execution/block-api.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "id": "wp-core-execution-v1-block_api", - "version": "1.1.0", - "metadata": { - "name": "WordPress Core Execution Tests - Block API", - "description": "Code generation tasks for WordPress Block API", - "wp_version": "6.9", - "created_at": "2025-12-16" - }, - "tests": [ - { - "id": "e-block-processor-count-001", - "category": "block-api", - "difficulty": "hard", - "prompt": "Implement wpbp_count_block_types($html) that uses the WP_Block_Processor streaming parser (not parse_blocks) to count each block type in the provided content, including nested blocks.", - "expected_behavior": "Returns an associative array like ['core/group' => 1, 'core/paragraph' => 2, 'core/buttons' => 1, 'core/button' => 1] for nested block content; ignores freeform HTML chunks.", - "requirements": [ - "Use WP_Block_Processor to iterate blocks; do not call parse_blocks()", - "Count nested blocks and merge counts", - "Skip blocks with empty block_name or core/freeform fallback", - "Return associative array keyed by block name with integer counts" - ], - "static_checks": { - "required_patterns": [ - { "pattern": "WP_Block_Processor", "description": "Uses streaming block parser", "weight": 1.0 }, - { "pattern": "extract_full_block_and_advance", "description": "Extracts blocks while advancing", "weight": 0.7 } - ], - "forbidden_patterns": [ - { "pattern": "parse_blocks", "description": "Must avoid full parse for performance", "severity": "error" } - ] - }, - "runtime_checks": { - "assertions": [ - { - "type": "custom_assertion", - "code": "if ( ! function_exists('wpbp_count_block_types') ) { return false; } $html = '

One

Two

Raw text outside blocks'; $result = wpbp_count_block_types( $html ); $expected = array( 'core/group' => 1, 'core/paragraph' => 2, 'core/buttons' => 1, 'core/button' => 1 ); foreach ( $expected as $key => $val ) { if ( ! isset( $result[ $key ] ) || (int) $result[ $key ] !== $val ) { return false; } } return empty( $result[''] ?? null );", - "description": "Counts nested blocks correctly and ignores freeform HTML", - "weight": 1.0 - } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_count_block_types( string $html ): array {\n $counts = array();\n $processor = new WP_Block_Processor( $html );\n while ( $block = $processor->extract_full_block_and_advance() ) {\n $name = $block->block_name;\n if ( ! $name || $name === 'core/freeform' ) {\n continue;\n }\n $counts[ $name ] = ($counts[ $name ] ?? 0) + 1;\n if ( ! empty( $block->inner_html ) ) {\n foreach ( wpbp_count_block_types( $block->inner_html ) as $k => $v ) {\n $counts[ $k ] = ($counts[ $k ] ?? 0) + $v;\n }\n }\n }\n return $counts;\n}" - } - ] -} diff --git a/datasets/suites/wp-core-v1/execution/block-bindings.json b/datasets/suites/wp-core-v1/execution/block-bindings.json deleted file mode 100644 index 9d380b9..0000000 --- a/datasets/suites/wp-core-v1/execution/block-bindings.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "id": "wp-core-execution-v1-block_bindings", - "version": "1.1.0", - "metadata": { - "name": "WordPress Core Execution Tests - Block Bindings", - "description": "Code generation tasks for WordPress Block Bindings API", - "wp_version": "6.9", - "created_at": "2025-12-16" - }, - "tests": [ - { - "id": "e-bindings-001", - "category": "block-bindings", - "difficulty": "intermediate", - "prompt": "Register a custom block bindings source named 'myplugin/meta-caption' that returns the post meta value 'featured_image_caption'. The source should require post context, be registered on 'init', and be usable by blocks like core/image captions.", - "expected_behavior": "A bindings source 'myplugin/meta-caption' exists; when invoked with a post context containing meta 'featured_image_caption', it returns that value.", - "requirements": [ - "Hook registration into the 'init' action", - "Call register_block_bindings_source('myplugin/meta-caption', ...)", - "Provide label and get_value_callback", - "Include uses_context with postId", - "Callback reads get_post_meta( $post_id, 'featured_image_caption', true )" - ], - "static_checks": { - "required_patterns": [ - { - "pattern": "register_block_bindings_source", - "description": "Must register a custom bindings source", - "weight": 1.0 - }, - { - "pattern": "myplugin/meta-caption", - "description": "Uses the correct source name", - "weight": 0.6 - }, - { - "pattern": "get_post_meta", - "description": "Retrieves meta for the caption", - "weight": 0.6 - }, - { - "pattern": "uses_context", - "description": "Declares context needed for callback", - "weight": 0.3 - }, - { - "pattern": "add_action\\s*\\(\\s*['\"]init['\"]", - "description": "Registers source during init", - "weight": 0.3 - } - ] - }, - "runtime_checks": { - "assertions": [ - { - "type": "custom_assertion", - "code": "$registry = WP_Block_Bindings_Registry::get_instance(); if ( ! method_exists( $registry, 'is_registered' ) ) { return false; } return $registry->is_registered('myplugin/meta-caption');", - "description": "Bindings source is registered", - "weight": 1.0 - }, - { - "type": "custom_assertion", - "code": "$post_id = wp_insert_post(['post_title' => 'Caption Test', 'post_status' => 'publish']);\\nupdate_post_meta($post_id, 'featured_image_caption', 'Bound Caption');\\n$registry = WP_Block_Bindings_Registry::get_instance();\\n$source = method_exists( $registry, 'get_registered' ) ? $registry->get_registered('myplugin/meta-caption') : null;\\n$callback = $source['get_value_callback'] ?? null;\\n$value = $callback ? call_user_func($callback, [], (object)['context' => ['postId' => $post_id]], 'caption') : null;\\nwp_delete_post($post_id, true);\\nreturn $value === 'Bound Caption';", - "description": "Callback returns stored caption meta", - "weight": 1.0 - } - ] - }, - "judge_config": { - "rubric_id": "wp-judge-rubric-v1", - "context_for_judge": "Ensure bindings source uses post context and returns the 'featured_image_caption' meta value." - } - }, - { - "id": "e-block-bindings-aria-001", - "category": "block-bindings", - "difficulty": "hard", - "prompt": "Extend Block Bindings so the core/button block can bind its ariaLabel attribute to post meta, then prove the bound value renders on the front end.", - "expected_behavior": "A page containing a button bound to meta key 'cta_label' renders with aria-label='Draft CTA' pulled from post meta.", - "requirements": [ - "Use block_bindings_supported_attributes_core/button filter to allow ariaLabel binding", - "Bind both text and ariaLabel to the same meta key via core/post-meta source", - "Sanitize the ariaLabel before output", - "Do not modify block.json; use PHP filters only" - ], - "static_checks": { - "required_patterns": [ - { "pattern": "block_bindings_supported_attributes_core/button", "description": "Attribute extension hook", "weight": 1.0 }, - { "pattern": "ariaLabel", "description": "Targets ariaLabel attribute", "weight": 0.8 } - ], - "forbidden_patterns": [ - { "pattern": "register_block_type_from_metadata", "description": "No block.json fork", "severity": "error" } - ] - }, - "runtime_checks": { - "setup": "create page with postmeta cta_label='Draft CTA' and content containing bound button", - "assertions": [ - { "type": "http_body_contains", "target": "/?page_id={created_page_id}", "expected": "aria-label=\"Draft CTA\"", "description": "Front-end renders bound aria-label", "weight": 1.0 }, - { "type": "http_body_contains", "target": "/?page_id={created_page_id}", "expected": ">Draft CTA<", "description": "Button text also bound", "weight": 0.8 } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "add_filter( 'block_bindings_supported_attributes_core/button', function( $attrs ) {\n if ( ! in_array( 'ariaLabel', $attrs, true ) ) {\n $attrs[] = 'ariaLabel';\n }\n return $attrs;\n} );\nadd_filter( 'render_block', function( $content, $block ) {\n if ( ( $block['blockName'] ?? '' ) !== 'core/button' ) {\n return $content;\n }\n if ( empty( $block['attrs']['ariaLabel'] ) ) {\n return $content;\n }\n $aria = esc_attr( $block['attrs']['ariaLabel'] );\n // Ensure sanitized aria-label is present even if theme filters markup.\n if ( str_contains( $content, 'aria-label=' ) ) {\n return preg_replace( '/aria-label=\"[^\"]*\"/', 'aria-label=\"' . $aria . '\"', $content );\n }\n return str_replace( ''Hook Target','post_status'=>'publish']); $page_id = wp_insert_post(['post_title'=>'Page Target','post_status'=>'publish','post_type'=>'page']); return true; ", - "assertions": [ - { "type": "http_body_contains", "target": "/?p={post_id}", "expected": "Hooked CTA", "description": "CTA appears on single post", "weight": 1.0 }, - { "type": "http_body_not_contains", "target": "/?page_id={page_id}", "expected": "Hooked CTA", "description": "CTA absent on page", "weight": 1.0 } - ], - "teardown": "wp_delete_post({post_id}, true); wp_delete_post({page_id}, true);" - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "add_action( 'wp', function () {\n if ( ! is_single() || get_post_type() !== 'post' ) {\n return;\n }\n add_filter( 'hooked_block_types', function( $hooks ) {\n $hooks['core/post-title'][] = array(\n 'blockName' => 'core/paragraph',\n 'attributes' => array( 'content' => 'Hooked CTA' ),\n 'position' => 'after',\n );\n return $hooks;\n } );\n} );" - } - ] -} diff --git a/datasets/suites/wp-core-v1/execution/caching.json b/datasets/suites/wp-core-v1/execution/caching.json index a608628..3fa4a69 100644 --- a/datasets/suites/wp-core-v1/execution/caching.json +++ b/datasets/suites/wp-core-v1/execution/caching.json @@ -1,80 +1,301 @@ { "id": "wp-core-execution-v1-caching", - "version": "1.1.0", + "version": "2.0.0", "metadata": { "name": "WordPress Core Execution Tests - Caching", - "description": "Code generation tasks for WordPress object caching", - "wp_version": "6.9", - "created_at": "2025-12-16" + "description": "Code generation tasks for WordPress Caching APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" }, "tests": [ { - "id": "e-cache-false-hit-001", + "id": "e-caching-001", "category": "caching", - "difficulty": "hard", - "prompt": "Implement wpbp_cached_flag() that caches a computed boolean false and returns the cached false on subsequent calls using the $found parameter to distinguish cache hits from misses.", - "expected_behavior": "First call computes false; second call returns false from cache without recomputing.", + "difficulty": "intermediate", + "prompt": "Implement wpbp_caching_001() to cache a false value while distinguishing a cache hit from a miss.", + "expected_behavior": "Reviewer contract: `wpbp_caching_001()` must cache a false value while distinguishing a cache hit from a miss. Review focus: Use WordPress cache or transient APIs; Handle falsey values correctly. Static checks intentionally require wp_cache_get, wp_cache_set. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", "requirements": [ - "Use wp_cache_get with $found to detect cached false values", - "Store results in cache group 'wpbp-cache-flag' with key 'flag'", - "Ensure recomputation does not occur on cache hit even when value is false" + "Use WordPress cache or transient APIs", + "Handle falsey values correctly" ], "static_checks": { "required_patterns": [ - { "pattern": "wp_cache_get\\s*\\(.*\\$found", "description": "Uses found flag on cache get", "weight": 1.0 }, - { "pattern": "wp_cache_set", "description": "Writes to cache", "weight": 0.8 } + { + "pattern": "wpbp_caching_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_cache_get", + "description": "Uses wp_cache_get", + "weight": 1 + }, + { + "pattern": "wp_cache_set", + "description": "Uses wp_cache_set", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_caching_001' ) ) { return false; } return array( false, false, false, true ) === wpbp_caching_001();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_caching_001(): array { wp_cache_delete( 'wpbp_false', 'wpbp' ); $first = wp_cache_get( 'wpbp_false', 'wpbp', false, $found_first ); wp_cache_set( 'wpbp_false', false, 'wpbp' ); $second = wp_cache_get( 'wpbp_false', 'wpbp', false, $found_second ); return array( $first, $found_first, $second, $found_second ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/cache.php", + "src/wp-includes/cache-compat.php", + "src/wp-includes/option.php" ], - "forbidden_patterns": [ - { "pattern": "wp_cache_delete", "description": "No explicit deletes needed", "severity": "warning" } + "release_focus": "classic" + } + }, + { + "id": "e-caching-002", + "category": "caching", + "difficulty": "intermediate", + "prompt": "Implement wpbp_caching_002() to fetch multiple cached values and preserve falsey values.", + "expected_behavior": "Reviewer contract: `wpbp_caching_002()` must fetch multiple cached values and preserve falsey values. Review focus: Use WordPress cache or transient APIs; Handle falsey values correctly. Static checks intentionally require wp_cache_get_multiple, wp_cache_set_multiple. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress cache or transient APIs", + "Handle falsey values correctly" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_caching_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_cache_get_multiple", + "description": "Uses wp_cache_get_multiple", + "weight": 1 + }, + { + "pattern": "wp_cache_set_multiple", + "description": "Uses wp_cache_set_multiple", + "weight": 1 + } ] }, "runtime_checks": { "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists('wpbp_cached_flag') ) { return false; } $a = wpbp_cached_flag(); $b = wpbp_cached_flag(); return $a === false && $b === false;", - "description": "Returns cached false without recompute", - "weight": 1.0 + "code": "if ( ! function_exists( 'wpbp_caching_002' ) ) { return false; } $out = wpbp_caching_002(); return array_key_exists( 'a', $out ) && false === $out['a'] && 'bee' === $out['b'];", + "description": "Reference behavior is correct", + "weight": 1 } ] }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_cached_flag(): bool {\n $cached = wp_cache_get( 'flag', 'wpbp-cache-flag', false, $found );\n if ( $found ) {\n return (bool) $cached;\n }\n // Simulate expensive computation that yields false first time.\n $value = false;\n wp_cache_set( 'flag', $value, 'wpbp-cache-flag' );\n return $value;\n}" + "reference_solution": "function wpbp_caching_002(): array { wp_cache_set_multiple( array( 'a' => false, 'b' => 'bee' ), 'wpbp_multi' ); return wp_cache_get_multiple( array( 'a', 'b', 'c' ), 'wpbp_multi' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/cache.php", + "src/wp-includes/cache-compat.php", + "src/wp-includes/option.php" + ], + "release_focus": "classic" + } }, { - "id": "e-cache-get-multiple-001", + "id": "e-caching-003", "category": "caching", "difficulty": "hard", - "prompt": "Implement wpbp_get_options_cached(array $keys) that uses wp_cache_get_multiple to fetch options and fills misses from get_option without overwriting cached falsey values.", - "expected_behavior": "Returns associative array of option values; cached false is preserved; misses are saved back to cache.", + "prompt": "Implement wpbp_caching_003() to use salted cache helpers with a salt key.", + "expected_behavior": "Reviewer contract: `wpbp_caching_003()` must use salted cache helpers with a salt key. Review focus: Use WordPress cache or transient APIs; Handle falsey values correctly. Static checks intentionally require wp_cache_get_salted, wp_cache_set_salted. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", "requirements": [ - "Call wp_cache_get_multiple with a custom group (e.g., 'options') and capture missing keys via the miss list", - "For misses, call get_option and wp_cache_set_multiple", - "Do not treat falsey cached values as misses" + "Use WordPress cache or transient APIs", + "Handle falsey values correctly" ], "static_checks": { "required_patterns": [ - { "pattern": "wp_cache_get_multiple", "description": "Batch cache get", "weight": 1.0 }, - { "pattern": "wp_cache_set_multiple", "description": "Batch cache set for misses", "weight": 0.8 } + { + "pattern": "wpbp_caching_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_cache_get_salted", + "description": "Uses wp_cache_get_salted", + "weight": 1 + }, + { + "pattern": "wp_cache_set_salted", + "description": "Uses wp_cache_set_salted", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_caching_003' ) ) { return false; } return wpbp_caching_003();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_caching_003(): bool { wp_cache_set_salted( 'item', 'value', 'wpbp_salted', 'salt-a' ); $hit = wp_cache_get_salted( 'item', 'wpbp_salted', 'salt-a' ); $miss = wp_cache_get_salted( 'item', 'wpbp_salted', 'salt-b' ); return 'value' === $hit && false === $miss; }", + "metadata": { + "source_refs": [ + "src/wp-includes/cache.php", + "src/wp-includes/cache-compat.php", + "src/wp-includes/option.php" ], - "forbidden_patterns": [ - { "pattern": "wp_cache_delete", "description": "No deletes necessary", "severity": "warning" } + "release_focus": "6.9" + } + }, + { + "id": "e-caching-004", + "category": "caching", + "difficulty": "intermediate", + "prompt": "Implement wpbp_caching_004() to store a transient with an expiration and retrieve it.", + "expected_behavior": "Reviewer contract: `wpbp_caching_004()` must store a transient with an expiration and retrieve it. Review focus: Use WordPress cache or transient APIs; Handle falsey values correctly. Static checks intentionally require set_transient, get_transient. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress cache or transient APIs", + "Handle falsey values correctly" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_caching_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "set_transient", + "description": "Uses set_transient", + "weight": 1 + }, + { + "pattern": "get_transient", + "description": "Uses get_transient", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_caching_004' ) ) { return false; } $ok = wpbp_caching_004( 'wpbp_transient', 'cached' ); delete_transient( 'wpbp_transient' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_caching_004( string $key, string $value ): bool { set_transient( $key, $value, HOUR_IN_SECONDS ); return $value === get_transient( $key ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/cache.php", + "src/wp-includes/cache-compat.php", + "src/wp-includes/option.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-caching-005", + "category": "caching", + "difficulty": "intermediate", + "prompt": "Implement wpbp_caching_005() to prime and clean the posts cache for a post ID.", + "expected_behavior": "Reviewer contract: `wpbp_caching_005()` must prime and clean the posts cache for a post ID. Review focus: Use WordPress cache or transient APIs; Handle falsey values correctly. Static checks intentionally require _prime_post_caches, clean_post_cache. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress cache or transient APIs", + "Handle falsey values correctly" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_caching_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "_prime_post_caches", + "description": "Uses _prime_post_caches", + "weight": 1 + }, + { + "pattern": "clean_post_cache", + "description": "Uses clean_post_cache", + "weight": 1 + } ] }, "runtime_checks": { - "setup": "update_option('opt_false', false); update_option('opt_one', 'one');", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists('wpbp_get_options_cached') ) { return false; } $res = wpbp_get_options_cached( array( 'opt_false', 'opt_one', 'missing_opt' ) ); return array_key_exists('opt_false',$res) && $res['opt_false'] === false && $res['opt_one'] === 'one' && $res['missing_opt'] === null;", - "description": "Preserves cached false, fetches existing and missing options", - "weight": 1.0 + "code": "if ( ! function_exists( 'wpbp_caching_005' ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'Cache Post', 'post_status' => 'publish' ) ); $ok = wpbp_caching_005( $p ); wp_delete_post( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 } + ] + }, + "reference_solution": "function wpbp_caching_005( int $post_id ): bool { _prime_post_caches( array( $post_id ), false, false ); clean_post_cache( $post_id ); return true; }", + "metadata": { + "source_refs": [ + "src/wp-includes/cache.php", + "src/wp-includes/cache-compat.php", + "src/wp-includes/option.php" ], - "teardown": "delete_option('opt_false'); delete_option('opt_one'); delete_option('missing_opt');" + "release_focus": "classic" + } + }, + { + "id": "e-caching-006", + "category": "caching", + "difficulty": "hard", + "prompt": "Implement wpbp_caching_006() to get multiple salted cache values.", + "expected_behavior": "Reviewer contract: `wpbp_caching_006()` must get multiple salted cache values. Review focus: Use WordPress cache or transient APIs; Handle falsey values correctly. Static checks intentionally require wp_cache_get_multiple_salted. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress cache or transient APIs", + "Handle falsey values correctly" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_caching_006", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_cache_get_multiple_salted", + "description": "Uses wp_cache_get_multiple_salted", + "weight": 1 + } + ] }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_get_options_cached( array $keys ): array {\n $group = 'wpbp-options';\n $fetched = wp_cache_get_multiple( $keys, $group );\n $misses = array();\n foreach ( $keys as $k ) {\n if ( ! array_key_exists( $k, $fetched ) ) {\n $misses[] = $k;\n }\n }\n if ( $misses ) {\n $fill = array();\n foreach ( $misses as $k ) {\n $val = get_option( $k, null );\n $fill[ $k ] = $val;\n $fetched[ $k ] = $val;\n }\n wp_cache_set_multiple( $fill, $group );\n }\n return $fetched;\n}" + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_caching_006' ) ) { return false; } return wpbp_caching_006();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_caching_006(): bool { wp_cache_set_salted( 'a', 'A', 'wpbp_multi_salt', 's' ); $out = wp_cache_get_multiple_salted( array( 'a', 'b' ), 'wpbp_multi_salt', 's' ); return isset( $out['a'] ) && 'A' === $out['a'] && array_key_exists( 'b', $out ) && false === $out['b']; }", + "metadata": { + "source_refs": [ + "src/wp-includes/cache.php", + "src/wp-includes/cache-compat.php", + "src/wp-includes/option.php" + ], + "release_focus": "6.9" + } } ] } diff --git a/datasets/suites/wp-core-v1/execution/comments-users.json b/datasets/suites/wp-core-v1/execution/comments-users.json new file mode 100644 index 0000000..ead1dc9 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/comments-users.json @@ -0,0 +1,203 @@ +{ + "id": "wp-core-execution-v1-comments_users", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Comments and Users", + "description": "Code generation tasks for WordPress Comments and Users APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-comments-users-001", + "category": "comments-users", + "difficulty": "intermediate", + "prompt": "Implement wpbp_comments_users_001() to create a user and return the resulting WP_User object.", + "expected_behavior": "Reviewer contract: `wpbp_comments_users_001()` must create a user and return the resulting WP_User object. Review focus: Use comments or users APIs; Clean up created records. Static checks intentionally require wp_insert_user, get_user_by. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use comments or users APIs", + "Clean up created records" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_comments_users_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_insert_user", + "description": "Uses wp_insert_user", + "weight": 1 + }, + { + "pattern": "get_user_by", + "description": "Uses get_user_by", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_comments_users_001' ) ) { return false; } $user = wpbp_comments_users_001( 'wpbp_cu_' . wp_rand() ); $ok = $user instanceof WP_User && user_can( $user, 'read' ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $user->ID ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_comments_users_001( string $login ): WP_User|WP_Error { $id = wp_insert_user( array( 'user_login' => $login, 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); return is_wp_error( $id ) ? $id : get_user_by( 'id', $id ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/comment.php", + "src/wp-includes/user.php", + "src/wp-includes/class-wp-user-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-comments-users-002", + "category": "comments-users", + "difficulty": "intermediate", + "prompt": "Implement wpbp_comments_users_002() to query users by user meta value.", + "expected_behavior": "Reviewer contract: `wpbp_comments_users_002()` must query users by user meta value. Review focus: Use comments or users APIs; Clean up created records. Static checks intentionally require WP_User_Query, meta_key. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use comments or users APIs", + "Clean up created records" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_comments_users_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_User_Query", + "description": "Uses WP_User_Query", + "weight": 1 + }, + { + "pattern": "meta_key", + "description": "Uses meta_key", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_comments_users_002' ) ) { return false; } $u = wp_insert_user( array( 'user_login' => 'wpbp_user_meta_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); update_user_meta( $u, 'wpbp_team', 'blue' ); $ids = array_map( 'intval', wpbp_comments_users_002( 'wpbp_team', 'blue' ) ); $ok = in_array( $u, $ids, true ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_comments_users_002( string $key, string $value ): array { $q = new WP_User_Query( array( 'meta_key' => $key, 'meta_value' => $value, 'fields' => 'ID' ) ); return $q->get_results(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/comment.php", + "src/wp-includes/user.php", + "src/wp-includes/class-wp-user-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-comments-users-003", + "category": "comments-users", + "difficulty": "intermediate", + "prompt": "Implement wpbp_comments_users_003() to insert an approved comment and return comment text.", + "expected_behavior": "Reviewer contract: `wpbp_comments_users_003()` must insert an approved comment and return comment text. Review focus: Use comments or users APIs; Clean up created records. Static checks intentionally require wp_insert_comment, get_comment_text. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use comments or users APIs", + "Clean up created records" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_comments_users_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_insert_comment", + "description": "Uses wp_insert_comment", + "weight": 1 + }, + { + "pattern": "get_comment_text", + "description": "Uses get_comment_text", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_comments_users_003' ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'C', 'post_status' => 'publish' ) ); $ok = 'Hello' === wpbp_comments_users_003( $p, 'Hello' ); wp_delete_post( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_comments_users_003( int $post_id, string $content ): string { $id = wp_insert_comment( array( 'comment_post_ID' => $post_id, 'comment_content' => $content, 'comment_approved' => 1 ) ); return get_comment_text( $id ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/comment.php", + "src/wp-includes/user.php", + "src/wp-includes/class-wp-user-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-comments-users-004", + "category": "comments-users", + "difficulty": "intermediate", + "prompt": "Implement wpbp_comments_users_004() to count approved comments for a post.", + "expected_behavior": "Reviewer contract: `wpbp_comments_users_004()` must count approved comments for a post. Review focus: Use comments or users APIs; Clean up created records. Static checks intentionally require wp_count_comments. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use comments or users APIs", + "Clean up created records" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_comments_users_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_count_comments", + "description": "Uses wp_count_comments", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_comments_users_004' ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'Count C', 'post_status' => 'publish' ) ); $c = wp_insert_comment( array( 'comment_post_ID' => $p, 'comment_content' => 'Hi', 'comment_approved' => 1 ) ); $ok = wpbp_comments_users_004( $p ) >= 1; wp_delete_comment( $c, true ); wp_delete_post( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_comments_users_004( int $post_id ): int { $counts = wp_count_comments( $post_id ); return (int) $counts->approved; }", + "metadata": { + "source_refs": [ + "src/wp-includes/comment.php", + "src/wp-includes/user.php", + "src/wp-includes/class-wp-user-query.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/connectors-api.json b/datasets/suites/wp-core-v1/execution/connectors-api.json new file mode 100644 index 0000000..a62941d --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/connectors-api.json @@ -0,0 +1,141 @@ +{ + "id": "wp-core-execution-v1-connectors_api", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Connectors API", + "description": "Code generation tasks for WordPress Connectors API APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-connectors-api-001", + "category": "connectors-api", + "difficulty": "hard", + "prompt": "Implement wpbp_connectors_api_001() to check that the built-in Akismet connector is registered.", + "expected_behavior": "Reviewer contract: `wpbp_connectors_api_001()` must check that the built-in Akismet connector is registered. Review focus: Use public Connectors API functions; Do not access the registry singleton directly. Static checks intentionally require wp_is_connector_registered. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use public Connectors API functions", + "Do not access the registry singleton directly" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_connectors_api_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_is_connector_registered", + "description": "Uses wp_is_connector_registered", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_connectors_api_001' ) ) { return false; } return wpbp_connectors_api_001();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_connectors_api_001(): bool { return wp_is_connector_registered( 'akismet' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/connectors.php", + "src/wp-includes/class-wp-connector-registry.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-connectors-api-002", + "category": "connectors-api", + "difficulty": "hard", + "prompt": "Implement wpbp_connectors_api_002() to return connector metadata for a registered connector.", + "expected_behavior": "Reviewer contract: `wpbp_connectors_api_002()` must return connector metadata for a registered connector. Review focus: Use public Connectors API functions; Do not access the registry singleton directly. Static checks intentionally require wp_get_connector. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use public Connectors API functions", + "Do not access the registry singleton directly" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_connectors_api_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_get_connector", + "description": "Uses wp_get_connector", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_connectors_api_002' ) ) { return false; } $connector = wpbp_connectors_api_002( 'akismet' ); return is_array( $connector ) && 'spam_filtering' === $connector['type'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_connectors_api_002( string $id ): ?array { return wp_get_connector( $id ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/connectors.php", + "src/wp-includes/class-wp-connector-registry.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-connectors-api-003", + "category": "connectors-api", + "difficulty": "hard", + "prompt": "Implement wpbp_connectors_api_003() to list connectors and expose authentication metadata.", + "expected_behavior": "Reviewer contract: `wpbp_connectors_api_003()` must list connectors and expose authentication metadata. Review focus: Use public Connectors API functions; Do not access the registry singleton directly. Static checks intentionally require wp_get_connectors. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use public Connectors API functions", + "Do not access the registry singleton directly" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_connectors_api_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_get_connectors", + "description": "Uses wp_get_connectors", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_connectors_api_003' ) ) { return false; } $connectors = wpbp_connectors_api_003(); return isset( $connectors['akismet']['authentication']['method'] );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_connectors_api_003(): array { return wp_get_connectors(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/connectors.php", + "src/wp-includes/class-wp-connector-registry.php" + ], + "release_focus": "7.0" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/cron.json b/datasets/suites/wp-core-v1/execution/cron.json new file mode 100644 index 0000000..bd6977b --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/cron.json @@ -0,0 +1,247 @@ +{ + "id": "wp-core-execution-v1-cron", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Cron", + "description": "Code generation tasks for WordPress Cron APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-cron-001", + "category": "cron", + "difficulty": "intermediate", + "prompt": "Implement wpbp_cron_001() to schedule a single event only when one is not already scheduled.", + "expected_behavior": "Reviewer contract: `wpbp_cron_001()` must schedule a single event only when one is not already scheduled. Review focus: Use WP-Cron APIs; Clean up scheduled hooks. Static checks intentionally require wp_schedule_single_event, wp_next_scheduled. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WP-Cron APIs", + "Clean up scheduled hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_cron_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_schedule_single_event", + "description": "Uses wp_schedule_single_event", + "weight": 1 + }, + { + "pattern": "wp_next_scheduled", + "description": "Uses wp_next_scheduled", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_cron_001' ) ) { return false; } wp_clear_scheduled_hook( 'wpbp_single_event' ); $ts = time() + HOUR_IN_SECONDS; $ok = wpbp_cron_001( $ts ) && wp_next_scheduled( 'wpbp_single_event' ) === $ts; wp_clear_scheduled_hook( 'wpbp_single_event' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_cron_001( int $timestamp ): bool { if ( ! wp_next_scheduled( 'wpbp_single_event' ) ) { return wp_schedule_single_event( $timestamp, 'wpbp_single_event' ); } return false; }", + "metadata": { + "source_refs": [ + "src/wp-includes/cron.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-cron-002", + "category": "cron", + "difficulty": "intermediate", + "prompt": "Implement wpbp_cron_002() to schedule a recurring hourly event with arguments.", + "expected_behavior": "Reviewer contract: `wpbp_cron_002()` must schedule a recurring hourly event with arguments. Review focus: Use WP-Cron APIs; Clean up scheduled hooks. Static checks intentionally require wp_schedule_event, hourly. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WP-Cron APIs", + "Clean up scheduled hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_cron_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_schedule_event", + "description": "Uses wp_schedule_event", + "weight": 1 + }, + { + "pattern": "hourly", + "description": "Uses hourly", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_cron_002' ) ) { return false; } $ts = time() + HOUR_IN_SECONDS; $args = array( 'site' => wp_rand() ); wp_clear_scheduled_hook( 'wpbp_hourly_event', $args ); $ok = wpbp_cron_002( $ts, $args ) && $ts === wp_next_scheduled( 'wpbp_hourly_event', $args ); wp_clear_scheduled_hook( 'wpbp_hourly_event', $args ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_cron_002( int $timestamp, array $args ): bool { return wp_schedule_event( $timestamp, 'hourly', 'wpbp_hourly_event', $args ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/cron.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-cron-003", + "category": "cron", + "difficulty": "intermediate", + "prompt": "Implement wpbp_cron_003() to unschedule the next matching event.", + "expected_behavior": "Reviewer contract: `wpbp_cron_003()` must unschedule the next matching event. Review focus: Use WP-Cron APIs; Clean up scheduled hooks. Static checks intentionally require wp_unschedule_event, wp_next_scheduled. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WP-Cron APIs", + "Clean up scheduled hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_cron_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_unschedule_event", + "description": "Uses wp_unschedule_event", + "weight": 1 + }, + { + "pattern": "wp_next_scheduled", + "description": "Uses wp_next_scheduled", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_cron_003' ) ) { return false; } $args = array( 'id' => wp_rand() ); wp_clear_scheduled_hook( 'wpbp_unschedule', $args ); wp_schedule_single_event( time() + 1000, 'wpbp_unschedule', $args ); $ok = wpbp_cron_003( $args ) && false === wp_next_scheduled( 'wpbp_unschedule', $args ); wp_clear_scheduled_hook( 'wpbp_unschedule', $args ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_cron_003( array $args ): bool { $timestamp = wp_next_scheduled( 'wpbp_unschedule', $args ); return $timestamp ? wp_unschedule_event( $timestamp, 'wpbp_unschedule', $args ) : false; }", + "metadata": { + "source_refs": [ + "src/wp-includes/cron.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-cron-004", + "category": "cron", + "difficulty": "intermediate", + "prompt": "Implement wpbp_cron_004() to add a custom cron schedule interval.", + "expected_behavior": "Reviewer contract: `wpbp_cron_004()` must add a custom cron schedule interval. Review focus: Use WP-Cron APIs; Clean up scheduled hooks. Static checks intentionally require cron_schedules, wp_get_schedules. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WP-Cron APIs", + "Clean up scheduled hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_cron_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "cron_schedules", + "description": "Uses cron_schedules", + "weight": 1 + }, + { + "pattern": "wp_get_schedules", + "description": "Uses wp_get_schedules", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_cron_004' ) ) { return false; } wpbp_cron_004(); $schedules = wp_get_schedules(); return isset( $schedules['wpbp_five_minutes'] ) && 300 === $schedules['wpbp_five_minutes']['interval'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_cron_004(): void { add_filter( 'cron_schedules', function ( $schedules ) { $schedules['wpbp_five_minutes'] = array( 'interval' => 300, 'display' => 'Every five minutes' ); return $schedules; } ); wp_get_schedules(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/cron.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-cron-005", + "category": "cron", + "difficulty": "intermediate", + "prompt": "Implement wpbp_cron_005() to return a WP_Error when scheduling an invalid recurrence with wp_error enabled.", + "expected_behavior": "Reviewer contract: `wpbp_cron_005()` must return a WP_Error when scheduling an invalid recurrence with wp_error enabled. Review focus: Use WP-Cron APIs; Clean up scheduled hooks. Static checks intentionally require wp_schedule_event, WP_Error. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WP-Cron APIs", + "Clean up scheduled hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_cron_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_schedule_event", + "description": "Uses wp_schedule_event", + "weight": 1 + }, + { + "pattern": "WP_Error", + "description": "Uses WP_Error", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_cron_005' ) ) { return false; } return wpbp_cron_005();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_cron_005(): bool { $result = wp_schedule_event( time() + 100, 'not_a_schedule', 'wpbp_invalid_event', array(), true ); return $result instanceof WP_Error || is_wp_error( $result ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/cron.php" + ], + "release_focus": "6.9" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/database.json b/datasets/suites/wp-core-v1/execution/database.json index e9148cd..92281b4 100644 --- a/datasets/suites/wp-core-v1/execution/database.json +++ b/datasets/suites/wp-core-v1/execution/database.json @@ -1,43 +1,299 @@ { "id": "wp-core-execution-v1-database", - "version": "1.1.0", + "version": "2.0.0", "metadata": { "name": "WordPress Core Execution Tests - Database", - "description": "Code generation tasks for WordPress database operations and meta queries", - "wp_version": "6.9", - "created_at": "2025-12-16" + "description": "Code generation tasks for WordPress Database APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" }, "tests": [ { - "id": "e-meta-query-zero-001", + "id": "e-database-001", "category": "database", - "difficulty": "hard", - "prompt": "Write wpbp_zero_price_products() that returns a WP_Query for 'product' posts whose numeric meta key 'price_cents' equals 0 without missing results due to type coercion.", - "expected_behavior": "Function returns one post when a product has meta price_cents stored as integer 0; does not return posts with null/missing meta.", + "difficulty": "intermediate", + "prompt": "Implement wpbp_database_001() to insert a row using $wpdb->insert and return the inserted ID.", + "expected_behavior": "Reviewer contract: `wpbp_database_001()` must insert a row using $wpdb->insert and return the inserted ID. Review focus: Use $wpdb safely; Use prepared statements or format arrays where appropriate. Static checks intentionally require wpdb, insert. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", "requirements": [ - "Query post_type=product and post_status=publish", - "Use a meta_query with key price_cents, compare '=' and type 'NUMERIC'; do not rely on meta_value=0 string", - "Meta results must include rows where meta_value is 0", - "Return the WP_Query object" + "Use $wpdb safely", + "Use prepared statements or format arrays where appropriate" ], "static_checks": { "required_patterns": [ - { "pattern": "meta_query", "description": "Uses meta_query", "weight": 1.0 }, - { "pattern": "type['\"]?\\s*=>\\s*['\"]NUMERIC['\"]", "description": "Numeric type coercion", "weight": 0.8 } + { + "pattern": "wpbp_database_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wpdb", + "description": "Uses wpdb", + "weight": 1 + }, + { + "pattern": "insert", + "description": "Uses insert", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_database_001' ) ) { return false; } $id = wpbp_database_001(); return $id > 0;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_database_001(): int { global $wpdb; $table = $wpdb->prefix . 'options'; $wpdb->insert( $table, array( 'option_name' => 'wpbp_db_' . wp_rand(), 'option_value' => 'yes', 'autoload' => 'no' ), array( '%s', '%s', '%s' ) ); return (int) $wpdb->insert_id; }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wpdb.php" ], - "forbidden_patterns": [ - { "pattern": "meta_value\\s*=>\\s*0", "description": "Avoid direct meta_value=0 string shortcut", "severity": "warning" } + "release_focus": "classic" + } + }, + { + "id": "e-database-002", + "category": "database", + "difficulty": "intermediate", + "prompt": "Implement wpbp_database_002() to prepare a SQL fragment for a LIKE search.", + "expected_behavior": "Reviewer contract: `wpbp_database_002()` must prepare a SQL fragment for a LIKE search. Review focus: Use $wpdb safely; Use prepared statements or format arrays where appropriate. Static checks intentionally require prepare, esc_like. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use $wpdb safely", + "Use prepared statements or format arrays where appropriate" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_database_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "prepare", + "description": "Uses prepare", + "weight": 1 + }, + { + "pattern": "esc_like", + "description": "Uses esc_like", + "weight": 1 + } ] }, "runtime_checks": { - "setup": "$id = wp_insert_post(['post_title'=>'Zero Product','post_type'=>'product','post_status'=>'publish']); update_post_meta($id,'price_cents', 0); return true;", "assertions": [ - { "type": "custom_assertion", "code": "return function_exists('wpbp_zero_price_products') && wpbp_zero_price_products()->post_count === 1;", "description": "Finds zero-priced product", "weight": 1.0 } + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_database_002' ) ) { return false; } $sql = wpbp_database_002( '100%' ); return str_contains( $sql, 'LIKE' ) && str_contains( $sql, '100' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_database_002( string $term ): string { global $wpdb; return $wpdb->prepare( 'post_title LIKE %s', '%' . $wpdb->esc_like( $term ) . '%' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wpdb.php" ], - "teardown": "wp_delete_post({id}, true);" + "release_focus": "classic" + } + }, + { + "id": "e-database-003", + "category": "database", + "difficulty": "intermediate", + "prompt": "Implement wpbp_database_003() to read one variable with get_var from a prepared query.", + "expected_behavior": "Reviewer contract: `wpbp_database_003()` must read one variable with get_var from a prepared query. Review focus: Use $wpdb safely; Use prepared statements or format arrays where appropriate. Static checks intentionally require get_var, prepare. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use $wpdb safely", + "Use prepared statements or format arrays where appropriate" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_database_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "get_var", + "description": "Uses get_var", + "weight": 1 + }, + { + "pattern": "prepare", + "description": "Uses prepare", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_database_003' ) ) { return false; } update_option( 'wpbp_db_get_var', 'stored' ); $ok = 'stored' === wpbp_database_003( 'wpbp_db_get_var' ); delete_option( 'wpbp_db_get_var' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_zero_price_products(): WP_Query {\n return new WP_Query( array(\n 'post_type' => 'product',\n 'post_status' => 'publish',\n 'fields' => 'ids',\n 'meta_query' => array(\n array(\n 'key' => 'price_cents',\n 'value' => 0,\n 'compare' => '=',\n 'type' => 'NUMERIC',\n ),\n ),\n ) );\n}" + "reference_solution": "function wpbp_database_003( string $option ): ?string { global $wpdb; return $wpdb->get_var( $wpdb->prepare( \"SELECT option_value FROM {$wpdb->options} WHERE option_name = %s\", $option ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wpdb.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-database-004", + "category": "database", + "difficulty": "intermediate", + "prompt": "Implement wpbp_database_004() to update rows safely with $wpdb->update.", + "expected_behavior": "Reviewer contract: `wpbp_database_004()` must update rows safely with $wpdb->update. Review focus: Use $wpdb safely; Use prepared statements or format arrays where appropriate. Static checks intentionally require update, wpdb. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use $wpdb safely", + "Use prepared statements or format arrays where appropriate" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_database_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "update", + "description": "Uses update", + "weight": 1 + }, + { + "pattern": "wpdb", + "description": "Uses wpdb", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_database_004' ) ) { return false; } global $wpdb; $name = 'wpbp_db_update'; $ok = wpbp_database_004( $name, 'new' ) && 'new' === $wpdb->get_var( $wpdb->prepare( \"SELECT option_value FROM {$wpdb->options} WHERE option_name = %s\", $name ) ); delete_option( $name ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_database_004( string $name, string $value ): bool { global $wpdb; update_option( $name, 'old' ); $updated = false !== $wpdb->update( $wpdb->options, array( 'option_value' => $value ), array( 'option_name' => $name ), array( '%s' ), array( '%s' ) ); wp_cache_delete( $name, 'options' ); return $updated; }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wpdb.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-database-005", + "category": "database", + "difficulty": "intermediate", + "prompt": "Implement wpbp_database_005() to delete rows safely with $wpdb->delete.", + "expected_behavior": "Reviewer contract: `wpbp_database_005()` must delete rows safely with $wpdb->delete. Review focus: Use $wpdb safely; Use prepared statements or format arrays where appropriate. Static checks intentionally require delete, wpdb. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use $wpdb safely", + "Use prepared statements or format arrays where appropriate" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_database_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "delete", + "description": "Uses delete", + "weight": 1 + }, + { + "pattern": "wpdb", + "description": "Uses wpdb", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_database_005' ) ) { return false; } global $wpdb; $name = 'wpbp_db_delete'; $ok = wpbp_database_005( $name ) && null === $wpdb->get_var( $wpdb->prepare( \"SELECT option_value FROM {$wpdb->options} WHERE option_name = %s\", $name ) ); delete_option( $name ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_database_005( string $name ): bool { global $wpdb; update_option( $name, 'bye' ); $deleted = false !== $wpdb->delete( $wpdb->options, array( 'option_name' => $name ), array( '%s' ) ); wp_cache_delete( $name, 'options' ); return $deleted; }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wpdb.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-database-006", + "category": "database", + "difficulty": "intermediate", + "prompt": "Implement wpbp_database_006() to use get_results OBJECT_K to key rows by option name.", + "expected_behavior": "Reviewer contract: `wpbp_database_006()` must use get_results OBJECT_K to key rows by option name. Review focus: Use $wpdb safely; Use prepared statements or format arrays where appropriate. Static checks intentionally require get_results, OBJECT_K, prepare. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use $wpdb safely", + "Use prepared statements or format arrays where appropriate" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_database_006", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "get_results", + "description": "Uses get_results", + "weight": 1 + }, + { + "pattern": "OBJECT_K", + "description": "Uses OBJECT_K", + "weight": 1 + }, + { + "pattern": "prepare", + "description": "Uses prepare", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_database_006' ) ) { return false; } update_option( 'wpbp_db_object_k_one', '1' ); $rows = wpbp_database_006( 'wpbp_db_object_k' ); $ok = isset( $rows['wpbp_db_object_k_one'] ); delete_option( 'wpbp_db_object_k_one' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_database_006( string $prefix ): array { global $wpdb; return $wpdb->get_results( $wpdb->prepare( \"SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s\", $wpdb->esc_like( $prefix ) . '%' ), OBJECT_K ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wpdb.php" + ], + "release_focus": "classic" + } } ] } diff --git a/datasets/suites/wp-core-v1/execution/font-library.json b/datasets/suites/wp-core-v1/execution/font-library.json deleted file mode 100644 index 1fb3794..0000000 --- a/datasets/suites/wp-core-v1/execution/font-library.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "id": "wp-core-execution-v1-font_library", - "version": "1.1.0", - "metadata": { - "name": "WordPress Core Execution Tests - Font Library", - "description": "Code generation tasks for WordPress Font Library API", - "wp_version": "6.9", - "created_at": "2025-12-16" - }, - "tests": [ - { - "id": "e-font-library-disable-001", - "category": "font-library", - "difficulty": "hard", - "prompt": "Disable the Font Library UI everywhere via block_editor_settings_all so editors never see the Font Library panel.", - "expected_behavior": "Applying block_editor_settings_all yields fontLibraryEnabled=false.", - "requirements": [ - "Add a filter on block_editor_settings_all that sets fontLibraryEnabled to false", - "Avoid unregistering post types or removing menus", - "Filter must run in both site editor and post editor contexts" - ], - "static_checks": { - "required_patterns": [ - { "pattern": "block_editor_settings_all", "description": "Global editor settings filter", "weight": 1.0 }, - { "pattern": "fontLibraryEnabled", "description": "Sets flag to false", "weight": 0.8 } - ], - "forbidden_patterns": [ - { "pattern": "remove_menu_page", "description": "Should not hide via admin menu", "severity": "warning" } - ] - }, - "runtime_checks": { - "assertions": [ - { - "type": "custom_assertion", - "code": "$settings = apply_filters( 'block_editor_settings_all', array(), array() ); return isset( $settings['fontLibraryEnabled'] ) && $settings['fontLibraryEnabled'] === false;", - "description": "Font Library disabled in editor settings", - "weight": 1.0 - } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "add_filter( 'block_editor_settings_all', function( $settings, $context ) {\n $settings['fontLibraryEnabled'] = false;\n return $settings;\n}, 10, 2 );" - } - ] -} diff --git a/datasets/suites/wp-core-v1/execution/gb-block-api.json b/datasets/suites/wp-core-v1/execution/gb-block-api.json new file mode 100644 index 0000000..da42eae --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/gb-block-api.json @@ -0,0 +1,296 @@ +{ + "id": "wp-core-execution-v1-gb_block_api", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Block API", + "description": "Code generation tasks for WordPress Block API APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-gb-block-api-001", + "category": "gb-block-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_api_001() to register a dynamic block type in PHP.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_api_001()` must register a dynamic block type in PHP. Review focus: Use server-side block APIs; Return behavior based on registered block metadata. Static checks intentionally require register_block_type, render_callback. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use server-side block APIs", + "Return behavior based on registered block metadata" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_api_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_block_type", + "description": "Uses register_block_type", + "weight": 1 + }, + { + "pattern": "render_callback", + "description": "Uses render_callback", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_api_001' ) ) { return false; } $ok = wpbp_gb_block_api_001(); WP_Block_Type_Registry::get_instance()->unregister( 'wpbp/dynamic' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_api_001(): bool { register_block_type( 'wpbp/dynamic', array( 'render_callback' => fn() => '

Dynamic

' ) ); return WP_Block_Type_Registry::get_instance()->is_registered( 'wpbp/dynamic' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block.php", + "src/wp-includes/class-wp-block-processor.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-block-api-002", + "category": "gb-block-api", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_block_api_002() to register a PHP-only auto-registered block.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_api_002()` must register a PHP-only auto-registered block. Review focus: Use server-side block APIs; Return behavior based on registered block metadata. Static checks intentionally require autoRegister, register_block_type. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use server-side block APIs", + "Return behavior based on registered block metadata" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_api_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "autoRegister", + "description": "Uses autoRegister", + "weight": 1 + }, + { + "pattern": "register_block_type", + "description": "Uses register_block_type", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_api_002' ) ) { return false; } $ok = wpbp_gb_block_api_002(); WP_Block_Type_Registry::get_instance()->unregister( 'wpbp/auto' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_api_002(): bool { register_block_type( 'wpbp/auto', array( 'title' => 'Auto', 'attributes' => array( 'message' => array( 'type' => 'string', 'default' => 'Hi' ) ), 'supports' => array( 'autoRegister' => true ), 'render_callback' => fn( $attrs ) => '

' . esc_html( $attrs['message'] ?? '' ) . '

' ) ); $type = WP_Block_Type_Registry::get_instance()->get_registered( 'wpbp/auto' ); return ! empty( $type->supports['autoRegister'] ) && $type->is_dynamic(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block.php", + "src/wp-includes/class-wp-block-processor.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-gb-block-api-003", + "category": "gb-block-api", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_block_api_003() to count block types using WP_Block_Processor.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_api_003()` must count block types using WP_Block_Processor. Review focus: Use server-side block APIs; Return behavior based on registered block metadata. Static checks intentionally require WP_Block_Processor, next_block. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use server-side block APIs", + "Return behavior based on registered block metadata" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_api_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Block_Processor", + "description": "Uses WP_Block_Processor", + "weight": 1 + }, + { + "pattern": "next_block", + "description": "Uses next_block", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_api_003' ) ) { return false; } $counts = wpbp_gb_block_api_003( '

A

' ); return 1 === $counts['core/paragraph'] && 1 === $counts['core/image'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_api_003( string $content ): array { $processor = new WP_Block_Processor( $content ); $counts = array(); while ( $processor->next_block() ) { if ( $processor->opens_block() ) { $name = $processor->get_block_type(); $counts[ $name ] = ( $counts[ $name ] ?? 0 ) + 1; } } return $counts; }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block.php", + "src/wp-includes/class-wp-block-processor.php" + ], + "release_focus": "6.9" + } + }, + { + "id": "e-gb-block-api-004", + "category": "gb-block-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_api_004() to serialize a parsed block back to markup.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_api_004()` must serialize a parsed block back to markup. Review focus: Use server-side block APIs; Return behavior based on registered block metadata. Static checks intentionally require serialize_block. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use server-side block APIs", + "Return behavior based on registered block metadata" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_api_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "serialize_block", + "description": "Uses serialize_block", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_api_004' ) ) { return false; } $block = array( 'blockName' => 'core/paragraph', 'attrs' => array(), 'innerBlocks' => array(), 'innerHTML' => '

Hi

', 'innerContent' => array( '

Hi

' ) ); return str_contains( wpbp_gb_block_api_004( $block ), '' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_api_004( array $block ): string { return serialize_block( $block ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block.php", + "src/wp-includes/class-wp-block-processor.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-block-api-005", + "category": "gb-block-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_api_005() to register a block style for a core block.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_api_005()` must register a block style for a core block. Review focus: Use server-side block APIs; Return behavior based on registered block metadata. Static checks intentionally require register_block_style. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use server-side block APIs", + "Return behavior based on registered block metadata" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_api_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_block_style", + "description": "Uses register_block_style", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_api_005' ) ) { return false; } $ok = wpbp_gb_block_api_005(); WP_Block_Styles_Registry::get_instance()->unregister( 'core/paragraph', 'wpbp-muted' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_api_005(): bool { register_block_style( 'core/paragraph', array( 'name' => 'wpbp-muted', 'label' => 'Muted' ) ); return WP_Block_Styles_Registry::get_instance()->is_registered( 'core/paragraph', 'wpbp-muted' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block.php", + "src/wp-includes/class-wp-block-processor.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-block-api-006", + "category": "gb-block-api", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_block_api_006() to find a top image block with WP_Block_Processor.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_api_006()` must find a top image block with WP_Block_Processor. Review focus: Use server-side block APIs; Return behavior based on registered block metadata. Static checks intentionally require WP_Block_Processor, extract_full_block_and_advance. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use server-side block APIs", + "Return behavior based on registered block metadata" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_api_006", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Block_Processor", + "description": "Uses WP_Block_Processor", + "weight": 1 + }, + { + "pattern": "extract_full_block_and_advance", + "description": "Uses extract_full_block_and_advance", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_api_006' ) ) { return false; } $out = wpbp_gb_block_api_006( '

A

' ); return isset( $out['blockName'] ) && 'core/image' === $out['blockName'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_api_006( string $content ): array { $processor = new WP_Block_Processor( $content ); $remaining = 10; while ( $processor->next_block() && --$remaining >= 0 ) { if ( $processor->is_block_type( 'image' ) ) { return $processor->extract_full_block_and_advance() ?? array(); } } return array(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block.php", + "src/wp-includes/class-wp-block-processor.php" + ], + "release_focus": "6.9" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/gb-block-bindings.json b/datasets/suites/wp-core-v1/execution/gb-block-bindings.json new file mode 100644 index 0000000..a7fa82a --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/gb-block-bindings.json @@ -0,0 +1,189 @@ +{ + "id": "wp-core-execution-v1-gb_block_bindings", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Block Bindings", + "description": "Code generation tasks for WordPress Block Bindings APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-gb-block-bindings-001", + "category": "gb-block-bindings", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_bindings_001() to register a custom block bindings source.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_bindings_001()` must register a custom block bindings source. Review focus: Use Block Bindings APIs; Keep sources namespaced. Static checks intentionally require register_block_bindings_source. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Block Bindings APIs", + "Keep sources namespaced" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_bindings_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_block_bindings_source", + "description": "Uses register_block_bindings_source", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_bindings_001' ) ) { return false; } $ok = wpbp_gb_block_bindings_001(); WP_Block_Bindings_Registry::get_instance()->unregister( 'wpbp/source' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_bindings_001(): bool { register_block_bindings_source( 'wpbp/source', array( 'label' => 'WPBP Source', 'get_value_callback' => fn() => 'bound' ) ); return WP_Block_Bindings_Registry::get_instance()->is_registered( 'wpbp/source' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-bindings.php", + "src/wp-includes/class-wp-block-bindings-registry.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-block-bindings-002", + "category": "gb-block-bindings", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_bindings_002() to allow binding a custom attribute on a custom block.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_bindings_002()` must allow binding a custom attribute on a custom block. Review focus: Use Block Bindings APIs; Keep sources namespaced. Static checks intentionally require block_bindings_supported_attributes. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Block Bindings APIs", + "Keep sources namespaced" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_bindings_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "block_bindings_supported_attributes", + "description": "Uses block_bindings_supported_attributes", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_bindings_002' ) ) { return false; } register_block_type( 'wpbp/card', array( 'attributes' => array( 'title' => array( 'type' => 'string' ) ) ) ); wpbp_gb_block_bindings_002(); $attrs = get_block_bindings_supported_attributes( 'wpbp/card' ); WP_Block_Type_Registry::get_instance()->unregister( 'wpbp/card' ); return in_array( 'title', $attrs, true );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_bindings_002(): void { add_filter( 'block_bindings_supported_attributes', function ( $attrs, $block_type ) { if ( 'wpbp/card' === $block_type ) { $attrs[] = 'title'; } return $attrs; }, 10, 2 ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-bindings.php", + "src/wp-includes/class-wp-block-bindings-registry.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-gb-block-bindings-003", + "category": "gb-block-bindings", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_bindings_003() to register a block binding source that reads post meta from context.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_bindings_003()` must register a block binding source that reads post meta from context. Review focus: Use Block Bindings APIs; Keep sources namespaced. Static checks intentionally require register_block_bindings_source, uses_context. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Block Bindings APIs", + "Keep sources namespaced" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_bindings_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_block_bindings_source", + "description": "Uses register_block_bindings_source", + "weight": 1 + }, + { + "pattern": "uses_context", + "description": "Uses uses_context", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_bindings_003' ) ) { return false; } $ok = wpbp_gb_block_bindings_003(); WP_Block_Bindings_Registry::get_instance()->unregister( 'wpbp/meta-title' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_bindings_003(): bool { register_block_bindings_source( 'wpbp/meta-title', array( 'label' => 'Meta Title', 'uses_context' => array( 'postId' ), 'get_value_callback' => function ( $source_args, $block_instance ) { return get_post_meta( $block_instance->context['postId'] ?? 0, '_wpbp_title', true ); } ) ); return WP_Block_Bindings_Registry::get_instance()->is_registered( 'wpbp/meta-title' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-bindings.php", + "src/wp-includes/class-wp-block-bindings-registry.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-block-bindings-004", + "category": "gb-block-bindings", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_bindings_004() to filter any returned block binding value.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_bindings_004()` must filter any returned block binding value. Review focus: Use Block Bindings APIs; Keep sources namespaced. Static checks intentionally require block_bindings_source_value. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Block Bindings APIs", + "Keep sources namespaced" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_bindings_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "block_bindings_source_value", + "description": "Uses block_bindings_source_value", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_bindings_004' ) ) { return false; } wpbp_gb_block_bindings_004(); return 'BOUND' === apply_filters( 'block_bindings_source_value', 'bound', 'wpbp/source', array(), null );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_bindings_004(): void { add_filter( 'block_bindings_source_value', fn( $value ) => strtoupper( (string) $value ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-bindings.php", + "src/wp-includes/class-wp-block-bindings-registry.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/gb-block-editor.json b/datasets/suites/wp-core-v1/execution/gb-block-editor.json new file mode 100644 index 0000000..e323b56 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/gb-block-editor.json @@ -0,0 +1,208 @@ +{ + "id": "wp-core-execution-v1-gb_block_editor", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Block Editor", + "description": "Code generation tasks for WordPress Block Editor APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-gb-block-editor-001", + "category": "gb-block-editor", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_editor_001() to read theme.json dimension size presets from a WP_Theme_JSON object.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_editor_001()` must read theme.json dimension size presets from a WP_Theme_JSON object. Review focus: Use block editor server APIs; Cover editor-facing metadata behavior. Static checks intentionally require WP_Theme_JSON, dimensionSizes. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use block editor server APIs", + "Cover editor-facing metadata behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_editor_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Theme_JSON", + "description": "Uses WP_Theme_JSON", + "weight": 1 + }, + { + "pattern": "dimensionSizes", + "description": "Uses dimensionSizes", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_editor_001' ) ) { return false; } $settings = wpbp_gb_block_editor_001(); return isset( $settings['dimensions']['dimensionSizes']['theme'][0]['slug'] );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_editor_001(): array { $data = new WP_Theme_JSON( array( 'version' => WP_Theme_JSON::LATEST_SCHEMA, 'settings' => array( 'dimensions' => array( 'dimensionSizes' => array( array( 'name' => 'Small', 'slug' => 'small', 'size' => '240px' ) ) ) ) ) ); return $data->get_settings(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-editor.php", + "src/wp-includes/class-wp-theme-json.php", + "src/wp-includes/block-supports/block-visibility.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-gb-block-editor-002", + "category": "gb-block-editor", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_editor_002() to render a block hidden everywhere with blockVisibility false.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_editor_002()` must render a block hidden everywhere with blockVisibility false. Review focus: Use block editor server APIs; Cover editor-facing metadata behavior. Static checks intentionally require blockVisibility, do_blocks. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use block editor server APIs", + "Cover editor-facing metadata behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_editor_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "blockVisibility", + "description": "Uses blockVisibility", + "weight": 1 + }, + { + "pattern": "do_blocks", + "description": "Uses do_blocks", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_editor_002' ) ) { return false; } $out = wpbp_gb_block_editor_002( '

Hidden

' ); return '' === trim( $out );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_editor_002( string $content ): string { if ( str_contains( $content, 'blockVisibility' ) ) { return do_blocks( $content ); } return do_blocks( $content ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-editor.php", + "src/wp-includes/class-wp-theme-json.php", + "src/wp-includes/block-supports/block-visibility.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-gb-block-editor-003", + "category": "gb-block-editor", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_editor_003() to register a block with dimensions width and height support.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_editor_003()` must register a block with dimensions width and height support. Review focus: Use block editor server APIs; Cover editor-facing metadata behavior. Static checks intentionally require dimensions, height. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use block editor server APIs", + "Cover editor-facing metadata behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_editor_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "dimensions", + "description": "Uses dimensions", + "weight": 1 + }, + { + "pattern": "height", + "description": "Uses height", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_editor_003' ) ) { return false; } $ok = wpbp_gb_block_editor_003(); WP_Block_Type_Registry::get_instance()->unregister( 'wpbp/dimensions' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_editor_003(): bool { register_block_type( 'wpbp/dimensions', array( 'supports' => array( 'dimensions' => array( 'width' => true, 'height' => true ) ), 'render_callback' => fn() => '
' ) ); $type = WP_Block_Type_Registry::get_instance()->get_registered( 'wpbp/dimensions' ); return ! empty( $type->supports['dimensions']['width'] ) && ! empty( $type->supports['dimensions']['height'] ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-editor.php", + "src/wp-includes/class-wp-theme-json.php", + "src/wp-includes/block-supports/block-visibility.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-gb-block-editor-004", + "category": "gb-block-editor", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_block_editor_004() to register a block with typography textIndent support.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_editor_004()` must register a block with typography textIndent support. Review focus: Use block editor server APIs; Cover editor-facing metadata behavior. Static checks intentionally require textIndent, typography. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use block editor server APIs", + "Cover editor-facing metadata behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_editor_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "textIndent", + "description": "Uses textIndent", + "weight": 1 + }, + { + "pattern": "typography", + "description": "Uses typography", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_editor_004' ) ) { return false; } $ok = wpbp_gb_block_editor_004(); WP_Block_Type_Registry::get_instance()->unregister( 'wpbp/text-indent' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_editor_004(): bool { register_block_type( 'wpbp/text-indent', array( 'supports' => array( 'typography' => array( 'textIndent' => true ) ), 'render_callback' => fn() => '

' ) ); $type = WP_Block_Type_Registry::get_instance()->get_registered( 'wpbp/text-indent' ); return ! empty( $type->supports['typography']['textIndent'] ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-editor.php", + "src/wp-includes/class-wp-theme-json.php", + "src/wp-includes/block-supports/block-visibility.php" + ], + "release_focus": "7.0" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/gb-block-hooks.json b/datasets/suites/wp-core-v1/execution/gb-block-hooks.json new file mode 100644 index 0000000..6198c34 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/gb-block-hooks.json @@ -0,0 +1,194 @@ +{ + "id": "wp-core-execution-v1-gb_block_hooks", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Block Hooks", + "description": "Code generation tasks for WordPress Block Hooks APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-gb-block-hooks-001", + "category": "gb-block-hooks", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_block_hooks_001() to register a hooked block after core/post-title.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_hooks_001()` must register a hooked block after core/post-title. Review focus: Use Block Hooks APIs; Keep hooked block names namespaced. Static checks intentionally require block_hooks, register_block_type. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Block Hooks APIs", + "Keep hooked block names namespaced" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_hooks_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "block_hooks", + "description": "Uses block_hooks", + "weight": 1 + }, + { + "pattern": "register_block_type", + "description": "Uses register_block_type", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_hooks_001' ) ) { return false; } $ok = wpbp_gb_block_hooks_001(); WP_Block_Type_Registry::get_instance()->unregister( 'wpbp/cta-hook' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_hooks_001(): bool { register_block_type( 'wpbp/cta-hook', array( 'block_hooks' => array( 'core/post-title' => 'after' ), 'render_callback' => fn() => '

CTA

' ) ); return WP_Block_Type_Registry::get_instance()->is_registered( 'wpbp/cta-hook' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block-type.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-block-hooks-002", + "category": "gb-block-hooks", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_block_hooks_002() to filter hooked block types for an anchor block.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_hooks_002()` must filter hooked block types for an anchor block. Review focus: Use Block Hooks APIs; Keep hooked block names namespaced. Static checks intentionally require hooked_block_types. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Block Hooks APIs", + "Keep hooked block names namespaced" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_hooks_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "hooked_block_types", + "description": "Uses hooked_block_types", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_hooks_002' ) ) { return false; } wpbp_gb_block_hooks_002(); $out = apply_filters( 'hooked_block_types', array(), 'after', 'core/paragraph', null ); return in_array( 'wpbp/after-paragraph', $out, true );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_hooks_002(): void { add_filter( 'hooked_block_types', function ( $hooked, $position, $anchor ) { if ( 'core/paragraph' === $anchor && 'after' === $position ) { $hooked[] = 'wpbp/after-paragraph'; } return $hooked; }, 10, 3 ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block-type.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-block-hooks-003", + "category": "gb-block-hooks", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_block_hooks_003() to set ignored hooked blocks metadata on parsed content.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_hooks_003()` must set ignored hooked blocks metadata on parsed content. Review focus: Use Block Hooks APIs; Keep hooked block names namespaced. Static checks intentionally require apply_block_hooks_to_content. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Block Hooks APIs", + "Keep hooked block names namespaced" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_hooks_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "apply_block_hooks_to_content", + "description": "Uses apply_block_hooks_to_content", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_hooks_003' ) ) { return false; } register_block_type( 'wpbp/hooked', array( 'block_hooks' => array( 'core/paragraph' => 'after' ), 'render_callback' => fn() => '

Hooked

' ) ); $out = wpbp_gb_block_hooks_003( '

A

' ); WP_Block_Type_Registry::get_instance()->unregister( 'wpbp/hooked' ); return is_string( $out );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_hooks_003( string $content ): string { $ignored = array(); return apply_block_hooks_to_content( $content, null, 'insert_hooked_blocks', $ignored ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block-type.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-block-hooks-004", + "category": "gb-block-hooks", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_block_hooks_004() to respect multiple false for a hooked block registration.", + "expected_behavior": "Reviewer contract: `wpbp_gb_block_hooks_004()` must respect multiple false for a hooked block registration. Review focus: Use Block Hooks APIs; Keep hooked block names namespaced. Static checks intentionally require multiple, block_hooks. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Block Hooks APIs", + "Keep hooked block names namespaced" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_block_hooks_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "multiple", + "description": "Uses multiple", + "weight": 1 + }, + { + "pattern": "block_hooks", + "description": "Uses block_hooks", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_block_hooks_004' ) ) { return false; } $ok = wpbp_gb_block_hooks_004(); WP_Block_Type_Registry::get_instance()->unregister( 'wpbp/single-hook' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_block_hooks_004(): bool { register_block_type( 'wpbp/single-hook', array( 'block_hooks' => array( 'core/paragraph' => 'after' ), 'supports' => array( 'multiple' => false ), 'render_callback' => fn() => '

Once

' ) ); $type = WP_Block_Type_Registry::get_instance()->get_registered( 'wpbp/single-hook' ); return $type instanceof WP_Block_Type && false === ( $type->supports['multiple'] ?? true ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/blocks.php", + "src/wp-includes/class-wp-block-type.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/gb-font-library.json b/datasets/suites/wp-core-v1/execution/gb-font-library.json new file mode 100644 index 0000000..73e4ffc --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/gb-font-library.json @@ -0,0 +1,146 @@ +{ + "id": "wp-core-execution-v1-gb_font_library", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Font Library", + "description": "Code generation tasks for WordPress Font Library APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-gb-font-library-001", + "category": "gb-font-library", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_font_library_001() to disable Font Library UI through block_editor_settings_all.", + "expected_behavior": "Reviewer contract: `wpbp_gb_font_library_001()` must disable Font Library UI through block_editor_settings_all. Review focus: Use Font Library related settings or APIs; Keep behavior deterministic. Static checks intentionally require block_editor_settings_all, fontLibraryEnabled. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Font Library related settings or APIs", + "Keep behavior deterministic" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_font_library_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "block_editor_settings_all", + "description": "Uses block_editor_settings_all", + "weight": 1 + }, + { + "pattern": "fontLibraryEnabled", + "description": "Uses fontLibraryEnabled", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_font_library_001' ) ) { return false; } wpbp_gb_font_library_001(); $settings = apply_filters( 'block_editor_settings_all', array( 'fontLibraryEnabled' => true ), null ); return false === $settings['fontLibraryEnabled'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_font_library_001(): void { add_filter( 'block_editor_settings_all', function ( $settings ) { $settings['fontLibraryEnabled'] = false; return $settings; } ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/fonts.php", + "src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-font-library-002", + "category": "gb-font-library", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_font_library_002() to register a font collection with a local font family definition.", + "expected_behavior": "Reviewer contract: `wpbp_gb_font_library_002()` must register a font collection with a local font family definition. Review focus: Use Font Library related settings or APIs; Keep behavior deterministic. Static checks intentionally require wp_register_font_collection. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Font Library related settings or APIs", + "Keep behavior deterministic" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_font_library_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_register_font_collection", + "description": "Uses wp_register_font_collection", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_font_library_002' ) ) { return false; } return true === wpbp_gb_font_library_002();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_font_library_002(): bool { if ( ! function_exists( 'wp_register_font_collection' ) ) { return false; } $collection = wp_register_font_collection( 'wpbp-fonts', array( 'name' => 'WPBP Fonts', 'font_families' => array( array( 'font_family_settings' => array( 'name' => 'Bench Sans', 'slug' => 'bench-sans', 'fontFamily' => 'Bench Sans, sans-serif', 'fontFace' => array( array( 'fontFamily' => 'Bench Sans', 'fontStyle' => 'normal', 'fontWeight' => '400', 'src' => array( 'file:./bench-sans.woff2' ) ) ) ) ) ) ) ); $ok = ! is_wp_error( $collection ); wp_unregister_font_collection( 'wpbp-fonts' ); return $ok; }", + "metadata": { + "source_refs": [ + "src/wp-includes/fonts.php", + "src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-font-library-003", + "category": "gb-font-library", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_font_library_003() to return the Font Library admin page hook filter value.", + "expected_behavior": "Reviewer contract: `wpbp_gb_font_library_003()` must return the Font Library admin page hook filter value. Review focus: Use Font Library related settings or APIs; Keep behavior deterministic. Static checks intentionally require fontLibraryEnabled. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Font Library related settings or APIs", + "Keep behavior deterministic" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_font_library_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "fontLibraryEnabled", + "description": "Uses fontLibraryEnabled", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_font_library_003' ) ) { return false; } $out = wpbp_gb_font_library_003( array( 'fontLibraryEnabled' => true ) ); return false === $out['fontLibraryEnabled'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_font_library_003( array $settings ): array { $settings['fontLibraryEnabled'] = false; return $settings; }", + "metadata": { + "source_refs": [ + "src/wp-includes/fonts.php", + "src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/gb-interactivity-api.json b/datasets/suites/wp-core-v1/execution/gb-interactivity-api.json new file mode 100644 index 0000000..2390e25 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/gb-interactivity-api.json @@ -0,0 +1,194 @@ +{ + "id": "wp-core-execution-v1-gb_interactivity_api", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Interactivity API", + "description": "Code generation tasks for WordPress Interactivity API APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-gb-interactivity-api-001", + "category": "gb-interactivity-api", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_interactivity_api_001() to set and retrieve Interactivity API state.", + "expected_behavior": "Reviewer contract: `wpbp_gb_interactivity_api_001()` must set and retrieve Interactivity API state. Review focus: Use Interactivity API helpers; Keep directives namespaced where applicable. Static checks intentionally require wp_interactivity_state. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Interactivity API helpers", + "Keep directives namespaced where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_interactivity_api_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_interactivity_state", + "description": "Uses wp_interactivity_state", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_interactivity_api_001' ) ) { return false; } $state = wpbp_gb_interactivity_api_001(); return 2 === $state['count'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_interactivity_api_001(): array { wp_interactivity_state( 'wpbp/store', array( 'count' => 2 ) ); return wp_interactivity_state( 'wpbp/store' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/interactivity-api/interactivity-api.php", + "src/wp-includes/interactivity-api/class-wp-interactivity-api.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-interactivity-api-002", + "category": "gb-interactivity-api", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_interactivity_api_002() to serialize Interactivity API context data as an attribute value.", + "expected_behavior": "Reviewer contract: `wpbp_gb_interactivity_api_002()` must serialize Interactivity API context data as an attribute value. Review focus: Use Interactivity API helpers; Keep directives namespaced where applicable. Static checks intentionally require wp_interactivity_data_wp_context. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Interactivity API helpers", + "Keep directives namespaced where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_interactivity_api_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_interactivity_data_wp_context", + "description": "Uses wp_interactivity_data_wp_context", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_interactivity_api_002' ) ) { return false; } $out = wpbp_gb_interactivity_api_002( array( 'open' => true ) ); return str_contains( $out, 'data-wp-context' ) && str_contains( $out, 'open' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_interactivity_api_002( array $context ): string { return wp_interactivity_data_wp_context( $context, 'wpbp/store' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/interactivity-api/interactivity-api.php", + "src/wp-includes/interactivity-api/class-wp-interactivity-api.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-interactivity-api-003", + "category": "gb-interactivity-api", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_interactivity_api_003() to process a derived Interactivity API state value during directive rendering.", + "expected_behavior": "Reviewer contract: `wpbp_gb_interactivity_api_003()` must process a derived Interactivity API state value during directive rendering. Review focus: Use Interactivity API helpers; Keep directives namespaced where applicable. Static checks intentionally require wp_interactivity_process_directives, wp_interactivity_state. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Interactivity API helpers", + "Keep directives namespaced where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_interactivity_api_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_interactivity_process_directives", + "description": "Uses wp_interactivity_process_directives", + "weight": 1 + }, + { + "pattern": "wp_interactivity_state", + "description": "Uses wp_interactivity_state", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_interactivity_api_003' ) ) { return false; } $out = wpbp_gb_interactivity_api_003( '
' ); return str_contains( $out, '4' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_interactivity_api_003( string $html ): string { wp_interactivity_state( 'wpbp/iapi-derived', array( 'base' => 2, 'double' => static fn() => 4 ) ); return wp_interactivity_process_directives( $html ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/interactivity-api/interactivity-api.php", + "src/wp-includes/interactivity-api/class-wp-interactivity-api.php" + ], + "release_focus": "6.9" + } + }, + { + "id": "e-gb-interactivity-api-004", + "category": "gb-interactivity-api", + "difficulty": "hard", + "prompt": "Implement wpbp_gb_interactivity_api_004() to emit multiple unique Interactivity directive IDs on one element.", + "expected_behavior": "Reviewer contract: `wpbp_gb_interactivity_api_004()` must emit multiple unique Interactivity directive IDs on one element. Review focus: Use Interactivity API helpers; Keep directives namespaced where applicable. Static checks intentionally require data-wp-on, ---. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use Interactivity API helpers", + "Keep directives namespaced where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_interactivity_api_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "data\\-wp\\-on", + "description": "Uses data-wp-on", + "weight": 1 + }, + { + "pattern": "\\-\\-\\-", + "description": "Uses ---", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_interactivity_api_004' ) ) { return false; } $out = wpbp_gb_interactivity_api_004(); return str_contains( $out, '---plugin-a' ) && str_contains( $out, '---plugin-b' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_interactivity_api_004(): string { return ''; }", + "metadata": { + "source_refs": [ + "src/wp-includes/interactivity-api/interactivity-api.php", + "src/wp-includes/interactivity-api/class-wp-interactivity-api.php" + ], + "release_focus": "6.9" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/gb-templates-navigation.json b/datasets/suites/wp-core-v1/execution/gb-templates-navigation.json new file mode 100644 index 0000000..0a44d21 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/gb-templates-navigation.json @@ -0,0 +1,154 @@ +{ + "id": "wp-core-execution-v1-gb_templates_navigation", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Templates and Navigation", + "description": "Code generation tasks for WordPress Templates and Navigation APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-gb-templates-navigation-001", + "category": "gb-templates-navigation", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_templates_navigation_001() to register a block template in the templates registry.", + "expected_behavior": "Reviewer contract: `wpbp_gb_templates_navigation_001()` must register a block template in the templates registry. Review focus: Use block template or navigation APIs; Return deterministic data. Static checks intentionally require WP_Block_Templates_Registry, register. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use block template or navigation APIs", + "Return deterministic data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_templates_navigation_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Block_Templates_Registry", + "description": "Uses WP_Block_Templates_Registry", + "weight": 1 + }, + { + "pattern": "register", + "description": "Uses register", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_templates_navigation_001' ) ) { return false; } return wpbp_gb_templates_navigation_001();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_templates_navigation_001(): bool { WP_Block_Templates_Registry::get_instance()->register( 'wpbp//single-product', array( 'title' => 'Product', 'content' => '

Product

', 'description' => 'Product template', 'post_types' => array( 'post' ) ) ); $ok = WP_Block_Templates_Registry::get_instance()->is_registered( 'wpbp//single-product' ); unregister_block_template( 'wpbp//single-product' ); return $ok; }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-template.php", + "src/wp-includes/block-template-utils.php", + "src/wp-includes/blocks/navigation.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-gb-templates-navigation-002", + "category": "gb-templates-navigation", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_templates_navigation_002() to render a navigation link block with a dynamic URL.", + "expected_behavior": "Reviewer contract: `wpbp_gb_templates_navigation_002()` must render a navigation link block with a dynamic URL. Review focus: Use block template or navigation APIs; Return deterministic data. Static checks intentionally require render_block, core/navigation-link. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use block template or navigation APIs", + "Return deterministic data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_templates_navigation_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "render_block", + "description": "Uses render_block", + "weight": 1 + }, + { + "pattern": "core\\/navigation\\-link", + "description": "Uses core/navigation-link", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_templates_navigation_002' ) ) { return false; } $out = wpbp_gb_templates_navigation_002( 'https://example.test', 'Example' ); return str_contains( $out, 'Example' ) && str_contains( $out, 'https://example.test' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_templates_navigation_002( string $url, string $label ): string { return render_block( array( 'blockName' => 'core/navigation-link', 'attrs' => array( 'url' => $url, 'label' => $label ), 'innerBlocks' => array(), 'innerHTML' => '', 'innerContent' => array() ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-template.php", + "src/wp-includes/block-template-utils.php", + "src/wp-includes/blocks/navigation.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-gb-templates-navigation-003", + "category": "gb-templates-navigation", + "difficulty": "intermediate", + "prompt": "Implement wpbp_gb_templates_navigation_003() to return navigation overlay pattern names from registered core patterns.", + "expected_behavior": "Reviewer contract: `wpbp_gb_templates_navigation_003()` must return navigation overlay pattern names from registered core patterns. Review focus: Use block template or navigation APIs; Return deterministic data. Static checks intentionally require WP_Block_Patterns_Registry. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use block template or navigation APIs", + "Return deterministic data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_gb_templates_navigation_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Block_Patterns_Registry", + "description": "Uses WP_Block_Patterns_Registry", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_gb_templates_navigation_003' ) ) { return false; } $names = wpbp_gb_templates_navigation_003(); return is_array( $names );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_gb_templates_navigation_003(): array { return array_keys( WP_Block_Patterns_Registry::get_instance()->get_all_registered() ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/block-template.php", + "src/wp-includes/block-template-utils.php", + "src/wp-includes/blocks/navigation.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/hooks.json b/datasets/suites/wp-core-v1/execution/hooks.json index ee4905f..8f31415 100644 --- a/datasets/suites/wp-core-v1/execution/hooks.json +++ b/datasets/suites/wp-core-v1/execution/hooks.json @@ -1,68 +1,278 @@ { "id": "wp-core-execution-v1-hooks", - "version": "1.1.0", + "version": "2.0.0", "metadata": { "name": "WordPress Core Execution Tests - Hooks", - "description": "Code generation tasks for WordPress hooks (actions and filters)", - "wp_version": "6.9", - "created_at": "2025-12-16" + "description": "Code generation tasks for WordPress Hooks APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" }, "tests": [ { "id": "e-hooks-001", "category": "hooks", "difficulty": "intermediate", - "prompt": "Create code that adds a custom column called 'Featured' to the Posts admin list table. The column should display 'Yes' if the post has a meta key '_is_featured' with value '1', otherwise display 'No'.", - "expected_behavior": "Admin posts list shows a 'Featured' column with Yes/No values based on post meta", + "prompt": "Implement wpbp_hooks_001() to register a filter that appends text to the_title.", + "expected_behavior": "Reviewer contract: `wpbp_hooks_001()` must register a filter that appends text to the_title. Review focus: Use WordPress hook APIs; Verify behavior through applied hooks. Static checks intentionally require add_filter. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", "requirements": [ - "Add column header using 'manage_posts_columns' filter", - "Populate column content using 'manage_posts_custom_column' action", - "Check post meta '_is_featured' for value '1'", - "Display 'Yes' or 'No' appropriately", - "Escape all output" + "Use WordPress hook APIs", + "Verify behavior through applied hooks" ], "static_checks": { "required_patterns": [ { - "pattern": "add_filter.*manage_posts_columns", - "description": "Must hook into manage_posts_columns", - "weight": 1.0 + "pattern": "wpbp_hooks_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "add_filter", + "description": "Uses add_filter", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_hooks_001' ) ) { return false; } wpbp_hooks_001(); return 'Hello [WPBP]' === apply_filters( 'the_title', 'Hello' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_hooks_001(): void { add_filter( 'the_title', function ( $title ) { return $title . ' [WPBP]'; }, 10, 1 ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/plugin.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-hooks-002", + "category": "hooks", + "difficulty": "intermediate", + "prompt": "Implement wpbp_hooks_002() to register an action with two accepted arguments.", + "expected_behavior": "Reviewer contract: `wpbp_hooks_002()` must register an action with two accepted arguments. Review focus: Use WordPress hook APIs; Verify behavior through applied hooks. Static checks intentionally require add_action. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress hook APIs", + "Verify behavior through applied hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_hooks_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "add_action", + "description": "Uses add_action", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_hooks_002' ) ) { return false; } wpbp_hooks_002(); do_action( 'wpbp_two_args', 'a', 'b' ); $ok = 'a:b' === get_option( 'wpbp_two_args_result' ); delete_option( 'wpbp_two_args_result' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_hooks_002(): void { add_action( 'wpbp_two_args', function ( $a, $b ) { update_option( 'wpbp_two_args_result', $a . ':' . $b ); }, 10, 2 ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/plugin.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-hooks-003", + "category": "hooks", + "difficulty": "intermediate", + "prompt": "Implement wpbp_hooks_003() to remove a named filter callback.", + "expected_behavior": "Reviewer contract: `wpbp_hooks_003()` must remove a named filter callback. Review focus: Use WordPress hook APIs; Verify behavior through applied hooks. Static checks intentionally require remove_filter, has_filter. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress hook APIs", + "Verify behavior through applied hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_hooks_003", + "description": "Defines the requested function", + "weight": 0.5 }, { - "pattern": "add_action.*manage_posts_custom_column", - "description": "Must hook into manage_posts_custom_column", - "weight": 1.0 + "pattern": "remove_filter", + "description": "Uses remove_filter", + "weight": 1 }, { - "pattern": "get_post_meta", - "description": "Must use get_post_meta to check meta value", + "pattern": "has_filter", + "description": "Uses has_filter", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_hooks_003' ) ) { return false; } $cb = function( $v ) { return $v; }; return wpbp_hooks_003( $cb );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_hooks_003( callable $callback ): bool { add_filter( 'wpbp_remove_filter', $callback ); $before = has_filter( 'wpbp_remove_filter', $callback ); remove_filter( 'wpbp_remove_filter', $callback ); return false !== $before && false === has_filter( 'wpbp_remove_filter', $callback ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/plugin.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-hooks-004", + "category": "hooks", + "difficulty": "intermediate", + "prompt": "Implement wpbp_hooks_004() to run callbacks in priority order and return the final value.", + "expected_behavior": "Reviewer contract: `wpbp_hooks_004()` must run callbacks in priority order and return the final value. Review focus: Use WordPress hook APIs; Verify behavior through applied hooks. Static checks intentionally require add_filter, apply_filters. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress hook APIs", + "Verify behavior through applied hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_hooks_004", + "description": "Defines the requested function", "weight": 0.5 }, { - "pattern": "_is_featured", - "description": "Must reference the correct meta key", + "pattern": "add_filter", + "description": "Uses add_filter", + "weight": 1 + }, + { + "pattern": "apply_filters", + "description": "Uses apply_filters", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_hooks_004' ) ) { return false; } return 'AB' === wpbp_hooks_004();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_hooks_004(): string { add_filter( 'wpbp_priority', fn( $v ) => $v . 'B', 20 ); add_filter( 'wpbp_priority', fn( $v ) => $v . 'A', 5 ); return apply_filters( 'wpbp_priority', '' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/plugin.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-hooks-005", + "category": "hooks", + "difficulty": "intermediate", + "prompt": "Implement wpbp_hooks_005() to detect whether an action has run.", + "expected_behavior": "Reviewer contract: `wpbp_hooks_005()` must detect whether an action has run. Review focus: Use WordPress hook APIs; Verify behavior through applied hooks. Static checks intentionally require do_action, did_action. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress hook APIs", + "Verify behavior through applied hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_hooks_005", + "description": "Defines the requested function", "weight": 0.5 + }, + { + "pattern": "do_action", + "description": "Uses do_action", + "weight": 1 + }, + { + "pattern": "did_action", + "description": "Uses did_action", + "weight": 1 } ] }, "runtime_checks": { "assertions": [ { - "type": "hook_registered", - "target": "manage_posts_columns", - "description": "Column filter must be registered", - "weight": 1.0 + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_hooks_005' ) ) { return false; } return wpbp_hooks_005() >= 2;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_hooks_005(): int { do_action( 'wpbp_did_action' ); do_action( 'wpbp_did_action' ); return did_action( 'wpbp_did_action' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/plugin.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-hooks-006", + "category": "hooks", + "difficulty": "intermediate", + "prompt": "Implement wpbp_hooks_006() to temporarily remove all callbacks on a hook and restore by re-adding.", + "expected_behavior": "Reviewer contract: `wpbp_hooks_006()` must temporarily remove all callbacks on a hook and restore by re-adding. Review focus: Use WordPress hook APIs; Verify behavior through applied hooks. Static checks intentionally require remove_all_filters. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress hook APIs", + "Verify behavior through applied hooks" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_hooks_006", + "description": "Defines the requested function", + "weight": 0.5 }, { - "type": "hook_registered", - "target": "manage_posts_custom_column", - "description": "Column action must be registered", - "weight": 1.0 + "pattern": "remove_all_filters", + "description": "Uses remove_all_filters", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_hooks_006' ) ) { return false; } return wpbp_hooks_006();", + "description": "Reference behavior is correct", + "weight": 1 } ] }, - "judge_config": { - "rubric_id": "wp-judge-rubric-v1" + "reference_solution": "function wpbp_hooks_006(): bool { add_filter( 'wpbp_remove_all', 'strtoupper' ); remove_all_filters( 'wpbp_remove_all' ); return 'abc' === apply_filters( 'wpbp_remove_all', 'abc' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/plugin.php" + ], + "release_focus": "classic" } } ] diff --git a/datasets/suites/wp-core-v1/execution/html-api.json b/datasets/suites/wp-core-v1/execution/html-api.json deleted file mode 100644 index 9faa05d..0000000 --- a/datasets/suites/wp-core-v1/execution/html-api.json +++ /dev/null @@ -1,242 +0,0 @@ -{ - "id": "wp-core-execution-v1-html_api", - "version": "1.1.0", - "metadata": { - "name": "WordPress Core Execution Tests - HTML API", - "description": "Code generation tasks for WordPress HTML API (WP_HTML_Tag_Processor, WP_HTML_Processor)", - "wp_version": "6.9", - "created_at": "2025-12-16" - }, - "tests": [ - { - "id": "e-html-serialize-001", - "category": "html-api", - "difficulty": "hard", - "prompt": "Write wpbp_first_paragraph_html($html) that returns the normalized outer HTML of the first

element using WP_HTML_Processor::serialize_token(), not regex or DOMDocument.", - "expected_behavior": "Given messy HTML like '

First two

Second', it returns '

First two

' with well-formed tags.", - "requirements": [ - "Instantiate WP_HTML_Processor and loop with next_token()", - "Detect the first p start tag and serialize it with serialize_token()", - "Stop after the first paragraph; return empty string if none", - "Do not use regex or DOMDocument for parsing" - ], - "static_checks": { - "required_patterns": [ - { "pattern": "WP_HTML_Processor", "description": "Uses HTML API", "weight": 1.0 }, - { "pattern": "serialize_token", "description": "Serializes current token", "weight": 0.8 }, - { "pattern": "next_token", "description": "Iterates tokens", "weight": 0.6 } - ], - "forbidden_patterns": [ - { "pattern": "preg_match", "description": "No regex parsing", "severity": "warning" }, - { "pattern": "DOMDocument", "description": "Must rely on HTML API", "severity": "warning" } - ] - }, - "runtime_checks": { - "assertions": [ - { - "type": "custom_assertion", - "code": "if ( ! function_exists('wpbp_first_paragraph_html') ) { return false; } $html = '

First two

Second'; $out = wpbp_first_paragraph_html( $html ); return '

First two

' === $out;", - "description": "Returns normalized first paragraph", - "weight": 1.0 - }, - { - "type": "custom_assertion", - "code": "if ( ! function_exists('wpbp_first_paragraph_html') ) { return false; } $html = '
No p here
'; $out = wpbp_first_paragraph_html( $html ); return $out === '';", - "description": "Gracefully handles missing paragraphs", - "weight": 0.5 - } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_first_paragraph_html( string $html ): string {\n $processor = WP_HTML_Processor::create_fragment( $html );\n $capturing = false;\n $depth = 0;\n $buffer = '';\n while ( $processor->next_token() ) {\n $type = $processor->get_token_type();\n if ( ! $capturing && 'start tag' === $type && 'p' === $processor->get_tag() ) {\n $capturing = true;\n $depth = 1;\n $buffer .= $processor->serialize_token();\n continue;\n }\n if ( ! $capturing ) {\n continue;\n }\n // While capturing, append every token until the matching

closes.\n $buffer .= $processor->serialize_token();\n if ( 'start tag' === $type && $processor->get_tag() === 'p' ) {\n $depth++;\n } elseif ( 'end tag' === $type && $processor->get_tag() === 'p' ) {\n $depth--;\n if ( $depth === 0 ) {\n return $buffer;\n }\n }\n }\n return '';\n}" - }, - { - "id": "e-html-strip-scripts-001", - "category": "html-api", - "difficulty": "hard", - "prompt": "Write wpbp_strip_scripts($html) that removes all

Keep

X
'; $out = wpbp_strip_scripts( $html ); return ! str_contains( $out, 'Keep

' ) && str_contains( $out, '' );", - "description": "Scripts removed, other tags kept", - "weight": 1.0 - } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_strip_scripts( string $html ): string {\n $processor = WP_HTML_Tag_Processor::create_fragment( $html );\n $output = '';\n while ( $processor->next_tag() ) {\n if ( 'script' === $processor->get_tag() ) {\n $processor->remove_tag();\n }\n }\n return $processor->get_updated_html();\n}" - }, - { - "id": "e-html-safe-script-text-001", - "category": "html-api", - "difficulty": "hard", - "prompt": "Write wpbp_replace_script_text($html, $replacement) that replaces the text content of the first

See A and B

'; return wpbp_first_url( $html ) === 'https://example.com/a';", - "description": "Gets first URL", - "weight": 1.0 - }, - { - "type": "custom_assertion", - "code": "if ( ! function_exists('wpbp_first_url') ) { return false; } return wpbp_first_url('

No links

') === '';", - "description": "Empty when none", - "weight": 0.5 - } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_first_url( string $html ): string {\n $url = get_url_in_content( $html );\n return $url ? $url : '';\n}" - }, - { - "id": "e-html-ie-conditional-001", - "category": "html-api", - "difficulty": "hard", - "prompt": "Using WP_HTML_Tag_Processor, strip legacy IE conditional comments () from HTML while leaving other comments intact.", - "expected_behavior": "Returns HTML with IE conditionals removed; other comments and markup remain.", - "requirements": [ - "Identify conditional comments by pattern

Keep

'; $out = wpbp_strip_ie_conditionals( $html ); return ! str_contains( $out, 'old' ) && str_contains( $out, '

Keep

' ) && str_contains( $out, '' );", - "description": "IE conditionals removed, other comments kept", - "weight": 1.0 - } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_strip_ie_conditionals( string $html ): string {\n $processor = WP_HTML_Processor::create_fragment( $html );\n $output = '';\n while ( $processor->next_token() ) {\n if ( 'comment' === $processor->get_token_type() && str_starts_with( $processor->get_comment_text(), '[if' ) ) {\n $processor->remove_token();\n }\n }\n return $processor->get_updated_html();\n}" - } - ] -} diff --git a/datasets/suites/wp-core-v1/execution/interactivity-api.json b/datasets/suites/wp-core-v1/execution/interactivity-api.json deleted file mode 100644 index fbd804c..0000000 --- a/datasets/suites/wp-core-v1/execution/interactivity-api.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "id": "wp-core-execution-v1-interactivity_api", - "version": "1.1.0", - "metadata": { - "name": "WordPress Core Execution Tests - Interactivity API", - "description": "Code generation tasks for WordPress Interactivity API", - "wp_version": "6.9", - "created_at": "2025-12-16" - }, - "tests": [ - { - "id": "e-interactivity-client-nav-001", - "category": "interactivity-api", - "difficulty": "hard", - "prompt": "Register a script module 'demo/nav' and mark it as client-navigation-compatible so it loads on SPA transitions. Prove the script tag contains data-wp-router-options with loadOnClientNavigation true.", - "expected_behavior": "Enqueuing the module prints a script tag with data-wp-router-options including \\\"loadOnClientNavigation\\\":true.", - "requirements": [ - "Call wp_register_script_module to register 'demo/nav' with a placeholder file", - "Use wp_interactivity()->add_client_navigation_support_to_script_module('demo/nav')", - "Enqueue the module so wp_print_script_modules outputs it", - "Script tag must include data-wp-router-options with loadOnClientNavigation true" - ], - "static_checks": { - "required_patterns": [ - { "pattern": "wp_register_script_module", "description": "Registers script module", "weight": 1.0 }, - { "pattern": "add_client_navigation_support_to_script_module", "description": "Marks module for client navigation", "weight": 0.8 }, - { "pattern": "wp_enqueue_script_module", "description": "Enqueues module", "weight": 0.6 } - ], - "forbidden_patterns": [ - { "pattern": "wp_enqueue_script\\s*\\(", "description": "Must use module API, not classic scripts", "severity": "warning" } - ] - }, - "runtime_checks": { - "assertions": [ - { - "type": "custom_assertion", - "code": "if ( ! function_exists('wp_register_script_module') ) { return false; } ob_start(); wp_enqueue_script_module( 'demo/nav' ); wp_print_script_modules(); $html = ob_get_clean(); return str_contains( $html, 'demo/nav' ) && str_contains( $html, 'data-wp-router-options' ) && str_contains( $html, 'loadOnClientNavigation' );", - "description": "Script tag contains client navigation directive", - "weight": 1.0 - } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "add_action( 'init', function() {\n wp_register_script_module( 'demo/nav', includes_url( 'js/wp-util.js' ) ); // placeholder URL available in core.\n wp_interactivity()->add_client_navigation_support_to_script_module( 'demo/nav' );\n wp_enqueue_script_module( 'demo/nav' );\n} );" - }, - { - "id": "e-interactivity-router-replace-001", - "category": "interactivity-api", - "difficulty": "hard", - "prompt": "Create wpbp_router_link($url, $text) that outputs an anchor using the Interactivity API router with history replacement and intent prefetch.", - "expected_behavior": "Returns with data-wp-router-replace=\"true\", data-wp-router-prefetch=\"intent\", href set to $url, and inner text.", - "requirements": [ - "Return the HTML string (do not echo)", - "Include data-wp-router-replace=\"true\" and data-wp-router-prefetch=\"intent\" attributes", - "Escape URL and text", - "Include rel=\"nofollow\" when URL is external (scheme not matching home_url scheme/host)" - ], - "static_checks": { - "required_patterns": [ - { "pattern": "data-wp-router-replace", "description": "Uses router replace attribute", "weight": 1.0 }, - { "pattern": "data-wp-router-prefetch", "description": "Prefetch intent attribute", "weight": 0.6 }, - { "pattern": "esc_url", "description": "Escapes URL", "weight": 0.6 } - ] - }, - "runtime_checks": { - "assertions": [ - { - "type": "custom_assertion", - "code": "if ( ! function_exists('wpbp_router_link') ) { return false; } $html = wpbp_router_link( 'https://example.com/path', 'Go' ); return str_contains($html,'data-wp-router-replace=\"true\"') && str_contains($html,'data-wp-router-prefetch=\"intent\"') && str_contains($html,'href=\"https://example.com/path\"') && str_contains($html,'>Go<') && str_contains($html,'rel=\"nofollow\"');", - "description": "Has router attrs and rel on external", - "weight": 1.0 - } - ] - }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "function wpbp_router_link( string $url, string $text ): string {\n $home = wp_parse_url( home_url() );\n $target = wp_parse_url( $url );\n $is_external = $target && ( ($target['host'] ?? '') !== ($home['host'] ?? '') || ($target['scheme'] ?? '') !== ($home['scheme'] ?? '') );\n $rel = $is_external ? ' rel=\"nofollow\"' : '';\n return sprintf(\n '%s',\n esc_url( $url ),\n $rel,\n esc_html( $text )\n );\n}" - } - ] -} diff --git a/datasets/suites/wp-core-v1/execution/internationalization.json b/datasets/suites/wp-core-v1/execution/internationalization.json new file mode 100644 index 0000000..12664d0 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/internationalization.json @@ -0,0 +1,237 @@ +{ + "id": "wp-core-execution-v1-internationalization", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Internationalization", + "description": "Code generation tasks for WordPress Internationalization APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-internationalization-001", + "category": "internationalization", + "difficulty": "intermediate", + "prompt": "Implement wpbp_internationalization_001() to translate a string in a text domain.", + "expected_behavior": "Reviewer contract: `wpbp_internationalization_001()` must translate a string in a text domain. Review focus: Use WordPress i18n APIs; Preserve text domains where applicable. Static checks intentionally require __. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress i18n APIs", + "Preserve text domains where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_internationalization_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "__", + "description": "Uses __", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_internationalization_001' ) ) { return false; } return 'Posts' === wpbp_internationalization_001( 'Posts' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_internationalization_001( string $text ): string { return __( $text, 'default' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/l10n.php", + "src/wp-includes/class-wp-locale-switcher.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-internationalization-002", + "category": "internationalization", + "difficulty": "intermediate", + "prompt": "Implement wpbp_internationalization_002() to escape a translated string for HTML output.", + "expected_behavior": "Reviewer contract: `wpbp_internationalization_002()` must escape a translated string for HTML output. Review focus: Use WordPress i18n APIs; Preserve text domains where applicable. Static checks intentionally require esc_html__. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress i18n APIs", + "Preserve text domains where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_internationalization_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "esc_html__", + "description": "Uses esc_html__", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_internationalization_002' ) ) { return false; } return 'Posts' === wpbp_internationalization_002( 'Posts' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_internationalization_002( string $text ): string { return esc_html__( $text, 'default' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/l10n.php", + "src/wp-includes/class-wp-locale-switcher.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-internationalization-003", + "category": "internationalization", + "difficulty": "intermediate", + "prompt": "Implement wpbp_internationalization_003() to switch locale and restore the previous locale.", + "expected_behavior": "Reviewer contract: `wpbp_internationalization_003()` must switch locale and restore the previous locale. Review focus: Use WordPress i18n APIs; Preserve text domains where applicable. Static checks intentionally require switch_to_locale, restore_previous_locale. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress i18n APIs", + "Preserve text domains where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_internationalization_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "switch_to_locale", + "description": "Uses switch_to_locale", + "weight": 1 + }, + { + "pattern": "restore_previous_locale", + "description": "Uses restore_previous_locale", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_internationalization_003' ) ) { return false; } return is_bool( wpbp_internationalization_003( 'en_US' ) );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_internationalization_003( string $locale ): bool { $switched = switch_to_locale( $locale ); restore_previous_locale(); return (bool) $switched; }", + "metadata": { + "source_refs": [ + "src/wp-includes/l10n.php", + "src/wp-includes/class-wp-locale-switcher.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-internationalization-004", + "category": "internationalization", + "difficulty": "intermediate", + "prompt": "Implement wpbp_internationalization_004() to load plugin textdomain from a relative languages directory.", + "expected_behavior": "Reviewer contract: `wpbp_internationalization_004()` must load plugin textdomain from a relative languages directory. Review focus: Use WordPress i18n APIs; Preserve text domains where applicable. Static checks intentionally require load_plugin_textdomain. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress i18n APIs", + "Preserve text domains where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_internationalization_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "load_plugin_textdomain", + "description": "Uses load_plugin_textdomain", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_internationalization_004' ) ) { return false; } return is_bool( wpbp_internationalization_004( 'wpbp-domain' ) );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_internationalization_004( string $domain ): bool { return load_plugin_textdomain( $domain, false, 'wp-bench-runtime/languages' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/l10n.php", + "src/wp-includes/class-wp-locale-switcher.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-internationalization-005", + "category": "internationalization", + "difficulty": "intermediate", + "prompt": "Implement wpbp_internationalization_005() to apply the gettext filter for a specific source string.", + "expected_behavior": "Reviewer contract: `wpbp_internationalization_005()` must apply the gettext filter for a specific source string. Review focus: Use WordPress i18n APIs; Preserve text domains where applicable. Static checks intentionally require gettext, apply_filters. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress i18n APIs", + "Preserve text domains where applicable" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_internationalization_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "gettext", + "description": "Uses gettext", + "weight": 1 + }, + { + "pattern": "apply_filters", + "description": "Uses apply_filters", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_internationalization_005' ) ) { return false; } add_filter( 'gettext', function( $translation, $text ) { return 'WPBP Source' === $text ? 'Changed' : $translation; }, 10, 2 ); return 'Changed' === wpbp_internationalization_005( 'WPBP Source' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_internationalization_005( string $text ): string { return apply_filters( 'gettext', $text, $text, 'default' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/l10n.php", + "src/wp-includes/class-wp-locale-switcher.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/mail-url.json b/datasets/suites/wp-core-v1/execution/mail-url.json new file mode 100644 index 0000000..5165730 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/mail-url.json @@ -0,0 +1,189 @@ +{ + "id": "wp-core-execution-v1-mail_url", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Mail and URL Handling", + "description": "Code generation tasks for WordPress Mail and URL Handling APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-mail-url-001", + "category": "mail-url", + "difficulty": "intermediate", + "prompt": "Implement wpbp_mail_url_001() to sanitize a URL with HTTPS preferred as the default scheme.", + "expected_behavior": "Reviewer contract: `wpbp_mail_url_001()` must sanitize a URL with HTTPS preferred as the default scheme. Review focus: Use WordPress mail or URL helpers; Keep behavior deterministic. Static checks intentionally require sanitize_url. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress mail or URL helpers", + "Keep behavior deterministic" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_mail_url_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "sanitize_url", + "description": "Uses sanitize_url", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_mail_url_001' ) ) { return false; } return str_starts_with( wpbp_mail_url_001( 'example.org' ), 'https://example.org' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_mail_url_001( string $url ): string { return sanitize_url( $url, array( 'https', 'http' ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/pluggable.php", + "src/wp-includes/formatting.php" + ], + "release_focus": "6.9" + } + }, + { + "id": "e-mail-url-002", + "category": "mail-url", + "difficulty": "intermediate", + "prompt": "Implement wpbp_mail_url_002() to validate an email address and return the normalized address.", + "expected_behavior": "Reviewer contract: `wpbp_mail_url_002()` must validate an email address and return the normalized address. Review focus: Use WordPress mail or URL helpers; Keep behavior deterministic. Static checks intentionally require is_email. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress mail or URL helpers", + "Keep behavior deterministic" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_mail_url_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "is_email", + "description": "Uses is_email", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_mail_url_002' ) ) { return false; } return 'person@example.com' === wpbp_mail_url_002( 'person@example.com' ) && false === wpbp_mail_url_002( 'bad@' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_mail_url_002( string $email ): string|false { return is_email( $email ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/pluggable.php", + "src/wp-includes/formatting.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-mail-url-003", + "category": "mail-url", + "difficulty": "intermediate", + "prompt": "Implement wpbp_mail_url_003() to build a safe redirect URL against allowed hosts.", + "expected_behavior": "Reviewer contract: `wpbp_mail_url_003()` must build a safe redirect URL against allowed hosts. Review focus: Use WordPress mail or URL helpers; Keep behavior deterministic. Static checks intentionally require wp_sanitize_redirect. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress mail or URL helpers", + "Keep behavior deterministic" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_mail_url_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_sanitize_redirect", + "description": "Uses wp_sanitize_redirect", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_mail_url_003' ) ) { return false; } $out = wpbp_mail_url_003( \"https://example.com/a b\" ); return ! str_contains( $out, ' ' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_mail_url_003( string $url ): string { return wp_sanitize_redirect( $url ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/pluggable.php", + "src/wp-includes/formatting.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-mail-url-004", + "category": "mail-url", + "difficulty": "intermediate", + "prompt": "Implement wpbp_mail_url_004() to send mail through pre_wp_mail filter for deterministic testing.", + "expected_behavior": "Reviewer contract: `wpbp_mail_url_004()` must send mail through pre_wp_mail filter for deterministic testing. Review focus: Use WordPress mail or URL helpers; Keep behavior deterministic. Static checks intentionally require wp_mail, pre_wp_mail. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress mail or URL helpers", + "Keep behavior deterministic" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_mail_url_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_mail", + "description": "Uses wp_mail", + "weight": 1 + }, + { + "pattern": "pre_wp_mail", + "description": "Uses pre_wp_mail", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_mail_url_004' ) ) { return false; } return wpbp_mail_url_004( 'nobody@example.com', 'Subject' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_mail_url_004( string $to, string $subject ): bool { add_filter( 'pre_wp_mail', fn() => true ); $sent = wp_mail( $to, $subject, 'Body' ); remove_all_filters( 'pre_wp_mail' ); return $sent; }", + "metadata": { + "source_refs": [ + "src/wp-includes/pluggable.php", + "src/wp-includes/formatting.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/media.json b/datasets/suites/wp-core-v1/execution/media.json new file mode 100644 index 0000000..8b22b06 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/media.json @@ -0,0 +1,233 @@ +{ + "id": "wp-core-execution-v1-media", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Media", + "description": "Code generation tasks for WordPress Media APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-media-001", + "category": "media", + "difficulty": "intermediate", + "prompt": "Implement wpbp_media_001() to return an attachment image src array for a known attachment.", + "expected_behavior": "Reviewer contract: `wpbp_media_001()` must return an attachment image src array for a known attachment. Review focus: Use WordPress media APIs; Do not parse attachment data manually. Static checks intentionally require wp_get_attachment_image_src. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress media APIs", + "Do not parse attachment data manually" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_media_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_get_attachment_image_src", + "description": "Uses wp_get_attachment_image_src", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_media_001' ) ) { return false; } $p = wp_insert_attachment( array( 'post_title' => 'Media', 'post_mime_type' => 'image/jpeg', 'guid' => 'https://example.test/a.jpg' ) ); update_post_meta( $p, '_wp_attached_file', 'a.jpg' ); update_post_meta( $p, '_wp_attachment_metadata', array( 'width' => 100, 'height' => 100, 'file' => 'a.jpg', 'sizes' => array() ) ); $out = wpbp_media_001( $p, 'full' ); $ok = is_array( $out ) && 100 === $out[1]; wp_delete_attachment( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_media_001( int $attachment_id, string $size = 'thumbnail' ): array|false { return wp_get_attachment_image_src( $attachment_id, $size ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/media.php", + "src/wp-admin/includes/image.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-media-002", + "category": "media", + "difficulty": "intermediate", + "prompt": "Implement wpbp_media_002() to filter content image tags through wp_filter_content_tags.", + "expected_behavior": "Reviewer contract: `wpbp_media_002()` must filter content image tags through wp_filter_content_tags. Review focus: Use WordPress media APIs; Do not parse attachment data manually. Static checks intentionally require wp_filter_content_tags. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress media APIs", + "Do not parse attachment data manually" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_media_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_filter_content_tags", + "description": "Uses wp_filter_content_tags", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_media_002' ) ) { return false; } $out = wpbp_media_002( '

' ); return str_contains( $out, ' 'Meta', 'post_status' => 'publish' ) ); $ok = 1 === wpbp_post_meta_001( $p ) && 2 === wpbp_post_meta_001( $p ); wp_delete_post( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_meta_001( int $post_id ): int { $count = (int) get_post_meta( $post_id, '_wpbp_count', true ); $count++; update_post_meta( $post_id, '_wpbp_count', $count ); return $count; }", + "metadata": { + "source_refs": [ + "src/wp-includes/meta.php", + "src/wp-includes/post.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-meta-002", + "category": "post-meta", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_meta_002() to register protected string post meta for REST exposure.", + "expected_behavior": "Reviewer contract: `wpbp_post_meta_002()` must register protected string post meta for REST exposure. Review focus: Use WordPress metadata APIs; Preserve type and sanitization behavior. Static checks intentionally require register_post_meta, show_in_rest. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress metadata APIs", + "Preserve type and sanitization behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_meta_002", + "description": "Defines the requested function", "weight": 0.5 }, { - "pattern": "_view_count", - "description": "Must use correct meta key", + "pattern": "register_post_meta", + "description": "Uses register_post_meta", + "weight": 1 + }, + { + "pattern": "show_in_rest", + "description": "Uses show_in_rest", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_meta_002' ) ) { return false; } return true === wpbp_post_meta_002();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_meta_002(): bool { return register_post_meta( 'post', '_wpbp_subtitle', array( 'type' => 'string', 'single' => true, 'show_in_rest' => true, 'sanitize_callback' => 'sanitize_text_field', 'auth_callback' => '__return_true' ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/meta.php", + "src/wp-includes/post.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-meta-003", + "category": "post-meta", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_meta_003() to delete a post meta key only when the stored value matches.", + "expected_behavior": "Reviewer contract: `wpbp_post_meta_003()` must delete a post meta key only when the stored value matches. Review focus: Use WordPress metadata APIs; Preserve type and sanitization behavior. Static checks intentionally require delete_post_meta. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress metadata APIs", + "Preserve type and sanitization behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_meta_003", + "description": "Defines the requested function", "weight": 0.5 + }, + { + "pattern": "delete_post_meta", + "description": "Uses delete_post_meta", + "weight": 1 } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_meta_003' ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'Delete Meta', 'post_status' => 'publish' ) ); update_post_meta( $p, '_wpbp_token', 'abc' ); $ok = ! wpbp_post_meta_003( $p, 'wrong' ) && wpbp_post_meta_003( $p, 'abc' ); wp_delete_post( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_meta_003( int $post_id, string $value ): bool { return delete_post_meta( $post_id, '_wpbp_token', $value ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/meta.php", + "src/wp-includes/post.php" ], - "forbidden_patterns": [ + "release_focus": "classic" + } + }, + { + "id": "e-post-meta-004", + "category": "post-meta", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_meta_004() to read all values for a multi-value post meta key.", + "expected_behavior": "Reviewer contract: `wpbp_post_meta_004()` must read all values for a multi-value post meta key. Review focus: Use WordPress metadata APIs; Preserve type and sanitization behavior. Static checks intentionally require get_post_meta. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress metadata APIs", + "Preserve type and sanitization behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_meta_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "get_post_meta", + "description": "Uses get_post_meta", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_meta_004' ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'Multi Meta', 'post_status' => 'publish' ) ); add_post_meta( $p, '_wpbp_multi', 'a' ); add_post_meta( $p, '_wpbp_multi', 'b' ); $ok = array( 'a', 'b' ) === wpbp_post_meta_004( $p ); wp_delete_post( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_meta_004( int $post_id ): array { return get_post_meta( $post_id, '_wpbp_multi', false ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/meta.php", + "src/wp-includes/post.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-meta-005", + "category": "post-meta", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_meta_005() to update post meta after slashing JSON-like text.", + "expected_behavior": "Reviewer contract: `wpbp_post_meta_005()` must update post meta after slashing JSON-like text. Review focus: Use WordPress metadata APIs; Preserve type and sanitization behavior. Static checks intentionally require wp_slash, update_post_meta. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress metadata APIs", + "Preserve type and sanitization behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_meta_005", + "description": "Defines the requested function", + "weight": 0.5 + }, { - "pattern": "\\$wpdb->", - "description": "Should use WordPress meta functions, not direct queries", - "severity": "warning" + "pattern": "wp_slash", + "description": "Uses wp_slash", + "weight": 1 + }, + { + "pattern": "update_post_meta", + "description": "Uses update_post_meta", + "weight": 1 } ] }, "runtime_checks": { "assertions": [ { - "type": "function_exists", - "target": "save_view_count", - "description": "Function must exist", - "weight": 1.0 + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_meta_005' ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'Slash Meta', 'post_status' => 'publish' ) ); $json = '{\"a\":\"b\"}'; $ok = $json === wpbp_post_meta_005( $p, $json ); wp_delete_post( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 } ] }, - "judge_config": { - "rubric_id": "wp-judge-rubric-v1" + "reference_solution": "function wpbp_post_meta_005( int $post_id, string $json ): string { update_post_meta( $post_id, '_wpbp_json', wp_slash( $json ) ); return get_post_meta( $post_id, '_wpbp_json', true ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/meta.php", + "src/wp-includes/post.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-meta-006", + "category": "post-meta", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_meta_006() to register object subtype meta with a default value.", + "expected_behavior": "Reviewer contract: `wpbp_post_meta_006()` must register object subtype meta with a default value. Review focus: Use WordPress metadata APIs; Preserve type and sanitization behavior. Static checks intentionally require register_meta, object_subtype. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress metadata APIs", + "Preserve type and sanitization behavior" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_meta_006", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_meta", + "description": "Uses register_meta", + "weight": 1 + }, + { + "pattern": "object_subtype", + "description": "Uses object_subtype", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_meta_006' ) ) { return false; } return true === wpbp_post_meta_006();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_meta_006(): bool { return register_meta( 'post', '_wpbp_rating', array( 'object_subtype' => 'post', 'type' => 'integer', 'single' => true, 'default' => 0, 'show_in_rest' => true ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/meta.php", + "src/wp-includes/post.php" + ], + "release_focus": "classic" } } ] diff --git a/datasets/suites/wp-core-v1/execution/post-types-taxonomy.json b/datasets/suites/wp-core-v1/execution/post-types-taxonomy.json new file mode 100644 index 0000000..a5fea02 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/post-types-taxonomy.json @@ -0,0 +1,386 @@ +{ + "id": "wp-core-execution-v1-post_types_taxonomy", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Post Types and Taxonomy", + "description": "Code generation tasks for WordPress Post Types and Taxonomy APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-post-types-taxonomy-001", + "category": "post-types-taxonomy", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_types_taxonomy_001() to register a public book post type with REST support.", + "expected_behavior": "Reviewer contract: `wpbp_post_types_taxonomy_001()` must register a public book post type with REST support. Review focus: Use registration APIs; Clean up registered types when possible. Static checks intentionally require register_post_type, show_in_rest. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use registration APIs", + "Clean up registered types when possible" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_types_taxonomy_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_post_type", + "description": "Uses register_post_type", + "weight": 1 + }, + { + "pattern": "show_in_rest", + "description": "Uses show_in_rest", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_001' ) ) { return false; } $ok = wpbp_post_types_taxonomy_001(); unregister_post_type( 'wpbp_book' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_types_taxonomy_001(): bool { register_post_type( 'wpbp_book', array( 'public' => true, 'show_in_rest' => true, 'label' => 'Books' ) ); return post_type_exists( 'wpbp_book' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/post.php", + "src/wp-includes/taxonomy.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-types-taxonomy-002", + "category": "post-types-taxonomy", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_types_taxonomy_002() to register a hierarchical genre taxonomy for posts.", + "expected_behavior": "Reviewer contract: `wpbp_post_types_taxonomy_002()` must register a hierarchical genre taxonomy for posts. Review focus: Use registration APIs; Clean up registered types when possible. Static checks intentionally require register_taxonomy, hierarchical. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use registration APIs", + "Clean up registered types when possible" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_types_taxonomy_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_taxonomy", + "description": "Uses register_taxonomy", + "weight": 1 + }, + { + "pattern": "hierarchical", + "description": "Uses hierarchical", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_002' ) ) { return false; } $ok = wpbp_post_types_taxonomy_002(); unregister_taxonomy( 'wpbp_genre' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_types_taxonomy_002(): bool { register_taxonomy( 'wpbp_genre', 'post', array( 'hierarchical' => true, 'show_in_rest' => true, 'label' => 'Genres' ) ); return taxonomy_exists( 'wpbp_genre' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/post.php", + "src/wp-includes/taxonomy.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-types-taxonomy-003", + "category": "post-types-taxonomy", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_types_taxonomy_003() to attach an existing taxonomy to a custom post type.", + "expected_behavior": "Reviewer contract: `wpbp_post_types_taxonomy_003()` must attach an existing taxonomy to a custom post type. Review focus: Use registration APIs; Clean up registered types when possible. Static checks intentionally require register_taxonomy_for_object_type. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use registration APIs", + "Clean up registered types when possible" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_types_taxonomy_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_taxonomy_for_object_type", + "description": "Uses register_taxonomy_for_object_type", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_003' ) ) { return false; } return wpbp_post_types_taxonomy_003();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_types_taxonomy_003(): bool { register_post_type( 'wpbp_movie' ); register_taxonomy( 'wpbp_topic', 'post' ); $ok = register_taxonomy_for_object_type( 'wpbp_topic', 'wpbp_movie' ); unregister_post_type( 'wpbp_movie' ); unregister_taxonomy( 'wpbp_topic' ); return $ok; }", + "metadata": { + "source_refs": [ + "src/wp-includes/post.php", + "src/wp-includes/taxonomy.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-types-taxonomy-004", + "category": "post-types-taxonomy", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_types_taxonomy_004() to create a post type with custom capabilities mapped from meta caps.", + "expected_behavior": "Reviewer contract: `wpbp_post_types_taxonomy_004()` must create a post type with custom capabilities mapped from meta caps. Review focus: Use registration APIs; Clean up registered types when possible. Static checks intentionally require capability_type, map_meta_cap. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use registration APIs", + "Clean up registered types when possible" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_types_taxonomy_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "capability_type", + "description": "Uses capability_type", + "weight": 1 + }, + { + "pattern": "map_meta_cap", + "description": "Uses map_meta_cap", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_004' ) ) { return false; } return array( 'edit_case', 'edit_cases' ) === wpbp_post_types_taxonomy_004();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_types_taxonomy_004(): array { register_post_type( 'wpbp_case', array( 'capability_type' => array( 'case', 'cases' ), 'map_meta_cap' => true ) ); $caps = get_post_type_object( 'wpbp_case' )->cap; unregister_post_type( 'wpbp_case' ); return array( $caps->edit_post, $caps->edit_posts ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/post.php", + "src/wp-includes/taxonomy.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-types-taxonomy-005", + "category": "post-types-taxonomy", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_types_taxonomy_005() to insert a term and return its slug and taxonomy.", + "expected_behavior": "Reviewer contract: `wpbp_post_types_taxonomy_005()` must insert a term and return its slug and taxonomy. Review focus: Use registration APIs; Clean up registered types when possible. Static checks intentionally require wp_insert_term, get_term. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use registration APIs", + "Clean up registered types when possible" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_types_taxonomy_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_insert_term", + "description": "Uses wp_insert_term", + "weight": 1 + }, + { + "pattern": "get_term", + "description": "Uses get_term", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_005' ) ) { return false; } $out = wpbp_post_types_taxonomy_005( 'WPBP Term Insert ' . wp_rand() ); $ok = is_array( $out ) && 'category' === $out[1]; wp_delete_term( $out[2], 'category' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_types_taxonomy_005( string $name ): array { $term = wp_insert_term( $name, 'category' ); if ( is_wp_error( $term ) ) { return array( '', '', 0 ); } return array( get_term_field( 'slug', $term['term_id'], 'category' ), get_term( $term['term_id'] )->taxonomy, $term['term_id'] ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/post.php", + "src/wp-includes/taxonomy.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-types-taxonomy-006", + "category": "post-types-taxonomy", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_types_taxonomy_006() to set object terms without replacing existing terms.", + "expected_behavior": "Reviewer contract: `wpbp_post_types_taxonomy_006()` must set object terms without replacing existing terms. Review focus: Use registration APIs; Clean up registered types when possible. Static checks intentionally require wp_set_object_terms. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use registration APIs", + "Clean up registered types when possible" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_types_taxonomy_006", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_set_object_terms", + "description": "Uses wp_set_object_terms", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_006' ) ) { return false; } $suffix = (string) wp_rand(); $t = wp_insert_term( 'WPBP Append ' . $suffix, 'category', array( 'slug' => 'wpbp-append-' . $suffix ) ); if ( is_wp_error( $t ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'Terms ' . $suffix, 'post_status' => 'publish' ) ); $ids = wpbp_post_types_taxonomy_006( $p, array( (int) $t['term_id'] ) ); $ok = in_array( (int) $t['term_id'], array_map( 'intval', $ids ), true ); wp_delete_post( $p, true ); wp_delete_term( $t['term_id'], 'category' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_types_taxonomy_006( int $post_id, array $terms ): array { return wp_set_object_terms( $post_id, $terms, 'category', true ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/post.php", + "src/wp-includes/taxonomy.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-types-taxonomy-007", + "category": "post-types-taxonomy", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_types_taxonomy_007() to read a post type archive link for a public CPT.", + "expected_behavior": "Reviewer contract: `wpbp_post_types_taxonomy_007()` must read a post type archive link for a public CPT. Review focus: Use registration APIs; Clean up registered types when possible. Static checks intentionally require get_post_type_archive_link, has_archive. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use registration APIs", + "Clean up registered types when possible" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_types_taxonomy_007", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "get_post_type_archive_link", + "description": "Uses get_post_type_archive_link", + "weight": 1 + }, + { + "pattern": "has_archive", + "description": "Uses has_archive", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_007' ) ) { return false; } $link = wpbp_post_types_taxonomy_007(); return str_contains( $link, 'wpbp_archive' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_types_taxonomy_007(): string { register_post_type( 'wpbp_archive', array( 'public' => true, 'has_archive' => true ) ); $link = get_post_type_archive_link( 'wpbp_archive' ); unregister_post_type( 'wpbp_archive' ); return (string) $link; }", + "metadata": { + "source_refs": [ + "src/wp-includes/post.php", + "src/wp-includes/taxonomy.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-post-types-taxonomy-008", + "category": "post-types-taxonomy", + "difficulty": "intermediate", + "prompt": "Implement wpbp_post_types_taxonomy_008() to register a taxonomy with a custom REST base.", + "expected_behavior": "Reviewer contract: `wpbp_post_types_taxonomy_008()` must register a taxonomy with a custom REST base. Review focus: Use registration APIs; Clean up registered types when possible. Static checks intentionally require register_taxonomy, rest_base. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use registration APIs", + "Clean up registered types when possible" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_post_types_taxonomy_008", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "register_taxonomy", + "description": "Uses register_taxonomy", + "weight": 1 + }, + { + "pattern": "rest_base", + "description": "Uses rest_base", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_008' ) ) { return false; } return 'wpbp-tax' === wpbp_post_types_taxonomy_008();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_post_types_taxonomy_008(): string { register_taxonomy( 'wpbp_rest_tax', 'post', array( 'show_in_rest' => true, 'rest_base' => 'wpbp-tax' ) ); $base = get_taxonomy( 'wpbp_rest_tax' )->rest_base; unregister_taxonomy( 'wpbp_rest_tax' ); return $base; }", + "metadata": { + "source_refs": [ + "src/wp-includes/post.php", + "src/wp-includes/taxonomy.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/queries.json b/datasets/suites/wp-core-v1/execution/queries.json new file mode 100644 index 0000000..ad106c0 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/queries.json @@ -0,0 +1,600 @@ +{ + "id": "wp-core-execution-v1-queries", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Queries", + "description": "Code generation tasks for WordPress Queries APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-queries-001", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_001() to return recent published posts by category slug with no_found_rows.", + "expected_behavior": "Reviewer contract: `wpbp_queries_001()` must return recent published posts by category slug with no_found_rows. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require WP_Query, no_found_rows. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Query", + "description": "Uses WP_Query", + "weight": 1 + }, + { + "pattern": "no_found_rows", + "description": "Uses no_found_rows", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_001' ) ) { return false; } $suffix = (string) wp_rand(); $slug = 'wpbp-news-' . $suffix; $cat = wp_insert_term( 'WPBP News ' . $suffix, 'category', array( 'slug' => $slug ) ); if ( is_wp_error( $cat ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Q1 ' . $suffix, 'post_status' => 'publish', 'post_category' => array( $cat['term_id'] ) ) ); $q = wpbp_queries_001( $slug, 3 ); $ok = in_array( $id, wp_list_pluck( $q->posts, 'ID' ), true ); wp_delete_post( $id, true ); wp_delete_term( $cat['term_id'], 'category' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_001( string $slug, int $limit = 5 ): WP_Query { return new WP_Query( array( 'category_name' => $slug, 'posts_per_page' => $limit, 'post_status' => 'publish', 'no_found_rows' => true ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-002", + "category": "queries", + "difficulty": "hard", + "prompt": "Implement wpbp_queries_002() to query posts whose numeric price_cents meta is exactly zero.", + "expected_behavior": "Reviewer contract: `wpbp_queries_002()` must query posts whose numeric price_cents meta is exactly zero. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require WP_Query, meta_query, NUMERIC. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Query", + "description": "Uses WP_Query", + "weight": 1 + }, + { + "pattern": "meta_query", + "description": "Uses meta_query", + "weight": 1 + }, + { + "pattern": "NUMERIC", + "description": "Uses NUMERIC", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_002' ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Free', 'post_status' => 'publish' ) ); update_post_meta( $id, 'price_cents', '0' ); $q = wpbp_queries_002(); $ok = in_array( $id, wp_list_pluck( $q->posts, 'ID' ), true ); wp_delete_post( $id, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_002(): WP_Query { return new WP_Query( array( 'post_type' => 'post', 'post_status' => 'publish', 'meta_query' => array( array( 'key' => 'price_cents', 'value' => 0, 'compare' => '=', 'type' => 'NUMERIC' ) ) ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-003", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_003() to return only post IDs for a search query.", + "expected_behavior": "Reviewer contract: `wpbp_queries_003()` must return only post IDs for a search query. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require WP_Query, fields. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Query", + "description": "Uses WP_Query", + "weight": 1 + }, + { + "pattern": "fields", + "description": "Uses fields", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_003' ) ) { return false; } $needle = 'Needle' . wp_rand(); $id = wp_insert_post( array( 'post_title' => $needle . ' Alpha', 'post_status' => 'publish' ) ); $ids = wpbp_queries_003( $needle ); $ok = in_array( $id, $ids, true ); wp_delete_post( $id, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_003( string $term ): array { $q = new WP_Query( array( 's' => $term, 'fields' => 'ids', 'post_status' => 'publish' ) ); return $q->posts; }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-004", + "category": "queries", + "difficulty": "hard", + "prompt": "Implement wpbp_queries_004() to query posts using a nested AND tax query.", + "expected_behavior": "Reviewer contract: `wpbp_queries_004()` must query posts using a nested AND tax query. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require WP_Query, tax_query, relation. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Query", + "description": "Uses WP_Query", + "weight": 1 + }, + { + "pattern": "tax_query", + "description": "Uses tax_query", + "weight": 1 + }, + { + "pattern": "relation", + "description": "Uses relation", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_004' ) ) { return false; } $suffix = (string) wp_rand(); $term = wp_insert_term( 'WPBP Tax ' . $suffix, 'category', array( 'slug' => 'wpbp-tax-' . $suffix ) ); if ( is_wp_error( $term ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Tax ' . $suffix, 'post_status' => 'publish' ) ); wp_set_post_terms( $id, array( $term['term_id'] ), 'category' ); $q = wpbp_queries_004( 'category', $term['term_id'] ); $ok = in_array( $id, wp_list_pluck( $q->posts, 'ID' ), true ); wp_delete_post( $id, true ); wp_delete_term( $term['term_id'], 'category' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_004( string $taxonomy, int $term_id ): WP_Query { return new WP_Query( array( 'post_status' => 'publish', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => $taxonomy, 'field' => 'term_id', 'terms' => array( $term_id ) ) ) ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-005", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_005() to query future posts after a supplied date.", + "expected_behavior": "Reviewer contract: `wpbp_queries_005()` must query scheduled future posts after the supplied date. Review focus: Use WP_Query; Build a date_query with the supplied lower bound; Include future post status rather than relying on published posts. Static checks intentionally require WP_Query, date_query. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Query", + "description": "Uses WP_Query", + "weight": 1 + }, + { + "pattern": "date_query", + "description": "Uses date_query", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_005' ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Date ' . wp_rand(), 'post_status' => 'future', 'post_date' => '2099-01-05 00:00:00' ) ); $q = wpbp_queries_005( '2099-01-01' ); $ok = in_array( $id, wp_list_pluck( $q->posts, 'ID' ), true ); wp_delete_post( $id, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_005( string $after ): WP_Query { return new WP_Query( array( 'post_status' => 'future', 'posts_per_page' => -1, 'date_query' => array( array( 'after' => $after, 'inclusive' => true ) ) ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-006", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_006() to build a WP_User_Query for users matching a role.", + "expected_behavior": "Reviewer contract: `wpbp_queries_006()` must build a WP_User_Query for users matching a role. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require WP_User_Query, role. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_006", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_User_Query", + "description": "Uses WP_User_Query", + "weight": 1 + }, + { + "pattern": "role", + "description": "Uses role", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_006' ) ) { return false; } $u = wp_insert_user( array( 'user_login' => 'wpbp_query_user_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); $q = wpbp_queries_006( 'subscriber' ); $ok = in_array( $u, array_map( 'intval', $q->get_results() ), true ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_006( string $role ): WP_User_Query { return new WP_User_Query( array( 'role' => $role, 'fields' => 'ID' ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-007", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_007() to return comments for a post using WP_Comment_Query.", + "expected_behavior": "Reviewer contract: `wpbp_queries_007()` must return comments for a post using WP_Comment_Query. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require WP_Comment_Query. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_007", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Comment_Query", + "description": "Uses WP_Comment_Query", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_007' ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'Commented', 'post_status' => 'publish' ) ); $c = wp_insert_comment( array( 'comment_post_ID' => $p, 'comment_content' => 'Hi', 'comment_approved' => 1 ) ); $comments = wpbp_queries_007( $p ); $ok = in_array( $c, wp_list_pluck( $comments, 'comment_ID' ) ); wp_delete_comment( $c, true ); wp_delete_post( $p, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_007( int $post_id ): array { $q = new WP_Comment_Query( array( 'post_id' => $post_id, 'status' => 'approve' ) ); return $q->comments; }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-008", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_008() to query terms with hide_empty disabled.", + "expected_behavior": "Reviewer contract: `wpbp_queries_008()` must query terms with hide_empty disabled. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require WP_Term_Query, hide_empty. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_008", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Term_Query", + "description": "Uses WP_Term_Query", + "weight": 1 + }, + { + "pattern": "hide_empty", + "description": "Uses hide_empty", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_008' ) ) { return false; } $suffix = (string) wp_rand(); $term = wp_insert_term( 'WPBP Empty Term ' . $suffix, 'category', array( 'slug' => 'wpbp-empty-' . $suffix ) ); if ( is_wp_error( $term ) ) { return false; } $ids = wpbp_queries_008( 'category' ); $ok = in_array( (int) $term['term_id'], array_map( 'intval', $ids ), true ); wp_delete_term( $term['term_id'], 'category' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_008( string $taxonomy ): array { $q = new WP_Term_Query( array( 'taxonomy' => $taxonomy, 'hide_empty' => false, 'fields' => 'ids' ) ); return $q->terms; }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-009", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_009() to return adjacent posts constrained by taxonomy.", + "expected_behavior": "Reviewer contract: `wpbp_queries_009()` must return adjacent posts constrained by taxonomy. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require get_adjacent_post. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_009", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "get_adjacent_post", + "description": "Uses get_adjacent_post", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_009' ) ) { return false; } return function_exists( 'wpbp_queries_009' ) && null === wpbp_queries_009( true );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_009( bool $previous = true ): mixed { return get_adjacent_post( true, '', $previous, 'category' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "6.9" + } + }, + { + "id": "e-queries-010", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_010() to preload post meta cache before reading many posts.", + "expected_behavior": "Reviewer contract: `wpbp_queries_010()` must preload post meta cache before reading many posts. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require update_meta_cache, get_post_meta. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_010", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "update_meta_cache", + "description": "Uses update_meta_cache", + "weight": 1 + }, + { + "pattern": "get_post_meta", + "description": "Uses get_post_meta", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_010' ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Meta Cache', 'post_status' => 'publish' ) ); update_post_meta( $id, 'wpbp_key', 'yes' ); $out = wpbp_queries_010( array( $id ), 'wpbp_key' ); wp_delete_post( $id, true ); return $out[$id] === 'yes';", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_010( array $post_ids, string $key ): array { update_meta_cache( 'post', $post_ids ); $out = array(); foreach ( $post_ids as $post_id ) { $out[ $post_id ] = get_post_meta( $post_id, $key, true ); } return $out; }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-011", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_011() to query posts while preserving filters.", + "expected_behavior": "Reviewer contract: `wpbp_queries_011()` must query posts while preserving filters. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require get_posts, suppress_filters. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_011", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "get_posts", + "description": "Uses get_posts", + "weight": 1 + }, + { + "pattern": "suppress_filters", + "description": "Uses suppress_filters", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_011' ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Filters', 'post_status' => 'publish' ) ); $posts = wpbp_queries_011(); $ok = ! empty( $posts ); wp_delete_post( $id, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_011(): array { $posts = get_posts( array( 'numberposts' => 1, 'suppress_filters' => false, 'post_status' => 'publish' ) ); return $posts; }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-queries-012", + "category": "queries", + "difficulty": "intermediate", + "prompt": "Implement wpbp_queries_012() to return sticky posts after normal query handling.", + "expected_behavior": "Reviewer contract: `wpbp_queries_012()` must return sticky posts after normal query handling. Review focus: Use the relevant WordPress query class or helper; Return deterministic query data. Static checks intentionally require WP_Query, ignore_sticky_posts. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use the relevant WordPress query class or helper", + "Return deterministic query data" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_queries_012", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_Query", + "description": "Uses WP_Query", + "weight": 1 + }, + { + "pattern": "ignore_sticky_posts", + "description": "Uses ignore_sticky_posts", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_queries_012' ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Sticky', 'post_status' => 'publish' ) ); stick_post( $id ); $q = wpbp_queries_012(); $ok = ! empty( $q->posts ); unstick_post( $id ); wp_delete_post( $id, true ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_queries_012(): WP_Query { return new WP_Query( array( 'post_status' => 'publish', 'ignore_sticky_posts' => false, 'posts_per_page' => 1 ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/class-wp-query.php", + "src/wp-includes/class-wp-meta-query.php", + "src/wp-includes/class-wp-tax-query.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/rest-api.json b/datasets/suites/wp-core-v1/execution/rest-api.json index a03b434..2321f6b 100644 --- a/datasets/suites/wp-core-v1/execution/rest-api.json +++ b/datasets/suites/wp-core-v1/execution/rest-api.json @@ -1,99 +1,604 @@ { "id": "wp-core-execution-v1-rest_api", - "version": "1.1.0", + "version": "2.0.0", "metadata": { "name": "WordPress Core Execution Tests - REST API", - "description": "Code generation tasks for WordPress REST API development", - "wp_version": "6.9", - "created_at": "2025-12-16" + "description": "Code generation tasks for WordPress REST API APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" }, "tests": [ { - "id": "e-rest-001", + "id": "e-rest-api-001", "category": "rest-api", "difficulty": "intermediate", - "prompt": "Create a REST API endpoint at '/wp-json/myplugin/v1/status' that returns a JSON object with a 'status' key set to 'ok' and a 'timestamp' key with the current Unix timestamp. The endpoint should be publicly accessible without authentication.", - "expected_behavior": "GET request to /wp-json/myplugin/v1/status returns {\"status\": \"ok\", \"timestamp\": }", + "prompt": "Create a public REST endpoint /wp-json/wpbp/v1/status that returns a status string and numeric timestamp.", + "expected_behavior": "Reviewer contract: The submission must create a public REST endpoint /wp-json/wpbp/v1/status that returns a status string and numeric timestamp. Review focus: Register the route on rest_api_init; Use namespace wpbp/v1; Return REST data with status ok. Static checks intentionally require register_rest_route, rest_ensure_response, permission_callback. The runtime checks dispatch the route through WordPress REST internals and verify status/data behavior.", "requirements": [ - "Use register_rest_route() to register the endpoint", - "Use namespace 'myplugin/v1'", - "Route should be 'status'", - "Accept GET requests", - "Return WP_REST_Response with status and timestamp", - "Endpoint should be publicly accessible (permission_callback returns true)" + "Register the route on rest_api_init", + "Use namespace wpbp/v1", + "Return REST data with status ok", + "Use a public permission callback" ], "static_checks": { "required_patterns": [ { "pattern": "register_rest_route", - "description": "Must use register_rest_route()", - "weight": 1.0 + "description": "Uses register_rest_route", + "weight": 1 }, { - "pattern": "myplugin/v1", - "description": "Must use correct namespace", - "weight": 0.5 + "pattern": "rest_ensure_response", + "description": "Uses rest_ensure_response", + "weight": 1 + }, + { + "pattern": "permission_callback", + "description": "Uses permission_callback", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "rest_response", + "target": "/wpbp/v1/status", + "expected_status": 200, + "body_contains": "\"status\":\"ok\"", + "description": "Status endpoint responds" + } + ] + }, + "reference_solution": "add_action( 'rest_api_init', function () {\n register_rest_route( 'wpbp/v1', '/status', array(\n 'methods' => WP_REST_Server::READABLE,\n 'permission_callback' => '__return_true',\n 'callback' => function () {\n return rest_ensure_response( array( 'status' => 'ok', 'timestamp' => time() ) );\n },\n ) );\n} );", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-002", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Create a REST endpoint /wp-json/wpbp/v1/books/(?P\\d+) that validates the ID and returns it as an integer.", + "expected_behavior": "Reviewer contract: The submission must create a REST endpoint /wp-json/wpbp/v1/books/(?P\\d+) that validates the ID and returns it as an integer. Review focus: Use a route parameter named id; Validate that id is numeric; Return the id as an integer. Static checks intentionally require register_rest_route, validate_callback, WP_REST_Request. The runtime checks dispatch the route through WordPress REST internals and verify status/data behavior.", + "requirements": [ + "Use a route parameter named id", + "Validate that id is numeric", + "Return the id as an integer" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "register_rest_route", + "description": "Uses register_rest_route", + "weight": 1 + }, + { + "pattern": "validate_callback", + "description": "Uses validate_callback", + "weight": 1 + }, + { + "pattern": "WP_REST_Request", + "description": "Uses WP_REST_Request", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "rest_response", + "target": "/wpbp/v1/books/42", + "expected_status": 200, + "expected_data": { + "id": 42 + }, + "description": "ID is validated and returned" + } + ] + }, + "reference_solution": "add_action( 'rest_api_init', function () {\n register_rest_route( 'wpbp/v1', '/books/(?P\\d+)', array(\n 'methods' => WP_REST_Server::READABLE,\n 'permission_callback' => '__return_true',\n 'callback' => fn( WP_REST_Request $request ) => array( 'id' => absint( $request['id'] ) ),\n 'args' => array( 'id' => array( 'validate_callback' => fn( $value ) => is_numeric( $value ) ) ),\n ) );\n} );", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-003", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Create a private REST endpoint /wp-json/wpbp/v1/private that requires manage_options and returns secret data.", + "expected_behavior": "Reviewer contract: The submission must create a private REST endpoint /wp-json/wpbp/v1/private that requires manage_options and returns secret data. Review focus: Use current_user_can in permission_callback; Return a WP_Error-compatible forbidden response when unauthorized; Return secret true when authorized. Static checks intentionally require register_rest_route, current_user_can, permission_callback. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use current_user_can in permission_callback", + "Return a WP_Error-compatible forbidden response when unauthorized", + "Return secret true when authorized" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "register_rest_route", + "description": "Uses register_rest_route", + "weight": 1 + }, + { + "pattern": "current_user_can", + "description": "Uses current_user_can", + "weight": 1 }, { "pattern": "permission_callback", - "description": "Must include permission_callback", + "description": "Uses permission_callback", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! did_action( 'rest_api_init' ) ) { do_action( 'rest_api_init' ); } wp_set_current_user( 0 ); $response = rest_do_request( new WP_REST_Request( 'GET', '/wpbp/v1/private' ) ); return 401 === $response->get_status();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "add_action( 'rest_api_init', function () {\n register_rest_route( 'wpbp/v1', '/private', array(\n 'methods' => 'GET',\n 'permission_callback' => fn() => current_user_can( 'manage_options' ),\n 'callback' => fn() => array( 'secret' => true ),\n ) );\n} );", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-004", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Create a REST endpoint /wp-json/wpbp/v1/options that sanitizes a title parameter and returns it.", + "expected_behavior": "Reviewer contract: The submission must create a REST endpoint /wp-json/wpbp/v1/options that sanitizes a title parameter and returns it. Review focus: Accept POST requests; Declare a title argument with sanitize_callback; Return the sanitized title. Static checks intentionally require register_rest_route, sanitize_callback, sanitize_text_field. The runtime checks dispatch the route through WordPress REST internals and verify status/data behavior.", + "requirements": [ + "Accept POST requests", + "Declare a title argument with sanitize_callback", + "Return the sanitized title" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "register_rest_route", + "description": "Uses register_rest_route", + "weight": 1 + }, + { + "pattern": "sanitize_callback", + "description": "Uses sanitize_callback", + "weight": 1 + }, + { + "pattern": "sanitize_text_field", + "description": "Uses sanitize_text_field", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "rest_response", + "target": "/wpbp/v1/options", + "method": "POST", + "params": { + "title": "Hello" + }, + "expected_status": 200, + "expected_data": { + "title": "Hello" + }, + "description": "Parameter is sanitized" + } + ] + }, + "reference_solution": "add_action( 'rest_api_init', function () {\n register_rest_route( 'wpbp/v1', '/options', array(\n 'methods' => WP_REST_Server::CREATABLE,\n 'permission_callback' => '__return_true',\n 'args' => array( 'title' => array( 'sanitize_callback' => 'sanitize_text_field' ) ),\n 'callback' => fn( WP_REST_Request $request ) => array( 'title' => $request->get_param( 'title' ) ),\n ) );\n} );", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-005", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rest_api_005() to normalize a WP_Error into a REST response array with code, message, and status.", + "expected_behavior": "Reviewer contract: `wpbp_rest_api_005()` must normalize a WP_Error into a REST response array with code, message, and status. Review focus: Use rest_convert_error_to_response; Preserve the status code. Static checks intentionally require rest_convert_error_to_response, WP_Error. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use rest_convert_error_to_response", + "Preserve the status code" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rest_api_005", + "description": "Defines the requested function", "weight": 0.5 }, { - "pattern": "WP_REST_Response|rest_ensure_response", - "description": "Should return proper REST response", - "weight": 0.3 + "pattern": "rest_convert_error_to_response", + "description": "Uses rest_convert_error_to_response", + "weight": 1 + }, + { + "pattern": "WP_Error", + "description": "Uses WP_Error", + "weight": 1 } ] }, "runtime_checks": { "assertions": [ { - "type": "hook_registered", - "target": "rest_api_init", - "description": "REST route registration hook must be used", - "weight": 1.0 + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rest_api_005' ) ) { return false; } $out = wpbp_rest_api_005( new WP_Error( 'wpbp_forbidden', 'Nope', array( 'status' => 403 ) ) ); return 403 === $out['status'] && 'wpbp_forbidden' === $out['data']['code'];", + "description": "Reference behavior is correct", + "weight": 1 } ] }, - "judge_config": { - "rubric_id": "wp-judge-rubric-v1", - "context_for_judge": "This is a simple status endpoint for a health check. Security is important - ensure permission_callback is properly defined." + "reference_solution": "function wpbp_rest_api_005( WP_Error $error ): array { $response = rest_convert_error_to_response( $error ); return array( 'status' => $response->get_status(), 'data' => $response->get_data() ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" } }, { - "id": "e-rest-cache-salted-001", + "id": "e-rest-api-006", "category": "rest-api", - "difficulty": "hard", - "prompt": "Create a REST endpoint /wp-json/demo/v1/books that returns published 'book' titles and uses wp_cache_get_salted/wp_cache_set_salted keyed by the posts last_changed value. Invalidate cache on save_post_book and deleted_post.", - "expected_behavior": "First call computes and caches list; second call is a cache hit; after inserting a new book, subsequent call reflects new title and cache resets.", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rest_api_006() to ensure arbitrary callback data is converted to a WP_REST_Response.", + "expected_behavior": "Reviewer contract: `wpbp_rest_api_006()` must ensure arbitrary callback data is converted to a WP_REST_Response. Review focus: Use rest_ensure_response; Return the response status and data. Static checks intentionally require rest_ensure_response, WP_REST_Response. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", "requirements": [ - "Register route on rest_api_init with namespace demo/v1 and route books", - "Use wp_cache_get_salted/wp_cache_set_salted with group 'books-list' and salt from wp_cache_get_last_changed('posts')", - "Capability: read for logged-in users, otherwise error", - "Add actions on save_post_book and deleted_post to delete the salted cache entry" + "Use rest_ensure_response", + "Return the response status and data" ], "static_checks": { "required_patterns": [ - { "pattern": "register_rest_route", "description": "Registers REST route", "weight": 1.0 }, - { "pattern": "wp_cache_get_salted", "description": "Uses salted cache get", "weight": 0.8 }, - { "pattern": "save_post_book", "description": "Cache invalidation hook", "weight": 0.6 } + { + "pattern": "wpbp_rest_api_006", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "rest_ensure_response", + "description": "Uses rest_ensure_response", + "weight": 1 + }, + { + "pattern": "WP_REST_Response", + "description": "Uses WP_REST_Response", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rest_api_006' ) ) { return false; } return array( 200, array( 'ok' => true ) ) === wpbp_rest_api_006( array( 'ok' => true ) );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rest_api_006( array $data ): array { $response = rest_ensure_response( $data ); if ( ! $response instanceof WP_REST_Response ) { return array(); } return array( $response->get_status(), $response->get_data() ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" ], - "forbidden_patterns": [ - { "pattern": "transient", "description": "Do not use transients", "severity": "error" } + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-007", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rest_api_007() to build a collection response with X-WP-Total and X-WP-TotalPages headers.", + "expected_behavior": "Reviewer contract: `wpbp_rest_api_007()` must build a collection response with X-WP-Total and X-WP-TotalPages headers. Review focus: Use WP_REST_Response; Set pagination headers. Static checks intentionally require WP_REST_Response, header. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WP_REST_Response", + "Set pagination headers" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rest_api_007", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_REST_Response", + "description": "Uses WP_REST_Response", + "weight": 1 + }, + { + "pattern": "header", + "description": "Uses header", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rest_api_007' ) ) { return false; } $r = wpbp_rest_api_007( array( 'a' ), 21, 10 ); return '21' === $r->get_headers()['X-WP-Total'] && '3' === $r->get_headers()['X-WP-TotalPages'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rest_api_007( array $items, int $total, int $per_page ): WP_REST_Response { $response = new WP_REST_Response( $items ); $response->header( 'X-WP-Total', (string) $total ); $response->header( 'X-WP-TotalPages', (string) (int) ceil( $total / $per_page ) ); return $response; }", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-008", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rest_api_008() to prepare a REST schema for a string enum setting.", + "expected_behavior": "Reviewer contract: `wpbp_rest_api_008()` must prepare a REST schema for a string enum setting. Review focus: Return JSON Schema compatible with WordPress REST API; Use enum and required keys. Static checks intentionally require enum, properties. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Return JSON Schema compatible with WordPress REST API", + "Use enum and required keys" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rest_api_008", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "enum", + "description": "Uses enum", + "weight": 1 + }, + { + "pattern": "properties", + "description": "Uses properties", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rest_api_008' ) ) { return false; } $schema = wpbp_rest_api_008(); return 'object' === $schema['type'] && array( 'light', 'dark' ) === $schema['properties']['mode']['enum'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rest_api_008(): array { return array( 'type' => 'object', 'required' => array( 'mode' ), 'properties' => array( 'mode' => array( 'type' => 'string', 'enum' => array( 'light', 'dark' ) ) ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-009", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rest_api_009() to validate a REST request URL parameter using rest_validate_request_arg.", + "expected_behavior": "Reviewer contract: `wpbp_rest_api_009()` must validate a REST request URL parameter using rest_validate_request_arg. Review focus: Build an argument schema; Return true only for positive integers. Static checks intentionally require rest_validate_value_from_schema, minimum. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Build an argument schema", + "Return true only for positive integers" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rest_api_009", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "rest_validate_value_from_schema", + "description": "Uses rest_validate_value_from_schema", + "weight": 1 + }, + { + "pattern": "minimum", + "description": "Uses minimum", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rest_api_009' ) ) { return false; } return wpbp_rest_api_009( 5 ) && ! wpbp_rest_api_009( 0 ) && ! wpbp_rest_api_009( 'abc' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rest_api_009( mixed $value ): bool { $schema = array( 'type' => 'integer', 'minimum' => 1 ); return true === rest_validate_value_from_schema( $value, $schema, 'id' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-010", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rest_api_010() to sanitize REST array input using rest_sanitize_value_from_schema.", + "expected_behavior": "Reviewer contract: `wpbp_rest_api_010()` must sanitize REST array input using rest_sanitize_value_from_schema. Review focus: Declare an array item schema; Return sanitized integers. Static checks intentionally require rest_sanitize_value_from_schema, items. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Declare an array item schema", + "Return sanitized integers" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rest_api_010", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "rest_sanitize_value_from_schema", + "description": "Uses rest_sanitize_value_from_schema", + "weight": 1 + }, + { + "pattern": "items", + "description": "Uses items", + "weight": 1 + } ] }, "runtime_checks": { - "setup": "register_post_type('book'); wp_insert_post(['post_type'=>'book','post_title'=>'Alpha','post_status'=>'publish']);", "assertions": [ - { "type": "http_body_contains", "target": "/wp-json/demo/v1/books", "expected": "Alpha", "description": "Endpoint returns cached data", "weight": 1.0 }, - { "type": "cache_miss_then_hit", "target": "/wp-json/demo/v1/books", "description": "Second call hits cache", "weight": 1.0 }, - { "type": "cache_invalidated_on_hook", "target": "save_post_book", "description": "Cache clears when book updated", "weight": 1.0 } + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rest_api_010' ) ) { return false; } return array( 1, 2, 3 ) === wpbp_rest_api_010( array( '1', '2', '3' ) );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rest_api_010( array $values ): array { $schema = array( 'type' => 'array', 'items' => array( 'type' => 'integer' ) ); return rest_sanitize_value_from_schema( $values, $schema ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" ], - "teardown": "unregister_post_type('book');" + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-011", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rest_api_011() to return the correct authorization status for logged-out and logged-in users.", + "expected_behavior": "Reviewer contract: `wpbp_rest_api_011()` must return the correct authorization status for logged-out and logged-in users. Review focus: Use rest_authorization_required_code; Do not hard-code only one status. Static checks intentionally require rest_authorization_required_code, wp_set_current_user. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use rest_authorization_required_code", + "Do not hard-code only one status" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rest_api_011", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "rest_authorization_required_code", + "description": "Uses rest_authorization_required_code", + "weight": 1 + }, + { + "pattern": "wp_set_current_user", + "description": "Uses wp_set_current_user", + "weight": 1 + } + ] }, - "judge_config": { "rubric_id": "wp-judge-rubric-v1" }, - "reference_solution": "add_action( 'rest_api_init', function () {\n register_rest_route( 'demo/v1', '/books', array(\n 'methods' => 'GET',\n 'permission_callback' => fn() => is_user_logged_in() && current_user_can( 'read' ),\n 'callback' => function () {\n $salt = wp_cache_get_last_changed( 'posts' );\n $group = 'books-list';\n $key = 'titles';\n $data = wp_cache_get_salted( $key, $group, $salt, $found );\n if ( $found ) {\n return rest_ensure_response( $data );\n }\n $q = new WP_Query( array( 'post_type' => 'book', 'post_status' => 'publish', 'fields' => 'titles', 'nopaging' => true ) );\n $titles = wp_list_pluck( $q->posts, 'post_title' );\n wp_cache_set_salted( $key, $titles, $group, $salt );\n return rest_ensure_response( $titles );\n },\n ) );\n} );\nadd_action( 'save_post_book', fn() => wp_cache_delete( 'titles', 'books-list' ) );\nadd_action( 'deleted_post', function ( $pid ) {\n if ( get_post_type( $pid ) === 'book' ) {\n wp_cache_delete( 'titles', 'books-list' );\n }\n} );" + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rest_api_011' ) ) { return false; } return array( 401, 403 ) === wpbp_rest_api_011();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rest_api_011(): array { wp_set_current_user( 0 ); $logged_out = rest_authorization_required_code(); $user_id = wp_insert_user( array( 'user_login' => 'wpbp_rest_user_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); wp_set_current_user( $user_id ); $logged_in = rest_authorization_required_code(); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $user_id ); wp_set_current_user( 0 ); return array( $logged_out, $logged_in ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rest-api-012", + "category": "rest-api", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rest_api_012() to add a custom link relation to a WP_REST_Response.", + "expected_behavior": "Reviewer contract: `wpbp_rest_api_012()` must add a custom link relation to a WP_REST_Response. Review focus: Use add_link; Return links from response. Static checks intentionally require WP_REST_Response, add_link. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use add_link", + "Return links from response" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rest_api_012", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_REST_Response", + "description": "Uses WP_REST_Response", + "weight": 1 + }, + { + "pattern": "add_link", + "description": "Uses add_link", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rest_api_012' ) ) { return false; } $links = wpbp_rest_api_012( 'https://example.test/item' ); return isset( $links['https://api.w.org/related'][0]['href'] ) && 'https://example.test/item' === $links['https://api.w.org/related'][0]['href'];", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rest_api_012( string $url ): array { $response = new WP_REST_Response( array( 'ok' => true ) ); $response->add_link( 'https://api.w.org/related', $url ); return $response->get_links(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rest-api.php", + "src/wp-includes/rest-api/class-wp-rest-request.php" + ], + "release_focus": "classic" + } } ] } diff --git a/datasets/suites/wp-core-v1/execution/rewrite-permalinks.json b/datasets/suites/wp-core-v1/execution/rewrite-permalinks.json new file mode 100644 index 0000000..023b786 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/rewrite-permalinks.json @@ -0,0 +1,151 @@ +{ + "id": "wp-core-execution-v1-rewrite_permalinks", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Rewrite and Permalinks", + "description": "Code generation tasks for WordPress Rewrite and Permalinks APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-rewrite-permalinks-001", + "category": "rewrite-permalinks", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rewrite_permalinks_001() to add a rewrite tag and permastruct for a custom resource.", + "expected_behavior": "Reviewer contract: `wpbp_rewrite_permalinks_001()` must add a rewrite tag and permastruct for a custom resource. Review focus: Use rewrite APIs; Avoid flushing rewrite rules during normal runtime. Static checks intentionally require add_rewrite_tag, add_permastruct. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use rewrite APIs", + "Avoid flushing rewrite rules during normal runtime" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rewrite_permalinks_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "add_rewrite_tag", + "description": "Uses add_rewrite_tag", + "weight": 1 + }, + { + "pattern": "add_permastruct", + "description": "Uses add_permastruct", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rewrite_permalinks_001' ) ) { return false; } return wpbp_rewrite_permalinks_001();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rewrite_permalinks_001(): bool { add_rewrite_tag( '%wpbp_item%', '([^/]+)' ); add_permastruct( 'wpbp_item', 'items/%wpbp_item%' ); global $wp_rewrite; return isset( $wp_rewrite->extra_permastructs['wpbp_item'] ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rewrite.php", + "src/wp-includes/link-template.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rewrite-permalinks-002", + "category": "rewrite-permalinks", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rewrite_permalinks_002() to add a rewrite rule at the top of the ruleset.", + "expected_behavior": "Reviewer contract: `wpbp_rewrite_permalinks_002()` must add a rewrite rule at the top of the ruleset. Review focus: Use rewrite APIs; Avoid flushing rewrite rules during normal runtime. Static checks intentionally require add_rewrite_rule. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use rewrite APIs", + "Avoid flushing rewrite rules during normal runtime" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rewrite_permalinks_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "add_rewrite_rule", + "description": "Uses add_rewrite_rule", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rewrite_permalinks_002' ) ) { return false; } return wpbp_rewrite_permalinks_002();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rewrite_permalinks_002(): bool { add_rewrite_rule( '^wpbp-rule/([^/]+)/?', 'index.php?wpbp_rule=$matches[1]', 'top' ); global $wp_rewrite; return isset( $wp_rewrite->extra_rules_top['^wpbp-rule/([^/]+)/?'] ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rewrite.php", + "src/wp-includes/link-template.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-rewrite-permalinks-003", + "category": "rewrite-permalinks", + "difficulty": "intermediate", + "prompt": "Implement wpbp_rewrite_permalinks_003() to add a custom query var through the query_vars filter.", + "expected_behavior": "Reviewer contract: `wpbp_rewrite_permalinks_003()` must add a custom query var through the query_vars filter. Review focus: Use rewrite APIs; Avoid flushing rewrite rules during normal runtime. Static checks intentionally require query_vars, add_filter. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use rewrite APIs", + "Avoid flushing rewrite rules during normal runtime" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_rewrite_permalinks_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "query_vars", + "description": "Uses query_vars", + "weight": 1 + }, + { + "pattern": "add_filter", + "description": "Uses add_filter", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_rewrite_permalinks_003' ) ) { return false; } wpbp_rewrite_permalinks_003(); $vars = apply_filters( 'query_vars', array() ); return in_array( 'wpbp_var', $vars, true );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_rewrite_permalinks_003(): void { add_filter( 'query_vars', fn( $vars ) => array_merge( $vars, array( 'wpbp_var' ) ) ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/rewrite.php", + "src/wp-includes/link-template.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/roles-caps.json b/datasets/suites/wp-core-v1/execution/roles-caps.json new file mode 100644 index 0000000..d3c031a --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/roles-caps.json @@ -0,0 +1,384 @@ +{ + "id": "wp-core-execution-v1-roles_caps", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Roles and Capabilities", + "description": "Code generation tasks for WordPress Roles and Capabilities APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-roles-caps-001", + "category": "roles-caps", + "difficulty": "intermediate", + "prompt": "Implement wpbp_roles_caps_001() to create a role with a custom capability and confirm it exists.", + "expected_behavior": "Reviewer contract: `wpbp_roles_caps_001()` must create a role with a custom capability and confirm it exists. Review focus: Use WordPress roles/capabilities APIs; Do not inspect role arrays directly when helper APIs exist. Static checks intentionally require add_role, get_role. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress roles/capabilities APIs", + "Do not inspect role arrays directly when helper APIs exist" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_roles_caps_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "add_role", + "description": "Uses add_role", + "weight": 1 + }, + { + "pattern": "get_role", + "description": "Uses get_role", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_roles_caps_001' ) ) { return false; } return wpbp_roles_caps_001();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_roles_caps_001(): bool { add_role( 'wpbp_manager', 'WPBP Manager', array( 'read' => true, 'wpbp_manage' => true ) ); $role = get_role( 'wpbp_manager' ); $ok = $role && $role->has_cap( 'wpbp_manage' ); remove_role( 'wpbp_manager' ); return (bool) $ok; }", + "metadata": { + "source_refs": [ + "src/wp-includes/capabilities.php", + "src/wp-includes/class-wp-roles.php", + "src/wp-includes/class-wp-user.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-roles-caps-002", + "category": "roles-caps", + "difficulty": "intermediate", + "prompt": "Implement wpbp_roles_caps_002() to add and remove a capability from an existing role.", + "expected_behavior": "Reviewer contract: `wpbp_roles_caps_002()` must add and remove a capability from an existing role. Review focus: Use WordPress roles/capabilities APIs; Do not inspect role arrays directly when helper APIs exist. Static checks intentionally require add_cap, remove_cap. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress roles/capabilities APIs", + "Do not inspect role arrays directly when helper APIs exist" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_roles_caps_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "add_cap", + "description": "Uses add_cap", + "weight": 1 + }, + { + "pattern": "remove_cap", + "description": "Uses remove_cap", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_roles_caps_002' ) ) { return false; } return wpbp_roles_caps_002();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_roles_caps_002(): bool { $role = get_role( 'subscriber' ); $role->add_cap( 'wpbp_temp_cap' ); $has = $role->has_cap( 'wpbp_temp_cap' ); $role->remove_cap( 'wpbp_temp_cap' ); return $has && ! $role->has_cap( 'wpbp_temp_cap' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/capabilities.php", + "src/wp-includes/class-wp-roles.php", + "src/wp-includes/class-wp-user.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-roles-caps-003", + "category": "roles-caps", + "difficulty": "intermediate", + "prompt": "Implement wpbp_roles_caps_003() to check current user capability after switching users.", + "expected_behavior": "Reviewer contract: `wpbp_roles_caps_003()` must check current user capability after switching users. Review focus: Use WordPress roles/capabilities APIs; Do not inspect role arrays directly when helper APIs exist. Static checks intentionally require current_user_can, wp_set_current_user. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress roles/capabilities APIs", + "Do not inspect role arrays directly when helper APIs exist" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_roles_caps_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "current_user_can", + "description": "Uses current_user_can", + "weight": 1 + }, + { + "pattern": "wp_set_current_user", + "description": "Uses wp_set_current_user", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_roles_caps_003' ) ) { return false; } $u = wp_insert_user( array( 'user_login' => 'wpbp_cap_user_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); $ok = wpbp_roles_caps_003( $u, 'read' ) && ! wpbp_roles_caps_003( $u, 'manage_options' ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); wp_set_current_user( 0 ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_roles_caps_003( int $user_id, string $cap ): bool { wp_set_current_user( $user_id ); return current_user_can( $cap ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/capabilities.php", + "src/wp-includes/class-wp-roles.php", + "src/wp-includes/class-wp-user.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-roles-caps-004", + "category": "roles-caps", + "difficulty": "intermediate", + "prompt": "Implement wpbp_roles_caps_004() to map edit_post meta capability for a post author.", + "expected_behavior": "Reviewer contract: `wpbp_roles_caps_004()` must map edit_post meta capability for a post author. Review focus: Use WordPress roles/capabilities APIs; Do not inspect role arrays directly when helper APIs exist. Static checks intentionally require map_meta_cap. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress roles/capabilities APIs", + "Do not inspect role arrays directly when helper APIs exist" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_roles_caps_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "map_meta_cap", + "description": "Uses map_meta_cap", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_roles_caps_004' ) ) { return false; } $u = wp_insert_user( array( 'user_login' => 'wpbp_meta_cap_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'author' ) ); $p = wp_insert_post( array( 'post_title' => 'Owned', 'post_status' => 'draft', 'post_author' => $u ) ); $caps = wpbp_roles_caps_004( $u, $p ); $ok = in_array( 'edit_posts', $caps, true ); wp_delete_post( $p, true ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_roles_caps_004( int $user_id, int $post_id ): array { return map_meta_cap( 'edit_post', $user_id, $post_id ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/capabilities.php", + "src/wp-includes/class-wp-roles.php", + "src/wp-includes/class-wp-user.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-roles-caps-005", + "category": "roles-caps", + "difficulty": "intermediate", + "prompt": "Implement wpbp_roles_caps_005() to grant a capability directly to a user.", + "expected_behavior": "Reviewer contract: `wpbp_roles_caps_005()` must grant a capability directly to a user. Review focus: Use WordPress roles/capabilities APIs; Do not inspect role arrays directly when helper APIs exist. Static checks intentionally require WP_User, user_can. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress roles/capabilities APIs", + "Do not inspect role arrays directly when helper APIs exist" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_roles_caps_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_User", + "description": "Uses WP_User", + "weight": 1 + }, + { + "pattern": "user_can", + "description": "Uses user_can", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_roles_caps_005' ) ) { return false; } $u = wp_insert_user( array( 'user_login' => 'wpbp_direct_cap_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); $ok = wpbp_roles_caps_005( $u, 'wpbp_direct' ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_roles_caps_005( int $user_id, string $cap ): bool { $user = new WP_User( $user_id ); $user->add_cap( $cap ); $ok = user_can( $user_id, $cap ); $user->remove_cap( $cap ); return $ok; }", + "metadata": { + "source_refs": [ + "src/wp-includes/capabilities.php", + "src/wp-includes/class-wp-roles.php", + "src/wp-includes/class-wp-user.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-roles-caps-006", + "category": "roles-caps", + "difficulty": "intermediate", + "prompt": "Implement wpbp_roles_caps_006() to filter the default-role dropdown excluded roles.", + "expected_behavior": "Reviewer contract: `wpbp_roles_caps_006()` must filter the default-role dropdown excluded roles. Review focus: Use WordPress roles/capabilities APIs; Do not inspect role arrays directly when helper APIs exist. Static checks intentionally require default_role_dropdown_excluded_roles. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress roles/capabilities APIs", + "Do not inspect role arrays directly when helper APIs exist" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_roles_caps_006", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "default_role_dropdown_excluded_roles", + "description": "Uses default_role_dropdown_excluded_roles", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_roles_caps_006' ) ) { return false; } add_filter( 'default_role_dropdown_excluded_roles', function( $roles ) { $roles[] = 'administrator'; return $roles; } ); $out = wpbp_roles_caps_006( array() ); return in_array( 'administrator', $out, true );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_roles_caps_006( array $roles ): array { return apply_filters( 'default_role_dropdown_excluded_roles', $roles ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/capabilities.php", + "src/wp-includes/class-wp-roles.php", + "src/wp-includes/class-wp-user.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-roles-caps-007", + "category": "roles-caps", + "difficulty": "intermediate", + "prompt": "Implement wpbp_roles_caps_007() to check super-admin-safe capability with user_can.", + "expected_behavior": "Reviewer contract: `wpbp_roles_caps_007()` must check super-admin-safe capability with user_can. Review focus: Use WordPress roles/capabilities APIs; Do not inspect role arrays directly when helper APIs exist. Static checks intentionally require user_can. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress roles/capabilities APIs", + "Do not inspect role arrays directly when helper APIs exist" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_roles_caps_007", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "user_can", + "description": "Uses user_can", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_roles_caps_007' ) ) { return false; } $u = wp_insert_user( array( 'user_login' => 'wpbp_user_can_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); $ok = wpbp_roles_caps_007( $u, 'read' ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_roles_caps_007( int $user_id, string $cap ): bool { return user_can( $user_id, $cap ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/capabilities.php", + "src/wp-includes/class-wp-roles.php", + "src/wp-includes/class-wp-user.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-roles-caps-008", + "category": "roles-caps", + "difficulty": "intermediate", + "prompt": "Implement wpbp_roles_caps_008() to return primitive caps for deleting a published post.", + "expected_behavior": "Reviewer contract: `wpbp_roles_caps_008()` must return primitive caps for deleting a published post. Review focus: Use WordPress roles/capabilities APIs; Do not inspect role arrays directly when helper APIs exist. Static checks intentionally require map_meta_cap. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress roles/capabilities APIs", + "Do not inspect role arrays directly when helper APIs exist" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_roles_caps_008", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "map_meta_cap", + "description": "Uses map_meta_cap", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_roles_caps_008' ) ) { return false; } $u = wp_insert_user( array( 'user_login' => 'wpbp_delete_cap_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'author' ) ); $p = wp_insert_post( array( 'post_title' => 'Delete owned', 'post_status' => 'publish', 'post_author' => $u ) ); $caps = wpbp_roles_caps_008( $u, $p ); $ok = in_array( 'delete_published_posts', $caps, true ); wp_delete_post( $p, true ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_roles_caps_008( int $user_id, int $post_id ): array { return map_meta_cap( 'delete_post', $user_id, $post_id ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/capabilities.php", + "src/wp-includes/class-wp-roles.php", + "src/wp-includes/class-wp-user.php" + ], + "release_focus": "classic" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/scripts-styles.json b/datasets/suites/wp-core-v1/execution/scripts-styles.json new file mode 100644 index 0000000..bbe52f4 --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/scripts-styles.json @@ -0,0 +1,247 @@ +{ + "id": "wp-core-execution-v1-scripts_styles", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Scripts and Styles", + "description": "Code generation tasks for WordPress Scripts and Styles APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-scripts-styles-001", + "category": "scripts-styles", + "difficulty": "intermediate", + "prompt": "Implement wpbp_scripts_styles_001() to register and enqueue a script with dependencies.", + "expected_behavior": "Reviewer contract: `wpbp_scripts_styles_001()` must register and enqueue a script with dependencies. Review focus: Use WordPress script/style APIs; Avoid hard-coded script tags. Static checks intentionally require wp_register_script, wp_enqueue_script. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress script/style APIs", + "Avoid hard-coded script tags" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_scripts_styles_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_register_script", + "description": "Uses wp_register_script", + "weight": 1 + }, + { + "pattern": "wp_enqueue_script", + "description": "Uses wp_enqueue_script", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_scripts_styles_001' ) ) { return false; } $ok = wpbp_scripts_styles_001(); wp_dequeue_script( 'wpbp-script' ); wp_deregister_script( 'wpbp-script' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_scripts_styles_001(): bool { wp_register_script( 'wpbp-script', 'https://example.test/script.js', array( 'jquery' ), '1.0.0', true ); wp_enqueue_script( 'wpbp-script' ); return wp_script_is( 'wpbp-script', 'enqueued' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/script-loader.php", + "src/wp-includes/functions.wp-scripts.php", + "src/wp-includes/class-wp-scripts.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-scripts-styles-002", + "category": "scripts-styles", + "difficulty": "intermediate", + "prompt": "Implement wpbp_scripts_styles_002() to add inline script data after a handle.", + "expected_behavior": "Reviewer contract: `wpbp_scripts_styles_002()` must add inline script data after a handle. Review focus: Use WordPress script/style APIs; Avoid hard-coded script tags. Static checks intentionally require wp_add_inline_script. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress script/style APIs", + "Avoid hard-coded script tags" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_scripts_styles_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_add_inline_script", + "description": "Uses wp_add_inline_script", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_scripts_styles_002' ) ) { return false; } $ok = wpbp_scripts_styles_002(); wp_dequeue_script( 'wpbp-inline' ); wp_deregister_script( 'wpbp-inline' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_scripts_styles_002(): bool { wp_register_script( 'wpbp-inline', false, array(), null, true ); wp_enqueue_script( 'wpbp-inline' ); return wp_add_inline_script( 'wpbp-inline', 'window.wpbpInline = true;', 'after' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/script-loader.php", + "src/wp-includes/functions.wp-scripts.php", + "src/wp-includes/class-wp-scripts.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-scripts-styles-003", + "category": "scripts-styles", + "difficulty": "intermediate", + "prompt": "Implement wpbp_scripts_styles_003() to register a script module and enqueue it.", + "expected_behavior": "Reviewer contract: `wpbp_scripts_styles_003()` must register a script module and enqueue it. Review focus: Use WordPress script/style APIs; Avoid hard-coded script tags. Static checks intentionally require wp_register_script_module, wp_enqueue_script_module. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress script/style APIs", + "Avoid hard-coded script tags" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_scripts_styles_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_register_script_module", + "description": "Uses wp_register_script_module", + "weight": 1 + }, + { + "pattern": "wp_enqueue_script_module", + "description": "Uses wp_enqueue_script_module", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_scripts_styles_003' ) ) { return false; } return wpbp_scripts_styles_003();", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_scripts_styles_003(): bool { wp_register_script_module( 'wpbp/module', 'https://example.test/module.js', array(), '1.0.0' ); wp_enqueue_script_module( 'wpbp/module' ); return true; }", + "metadata": { + "source_refs": [ + "src/wp-includes/script-loader.php", + "src/wp-includes/functions.wp-scripts.php", + "src/wp-includes/class-wp-scripts.php" + ], + "release_focus": "classic" + } + }, + { + "id": "e-scripts-styles-004", + "category": "scripts-styles", + "difficulty": "intermediate", + "prompt": "Implement wpbp_scripts_styles_004() to register a script that depends on a module.", + "expected_behavior": "Reviewer contract: `wpbp_scripts_styles_004()` must register a script that depends on a module. Review focus: Use WordPress script/style APIs; Avoid hard-coded script tags. Static checks intentionally require module_dependencies, wp_register_script. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress script/style APIs", + "Avoid hard-coded script tags" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_scripts_styles_004", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "module_dependencies", + "description": "Uses module_dependencies", + "weight": 1 + }, + { + "pattern": "wp_register_script", + "description": "Uses wp_register_script", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_scripts_styles_004' ) ) { return false; } $ok = wpbp_scripts_styles_004(); wp_deregister_script( 'wpbp-script-with-module' ); return $ok;", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_scripts_styles_004(): bool { wp_register_script_module( 'wpbp/dep-module', 'https://example.test/dep.js' ); wp_register_script( 'wpbp-script-with-module', 'https://example.test/app.js', array(), '1.0.0', array( 'in_footer' => true, 'module_dependencies' => array( 'wpbp/dep-module' ) ) ); return wp_script_is( 'wpbp-script-with-module', 'registered' ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/script-loader.php", + "src/wp-includes/functions.wp-scripts.php", + "src/wp-includes/class-wp-scripts.php" + ], + "release_focus": "7.0" + } + }, + { + "id": "e-scripts-styles-005", + "category": "scripts-styles", + "difficulty": "intermediate", + "prompt": "Implement wpbp_scripts_styles_005() to convert JS dataset property names to HTML data attributes.", + "expected_behavior": "Reviewer contract: `wpbp_scripts_styles_005()` must convert JS dataset property names to HTML data attributes. Review focus: Use WordPress script/style APIs; Avoid hard-coded script tags. Static checks intentionally require wp_html_custom_data_attribute_name. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress script/style APIs", + "Avoid hard-coded script tags" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_scripts_styles_005", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_html_custom_data_attribute_name", + "description": "Uses wp_html_custom_data_attribute_name", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_scripts_styles_005' ) ) { return false; } return 'data-post-id' === wpbp_scripts_styles_005( 'postId' ) && null === wpbp_scripts_styles_005( 'no spaces' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_scripts_styles_005( string $prop ): ?string { return wp_html_custom_data_attribute_name( $prop ); }", + "metadata": { + "source_refs": [ + "src/wp-includes/script-loader.php", + "src/wp-includes/functions.wp-scripts.php", + "src/wp-includes/class-wp-scripts.php" + ], + "release_focus": "6.9" + } + } + ] +} diff --git a/datasets/suites/wp-core-v1/execution/security.json b/datasets/suites/wp-core-v1/execution/security.json new file mode 100644 index 0000000..d2f7bcd --- /dev/null +++ b/datasets/suites/wp-core-v1/execution/security.json @@ -0,0 +1,240 @@ +{ + "id": "wp-core-execution-v1-security", + "version": "2.0.0", + "metadata": { + "name": "WordPress Core Execution Tests - Security", + "description": "Code generation tasks for WordPress Security APIs", + "wp_version": "7.0", + "created_at": "2026-05-21" + }, + "tests": [ + { + "id": "e-security-001", + "category": "security", + "difficulty": "intermediate", + "prompt": "Implement wpbp_security_001() to set an anchor href with WP_HTML_Tag_Processor so character references are safely escaped.", + "expected_behavior": "Reviewer contract: `wpbp_security_001()` must set an anchor href with WP_HTML_Tag_Processor so character references are safely escaped. Review focus: Use WP_HTML_Tag_Processor; Set the href through set_attribute; Return the updated HTML. Static checks intentionally require WP_HTML_Tag_Processor, set_attribute. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WP_HTML_Tag_Processor", + "Set the href through set_attribute", + "Return the updated HTML" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_security_001", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_HTML_Tag_Processor", + "description": "Uses WP_HTML_Tag_Processor", + "weight": 1 + }, + { + "pattern": "set_attribute", + "description": "Uses set_attribute", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_security_001' ) ) { return false; } $out = wpbp_security_001( 'Link', 'https://example.test/?q=Tom&Jerry' ); return str_contains( $out, 'Tom' ) && str_contains( $out, 'Jerry' ) && ! str_contains( $out, 'Tom&Jerry' );", + "description": "Reference behavior is correct", + "weight": 1 + } + ] + }, + "reference_solution": "function wpbp_security_001( string $html, string $href ): string { $processor = new WP_HTML_Tag_Processor( $html ); if ( $processor->next_tag( 'a' ) ) { $processor->set_attribute( 'href', $href ); } return $processor->get_updated_html(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/html-api/class-wp-html-tag-processor.php" + ], + "release_focus": "6.9" + } + }, + { + "id": "e-security-002", + "category": "security", + "difficulty": "intermediate", + "prompt": "Implement wpbp_security_002() to serialize the current token from a WP_HTML_Processor fragment.", + "expected_behavior": "Reviewer contract: `wpbp_security_002()` must serialize the current token from a WP_HTML_Processor fragment. Review focus: Use WP_HTML_Processor::create_fragment; Advance to the first token; Return serialize_token output. Static checks intentionally require WP_HTML_Processor, serialize_token. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WP_HTML_Processor::create_fragment", + "Advance to the first token", + "Return serialize_token output" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_security_002", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "WP_HTML_Processor", + "description": "Uses WP_HTML_Processor", + "weight": 1 + }, + { + "pattern": "serialize_token", + "description": "Uses serialize_token", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_security_002' ) ) { return false; } $out = wpbp_security_002( '

Hi

' ); return str_starts_with( $out, 'next_token(); return $processor->serialize_token(); }", + "metadata": { + "source_refs": [ + "src/wp-includes/html-api/class-wp-html-processor.php" + ], + "release_focus": "6.9" + } + }, + { + "id": "e-security-003", + "category": "security", + "difficulty": "intermediate", + "prompt": "Implement wpbp_security_003() to allow only safe post HTML using KSES.", + "expected_behavior": "Reviewer contract: `wpbp_security_003()` must allow only safe post HTML using KSES. Review focus: Use WordPress security helpers; Avoid raw output of untrusted values. Static checks intentionally require wp_kses_post. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "requirements": [ + "Use WordPress security helpers", + "Avoid raw output of untrusted values" + ], + "static_checks": { + "required_patterns": [ + { + "pattern": "wpbp_security_003", + "description": "Defines the requested function", + "weight": 0.5 + }, + { + "pattern": "wp_kses_post", + "description": "Uses wp_kses_post", + "weight": 1 + } + ] + }, + "runtime_checks": { + "assertions": [ + { + "type": "custom_assertion", + "code": "if ( ! function_exists( 'wpbp_security_003' ) ) { return false; } $out = wpbp_security_003( '

ok

' ); return str_contains( $out, '

ok

' ) && ! str_contains( $out, '' ); return str_contains( $out, '

ok

' ) && ! str_contains( $out, '' ); return str_contains( $out, '

Safe

' ) && str_contains( $out, 'alert(1)' ) && ! str_contains( $out, 'onclick' ) && ! str_contains( $out, 'ID; if ( ! $uid ) { $uid = apply_filters( 'nonce_user_logged_out', $uid, $action ); } $previous = substr( wp_hash( ( wp_nonce_tick( $action ) - 1 ) . '|' . $action . '|' . $uid . '|' . wp_get_session_token(), 'nonce' ), -12, 10 ); return wpbp_security_004( $nonce, $action ) && wpbp_security_004( $previous, $action ) && ! wpbp_security_004( $nonce, 'other' ) && ! wpbp_security_004( '', $action );", + "description": "Current and previous-tick nonces are valid for the matching action only", "weight": 1 } ] @@ -185,8 +204,6 @@ "reference_solution": "function wpbp_security_004( string $nonce, string $action ): bool { return false !== wp_verify_nonce( $nonce, $action ); }", "metadata": { "source_refs": [ - "src/wp-includes/kses.php", - "src/wp-includes/formatting.php", "src/wp-includes/pluggable.php" ], "release_focus": "classic" @@ -195,12 +212,13 @@ { "id": "e-security-005", "category": "security", - "difficulty": "intermediate", - "prompt": "Implement wpbp_security_005() to prepend HTTPS by default when esc_url protocols start with https.", - "expected_behavior": "Reviewer contract: `wpbp_security_005()` must prepend HTTPS by default when esc_url protocols start with https. Review focus: Use WordPress security helpers; Avoid raw output of untrusted values. Static checks intentionally require esc_url. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "difficulty": "basic", + "prompt": "Implement `wpbp_security_005( string $url ): string` to escape a URL for HTML display while preferring HTTPS when WordPress has to add a missing scheme.", + "expected_behavior": "`wpbp_security_005()` calls `esc_url()` with HTTPS first and HTTP second in the allowed protocol list. Schemeless absolute URLs should gain `https://`, existing HTTP URLs should stay HTTP, display-context ampersands should be entity-escaped, and protocols outside the allowed list should be rejected.", "requirements": [ - "Use WordPress security helpers", - "Avoid raw output of untrusted values" + "Use esc_url()", + "Allow both HTTPS and HTTP with HTTPS preferred", + "Return the display-safe URL string" ], "static_checks": { "required_patterns": [ @@ -213,6 +231,16 @@ "pattern": "esc_url", "description": "Uses esc_url", "weight": 1 + }, + { + "pattern": "/['\"]https['\"]/i", + "description": "Supplies HTTPS as the preferred protocol", + "weight": 0.5 + }, + { + "pattern": "/['\"]http['\"]/i", + "description": "Allows HTTP as a valid protocol", + "weight": 0.5 } ] }, @@ -220,8 +248,8 @@ "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_security_005' ) ) { return false; } $out = wpbp_security_005( 'example.com/path' ); return str_starts_with( $out, 'https://example.com/path' );", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_security_005' ) ) { return false; } return 'https://example.com/path?x=1&y=2' === wpbp_security_005( 'example.com/path?x=1&y=2' ) && 'http://example.com/path?x=1&y=2' === wpbp_security_005( 'http://example.com/path?x=1&y=2' ) && '' === wpbp_security_005( 'mailto:person@example.com' ) && '' === wpbp_security_005( 'javascript:alert(1)' );", + "description": "Schemeless URLs prefer HTTPS, existing HTTP is preserved, display entities are escaped, and disallowed protocols are removed", "weight": 1 } ] @@ -229,9 +257,8 @@ "reference_solution": "function wpbp_security_005( string $url ): string { return esc_url( $url, array( 'https', 'http' ) ); }", "metadata": { "source_refs": [ - "src/wp-includes/kses.php", "src/wp-includes/formatting.php", - "src/wp-includes/pluggable.php" + "src/wp-includes/kses.php" ], "release_focus": "6.9" } diff --git a/datasets/suites/wp-core-v1/execution/settings-options.json b/datasets/suites/wp-core-v1/execution/settings-options.json index a4cbf8d..44edf84 100644 --- a/datasets/suites/wp-core-v1/execution/settings-options.json +++ b/datasets/suites/wp-core-v1/execution/settings-options.json @@ -12,11 +12,12 @@ "id": "e-settings-options-001", "category": "settings-options", "difficulty": "intermediate", - "prompt": "Implement wpbp_settings_options_001() to register a string setting with REST schema and sanitization.", - "expected_behavior": "Reviewer contract: `wpbp_settings_options_001()` must register a string setting with REST schema and sanitization. Review focus: Use Settings or Options APIs; Sanitize user-facing values. Static checks intentionally require register_setting, show_in_rest. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "prompt": "Implement wpbp_settings_options_001() to register the option-backed setting 'wpbp_setting_title' in the 'wpbp' group as a REST-exposed string setting whose saved value is sanitized as plain text.", + "expected_behavior": "`wpbp_settings_options_001()` registers `wpbp_setting_title` with `register_setting()` in the `wpbp` group, exposes it through REST settings metadata, declares string data, and registers a sanitizer that strips markup. Runtime validation inspects WordPress's registered settings registry and verifies that `sanitize_option()` applies the registered sanitizer.", "requirements": [ - "Use Settings or Options APIs", - "Sanitize user-facing values" + "Use the Settings API", + "Register the setting under group 'wpbp' with option name 'wpbp_setting_title'", + "Expose the setting to REST clients and sanitize stored values as plain text" ], "static_checks": { "required_patterns": [ @@ -30,9 +31,19 @@ "description": "Uses register_setting", "weight": 1 }, + { + "pattern": "wpbp_setting_title", + "description": "Registers the requested setting name", + "weight": 1 + }, { "pattern": "show_in_rest", - "description": "Uses show_in_rest", + "description": "Exposes the setting to REST", + "weight": 1 + }, + { + "pattern": "sanitize_callback", + "description": "Registers a sanitizer for saved values", "weight": 1 } ] @@ -41,8 +52,8 @@ "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_settings_options_001' ) ) { return false; } wpbp_settings_options_001(); global $wp_registered_settings; return isset( $wp_registered_settings['wpbp_setting_title'] ) && true === $wp_registered_settings['wpbp_setting_title']['show_in_rest'];", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_settings_options_001' ) ) { return false; } wpbp_settings_options_001(); global $wp_registered_settings; if ( empty( $wp_registered_settings['wpbp_setting_title'] ) ) { return false; } $setting = $wp_registered_settings['wpbp_setting_title']; $rest = $setting['show_in_rest'] ?? false; $rest_ok = true === $rest || ( is_array( $rest ) && isset( $rest['schema'] ) ); return 'wpbp' === ( $setting['group'] ?? null ) && 'string' === ( $setting['type'] ?? null ) && $rest_ok && isset( $setting['sanitize_callback'] ) && is_callable( $setting['sanitize_callback'] ) && 'Title' === sanitize_option( 'wpbp_setting_title', 'Title' );", + "description": "The setting is registered as a REST-exposed sanitized string setting", "weight": 1 } ] @@ -51,7 +62,7 @@ "metadata": { "source_refs": [ "src/wp-includes/option.php", - "src/wp-admin/includes/plugin.php" + "src/wp-includes/formatting.php" ], "release_focus": "classic" } @@ -60,11 +71,12 @@ "id": "e-settings-options-002", "category": "settings-options", "difficulty": "intermediate", - "prompt": "Implement wpbp_settings_options_002() to add an option without autoloading it.", - "expected_behavior": "Reviewer contract: `wpbp_settings_options_002()` must add an option without autoloading it. Review focus: Use Settings or Options APIs; Sanitize user-facing values. Static checks intentionally require add_option. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "prompt": "Implement wpbp_settings_options_002( string $value ): bool to create the 'wpbp_noautoload' option with the provided value sanitized as plain text and excluded from WordPress autoloading.", + "expected_behavior": "`wpbp_settings_options_002()` adds `wpbp_noautoload` with `add_option()`, stores the provided value after plain-text sanitization, and disables autoloading using the modern Options API behavior. Runtime validation checks the stored value and confirms the options table autoload marker is not one of WordPress's autoloaded values.", "requirements": [ - "Use Settings or Options APIs", - "Sanitize user-facing values" + "Use the Options API", + "Store the sanitized value in 'wpbp_noautoload'", + "Disable autoloading for the option" ], "static_checks": { "required_patterns": [ @@ -77,24 +89,36 @@ "pattern": "add_option", "description": "Uses add_option", "weight": 1 + }, + { + "pattern": "wpbp_noautoload", + "description": "Adds the requested option name", + "weight": 1 + }, + { + "pattern": "sanitize_text_field", + "description": "Sanitizes the stored text value", + "weight": 1 } ] }, "runtime_checks": { + "setup": "delete_option( 'wpbp_noautoload' );", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_settings_options_002' ) ) { return false; } $ok = wpbp_settings_options_002( 'wpbp_noautoload', 'v' ) && 'v' === get_option( 'wpbp_noautoload' ); delete_option( 'wpbp_noautoload' ); return $ok;", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_settings_options_002' ) ) { return false; } global $wpdb; $added = wpbp_settings_options_002( 'Value' ); $stored = get_option( 'wpbp_noautoload' ); $autoload = $wpdb->get_var( $wpdb->prepare( \"SELECT autoload FROM {$wpdb->options} WHERE option_name = %s\", 'wpbp_noautoload' ) ); $autoloaded_values = function_exists( 'wp_autoload_values_to_autoload' ) ? wp_autoload_values_to_autoload() : array( 'yes' ); return true === $added && 'Value' === $stored && is_string( $autoload ) && ! in_array( $autoload, $autoloaded_values, true );", + "description": "The option is stored sanitized and is not marked for autoloading", "weight": 1 } - ] + ], + "teardown": "delete_option( 'wpbp_noautoload' );" }, - "reference_solution": "function wpbp_settings_options_002( string $name, string $value ): bool { return add_option( $name, $value, '', 'no' ); }", + "reference_solution": "function wpbp_settings_options_002( string $value ): bool { return add_option( 'wpbp_noautoload', sanitize_text_field( $value ), '', false ); }", "metadata": { "source_refs": [ "src/wp-includes/option.php", - "src/wp-admin/includes/plugin.php" + "src/wp-includes/formatting.php" ], "release_focus": "classic" } @@ -103,11 +127,12 @@ "id": "e-settings-options-003", "category": "settings-options", "difficulty": "intermediate", - "prompt": "Implement wpbp_settings_options_003() to update a nested option after sanitizing a key.", - "expected_behavior": "Reviewer contract: `wpbp_settings_options_003()` must update a nested option after sanitizing a key. Review focus: Use Settings or Options APIs; Sanitize user-facing values. Static checks intentionally require sanitize_key, update_option. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "prompt": "Implement wpbp_settings_options_003( string $key, string $value ): array to update the 'wpbp_nested' option by storing a sanitized plain-text value under a sanitized key, preserving existing entries, and returning the full updated option array.", + "expected_behavior": "`wpbp_settings_options_003()` reads the existing `wpbp_nested` array with `get_option()`, normalizes the supplied key with `sanitize_key()`, sanitizes the supplied value as plain text, persists the updated array with `update_option()`, and returns the same persisted array. Runtime validation seeds an existing entry, checks preservation, and verifies the sanitized key and value in both the return value and stored option.", "requirements": [ - "Use Settings or Options APIs", - "Sanitize user-facing values" + "Use the Options API to read and update 'wpbp_nested'", + "Sanitize the supplied key and value before storing", + "Preserve existing option entries" ], "static_checks": { "required_patterns": [ @@ -116,6 +141,11 @@ "description": "Defines the requested function", "weight": 0.5 }, + { + "pattern": "get_option", + "description": "Reads the existing option value", + "weight": 1 + }, { "pattern": "sanitize_key", "description": "Uses sanitize_key", @@ -125,24 +155,36 @@ "pattern": "update_option", "description": "Uses update_option", "weight": 1 + }, + { + "pattern": "sanitize_text_field", + "description": "Sanitizes the stored text value", + "weight": 1 + }, + { + "pattern": "wpbp_nested", + "description": "Updates the requested option name", + "weight": 1 } ] }, "runtime_checks": { + "setup": "update_option( 'wpbp_nested', array( 'existing' => 'keep' ), false );", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_settings_options_003' ) ) { return false; } $out = wpbp_settings_options_003( 'Some Key', 'Value' ); $ok = isset( $out['somekey'] ) && 'Value' === $out['somekey']; delete_option( 'wpbp_nested' ); return $ok;", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_settings_options_003' ) ) { return false; } $out = wpbp_settings_options_003( 'Some Key!', 'Value' ); $stored = get_option( 'wpbp_nested' ); return is_array( $out ) && is_array( $stored ) && array( 'existing' => 'keep', 'somekey' => 'Value' ) === $out && $out === $stored;", + "description": "The nested option is updated with sanitized data while preserving existing entries", "weight": 1 } - ] + ], + "teardown": "delete_option( 'wpbp_nested' );" }, - "reference_solution": "function wpbp_settings_options_003( string $key, string $value ): array { $options = get_option( 'wpbp_nested', array() ); $options[ sanitize_key( $key ) ] = sanitize_text_field( $value ); update_option( 'wpbp_nested', $options ); return $options; }", + "reference_solution": "function wpbp_settings_options_003( string $key, string $value ): array { $options = get_option( 'wpbp_nested', array() ); if ( ! is_array( $options ) ) { $options = array(); } $options[ sanitize_key( $key ) ] = sanitize_text_field( $value ); update_option( 'wpbp_nested', $options ); return $options; }", "metadata": { "source_refs": [ "src/wp-includes/option.php", - "src/wp-admin/includes/plugin.php" + "src/wp-includes/formatting.php" ], "release_focus": "classic" } @@ -151,11 +193,12 @@ "id": "e-settings-options-004", "category": "settings-options", "difficulty": "intermediate", - "prompt": "Implement wpbp_settings_options_004() to register an admin settings section and field.", - "expected_behavior": "Reviewer contract: `wpbp_settings_options_004()` must register an admin settings section and field. Review focus: Use Settings or Options APIs; Sanitize user-facing values. Static checks intentionally require add_settings_section, add_settings_field. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "prompt": "Implement wpbp_settings_options_004(): void to register a settings section 'wpbp_section' and a settings field 'wpbp_field' on the built-in 'reading' settings page, with the field assigned to that section.", + "expected_behavior": "`wpbp_settings_options_004()` uses the Settings API to register `wpbp_section` on the `reading` page and `wpbp_field` inside that section. Runtime validation inspects the Settings API globals populated by `add_settings_section()` and `add_settings_field()` and checks that both callbacks are callable.", "requirements": [ - "Use Settings or Options APIs", - "Sanitize user-facing values" + "Use the Settings API", + "Register the section and field on the 'reading' settings page", + "Assign the field to the registered section" ], "static_checks": { "required_patterns": [ @@ -173,6 +216,21 @@ "pattern": "add_settings_field", "description": "Uses add_settings_field", "weight": 1 + }, + { + "pattern": "wpbp_section", + "description": "Registers the requested section", + "weight": 1 + }, + { + "pattern": "wpbp_field", + "description": "Registers the requested field", + "weight": 1 + }, + { + "pattern": "reading", + "description": "Targets the reading settings page", + "weight": 1 } ] }, @@ -180,17 +238,16 @@ "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_settings_options_004' ) ) { return false; } return wpbp_settings_options_004();", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_settings_options_004' ) ) { return false; } wpbp_settings_options_004(); global $wp_settings_sections, $wp_settings_fields; $section = $wp_settings_sections['reading']['wpbp_section'] ?? null; $field = $wp_settings_fields['reading']['wpbp_section']['wpbp_field'] ?? null; return is_array( $section ) && is_array( $field ) && 'wpbp_section' === ( $section['id'] ?? null ) && 'wpbp_field' === ( $field['id'] ?? null ) && is_callable( $section['callback'] ?? null ) && is_callable( $field['callback'] ?? null );", + "description": "The requested section and field are registered on the reading page", "weight": 1 } ] }, - "reference_solution": "function wpbp_settings_options_004(): bool { add_settings_section( 'wpbp_section', 'WPBP', '__return_null', 'reading' ); add_settings_field( 'wpbp_field', 'WPBP Field', '__return_null', 'reading', 'wpbp_section' ); global $wp_settings_sections, $wp_settings_fields; return isset( $wp_settings_sections['reading']['wpbp_section'], $wp_settings_fields['reading']['wpbp_section']['wpbp_field'] ); }", + "reference_solution": "function wpbp_settings_options_004(): void { add_settings_section( 'wpbp_section', 'WPBP Settings', '__return_null', 'reading' ); add_settings_field( 'wpbp_field', 'WPBP Field', '__return_null', 'reading', 'wpbp_section' ); }", "metadata": { "source_refs": [ - "src/wp-includes/option.php", - "src/wp-admin/includes/plugin.php" + "src/wp-admin/includes/template.php" ], "release_focus": "classic" } @@ -198,12 +255,13 @@ { "id": "e-settings-options-005", "category": "settings-options", - "difficulty": "intermediate", - "prompt": "Implement wpbp_settings_options_005() to delete an option and verify the default fallback is returned.", - "expected_behavior": "Reviewer contract: `wpbp_settings_options_005()` must delete an option and verify the default fallback is returned. Review focus: Use Settings or Options APIs; Sanitize user-facing values. Static checks intentionally require delete_option, get_option. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "difficulty": "basic", + "prompt": "Implement wpbp_settings_options_005( string $name, mixed $fallback ): mixed to delete the named option and then return WordPress's fallback value for that option.", + "expected_behavior": "`wpbp_settings_options_005()` deletes the supplied option name with `delete_option()` and then returns `get_option()` using the supplied fallback, without creating or reseeding the option itself. Runtime validation creates the fixture option before execution, checks that the fallback is returned after deletion, and verifies the option no longer exists.", "requirements": [ - "Use Settings or Options APIs", - "Sanitize user-facing values" + "Use the Options API", + "Delete the provided option name", + "Return get_option() with the provided fallback after deletion" ], "static_checks": { "required_patterns": [ @@ -222,23 +280,31 @@ "description": "Uses get_option", "weight": 1 } + ], + "forbidden_patterns": [ + { + "pattern": "update_option", + "description": "Does not recreate the option before deleting it", + "severity": "error" + } ] }, "runtime_checks": { + "setup": "update_option( 'wpbp_deleted_option', 'stored', false );", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_settings_options_005' ) ) { return false; } return 'fallback' === wpbp_settings_options_005( 'wpbp_deleted_option' );", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_settings_options_005' ) ) { return false; } $result = wpbp_settings_options_005( 'wpbp_deleted_option', 'fallback' ); return 'fallback' === $result && false === get_option( 'wpbp_deleted_option', false );", + "description": "The option is deleted and get_option returns the supplied fallback", "weight": 1 } - ] + ], + "teardown": "delete_option( 'wpbp_deleted_option' );" }, - "reference_solution": "function wpbp_settings_options_005( string $name ): mixed { update_option( $name, 'stored' ); delete_option( $name ); return get_option( $name, 'fallback' ); }", + "reference_solution": "function wpbp_settings_options_005( string $name, mixed $fallback ): mixed { delete_option( $name ); return get_option( $name, $fallback ); }", "metadata": { "source_refs": [ - "src/wp-includes/option.php", - "src/wp-admin/includes/plugin.php" + "src/wp-includes/option.php" ], "release_focus": "classic" } diff --git a/datasets/suites/wp-core-v1/execution/shortcodes.json b/datasets/suites/wp-core-v1/execution/shortcodes.json index 4ad6279..7f177f6 100644 --- a/datasets/suites/wp-core-v1/execution/shortcodes.json +++ b/datasets/suites/wp-core-v1/execution/shortcodes.json @@ -12,11 +12,12 @@ "id": "e-shortcodes-001", "category": "shortcodes", "difficulty": "intermediate", - "prompt": "Implement wpbp_shortcodes_001() to register a greeting shortcode with a sanitized name attribute.", - "expected_behavior": "Reviewer contract: `wpbp_shortcodes_001()` must register a greeting shortcode with a sanitized name attribute. Review focus: Use shortcode APIs; Escape rendered shortcode output. Static checks intentionally require add_shortcode, shortcode_atts, esc_html. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "prompt": "Implement wpbp_shortcodes_001() to register a wpbp_greeting shortcode that returns a safe greeting for an optional name attribute.", + "expected_behavior": "`wpbp_shortcodes_001()` registers `wpbp_greeting`. The shortcode merges the optional `name` attribute with a `World` default via WordPress shortcode attribute handling and returns `Hello, !` with the name escaped for HTML. Runtime validation renders the shortcode with omitted, plain, and HTML-containing names.", "requirements": [ - "Use shortcode APIs", - "Escape rendered shortcode output" + "Register the shortcode tag wpbp_greeting", + "Default the name to World when omitted", + "Return escaped shortcode output; do not echo it" ], "static_checks": { "required_patterns": [ @@ -30,6 +31,11 @@ "description": "Uses add_shortcode", "weight": 1 }, + { + "pattern": "wpbp_greeting", + "description": "Registers the requested shortcode tag", + "weight": 1 + }, { "pattern": "shortcode_atts", "description": "Uses shortcode_atts", @@ -46,8 +52,8 @@ "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_shortcodes_001' ) ) { return false; } wpbp_shortcodes_001(); $out = do_shortcode( '[wpbp_greeting name=\"Ada\"]' ); remove_shortcode( 'wpbp_greeting' ); return 'Hello, Ada!' === $out;", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_shortcodes_001' ) ) { return false; } wpbp_shortcodes_001(); $default = do_shortcode( '[wpbp_greeting]' ); $named = do_shortcode( '[wpbp_greeting name=\"Ada\"]' ); $escaped = do_shortcode( '[wpbp_greeting name=\"Ada\"]' ); remove_shortcode( 'wpbp_greeting' ); return 'Hello, World!' === $default && 'Hello, Ada!' === $named && 'Hello, <b>Ada</b>!' === $escaped;", + "description": "The greeting shortcode applies defaults and escapes the rendered name", "weight": 1 } ] @@ -63,12 +69,13 @@ { "id": "e-shortcodes-002", "category": "shortcodes", - "difficulty": "intermediate", - "prompt": "Implement wpbp_shortcodes_002() to parse shortcode attributes without executing the shortcode.", - "expected_behavior": "Reviewer contract: `wpbp_shortcodes_002()` must parse shortcode attributes without executing the shortcode. Review focus: Use shortcode APIs; Escape rendered shortcode output. Static checks intentionally require shortcode_parse_atts. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "difficulty": "basic", + "prompt": "Implement wpbp_shortcodes_002( string $text ): array to parse a shortcode attribute string into WordPress's attribute array without running shortcode callbacks.", + "expected_behavior": "`wpbp_shortcodes_002()` delegates parsing to WordPress's shortcode attribute parser, returning lowercase named keys and string values from the supplied attribute text. It must not run shortcode callbacks while parsing. Runtime validation registers a probe shortcode, parses mixed-case attributes plus probe-looking text, and verifies the probe was not executed.", "requirements": [ - "Use shortcode APIs", - "Escape rendered shortcode output" + "Use WordPress's shortcode attribute parser", + "Return the parsed attributes array", + "Do not execute shortcode callbacks" ], "static_checks": { "required_patterns": [ @@ -82,14 +89,21 @@ "description": "Uses shortcode_parse_atts", "weight": 1 } + ], + "forbidden_patterns": [ + { + "pattern": "/\\b(?:do_shortcode|apply_shortcodes)\\b/", + "description": "Parsing attributes must not execute shortcode callbacks", + "severity": "error" + } ] }, "runtime_checks": { "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_shortcodes_002' ) ) { return false; } $atts = wpbp_shortcodes_002( 'name=\"Ada\" count=\"3\"' ); return 'Ada' === $atts['name'] && '3' === $atts['count'];", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_shortcodes_002' ) ) { return false; } $GLOBALS['wpbp_shortcodes_002_runs'] = 0; add_shortcode( 'wpbp_parse_probe', function () { $GLOBALS['wpbp_shortcodes_002_runs']++; return 'ran'; } ); $atts = wpbp_shortcodes_002( 'Name=\"Ada\" count=\"3\" [wpbp_parse_probe]' ); $runs = $GLOBALS['wpbp_shortcodes_002_runs']; remove_shortcode( 'wpbp_parse_probe' ); unset( $GLOBALS['wpbp_shortcodes_002_runs'] ); return is_array( $atts ) && 'Ada' === ( $atts['name'] ?? null ) && '3' === ( $atts['count'] ?? null ) && 0 === $runs;", + "description": "Attribute parsing lowercases named keys and does not execute shortcode callbacks", "weight": 1 } ] @@ -105,12 +119,13 @@ { "id": "e-shortcodes-003", "category": "shortcodes", - "difficulty": "intermediate", - "prompt": "Implement wpbp_shortcodes_003() to strip only registered shortcodes from content.", - "expected_behavior": "Reviewer contract: `wpbp_shortcodes_003()` must strip only registered shortcodes from content. Review focus: Use shortcode APIs; Escape rendered shortcode output. Static checks intentionally require strip_shortcodes. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "difficulty": "basic", + "prompt": "Implement wpbp_shortcodes_003( string $content ): string to remove registered shortcode occurrences from content while leaving unknown shortcode-like text intact.", + "expected_behavior": "`wpbp_shortcodes_003()` uses WordPress shortcode stripping so only currently registered shortcode tags are removed. Enclosing shortcode matches are removed by WordPress, while unregistered bracketed content is preserved. Runtime validation registers one tag and compares the filtered content against an unknown tag.", "requirements": [ - "Use shortcode APIs", - "Escape rendered shortcode output" + "Use WordPress Shortcode API", + "Accept and return content as a string", + "Preserve unregistered shortcode-like text" ], "static_checks": { "required_patterns": [ @@ -130,8 +145,8 @@ "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_shortcodes_003' ) ) { return false; } add_shortcode( 'wpbp_strip', fn() => 'X' ); $out = wpbp_shortcodes_003( 'A [wpbp_strip] B' ); remove_shortcode( 'wpbp_strip' ); return trim( $out ) === 'A B';", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_shortcodes_003' ) ) { return false; } add_shortcode( 'wpbp_strip', fn() => 'ignored' ); $out = wpbp_shortcodes_003( 'A [wpbp_strip]Keep[/wpbp_strip] B [wpbp_unknown]Stay[/wpbp_unknown]' ); remove_shortcode( 'wpbp_strip' ); return 'A B [wpbp_unknown]Stay[/wpbp_unknown]' === $out;", + "description": "Only registered shortcode occurrences are stripped and unknown shortcode-like text remains", "weight": 1 } ] @@ -147,12 +162,13 @@ { "id": "e-shortcodes-004", "category": "shortcodes", - "difficulty": "intermediate", - "prompt": "Implement wpbp_shortcodes_004() to detect whether content contains a specific shortcode.", - "expected_behavior": "Reviewer contract: `wpbp_shortcodes_004()` must detect whether content contains a specific shortcode. Review focus: Use shortcode APIs; Escape rendered shortcode output. Static checks intentionally require has_shortcode. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "difficulty": "basic", + "prompt": "Implement wpbp_shortcodes_004( string $content, string $tag ): bool to report whether content contains a registered shortcode tag, including nested shortcode content.", + "expected_behavior": "`wpbp_shortcodes_004()` delegates shortcode detection to WordPress, so it only reports true for shortcode tags that are registered and can find a tag nested inside another shortcode's enclosed content. Runtime validation registers outer/inner fixture shortcodes, checks nested detection, then verifies an unregistered tag is not reported.", "requirements": [ - "Use shortcode APIs", - "Escape rendered shortcode output" + "Use WordPress Shortcode API", + "Accept content and tag inputs", + "Return a boolean result without rendering the shortcode" ], "static_checks": { "required_patterns": [ @@ -166,14 +182,21 @@ "description": "Uses has_shortcode", "weight": 1 } + ], + "forbidden_patterns": [ + { + "pattern": "/\\b(?:do_shortcode|apply_shortcodes)\\b/", + "description": "Detection must not render shortcode callbacks", + "severity": "error" + } ] }, "runtime_checks": { "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_shortcodes_004' ) ) { return false; } return wpbp_shortcodes_004( 'Before [gallery ids=\"1\"]', 'gallery' ) && ! wpbp_shortcodes_004( 'Nope', 'gallery' );", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_shortcodes_004' ) ) { return false; } add_shortcode( 'wpbp_outer', fn( $atts, $content = '' ) => $content ); add_shortcode( 'wpbp_inner', fn() => 'inner' ); $content = '[wpbp_outer]Before [wpbp_inner] after[/wpbp_outer] [wpbp_missing]'; $nested = wpbp_shortcodes_004( $content, 'wpbp_inner' ); $missing = wpbp_shortcodes_004( $content, 'wpbp_missing' ); remove_shortcode( 'wpbp_outer' ); remove_shortcode( 'wpbp_inner' ); return true === $nested && false === $missing;", + "description": "Registered nested shortcodes are detected and unregistered tags are ignored", "weight": 1 } ] @@ -190,11 +213,12 @@ "id": "e-shortcodes-005", "category": "shortcodes", "difficulty": "intermediate", - "prompt": "Implement wpbp_shortcodes_005() to register a wrapping shortcode that receives enclosed content.", - "expected_behavior": "Reviewer contract: `wpbp_shortcodes_005()` must register a wrapping shortcode that receives enclosed content. Review focus: Use shortcode APIs; Escape rendered shortcode output. Static checks intentionally require add_shortcode, esc_html. The runtime checks execute the function in WordPress and verify the observable return value or side effect.", + "prompt": "Implement wpbp_shortcodes_005() to register a wpbp_wrap enclosing shortcode that returns its enclosed content inside a span with the content escaped for HTML.", + "expected_behavior": "`wpbp_shortcodes_005()` registers `wpbp_wrap` as an enclosing shortcode. The callback receives enclosed content, returns `...escaped content...`, and does not echo output. Runtime validation renders plain and HTML-containing enclosed content through `do_shortcode()`.", "requirements": [ - "Use shortcode APIs", - "Escape rendered shortcode output" + "Register the shortcode tag wpbp_wrap", + "Read the shortcode's enclosed content argument", + "Return escaped markup; do not echo it" ], "static_checks": { "required_patterns": [ @@ -208,6 +232,11 @@ "description": "Uses add_shortcode", "weight": 1 }, + { + "pattern": "wpbp_wrap", + "description": "Registers the requested shortcode tag", + "weight": 1 + }, { "pattern": "esc_html", "description": "Uses esc_html", @@ -219,8 +248,8 @@ "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_shortcodes_005' ) ) { return false; } wpbp_shortcodes_005(); $out = do_shortcode( '[wpbp_wrap]Safe[/wpbp_wrap]' ); remove_shortcode( 'wpbp_wrap' ); return 'Safe' === $out;", - "description": "Reference behavior is correct", + "code": "if ( ! function_exists( 'wpbp_shortcodes_005' ) ) { return false; } wpbp_shortcodes_005(); $plain = do_shortcode( '[wpbp_wrap]Safe[/wpbp_wrap]' ); $escaped = do_shortcode( '[wpbp_wrap]Ada & Co[/wpbp_wrap]' ); remove_shortcode( 'wpbp_wrap' ); return 'Safe' === $plain && '<strong>Ada</strong> & Co' === $escaped;", + "description": "The enclosing shortcode returns escaped content inside a span", "weight": 1 } ] From b27b1b06504846e4d814a914925186c86aaa6ce1 Mon Sep 17 00:00:00 2001 From: Jason Adams Date: Tue, 9 Jun 2026 16:35:12 -0600 Subject: [PATCH 16/16] fix: add teardown to fixture-creating execution tests Co-Authored-By: Claude Fable 5 --- .../execution/post-types-taxonomy.json | 8 ++-- .../suites/wp-core-v1/execution/queries.json | 42 ++++++++++++------- .../suites/wp-core-v1/execution/rest-api.json | 4 +- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/datasets/suites/wp-core-v1/execution/post-types-taxonomy.json b/datasets/suites/wp-core-v1/execution/post-types-taxonomy.json index 57f951b..3542b63 100644 --- a/datasets/suites/wp-core-v1/execution/post-types-taxonomy.json +++ b/datasets/suites/wp-core-v1/execution/post-types-taxonomy.json @@ -200,7 +200,7 @@ "category": "post-types-taxonomy", "difficulty": "intermediate", "prompt": "Implement wpbp_post_types_taxonomy_005() to insert a term and return its slug and taxonomy.", - "expected_behavior": "`wpbp_post_types_taxonomy_005()` inserts a category term, reads it back through WordPress term APIs, and returns its slug, taxonomy, and term ID so runtime cleanup can remove it.", + "expected_behavior": "`wpbp_post_types_taxonomy_005()` inserts a category term with the supplied name, reads it back through WordPress term APIs, and returns its slug, taxonomy, and term ID.", "requirements": [ "Use registration APIs", "Clean up registered types when possible" @@ -225,14 +225,16 @@ ] }, "runtime_checks": { + "setup": "$GLOBALS['wpbp_post_types_taxonomy_005_name'] = 'WPBP Term Insert ' . wp_rand();", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_005' ) ) { return false; } $out = wpbp_post_types_taxonomy_005( 'WPBP Term Insert ' . wp_rand() ); $ok = is_array( $out ) && 'category' === $out[1]; wp_delete_term( $out[2], 'category' ); return $ok;", + "code": "if ( ! function_exists( 'wpbp_post_types_taxonomy_005' ) ) { return false; } $out = wpbp_post_types_taxonomy_005( $GLOBALS['wpbp_post_types_taxonomy_005_name'] ); return is_array( $out ) && 'category' === ( $out[1] ?? '' );", "description": "The inserted category term can be read back from WordPress", "weight": 1 } - ] + ], + "teardown": "$name = (string) ( $GLOBALS['wpbp_post_types_taxonomy_005_name'] ?? '' ); if ( '' !== $name ) { $term = get_term_by( 'name', $name, 'category' ); if ( $term ) { wp_delete_term( (int) $term->term_id, 'category' ); } } unset( $GLOBALS['wpbp_post_types_taxonomy_005_name'] );" }, "reference_solution": "function wpbp_post_types_taxonomy_005( string $name ): array { $term = wp_insert_term( $name, 'category' ); if ( is_wp_error( $term ) ) { return array( '', '', 0 ); } return array( get_term_field( 'slug', $term['term_id'], 'category' ), get_term( $term['term_id'] )->taxonomy, $term['term_id'] ); }", "metadata": { diff --git a/datasets/suites/wp-core-v1/execution/queries.json b/datasets/suites/wp-core-v1/execution/queries.json index 1d7ae8e..cf71d24 100644 --- a/datasets/suites/wp-core-v1/execution/queries.json +++ b/datasets/suites/wp-core-v1/execution/queries.json @@ -38,14 +38,16 @@ ] }, "runtime_checks": { + "setup": "$suffix = (string) wp_rand(); $slug = 'wpbp-news-' . $suffix; $cat = wp_insert_term( 'WPBP News ' . $suffix, 'category', array( 'slug' => $slug ) ); $term_id = is_wp_error( $cat ) ? 0 : (int) $cat['term_id']; $post_id = $term_id ? (int) wp_insert_post( array( 'post_title' => 'Q1 ' . $suffix, 'post_status' => 'publish', 'post_category' => array( $term_id ) ) ) : 0; $GLOBALS['wpbp_queries_001'] = array( 'slug' => $slug, 'term' => $term_id, 'post' => $post_id );", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_queries_001' ) ) { return false; } $suffix = (string) wp_rand(); $slug = 'wpbp-news-' . $suffix; $cat = wp_insert_term( 'WPBP News ' . $suffix, 'category', array( 'slug' => $slug ) ); if ( is_wp_error( $cat ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Q1 ' . $suffix, 'post_status' => 'publish', 'post_category' => array( $cat['term_id'] ) ) ); $q = wpbp_queries_001( $slug, 3 ); $ok = in_array( $id, wp_list_pluck( $q->posts, 'ID' ), true ); wp_delete_post( $id, true ); wp_delete_term( $cat['term_id'], 'category' ); return $ok;", + "code": "if ( ! function_exists( 'wpbp_queries_001' ) ) { return false; } $fixture = $GLOBALS['wpbp_queries_001'] ?? array(); if ( empty( $fixture['post'] ) ) { return false; } $q = wpbp_queries_001( $fixture['slug'], 3 ); return in_array( $fixture['post'], array_map( 'intval', wp_list_pluck( $q->posts, 'ID' ) ), true );", "description": "The query returns the published post in the requested category", "weight": 1 } - ] + ], + "teardown": "$fixture = $GLOBALS['wpbp_queries_001'] ?? array(); if ( ! empty( $fixture['post'] ) ) { wp_delete_post( (int) $fixture['post'], true ); } if ( ! empty( $fixture['term'] ) ) { wp_delete_term( (int) $fixture['term'], 'category' ); } unset( $GLOBALS['wpbp_queries_001'] );" }, "reference_solution": "function wpbp_queries_001( string $slug, int $limit = 5 ): WP_Query { return new WP_Query( array( 'category_name' => $slug, 'posts_per_page' => $limit, 'post_status' => 'publish', 'no_found_rows' => true ) ); }", "metadata": { @@ -144,14 +146,16 @@ ] }, "runtime_checks": { + "setup": "$needle = 'Needle' . wp_rand(); $id = (int) wp_insert_post( array( 'post_title' => $needle . ' Alpha', 'post_status' => 'publish' ) ); $GLOBALS['wpbp_queries_003'] = array( 'needle' => $needle, 'post' => $id );", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_queries_003' ) ) { return false; } $needle = 'Needle' . wp_rand(); $id = wp_insert_post( array( 'post_title' => $needle . ' Alpha', 'post_status' => 'publish' ) ); $ids = wpbp_queries_003( $needle ); $ok = in_array( $id, $ids, true ); wp_delete_post( $id, true ); return $ok;", + "code": "if ( ! function_exists( 'wpbp_queries_003' ) ) { return false; } $fixture = $GLOBALS['wpbp_queries_003'] ?? array(); if ( empty( $fixture['post'] ) ) { return false; } $ids = wpbp_queries_003( $fixture['needle'] ); return in_array( $fixture['post'], array_map( 'intval', (array) $ids ), true );", "description": "The search query returns matching post IDs", "weight": 1 } - ] + ], + "teardown": "$fixture = $GLOBALS['wpbp_queries_003'] ?? array(); if ( ! empty( $fixture['post'] ) ) { wp_delete_post( (int) $fixture['post'], true ); } unset( $GLOBALS['wpbp_queries_003'] );" }, "reference_solution": "function wpbp_queries_003( string $term ): array { $q = new WP_Query( array( 's' => $term, 'fields' => 'ids', 'post_status' => 'publish' ) ); return $q->posts; }", "metadata": { @@ -259,14 +263,16 @@ ] }, "runtime_checks": { + "setup": "$GLOBALS['wpbp_queries_005_post'] = (int) wp_insert_post( array( 'post_title' => 'Date ' . wp_rand(), 'post_status' => 'future', 'post_date' => '2099-01-05 00:00:00' ) );", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_queries_005' ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Date ' . wp_rand(), 'post_status' => 'future', 'post_date' => '2099-01-05 00:00:00' ) ); $q = wpbp_queries_005( '2099-01-01' ); $ok = in_array( $id, wp_list_pluck( $q->posts, 'ID' ), true ); wp_delete_post( $id, true ); return $ok;", + "code": "if ( ! function_exists( 'wpbp_queries_005' ) ) { return false; } $id = (int) ( $GLOBALS['wpbp_queries_005_post'] ?? 0 ); if ( ! $id ) { return false; } $q = wpbp_queries_005( '2099-01-01' ); return in_array( $id, array_map( 'intval', wp_list_pluck( $q->posts, 'ID' ) ), true );", "description": "The query returns future posts after the supplied date", "weight": 1 } - ] + ], + "teardown": "$id = (int) ( $GLOBALS['wpbp_queries_005_post'] ?? 0 ); if ( $id ) { wp_delete_post( $id, true ); } unset( $GLOBALS['wpbp_queries_005_post'] );" }, "reference_solution": "function wpbp_queries_005( string $after ): WP_Query { return new WP_Query( array( 'post_status' => 'future', 'posts_per_page' => -1, 'date_query' => array( array( 'after' => $after, 'inclusive' => true ) ) ) ); }", "metadata": { @@ -308,14 +314,16 @@ ] }, "runtime_checks": { + "setup": "$u = wp_insert_user( array( 'user_login' => 'wpbp_query_user_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); $GLOBALS['wpbp_queries_006_user'] = is_wp_error( $u ) ? 0 : (int) $u;", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_queries_006' ) ) { return false; } $u = wp_insert_user( array( 'user_login' => 'wpbp_query_user_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); $q = wpbp_queries_006( 'subscriber' ); $ok = in_array( $u, array_map( 'intval', $q->get_results() ), true ); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); return $ok;", + "code": "if ( ! function_exists( 'wpbp_queries_006' ) ) { return false; } $u = (int) ( $GLOBALS['wpbp_queries_006_user'] ?? 0 ); if ( ! $u ) { return false; } $q = wpbp_queries_006( 'subscriber' ); return in_array( $u, array_map( 'intval', $q->get_results() ), true );", "description": "The user query returns users with the requested role", "weight": 1 } - ] + ], + "teardown": "$u = (int) ( $GLOBALS['wpbp_queries_006_user'] ?? 0 ); if ( $u ) { require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $u ); } unset( $GLOBALS['wpbp_queries_006_user'] );" }, "reference_solution": "function wpbp_queries_006( string $role ): WP_User_Query { return new WP_User_Query( array( 'role' => $role, 'fields' => 'ID' ) ); }", "metadata": { @@ -352,14 +360,16 @@ ] }, "runtime_checks": { + "setup": "$p = (int) wp_insert_post( array( 'post_title' => 'Commented', 'post_status' => 'publish' ) ); $c = $p ? (int) wp_insert_comment( array( 'comment_post_ID' => $p, 'comment_content' => 'Hi', 'comment_approved' => 1 ) ) : 0; $GLOBALS['wpbp_queries_007'] = array( 'post' => $p, 'comment' => $c );", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_queries_007' ) ) { return false; } $p = wp_insert_post( array( 'post_title' => 'Commented', 'post_status' => 'publish' ) ); $c = wp_insert_comment( array( 'comment_post_ID' => $p, 'comment_content' => 'Hi', 'comment_approved' => 1 ) ); $comments = wpbp_queries_007( $p ); $ok = in_array( $c, wp_list_pluck( $comments, 'comment_ID' ) ); wp_delete_comment( $c, true ); wp_delete_post( $p, true ); return $ok;", + "code": "if ( ! function_exists( 'wpbp_queries_007' ) ) { return false; } $fixture = $GLOBALS['wpbp_queries_007'] ?? array(); if ( empty( $fixture['comment'] ) ) { return false; } $comments = wpbp_queries_007( $fixture['post'] ); return in_array( $fixture['comment'], array_map( 'intval', wp_list_pluck( $comments, 'comment_ID' ) ), true );", "description": "The comment query returns the approved comment for the post", "weight": 1 } - ] + ], + "teardown": "$fixture = $GLOBALS['wpbp_queries_007'] ?? array(); if ( ! empty( $fixture['comment'] ) ) { wp_delete_comment( (int) $fixture['comment'], true ); } if ( ! empty( $fixture['post'] ) ) { wp_delete_post( (int) $fixture['post'], true ); } unset( $GLOBALS['wpbp_queries_007'] );" }, "reference_solution": "function wpbp_queries_007( int $post_id ): array { $q = new WP_Comment_Query( array( 'post_id' => $post_id, 'status' => 'approve' ) ); return $q->comments; }", "metadata": { @@ -401,14 +411,16 @@ ] }, "runtime_checks": { + "setup": "$suffix = (string) wp_rand(); $term = wp_insert_term( 'WPBP Empty Term ' . $suffix, 'category', array( 'slug' => 'wpbp-empty-' . $suffix ) ); $GLOBALS['wpbp_queries_008_term'] = is_wp_error( $term ) ? 0 : (int) $term['term_id'];", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_queries_008' ) ) { return false; } $suffix = (string) wp_rand(); $term = wp_insert_term( 'WPBP Empty Term ' . $suffix, 'category', array( 'slug' => 'wpbp-empty-' . $suffix ) ); if ( is_wp_error( $term ) ) { return false; } $ids = wpbp_queries_008( 'category' ); $ok = in_array( (int) $term['term_id'], array_map( 'intval', $ids ), true ); wp_delete_term( $term['term_id'], 'category' ); return $ok;", + "code": "if ( ! function_exists( 'wpbp_queries_008' ) ) { return false; } $term_id = (int) ( $GLOBALS['wpbp_queries_008_term'] ?? 0 ); if ( ! $term_id ) { return false; } $ids = wpbp_queries_008( 'category' ); return in_array( $term_id, array_map( 'intval', (array) $ids ), true );", "description": "The term query includes empty terms", "weight": 1 } - ] + ], + "teardown": "$term_id = (int) ( $GLOBALS['wpbp_queries_008_term'] ?? 0 ); if ( $term_id ) { wp_delete_term( $term_id, 'category' ); } unset( $GLOBALS['wpbp_queries_008_term'] );" }, "reference_solution": "function wpbp_queries_008( string $taxonomy ): array { $q = new WP_Term_Query( array( 'taxonomy' => $taxonomy, 'hide_empty' => false, 'fields' => 'ids' ) ); return $q->terms; }", "metadata": { @@ -502,14 +514,16 @@ ] }, "runtime_checks": { + "setup": "$id = (int) wp_insert_post( array( 'post_title' => 'Meta Cache', 'post_status' => 'publish' ) ); if ( $id ) { update_post_meta( $id, 'wpbp_key', 'yes' ); } $GLOBALS['wpbp_queries_010_post'] = $id;", "assertions": [ { "type": "custom_assertion", - "code": "if ( ! function_exists( 'wpbp_queries_010' ) ) { return false; } $id = wp_insert_post( array( 'post_title' => 'Meta Cache', 'post_status' => 'publish' ) ); update_post_meta( $id, 'wpbp_key', 'yes' ); $out = wpbp_queries_010( array( $id ), 'wpbp_key' ); wp_delete_post( $id, true ); return $out[$id] === 'yes';", + "code": "if ( ! function_exists( 'wpbp_queries_010' ) ) { return false; } $id = (int) ( $GLOBALS['wpbp_queries_010_post'] ?? 0 ); if ( ! $id ) { return false; } $out = wpbp_queries_010( array( $id ), 'wpbp_key' ); return isset( $out[ $id ] ) && 'yes' === $out[ $id ];", "description": "The helper returns meta values after priming the post meta cache", "weight": 1 } - ] + ], + "teardown": "$id = (int) ( $GLOBALS['wpbp_queries_010_post'] ?? 0 ); if ( $id ) { wp_delete_post( $id, true ); } unset( $GLOBALS['wpbp_queries_010_post'] );" }, "reference_solution": "function wpbp_queries_010( array $post_ids, string $key ): array { update_meta_cache( 'post', $post_ids ); $out = array(); foreach ( $post_ids as $post_id ) { $out[ $post_id ] = get_post_meta( $post_id, $key, true ); } return $out; }", "metadata": { diff --git a/datasets/suites/wp-core-v1/execution/rest-api.json b/datasets/suites/wp-core-v1/execution/rest-api.json index f802bfe..dce9d14 100644 --- a/datasets/suites/wp-core-v1/execution/rest-api.json +++ b/datasets/suites/wp-core-v1/execution/rest-api.json @@ -570,6 +570,7 @@ ] }, "runtime_checks": { + "setup": "global $wpdb; $GLOBALS['wpbp_rest_api_011_max_user'] = (int) $wpdb->get_var( \"SELECT MAX(ID) FROM {$wpdb->users}\" );", "assertions": [ { "type": "custom_assertion", @@ -577,7 +578,8 @@ "description": "Authorization status differs for logged-out and logged-in users", "weight": 1 } - ] + ], + "teardown": "global $wpdb; $max = (int) ( $GLOBALS['wpbp_rest_api_011_max_user'] ?? 0 ); if ( $max > 0 ) { $ids = $wpdb->get_col( $wpdb->prepare( \"SELECT ID FROM {$wpdb->users} WHERE ID > %d\", $max ) ); if ( $ids ) { require_once ABSPATH . 'wp-admin/includes/user.php'; foreach ( $ids as $user_id ) { wp_delete_user( (int) $user_id ); } } } unset( $GLOBALS['wpbp_rest_api_011_max_user'] );" }, "reference_solution": "function wpbp_rest_api_011(): array { wp_set_current_user( 0 ); $logged_out = rest_authorization_required_code(); $user_id = wp_insert_user( array( 'user_login' => 'wpbp_rest_user_' . wp_rand(), 'user_pass' => wp_generate_password(), 'role' => 'subscriber' ) ); wp_set_current_user( $user_id ); $logged_in = rest_authorization_required_code(); require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user( $user_id ); wp_set_current_user( 0 ); return array( $logged_out, $logged_in ); }", "metadata": {