Audit — R93 B6 stake_discount_bps Rename
Round: R93 debug-sweep (fix #6 of 6, XS)
Branch: feature/r93-b6-reputation-field-rename
Base SHA: fbc8808a
β task: 2e8978e9-e83d-4c3a-a20a-bf66cacc9251
§1. Goal
Rename the stake_discount_bps output field of reputation_check_gates to effective_stake_bps. The current name is misleading — it sounds like a percent discount but is in fact the effective stake amount in BPS-multiplied form.
§2. The misleading semantics
src/domains/reputation/limits.ts:172-180 defines stake_discount(required_stake, rep_execution):
stake_discount = safe_div(safe_mul(stake, BPS_100_PERCENT), max(score, 1000n))
For an unknown node with score=0 and the canonical input stake=BPS_100_PERCENT=10000, the result is 100000 — which the tool surfaces as stake_discount_bps: 100000. The docstring on the tool says this is “10× stake required”. The field name implies “1000% discount”. Those mean opposite things.
Per the live MCP probe in the R93 debug audit:
mcp__colibri__reputation_check_gates {node_id:"unknown", current_epoch:0}
→ {can_arbitrate:false, can_govern:false, max_parallel_tasks:0,
rate_limit_bonus_factor:0, stake_discount_bps:100000}
A consumer reading this naïvely sees “1000% stake discount, free entry!” — the opposite of the actual meaning.
§3. Scope of the rename
rg stake_discount_bps E:\AMS returns 5 files:
| File | Occurrences |
|---|---|
src/domains/reputation/tools.ts |
output type (§C); handler return (§G); docstring example (§G); MCP tool description string |
src/__tests__/domains/reputation/tools.test.ts |
tests asserting on the field |
docs/contracts/p2-5-1-tools-contract.md |
heritage P2.5.1 contract doc — describes the field shape that shipped |
docs/audits/p2-5-1-tools-audit.md |
heritage P2.5.1 audit doc |
docs/guides/implementation/task-prompts/p2.1-lambda-reputation.md |
source prompt for the work |
Notable absent: docs/3-world/social/reputation.md and docs/spec/s04-reputation.md do not reference the field by name — they document the formula, not the wire shape. The underlying stake_discount(...) function name (src/domains/reputation/limits.ts:172) describes the formula and stays unchanged.
§4. Constraints
- MUST NOT rename the underlying
stake_discount(...)function — its name describes the formula and is referenced from spec docs (docs/spec/s04-reputation.md §Derived limits row 4describes the formula by that name). - MUST update every
stake_discount_bpsfield-name reference (tool wire shape) toeffective_stake_bps. - MUST update tests that assert on the field name.
- MAY update heritage docs (p2-5-1-tools-*) to reflect the new wire shape; the original audit/contract/packet chain stays intact as historical, but the field-name reference is brought in line with what’s actually emitted today.
- The MCP tool description string in
tools.ts:436references the field by name — update.
§5. Path forward
Six replace_all operations on the literal stake_discount_bps → effective_stake_bps across the 5 files. Update the docstring example block in tools.ts:330-334 to use the new name. Update the docstring rationale paragraph to make clear this is the effective stake, not a discount factor.
Proceeding to contract + packet (compact for XS scope).