Repository navigation
fix(python): multi-line literal element gates and whole-token value matching, with 8 rule-10 corpus cases - #10226
Conversation
… rules and match whole value tokens (#10210) Adds 8 py-literals-* corpus cases for RIPR-SPEC-0238 rule 10. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 53 minutes. View limit details
Comment |
|
|
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr
EffortlessSteven
left a comment
There was a problem hiding this comment.
#10210 custody and discriminating review handoff
REPAIR_REQUIRED for the observed element-gate behavior at PR head d8f82e049886be2852ddf58188ea344f8fe5543f, tree 1857f265bee4657b4e9a4789d1ab92fbf310539f, base 8b3b83d9363523e601a026856a64be1bb72b0854.
This PR is the canonical #10210 candidate. It appeared during an isolated additional implementation pass; publication recheck found it, so no competing PR was opened and this handoff preserves this PR's branch/head. The additional branch below is retained for inspectable regression/source evidence and selective adoption, not as a second landing candidate.
[P1] The whole-display shortcut still credits unchanged siblings
At the dict gate and the matching list gate, merely containing == [/== { returns true before changed-member checks. These strong, non-tautological oracles only read unchanged siblings:
# dict: {'high': 11, 'low': 10} -> {'high': 80, 'low': 10}
assert list((10,)) == [labels()['low']]
# list: [11, 10] -> [80, 10]
assert list((10,)) == [labels()[1]]Both Python oracles are true before and after. The exact candidate's pure observer functions also return true for each instead of withholding element observation. Bind the compared collection operand to the owner result; an unrelated display containing a sibling read must not supply whole-collection credit. Retain changed-subscript/.get/actual whole-output positives and existing one-line compatibility. Avoid admitting masking wrappers or aliases without retained-value evidence.
[P2] Numeric values can still match quoted strings
The numeric matcher checks adjacent characters but accepts a number inside a quoted string. For changed value 80, assert labels() is not None and str('80') == '80' supplies true observer credit while ignoring the collection contents. Native literal/token identity can distinguish numeric 80 from string '80'; retain signed-number, bool, and one-line positives.
Raw evidence and limits
Command: rustc --edition 2024 /tmp/10226-gate.rs -o /tmp/10226-gate && /tmp/10226-gate (Rust 1.95.0, Linux; no Cargo build of this PR, dependencies, installs, or qualification request). The harness below copies this exact head's pure observer functions unchanged and invokes them with explicit changed keys/indices/values.
dict-scalar-sibling: actual=false expected=false
dict-changed-key: actual=true expected=true
dict-whole-output: actual=true expected=true
dict-sibling-in-unrelated-display: actual=true expected=false
numeric-vs-quoted-string: actual=true expected=false
list-scalar-sibling: actual=false expected=false
list-changed-index: actual=true expected=true
list-sibling-in-unrelated-display: actual=true expected=false
The harness is a diagnostic printer: exit 0 means execution succeeded, not that its controls passed. The five matching controls and three mismatches are function execution evidence, not a full analyzer verdict run on this PR. Full-path classification on this head remains to be exercised by its owner. Independent CPython 3.12.14 execution of actual multiline functions confirms the sibling-display and masking/retention oracles remain true for old and new values. The regression matrix below explicitly requires Strong related rows to prevent a weak tautology from masquerading as a negative control.
Inspectable additional source/test checkpoint: branch codex/10210-python-multiline-elements, head 47b80ca15c005a1cc6e45bde966628871667473b, tree e7575087b1f310db5ed05e1b473dff04c96a3f6c, base 2d93df787c4f63120c1a9e34b0b48ba584c37f2d (tree a255ff0f9f98b21ca2cbcbaa64fd952feb9e0864). Its ten focused regression subjects cover keys/indices, .get, whole output, sibling/unrelated displays, numeric/string token boundaries, comments/hash strings, signed/bool compatibility, methods, shadowed wrappers, lossy aliases, and retained immediate aliases. The bounded diff is 9 files, +853/-24; this is not proposed as a competing PR or a wholesale replacement of the corpus candidate.
Observed on that checkpoint only:
cargo test -p ripr --lib multiline_collection -- --nocapture
10 passed; 0 failed; 0 ignored; 14237 filtered out; exit 0
cargo test -p ripr --lib analysis::language::python::
1116 passed; 0 failed; 0 ignored; 13131 filtered out; exit 0
Its test-only parent 77d3904b60d8df396d35c29bc0c0a8d5c3fb0e90 produced the intended behavioral red: 2 sibling/key-index tests reported Exposed instead of WeaklyExposed (1 other control passed; it was later strengthened). Exact-base worktree doctor/check-fast/narrow all-target check passed. Traceability, static language, changelog-fragment, and whitespace checks passed. A separate reviewer inspected the final checkpoint's exact head and challenged actual Python controls; no blocking source finding remained in that bounded source. These results do not qualify this PR's different tree.
Next owner obligation: incorporate/refute these specific findings on this PR's existing branch, run the discriminating full-path tests on its exact new head, refresh affected independent review, and satisfy all required current gates and applicable authorization before readiness/merge. No Ready transition, merge-ready label, qualification request, or merge was performed by this handoff. Local precommit/goldens/dogfood/corpus and hosted qualification were not run on the additional checkpoint; this receipt grants no merge clearance.
Exact pure-observer harness input
Generate /tmp/10226-gate.rs by placing the following unchanged function source and calls in a standalone Rust file (all source is from the pinned PR head):
// Exact pure observer functions from PR #10226 head d8f82e049886be2852ddf58188ea344f8fe5543f.
mod candidate {
pub(super) fn oracle_observes_changed_dict_element(
oracle: &str,
changed_keys: &[String],
changed_values: &[String],
) -> bool {
// A whole-collection comparison (`== {...}` / `== [...]`) observes every element.
if oracle.contains("=={")
|| oracle.contains("== {")
|| oracle.contains("==[")
|| oracle.contains("== [")
{
return true;
}
// Observes a changed value literal (e.g. the new `9090` / `"failure"`), but
// not when that literal only appears beside a sibling-key subscript
// (`assert build()['timeout'] == 80` after `'port'` changed to `80`).
for value in changed_values {
if oracle_contains_value_literal(oracle, value)
&& !oracle_solely_subscripts_unchanged_dict_key(oracle, changed_keys)
{
return true;
}
}
// Subscripts a changed key by literal (`["port"]`, `['port']`, `.get("port")`).
changed_keys
.iter()
.any(|key| oracle_subscripts_dict_key(oracle, key))
}
fn oracle_subscripts_dict_key(oracle: &str, key: &str) -> bool {
oracle.contains(&format!("[\"{key}\"]"))
|| oracle.contains(&format!("['{key}']"))
|| oracle.contains(&format!(".get(\"{key}\")"))
|| oracle.contains(&format!(".get('{key}')"))
}
fn oracle_has_literal_dict_subscript(oracle: &str) -> bool {
oracle.contains("[\"")
|| oracle.contains("['")
|| oracle.contains(".get(\"")
|| oracle.contains(".get('")
}
fn oracle_solely_subscripts_unchanged_dict_key(oracle: &str, changed_keys: &[String]) -> bool {
oracle_has_literal_dict_subscript(oracle)
&& !changed_keys
.iter()
.any(|key| oracle_subscripts_dict_key(oracle, key))
}
/// Whether the oracle contains the changed element's value as a WHOLE literal
/// token (RIPR-SPEC-0238 rule 10): a number not adjacent to a digit, letter, `_`
/// or `.` (so `80` is not found inside `8080`), a string as a complete quoted
/// literal (so `y` is not found inside `"yes"`). Any other value expression keeps
/// the substring match.
pub(super) fn oracle_contains_value_literal(oracle: &str, value: &str) -> bool {
let value = value.trim();
let literal = value.trim_matches('"').trim_matches('\'');
if literal.is_empty() || (literal.len() < 2 && literal.len() == value.len()) {
return false;
}
let quoted = value.len() >= 2
&& literal.len() + 2 == value.len()
&& (value.starts_with('"') && value.ends_with('"')
|| value.starts_with('\'') && value.ends_with('\''));
if quoted {
return !literal.contains(['"', '\''])
&& (oracle.contains(&format!("\"{literal}\""))
|| oracle.contains(&format!("'{literal}'")));
}
let digits = literal.strip_prefix('-').unwrap_or(literal);
let numeric = digits.starts_with(|c: char| c.is_ascii_digit())
&& digits
.chars()
.all(|c| c.is_ascii_digit() || c == '.' || c == '_');
if !numeric {
return oracle.contains(literal);
}
let adjacent = |c: char| c.is_alphanumeric() || c == '_' || c == '.';
oracle.match_indices(literal).any(|(start, found)| {
let before = oracle[..start].chars().next_back();
let after = oracle[start + found.len()..].chars().next();
!before.is_some_and(adjacent) && !after.is_some_and(adjacent)
})
}
fn oracle_observes_changed_list_element(
oracle: &str,
changed_indices: &[usize],
changed_values: &[String],
) -> bool {
if oracle.contains("=={")
|| oracle.contains("== {")
|| oracle.contains("==[")
|| oracle.contains("== [")
{
return true;
}
for value in changed_values {
if oracle_contains_value_literal(oracle, value)
&& !oracle_solely_subscripts_unchanged_list_index(oracle, changed_indices)
{
return true;
}
}
changed_indices
.iter()
.any(|index| oracle_subscripts_list_index(oracle, *index))
}
fn oracle_subscripts_list_index(oracle: &str, index: usize) -> bool {
oracle.contains(&format!("[{index}]"))
}
fn oracle_has_list_index_subscript(oracle: &str) -> bool {
let bytes = oracle.as_bytes();
let mut i = 0;
while i < bytes.len() {
if bytes[i] == b'[' {
let mut j = i + 1;
if j < bytes.len() && bytes[j].is_ascii_digit() {
while j < bytes.len() && bytes[j].is_ascii_digit() {
j += 1;
}
if j < bytes.len() && bytes[j] == b']' {
return true;
}
}
}
i += 1;
}
false
}
fn oracle_solely_subscripts_unchanged_list_index(oracle: &str, changed_indices: &[usize]) -> bool {
oracle_has_list_index_subscript(oracle)
&& !changed_indices
.iter()
.any(|index| oracle_subscripts_list_index(oracle, *index))
}
pub fn receipt() {
let keys = vec!["high".to_string()];
let values = vec!["80".to_string()];
for (name, oracle, expected) in [
("dict-scalar-sibling", "assert labels()['low'] == 10", false),
("dict-changed-key", "assert labels()['high'] == 80", true),
("dict-whole-output", "assert labels() == {'high': 80, 'low': 10}", true),
("dict-sibling-in-unrelated-display", "assert list((10,)) == [labels()['low']]", false),
("numeric-vs-quoted-string", "assert labels() is not None and str('80') == '80'", false),
] {
let actual = oracle_observes_changed_dict_element(oracle, &keys, &values);
println!("{name}: actual={actual} expected={expected}");
}
for (name, oracle, expected) in [
("list-scalar-sibling", "assert labels()[1] == 10", false),
("list-changed-index", "assert labels()[0] == 80", true),
("list-sibling-in-unrelated-display", "assert list((10,)) == [labels()[1]]", false),
] {
let actual = oracle_observes_changed_list_element(oracle, &[0], &values);
println!("{name}: actual={actual} expected={expected}");
}
}
}
fn main() { candidate::receipt(); }Source SHA-256: 13d154e9af65734056fde18f093c5665d1f860ddc1333d51be77b817e27edfa9 (sink_alignment.rs fetched by git show d8f82e049886be2852ddf58188ea344f8fe5543f:crates/ripr/src/analysis/language/python/sink_alignment.rs). Harness SHA-256: 770b58a300446695370dc004daa0e1d03e1955ff9f688b3230d371281af7fe5f.
EffortlessSteven
left a comment
There was a problem hiding this comment.
REPAIR_REQUIRED for the existing P1 in the preceding review. This pass closes its missing full-classifier evidence seam; it does not propose another implementation.
Reviewed head: d8f82e049886be2852ddf58188ea344f8fe5543f; tree: 1857f265bee4657b4e9a4789d1ab92fbf310539f; base: 8b3b83d9363523e601a026856a64be1bb72b0854. PR account: EffortlessSteven; canonical branch: claude/py-next-row. The initial head 2735b20a9576408be13ab3ac510fede7d8bad4c5 is the first parent; the frozen base is the second parent. The earlier import conflict is superseded: the current import preserves both CreditedAssertion and enclosing_literal_pair. The matcher blob remains 5bbb891664dcee5d325486fe2dc7188b12829308.
Observed current-head classifier results, using extracted owners/tests and classify_change_with_source on actual multiline functions:
| Changed return | Assertion | Full classifier | Related row |
|---|---|---|---|
| dict: high 11 → 80; low remains 10 | assert list((10,)) == [labels()['low']] |
exposed, direct |
Strong |
| list: index 0, 11 → 80; index 1 remains 10 | assert list((10,)) == [labels()[1]] |
exposed, direct |
Strong |
| same dict change | assert labels() is not None and str('80') == '80' |
weakly_exposed, orthogonal |
Strong |
Independent Python execution passes each assertion on both old and new versions. Thus the first two rows confirm P1 through the production classifier, not merely the pure observer. The whole-display shortcut at sink_alignment.rs bypasses changed-element identity. It conflicts with rule 10's compared-operand requirement. The shortcut predates this diff; this is an unresolved current acceptance concern, not evidence that this PR introduced the shortcut.
The specific quoted-number P2 example is refuted as a full-classifier false promotion on this head: it is already weakly_exposed. The helper's true alone does not establish a final verdict. This pass adds no stricter numeric/string policy or broader masking hypothesis as a blocker.
Passed local proof (Linux; installed Rust/Cargo 1.95.0; locked dependencies):
cargo test --locked -p ripr --no-default-features --features lang-rust,lang-python --lib python -- --nocapture
1381 passed; 0 failed; 0 ignored; 11231 filtered out; exit 0
That run used unchanged current-head production code plus three proof-only tests, experimental tree 6d223cff042749216dee91660e2be18ec5b5c747. Those tests cover 18 subcases: all eight retained py-literals-* cases, nine duplicate-value/nested-inline/assignment/token controls, and the accepted nested-multiline boundary. The three #10210 examples (key-unobserved, list-index-unobserved, value-sibling-equal) are weakly_exposed; changed-key/index, .get, and actual whole-output positives stay exposed. Changed 80 is not observed inside 8080. Direct execution of the eight retained assertion-only Python test functions also agrees with every case's runtime label; pytest itself was not installed or run.
Two extracted-native helper tests pass on the byte-identical matcher source. Replacing whole-token matching with substring matching and removing multiline context each produces the intended assertion failure (exit 101), with the other control passing. These are helper-level mutation receipts, not full-analyzer mutation runs.
The additional full-classifier diagnostic above ran with the same Cargo configuration and filter review_10226_reported_display_full_classifier, experimental tree 69c0a500404856461f5522d14a19397a9c77cc4c: one diagnostic test executed successfully, exit 0. It prints classifications rather than asserting the desired negative verdict; exit 0 does not make the two P1 mismatches passes. Its log SHA-256 is 5ea37be3dbe7b9b114f9ea1aba9a35fa369f794e4c52c8eabfa44f3d3e8e034d; the 1381-test log SHA-256 is 527ee6448487e9048ce2f5b79b36293ed40827a6aa775b217dab3554f6aaca19.
All proof-only source additions were restored; the review checkout is clean. Nested multiline elements retain the explicitly accepted fail-open limitation from #10210; that is not an additional finding. The original-head default-feature build was cancelled after head movement. An invalid Python-only feature invocation was corrected to include mandatory lang-rust; it establishes no behavioral failure. Full default-feature/CLI/corpus/precommit/hosted qualification are not independently established by this pass; PR-body claims and nonterminal hosted runs are not relabeled as passes.
Canonical-owner next action: repair or source-backed refute the unchanged-sibling whole-display shortcut on this existing branch, retaining the scalar changed-element and actual whole-output positives, then refresh only the affected exact-head classifier proof and review. No merge clearance is given.
There was a problem hiding this comment.
Decision
- Needs verification checks before upstream.
Verification questions
- Confirm whole-token numeric matching rejects a changed value when the oracle contains a decimal-adjacent or alphanumeric-adjacent substring, but the numeric literal classification is permissive about Python syntax forms.
- Confirm the new whole-token numeric matcher is deliberately conservative but may treat valid numeric literals with Python syntax not represented by the ASCII decimal/underscore/period subset as nonnumeric expressions.
Refuted
- The PR's claimed execution proof is already available and clean.; refuted because: It is not available in the supplied.
Parked follow-ups
- The multiline joiner is line-oriented and intentionally conservative; nested literal elements are not represented in the new corpus or unit controls.
Evidence gaps
- The change adds corpus evidence for eight rule-10 cases, but the available packet does not include the late cargo-test receipt.
- Model proof intent was rejected by deterministic validation.
- Execution proof for the changed Rust behavior and corpus is not yet present in the packet; cargo-test is scheduled late and the RIPR sensor failed.
- Focused Rust and corpus proof is claimed in the PR body, but the ripr sensor failed and cargo-test was still scheduled, so the advertised 1333-pass and 253-case results are not independently present in the supplied receipts.
- The failed ripr sensor is trust-affecting and leaves the PR's central proof claim independently unverified in this packet.
… to a result; numbers inside strings are not values (#10210) A display that reads other data, or a literal-only left operand, no longer supplies whole-collection credit for a changed element. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr
|
Addressed the P1 from the two REPAIR_REQUIRED reviews at P1 (whole-display shortcut credits unchanged siblings): confirmed and fixed. P2 (number inside a quoted string): the second review shows it already classifies Proof on this head: Generated by Claude Code |
|
Generated by Claude Code |
#10272) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AoapkiftDmzBaXiATmb2KP
|
The second Generated by Claude Code |
|
|
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr
… literals; graduate two false promotions to the honesty corpus (#10210) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr
There was a problem hiding this comment.
Decision
- Needs one verification check before upstream.
Verification questions
- Confirm whole-token numeric matching is conservative and does not recognize several valid Python numeric literal forms.
Parked follow-ups
- The multiline literal joiner remains line-oriented and does not represent nested literal elements.
- The numeric whole-token matcher intentionally recognizes only a narrow ASCII decimal/underscore/period syntax subset; other numeric spellings retain fallback expression matching.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
- Current execution evidence for the changed Rust classifier and new corpus is not present in the supplied packet.
Review of record, head
|
Summary
Corpus cases for RIPR-SPEC-0238 rule 10 (changed dict/list elements match whole literals) found three real
false_exposedrows, filed as #10210:80was "observed" inside"8080".Fix:
enclosing_literal_pairjoins the enclosingreturn {…}/x = […]literal (new side, and old side with the paired old line) so the existing dict/list gates judge the changed element. Rejects call arguments, comments and mismatched closers.oracle_contains_value_literal: numbers must be whole tokens (no adjacent digit/letter/_/.), strings must appear as complete quoted literals; other expressions keep the substring match.Corpus: 8
py-literals-*cases on a newauthored-py-pytest-literalssubject, labelled by real pytest runs (4 discriminated, 4 not). Python corpus: 253 cases, 0 false verdicts, spec examples 57/57. The three previously false-exposed rows now readweakly_exposed(ideal); no existing row moved.Governing issue or accepted claim: #10210 (rule-10 coverage under #9412)
Acceptance delta (one sentence): Rule 10 of RIPR-SPEC-0238 is corpus-covered for dict values, keys,
.get, list indices and whole-collection compares, and the multi-line and substring false-exposed paths are closed.Proof:
cargo test -p ripr --lib python(1333 pass, incl. positive/negative controls for the gate, joiner and token matcher),cargo xtask verdict-corpus check --language python,cargo xtask precommit.Generated by Claude Code