⚠️ 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 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
Context
#3810 was a production incident where
signal_snapshotshit 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 addedLATEST_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, andpr-reviewabilityare ALL written unconditionally every run (src/db/repositories.ts:5434-5444'spersistSignalSnapshotis a plainINSERT, no upsert; writers atsrc/queue/signal-snapshot.ts:156-235andsrc/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 (unlikequeue-health, which genuinely feedsbuildQueueTrendReportand is correctly excluded from the dedup list).Requirements
Add these 8 signal types to
LATEST_ONLY_SIGNAL_SNAPSHOT_TYPESinsrc/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 existingdedupeSignalSnapshotstest harness that a repo with N stale rows for each type collapses to 1.Deliverables
LATEST_ONLY_SIGNAL_SNAPSHOT_TYPESdedupeSignalSnapshotsharness) confirming each of the 8 types correctly collapses stale rows to 1 per repoAll 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-121src/db/repositories.ts:5434-5444src/queue/signal-snapshot.ts:156-235src/api/routes.ts:3459,5763src/services/issue-quality.ts:13,47src/services/repo-outcome-patterns.ts:29,64src/mcp/server.ts:3667