Skip to content

aggregator: freshness() ages date-only stamps by the UTC day, not Chicago — a read dated today reports '1d ago' (and stale) from 19:00 Chicago onward #1629

Closed

Description

@dezren39

Summary

freshness() in pm-stack/aggregator/src/derive.ts:852-868 ages date-only stamps by the UTC calendar day, while the same file's calendar helpers define "today" in America/Chicago (chicagoYmd, derive.ts:462-470, under the header "Calendar helpers (America/Chicago — Drew's timezone)"). The date-only branch (derive.ts:858-862) computes:

const startOfToday = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
const ageDays = Math.max(0, Math.round((startOfToday - t) / 86_400_000));
return { stale: ageDays > cadenceDays, ageDays };

Its own comment states the intended semantics: "a read dated yesterday is 1 day old all day today". But with the UTC day boundary, "today" flips at 19:00 Chicago (CDT) / 18:00 (CST) — so for the last 5–6 hours of every Chicago day, a read dated today (Chicago) already reports ageDays: 1, and a service whose cadence is tight flips to stale on the very day it was read. The rendered surfaces inherit it: freshnessStamp (render.ts:1651-1659, prints "· 1d ago" / the stale badge) and the SaaS service cards/detail (render.ts:1704, render.ts:1889).

Verified (this run, on main be7cf62)

Probe ON THE LAPTOP (Bun 1.4.2, driving the real derive.ts — sha256 312ac0fb… identical in both clones; probe + log in the goal's hidden_files/probe-2026-10-28-laneB-horizondate/probe3.ts + out3.log, output identical across runs):

now = 2026-10-28T01:30:00Z  (= 2026-10-27 20:30 Chicago)
chicagoYmd(now) = 2026-10-27                       (the file's own "today")
freshness('2026-10-27', 7, now) = { stale: false, ageDays: 1 }
    <- a read dated TODAY (Chicago) is already "1 day old"
freshness('2026-10-27', 0, now) = { stale: true,  ageDays: 1 }
    <- at cadence 0 it is STALE on the day it was read
now = 2026-10-28T06:30:00Z  (= 2026-10-28 01:30 Chicago)
chicagoYmd(now) = 2026-10-28
freshness('2026-10-27', 7, now) = { stale: false, ageDays: 1 }   (correct: yesterday)

So the same measuredAt is aged 0 for the first ~19 hours of its Chicago day and 1 for the remaining ~5 — the age (and any stale verdict at the boundary) depends on the time of day in a way neither the comment nor the file's Chicago convention intends. The datetime branch below it (derive.ts:864-867) ages by elapsed whole days and is unaffected; only date-only stamps (the hub's dated reads — quota-view / SaaS measuredAt dates) take the UTC-calendar branch.

Why it matters

Every hub card's freshness stamp and stale badge derives from this function. Date-only reads are the common case for the manually-read SaaS/quota services, and their cadences are in days: being aged a day early for a quarter of every day makes cards flicker to "1d ago"/stale each evening and back — noise on exactly the honesty surface (#1139/#1140 family) whose job is to state data age truthfully, and a false stale can mask (or train Drew to ignore) a genuinely stale source. It is also an internal inconsistency: two functions in one file disagree about what day it is.

Distinct from #1568/#1541/#1564 (future/garbage timestamps pinning freshness forever in freshness callers / quota-current / feed gates — those are missing upper-bound/parse checks; this one is a wrong day-boundary for perfectly valid, past, date-only stamps) and from #1587 (julesSummary HHMM key rollover).

Acceptance criteria

  • For a date-only measuredAt, ageDays is the number of whole America/Chicago calendar days between the stamp's date and today-in-Chicago: a stamp dated today (Chicago) reports ageDays: 0 at every hour of that day, and yesterday's stamp reports 1 all day.
  • A date-only read cannot flip to stale before its Chicago calendar age actually exceeds cadenceDays (boundary case pinned by a test at e.g. 20:30 Chicago on the stamp's own date, cadence 0).
  • Regression tests cover the evening-Chicago case (UTC date = Chicago date + 1) and the early-morning control, for both the age value and the stale verdict; the datetime branch's behaviour is unchanged.
  • Existing aggregator test suites still pass.

Activity

  1. developing-today commented on Oct 28, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    app/aggregatorPackage/app: aggregator (pm-stack in this repo)
    effort/sSmall: expected under 2 hours of work
    on Oct 28, 2026
  3. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (lane B, new-issue-creator-code-b)
    • Session / ID: new-issue-creator-code-b run 2026-10-28 03:50 CDT
    • Found via: filed this run
    • Task: Triage the freshness() date-only day-boundary defect: UTC start-of-day vs the file's America/Chicago calendar — a read dated today (Chicago) ages a day early each evening and can flip stale the day it was read.
    • Expectation: effort/s — done looks like date-only ages computed on the Chicago calendar, with the evening-boundary case pinned by tests.
    • Links: probe + log in the goal's hidden_files/probe-2026-10-28-laneB-horizondate/ (probe3.ts + out3.log; laptop, real derive.ts, sha256 312ac0fb identical both clones)
  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Oct 31, 2026
  5. 3 remaining items

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Oct 31, 2026
  7. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  8. added a commit that references this issue on Oct 31, 2026
  9. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · fixed and merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/aggregatorPackage/app: aggregator (pm-stack in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions