Skip to content

fix(codex P1 #457): restore deprecated NarsRule + nars_rule() for back-compat#458

Merged
AdaWorldAPI merged 2 commits into
mainfrom
fix/pearl-junction-deprecated-shim
Jun 3, 2026
Merged

fix(codex P1 #457): restore deprecated NarsRule + nars_rule() for back-compat#458
AdaWorldAPI merged 2 commits into
mainfrom
fix/pearl-junction-deprecated-shim

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

PR #457 removed PearlJunction::nars_rule() + the NarsRule enum outright in favor of the canonical crate::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 at InferenceType
  • PearlJunction::nars_rule() -> Option<NarsRule> — same #[deprecated] attribute, same mapping as PR feat(hhtl + pearl_junction): NiblePath utility methods + Pearl-junction figure classifier #456
  • impl From<NarsRule> for InferenceType — 1:1 migration helper so consumers can lift the deprecated type to the canonical one in a single .into() call

The 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 via From<NarsRule>
  • deprecated_nars_rule_none_when_unrelatedUnrelated returns None on both methods
  • from_nars_rule_lifts_to_inference_type — the From mapping

All 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 cite since = "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

Summary by CodeRabbit

  • Chores
    • Added a deprecated compatibility method and deprecated enum to provide backward-compatible API access; added a conversion path to the canonical inference type.
  • Tests
    • Added unit tests validating legacy-method behavior for matching and non-matching junctions and verifying the conversion maps all legacy variants correctly.

…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.
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f6453b4-3c64-4774-9b2f-8a6388c25f6b

📥 Commits

Reviewing files that changed from the base of the PR and between c034829 and 34c53f6.

📒 Files selected for processing (1)
  • crates/lance-graph-contract/src/pearl_junction.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/lance-graph-contract/src/pearl_junction.rs

📝 Walkthrough

Walkthrough

Adds a deprecated NarsRule enum and a deprecated PearlJunction::nars_rule() shim that mirrors inference_type(), plus From<NarsRule> for InferenceType and unit tests validating the mappings.

Changes

NARS Rule Deprecation Shim

Layer / File(s) Summary
Deprecated types and conversion
crates/lance-graph-contract/src/pearl_junction.rs (lines 102–176)
Adds deprecated NarsRule enum (Deduction, Induction, Abduction), pub const fn nars_rule(self) -> Option<NarsRule> on PearlJunction, and impl From<NarsRule> for InferenceType to lift deprecated variants into the canonical InferenceType.
Backwards compatibility validation
crates/lance-graph-contract/src/pearl_junction.rs (lines 423–467)
Unit tests ensure nars_rule() returns the expected NarsRule for collider junctions, returns None for unrelated junctions, and that each NarsRule variant converts to the corresponding InferenceType via From.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 I hopped through enums old and new,
Kept Deduction, Induction, Abduction in view.
A gentle shim, a quiet lift,
Old rules retire with a tidy gift.
Code and tests now share the queue.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: restoring deprecated NarsRule and nars_rule() for backward compatibility after a breaking API change, directly matching the PR's core objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pearl-junction-deprecated-shim

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 063f7df and c034829.

📒 Files selected for processing (1)
  • crates/lance-graph-contract/src/pearl_junction.rs

Comment thread 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.
@AdaWorldAPI AdaWorldAPI merged commit 41273f3 into main Jun 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant