Skip to content

refactor(sync): share one subscription renew window across sweep, operation, and health - #5217

Merged
tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-rtcum1
Nov 11, 2026
Merged

tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-rtcum1

Conversation

@tyler-dane

Copy link
Copy Markdown
Contributor

What and why

Tech-debt sweep of the 9 merges that landed after the 2026-11-10 sweep (#5209 to #5216 plus #5177). One finding.

The push-channel renew window was stated three times as 24h and enforced nowhere. Each copy's comment claimed it matched the others, but nothing made it so:

Site Role
subscription-maintenance.service.ts DEFAULT_RENEW_BEFORE_MS the decision: maintainSubscription reports "current" and touches nothing when a channel has more than this much life left
app.ts SUBSCRIPTION_RENEW_BEFORE_MS the sweep's windowMs: which resources get a subscriptionMaintain job enqueued
health-snapshot.service.ts HEALTH_SUBSCRIPTION_RENEW_BEFORE_MS the metric: which channels count as renewSoon

No production code overrides options.renewBeforeMs, so in production all three were the same number purely by hand-copy. The divergence is silent in both directions:

  • Raise the maintenance guard alone, which the constant's own comment says must happen in step with the Google adapter's 48h channel TTL, and the sweep keeps enqueueing only the old 24h set. The renewal cadence that comment calls "the point, not a side effect" quietly shrinks back relative to the TTL, which is exactly the window bounding how long a channel can stay silently dead.
  • Change the sweep window alone and it either enqueues jobs the operation immediately reports "current" for, or stops enqueueing channels the operation would have renewed.
  • Either way renewSoon stops describing the set the sweep acts on, so the health dashboard misreports renewal pressure.

Nothing catches it: each site's tests assert against its own copy, so all three suites stay green after a divergence.

Fix: export the owning constant and read it at all three sites. This matches the sibling DEFAULT_PUSH_STAMP_HEAL_COOLDOWN_MS, which app.ts already imports from the same module for the adjacent pushStampHeal sweep row, one entry below the row that was hardcoding its copy. Value unchanged at 24h, so behavior is identical and the import is now the thing that keeps them in step.

Also records this sweep's judgments in .agents/skills/tech-debt-sweep/judged-fine.md, including the areas examined and deliberately left alone so the next sweep does not redo them:

Verify

bun run verify --strict

Selected packages: sync
Checks run: type-check, lint, knip
Failed: test:sync
VERDICT: FAIL

PRE-EXISTING (environmental, not reachable by this diff): test:sync's Mongo tier cannot start in this sandbox. mongodb-memory-server fails to allocate a port (error: Failed to listen at :: from getFreePort, then SyncMongoService is not connected). Baselined by hand because verify only auto-baselines test:web, test:a11y and test:e2e: with the working tree reset to origin/main (0b2f185, zero modified files), bun test packages/sync/src/telemetry/health-snapshot.service.db.test.ts fails identically at 0 pass / 2 fail, the same as on this branch. No compass.yaml and no mongod in this environment.

FLAKY: none.

Green locally on everything that can run here:

  • bun test:sync:fast (the non-Mongo tier, which covers the changed sweep wiring): 933 pass, 8 skip, 0 fail across 97 files
  • bun type-check, bun lint (all rules), bun knip (no unused files or exports, including after the export moved)

CI decides the Mongo tier.


Generated by Claude Code

…ration, and health

The renew guard was stated three times at 24h and enforced nowhere:
DEFAULT_RENEW_BEFORE_MS in subscription-maintenance.service.ts decides
whether maintainSubscription renews a channel, SUBSCRIPTION_RENEW_BEFORE_MS
in app.ts selects which channels the subscription sweep enqueues, and
HEALTH_SUBSCRIPTION_RENEW_BEFORE_MS in health-snapshot.service.ts counts
renewSoon. Each comment claimed it matched the others; nothing made it so,
and each site's tests assert against its own copy, so a divergence stays
green.

Export the owning constant and read it at all three sites, matching the
sibling DEFAULT_PUSH_STAMP_HEAL_COOLDOWN_MS, which the adjacent sweep row
already imports from the same module. Value unchanged at 24h, so behavior
is identical.

Also record this sweep's judgments in the tech-debt ledger.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQE9vu35agjjdcadkf6
@tyler-dane
tyler-dane enabled auto-merge November 11, 2026 11:15
@tyler-dane
tyler-dane added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 824e713 Nov 11, 2026
30 checks passed
@tyler-dane
tyler-dane deleted the claude/kind-dirac-rtcum1 branch November 11, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants