@tokenoftrust/storefront-runner 7.11.4 → 7.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -315,22 +315,6 @@ export class SourceAuthorityStore {
315
315
  mutation,
316
316
  ],
317
317
  });
318
- for (const r of records.filter(
319
- (r) => r.kind === "check" || r.kind === "result",
320
- )) {
321
- const controlId = `source-control:${await digestJson({ key, kind: r.kind, id: r.id })}`;
322
- statements.push({
323
- sql: `INSERT INTO scrappy_commerce_inbox(tenant_id,stage,source,source_event_id,event_version,idempotency_key,payload_digest,received_at) SELECT tenant_id,stage,source,?,1,?,?,? FROM commerce_source_authority WHERE ${WHERE} AND mutation_id=?`,
324
- params: [
325
- controlId,
326
- controlId,
327
- r.digest,
328
- now,
329
- ...keyParams(key),
330
- mutation,
331
- ],
332
- });
333
- }
334
318
  if (replay)
335
319
  statements.push({
336
320
  sql: `INSERT INTO scrappy_caller_replay(tenant_id,stage,issuer,jti,seen_at) SELECT tenant_id,stage,?,?,? FROM commerce_source_authority WHERE ${WHERE} AND mutation_id=?`,
@@ -359,25 +343,40 @@ export class SourceAuthorityStore {
359
343
  mutation,
360
344
  ],
361
345
  });
362
- statements.push({
363
- sql: `INSERT INTO scrappy_shipment_audit(audit_id,tenant_id,stage,order_id,at,actor_id,kind,from_state,to_state)
364
- SELECT ?,tenant_id,stage,order_id,?,'commerce-source-authority','source-authority','source',?
365
- FROM scrappy_commerce_orders WHERE tenant_id=? AND stage=? AND source=? AND source_order_id=?
366
- AND EXISTS(SELECT 1 FROM commerce_source_authority WHERE ${WHERE} AND mutation_id=?)`,
367
- params: [
368
- `audit_${crypto.randomUUID()}`,
369
- `${now}#source-${state.version}`,
370
- state.pending || state.sync || state.holds.length || state.budget
371
- ? "held"
372
- : "verified",
373
- key.tenantId,
374
- key.stage,
375
- key.source,
376
- key.sourceOrderId,
377
- ...keyParams(key),
378
- mutation,
379
- ],
380
- });
346
+ // Record a source-authority audit entry only when durable authority health transitions
347
+ // (ignoring transient pending_check flips during healthy renewals).
348
+ const prevDurableStatus = !old
349
+ ? "none"
350
+ : !old.accepted_ledger_generation ||
351
+ old.source_sync_pending ||
352
+ old.unresolved_count ||
353
+ old.authority_budget
354
+ ? "held"
355
+ : "verified";
356
+ const nextDurableStatus =
357
+ !state.accepted || state.sync || state.holds.length > 0 || state.budget
358
+ ? "held"
359
+ : "verified";
360
+ if (nextDurableStatus !== prevDurableStatus) {
361
+ statements.push({
362
+ sql: `INSERT INTO scrappy_shipment_audit(audit_id,tenant_id,stage,order_id,at,actor_id,kind,from_state,to_state)
363
+ SELECT ?,tenant_id,stage,order_id,?,'commerce-source-authority','source-authority',?,?
364
+ FROM scrappy_commerce_orders WHERE tenant_id=? AND stage=? AND source=? AND source_order_id=?
365
+ AND EXISTS(SELECT 1 FROM commerce_source_authority WHERE ${WHERE} AND mutation_id=?)`,
366
+ params: [
367
+ `audit_${crypto.randomUUID()}`,
368
+ `${now}#source-${state.version}`,
369
+ prevDurableStatus,
370
+ nextDurableStatus,
371
+ key.tenantId,
372
+ key.stage,
373
+ key.source,
374
+ key.sourceOrderId,
375
+ ...keyParams(key),
376
+ mutation,
377
+ ],
378
+ });
379
+ }
381
380
  const result = await this.db.batchResults(statements);
382
381
  return Boolean(result[0]?.results.length);
383
382
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "7.11.4",
3
+ "version": "7.11.5",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",