Skip to content

feat(#741): unify tool registry — single datamachine_tools filter with context arrays#748

Merged
chubes4 merged 1 commit intomainfrom
feature/741-unified-tool-registry
Mar 8, 2026
Merged

feat(#741): unify tool registry — single datamachine_tools filter with context arrays#748
chubes4 merged 1 commit intomainfrom
feature/741-unified-tool-registry

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 8, 2026

Summary

Phase 1 of #741: Replace the 3 separate tool registration channels with a single unified datamachine_tools filter. Every tool now declares a contexts array specifying where it's available.

  • Single filter: datamachine_tools replaces datamachine_global_tools, datamachine_chat_tools, datamachine_system_tools
  • Context arrays: Each tool declares contexts: ['chat', 'pipeline', 'standalone'] (or subset)
  • No backward compatibility bridge — all callers updated directly

Changes

BaseTool.php

  • registerTool(toolName, toolDefinition, contexts) replaces the old 3-param (agentType, toolName, toolDefinition) signature
  • Deleted registerGlobalTool() and registerChatTool()
  • Callable definitions wrapped with _callable key to keep contexts available pre-resolution

ToolManager.php

  • get_all_tools() reads from datamachine_tools filter (replaces get_global_tools())
  • get_global_tools() kept as deprecated alias
  • get_raw_tools() and get_tool_contexts() added for pre-resolution context checks
  • resolveToolDefinition() handles _callable wrapper format, merging contexts into resolved result

ToolPolicyResolver.php

  • filterByContext() helper filters resolved tools by context string
  • gatherPipelineTools(): filters to 'pipeline' context + handler tools from chubes_ai_tools
  • gatherChatTools(): filters to 'chat' context with availability/enablement checks
  • gatherStandaloneTools(): filters to 'standalone' context
  • gatherSystemTools(): filters to 'system' context (currently empty — no tools register with system context)
  • Surface constants kept for Phase 2 rename

ToolServiceProvider.php

  • Merged registerGlobalTools() + registerChatTools() into single registerTools()

46+ tool registration sites updated

  • Former global toolscontexts: ['chat', 'pipeline', 'standalone']
  • Former chat-only toolscontexts: ['chat']
  • Ability-registered tools (PostQuery, GetPostBlocks, EditPostBlocks, ReplacePostBlocks) → datamachine_tools filter with 'chat' context

Tests

  • ToolPolicyResolverTest: system surface test updated (no tools have system context now)
  • ImageGenerationTest: datamachine_global_toolsdatamachine_tools
  • ListFlowsTest: datamachine_chat_toolsdatamachine_tools with _callable unwrapping

Test Results

764 tests, 0 failures, 3 skipped (pre-existing)

What's NOT in this PR (Phase 2)

  • Renaming SURFACE_* constants to CONTEXT_* in ToolPolicyResolver
  • Full ToolPolicyResolver rewrite with context-first architecture

…h context arrays

Replace 3 separate tool registration channels (datamachine_global_tools,
datamachine_chat_tools, datamachine_system_tools) with a single unified
datamachine_tools filter. Every tool now registers once with a contexts
array declaring where it's available.

- BaseTool.registerTool() now takes (toolName, toolDefinition, contexts)
  instead of (agentType, toolName, toolDefinition)
- Delete registerGlobalTool() and registerChatTool() from BaseTool
- ToolManager gains get_all_tools(), get_raw_tools(), get_tool_contexts()
  with get_global_tools() kept as deprecated alias
- ToolManager.resolveToolDefinition() handles _callable wrapper format
  for pre-resolution context filtering
- ToolPolicyResolver.gatherBySurface() methods now filter unified
  registry by context instead of reading separate filters
- All 46+ tool registrations updated with context declarations
- Ability-registered tools (PostQuery, GetPostBlocks, EditPostBlocks,
  ReplacePostBlocks) updated to use datamachine_tools filter
- Tests updated to use new filter and context patterns

Phase 1 of #741 — ToolPolicyResolver surface→context rename is Phase 2.
@github-actions
Copy link

github-actions bot commented Mar 8, 2026

Homeboy Results — data-machine

Lint

Tooling versions

  • Homeboy CLI: homeboy 0.72.0
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v1

ℹ️ PR test scope resolved to full for compatibility with installed Homeboy CLI

lint (changed files only)

  • PHPCS: LINT SUMMARY: 0 errors, 5 warnings
  • Fixable: 1 | Files with issues: 3 of 56
  • PHPStan: PHPSTAN SUMMARY: 204 errors at level 5

Test

Tooling versions

  • Homeboy CLI: homeboy 0.72.0
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v1

⚡ PR test scope resolved to changed

test

  • PHPCS: LINT SUMMARY: 65 errors, 57 warnings
  • Fixable: 103 | Files with issues: 19 of 368
Top violations
  WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine    51
  Generic.Formatting.MultipleStatementAlignment.NotSameWarning    31
  WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned    17
  Universal.Operators.DisallowShortTernary.Found              4
  WordPress.DB.PreparedSQL.NotPrepared                        4
- PHPStan: PHPSTAN SUMMARY: 204 errors at level 5 - OK (470 tests, 1535 assertions)

Audit

Tooling versions

  • Homeboy CLI: homeboy 0.72.0
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v1

ℹ️ PR test scope resolved to full for compatibility with installed Homeboy CLI

audit (changed files only)

  • Actionable audit summary:
  • Alignment score: 0.701
  • Severity counts: info: 13, unknown: 76, warning: 78
  • Drift increased: no
  • Outliers in current run: 76
  • Parsed outlier entries: 76
  • Top actionable findings:
    1. tests/Unit/Abilities/SystemAbilitiesTest.php — missing_registration — Missing registration: datamachine_cli_bypass_permissions
    2. tests/Unit/Abilities/PermissionHelperTest.php — missing_method — Missing method: set_up
    3. tests/Unit/Abilities/PermissionHelperTest.php — missing_registration — Missing registration: datamachine_cli_bypass_permissions
    4. tests/Unit/Abilities/ImageGenerationPromptRefinementTest.php — missing_registration — Missing registration: datamachine_cli_bypass_permissions
    5. tests/Unit/Abilities/ImageGenerationAbilitiesTest.php — missing_registration — Missing registration: datamachine_cli_bypass_permissions

Homeboy Action v1

@chubes4 chubes4 merged commit 02024be into main Mar 8, 2026
3 checks passed
@chubes4 chubes4 deleted the feature/741-unified-tool-registry branch March 8, 2026 21:32
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.

1 participant