Skip to content

Commit 34c53f6

Browse files
committed
fix(coderabbit #458): route deprecated nars_rule() through inference_type()
CodeRabbit caught that the deprecated nars_rule() shim duplicated the Chain/ChainRev/Fork/Collider → Deduction/Induction/Abduction mapping that already lives in the canonical inference_type() method. Two-source mappings drift. If a future PR ever extends the junction taxonomy or refines a mapping (e.g. Pearl figure → NARS rule discount calibration), maintainers would have to update both sites and the v1 + v2 APIs could disagree silently for downstream consumers. This commit routes nars_rule() through inference_type() so the v1 shim is a transparent projection: match self.inference_type() { Some(InferenceType::Deduction) => Some(NarsRule::Deduction), Some(InferenceType::Induction) => Some(NarsRule::Induction), Some(InferenceType::Abduction) => Some(NarsRule::Abduction), Some(InferenceType::Revision) | Some(InferenceType::Synthesis) | None => None, } Revision + Synthesis are NOT junction-derivable (no Pearl junction maps to either), so those arms return None defensively even though they are unreachable in practice given the Chain/ChainRev/Fork/ Collider/Unrelated exhaustion. The existing tests (deprecated_nars_rule_matches_inference_type, deprecated_nars_rule_none_when_unrelated, from_nars_rule_lifts_to_ inference_type) all continue to pass with the routed shim — the observable behavior is identical; only the source of truth is consolidated. The CodeRabbit comment references the same learnings note that codex P1 #457 cited: 'When a PR ships v2-feature work with v1 API backward- compat shims, expect codex review to flag any v1 accessor that hasn't been routed through the canonical mapping. Resolve before merge; don\'t defer.' Provenance: CodeRabbit review on PR #458.
1 parent c034829 commit 34c53f6

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

crates/lance-graph-contract/src/pearl_junction.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,20 @@ impl PearlJunction {
118118
)]
119119
#[allow(deprecated)]
120120
pub const fn nars_rule(self) -> Option<NarsRule> {
121-
match self {
122-
Self::Chain | Self::ChainRev => Some(NarsRule::Deduction),
123-
Self::Fork => Some(NarsRule::Induction),
124-
Self::Collider => Some(NarsRule::Abduction),
125-
Self::Unrelated => None,
121+
// Route the deprecated v1 surface through inference_type() so the
122+
// junction → rule mapping lives in ONE place (per CodeRabbit on
123+
// PR #458 — avoid the same duplication-map drift class that
124+
// motivated the inference_type() introduction in #457).
125+
//
126+
// The full InferenceType taxonomy includes Revision + Synthesis
127+
// which are NOT junction-derivable (no Pearl junction maps to
128+
// either), so those arms return None defensively even though
129+
// they are unreachable in practice.
130+
match self.inference_type() {
131+
Some(InferenceType::Deduction) => Some(NarsRule::Deduction),
132+
Some(InferenceType::Induction) => Some(NarsRule::Induction),
133+
Some(InferenceType::Abduction) => Some(NarsRule::Abduction),
134+
Some(InferenceType::Revision) | Some(InferenceType::Synthesis) | None => None,
126135
}
127136
}
128137
}

0 commit comments

Comments
 (0)