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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): honor aesthetic lock + idea-step output in stale hash
Adam Eivyc080ec244400
diff --git a/server/services/storyBuilder.js b/server/services/storyBuilder.jsindex 68762d0117..816eda3d97 100644--- a/server/services/storyBuilder.js+++ b/server/services/storyBuilder.js@@ -266,10 +266,22 @@ function buildUpstreamInputs(session, universe, series) {const arc = projectArc(series);const readerMap = series?.arc?.readerMap || null;const cast = projectCast(universe);+ // The idea step expands seedIdea into universe.starterPrompt + series+ // logline/premise. Those are non-deterministic LLM outputs, so seedIdea+ // alone is NOT a sufficient proxy for "idea-step content unchanged" — re-+ // running idea expand can produce a different starterPrompt with the same+ // seed, and downstream steps (aesthetic, plotArc) consume those outputs.+ // Including them in the downstream hashes flags those locked steps stale+ // when idea is regenerated.+ const ideaOutputs = {+ starterPrompt: universe?.starterPrompt || '',+ seriesLogline: series?.logline || '',+ seriesPremise: series?.premise || '',+ };return {idea: { intakeMode: session.intakeMode, seedIdea: session.seedIdea || '' },- universeAesthetic: { seedIdea: session.seedIdea || '' },- plotArc: { aesthetic, seedIdea: session.seedIdea || '' },+ universeAesthetic: { seedIdea: session.seedIdea || '', ideaOutputs },+ plotArc: { aesthetic, seedIdea: session.seedIdea || '', ideaOutputs },readerMap: { arc },characters: { readerMap, arcSummary: arc.summary, aesthetic },issues: { arc, readerMap, cast },@@ -438,8 +450,16 @@ export async function generateStep(id, stepId, options = {}) {const expandedIdea = isStr(content?.expandedIdea) ? content.expandedIdea.trim() : '';const logline = isStr(content?.logline) ? content.logline.trim() : '';// Seed the universe starter + series premise/logline from the expansion.+ // Honor downstream lock keys: locking the universeAesthetic step sets+ // universe.locked.{logline,...} via applyUnderlyingLock, but+ // updateUniverse doesn't enforce those locks on scalar writes — so a+ // re-run of the idea step would otherwise silently clobber a locked+ // logline. Skip any scalar field the user has explicitly locked.if (session.universeId && expandedIdea) {- await updateUniverse(session.universeId, { starterPrompt: expandedIdea, ...(logline ? { logline } : {}) });+ const universe = await getUniverse(session.universeId);+ const patch = { starterPrompt: expandedIdea };+ if (logline && !universe?.locked?.logline) patch.logline = logline;+ await updateUniverse(session.universeId, patch);}if (session.seriesId) {await updateSeries(session.seriesId, { ...(logline ? { logline } : {}), ...(expandedIdea ? { premise: expandedIdea } : {}) });diff --git a/server/services/storyBuilder.test.js b/server/services/storyBuilder.test.jsindex d0fc8eda24..3ea76bc029 100644--- a/server/services/storyBuilder.test.js+++ b/server/services/storyBuilder.test.js@@ -146,6 +146,23 @@ describe('storyBuilder — integrity / staleness', () => {const view = await sb.getStorySessionView(s.id);expect(view.staleSteps).toEqual([]);});++ it('flags a locked universeAesthetic stale when the idea step re-runs with a new starterPrompt', async () => {+ // Regression for the codex review finding: universeAesthetic's upstream+ // hash must track universe.starterPrompt (an idea-step OUTPUT that the+ // aesthetic expand reads), not just session.seedIdea. Without this,+ // re-running idea expand with the same seed but a non-deterministic LLM+ // result silently keeps a locked aesthetic step un-flagged.+ const s = await sb.createStorySession({ title: 'X', seedIdea: 'seed' });+ await universeSvc.updateUniverse(s.universeId, { starterPrompt: 'starter v1' });+ await sb.lockStep(s.id, 'universeAesthetic');+ let view = await sb.getStorySessionView(s.id);+ expect(view.staleSteps).not.toContain('universeAesthetic');+ // Mutate starterPrompt — same seedIdea but a fresh expansion.+ await universeSvc.updateUniverse(s.universeId, { starterPrompt: 'starter v2' });+ view = await sb.getStorySessionView(s.id);+ expect(view.staleSteps).toContain('universeAesthetic');+ });});describe('storyBuilder — generate delegation', () => {@@ -201,4 +218,25 @@ describe('storyBuilder — generate delegation', () => {expect.objectContaining({ providerOverride: 'override-z', modelOverride: 'override-m' }),);});++ it('generateStep(idea) skips writing a locked universe.logline', async () => {+ // Regression for the codex review finding: locking the aesthetic step+ // sets universe.locked.{logline,premise,...}=true, but updateUniverse+ // doesn't enforce those locks on scalar writes — so a re-run of the+ // idea step would otherwise silently clobber the locked logline.+ const s = await sb.createStorySession({ title: 'X', seedIdea: 'seed' });+ await universeSvc.updateUniverse(s.universeId, {+ logline: 'frozen logline',+ locked: { logline: true },+ });+ stageRunnerSpy = vi.fn(async () => ({+ content: { expandedIdea: 'new starter prose', logline: 'replacement logline that must NOT land' },+ runId: 'r', providerId: 'p', model: 'm',+ }));+ await sb.generateStep(s.id, 'idea');+ const universe = await universeSvc.getUniverse(s.universeId);+ expect(universe.logline).toBe('frozen logline');+ // starterPrompt is NOT locked by the aesthetic step's keys, so this DID land.+ expect(universe.starterPrompt).toBe('new starter prose');+ });});