From de4029e72378b59b1e5028e68bd1e72fcaa982ad Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Tue, 1 Dec 2026 03:17:52 +0000 Subject: [PATCH 1/2] refactor(core)!: delete legacy input-shape aliases for tools, bundles, schemas, and post identity --- .../docs/core-system/tool-manager.md | 11 +- .../docs/core-system/wordpress-components.md | 2 +- .../docs/development/hooks/engine-filters.md | 22 +- .../handlers/publish/handlers-overview.md | 24 ++- .../handlers/publish/wordpress-publish.md | 10 +- .../Content/InsertContentAbility.php | 44 ++-- .../Abilities/Content/UpsertPostAbility.php | 195 +++++++----------- .../inc/Core/Agents/AgentBundler.php | 108 +--------- .../PostIdentityReservations.php | 12 +- .../Core/WordPress/WordPressPublishHelper.php | 14 +- .../inc/Engine/AI/ToolSchemaNormalizer.php | 135 +----------- .../inc/Engine/AI/Tools/ToolManager.php | 17 +- .../inc/Engine/Agents/AgentSubagentGraph.php | 11 - .../Content/UpsertPostAbilityTest.php | 79 ++++--- .../Core/Agents/AgentBundlerImportTest.php | 7 +- .../WordPress/WordPressPublishHelperTest.php | 76 ++++--- .../tests/ability-tool-source-smoke.php | 12 +- ...-bundle-export-config-projection-smoke.php | 7 +- .../agent-bundle-subagent-graph-smoke.php | 12 +- .../agent-bundler-directory-adapter-smoke.php | 20 +- .../tests/content-format-abilities-smoke.php | 4 +- .../tests/tool-schema-normalizer-smoke.php | 42 +--- .../tests/wp-ai-client-tool-schema-smoke.php | 47 ----- 23 files changed, 299 insertions(+), 612 deletions(-) diff --git a/plugins/data-machine/docs/core-system/tool-manager.md b/plugins/data-machine/docs/core-system/tool-manager.md index a0731d7d29..641ede8712 100644 --- a/plugins/data-machine/docs/core-system/tool-manager.md +++ b/plugins/data-machine/docs/core-system/tool-manager.md @@ -48,11 +48,14 @@ The `_callable` wrapper defers the full definition until a resolver needs it. Th array( 'description' => 'Search the My Plugin index.', 'parameters' => array( - 'query' => array( - 'type' => 'string', - 'required' => true, - 'description' => 'Search terms.', + 'type' => 'object', + 'properties' => array( + 'query' => array( + 'type' => 'string', + 'description' => 'Search terms.', + ), ), + 'required' => array( 'query' ), ), 'class' => MySearchTool::class, 'method' => 'handle_tool_call', diff --git a/plugins/data-machine/docs/core-system/wordpress-components.md b/plugins/data-machine/docs/core-system/wordpress-components.md index bf97b1e83e..cac5fef2a5 100644 --- a/plugins/data-machine/docs/core-system/wordpress-components.md +++ b/plugins/data-machine/docs/core-system/wordpress-components.md @@ -53,7 +53,7 @@ Apply source URL attribution to content based on configuration. **Process**: 1. Check configuration (`link_handling` = 'append') 2. Validate source URL -3. Read the declared `content_format` from handler config (`html`, `markdown`, or `blocks`) +3. Read the explicit `content_format` from config (`html`, `markdown`, or `blocks`; defaults to `html`) 4. Generate source attribution in the same source format 5. Append to content diff --git a/plugins/data-machine/docs/development/hooks/engine-filters.md b/plugins/data-machine/docs/development/hooks/engine-filters.md index f8bd29bda2..9656bc9931 100644 --- a/plugins/data-machine/docs/development/hooks/engine-filters.md +++ b/plugins/data-machine/docs/development/hooks/engine-filters.md @@ -97,11 +97,14 @@ $tools = apply_filters( 'datamachine_tools', array() ); 'method' => 'handle_tool_call', 'description' => 'Clear, AI-readable description.', 'parameters' => [ - 'query' => [ - 'type' => 'string', - 'required' => true, - 'description' => 'Search query', + 'type' => 'object', + 'properties' => [ + 'query' => [ + 'type' => 'string', + 'description' => 'Search query', + ], ], + 'required' => ['query'], ], 'modes' => ['system'], // which modes can see this tool (required) 'requires_config' => true, // checked via datamachine_tool_configured @@ -119,11 +122,14 @@ add_filter( 'datamachine_tools', function ( $tools ) { 'method' => 'handle_tool_call', 'description' => 'Search the My Plugin index.', 'parameters' => [ - 'query' => [ - 'type' => 'string', - 'required' => true, - 'description' => 'Search terms', + 'type' => 'object', + 'properties' => [ + 'query' => [ + 'type' => 'string', + 'description' => 'Search terms', + ], ], + 'required' => ['query'], ], 'modes' => ['system'], 'requires_config' => false, diff --git a/plugins/data-machine/docs/handlers/publish/handlers-overview.md b/plugins/data-machine/docs/handlers/publish/handlers-overview.md index d68b973533..4bd2ff90ef 100644 --- a/plugins/data-machine/docs/handlers/publish/handlers-overview.md +++ b/plugins/data-machine/docs/handlers/publish/handlers-overview.md @@ -120,17 +120,21 @@ add_filter('datamachine_tools', function($tools) { 'handler' => $handler_slug, 'description' => 'Publish content to WordPress', 'parameters' => [ - 'content' => [ - 'type' => 'string', - 'required' => true, - 'description' => 'Content to publish', + 'type' => 'object', + 'properties' => [ + 'content' => [ + 'type' => 'string', + 'description' => 'Content to publish', + ], ], + 'required' => ['content'], ], 'handler_config' => $handler_config, ], ]; }, 'handler' => 'wordpress_publish', + 'client_context_bindings' => ['job_id'], 'modes' => ['pipeline'], 'access_level' => 'admin', ]; @@ -378,17 +382,21 @@ add_filter('datamachine_tools', function($tools) { 'handler' => $handler_slug, 'description' => 'Publish content to custom platform', 'parameters' => [ - 'content' => [ - 'type' => 'string', - 'required' => true, - 'description' => 'Content to publish', + 'type' => 'object', + 'properties' => [ + 'content' => [ + 'type' => 'string', + 'description' => 'Content to publish', + ], ], + 'required' => ['content'], ], 'handler_config' => $handler_config, ], ]; }, 'handler' => 'custom_platform', + 'client_context_bindings' => ['job_id'], 'modes' => ['pipeline'], 'access_level' => 'admin', ]; diff --git a/plugins/data-machine/docs/handlers/publish/wordpress-publish.md b/plugins/data-machine/docs/handlers/publish/wordpress-publish.md index 3365338784..14a34c047a 100644 --- a/plugins/data-machine/docs/handlers/publish/wordpress-publish.md +++ b/plugins/data-machine/docs/handlers/publish/wordpress-publish.md @@ -237,16 +237,20 @@ class WordPress extends PublishHandler { // 3. Get source URL and apply source attribution using helper $source_url = $engine->getSourceUrl(); - $content = WordPressPublishHelper::applySourceAttribution( + $content_format = $parameters['content_format'] ?? 'html'; + $content = WordPressPublishHelper::applySourceAttribution( $parameters['content'], $source_url, - $handler_config + array( + 'link_handling' => 'append', + 'content_format' => $content_format, + ) ); // 4. Convert source content to the post type's stored format $stored_content = ContentFormat::sourceToStored( $content, - $parameters['content_format'] ?? 'html', + $content_format, $handler_config['post_type'] ); diff --git a/plugins/data-machine/inc/Abilities/Content/InsertContentAbility.php b/plugins/data-machine/inc/Abilities/Content/InsertContentAbility.php index f7e09e06c6..c0af63453a 100644 --- a/plugins/data-machine/inc/Abilities/Content/InsertContentAbility.php +++ b/plugins/data-machine/inc/Abilities/Content/InsertContentAbility.php @@ -122,27 +122,31 @@ public static function getToolDefinition(): array { 'method' => 'handleToolCall', 'description' => 'Insert new content into a WordPress post at a specific position (beginning, end, or after a specific paragraph). Returns a canonical preview diff for user review.', 'parameters' => array( - 'post_id' => array( - 'type' => 'integer', - 'description' => 'The post ID to insert content into.', - ), - 'blog_id' => array( - 'type' => 'integer', - 'description' => 'Optional multisite blog ID the post lives on. Omit for the current site.', - ), - 'content' => array( - 'type' => 'string', - 'description' => 'The new content to insert (wrapped in paragraph blocks automatically).', - ), - 'position' => array( - 'type' => 'string', - 'enum' => array( 'beginning', 'end', 'after_paragraph' ), - 'description' => 'Where to insert the content.', - ), - 'target_paragraph_text' => array( - 'type' => 'string', - 'description' => 'Required when position is "after_paragraph". A short phrase (3-8 words) from the target paragraph.', + 'type' => 'object', + 'properties' => array( + 'post_id' => array( + 'type' => 'integer', + 'description' => 'The post ID to insert content into.', + ), + 'blog_id' => array( + 'type' => 'integer', + 'description' => 'Optional multisite blog ID the post lives on. Omit for the current site.', + ), + 'content' => array( + 'type' => 'string', + 'description' => 'The new content to insert (wrapped in paragraph blocks automatically).', + ), + 'position' => array( + 'type' => 'string', + 'enum' => array( 'beginning', 'end', 'after_paragraph' ), + 'description' => 'Where to insert the content.', + ), + 'target_paragraph_text' => array( + 'type' => 'string', + 'description' => 'Required when position is "after_paragraph". A short phrase (3-8 words) from the target paragraph.', + ), ), + 'required' => array( 'post_id', 'content', 'position' ), ), ); } diff --git a/plugins/data-machine/inc/Abilities/Content/UpsertPostAbility.php b/plugins/data-machine/inc/Abilities/Content/UpsertPostAbility.php index 6bfafc0eb5..37e35a2d46 100644 --- a/plugins/data-machine/inc/Abilities/Content/UpsertPostAbility.php +++ b/plugins/data-machine/inc/Abilities/Content/UpsertPostAbility.php @@ -222,58 +222,61 @@ public static function getToolDefinition(): array { 'method' => 'handleToolCall', 'description' => 'Idempotently create or update a WordPress post. For normal authored prose, write content as markdown and omit content_format; Data Machine converts that authoring format to the post type stored format. Only set content_format when you are intentionally providing html or serialized block markup.', 'parameters' => array( - 'post_type' => array( - 'type' => 'string', - 'description' => 'Post type slug.', - ), - 'title' => array( - 'type' => 'string', - 'description' => 'Post title.', - ), - 'content' => array( - 'type' => 'string', - 'description' => 'Post content to author. Use markdown for normal prose unless content_format explicitly says otherwise.', - ), - 'content_format' => array( - 'type' => 'string', - 'enum' => array( 'markdown', 'html', 'blocks' ), - 'description' => 'Optional authoring/source format for content. Omit for normal prose; AI tool calls default to markdown. Set to html or blocks only when content is already in that format. This is distinct from the stored format chosen by the post type.', - ), - 'slug' => array( - 'type' => 'string', - 'description' => 'Post slug for lookup.', - ), - 'parent_id' => array( - 'type' => 'integer', - 'description' => 'Parent post ID.', - ), - 'parent_path' => array( - 'type' => 'string', - 'description' => 'Slash-delimited parent path (e.g. "artist/link-pages").', - ), - 'post_author' => array( - 'type' => 'integer', - 'description' => 'Post author user ID (create only).', - ), - 'content_hash' => array( - 'type' => 'string', - 'description' => 'Hash for idempotency check.', - ), - 'source_url' => array( - 'type' => 'string', - 'description' => 'Original source URL for attribution and dedupe.', - ), - 'original_date_gmt' => array( - 'type' => 'string', - 'description' => 'Original source publication date in GMT.', - ), + 'type' => 'object', + 'properties' => array( + 'post_type' => array( + 'type' => 'string', + 'description' => 'Post type slug.', + ), + 'title' => array( + 'type' => 'string', + 'description' => 'Post title.', + ), + 'content' => array( + 'type' => 'string', + 'description' => 'Post content to author. Use markdown for normal prose unless content_format explicitly says otherwise.', + ), + 'content_format' => array( + 'type' => 'string', + 'enum' => array( 'markdown', 'html', 'blocks' ), + 'description' => 'Optional authoring/source format for content. Omit for normal prose; AI tool calls default to markdown. Set to html or blocks only when content is already in that format. This is distinct from the stored format chosen by the post type.', + ), + 'slug' => array( + 'type' => 'string', + 'description' => 'Post slug for lookup.', + ), + 'parent_id' => array( + 'type' => 'integer', + 'description' => 'Parent post ID.', + ), + 'parent_path' => array( + 'type' => 'string', + 'description' => 'Slash-delimited parent path (e.g. "artist/link-pages").', + ), + 'post_author' => array( + 'type' => 'integer', + 'description' => 'Post author user ID (create only).', + ), + 'content_hash' => array( + 'type' => 'string', + 'description' => 'Hash for idempotency check.', + ), + 'source_url' => array( + 'type' => 'string', + 'description' => 'Original source URL for attribution and dedupe.', + ), + 'original_date_gmt' => array( + 'type' => 'string', + 'description' => 'Original source publication date in GMT.', + ), - 'add_source_attribution' => array( - 'type' => 'boolean', - 'description' => 'When true, append a clickable source link to the stored content when source_url is available.', + 'add_source_attribution' => array( + 'type' => 'boolean', + 'description' => 'When true, append a clickable source link to the stored content when source_url is available.', + ), ), + 'required' => array( 'post_type', 'title', 'content' ), ), - 'required' => array( 'post_type', 'title', 'content' ), ); } @@ -318,7 +321,7 @@ public static function execute( array $input ): array|\WP_Error { $slug = sanitize_title( $input['slug'] ?? '' ); $parent_id = absint( $input['parent_id'] ?? 0 ); $parent_path = trim( $input['parent_path'] ?? '' ); - $identity_meta = $input['identity_meta'] ?? array(); + $identity_meta = ! empty( $input['identity_meta'] ) ? $input['identity_meta'] : null; $content_hash = $input['content_hash'] ?? ''; $raw_source = $input['raw_source'] ?? ''; $source_url = esc_url_raw( (string) ( $input['source_url'] ?? '' ) ); @@ -411,45 +414,28 @@ public static function execute( array $input ): array|\WP_Error { 'meta_input' => $meta_input, ); - if ( $post_id > 0 ) { - $existing_id = self::resolve_existing_post( $post_id, $slug, $parent_id, is_array( $identity_meta ) ? $identity_meta : array(), $post_type ); + // Explicit post IDs are validated up front; slug lookup only runs here + // when no identity is provided (identity writes resolve slugs under lock). + $existing_id = 0; + if ( $post_id > 0 || null === $identity_meta ) { + $existing_id = self::resolve_existing_post( $post_id, $slug, $parent_id, $post_type ); if ( is_wp_error( $existing_id ) ) { - return new \WP_Error( - $existing_id->get_error_code(), - $existing_id->get_error_message(), - array_merge( array( 'status' => 404 ), is_array( $existing_id->get_error_data() ) ? $existing_id->get_error_data() : array() ) - ); - } - - if ( ! self::has_usable_identity_meta( $identity_meta ) ) { - return self::callback_result( self::execute_resolved_write( $write_context, (int) $existing_id ) ); + return new \WP_Error( $existing_id->get_error_code(), $existing_id->get_error_message(), array_merge( array( 'status' => 404 ), is_array( $existing_id->get_error_data() ) ? $existing_id->get_error_data() : array() ) ); } } - if ( self::has_usable_identity_meta( $identity_meta ) ) { + // The post-identity reservations table owns identity: any provided + // identity_meta resolves through it (or fails validation there). + if ( null !== $identity_meta ) { return self::execute_identity_backed( $write_context, - $identity_meta, + is_array( $identity_meta ) ? $identity_meta : array(), $slug, $parent_id, $post_id ); } - // Preserve explicit > identity > slug resolution for omitted, partial, - // empty, and otherwise unusable identity_meta direct-execute inputs. - $existing_id = self::resolve_existing_post( - $post_id, - $slug, - $parent_id, - is_array( $identity_meta ) ? $identity_meta : array(), - $post_type - ); - - if ( is_wp_error( $existing_id ) ) { - return new \WP_Error( $existing_id->get_error_code(), $existing_id->get_error_message(), array_merge( array( 'status' => 404 ), is_array( $existing_id->get_error_data() ) ? $existing_id->get_error_data() : array() ) ); - } - return self::callback_result( self::execute_resolved_write( $write_context, (int) $existing_id ) ); } @@ -535,9 +521,12 @@ private static function authorize_request( array $input ): bool|\WP_Error { // Protected (underscore-prefixed) meta is internal plugin/core state. // Only principals trusted to edit any post of this type may set it. - $meta_keys = is_array( $input['meta_input'] ?? null ) ? array_map( 'strval', array_keys( $input['meta_input'] ) ) : array(); - if ( self::has_usable_identity_meta( $input['identity_meta'] ?? null ) ) { - $meta_keys[] = sanitize_key( (string) $input['identity_meta']['key'] ); + $meta_keys = is_array( $input['meta_input'] ?? null ) ? array_map( 'strval', array_keys( $input['meta_input'] ) ) : array(); + $identity_key = is_array( $input['identity_meta'] ?? null ) && is_string( $input['identity_meta']['key'] ?? null ) + ? sanitize_key( $input['identity_meta']['key'] ) + : ''; + if ( '' !== $identity_key ) { + $meta_keys[] = $identity_key; } foreach ( $meta_keys as $meta_key ) { if ( is_protected_meta( $meta_key, 'post' ) && ! PermissionHelper::can_wp_capability( $caps->edit_others_posts ) ) { @@ -612,7 +601,7 @@ private static function execute_identity_backed( $slug_fallback_id = 0; if ( $explicit_post_id <= 0 && '' !== $slug ) { - $slug_fallback_id = self::resolve_existing_post( 0, $slug, $parent_id, array(), $post_type ); + $slug_fallback_id = self::resolve_existing_post( 0, $slug, $parent_id, $post_type ); if ( is_wp_error( $slug_fallback_id ) ) { return self::callback_result( array( 'success' => false, @@ -991,16 +980,6 @@ private static function execute_resolved_write( ); } - /** Match the historical direct-execute identity_meta truthiness contract. */ - private static function has_usable_identity_meta( $identity_meta ): bool { - if ( ! is_array( $identity_meta ) || empty( $identity_meta['key'] ) || empty( $identity_meta['value'] ) ) { - return false; - } - - return '' !== sanitize_key( (string) $identity_meta['key'] ) - && '' !== sanitize_text_field( (string) $identity_meta['value'] ); - } - /** * Apply source metadata to an existing post when content is unchanged. * @@ -1029,12 +1008,12 @@ private static function applySourceMetadata( int $post_id, string $source_url, ? /** * Resolve an existing post by the provided identity fields. * - * Priority: post_id > identity_meta > slug+parent_id. + * Priority: post_id > slug+parent_id. Identity meta resolves through + * PostIdentityReservations, never through this lookup. * * @param int $post_id Explicit post ID. * @param string $slug Post slug. * @param int $parent_id Parent post ID. - * @param array $identity_meta Custom meta identity. * @param string $post_type Post type. * @return int|\WP_Error Existing post ID, 0 if not found, or WP_Error. */ @@ -1042,7 +1021,6 @@ private static function resolve_existing_post( int $post_id, string $slug, int $parent_id, - array $identity_meta, string $post_type ) { // 1. Explicit post_id. @@ -1058,34 +1036,7 @@ private static function resolve_existing_post( ); } - // 2. Custom meta identity. - if ( ! empty( $identity_meta['key'] ) && ! empty( $identity_meta['value'] ) ) { - $meta_key = sanitize_key( $identity_meta['key'] ); - $meta_value = sanitize_text_field( $identity_meta['value'] ); - - $args = array( - 'post_type' => $post_type, - 'post_status' => 'any', - // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Legacy direct-execute fallback; valid identities use the indexed post-identity-reservations table. - 'meta_query' => array( - array( - 'key' => $meta_key, - 'value' => $meta_value, - ), - ), - 'posts_per_page' => 1, - 'fields' => 'ids', - 'no_found_rows' => true, - ); - - $query = new \WP_Query( $args ); - if ( ! empty( $query->posts ) ) { - $found = $query->posts[0]; - return $found instanceof \WP_Post ? (int) $found->ID : (int) $found; - } - } - - // 3. Slug + parent_id. + // 2. Slug + parent_id. if ( '' !== $slug ) { $args = array( 'post_type' => $post_type, diff --git a/plugins/data-machine/inc/Core/Agents/AgentBundler.php b/plugins/data-machine/inc/Core/Agents/AgentBundler.php index e30fa90380..6efcbd411c 100644 --- a/plugins/data-machine/inc/Core/Agents/AgentBundler.php +++ b/plugins/data-machine/inc/Core/Agents/AgentBundler.php @@ -2596,113 +2596,19 @@ public function to_directory( array $bundle, string $directory ): bool { /** * Read bundle from a directory export. * + * The directory must be a schema-versioned bundle; manifests without + * `schema_version` fail validation. + * * @param string $directory Source directory. - * @return array|null Bundle data or null on failure. + * @return array|null Bundle data, or null when no manifest.json exists. + * @throws BundleValidationException When the bundle is invalid. */ public function from_directory( string $directory ): ?array { - try { - return AgentBundleArrayAdapter::to_array_bundle( AgentBundleDirectory::read( $directory ) ); - } catch ( BundleValidationException $e ) { - if ( $this->is_directory_bundle_schema( $directory ) ) { - throw $e; - } - // Fall through to the legacy monolithic manifest reader for old exports. - } - - $manifest_path = $directory . '/manifest.json'; - if ( ! file_exists( $manifest_path ) ) { + if ( ! file_exists( rtrim( $directory, '/\\' ) . '/manifest.json' ) ) { return null; } - $manifest = json_decode( $this->read_text_file( $manifest_path ), true ); - if ( ! is_array( $manifest ) ) { - return null; - } - - $bundle = $manifest; - - // Read agent identity files. - $agent_dir = $directory . '/agent'; - $bundle['files'] = array(); - if ( is_dir( $agent_dir ) ) { - $bundle['files'] = $this->read_directory_recursive( $agent_dir ); - } - - // Read USER.md template. - $user_md_path = $directory . '/USER.md'; - $bundle['user_template'] = file_exists( $user_md_path ) - ? $this->read_text_file( $user_md_path ) - : ''; - - // Read pipeline memory files. - $pipelines_dir = $directory . '/pipelines'; - if ( is_dir( $pipelines_dir ) ) { - $pipeline_dirs = $this->glob_directories( $pipelines_dir ); - foreach ( $pipeline_dirs as $i => $pipeline_dir ) { - if ( isset( $bundle['pipelines'][ $i ] ) ) { - $bundle['pipelines'][ $i ]['memory_file_contents'] = $this->read_directory_recursive( $pipeline_dir ); - } - } - } - - // Read flow memory files. - $flows_dir = $directory . '/flows'; - if ( is_dir( $flows_dir ) ) { - $flow_dirs = $this->glob_directories( $flows_dir ); - foreach ( $flow_dirs as $i => $flow_dir ) { - if ( isset( $bundle['flows'][ $i ] ) ) { - $bundle['flows'][ $i ]['memory_file_contents'] = $this->read_directory_recursive( $flow_dir ); - } - } - } - - return $bundle; - } - - private function is_directory_bundle_schema( string $directory ): bool { - $manifest_path = rtrim( $directory, '/\\' ) . '/manifest.json'; - if ( ! file_exists( $manifest_path ) ) { - return false; - } - - $manifest = json_decode( $this->read_text_file( $manifest_path ), true ); - return is_array( $manifest ) && array_key_exists( 'schema_version', $manifest ); - } - - /** - * Read all text files from a directory recursively. - * - * @param string $directory Directory to read. - * @param string $prefix Path prefix. - * @return array relative_path => content. - */ - private function read_directory_recursive( string $directory, string $prefix = '' ): array { - $files = array(); - - if ( ! is_dir( $directory ) ) { - return $files; - } - - $iterator = new \DirectoryIterator( $directory ); - foreach ( $iterator as $item ) { - if ( $item->isDot() ) { - continue; - } - - $relative = $prefix . $item->getFilename(); - - if ( $item->isDir() ) { - $sub_files = $this->read_directory_recursive( $item->getPathname(), $relative . '/' ); - $files = array_merge( $files, $sub_files ); - } elseif ( $item->isFile() ) { - $ext = strtolower( $item->getExtension() ); - if ( in_array( $ext, array( 'md', 'txt', 'json', 'yaml', 'yml', 'csv' ), true ) ) { - $files[ $relative ] = $this->read_text_file( $item->getPathname() ); - } - } - } - - return $files; + return AgentBundleArrayAdapter::to_array_bundle( AgentBundleDirectory::read( $directory ) ); } /** diff --git a/plugins/data-machine/inc/Core/Database/PostIdentityReservations/PostIdentityReservations.php b/plugins/data-machine/inc/Core/Database/PostIdentityReservations/PostIdentityReservations.php index 7733d4f098..191d036f08 100644 --- a/plugins/data-machine/inc/Core/Database/PostIdentityReservations/PostIdentityReservations.php +++ b/plugins/data-machine/inc/Core/Database/PostIdentityReservations/PostIdentityReservations.php @@ -683,7 +683,7 @@ protected function resolve_locked( $post_id = $explicit_post_id; $adopted = true; } else { - $candidates = $this->find_legacy_candidates( $identity ); + $candidates = $this->find_posts_identified_by_meta( $identity ); } if ( $explicit_post_id <= 0 && count( $candidates ) > 1 ) { @@ -819,8 +819,14 @@ private function supports_transactional_tables( array $tables ): bool { } } - /** @return int[] */ - protected function find_legacy_candidates( array $identity ): array { + /** + * Find posts already carrying this identity in post meta, so an unlinked + * reservation can adopt the post instead of creating a duplicate. + * + * @param array $identity Normalized identity. + * @return int[] + */ + protected function find_posts_identified_by_meta( array $identity ): array { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $ids = $this->wpdb->get_col( $this->wpdb->prepare( diff --git a/plugins/data-machine/inc/Core/WordPress/WordPressPublishHelper.php b/plugins/data-machine/inc/Core/WordPress/WordPressPublishHelper.php index 19656a7b26..09675b485e 100644 --- a/plugins/data-machine/inc/Core/WordPress/WordPressPublishHelper.php +++ b/plugins/data-machine/inc/Core/WordPress/WordPressPublishHelper.php @@ -109,7 +109,8 @@ public static function attachImageToPost( int $post_id, ?string $image_path, arr * * @param string $content The content to modify. * @param string|null $source_url Source URL to append. - * @param array $config Handler configuration (checks 'link_handling' and 'content_format'). + * @param array $config Handler configuration: 'link_handling' and the explicit + * source 'content_format' (html, markdown, or blocks; defaults to html). * @return string Modified content. */ public static function applySourceAttribution( string $content, ?string $source_url, array $config ): string { @@ -126,9 +127,7 @@ public static function applySourceAttribution( string $content, ?string $source_ return $content; } - $content_format = isset( $config['content_format'] ) - ? sanitize_key( $config['content_format'] ) - : ( self::contentHasBlocks( $content ) ? 'blocks' : 'html' ); + $content_format = sanitize_key( (string) ( $config['content_format'] ?? '' ) ); $content_format = '' !== $content_format ? $content_format : 'html'; if ( 'markdown' === $content_format ) { @@ -142,13 +141,6 @@ public static function applySourceAttribution( string $content, ?string $source_ return $content . "\n\n

Source: {$sanitized_url}

"; } - /** - * Determine whether legacy callers passed block markup without an explicit format. - */ - private static function contentHasBlocks( string $content ): bool { - return strpos( $content, '

Direct body

', + 'post_type' => 'post', + 'post_id' => $post_id, + 'title' => 'Malformed identity ' . $label, + 'content' => '

Direct body

', + 'identity_meta' => $identity_meta, ); - if ( 'omitted' !== $label ) { - $input['identity_meta'] = $identity_meta; - } $result = UpsertPostAbility::execute( $input ); - $this->assertTrue( $result['success'], $label ); - $this->assertSame( 'updated', $result['action'], $label ); - $this->assertSame( $post_id, $result['post_id'], $label ); - $this->assertSame( 'Direct explicit ' . $label, get_post( $post_id )->post_title, $label ); - $this->assertSame( '', get_post_meta( $post_id, '_source', true ), $label ); + $this->assertWPError( $result, $label ); + $this->assertSame( 'invalid_identity_meta', $result->get_error_code(), $label ); + $this->assertNotSame( 'Malformed identity ' . $label, get_post( $post_id )->post_title, $label ); } global $wpdb; diff --git a/plugins/data-machine/tests/Unit/Core/Agents/AgentBundlerImportTest.php b/plugins/data-machine/tests/Unit/Core/Agents/AgentBundlerImportTest.php index 93b752ee06..fcf71bf882 100644 --- a/plugins/data-machine/tests/Unit/Core/Agents/AgentBundlerImportTest.php +++ b/plugins/data-machine/tests/Unit/Core/Agents/AgentBundlerImportTest.php @@ -1293,7 +1293,10 @@ public function test_backup_export_restores_tracking_excluded_agent_config_to_fr $source_config = array( 'default_provider' => 'openai', 'default_model' => 'gpt-5.5', - 'tool_policy' => array( 'allow' => array( 'datamachine/search' ) ), + 'tool_policy' => array( + 'mode' => 'allow', + 'tools' => array( 'datamachine/search' ), + ), 'example_extension' => array( 'graph' => array( 'enabled' => true ) ), 'example' => array( 'runtime_endpoints' => array( 'events' => array( 'url' => 'https://runtime.example.test' ) ), @@ -1381,7 +1384,7 @@ public function test_backup_export_restores_tracking_excluded_agent_config_to_fr $this->assertSame( 7, (int) ( $restored['site_scope'] ?? 0 ), 'Fresh restore preserves site scope.' ); $this->assertSame( 'openai', $restored_config['default_provider'] ?? null ); $this->assertSame( 'gpt-5.5', $restored_config['default_model'] ?? null ); - $this->assertSame( array( 'datamachine/search' ), $restored_config['tool_policy']['allow'] ?? null ); + $this->assertSame( array( 'datamachine/search' ), $restored_config['tool_policy']['tools'] ?? null ); $this->assertTrue( $restored_config['example_extension']['graph']['enabled'] ?? false ); $this->assertSame( 'https://runtime.example.test', $restored_config['example']['runtime_endpoints']['events']['url'] ?? null ); $this->assertSame( 'runtime:events', $restored_config['example']['auth_refs']['events'] ?? null ); diff --git a/plugins/data-machine/tests/Unit/Core/WordPress/WordPressPublishHelperTest.php b/plugins/data-machine/tests/Unit/Core/WordPress/WordPressPublishHelperTest.php index 942924b388..5f8cfc570a 100644 --- a/plugins/data-machine/tests/Unit/Core/WordPress/WordPressPublishHelperTest.php +++ b/plugins/data-machine/tests/Unit/Core/WordPress/WordPressPublishHelperTest.php @@ -10,45 +10,63 @@ use DataMachine\Core\WordPress\WordPressPublishHelper; use WP_UnitTestCase; +/** + * Source attribution follows the explicit content format. + */ class WordPressPublishHelperTest extends WP_UnitTestCase { - public function test_appends_block_attribution_when_blocks_present(): void { - $content = "\n

Content

\n"; + /** + * Blocks format appends a paragraph block. + */ + public function test_appends_block_attribution_for_blocks_format(): void { + $content = "\n

Content

\n"; - $result = WordPressPublishHelper::applySourceAttribution( - $content, - 'https://example.com', - ['link_handling' => 'append'] - ); + $result = WordPressPublishHelper::applySourceAttribution( + $content, + 'https://example.com', + array( + 'link_handling' => 'append', + 'content_format' => 'blocks', + ) + ); - $expected_append = "\n\n\n

Source: https://example.com

\n"; + $expected_append = "\n\n\n

Source: https://example.com

\n"; - $this->assertSame($content . $expected_append, $result); - } + $this->assertSame( $content . $expected_append, $result ); + } - public function test_appends_html_attribution_when_no_blocks_present(): void { - $content = '

Content

'; + /** + * HTML format appends a paragraph tag. + */ + public function test_appends_html_attribution_for_html_format(): void { + $content = '

Content

'; - $result = WordPressPublishHelper::applySourceAttribution( - $content, - 'https://example.com', - ['link_handling' => 'append'] - ); + $result = WordPressPublishHelper::applySourceAttribution( + $content, + 'https://example.com', + array( + 'link_handling' => 'append', + 'content_format' => 'html', + ) + ); - $expected_append = "\n\n

Source: https://example.com

"; + $expected_append = "\n\n

Source: https://example.com

"; - $this->assertSame($content . $expected_append, $result); - } + $this->assertSame( $content . $expected_append, $result ); + } - public function test_skips_attribution_when_url_is_invalid(): void { - $content = '

Content

'; + /** + * Invalid URLs leave content untouched. + */ + public function test_skips_attribution_when_url_is_invalid(): void { + $content = '

Content

'; - $result = WordPressPublishHelper::applySourceAttribution( - $content, - 'not-a-url', - ['link_handling' => 'append'] - ); + $result = WordPressPublishHelper::applySourceAttribution( + $content, + 'not-a-url', + array( 'link_handling' => 'append' ) + ); - $this->assertSame($content, $result); - } + $this->assertSame( $content, $result ); + } } diff --git a/plugins/data-machine/tests/ability-tool-source-smoke.php b/plugins/data-machine/tests/ability-tool-source-smoke.php index 4aa91b1aaf..b795e5d7b4 100644 --- a/plugins/data-machine/tests/ability-tool-source-smoke.php +++ b/plugins/data-machine/tests/ability-tool-source-smoke.php @@ -276,11 +276,14 @@ function resolve_ability_source_tools( string|array $modes, array $extra = array 'Summarize a demo payload.', 'demo-category', array( - 'message' => array( - 'type' => 'string', - 'description' => 'Message to summarize.', - 'required' => true, + 'type' => 'object', + 'properties' => array( + 'message' => array( + 'type' => 'string', + 'description' => 'Message to summarize.', + ), ), + 'required' => array( 'message' ), ), array( 'annotations' => array( @@ -397,7 +400,6 @@ static function ( array $tool, string $tool_name ): array { assert_ability_tool_source_equals( 'Model-facing summary override.', $tools['summarize_demo']['description'] ?? '', 'definition filter can override model-facing description', $failures, $passes ); assert_ability_tool_source_equals( array( 'message' ), $tools['summarize_demo']['parameters']['required'] ?? array(), 'generated parameters come from ability input schema', $failures, $passes ); assert_ability_tool_source_equals( 'object', $tools['summarize_demo']['parameters']['type'] ?? '', 'ability input schema is normalized to root object schema', $failures, $passes ); -assert_ability_tool_source_equals( false, isset( $tools['summarize_demo']['parameters']['properties']['message']['required'] ), 'ability input schema strips property-level required flag', $failures, $passes ); assert_ability_tool_source_equals( true, $tools['summarize_demo']['annotations']['readonly'] ?? false, 'generated tool carries ability annotations', $failures, $passes ); echo "\n[2] source policy handles opt-in, missing abilities, config, and modes:\n"; diff --git a/plugins/data-machine/tests/agent-bundle-export-config-projection-smoke.php b/plugins/data-machine/tests/agent-bundle-export-config-projection-smoke.php index 4bef0ed776..3ff94cd636 100644 --- a/plugins/data-machine/tests/agent-bundle-export-config-projection-smoke.php +++ b/plugins/data-machine/tests/agent-bundle-export-config-projection-smoke.php @@ -179,7 +179,10 @@ function export_config_bundler( array $agent ): AgentBundler { 'agent_config' => array( 'provider' => 'openai', 'model' => 'gpt-5.5', - 'tool_policy' => array( 'allow' => array( 'datamachine/search' ) ), + 'tool_policy' => array( + 'mode' => 'allow', + 'tools' => array( 'datamachine/search' ), + ), 'example_extension' => array( 'graph' => array( 'enabled' => true ) ), 'example' => array( 'runtime_endpoints' => array( 'events' => array( 'url' => 'https://runtime.example.test' ) ), @@ -253,7 +256,7 @@ static function ( array $policies ): array { export_config_assert( "{$profile} honors explicit backup-private exclusion", ! isset( $config['backup_private'] ) ); export_config_assert_equals( "{$profile} keeps normalized provider", 'openai', $config['default_provider'] ?? null ); export_config_assert_equals( "{$profile} keeps normalized model", 'gpt-5.5', $config['default_model'] ?? null ); - export_config_assert_equals( "{$profile} keeps tool policy", array( 'datamachine/search' ), $config['tool_policy']['allow'] ?? null ); + export_config_assert_equals( "{$profile} keeps tool policy", array( 'datamachine/search' ), $config['tool_policy']['tools'] ?? null ); export_config_assert_equals( "{$profile} keeps plugin bundle-owned policy", true, $config['example_extension']['graph']['enabled'] ?? null ); export_config_assert_equals( "{$profile} keeps site scope", 7, $round_trip['agent']['site_scope'] ?? null ); } diff --git a/plugins/data-machine/tests/agent-bundle-subagent-graph-smoke.php b/plugins/data-machine/tests/agent-bundle-subagent-graph-smoke.php index dc286ab9f4..1dedd33eb5 100644 --- a/plugins/data-machine/tests/agent-bundle-subagent-graph-smoke.php +++ b/plugins/data-machine/tests/agent-bundle-subagent-graph-smoke.php @@ -94,18 +94,16 @@ function subagent_graph_node( string $slug, array $edges = array() ): array { } catch ( BundleValidationException $e ) { $rejected = true; } subagent_graph_assert( $rejected, 'traversal skill artifact paths are rejected before package path construction' ); -$legacy = subagent_graph_node( 'writer' ); -$legacy['tool_policy'] = array( 'default' => 'deny', 'allow' => array( 'generic/tool' ) ); -$legacy_nodes = AgentSubagentGraph::normalize( array( $legacy ), 'coordinator' ); -subagent_graph_assert( array( 'mode' => 'allow', 'tools' => array( 'generic/tool' ), 'categories' => array() ) === $legacy_nodes[0]['tool_policy'], 'shipped legacy allowlists migrate to the enforceable policy shape' ); - $rejected = false; try { $invalid = subagent_graph_node( 'writer' ); - $invalid['tool_policy'] = array( 'default' => null, 'allow' => array( 'generic/tool' ) ); + $invalid['tool_policy'] = array( + 'default' => 'deny', + 'allow' => array( 'generic/tool' ), + ); AgentSubagentGraph::normalize( array( $invalid ), 'coordinator' ); } catch ( BundleValidationException $e ) { $rejected = true; } -subagent_graph_assert( $rejected, 'present legacy defaults must be exactly deny' ); +subagent_graph_assert( $rejected, 'allow/default tool policies are rejected; mode/tools is the only shape' ); if ( $failures ) { exit( 1 ); diff --git a/plugins/data-machine/tests/agent-bundler-directory-adapter-smoke.php b/plugins/data-machine/tests/agent-bundler-directory-adapter-smoke.php index 2df6f77724..d94c5461e2 100644 --- a/plugins/data-machine/tests/agent-bundler-directory-adapter-smoke.php +++ b/plugins/data-machine/tests/agent-bundler-directory-adapter-smoke.php @@ -321,7 +321,10 @@ function rm_adapter_tree( string $path ): void { 'agent_slug' => 'coordinator', 'agent_name' => 'Coordinator', 'agent_config' => array( 'model' => 'gpt-5', 'subagents' => array( 'writer' ) ), 'subagents' => array( 'writer' ), - 'tool_policy' => array( 'allow' => array( 'datamachine/read-file' ) ), + 'tool_policy' => array( + 'mode' => 'allow', + 'tools' => array( 'datamachine/read-file' ), + ), 'skill_policy' => array( 'mode' => 'explicit' ), 'skills' => array( 'root.md' => "root \0\xFF" ), 'references' => array( 'root-ref.md' => "root reference \xC3\xA9" ), @@ -331,7 +334,10 @@ function rm_adapter_tree( string $path ): void { array( 'slug' => 'writer', 'label' => 'Writer', 'description' => 'Writes.', 'agent_config' => array( 'model' => 'gpt-5-mini' ), 'memory' => array( 'SOUL.md' => "Writer\n" ), - 'tool_policy' => array( 'allow' => array( 'datamachine/read-file' ) ), + 'tool_policy' => array( + 'mode' => 'allow', + 'tools' => array( 'datamachine/read-file' ), + ), 'skill_policy' => array( 'mode' => 'explicit', 'allowed' => array( 'compose.md' ) ), 'skills' => array( 'compose.md' => "cafe \xC3\xA9\0skill" ), 'references' => array( 'guide.bin' => "\0reference\xFF" ), @@ -356,7 +362,15 @@ function rm_adapter_tree( string $path ): void { assert_adapter_equals( 'root skill bytes survive directory package read', "root \0\xFF", $graph_round_trip['agent']['skills']['root.md'] ?? null ); assert_adapter_equals( 'root reference bytes survive directory package read', "root reference \xC3\xA9", $graph_round_trip['agent']['references']['root-ref.md'] ?? null ); assert_adapter_equals( 'root skill policy survives directory package read', array( 'mode' => 'explicit' ), $graph_round_trip['agent']['skill_policy'] ?? null ); -assert_adapter_equals( 'legacy root tool policy migrates during directory package read', array( 'mode' => 'allow', 'tools' => array( 'datamachine/read-file' ), 'categories' => array() ), $graph_round_trip['agent']['tool_policy'] ?? null ); +assert_adapter_equals( + 'root tool policy normalizes during directory package read', + array( + 'mode' => 'allow', + 'tools' => array( 'datamachine/read-file' ), + 'categories' => array(), + ), + $graph_round_trip['agent']['tool_policy'] ?? null +); $child_skill_policy = $graph_round_trip['subagents'][0]['skill_policy'] ?? array(); assert_adapter( 'child skill policy survives directory package read', diff --git a/plugins/data-machine/tests/content-format-abilities-smoke.php b/plugins/data-machine/tests/content-format-abilities-smoke.php index 2b10d6e190..0bde1d9121 100644 --- a/plugins/data-machine/tests/content-format-abilities-smoke.php +++ b/plugins/data-machine/tests/content-format-abilities-smoke.php @@ -766,9 +766,9 @@ static function ( string $format, string $post_type ): string { assert_content_ability( 'blocks-engine-conversion-error-code-is-distinct-from-missing-transformer', 'datamachine_content_format_blocks_engine_conversion_failed' === $conversion_error->get_error_code() ); $tool = DataMachine\Abilities\Content\UpsertPostAbility::getToolDefinition(); - assert_content_ability( 'model-tool-content-format-is-optional', ! in_array( 'content_format', $tool['required'] ?? array(), true ) ); + assert_content_ability( 'model-tool-content-format-is-optional', ! in_array( 'content_format', $tool['parameters']['required'] ?? array(), true ) ); assert_content_ability( 'model-tool-description-prefers-markdown-authoring', false !== strpos( $tool['description'], 'write content as markdown' ) ); - assert_content_ability( 'model-tool-content-format-description-defaults-markdown', false !== strpos( $tool['parameters']['content_format']['description'] ?? '', 'default to markdown' ) ); + assert_content_ability( 'model-tool-content-format-description-defaults-markdown', false !== strpos( $tool['parameters']['properties']['content_format']['description'] ?? '', 'default to markdown' ) ); assert_content_ability( 'model-tool-guidance-does-not-default-to-blocks', false === strpos( $tool['parameters']['content_format']['description'] ?? '', 'Defaults to blocks' ) ); echo "\nContentFormat abilities smoke: {$total} assertions, {$failed} failures.\n"; diff --git a/plugins/data-machine/tests/tool-schema-normalizer-smoke.php b/plugins/data-machine/tests/tool-schema-normalizer-smoke.php index c4daa69002..8e77504fc3 100644 --- a/plugins/data-machine/tests/tool-schema-normalizer-smoke.php +++ b/plugins/data-machine/tests/tool-schema-normalizer-smoke.php @@ -45,48 +45,16 @@ function datamachine_tool_schema_assert_equals( $expected, $actual, string $name ); datamachine_tool_schema_assert_equals( $canonical, ToolSchemaNormalizer::normalize( $canonical ), 'canonical object schema is preserved', $failures, $passes ); -$flat = ToolSchemaNormalizer::normalize( +$untyped = ToolSchemaNormalizer::normalize( array( - 'message' => array( - 'type' => 'string', - 'description' => 'Message to summarize.', - ), - 'count' => 'integer', - ) -); -datamachine_tool_schema_assert_equals( 'object', $flat['type'] ?? null, 'flat legacy map becomes root object schema', $failures, $passes ); -datamachine_tool_schema_assert_equals( - array( - 'message' => array( - 'type' => 'string', - 'description' => 'Message to summarize.', - ), - 'count' => array( 'type' => 'string' ), - ), - $flat['properties'] ?? null, - 'flat legacy map becomes properties map', - $failures, - $passes -); - -$required = ToolSchemaNormalizer::normalize( - array( - 'type' => 'object', - 'required' => array( 'message' ), 'properties' => array( - 'message' => array( - 'type' => 'string', - 'required' => true, - ), - 'title' => array( - 'type' => 'string', - 'required' => true, - ), + 'message' => array( 'type' => 'string' ), ), + 'required' => array( 'message' ), ) ); -datamachine_tool_schema_assert_equals( array( 'message', 'title' ), $required['required'] ?? null, 'property-level required flags are hoisted and deduped', $failures, $passes ); -datamachine_tool_schema_assert_equals( false, isset( $required['properties']['title']['required'] ), 'property-level required flag is removed from property schema', $failures, $passes ); +datamachine_tool_schema_assert_equals( 'object', $untyped['type'] ?? null, 'root schema without type defaults to object', $failures, $passes ); +datamachine_tool_schema_assert_equals( array( 'message' ), $untyped['required'] ?? null, 'root required array is preserved', $failures, $passes ); echo "\nAssertions: {$passes} passed, " . count( $failures ) . ' failed, ' . ( $passes + count( $failures ) ) . " total\n"; exit( count( $failures ) ); diff --git a/plugins/data-machine/tests/wp-ai-client-tool-schema-smoke.php b/plugins/data-machine/tests/wp-ai-client-tool-schema-smoke.php index d215dd2c4d..05e0684a44 100644 --- a/plugins/data-machine/tests/wp-ai-client-tool-schema-smoke.php +++ b/plugins/data-machine/tests/wp-ai-client-tool-schema-smoke.php @@ -190,53 +190,6 @@ function ( array $request ) use ( &$captured_request ): array { $assert( array( 'reason' ) === ( $schema['required'] ?? null ), 'canonical object-level required array is preserved' ); $assert( 'string' === ( $schema['properties']['reason']['type'] ?? null ), 'property schema fields are preserved' ); -// --- Legacy flat parameter map normalization --------------------------------- -// -// Older internal tools may still declare parameters as a flat property map. The -// provider-facing schema must still be canonical JSON Schema. -$captured_request = array(); -\DataMachine\Tests\Unit\Support\WpAiClientTestDouble::reset(); -\DataMachine\Tests\Unit\Support\WpAiClientTestDouble::set_response_callback( - function ( array $request ) use ( &$captured_request ): array { - $captured_request = $request; - return array( - 'success' => true, - 'data' => array( 'content' => 'ok' ), - ); - }, -); - -\DataMachine\Engine\AI\RequestBuilder::build( - array( - array( - 'role' => 'user', - 'content' => 'Run legacy tool.', - ), - ), - 'openai', - 'gpt-smoke', - array( - 'client/legacy_schema_tool' => array( - 'name' => 'client/legacy_schema_tool', - 'description' => 'Legacy schema test tool.', - 'parameters' => array( - 'reason' => array( - 'type' => 'string', - 'description' => 'Reason text.', - 'required' => true, - ), - ), - ), - ), - array( 'pipeline' ), - array( 'job_id' => 1686 ) -); - -$legacy_schema = $captured_request['tools']['client_legacy_schema_tool']['parameters'] ?? null; -$assert( 'object' === ( $legacy_schema['type'] ?? null ), 'legacy flat parameter map becomes a root object schema' ); -$assert( array( 'reason' ) === ( $legacy_schema['required'] ?? null ), 'legacy property-level required flag becomes object-level required array' ); -$assert( ! isset( $legacy_schema['properties']['reason']['required'] ), 'legacy property-level required flag is removed from property schema' ); - // --- Empty-prompt fallback ---------------------------------------------------- // // Regression coverage for https://github.com/Extra-Chill/data-machine/issues/1789. From 765f142a701b4a6fdadc8447b116fd77c2f522ca Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Tue, 1 Dec 2026 08:18:12 -0500 Subject: [PATCH 2/2] test(tools): declare canonical object schema in claimed handler-tool fixture --- .../tests/Unit/AI/Tools/HandlerToolResolutionTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/data-machine/tests/Unit/AI/Tools/HandlerToolResolutionTest.php b/plugins/data-machine/tests/Unit/AI/Tools/HandlerToolResolutionTest.php index 31ee0adda7..ce03abb3fe 100644 --- a/plugins/data-machine/tests/Unit/AI/Tools/HandlerToolResolutionTest.php +++ b/plugins/data-machine/tests/Unit/AI/Tools/HandlerToolResolutionTest.php @@ -168,7 +168,11 @@ function ( array $tools ): array { static fn(): array => array( 'claimed_publish' => array( 'description' => 'Publish one claimed packet', - 'parameters' => array( 'title' => array( 'type' => 'string', 'required' => true ) ), + 'parameters' => array( + 'type' => 'object', + 'properties' => array( 'title' => array( 'type' => 'string' ) ), + 'required' => array( 'title' ), + ), ), ), array( 'handler' => 'claimed_publish' )