From 4bbd87953fa0ac78ca22e4321cce458558319205 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Tue, 27 Oct 2026 03:24:53 +0800 Subject: [PATCH] fix(environment): align recorded probe chronology Use the shared recorded timestamp interpretation for replay ordering, including exact fractions and UTC interpretation of supported zone-less forms. Preserve native-Date fallback for unsupported historical spellings. Validated environment comparison, state ordering and CLI tests; five new cases reproduce prior drift. --- .../environment/environmentCompare.test.ts | 20 +++++++++++++------ .../environment/environmentCompareProbe.ts | 10 +--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/application/environment/environmentCompare.test.ts b/src/application/environment/environmentCompare.test.ts index d1436ba915..d5335e2180 100644 --- a/src/application/environment/environmentCompare.test.ts +++ b/src/application/environment/environmentCompare.test.ts @@ -735,6 +735,11 @@ describe("probe request chronology", () => { it.each([ ["2026-10-20T09:00:00.000100Z", "2026-10-20T10:00:00.0001+01:00"], ["2026-10-20T09:00:00.0001Z", "2026-10-20T09:00:00.000100"], + ["2026-10-20T10:00+01:00", "2026-10-20 09:00"], + [ + "2026-10-20T10:00:00.0000000001+01:00", + "2026-10-20 09:00:00.000000000100", + ], ["Tue, 20 Oct 2026 09:00:00 GMT", "2026-10-20T09:00:00Z"], ])( "keeps ordinal order for equal instants and native-Date spelling compatibility (%s)", @@ -860,17 +865,20 @@ const registerProbeOrderingAndCaptureCases = () => { }); it.each([ - ["0002", "0001"], - ["002", "001"], + ["2026-10-20T09:00:00.0002Z", "2026-10-20T09:00:00.0001Z"], + ["2026-10-20T09:00:00.002Z", "2026-10-20T09:00:00.001Z"], + ["2026-10-20 09:00:00.0000000002Z", "2026-10-20 09:00:00.0000000001Z"], + ["2026-10-20 09:00:00.0000000002", "2026-10-20T10:00:00.0000000001+01:00"], + ["2026-10-20 09:01", "2026-10-20T10:00+01:00"], ])( - "orders probe requests by complete fractional timestamps: %s after %s", - (readFraction, writeFraction) => { + "orders probe requests by the owner's UTC instant: %s after %s", + (readTime, writeTime) => { const report = run( analysisViewCaptureEvidence( environmentManifestCaptureFixture([ { ...exchange(0, "GET", "http://app.example/api/books/2", 404), - startedDateTime: `2026-10-20T09:00:00.${readFraction}Z`, + startedDateTime: readTime, response: { status: 404, content: { @@ -881,7 +889,7 @@ const registerProbeOrderingAndCaptureCases = () => { }, { ...exchange(0, "DELETE", "http://app.example/api/books/2", 204), - startedDateTime: `2026-10-20T09:00:00.${writeFraction}Z`, + startedDateTime: writeTime, }, ]), ), diff --git a/src/application/environment/environmentCompareProbe.ts b/src/application/environment/environmentCompareProbe.ts index b49a69d1af..8def1fa49a 100644 --- a/src/application/environment/environmentCompareProbe.ts +++ b/src/application/environment/environmentCompareProbe.ts @@ -56,15 +56,7 @@ const startedInstant = ( const started = startedSchema.safeParse(record.reported); if (!started.success) return undefined; const reading = readRecordedDateTime(started.data.startedDateTime); - if (reading !== undefined) { - const { spelling } = reading; - const offsetTimestamp = - spelling.separator === "T" && - (spelling.zone === "Z" || spelling.zone.includes(":")); - const clockTimestamp = - spelling.secondsPresent && spelling.fractionDigits <= 9; - if (offsetTimestamp || clockTimestamp) return reading.instant; - } + if (reading !== undefined) return reading.instant; // Preserve native-Date admission for legacy spellings, at its original precision. const ms = Date.parse(started.data.startedDateTime); return Number.isFinite(ms)