You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rendering a foreign-session digest can crash the resume/send flow with RangeError: Invalid time value.
packages/core/src/foreign-session.ts:635 guards the toISOString() call with Number.isFinite(digest.updatedAtMs), with a comment claiming this prevents exactly that RangeError. It does not:
Date clamps at ±8.64e15 ms (TimeClip); any finite value beyond that makes new Date(ts) an Invalid Date, and .toISOString() throws. Verified on Node 24:
$ node -e "console.log(new Date(1e16).toISOString())"
RangeError: Invalid time value
The untrusted value flows straight through: normalizeEpochMs (packages/core/src/foreign-session.ts:404-413) accepts any finite number ≥ 1,577,836,800,000 as-is, so a corrupt or future-schema Codex SQLite row (e.g. a nanosecond epoch ≈ 1.7e18) passes validation, survives the 30-day window filter in codexRowsToSummaries, and reaches the digest render via buildForeignSessionHandoffMessage.
How to reproduce
Point Maka at a Codex store whose threads.updated_at_ms contains e.g. 10000000000000000 (1e16)
Resume / send in that session — the digest render throws RangeError: Invalid time value
Suggested fix
Validate epoch range, not just finiteness — accept only Math.abs(t) <= 8_640_000_000_000 inside normalizeEpochMs (rejecting or clamping out-of-range rows), or apply the same range check at line 635.
Dev design: define the ECMAScript TimeClip bound once, reject normalized store timestamps outside that range, and keep the prompt-render boundary fail-closed by emitting updated_at=unknown for any invalid digest timestamp.
Scope / non-goals: no schema migration, no clamping, and no change to valid seconds-to-milliseconds normalization.
Test plan / acceptance: add a RED regression for a Codex row with updated_at_ms = 1e16 plus direct digest rendering at that boundary; after the fix, the row must not carry the invalid timestamp, rendering must not throw, valid timestamps must remain ISO-formatted, and the full @maka/core suite must pass.
Implemented in #3835 at a68af7b193cfa9333cc56f7ec818868e88da0faf.
RED / GREEN evidence:
RED on current main: npm --workspace @maka/core test reported 656 passed / 2 failed; the invalid timestamp was retained and direct digest rendering threw RangeError.
GREEN: the same core suite passes 658/658.
Full workspace typecheck, production build, Biome lint/format, desktop/UI Knip, and git diff --check pass.
Acceptance:
out-of-range normalized timestamps are rejected
direct invalid digest timestamps render as updated_at=unknown without throwing
valid timestamp behavior and existing seconds normalization remain covered
Activity
hydraxman commentedon Aug 25, 2026
I can take this.
Dev design: define the ECMAScript
TimeClipbound once, reject normalized store timestamps outside that range, and keep the prompt-render boundary fail-closed by emittingupdated_at=unknownfor any invalid digest timestamp.Scope / non-goals: no schema migration, no clamping, and no change to valid seconds-to-milliseconds normalization.
Test plan / acceptance: add a RED regression for a Codex row with
updated_at_ms = 1e16plus direct digest rendering at that boundary; after the fix, the row must not carry the invalid timestamp, rendering must not throw, valid timestamps must remain ISO-formatted, and the full@maka/coresuite must pass.hydraxman commentedon Aug 25, 2026
Implemented in #3835 at
a68af7b193cfa9333cc56f7ec818868e88da0faf.RED / GREEN evidence:
main:npm --workspace @maka/core testreported 656 passed / 2 failed; the invalid timestamp was retained and direct digest rendering threwRangeError.git diff --checkpass.Acceptance:
updated_at=unknownwithout throwing