Skip to content

Validate/correct header dates: epoch↔ISO consistency and @Date vs git creation #31

Description

@Shinrai

Problem

Two header-date gaps let inconsistent dates accumulate silently:

  1. The parenthesized unix-epoch is never checked against the ISO datetime. toDatePayload() (src/utils/time.mjs:39) computes the epoch independently, and for an existing header extractHeaderCreatedAt() / extractHeaderLastModifiedAt() (src/core/fix-headers.mjs:152, :174) copy the date-string and epoch straight back out with no cross-check. So a header like @Date: 2026-08-24T00:00:00-08:00 (1756022400) (epoch = 2025-08-24) is never flagged or corrected.
  2. @Date (creation) is never git-corrected once present. Precedence at src/core/fix-headers.mjs:286 is existingCreatedAt || gitCreated || filesystem, so an existing @Date is preserved verbatim; fix:headers only ever maintains @Last modified time. A wrong/stale creation date persists forever.

There's also a format inconsistency: git-sourced dates use %aI (…T…, src/utils/git.mjs:93,119) while filesystem/now dates use the space form from formatDateWithTimezone() (src/utils/time.mjs:24), so a single file can carry two shapes — which makes hand-authored headers easy to get wrong.

Real impact: a repo-wide scan of @cldmv/slothlet found 49 files with an epoch that doesn't match its ISO string (mostly timezone/hour drift, a handful with the wrong year — including, ironically, tools/dev/fix-headers.mjs itself).

Ask

  • Add a --check mode that validates each managed header and exits non-zero on drift (today there's only write + --dry-run, and --dry-run always exits 0 — src/cli.mjs:286), so it can gate CI.
  • Validate: (a) epoch decodes to the ISO string shown (local, no git — catches all 49); (b) @Date == git first-commit (getGitCreationDate, src/utils/git.mjs:92); (c) @Last modified time == git last-commit (advisory).
  • In fix mode, autocorrect a stale/inconsistent @Date from git instead of preserving it, and normalize to one canonical date shape (suggest the git %aI T-form).

Design constraint

needsUpdate is a byte-diff of a freshly-rendered header vs the file (src/core/fix-headers.mjs:291-325), which already causes a repo-wide @Last modified restamp on an author/identity mismatch. The date checks must compare epoch-vs-ISO and @Date-vs-git independently of that content/identity diff, so --check reports genuine date drift only and never trips on an identity delta. Layer on top of the in-flight fix/preserve-last-modified-identity branch.

Surfaced while addressing review comments on CLDMV/slothlet#306.

Activity

  1. added
    priority: low
    type: feature request
    area: core
    on Sep 14, 2026
  2. Shinrai commented on Sep 27, 2026

    @Shinrai
    ContributorAuthor

    Two more concrete cases from @cldmv/slothlet (2026-09-26/27):

    1. Hand-written dates with no epoch — caught, but only because they were malformed. 13 files on slothlet next carried headers like @Date: 2026-09-17 00:00:00 -07:00 / @Last modified time: 2026-09-17 00:00:00 -07:00 with no (epoch) suffix (e.g. src/lib/handlers/event-manager.mjs). fix:headers did repair these — the unparseable value falls through to the git creation date — producing @Date: 2026-09-20T15:33:32+00:00 (1789918412). Fixed in CLDMV/slothlet#463. Note the result mixes shapes within one header (@Date in git %aI T-form, @Last modified time in the space form), which is the format inconsistency this issue describes.

    2. A well-formed but invented @Date passes every check. New files were written with a made-up midnight timestamp that is internally consistent — @Date: 2026-09-26 00:00:00 -07:00 (1790406000), where the epoch does decode to the ISO string — but is not the file's creation time (they were created that evening). Neither fix:headers nor slothlet's analyze flags it, because an existing parseable @Date is preserved verbatim (existingCreatedAt || gitCreated || …). Only the @Date vs git first-commit check in (b) catches this class; the epoch↔ISO check in (a) cannot. It was corrected by hand before committing, so it is not in the repo — but nothing would have stopped it.

    Both support making @Date-vs-git part of --check, not just the epoch cross-check.

  3. added
    area: cli
    status: not started
    on Sep 27, 2026
  4. added theissue type on Sep 27, 2026
  5. Shinrai commented on Sep 27, 2026

    @Shinrai
    ContributorAuthor

    Triage note: the fix/preserve-last-modified-identity prerequisite has landed (#25, merged 2026-08-09), so this can build on next directly. Nothing from the ask is implemented yet — @Date still resolves existingCreatedAt || gitCreated || filesystem and there's no --check mode.

    Two behavior calls to settle before implementing:

    • Autocorrecting an existing @Date from git's first commit will rewrite dates in every consumer on their next run, including files whose first commit isn't their real creation (moved or copied in from another repo). Should the correction be opt-in (e.g. --fix-created-date), or apply by default?
    • Normalizing everything to the %aI T-form is a one-time restamp of every managed file in every consumer. Default, or opt-in?

    The epoch↔ISO cross-check plus a non-zero-exit --check is uncontroversial and could ship first on its own.

  6. Shinrai commented on Sep 27, 2026

    @Shinrai
    ContributorAuthor

    Triage note: the fix/preserve-last-modified-identity prerequisite has landed (#25, merged 2026-08-09), so this can build on next directly. Nothing from the ask is implemented yet — @Date still resolves existingCreatedAt || gitCreated || filesystem and there's no --check mode.

    Two behavior calls to settle before implementing:

    • Autocorrecting an existing @Date from git's first commit will rewrite dates in every consumer on their next run, including files whose first commit isn't their real creation (moved or copied in from another repo). Should the correction be opt-in (e.g. --fix-created-date), or apply by default?
    • Normalizing everything to the %aI T-form is a one-time restamp of every managed file in every consumer. Default, or opt-in?

    The epoch↔ISO cross-check plus a non-zero-exit --check is uncontroversial and could ship first on its own.

  7. added
    status: in progress
    and removed
    status: not started
    on Sep 28, 2026
  8. Shinrai commented on Sep 28, 2026

    @Shinrai
    ContributorAuthor

    Implementation started on feat/header-date-check (off next). The two open behaviour calls are settled on the side that never rewrites existing headers unasked:

    • --check / check: true writes nothing and exits non-zero on date drift: (a) epoch ↔ ISO mismatch on @Date and @Last modified time, (b) @Date ≠ git first-commit date (skipped for files with no history). (c) @Last modified time vs git last-commit is reported as advisory only. Instants are compared, not strings, and author/identity differences never trip it.
    • Correcting an existing @Date from git is opt-in: --fix-created-date / fixCreatedDate: true. Without it an existing parseable @Date is kept, as today.
    • Normalising dates to the git %aI T-form is opt-in: --normalize-date-format / normalizeDateFormat: true. Default output format is unchanged.
    • In fix mode, an epoch that doesn't match its own ISO text is repaired to match it (a consistency fix that changes no dates).
  9. added
    status: implemented
    and removed
    status: in progress
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliarea: corepriority: lowstatus: implementedtype: feature request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions