Repository navigation
fix(aggregator): effortWeight ignores prototype-chain members (#2734) - #2884
Conversation
EFFORT_WEIGHTS is a plain object literal, so effort/constructor and effort/__proto__ resolved as weights and string-poisoned weighted summaries. Guard the lookup with Object.hasOwn; such items are now unsized. Regression tests added.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 37 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Fixes #2734.
Problem
effortWeight(pm-stack/aggregator/src/weights.ts) looked upEFFORT_WEIGHTS[size]on a plain object literal with only aw !== undefinedcheck, so prototype-chain members resolved as weights:effort/constructorreturned theObjectconstructor function,effort/__proto__returnedObject.prototype— andsummarizeWeightsthen string-poisonedtotalWeight/closedWeightvia+=coercion.Fix
One-line guard: the lookup now requires an own key (
Object.hasOwn), so anyeffort/*suffix outsidexs/s/m/lis unsized.EFFORT_WEIGHTSis referenced only insideweights.ts, so the guard is contained; values, first-recognised-wins, and the unsized contract are untouched.Tests
test/weights.test.ts:effort/constructor,effort/__proto__,effort/hasOwnProperty,effort/toStringall unsized;summarizeWeightsover prototype-labelled items yields numeric totals, correct unsized counts, and aweightedLinewith no function/object source.bun test test/weights.test.ts: 11 pass, 0 fail (negative control: the 2 new tests fail on unfixed code).origin/mainb5d334b0, pre-existing and unrelated; zero weights failures.🤖 Agent note: queue task 4095 (repo-worker-code, openchamber scheduled lane).
Need help on this PR? Tag
@codesmith-botwith what you need.