Skip to content

Add extensibility hooks to daily memory archive#1046

Merged
chubes4 merged 1 commit intomainfrom
add/daily-memory-hooks
Apr 14, 2026
Merged

Add extensibility hooks to daily memory archive#1046
chubes4 merged 1 commit intomainfrom
add/daily-memory-hooks

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Apr 14, 2026

Summary

  • Adds datamachine_daily_memory_pre_archive filter so developers can intercept archived content and handle storage themselves (WordPress pages, external APIs, etc.)
  • Adds datamachine_daily_memory_archived action that fires after archive processing, regardless of how storage was handled

Why

The daily memory task currently writes archived content exclusively to flat markdown files (daily/YYYY/MM/DD.md). This works great as the default, but developers building on top of Data Machine may want to store archived knowledge differently — as WordPress content, in a database, or via an external service.

These hooks let them do that without modifying the core task. If datamachine_daily_memory_pre_archive returns true, the flat-file write is skipped entirely. If nothing hooks it, behavior is 100% unchanged.

Example usage

// Store archived memory as a WordPress page instead of a flat file.
add_filter( 'datamachine_daily_memory_pre_archive', function ( $handled, $content, $date, $context ) {
    wp_insert_post( array(
        'post_type'    => 'page',
        'post_title'   => 'Daily Knowledge — ' . $date,
        'post_content' => $content,
        'post_status'  => 'private',
        'post_date'    => $date . ' 00:00:00',
    ) );
    return true; // Skip flat-file write.
}, 10, 4 );

// Log archive events without changing storage.
add_action( 'datamachine_daily_memory_archived', function ( $content, $date, $handled, $context ) {
    error_log( sprintf( 'Daily memory archived for %s (%d bytes, handled: %s)', $date, $context['archived_size'], $handled ? 'yes' : 'no' ) );
}, 10, 4 );

Changes

One file: inc/Engine/AI/System/Tasks/DailyMemoryTask.php

  • Extract $archive_context array to avoid duplication between filter and action
  • Add datamachine_daily_memory_pre_archive filter before the flat-file write
  • Wrap existing flat-file write in if ( ! $handled ) conditional
  • Add datamachine_daily_memory_archived action after processing
  • Full PHPDoc with @since 0.46.0 tags on both hooks

Add two extensibility points to DailyMemoryTask so developers can
intercept and replace the flat-file archive write:

- datamachine_daily_memory_pre_archive (filter): return true to skip
  the default daily/YYYY/MM/DD.md write and handle storage externally
  (e.g., WordPress pages, external services)

- datamachine_daily_memory_archived (action): fires after archive
  processing completes, regardless of how storage was handled

Default behavior is completely unchanged — flat-file write proceeds
unless a filter explicitly opts out.
@homeboy-ci
Copy link
Copy Markdown
Contributor

homeboy-ci bot commented Apr 14, 2026

Homeboy Results — data-machine

Audit

⚡ Scope: changed files only

audit (changed files only)

  • Alignment score: 0.763
  • Outliers in current run: 52
  • Drift increased: no
  • Severity counts: info: 39, unknown: 52, warning: 38
  • Top actionable findings:
    1. inc/Engine/AI/Directives/DirectiveOutputValidator.php — missing_method — Missing method: get_outputs
    2. inc/Abilities/Flow/FlowHelpers.php — naming_mismatch — Helper-like name does not match convention suffix 'Ability': FlowHelpers
    3. inc/Abilities/FlowStep/FlowStepHelpers.php — naming_mismatch — Helper-like name does not match convention suffix 'Ability': FlowStepHelpers
    4. inc/Abilities/Job/JobHelpers.php — naming_mismatch — Helper-like name does not match convention suffix 'Ability': JobHelpers
    5. inc/Abilities/Flow/CreateFlowAbility.php — intra_method_duplicate — Duplicated block in executeBulk — 6 identical lines at line 358 and line 389
    6. inc/Abilities/FlowStep/FlowStepHelpers.php — intra_method_duplicate — Duplicated block in updateUserMessage — 7 identical lines at line 522 and line 537
    7. inc/Core/Steps/Update/Handlers/WordPress/WordPress.php — intra_method_duplicate — Duplicated block in registerTools — 5 identical lines at line 65 and line 87
    8. inc/Engine/AI/System/Tasks/DailyMemoryTask.php — intra_method_duplicate — Duplicated block in execute — 6 identical lines at line 302 and line 312
    9. inc/Engine/AI/System/Tasks/ImageGenerationTask.php — intra_method_duplicate — Duplicated block in trySetFeaturedImage — 6 identical lines at line 281 and line 299
    10. inc/Abilities/Flow/FlowHelpers.php — parallel_implementation — Parallel implementation: syncStepsToFlow has similar call pattern to popFromQueue in inc/Abilities/Flow/QueueAbility.php — shared calls: array, count, do_action, get_flow, update_flow
Audit findings (10 shown)
1. **inc/Engine/AI/Directives/DirectiveOutputValidator.php** — missing_method — Missing method: get_outputs
2. **inc/Abilities/Flow/FlowHelpers.php** — naming_mismatch — Helper-like name does not match convention suffix 'Ability': FlowHelpers
3. **inc/Abilities/FlowStep/FlowStepHelpers.php** — naming_mismatch — Helper-like name does not match convention suffix 'Ability': FlowStepHelpers
4. **inc/Abilities/Job/JobHelpers.php** — naming_mismatch — Helper-like name does not match convention suffix 'Ability': JobHelpers
5. **inc/Abilities/Flow/CreateFlowAbility.php** — intra_method_duplicate — Duplicated block in `executeBulk` — 6 identical lines at line 358 and line 389
6. **inc/Abilities/FlowStep/FlowStepHelpers.php** — intra_method_duplicate — Duplicated block in `updateUserMessage` — 7 identical lines at line 522 and line 537
7. **inc/Core/Steps/Update/Handlers/WordPress/WordPress.php** — intra_method_duplicate — Duplicated block in `registerTools` — 5 identical lines at line 65 and line 87
8. **inc/Engine/AI/System/Tasks/DailyMemoryTask.php** — intra_method_duplicate — Duplicated block in `execute` — 6 identical lines at line 302 and line 312
9. **inc/Engine/AI/System/Tasks/ImageGenerationTask.php** — intra_method_duplicate — Duplicated block in `trySetFeaturedImage` — 6 identical lines at line 281 and line 299
10. **inc/Abilities/Flow/FlowHelpers.php** — parallel_implementation — Parallel implementation: `syncStepsToFlow` has similar call pattern to `popFromQueue` in inc/Abilities/Flow/QueueAbility.php — shared calls: `array`, `count`, `do_action`, `get_flow`, `update_flow`
Tooling versions
  • Homeboy CLI: homeboy 0.88.7+86d3def9
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v2

Homeboy Action v1

@chubes4 chubes4 merged commit 27f05e8 into main Apr 14, 2026
1 check passed
@chubes4 chubes4 deleted the add/daily-memory-hooks branch April 14, 2026 02:27
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