@ouro.bot/cli 0.1.0-alpha.1171 → 0.1.0-alpha.1172
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.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1172",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Mailroom: AzureBlobMailroomStore.sweepOrphanedEncryptedRaw deletes encrypted raw objects no committed message references (24h grace, fail-closed, dry-run), paying the raw-orphan debt."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1171",
|
|
6
12
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1172</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -22,6 +22,9 @@ const DEFAULT_BLOB_DOWNLOAD_ATTEMPTS = 2;
|
|
|
22
22
|
const DEFAULT_MESSAGE_FETCH_CONCURRENCY = 20;
|
|
23
23
|
const DEFAULT_MESSAGE_INDEX_BACKFILL_CONCURRENCY = 8;
|
|
24
24
|
const MESSAGE_LIST_SCAN_CONCURRENCY = 32;
|
|
25
|
+
// An encrypted raw object is uploaded before its message commits, so a young unreferenced object may be in flight.
|
|
26
|
+
const DEFAULT_ORPHAN_RAW_MIN_AGE_MS = 24 * 60 * 60 * 1000;
|
|
27
|
+
const ENCRYPTED_RAW_OBJECT_PATTERN = /^raw\/([^/]+)\.[a-f0-9]{64}\.json$/;
|
|
25
28
|
function compareNewestFirst(left, right) {
|
|
26
29
|
return Date.parse(right.receivedAt) - Date.parse(left.receivedAt);
|
|
27
30
|
}
|
|
@@ -546,6 +549,87 @@ class AzureBlobMailroomStore {
|
|
|
546
549
|
});
|
|
547
550
|
return indexed;
|
|
548
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Deletes encrypted raw objects that no committed message references. Fails closed: if any committed
|
|
554
|
+
* message cannot be read, nothing is deleted. Young objects (possibly mid-ingest) and objects a
|
|
555
|
+
* message still references at delete time are always kept.
|
|
556
|
+
*/
|
|
557
|
+
async sweepOrphanedEncryptedRaw(options = {}) {
|
|
558
|
+
await this.ensureContainer();
|
|
559
|
+
const minAgeMs = options.minAgeMs ?? DEFAULT_ORPHAN_RAW_MIN_AGE_MS;
|
|
560
|
+
const nowMs = (options.now ?? new Date()).getTime();
|
|
561
|
+
const dryRun = options.dryRun === true;
|
|
562
|
+
(0, runtime_1.emitNervesEvent)({
|
|
563
|
+
component: "senses",
|
|
564
|
+
event: "senses.mail_blob_store_raw_sweep_start",
|
|
565
|
+
message: "azure blob mailroom store started encrypted raw orphan sweep",
|
|
566
|
+
meta: { minAgeMs, dryRun },
|
|
567
|
+
});
|
|
568
|
+
try {
|
|
569
|
+
const messageNames = [];
|
|
570
|
+
for await (const item of this.container.listBlobsFlat({ prefix: "messages/" }))
|
|
571
|
+
messageNames.push(item.name);
|
|
572
|
+
const referenced = new Set();
|
|
573
|
+
await mapWithConcurrency(messageNames, this.messageFetchConcurrency, async (name) => {
|
|
574
|
+
const message = await downloadJson(this.container.getBlockBlobClient(name), this.blobOperationTimeoutMs);
|
|
575
|
+
if (!isNonEmptyString(message?.rawObject))
|
|
576
|
+
throw new Error(`committed message blob ${name} has no raw reference; refusing to sweep`);
|
|
577
|
+
referenced.add(message.rawObject);
|
|
578
|
+
});
|
|
579
|
+
const candidates = [];
|
|
580
|
+
let scanned = 0;
|
|
581
|
+
for await (const item of this.container.listBlobsFlat({ prefix: "raw/" })) {
|
|
582
|
+
const match = ENCRYPTED_RAW_OBJECT_PATTERN.exec(item.name);
|
|
583
|
+
if (!match)
|
|
584
|
+
continue;
|
|
585
|
+
scanned += 1;
|
|
586
|
+
if (referenced.has(item.name))
|
|
587
|
+
continue;
|
|
588
|
+
const modified = item.properties?.lastModified;
|
|
589
|
+
candidates.push({ name: item.name, messageId: match[1], ageMs: modified ? nowMs - modified.getTime() : null });
|
|
590
|
+
}
|
|
591
|
+
let deleted = 0;
|
|
592
|
+
let skippedYoung = 0;
|
|
593
|
+
for (const candidate of candidates) {
|
|
594
|
+
if (candidate.ageMs === null || candidate.ageMs < minAgeMs) {
|
|
595
|
+
skippedYoung += 1;
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
// Re-read the owner at delete time: a commit may have landed since the scan.
|
|
599
|
+
const owner = await downloadJson(this.messageBlob(candidate.messageId), this.blobOperationTimeoutMs);
|
|
600
|
+
if (owner?.rawObject === candidate.name)
|
|
601
|
+
continue;
|
|
602
|
+
if (!dryRun)
|
|
603
|
+
await this.rawBlob(candidate.name).deleteIfExists();
|
|
604
|
+
deleted += 1;
|
|
605
|
+
}
|
|
606
|
+
const result = {
|
|
607
|
+
scanned,
|
|
608
|
+
referenced: scanned - candidates.length,
|
|
609
|
+
orphaned: candidates.length,
|
|
610
|
+
deleted: dryRun ? 0 : deleted,
|
|
611
|
+
skippedYoung,
|
|
612
|
+
dryRun,
|
|
613
|
+
};
|
|
614
|
+
(0, runtime_1.emitNervesEvent)({
|
|
615
|
+
component: "senses",
|
|
616
|
+
event: "senses.mail_blob_store_raw_sweep_end",
|
|
617
|
+
message: "azure blob mailroom store finished encrypted raw orphan sweep",
|
|
618
|
+
meta: { ...result },
|
|
619
|
+
});
|
|
620
|
+
return result;
|
|
621
|
+
}
|
|
622
|
+
catch (error) {
|
|
623
|
+
(0, runtime_1.emitNervesEvent)({
|
|
624
|
+
level: "error",
|
|
625
|
+
component: "senses",
|
|
626
|
+
event: "senses.mail_blob_store_raw_sweep_error",
|
|
627
|
+
message: "azure blob mailroom store encrypted raw orphan sweep failed",
|
|
628
|
+
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
629
|
+
});
|
|
630
|
+
throw error;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
549
633
|
async putRawMessage(input) {
|
|
550
634
|
await this.ensureContainer();
|
|
551
635
|
const { message, rawPayload, privateEnvelope, candidate } = await (0, core_1.buildEncryptedStoredMailMessage)(input);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1172",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1172",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|