Skip to content

fix(python,typescript): credit a same-file assertion helper called with literals (#9636) - #9702

Merged
EffortlessSteven merged 16 commits into
mainfrom
claude/fix-9636-helper-credit
Oct 24, 2026
Merged

EffortlessSteven merged 16 commits into
mainfrom
claude/fix-9636-helper-credit

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Summary

  • A plain Python or TypeScript test that calls a same-file, non-exported assertion helper with literal arguments (check_pass(50, True) over assert passes(score) == want) now reads as the assertions that helper runs. Before, ripr reported no_static_path / 0 related tests and abstained although the tests catch the change.
  • Credit-or-unknown only. No new finding kind or repair rule; the ordinary classifier applies and the rewritten asserts go through the ordinary oracle admission.
  • Seven rows move to credited on the current base: the six py-grid-*-helper Python rows and ts-grid-returns-helper (string-literal arguments, which main's TypeScript decision-19 helper pass refuses). The other five ts-grid-*-helper rows were already credited on main by fix(ts): credit literal-table and same-file helper assertions for field updates #9717 before this PR merged main in, so this PR does not move them. This PR does not edit any ceiling.

Swarm / Source Boundary

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

Source-of-truth Links

Proposal:
Spec: RIPR-SPEC-0028 (Helper Inlining Amendment), RIPR-SPEC-0243 rule 17
ADR:
Plan item:
Governing issue or accepted claim: #9636
Acceptance delta (one sentence): The six py-grid-*-helper abstained rows and ts-grid-returns-helper move to credited; the other five TypeScript helper rows were already credited by #9717.

Candidate Relationships

Candidate branch (GitHub PR head is authoritative after publication): claude/fix-9636-helper-credit
Stack parent or prerequisite PR (if any): none
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): n/a
Accepted winner and losing candidate disposition (when decided): n/a

Overlap with main: TypeScript assertion_helper.rs (#9717, decision 19) runs first and expands helpers it fully understands; helper_inline only rewrites helpers it leaves untouched, so no helper is expanded twice. Python helper_assertions (#9419/#9711) runs later on extracted tests and sees no call once helper_inline has rewritten it.

Scope

  • Python: python/helper_inline.rs, called from extract_source_facts for test files. Rewrites the file source before extraction.
  • TypeScript: typescript/helper_inline.rs, called from the test extractor through the existing source-expansion path (the suite-factory precedent, no appended lines).
  • A helper-call statement becomes the helper's asserts with the call's literal arguments substituted, on the same physical line, so no line number moves.
  • Fail-closed admission is stated as spec rules (0028 amendment, 0243 rule 17): same-file, undecorated, sync, declared-once (never also a class) helper with plain parameters and an assert-only body; a call that is a top-level statement alone on its line in a top-level test with no parameters or locals; literal arguments only (negative numbers parenthesised); parameters used only as plain values; every [ / { in the asserts refused; no dynamic name binding in the file.
  • Defence in depth: if the rewritten source fails to parse, both languages fall back to the original source (unknown) so the file's other tests are still extracted.
  • Cross-file helpers (Python: assertion inside a helper function in another file reads as reach-only #9419), conditional or loop-nested calls, computed arguments, branching or defaulted helpers, and nested describe tests stay unknown.

Scope Classification

  • One production behavior

Production delta:

  • python/helper_inline.rs (new) and its hook in python/source_facts.rs; typescript/helper_inline.rs (new) and its hook in typescript/tests_extract.rs.

Evidence/support delta:

  • helper_inline_tests.rs for both languages: positive credit, exact rewrite text, line-number stability, and negative controls for every guard. TypeScript negatives measure the inline pass directly (test-only inline_rewrites()), because main's decision-19 pass now credits some of the same shapes end to end.
  • Blessed corpus rows, spec rules, .ripr/traceability.toml entries, changelog.d/helper-wrapped-assertion-credit.md.

Single acceptance criterion:

  • The seven rows named above credit and no other row's verdict moves.

Non-goals:

  • Cross-file helpers, helper bodies with control flow, non-literal call arguments, Rust and Perl, the trap-* rows.

Support-tier Impact

  • none

Policy Impact

  • none

Proof

On the merge of main at 12733f9 (head 02078fb; 126b841 plus a docs-only spec follow-up):

cargo test -p ripr --lib helper_inline                  # 41 passed (at 126b84176c)
cargo xtask verdict-corpus check --language python      # clean (224 cases, 0 contradictions)
cargo xtask verdict-corpus check --language typescript  # clean (334 cases, 0 contradictions)
cargo xtask precommit                                   # exit 0 (at 126b84176c)

Review of record is on the PR (head 9fb40cd, plus an interaction review of the merge with main at 02078fb). The follow-up commit changes spec text, a changelog line and one doc comment only.

Result, failures, or skipped proof:

  • Precommit's goldens step reported one fixture it could not compare (owner_return_pin_fallible_literal, dependency preparation failed offline); hosted CI owns it.
  • Full workspace test and qualification were not run locally.

Claim Boundary

  • May claim: same-file literal-argument assertion helpers are credited through the existing oracle admission in Python and TypeScript.
  • Not claimed: cross-file helpers, helpers with control flow or computed arguments, nested-describe TypeScript tests, or any runtime mutation outcome.

Rollback

  • Revert this PR. The hooks are single call sites; fixtures and specs revert with it.

Spec-Test-Code Traceability

  • Spec: RIPR-SPEC-0028, RIPR-SPEC-0243
  • Tests: python/helper_inline_tests.rs, typescript/helper_inline_tests.rs, the verdict-corpus rows above
  • Code: python/helper_inline.rs, typescript/helper_inline.rs
  • Golden outputs: fixtures/{python,typescript}-verdict-corpus/expected/rows/*-grid-*-helper.json
  • Metrics: Python missed-credit 6 fewer; TypeScript 1 fewer (reported by feat(corpus): ratchet a per-language missed-credit ceiling in verdict-corpus check #9628 as a note)
  • ADR/learning:

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.
  • Unknowns include stop reasons where applicable.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.
  • New non-Rust programming files are allowlisted with owner, surface, and reason (none added).
  • New generated, dependency, process-spawn, or network surfaces are allowlisted with owner and reason (none added).
  • Errors are reported with actionable context.
  • Public JSON/schema changes are documented (none).

Gates

  • cargo fmt --check
  • cargo xtask precommit

Full workspace gates are left to hosted qualification of the selected candidate.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WJr6YizPnC777wfxAd9ubU

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 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 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 141 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: 1a3d0320-872c-4aaf-9b32-9eb13e533fae
Commits

Reviewing files that changed from the base of the PR and between aad05dd and 4e90f5f.

Files selected for processing: 21
  • .ripr/traceability.toml
  • changelog.d/helper-wrapped-assertion-credit.md
  • crates/ripr/src/analysis/language/python.rs
  • crates/ripr/src/analysis/language/python/helper_inline.rs
  • crates/ripr/src/analysis/language/python/helper_inline_tests.rs
  • crates/ripr/src/analysis/language/python/python_tests.rs
  • crates/ripr/src/analysis/language/python/source_facts.rs
  • crates/ripr/src/analysis/language/typescript/helper_inline.rs
  • crates/ripr/src/analysis/language/typescript/helper_inline_tests.rs
  • crates/ripr/src/analysis/language/typescript/mod.rs
  • crates/ripr/src/analysis/language/typescript/tests_extract.rs
  • crates/ripr/src/app/test_stub.rs
  • docs/specs/RIPR-SPEC-0028-python-preview-static-facts.md
  • docs/specs/RIPR-SPEC-0243-typescript-oracle-and-reach-rules.md
  • fixtures/python-verdict-corpus/expected/rows/py-grid-arithmetic-helper.json
  • fixtures/python-verdict-corpus/expected/rows/py-grid-boundary-helper.json
  • fixtures/python-verdict-corpus/expected/rows/py-grid-constant-helper.json
  • fixtures/python-verdict-corpus/expected/rows/py-grid-equality-helper.json
  • fixtures/python-verdict-corpus/expected/rows/py-grid-logical-helper.json
  • fixtures/python-verdict-corpus/expected/rows/py-grid-returns-helper.json
  • fixtures/typescript-verdict-corpus/expected/rows/ts-grid-returns-helper.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

…th literals (#9636)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJr6YizPnC777wfxAd9ubU
…aceability (#9636)

Also restores a build break on main in agent/artifact.rs (undefined subject in validate_artifact_identity).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01WJr6YizPnC777wfxAd9ubU
@EffortlessSteven
EffortlessSteven force-pushed the claude/fix-9636-helper-credit branch from d59a1ce to b4b9810 Compare October 22, 2026 14:19
@EffortlessSteven
EffortlessSteven changed the base branch from claude/project-thread-9o1b80 to main October 22, 2026 14:19

Copy link
Copy Markdown
Member Author

Review of record, head 9fb40cd (base main)

Angles: (1) adversarial false-credit safety, (2) tests, spec/contract and repo gates, each as an independent reviewer on the first head; (3) a re-review of the fixes on 1411f74; the final commit is the hardening those reviews asked for.

  • Blocking findings: none outstanding. The adversarial pass found a Python conditional/nested redefinition, a -2 ** 2 precedence change, non-ASCII corruption in substitute(), numeric-member parse errors, walrus shadowing, non-ASCII identifier chars, and TS this/arguments/assert/expect parameters. All fixed with a negative-control test each.
  • Second round (non-blocking, fixed in 9fb40cd): a class NAME rebind, a parameter followed by a quote (b'abc'), a reparse fallback in both languages (a rewrite that fails to parse falls back to the original source), TS <<=/>>=/>>>=, a discriminating assert/expect parameter-name test, spec wording ("no new finding kind or repair rule; the ordinary classifier applies"), and a duplicate spec rule number (now 0243 Rule 16).
  • Spec and traceability: SPEC-0028 amendment, SPEC-0243 Rule 16 and .ripr/traceability.toml entries added; check-spec-format, check-traceability, check-doc-artifacts pass.
  • Proof run by the author on this head: cargo test -p ripr --lib helper_inline 41 pass; Python corpus 194 cases and TypeScript 309 cases, 0 contradictions, no drifted rows beyond the 12 credited ones; clippy -D warnings clean; cargo xtask precommit exit 0 (one fixture not comparable offline, owner_return_pin_fallible_literal; hosted CI owns it).
  • Known residual, accepted: the textual rewrite refuses brackets, braces and closures, so some real helpers stay unknown. Two #[cfg(test)] seams (finish()) exist only to force a parse-failing rewrite for the fallback tests; production uses an identity function.
  • Not established: no required hosted CI has run on this head (the merge-ready label that starts it is outstanding), so merge is waiting on that.

Generated by Claude Code

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

Verification questions

  • Confirm the Python route is test-file gated and recursively re-extracts only after parsing the rewritten module succeeds.
  • Confirm identifier_occurrences is computed in ts::substitute but never used in span building — only the outer word_occurrences drives the span list. The whole plain count is effectively unused. Dead computation, not a credit bug.
  • Confirm the TypeScript route participates in the existing bounded expansion loop and rejects opaque or malformed rewrites before extraction retries.
  • Confirm python inlining joins multi-assert helpers with ; , then finish keeps total line count of original statement, so test.body_text.lines().count() == 3 test for a 2-assert helper expects 2 substituted lines + 1 def line. With ; joining the rewrite is one physical line; extract_tests re-parses and line numbers of asserts are not the call's line.
  • Confirm typeScript helper inlining shares the suite-factory expansion rerun; interaction coverage is absent, so the combined rewrite path should be verified rather than broadened in this PR.

Refuted

  • Literal substitution can syntactically fuse or corrupt assertions and turn a nominal test into a false credit.; refuted because: Signed literals are parenthesised, substitutions are UTF-8-safe, member/prefix hazards are rejected, whole-line ownership is required, and failed reparses fall back to original extraction.
  • Relevant crypto/compression/runtime sibling helpers should be brought under this PR.; refuted because: The changed feature recognizes only syntactic same-file assertion wrappers. Runtime/crypto/compression behavior does not alter helper declaration uniqueness, literal-only admission, or ordinary oracle extraction, so broadening would add untested semantics rather than close this change's path.
  • The rewrite may expose a stale active-view region after source mutation.; refuted because: This is a source-analysis rewrite, not a resizable buffer or view; the implementation reparses rewritten text before using it and otherwise follows the existing extraction fallback.
  • The TypeScript helper route could conflict with or bypass the existing suite-factory expansion behavior.; refuted because: The new hook reuses SuiteFactoryExpansion in the same guarded rerun path; absent or invalid helper expansion does not preempt normal processing.

Evidence gaps

  • Executable current-head test proof remains gated on the scheduled late cargo-test receipt.
  • The strongest red/green objection lacks a post-merge automated witness in the packet, although the exact-output and negative controls address smoke-only and tautological concerns.
  • Model proof intent was rejected by deterministic validation.

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJr6YizPnC777wfxAd9ubU
…ss itself

main's same-file assertion-helper pre-pass (decision 19) credits shapes the
helper-inline pass refuses, so the refusal tests assert on the pass directly.

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

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

Decision

  • Needs verification checks before upstream.

Verification questions

  • Confirm the PR claims twelve credited corpus rows, but only six Python rows and one TypeScript row are changed.
  • Confirm helper inlining has one centralized implementation per language, with extraction hooks at the Python source-facts and TypeScript test-expansion entry points; no sibling runtime/crypto/compression helper path is implicated.
  • Confirm the TypeScript shared expansion loop has no explicit interaction test for suite-factory expansion followed by helper inlining.

Refuted

  • Byte-range replacement could leave aliased slices into the original source alive across mutation.; refuted because: Edits contain owned Strings and replace_range borrows only for each operation; no replacement borrows source text.
  • The change may expose an active-view or backing-store resize/detach/transfer invariant.; refuted because: No active-view memory API is changed. Both implementations allocate and rewrite owned Rust strings using AST-derived source spans, then validate the rewritten source before recursive extraction.
  • The analyzer may hand a JS-backed object or transferred memory reference across a worker/async boundary.; refuted because: The changed paths only own Rust strings and AST data. They do not invoke JavaScript, spawn workers, create GC-managed values, or expose ArrayBuffers/pointers; async callbacks are rejected.
  • The helper-inline change could introduce an exploitable memory-safety or information-disclosure primitive.; refuted because: The diff adds ordinary owned Rust string processing with no unsafe blocks, raw pointers, external data, secret handling, network/process spawning, or public classification changes.

Parked follow-ups

  • Related TypeScript suite-factory and named-callback extraction paths should remain parked rather than be broadened into this PR.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • The claimed twelve corpus-row movements are only partially visible in the supplied patch: six Python rows and one TypeScript row are shown.

…on 19, note helper_assertions

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

Copy link
Copy Markdown
Member Author

Review of record update, head 02078fb (merge of main 12733f9 at 126b841, then a docs-only follow-up).

Angle: interaction of this PR with what main gained while it was open. An independent static reviewer read both TypeScript passes and the Python helper_assertions path.

  • No double expansion. Main's TypeScript decision-19 pass (fix(ts): credit literal-table and same-file helper assertions for field updates #9717) runs first and rewrites a helper only when every mention is replaceable; helper_inline then finds no call for it and does nothing. Each helper is rewritten by at most one pass, and line numbers do not move. Python helper_assertions sees no call once helper_inline has rewritten it.
  • Corpus claim corrected. Five of the six TypeScript helper rows were already credited by fix(ts): credit literal-table and same-file helper assertions for field updates #9717, so this PR now moves seven rows (six Python, ts-grid-returns-helper), not twelve. The PR body says so. That row depends on string-literal arguments, which decision 19 refuses.
  • Spec drift fixed. Rule 16 in RIPR-SPEC-0243 duplicated main's Playwright Rule 16 and was looser than decision 19's Rejected list. It is now Rule 17, in numeric order, stating it extends decision 19(b) for literal-argument call sites of helpers that pass leaves untouched; decision 19 points to it. RIPR-SPEC-0028 and the helper_inline.rs docstring say how this differs from helper_assertions.
  • Tests. After the merge, 10 TypeScript negative tests failed because main's pass now credits those shapes end to end. They now measure the inline pass directly through a cfg(test)-only seam over the production function; no production divergence. Reported on 126b841: 41 helper_inline tests pass, Python corpus 224 cases and TypeScript 334 cases with 0 contradictions, cargo xtask precommit exit 0.
  • Not re-run on 02078fb: the delta is spec text, a changelog line and a doc comment; spec-format, traceability and doc-artifacts checks pass. Required CI runs on this head.

No blockers. Not final-merge REVIEW_READY until the exact-head required check is read.


Generated by Claude Code

…omputed argument

A same-file helper called with a literal is now credited by helper_inline
(RIPR-SPEC-0028); the unresolved-form check uses a shape it still refuses.

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

Copy link
Copy Markdown
Member Author

Head moved 02078fb to f3a7f1a. Required CI on 02078fb failed on one test, python_tests::assertion_admission_separates_no_assertion_from_unresolved_assertion_like_forms (3230 of 3231 lib tests passed): its "same-module helper with an arbitrary name" case called run_case(20), a same-file literal-argument helper that this PR intentionally credits. That is the test encoding the old limit, not an over-credit. The follow-up changes that case to run_case(10 + 10) (computed argument, still unresolved) so the case stays discriminating; the credited literal form has positive tests in helper_inline_tests. The diff against 02078fb is those two lines. The author reports cargo test -p ripr --lib python 1074 pass and cargo xtask precommit exit 0. merge-ready re-applied on this head. The review of record above carries over; this is a test-only delta.


Generated by Claude Code

…umbered 19)

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

Copy link
Copy Markdown
Member Author

Head moved f3a7f1a to ad12d92 (merge of current main). Only conflict was RIPR-SPEC-0243, where main had since added rules 17 and 18 and decision 20, so this PR's helper rule is now Rule 19 (decision 19's pointer, the implementation-mapping line and the changelog fragment updated to match). No other review-relevant change. Reported on this head: cargo test -p ripr --lib python 1135 pass, helper_inline 41 pass, Python and TypeScript verdict-corpus checks pass with 0 contradictions. Local precommit fails only at goldens on typescript_enum_wrong_export (main's known drift, fixed by #9884) and the offline fixture-dependency preparation for owner_return_pin_fallible_literal; all policy checks passed. merge-ready re-applied on this head; the review of record above carries over.


Generated by Claude Code

…-9636-helper-credit

# Conflicts:
#	crates/ripr/src/analysis/language/python.rs
#	crates/ripr/src/analysis/language/typescript/mod.rs
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