Repository navigation
fix(typescript): credit an exact test of a memoizing method decorator's cached value (#13657) - #13792
Conversation
…'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
|
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 18 minutes. View limit details
|
…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
left a comment
There was a problem hiding this comment.
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:
Maprebound 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
argumentsalias of the key. - Default, destructured or rest wrapper parameters that could rebind the key.
- A multi-line
set, and asetthat shares the guard's line (whereif (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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
EffortlessSteven
left a comment
There was a problem hiding this comment.
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
ripr static exposure checkCommit Took 67s. |
EffortlessSteven
left a comment
There was a problem hiding this comment.
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
Requested by Steven Zimmerman · project thread
Summary
if (!cache.has(k)) cache.set(k, <flow>); return cache.get(k);lendsexposedto the decorated method's exact tests for an edit to thecache.setline. Two conditions apply: the cache is a decorator-local, argument-freeconst cache = new Map()named nowhere else, and the key is one plain wrapper parameter.setcomputed for that key. So every call returns<flow>for its key, whichever call populated it, and the edit reaches the method's result.decorator_indirectionreading: prefilled,let,WeakMapor leaked caches, mismatched keys, anelse, extra guard statements, combined returns, and call arguments that could rebind the key. The change is reversible, because deletingmemoized_flowrestores the old reading.Swarm / Source Boundary
ripr-swarmSource-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-valuefrom 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).deco-decorator-wrapper-valuere-blessed (limited -> credited; its tests fail on the edit, since4*4+1 != 16), and itsmissed-credit.tomlentry is removed, as the file requires.Scope Classification
Moved corpus row
deco-decorator-wrapper-valueno_static_path)exposed)Calc.square's exacttoBe(16)/toBe(9)testsNo 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 onuseDefineForClassFieldsand 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)
cargo test -p ripr --lib decorated_entries: 20 passed.cargo xtask verdict-corpus check --language typescript: 0/373 false verdicts, no drift after bless.cargo xtask public-proof --check: passes.cargo xtask precommit: exit 0.check-fixture-contractswas run with main's known-redmodule_reach_control_qualifiedSPEC line patched locally and not committed. That failure is on main and is fixed by open PRs fix(fixtures): declare module_reach_control_qualified return_value as exposed (#13771) #13773, fix(fixtures): declare module_reach_control_qualified's return-value finding exposed #13774 and fix(main): rebless CLI reference for repair/continue --json, plus fixture SPEC class line #13778.Generated by Claude Code