Skip to content

fix(settings): stop normalizeOpenItemCap's cap leaking into unrelated fields - #3994

Merged
JSONbored merged 1 commit into
mainfrom
fix/normalize-open-item-cap-collateral
Jul 7, 2026
Merged

fix(settings): stop normalizeOpenItemCap's cap leaking into unrelated fields#3994
JSONbored merged 1 commit into
mainfrom
fix/normalize-open-item-cap-collateral

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • PR fix(settings): bound contributor open caps #3977 correctly clamped normalizeOpenItemCap to MAX_CONTRIBUTOR_OPEN_ITEM_CAP (100) for contributorOpenPrCap/contributorOpenIssueCap, since live enforcement only ever samples a fixed 100-row budget.
  • That function is also reused by three unrelated settings purely for its "positive integer or null" validation, and they silently inherited the same 100 ceiling:
    • normalizeModerationDecayDays (violation-decay days, intended ceiling MAX_MODERATION_VIOLATION_DECAY_DAYS = 3650) — double-clamped down to 100 first, so its own ceiling was never reachable. Caught by 3 already-failing assertions in test/unit/moderation-config-db.test.ts (e.g. expected 100 to be 3650).
    • requireFreshRebaseWindowMinutes and accountAgeThresholdDays — silently capped at 100 (minutes / days respectively) with no existing test exercising a value above 100, so this was live but latent.
  • Extracts the shared "positive integer or null" validation into normalizePositiveIntOrNull (no cap). normalizeOpenItemCap and normalizeModerationDecayDays each apply their own, unrelated ceiling on top of it; the other two fields use the uncapped helper directly.

Scope

  • src/db/repositories.ts (the shared helper + its 5 call sites) and test/unit/data-spine.test.ts (new regression coverage for the 2 latent fields).

Validation

  • npx tsc --noEmit — clean.
  • npx vitest run test/unit/data-spine.test.ts test/unit/moderation-config-db.test.ts — 35/35 pass (the 3 previously-failing moderation assertions now pass without being touched).
  • Scoped coverage on every changed line range in src/db/repositories.ts: 100%.

Safety

  • No secrets/wallets/hotkeys/trust-scores/reward-values touched.
  • No changelog edit; no site//CNAME/lovable changes.

… fields

normalizeOpenItemCap gained a 100-row clamp for contributorOpenPrCap/
contributorOpenIssueCap, but three unrelated callers reused it purely for
its "positive integer or null" validation and silently inherited the same
100 ceiling: requireFreshRebaseWindowMinutes and accountAgeThresholdDays
(latent -- no existing test exercised a value above 100), and
normalizeModerationDecayDays, which was double-clamped down from its own
intended 3650-day ceiling (caught by 3 already-failing tests in
moderation-config-db.test.ts). Extracts the shared validation into
normalizePositiveIntOrNull with no cap, and has normalizeOpenItemCap and
normalizeModerationDecayDays each apply their own, unrelated ceiling on
top of it.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 7, 2026
@JSONbored
JSONbored merged commit c585c41 into main Jul 7, 2026
4 checks passed
@JSONbored
JSONbored deleted the fix/normalize-open-item-cap-collateral branch July 7, 2026 09:32
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 7, 2026
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
11138 1 11137 7
View the full list of 1 ❄️ flaky test(s)
test/unit/queue.test.ts > queue processors > a #1960 action-command verb with no dispatch handler wired yet (e.g. pause) is bailed out of the Q&A answer-card path, not misrendered as help (#2160)

Flake rate in main: 100.00% (Passed 0 times, Failed 1 times)

Stack Traces | 0.872s run time
AssertionError: expected 1 to be +0 // Object.is equality

- Expected
+ Received

- 0
+ 1

 ❯ test/unit/queue.test.ts:22807:28

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant