Skip to content

fix(python): a recorded private container needs a test that reads it (#16010) - #16107

Merged
EffortlessSteven merged 12 commits into
mainfrom
claude/project-thread-wsi85f
Nov 29, 2026
Merged

EffortlessSteven merged 12 commits into
mainfrom
claude/project-thread-wsi85f

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Summary

  • A rewritten self._name.append(..) (also appendleft, extend, extendleft, insert, add, update) in an ordinary Python method read exposed whenever a strong test pinned the method's own return value. It now reads weakly_exposed and names the functions that read the container, unless a related test names the container, calls a reader, or calls a function that reaches a reader.
  • Every shape whose readers cannot be listed from the file keeps the existing verdict (decorated methods, base classes, return self, aliased seeds, public names, dunder readers; see the module doc of self_container_reader.rs and SPEC-0238).

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Spec: RIPR-SPEC-0238 (Python oracle and reach rules)
Governing issue or accepted claim: #16010 (partial: private self._x containers only)
Acceptance delta (one sentence): a private recorded container whose only test pins the method result no longer earns exposed credit.

Candidate Relationships

Candidate branch: claude/project-thread-wsi85f
Stack parent or prerequisite PR: none. Enqueue waits on import #16016 under the release lead's analysis/** hold.
Proposed replacement of PR: none.

Scope

  • Python classifier gate for private self containers mutated in place.

Scope Classification

  • One production behavior

Production delta:

  • crates/ripr/src/analysis/language/python/self_container_reader.rs (new) and its call from python/classify.rs.

Evidence/support delta:

  • Four adapter tests (self_container_reader_tests.rs), honesty fixture python_self_container_record_unread_no_exposed_credit with goldens and corpus case, SPEC-0238 text, changelog, traceability, inventory pin 26 to 27 in gap_decision_ledger.rs.

Single acceptance criterion:

  • The fixture's result-pin case reads weakly_exposed naming the reader; controls that read the container keep exposed.

Non-goals:

Support-tier Impact

  • none

Policy Impact

  • none

Proof

cargo fmt --check                                   # current head: ok
cargo check -p ripr --lib --tests                   # patch commit, Python + Rust features: exit 0
cargo clippy -p ripr --all-targets -- -D warnings   # patch commit: exit 0
cargo xtask goldens check                           # patch commit: 0 drift
cargo xtask check-evidence-promotion-honesty        # patch commit: exit 0
cargo xtask verdict-corpus check-all                # patch commit: exit 0
cargo xtask precommit                               # rerun on this head, see thread

Result, failures, or skipped proof:

  • Release binary on 13 lab cases: the result-pin case and class Clock(object): read weakly_exposed; names-attr, calls-reader, calls-reader-caller, base class, return self, aliased seed, owner reads, owner calls reader, public name and dunder reader keep exposed; a decorated method keeps static_unknown.
  • 90 real Python commits (981 findings) replayed with the release binary: the gate moved no verdict.
  • Not established locally: the four unit tests in self_container_reader_tests.rs compile but have never executed, because the ripr lib test binary does not link in the cloud container. Hosted CI is their first run; they will be confirmed by name in the shard logs. cargo clippy -p xtask was not run.
  • Patch was authored on main e7eff2ae and applied cleanly to 21c3140a; none of the 7 intervening commits touch Python analysis or the ledger pin.

Claim Boundary

May claim: a private self container mutated in an ordinary method needs a test that reads it for exposed. Must not claim: anything about public attributes or module-level containers.

Rollback

Revert the squash commit; the gate is additive and only downgrades exposed to weakly_exposed.

Spec-Test-Code Traceability

  • Spec: RIPR-SPEC-0238
  • Tests: self_container_reader_tests.rs, fixture python_self_container_record_unread_no_exposed_credit
  • Code: python/self_container_reader.rs, python/classify.rs
  • Golden outputs: fixture expected/
  • Metrics: n/a
  • ADR/learning: n/a

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.

Generated by Claude Code

…16010)

