Skip to content

fix(db): seven signal_snapshots types are latest-only-consumed but missing from LATEST_ONLY_SIGNAL_SNAPSHOT_TYPES #8900

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

Context

#3810 was a production incident where signal_snapshots hit D1's size cap because several signal types were inserted as a fresh row every run with no reader ever consuming more than the latest one; the fix added LATEST_ONLY_SIGNAL_SNAPSHOT_TYPES (src/db/retention.ts:105-121), later extended for 3 contributor-* types. Applying that exact test today -- "no reader consumes them as a series" -- to the current codebase: config-quality, label-audit, maintainer-lane, maintainer-cut-readiness, contributor-intake-health, issue-quality, repo-outcome-patterns, and pr-reviewability are ALL written unconditionally every run (src/db/repositories.ts:5434-5444's persistSignalSnapshot is a plain INSERT, no upsert; writers at src/queue/signal-snapshot.ts:156-235 and src/api/routes.ts:3459) and every single consumer (src/api/routes.ts:5763, src/services/issue-quality.ts:13,47, src/services/repo-outcome-patterns.ts:29,64, src/mcp/server.ts:3667) reads only index [0] -- none are treated as a trend series (unlike queue-health, which genuinely feeds buildQueueTrendReport and is correctly excluded from the dedup list).

Requirements

Add these 8 signal types to LATEST_ONLY_SIGNAL_SNAPSHOT_TYPES in src/db/retention.ts: config-quality, label-audit, maintainer-lane, maintainer-cut-readiness, contributor-intake-health, issue-quality, repo-outcome-patterns, pr-reviewability. Verify via the existing dedupeSignalSnapshots test harness that a repo with N stale rows for each type collapses to 1.

Deliverables

  • All 8 signal types listed above are added to LATEST_ONLY_SIGNAL_SNAPSHOT_TYPES
  • A test (extending the existing dedupeSignalSnapshots harness) confirming each of the 8 types correctly collapses stale rows to 1 per repo

All of the above Deliverables are required in the same PR unless the deliverable text itself states otherwise.

Test Coverage Requirements

src/** -- 99%+ patch coverage, branch-counted, on the extended dedup list and its test.

Expected Outcome

These 8 signal-snapshot types no longer accumulate unbounded rows with each run, closing a recurrence of the #3810 incident class before it hits the D1 size cap again.

Links & Resources

  • src/db/retention.ts:105-121
  • src/db/repositories.ts:5434-5444
  • src/queue/signal-snapshot.ts:156-235
  • src/api/routes.ts:3459,5763
  • src/services/issue-quality.ts:13,47
  • src/services/repo-outcome-patterns.ts:29,64
  • src/mcp/server.ts:3667

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions