Skip to content

fix(typescript): credit an exact test of a memoizing method decorator's cached value (#13657) - #13792

Merged
EffortlessSteven merged 7 commits into
mainfrom
claude/project-thread-emewgg
Nov 8, 2026
Merged

EffortlessSteven merged 7 commits into
mainfrom
claude/project-thread-emewgg

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven Zimmerman · project thread

Summary

  • RIPR-SPEC-0243 rule 21 gains condition 2a. A method decorator whose wrapper is the memo idiom if (!cache.has(k)) cache.set(k, <flow>); return cache.get(k); lends exposed to the decorated method's exact tests for an edit to the cache.set line. Two conditions apply: the cache is a decorator-local, argument-free const cache = new Map() named nowhere else, and the key is one plain wrapper parameter.
  • Why this is sound: the cache only ever holds values that set computed for that key. So every call returns <flow> for its key, whichever call populated it, and the edit reaches the method's result.
  • Decision record: rule 21 listed this shape as a pinned negative because a cache can return a value the original never produced. Condition 2a admits only the shape where it cannot. Everything else keeps the old decorator_indirection reading: prefilled, let, WeakMap or leaked caches, mismatched keys, an else, extra guard statements, combined returns, and call arguments that could rebind the key. The change is reversible, because deleting memoized_flow restores the old reading.

Swarm / Source Boundary

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

Source-of-truth Links

Proposal: #13657 (TypeScript abstention triage)
Spec: RIPR-SPEC-0243 rule 21 condition 2a
ADR: none
Plan item: none
Governing issue or accepted claim: #13657
Acceptance delta (one sentence): A jest/vitest exact assertion on a method wrapped by a memoizing decorator now credits an edit to the decorator's cached value, moving deco-decorator-wrapper-value from limited to credited with zero false verdicts.

Candidate Relationships

