deduplication

48 beliefs (48 IN, 0 OUT)

This topic covers two closely related concerns: how the reasons system groups semantically similar beliefs using embedding-based clustering, and how it uses those clusters to detect and eliminate duplicate beliefs while preserving the integrity of the justification network. These capabilities matter because a growing belief network inevitably accumulates redundant claims, and naive deduplication risks severing dependency chains that downstream beliefs rely on. The clustering infrastructure also serves double duty, powering both the derive command's budget-aware belief selection and the semantic contradiction detection pipeline.

The clustering subsystem is built on optional dependencies, sentence-transformers and scikit-learn, gated behind a clean import check that degrades gracefully when they are absent (cluster-deps-are-optional, cluster-deps-optional-with-graceful-skip). When available, the system embeds beliefs in sorted ID order for determinism (cluster-embed-order-is-deterministic), caches embeddings keyed by content hash so edits force re-embedding (cluster-cache-keys-include-content-hash, cluster-cache-no-recompute), and partitions beliefs into clusters where every belief lands in exactly one group (list-clusters-partitions-all-beliefs, cluster-stats-sizes-sum-to-input). Budget management is precise: the auto-k heuristic targets roughly five beliefs per cluster (cluster-auto-k-heuristic), remainder slots go to the largest clusters (cluster-remainder-favors-largest), and the output never exceeds the requested budget (cluster-beliefs-respects-budget, cluster-beliefs-returns-exact-budget). The entire pipeline is deterministic given the same seed (cluster-beliefs-deterministic-with-seed, cluster-selection-is-deterministic-and-budget-exact), and it shortcuts all ML work when beliefs fit within budget (cluster-skips-ml-when-under-budget). This same infrastructure is reused by semantic contradiction detection (semantic-contradiction-reuses-cluster-infrastructure), which clusters beliefs before sending topically related groups to the LLM (semantic-contradictions-cluster-before-llm), skipping singleton clusters where no contradiction is possible (semantic-contradiction-skips-singleton-clusters).

Deduplication itself operates on these clusters with careful attention to network topology. In auto mode, the survivor of each duplicate cluster is the node with the most dependents, with lexicographic tiebreaking (dedup-auto-keeps-most-dependents, dedup-keeps-most-connected-node, dedup-survivor-selection-is-topology-reliable). The dependent count reflects the complete dependency graph including both antecedent and outlist edges (dedup-reflects-complete-dependency-graph). When losers are retracted, all justification references across the network are rewritten to point at the survivor (dedup-rewrites-both-antecedents-and-outlist), preserving topology (dedup-is-topology-preserving-and-auditable). The system also supports human oversight through an editable plan format with KEEP/RETRACT markers (dedup-plan-is-user-editable). On the prevention side, the validate-proposals step uses Jaccard similarity on tokenized belief IDs to block re-derivation of retracted beliefs under variant names (validate-proposals-rejects-jaccard-similar-to-out, jaccard-tokenizer-splits-on-hyphens-and-colons).

A substantial number of beliefs in this topic are themselves flagged as duplicates or as being covered by other existing beliefs. Entries like import-is-idempotent, network-dependents-eagerly-maintained, premise-default-in, and propagation-is-immediate each note which prior belief already captures the same claim. Several others, such as make-nodes-excludes-active-premises, network-tests-are-database-free, and hash-file-import-unused, are marked as test infrastructure details or trivial implementation artifacts rather than meaningful architectural invariants. All of these remain IN rather than retracted, which suggests they were identified as duplicates during a review pass but have not yet been cleaned up through the deduplication pipeline they themselves describe.