A rewritten `self._name.append(..)` in an ordinary method changes what the
object holds, not what the method returns. A test that only pins the
method's own result no longer reads `exposed`; it reads `weakly_exposed`
and names the functions that read the container. A test that names the
container, calls a reader, or calls a function that reaches a reader keeps
the oracle verdict, and every shape whose readers cannot be listed from the
file keeps the existing verdict.

Adds `self_container_reader.rs` with four adapter tests, the honesty
fixture `python_self_container_record_unread_no_exposed_credit`, SPEC-0238
text, changelog and traceability.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvmPmqCuvW74ugVN5uSG3k
@EffortlessSteven EffortlessSteven self-assigned this Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 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 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 138 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: a390eb51-6974-4fc9-8695-ea065dbd5914
Commits

Reviewing files that changed from the base of the PR and between b32e200 and 60ca48d.

Files selected for processing: 18

  • .ripr/traceability.d/16010-python-recorded-container.toml
  • changelog.d/16010-python-recorded-container.md
  • crates/ripr/src/analysis/language/python.rs
  • crates/ripr/src/analysis/language/python/classify.rs
  • crates/ripr/src/analysis/language/python/self_container_reader.rs
  • crates/ripr/src/analysis/language/python/self_container_reader_tests.rs
  • crates/ripr/src/output/gap_decision_ledger.rs
  • docs/specs/RIPR-SPEC-0238-python-oracle-and-reach-rules.md
  • fixtures/evidence-promotion-honesty-corpus/cases/16010-python-self-container-record-unread.json
  • fixtures/python_self_container_record_unread_no_exposed_credit/SPEC.md
  • fixtures/python_self_container_record_unread_no_exposed_credit/diff.patch
  • fixtures/python_self_container_record_unread_no_exposed_credit/expected/CHANGELOG.md
  • fixtures/python_self_container_record_unread_no_exposed_credit/expected/check.json
  • fixtures/python_self_container_record_unread_no_exposed_credit/expected/human-full.txt
  • fixtures/python_self_container_record_unread_no_exposed_credit/expected/human.txt
  • fixtures/python_self_container_record_unread_no_exposed_credit/input/ripr.toml
  • fixtures/python_self_container_record_unread_no_exposed_credit/input/src/lib.py
  • fixtures/python_self_container_record_unread_no_exposed_credit/input/tests/test_lib.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

gemini-code-assist[bot]

This comment was marked as resolved.

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review November 22, 2026 09:32

@devin-ai-integration devin-ai-integration 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.

Devin Review found 5 potential issues.

Devin Review

