Skip to content

refactor: stop hand-typing core's datamachine namespace in AgentsMdSections.php; reflect DMC's own commands#735

Merged
chubes4 merged 1 commit into
mainfrom
drop-core-narration
Jun 15, 2026
Merged

refactor: stop hand-typing core's datamachine namespace in AgentsMdSections.php; reflect DMC's own commands#735
chubes4 merged 1 commit into
mainfrom
drop-core-narration

Conversation

@chubes4

@chubes4 chubes4 commented Jun 15, 2026

Copy link
Copy Markdown
Member

Closes #734.

Layer-inversion fix

inc/Runtime/AgentsMdSections.php hand-typed core's entire datamachine command surface as a static heredoc (Memory & Agents / Automation / Communication / Content ops / System bullets). That is a layer inversion: DMC was narrating core's namespace from a hand-copy that silently drifts. Core is taking over its own reflected datamachine AGENTS.md section (data-machine#2640), so this PR:

  • Removes the hand-typed core datamachine ... narration block entirely.
  • Renames the section datamachinedatamachine-code and keeps only the workspace / worktree / github guidance DMC rightfully owns. A short pointer tells readers core's operating layer lives in its own section (datamachine --help).
  • Reflects DMC's own worktree operation list (previously a hand-typed pipe-list at the old :148) the same way workspace/github already are. No hand-typed DMC command lines remain.

The now-wrong analytics line

The removed block contained - Analytics & logs: datamachine analytics|logs. That line was actively wrong: datamachine analytics was removed from core and moved to data-machine-business. DMC was shipping false guidance. Deleting the hand-copy fixes this and prevents the class of drift entirely.

How the worktree list is reflected

worktree's operations (add|list|remove|…) are not separate @subcommand methods — they're dispatched through an internal match ( $operation ) { … } inside the single worktree() method. So the existing CommandIntrospector::subcommands() (which reflects @subcommand annotations) can't see them.

This PR adds CommandIntrospector::match_arm_pipe_list() / match_arm_keys(), which read the method's source range via reflection and extract the string-literal match arm keys in source order, de-duplicated, ignoring default. Context-safe (only runs when WP_CLI_Command is loaded; never constructs command instances), with a hand-typed fallback only used if reflection is unavailable.

Bonus: the reflected list is more accurate than the old literal — it recovers operations the hand-typed list omitted (bounded-cleanup-eligible-apply, emergency-cleanup, active-no-signal-*).

Merge ORDER (critical — do not merge out of order)

⚠️ data-machine#2640 (core registering its own reflected datamachine section) MUST merge BEFORE this removal. If this merges first, wp datamachine memory compose AGENTS.md produces no datamachine section (core's operating layer would vanish from AGENTS.md until #2640 lands).

Introspector delegation note

The issue notes that once data-machine#2639 (shared __invoke-aware CliCommandIntrospector) lands, DMC should prefer the shared helper via class_exists guard. As of this PR #2639 is still open, so per the issue's instruction the local CommandIntrospector stays. Migrating to the shared helper is left as follow-up once #2639 merges.

Verification

  • No datamachine (core) command lines remain in AgentsMdSections.php; no hand-typed DMC command lists remain.
  • php -l clean on both files. (This component ships no phpcs harness/config; php -l is the lint surface.)
  • Reflection verified against the real WorkspaceCommand::worktree() body — extracts all 17 match-arm operations correctly.

Refs the #2613 (data-machine) AGENTS.md dynamic-CLI fleet.

…d section

DMC's AgentsMdSections.php hand-typed core's entire `datamachine` command
surface as a static heredoc, a layer inversion: core now registers its own
reflected AGENTS.md section (data-machine#2640), and the hand-copy had already
drifted (the `datamachine analytics|logs` line was wrong — analytics moved to
data-machine-business).

- Remove the hand-typed core `datamachine ...` narration (Memory/Automation/
  Communication/Content-ops/System bullets). Core owns that section.
- Rename the section to `datamachine-code` and keep only the workspace/worktree/
  github guidance DMC rightfully owns.
- Reflect the `worktree` operation list from its dispatch `match` arms via a new
  CommandIntrospector::match_arm_pipe_list() helper, mirroring how workspace/
  github are already reflected. No hand-typed DMC command lists remain; the
  reflected list also recovers operations the literal omitted.

Refs #734
@homeboy-ci

homeboy-ci Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Homeboy Results — data-machine-code

Lint

lint — passed

ℹ️ Full options: homeboy docs commands/lint
Deep dive: homeboy lint data-machine-code --changed-since edd42e3

Artifacts and drill-down
  • CI results artifact: homeboy-ci-results-data-machine-code-lint-quality-Linux-node24 contains immediate command JSON for this action invocation.
  • Observation artifact: homeboy-observations-data-machine-code-lint-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>.
  • Artifacts are attached to the workflow run: https://github.com/Extra-Chill/data-machine-code/actions/runs/27582717914

Test

test — passed

ℹ️ Auto-fix lint issues: homeboy refactor data-machine-code --from lint --write
ℹ️ Collect coverage: homeboy test data-machine-code --coverage
ℹ️ Save test baseline: homeboy test data-machine-code --baseline
ℹ️ Pass args to test runner: homeboy test -- [args]
ℹ️ Full options: homeboy docs commands/test
Deep dive: homeboy test data-machine-code --changed-since edd42e3

Artifacts and drill-down
  • CI results artifact: homeboy-ci-results-data-machine-code-test-quality-Linux-node24 contains immediate command JSON for this action invocation.
  • Observation artifact: homeboy-observations-data-machine-code-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>.
  • Artifacts are attached to the workflow run: https://github.com/Extra-Chill/data-machine-code/actions/runs/27582717914

Audit

audit — passed

  • audit — 1 finding(s)
  • Total: 1 finding(s)

Deep dive: homeboy audit data-machine-code --changed-since edd42e3

Artifacts and drill-down
  • CI results artifact: homeboy-ci-results-data-machine-code-audit-quality-Linux-node24 contains immediate command JSON for this action invocation.
  • Observation artifact: homeboy-observations-data-machine-code-audit-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>.
  • Artifacts are attached to the workflow run: https://github.com/Extra-Chill/data-machine-code/actions/runs/27582717914
Tooling versions
  • Homeboy CLI: homeboy 0.232.0+8fd2b92d870e+f9a45f7
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: 4a30a5a6
  • Action: unknown@unknown

@chubes4 chubes4 merged commit 8535ecd into main Jun 15, 2026
5 checks 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.

refactor: stop hand-typing core's 'datamachine' namespace in AgentsMdSections.php; reflect DMC's own commands too

1 participant