// Reproduce: download this file and https://revsetlabs.com/customer-model.js // into the same directory. Rename customer-model.js to customer-model.mjs. // Run: node check-followup-rules.mjs import assert from 'node:assert/strict'; import {initialState,transition} from './customer-model.mjs'; const actions=['run','reply','optout','pause','resume']; let transitions=0,completeSequences=0; function visit(state,depth){ if(!depth){completeSequences++;return;} for(const type of actions){ const next=transition(state,{type});transitions++; assert.ok(next.sent>=state.sent&&next.sent<=1,'At most one send'); if(type==='run'&&(state.hold||state.processed))assert.equal(next.sent,state.sent,'Held or processed reminder cannot send'); if(state.hold==='optout')assert.equal(next.hold,'optout','Opt-out remains a stop'); if(type==='resume'&&state.hold==='reply')assert.equal(next.hold,'reply','Resume cannot clear a customer reply'); visit(next,depth-1); } } visit(initialState('followup'),4); console.log(JSON.stringify({scope:'RevSet browser simulation only; no CRM, delivery provider, or client revenue tested',actions,depth:4,completeSequences,transitions,result:'passed'},null,2));