@camstack/server 1.2.760 → 1.2.762
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 +17 -2
- package/dist/agent/main.js +1 -0
- package/dist/api/core/cap-providers.js +39 -8
- package/dist/api/core/integration-role.js +6 -3
- package/dist/api/trpc/generated-cap-mounts.js +1 -0
- package/dist/api/trpc/generated-cap-routers.js +27 -12
- package/dist/core/addon/addon-registry.service.js +1 -0
- package/package.json +19 -8
- package/system/dist/addon-runner.js +1 -0
- package/system/dist/addon-runner.mjs +1 -0
- package/system/dist/{agent-https-DXDFMq90.js → agent-https-BHpDnJr0.js} +1 -1
- package/system/dist/{agent-https-Bafgj4ni.mjs → agent-https-UksJdbes.mjs} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +7 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +7 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +3 -3
- package/system/dist/builtins/composer/composer.addon.mjs +3 -3
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +3 -3
- package/system/dist/builtins/keychain/index.mjs +3 -3
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +2 -1
- package/system/dist/builtins/loki-logging/index.mjs +2 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +6 -0
- package/system/dist/builtins/sqlite-storage/integration-rows-ports.d.ts +16 -0
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
- package/system/dist/builtins/storage-orchestrator/location-store.d.ts +8 -0
- package/system/dist/builtins/storage-orchestrator/migrations/index.d.ts +10 -0
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +22 -0
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +260 -19
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +260 -19
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +54 -21
- package/system/dist/builtins/storage-orchestrator/storage-writability-monitor.d.ts +36 -0
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-WttiBMdu.mjs → capture-engine-Btq9LseJ.mjs} +1 -1
- package/system/dist/{capture-engine-CInzGJAh.js → capture-engine-DgcmHuIi.js} +1 -1
- package/system/dist/{composition-sources-DQHH_g-A.js → composition-sources-DrGLoV8D.js} +1 -1
- package/system/dist/{composition-sources-A4LM38lT.mjs → composition-sources-xyPI-9ja.mjs} +1 -1
- package/system/dist/{constants-BAG_5cF6.mjs → constants-B8q9KsGq.mjs} +1 -1
- package/system/dist/{constants-hAbcGGDs.js → constants-BiE3GU1C.js} +1 -1
- package/system/dist/{device-ca-lLGjDsFP.js → device-ca-Bel2vDyJ.js} +1 -1
- package/system/dist/{device-ca-CCIaKs70.mjs → device-ca-D5U9i2AO.mjs} +1 -1
- package/system/dist/{dist-CiwLP3-C.js → dist-B6-AUY2T.js} +166 -24
- package/system/dist/{dist-BIJD_nvZ.mjs → dist-Dd_vXorK.mjs} +166 -24
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-CLlDILdC.js → hub-mdns-ciao-DV7bwoub.js} +2 -2
- package/system/dist/{hub-mdns-ciao-CXsUIWw_.mjs → hub-mdns-ciao-Dz9w_pd0.mjs} +2 -2
- package/system/dist/index.js +54 -7
- package/system/dist/index.mjs +54 -7
- package/system/dist/kernel/addon-loader.d.ts +13 -1
- package/system/dist/kernel/moleculer/addon-context-factory.d.ts +3 -1
- package/system/dist/{restore-archive-Dx9r-ndj.mjs → restore-archive-BcdcInFR.mjs} +1 -1
- package/system/dist/{restore-archive-CN1BA_o6.js → restore-archive-BcstsRhG.js} +1 -1
- package/system/dist/{wal-maintenance-B7wMSexc.mjs → wal-maintenance-Ctp8Q-y7.mjs} +0 -0
- package/system/dist/{wal-maintenance-CecPWej8.js → wal-maintenance-CzjpuF7n.js} +0 -0
- package/system/package.json +1 -1
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-B6-AUY2T.js");
|
|
7
7
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
8
8
|
let zod = require("zod");
|
|
9
9
|
let node_crypto = require("node:crypto");
|
|
@@ -217,6 +217,11 @@ var SqliteLocationStore = class {
|
|
|
217
217
|
data: { seededAt: Date.now() }
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
+
async unmarkTypeSeeded(type) {
|
|
221
|
+
const kind = this.seedMarkersKind;
|
|
222
|
+
if (kind === null) return;
|
|
223
|
+
await kind.delete(type);
|
|
224
|
+
}
|
|
220
225
|
static recordStoresOf(records) {
|
|
221
226
|
return records.kind(storageOrchestratorRecordKinds.locations);
|
|
222
227
|
}
|
|
@@ -1256,6 +1261,29 @@ function buildStorageLocationRegistry(perAddon) {
|
|
|
1256
1261
|
}
|
|
1257
1262
|
};
|
|
1258
1263
|
}
|
|
1264
|
+
/** The `storage-orchestrator` catalogue (D987): offered to the engine once the seed state is known. */
|
|
1265
|
+
var ADDON_MIGRATIONS = [{
|
|
1266
|
+
meta: {
|
|
1267
|
+
id: "storage-orchestrator/2026-11-04-reseed-pruned-defaults",
|
|
1268
|
+
owner: "storage-orchestrator",
|
|
1269
|
+
level: "addon-state",
|
|
1270
|
+
seq: 1,
|
|
1271
|
+
dependsOn: [],
|
|
1272
|
+
store: "settings",
|
|
1273
|
+
scope: "cluster",
|
|
1274
|
+
onFailure: "tolerate",
|
|
1275
|
+
bodyKind: "procedure",
|
|
1276
|
+
description: "Re-create the default storage location of a declared type whose seed marker survived the 2026-11-01 prune with no rows left",
|
|
1277
|
+
fixtureMark: "a type that still has its row and its seed marker, which the repair must not touch"
|
|
1278
|
+
},
|
|
1279
|
+
procedure: async (ports) => {
|
|
1280
|
+
const types = ports.reseed();
|
|
1281
|
+
return {
|
|
1282
|
+
outcome: types.length > 0 ? "done" : "already-done",
|
|
1283
|
+
summary: { types: [...types] }
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
}];
|
|
1259
1287
|
//#endregion
|
|
1260
1288
|
//#region src/builtins/storage-orchestrator/location-occupancy.ts
|
|
1261
1289
|
/**
|
|
@@ -2803,6 +2831,25 @@ var StorageOrchestratorService = class {
|
|
|
2803
2831
|
} });
|
|
2804
2832
|
});
|
|
2805
2833
|
}
|
|
2834
|
+
forgetSeeded(type) {
|
|
2835
|
+
const seeded = this.seededTypes;
|
|
2836
|
+
const store = this.locationStore;
|
|
2837
|
+
if (seeded === null || !seeded.delete(type) || !store?.unmarkTypeSeeded) return;
|
|
2838
|
+
store.unmarkTypeSeeded(type).catch((err) => {
|
|
2839
|
+
this.logger.error("storage-orchestrator: forgetting the seed memory failed", { meta: {
|
|
2840
|
+
type,
|
|
2841
|
+
error: err instanceof Error ? err.message : String(err)
|
|
2842
|
+
} });
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
/**
|
|
2846
|
+
* Do the rows this service holds answer "which locations exist"? False while
|
|
2847
|
+
* a store that must answer has not (not wired, adoption pending, read
|
|
2848
|
+
* failed): an empty map then means NOT YET KNOWN, never "none" (D315).
|
|
2849
|
+
*/
|
|
2850
|
+
locationsAuthoritative() {
|
|
2851
|
+
return !(this.storeRequiredForSeed && this.locationStore === null);
|
|
2852
|
+
}
|
|
2806
2853
|
/** True once a persistence store is wired (constructor or {@link attachStore}). */
|
|
2807
2854
|
hasStore() {
|
|
2808
2855
|
return this.locationStore !== null;
|
|
@@ -3247,39 +3294,71 @@ var StorageOrchestratorService = class {
|
|
|
3247
3294
|
}
|
|
3248
3295
|
}
|
|
3249
3296
|
/**
|
|
3250
|
-
* Remove seed-shaped locations (`<type>:default`) whose type
|
|
3251
|
-
*
|
|
3297
|
+
* Remove seed-shaped locations (`<type>:default`) whose type no INSTALLED
|
|
3298
|
+
* package declares any more (stale defaults from a removed location type).
|
|
3252
3299
|
* Operator-added locations of an undeclared type are KEPT but warned.
|
|
3253
3300
|
*
|
|
3301
|
+
* "Undeclared" means undeclared by every installed package, not by every
|
|
3302
|
+
* LOADED addon. The registry is built from the addons that loaded; an addon
|
|
3303
|
+
* whose load failed (`Cannot find module` after a bad deploy) declares the
|
|
3304
|
+
* same types it always did, and "not known right now" is not "removed"
|
|
3305
|
+
* (D49, D315). `unloaded` is that other half — every installed declarer
|
|
3306
|
+
* that is not loaded. A type one of them declares is kept, by name in the
|
|
3307
|
+
* log; a package that could not even be read has unknown declarations, so
|
|
3308
|
+
* the whole pass is skipped (a read that would DESTROY needs an answer).
|
|
3309
|
+
*
|
|
3310
|
+
* A pruned type also forgets that it was seeded: were it declared again, it
|
|
3311
|
+
* seeds again, while an operator's own delete (which never reaches here)
|
|
3312
|
+
* keeps sticking.
|
|
3313
|
+
*
|
|
3254
3314
|
* FAIL-SAFE: if the registry is EMPTY (no addon declared any location), we
|
|
3255
3315
|
* refuse to prune anything. An empty registry almost always means
|
|
3256
3316
|
* declarations failed to load (boot ordering, a stale install) — pruning
|
|
3257
3317
|
* "everything undeclared" in that state would wipe every seeded location
|
|
3258
3318
|
* (data/logs/recordings/…). Better to keep stale rows than destroy live ones.
|
|
3259
3319
|
*/
|
|
3260
|
-
pruneUndeclaredSystemLocations() {
|
|
3320
|
+
pruneUndeclaredSystemLocations(unloaded = []) {
|
|
3261
3321
|
if (!this.registry) return;
|
|
3262
3322
|
if (this.registry.list().length === 0) {
|
|
3263
3323
|
this.logger.warn("storage-orchestrator: skipping prune — no location declarations loaded (fail-safe)");
|
|
3264
3324
|
return;
|
|
3265
3325
|
}
|
|
3326
|
+
const unreadable = unloaded.filter((d) => d.addonId === null);
|
|
3327
|
+
if (unreadable.length > 0) {
|
|
3328
|
+
this.logger.warn("storage-orchestrator: skipping prune — an installed package could not be read, so what it declares is unknown", { meta: { packages: unreadable.map((d) => d.packageName) } });
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3266
3331
|
for (const [id, loc] of Array.from(this.locations)) {
|
|
3267
3332
|
if (this.registry.cardinalityOf(loc.type) !== null) continue;
|
|
3268
|
-
if (loc.id === `${loc.type}:default`) {
|
|
3269
|
-
this.
|
|
3270
|
-
if (this.locationStore) this.locationStore.delete(id).catch((err) => {
|
|
3271
|
-
this.logger.error("storage-orchestrator: prune persistence failed", { meta: {
|
|
3272
|
-
id,
|
|
3273
|
-
error: err instanceof Error ? err.message : String(err)
|
|
3274
|
-
} });
|
|
3275
|
-
});
|
|
3276
|
-
this.logger.info("storage-orchestrator: pruned stale seeded location", { meta: {
|
|
3333
|
+
if (!(loc.id === `${loc.type}:default`)) {
|
|
3334
|
+
this.logger.warn("storage-orchestrator: location of undeclared type kept (operator-owned)", { meta: {
|
|
3277
3335
|
id,
|
|
3278
3336
|
type: loc.type
|
|
3279
3337
|
} });
|
|
3280
|
-
|
|
3338
|
+
continue;
|
|
3339
|
+
}
|
|
3340
|
+
const holders = unloaded.filter((d) => d.declarations.some((x) => x.id === loc.type));
|
|
3341
|
+
if (holders.length > 0) {
|
|
3342
|
+
this.logger.info("storage-orchestrator: prune skipped — type declared by an installed addon that is not loaded", { meta: {
|
|
3343
|
+
id,
|
|
3344
|
+
type: loc.type,
|
|
3345
|
+
addons: holders.map((d) => d.addonId),
|
|
3346
|
+
reason: "declaring-addon-unloaded"
|
|
3347
|
+
} });
|
|
3348
|
+
continue;
|
|
3349
|
+
}
|
|
3350
|
+
this.locations.delete(id);
|
|
3351
|
+
this.forgetSeeded(loc.type);
|
|
3352
|
+
if (this.locationStore) this.locationStore.delete(id).catch((err) => {
|
|
3353
|
+
this.logger.error("storage-orchestrator: prune persistence failed", { meta: {
|
|
3354
|
+
id,
|
|
3355
|
+
error: err instanceof Error ? err.message : String(err)
|
|
3356
|
+
} });
|
|
3357
|
+
});
|
|
3358
|
+
this.logger.info("storage-orchestrator: pruned stale seeded location", { meta: {
|
|
3281
3359
|
id,
|
|
3282
|
-
type: loc.type
|
|
3360
|
+
type: loc.type,
|
|
3361
|
+
reason: "no-installed-package-declares-type"
|
|
3283
3362
|
} });
|
|
3284
3363
|
}
|
|
3285
3364
|
}
|
|
@@ -3480,6 +3559,32 @@ var StorageOrchestratorService = class {
|
|
|
3480
3559
|
} : { added };
|
|
3481
3560
|
}
|
|
3482
3561
|
/**
|
|
3562
|
+
* Re-create the default of a type whose seed marker survived the loss of every
|
|
3563
|
+
* row (the 2026-11-01 prune: it deleted the rows and, until D1006, left the
|
|
3564
|
+
* marker). That state cannot be an operator action — the service refuses to
|
|
3565
|
+
* delete or disable the LAST enabled location of a type — so it is repaired
|
|
3566
|
+
* with the normal seed rules (media/backup roots, `defaultsTo`), each one
|
|
3567
|
+
* logged with its reason. Returns the types that got their default back.
|
|
3568
|
+
*
|
|
3569
|
+
* The caller states that every declaring addon is loaded and the store has
|
|
3570
|
+
* answered: this never guesses (D49, D315).
|
|
3571
|
+
*/
|
|
3572
|
+
reseedPrunedDefaults(input) {
|
|
3573
|
+
const seeded = this.seededTypes;
|
|
3574
|
+
if (seeded === null) return [];
|
|
3575
|
+
const candidates = input.declarations.filter((d) => seeded.has(d.id) && !this.hasAnyLocationOfType(d.id));
|
|
3576
|
+
if (candidates.length === 0) return [];
|
|
3577
|
+
for (const d of candidates) seeded.delete(d.id);
|
|
3578
|
+
this.seedDefaults(input);
|
|
3579
|
+
const restored = candidates.filter((d) => this.hasAnyLocationOfType(d.id)).map((d) => d.id);
|
|
3580
|
+
for (const d of candidates) if (restored.includes(d.id)) this.logger.info("storage-orchestrator: re-seeded a default that a prune had removed", { meta: {
|
|
3581
|
+
type: d.id,
|
|
3582
|
+
reason: "seed-marker-without-rows"
|
|
3583
|
+
} });
|
|
3584
|
+
else this.rememberSeeded(d.id);
|
|
3585
|
+
return restored;
|
|
3586
|
+
}
|
|
3587
|
+
/**
|
|
3483
3588
|
* The same-type physical-root refusal (D389).
|
|
3484
3589
|
*
|
|
3485
3590
|
* An unresolvable root — another node's disk, a remote provider, a path that
|
|
@@ -3847,6 +3952,67 @@ var StoragePressureManager = class {
|
|
|
3847
3952
|
}
|
|
3848
3953
|
};
|
|
3849
3954
|
//#endregion
|
|
3955
|
+
//#region src/builtins/storage-orchestrator/storage-writability-monitor.ts
|
|
3956
|
+
var WRITABILITY_FINDING_PREFIX = "storage:no-writable-location:";
|
|
3957
|
+
var STORAGE_PAGE = "/system/storage";
|
|
3958
|
+
/** What stops working when the type has nowhere to write. */
|
|
3959
|
+
var IMPACT_BY_TYPE = {
|
|
3960
|
+
eventMedia: "no thumbnails or track photos are saved",
|
|
3961
|
+
recordings: "no recordings are written",
|
|
3962
|
+
recordingsLow: "no low-resolution recordings are written",
|
|
3963
|
+
artifacts: "no analysis artifacts are saved",
|
|
3964
|
+
backups: "no backups can be written"
|
|
3965
|
+
};
|
|
3966
|
+
var GENERIC_IMPACT = "everything that writes to it is refused";
|
|
3967
|
+
var StorageWritabilityMonitor = class {
|
|
3968
|
+
deps;
|
|
3969
|
+
failing = /* @__PURE__ */ new Set();
|
|
3970
|
+
evaluated = false;
|
|
3971
|
+
constructor(deps) {
|
|
3972
|
+
this.deps = deps;
|
|
3973
|
+
}
|
|
3974
|
+
evaluate(input) {
|
|
3975
|
+
if (!input.authoritative) return;
|
|
3976
|
+
if (input.declarers.some((d) => d.addonId === null)) return;
|
|
3977
|
+
const first = !this.evaluated;
|
|
3978
|
+
this.evaluated = true;
|
|
3979
|
+
const loaded = input.declarers.filter((d) => d.loaded);
|
|
3980
|
+
const types = /* @__PURE__ */ new Map();
|
|
3981
|
+
for (const declarer of loaded) for (const d of declarer.declarations) {
|
|
3982
|
+
const entry = types.get(d.id) ?? {
|
|
3983
|
+
displayName: d.displayName,
|
|
3984
|
+
addons: []
|
|
3985
|
+
};
|
|
3986
|
+
if (declarer.addonId !== null && !entry.addons.includes(declarer.addonId)) entry.addons.push(declarer.addonId);
|
|
3987
|
+
types.set(d.id, entry);
|
|
3988
|
+
}
|
|
3989
|
+
for (const [type, info] of types) {
|
|
3990
|
+
const findingId = `${WRITABILITY_FINDING_PREFIX}${type}`;
|
|
3991
|
+
if (!input.locations.some((l) => l.type === type && require_dist.mayWriteToLocation(l))) {
|
|
3992
|
+
this.failing.add(type);
|
|
3993
|
+
this.deps.logger.warn("storage-orchestrator: declared type has no writable location", { meta: {
|
|
3994
|
+
type,
|
|
3995
|
+
addons: info.addons
|
|
3996
|
+
} });
|
|
3997
|
+
this.deps.emit({
|
|
3998
|
+
category: require_dist.EventCategory.SystemLivenessFailed,
|
|
3999
|
+
data: {
|
|
4000
|
+
findingId,
|
|
4001
|
+
severity: "error",
|
|
4002
|
+
title: `No writable ${info.displayName.toLowerCase()} location`,
|
|
4003
|
+
message: `${info.displayName} (${type}) is needed by ${info.addons.join(", ")} but has no location that accepts writes: ${IMPACT_BY_TYPE[type] ?? GENERIC_IMPACT}. Add or re-enable a location on the Storage page.`,
|
|
4004
|
+
href: STORAGE_PAGE,
|
|
4005
|
+
actionLabel: "Open Storage"
|
|
4006
|
+
}
|
|
4007
|
+
});
|
|
4008
|
+
} else if (this.failing.delete(type) || first) this.deps.emit({
|
|
4009
|
+
category: require_dist.EventCategory.SystemLivenessRecovered,
|
|
4010
|
+
data: { findingId }
|
|
4011
|
+
});
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
};
|
|
4015
|
+
//#endregion
|
|
3850
4016
|
//#region src/builtins/storage-orchestrator/storage-location-band-monitor.ts
|
|
3851
4017
|
var DEFAULT_STORAGE_LOCATION_BAND_CONFIG = {
|
|
3852
4018
|
lowPercent: 15,
|
|
@@ -4918,6 +5084,7 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
4918
5084
|
* failed upsert.
|
|
4919
5085
|
*/
|
|
4920
5086
|
announceLocationsChanged(locationId, locationType, reason) {
|
|
5087
|
+
this.evaluateWritability();
|
|
4921
5088
|
try {
|
|
4922
5089
|
this.ctx.eventBus.emit({
|
|
4923
5090
|
id: (0, node_crypto.randomUUID)(),
|
|
@@ -5182,6 +5349,35 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5182
5349
|
async locationVolumeTotalBytes(locationId) {
|
|
5183
5350
|
return volumeTotalBytesOf(await this.volumeCapacityOf(locationId));
|
|
5184
5351
|
}
|
|
5352
|
+
declarersSeen = null;
|
|
5353
|
+
seedAnswered = false;
|
|
5354
|
+
reseedRepairDone = false;
|
|
5355
|
+
reseedRepairRunning = false;
|
|
5356
|
+
writabilityMonitor = null;
|
|
5357
|
+
/** Built on first use: `this.ctx` does not exist in a field initializer. */
|
|
5358
|
+
get writability() {
|
|
5359
|
+
this.writabilityMonitor ??= new StorageWritabilityMonitor({
|
|
5360
|
+
logger: this.ctx.logger,
|
|
5361
|
+
emit: (event) => this.emitWritabilityEvent(event)
|
|
5362
|
+
});
|
|
5363
|
+
return this.writabilityMonitor;
|
|
5364
|
+
}
|
|
5365
|
+
emitWritabilityEvent(event) {
|
|
5366
|
+
try {
|
|
5367
|
+
this.ctx.eventBus.emit({
|
|
5368
|
+
id: (0, node_crypto.randomUUID)(),
|
|
5369
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
5370
|
+
source: {
|
|
5371
|
+
type: "addon",
|
|
5372
|
+
id: this.ctx.id
|
|
5373
|
+
},
|
|
5374
|
+
category: event.category,
|
|
5375
|
+
data: { ...event.data }
|
|
5376
|
+
});
|
|
5377
|
+
} catch (err) {
|
|
5378
|
+
this.ctx.logger.warn("storage-orchestrator: could not emit the writability finding", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
5379
|
+
}
|
|
5380
|
+
}
|
|
5185
5381
|
/**
|
|
5186
5382
|
* Seed default storage locations from the addon-declared
|
|
5187
5383
|
* `storageLocations`, aggregated by the kernel into a
|
|
@@ -5198,19 +5394,64 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5198
5394
|
async seedFromDeclarations() {
|
|
5199
5395
|
if (!this.service) return;
|
|
5200
5396
|
await this.refreshNodeLocalCache();
|
|
5201
|
-
const
|
|
5397
|
+
const declarers = this.ctx.kernel.listStorageLocationDeclarers?.();
|
|
5398
|
+
const perAddon = declarers !== void 0 ? declarers.filter((d) => d.loaded).map((d) => d.declarations) : this.ctx.kernel.listStorageLocationDeclarations?.() ?? [];
|
|
5399
|
+
const unloaded = declarers?.filter((d) => !d.loaded) ?? [];
|
|
5400
|
+
const registry = buildStorageLocationRegistry(perAddon);
|
|
5202
5401
|
this.service.setRegistry(registry);
|
|
5203
|
-
this.service.pruneUndeclaredSystemLocations();
|
|
5402
|
+
this.service.pruneUndeclaredSystemLocations(unloaded);
|
|
5204
5403
|
const mediaRoot = process.env.CAMSTACK_MEDIA_ROOT?.trim();
|
|
5205
5404
|
const backupRoot = process.env.CAMSTACK_BACKUP_ROOT?.trim();
|
|
5206
|
-
|
|
5405
|
+
const seedInput = {
|
|
5207
5406
|
providerId: "filesystem-storage",
|
|
5208
5407
|
basePath: this.ctx.nodeDataDir,
|
|
5209
5408
|
mediaBasePath: mediaRoot && mediaRoot.length > 0 ? mediaRoot : void 0,
|
|
5210
5409
|
backupBasePath: backupRoot && backupRoot.length > 0 ? backupRoot : void 0,
|
|
5211
5410
|
declarations: registry.list()
|
|
5212
|
-
}
|
|
5411
|
+
};
|
|
5412
|
+
const seedOutcome = this.service.seedDefaults(seedInput);
|
|
5213
5413
|
await this.service.backfillNodeIds(HUB_NODE_ID);
|
|
5414
|
+
this.declarersSeen = declarers ?? null;
|
|
5415
|
+
this.seedAnswered = seedOutcome.deferred === void 0;
|
|
5416
|
+
await this.repairPrunedDefaults(seedInput, declarers);
|
|
5417
|
+
this.evaluateWritability();
|
|
5418
|
+
}
|
|
5419
|
+
/**
|
|
5420
|
+
* One-shot ledger migration (D987): re-create the default of a declared type whose
|
|
5421
|
+
* seed marker survived the 2026-11-01 prune with no rows left. It is offered ONLY
|
|
5422
|
+
* when the whole picture is known: the kernel listed its declarers, every one of them
|
|
5423
|
+
* is loaded and readable, and the seed pass answered. Otherwise it is not offered and
|
|
5424
|
+
* the next seed pass tries again; it never guesses (D49/D315).
|
|
5425
|
+
*/
|
|
5426
|
+
async repairPrunedDefaults(seedInput, declarers) {
|
|
5427
|
+
const service = this.service;
|
|
5428
|
+
if (!service || this.reseedRepairDone || this.reseedRepairRunning) return;
|
|
5429
|
+
if (declarers === void 0 || declarers.some((d) => !d.loaded || d.addonId === null)) return;
|
|
5430
|
+
if (!this.seedAnswered || !service.locationsAuthoritative()) return;
|
|
5431
|
+
this.reseedRepairRunning = true;
|
|
5432
|
+
try {
|
|
5433
|
+
await this.runMigrations(require_dist.defineAddonMigrations(ADDON_MIGRATIONS, { reseed: () => service.reseedPrunedDefaults(seedInput) }));
|
|
5434
|
+
this.reseedRepairDone = true;
|
|
5435
|
+
} catch (err) {
|
|
5436
|
+
this.ctx.logger.warn("storage-orchestrator: the pruned-default repair did not run", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
5437
|
+
} finally {
|
|
5438
|
+
this.reseedRepairRunning = false;
|
|
5439
|
+
}
|
|
5440
|
+
}
|
|
5441
|
+
/**
|
|
5442
|
+
* Alert when a declared type has nowhere to write. Runs after every seed pass
|
|
5443
|
+
* and every change to the set of locations; a no-op until a pass has an
|
|
5444
|
+
* answered state AND the kernel could list its declarers (D315).
|
|
5445
|
+
*/
|
|
5446
|
+
evaluateWritability() {
|
|
5447
|
+
const service = this.service;
|
|
5448
|
+
const declarers = this.declarersSeen;
|
|
5449
|
+
if (!service || declarers === null) return;
|
|
5450
|
+
this.writability.evaluate({
|
|
5451
|
+
authoritative: this.seedAnswered && service.locationsAuthoritative(),
|
|
5452
|
+
declarers,
|
|
5453
|
+
locations: service.listLocations()
|
|
5454
|
+
});
|
|
5214
5455
|
}
|
|
5215
5456
|
/**
|
|
5216
5457
|
* Rebuild the `providerId → nodeLocal` cache from every registered
|