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

docs([extract-single-flight-map-helper]): remove from PLAN.md and log to changelog

[._.]/ Adam Eivy10f853dd6203
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 608394d21c..c13e6bb480 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -66,6 +66,7 @@
- **[settings-shallow-getsave-callers-tidy]** Saving Telegram config (method, bot token/chat id, forwarded types) and system-health alert thresholds now runs inside the settings write queue too, closing the same stale-snapshot clobber window (no user-facing change).
- **[json-state-serialization-one-mechanism]** The Chief-of-Staff state file now serializes its writes with the same shared queue the rest of the app's JSON stores use, instead of a separate bespoke lock — one fewer concurrency mechanism to maintain (no user-facing change).
- **[worktree-remove-helper]** The four agent-worktree cleanup paths now share one robust "remove, then force-clean if git refuses" helper instead of four hand-copied versions — same cleanup behavior, less duplicated code to drift (no user-facing change).
+- **[extract-single-flight-map-helper]** The provider-fallback path now uses a shared "coalesce concurrent calls onto one in-flight result" helper instead of a hand-rolled version, standardizing the cleanup idiom for future reuse (no user-facing change).
- **[plan-task-prefer-merge] The scheduled "ship the next PLAN.md item" agent now prefers a real merge commit over a squash when closing its PR.** Its merge step tries auto-merge first, then a plain `--merge`, then squash/rebase as fallbacks — matching the merge style the manual review flow already uses, so scheduled and manual work land in your history the same way. Existing installs auto-upgrade the prompt unless you've customized it.
- **[wardrobe-appearance-id-route-validation] Rendering a storyboard scene with a stale outfit pick now fails clearly instead of silently ignoring it.** If a scene's wardrobe selection points at a character or outfit that no longer exists (e.g. it was deleted after the pick was made), the render returns a clear error instead of quietly rendering the character without that outfit.
- **[create-issue-preload-series-for-batch]** Seeding a whole season's episodes into issues now reads the series record once for the batch instead of once per episode (no user-facing change).
diff --git a/PLAN.md b/PLAN.md
index a81979f593..96f59538fc 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -38,7 +38,6 @@ Claimable, well-specified, no decision needed — `/claim`-able. Unordered.
- [ ] [prune-orphan-subscriptions-for-deleted-records] **Sweep orphaned peer subscriptions left by tombstone prune.** `pruneTombstonedUniverses` / `pruneTombstonedSeries` rm the record dir but leave its rows in `data/peer_subscriptions.json`. On `peer:online`, `retryPendingPushesForPeer` walks them, `loadOne` returns null, and the push no-ops (harmless but inflates the "retrying N pending pushes" count). Add an orphan-subscription sweep (drop subs whose `recordKind/recordId` no longer resolves) to the tombstone GC path.
- [ ] [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).
- [ ] [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.
-- [ ] [extract-single-flight-map-helper] **Extract a shared single-flight / in-flight-coalescing helper.** Three sites now hand-roll the `Map<key, Promise>` "share the in-flight result, delete on settle" idiom: `server/lib/sseDownload.js` (`inFlight` keyed by repo, line ~12), `server/lib/promptRunner.js` (`_fallbackMarkAndPickInFlight` keyed by failed provider id), and the read-coalescing half of `server/lib/aiToolkit/providers.js#loadProviders` (`providersLoadInFlight`). A small `server/lib/singleFlight.js` (`createSingleFlight()` returning `run(key, fn)` that returns the shared promise and auto-clears on settle) would dedupe the boilerplate and standardize the cleanup. Note the three sites differ in shape — providers.js layers a TTL snapshot cache on top, promptRunner does keyed side-effectful work — so the helper must stay minimal (just the keyed coalesce) and not try to absorb the TTL/cache concern. Deferred from the coalesce-fallback PR: it's a new public lib module (barrel + README maintenance) that also touches an unrelated file, so it warrants its own PR. Surfaced by /simplify (reuse, 2026-06-01).
## Blocked / Deferred (skip for `/claim`)