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([issue-727]): strip importDraft at share-bucket import and export boundaries

[._.]/ Adam Eivy061c86dbb5b4
diff --git a/server/services/sharing/exporter.js b/server/services/sharing/exporter.js
index 933ded1683..95b3a755fe 100644
--- a/server/services/sharing/exporter.js
+++ b/server/services/sharing/exporter.js
@@ -335,8 +335,14 @@ function collectCollectionAssets(collection) {
/** Stamp the outgoing record with origin metadata. */
function stampOrigin(record, { bucket, source, sourceBio, manifestId }) {
+ // `importDraft` (issue #727) is a LOCAL-only importer-orphan GC marker — it
+ // must never travel in a share bucket, or an importing peer could inherit it
+ // and have its copy swept by the orphan GC. Strip it here so the exported
+ // record honors the local-only contract (the importer also strips inbound,
+ // belt-and-suspenders). In practice only universes/series ever carry it.
+ const { importDraft: _importDraft, ...rest } = record;
return {
- ...record,
+ ...rest,
origin: {
bucketId: bucket.id,
bucketName: bucket.name,
diff --git a/server/services/sharing/importer.js b/server/services/sharing/importer.js
index 05ca8b39ce..40afcca1e5 100644
--- a/server/services/sharing/importer.js
+++ b/server/services/sharing/importer.js
@@ -404,6 +404,15 @@ async function readReferencedRecords(bucketPath, manifest) {
};
const resolved = await Promise.all((manifest.recordIds || []).map(resolveOne));
for (const r of resolved) {
+ // `importDraft` (issue #727) is a LOCAL-only importer-orphan GC marker —
+ // never trust an inbound value from a share bucket, or a crafted/stale
+ // record could mark a local universe/series GC-eligible. The service
+ // sanitizers persist a literal `importDraft: true`, so strip it at this
+ // boundary (mirrors the peer-sync merge strip in mergeUniversesFromSync /
+ // mergeSeriesFromSync). Only universes + series carry the marker.
+ if (r.record && typeof r.record === 'object' && 'importDraft' in r.record) {
+ delete r.record.importDraft;
+ }
if (r.kind === 'missing') missing.push(r.id);
else if (r.kind === 'series') records.series.push(r.record);
else if (r.kind === 'issues') records.issues.push(r.record);