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

address review (gemini): prefer stage output over input when collecting source text; target post-import issue total in additive imports

[._.]/ Adam Eivy6d40912e0251
diff --git a/server/services/importer.js b/server/services/importer.js
index 6f18a51014..936e447a74 100644
--- a/server/services/importer.js
+++ b/server/services/importer.js
@@ -1201,7 +1201,11 @@ export async function commitImport({
} else {
if (arcLogline && !(series.logline || '').trim()) biblePatch.logline = arcLogline;
if (arcPremise && !(series.premise || '').trim()) biblePatch.premise = arcPremise;
- if (issueCount > 0 && !(series.issueCountTarget > 0)) biblePatch.issueCountTarget = issueCount;
+ // Additive: target the POST-import total (issues already on the series plus
+ // the ones being added), not just this batch — adding 3 issues to a series
+ // that already has 2 should target 5, not 3. Only when no target is set yet.
+ const additiveTotal = existingIssues.length + issueCount;
+ if (additiveTotal > 0 && !(series.issueCountTarget > 0)) biblePatch.issueCountTarget = additiveTotal;
}
let updatedSeries = series;
diff --git a/server/services/pipeline/arcPlanner.js b/server/services/pipeline/arcPlanner.js
index cd841f6378..2632ec063c 100644
--- a/server/services/pipeline/arcPlanner.js
+++ b/server/services/pipeline/arcPlanner.js
@@ -163,7 +163,12 @@ const BACKFILL_SOURCE_MAX = 200_000;
// textStages.js imports from THIS module (compareIssuesByPosition,
// NO_LINKED_UNIVERSE_PLACEHOLDER) — importing back would create a cycle whose
// binding is undefined at module-eval time. The one-liner is stable.
-const stageTextOf = (stage) => (stage?.input?.trim() || stage?.output?.trim() || '');
+// output (the generated/edited artifact) before input (the upstream seed): for
+// back-derivation we want the most-developed text, so a prose stage with both a
+// beat-sheet seed (input) and a drafted manuscript (output) yields the draft.
+// (textStages.stageContentOf is input-first because it answers a different
+// question — "does this stage have ANY content to use as a generation source".)
+const stageTextOf = (stage) => (stage?.output?.trim() || stage?.input?.trim() || '');
// Default stage precedence: the richest authored artifact per issue. `idea`
// (the outline/synopsis seed) is the lowest-priority fallback — it lets an