FORGE-85: bind time cutoffs instead of interval SQL #703
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!703
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "FORGE-85-time-cutoffs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part 3 of FORGE-85 (D1 Phase 2, parent FORGE-69). Stacked on #701. No behaviour change.
msAgo/msFromNow+SECOND_MS…DAY_MSin@forgegraph/db(packages/db/src/time.ts). Cutoffs are computed in JS and compared with drizzle operators so the column mapping picks the stored form.now() - interval/make_interval/::intervalat 8 sites: fg/monitoring/logs, delivery-alert-sweep baseline window, registry/health, registry upgrade-reconcile, node-access-db lease (expiry and the expired-lease check now use one JS clock), registry upstream-tracker, latest-version-resolver.created_at + make_interval(timeout) < now()becomes one bound cutoff per distincttimeout_msvalue, matched against the joined type row (exactly equivalent; production has 3 timed types with 2 distinct values, read-only check).gt(column, date)./health, upstream-tracker) bind through the column encoder,sql.param(msAgo(…), table.column): postgres-js (fetch_types off) cannot serialise a raw Date once the server infers a timestamp parameter.registry-stale-cutoff.database.test.tscovers it and fails with a raw Date.monitorUpstreamDependenciesrunsSELECT DISTINCT … ORDER BY latest_checked_at, which Postgres rejects because the ORDER BY column is not selected, so the monitor errors on every call.INTERVAL n MINUTEqueries (not our DB).Verification
packages/db/src/time.test.ts(3) andapps/web/src/lib/__tests__/time-cutoffs.database.test.ts(3): attestation sweep with per-type timeouts at ms offsets, logs window, Date cursor strictly-after at 1 ms. Green on PGlite and Postgres 16.🤖 Generated with Claude Code
134f3fba86e2794bc3e8e2794bc3e83599cd0939Preview environment is live: https://pr-703-forgegraph.forgegraf.com
Deployed
3599cd09with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.Preview environment is live: https://pr-703-forgegraph.forgegraf.com
Deployed
3599cd09with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.Preview environment is live: https://pr-703-forgegraph.forgegraf.com
Deployed
3599cd09with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.Preview environment is live: https://pr-703-forgegraph.forgegraf.com
Deployed
3599cd09with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.3599cd0939cec284a054