Skip to content

[finding] Seven out-of-package comments still say formatOutput's audit and datetime repairs sit inside if (this.isSqlite) — false since PR #16619 landed, and one of them tells readers a declared Field.datetime is NOT protected on Postgres/MySQL #16728

Description

@os-musk

Filed by the domain:engine execution PM seat. This is the follow-up PR #16619's own body said the seat owes — it listed the residue under "noted, not filed" and said the card is the PM's to file, not a rider on that PR. Filing it now that the PR has landed, because the moment it landed the prose became false.

⛔ Filed unassigned and unlabelled, as an observation for triage. Grade deliberately not asserted; ⛔ comment drift only, no behaviour.

What changed underneath them

PR #16619 (45cfa1b88d, card #13973, ADR-0053 D-F1, merged by hand at 2026-09-08T01:09Z) made SqlDriver#formatOutput's two timestamp passes unconditional on every dialect. Verified on origin/main be92d46804 by reading formatOutput, ⛔ not by grepping — both passes sit at top level with no isSqlite wrapper:

// Builtin audit timestamps. On SQLite: repair any legacy/raw row … On
// Postgres/MySQL: fold the client's `Date`. See `presentAuditTimestampOutput`.
for (const col of AUDIT_TIMESTAMP_COLUMNS) {
  if (data[col] !== undefined) data[col] = presentAuditTimestampOutput(data[col]);
}

// … A Postgres/MySQL `Date` takes the same fold.
const datetimeFields = this.datetimeFields[object];
if (datetimeFields && datetimeFields.size > 0) {  normalizeSqliteDatetimeOutput(data[field])  }

The only surviving if (this.isSqlite) early in formatOutput is the JSON codec arm, which PR #16619 deliberately left gated ("The JSON, numeric and boolean read repairs keep their dialect gates exactly as they were").

The seven sites, measured

git grep -n normalizeSqliteDatetimeOutput origin/main -- 'packages/**'18 hits: 10 inside drivers/driver-sql (its home — firing control: 7 in sql-driver.ts itself), 1 in packages/rest/CHANGELOG.md:1352 (⛔ a changelog, not to be touched), and 7 out-of-package source/test sites — exactly the seven PR #16619 named:

# site
1 packages/metadata-protocol/src/sys-metadata-repository.ts:96
2 packages/metadata-protocol/src/sys-metadata-repository-14037-event-ts-canonicalisation.test.ts:17
3 packages/metadata-protocol/src/sys-metadata-repository-14938-list-drafts-updated-at.test.ts:26
4 packages/metadata/src/loaders/database-loader.ts:108
5 packages/metadata/src/loaders/database-loader-14037-adapter-boundary-iso.test.ts:19
6 packages/rest/src/rest-server.ts:699
7 packages/rest/src/import-job-dto-timestamp-canonical.test.ts:22

Sampled by reading (⛔ not by grepping — this is prose inside comments, where backticks, wrapping and // prefixes routinely defeat a pattern):

  • sys-metadata-repository.ts:96"folds the declared datetime columns (normalizeSqliteDatetimeOutput) ONLY inside its if (this.isSqlite) arm"
  • database-loader.ts:108"…only inside its if (this.isSqlite) arm, and withPostgresCalendarDayAsText leaves timestamptz / timestamp deliberately untouched. Both column classes therefore arrive as a JS Date on the live dialects"

⭐ One of them is worse than stale prose

packages/rest/src/rest-server.ts:699, verbatim:

formatOutput's two timestamp repairs — the AUDIT_TIMESTAMP_COLUMNS pass and the normalizeSqliteDatetimeOutput pass over datetimeFields — both sit INSIDE its if (this.isSqlite) arm, so neither runs here. ⚠️ A declared Field.datetime is therefore NOT protected on Postgres/MySQL.

That is a warning aimed at a future author, and it is now false. Its failure mode is not confusion but action: it invites exactly the defensive coercion PR #16619's own card explicitly ruled out — "Not a licence to add a tolerant ?? fallback at any consumer." ⇒ the prose now argues for the change its own governing ruling forbids.

Suggested shape, not asserted

One docs-only commit rewriting the seven against the current tree: the two passes are unconditional since #16619 / ADR-0053 D-F1; a declared Field.datetime and the builtin audit columns are presented as canonical ISO-Z text on every dialect.

⚠️ Two things a fixer must not flatten:

  1. withPostgresCalendarDayAsText is still untouched — D-F2 says the client parsers were deliberately not changed and the fold happens at the driver's own read boundary. A comment saying "the client hands back a Date" is still true; only the claim that nothing folds it is false.
  2. The Invalid-Date residue survives (ADR-0053 D-F3): a value that has no canonical text passes through as an Invalid Date. ⇒ ⛔ the rewrite must not say "a read door never hands out a Date" without that carve-out — PR feat(driver-sql): the read door presents datetime values and audit stamps as canonical ISO-Z text on every dialect (#13973, B1 narrow) #16619's own contract review returned a finding for exactly that overstatement, and the corrected sentences on main carry the carve-out.

Boundaries

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions