feat(loom): configurable fusion threshold, edge dedup fix, and graph-build E2E coverage#77
Open
tongshu2023 wants to merge 1 commit into
Open
feat(loom): configurable fusion threshold, edge dedup fix, and graph-build E2E coverage#77tongshu2023 wants to merge 1 commit into
tongshu2023 wants to merge 1 commit into
Conversation
…d E2E coverage (zijinz456#38) Closes out the remaining LOOM MVP checklist items from zijinz456#38: - Surface the Graphusion fusion similarity threshold as a setting (LOOM_FUSION_SIMILARITY_THRESHOLD, default 0.85) resolved at call time, so deployments can tune fusion aggressiveness without a code change. Falls back to the module default when settings are unavailable. - Fix a real edge-insertion bug surfaced by the new E2E test: when the same concept is extracted from multiple chunks and embedding fusion is unavailable (no embedding provider configured), identical edges were emitted repeatedly and violated uq_knowledge_edge at commit, failing the whole graph build. Edge creation now dedupes on (source, target, relation_type). - Add tests/test_loom_graph_e2e.py: end-to-end content upload -> build_course_graph -> persisted node/edge verification on real in-memory SQLite (not mocks), idempotent rebuild, no-content course, fusion dedup of near-duplicate concepts, threshold override behavior, and bidirectional cross-course reinforces linking without duplicates. Consolidation triggers and cross-course linking from the checklist already exist in loom_mastery.py / loom_graph.py; this PR verifies the latter end-to-end. Co-Authored-By: Claude Fable 5 <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
Addresses the remaining LOOM MVP checklist items from #38. Of the backend checklist, consolidation triggers (
_consolidate_mastered_concepts, threshold 0.85 → parent boost) and cross-course linking (link_cross_course_concepts) already exist in the codebase — what was missing was the configurable fusion threshold and the end-to-end test, plus a real bug the new E2E test surfaced.Changes
1.
LOOM_FUSION_SIMILARITY_THRESHOLDis now a settingconfig.pygainsloom_fusion_similarity_threshold: float = 0.85._fuse_conceptsresolves it at call time via_fusion_threshold(), so deployments can tune fusion aggressiveness through the environment without a code change. Falls back to the module default when settings are unavailable (isolated unit tests).2. Bug fix: duplicate edge insertion fails the whole graph build
Surfaced by the new E2E test running against real SQLite instead of mocks: when the same concept is extracted from multiple content chunks and embedding fusion is unavailable (no embedding provider configured — a common deployment), edge creation re-emitted identical
(source, target, relation_type)rows. Theuq_knowledge_edgeconstraint then aborted the commit, failing the entire graph build. The existing mocked tests could not catch this because mock sessions don't enforce constraints.Edge creation now dedupes on
(source_id, target_id, relation_type).3. E2E test: upload → auto-build graph → verify nodes/edges
tests/test_loom_graph_e2e.py, on real in-memory SQLite (aiosqlite+Base.metadata.create_all), following the house pattern fromtest_learning_pipeline_e2e.py:build_course_graph→ persisted nodes verified by name/description/bloom metadata, prerequisite and related edges verified by directionreinforcesedges exactly once, and re-linking does not duplicateTests
tests/test_loom_graph_e2e.py(6 new) +tests/test_loom.py: 43 passed locally.Checklist mapping
LOOM_FUSION_SIMILARITY_THRESHOLD=0.85) — threshold now configurable; chunk-duplicate edge bug fixedloom_mastery.py(CONSOLIDATION_THRESHOLD = 0.85, parent boost 0.1)🤖 Generated with Claude Code