Skip to content

fix(tools): canonical JSON Schema for chat tools (#138)#139

Merged
chubes4 merged 1 commit into
mainfrom
fix-138-canonical-tool-schemas
May 9, 2026
Merged

fix(tools): canonical JSON Schema for chat tools (#138)#139
chubes4 merged 1 commit into
mainfrom
fix-138-canonical-tool-schemas

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented May 9, 2026

Why

Data Machine 0.107.0 requires canonical AI tool schemas — the auto-normalization layer that previously converted legacy property-keyed parameter shapes was already removed in DM 0.106.x and is fully gone in 0.107.0. Extension plugins must ship canonical schemas directly or their chat tool calls fail with provider schema-validation errors.

This is a pre-flight fix landed before the DM bump — canonical schemas already work on DM 0.103.14 (current production on extrachill.com), so this PR can ship and deploy independently of the DM upgrade. Same pattern as Extra-Chill/data-machine-events#232 which prefighted the equivalent change across 9 chat tools without disrupting production.

What changed

Converted all 35 chat tool definitions in inc/Chat/Tools/ from the legacy shape:

// Legacy
'parameters' => array(
    'content' => array( 'type' => 'string', 'required' => true, 'description' => '...' ),
)

…to canonical JSON Schema:

// Canonical
'parameters' => array(
    'type'       => 'object',
    'properties' => array(
        'content' => array( 'type' => 'string', 'description' => '...' ),
    ),
    'required'   => array( 'content' ),
)

Files (35 chat tools)

inc/Chat/Tools/:

  • DeleteBluesky.php, DeleteFacebook.php, DeleteInstagram.php, DeleteLinkedIn.php, DeletePinterest.php, DeleteThreads.php, DeleteTwitter.php
  • FetchReddit.php
  • PublishBluesky.php, PublishFacebook.php, PublishInstagram.php, PublishLinkedIn.php, PublishPinterest.php, PublishReelInstagram.php, PublishStoryInstagram.php, PublishThreads.php, PublishTwitter.php
  • ReadBluesky.php, ReadFacebook.php, ReadInstagram.php, ReadLinkedIn.php, ReadPinterest.php, ReadThreads.php, ReadTwitter.php
  • ReplyInstagramComment.php, ReplyReddit.php
  • SubmitReddit.php
  • UpdateBluesky.php, UpdateFacebook.php, UpdateInstagram.php, UpdateLinkedIn.php, UpdatePinterest.php, UpdateThreads.php, UpdateTwitter.php
  • VoteReddit.php

Conversion rules applied

  1. Wrap properties under { type: 'object', properties: {...} }.
  2. Move required => true properties into a top-level required[] array of property names; remove required from individual property defs.
  3. Drop required => false entirely (no-op in legacy schema).
  4. Omit required key when no properties are required (no empty arrays emitted).
  5. Every type: array property must declare items. The audit found exactly one such property — PublishInstagram.image_urls — which already had a sane shape and is preserved verbatim:
    'image_urls' => array(
        'type'        => 'array',
        'description' => 'Array of public image URLs to post. 1 image for single post, 2-10 for carousel.',
        'items'       => array( 'type' => 'string' ),
    ),
    items: { type: 'string' } is the correct shape — the field accepts an array of public image URL strings, not an array of structs. No other tool in the 35 has a type: array property.
  6. All other property keys (description, enum, items) preserved verbatim.

Required-fields summary

Tools with required fields:

  • DeleteBluesky, DeleteTwitter, DeleteFacebook, DeleteInstagram, DeleteLinkedIn, DeletePinterest, DeleteThreadspost_uri (or platform equivalent: tweet_id, post_id, media_id, pin_id, etc.)
  • PublishBluesky, PublishTwitter, PublishFacebook, PublishLinkedIn, PublishThreadscontent
  • PublishInstagram, PublishReelInstagram, PublishStoryInstagram — caption + media URL fields per network
  • PublishPinteresttitle, image_url, board_id
  • ReplyInstagramCommentcomment_id, message
  • ReplyRedditparent_id, text
  • SubmitRedditsubreddit, title
  • UpdateBluesky, UpdateTwitter, UpdateFacebook, UpdateInstagram, UpdateLinkedIn, UpdatePinterest, UpdateThreadsaction + post identifier per network
  • VoteRedditthing_id, direction

Tools with no required fields (all-optional schemas, required key omitted): FetchReddit, all Read* tools.

Out of scope (intentionally)

Backwards compatibility

Canonical schemas are accepted by both DM 0.103.14 (current production on extrachill.com) and DM 0.107.0+ (target). The legacy normalization path on 0.103.x silently passes canonical schemas through. No behavior change on the current site.

Test plan

  • PHP syntax check (php -l) passes on all 35 edited files.
  • homeboy lint --path . --changed-since main shows zero findings on any of the 35 edited tool files. The only findings (4 total) are pre-existing baseline noise on inc/Abilities/Reddit/FetchRedditAbility.php from the prior Refactor Reddit fetches onto core fresh candidates #136 refactor commit on this branch — unrelated to this changeset.
  • Manual diff spot-checked on PublishTwitter (string + optional), ReadInstagram (all-optional with enum), DeleteBluesky (single required), PublishInstagram (mixed required + array with items), SubmitReddit (mixed shape), VoteReddit (multi-required) to confirm the transformation is correct and idiomatic.
  • Live tool calls in production chat post-merge (manual sanity check on at least one Publish, one Read, one Delete tool per network family).

Constraints honored

  • Branched off main, no commits to main.
  • No CHANGELOG.md edits, no version constant bumps — homeboy owns those.
  • No deploy, no release.
  • Conventional commit (fix:).

Closes #138.

Convert all 35 chat tool definitions in inc/Chat/Tools/ from the legacy
property-keyed parameter shape to canonical JSON Schema. DM 0.107.0 removes
the auto-normalization layer that previously converted legacy schemas;
extension plugins must ship canonical schemas directly.

Forward-compatible pre-flight: canonical schemas are accepted by both DM
0.103.14 (current production) and DM 0.107.0+ (target). No behavior change
on the current site.

Conversion rules applied:
- Wrap properties under { type: 'object', properties: {...} }.
- Move 'required => true' fields into top-level required[] array of
  property names; remove 'required' from individual property defs.
- Drop 'required => false' (no-op in legacy schema).
- Omit 'required' key when no properties are required.
- Preserve 'description', 'enum', and 'items' verbatim.
- PublishInstagram.image_urls keeps its existing items: { type: string }
  (array of public image URL strings).

Same pattern as data-machine-events#232 (9 tools). Closes #138.
@homeboy-ci
Copy link
Copy Markdown
Contributor

homeboy-ci Bot commented May 9, 2026

Homeboy Results — data-machine-socials

Audit

audit — passed

  • dead_code — 35 finding(s)
  • test_coverage — 35 finding(s)
  • repeated_literal_shape — 3 finding(s)
  • intra-method-duplication — 2 finding(s)
  • Total: 75 finding(s)

Deep dive: homeboy audit data-machine-socials --changed-since c961a02

Tooling versions
  • Homeboy CLI: homeboy 0.163.1+6f58c1b87
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: 17ddd41
  • Action: Extra-Chill/homeboy-action@v2

@chubes4 chubes4 merged commit 02c6d90 into main May 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tools): canonical JSON Schema for chat tools (DM 0.107.0 pre-flight)

1 participant