Skip to content

scripts/publish-dashboard.sh takes no --now, so every windowed digest test is coupled to the real clock

Id: TD-PPagop-26082316 · Status: resolved · Filed: 2026-08-23 · Resolved: 2026-09-06 · Ref: https://github.com/Pullwright/agent-ops/pull/1207

Noticed while reviewing PR #685 (requirement 8x, D18, agent-ops#578), which this gap dequeued from the merge queue.

scripts/publish-dashboard.sh reads its own notion of “now” once, from the real clock, with no way for a caller to supply one:

Terminal window
now_iso="$(date -u +%Y-%m-%dT%H:%M:%SZ)" # scripts/publish-dashboard.sh:167

Everything time-windowed in the script is derived from that single value — the WI-8 landing digest’s rolling in_window and stale() cutoffs, the merge-budget reading, recent_cut, day_cut. So a test that wants to exercise any of them has no way to say when it is running, and must instead arrange its fixture timestamps to fall inside a window measured from whatever the wall clock happens to read at that moment.

Two of this script’s siblings already solve exactly this and show what the seam should look like: scripts/publish-revert-rate.sh takes --now (test/publish-revert-rate.test.sh passes a fixed $NOW to all six of its runs, and so can use fixed calendar dates throughout), and scripts/autonomy-stage-report.sh takes --now the same way (test/autonomy-stage-report.test.sh:223). publish-dashboard.sh is the odd one out.

The failure this produces is a delayed-action one, which is the expensive kind: a test written with fixed calendar timestamps passes for its author, passes the pull request’s own checks, and then starts failing later on a clock nobody changed.

That is not hypothetical — it is what happened to PR #685. test/landing-audit-record.test.sh Part B seeded a synthetic log.jsonl with fixed 2026-08-22T01:00:00Z…T05:00:01Z timestamps. The PR’s own checks were green. More than 24h later the merge queue re-ran the same suite against a later clock, the 2026-08-22T01:00:00Z arm had fallen out of the rolling 24h window, and three assertions failed (run 32611350261), dequeuing the pull request. Note where it fired: not in the PR’s checks, but in the merge group — after a human had clicked “Merge when ready”, costing a dequeue, a diagnosis cycle and a re-approval.

docs/DASHBOARD-SPEC.md:953 already documents LANDING_DIGEST_WINDOW_HOURS as “overridable for tests”, so the need for a test seam here is recognised; that override just is not enough on its own, because it widens the window without pinning the origin the window is measured from.

  • scripts/publish-dashboard.sh:167 — the now_iso assignment, and the windowed readers that derive from it (in_window / stale() around :2199, recent_cut :878, day_cut :776).
  • scripts/publish-revert-rate.sh, scripts/autonomy-stage-report.sh — the --now seam to mirror.
  • test/landing-audit-record.test.sh Part B, test/publish-dashboard.test.sh — the tests that work around the missing seam today by computing every fixture timestamp as an offset from date -u +%s at run time.

Give publish-dashboard.sh a --now <iso8601> option that overrides the now_iso assignment, defaulting to the current behaviour when absent, and validate it the way publish-revert-rate.sh validates its own. Then the windowed tests can go back to fixed calendar timestamps and assert against a clock they control, rather than restating the window arithmetic in their fixtures.

A smaller, independent hardening worth taking either way: those tests should pin LANDING_DIGEST_WINDOW_HOURS explicitly on the runs they make, so an ambient value in the environment cannot silently change what they assert.

Migrated to https://github.com/Poetic-Poems/agent-ops/issues/957.