diff --git a/src/lib/exomem-hosted/__tests__/cloud-home-postgres.integration.test.ts b/src/lib/exomem-hosted/__tests__/cloud-home-postgres.integration.test.ts index 809dc4ad..5511562b 100644 --- a/src/lib/exomem-hosted/__tests__/cloud-home-postgres.integration.test.ts +++ b/src/lib/exomem-hosted/__tests__/cloud-home-postgres.integration.test.ts @@ -2295,9 +2295,23 @@ describe("Cloud Home channel and exports PostgreSQL boundary", { skip: !database assert.deepEqual(after.custody.observation, observation); assert.equal(after.custody.content_keys_retired_at, "2026-10-20T03:00:00.000Z"); assert.equal(after.custody.keys_expire_at, null); + assert.equal(after.custody.backup_expires_at, null); assert.equal(after.custody.retention_sources, null); }); + it("reports the backup expiry forecast before the backup bucket is confirmed empty", async () => { + const alice = await owner(); + await pool.query( + "UPDATE exomem_cloud_cells SET desired_state='deleted', last_live_key_destroyed_at='2026-12-01T00:00:00Z', custody_observation=$2::jsonb WHERE cell_id=$1", + [alice.cellId, JSON.stringify({ backup_expires_at: "2027-01-03T00:00:00+00:00" })] + ); + + const { custody } = await getOwnerCloudHomeStatus(alice.tenantId); + assert.equal(custody.backup_expires_at, "2027-01-03T00:00:00.000Z"); + assert.equal(custody.backup_absent_at, null); + assert.equal(custody.keys_expire_at, null); + }); + it("reports a deleted cell's copies expired from the evidence cellctl recorded, not from the date alone", async () => { const alice = await owner(); const sources = [ diff --git a/src/lib/exomem-hosted/cloud-status.ts b/src/lib/exomem-hosted/cloud-status.ts index 732184dc..94d2928b 100644 --- a/src/lib/exomem-hosted/cloud-status.ts +++ b/src/lib/exomem-hosted/cloud-status.ts @@ -115,6 +115,8 @@ export type CloudCustodyObservation = { last_live_key_destroyed_at: string | null; retention_sources: unknown[] | null; keys_expire_at: string | null; + /** Forecast for the backup bucket. The backup_absent_at field records confirmed absence. */ + backup_expires_at: string | null; backup_hidden_at: string | null; backup_absent_at: string | null; node_snapshots_cleared_at: string | null; @@ -324,6 +326,13 @@ export async function getOwnerCloudHomeStatus(tenantId: string): Promise<{ runningRelease: string | null; }> { const row = await readNewestCloudCell(tenantId); + const recordedExpiry = row?.custody_observation?.backup_expires_at; + const backupExpiry = + row?.desired_state === "deleted" && + row.last_live_key_destroyed_at && + typeof recordedExpiry === "string" + ? new Date(recordedExpiry) + : null; return { runningRelease: row?.running_release ?? null, status: mapCloudCellToLifecycleStatus(row), @@ -335,6 +344,8 @@ export async function getOwnerCloudHomeStatus(tenantId: string): Promise<{ last_live_key_destroyed_at: row?.last_live_key_destroyed_at?.toISOString() ?? null, retention_sources: row?.key_retention_sources ?? null, keys_expire_at: row?.keys_expire_at?.toISOString() ?? null, + backup_expires_at: + backupExpiry && Number.isFinite(backupExpiry.getTime()) ? backupExpiry.toISOString() : null, backup_hidden_at: row?.backup_hidden_at?.toISOString() ?? null, backup_absent_at: row?.backup_absent_at?.toISOString() ?? null, node_snapshots_cleared_at: row?.node_snapshots_cleared_at?.toISOString() ?? null,