Skip to content

fix(health): add finite stale-content grace - #7577

Merged
koala73 merged 9 commits into
mainfrom
codex2/fix-stale-content-grace
Sep 3, 2026
Merged

fix(health): add finite stale-content grace#7577
koala73 merged 9 commits into
mainfrom
codex2/fix-stale-content-grace

Conversation

@koala73

@koala73 koala73 commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

STALE_CONTENT no longer makes production health non-healthy at the exact content-freshness boundary. The diagnostic stays visible for a fixed three-hour grace period, with staleContentGraceUntil showing the deadline. At and after that deadline, the existing warning behavior applies without a new public status.

Timestamped content derives its deadline from the observed content boundary. Content with no usable timestamp claims one Redis deadline with HSETNX, so repeated fresh seeder metadata cannot renew the grace. Redis errors fail closed and keep the warning.

Content evidence Grace deadline
Usable newestItemAt newestItemAt + maxContentAgeMin + 3 hours
Missing newestItemAt First observed stale evaluation + 3 hours, persisted once

Implementation plan

Type of change

  • Bug fix
  • Documentation

Affected areas

  • API endpoints (/api/*)
  • Other: scheduled seed-freshness monitor and health documentation

Validation

The pre-change production response at 2026-09-03T02:49:35.461Z showed WARNING, warn: 2, and staleContent: 2. diseaseOutbreaks had fresh seeder metadata and content 170 minutes beyond its nine-day budget. temporalAnomalies had four-minute seeder metadata and contentAgeMin: null.

Proof-first tests failed in six health assertions before the API implementation. The documentation contract and scheduled monitor tests also failed before their consumers were aligned.

  • Focused health and cache tests: 46 passed, 0 failed
  • Documentation contract tests: 36 passed, 0 failed
  • Scheduled monitor tests: 43 passed, 0 failed
  • npm run typecheck:api: passed
  • npm run lint:boundaries: passed
  • npm run docs:check: passed
  • npm run test:data: 29,487 passed, 0 failed, 35 skipped
  • git diff --check: passed

Post-deploy monitoring and validation

  1. Check https://worldmonitor.app/api/health?compact=1 after deployment and through the next health sweep.
  2. During active grace, expect each affected source to remain in problems as STALE_CONTENT, include a future staleContentGraceUntil, increment staleContent, and not increment warn.
  3. For missing timestamps, confirm that repeated fresh seed metadata does not move the published deadline.
  4. At and after the deadline, confirm that the entry increments warn and can make the top-level status WARNING.
  5. Check the scheduled seed-freshness workflow and [health] logs. It must ignore only active, parseable deadlines of at most three hours.

Failure signals are a moving missing-timestamp deadline, grace longer than three hours, a monitor warning before the deadline, or no warning at and after expiry. Roll back the deployment if any signal occurs. The versioned Redis hash is safe to leave in place after rollback.

The timestamp-based disease-outbreak grace was already about 170 minutes old at reproduction time, so it can be expired by deployment. The temporal-anomaly grace starts on its first production health evaluation after deployment. Production acceptance remains unproved until this PR is merged and deployed.

Checklist

  • Tested on the deployed worldmonitor.app variant after this change
  • No API keys or secrets committed
  • API type checking completed without errors (npm run typecheck:api)
  • Existing health statuses and activation contracts remain unchanged

Documentation alignment

  • Claim ledger: N/A. The implementation plan and proof-first tests define the changed API claim.
  • Audit Council signoffs: N/A. No generated methodology or data claim changed.
  • Generated docs: N/A. No proto or generated client changed.
  • Fixture-backed examples: N/A. No fixture-backed example changed.
  • Redis writers and readers: api/health.js is the only writer and reader of health:stale-content-grace:v1; the monitor consumes only the public deadline.

Compound Engineering
Codex

@mintlify

mintlify Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
WorldMonitor 🟢 Ready View Preview Sep 3, 2026, 3:25 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
worldmonitor Ready Ready Preview Sep 3, 2026 7:24am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T03:26:52.469566Z 6277901 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6277901ad3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/health.js Outdated
Extend stale-content grace to per-entity checks and keep count-driven grace on one stable Redis deadline.
Review of #7577 found the grace was not finite for two reachable source
classes, and that its production wiring had no end-to-end coverage.

The deadline was re-derived from the live observation on every sweep. A feed
that keeps publishing while staying just past its budget therefore advanced
its own deadline forever and could never reach the warning bucket, and a
source that changed which evidence shape applied was granted a second window
without ever recovering. Both alarms were silent for the whole time, since the
scheduled monitor's ceiling was satisfied too.

Redis is now the single source of truth for the deadline in both modes. Every
graced source claims one anchor with HSETNX and republishes that stored value,
so the window cannot slide or be re-granted. The claim runs after
classification and is gated on the status a key actually received, so a
higher-precedence failure (REDIS_PARTIAL, EMPTY, STALE_SEED) can no longer
burn the source's single anchor while publishing no grace at all.

Also from the review:

- Split the grace pipeline by urgency. Only the claim decides what the
  response publishes; the recovery cleanup now goes through ctx.waitUntil
  instead of adding a round trip to nearly every sweep.
- Give the grace hash a refreshed TTL so retired registry names and
  per-deploy preview keys reap themselves.
- Drop the seedMetaByName precompute, which was provably identical to the
  fallback it bypassed.
- Collapse the three copy-pasted deadline branches into one declared table.
- Restore the #3845 provenance comments and document why the window is
  source-agnostic.
- Re-bound the docs gate on staleContent (<= ok + warn, still true) instead
  of dropping the check.
- Give the monitor ceiling explicit clock-skew slack, and keep graced entries
  visible in its report rather than filtering them into silence.

Tests: the helpers were the only thing covered, so the wiring could have been
deleted green. Adds handleHealth-level coverage for the claim, the
fail-closed path, and the cached-snapshot guard.
@koala73
koala73 merged commit d771b51 into main Sep 3, 2026
51 of 53 checks passed
@koala73
koala73 deleted the codex2/fix-stale-content-grace branch September 3, 2026 09:28
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.

1 participant