fix: stabilize playbook aggregation clustering - #393
Conversation
📝 WalkthroughWalkthroughPlaybook aggregation now defaults its configuration, resolves clustering thresholds per embedding model, sanitizes trigger text for embeddings, reads storage pages exhaustively, and excludes unclusterable playbooks. Tests cover configuration migration, embedding behavior, pagination, clustering, and stale-field clearing. ChangesPlaybook aggregation pipeline
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PlaybookAggregator
participant SQLiteStorage
participant EmbeddingPolicy
participant HDBSCAN
PlaybookAggregator->>SQLiteStorage: read playbooks across bounded pages
SQLiteStorage-->>PlaybookAggregator: return complete snapshot
PlaybookAggregator->>EmbeddingPolicy: resolve clustering similarity
EmbeddingPolicy-->>PlaybookAggregator: return model threshold
PlaybookAggregator->>HDBSCAN: cluster embedded playbooks
HDBSCAN-->>PlaybookAggregator: return clusters
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@reflexio/server/services/playbook/components/aggregator.py`:
- Around line 65-75: Update _read_all_pages and its get_*_playbooks callers to
replace mutable OFFSET pagination with a consistent keyset cursor plus
high-watermark, or reuse a backend-consistent read snapshot. Ensure each page
request preserves the original ordered result set across inserts, archives, and
deletions while retaining exhaustive aggregation and bookmark behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 08d747aa-98bf-419a-bb47-bd4482dbab31
⛔ Files ignored due to path filters (1)
tests/test_data/mock_playbooks.csvis excluded by!**/*.csv
📒 Files selected for processing (18)
docs/lib/config-schema.tsreflexio/integrations/openclaw/plugin/src/openclaw_smart/publish.pyreflexio/models/config_schema.pyreflexio/server/services/embedding_text.pyreflexio/server/services/playbook/components/aggregator.pyreflexio/server/services/playbook/components/aggregator_clustering.pyreflexio/server/services/storage/sqlite_storage/governance/_rebuild_hide.pyreflexio/server/services/storage/sqlite_storage/playbook/_agent.pyreflexio/server/services/storage/sqlite_storage/playbook/_user.pytests/e2e_tests/conftest.pytests/models/test_playbook_aggregator_config.pytests/models/test_validators.pytests/server/services/playbook/test_playbook_aggregator.pytests/server/services/playbook/test_playbook_aggregator_clustering.pytests/server/services/playbook/test_playbook_generation_service.pytests/server/services/storage/test_storage_contract_playbook.pytests/server/services/storage/test_storage_contract_retention.pytests/server/services/test_embedding_text.py
b7ad899 to
30efd4f
Compare
Summary
Test plan
uv run ruff check open_source/reflexiouv run pyrightNotes
Trigger normalization is intentionally prospective. Existing stored playbook embeddings are not rewritten or backfilled by this change.
Summary by CodeRabbit
New Features
Bug Fixes