fix(codex P1 #457): restore deprecated NarsRule + nars_rule() for back-compat#458
Conversation
…k-compat PR #457 removed PearlJunction::nars_rule() + the NarsRule enum outright. Codex P1 review flagged this as a breaking change for downstream consumers that imported PR #456's public surface, even one commit after introduction. This PR restores both as #[deprecated] shims: - pub enum NarsRule { Deduction, Induction, Abduction } marked #[deprecated(since = "0.2.0", note = "...")] - preserved as the original three-variant alias enum - PearlJunction::nars_rule() -> Option<NarsRule> marked deprecated with the same since/note - delegates to the same Chain/ChainRev/ Fork/Collider mapping it had in PR #456 - impl From<NarsRule> for InferenceType - 1:1 migration helper so consumers can lift the deprecated type to the canonical one The canonical inference_type() -> Option<InferenceType> method introduced in PR #457 is the recommended API; the deprecated shims emit a compile-time warning pointing to it. Removed in a future major version bump. Tests: - deprecated_nars_rule_matches_inference_type (round-trip via From) - deprecated_nars_rule_none_when_unrelated - from_nars_rule_lifts_to_inference_type (the From mapping) All marked #[allow(deprecated)] so they exercise the shim without triggering the warning. Net: the public surface of PR #456 remains intact (with deprecation warnings); new consumers reach for inference_type() + InferenceType; the duplication-map drift CodeRabbit warned about is constrained to the deprecated subset and slated for removal in 0.x.0. Provenance: codex P1 on PR #457 commit 5e3740c.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a deprecated ChangesNARS Rule Deprecation Shim
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/lance-graph-contract/src/pearl_junction.rs`:
- Around line 120-126: The nars_rule() function currently reimplements the
mapping from pearl junction variants to NarsRule in parallel; change it to
derive its result from self.inference_type() instead so the v1 shim follows the
canonical semantics. Update the body of pub const fn nars_rule(self) ->
Option<NarsRule> to call self.inference_type() and then map the resulting
InferenceType to the appropriate NarsRule (e.g., map
Deduction/Induction/Abduction cases to NarsRule::Deduction/Induction/Abduction
and pass through None for Unrelated) rather than matching on
Self::Chain/ChainRev/Fork/Collider/Unrelated directly, keeping all
variant-to-rule logic centralized in inference_type.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e81d6187-895d-4f1f-9a89-da0a1ba35dfc
📒 Files selected for processing (1)
crates/lance-graph-contract/src/pearl_junction.rs
…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.
Summary
PR #457 removed
PearlJunction::nars_rule()+ theNarsRuleenum outright in favor of the canonicalcrate::nars::InferenceType. Codex P1 review flagged this as a breaking change for downstream consumers that imported PR #456's public surface, even one commit after introduction.This PR restores both as
#[deprecated]shims so the migration is non-breaking:What's restored
pub enum NarsRule { Deduction, Induction, Abduction }— marked#[deprecated(since = "0.2.0", ...)]pointing atInferenceTypePearlJunction::nars_rule() -> Option<NarsRule>— same#[deprecated]attribute, same mapping as PR feat(hhtl + pearl_junction): NiblePath utility methods + Pearl-junction figure classifier #456impl From<NarsRule> for InferenceType— 1:1 migration helper so consumers can lift the deprecated type to the canonical one in a single.into()callThe canonical
inference_type() -> Option<InferenceType>method introduced in PR #457 remains the recommended API; the deprecated shims emit compile-time warnings pointing to it.Tests added
deprecated_nars_rule_matches_inference_type— round-trip viaFrom<NarsRule>deprecated_nars_rule_none_when_unrelated—UnrelatedreturnsNoneon both methodsfrom_nars_rule_lifts_to_inference_type— theFrommappingAll marked
#[allow(deprecated)]so they exercise the shim without triggering the warning.Why this matters
Even though no downstream consumer is known to have imported
nars_rule()in the few hours between PR #456 merging and PR #457 merging, the contract crate is explicitly described as "the single source of truth" consumed outside this repo. Removing a method one commit after introduction breaks the implicit promise that the public surface is stable enough to import. The deprecated shim costs nothing at runtime and one line of compile-time warning per call site.Slate for removal
The
#[deprecated]markers citesince = "0.2.0". The next major version bump (or whenever a coordinated breaking-change wave lands) is the right window to drop these shims; until then they keep the contract crate's surface promise.Provenance
5e3740cdSummary by CodeRabbit