Set the decision and its input
The fictional day indices are supplied integers, not timezone conversions. The filter was saved on day10 and runs on12. Its inclusive seven-day range is6..12, so B6 and C11 match; A4 leaves the live result. The frozen day10 snapshot still contains A4 and B6.
| Case | Input JSON |
|---|---|
| Base test | {"savedDay":10,"executedDay":12,"records":[{"id":"A","day":4},{"id":"B","day":6},{"id":"C","day":11}]} |
Run the supplied comparison
The executable selection preserves both live and snapshot identities. A saved relative expression and a persisted result are different artefacts; a changed live membership does not corrupt the original snapshot.
| Path | Output JSON |
|---|---|
| Faulty path | {"liveIds":["A","B","C"],"snapshotIds":["A","B"]} |
| Required path | {"liveIds":["B","C"],"snapshotIds":["A","B"]} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(i.executedDay===null)return {held:true};const cutoff=(corrected?i.executedDay:i.savedDay)-6;
return {liveIds:i.records.filter(r=>r.day>=cutoff&&r.day<=i.executedDay).map(r=>r.id),snapshotIds:i.records.filter(r=>r.day>=i.savedDay-6&&r.day<=i.savedDay).map(r=>r.id)};
};
const cases=[{"input":{"savedDay":10,"executedDay":12,"records":[{"id":"A","day":4},{"id":"B","day":6},{"id":"C","day":11}]},"corrected":false,"expected":{"liveIds":["A","B","C"],"snapshotIds":["A","B"]}},{"input":{"savedDay":10,"executedDay":12,"records":[{"id":"A","day":4},{"id":"B","day":6},{"id":"C","day":11}]},"corrected":true,"expected":{"liveIds":["B","C"],"snapshotIds":["A","B"]}},{"input":{"savedDay":10,"executedDay":10,"records":[{"id":"A","day":4},{"id":"B","day":11}]},"corrected":true,"expected":{"liveIds":["A"],"snapshotIds":["A"]}},{"input":{"savedDay":10,"executedDay":null,"records":[]},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
Running on the original day matches its snapshot anchor. Missing execution day is held rather than inferred from the save time.
- Read expression and snapshot anchor
- Resolve the execution window
- Retain both result identities
Do not silently turn a relative saved query into an old fixed cutoff.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| same execution day as snapshot | {"savedDay":10,"executedDay":10,"records":[{"id":"A","day":4},{"id":"B","day":11}]} | {"liveIds":["A"],"snapshotIds":["A"]} |
| execution anchor unknown | {"savedDay":10,"executedDay":null,"records":[]} | {"held":true} |
Which IDs belong to the base live result and snapshot?
Show the worked answer
Live B,C; snapshot A,B. Each uses its declared anchor, so both results can be correct together.