Field operations software · Pre-launch
Jemparo
A client flags one repair on a three-item job. What should the contractor reopen, and which version of the receipt should the office keep? I built Jemparo’s field tools around handoffs like this.
Product preview
Field workspace
Work through four fictional field records. Changes stay in this page.
Shared billing integration
The delivery replay.
A subscription cancellation and a renewal can arrive out of order. Replay the sequence and inspect which events change access.
One event crosses three boundaries
The billing package verifies the raw Stripe message, checks the event against the checkout binding, then records an entitlement decision. Retries and delayed messages complicate every step. A cancellation takes precedence over a grant with the same provider timestamp.
I wrote a standalone version of this problem using Node’s crypto APIs and SQLite. It commits the delivery record, access projection and downstream notification in one transaction. A failed transaction permits a safe retry. Its local tests also cover conflicting identities, two database connections and recovery after reopening the database.
const current = this.snapshot(subscription);
if (current && (time < current.position ||
(time === current.position && rank <= current.precedence))) {
return 'stale';
}
Inspect the transaction and replay boundary
this.db.exec('BEGIN IMMEDIATE');
try {
const previous = this.db.prepare('SELECT fingerprint,result FROM inbox WHERE account=? AND event_id=?')
.get(event.account, event.id);
let response;
if (previous) {
response = previous.fingerprint === digest
? {result:previous.result, replay:true}
: {result:'identity-conflict', replay:false};
} else {
const result = this.project(event);
// A binding can arrive after the subscription event. An ACK here would
// make a later redelivery useless, so leave this particular key unclaimed.
if (result !== 'retry-unbound') {
this.db.prepare('INSERT INTO inbox VALUES(?,?,?,?)').run(event.account, event.id, digest, result);
}
options.beforeCommit?.(); // test seam for a crash after the writes
response = {result, replay:false};
}
this.db.exec('COMMIT');
return response;
} catch (error) {
this.db.exec('ROLLBACK');
throw error;
}Source explorer.
Follow the public implementation from integration logic to failure tests.
jemparo.mjsCommit a delivery
Fingerprint the normalized event and record its projection, delivery outcome and notification inside one database transaction.
receive(body, signature, options = {}) { const event = normalize(openEnvelope(body, signature, this.secret, this.clock()), this.account); // Hash normalized business fields. JSON whitespace, key order and unrelated // envelope properties can change without changing the delivery's identity. const digest = createHash('sha256').update(JSON.stringify(event)).digest('hex'); this.db.exec('BEGIN IMMEDIATE'); try { const previous = this.db.prepare('SELECT fingerprint,result FROM inbox WHERE account=? AND event_id=?') .get(event.account, event.id); let response; if (previous) { response = previous.fingerprint === digest ? {result:previous.result, replay:true} : {result:'identity-conflict', replay:false}; } else { const result = this.project(event); // A binding can arrive after the subscription event. An ACK here would // make a later redelivery useless, so leave this particular key unclaimed. if (result !== 'retry-unbound') { this.db.prepare('INSERT INTO inbox VALUES(?,?,?,?)').run(event.account, event.id, digest, result); } options.beforeCommit?.(); // test seam for a crash after the writes response = {result, replay:false}; } this.db.exec('COMMIT'); return response; } catch (error) { this.db.exec('ROLLBACK'); throw error; } }