Check whether a ranking engine ignores payout
check_payout_invarianceCheck whether a ranking engine's output order changes when payouts or commissions change. Run mutation scenarios or scan source for payout references to catch bias.
Instructions
Checks -- for the specific scenarios you supply, not a formal proof for every possible payout configuration -- whether a ranking/recommendation/comparison engine's output ordering changes depending on which option pays the operator more (affiliate commission, sponsored placement, referral fee). Two modes: runtime re-runs your actual ranking function under adversarial payout-mutation scenarios you name and confirms the result is byte-identical to the unmutated baseline (pass JS source for the ranking function and each mutation -- this runs in a worker thread with a bounded timeout, not a sandbox, so only pass code you wrote or trust; a scenario whose mutation didn't actually change the input is flagged 'vacuous' rather than silently counting as a pass). static-imports instead greps a set of source files for any reference to payout-related identifiers, to assert the ranking engine's code never even has payout data in scope -- no code execution needed for this mode, and it's a best-effort text/regex grep, not a real parser (it won't catch a dynamically-built import specifier or a re-export under an aliased name). Use runtime when you can call the ranking function directly; use static-imports as a cheaper, complementary check on the engine's source. A passing result means no difference in the scenarios tested, not that the function is payout-neutral in general -- write adversarial and boundary scenarios, not one easy case, and re-run this in CI whenever the ranking logic changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | Which check to run. | |
| files | No | [static-imports mode, required] Source files to scan for payout references. | |
| baseInput | No | [runtime mode, required] The baseline input to rankFn -- e.g. an array of candidate objects each carrying a payout/commission field. | |
| mutations | No | [runtime mode, required, non-empty] Named adversarial payout-mutation scenarios. | |
| rankFnSource | No | [runtime mode, required] JS source for a pure ranking function `(input) => result`, e.g. "(candidates) => candidates.slice().sort((a, b) => b.score - a.score)". Built and run in a worker thread with a bounded timeout (default 10s, see README). | |
| stripComments | No | [static-imports mode] Strip comments before matching, so a mention in a comment doesn't count. Default true. | |
| payoutIdentifiers | No | [static-imports mode, required, non-empty] Identifiers that must never appear in the ranking engine's source, e.g. "commission", "payout", "affiliateRate". | |
| caseInsensitiveMatch | No | [static-imports mode] Case-insensitive identifier matching. Default true. |