Observation is not a new event
A browser refresh, worker restart or second status reader can observe completion again. If each observation directly sends a message, users receive repeated notices. A local notification ledger lets you retry delivery while keeping the underlying event stable.
What to do next
- 01
Create one event transactionally
When your application first records the meaningful completion transition, insert a notification event with a unique key such as task plus event type plus recipient. Enforce that uniqueness in the database.
- 02
Dispatch from delivery state
Let a notification worker attempt delivery and record its outcome separately. Use the destination transport's duplicate controls where available, but do not assume an external email or push provider offers exactly-once delivery.
- 03
Make notices useful after delays
Link to the durable task rather than embedding private media or a transient preview URL. Check the recipient's current access and preference before delivery, particularly after a long delay or project membership change.
A concrete example
Illustrative example: three pollers observe task J as completed. All attempt to insert event J:completed:user7; one row wins. A notification transport timeout creates a second delivery attempt for that event, not a second completion event.
Run the local counterexample
Local runtime fixture, executed November 16, 2026. No AISwapLab request, payment or model generation was made.
Recorded runtime: Python 3.12.10; SQLite 3.49.1. Run the complete script below using that runtime or record the version and changed behavior in your own environment. The script uses synthetic data and temporary resources only.
import sqlite3,json
def run(strategy):
c=sqlite3.connect(':memory:');c.execute('PRAGMA foreign_keys=ON')
c.executescript('CREATE TABLE event(id INTEGER PRIMARY KEY, identity TEXT UNIQUE);'
'CREATE TABLE attempt(event_id INTEGER REFERENCES event(id) ON DELETE CASCADE);')
c.execute("INSERT INTO event(identity) VALUES('J:complete:U')")
c.execute('INSERT INTO attempt VALUES(1)');c.commit()
if strategy=='replace':
c.execute("INSERT OR REPLACE INTO event(identity) VALUES('J:complete:U')")
else:
c.execute("INSERT INTO event(identity) VALUES('J:complete:U') ON CONFLICT(identity) DO NOTHING")
result={'eventIds':[r[0] for r in c.execute('SELECT id FROM event')],
'deliveryAttempts':c.execute('SELECT count(*) FROM attempt').fetchone()[0]}
c.close();return result
print(json.dumps({'replace':run('replace'),'doNothing':run('ignore')}))
Actual output from this run
{
"replace": {
"eventIds": [
2
],
"deliveryAttempts": 0
},
"doNothing": {
"eventIds": [
1
],
"deliveryAttempts": 1
}
}Use the result within its scope
The replacement statement changed the event row and removed its dependent attempt in this foreign-key-enabled schema. The conflict-do-nothing statement retained both. A unique identity alone is insufficient if conflict handling destroys the evidence it was meant to preserve. Choose conflict behavior that keeps the original event, then inspect delivery attempts as separate records.
No notification was sent. Cascade behavior follows this small SQLite schema; it does not establish email/push exactly-once delivery or behavior of another database engine.
Before you call it ready
- One event survives repeated observations.
- Delivery attempts retain the same event ID.
- Current recipient access is checked before sending.
When to stop or choose another method
Stop sending notifications directly inside every completed-status response handler; establish a durable event and explicit delivery policy first.
