@blamejs/blamejs-shop 0.2.15 → 0.2.17

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/README.md +1 -1
  3. package/lib/asset-manifest.json +5 -1
  4. package/lib/customers.js +71 -4
  5. package/lib/storefront.js +462 -0
  6. package/lib/vendor/MANIFEST.json +2 -2
  7. package/lib/vendor/blamejs/CHANGELOG.md +20 -0
  8. package/lib/vendor/blamejs/api-snapshot.json +6 -2
  9. package/lib/vendor/blamejs/examples/wiki/docker-compose.prod.yml +29 -0
  10. package/lib/vendor/blamejs/examples/wiki/docker-compose.yml +7 -0
  11. package/lib/vendor/blamejs/lib/agent-idempotency.js +15 -3
  12. package/lib/vendor/blamejs/lib/agent-orchestrator.js +39 -0
  13. package/lib/vendor/blamejs/lib/app-shutdown.js +32 -0
  14. package/lib/vendor/blamejs/lib/bounded-map.js +102 -0
  15. package/lib/vendor/blamejs/lib/cache.js +184 -23
  16. package/lib/vendor/blamejs/lib/cert.js +68 -11
  17. package/lib/vendor/blamejs/lib/cluster-storage.js +114 -10
  18. package/lib/vendor/blamejs/lib/db.js +205 -15
  19. package/lib/vendor/blamejs/lib/dual-control.js +139 -143
  20. package/lib/vendor/blamejs/lib/i18n.js +10 -1
  21. package/lib/vendor/blamejs/lib/mail-crypto-smime.js +43 -9
  22. package/lib/vendor/blamejs/lib/network-dns.js +10 -2
  23. package/lib/vendor/blamejs/lib/nonce-store.js +39 -12
  24. package/lib/vendor/blamejs/lib/queue-local.js +2 -2
  25. package/lib/vendor/blamejs/lib/redis-client.js +14 -1
  26. package/lib/vendor/blamejs/lib/subject.js +8 -1
  27. package/lib/vendor/blamejs/package.json +1 -1
  28. package/lib/vendor/blamejs/release-notes/v0.13.33.json +26 -0
  29. package/lib/vendor/blamejs/release-notes/v0.13.34.json +48 -0
  30. package/lib/vendor/blamejs/release-notes/v0.13.35.json +35 -0
  31. package/lib/vendor/blamejs/release-notes/v0.13.36.json +27 -0
  32. package/lib/vendor/blamejs/release-notes/v0.13.37.json +18 -0
  33. package/lib/vendor/blamejs/release-notes/v0.13.38.json +27 -0
  34. package/lib/vendor/blamejs/release-notes/v0.13.39.json +27 -0
  35. package/lib/vendor/blamejs/release-notes/v0.13.40.json +22 -0
  36. package/lib/vendor/blamejs/release-notes/v0.13.41.json +27 -0
  37. package/lib/vendor/blamejs/release-notes/v0.13.42.json +18 -0
  38. package/lib/vendor/blamejs/test/20-db.js +191 -0
  39. package/lib/vendor/blamejs/test/layer-0-primitives/agent-idempotency.test.js +20 -0
  40. package/lib/vendor/blamejs/test/layer-0-primitives/agent-orchestrator.test.js +33 -0
  41. package/lib/vendor/blamejs/test/layer-0-primitives/api-encrypt.test.js +35 -0
  42. package/lib/vendor/blamejs/test/layer-0-primitives/app-shutdown.test.js +64 -0
  43. package/lib/vendor/blamejs/test/layer-0-primitives/bounded-map.test.js +87 -0
  44. package/lib/vendor/blamejs/test/layer-0-primitives/cache.test.js +48 -0
  45. package/lib/vendor/blamejs/test/layer-0-primitives/cert.test.js +170 -0
  46. package/lib/vendor/blamejs/test/layer-0-primitives/cluster-storage.test.js +125 -0
  47. package/lib/vendor/blamejs/test/layer-0-primitives/codebase-patterns.test.js +92 -1
  48. package/lib/vendor/blamejs/test/layer-0-primitives/dual-control.test.js +32 -0
  49. package/lib/vendor/blamejs/test/layer-0-primitives/mail-crypto-smime.test.js +31 -0
  50. package/lib/vendor/blamejs/test/layer-0-primitives/redis-client.test.js +14 -0
  51. package/package.json +1 -1
@@ -64,6 +64,15 @@ var requestHelpers = require("./request-helpers");
64
64
  var safeJson = require("./safe-json");
65
65
  var validateOpts = require("./validate-opts");
66
66
  var { I18nError } = require("./framework-error");
67
+ var { boundedMap } = require("./bounded-map");
68
+
69
+ // Per-instance formatter caches are keyed on (locale, JSON.stringify
70
+ // formatOpts). A fixed `locales` set bounds the locale axis, but operators
71
+ // can pass fresh formatOpts shapes per call (and `Intl` options are open-
72
+ // ended), so the key space is request-influenced — cap it so it can't grow
73
+ // without limit. Evict-oldest is free here: a formatter is pure-derived and
74
+ // re-created on the next miss.
75
+ var FORMATTER_CACHE_MAX_ENTRIES = 512;
67
76
 
68
77
  var observability = lazyRequire(function () { return require("./observability"); });
69
78
 
