@twinsearth/w2m-dsh-plugin 1.0.5 → 1.0.6
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.
- package/CHANGELOG.md +52 -0
- package/cordis.patch.yml +20 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/src/plugin/tools.mjs +1 -1
- package/src/relay/persistence.mjs +249 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented here.
|
|
4
4
|
|
|
5
|
+
## [1.0.6] — 2026-10-17
|
|
6
|
+
|
|
7
|
+
**DSH-GPW now ships *findable*: installed with the package, present in the plugin list, and off until an operator
|
|
8
|
+
turns it on.**
|
|
9
|
+
|
|
10
|
+
### What v1.0.5 got wrong
|
|
11
|
+
|
|
12
|
+
It shipped the subpath export `@twinsearth/w2m-dsh-plugin/gpw` and no config row. **A plugin the composed tree does
|
|
13
|
+
not mention is a plugin the plugin manager cannot list** -- so "enable it manually" had **nothing to click**, and
|
|
14
|
+
the only way in was hand-editing a profile patch.
|
|
15
|
+
|
|
16
|
+
**An optional component nobody can find is not optional, it is absent.** That is the same distinction as the seven
|
|
17
|
+
written-but-unreachable modules in this repository, seen from the user's side instead of the code's.
|
|
18
|
+
|
|
19
|
+
### The shape that fixes it
|
|
20
|
+
|
|
21
|
+
The package's own bundle patch now carries a second entry:
|
|
22
|
+
|
|
23
|
+
- id: dsh-gpw
|
|
24
|
+
name: '@twinsearth/w2m-dsh-plugin/gpw'
|
|
25
|
+
disabled: true
|
|
26
|
+
config:
|
|
27
|
+
maxPerWindow: 10
|
|
28
|
+
windowMs: 60000
|
|
29
|
+
minGapMs: 3000
|
|
30
|
+
|
|
31
|
+
**`disabled: true` is the load-bearing field.** The row exists, so the component appears; the toggle is off, so
|
|
32
|
+
nothing answers `approval/request`; and **flipping it in the UI is the whole enablement step** -- no file edit, no
|
|
33
|
+
restart of anything but the client.
|
|
34
|
+
|
|
35
|
+
**It stays in the same `insert:` list as the w2m row**, and that is still the correct form: this is an insert
|
|
36
|
+
because no earlier layer creates a `dsh-gpw` row. (A *bare* `- id:` patch aimed at a nonexistent row is skipped
|
|
37
|
+
silently -- the failure recorded in this file and in TROUBLESHOOTING 3.2.)
|
|
38
|
+
|
|
39
|
+
### The distinction the two releases now make
|
|
40
|
+
|
|
41
|
+
| | v1.0.5 | v1.0.6 |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| Installs with the package | yes | yes |
|
|
44
|
+
| Appears in the plugin manager | **no** | **yes** |
|
|
45
|
+
| Enabled by default | no | no |
|
|
46
|
+
| How you turn it on | hand-edit a profile patch | **click its toggle** |
|
|
47
|
+
|
|
48
|
+
**Not verified: that the toggle actually flips it on and that it then intercepts.** That needs a live host. The
|
|
49
|
+
observable evidence is its own startup line followed by its counted line --
|
|
50
|
+
|
|
51
|
+
approval-ratelimit: active -- at most 10 auto-approvals per 60 s, at least 3000 ms apart, process-wide
|
|
52
|
+
approval-ratelimit: N auto-approved, M deferred to the human
|
|
53
|
+
|
|
54
|
+
-- **because without the second line, "mounted and working" and "mounted and doing nothing" are the same picture**,
|
|
55
|
+
which is the failure this watchdog's own counters exist to prevent.
|
|
56
|
+
|
|
5
57
|
## [1.0.5] — 2026-10-17
|
|
6
58
|
|
|
7
59
|
**DSH-GPW ships as an optional sub-plugin, and the reason it never activated is fixed.**
|
package/cordis.patch.yml
CHANGED
|
@@ -115,3 +115,23 @@
|
|
|
115
115
|
allowedCommands: []
|
|
116
116
|
p2pMode: auto
|
|
117
117
|
stunServers: []
|
|
118
|
+
# DSH-GPW (Global Permission Watchdog) ships with this package and is **off until an operator turns it on**.
|
|
119
|
+
#
|
|
120
|
+
# It is in this insert list rather than left out of the tree entirely, because a plugin the composed tree does
|
|
121
|
+
# not mention is a plugin the plugin manager cannot list -- and then "enable it manually" has no control to
|
|
122
|
+
# click. **A row with `disabled: true` is the shape that makes it installable with the package and switchable
|
|
123
|
+
# from the UI**: the component shows up, its toggle is off, and flipping it needs no file edit.
|
|
124
|
+
#
|
|
125
|
+
# Found this way, not assumed: v1.0.5 shipped the subpath export but no row, so the watchdog was reachable only
|
|
126
|
+
# by hand-editing a profile patch. **An optional component nobody can find is not optional, it is absent.**
|
|
127
|
+
#
|
|
128
|
+
# What it does once enabled: answers `approval/request` with at most 10 auto-approvals per rolling 60 s, at
|
|
129
|
+
# least 3000 ms apart, and defers everything past that to the human prompt, where it waits.
|
|
130
|
+
- id: dsh-gpw
|
|
131
|
+
name: '@twinsearth/w2m-dsh-plugin/gpw'
|
|
132
|
+
disabled: true
|
|
133
|
+
config:
|
|
134
|
+
maxPerWindow: 10
|
|
135
|
+
windowMs: 60000
|
|
136
|
+
minGapMs: 3000
|
|
137
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twinsearth/w2m-dsh-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Run one project across your own Windows and macOS machines from a single DeepSeek account, through 11 w2m_* tools. Four coordination modes (replicate, split, broadcast, pipeline) and six aggregate verdicts (consistent, divergent, divergent-platform, failed, partial, unverifiable). P2P hole punching by default, with a bundled relay, STUN responder and ledger fallback, so the fleet needs no third-party service. Joining needs a pairing code plus autoStartAgent: true; installing alone does not join.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "twinsearth-w2m-dsh",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"description": "Run one project across your own Windows and macOS machines from a single DeepSeek account, through 11 w2m_* tools. Four coordination modes (replicate, split, broadcast, pipeline) and six aggregate verdicts (consistent, divergent, divergent-platform, failed, partial, unverifiable). P2P hole punching by default, with a bundled relay, STUN responder and ledger fallback, so the fleet needs no third-party service. Joining needs a pairing code plus autoStartAgent: true; installing alone does not join.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
package/src/plugin/tools.mjs
CHANGED
|
@@ -208,7 +208,7 @@ const MAX_STAGES = 16;
|
|
|
208
208
|
* `package.json` during `scripts/pack.mjs` rather than hand-maintained, and `W2M_PLUGIN_VERSION`
|
|
209
209
|
* overrides it at runtime for tests and packagers.
|
|
210
210
|
*/
|
|
211
|
-
const PLUGIN_VERSION = '1.0.
|
|
211
|
+
const PLUGIN_VERSION = '1.0.6';
|
|
212
212
|
|
|
213
213
|
/** How long any single HTTP call may take before it is aborted, in milliseconds. */
|
|
214
214
|
const DEFAULT_REQUEST_TIMEOUT_MS = 15_000;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* `<state>/devices.json` atomic snapshot (tmp file + rename)
|
|
5
5
|
* `<state>/ledger.jsonl` append-only, one JSON object per line
|
|
6
6
|
* `<state>/operator-token.txt` single line, 0600
|
|
7
|
+
* `<state>/blobs/<aa>/<sha256>` content-addressed bytes, v1.0.7 (see `putBlob`)
|
|
7
8
|
*
|
|
8
9
|
* This is the only relay module allowed to touch the filesystem.
|
|
9
10
|
* Corruption is never silent: every skipped line / unreadable snapshot is
|
|
@@ -12,12 +13,31 @@
|
|
|
12
13
|
|
|
13
14
|
import fs from 'node:fs';
|
|
14
15
|
import path from 'node:path';
|
|
16
|
+
import { createHash } from 'node:crypto';
|
|
15
17
|
|
|
16
18
|
import { rfc3339 } from './state.mjs';
|
|
17
19
|
|
|
18
20
|
export const DEVICES_FILE = 'devices.json';
|
|
19
21
|
export const LEDGER_FILE = 'ledger.jsonl';
|
|
20
22
|
export const OPERATOR_TOKEN_FILE = 'operator-token.txt';
|
|
23
|
+
/** v1.0.7: the content-addressed blob directory, and the two caps that keep it bounded. */
|
|
24
|
+
export const BLOB_DIR = 'blobs';
|
|
25
|
+
export const MAX_BLOB_BYTES = 8 * 1024 * 1024;
|
|
26
|
+
export const MAX_BLOBS = 256;
|
|
27
|
+
/**
|
|
28
|
+
* v1.0.7: **which fleet wrote each blob.**
|
|
29
|
+
*
|
|
30
|
+
* Content addressing keys a blob by its own hash, and a hash knows nothing about fleets. So two fleets that store
|
|
31
|
+
* the same bytes land at the same path -- and without this index, the second one could read the first one's content.
|
|
32
|
+
* **A content-addressed store with no ownership record is not isolated, it is shared.**
|
|
33
|
+
*
|
|
34
|
+
* The index is a separate document rather than part of the path (`blobs/<fleet>/<aa>/<hash>`) for one concrete
|
|
35
|
+
* reason: **deduplication is only sound when the content is identical**, and identical bytes stored twice would
|
|
36
|
+
* otherwise occupy two entries. The path stays a pure function of the content; the fleet is metadata.
|
|
37
|
+
*
|
|
38
|
+
* Shape: `{ "<sha256>": { fleet_id: string|null, added_at_ms: number } }`.
|
|
39
|
+
*/
|
|
40
|
+
export const BLOB_INDEX_FILE = 'index.json';
|
|
21
41
|
|
|
22
42
|
/** Ledger entry types understood by `RabbitState#restore`. */
|
|
23
43
|
export const LEDGER_TYPES = Object.freeze([
|
|
@@ -250,8 +270,232 @@ export class Persistence {
|
|
|
250
270
|
return true;
|
|
251
271
|
}
|
|
252
272
|
|
|
273
|
+
/* ------------------------------------------------------------------------------------------- */
|
|
274
|
+
/* v1.0.7: content-addressed blobs — the fleet sync channel (#1) */
|
|
275
|
+
/* ------------------------------------------------------------------------------------------- */
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Store bytes under their own SHA-256, and read them back by that hash.
|
|
279
|
+
*
|
|
280
|
+
* ## Why the relay may carry bytes at all, when it deliberately carries none today
|
|
281
|
+
*
|
|
282
|
+
* The relay persists `stdout_sha256` and never the text, and `src/agent/storage.mjs` records why that matters:
|
|
283
|
+
* `memory.jsonl` on each machine is the only durable copy of what a command printed. **That invariant is about
|
|
284
|
+
* the relay not becoming a document store** — it never interprets content and never asserts that content is
|
|
285
|
+
* authentic.
|
|
286
|
+
*
|
|
287
|
+
* A blob keyed by **its own hash** preserves both halves. The relay still interprets nothing; **the hash is what
|
|
288
|
+
* says the bytes are the bytes**, exactly as `stdout_sha256` does for a result. The only thing that is new is
|
|
289
|
+
* that a hash the relay already holds can now have its bytes fetched from the same place.
|
|
290
|
+
*
|
|
291
|
+
* ## The two limits, because an uncapped writer is what caused the original incident
|
|
292
|
+
*
|
|
293
|
+
* `storage.mjs`'s header records the incident that produced its whole design: a single uncapped writer reached
|
|
294
|
+
* 100% filesystem at 14.7 GB/day. A blob channel with no ceiling reproduces that on the relay, so:
|
|
295
|
+
*
|
|
296
|
+
* * **8 MiB per blob** — a `fleet-memory.md` is tens of KB; this is three orders of magnitude of headroom.
|
|
297
|
+
* Larger content is an archive, not a memory.
|
|
298
|
+
* * **256 blobs** — bounded *count* matters as much as bounded size: 256 × 8 MiB caps a fleet's share at
|
|
299
|
+
* 2 GiB regardless of what it writes.
|
|
300
|
+
*
|
|
301
|
+
* Eviction is oldest-first and **never takes the last blob**: deleting the only copy of a fact is the failure
|
|
302
|
+
* `UNDELETABLE_TIERS` exists to prevent locally.
|
|
303
|
+
*
|
|
304
|
+
* @param {Buffer} bytes
|
|
305
|
+
* @param {{fleetId?: string|null}} [options] the owning fleet, recorded so another fleet cannot read it back
|
|
306
|
+
* @returns {{ok:true, hash:string, bytes:number, evicted:string[]}|{ok:false, reason:string, detail:string}}
|
|
307
|
+
*/
|
|
308
|
+
putBlob(bytes, options = {}) {
|
|
309
|
+
if (!this.enabled) return { ok: false, reason: 'PERSISTENCE_DISABLED', detail: 'the relay has no state directory' };
|
|
310
|
+
if (!Buffer.isBuffer(bytes) || bytes.length === 0) {
|
|
311
|
+
return { ok: false, reason: 'BLOB_EMPTY', detail: 'an empty blob is a caller bug, not content' };
|
|
312
|
+
}
|
|
313
|
+
if (bytes.length > MAX_BLOB_BYTES) {
|
|
314
|
+
return {
|
|
315
|
+
ok: false,
|
|
316
|
+
reason: 'BLOB_TOO_LARGE',
|
|
317
|
+
detail: `${bytes.length} bytes exceeds the ${MAX_BLOB_BYTES}-byte limit`,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
const hash = createHash('sha256').update(bytes).digest('hex');
|
|
321
|
+
const file = this.blobFile(hash);
|
|
322
|
+
if (file === null) return { ok: false, reason: 'PERSISTENCE_DISABLED', detail: 'no blob directory' };
|
|
323
|
+
|
|
324
|
+
const index = this.readBlobIndex();
|
|
325
|
+
const fleetId = typeof options.fleetId === 'string' && options.fleetId !== '' ? options.fleetId : null;
|
|
326
|
+
|
|
327
|
+
// Content addressing makes the write idempotent: the same bytes always land at the same path.
|
|
328
|
+
if (fs.existsSync(file)) {
|
|
329
|
+
/**
|
|
330
|
+
* Already stored. **The first writer's fleet keeps ownership** -- re-assigning it on a second write would let
|
|
331
|
+
* one fleet claim a blob another fleet already owns by simply PUT-ting the same bytes, which is the same
|
|
332
|
+
* failure as having no index at all.
|
|
333
|
+
*/
|
|
334
|
+
const entry = index[hash];
|
|
335
|
+
if (entry === undefined) {
|
|
336
|
+
index[hash] = { fleet_id: fleetId, added_at_ms: this._now() };
|
|
337
|
+
this.writeBlobIndex(index);
|
|
338
|
+
}
|
|
339
|
+
return { ok: true, hash, bytes: bytes.length, evicted: [] };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const evicted = this.evictBlobsFor(1);
|
|
343
|
+
for (const gone of evicted) delete index[gone];
|
|
344
|
+
try {
|
|
345
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
346
|
+
const tmp = `${file}.tmp-${process.pid}-${this._now()}`;
|
|
347
|
+
fs.writeFileSync(tmp, bytes);
|
|
348
|
+
fs.renameSync(tmp, file);
|
|
349
|
+
} catch (error) {
|
|
350
|
+
this.warn(BLOB_DIR, `blob write failed: ${error?.message ?? String(error)}`);
|
|
351
|
+
return { ok: false, reason: 'BLOB_WRITE_FAILED', detail: error?.message ?? String(error) };
|
|
352
|
+
}
|
|
353
|
+
index[hash] = { fleet_id: fleetId, added_at_ms: this._now() };
|
|
354
|
+
this.writeBlobIndex(index);
|
|
355
|
+
return { ok: true, hash, bytes: bytes.length, evicted };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* The bytes for a hash, or `null`.
|
|
360
|
+
*
|
|
361
|
+
* Never throws -- an unreadable blob is a miss, not a crash -- and **when `fleetId` is supplied, a blob owned by a
|
|
362
|
+
* different fleet is a miss too.** The caller cannot distinguish "no such blob" from "not yours", which is
|
|
363
|
+
* deliberate: a distinguishable refusal tells a prober that a hash exists on this relay.
|
|
364
|
+
*
|
|
365
|
+
* @param {string} hash
|
|
366
|
+
* @param {{fleetId?: string|null|undefined}} [options] omit `fleetId` entirely for an unscoped read
|
|
367
|
+
*/
|
|
368
|
+
getBlob(hash, options = {}) {
|
|
369
|
+
const file = this.blobFile(hash);
|
|
370
|
+
if (file === null) return null;
|
|
371
|
+
if (options.fleetId !== undefined) {
|
|
372
|
+
const entry = this.readBlobIndex()[hash];
|
|
373
|
+
// A blob with no recorded owner predates the index or was written unscoped; it is not this fleet's.
|
|
374
|
+
if (entry === undefined || entry.fleet_id !== options.fleetId) return null;
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
return fs.readFileSync(file);
|
|
378
|
+
} catch {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
hasBlob(hash) {
|
|
384
|
+
const file = this.blobFile(hash);
|
|
385
|
+
if (file === null) return false;
|
|
386
|
+
try {
|
|
387
|
+
return fs.statSync(file).isFile();
|
|
388
|
+
} catch {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Every stored blob, newest last, with the size and mtime needed to enforce the count cap.
|
|
395
|
+
*
|
|
396
|
+
* @returns {{hash:string, bytes:number, mtimeMs:number}[]}
|
|
397
|
+
*/
|
|
398
|
+
listBlobs() {
|
|
399
|
+
if (!this.enabled) return [];
|
|
400
|
+
const root = path.join(this.dir, BLOB_DIR);
|
|
401
|
+
let shards;
|
|
402
|
+
try {
|
|
403
|
+
shards = fs.readdirSync(root, { withFileTypes: true });
|
|
404
|
+
} catch {
|
|
405
|
+
return [];
|
|
406
|
+
}
|
|
407
|
+
const out = [];
|
|
408
|
+
for (const shard of shards) {
|
|
409
|
+
if (!shard.isDirectory()) continue;
|
|
410
|
+
const shardPath = path.join(root, shard.name);
|
|
411
|
+
let names;
|
|
412
|
+
try {
|
|
413
|
+
names = fs.readdirSync(shardPath, { withFileTypes: true });
|
|
414
|
+
} catch {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
for (const entry of names) {
|
|
418
|
+
if (!entry.isFile() || entry.name.includes('.tmp-')) continue;
|
|
419
|
+
try {
|
|
420
|
+
const stat = fs.statSync(path.join(shardPath, entry.name));
|
|
421
|
+
out.push({ hash: entry.name, bytes: stat.size, mtimeMs: stat.mtimeMs });
|
|
422
|
+
} catch {
|
|
423
|
+
/* a blob that vanished mid-scan is not a failure */
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
out.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
428
|
+
return out;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Make room for `incoming` more blobs, oldest first, and never take the last one.
|
|
433
|
+
*
|
|
434
|
+
* **The caller must prune the index for the returned hashes** -- this method deletes files, and the index is a
|
|
435
|
+
* separate document. `putBlob` does that pruning; a future caller that evicts for another reason owes the same.
|
|
436
|
+
*
|
|
437
|
+
* @param {number} incoming
|
|
438
|
+
* @returns {string[]} the hashes evicted
|
|
439
|
+
*/
|
|
440
|
+
evictBlobsFor(incoming) {
|
|
441
|
+
const existing = this.listBlobs();
|
|
442
|
+
const over = existing.length + incoming - MAX_BLOBS;
|
|
443
|
+
if (over <= 0) return [];
|
|
444
|
+
const evicted = [];
|
|
445
|
+
let count = existing.length;
|
|
446
|
+
for (const blob of existing) {
|
|
447
|
+
if (count <= 1) break; // never delete the only copy of anything
|
|
448
|
+
try {
|
|
449
|
+
fs.rmSync(path.join(this.dir, BLOB_DIR, blob.hash.slice(0, 2), blob.hash), { force: true });
|
|
450
|
+
evicted.push(blob.hash);
|
|
451
|
+
count -= 1;
|
|
452
|
+
} catch {
|
|
453
|
+
/* leave it; the caller will see the count did not drop */
|
|
454
|
+
}
|
|
455
|
+
if (evicted.length >= over) break;
|
|
456
|
+
}
|
|
457
|
+
if (evicted.length > 0) this.warn(BLOB_DIR, `evicted ${evicted.length} blob(s) to stay within ${MAX_BLOBS}`);
|
|
458
|
+
return evicted;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Read the hash -> owner map. A missing or corrupt index reads as empty rather than taking the relay down. */
|
|
462
|
+
readBlobIndex() {
|
|
463
|
+
if (!this.enabled) return {};
|
|
464
|
+
try {
|
|
465
|
+
const raw = fs.readFileSync(path.join(this.dir, BLOB_DIR, BLOB_INDEX_FILE), 'utf8');
|
|
466
|
+
const parsed = JSON.parse(raw);
|
|
467
|
+
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
468
|
+
} catch {
|
|
469
|
+
return {};
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** Atomically replace the index. Best-effort: a failure is warned about, never thrown at the caller. */
|
|
474
|
+
writeBlobIndex(index) {
|
|
475
|
+
if (!this.enabled) return false;
|
|
476
|
+
const file = path.join(this.dir, BLOB_DIR, BLOB_INDEX_FILE);
|
|
477
|
+
try {
|
|
478
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
479
|
+
const tmp = `${file}.tmp-${process.pid}-${this._now()}`;
|
|
480
|
+
fs.writeFileSync(tmp, `${JSON.stringify(index)}\n`, 'utf8');
|
|
481
|
+
fs.renameSync(tmp, file);
|
|
482
|
+
return true;
|
|
483
|
+
} catch (error) {
|
|
484
|
+
this.warn(BLOB_DIR, `blob index write failed: ${error?.message ?? String(error)}`);
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/** `<state>/blobs/<aa>/<sha256>`, or `null` when persistence is off or the hash is not a sha256. */
|
|
490
|
+
blobFile(hash) {
|
|
491
|
+
if (!this.enabled) return null;
|
|
492
|
+
if (typeof hash !== 'string' || !/^[0-9a-f]{64}$/.test(hash)) return null;
|
|
493
|
+
return path.join(this.dir, BLOB_DIR, hash.slice(0, 2), hash);
|
|
494
|
+
}
|
|
495
|
+
|
|
253
496
|
/** Redacted view for `/healthz` — never contains tokens. */
|
|
254
497
|
describe() {
|
|
498
|
+
const blobs = this.listBlobs();
|
|
255
499
|
return {
|
|
256
500
|
enabled: this.enabled,
|
|
257
501
|
dir: this.dir,
|
|
@@ -261,6 +505,11 @@ export class Persistence {
|
|
|
261
505
|
devices_missing: this.devicesMissing,
|
|
262
506
|
ledger_lines_read: this.ledgerLinesRead,
|
|
263
507
|
ledger_lines_skipped: this.ledgerLinesSkipped,
|
|
508
|
+
/** v1.0.7: the fleet sync channel's occupancy, reported as counts and bytes — never contents. */
|
|
509
|
+
blobs: blobs.length,
|
|
510
|
+
blob_bytes: blobs.reduce((sum, b) => sum + b.bytes, 0),
|
|
511
|
+
blobs_limit: MAX_BLOBS,
|
|
512
|
+
blob_bytes_limit: MAX_BLOB_BYTES,
|
|
264
513
|
/**
|
|
265
514
|
* v0.6.2. `degraded: true` means the relay is answering requests while failing to record them,
|
|
266
515
|
* which is the one relay failure that looks exactly like health from the outside.
|