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(sharing): don't flip deliberately-subscribed records to adoptedFromImport

[._.]/ Adam Eivy7b78e4511013
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index bcc57f5651..e57584f776 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -41,6 +41,16 @@
## Fixed
+- **`adoptImportedSubscription` no longer mislabels deliberately-subscribed
+ records as imported.** On the update branch, `sub.adoptedFromImport ?? true`
+ flipped `undefined` (a deliberate `subscribe()` result) to `true` the next
+ time an inbound manifest arrived for the same record, falsely marking it as
+ adopted-from-import. The flag is now set only on creation and left
+ untouched on subsequent inbound manifests, so user-initiated subscriptions
+ retain their `undefined`/`false` state across re-adoption. Addresses
+ Copilot review on PR #241; regression test in
+ `server/services/sharing/subscriptions.test.js`.
+
- **Scheduled cron tasks (e.g. `plan-task` at 9 AM) silently never fired.**
Four overlapping bugs in the CoS scheduler combined to make user-pinned
cron schedules guaranteed misses: (1) `shouldRunTask` had no catch-up
diff --git a/server/services/sharing/subscriptions.js b/server/services/sharing/subscriptions.js
index 487dd3dd27..fad7ae93ed 100644
--- a/server/services/sharing/subscriptions.js
+++ b/server/services/sharing/subscriptions.js
@@ -106,7 +106,6 @@ export async function adoptImportedSubscription({ bucketId, recordKind, recordId
} else {
sub.updatedAt = now;
sub.lastManifestId = lastManifestId || sub.lastManifestId || null;
- sub.adoptedFromImport = sub.adoptedFromImport ?? true;
}
await writeState(state);
return sub;
diff --git a/server/services/sharing/subscriptions.test.js b/server/services/sharing/subscriptions.test.js
index f162bfee72..bc13ef9c88 100644
--- a/server/services/sharing/subscriptions.test.js
+++ b/server/services/sharing/subscriptions.test.js
@@ -134,6 +134,20 @@ describe('sharing/subscriptions', () => {
rmSync(bucket2Path, { recursive: true, force: true });
});
+ it('adoptImportedSubscription does not flip a deliberately-subscribed record to adoptedFromImport on re-adopt', async () => {
+ const bucket = await buckets.createBucket({ name: 'B', path: tempBucket });
+ const u = await universeBuilder.createUniverse({ name: 'U-adopt' });
+ const original = await subs.subscribe({ bucketId: bucket.id, recordKind: 'universe', recordId: u.id });
+ expect(original.adoptedFromImport).toBeUndefined();
+
+ const adopted = await subs.adoptImportedSubscription({
+ bucketId: bucket.id, recordKind: 'universe', recordId: u.id, lastManifestId: 'inbound-1',
+ });
+ expect(adopted.id).toBe(original.id);
+ expect(adopted.adoptedFromImport).toBeUndefined();
+ expect(adopted.lastManifestId).toBe('inbound-1');
+ });
+
it('deleting the local record auto-unsubscribes via the deleted recordEvent', async () => {
subs.installSubscriptionListener();
const bucket = await buckets.createBucket({ name: 'D', path: tempBucket });