You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
datamachine_resolve_system_agent_context() conflated attribution (which human triggered the work) with agent identity (a persistent row in the agents table). Any authenticated user who triggered a system-owned queued task — uploading an image, generating alt text, meta descriptions, image optimization, internal linking — got a full agent identity minted from their login. ChatOrchestrator is the only legitimate auto-provision surface.
Fix: attribution vs. identity
datamachine_resolve_system_agent_context() now always resolves to the install's default agent owner (DirectoryManager::get_default_agent_user_id() → its agent id). It only calls datamachine_resolve_or_create_agent_id() for that default owner, never for the triggering human.
The original triggering user is returned separately as triggering_user_id.
Media/SEO/linking callers pass triggering_user_id into the TaskScheduler context so it is preserved in engine_data['task_context'] for audit, without minting a row.
ChatOrchestrator keeps datamachine_resolve_or_create_agent_id() — opening chat is still operating an agent.
Cleanup: wp datamachine agent prune
New datamachine/prune-agents ability and matching wp datamachine agent prune subcommand.
Default is dry-run listing; --yes applies deletion.
A candidate is an agent row with zero references:
no chat sessions (network-wide table + legacy per-site tables)
no jobs (agent_id)
no access grants (user or principal)
no on-disk agent directory
no datamachine_bundle config block
not the install's default agent
Uses the existing deleteAgent path so grants are cleaned up; directories are never auto-deleted.
Tests
Updated tests/system-agent-context-resolution-smoke.php for the new resolver behavior.
Added tests/agent-prune-smoke.php covering zero-reference detection, default-agent protection, and session/job/grant/directory/bundle spares.
Verification
Local phpcs clean.
homeboy review data-machine --changed-since origin/main --summary: lint passed; test stage failed before running tests due to a missing wp-codebox CLI binary in this environment (infrastructure, not code).
ℹ️ No tests ran — the runner failed before producing results. See raw_output.stderr_tail / raw_output.stdout_tail for the underlying error (bootstrap failure, missing deps, DB connection, etc.).
ℹ️ To run specific tests: homeboy test data-machine -- --filter=TestName
ℹ️ Auto-fix lint issues: homeboy refactor data-machine --from lint --write
ℹ️ Collect coverage: homeboy test data-machine --coverage
ℹ️ Analyze failures: homeboy test data-machine --analyze
ℹ️ Pass args to test runner: homeboy test -- [args]
ℹ️ Full options: homeboy self docs commands/test
Deep dive: homeboy review test data-machine --changed-since ad09ae9
Artifacts and drill-down
CI results artifact: homeboy-ci-results-data-machine-review-test-quality-Linux-node24 contains immediate command JSON for this action invocation.
Observation artifact: homeboy-observations-data-machine-review-test-quality-Linux-node24 contains exported Homeboy run history for deeper queries.
Drill-down: download the observation artifact, then run homeboy runs import <dir>, homeboy runs list, and homeboy runs findings <run-id>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2864.
Problem
datamachine_resolve_system_agent_context()conflated attribution (which human triggered the work) with agent identity (a persistent row in the agents table). Any authenticated user who triggered a system-owned queued task — uploading an image, generating alt text, meta descriptions, image optimization, internal linking — got a full agent identity minted from their login. ChatOrchestrator is the only legitimate auto-provision surface.Fix: attribution vs. identity
datamachine_resolve_system_agent_context()now always resolves to the install's default agent owner (DirectoryManager::get_default_agent_user_id()→ its agent id). It only callsdatamachine_resolve_or_create_agent_id()for that default owner, never for the triggering human.triggering_user_id.triggering_user_idinto theTaskSchedulercontext so it is preserved inengine_data['task_context']for audit, without minting a row.ChatOrchestratorkeepsdatamachine_resolve_or_create_agent_id()— opening chat is still operating an agent.Cleanup:
wp datamachine agent prunedatamachine/prune-agentsability and matchingwp datamachine agent prunesubcommand.--yesapplies deletion.agent_id)datamachine_bundleconfig blockdeleteAgentpath so grants are cleaned up; directories are never auto-deleted.Tests
tests/system-agent-context-resolution-smoke.phpfor the new resolver behavior.tests/agent-prune-smoke.phpcovering zero-reference detection, default-agent protection, and session/job/grant/directory/bundle spares.Verification
phpcsclean.homeboy review data-machine --changed-since origin/main --summary: lint passed; test stage failed before running tests due to a missingwp-codeboxCLI binary in this environment (infrastructure, not code).Fixes #2864