Skip to content

fix(scoring): per-event output cap on scaled reward (cannot fill the scale in one insert) - #739

Draft
DealAppSeo wants to merge 1 commit into
mainfrom
feat/xc-2026-09-13-scaled-reward-cap
Draft

DealAppSeo wants to merge 1 commit into
mainfrom
feat/xc-2026-09-13-scaled-reward-cap

Conversation

@DealAppSeo

Copy link
Copy Markdown
Owner

Dispatch #64 P3 — XC drafted because no CC1 get_scaled_reward PR existed after one wakeup

Draft — do not merge. Did not flip REPID_RUN_EARN_GATE.

The hole

Live clamp is only clampEventDelta ±9990 — the full 10–10000 scale width. One poisoned factor / config-injected impact_factor_cap fills the scale in a single repid_score_events insert. Parallel events are unrate-limited. Earn-gate is SHADOW.

The SQL rpc get_scaled_reward (Args: never) is not this path: live POST /rest/v1/rpc/get_scaled_reward returns 9 [V 2026-09-14]. Scoring goes through calculateFullReward in agents-external.ts.

What this PR does

  • New capScaledReward / MAX_ABS_SCALED_REWARD = 50 in wisdom-normalize.ts — a code constant, not repid_config.
  • Applied at the score-event route before the earn-gate and before clampEventDelta.
  • Loud-log when tripped.

XC red-team (the tests)

Attack Result
count-floor (vdrCount=0) healthy path stays under the cap
config injection (impactCap=1e9 + exploding factors) formula exceeds 50; cap returns 50
race (two sequential 9990s) each capped independently; sum is 100 — remaining hole, not closed
non-finite 0, same posture as clampEventDelta

npx jest tests/wisdom-normalize.test.ts19/19.

Not this PR

Per-agent rate limit (the race hole). SQL CREATE OR REPLACE get_scaled_reward (no function body in-repo; live rpc is not the scoring path). Earn-gate enforce. Merging.

…scale in one insert)

clampEventDelta ±9990 is the int4/full-scale backstop — one event can still
walk 10–10000. Cap the formula output at ±50 (code constant, not
repid_config) so a poisoned impact_factor_cap, a zero count-floor, or a
factor explosion cannot fill the scale in a single score-event.

Does not close parallel-event summing (documented in tests). Does not flip
REPID_RUN_EARN_GATE. SQL get_scaled_reward rpc is not this path (measured
return 9, no args); live scoring is calculateFullReward at the route.

Draft, do not merge.

Co-authored-by: XC <xc@trustshell.dev>
DealAppSeo added a commit that referenced this pull request Sep 16, 2026
…checked; #743 flagged to Sean (#759)

- Verifies prior beat (PR #758, 19231d3): merged 2026-09-16T04:30:32Z — all claims hold
- #743 (HAL free-tier quorum fix, 98/98): needs Sean to mark ready + merge + recycle Railway
- #739 (scaled reward cap): SAFE-CLASS but Sean-flagged draft; needs clearance
- All 3 open PRs have explicit "Do not merge" — none auto-merged
- Item 7 (ANFIS staging) deferred to own dedicated beat; this beat stops here

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
DealAppSeo added a commit that referenced this pull request Sep 16, 2026
…staging confirmed complete (8/8 tests pass); no new code needed (#760)

Prior beat (#759) verified: same 3 draft PRs (#749/#743/#739) still DRAFT,
no Sean action. Item 7 ANFIS staging acceptance tests found to already exist
in tests/anfis-enablement.test.ts (305 lines, 8/8 pass) — prevented a
prior-work redo. All remaining Item 7 work is Sean-gated (flag flips + key mint).

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant