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

refactor([manuscript-review-sync]): /simplify — collapse review-fetch IIFE to .then().catch()

[._.]/ Adam Eivyec2652fcf8fc
diff --git a/PLAN.md b/PLAN.md
index 8d4e4651f7..3c3ccb1ed4 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -23,6 +23,7 @@ Claimable, well-specified, no decision needed — `/claim`-able. Unordered.
- [ ] [hidream-requires-hf-token-fail-fast] **Probe HF token upfront for HiDream gated-encoder downloads.** `data.reference/media-models.json`'s HiDream entries carry `requiresHfToken: true`, but `scripts/z_image_turbo.py` `load_external_text_encoder()` does NOT call `probe_hf_auth()` the way `flux2_macos.py:265` does. A user without a valid HF token currently sees a multi-GB download attempt that fails with a 401 deep inside transformers. Mirror the FLUX.2 probe before invoking `transformers.from_pretrained()` on the gated encoder repo.
- [ ] [flux2-runner-sidecar-tests] **Test coverage for `generateImage`'s sidecar `meta` payload.** `server/services/imageGen/local.test.js` exercises `buildArgs` but never asserts on the sidecar `meta` object built inside `generateImage` — including the `referenceImageFilenames` + `referenceImageStrengths` fields. A focused test would need to either factor the meta-builder out of `generateImage` so it's callable without spawning Python, or stub the spawn + assert on the persisted sidecar JSON.
- [ ] [extract-use-universe-load-hook] **Extract a `useUniverse(universeId)` load hook.** `client/src/components/pipeline/stages/StoryboardsStage.jsx` (~line 57) and `NounsStage.jsx` (~line 149) now run a byte-identical `useMounted` + `let cancelled` + `getUniverse(series.universeId).then(...).catch(...)` effect to load the linked universe record. Extract a `client/src/hooks/useUniverse.js` returning `[universe, loading, error]` (handling the mount/cancel guards internally), register it in the hooks `index.js` barrel + README, and migrate both call sites. Deferred from the wardrobe-picking PR: migrating `NounsStage` is outside that diff's scope and the new module trips the barrel maintenance rule. Surfaced by /simplify (reuse, 2026-06-01).
+- [ ] [bucket-record-path-helper] **Extract bucket record-file path helpers.** The share-bucket exporter and importer hand-join `join(bucket.path, 'records', '<type>', `${id}.json`)` at ~10 sites across `server/services/sharing/exporter.js` (series/issues/universes/media/reviews) and `server/services/sharing/importer.js` (`readReferencedRecords` + the manuscript-review read). `buckets.js` already has the parallel blob helpers (`bucketBlobPath`/`bucketBlobsDir`) but no record-path equivalent. Add `bucketRecordsDir(bucketPath, type)` + `bucketRecordPath(bucketPath, type, id)` to `buckets.js`, optionally add `records/reviews` to `ensureBucketLayout`, and migrate all sites. Deferred from the manuscript-review-sync PR: it's a cross-cutting cleanup of pre-existing hand-joins (my new code follows the established pattern), so it warrants its own change rather than a half-migration. Surfaced by /simplify (reuse, 2026-06-02).
- [ ] [create-issue-preload-series-for-batch] **`createIssue`'s renumber pass re-reads the series on every call — preload it for batch episode seeding.** `createIssue` (`server/services/pipeline/issues.js`) calls `getSeries()` inside its `renumberInline` pass on every invocation. `commitEpisodesToIssues` (`server/services/pipeline/arcPlanner.js`) creates one issue per episode in a loop, so a 12-episode season does 12 redundant `getSeries()` reads of an unchanging record (and `generateIssuesFromArc` already fetched it once). Add a `createIssueWithPreloadedSeries(series, input)` variant (or a `{ preloadedSeries }` option) that threads the already-fetched series into `renumberInline`, and route the batch loop through it. Pre-existing in `createIssue` (the Pipeline season-episodes route pays the same cost); LLM-bound batch so the realized win is small — surfaced by /simplify (efficiency) during the story-builder-issue-llm-seeding PR (2026-06-01). Deferred because it touches the `issues.js` renumber internals beyond this diff's scope.
## Blocked / Deferred (skip for `/claim`)
diff --git a/server/services/sharing/peerSync.js b/server/services/sharing/peerSync.js
index bdb4ca45a1..451596fb48 100644
--- a/server/services/sharing/peerSync.js
+++ b/server/services/sharing/peerSync.js
@@ -1281,10 +1281,9 @@ async function buildPushPayload(sub, sourceInstanceId) {
// boot load path (matches the catalogBundle pattern).
const manuscriptReview = record.deleted === true
? null
- : await (async () => {
- const { getReview } = await import('../pipeline/manuscriptReview.js');
- return getReview(sub.recordId).catch(() => null);
- })();
+ : await import('../pipeline/manuscriptReview.js')
+ .then(({ getReview }) => getReview(sub.recordId))
+ .catch(() => null);
return {
kind: 'series',
record: sanitized,