@@ -353,7 +362,7 @@ function _interpolate(template, vars, interpolation) {
353
362
  // only with operators handing in fresh literals every call (they
354
363
  // usually pass the same shape).
355
364
  function _makeFormatterCache(make, kind, emitObs) {
356
- var cache = new Map();
365
+ var cache = boundedMap({ maxEntries: FORMATTER_CACHE_MAX_ENTRIES, policy: "evict-oldest" });
357
366
  return function getFormatter(locale, formatOpts) {
358
367
  var optsKey = formatOpts ? JSON.stringify(formatOpts) : "";
359
368
  var cacheKey = locale + "\x1f" + optsKey;
@@ -386,6 +386,25 @@ function _verifySignerInfo(si, msgBytes, signerPublicKey, auditHandle) {
386
386
  return { sigAlg: sigAlg, digestAlg: digestAlg };
387
387
  }
388
388
 
389
+ // Does this cert's public key match the raw signer key that verified the
390
+ // signature? signerBytes is the key passed to the PQC/classical verify; a
391
+ // cert exposes its key as SPKI DER. The raw subjectPublicKey is the tail of
392
+ // the SPKI (its last element), so a suffix match catches the raw-key form
393
+ // while a full-length compare catches a caller who passed the SPKI itself.
394
+ // If the key can't be exported (an algorithm this Node build can't parse),
395
+ // the cert can't be bound — return false so the caller fails closed rather
396
+ // than trusting an unverifiable binding.
397
+ function _certKeyMatches(cert, signerBytes) {
398
+ var spki;
399
+ try { spki = Buffer.from(cert.publicKey.export({ format: "der", type: "spki" })); }
400
+ catch (_e) { return false; }
401
+ if (spki.length === signerBytes.length) return Buffer.compare(spki, signerBytes) === 0;
402
+ if (signerBytes.length < spki.length) {
403
+ return Buffer.compare(spki.subarray(spki.length - signerBytes.length), signerBytes) === 0;
404
+ }
405
+ return false;
406
+ }
407
+
389
408
  function _verifyTrustChain(sd, trustAnchorCertsPem, signerPublicKey, auditHandle) {
390
409
  if (sd.certificates.length === 0) {
391
410
  throw new MailCryptoError("mail-crypto/smime/no-certs",
@@ -411,13 +430,24 @@ function _verifyTrustChain(sd, trustAnchorCertsPem, signerPublicKey, auditHandle
411
430
  "trustAnchorCertsPem[" + idx + "] parse failed: " + ((e && e.message) || String(e)));
412
431
  }
413
432
  });
414
- // Pick the leaf the cert whose public key matches the verified
415
- // signature. signerPublicKey is the PQC raw bytes; we compare
416
- // against each chain cert's exported jwk x / SPKI. Hardest path:
417
- // PQC isn't in node:crypto X509Certificate yet, so the leaf might
418
- // be ECDSA / RSA. Fall back to picking the first cert when no
419
- // other comparison applies (operator's chain is operator-curated).
420
- var leaf = chain[0];
433
+ // Bind the leaf to the key that ACTUALLY verified the signature
434
+ // (signerPublicKey). Without this, a validly-chained certificate for a
435
+ // DIFFERENT identity would pass chain validation while the signature was
436
+ // verified under an unrelated key chainVerified would assert a binding
437
+ // the code never made. Find the chain cert whose public key matches
438
+ // signerPublicKey; if none does, the supplied chain does not correspond
439
+ // to the verified signer, so fail closed.
440
+ var signerBytes = Buffer.from(signerPublicKey);
441
+ var leaf = null;
442
+ for (var lci = 0; lci < chain.length; lci += 1) {
443
+ if (_certKeyMatches(chain[lci], signerBytes)) { leaf = chain[lci]; break; }
444
+ }
445
+ if (!leaf) {
446
+ throw new MailCryptoError("mail-crypto/smime/signer-not-in-chain",
447
+ "trust-chain validation: no certificate in SignedData.certificates carries the " +
448
+ "public key that verified the signature — the supplied chain does not correspond " +
449
+ "to the verified signer");
450
+ }
421
451
  // Validity window check (RFC 5280 §4.1.2.5) — every cert in chain
422
452
  // must be within validFrom..validTo at the current wall-clock.
423
453
  var nowMs = Date.now();
@@ -444,8 +474,8 @@ function _verifyTrustChain(sd, trustAnchorCertsPem, signerPublicKey, auditHandle
444
474
  if (current.issuer === r.subject) {
445
475
  try {
446
476
  if (current.verify(r.publicKey)) {
447
- void signerPublicKey; void auditHandle;
448
- return; // chain validates
477
+ void auditHandle;
478
+ return; // chain validates (and the leaf is the verified signer)
449
479
  }
450
480
  } catch (_e) { /* fall through to next root */ }
451
481
  }
@@ -787,4 +817,8 @@ module.exports = {
787
817
  ALLOWED_HASHES: ALLOWED_HASHES,
788
818
  REFUSED_HASHES: REFUSED_HASHES,
789
819
  RSA_MIN_BITS: RSA_MIN_BITS,
820
+ // Exposed for tests — the leaf↔signer-key binding used by trust-chain
821
+ // validation (a cert matches the verified signer key iff its SPKI public
822
+ // key equals, or has as a suffix, the raw signer key bytes).
823
+ _certKeyMatches: _certKeyMatches,
790
824
  };
@@ -13,6 +13,7 @@ var safeBuffer = require("./safe-buffer");
13
13
  var safeUrl = require("./safe-url");
14
14
  var validateOpts = require("./validate-opts");
15
15
  var { defineClass } = require("./framework-error");
16
+ var { boundedMap } = require("./bounded-map");
16
17
 
17
18
  var DnsError = defineClass("DnsError", { alwaysPermanent: false });
18
19
 
@@ -89,8 +90,15 @@ function _ensureSecureDefault() {
89
90
  STATE.doh = { url: DEFAULT_DOH_URL, method: null, ca: null };
90
91
  }
91
92
 
92
- var POSITIVE_CACHE = new Map();
93
- var NEGATIVE_CACHE = new Map();
93
+ // Resolver caches are keyed on (hostname, family). Hostnames reaching the
94
+ // resolver are request-influenced (outbound HTTP targets, mail MX lookups,
95
+ // operator-supplied URLs), and expired entries are only reclaimed lazily on
96
+ // a re-query of the SAME key — so a stream of unique hostnames would grow
97
+ // these without bound. Cap them; evict-oldest is free (DNS re-resolves on
98
+ // the next miss). The cap bounds peak memory even with no periodic sweep.
99
+ var DNS_CACHE_MAX_ENTRIES = 4096;
100
+ var POSITIVE_CACHE = boundedMap({ maxEntries: DNS_CACHE_MAX_ENTRIES, policy: "evict-oldest" });
101
+ var NEGATIVE_CACHE = boundedMap({ maxEntries: DNS_CACHE_MAX_ENTRIES, policy: "evict-oldest" });
94
102
 
95
103
  function _now() { return Date.now(); }
96
104
 
@@ -45,10 +45,18 @@ var clusterStorage = require("./cluster-storage");
45
45
  var C = require("./constants");
46
46
  var safeAsync = require("./safe-async");
47
47
  var { defineClass } = require("./framework-error");
48
+ var { boundedMap } = require("./bounded-map");
48
49
 
49
50
  var NonceStoreError = defineClass("NonceStoreError");
50
51
 
51
52
  var DEFAULT_SWEEP_INTERVAL_MS = C.TIME.minutes(5);
53
+ // Memory-backend ceiling. Each request carries an attacker-choosable unique
54
+ // nonce, so between sweeps the store would otherwise grow without bound (a
55
+ // memory-amplification DoS). Capped — but a replay-protection store must
56
+ // NOT evict a live nonce to admit a new one (that reopens a replay window
57
+ // for the evicted nonce), so the cap uses the "reject" policy and the
58
+ // backend fails CLOSED at capacity (see checkAndInsert).
59
+ var DEFAULT_MAX_ENTRIES = 1000000;
52
60
 
53
61
  function _err(code, message) {
54
62
  return new NonceStoreError(code, message, true);
@@ -58,14 +66,22 @@ function _err(code, message) {
58
66
 
59
67
  function _memoryBackend(opts) {
60
68
  var sweepIntervalMs = opts.sweepIntervalMs || DEFAULT_SWEEP_INTERVAL_MS;
61
- var seen = new Map(); // nonce -> expireAt
69
+ var maxEntries = opts.maxEntries || DEFAULT_MAX_ENTRIES;
70
+ // policy "reject" — never evict a live nonce (that would reopen a replay
71
+ // window for the dropped one). At capacity the backend fails closed.
72
+ var seen = boundedMap({ maxEntries: maxEntries, policy: "reject" });
73
+ var capacityRejects = 0;
62
74
 
63
- var sweepTimer = safeAsync.repeating(function () {
75
+ function _purgeExpiredSync() {
64
76
  var now = Date.now();
77
+ var removed = 0;
65
78
  for (var entry of seen) {
66
- if (entry[1] <= now) seen.delete(entry[0]);
79
+ if (entry[1] <= now) { seen.delete(entry[0]); removed++; }
67
80
  }
68
- }, sweepIntervalMs, { name: "nonce-sweep" });
81
+ return removed;
82
+ }
83
+
84
+ var sweepTimer = safeAsync.repeating(_purgeExpiredSync, sweepIntervalMs, { name: "nonce-sweep" });
69
85
 
70
86
  function checkAndInsert(nonce, expireAt) {
71
87
  if (typeof nonce !== "string" || nonce.length === 0) {
@@ -78,17 +94,26 @@ function _memoryBackend(opts) {
78
94
  if (existing !== undefined && existing > Date.now()) {
79
95
  return Promise.resolve(false); // replay
80
96
  }
81
- seen.set(nonce, expireAt);
97
+ var stored = seen.set(nonce, expireAt);
98
+ if (!stored) {
99
+ // At capacity. Reclaim expired entries inline, then retry once.
100
+ _purgeExpiredSync();
101
+ stored = seen.set(nonce, expireAt);
102
+ }
103
+ if (!stored) {
104
+ // Still full of LIVE nonces — a genuine flood. FAIL CLOSED: we
105
+ // cannot record this nonce, so we cannot prove it is first-seen.
106
+ // Refuse it (report as "seen") rather than admit an unprotected
107
+ // request. Evicting a live nonce to make room would reopen a replay
108
+ // window, so we never evict — the request is rejected instead.
109
+ capacityRejects += 1;
110
+ return Promise.resolve(false);
111
+ }
82
112
  return Promise.resolve(true);
83
113
  }
84
114
 
85
115
  function purgeExpired() {
86
- var now = Date.now();
87
- var removed = 0;
88
- for (var entry of seen) {
89
- if (entry[1] <= now) { seen.delete(entry[0]); removed++; }
90
- }
91
- return Promise.resolve(removed);
116
+ return Promise.resolve(_purgeExpiredSync());
92
117
  }
93
118
 
94
119
  function close() {
@@ -101,8 +126,10 @@ function _memoryBackend(opts) {
101
126
  checkAndInsert: checkAndInsert,
102
127
  purgeExpired: purgeExpired,
103
128
  close: close,
104
- // Test hookdirect read of the underlying Map size
129
+ // Test hooksunderlying entry count + count of capacity fail-closed
130
+ // rejections (a nonce flood that hit the ceiling).
105
131
  _size: function () { return seen.size; },
132
+ _capacityRejects: function () { return capacityRejects; },
106
133
  };
107
134
  }
108
135
 
@@ -88,7 +88,7 @@ function _shapeLeasedRow(raw) {
88
88
  return {
89
89
  jobId: unsealed._id,
90
90
  queueName: unsealed.queueName,
91
- payload: unsealed.payload ? safeJson.parse(unsealed.payload) : null,
91
+ payload: unsealed.payload ? safeJson.parse(unsealed.payload, { maxBytes: C.BYTES.mib(64) }) : null,
92
92
  attempts: Number(unsealed.attempts),
93
93
  maxAttempts: Number(unsealed.maxAttempts),
94
94
  traceId: unsealed.traceId,
@@ -270,7 +270,7 @@ function create(_config) {
270
270
  var cron = scheduler.parseCron(unsealedRow.repeatCron);
271
271
  var nextMs = scheduler.nextCronFire(cron, new Date(nowMs), unsealedRow.repeatTimezone || null);
272
272
  await enqueue(unsealedRow.queueName,
273
- unsealedRow.payload ? safeJson.parse(unsealedRow.payload) : null,
273
+ unsealedRow.payload ? safeJson.parse(unsealedRow.payload, { maxBytes: C.BYTES.mib(64) }) : null,
274
274
  {
275
275
  // availableAt is the precise next-fire ms — pass it alone.
276
276
  // Don't also pass delaySeconds (the v0.6.22 / v0.6.23 fix
@@ -182,6 +182,11 @@ function create(opts) {
182
182
  var connected = false;
183
183
  var connecting = false;
184
184
  var closing = false;
185
+ // Tracked + unref'd reconnect timer. Tracked so close() can cancel a
186
+ // pending backoff (otherwise a reconnect scheduled before close fires
187
+ // after it and opens a fresh socket); unref'd so a backoff window doesn't
188
+ // by itself keep the event loop alive (the process-won't-exit class).
189
+ var reconnectTimer = null;
185
190
  var rxBuffer = Buffer.alloc(0);
186
191
  // FIFO of in-flight commands awaiting a response
187
192
  var pending = [];
@@ -210,7 +215,11 @@ function create(opts) {
210
215
  }
211
216
  reconnectAttempt++;
212
217
  var delay = Math.min(C.TIME.seconds(30), 100 * Math.pow(2, reconnectAttempt - 1));
213
- setTimeout(function () { _connect().catch(function () { /* will reschedule */ }); }, delay);
218
+ reconnectTimer = setTimeout(function () {
219
+ reconnectTimer = null;
220
+ _connect().catch(function () { /* will reschedule */ });
221
+ }, delay);
222
+ if (typeof reconnectTimer.unref === "function") reconnectTimer.unref();
214
223
  }
215
224
 
216
225
  function _drainPending(err) {
@@ -290,6 +299,9 @@ function create(opts) {
290
299
  }
291
300
 
292
301
  async function _connect() {
302
+ // A reconnect timer scheduled before close() can still fire afterward;
303
+ // refuse to re-open once closing so it doesn't leak a fresh socket.
304
+ if (closing) return;
293
305
  if (connected) return;
294
306
  if (connecting) {
295
307
  // Wait until current connect attempt resolves
@@ -423,6 +435,7 @@ function create(opts) {
423
435
 
424
436
  async function close() {
425
437
  closing = true;
438
+ if (reconnectTimer) { clearTimeout(reconnectTimer); reconnectTimer = null; }
426
439
  var err = _err("CLOSED", "redis client closed");
427
440
  _drainPending(err);
428
441
  if (socket) {
@@ -257,6 +257,11 @@ function rectify(subjectId, opts) {
257
257
  * override an active hold (FRCP Rule 26/37(e), GDPR Art 17(3)(e),
258
258
  * SEC Rule 17a-4, HIPAA §164.530(j)(2)).
259
259
  *
260
+ * Security: any `actor` recorded here is an audit-record field, NOT
261
+ * authentication. This primitive gates the deletion on acknowledgements
262
+ * and the legal-hold registry, not on caller identity — the caller MUST be
263
+ * authenticated and authorized by your route before invoking.
264
+ *
260
265
  * Returns `{ rowsDeleted, perTable }`. Use `b.subject.eraseHard` when
261
266
  * residual ciphertext in WAL / replicas / backups must also be made
262
267
  * undecryptable.
@@ -383,7 +388,9 @@ function erase(subjectId, opts) {
383
388
  * Art. 17 erasure shape the framework offers.
384
389
  *
385
390
  * Same legal-hold + acknowledgement gates as `b.subject.erase`.
386
- * Leader-only. Returns `{ rowsDeleted, perRowKeysDestroyed, perTable }`.
391
+ * Security: the `actor` is an audit-record field, not authentication —
392
+ * authorize the caller upstream. Leader-only.
393
+ * Returns `{ rowsDeleted, perRowKeysDestroyed, perTable }`.
387
394
  *
388
395
  * @opts
389
396
  * reason: string, // ticket reference recorded in the audit event
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/core",
3
- "version": "0.13.32",
3
+ "version": "0.13.42",
4
4
  "description": "The Node framework that owns its stack.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "blamejs contributors",
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.33",
4
+ "date": "2026-05-28",
5
+ "headline": "Encrypted-mode DB recovers from a corrupt tmpfs working copy instead of crash-looping",
6
+ "summary": "In encrypted-at-rest mode the live SQLite copy is decrypted into a tmpfs working file and re-encrypted to db.enc periodically. If that working copy was corrupted (an unclean shutdown, or a full tmpfs — Docker's /dev/shm defaults to 64 MiB), the boot path trusted it because its mtime was newer than db.enc, so db.init failed its integrity gate with \"database disk image is malformed\" identically on every boot — an unrecoverable crash loop. db now integrity-probes the newer working copy before trusting it: if it is unreadable, the working copy is discarded and db.enc (the last-good encrypted snapshot) is re-decrypted, so the next boot self-heals. db.enc is never modified by this path, and a genuinely-corrupt db.enc still fails loudly rather than wiping data. The boot error on an unreadable database is now actionable (it names the tmpfs-size cause and the recovery). The wiki production compose also gains the storage settings encrypted mode needs.",
7
+ "sections": [
8
+ {
9
+ "heading": "Fixed",
10
+ "items": [
11
+ {
12
+ "title": "Corrupt tmpfs working copy no longer causes a boot crash loop (encrypted-at-rest mode)",
13
+ "body": "`db.init`'s crash-recovery path preferred a newer tmpfs working copy over `db.enc` unconditionally. When that copy was corrupt (truncated by an unclean shutdown or a full `/dev/shm`), every boot trusted it and failed the integrity gate the same way — an unrecoverable loop. The newer working copy is now integrity-probed (`PRAGMA quick_check`); if it is unreadable it is discarded and `db.enc` — the last-good encrypted snapshot — is re-decrypted, so boot self-heals. `db.enc` is never modified, so this only ever rolls back to the persistent copy; if `db.enc` is also corrupt, boot still fails loudly (no silent data loss). A regression test pins the recovery."
14
+ },
15
+ {
16
+ "title": "Actionable boot error when the database is unreadable",
17
+ "body": "When SQLite reports a database too corrupt to even run an integrity check, the boot error now names the likely cause and recovery instead of surfacing the raw \"database disk image is malformed\": in encrypted mode it points at the tmpfs working copy and the most common operational cause (Docker's 64 MiB `/dev/shm` default — raise it via `shm_size` / `--shm-size`), or restoring `db.enc` / the DB file from backup."
18
+ },
19
+ {
20
+ "title": "Wiki production compose ships the storage encrypted mode needs",
21
+ "body": "`examples/wiki/docker-compose.prod.yml` now sets `shm_size: '512m'` (so the encrypted-mode tmpfs working copy has headroom above Docker's 64 MiB default) and mounts a persistent `wiki-data` volume at `/data` (so `db.enc` + sealed keys survive container recreate, host reboot, and image redeploys, and give a restore point). A note flags that PaaS platforms which regenerate the compose on deploy (Coolify, Dokku, CapRover, …) must set both via the platform UI — a persistent-storage mount for `/data` and a `--shm-size 512m` custom option."
22
+ }
23
+ ]
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.34",
4
+ "date": "2026-05-29",
5
+ "headline": "Corrupt TLS certs self-heal at boot, and graceful shutdown no longer loses the final DB flush",
6
+ "summary": "Two failure-mode fixes in the same family as the encrypted-DB recovery in 0.13.33. The cert manager treated a corrupt sealed cert or key worse than a missing one: a missing file re-issues via ACME, but a corrupt one let a raw decrypt error escape out of start(), so the same bad file was read on every boot — an unrecoverable crash loop. A corrupt sealed cert/key is now treated like an absent one and re-issued, and a corrupt derived meta.json is re-derived rather than fatal; the ACME account key (which binds order history) instead fails with an actionable error rather than a raw throw. On the shutdown side, an encrypted database that failed its final re-encrypt used to delete its plaintext working copy anyway, discarding every write since the last periodic flush; it now keeps the working copy so the next boot recovers it. The shutdown orchestrator also gains a hard-deadline watchdog: when the operator delegates signal handling to it, a phase that never settles can no longer hold the process open until the supervisor SIGKILLs it (which would skip the final DB re-encrypt) — the watchdog forces a clean exit, so exit handlers still flush. The wiki production and base compose files set a stop_grace_period above that budget so a docker stop or rolling redeploy lets the re-encrypt finish.",
7
+ "sections": [
8
+ {
9
+ "heading": "Fixed",
10
+ "items": [
11
+ {
12
+ "title": "A corrupt sealed TLS cert or key re-issues instead of crash-looping at boot",
13
+ "body": "`b.cert`'s start path read the sealed `cert.pem`/`key.pem` and let a raw unseal/decrypt error escape if the file was truncated or corrupt, so a managed restart read the same bad file on every boot — a crash loop, and worse handling than an absent file (which already re-issues). A corrupt sealed cert/key is now treated like a missing one: it is logged, an audit event is emitted, and the certificate is re-issued via ACME. A corrupt derived `meta.json` is likewise re-derived rather than throwing `cert/bad-meta`."
14
+ },
15
+ {
16
+ "title": "Unreadable ACME account key fails with an actionable error, not a raw decrypt throw",
17
+ "body": "Unlike a re-issuable certificate, the ACME account key binds existing order and authorization history, so it is not silently regenerated on corruption. An unreadable `account/jwk.json.sealed` now raises `cert/account-key-unreadable` naming the file and the recovery (restore from backup, or delete to register a fresh account) instead of letting a raw decrypt/parse error escape out of start()."
18
+ },
19
+ {
20
+ "title": "Encrypted DB keeps its working copy when the final shutdown re-encrypt fails",
21
+ "body": "`db.close()` re-encrypts the tmpfs working copy to `db.enc`, then deletes the working copy. If that final re-encrypt failed (a full `/dev/shm`, a full disk), the delete still ran, discarding every write since the last periodic flush and leaving only the older `db.enc`. The working copy is now kept whenever the re-encrypt fails, so the next boot's integrity-probed recovery picks up the latest writes (and still falls back to `db.enc` if the working copy is itself corrupt). `db.enc` is never modified by this path."
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "heading": "Changed",
27
+ "items": [
28
+ {
29
+ "title": "Shutdown watchdog forces a clean, DB-flushing exit if a phase hangs",
30
+ "body": "The graceful-shutdown orchestrator uses soft per-phase timeouts — on expiry the underlying work keeps running — so a phase that never settles could hold the event loop open past the grace window, after which a container supervisor SIGKILLs the process and skips the final DB re-encrypt. When the operator opts into signal handling, a watchdog now forces `process.exit` `graceMs + forceExitMarginMs` after the signal; exit runs the registered handlers (the DB re-encrypt), so the last flush still happens. A new `forceExitMarginMs` option (default 5000) tunes the headroom; set the container stop grace above `graceMs + forceExitMarginMs`."
31
+ },
32
+ {
33
+ "title": "Wiki compose sets stop_grace_period above the shutdown budget",
34
+ "body": "`examples/wiki/docker-compose.yml` and `docker-compose.prod.yml` now set `stop_grace_period: 40s`. Docker's 10s default would SIGKILL the container before the 30s shutdown budget reaches the DB re-encrypt phase, losing the final flush on a `docker stop` or rolling redeploy. The production note also reminds PaaS platforms that regenerate the compose (Coolify, Dokku, CapRover) to set the stop grace via the platform UI alongside the persistent-storage mount and `--shm-size`."
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ "heading": "Detectors",
40
+ "items": [
41
+ {
42
+ "title": "Cross-artifact guard that stop_grace_period covers the shutdown budget",
43
+ "body": "A new codebase check fails if either wiki compose file omits `stop_grace_period` or sets it below the orchestrator's `graceMs` plus the watchdog margin read from `lib/app-shutdown.js`, so raising the shutdown budget without bumping the compose — or dropping the setting — cannot silently reopen the SIGKILL-before-re-encrypt data-loss window."
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.35",
4
+ "date": "2026-05-29",
5
+ "headline": "In-memory replay, idempotency, DNS, and i18n stores gain entry-count ceilings",
6
+ "summary": "Several framework caches keyed on request-influenced input grew without an upper bound between their periodic sweeps, so a flood of unique keys could exhaust process memory faster than the sweep reclaimed it. Each now enforces a hard entry ceiling. The replay-protection nonce store is the security-sensitive one: rather than evict a live nonce to admit a new one — which would reopen a replay window for the evicted nonce — it purges expired entries and then fails closed at capacity, refusing the unrecordable request instead of admitting it unprotected. The idempotency, DNS, and i18n caches hold re-derivable values, so they evict the oldest entry instead (the worst case is a recomputed value or a single re-executed retry under flood). Ceilings are generous defaults that normal traffic never reaches; the nonce store and the agent idempotency in-memory backend expose options to tune them.",
7
+ "sections": [
8
+ {
9
+ "heading": "Security",
10
+ "items": [
11
+ {
12
+ "title": "Replay-nonce store bounds memory and fails closed under a nonce flood",
13
+ "body": "The in-memory `b.nonceStore` backend recorded every request-supplied nonce until a periodic sweep ran, so a stream of unique nonces could exhaust memory between sweeps (a memory-amplification denial of service). It now caps its entry count. Because a replay-protection store must never evict a live nonce to make room — doing so would reopen a replay window for the evicted nonce — it instead purges expired entries inline and, if still at capacity with live nonces, fails closed: the new request is refused rather than admitted without replay protection. A new `maxEntries` option tunes the ceiling (default 1,000,000)."
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "heading": "Fixed",
19
+ "items": [
20
+ {
21
+ "title": "Agent idempotency in-memory backend no longer grows without bound",
22
+ "body": "The default in-memory backend for `b.agent.idempotency` is keyed on the request-supplied idempotency key, and its garbage collector only reclaims expired rows when an operator wires a scheduler to call it — so a flood of distinct keys could grow it until the process ran out of memory. It now caps its entry count and evicts oldest-first; a dropped record just means that one key re-executes on a later retry, never a crash. A new `maxInMemoryEntries` option tunes the ceiling (default 100,000); deployments needing a hard guarantee at scale still supply a durable `store`."
23
+ },
24
+ {
25
+ "title": "DNS resolver cache is bounded",
26
+ "body": "The positive and negative resolver caches in `b.network.dns` reclaimed an expired entry only when the same hostname was looked up again, so entries for never-requeried hostnames persisted — and hostnames reaching the resolver are request-influenced (outbound request targets, mail MX lookups). Both caches now cap their entry count and evict oldest-first; DNS simply re-resolves on the next miss."
27
+ },
28
+ {
29
+ "title": "i18n formatter cache is bounded",
30
+ "body": "Per-instance `Intl` formatter caches in `b.i18n` are keyed on the locale plus a hash of the format options. The format-options shape is open-ended and caller-supplied, so the key space was request-influenced and uncapped. The cache now enforces an entry ceiling and evicts oldest-first — a formatter is pure-derived and re-created on the next miss."
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.36",
4
+ "date": "2026-05-29",
5
+ "headline": "Certificate renewal trusts the sealed cert's own expiry, not the plaintext index",
6
+ "summary": "The managed-certificate renewal check decided a cached cert was still fresh by reading expiresAt from the plaintext meta.json index that sits beside the sealed cert, rather than from the certificate itself. If that index drifted from — or was tampered relative to — the actual cert (a far-future expiry recorded over a certificate that is in fact near expiry), the manager would skip renewal and keep serving a cert that was about to expire or already had. Renewal now re-derives the expiry and fingerprint from the sealed certificate itself; meta.json is treated as an advisory convenience copy. A sealed cert that no longer parses is re-issued (the same recovery as an unreadable one), and a corrupt meta.json over a valid cert now loads cleanly from the cert instead of forcing a needless re-issue. The local job queue also bounds the size of a job payload it parses back from a stored row, matching the cap the dead-letter listing already used.",
7
+ "sections": [
8
+ {
9
+ "heading": "Security",
10
+ "items": [
11
+ {
12
+ "title": "Cert renewal re-derives expiry from the sealed certificate, not the meta.json index",
13
+ "body": "`b.cert`'s renewal short-circuit read `expiresAt` from the plaintext `meta.json` written beside each sealed cert. Because that index can drift from the actual certificate (or be altered independently of it), a far-future value over an actually-expiring cert would suppress renewal and serve a cert past — or about to pass — its validity. The renewal decision now parses the expiry and fingerprint from the sealed certificate itself on load, so `meta.json` is advisory only. A sealed cert that will not parse is treated as corrupt and re-issued; a corrupt `meta.json` over an otherwise-valid cert loads from the cert without a needless re-issue."
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "heading": "Fixed",
19
+ "items": [
20
+ {
21
+ "title": "Local job queue bounds the size of a payload parsed back from a stored row",
22
+ "body": "When the local queue leased a job or re-enqueued a repeating one, it parsed the job payload back from its stored row without an upper size bound, unlike the dead-letter listing which already capped it. A row with an oversized payload (a corrupted or tampered store) could force an unbounded parse. Both paths now cap the parse at the same 64 MiB ceiling the dead-letter path uses."
23
+ }
24
+ ]
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.37",
4
+ "date": "2026-05-29",
5
+ "headline": "Encrypted-mode DB refuses writes before a full tmpfs corrupts it",
6
+ "summary": "In encrypted-at-rest mode the live SQLite working copy is on a tmpfs (Docker's /dev/shm defaults to 64 MiB). If that fills — an append-only audit chain and session rows grow over time — SQLite hits ENOSPC and the working copy is corrupted. Earlier releases made that corruption self-heal on the next boot by rolling back to the last encrypted snapshot, but the rollback still loses writes since the last flush. This adds the prevention side: a periodic free-space probe refuses growth writes (INSERT / UPDATE / REPLACE) with a clear db/storage-low error once free space drops below a threshold, before the tmpfs fills. DELETE and reads stay available so retention can reclaim space and the application keeps serving, and the refusal lifts automatically once free space recovers. The threshold defaults to 16 MiB of headroom and is tunable; the guard is encrypted-mode only.",
7
+ "sections": [
8
+ {
9
+ "heading": "Security",
10
+ "items": [
11
+ {
12
+ "title": "Free-space guard refuses growth writes before the tmpfs working copy fills",
13
+ "body": "`b.db` in encrypted-at-rest mode now probes free space on the tmpfs holding the working copy and, when it falls below `minFreeBytes` (default 16 MiB), refuses `INSERT` / `UPDATE` / `REPLACE` with a clear `db/storage-low` error instead of letting the write run the mount out of space and corrupt the database. `DELETE`, reads, and DDL stay available so retention can prune and the app keeps serving; the refusal clears automatically when free space recovers. The error message points at the cause (Docker's 64 MiB `/dev/shm` default) and the fix (`shm_size` / `--shm-size`, or pruning). Set `minFreeBytes` to tune the headroom, or `0` to disable. This complements the existing boot-time recovery: prevention (fail clear, keep recent writes) ahead of recovery (roll back to the last snapshot)."
14
+ }
15
+ ]
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.38",
4
+ "date": "2026-05-29",
5
+ "headline": "Atomic cache tag invalidation, and a clusterStorage.transaction primitive for multi-statement framework writes",
6
+ "summary": "The cluster cache stored a value and its tag index with separate statements, so two concurrent writes to the same key could interleave their tag updates and leave the index out of step with the value — a later tag-based invalidation would then miss the key, letting a stale (possibly authorization-bearing) value survive a wipe. The value and tag writes now commit as one atomic unit. The enabling piece is a new b.clusterStorage.transaction primitive that runs a multi-statement read-modify-write all-or-nothing against the active backend — the external DB's pooled transaction in cluster mode, and a serialized transaction on the shared SQLite connection in single-node mode (so no concurrent statement can interleave into an open transaction).",
7
+ "sections": [
8
+ {
9
+ "heading": "Added",
10
+ "items": [
11
+ {
12
+ "title": "b.clusterStorage.transaction(fn) — atomic multi-statement framework-state writes",
13
+ "body": "Runs `fn` inside one transaction against the active backend so a multi-statement read-modify-write commits all-or-nothing. `fn` receives a transaction handle with the same `execute` / `executeOne` / `executeAll` surface, scoped to the open transaction. Cluster mode uses the external DB's pooled transaction (with its deadlock retry); single-node mode serializes against other transactions and against `execute` on the shared SQLite connection, so a concurrent statement cannot interleave into an open transaction. Use the handle's methods inside `fn` — calling the module-level `execute` from within `fn` would wait on the very transaction it is running."
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "heading": "Fixed",
19
+ "items": [
20
+ {
21
+ "title": "Cluster cache tag invalidation can no longer miss a key under concurrent writes",
22
+ "body": "The cluster cache wrote a value (`INSERT ... ON CONFLICT DO UPDATE`) and then rewrote its tag index (`DELETE` prior tags, `INSERT` new ones) as separate statements. Two concurrent `set()`s on the same key could interleave those tag statements, leaving the tag index inconsistent with the value — so a later `invalidateTag` could miss the key and a stale value would survive the wipe. The value and tag writes now run inside a single `clusterStorage.transaction`, so a concurrent writer observes either the whole prior state or the whole new state, never a mix."
23
+ }
24
+ ]
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.39",
4
+ "date": "2026-05-29",
5
+ "headline": "Dual-control approvals are atomic — no quorum bypass or double-consume under concurrency",
6
+ "summary": "The dual-control approval store read a grant, mutated it in memory, and wrote it back with an await in between — a non-atomic read-modify-write. Under concurrent calls (two approvals, or a retried one) each could act on a stale snapshot: the same approver could be appended twice and reach the M-of-N quorum with a single human, or a single-use grant could be consumed twice. approve / consume / revoke / cancel now commit through a new atomic cache.update primitive, so the check and the mutation are one indivisible step. The new b.cache.update is available to application code too — the memory backend is atomic by single-thread, and the cluster backend uses a transaction with compare-and-set so a concurrent writer on another node cannot lose an update.",
7
+ "sections": [
8
+ {
9
+ "heading": "Security",
10
+ "items": [
11
+ {
12
+ "title": "Dual-control quorum and single-use guarantees hold under concurrent approvals",
13
+ "body": "`b.dualControl` persisted each grant through a cache read → in-memory mutate → write-back. Because the read and the write were separate awaited steps, two concurrent `approve` calls (or a retried one behind a load balancer) could each read the same pre-approval snapshot, so the duplicate-approver guard passed twice and the same approver was counted toward the M-of-N quorum twice — reaching quorum with one human. The same shape let two concurrent `consume` calls each see an unconsumed grant and both run the destructive operation. `approve` / `consume` / `revoke` / `cancel` now perform the check-and-mutate atomically via `cache.update`, so exactly one concurrent caller wins each transition."
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "heading": "Added",
19
+ "items": [
20
+ {
21
+ "title": "b.cache.update(key, mutatorFn, opts?) — atomic read-modify-write",
22
+ "body": "Reads the current value, calls `mutatorFn(current | null)`, and commits the result in one operation so a concurrent writer cannot clobber the change — the lost-update race that makes a plain `get` → mutate → `set` unsafe for counters, sets, and quorum state. The memory backend is atomic by single-thread; the cluster backend runs a transaction with a compare-and-set (and retries on contention) so the guarantee holds across nodes. `mutatorFn` returns `{ value }` to commit, `{ abort: data }` to leave the entry untouched and surface `data`, or `{ delete: true }` to remove it; the call resolves to `{ updated, value }`, `{ updated, deleted }`, or `{ aborted }`."
23
+ }
24
+ ]
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.40",
4
+ "date": "2026-05-29",
5
+ "headline": "Redis client stops leaking a socket and blocking exit after close; DB exit-handler registers once",
6
+ "summary": "Two handle-lifecycle fixes. The Redis client's reconnect backoff used an untracked, non-unref'd timer: during a backoff window it alone could keep the event loop alive (a process that won't exit), and a reconnect scheduled before close() fired afterward and opened a fresh socket because the connect path didn't re-check the closing flag. The timer is now tracked, unref'd, cancelled in close(), and the connect path refuses to re-open once closing. Separately, the encrypted database registered its process-exit final-flush handler on every init(), so repeated init/close cycles (long test runs, hot reload) accumulated 'exit' listeners toward the MaxListenersExceeded warning; it now registers once for the process lifetime.",
7
+ "sections": [
8
+ {
9
+ "heading": "Fixed",
10
+ "items": [
11
+ {
12
+ "title": "Redis client cancels its reconnect timer on close and won't re-open a closed connection",
13
+ "body": "The reconnect backoff scheduled `setTimeout(reconnect, delay)` without keeping a handle, without `unref()`, and the reconnect path checked only `connected`/`connecting` — not `closing`. So a backoff window could by itself hold the process open (it won't exit), and a reconnect scheduled before `close()` would fire afterward and open a fresh socket with listeners — a leak after explicit close. The timer is now tracked and `unref()`'d (a backoff no longer blocks exit), cancelled in `close()`, and the connect path returns early once closing so no socket is opened after close."
14
+ },
15
+ {
16
+ "title": "Encrypted DB registers its process-exit flush handler once, not per init()",
17
+ "body": "`b.db.init()` in encrypted mode added a `process.on(\"exit\")` final-flush handler on every call. Across repeated init/close cycles — long test suites, hot reload, embedded re-inits — these accumulated and tripped Node's MaxListenersExceeded warning (and grew memory slightly). The handler is now registered once for the process lifetime, guarded by a module flag, and still flushes whichever encrypted DB is open at exit time."
18
+ }
19
+ ]
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.41",
4
+ "date": "2026-05-29",
5
+ "headline": "Agent registry reads can be tenant-scoped; compliance-erasure docs clarify actor is an audit field",
6
+ "summary": "The agent orchestrator's registry reads (list and lookup) gated only on the flat agent-registry:read scope, so any holder could enumerate every tenant's agents and resolve a handle to one — even though the event bus already scopes subscribe and delivery by tenant. The orchestrator now mirrors that: with the new tenantScope option enabled, list returns only the actor's own tenant's agents and lookup refuses a cross-tenant name, unless the actor holds the framework cross-tenant-admin scope. Off by default, so single-tenant deployments are unaffected. Separately, the subject-erasure docs now state explicitly that the recorded actor is an audit field, not authentication — the caller must be authorized upstream.",
7
+ "sections": [
8
+ {
9
+ "heading": "Added",
10
+ "items": [
11
+ {
12
+ "title": "Tenant-scoped agent registry reads (opts.tenantScope)",
13
+ "body": "`b.agent.orchestrator.create({ tenantScope: true })` now scopes `list` and `lookup` to the calling actor's tenant: `list` filters out agents in other tenants and `lookup` returns null for a cross-tenant name, unless the actor holds the cross-tenant-admin scope (`b.agent.tenant.CROSS_TENANT_ADMIN_SCOPE`). This closes a cross-tenant metadata-enumeration and handle-acquisition path — `agent-registry:read` alone no longer exposes other tenants' agents — and mirrors the tenant scoping the event bus enforces on subscribe and delivery. The option defaults off; existing single-tenant orchestrators behave exactly as before. The `tenantId` argument to `list` remains a convenience filter, distinct from this authorization boundary."
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "heading": "Changed",
19
+ "items": [
20
+ {
21
+ "title": "Subject-erasure docs clarify the actor is an audit field, not authentication",
22
+ "body": "`b.subject.erase` and `b.subject.eraseHard` gate the deletion on operator acknowledgements and the legal-hold registry, not on caller identity. Their documentation now states explicitly that the recorded `actor` is an audit-record field, not authentication — the caller MUST be authenticated and authorized by the route before invoking. No behavior change; this removes an implicit assumption that could otherwise be read as the primitive authorizing the call."
23
+ }
24
+ ]
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "../scripts/release-notes-schema.json",
3
+ "version": "0.13.42",
4
+ "date": "2026-05-29",
5
+ "headline": "S/MIME trust-chain validation binds the leaf to the key that verified the signature",
6
+ "summary": "When b.mail.crypto.smime.verify is given trust anchors, it validates the supplied certificate chain — but it picked the chain leaf unconditionally (the first cert) and never tied it to signerPublicKey, the key that actually verified the signature. A SignedData blob could therefore carry a validly-chained certificate for one identity while the signature was verified under an unrelated key, and the chain-validated result would imply a cert↔signer binding the code never made. Chain validation now selects the leaf as the certificate whose public key matches signerPublicKey, and refuses (signer-not-in-chain) when no certificate in the chain carries that key — so a chain-validated signature is bound to the cert it claims.",
7
+ "sections": [
8
+ {
9
+ "heading": "Security",
10
+ "items": [
11
+ {
12
+ "title": "Trust-chain leaf is bound to the verified signer key",
13
+ "body": "`smime.verify({ trustAnchorCertsPem })` validated the supplied chain starting from `chain[0]` without checking that the leaf's public key was the one that verified the signature (the operator-supplied `signerPublicKey`). A crafted `SignedData` could pair a validly-chained certificate for identity A with a signature verified under an unrelated key, and the chain-valid result would assert a binding that didn't hold. The chain walk now selects the leaf as the certificate whose public key equals `signerPublicKey` (matched against the certificate's SPKI, raw key or full-encoding form), and throws `mail-crypto/smime/signer-not-in-chain` when no certificate in `SignedData.certificates` carries that key. A certificate whose key cannot be extracted is treated as a non-match, so validation fails closed rather than trusting an unverifiable binding."
14
+ }
15
+ ]
16
+ }
17
+ ]
18
+ }