Skip to content

Commit 0446265

Browse files
TMHSDigitalclaude
andcommitted
Merge main (#48) into review-fixes
#48 fixed impossible dates (#10) independently. Keep its isRealDate, which also handles years 0000-0099 and non-strings, and its messages ("is not a real YYYY-MM-DD date"); drop this branch's copy. Keep this branch's evidenceDates (dates inside URLs ignored) and latestAllowedDate. Both test suites pass together: 101 check and 296 lib assertions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wc67NX9MM964uaVGn4bpZJ
2 parents 55acbcc + ed697b2 commit 0446265

6 files changed

Lines changed: 56 additions & 24 deletions

File tree

‎docs/review-ledger.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ most of them on the `review-fixes` branch, one commit per issue or per interlock
1818
and validate, which had drifted; summaries keep literal `_` and `#` (five changed); the
1919
build fails on an unreadable entry instead of dropping it. New checks: V16 url scheme,
2020
V17 category sets (folders, config, issue form), V18 heading anchors, V19 retired
21-
spellings (`site/value-aliases.json`); real calendar dates; Evidence dates inside URLs
21+
spellings (`site/value-aliases.json`); real calendar dates (the shared `isRealDate` is
22+
from a contributor's PR, #48, merged first); Evidence dates inside URLs
2223
no longer count; a day of time-zone slack. Renderer: parens in link hrefs, misnested
2324
emphasis, unique heading ids.
2425
- **Tooling:** `package.json` scripts (`npm run check`), `site/new-entry.mjs`,

‎site/checks.mjs‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export function checkAttributionConsistency(rel, meta, body, vocab) {
152152
* The check that defends the repo's central promise: a `verified` date may
153153
* never be newer than the evidence it claims to rest on. Bumping `verified`
154154
* without adding a dated Evidence line is exactly the failure this catches.
155-
* Also rejects Evidence dates in the future, and (V10) an Evidence section
155+
* Also rejects impossible or future Evidence dates, and (V10) an Evidence section
156156
* that carries no date at all, whatever the entry's status.
157157
*/
158158
export function checkEvidenceDates(rel, meta, body, today) {
@@ -164,15 +164,18 @@ export function checkEvidenceDates(rel, meta, body, today) {
164164
errors.push(`${rel} ## Evidence section carries no YYYY-MM-DD date`);
165165
return errors;
166166
}
167-
for (const d of new Set(dates)) {
168-
if (!isRealDate(d)) errors.push(`${rel} Evidence date ${d} is not a real calendar date`);
169-
}
170-
const newest = dates[dates.length - 1];
167+
const validDates = dates.filter((date) => {
168+
if (isRealDate(date)) return true;
169+
errors.push(`${rel} Evidence date ${date} is not a real YYYY-MM-DD date`);
170+
return false;
171+
});
172+
if (!validDates.length) return errors;
173+
const newest = validDates[validDates.length - 1];
171174
if (newest > today) {
172175
errors.push(`${rel} Evidence date ${newest} is in the future`);
173176
}
174177
const verified = empty(meta.verified) ? null : String(meta.verified);
175-
if (verified && isRealDate(verified) && verified > newest) {
178+
if (isRealDate(verified) && verified > newest) {
176179
errors.push(
177180
`${rel} verified ${verified} is newer than its newest Evidence date ${newest}. ` +
178181
`A new verified date needs a dated Evidence line from the same check`

‎site/checks.test.mjs‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,22 @@ accepts(
167167
);
168168

169169
/* V8 / V10 -------------------------------------------------------------- */
170+
for (const date of ["2025-13-01", "2026-02-30", "2025-02-29", "1900-02-29", "2026-04-31"]) {
171+
rejects(
172+
`V8 rejects impossible Evidence date ${date}`,
173+
checkEvidenceDates("bad.md", { verified: "2026-01-01" }, `# X${EV(date)}`, TODAY),
174+
`Evidence date ${date} is not a real YYYY-MM-DD date`
175+
);
176+
}
177+
rejects(
178+
"V8 rejects an impossible date even alongside valid Evidence",
179+
checkEvidenceDates("bad.md", { verified: "2026-09-20" }, `# X${EV("2026-02-30")}\n- Rechecked 2026-09-20.\n`, TODAY),
180+
"Evidence date 2026-02-30 is not a real YYYY-MM-DD date"
181+
);
182+
accepts(
183+
"V8 accepts real leap-day Evidence",
184+
checkEvidenceDates("ok.md", { verified: "2000-02-29" }, `# X${EV("2000-02-29")}`, TODAY)
185+
);
170186
rejects(
171187
"V8 rejects a verified date newer than its newest Evidence date",
172188
checkEvidenceDates(
@@ -593,7 +609,7 @@ rejects(
593609
rejects(
594610
"V8 rejects an impossible Evidence date",
595611
checkEvidenceDates("bad.md", { verified: "2026-02-01" }, EV("2026-02-30"), TODAY),
596-
"2026-02-30 is not a real calendar date"
612+
"2026-02-30 is not a real YYYY-MM-DD date"
597613
);
598614
eq(
599615
"evidenceDates reads prose dates only",

‎site/lib/lib.test.mjs‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
commercialLabel,
88
entryPageUrl,
99
esc,
10+
isRealDate,
1011
STATUS_NOTES,
1112
verifiedAge,
1213
} from "./shared.mjs";
@@ -37,12 +38,21 @@ function throws(label, fn, needle) {
3738
}
3839

3940
/* shared ----------------------------------------------------------------- */
41+
for (const date of ["2026-01-01", "2026-12-31", "2026-04-30", "2024-02-29", "2000-02-29", "0000-02-29", "0099-12-31"]) {
42+
eq(`isRealDate accepts ${date}`, isRealDate(date), true);
43+
}
44+
for (const date of ["2025-13-01", "2026-02-30", "2025-02-29", "1900-02-29", "2100-02-29", "2026-04-31", "2026-00-01", "2026-01-00", "2026-01-32", "0099-02-29", "2026-1-01", "2026-01-1", "2026-01-01\n", " 2026-01-01", "2026-01-01T00:00:00Z", "", null, undefined, 20260101]) {
45+
eq(`isRealDate rejects ${JSON.stringify(date)}`, isRealDate(date), false);
46+
}
4047
eq("esc escapes all five characters", esc(`<a href="x">'&'</a>`), "&lt;a href=&quot;x&quot;&gt;&#39;&amp;&#39;&lt;/a&gt;");
4148
eq("commercialLabel true", commercialLabel(true), "commercial OK");
4249
eq("commercialLabel varies", commercialLabel("varies"), "per-file review");
4350
eq("commercialLabel unknown", commercialLabel("unknown"), "commercial ?");
4451
eq("verifiedAge fresh", verifiedAge("2026-09-01", Date.parse("2026-09-24T00:00:00Z")).bucket, "fresh");
4552
eq("verifiedAge missing", verifiedAge(null, Date.now()).bucket, "unknown");
53+
for (const date of ["2025-13-01", "2026-02-30", "2025-02-29", "1900-02-29", "2026-04-31"]) {
54+
eq(`verifiedAge rejects ${date}`, verifiedAge(date, Date.parse("2026-09-24T00:00:00Z")).bucket, "unknown");
55+
}
4656
eq("entryPageUrl trims the site slash", entryPageUrl({ siteUrl: "https://x.test/site/" }, "a-b"), "https://x.test/site/entry/a-b/");
4757
has("STATUS_NOTES covers needs-review", STATUS_NOTES["needs-review"], "open");
4858

@@ -242,7 +252,11 @@ throws("pick without a why", badStack((m) => m.replace("). Idle, run and jump.",
242252
throws("licence in a why sentence", badStack((m) => m.replace("Five loops.", "Five CC0 loops.")), 'stacks/s1.md:20: the why sentence names a licence ("CC0")');
243253
throws("licence phrase in a why sentence", badStack((m) => m.replace("Five loops.", "Five public domain loops.")), '("public domain")');
244254
throws("missing walked", badStack((m) => m.replace("walked: 2026-09-20\n", "")), "frontmatter is missing walked");
245-
throws("bad walked date", badStack((m) => m.replace("2026-09-20", "20 Sept")), "walked is not a real YYYY-MM-DD date");
255+
throws("bad walked date", badStack((m) => m.replace("2026-09-20", "20 Sept")), "walked is not YYYY-MM-DD");
256+
for (const date of ["2025-13-01", "2026-02-30", "2025-02-29", "1900-02-29", "2026-04-31"]) {
257+
throws(`impossible walked date ${date}`, badStack((m) => m.replace("2026-09-20", date)), "walked is not YYYY-MM-DD");
258+
}
259+
eq("leap-day walked date", parseStack(stackMd.replace("2026-09-20", "2000-02-29"), { file: "stacks/s1.md" }).meta.walked, "2000-02-29");
246260
throws("empty pick section", badStack((m) => m.replace("- **Music, no credit:** [Chips](../catalog/audio/subspaceaudio-5-chiptunes.md). Five loops.", "")), 'section "Audio" has no picks');
247261
throws("gaps line not a bullet", badStack((m) => m.replace("- No parallax layers yet.", "No parallax layers yet.")), "stacks/s1.md:24: a Gaps line is a bullet");
248262
eq("licence terms skip plain words", licenceTerms({ licenses: { custom: {}, MIT: { spdx: "MIT" }, CC0: { spdx: "CC0-1.0" } } }, ["OFL-1.1"]).sort().join(","), "CC0,CC0-1.0,MIT,OFL-1.1");
@@ -429,7 +443,7 @@ has("empty recent window wording counts the build day", freshnessPageHtml({ stat
429443

430444
/* frontmatter -------------------------------------------------------------- */
431445
import { evidenceSection, parseFrontmatter, plainText, summaryFromBody } from "./frontmatter.mjs";
432-
import { isRealDate, latestAllowedDate } from "./shared.mjs";
446+
import { latestAllowedDate } from "./shared.mjs";
433447
const fm = (lines, body = "Body.\n") => parseFrontmatter(`---\n${lines.join("\n")}\n---\n${body}`);
434448
const f1 = fm([
435449
"id: a",

‎site/lib/shared.mjs‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@ export const STATUS_NOTES = {
1919
const VERIFIED_FRESH_DAYS = 180;
2020
const VERIFIED_AGING_DAYS = 365;
2121

22+
/** A real calendar date in strict YYYY-MM-DD form, independent of local time. */
23+
export function isRealDate(value) {
24+
if (typeof value !== "string" || value.length !== 10 || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return false;
25+
const [year, month, day] = value.split("-").map(Number);
26+
const date = new Date(0);
27+
// Unlike Date.UTC, this preserves years 0000-0099.
28+
date.setUTCFullYear(year, month - 1, day);
29+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
30+
}
31+
2232
export function verifiedAge(verified, now) {
23-
if (!verified) return { days: null, bucket: "unknown" };
33+
if (!isRealDate(verified)) return { days: null, bucket: "unknown" };
2434
const t = Date.parse(`${verified}T00:00:00Z`);
2535
if (Number.isNaN(t)) return { days: null, bucket: "unknown" };
2636
const days = Math.max(0, Math.floor((now - t) / 86400000));
@@ -45,18 +55,6 @@ export function commercialLabel(v) {
4555
return "commercial ?";
4656
}
4757

48-
/**
49-
* True for a YYYY-MM-DD string that names a real calendar day. The shape
50-
* alone let 2025-13-01 through, and 2026-02-30 rolled over to 2 March.
51-
*/
52-
export function isRealDate(s) {
53-
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s));
54-
if (!m) return false;
55-
const [y, mo, d] = m.slice(1).map(Number);
56-
const t = new Date(Date.UTC(y, mo - 1, d));
57-
return t.getUTCFullYear() === y && t.getUTCMonth() === mo - 1 && t.getUTCDate() === d;
58-
}
59-
6058
/**
6159
* The newest date a check may accept as "not in the future": tomorrow in UTC.
6260
* A contributor east of UTC who writes their local date before UTC midnight

‎site/lib/stacks.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function parseStack(text, { file, terms = [] }) {
9898
metaLine[key] = i;
9999
}
100100
for (const key of REQUIRED) if (!meta[key]) fail(0, `frontmatter is missing ${key}`);
101-
if (!isRealDate(meta.walked)) fail(0, "walked is not a real YYYY-MM-DD date");
101+
if (!isRealDate(meta.walked)) fail(0, "walked is not YYYY-MM-DD (a real calendar date is required)");
102102
noLicence(metaLine.title, meta.title, "title");
103103
noLicence(metaLine.task, meta.task, "task");
104104

0 commit comments

Comments
 (0)