refactor: centralize site-scoped agent-context default in MaintenanceTask base#568
Merged
Merged
Conversation
…Task base Introduce a thin MaintenanceTask abstract base (extends SystemTask) that sets requiresAgentContext()=false once, then reparent the five workspace- maintenance tasks to it and delete their five duplicated overrides. Every DMC task is site-scoped workspace maintenance with no agent owner; core SystemTask defaults requiresAgentContext() to true, so forgetting the override fails quietly at TaskScheduler's agent-context gate (the #564 silent-cleanup failure). Centralizing the default makes that failure mode impossible by omission. Mirrors core's RetentionTask, which performs the same opt-out in its base. Kept as a pure default base (no executeTask finalizer) since only the agent-context default needs centralizing. No behavior change vs #565: all five tasks still report requiresAgentContext()=false, now inherited from MaintenanceTask. Closes #566
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #566
What
Introduce a thin
MaintenanceTaskabstract base class ininc/Tasks/that sets the site-scoped agent-context default once, then reparent the five workspace-maintenance tasks to it and delete their five hand-copiedrequiresAgentContext()overrides (the ones PR #565 added as the symptom fix).Reparented (and override deleted) in:
inc/Tasks/WorkspaceDiskEmergencyCleanupTask.phpinc/Tasks/WorktreeCleanupTask.phpinc/Tasks/WorkspaceRetentionCleanupTask.phpinc/Tasks/WorkspaceHygieneReportTask.phpinc/Tasks/WorktreeCleanupChunkTask.phpNow-unused
use DataMachine\Engine\AI\System\Tasks\SystemTask;was removed from the two files that no longer referenceSystemTaskdirectly (WorktreeCleanupTask,WorktreeCleanupChunkTask);MaintenanceTaskis same-namespace so needs nouse. No change to the schedule registration indata-machine-code.php(alreadyper_agent => false).Why this shape
Every DMC task is site-scoped workspace maintenance with no agent owner. Core
SystemTaskdefaultsrequiresAgentContext()totrue(the safe default for content-mutating agent tasks indata-machinecore), so each DMC task author must remember to override it — and forgetting fails quietly: the agent-less recurring schedule is rejected atTaskScheduler::schedule()'s agent-context gate and the cleanup silently stops (the #564 failure: 213 identical hourly errors, disk never cleaned). Centralizing the correct-for-DMC default makes that failure mode impossible by omission, and gives one obvious place to document the site-scoped contract.Core precedent
This mirrors core's
DataMachine\Engine\AI\System\Tasks\Retention\RetentionTask, which already does the identical opt-out in its base:Unlike
RetentionTask,MaintenanceTaskis kept a pure default base — noexecuteTask()finalizer, no abstract wrapper, no other behavior — because we only want the agent-context default centralized. A task that genuinely needs agent context can still override back totrue.No behavior change vs #565
All five tasks still report
requiresAgentContext() === false— now inherited fromMaintenanceTaskrather than declared per-class.Evidence
php -lclean onMaintenanceTask.phpand all five reparented files:Reflection harness (loads core
SystemTask, thenMaintenanceTask+ the five tasks, reflectsrequiresAgentContext()on each):getDeclaringClass()is nowDataMachineCode\Tasks\MaintenanceTaskfor all five — proving the override is inherited from the base, not duplicated.homeboy lint(PHPCS + PHPStan) on the 6 changed files: PHPCS passed, PHPStan passed. (The command's overall exit was non-zero only due to a pre-existing CI-parity meta-warning that the localdata-machinevalidation-dependency checkout is behind origin/main — unrelated to these changes; the actual lint and static analysis ran clean.)Target branch note
This PR targets
fix-disk-cleanup-agent-context(the #565 branch), notmain, because #565 is unmerged and this refactor builds on its override methods. Once #565 merges, retarget this PR tomain(or rebase onto main).