mirror of
https://github.com/morluto/rea.git
synced 2026-11-07 05:56:19 -10:00
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.
This commit is contained in:
1 parent
1008d5e302
commit
4bbd87953f
2 files changed
+15
-15
No files matched your search
@@ -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,
|
||||
},
|
||||
]),
|
||||
),
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user