Skip to content

fix(retention): dedup the contributor-intelligence snapshot types — 2026-07 recurrence of #3810 - #8240

Merged
JSONbored merged 2 commits into
mainfrom
fix/signal-snapshot-flood
Jul 23, 2026
Merged

fix(retention): dedup the contributor-intelligence snapshot types — 2026-07 recurrence of #3810#8240
JSONbored merged 2 commits into
mainfrom
fix/signal-snapshot-flood

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

What

Production incident, found mid-#8170: the cloud D1 hit its absolute 10 GB maximumsignal_snapshots alone held 6 GB, generated in the last ~3 weeks.

Root cause

The contributor-intelligence writers (the scoring pass) append one ~36 KB row per contributor per pass for contributor-evidence-graph / contributor-outcome-history / contributor-strategy. At current review volume that's ~8k rows/day — the table refills D1's cap faster than the 90-day retention window can ever engage (only 299 rows were old enough to prune). This is a recurrence of #3810 with new offender types that postdate that incident's latest-only list.

Fix

  • The three types join LATEST_ONLY_SIGNAL_SNAPSHOT_TYPES, so the existing scheduled dedup keeps exactly one row per contributor. Lossless for every actual consumer: no reader consumes these as a series — the canonical latest lives in the dedicated contributor_evidence / contributor_scoring_profiles upsert tables, and nothing calls listSignalSnapshots for any contributor-* type. contributor-decision-pack stays excluded as the documented bounded trend series.
  • Regression test pins the new coverage and the decision-pack exclusion.
  • Production remediation ran alongside this PR using the incident playbook's chunked per-type manual dedup (results on the run log; frees ~5+ GB of pages and un-jams live writes + the calibration: backfill phase 2 — GitHub-truth reversed labels (retro successor scan) + raw-context re-fetch #8170 cloud apply).

Validation

Retention suite 19/19 green; root typecheck green. The changed function's behavior for previously-covered types is pinned by the existing tests.

Advances #3810 (recurrence)

…026-07 recurrence of #3810

signal_snapshots reached D1's absolute 10GB cap again, 61 days into this
database's life: the contributor-intelligence writers (the scoring pass in
processors.ts) append one ~36KB row per contributor per pass for
contributor-evidence-graph / contributor-outcome-history /
contributor-strategy — ~6GB in three weeks at current review volume,
refilling the cap before the 90-day age window could ever engage. Live
writes were one page-split from failing; the phase-2 label apply already
did.

No reader consumes these types as a series (the canonical latest lives in
the dedicated contributor_evidence / contributor_scoring_profiles upsert
tables; nothing calls listSignalSnapshots for contributor-*), so the
existing latest-only dedup job now covers them — lossless for every actual
consumer. contributor-decision-pack stays excluded as the bounded trend
series the retention doc records it to be. Production remediation (the
incident playbook's chunked per-type manual dedup) executed alongside.
@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 23, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.58%. Comparing base (c1e2ab2) to head (3395a9f).
⚠️ Report is 9 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8240      +/-   ##
==========================================
- Coverage   92.11%   91.58%   -0.53%     
==========================================
  Files         777      777              
  Lines       78364    78364              
  Branches    23677    23676       -1     
==========================================
- Hits        72183    71768     -415     
- Misses       5062     5524     +462     
+ Partials     1119     1072      -47     
Flag Coverage Δ
shard-1 56.81% <ø> (-0.69%) ⬇️
shard-2 51.23% <ø> (-0.58%) ⬇️
shard-3 52.60% <ø> (-0.60%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/db/retention.ts 96.49% <ø> (ø)

... and 3 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 23, 2026
…Y_SIGNAL_SNAPSHOT_TYPES

The pin hardcoded four placeholders; the list just grew to seven (the
#3810 recurrence fix) and will grow again — derive it so the guard can
never silently desync from the probe's real SQL.
@JSONbored
JSONbored merged commit 3b1d5ad into main Jul 23, 2026
11 checks passed
@JSONbored
JSONbored deleted the fix/signal-snapshot-flood branch July 23, 2026 14:24
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