Repository navigation
Description
Problem
Two header-date gaps let inconsistent dates accumulate silently:
- 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 headerextractHeaderCreatedAt()/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. @Date(creation) is never git-corrected once present. Precedence atsrc/core/fix-headers.mjs:286isexistingCreatedAt || gitCreated || filesystem, so an existing@Dateis preserved verbatim;fix:headersonly 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
--checkmode that validates each managed header and exits non-zero on drift (today there's only write +--dry-run, and--dry-runalways 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
@Datefrom git instead of preserving it, and normalize to one canonical date shape (suggest the git%aIT-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
fix(ownership): drop moduleEndpoints on a full scoped removal; correc…
Shinrai commentedon Sep 27, 2026
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
nextcarried headers like@Date: 2026-09-17 00:00:00 -07:00/@Last modified time: 2026-09-17 00:00:00 -07:00with no(epoch)suffix (e.g.src/lib/handlers/event-manager.mjs).fix:headersdid 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 (@Datein git%aIT-form,@Last modified timein the space form), which is the format inconsistency this issue describes.2. A well-formed but invented
@Datepasses 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). Neitherfix:headersnor slothlet'sanalyzeflags it, because an existing parseable@Dateis preserved verbatim (existingCreatedAt || gitCreated || …). Only the@Datevs 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.Shinrai commentedon Sep 27, 2026
Triage note: the
fix/preserve-last-modified-identityprerequisite has landed (#25, merged 2026-08-09), so this can build onnextdirectly. Nothing from the ask is implemented yet —@Datestill resolvesexistingCreatedAt || gitCreated || filesystemand there's no--checkmode.Two behavior calls to settle before implementing:
@Datefrom 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?%aIT-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
--checkis uncontroversial and could ship first on its own.Shinrai commentedon Sep 27, 2026
Triage note: the
fix/preserve-last-modified-identityprerequisite has landed (#25, merged 2026-08-09), so this can build onnextdirectly. Nothing from the ask is implemented yet —@Datestill resolvesexistingCreatedAt || gitCreated || filesystemand there's no--checkmode.Two behavior calls to settle before implementing:
@Datefrom 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?%aIT-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
--checkis uncontroversial and could ship first on its own.Shinrai commentedon Sep 28, 2026
Implementation started on
feat/header-date-check(offnext). The two open behaviour calls are settled on the side that never rewrites existing headers unasked:--check/check: truewrites nothing and exits non-zero on date drift: (a) epoch ↔ ISO mismatch on@Dateand@Last modified time, (b)@Date≠ git first-commit date (skipped for files with no history). (c)@Last modified timevs git last-commit is reported as advisory only. Instants are compared, not strings, and author/identity differences never trip it.@Datefrom git is opt-in:--fix-created-date/fixCreatedDate: true. Without it an existing parseable@Dateis kept, as today.%aIT-form is opt-in:--normalize-date-format/normalizeDateFormat: true. Default output format is unchanged.feat: oldest-wins creation date, advisory created-date check by default
feat: validate header dates with --check, repair mismatched epochs
feat: oldest-wins creation date, advisory created-date check by default
fix: write git commit dates with a numeric UTC offset on every git ve…
release: v2.0.0 - re-cut the release notes as v2.0.0