chore: closure-tracker quick wins (R3-P-06 + insights filter DSL + v0.8.0) - #12
Merged
Conversation
….8.0) Three small bundled fixes from the closure-tracker tail. 1. fix(insights): filter DSL repair (cross-tenant leak) src/opencortex/insights/collector.py:49-55 used the wrong filter shape: ``conditions/op="="`` instead of the canonical ``conds/op="must"``. The Qdrant adapter's filter translator silently treated the whole expression as a no-op, so ``traces_for_period`` returned ALL traces in the collection regardless of tenant/user — every insights generation path read cross-tenant data. Fixed to match SessionRecordsRepository's ``_build_session_filter`` reference shape. 2. perf(orchestrator): R3-P-06 stale-filter short-circuit ``_sync_anchor_projection_records`` paid 2 stale-filter scans on every defer_derive initial leaf write — both prefixes were guaranteed to be empty (the leaf is brand new) but we scanned anyway. Added ``if not all_new_records and not abstract_json: return`` guard. The ``not abstract_json`` clause keeps the cleanup path on legitimate update flows where abstract_json is present but happens to contribute no anchors/fact_points. 3. chore: bump version 0.7.0 → 0.8.0 pyproject.toml + __init__.py both updated. The cone retrieval commit was labeled v0.8.0 in memory notes but neither file got bumped. After PRs #7-#11 (server-side patterns + adapter helper + perf cluster + correctness fixes + cleanup bundle), a minor bump is warranted. Verification: 277 tests run, only the pre-existing test_update_regenerates_fact_points_after_content_change failure remains (unrelated). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Three small bundled fixes from the closure-tracker tail. All single-file, low-risk.
Changes
1. fix(insights): filter DSL repair — cross-tenant leak
src/opencortex/insights/collector.py:49-55used the wrong filter shape:conditions/op="="instead of the canonicalconds/op="must". The Qdrant adapter's filter translator silently treated the whole expression as a no-op, sotraces_for_period()returned ALL traces in the collection regardless of tenant/user. Every insights generation path read cross-tenant data.Fixed to match
SessionRecordsRepository._build_session_filterreference shape:{"op": "and", "conds": [ {"op": "must", "field": "tenant_id", "conds": [tenant_id]}, {"op": "must", "field": "user_id", "conds": [user_id]}, ]}This bug was tracked in memory notes for a while but never landed. Severity: cross-tenant data leak.
2. perf(orchestrator): R3-P-06 stale-filter short-circuit
_sync_anchor_projection_recordspaid 2 stale-filter scans on everydefer_deriveinitial leaf write — both prefixes were guaranteed to be empty (the leaf is brand new) but we scanned anyway. Added a guard:The
not abstract_jsonclause keeps the cleanup path on legitimate update flows whereabstract_jsonis present but happens to contribute no anchors/fact_points.Closes closure tracker R3-P-06.
3. chore: bump version 0.7.0 → 0.8.0
pyproject.toml+src/opencortex/__init__.pyboth updated. The cone retrieval commit was labeled v0.8.0 in memory notes but neither version file got bumped. After PRs #7-#11 (server-side patterns + adapter helper + perf cluster + correctness fixes + cleanup bundle), a minor bump is warranted.Verification
tests.test_context_managertests.test_benchmark_ingest_lifecycle/test_benchmark_ingest_service/test_benchmark_ingest_response_model/test_session_records_repositorytests.test_locomo_bench/test_beam_bench/test_conversation_mapping/test_conversation_mergetests.test_http_server/test_e2e_phase1/test_write_dedupTotal: 277 tests, only pre-existing
test_update_regenerates_fact_points_after_content_changefailure remains.Closure tracker
After this PR + PR #11 (medium tier cleanup) + PR #10 (R3-RC-02/R2-14):
Test plan
uv run python3 -m unittest discover -s tests— all green except known pre-existing failure__version__import:python -c "import opencortex; print(opencortex.__version__)"returns0.8.0🤖 Generated with Claude Code