Repository navigation
Conversation
cosine() returns None when a member has no usable embedding, but 0.0 is a valid similarity for orthogonal vectors. The old rank key used -(cosine(...) or -1.0), which folded 0.0 into -1.0 and made the key +1.0, so a genuinely orthogonal member sorted behind a negative-similarity one and was dropped first by [:per_node_pool]. Use 'similarity if similarity is not None else -1.0' instead, matching the score_of() convention in the same file. Members without a vector still sort last.
7 tasks done
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.
Problem
build_hierarchy_bundle_candidateranks the members of each selected topic before truncating toper_node_pool. The rank key used:cosine()(defined in this file) returnsNonewhen a member has no usable vector (missing, zero-norm, or dimension mismatch), but0.0is a perfectly valid similarity for orthogonal vectors. Because0.0 or -1.0evaluates to-1.0, an orthogonal member gets+1.0as its rank key and sorts behind a member with negative similarity (-(-0.2) = +0.2). When the pool is truncated, the orthogonal member is dropped first and a strictly worse member is kept.Fix
Resolve
Noneexplicitly instead of relying on truthiness, matching thescore_of()convention already used in the same module:Members with no usable vector still sort last (the
-1.0fallback is retained).Evidence
tests/test_hierarchy_member_pool.pydrives the realbuild_hierarchy_bundle_candidatewith a stub graph/vector store and three members with cosines1.0,0.0,-0.2, truncating the pool to 2:main:test_orthogonal_member_beats_a_negative_one_in_the_poolFAILS ('m_zero' in ['m_pos', 'm_neg']is false), i.e. the orthogonal member is lost.None) still sorts last and is not promoted by the change.ruff checkpasses on both changed files.Scope
Only the member-pool sort key changes. No public API, config, or storage format changes; no new dependencies.