Repository navigation
fix(python): a recorded private container needs a test that reads it (#16010) - #16107
Conversation
…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
|
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 21 minutes. View limit details
|
…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
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
left a comment
There was a problem hiding this comment.
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(), aself._bump()call,:=): exposed; - an iterating mutator consuming an iterator the method still returns (
extend(primary)toextend(backup),return list(backup)): exposed; - a reader in another module handed the instance (
dump(c), and thedump([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
|
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
Root causeThe second case of assert!(
new_text.trim().starts_with("self.") && new_text.contains(".append("),
"fixture record line: {new_text}"
);
Suggested direction (writer's call)The invariant exists to prove the fixture really edits the intended line. Options: accept any 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
|
Thanks, confirmed and fixed. Generated by Claude Code |
EffortlessSteven
left a comment
There was a problem hiding this comment.
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(..)(andappendleft/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 readexposedon main. -
The new
self_container_reader.rsgate 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 failingcalling_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
left a comment
There was a problem hiding this comment.
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.txtandexpected/human-full.txt, which follows main's renderer text.expected/check.json,self_container_reader.rsand theclassify.rsbranch are identical. - Main's Python changes in that window (
range_activation,guard_activation,related_tests/project_names,related_tests/test_local_shadow) do not touchclassify.rs.
What was run
cargo build -p riprat 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 readweakly_exposed; B C D F J K L V X keepexposed.
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 --testsand the corpus gates on this head.
Generated by Claude Code
|
Shard 2 failure on 044d217 is this PR's: 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
left a comment
There was a problem hiding this comment.
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 ofcrates/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_oracleas 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
|
|
…-wsi85f # Conflicts: # crates/ripr/src/output/gap_decision_ledger.rs
EffortlessSteven
left a comment
There was a problem hiding this comment.
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.rsand tests; inclassify.rsonly a comment moved.
What was run
cargo build -p riprat 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 readweakly_exposed; B C D F J K L V X keepexposed.
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
Requested by Steven · project thread
Summary
self._name.append(..)(alsoappendleft,extend,extendleft,insert,add,update) in an ordinary Python method readexposedwhenever a strong test pinned the method's own return value. It now readsweakly_exposedand 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.return self, aliased seeds, public names, dunder readers; see the module doc ofself_container_reader.rsand SPEC-0238).Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Spec: RIPR-SPEC-0238 (Python oracle and reach rules)
Governing issue or accepted claim: #16010 (partial: private
self._xcontainers only)Acceptance delta (one sentence): a private recorded container whose only test pins the method result no longer earns
exposedcredit.Candidate Relationships
Candidate branch:
claude/project-thread-wsi85fStack parent or prerequisite PR: none. Enqueue waits on import #16016 under the release lead's analysis/** hold.
Proposed replacement of PR: none.
Scope
Scope Classification
Production delta:
crates/ripr/src/analysis/language/python/self_container_reader.rs(new) and its call frompython/classify.rs.Evidence/support delta:
self_container_reader_tests.rs), honesty fixturepython_self_container_record_unread_no_exposed_creditwith goldens and corpus case, SPEC-0238 text, changelog, traceability, inventory pin 26 to 27 ingap_decision_ledger.rs.Single acceptance criterion:
weakly_exposednaming the reader; controls that read the container keepexposed.Non-goals:
self.seen.append) and module-level containers (LOG.append) stay open on python: a changedself.x.append(...)or module-container mutation reads exposed from a return-value pin (false exposed) #16010.Support-tier Impact
Policy Impact
Proof
Result, failures, or skipped proof:
class Clock(object):readweakly_exposed; names-attr, calls-reader, calls-reader-caller, base class,return self, aliased seed, owner reads, owner calls reader, public name and dunder reader keepexposed; a decorated method keepsstatic_unknown.self_container_reader_tests.rscompile 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 xtaskwas not run.e7eff2aeand applied cleanly to21c3140a; 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
exposedtoweakly_exposed.Spec-Test-Code Traceability
self_container_reader_tests.rs, fixturepython_self_container_record_unread_no_exposed_creditpython/self_container_reader.rs,python/classify.rsexpected/Static Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.Generated by Claude Code