Repository navigation
fix(perl): mapping-integrity hotfix for packet_to_findings (PR H1, Campaign 31 #1409) - #1447
Conversation
) The production mapper `packet_to_findings` bypassed the packet-owned relation/oracle/command/identity helpers and reimplemented classification inline, incorrectly. This is the first PR of the Perl honesty split (H1: mapping integrity; H2: classification semantics lands after the producer contract adds sink-alignment fields). Verified defects fixed (all routed through existing packet helpers, no third classifier): - `related_test.file` was built from the PRODUCTION source path (`PathBuf::from(&file.path)`, mod.rs:178), not the test file. The cardinal-sin risk: an edit surface pointing at `lib/*.pm`. Now resolved through `test.file_id` via `related_test_evidence_for_change`. - `related_test.line` was hardcoded to `1`. Now from the TestFact range. - `relation_reason`/`relation_confidence` were always `None`. Now mapped via `perl_relation_to_domain` (mirrors `ts_relation_to_domain`). - Verify command was selected globally by `CommandScope::Test`. Now per-test via `verify_command_for_test(test_id)`. - Dynamic boundary was scoped to the whole `file_id`. Now uses the conservative `has_blocking_dynamic_boundary` (owner OR file OR test file); an ownerless file-level boundary still blocks. - Canonical gap was built from generic enum labels. Now attached ONLY when a concrete `discriminator:`-prefixed `changed_text_digest` exists; otherwise the Finding is informational with `canonical_gap: None`. Classification is conservative-or-stricter only. Advisory relation kinds (`FileProximity`, `PackageReference`, `TestNameMatch`, `FixtureSetup`, `Unknown`) never promote past `ReachableUnrevealed` — this is the relation-kind gate `classify_related_relation` omits. "Already observed" is intentionally NOT claimed: owner-target identity (`oracle.target_owner_id`) is not changed-sink observation, and the Finding leaves `observed_sink`/`oracle_alignment` `None`. That matrix lands in H2 once the producer can prove sink alignment. No `gap_state:` emission; public readiness stays off (the projection remains gated-closed at `preview_actionability.rs:46`). Tests: 8 adversarial tests added — the FIRST direct coverage of `packet_to_findings` (it previously had zero). All 51 Perl tests pass. Validation (feature-gated; `lang-perl` is opt-in, NOT a default feature): cargo test -p ripr --features lang-perl --lib analysis::language::perl cargo fmt --check cargo xtask goldens check cargo xtask check-output-contracts all exit 0. Note: `cargo clippy --workspace --all-targets --features lang-perl` fails on pre-existing dead-code scaffolding that `main` also fails (51 errors on main, 49 on this branch). CI runs clippy on default features (no `lang-perl`), so it does not see the Perl module; the new H1 code is clippy-clean within the feature. Clearing the pre-existing scaffolding is out of H1 scope (it is the "dead scaffolding" flagged for PRs 4-7). Campaign 31 (#1379). Followups: H2 classification semantics (after PR 2A adds `ChangeFact.changed_observable`/`OracleFact.observed_sink`), and the perl-lsp-swarm CI scratch-GC fix (documented separately).
…scratch-GC spec Companion to the H1 mapper hotfix (97be8b9). Two durable artifacts: docs/LEARNINGS.md — new entry "Perl mapper honesty" capturing two lessons: 1. Owner-target identity (oracle.target_owner_id == changed_owner) is not changed-sink observation. The packet leaves observed_sink/oracle_alignment None, so crediting reach-plus-strong-oracle as "already discriminated" is the false-exposed family. Fail closed until the producer contract adds ChangeFact.changed_observable / OracleFact.observed_sink; split mapping integrity (H1) from classification semantics (H2). 2. lang-perl is not a default feature, so CI's default-feature clippy gate never compiles the Perl module — a false-green oracle. Validation for a feature-gated module must pass --features <feature> explicitly. RIPR-SPEC-0121 (proposed) — the perl-lsp-swarm CI scratch-GC orphan-reaper path mismatch: per-run dirs nest under /mnt/ci-scratch/{perl-lsp-swarm,tmp} /ripr-* but the reaper scans the parent at depth 1, so killed/OOM/cancelled runs leak multi-GB Cargo target trees. Spec-only (the fix lands in perl-lsp-swarm, unreachable from this session); ripr-swarm's own scratch-gc.yml is the reference pattern (it sweeps inside each subdir at -maxdepth 1). Status proposed until applied there. Registered in docs/specs/README.md, policy/doc-artifacts.toml, and .ripr/traceability.toml. Gates: check-spec-format, check-spec-numbering, check-traceability, check-static-language, check-doc-index, check-generated-clean all exit 0. Campaign 31 (#1379).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
More reviews will be available in 19 minutes and 22 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request implements the H1 mapping-integrity contract for the Perl adapter, ensuring that related-test evidence correctly resolves to test file paths rather than production source paths, gating canonical repair gaps behind concrete discriminators, and adding comprehensive adversarial tests. Feedback on these changes highlights a potential logic issue where dynamic boundaries are only evaluated for the first related evidence, the use of the unstable let_chains feature which should be refactored for stable Rust compatibility, and an opportunity to simplify perl_relation_to_domain into a single match statement.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| let has_boundary = related_evidence | ||
| .first() | ||
| .map(|ev| packet.has_blocking_dynamic_boundary(change, Some(ev))) | ||
| .unwrap_or_else(|| packet.has_blocking_dynamic_boundary(change, None)); |
There was a problem hiding this comment.
Using .first() on related_evidence to determine has_boundary introduces an ordering dependency. If there are multiple related tests, a dynamic boundary on the second or subsequent test will be completely ignored if the first one is unblocked. Conversely, if the first test is blocked, the entire change is classified as StaticUnknown even if other unblocked tests exist.
Evaluating the boundaries for all related evidences ensures consistent and robust classification.
| let has_boundary = related_evidence | |
| .first() | |
| .map(|ev| packet.has_blocking_dynamic_boundary(change, Some(ev))) | |
| .unwrap_or_else(|| packet.has_blocking_dynamic_boundary(change, None)); | |
| let has_boundary = if related_evidence.is_empty() { | |
| packet.has_blocking_dynamic_boundary(change, None) | |
| } else { | |
| related_evidence | |
| .iter() | |
| .any(|ev| packet.has_blocking_dynamic_boundary(change, Some(ev))) | |
| }; |
| if has_concrete_discriminator && let Some(first) = related.first() { | ||
| evidence.push(format!( | ||
| "perl_suggested_test_location: {}::{}", | ||
| first.file.display(), | ||
| first.name | ||
| )); | ||
| evidence.push(format!( | ||
| "perl_verify_command: {}", | ||
| verify_cmd.argv.join(" ") | ||
| "perl_suggested_assertion: {}", | ||
| change.behavior_hint.default_missing_discriminator() | ||
| )); | ||
| } |
There was a problem hiding this comment.
This code uses the let_chains feature (if ... && let ...), which is currently unstable in Rust. To ensure compatibility with stable Rust compilers and avoid relying on unstable nightly features, rewrite this using nested if let statements.
| if has_concrete_discriminator && let Some(first) = related.first() { | |
| evidence.push(format!( | |
| "perl_suggested_test_location: {}::{}", | |
| first.file.display(), | |
| first.name | |
| )); | |
| evidence.push(format!( | |
| "perl_verify_command: {}", | |
| verify_cmd.argv.join(" ") | |
| "perl_suggested_assertion: {}", | |
| change.behavior_hint.default_missing_discriminator() | |
| )); | |
| } | |
| if has_concrete_discriminator { | |
| if let Some(first) = related.first() { | |
| evidence.push(format!( | |
| "perl_suggested_test_location: {}::{}", | |
| first.file.display(), | |
| first.name | |
| )); | |
| evidence.push(format!( | |
| "perl_suggested_assertion: {}", | |
| change.behavior_hint.default_missing_discriminator() | |
| )); | |
| } | |
| } |
| if let Some(first_ev) = related_evidence.first() | ||
| && let Some(argv) = first_ev.verify_command.as_ref() | ||
| && !argv.is_empty() | ||
| { | ||
| evidence.push(format!("perl_verify_command: {}", argv.join(" "))); | ||
| } |
There was a problem hiding this comment.
This is another instance of the unstable let_chains feature. It can be cleanly rewritten using standard Option::and_then and a nested if statement to remain compatible with stable Rust.
if let Some(argv) = related_evidence.first().and_then(|ev| ev.verify_command.as_ref()) {
if !argv.is_empty() {
evidence.push(format!("perl_verify_command: {}", argv.join(" ")));
}
}| fn perl_relation_to_domain( | ||
| kind: RelationKind, | ||
| ) -> ( | ||
| Option<crate::domain::RelationReason>, | ||
| Option<crate::domain::RelationConfidence>, | ||
| ) { | ||
| use crate::domain::{RelationConfidence, RelationReason}; | ||
| let reason = match kind { | ||
| RelationKind::DirectOwnerCall => RelationReason::DirectOwnerCall, | ||
| RelationKind::HelperCall => RelationReason::HelperOwnerCall, | ||
| RelationKind::PackageReference => RelationReason::ImportPathAffinity, | ||
| RelationKind::MethodReceiver => RelationReason::DirectOwnerCall, | ||
| RelationKind::TestNameMatch => RelationReason::OwnerNamedTest, | ||
| // Advisory-only signals with no clean owner-call mapping: emit None so | ||
| // they disclose as `relation_reason: null` (legacy advisory style), | ||
| // matching how the TS adapter treats SameFileProximity/DescribeName. | ||
| RelationKind::FileProximity | RelationKind::FixtureSetup | RelationKind::Unknown => { | ||
| return (None, None); | ||
| } | ||
| }; | ||
| let confidence = match kind { | ||
| RelationKind::DirectOwnerCall | RelationKind::MethodReceiver => RelationConfidence::High, | ||
| RelationKind::HelperCall => RelationConfidence::High, | ||
| RelationKind::PackageReference | RelationKind::TestNameMatch => RelationConfidence::Medium, | ||
| // Unreachable: the match above returns early for these. | ||
| RelationKind::FileProximity | RelationKind::FixtureSetup | RelationKind::Unknown => { | ||
| RelationConfidence::Low | ||
| } | ||
| }; | ||
| (Some(reason), Some(confidence)) | ||
| } |
There was a problem hiding this comment.
The current implementation of perl_relation_to_domain uses two separate match statements, an early return, and duplicate unreachable match arms.
We can refactor this into a single, elegant, and exhaustive match statement. This improves readability, idiomaticity, and maintainability.
fn perl_relation_to_domain(
kind: RelationKind,
) -> (
Option<crate::domain::RelationReason>,
Option<crate::domain::RelationConfidence>,
) {
use crate::domain::{RelationConfidence, RelationReason};
match kind {
RelationKind::DirectOwnerCall => (
Some(RelationReason::DirectOwnerCall),
Some(RelationConfidence::High),
),
RelationKind::MethodReceiver => (
Some(RelationReason::DirectOwnerCall),
Some(RelationConfidence::High),
),
RelationKind::HelperCall => (
Some(RelationReason::HelperOwnerCall),
Some(RelationConfidence::High),
),
RelationKind::PackageReference => (
Some(RelationReason::ImportPathAffinity),
Some(RelationConfidence::Medium),
),
RelationKind::TestNameMatch => (
Some(RelationReason::OwnerNamedTest),
Some(RelationConfidence::Medium),
),
RelationKind::FileProximity | RelationKind::FixtureSetup | RelationKind::Unknown => {
(None, None)
}
}
}
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…tion_to_domain (#1447 review) (#1448) Addresses droid-review findings on #1447: 1. (HIGH) Boundary check sampled only .first() related evidence, so a dynamic boundary tied to a SECOND/subsequent test's file was silently missed (ordering dependency). Now checks EVERY related evidence via .any(); the change still blocks if any related test's file has a blocking boundary. New adversarial test h1_boundary_check_is_ordering_independent_across_related_tests pins this (two related tests, boundary on the second test's file → still StaticUnknown). 4. Refactor perl_relation_to_domain from two match statements + early return + unreachable arms into a single exhaustive match (cleaner, no duplicate unreachable arms). Dismissed (verified against the toolchain): #2/#3 claim `let_chains` is unstable — false. The repo pins Rust 1.95.0 (rust-toolchain.toml); let_chains stabilized in 1.87 and is already used in value_resolution.rs, json/report.rs, and review_comments.rs. CI rust-tests-junit passed. Validation (feature-gated, lang-perl is non-default): cargo test -p ripr --features lang-perl --lib analysis::language::perl → 52 passed / 0 failed cargo fmt --check → clean clippy within feature → my code clean Campaign 31 (#1379).
Summary
Campaign 31 Perl repair routing — PR H1: mapping-integrity hotfix. First of a two-PR honesty split (H1 mapping integrity lands now; H2 classification semantics lands after the cross-repo contract freeze adds sink-alignment fields).
The production mapper
packet_to_findingsbypassed the packet-owned relation/oracle/command/identity helpers and reimplemented classification inline, incorrectly. This PR rewrites it to route through the existing (tested) packet helpers. Classification is conservative-or-stricter only.Defects fixed (all routed through existing packet helpers — no third classifier)
related_test.filelib/*.pm) — cardinal-sin risktest.file_id(related_test_evidence_for_change)related_test.line1TestFactrangerelation_reason/relation_confidenceNoneperl_relation_to_domain(mirrorsts_relation_to_domain)CommandScope::Testscanverify_command_for_test(test_id)file_idhas_blocking_dynamic_boundary(owner OR file OR test file); ownerless file-level boundary still blocksdiscriminator:-prefixed digest exists; elseNoneClassification policy (H1)
FileProximity,PackageReference,TestNameMatch,FixtureSetup,Unknown) never promote pastReachableUnrevealed. This is the relation-kind gateclassify_related_relationomits.oracle.target_owner_id) is not changed-sink observation; the Finding leavesobserved_sink/oracle_alignmentNone. The three-way matrix lands in H2 once the producer can prove sink alignment (cf.docs/LEARNINGS.md).gap_state:emission; public readiness stays off (projection gated-closed atpreview_actionability.rs:46).Tests
8 adversarial tests added — the first direct coverage of
packet_to_findings(it previously had zero, which is why the production-path bug survived 3 merged PRs). Pins: test-path-not-production-path, line-from-range, file_proximity-not-eligible, verify-by-test_id, boundary-on-other-owner-doesn't-block, ownerless-file-boundary-blocks, generic-discriminator-no-gap, concrete-discriminator-attaches-gap. All 51 Perl tests pass.Validation (feature-gated —
lang-perlis NOT a default feature)cargo test -p ripr --features lang-perl --lib analysis::language::perl→ 51/0cargo fmt --check→ cleancargo xtask goldens check→ cleancargo xtask check-output-contracts→ cleancargo xtask check-spec-{format,numbering}/check-traceability/check-static-language/check-doc-index/check-generated-clean→ all cleanCaveats
cargo clippy --workspace --all-targets --features lang-perl -- -D warningsfails on pre-existing dead scaffolding (mainfails it too: 51 errors; this branch: 49). CI runs clippy on default features (nolang-perl), so it never sees the Perl module. The new H1 code is clippy-clean within the feature. Clearing the pre-existing scaffolding is out of H1 scope (flagged for PRs 4–7).Spec / docs
docs/LEARNINGS.md: two durable lessons (owner-target ≠ sink observation; the feature-gate false-green oracle).RIPR-SPEC-0121(proposed): theperl-lsp-swarmCI scratch-GC orphan-reaper path mismatch — spec-only, fix lands in the other repo.Non-goals
perl-lsp-swarmCI change (spec-only).Campaign 31 (#1379). Followups: H2 (after PR 2A adds
ChangeFact.changed_observable/OracleFact.observed_sink),perl-lsp-swarmscratch-GC fix.