Skip to content

fix(python): None never equals a number in shared literal equality (main red) - #11918

Merged
EffortlessSteven merged 2 commits into
mainfrom
claude/fix-main-none-vs-number
Oct 31, 2026
Merged

EffortlessSteven merged 2 commits into
mainfrom
claude/fix-main-none-vs-number

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Governing issue or accepted claim: #11842 regression on main (guard gate None != 0)
Acceptance delta (one sentence): The Python guard gate again answers None != 0 as definitely true, so compare_literal_values_fails_open_on_undecoded_literals passes on main, without changing the shared literal equality the boundary rule uses for credit.

Diagnosis

#11842 replaced the guard-local guard_literals_equal with the shared three-valued literals_equal, which returns unknown for a decimal against a non-decimal. None != 0 became None, failing the guard oracle at guard_activation.rs:1436 on every PR carrying main (confirmed on #11830, #11517, #11919, #11915).

Change (head b75ec4e)

  • guard_activation.rs: guard_literals_equal states None against a decimal as Some(false) and defers everything else to literals_equal; module doc names the exception.
  • boundary.rs untouched: RIPR-SPEC-0260's non-goal (the boundary rule's mixed-kind inequality stays conservative for credit) still holds. This replaces the first revision (1d0547d), which changed the shared helper and was reviewed REPAIR_REQUIRED for exactly that.
  • Tests: None symmetric and ==/!=, None == None, ordering still unknown, and literals_equal("None", "0") stays unknown.
  • Registered the guard oracle in .ripr/traceability.toml; changelog fragment renamed to the governing item.

Proof

cargo test -p ripr --lib python:: 1712 passed locally on this head; cargo fmt --check clean. cargo xtask check-traceability was not completed locally; the hosted gate decides.

Not established

Other cross-kind pairs stay unknown.

Rollback

Revert the commit.


🤖 Generated with Claude Code

https://claude.ai/code/session_01SvmPmoTceRbARsa5PtgeVZ

#11842 made literals_equal return None for any decimal-vs-unreadable pair,
which stopped the guard gate from treating None != 0 as definitely true and
failed compare_literal_values_fails_open_on_undecoded_literals on main.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvmPmoTceRbARsa5PtgeVZ
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 149 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 0d14e1ef-d1fa-4358-af18-1a5c00af5b5c
Commits

Reviewing files that changed from the base of the PR and between fa621a3 and b75ec4e.

Files selected for processing: 3
  • .ripr/traceability.toml
  • changelog.d/11842-python-guard-none-vs-number.md
  • crates/ripr/src/analysis/language/python/guard_activation.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Copy link
Copy Markdown
Member Author

Independent bounded source review of 1d0547d: no material correctness finding in this repair. boundary.rs:2104–2111 adds symmetric decimal-versus-None inequality only after both operands are recognized; unknown identifiers remain unknown, preceding bool/number behavior and later string handling are unchanged. The two assertions at 2239–2244 discriminate removal of either new branch, and the existing guard_activation.rs regression exercises the failing None != 0 consumer. Ordering continues to refuse cross-kind comparisons.

Optional strengthening: consumer-level 0 != None, None == 0 and None < 0 controls would pin symmetry and operator separation directly. These are not identified blockers.

This is source review, not independent execution or formal PR approval. The author's 1,712 passing Python tests remain author-reported; required run 41245211953 was still running when inspected. Preserve current-candidate qualification and the existing #11830 owner's integrate-then-requalify sequence; this comment does not establish acceptance of either combined tree.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent review (fresh-context reviewer, head 1d0547d): REPAIR_REQUIRED

Inspected:

  • crates/ripr/src/analysis/language/python/boundary.rs at head 1d0547d7 and base fa621a32. The whole production change is two arms added at :2108-2109; the test change is three assertions added to boundary.rs::literals_equal_tests::python_bool_numeric_equality_and_inequality.
  • The surrounding literal-equality model in the same file: literals_equal (:2089-2134), bool_as_decimal / canonical_decimal use in the two leading matches (:2090-2103, :2104-2112), and provably_unequal with its kind() model (:871-899).
  • crates/ripr/src/analysis/language/python/guard_activation.rs at the head: compare_literal_values (:1199-1247), its readability pre-check guard_literal_is_readable (:1249-1255), the eval_comparison call site (:1115-1118), and the module doc (:19-20).
  • The pre-existing oracle the change targets: guard_activation.rs::tests::compare_literal_values_fails_open_on_undecoded_literals at base :1419-1437, whose line :1436 asserts compare_literal_values("None", "!=", "0") == Some(true). That file is not modified by this change, so the oracle is pre-existing and independent of the candidate.
  • docs/specs/RIPR-SPEC-0260-python-guarded-arm-activation.md: the equality clause (:77-79), the ordering clause (:80-85), the exclusion rule (:36-40), and the Non-Goals clause (:176-178).
  • .ripr/traceability.toml behavior entry id = "RIPR-SPEC-0260" (:18756-18858): its tests list and its code list.
  • Every None-related comparison under fixtures/ (:*.py).
  • Hosted proof for this exact head, grouped by workflow run.