…nseen (#16010)

Review of #16107 found six shapes the recorded-container gate downgraded
although the related test tells the old line from the new one or does
read the container:

- the recorded argument calls, assigns (`:=`), awaits or yields, so the
  edit can change state the method's result carries;
- the test hands a name it binds to a call (a reader in another module);
- the test reads attributes by name (`vars(c)`);
- the test calls a helper method of its own test class;
- the test imports a module-level reader under another name.

Each now keeps the existing verdict. The advice asks for an assertion on
the recorded values rather than any reader call, since a size-only reader
does not tell `[2]` from `[3]`. Four adapter controls cover the shapes;
the fixture goldens are re-blessed for the new wording and SPEC-0238 lists
the added conditions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
The public-name case renames `_seen` to `seen` on every line, so the
fixture guard must not require the private spelling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
… is shared

`extend`, `extendleft` and `update` iterate their argument, so
`self._seen.extend(primary)` -> `self._seen.extend(backup)` consumes an
iterator the method may still return. When a name in either side's
argument appears on another line of the method, the existing verdict is
kept. Control added to `calling_argument_keeps_the_oracle_verdict`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
Replace the call-argument match with the test-side twin of
`names_bare_self`: a name the test binds (assignment, `as`, `for`)
that is used other than at its binding or through an attribute access
may reach a reader this file cannot list, as in `dump([c][0])`,
`other = c` or `for item in [c]`. Controls added for each spelling.

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

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

SOURCE_REVIEW_READY

Independent source and oracle review of head 5cb003b, by a session that did not write this PR. Scope: analysis/language/python/self_container_reader.rs, its branch in python/classify.rs, the adapter tests, SPEC-0238 text and the fixture python_self_container_record_unread_no_exposed_credit. Hosted checks, goldens and the verdict corpus were not part of this pass.

Method. Read the full diff against merge base 21c3140 and each later delta. Built ripr at four successive heads, this one included, and ran ripr check --base HEAD~1 --committed --format json on two-commit lab repositories, reading both the class and whether the new gate's own message was present.

What the gate does. It only ever lowers exposed to weakly_exposed, for a rewritten in-place record into a private self._name when every reader can be listed from the file and no related test reads the container or reaches a reader. classify.rs is unchanged since the first reviewed head: the branch sits behind static_limit.is_none(), a strong oracle and alignment.observes(), and the exposed arm excludes it.

Counterexamples tried, and where they stand on this head. Earlier heads lowered the class in shapes where the test does tell old from new; each now keeps the existing verdict, observed on the built binary:

  • recorded argument with a side effect that reaches the result (n.pop(), a self._bump() call, :=): exposed;
  • an iterating mutator consuming an iterator the method still returns (extend(primary) to extend(backup), return list(backup)): exposed;
  • a reader in another module handed the instance (dump(c), and the dump([c][0]) spelling): exposed;
  • attribute access by name in the test (vars(c)): exposed;
  • a helper method of the test class that calls a reader: exposed;
  • a module-level test helper that calls a reader: exposed.

Controls that should still be lowered are: the fixture shape, the same test with the instance bound to a local, and extend([1]) to extend([0]) with an unaffected result. All three read weakly_exposed with the gate's message.

For-loop, tuple, module-global, walrus and parametrized bindings of an instance handed to an outside reader read weakly_exposed without the gate's message, from the older generic path, on every head I built. That behavior predates this PR.

Residual assumptions, stated so they are not read as covered. A test parameter, a tuple-unpacked name or a module-global instance is not a binding test_local_escapes tracks; I found no case where the gate fires through one, but I did not prove there is none. argument_names and the escape scan are word scans over text, so a name inside a string literal keeps the existing verdict more often, never less. The adapter's aliased-reader control is also held by the escape rule, so it does not isolate the alias rule.

Not executed by me. The lib unit tests (the lib test binary does not link in a 15 GB container), cargo xtask goldens check, verdict-corpus check-all, precommit. Their first run is hosted.


Generated by Claude Code

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Native-Windows per-worktree proof run (dedicated target dir, no shared cache — trustworthy environment) found one genuine failure in this PR; it is deterministic and platform-independent, not an infrastructure artifact.

Failing test

cargo test -p ripr --lib self_container_reader → 5 passed; 1 failed:

analysis::language::python::self_container_reader_tests::calling_argument_keeps_the_oracle_verdict
panicked at crates\ripr\src\analysis\language\python\self_container_reader_tests.rs:86:5:
fixture record line:         self._seen.extend(m)

Root cause

The second case of calling_argument_keeps_the_oracle_verdict rewrites the tick body so the fixture's record line (line 7, RECORD_LINE = 7) becomes self._seen.extend(m) — by design, to model the consumed-iterator shape. But the shared helper analyze_edit hard-codes the original fixture's shape at line ~86:

assert!(
    new_text.trim().starts_with("self.") && new_text.contains(".append("),
    "fixture record line: {new_text}"
);

self._seen.extend(m) satisfies starts_with("self.") but not contains(".append("), so the PR's own new case trips the helper's invariant before the analysis under test ever runs. The first case in the same test (self._seen.append(abs(n + 1))) passes the invariant, which is why 5 of 6 still pass.

Suggested direction (writer's call)

The invariant exists to prove the fixture really edits the intended line. Options: accept any self. record line, take the expected record marker as a parameter, or scope the check to cases where the caller opts into the .append( shape. The analysis behavior under test is unaffected.

Batch B proof continues on the remaining PRs; no marker posted for this head until this test is green on rerun.

The consumed-iterator control records with `extend`, which the guard's
`.append(` requirement rejected before the analysis ran (found by the
native Windows proof run on 5cb003b).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
Resolve the corpus inventory pin (main 34 direct-aligned cards plus this
fixture: 35) and SPEC-0238 (main's class-attribute rule, then the
recorded-container rule).

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

Copy link
Copy Markdown
Member Author

Thanks, confirmed and fixed. c6487366 loosens the helper's record-line guard to any self. line with a call, so the extend(m) control in calling_argument_keeps_the_oracle_verdict now reaches the analysis. 6acd438c merges current main (inventory pin resolved to 35 = main's 34 plus this fixture; SPEC-0238 keeps main's class-attribute rule and appends this one). New head 6acd438ca001df3bdfc69b2a2cdd4a463016c317: please re-run cargo test -p ripr --lib self_container_reader and python_repair_card_corpus_pins_alignment_inventory there; this container cannot link the lib test binary.


Generated by Claude Code

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

REVIEW_READY for head 6acd438

Independent native-Windows review of fix(python): a recorded private container needs a test that reads it (#16010) at 5cb003b.

Source review (verified against source)

  • Root cause is exact: self._name.append(..) (and appendleft/extend/extendleft/insert/add/update) changes what the object holds, not what the method returns, so a strong test pinning the method's own return value reaches the owner without observing the recorded value — reach plus a strong oracle on the wrong sink read exposed on main.

  • The new self_container_reader.rs gate is a model of the product's fail-closed discipline: the gap is reported only when static evidence can list every reader from the file, and each condition that cannot be established (decorated methods, base classes, return self, aliased seeds, public names, dunder readers, fixtures/setup receivers, vars(c) inspection, renamed imports, escaping name bindings) keeps the existing verdict. The module doc enumerates each one explicitly.

  • Over-approximation is fail-closed by construction: readers are found by whole-word name plus closed-over same-file callers, which only keeps the existing verdict more often, never credits less.

  • The repair advice is honest: when a related test does call a reader, the gate does not judge whether that read discriminates the edit, and its advice asks for the recorded values rather than any reader call — a named repair target, not a vague "add a test".

  • Evidence discipline: the unread-no-credit fixture plus a honesty-corpus case pin the downgrade, with RIPR-SPEC-0238, the gap-decision ledger, traceability, and changelog moving together.

  • Native proof (native Windows, worktree wt-16107 advanced to the fix head 6acd438): cargo test -p ripr --lib self_container_reader => 6 passed; 0 failed (exit 0), including the previously failing calling_argument_keeps_the_oracle_verdict.

Residuals

The PR scopes to private single-underscore containers per #16010; public-container readers stay on the existing verdict until a follow-up extends the seed conditions.

Inventory pin: main's (34, 37, 51, 2) plus this fixture's direct card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
Main changed shared human-output legend text; no class or finding moved.

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

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

SOURCE_REVIEW_READY

Independent source review of head 044d217, continuing the pass recorded on 5cb003b (review 6011787092).

What was compared

  • The PR's contribution against its main parent 5a04905, line by line with the contribution at 6acd438 against 4d2964f. Differences: the ledger inventory pin (35, 37, 51, 2), which is main's (34, 37, 51, 2) plus this fixture's one direct card; a fixture CHANGELOG entry; and the legend wording in expected/human.txt and expected/human-full.txt, which follows main's renderer text. expected/check.json, self_container_reader.rs and the classify.rs branch are identical.
  • Main's Python changes in that window (range_activation, guard_activation, related_tests/project_names, related_tests/test_local_shadow) do not touch classify.rs.

What was run

  • cargo build -p ripr at this head, then the 17 lab repositories from the earlier rounds. All verdicts equal the 5cb003b and 6acd438 runs: A P M N O Q W Y read weakly_exposed; B C D F J K L V X keep exposed.

Scope of this review

  • Source and oracle only. Hosted qualification on this head has not run yet and is not covered here. Lib unit tests were not run in this container; the author reports cargo check --lib --tests and the corpus gates on this head.

Generated by Claude Code

Copy link
Copy Markdown
Member Author

Shard 2 failure on 044d217 is this PR's: python_repair_card_corpus_pins_alignment_inventory rejects the new fixture's card pair (direct, strong_oracle_observes_owner_method_on_bound_receiver), a reason the inventory match never listed. The production eligibility table already treats it as a direct route (python_direct_bound_receiver_oracle). Fix: count that pair as direct in the inventory test, pin stays (35, 37, 51, 2). Pushing once the gates job and shard 1 finish on this head, so any other failure lands in the same push. The four self_container_reader_tests functions passed in shard 2.


Generated by Claude Code

…ntory

The recorded-container fixture's weak card carries
(direct, strong_oracle_observes_owner_method_on_bound_receiver), which
the production eligibility table already treats as a direct route
(python_direct_bound_receiver_oracle) but the inventory match rejected.
Found by hosted shard 2 on 044d217.

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

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

SOURCE_REVIEW_READY

Independent source review of head a03a181, continuing the pass recorded on 044d217 (review 6100287029).

What changed

  • One commit, a03a181, touching only the #[cfg(test)] module of crates/ripr/src/output/gap_decision_ledger.rs: the Python inventory test now counts the pair (direct, strong_oracle_observes_owner_method_on_bound_receiver) with the direct cards, and a comment is corrected. No production line, fixture or golden differs from 044d217.

What was checked

  • The production eligibility table in the same file already maps that pair to python_direct_bound_receiver_oracle as eligible, so the test arm's requirement (direct cards are eligible) agrees with production and adds no new permission.
  • The card's target is sound for this fixture: the related test calls the owner method on a bound receiver and asserts its return value, so the advised assertion on the recorded values belongs in that test.
  • The earlier lab build and 17 cases stand for this head, since no analyzed code changed.

Scope of this review

  • Source and oracle only. The pinned inventory (35, 37, 51, 2) is a lib unit test that does not link in this container; the hosted shard that reported the unlisted pair on 044d217 is the run that decides it on this head.

Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

merge-ready is set, but this PR conflicts with main (head a03a181b), so GitHub creates no test-merge ref and no qualification run can start. 1. Merge main into the branch and resolve the conflicts. 2. Remove and re-apply merge-ready to request admission and qualification only. 3. After qualification is green, enqueue the PR through the native queue route; re-applying the label does not enqueue it.

…-wsi85f

# Conflicts:
#	crates/ripr/src/output/gap_decision_ledger.rs

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

SOURCE_REVIEW_READY

Independent source review of head 60ca48d (merge of main b32e200 into a03a181), continuing the pass recorded on a03a181 (review 6100420875).

What was compared

  • The PR's contribution against its main parent b32e200, line by line with its contribution at a03a181 against 5a04905. The single difference is the Python inventory pin: main's #15287 moved it to (35, 37, 51, 2), and this head sets (36, 37, 51, 2) with both explanatory comments kept. Every other line of the contribution is identical.
  • Main's Python changes in that window touch boundary.rs, no_behavior.rs and tests; in classify.rs only a comment moved.

What was run

  • cargo build -p ripr at this head, then the 17 lab repositories from the earlier rounds. All verdicts equal the earlier runs: A P M N O Q W Y read weakly_exposed; B C D F J K L V X keep exposed.

Scope of this review

  • Source and oracle only. The pinned inventory is a lib unit test that does not link in this container, so the hosted unit shard is the run that decides (36, 37, 51, 2) on this head.

Generated by Claude Code

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