Candidate branch: claude/project-thread-emewgg (restarted from main after #13693 merged)
Stack parent or prerequisite PR: none
Proposed replacement of PR: none

Scope

  • crates/ripr/src/analysis/language/typescript/decorated_entries.rs: memoized_flow, map_call, plain_call_arguments; the existing pass-through path is unchanged and is tried after the memo shape.
  • decorated_entries_tests.rs: one positive test (braced and braceless guard, as/! return) and two negative tests (8 cache shapes, 9 wrapper-body shapes).
  • Spec text (rule 21 condition 2a, negatives list).
  • TypeScript corpus: deco-decorator-wrapper-value re-blessed (limited -> credited; its tests fail on the edit, since 4*4+1 != 16), and its missed-credit.toml entry is removed, as the file requires.
  • Changelog fragment (Fixed).

Scope Classification

  • One production behavior

Moved corpus row

Case Before After Truth Why
deco-decorator-wrapper-value limited (no_static_path) credited (exposed) discriminated memo wrapper now reaches Calc.square's exact toBe(16) / toBe(9) tests

No other row moves (373 cases, 0 false verdicts, 0 contradictions).

Not taken

The property-decorator setter rows (deco-property-*) stay abstained. The setter only runs if the class field does not shadow it, which depends on useDefineForClassFields and on the transpiler, so crediting it from syntax alone could credit tests that never reach the setter. See the #13657 comment.

Local evidence (head 4ace06b)


Generated by Claude Code

…'s cached value (#13657)

RIPR-SPEC-0243 rule 21 gains condition 2a: the memo idiom
`if (!cache.has(k)) cache.set(k, <flow>); return cache.get(k);` over a
decorator-local, argument-free `const cache = new Map()` named nowhere
else, keyed by one plain wrapper parameter. `get` can only return what
`set` computed for that key, so an edit to the `set` line reaches the
decorated method's result; that line is the observed one.

Prefilled, `let`, `WeakMap` and leaked caches, mismatched keys, `else`
branches, extra guard statements, combined returns and key-rebinding
call arguments keep the old `decorator_indirection` reading (unit tests
pin each). TypeScript corpus: deco-decorator-wrapper-value moves
limited -> credited (tests fail on the edit: 4*4+1 != 16); its
missed-credit entry is removed; 0 false verdicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLUiGE7tPe9UFd5gbYQ
@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 Nov 8, 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 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 152 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: c99f336a-8ce9-4e3a-b2cb-89e9a178eb12
Commits

Reviewing files that changed from the base of the PR and between f1a321f and 65f76c9.

Files selected for processing: 6

  • changelog.d/13657-typescript-memoizing-decorator-credit.md
  • crates/ripr/src/analysis/language/typescript/decorated_entries.rs
  • crates/ripr/src/analysis/language/typescript/decorated_entries_tests.rs
  • docs/specs/RIPR-SPEC-0243-typescript-oracle-and-reach-rules.md
  • fixtures/typescript-verdict-corpus/expected/rows/deco-decorator-wrapper-value.json
  • fixtures/typescript-verdict-corpus/missed-credit.toml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@EffortlessSteven EffortlessSteven self-assigned this Nov 8, 2026
…ecorator credit (#13657)

Refuse the memoizing-decorator credit when Map is named anywhere else in
the file (import, local class or binding, prototype patch), when the file
holds a \u escape, eval or Function, or when the cache.set statement
spans lines. Adds negative tests for each adversarial-review probe and
amends RIPR-SPEC-0243 rule 21 condition 2a.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLUiGE7tPe9UFd5gbYQ
…es and arguments (#13657)

A file that reaches the global object (globalThis, window, global, self,
Reflect), builds names from character codes or escapes (any backslash,
fromCharCode), writes a prototype, or uses arguments (a sloppy-mode alias
of the key) no longer admits the memoizing-decorator credit. Negative
tests pin each probe from the second adversarial review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLUiGE7tPe9UFd5gbYQ
…defaults and scripts (#13657)

Refuse the credit when a wrapper parameter has a default value (a closure
that can rebind the key), when the file is not an ES module, or when it
names constructor, __proto__ or the prototype/descriptor reflection
helpers. The spec now states the Map check is a best-effort screen, with
obfuscated built-in replacement outside the static model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLUiGE7tPe9UFd5gbYQ
…and plain parameters (#13657)

A set sharing the guard's or return's line is refused: an edit there such
as if (true) cache.set(..) disables the memo without changing any result.
Destructured and rest wrapper parameters are refused, since a nested
default can rebind the key. Adds a get(m) mismatched-key negative.

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

@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

Reviewed at 8510550: the full diff of memoized_flow, its tests, RIPR-SPEC-0243 rule 21 condition 2a, and the consumer decorated_return_changed in classifier.rs.

Four rounds of independent adversarial review raised holes, and each is now closed with a negative unit test:

  • Map rebound or patched in the file.
  • Escapes of any kind, eval or Function, constructor or prototype routes, and computed global writes.
  • A non-module file.
  • A sloppy arguments alias of the key.
  • Default, destructured or rest wrapper parameters that could rebind the key.
  • A multi-line set, and a set that shares the guard's line (where if (true) cache.set(..) would disable the memo without changing the result).

The spec now states that the global-Map check is a best-effort screen, and that deliberately obfuscated replacement of built-ins is outside the static model, as it already is for original.call in the pass-through rule.

Local proof on this head:

  • cargo test -p ripr --lib decorated_entries: 21 passed.
  • cargo xtask verdict-corpus check --language typescript: 373 cases, 0 false verdicts, 0 contradictions. deco-decorator-wrapper-value is ideal (exposed).
  • cargo xtask precommit: exit 0.

Hosted CI on this head has not reported yet.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review November 8, 2026 17:10
@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!

@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 1 potential issue.

Devin Review

@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

Reviewed at 8510550 (same head as the earlier pass). The bot thread on replaced methods was answered with source evidence and resolved. ts_observes_decorated_method_call already refuses instance and prototype replacement, spies, Object.assign and defineProperty for every decorated entry, and decorated_call_refuses_a_method_replaced_in_the_test pins those shapes. The earlier local proof stands: decorated_entries tests pass, the TypeScript verdict corpus shows 0 false verdicts, and precommit exits 0.


Generated by Claude Code

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

ripr static exposure check

Commit 65f76c92c2af · run · advisory, static evidence only (not a mutation run).

#ripr agent static-advisory base=f1a321f00eca794a41c6bfa7dea15b0b6566ba61 findings=119 gaps=8 infection_unknown=4 propagation_unknown=1 reachable_unrevealed=5 static_unknown=42 weakly_exposed=67
reachable_unrevealed|crates/ripr/src/analysis/language/typescript/decorated_entries.rs:428|let (set_cache, set_key) = map_call(&set_expression.expression, "set", 2)?;|missing=No exact error variant discriminator was detected|test=t1|id=probe:crates_ripr_src_analysis_language_typescript_decorated_entries.rs:error_path:591c3606
reachable_unrevealed|crates/ripr/src/analysis/language/typescript/decorated_entries.rs:469|Some(id.name.as_str())|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t1|id=probe:crates_ripr_src_analysis_language_typescript_decorated_entries.rs:return_value:a04f9ecb
reachable_unrevealed|crates/ripr/src/analysis/language/typescript/decorated_entries.rs:473|Some(1)|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t1|id=probe:crates_ripr_src_analysis_language_typescript_decorated_entries.rs:return_value:bba4f963
reachable_unrevealed|crates/ripr/src/analysis/language/typescript/decorated_entries.rs:524|(start == end && guard_line < start && start < return_line).then_some((start, en…|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t1|id=probe:crates_ripr_src_analysis_language_typescript_decorated_entries.rs:return_value:760aa227
weakly_exposed|crates/ripr/src/analysis/language/typescript/decorated_entries.rs:543|call.optional \|\| callee.optional \|\| callee.property.name != method|missing=Check unconfirmed: no supported assertion that distinguishes the changed behavio…|test=t2|id=probe:crates_ripr_src_analysis_language_typescript_decorated_entries.rs:predicate:124a1567
weakly_exposed|crates/ripr/src/analysis/language/typescript/decorated_entries.rs:546|call.arguments.len() != arity|missing=Check unconfirmed: no supported assertion that distinguishes the changed behavio…|test=t2|id=probe:crates_ripr_src_analysis_language_typescript_decorated_entries.rs:predicate:7c16aef5
t1=crates/ripr/src/analysis/language/typescript/decorated_entries_tests.rs:359 memoizing_decorator_records_the_cache_set_lines unknown miss=assertion_inert
t2=crates/ripr/tests/cli_smoke/typescript_constructor_callback.rs:122 eager_map_callback_keeps_the_module_initializer_advice relational_check `assert!(step.contains("expect(IMPORTED_CONST).toBe"), "{step}");` miss=weak_assertion
+2 more gaps not shown; `--format json` lists all
limits=infection_unknown:4,propagation_unknown:1,static_unknown:42,weakly_exposed:64
next=ripr explain --root . --base f1a321f00eca794a41c6bfa7dea15b0b6566ba61 --committed --mode draft --format agent probe:crates_ripr_src_analysis_language_typescript_decorated_entries.rs:error_path:591c3606
verify=refused|outcome=complete_with_findings|findings=119|exposed=0|reason=gaps_remain

Took 67s.

@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

Reviewed at 65f76c9. The only change since 8510550 is a merge of main. That merge brings in the CLI reference rebless from #13811, which fixes the stale docs/CLI_REFERENCE.md failure seen in the Rust-only feature lane. None of this PR's files changed in the merge.

Re-run on the merged tree:

  • cargo test -p ripr --test cli_reference_doc: 2 passed.
  • decorated_entries unit tests: pass.
  • TypeScript verdict corpus: 373 cases, 0 false verdicts, 0 contradictions.

The source review recorded on 8510550 still covers the memoizing decorator change.


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