Skip to content
Astera Technology

Why did loading history create a new live notification row?

Make the supplied historical-load distinction part of the trigger’s actual condition.

Download complete case notes and answer keys ↓

Read the source and its declared rule

The original rule sends an auto notice only for a new live movement. Historical movementM carries historical 1 and may include an old source notice. An unguarded insert trigger fires during history loading too, adding auto:M beside old:M. The corrected trigger uses WHEN historical=0.

Filled synthetic input
RecordInput JSON
Base input{"id":"M","historical":1,"sourceNotice":"old:M"}
Download editable CSV ↓

Compare the actual paths

Correct history contains M and old:M only. These are local table rows demonstrating the side effect; no notification provider or real recipient action is performed.

Misleading and corrected outputs
PathOutput JSON
Misleading path{"movements":[{"id":"M","historical":1}],"notices":[{"id":"auto:M"},{"id":"old:M"}]}
Corrected path{"movements":[{"id":"M","historical":1}],"notices":[{"id":"old:M"}]}
Download editable CSV ↓
Local Node.js program: 22.23.3 or 24.14.1
import {DatabaseSync} from 'node:sqlite';
import {TextDecoder} from 'node:util';
import {inflateSync} from 'node:zlib';
import {posix} from 'node:path';
import {createHash} from 'node:crypto';
const rows=(db,sql)=>db.prepare(sql).all().map(r=>({...r}));
const failed=(action)=>{try{action();return null;}catch(e){return {code:e.errcode??e.code??e.name};}};

import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
    const db=new DatabaseSync(':memory:');try{db.exec('CREATE TABLE movement(id TEXT PRIMARY KEY,historical INTEGER CHECK(historical IN(0,1)));CREATE TABLE notice(id TEXT);CREATE TRIGGER notify AFTER INSERT ON movement '+(corrected?'WHEN NEW.historical=0 ':'')+"BEGIN INSERT INTO notice VALUES('auto:'||NEW.id);END;");
      db.prepare('INSERT INTO movement VALUES(?,?)').run(i.id,i.historical);
      if(i.sourceNotice!==null)db.prepare('INSERT INTO notice VALUES(?)').run(i.sourceNotice);
      return {movements:rows(db,'SELECT * FROM movement'),notices:rows(db,'SELECT * FROM notice ORDER BY id')};
    }finally{db.close();}
  };
const cases=[{"label":"misleading base","input":{"id":"M","historical":1,"sourceNotice":"old:M"},"expected":{"movements":[{"id":"M","historical":1}],"notices":[{"id":"auto:M"},{"id":"old:M"}]},"corrected":false},{"label":"corrected base","input":{"id":"M","historical":1,"sourceNotice":"old:M"},"expected":{"movements":[{"id":"M","historical":1}],"notices":[{"id":"old:M"}]},"corrected":true},{"label":"new live input creates its live effect","input":{"id":"M","historical":0,"sourceNotice":null},"expected":{"movements":[{"id":"M","historical":0}],"notices":[{"id":"auto:M"}]},"corrected":true},{"label":"history has no old notice to import","input":{"id":"M","historical":1,"sourceNotice":null},"expected":{"movements":[{"id":"M","historical":1}],"notices":[]},"corrected":true}];
for(const test of cases){
  const actual=run(test.input,test.corrected);
  assert.deepEqual(actual,test.expected,test.label);
  console.log(test.label,actual);
}
Download runnable example ↓

Check boundaries before the next load

Live M creates auto:M. Historical M with no old notice creates none under this rule.

Editable boundary records and expected outputs
CaseInput JSONExpected output JSON
New live movement{"id":"M","historical":0,"sourceNotice":null}{"movements":[{"id":"M","historical":0}],"notices":[{"id":"auto:M"}]}
History without old notice{"id":"M","historical":1,"sourceNotice":null}{"movements":[{"id":"M","historical":1}],"notices":[]}
Download editable CSV ↓

Should importing historical 1 create auto:M?

Show the worked answer

No. Preserve the historical movement and any supplied old notice; automatic live effects belong only to historical 0.

Related resources