Skip to main content
← Back to list
01Issue
FeatureOpenSwamp CLI
AssigneesNone

Relationships

#855 Epic #847 · Unit 3: Migrate the 5 recompute contributions to per-event grants; delete the recompute path

Opened by keeb · 6/27/2026

Part of epic #847. Unit 3 of 6. Prerequisite: #854 (ledger write-model + grant()).

Problem

lib/app/refresh-user-score.ts:35-141 rebuilds all five recompute buckets from current cumulative counts every batch and overwrites them — the non-monotonic core. Per scoring/scoring.md → "Recompute audit", all five must become per-event grants:

Contribution Overwrite site Grant per…
telemetry:activity refresh-user-score.ts:89,203 cli_invocation event
content:extension-pulls refresh-user-score.ts:95,209 extension_pulled event
content:extension-publishes refresh-user-score.ts:101,215 published version
community:lab-issues refresh-user-score.ts:107,221 issue_created event
community:daily-sign-in refresh-user-score.ts:114 daily_sign_in (streak at grant time)

Scope

  1. Emit a grant for each of the five events, keyed by originating entity, valued at grant time.
  2. Remove each from the refreshUserScoreFromMetrics / refreshUserScoreFromApi overwrite loop.
  3. Once all five are migrated, delete the recompute path: the overwrite block, the *-score.ts count functions, the ActivitySnapshot round trip, and the singleton-bucket semantics of contribute().
  4. Caps frozen (epic decision): preserve the current pull cap (500) and publish cap (5,000) exactly. #763 removed them and #764 reverted; caps-removal is a SEPARATE balance decision, explicitly OUT of scope here so the parity test below stays clean.

Acceptance

  • No code path recomputes a total from current counts (enforce with a CI grep assertion).
  • A replay of historical events → grants reproduces each user's existing total (parity), caps included.
  • The Mongo running balance is the authoritative scoring total.

Tests

  • tests/domain/ + tests/app/ — per-contribution grant emission (incl. sign-in streak-at-grant-time, capped pulls/publishes).
  • tests/integration/ — backfill/replay parity: legacy recompute total vs ledger balance.

Files

  • lib/app/refresh-user-score.ts (delete recompute path)
  • lib/domain/scoring/*-score.ts (activity / extension / issue / sign-in)
  • grant-emission wiring in the telemetry/score event handlers
02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

6/27/2026, 3:33:53 AM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.