Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Jul 21, 2025

Refactor the scheduler to use the new storage notifications API instead of per-document update callbacks. This provides a more efficient and unified approach to tracking changes across the memory space.

  • Replace document.updates() with IStorageSubscription notifications
  • Migrate from per-document callbacks to centralized change handling
  • Update reactive dependencies to use IMemorySpaceAddress throughout
  • Add addressesToPathByEntity() utility for path organization
  • Improve path-based change detection with proper prefix matching
  • Fix edge cases where startPath is longer than triggering paths
  • Add comprehensive tests for literal values and complex scenarios

Summary by cubic

Refactored the scheduler to use the new storage notifications API and updated reactive dependency tracking for better efficiency and accuracy across memory spaces.

  • Refactors
    • Replaced per-document update callbacks with centralized storage notifications.
    • Updated dependency tracking to use IMemorySpaceAddress and improved path compaction and overlap detection.
    • Fixed edge cases where dependency paths and triggering paths differ in length.
    • Added addressesToPathByEntity utility and comprehensive tests for literal and complex value scenarios.

@seefeldb seefeldb requested review from Copilot and ubik2 July 21, 2025 17:58
@linear
Copy link

linear bot commented Jul 21, 2025

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the reactive dependencies system to use a new storage notifications API instead of per-document update callbacks. The change improves efficiency by centralizing change handling and provides better path-based change detection.

  • Replace document.updates() callbacks with centralized IStorageSubscription notifications
  • Migrate from individual document subscriptions to unified change tracking via addresssesToPathByEntity()
  • Update path comparison logic to use arraysOverlap() function for more accurate dependency matching

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/runner/test/schema.test.ts Update import to use sortAndCompactPaths from reactive-dependencies
packages/runner/test/scheduler.test.ts Remove compactifyPaths tests and update imports
packages/runner/test/reactive-dependencies.test.ts Add comprehensive tests for new utility functions and edge cases
packages/runner/src/storage/interface.ts Change MemoryAddressPathComponent from string | number to string only
packages/runner/src/scheduler.ts Replace per-document callbacks with centralized storage subscription handling
packages/runner/src/reactive-dependencies.ts Add new utility functions and improve path overlap detection
packages/runner/src/query-result-proxy.ts Convert numeric indices to strings for path consistency

Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Function name has a typo: 'addresssesToPathByEntity' should be 'addressesToPathByEntity' (extra 's')

Suggested change
addresssesToPathByEntity,
addressesToPathByEntity,

Copilot uses AI. Check for mistakes.
seefeldb and others added 6 commits July 21, 2025 13:02
…ress

Update sortAndCompactPaths to accept IMemorySpaceAddress objects instead of
raw path arrays, enabling proper handling of space, id, and type metadata.

Changes:
- Update sortAndCompactPaths to work with IMemorySpaceAddress[]
- Sort by space, id, type, then path for consistent ordering
- Only compact paths within the same space/id/type combination
- Add pathsToMapByEntity function to group addresses by space/id
- Filter non-JSON types in pathsToMapByEntity
- Update all tests to use IMemorySpaceAddress with proper URI/MediaType formats
- Add comprehensive tests for pathsToMapByEntity function
- Update benchmarks to test new sorting dimensions

This enables the scheduler to properly track dependencies across different
spaces and entities while maintaining efficient path compaction.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@seefeldb seefeldb force-pushed the berni/ct-622-switch-scheduler-to-new-updates branch from e44e206 to 8049aa9 Compare July 21, 2025 18:02
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

1 issue found across 7 files • Review in cubic

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@seefeldb seefeldb merged commit e22396b into main Jul 21, 2025
7 checks passed
@seefeldb seefeldb deleted the berni/ct-622-switch-scheduler-to-new-updates branch July 21, 2025 21:10
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.

3 participants