Skip to content

Comments

Replace individual memory directives with filter-based CoreMemoryFilesDirective#330

Merged
chubes4 merged 6 commits intomainfrom
feature/core-memory-files-directive
Feb 24, 2026
Merged

Replace individual memory directives with filter-based CoreMemoryFilesDirective#330
chubes4 merged 6 commits intomainfrom
feature/core-memory-files-directive

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Feb 24, 2026

Summary

Replaces the individual AgentSoulDirective and AgentMemoryDirective with a single CoreMemoryFilesDirective backed by a WordPress filter registry. Adds USER.md as a new default memory file. Removes deletion protection — all memory files are equal.

Before → After

BEFORE (one class per file):
Priority 20 → AgentSoulDirective     → reads SOUL.md
Priority 30 → AgentMemoryDirective   → reads MEMORY.md

AFTER (single directive, filter registry):
Priority 20 → CoreMemoryFilesDirective
               ├─ internal 10: SOUL.md
               ├─ internal 20: USER.md  (new)
               └─ internal 30: MEMORY.md

Design

  • datamachine_memory_files filter — the single registry for all core memory files
  • Files declare file (filename) and priority (sort order)
  • Plugins/themes hook in to add, remove, or reorder files
  • Adding a new memory file = one filter callback, not a new PHP class
  • No core vs custom distinction — all memory files are just files

What changed

File Change
CoreMemoryFilesDirective.php New — single directive + default file registration via filter
AgentSoulDirective.php Deleted
AgentMemoryDirective.php Deleted
bootstrap.php 1 require instead of 2
AgentMemoryMigration.php Adds USER.md template + ensure method, version bump to 1.2
FileAbilities.php Removed deletion protection for SOUL.md/MEMORY.md
3 other directives Updated priority order comments

Extensibility example

// A theme adding a brand voice file:
add_filter('datamachine_memory_files', function ($files) {
    $files[] = ['file' => 'BRAND-VOICE.md', 'priority' => 15];
    return $files;
});

Net: -164 lines, +214 lines (includes new USER.md template + ensure method). Removes 2 classes, adds 1.

chubes-bot added 3 commits February 24, 2026 05:45
Consolidates AgentSoulDirective, AgentMemoryDirective (and the new
AgentUserDirective) into a single CoreMemoryFilesDirective backed by
the datamachine_memory_files WordPress filter.

- One directive loads all core memory files (SOUL.md, USER.md, MEMORY.md)
- Files registered via filter with internal priority ordering
- Plugins/themes can add, remove, or reorder files via the same filter
- No deletion protection — all memory files are equal
- Migration creates USER.md with default template on upgrade
- Removes 2 directive classes, adds 1 — net reduction in code
Extracts memory file registration into a dedicated MemoryFileRegistry
class with register/deregister/is_registered/get_all/get_filenames API.

- Registry is a pure empty container — no hardcoded files
- Default files (SOUL.md, USER.md, MEMORY.md) register in bootstrap
  through the same API any plugin or theme would use
- CoreMemoryFilesDirective simplified to just read from the registry
- MemoryFileRegistry autoloads via Composer PSR-4 (no require_once)
Legacy migration from DB to files and default file seeding are no
longer needed. The directive skips missing files gracefully — users
create memory files when they're ready. No auto-creation, no
hardcoded filenames bypassing the registry.
Copy link
Member Author

@chubes4 chubes4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean refactor. Two classes → one directive + MemoryFileRegistry with filter-driven extensibility. USER.md as a default is smart.

One issue: AgentMemoryMigration.php is deleted entirely. That handles first-run creation of SOUL.md and MEMORY.md for new installs. Without it, a fresh DM install gets no default files on disk. MemoryFileRegistry::register() just registers filenames — it doesn't create files. You need a bootstrap/ensure step somewhere, even if simpler than the old migration class.

Also: the AgentPing::register() line in data-machine.php is missing indentation and leading backslash — looks like bleed from #309, not this PR.

chubes4 and others added 3 commits February 24, 2026 11:29
Fresh installs need starter SOUL.md and MEMORY.md templates.
The removed AgentMemoryMigration handled this — replace with a
lightweight function in the activation hook. Existing files are
never overwritten. USER.md intentionally omitted (user-created).
All three registered memory files should get starter templates —
no reason to treat USER.md differently from SOUL.md and MEMORY.md.
- Remove agent_soul and global_system_prompt from SettingsAbilities
  (schema, response, save logic) — nothing reads these for AI injection
  since the migration was removed
- Remove 3 related tests for dead settings fields
- Fix use statement in bootstrap.php to fully qualified names
- Fix stale '5-tier' reference in SiteContextDirective description
@chubes4 chubes4 merged commit 03ec7c2 into main Feb 24, 2026
@chubes4 chubes4 deleted the feature/core-memory-files-directive branch February 24, 2026 21:54
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.

1 participant