Skip to content

feat: CLI --user flag and ability-level user_id for multi-agent scoping (#566)#574

Open
chubes4 wants to merge 7 commits intomainfrom
feature/multi-agent-phase3-cli
Open

feat: CLI --user flag and ability-level user_id for multi-agent scoping (#566)#574
chubes4 wants to merge 7 commits intomainfrom
feature/multi-agent-phase3-cli

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 3, 2026

Summary

Phase 3 of multi-agent support (#560, #566): adds --user flag to all relevant CLI commands and user_id input parameter to abilities, enabling per-agent scoping of pipelines, flows, jobs, and agent files.

Changes

Abilities Layer

  • AgentMemoryAbilities: user_id added to all 4 input schemas + extracted in execute methods
  • FileAbilities: user_id flows through list, get, write, delete, upload for agent-scoped ops
  • GetPipelinesAbility: user_id filter on pipeline listing
  • GetFlowsAbility: user_id filter via getAllFlowsPaginated/countAllFlows helpers
  • GetJobsAbility: user_id filter on job listing
  • FlowHelpers: getAllFlowsPaginated/countAllFlows accept optional $user_id

CLI Layer

  • New UserResolver: resolves --user=<id|login|email> to WP user ID (0 when omitted)
  • MemoryCommand: --user wired through read, sections, write, search, daily, files
  • PipelinesCommand: --user filters pipeline listing
  • FlowsCommand: --user filters flow listing
  • JobsCommand: --user filters job listing
  • New AgentsCommand: wp datamachine agents list — shows all configured agents

REST API

  • Files.php: user_id query param on agent file list/get/put/delete endpoints

Backward Compatibility

  • All user_id params default to 0 (shared/legacy agent)
  • Omitting --user on CLI preserves existing behavior
  • Single-agent installs work without configuration changes

Testing

  • php -l passes on all 14 changed files
  • All changes are additive — no existing method signatures broken

Depends On

Closes #566

chubes4 added 4 commits March 3, 2026 23:20
…nt (#565)

Phase 2 of multi-agent support: directives now read the correct agent's
files based on user_id from the execution context.

Pipeline path:
- RunFlowAbility propagates flow's user_id to job record and engine snapshot
- AIStep extracts user_id from engine snapshot into payload

Chat path:
- ChatOrchestrator threads user_id through options into loop_context
- All three callers (processChat, processContinue, processPing) pass user_id

Directives:
- CoreMemoryFilesDirective resolves user_id from payload, passes to
  DirectoryManager::get_agent_directory()
- MemoryFilesReader::read() accepts user_id param (default 0 for compat)
- PipelineMemoryFilesDirective and FlowMemoryFilesDirective pass user_id
  through to MemoryFilesReader

All changes default to user_id=0 — existing single-agent installs keep
working without configuration.

Refs: #565, #560
…lti-agent scoping (#566)

Phase 3 of multi-agent support: CLI and ability-level user scoping.

Abilities layer:
- AgentMemoryAbilities: add user_id to all 4 input_schema definitions
  and extract from input in execute methods
- FileAbilities: add user_id to input_schema for list, get, write,
  delete, and upload abilities; pass through to agent-scoped private
  methods (listAgentFiles, getAgentFile, writeAgentFile, deleteAgentFile,
  uploadToAgent)
- GetPipelinesAbility: add user_id input param, pass to
  get_all_pipelines() DB query
- GetFlowsAbility: add user_id input param, pass through to
  getAllFlowsPaginated/countAllFlows helpers
- GetJobsAbility: add user_id input param, pass to DB query args
- FlowHelpers: update getAllFlowsPaginated/countAllFlows to accept
  optional user_id and use get_all_flows() when filtering

CLI layer:
- New UserResolver class: resolves --user flag (ID, login, or email)
  to WordPress user ID, returns 0 when omitted
- MemoryCommand: wire --user through all subcommands (read, sections,
  write, search, daily, files) to ability calls and DirectoryManager
- PipelinesCommand: resolve --user, pass to executeGetPipelines
- FlowsCommand: resolve --user, pass to executeAbility
- JobsCommand: resolve --user, pass to executeGetJobs
- New AgentsCommand: wp datamachine agents list — shows shared agent
  and all WP users with pipelines, flows, or agent directories
- Bootstrap: register agents command

REST API:
- Files.php: accept user_id query param on list, get, put, delete
  agent file endpoints; pass through to FileAbilities
Unit tests:
- UserResolverTest: validates resolve() contract — static, accepts
  array, returns int, returns 0 for empty/null/missing --user flag
- AgentsCommandTest: validates class structure — extends BaseCommand,
  has list_agents method with correct signature

Integration tests (WP_UnitTestCase):
- MultiAgentScopingTest: 16 tests covering end-to-end scoping:
  - AgentMemoryAbilities: all 4 input_schemas include user_id,
    getMemory defaults to user_id=0, explicit zero matches default
  - FileAbilities: input_schemas include user_id, agent file
    listing is scoped by user_id, write creates user-scoped
    directory, delete is scoped (cross-agent delete fails)
  - GetPipelinesAbility: input_schema includes user_id, listing
    filtered correctly (agent A sees only their pipelines),
    no filter returns all
  - GetFlowsAbility: input_schema includes user_id
  - GetJobsAbility: input_schema includes user_id, listing
    filtered by user_id returns only matching jobs
  - DirectoryManager: directories isolated by user_id,
    shared uses legacy path, user-scoped uses agent-{id} path
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Homeboy Results — data-machine

lint (changed files only)

test

  • PHPCS: LINT SUMMARY: 235 errors, 203 warnings
  • Fixable: 184 | Files with issues: 109 of 348
Top violations
  WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine    93
  WordPress.DB.PreparedSQL.NotPrepared                       73
  WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned    41
  Generic.Formatting.MultipleStatementAlignment.NotSameWarning    35
  Generic.CodeAnalysis.UnusedFunctionParameter.Found         34
- PHPStan: PHPSTAN SUMMARY: 135 errors at level 5 - BUILD FAILED: PHPUnit tests

audit


Homeboy Action v1 — homeboy 0.53.0

chubes4 added 3 commits March 4, 2026 00:51
…oader

Homeboy's WP test bootstrap loads the plugin on plugins_loaded, but
the plugin requires vendor/autoload.php (PSR-4 autoloader). Without
running composer install, no DataMachine classes are autoloadable,
causing 'Class not found' fatals in PHPUnit.
BaseCommand extends WP_CLI_Command, which isn't available in the
test environment without this dependency. WordPress core doesn't
include WP-CLI.
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.

Multi-agent: REST API + CLI --user support

1 participant