Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs([sharing-inbox-orphans-on-peer-instance-id-rotation]): archive to DONE.md

[._.]/ Adam Eivyd5458ed09871
diff --git a/DONE.md b/DONE.md
index 795be72a44..b6afe0679a 100644
--- a/DONE.md
+++ b/DONE.md
@@ -10,6 +10,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./
### 2026-05-18
+- **[sharing-inbox-orphans-on-peer-instance-id-rotation] Cull rotation-orphan inbox rows.** Closes the regression introduced by `[sharing-v2-per-sender-subscription-filenames]`: a peer that rotates its `senderInstanceId` (factory reset / new device) would otherwise leave its old identity's inbox row stranded forever, because the per-sender dedup keys on the new id. `applyInbox` in `server/services/sharing/importer.js` now culls cross-sender orphans on every subscription-manifest arrival when (a) same `(recordKind, recordId, source)`, (b) DIFFERENT `senderInstanceId`, and (c) existing row's `createdAt` older than the 30-day `ROTATION_CULL_MS` window. The window is conservative — two legitimately distinct peers sharing the same display name (e.g. both devices named "MacBook") would only be culled after a month of one going silent. 3 new integration tests in `integration.test.js` (cull at 60 days, preserve at 2 days, preserve different-source-old). 78 sharing tests pass.
- **[content-addressed-asset-dedup-today-asset-copies] Content-addressed asset dedup.** Share-bucket asset blobs are now stored content-addressed at `<bucket>/assets/blobs/<sha256>` (sidecar metadata at `<sha256>.metadata.json`) instead of filename-addressed at `assets/{images,videos}/<filename>`. Two manifests referencing identical bytes under different filenames now share one on-disk blob — every additional reference is a no-op file-existence check on the same hash. New shared helper `sha256File` in `server/lib/fileUtils.js` (one-shot < 512 KB / streaming ≥ 512 KB); `server/services/backup.js#generateManifest` migrated to the same helper (its inline reimplementation deleted). Path/sidecar helpers (`bucketBlobsDir`, `bucketBlobPath`, `bucketBlobSidecarPath`, `imageSidecarName`, `IMAGE_EXT_RE`) live in `server/services/sharing/buckets.js` so storage-layout changes touch one file. `exporter.js#copyAssetIfPresent` computes the hash and returns `{ kind, ref, hash }` per asset; `importer.js#copyAssetsLocally` resolves bucket paths via a `resolveBucketAssetPaths` helper that prefers `assets/blobs/<hash>` when present and falls back to legacy `assets/{kind}/<filename>` for v1 manifests still in-bucket. `SHARING_SCHEMA_VERSION` bumped 1 → 2; bucket layout adds `assets/blobs/` in `ensureBucketLayout`. `annotationsSync.js#listBucketAssetKeys` now derives the user-facing filename set by scanning manifests' `assetRefs` (with the legacy dir scan retained as a fall-through for v1 buckets). Coverage: 4 new unit tests in `fileUtils.test.js` (small/large split, cross-path identical-bytes equality, distinct-bytes inequality) + 2 new integration tests in `integration.test.js` (two manifests with different filenames + identical bytes share one blob and import cleanly; v1 manifest without `hash` field still imports via legacy path) + updated existing integration assertions to expect `assets/blobs/<hash>` paths. All 249 server test files / 5452 tests pass. Two performance follow-ups captured in PLAN.md: per-source hash caching on the exporter, and per-bucket manifest-scan caching on the annotation flush path.
### 2026-05-17
diff --git a/PLAN.md b/PLAN.md
index 2e065059e3..52564b0f4d 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -16,7 +16,6 @@ _Nothing currently parked — pick the next item from the Backlog._
- [ ] [multi-hop-provenance-chains-re-share-authors-a] **Multi-hop provenance chains.** Re-share authors a fresh `origin` block; `chain[]` would preserve full attribution. Defer until users ask.
- [ ] [same-collection-export-pattern-for-pipeline-series] **Same collection-export pattern for pipeline series with auto-collections.** Series renders that get auto-filed into a per-series collection should also flow through `manifest.collection`.
- [ ] [sharing-inbox-live-subscription-badge] **"🔄 live" badge on inbox subscription rows.** No badge UI today; mark rows whose subscription file has updated within the last sync window.
-- [ ] [sharing-inbox-orphans-on-peer-instance-id-rotation] **Cull orphan inbox rows on peer instance-id rotation.** Post-`sharing-v2-per-sender-subscription-filenames` (2026-05-17), inbox dedup in `server/services/sharing/importer.js:applyInbox` keys on `(recordKind, recordId, senderInstanceId)`. A peer that rotates its `instanceId` (factory reset, new device onboarding) re-shares with a new id; the old id's row no longer matches and persists forever as an "active" subscription row. Detect on import: when an incoming subscription manifest's `(recordKind, recordId, source)` matches an existing row but `senderInstanceId` differs, prompt the user (or auto-cull rows older than N days with the same source name) so stale identity rows don't pile up. Pre-v2 behavior wiped these implicitly because dedup was per-record, not per-sender.
### Importer (deferred research)