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

perf: load bible sync only for Writers Room work (#6943)

[._.]/ Adam Eivy8ca45f977473
diff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.js
index 8df75d67b4..0bb1eb75af 100644
--- a/server/lib/importScoping.test.js
+++ b/server/lib/importScoping.test.js
@@ -38,6 +38,10 @@ const reaches = (entry, target) => staticImportClosure(abs(entry)).files.has(abs
// Each row: the entry that was narrowed, the module it must no longer
const NARROWED = [
+ ['services/sharing/peerSyncPush.js', 'services/writersRoom/bibleSync.js',
+ 'loads bible asset handling only for Writers Room work pushes'],
+ ['services/sharing/peerSyncReceive.js', 'services/writersRoom/bibleSync.js',
+ 'loads bible asset handling only for Writers Room work receives'],
['services/persistentMindAttachments.js', 'services/persistentMindSupervisor.js',
'owns screenshot attachment lifecycle without supervisor turn execution'],
['services/mtplxModelManager.js', 'services/huggingFaceCatalog.js',
diff --git a/server/services/sharing/peerSyncPush.js b/server/services/sharing/peerSyncPush.js
index 94f988b572..427302a0e3 100644
--- a/server/services/sharing/peerSyncPush.js
+++ b/server/services/sharing/peerSyncPush.js
@@ -26,7 +26,6 @@ import {
findCollectionBySeriesId,
} from '../mediaCollections.js';
import { getTrack } from '../tracks/index.js';
-import { buildWorkBibleManifest } from '../writersRoom/bibleSync.js';
import { buildWorkBodyManifest } from '../writersRoom/sync.js';
import { ackDeletesUpTo } from './peerTombstoneCursors.js';
import {
@@ -711,6 +710,7 @@ export async function buildPushPayload(sub, sourceInstanceId) {
return { ...envelope, ...(linkedTrack ? { linkedTrack } : {}) };
}
if (sub.recordKind === 'writersRoomWork') {
+ const { buildWorkBibleManifest } = await import('../writersRoom/bibleSync.js');
// The work manifest carries draft-version METADATA; the file-primary `.md`
// prose bodies ride a separate `draftBodyManifest` (SHA256 per draft) the
// receiver diffs + pulls. A tombstone ships neither asset manifest.
diff --git a/server/services/sharing/peerSyncReceive.js b/server/services/sharing/peerSyncReceive.js
index 9703dac677..892a42239a 100644
--- a/server/services/sharing/peerSyncReceive.js
+++ b/server/services/sharing/peerSyncReceive.js
@@ -9,7 +9,6 @@
*
* Split out of the former 4,004-line peerSync.js (#1830).
*/
-import { diffWorkBibleManifest } from '../writersRoom/bibleSync.js';
import { isPlainObject } from '../../lib/objects.js';
import {
PORTOS_SCHEMA_VERSIONS,
@@ -453,6 +452,7 @@ export async function applyIncomingPush(payload) {
// Same guards as the asset path: skip for local-ephemeral and tombstone pushes.
let missingDraftBodies = [];
if (kind === 'writersRoomWork' && !localEphemeral && record.deleted !== true) {
+ const { diffWorkBibleManifest } = await import('../writersRoom/bibleSync.js');
// Scope the manifest to THIS work: a body entry's path is works/<workId>/...,
// so an entry whose workId != the pushed record's id would write bytes into a
// DIFFERENT local work's draft (clobbering unrelated prose when the merge