Skip to content

Protect agent files from deletion and enforce abilities-first architecture#375

Merged
chubes4 merged 1 commit into
mainfrom
fix/protect-agent-files-and-abilities-layer
Feb 25, 2026
Merged

Protect agent files from deletion and enforce abilities-first architecture#375
chubes4 merged 1 commit into
mainfrom
fix/protect-agent-files-and-abilities-layer

Conversation

@chubes4

@chubes4 chubes4 commented Feb 24, 2026

Copy link
Copy Markdown
Member

Summary

Fixes two security/architecture gaps in the file operations layer:

Changes

Issue #366 — Protected file deletion

  • Add FileAbilities::PROTECTED_FILES constant (SOUL.md, MEMORY.md)
  • Guard deleteAgentFile() in abilities layer — returns error for protected files
  • Defense-in-depth: REST delete_agent_file() also checks before delegating
  • UI: AgentFileList.jsx now protects MEMORY.md alongside SOUL.md (was only SOUL.md)

Issue #367 — Abilities-first enforcement

  • New datamachine/write-agent-file ability with executeWriteAgentFile() method
  • Protected files cannot be blanked (empty content write blocked)
  • put_agent_file() REST endpoint now delegates to abilities layer
  • New datamachine/daily-memory-delete ability in DailyMemoryAbilities
  • All 4 daily memory REST endpoints now delegate to DailyMemoryAbilities
  • put_daily_file() and delete_daily_file() now respect daily_memory_enabled setting
  • Removed direct DailyMemory, DirectoryManager, FilesystemHelper imports from Files.php

Architecture

Before:                          After:
REST PUT /agent/file             REST PUT /agent/file
  └─ DirectoryManager (direct)     └─ FileAbilities::executeWriteAgentFile()
                                       ├─ protected file validation
REST DELETE /agent/file                ├─ empty content guard
  └─ FileAbilities (no guard)          └─ DirectoryManager + FilesystemHelper

REST daily endpoints             REST DELETE /agent/file
  └─ new DailyMemory() (direct)    ├─ defense-in-depth protected check
                                    └─ FileAbilities::executeDeleteFile()
                                        └─ protected file guard

                                 REST daily endpoints
                                   └─ DailyMemoryAbilities
                                       ├─ daily_memory_enabled check
                                       └─ DailyMemory storage

Files Changed

File What
inc/Abilities/FileAbilities.php +PROTECTED_FILES constant, +writeAgentFile ability, +deletion guard
inc/Abilities/DailyMemoryAbilities.php +deleteDaily() with settings check, +ability registration
inc/Api/Files.php Delegate to abilities, defense-in-depth, remove direct storage imports
AgentFileList.jsx Protect MEMORY.md from deletion in UI

Closes #366, closes #367

…lities layer

- Add PROTECTED_FILES constant to FileAbilities (SOUL.md, MEMORY.md)
- Guard deleteAgentFile() against deleting protected files
- Add defense-in-depth protected file check in REST delete endpoint
- Create datamachine/write-agent-file ability with empty-content guard
- Delegate put_agent_file() REST endpoint to abilities layer
- Add deleteDaily() to DailyMemoryAbilities with settings check
- Route all 4 daily memory REST endpoints through DailyMemoryAbilities
- Protect MEMORY.md from deletion in AgentFileList.jsx UI
- Remove direct DailyMemory/DirectoryManager/FilesystemHelper usage from Files.php

Closes #366, closes #367
@chubes4 chubes4 force-pushed the fix/protect-agent-files-and-abilities-layer branch from e73b3af to 59fc448 Compare February 25, 2026 00:02
@chubes4 chubes4 merged commit 079931d into main Feb 25, 2026
@chubes4 chubes4 deleted the fix/protect-agent-files-and-abilities-layer branch February 25, 2026 00:02
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.

REST endpoints bypass abilities layer for agent files and daily memory SOUL.md and MEMORY.md deletion unprotected in backend

1 participant