@@ -30,6 +30,7 @@ describe("runHeartbeatOnce commitments", () => {
3030 id : string ;
3131 sessionKey : string ;
3232 to : string ;
33+ dueWindow ?: CommitmentRecord [ "dueWindow" ] ;
3334 sourceUserText ?: string ;
3435 sourceAssistantText ?: string ;
3536 } ) : CommitmentRecord {
@@ -48,7 +49,7 @@ describe("runHeartbeatOnce commitments", () => {
4849 suggestedText : "How did the interview go?" ,
4950 dedupeKey : "interview:2026-04-28" ,
5051 confidence : 0.92 ,
51- dueWindow : {
52+ dueWindow : params . dueWindow ?? {
5253 earliestMs : nowMs - 60_000 ,
5354 latestMs : nowMs + 60 * 60_000 ,
5455 timezone : "America/Los_Angeles" ,
@@ -76,6 +77,7 @@ describe("runHeartbeatOnce commitments", () => {
7677 async function setupCommitmentCase ( params ?: {
7778 replyText ?: string ;
7879 target ?: "last" | "none" ;
80+ dueWindow ?: CommitmentRecord [ "dueWindow" ] ;
7981 sourceUserText ?: string ;
8082 sourceAssistantText ?: string ;
8183 legacyRawSourceText ?: boolean ;
@@ -111,6 +113,7 @@ describe("runHeartbeatOnce commitments", () => {
111113 id : "cm_interview" ,
112114 sessionKey,
113115 to : "155462274" ,
116+ dueWindow : params ?. dueWindow ,
114117 sourceUserText : params ?. sourceUserText ,
115118 sourceAssistantText : params ?. sourceAssistantText ,
116119 } ) ,
@@ -391,6 +394,25 @@ describe("runHeartbeatOnce commitments", () => {
391394 } ) ;
392395 } ) ;
393396
397+ it ( "tolerates Date-invalid commitment due timestamps in heartbeat prompts" , async ( ) => {
398+ const { result, sendTelegram, store } = await setupCommitmentCase ( {
399+ dueWindow : {
400+ earliestMs : nowMs - 60_000 ,
401+ latestMs : 8_700_000_000_000_000 ,
402+ timezone : "UTC" ,
403+ } ,
404+ } ) ;
405+
406+ expect ( result . status ) . toBe ( "ran" ) ;
407+ expect ( sendTelegram ) . toHaveBeenCalled ( ) ;
408+ expectCommitmentFields ( store . commitments [ 0 ] , {
409+ id : "cm_interview" ,
410+ status : "sent" ,
411+ attempts : 1 ,
412+ sentAtMs : nowMs ,
413+ } ) ;
414+ } ) ;
415+
394416 it ( "dismisses a due commitment when the heartbeat model declines to send a check-in" , async ( ) => {
395417 const { result, sendTelegram, store } = await setupCommitmentCase ( {
396418 replyText : HEARTBEAT_TOKEN ,
0 commit comments