Skip to content

doctor.sh's store-size check asks the machine clock, not config.timezone, so it can invent an alarm the pipeline would not raise #357

Closed

Description

@fdaviddpt

Found by the release audit of v0.20.0..HEAD before tagging 0.21.0. Ranked misreports: non-blocking, filed rather than held.

The divergence

scripts/doctor.sh:421 gets today's date from the machine:

_DOCTOR_TODAY=$(date '+%Y-%m-%d')

The block's own header at scripts/doctor.sh:363-366 states the contract it is meant to hold — "The number being checked is the one the pipeline actually enforces... So this measures the same three parts against the same cap." It does not measure the same three parts.

The pipeline reaches today through config.timezone -> REMEMBER_TZ (scripts/log.sh:366) -> pipeline/_tz.py:34-36 today_str(), which is what _eligible_staging (pipeline/shell.py:393) excludes today by. doctor.sh deliberately does not source log.sh, and REMEMBER_TZ appears nowhere in it — one grep over the file returns line 421 and nothing else.

So with timezone set to a zone whose current date is ahead of the machine's, doctor excludes today-D.md (which the pipeline counts) and counts today-(D+1).md (which the pipeline excludes). A divergence in both directions at once.

Why that is worse than it sounds

The comment at scripts/doctor.sh:419-420 claims only one direction:

under-counting is the safe direction for a diagnostic — it cannot invent an alarm.

It can. When the D+1 file is the larger of the two, _STAGING_BYTES can cross _CONSOLIDATE_MAX_BYTES on a store the pipeline is about to rotate happily — producing the FAIL ... cannot heal itself arm (scripts/doctor.sh:451) and VERDICT: problem (:568). That is the arm added in #348 for the store rotation genuinely cannot fix, shown to a user whose store is fine.

The guard is nominally on and effectively off

tests/test_doctor_oversized_store_348.py:321 test_todays_staging_is_not_counted_against_the_cap obtains its date by running date +%Y-%m-%d in a subprocess (line 334) — the same clock as the code under test. Its own docstring names the direction it cannot detect ("the false-positive direction, and the expensive one"). It passes whether or not the code honours REMEMBER_TZ.

What settles it

Run doctor.sh against a store holding a large today-<tomorrow>.md with timezone set to a zone a day ahead, and compare its _STAGING_BYTES against _eligible_staging()'s sum.

Shape of a fix

Read .timezone the way _CONSOLIDATE_MAX_BYTES is already read at scripts/doctor.sh:377 and pass it to date, or use the same grep-then-TZ shape. The test needs a fixed date injected rather than one asked of the same clock, or it will keep passing through the fix.

Activity

  1. added
    priority:medium
    on Aug 18, 2026
  2. added
    cohort-1
    on Aug 27, 2026
  3. self-assigned this
    on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cohort-1priority:medium

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions