Skip to content

refactor(channels,runtimes): move mu-plugin file registrations to wp_options where safe #135

Description

@chubes4

Summary

wp-coding-agents currently writes two mu-plugin files at install/upgrade time:

This is the architectural inverse of the WordPress idiom: plugin-managed configuration normally lives in wp_options, not in mu-plugins/. Mu-plugins are reserved for site-operator-owned policy that cannot be deactivated. Third-party-managed config there:

DMC's runtime registries (CliChannelRegistry, the dispatch-message handler filter, the worktree-signature filter) already read from apply_filters( ... ) AND get_option( ... ) in a dual pattern — meaning the option-based path is supported in DMC today. Only the wp-coding-agents installer chose the mu-plugin path.

Why this wasn't done in the original PRs

Per #131's chosen-mechanism rationale (which I'm reproducing here from the PR body for context):

lib/cli-channel.sh:21 documents the prior rejection of wp option writes for the parallel CLI-channel registry: "DB writes there race against multisite + Redis caching and have been a source of intermittent install failures historically."

That's a real constraint. It's also one that can be fixed with care — wp option update works on multisite + Redis when invoked correctly. The historical install failures referenced in that comment are worth investigating before this refactor lands.

Proposed work

  1. Investigate the cited historical install failures. Find the actual symptoms (git-blame the comment, dig for prior install reports). Are they reproducible? Were they specific to a Redis configuration that's been since fixed? Was the issue actually wp option update itself or an unrelated install-time race?
  2. If the option path is genuinely safe today, rewrite both lib/cli-channel.sh and lib/runtime-signature.sh to use wp option patch insert/delete instead of the mu-plugin file rewrite.
  3. Migration path: on upgrade, if the legacy mu-plugin file exists, parse its marker blocks, write the equivalent entries to wp_options, then delete the file. Symmetric to how the agent-ping legacy retirement was handled — clean on-read migration with no script.
  4. If the option path is still unsafe (or partially so — e.g. safe for channels but risky for signatures, or vice versa), document the constraints clearly and stay on the mu-plugin path for whichever surface needs it. File a follow-up on the constraint.

Acceptance criteria

  • If the refactor proceeds: both lib/cli-channel.sh and lib/runtime-signature.sh write to wp_options instead of wp-content/mu-plugins/.
  • Migration handles existing installs without losing registered channels or signatures.
  • No regression in idempotency, dry-run support, or test coverage.
  • Documentation in README.md updated.
  • No CHANGELOG.md / VERSION edits.

If the refactor does NOT proceed because the option path is genuinely unsafe:

  • The investigation findings are documented in a comment on this issue.
  • lib/cli-channel.sh:21's comment is updated to be specific about which install configurations the prohibition covers, so future contributors don't perpetually re-debate.
  • This issue closes with wontfix and a link to the documented constraint.

Related

Priority

Low. The mu-plugin path works once #133 fixes perms. This is architectural cleanup, not a bug fix. File-and-park unless someone wants to do the investigation work in step 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions