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

fix([peer-sync-per-category-version-gate]): gate predicate mirrors merge predicate for bundled collections

Adam Eivyad1b608af4cb
diff --git a/server/services/sharing/importer.js b/server/services/sharing/importer.js
index 98d7237073..450a01da8b 100644
--- a/server/services/sharing/importer.js
+++ b/server/services/sharing/importer.js
@@ -422,7 +422,13 @@ function relevantSchemaCategoriesForManifest(manifest) {
else if (id.startsWith('chr-') || id.startsWith('set-') || id.startsWith('obj-')) add(RECORD_KIND_SCHEMA_CATEGORIES.universe);
else if (manifest?.kind !== 'media') add(RECORD_KIND_SCHEMA_CATEGORIES.universe);
}
- if (isPlainObject(manifest?.collection)) add(RECORD_KIND_SCHEMA_CATEGORIES.mediaCollection);
+ // Mirror peerSync's gate predicate: a bundled collection only counts as a
+ // mediaCollections transfer when it's a live record (a tombstone collection
+ // carries only delete fields, safe at any version). Today's exporter never
+ // bundles a deleted collection, so this is defensive consistency.
+ if (isPlainObject(manifest?.collection) && manifest.collection.deleted !== true) {
+ add(RECORD_KIND_SCHEMA_CATEGORIES.mediaCollection);
+ }
return [...categories];
}
diff --git a/server/services/sharing/peerSync.js b/server/services/sharing/peerSync.js
index 4f46fed79a..5a868cf46e 100644
--- a/server/services/sharing/peerSync.js
+++ b/server/services/sharing/peerSync.js
@@ -1299,8 +1299,11 @@ export async function applyIncomingPush(payload) {
for (const c of RECORD_KIND_SCHEMA_CATEGORIES.issue) relevantCategories.add(c);
}
// A linked collection only rides a non-deleted push (buildPushPayload drops
- // it for tombstones) and is itself a live record when present.
- if (isPlainObject(linkedCollection) && linkedCollection.deleted !== true) {
+ // it for tombstones) and is itself a live record when present. Mirror the
+ // merge predicate at the linkedCollection apply below exactly — it refuses
+ // the collection when the OWNER record is a tombstone — so the gate never
+ // blocks `mediaCollections` over a collection the merge would ignore.
+ if (record.deleted !== true && isPlainObject(linkedCollection) && linkedCollection.deleted !== true) {
for (const c of RECORD_KIND_SCHEMA_CATEGORIES.mediaCollection) relevantCategories.add(c);
}
const fullDiff = compareSchemaVersions(senderSchemaVersions, PORTOS_SCHEMA_VERSIONS);