Skip to content

fix: invalidate retired AGENTS.md sections across multisite snapshots - #3531

Merged
chubes4 merged 1 commit into
mainfrom
fix/3529-snapshot-invalidation
Sep 20, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/3529-snapshot-invalidation

Conversation

@chubes4

@chubes4 chubes4 commented Sep 20, 2026

Copy link
Copy Markdown
Member

Fixes #3529

The gap

MultisiteSectionAggregator merges per-site snapshots by union. A compose only rewrites the current site's snapshot, because switch_to_blog() does not load the other site's plugins. That design is correct and stays.

What it did not do: invalidate. Retire a section from a mu-plugin, compose on one site, and every other site's stored copy of that section is merged back into the shared AGENTS.md. On extrachill.com that was 10 stale snapshots resurrecting homeboy-codebox-agent-tasks after wp-coding-agents#610 unregistered it. One blog (13, extrachill.link) is domain-mapped onto blog 4 by sunrise.php and can never recompose itself.

The fix

When a slug leaves this site's previous snapshot, strip it from every other site's stored snapshot via update_blog_option. The other site's plugins never need to load.

Site-specific sections this site never rendered are absent from $previous, so they are not in $dropped and survive. The existing smoke assertion still holds: refreshing site 2 does not erase site 1's provider.

Also:

  • generated_at on snapshots (no version bump — bumping VERSION would fail valid_snapshot() for every existing site and blank the root file until the whole network reseeds, which is the bug we're fixing).
  • wp datamachine memory compose AGENTS.md --all-sites — one subprocess per public site with that site's --url, so new site-specific sections still get a honest full refresh. Duplicate hosts are skipped with a warning.

Test

php tests/agents-md-multisite-composition-smoke.php — existing cases plus: both sites render shared-retired, site 1 drops it, merged file and site 2's stored snapshot no longer contain it.

Not in this PR

  • Fan-out recompose on every section-registry change (option 1 in the issue). --all-sites is the operator lever; automatic fan-out is a later scheduler.
  • Fixing sunrise.php mapping extrachill.link → blog 4 while blog 13 still exists. That's Extra Chill config, not Data Machine. Drop-propagation still converges that zombie snapshot without loading it.

MultisiteSectionAggregator merges per-site snapshots by union. A section
retired from shared code (mu-plugin / network plugin) stayed in the root
file until every site recomposed, because each compose only rewrites the
current site's snapshot. On extrachill.com that turned unregistering
homeboy-codebox-agent-tasks into an 11-site manual loop, and one
unreachable blog (domain-mapped onto another) could never refresh itself.

When a slug leaves this site's previous snapshot, strip it from every
other site's stored snapshot via update_blog_option. switch_to_blog()
cannot rediscover the other site's plugins, but the stored arrays are
writable. Site-specific sections this site never rendered are absent
from the previous snapshot, so they are not dropped.

Also adds `wp datamachine memory compose --all-sites` to recompose each
public site through a fresh WP-CLI process with that site's --url, and
records generated_at on snapshots without bumping the payload version
(a version bump would blank the root file until every site reseeds).

Refs #3529
@chubes4
chubes4 merged commit 5c11727 into main Sep 20, 2026
25 checks passed
@chubes4
chubes4 deleted the fix/3529-snapshot-invalidation branch September 20, 2026 15:15
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.

MultisiteSectionAggregator: no snapshot invalidation — retired sections survive in composed root files

1 participant