koala73 / koala73/worldmonitor

chore(seeders): widen supply-chain-trade TTL gap-buffer (needs health maxStaleMin co-pin) — follow-up to #4864

Open
#4,873 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
86.6k
Forks
13.1k
Avg merge
8h 4m
Merged PRs (30d)
825

Description

## Context

Follow-up from #4864 / PR #4871. That PR fixed the fetch-phase deadline trips and made supply-chain-trade's data loss **recoverable** (the lockTtlMs bump restores republishing, so an expired canonical key is recreated on the next good run). But it **deliberately left `SHIPPING_TTL` / `TRADE_TTL` / `TARIFF_TTL` at 8h** rather than widening them for extra gap-buffer.

## Why it was deferred

Over a 6h cron, an 8h TTL only buffers ~1 missed cycle. A sustained gap (skipped Railway ticks, a deploy window, or a Redis error in the graceful `extendExistingTtl`) longer than 8h still drops the key. Widening to ~24h would give ~3 cycles of buffer — but the TTLs are **co-pinned to health-check `maxStaleMin` values**:

- `tests/trade-policy-tariffs.test.mjs` pins `TARIFF_TTL` = 28800 and enforces `tariffTrendsUs.maxStaleMin ∈ [TARIFF_TTL_min, TARIFF_TTL_min + 120]` — a regression-lock for the 2026-04-27 "silent EMPTY window" (data key expired but seed-meta still fresh → health reports EMPTY with no STALE_SEED, UptimeRobot keyword still green).

Raising a data-key TTL **without moving its health `maxStaleMin` in lockstep** reopens that window (or fires a false STALE). So this needs a coordinated change, not a one-line TTL bump.

## Task

For each of `SHIPPING_TTL`, `TRADE_TTL`, `TARIFF_TTL` in `scripts/seed-supply-chain-trade.mjs`:
1. Decide the target buffer (e.g. 24h = ~3 missed 6h cycles).
2. Find every health-check `maxStaleMin` co-pinned to that key and raise it in lockstep (`maxStaleMin ≈ TTL_min + grace`).
3. Update `tests/trade-policy-tariffs.test.mjs` and any sibling health tests together.
4. Confirm no silent-EMPTY / false-STALE window (consult the `health-seed-meta-gotchas` skill).

Low urgency — the #4871 budget fix already restores republishing (data loss is now recoverable, not permanent). This is defense-in-depth against multi-cycle gaps.

Contributor guide

Open the contributing guide

Research direction

Start in scripts/seed-supply-chain-trade.mjs and trace the health checks co-pinned to SHIPPING_TTL, TRADE_TTL, and TARIFF_TTL. Read tests/trade-policy-tariffs.test.mjs, sibling health tests, and the health-seed-meta-gotchas skill before choosing the target buffer. Done means the TTLs, maxStaleMin values, and regression tests agree without silent-EMPTY or false-STALE windows.

Written by the indexing model from the issue text.

Assessment

Tech stack
redis, typescript
Domain
backend, observability, testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.