Skip to content

fix(dashboard): window the slop/duplicate trend read by time, not a 2-per-week row cap - #9803

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/slop-trend-window-9699
Jul 29, 2026
Merged

fix(dashboard): window the slop/duplicate trend read by time, not a 2-per-week row cap#9803
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/slop-trend-window-9699

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What & why

SLOP_DUPLICATE_TREND_SNAPSHOT_LIMIT was SLOP_DUPLICATE_TREND_WEEKS * 2 = 16, documented as "two per week of history". That premise is false: queue-health snapshots are written up to once per repo per generate-signal-snapshots run (several per day). So the 16-row cap kept only the most recent ~4 days, and the maintainer dashboard's 8-week slop/duplicate trend card was almost entirely empty — row_number() ranked the cap within the last few days and never surfaced the older weeks.

The fix

  • Add an optional sinceIso?: string to listRecentSignalSnapshotsForTargets, applied as AND generated_at >= ? inside the windowed subquery, so the ranking is computed over the time-bounded set rather than the whole table. Bound as the fourth-then-fifth SQL param so it precedes the outer snapshot_rank <= ? cap.
  • GET /v1/app/maintainer-dashboard passes an 8-week sinceIso derived from the request's generatedAt.
  • maxPerTarget stays a hard backstop, re-budgeted to WEEKS * 28 (clamped to the query's existing 100 ceiling) so the time bound — not the row cap — is the primary constraint.
  • Omitting sinceIso is byte-identical to today.

Tests

test/unit/data-spine.test.ts:

  • sinceIso drops out-of-window rows even with a generous cap, and ranks only the in-window set (fails on main).
  • Omitting sinceIso (undefined) returns the same rows as before.

test/unit/maintainer-slop-duplicate-trend.test.ts:

  • The read cap is at least min(WEEKS * 28, 100), not WEEKS * 2 (fails on main).
  • 40 daily snapshots spanning 8 weeks populate at least 6 distinct weekly buckets (previously ~1–2).

The route line is exercised by the existing /v1/app/maintainer-dashboard integration test.

Validation

  • npm run typecheck green; npm run ui:openapi:check clean (no schema change — sinceIso is an internal computed arg); the two touched unit suites green.
  • Diff coverage on all three changed src files is 100% line and branch (both sinceIso present/omitted arms).
  • git diff --check <base> HEAD clean; no migration change.

Closes #9699

…-per-week row cap

`SLOP_DUPLICATE_TREND_SNAPSHOT_LIMIT` was `WEEKS * 2 = 16` on the false premise
that queue-health snapshots are written twice a week. They are written up to once
per repo per generate-signal-snapshots run (several per day), so the row cap kept
only the most recent ~4 days and the 8-week trend card was almost entirely empty.

Add an optional `sinceIso` to `listRecentSignalSnapshotsForTargets`, applied as
`AND generated_at >= ?` INSIDE the windowed subquery so row_number() ranks over
the time-bounded set (not the whole table); the route passes an 8-week bound
derived from the request's generatedAt. `maxPerTarget` stays a hard backstop,
re-budgeted to WEEKS * 28 (clamped to the query's 100 ceiling). Omitting sinceIso
is byte-identical to today.

Closes JSONbored#9699
@shin-core
shin-core requested a review from JSONbored as a code owner July 29, 2026 10:18
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 29, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@loopover-orb

loopover-orb Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-29 10:33:18 UTC

5 files · 1 AI reviewer · no blockers · CI green · unstable

⏸️ Suggested Action - Manual Review

  • AI review did not produce public notes: The configured AI reviewer returned no usable public assessment for this PR head.

Review summary
AI review is unavailable for this PR head. LoopOver is holding this PR for manual review until the configured AI provider returns a usable public review summary.

Nits — 1 non-blocking
  • AI review did not produce public notes — Fix the configured AI provider, then re-run LoopOver review before relying on the result.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ⚠️ Gate result — Not blocking (Advisory; not blocking this PR.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #9699
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 60 registered-repo PR(s), 43 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor shin-core; Gittensor profile; 60 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The diff adds an optional sinceIso applied inside the windowed subquery, wires it from the route using an 8-week window derived from generatedAt, and rebudgets/re-documents SLOP_DUPLICATE_TREND_SNAPSHOT_LIMIT as a safety cap rather than a cadence assumption, matching all stated requirements. Tests cover both sinceIso present/omitted branches, the constant invariant, and a 40-snapshot regression te

Review context
  • Author: shin-core
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is registered but has no active allocation in the current snapshot.
  • Public profile languages: TypeScript, JavaScript, Solidity, Dart, Python, CSS, PHP, Rust
  • Official Gittensor activity: 60 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Await review-lane availability.
  • Then work through the remaining 1 step in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Decision record
  • action: hold · clause: ai_review_inconclusive
  • config: 818248433d3ddfbefb773d8f67294d39c400884f98061dddd90cd686e6bfab03 · pack: oss-anti-slop · ci: passed
  • record: da0565c939936e1d284507a877ea6d3d5efeba2d48f4b6a02cdfb0ca507b6aa4 (schema v5, head 10bf82c)

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.06%. Comparing base (ec8a1d3) to head (10bf82c).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #9803       +/-   ##
===========================================
- Coverage   90.33%   78.06%   -12.27%     
===========================================
  Files         918      286      -632     
  Lines      113943    64256    -49687     
  Branches    26979     9966    -17013     
===========================================
- Hits       102933    50164    -52769     
- Misses       9681    13669     +3988     
+ Partials     1329      423      -906     
Flag Coverage Δ
backend 96.22% <100.00%> (+0.64%) ⬆️

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

Files with missing lines Coverage Δ
src/api/routes.ts 95.60% <100.00%> (+<0.01%) ⬆️
src/db/repositories.ts 96.86% <100.00%> (+<0.01%) ⬆️
src/services/maintainer-slop-duplicate-trend.ts 100.00% <100.00%> (ø)

... and 766 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 29, 2026
@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 29, 2026
@JSONbored
JSONbored merged commit dde80af into JSONbored:main Jul 29, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

orb(dashboard): the 8-week slop/duplicate trend can only ever cover ~4 days of history

2 participants