Blocking:

  1. The candidate makes a mixed-kind inequality decide credit, and the governing spec clause that pins that behavior is not narrowed.

    The governing text is docs/specs/RIPR-SPEC-0260-python-guarded-arm-activation.md:176-178 (Non-Goals): "This spec does not change the predicate boundary rule, the boundary rule's own literal equality (its mixed-kind inequality stays conservative for credit), or any non-Python adapter."

    The repo's own definition of "mixed kind" is in the file the candidate edits. boundary.rs:871-899 (provably_unequal) states: "Both literals are of one comparable kind and differ. Mixed kinds (True vs 1), escaped or prefixed strings and anything unparsed are unknown, never 'unequal'." Its kind() maps None to Kind::Singleton (:882-884) and a decimal to Kind::Number (:885-887), and its final comparison (:894-899) requires equal discriminants, so provably_unequal("None", "0") is false: a mixed-kind pair is unknown.

    The candidate adds exactly that mixed-kind pair as a definite inequality:

    // `None` is a singleton that never equals a number, so the pair is
    // definitely unequal; any other unreadable side stays unknown.
    (Some(_), None) if right == "None" => return Some(false),
    (None, Some(_)) if left == "None" => return Some(false),

    At the base, the same pair fell into (Some(_), None) | (None, Some(_)) => return None, i.e. unknown. At the head, literals_equal("None", "0") is Some(false).

    That definite answer reaches a credit decision, not only a helper result. compare_literal_values maps == straight to literals_equal (guard_activation.rs:1210-1212), eval_comparison feeds it into the guard walk (:1115-1118), and the spec's own exclusion rule (:36-40) is "when every strong related call provably fails at least one guarding comparison, the changed line never executes under an observed input. The finding fails closed to weakly_exposed". Concretely: with the candidate, a guard x == 0 where the strong related call binds x = None is now known-false, so the row provably fails the guard and the guarded arm is excluded and downgraded to weakly_exposed. At the base the same comparison was unknown, failed open, and the pre-gate verdict was kept. So the candidate lets a mixed-kind inequality decide credit -- the precise thing the clause says does not happen. The module doc that owns the conservative rule was not updated either (guard_activation.rs:19-20: "Equality follows Python semantics (True == 1), since a wrong exclusion is a wrong actionable signal").

    The Python semantics behind the new rule are correct -- None is a keyword singleton and never equals a number -- so this is not a semantic error in the change, and the analyzer becomes more accurate. It is a contract gap: the spec states an invariant the code now breaks, and the change records the new rule nowhere.

    Repair direction, not a prescription: narrow the Non-Goals clause at RIPR-SPEC-0260:176-178 to name the None-versus-number exception and to say explicitly what stays conservative (the PR body already lists the other cross-kind pairs as deliberately "not established"), and register the rule and its tests in .ripr/traceability.toml. The traceability entry for RIPR-SPEC-0260 already lists crates/ripr/src/analysis/language/python/boundary.rs under code and guard_activation.rs::tests::compare_literal_values_equates_bool_like_python under tests (:18772) -- the bool-versus-number equivalent -- but neither boundary.rs::literals_equal_tests::* nor guard_activation.rs::tests::compare_literal_values_fails_open_on_undecoded_literals, the two tests that actually carry this rule, is registered anywhere, and this change adds no entry.

Non-blocking:

  1. The changelog fragment's filename names the wrong work item. The file is changelog.d/11907-python-none-vs-number.md, but this PR is #11918 and its governing issue is #11842; #11907 is an unrelated pull request ("fix(ci): retry routed-rust runner inventory query before recording failure (#8858)", which ships changelog.d/8858-runner-inventory-retry.md). The repo's documented convention is "Name the file <pr-or-issue>-<short-slug>.md" (xtask/src/policy/changelog_fragments.rs:60). The gate does not check the filename number -- it validates the kebab-case stem, the <!-- section: Fixed --> line, and that the entry text cites a reference, and the fragment body does cite #11842 correctly -- so this passes CI while pointing a future fold at the wrong item.

  2. The new rule is expressed as a literal-text comparison in the decimal match while the singleton knowledge already lives in provably_unequal's kind() (boundary.rs:882-884). The two owners now disagree about cross-kind pairs: provably_unequal refuses all of them, the new arms make one definite, and the PR body lists the remaining cross-kind pairs as deliberately "not established". They do not conflict at runtime today, because the decimal match short-circuits before provably_unequal for this pair, but the duplication is a drift risk. Carrying the exception in the existing kind model would keep one owner for "what is provably unequal".

  3. Checked and cleared. No fixture under fixtures/ compares a None-resolving operand against a number: the eleven None hits in the fixture inputs are all rec.last == None, a same-singleton pair whose resolution is unaffected by the new arms, so no corpus row's expected output depends on the changed pair. No spec other than RIPR-SPEC-0260 governs this behavior -- a search of docs/specs/ for never equals, singleton, None == and None != returns no clause authorizing a definite None-versus-number answer. The change also repairs a real main-red without touching its oracle: at the base, literals_equal("None", "0") returned None, so compare_literal_values("None", "!=", "0") returned None while the pre-existing base assertion at guard_activation.rs:1436 expects Some(true); that is the source-verified basis for the PR body's "main red" claim, which the hosted log has not yet confirmed.

