Repository navigation
fix(python): a recorded public or module container needs a test that reads it (#16010) - #16563
Conversation
…reads it (#16010) #16107 covered a rewritten `self._name.append(..)`. The same edit on a public attribute (`self.seen.append(n + 1)`) or on a module-level name in a top-level function (`LOG.append(n + 1)`) still read `exposed` from a test that only pins the owner's own result. Both shapes now go through the same reader gate. Code outside the file can read a public attribute or a module name, so the gate reports the gap only when nothing outside the file can be shown to read it: - no other production file imports the module, a name from it, or `*`; - no test anywhere, related or not, names the container or a reader, or imports the module, the container, a reader or `*`; - no conftest that declares a fixture or hook sits above any test; - no module-level code names the owner or a reader (registration decorators, import-time calls); - no method of the class hands `self` on, and the file is not a package `__init__`. A module name must also be seeded once at module level by a fresh empty collection and named nowhere else outside a function. `globals` joins the dynamic-access spellings. Any condition that fails keeps the existing verdict. Adds four adapter tests, the fixtures `python_public_container_record_unread_no_exposed_credit` and `python_module_container_record_unread_no_exposed_credit` with honesty cases, SPEC-0238 text, changelog and traceability. The repair-card inventory pin moves to 38 direct-aligned cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
|
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 1 minute. View limit details
|
EffortlessSteven
left a comment
There was a problem hiding this comment.
Independent source review of ec8be81. No marker on this head: three shapes report the gap while a passing test reads the container.
Method: built ripr at this head and ran ripr check --base HEAD~1 --committed --format json on two-commit repositories whose only change is append(n) to append(n + 1), with the two new fixtures' src/lib.py (the total function removed). Every test below passes under pytest and fails if the recorded value is wrong. "Gap" means the finding is weakly_exposed and carries no related test reads ... or calls a function that reads it.
1. A test-support module that is not a test file reads the container (module name). Gap reported.
# tests/helpers.py
from src.lib import LOG
def recorded():
return list(LOG)
# tests/test_lib.py
from src.lib import tick
from tests.helpers import recorded
def test_tick():
assert tick(1, 2) == 3
assert recorded() == [3]tests/helpers.py has no test, so it is not in all_tests, and its import is not among the owners imports that wide_container_is_unobserved reads. The test's own imports name neither the module nor the container.
2. The same through a public attribute. Gap reported.
# tests/helpers.py
from src.lib import Clock
CLOCK = Clock(1)
def recorded():
return list(CLOCK.seen)
# tests/test_lib.py
from src.lib import Clock
from tests.helpers import recorded, CLOCK
def test_tick():
assert Clock(1).tick(2) == 3
assert CLOCK.tick(2) == 3
assert recorded() == [3]3. Another production file reaches the module without importing it by name. Gap reported for both.
# src/extra.py
import src
def recorded():
return list(src.lib.LOG)# src/extra.py
import sys
def recorded():
return list(sys.modules["src.lib"].LOG)with the test calling tick(1, 2) and then assert recorded() == [3]. The first is the more ordinary one: names_module compares the last segment of the import, and import src has none that equals the stem.
What the three share: the related test calls a function the gate cannot place. For self._name the stated assumption is that only the file reads it. For a wide container the module comment says importers can read it, so a call in a related test to a name that is neither a builtin, nor an assertion, nor defined in the owner's file is a possible reader. Declining on that (or on any import in the test file from a module other than the owner's) closes 1, 2 and 3 together without a list of import spellings. Reading helper files' imports would close 1 and 2 only.
Shapes tried that held (verdict stays exposed, or the gate declines): a plain local handed to a function; a test that names the container; a helper in the test file with a function-local import; import src in the test with src.lib.dump(). Tuple unpacking, a walrus binding, a chained assignment, a module-level instance in the test file and a test-file subclass are all weakly_exposed with strong_oracle_observes_different_sink and no gap text, so this gate is not what speaks there; I did not look at whether that older verdict is right.
Controls: both fixtures' own tests give the gap; adding assert c.seen == [3] gives exposed.
Not reviewed: hosted results, the fixture goldens beyond the two inputs, the ledger change in output/gap_decision_ledger.rs.
Generated by Claude Code
…ough another module (#16010) Review of #16563 found three shapes where the public or module container gate reported the gap although a passing test reads the container: - a helper module beside the tests (tests/helpers.py) imports the container or an instance and the related test calls its function; - another production module reaches the owner's module through a plain package import (import src; src.lib.LOG); - another production module reaches it by string (sys.modules[...]) and the related test calls that function. For a public or module container the gate now also declines when a related test uses any name it imports from a module other than the owner's, pytest or unittest; when any test imports from a module under a test directory; and when another production file's plain import names a parent package of the owner's module. The module-level registration check moves to the caller so the helper keeps a short argument list. Adds the reproductions as adapter test cases and updates SPEC-0238, the module doc and the changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
|
Re review 6101677539: all three shapes were real, and 6294fe8 repairs them. For a public or module container, the gate now also declines when:
The six reproductions (both helper-module variants, Generated by Claude Code |
EffortlessSteven
left a comment
There was a problem hiding this comment.
SOURCE_REVIEW_READY
Independent source review of 6294fe8, by a session that did not write it. It follows my findings record 6101677539 on ec8be81.
Scope: self_container_reader.rs at this head in full for ec8be81, plus the delta from ec8be81 to this head (the three added conditions for a public or module container, module_forms, the moved module-code check). Built ripr at this head and ran ripr check --base HEAD~1 --committed --format json on two-commit repositories. Every test in them succeeds under pytest. Not part of this record: hosted results, the lib unit tests (they do not link in my container), fixture goldens, the ledger change.
The three shapes from 6101677539 now read exposed: a tests/helpers.py reader for the module name, the same for a public attribute, and another production file reaching the module through import src or sys.modules.
Second round, all exposed with no gap text:
- a helper in the test file that calls a helper imported from another production file;
import src.extraused assrc.extra.recorded();- another production file whose reader imports the container inside the function;
- a module-level instance in the test file read by a test-file helper, by a test-file subclass, by
tearDown, byteardown_function, and by a decorator around the test; teardown_functionreading the module container through a function-local import, and through a helper from another production file;- a second test in the file reading it through
sys.modulesor a function-localimport src.lib.
Controls: the two fixtures' own shape still gives the gap for both kinds; a test that names the container gives exposed; an unrelated helper and test added to the test file leave the gap in place, so the gate is still reachable with other functions in the file.
Read, not run: module_forms takes every path suffix, so a shorter import root (pkg.lib for src/pkg/lib.py) counts as the owner's module; the foreign-name condition looks at related oracle tests only and at names the body mentions, which the test-directory and module-import conditions over all tests back up.
Generated by Claude Code
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
|
…-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 1fc4f42, by a session that did not write it. This head is the merge of 6294fe8 (my record 6101885613) with main at 4fba199.
Checked on the merge:
- The PR's change against main at this head equals its change against the old merge base at 6294fe8, added and removed line for added and removed line, with one difference: the corpus pin in
output/gap_decision_ledger.rsgoes from main's(37, 37, 51, 2)to(39, 37, 51, 2), where it went from(36, ...)to(38, ...)before. Main's #15970 added one direct-aligned card and this PR adds two, so 39 is the sum. Both comments are kept. - Main also moved
classify.rs(the guarded-arm gap now covers the side-effect and error-path families), which is the family a recorded append belongs to. Builtriprat this head and reran all twenty of my cases on the combined tree: the fixture shapes and the unrelated-helper control give the gap, and every reproduction from both rounds readsexposed, the same as on 6294fe8.
Not part of this record: hosted results on this head, the lib unit tests including the pin test itself (they do not link in my container), fixture goldens.
Generated by Claude Code
Fail open when the owner reaches a call into another module (a lazy import there may read the container), when a def header default or a module-level instance names the owner, class or a reader, when either recorded argument divides or subscripts, and when the old side iterates its argument. Test-helper imports now match a tests/test segment or a directory that holds a test, not the first component of any test path, so a test inside the production package no longer vetoes the gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
There was a problem hiding this comment.
Exact-head review note for 1fc4f428a5b852fba539280d105f178ae9e53e56: the current head is not merge-ready even if the hosted qualification Result goes green.
I checked the automated findings against the implementation rather than treating green CI as clearance. The five bug findings have concrete source-level bases:
collect_imports_from_statements(file, &module.body)only records module-level imports, whilewide_container_is_unobservedrelies onother.imports; function-local production imports can therefore be missed.- the iterator-consumption guard is conditional on
consumes_argument(new_line, ...), so anextend(..) -> append(..)edit never applies the guard to the removed consuming call. module_code_names_themonly considers lines outside every function, while default-argument expressions execute at import time.test_rootsis built from the first path component rather than the actual test directory, so nested/colocated layouts can misclassify helper imports.has_inert_argumentpermits division and other potentially raising operators because it only excludes calls,:=,awaitandyield.
The two test-oracle flags also look material: the parent-package control is masked by the foreign-use veto, and the sibling-reader control calls dump without importing it. Those controls cannot currently discriminate removal of the behavior they purport to pin.
I am not marking this REVIEW_READY; these need repair or a source-backed refutation before merge convergence. Green qualification is necessary evidence here, not sufficient landing authorization.
EffortlessSteven
left a comment
There was a problem hiding this comment.
Independent source review of 3b90320. No marker on this head: one shape still reports the gap while the test's pinned result is the container.
Built ripr at this head. My earlier cases keep their verdicts (fixture shapes and the unrelated-helper control give the gap; the helper-module, import src, lazy-import and named-container cases read exposed).
The owner returns what a parameter it calls returns. Gap reported (weakly_exposed, no related test reads LOG or calls a function that reads it); the test succeeds under pytest and stops succeeding if the recorded value is wrong.
# src/lib.py
LOG = []
def tick(hours, n, sink):
LOG.append(n + 1) # the change: was LOG.append(n)
return sink()
# tests/test_lib.py
from src.lib import tick
def snapshot():
from src.lib import LOG
return list(LOG)
def test_tick():
assert tick(1, 2, snapshot) == [3]The new call-out condition looks for import statements and imported names in the functions the owner reaches. A callable handed in as an argument is neither, so the owner's result can carry the container without the owner naming it twice. The test passes snapshot uncalled, which is not a local binding and not a helper call in the test body, and the import of LOG sits inside the helper, so none of the test-side conditions sees it.
The condition that would cover it sits on the owner, not on the test: for a public or module container, an owner that calls one of its own parameters (or a method on one) can return state the gate cannot list. The same owner with int passed as sink also reports the gap today, and that case would go quiet under such a rule, which matches how the other owner-side conditions already trade.
Not looked at on this head beyond the delta to self_container_reader.rs and the cases above: the new unit tests' results (the lib test binary does not link in my container), hosted results, the seven Devin repairs one by one.
Generated by Claude Code
A callable or object the caller passes in (return sink()) can return the container, so for a public or module container the gate keeps the existing verdict when any function the owner reaches calls, indexes or reads an attribute of a non-self parameter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
|
Review 6102125110 (owner returns a parameter it calls): repaired in 342290a. For a public or module container, the gate now keeps the existing verdict when any function the owner reaches calls, indexes or reads an attribute of a parameter other than Generated by Claude Code |
|
Coordination note (evidence-only reviewer): this branch is now conflicted with main ( |
Inventory pin: main's 38 direct cards plus this PR's two fixtures = 40. 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.
REVIEW_READY for head b52347c
Independent native-Windows review of fix(python): a recorded public or module container needs a test that reads it (#16010) (PR #16563) at b52347c (merge of current main into the branch).
Source review (verified against source)
Delta (PR vs merge-base 5ba252e: 29 files, +1803/−129): language/python/self_container_reader.rs + its _tests.rs, the language/python/classify.rs hook, the output/gap_decision_ledger.rs expectation, two evidence-promotion corpus cards, two full fixture workspaces, spec doc, traceability card, changelog. (Main has since relocated these modules out of analysis/classify/; the delta shape is unchanged from the prior reviewed head.)
-
The reader gate generalizes from private
self._namecontainers to public and module-levelNAME.append(..)records, so a rewritten module container is likewise observed only by a test that reads the container or calls a reader of it — closing the gap where a module-level record could be rewritten with no observing test and still no gap surfaced. -
The hook passes a
ChangedRecordstruct (text, old text, line) andall_testsinstead of just the current line: reader listing can look across the test surface rather than only same-file tests, which is what makes the module-container case decidable at all. -
The fail posture is preserved and stated: "shapes whose readers cannot all be listed fail open" — an undecidable record keeps the old (more permissive) behavior rather than inventing a gap claim, matching the repo's unknown-is-valid rule.
-
A reader that calls, indexes, or attribute-reads a parameter (excluding
self/cls) fails open viauses_as_object—name(..),name.x,name[..]runs caller-chosen code, so crediting it as a container read would fabricate an observer. Word-boundary checks (sinkingdoes not matchsink; nothing after.) keep the match honest. -
The ledger expectation moves with a comment naming the new corpus card — explained drift, not silent re-blessing; the two new corpus cards pin both the public and module variants as no-exposed-credit controls.
-
The two added
proptest-regressionsfiles copy seeds to post-relocation paths, matching the seed-carry contract the batches require. -
Native proof (native Windows, worktree wt-16563 at head b52347c):
cargo test -p ripr --lib language::python(exit 0);cargo test -p ripr --lib gap_decision_ledger(exit 0);cargo xtask goldens check(exit 0 apart from the known pre-existingpython_parent_collected_test_shadownative-Windows fixture drift);cargo xtask check-evidence-promotion-honesty(exit 0).
Scope and non-goals
- Reviewed and proven at this head only; a later push restarts review. Re-reviewed at b52347c after the main merge; conclusions carried from 342290a and re-verified against the relocated paths.
- Part of the #16010 recorded-container family with #16107 (private container) — same gate, wider record shapes.
- Merge mechanics belong to the writer; this review is evidence only.
|
Author note on review 6105064035 (REVIEW_READY on b52347c). Its delta description differs from this head in two places. Generated by Claude Code |
Requested by Steven · project thread
Summary
self._name.append(..). The same edit on a public attribute (self.seen.append(n + 1)) or on a module-level name in a top-level function (LOG.append(n + 1),_REGISTRY.add(..)) still readexposedwhen the only strong test pinned the owner's own return value. Both shapes now go through the same reader gate and readweakly_exposed, naming the functions that read the container.*;*;selfon;__init__;pytestorunittest(a helper module, or production code reaching the module throughsys.modules);import src);globalsjoins the dynamic-access spellings. The privateself._namepath is unchanged apart from that spelling.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Spec: RIPR-SPEC-0238 (Python oracle and reach rules)
Governing issue or accepted claim: #16010 (remainder after #16107)
Acceptance delta (one sentence): a public or module-level recorded container whose only test pins the owner result no longer earns
exposedcredit when nothing outside the file can read it.Candidate Relationships
Candidate branch:
claude/project-thread-wsi85fStack parent or prerequisite PR: #16107 (merged).
Proposed replacement of PR: none.
Scope
Scope Classification
Production delta:
crates/ripr/src/analysis/language/python/self_container_reader.rs(generalized to aRecordedcontainer kind, withwide_container_is_unobservedfor public and module names) and its call inpython/classify.rs, which now passesall_testsand aChangedRecord.Evidence/support delta:
self_container_reader_tests.rs. The old "public keeps the verdict" control moved into the new positive test.python_public_container_record_unread_no_exposed_creditandpython_module_container_record_unread_no_exposed_credit, with goldens and honesty corpus cases.gap_decision_ledger.rsmoves from 36 to 38 direct-aligned cards.Single acceptance criterion:
weakly_exposedand name the readers. Every hidden-read control keepsexposed.Non-goals:
importlibor a file RIPR did not read is not seen.Support-tier Impact
Policy Impact
Proof
Results, failures and skipped proof:
weakly_exposed: publicself.seen(chained and local receiver), moduleLOG, and module_REGISTRY.exposed: a test reading the attribute orLOG; another test calling a reader; another production file importing the module; an import-time call; a conftest fixture (autouse and plain); a test importingLOGor the module; a method returningself; the owner calling a reader; a module re-seed; an aliased seed.wide_container_is_unobserveddisabled, 8 of those controls flip toweakly_exposed, so those checks carry the verdict.weakly_exposedon main through the bound-receiver alignment path, so this PR does not move them: a receiver from a factory, a classmethod or a dict, and a test-file subclass.import src,sys.modules). 6294fe8 repairs them; all six reproductions keepexposedand are now adapter test cases.cargo clippy --all-targets) but have not executed, because the ripr lib test binary does not link in this container. Hosted CI is their first run, and they will be confirmed by name in the shard logs.Claim Boundary
May claim: a public self container or a module-level container recorded into, with no reader outside the file and no test naming it or a reader, needs a test that reads it for
exposed. Must not claim: mutation outcomes, or reads through files RIPR did not read.Rollback
Revert the squash commit. The gate is additive and only downgrades
exposedtoweakly_exposed.Spec-Test-Code Traceability
self_container_reader_tests.rs, both new fixturespython/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.https://claude.ai/code/session_01SvmPmphDz9csy269eJ23Wo
Generated by Claude Code