Skip to content

fix: report invalid pending capture times per sidecar - #1757

Merged
bcdonadio merged 1 commit into
mainfrom
fix/1737-sidecar-pending-min-invalid
Oct 25, 2026
Merged

bcdonadio merged 1 commit into
mainfrom
fix/1737-sidecar-pending-min-invalid

Conversation

@bcdonadio

Copy link
Copy Markdown
Contributor

Closes #1737

Why

The read-only sidecar scanner computed each sidecar's oldest pending capture time with a plain MIN(created_at) over unvalidated TEXT. When one sidecar held a valid pending row (2026-02-03 11:59:00) and an invalid one (not-a-timestamp, 2026-02-30 10:00:00, 2026-03-01 24:00:00), the lexicographic minimum returned the valid value, so runtime health reported an observed pending age and hid the invalid row. #1637 made the fold across sidecars sticky on invalid values, but never saw the invalid value inside a single sidecar.

How

  • src/db/event-sidecars.ts: oldestPendingAt is now COALESCE(MIN(created_at) FILTER (pending/retry AND NOT valid), MIN(created_at) FILTER (pending/retry)). An invalid pending or retry value is returned when one exists, so the existing Pending-age fold hides invalid sidecar timestamps #1637 fold and localPendingAgeRead report out-of-range; otherwise the valid minimum is returned as before. Validity is a shape GLOB, a created_at IS datetime(created_at) round trip (rejects impossible dates such as 02-30), and an hour guard (datetime keeps 24:00:00 unchanged). This agrees with sqliteUtcMs in src/storage/runtime-health.ts. Only the pending column changes.
  • Docs (docs/cli.md, postgresql-telemetry.md) now say the age is omitted when any pending or retry local event has an invalid capture time.
  • Changeset (patch) and codecov ownership fragment added.

Testing

  • test/db/events-stats.test.ts: each invalid value in a fresh sidecar next to a valid earlier row yields the invalid string and out-of-range; an invalid retry row counts; an invalid quarantined row is ignored.
  • The new cases fail on the base commit; the 24:00:00 case fails when only the hour guard is removed.
  • events-stats* and codecov-config tests, tsc --noEmit and eslint pass; src/db/event-sidecars.ts is at 100% across the sidecar test files.

Reviewer guide

Start with the SQL and VALID_CREATED_AT_SQL in src/db/event-sidecars.ts, then the new cases in test/db/events-stats.test.ts. oldestDeliveryAt and other counters are intentionally untouched.

The read-only sidecar scanner took MIN(created_at) over pending and
retry rows. created_at is unvalidated TEXT, so a valid timestamp
could win the lexicographic minimum and hide an invalid one in the
same sidecar; #1637 only made the fold across sidecars sticky.

Return an invalid pending or retry created_at when one exists,
otherwise the valid minimum. Validity is a shape GLOB, a datetime()
round trip, and an hour < 24 guard. The hour guard is needed because
datetime() leaves 24:00:00 unchanged. The result feeds the existing
out-of-range handling. oldestDeliveryAt and other counters are
unchanged.

Fixes #1737

Signed-off-by: Bernardo Donadio <bcdonadio@bcdonadio.com>
@bcdonadio bcdonadio self-assigned this Oct 25, 2026
@bcdonadio
bcdonadio enabled auto-merge October 25, 2026 06:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-10-25T06:44:22.479358Z 0e5912c PR opened
🔒 Security Review ✅ Completed 2026-10-25T06:45:28.140155Z 0e5912c 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.

@bcdonadio
bcdonadio merged commit 6082f12 into main Oct 25, 2026
23 checks passed
@bcdonadio
bcdonadio deleted the fix/1737-sidecar-pending-min-invalid branch October 25, 2026 06:48
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.

Single-sidecar pending-age MIN hides invalid created_at

1 participant