Not run:

  • No Rust toolchain on this reviewer host (rustc, cargo, rustup are absent from PATH), so cargo test -p ripr --lib python::, cargo xtask precommit, and cargo xtask check-traceability were not executed locally. The base-red finding above is a source-level reading of the base and head blobs, not a run.
  • Hosted proof at this exact head, grouped by workflow run. The current run (41245211953 and siblings, 21:47:24) has Admit PR Candidate SUCCESS, Rust-only feature lane SUCCESS, cargo-deny and dependency-review SUCCESS, and paste-ubuntu/macos/windows-latest SUCCESS, but Ripr Rust Small on GitHub Hosted / Rust gates is still IN_PROGRESS and windows-advisory-subset is still IN_PROGRESS, so the head is not fully qualified at review time. The base fa621a32 also shows Rust gates IN_PROGRESS (run 41243698941, 21:27:50), so there is no completed base lane to compare against yet; the base red is established by source, not by a hosted log.
  • The change does not state which lane it expects to turn the base red green, so this review cannot confirm that the rust-tests-junit failure named in the PR body is the only base-red symptom at this head.

Reviewed by an independent Mavis review agent on behalf of the maintainer; bound to head 1d0547d7b75622f11c333965a716761ad26d2bd1. Not an approval.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Evidence gaps

  • Execution evidence for the changed Rust behavior remains incomplete in the supplied packet.
  • Model proof intent was rejected by deterministic validation.
  • The named integration regression test is not included in the changed diff, and the supplied ripr receipt failed while the cargo-test receipt remained pending.
  • The claimed regression proof lacks an available completed sensor receipt in this review packet.

Copy link
Copy Markdown
Member Author

Additional independently retained failure evidence for the existing #11918 owner; no competing fix or takeover.

The same compare_literal_values("None", "!=", "0") assertion at guard_activation.rs:1436 failed on three actual GitHub merge checkouts:

The guard consumer file is identical across frozen main0f88, actual mainfa621 and these compositions. The shared literal-equality fallback from #11842 explains the same None-versus-number result; this is not a claim that I ran a standalone-main baseline. Your symmetric recognized-decimal/None repair is the existing ownership boundary. I am preserving its qualification/landing sequence, not modifying your branch.

Affected candidate convergence records will name #11918 as the shared integration prerequisite and will not turn optional review-workflow success into a passing native aggregate. Root will inspect the landed repair and actual new merge composition before final qualification/landing judgments.

…t the shared equality

The shared literals_equal leaves a decimal against None unknown so the
boundary rule never awards credit from it (RIPR-SPEC-0260 non-goals). The
exclusion gate states the Python answer itself, as it did before #11842.
Registers the guard oracle test in traceability and renames the changelog
fragment to the governing work item.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvmPmoTceRbARsa5PtgeVZ

Copy link
Copy Markdown
Member Author

Repair pushed as b75ec4e for the REPAIR_REQUIRED review on 1d0547d. The shared literals_equal is back to main's behaviour, so RIPR-SPEC-0260's boundary non-goal holds; the None-versus-number answer now lives in a guard-local guard_literals_equal. The guard oracle is registered in traceability, the fragment is renamed to #11842, and the review's optional symmetry and ordering controls are added. Correction to the PR body: cargo xtask check-traceability did finish locally and exited 0; cargo test -p ripr --lib python:: is 1712 passed, cargo fmt --check clean. Late CI is requested on the new head.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

Correction to my source review 6549704689: it was too narrow to establish contract alignment. Review 5725183185 identified that shared literal equality also feeds predicate-boundary credit, conflicting with SPEC0260's conservative boundary non-goal. My earlier no-material-finding statement applies only to the inspected literal-comparison semantics and missed that consumer/scope issue.

The owner has superseded 1d0547d with b75ec4e, moving the exception into guard-local equality and restoring shared behavior. The old review and reported execution are not qualification of this successor. Preserve the new candidate's independent contract review and required run 41247837150 before integration, then requalify #11830's combined source.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision

  • Needs verification checks before upstream.

Verification questions

  • Confirm the added assertions cover symmetry, equality direction, None equality, ordering, and the shared-boundary invariant.
  • Confirm the repair claim is backed by focused assertions for symmetry, equality, None identity, ordering, and shared-boundary behavior.

Evidence gaps

  • Independent execution evidence is absent because cargo-test has no receipt and ripr failed.
  • Model proof intent was rejected by deterministic validation.
  • Execution evidence for the changed Rust behavior is incomplete in the supplied review packet.
  • Execution proof for the changed Rust behavior is incomplete in the supplied packet.
  • Completed execution evidence for the changed Rust behavior is unavailable in this packet.
  • Execution proof for the changed Rust behavior is not independently available in this packet.

EffortlessSteven pushed a commit that referenced this pull request Oct 31, 2026
cursor Bot pushed a commit that referenced this pull request Nov 1, 2026
Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Nov 1, 2026
Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
EffortlessSteven added a commit that referenced this pull request Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants