Evidence
1. Schema duplication with silent-degradation failure mode. src/pages/[collection]/[...slug].astro:36-64 defines isRecord/isTruncatedWallet/isStatementData — a hand-rolled re-statement of statementSchema. The collection already validated entry.data against the Zod schema at sync time. If the guard drifts from the schema (next schema change), isStatementData returns false and the page silently drops the entire metrics block (statement = null → no dl, no top-wallets table) while still returning 200 — exactly the class of quiet failure a credibility site can't afford. This violates the repo's own deep-modules rule (schema = the one interface; pages should consume it, not mirror it).
2. Ordering triplicated, and the tiebreakers disagree. Live consequence (verified on prod): /statements lists monthly first (sort-newest-first.ts: period_end desc, id desc) while RSS lists weekly first (feeds/sort.ts: date desc, collection asc, slug asc) for the same two 2026-05-31 entries; latest.ts re-implements the pick a third time. Same data, different canonical order per surface.
TDD plan (failing tests first)
src/lib/statement-format/statement-data.ts: asStatementData(data: unknown): Statement | null implemented as statementSchema.safeParse (or a narrowing on the already-typed CollectionEntry<"statements">["data"]), exporting the inferred type. Tests FIRST:
- every fixture that passes
statementSchema is accepted (drift impossible by construction)
- the function and schema share one type (compile-time,
satisfies)
- decide + test the failure mode: log-and-render-without-metrics is current behavior; consider throwing in dev so drift is loud
- Collapse ordering:
sortStatementsNewestFirst stays the single comparator; pickLatestStatement becomes sorted[0] ?? null (its doc already promises head-equivalence — make it true by construction); feeds sortEntries documents why its tiebreaker differs (cross-collection) or aligns the same-date tiebreaker with the statements surface. Tests: same-date weekly+monthly fixture must order identically on /statements, RSS, llms.txt, sitemap (one shared fixture asserted across the three generators + the statement sort).
- Net deletion target: ~60 lines from the page frontmatter.
Acceptance criteria
| AC |
Test |
| No structural type-guard logic left in page frontmatter |
review (page imports asStatementData) |
| Schema change cannot silently blank the metrics block |
drift test above |
| One documented ordering for same-date entries across all surfaces |
cross-surface fixture test |
Evidence
1. Schema duplication with silent-degradation failure mode.
src/pages/[collection]/[...slug].astro:36-64definesisRecord/isTruncatedWallet/isStatementData— a hand-rolled re-statement ofstatementSchema. The collection already validatedentry.dataagainst the Zod schema at sync time. If the guard drifts from the schema (next schema change),isStatementDatareturns false and the page silently drops the entire metrics block (statement = null→ nodl, no top-wallets table) while still returning 200 — exactly the class of quiet failure a credibility site can't afford. This violates the repo's own deep-modules rule (schema = the one interface; pages should consume it, not mirror it).2. Ordering triplicated, and the tiebreakers disagree. Live consequence (verified on prod):
/statementslists monthly first (sort-newest-first.ts: period_end desc, id desc) while RSS lists weekly first (feeds/sort.ts: date desc, collection asc, slug asc) for the same two 2026-05-31 entries;latest.tsre-implements the pick a third time. Same data, different canonical order per surface.TDD plan (failing tests first)
src/lib/statement-format/statement-data.ts:asStatementData(data: unknown): Statement | nullimplemented asstatementSchema.safeParse(or a narrowing on the already-typedCollectionEntry<"statements">["data"]), exporting the inferred type. Tests FIRST:statementSchemais accepted (drift impossible by construction)satisfies)sortStatementsNewestFirststays the single comparator;pickLatestStatementbecomessorted[0] ?? null(its doc already promises head-equivalence — make it true by construction); feedssortEntriesdocuments why its tiebreaker differs (cross-collection) or aligns the same-date tiebreaker with the statements surface. Tests: same-date weekly+monthly fixture must order identically on /statements, RSS, llms.txt, sitemap (one shared fixture asserted across the three generators + the statement sort).Acceptance criteria
asStatementData)