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([issue-1289]): preserve tickingClock across arc regenerate/refine/resolve/derive

[._.]/ Adam Eivye83923c7e4fe
diff --git a/server/services/pipeline/arcPlanner.test.js b/server/services/pipeline/arcPlanner.test.js
index 328cd6b266..e37ca8103f 100644
--- a/server/services/pipeline/arcPlanner.test.js
+++ b/server/services/pipeline/arcPlanner.test.js
@@ -824,6 +824,33 @@ describe('arcPlanner — resolveVerifyIssues', () => {
expect(out.series.arc.shape).toBe('man-in-hole');
expect(out.series.arc.readerMap?.hooks?.[0]?.label).toBe('why is the foundry silent');
});
+
+ it('preserves series.arc.tickingClock when the resolve LLM does not author one', async () => {
+ // Same drift class as readerMap above — the resolve prompt never authors a
+ // ticking clock, so omitting it must not wipe the user's existing countdown.
+ const s = await setupSeries();
+ await seriesSvc.updateSeries(s.id, {
+ arc: {
+ logline: 'L', summary: 'S', shape: 'man-in-hole',
+ tickingClock: { enabled: true, label: 'The dam breaks', kind: 'deadline', stakes: 'town floods' },
+ },
+ });
+ stageRunnerSpy = vi.fn(async () => ({
+ content: {
+ arc: { logline: 'L2', summary: 'S2', themes: [], protagonistArc: '' },
+ seasons: [],
+ notes: '',
+ },
+ runId: 'r', providerId: 'p', model: 'm',
+ }));
+ const out = await planner.resolveVerifyIssues(s.id, {
+ findings: [{ severity: 'medium', problem: 'X', suggestion: 'Y' }],
+ });
+ expect(out.applied).toBe(true);
+ expect(out.series.arc.logline).toBe('L2');
+ expect(out.series.arc.tickingClock?.enabled).toBe(true);
+ expect(out.series.arc.tickingClock?.label).toBe('The dam breaks');
+ });
});
describe('arcPlanner — commitSeasonsWithRemap', () => {
diff --git a/server/services/pipeline/arcPlanner/arcCore.js b/server/services/pipeline/arcPlanner/arcCore.js
index c47fd1f331..70d2841c8b 100644
--- a/server/services/pipeline/arcPlanner/arcCore.js
+++ b/server/services/pipeline/arcPlanner/arcCore.js
@@ -16,7 +16,7 @@ import { emitRecordUpdated, withReexportSuppressed } from '../../sharing/recordE
import { getSeason } from '../seasons.js';
import { READER_MAP_BEAT_KINDS, buildSeason, cleanThemes, renderArcShapeGuidance, renderArcShapePositionSummary, sanitizeArc, sanitizeReaderMap, sanitizeSeason, sanitizeSeasonList } from '../../../lib/storyArc.js';
import { runPromptRefineRaw, trimChanges } from '../refineHelpers.js';
-import { ERR_VALIDATION, SHAPE_GUIDANCE_NONE, buildArcBaseContext, buildArcOverviewContext, buildNeighborVolumes, buildReaderMapContext, buildResolveContext, buildVerifyContext, compareIssuesByPosition, makeErr, renderVolumeIssue, resolveWorldContext, shapeFindings, shapeSeasonOutlines, shapeVerifyIssues } from './context.js';
+import { ERR_VALIDATION, SHAPE_GUIDANCE_NONE, appendTickingClock, buildArcBaseContext, buildArcOverviewContext, buildNeighborVolumes, buildReaderMapContext, buildResolveContext, buildVerifyContext, compareIssuesByPosition, makeErr, renderVolumeIssue, resolveWorldContext, shapeFindings, shapeSeasonOutlines, shapeVerifyIssues } from './context.js';
export async function generateArcOverview(seriesId, options = {}) {
const series = await getSeries(seriesId);
@@ -53,6 +53,9 @@ export async function generateArcOverview(seriesId, options = {}) {
// existing one (like `shape`) so regenerating the arc never silently wipes
// a reader map the user already built on the next step.
readerMap: series.arc?.readerMap ?? null,
+ // Same for the ticking clock — the overview prompt doesn't author it, so
+ // preserve any existing countdown across a regenerate.
+ tickingClock: series.arc?.tickingClock ?? null,
status: 'draft',
});
const seasons = shapeSeasonOutlines(content?.seasonOutlines);
@@ -128,7 +131,7 @@ export async function refineReaderMap(seriesId, feedback, options = {}) {
feedback: typeof feedback === 'string' ? feedback.trim().slice(0, 4000) : '',
arcSummary: arc.summary || '',
protagonistArc: arc.protagonistArc || '',
- shapeGuidance: renderArcShapeGuidance(arc.shape) || SHAPE_GUIDANCE_NONE,
+ shapeGuidance: appendTickingClock(renderArcShapeGuidance(arc.shape) || SHAPE_GUIDANCE_NONE, arc),
beatKindsCsv: READER_MAP_BEAT_KINDS.join(', '),
},
options,
@@ -184,7 +187,7 @@ export async function refineArc(seriesId, feedback, options = {}) {
currentSummary: arc.summary || '',
currentProtagonistArc: arc.protagonistArc || '',
currentThemesCsv: Array.isArray(arc.themes) ? arc.themes.join(', ') : '',
- shapeGuidance: renderArcShapeGuidance(arc.shape) || SHAPE_GUIDANCE_NONE,
+ shapeGuidance: appendTickingClock(renderArcShapeGuidance(arc.shape) || SHAPE_GUIDANCE_NONE, arc),
series: { name: series.name, premise: series.premise },
feedback: typeof feedback === 'string' ? feedback.trim().slice(0, 4000) : '',
},
@@ -217,6 +220,9 @@ export async function refineArc(seriesId, feedback, options = {}) {
themes: refinedThemes,
shape: arc.shape ?? null,
readerMap: arc.readerMap ?? null,
+ // The arc-refine prompt edits the narrative fields only — preserve the
+ // ticking clock (like readerMap/shape) so a refine never wipes it.
+ tickingClock: arc.tickingClock ?? null,
status: 'draft',
});
// sanitizeArc returns null only when every identifying field is empty — which,
@@ -372,6 +378,8 @@ export async function resolveVerifyIssues(seriesId, options = {}) {
// one so auto-resolve never silently wipes a reader map the user already
// built on the next step. Mirrors `generateArcOverview` above.
readerMap: series.arc?.readerMap ?? null,
+ // Same for the ticking clock — auto-resolve must not wipe the countdown.
+ tickingClock: series.arc?.tickingClock ?? null,
status: 'draft',
});
diff --git a/server/services/pipeline/arcPlanner/context.js b/server/services/pipeline/arcPlanner/context.js
index fdcc9d5bc2..7d2671b8b4 100644
--- a/server/services/pipeline/arcPlanner/context.js
+++ b/server/services/pipeline/arcPlanner/context.js
@@ -281,7 +281,7 @@ export const SHAPE_GUIDANCE_NONE = '(no Vonnegut story shape selected — the ve
// generation without adding a new template variable — and therefore without a
// stage-prompt migration. Returns the guidance unchanged when there's no
// enabled clock.
-function appendTickingClock(shapeGuidance, arc) {
+export function appendTickingClock(shapeGuidance, arc) {
const clock = renderTickingClock(arc?.tickingClock);
return clock ? `${shapeGuidance}\n\n${clock}` : shapeGuidance;
}
diff --git a/server/services/pipeline/arcPlanner/manuscriptDerive.js b/server/services/pipeline/arcPlanner/manuscriptDerive.js
index 643ce54538..92c05b6db2 100644
--- a/server/services/pipeline/arcPlanner/manuscriptDerive.js
+++ b/server/services/pipeline/arcPlanner/manuscriptDerive.js
@@ -64,6 +64,8 @@ export async function generateArcFromSource(seriesId, {
shape: content?.shape ?? series.arc?.shape ?? null,
// Preserve an existing reader map — the extraction doesn't author one.
readerMap: series.arc?.readerMap ?? null,
+ // Likewise preserve an existing ticking clock the extraction doesn't author.
+ tickingClock: series.arc?.tickingClock ?? null,
status: 'draft',
});
// importer-arc-extract returns `seasons` (number/title/logline/synopsis/