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
feat: add distinct climax arc role (#4454)
Adam Eivy9de39afe5c59
diff --git a/.changelog/next/added-issue-4454.md b/.changelog/next/added-issue-4454.mdnew file mode 100644index 0000000000..305e03178a--- /dev/null+++ b/.changelog/next/added-issue-4454.md@@ -0,0 +1 @@+- Added a distinct climax arc role across story planning, imports, issue editing, and cross-version sync.diff --git a/client/src/components/pipeline/ArcRolePicker.jsx b/client/src/components/pipeline/ArcRolePicker.jsxnew file mode 100644index 0000000000..d10e15e51a--- /dev/null+++ b/client/src/components/pipeline/ArcRolePicker.jsx@@ -0,0 +1,24 @@+const roleLabel = (role) => role+ .split('-')+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))+ .join(' ');++export default function ArcRolePicker({ issue, arcRoles = [], onChange, disabled = false }) {+ return (+ <label className="inline-flex items-center gap-2 text-xs text-gray-400">+ <span>Arc role</span>+ <select+ value={issue?.arcRole || ''}+ onChange={(event) => onChange(event.target.value || null)}+ disabled={disabled || arcRoles.length === 0}+ className="rounded-lg border border-port-border bg-port-card px-2 py-2 text-sm text-white disabled:opacity-50"+ title={arcRoles.length === 0 ? 'Arc roles unavailable' : 'Issue arc role'}+ >+ <option value="">None</option>+ {arcRoles.map((role) => (+ <option key={role} value={role}>{roleLabel(role)}</option>+ ))}+ </select>+ </label>+ );+}diff --git a/client/src/components/pipeline/ArcRolePicker.test.jsx b/client/src/components/pipeline/ArcRolePicker.test.jsxnew file mode 100644index 0000000000..b28b943e2c--- /dev/null+++ b/client/src/components/pipeline/ArcRolePicker.test.jsx@@ -0,0 +1,24 @@+import { describe, expect, it, vi } from 'vitest';+import { fireEvent, render, screen } from '@testing-library/react';++import ArcRolePicker from './ArcRolePicker';++describe('ArcRolePicker', () => {+ const arcRoles = ['pilot', 'climax', 'finale'];++ it('renders server-provided roles and saves climax independently', () => {+ const onChange = vi.fn();+ render(<ArcRolePicker issue={{ arcRole: 'pilot' }} arcRoles={arcRoles} onChange={onChange} />);+ const picker = screen.getByRole('combobox', { name: 'Arc role' });+ expect(screen.getByRole('option', { name: 'Climax' })).toBeInTheDocument();+ fireEvent.change(picker, { target: { value: 'climax' } });+ expect(onChange).toHaveBeenCalledWith('climax');+ });++ it('maps the empty selection to an intentional clear', () => {+ const onChange = vi.fn();+ render(<ArcRolePicker issue={{ arcRole: 'climax' }} arcRoles={arcRoles} onChange={onChange} />);+ fireEvent.change(screen.getByRole('combobox', { name: 'Arc role' }), { target: { value: '' } });+ expect(onChange).toHaveBeenCalledWith(null);+ });+});diff --git a/client/src/components/pipeline/arcCanvas/IssueRow.jsx b/client/src/components/pipeline/arcCanvas/IssueRow.jsxindex 5a0cdce5d1..f941248207 100644--- a/client/src/components/pipeline/arcCanvas/IssueRow.jsx+++ b/client/src/components/pipeline/arcCanvas/IssueRow.jsx@@ -69,6 +69,14 @@ export default function IssueRow({ issue, seasons, onIssuesUpdate }) {<span className={`text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded ${ISSUE_STATUS_COLORS[issue.status] || ISSUE_STATUS_COLORS.draft}`}>{issue.status}</span>+ {issue.arcRole ? (+ <span+ className="text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-port-accent/10 text-port-accent"+ title="Arc role"+ >+ {issue.arcRole}+ </span>+ ) : null}</div><p className="text-sm text-white font-medium line-clamp-2">{issue.title || 'Untitled'}</p><p className="text-[10px] text-gray-600">updated {timeAgo(issue.updatedAt)}</p>diff --git a/client/src/pages/PipelineIssue.jsx b/client/src/pages/PipelineIssue.jsxindex e849a487f4..d5a9ec3fa8 100644--- a/client/src/pages/PipelineIssue.jsx+++ b/client/src/pages/PipelineIssue.jsx@@ -16,7 +16,7 @@ import toast from '../components/ui/Toast';import Modal from '../components/ui/Modal';import TabPills from '../components/ui/TabPills';import {- getPipelineIssue, getPipelineSeries, updatePipelineIssue,+ getPipelineConfig, getPipelineIssue, getPipelineSeries, updatePipelineIssue,startPipelineAutoRunText, cancelPipelineAutoRunText, pipelineAutoRunSseUrl,PIPELINE_STAGES, PIPELINE_TAB_STAGES, PIPELINE_STAGE_LABELS,} from '../services/api';@@ -34,6 +34,7 @@ import AudioStage from '../components/pipeline/stages/AudioStage';import IssueJudgePanel from '../components/pipeline/IssueJudgePanel';import SeriesLlmPicker from '../components/pipeline/SeriesLlmPicker';import LengthProfilePicker from '../components/pipeline/LengthProfilePicker';+import ArcRolePicker from '../components/pipeline/ArcRolePicker';import CatalogCastPanel from '../components/CatalogCastPanel';import { VisualGenSettingsPanel } from '../components/pipeline/stages/VisualGenSettings';@@ -93,11 +94,13 @@ export default function PipelineIssue() {const [issue, setIssue] = useState(null);const [series, setSeries] = useState(null);+ const [arcRoles, setArcRoles] = useState([]);const [loading, setLoading] = useState(true);const [autoRunStarting, setAutoRunStarting] = useState(false);const [autoRunActive, setAutoRunActive] = useState(false);const [settingsOpen, setSettingsOpen] = useState(false);const [lengthProfileSaving, setLengthProfileSaving] = useState(false);+ const [arcRoleSaving, setArcRoleSaving] = useState(false);const [genConfigSaving, setGenConfigSaving] = useState(false);// Close the settings modal whenever the active stage changes so it doesn't// reopen unexpectedly when the user returns to a previously-visited stage.@@ -106,6 +109,9 @@ export default function PipelineIssue() {useEffect(() => {let canceled = false;+ getPipelineConfig({ silent: true })+ .then((config) => { if (!canceled) setArcRoles(config.arcRoles || []); })+ .catch(() => null);getPipelineIssue(issueId, { silent: true }).then((iss) => {if (canceled) return iss;@@ -170,6 +176,14 @@ export default function PipelineIssue() {.finally(() => setLengthProfileSaving(false));};+ const handleArcRoleChange = async (arcRole) => {+ setArcRoleSaving(true);+ updatePipelineIssue(issueId, { arcRole }, { silent: true })+ .then((updated) => { if (updated) setIssue(updated); })+ .catch((err) => { toast.error(err.message || 'Save failed'); })+ .finally(() => setArcRoleSaving(false));+ };+// Persist genConfig changes from the header settings modal. The active// visual stage owns the config record (we keep per-stage genConfig so a// user can pin "codex" for comicPages but "local" for storyboards).@@ -302,6 +316,12 @@ export default function PipelineIssue() {<div className="flex items-center justify-between gap-3 flex-wrap"><h1 className="text-xl font-bold text-white truncate">#{issue.number} — {issue.title}</h1><div className="flex items-center gap-2 flex-wrap">+ <ArcRolePicker+ issue={issue}+ arcRoles={arcRoles}+ onChange={handleArcRoleChange}+ disabled={autoRunStarting || autoRunActive || arcRoleSaving}+ /><LengthProfilePickerissue={issue}onChange={handleLengthChange}@@ -326,7 +346,7 @@ export default function PipelineIssue() {<buttontype="button"onClick={() => handleAutoRun({})}- disabled={autoRunStarting || autoRunActive || lengthProfileSaving || genConfigSaving}+ disabled={autoRunStarting || autoRunActive || arcRoleSaving || lengthProfileSaving || genConfigSaving}className="inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-port-accent text-white text-sm font-medium disabled:opacity-50"title={lengthProfileSaving ? 'Saving length profile…' : genConfigSaving ? 'Saving visual settings…' : 'Run idea → prose → (comic script + teleplay) end to end'}>@@ -336,7 +356,7 @@ export default function PipelineIssue() {<buttontype="button"onClick={() => handleAutoRun({ includeVideo: true })}- disabled={autoRunStarting || autoRunActive || lengthProfileSaving || genConfigSaving}+ disabled={autoRunStarting || autoRunActive || arcRoleSaving || lengthProfileSaving || genConfigSaving}className="inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-port-card border border-port-accent/40 text-white text-sm font-medium disabled:opacity-50 hover:bg-port-accent/10"title={lengthProfileSaving ? 'Saving length profile…' : genConfigSaving ? 'Saving visual settings…' : 'Run text stages and then kick off episode video via Creative Director (burns GPU)'}>@@ -417,7 +437,7 @@ export default function PipelineIssue() {series={series}onStageUpdate={handleStageUpdate}onSeriesUpdate={setSeries}- actionsGated={lengthProfileSaving || genConfigSaving}+ actionsGated={arcRoleSaving || lengthProfileSaving || genConfigSaving}/>) : (<div className="text-gray-500 text-sm">Unknown stage.</div>diff --git a/client/src/services/apiPipeline.js b/client/src/services/apiPipeline.jsindex 3f05400467..cb49fb331c 100644--- a/client/src/services/apiPipeline.js+++ b/client/src/services/apiPipeline.js@@ -68,6 +68,8 @@ export const PIPELINE_STAGE_STATUS_COLOR = Object.freeze({error: 'text-port-error',});+export const getPipelineConfig = (options = {}) => request('/pipeline/config', options);+// ---- Series ----// `options` lets a caller suppress request()'s auto-toast with `{ silent: true }`// (e.g. an optional join that should fail quietly) — see CLAUDE.md.diff --git a/data.reference/prompts/stage-config.json b/data.reference/prompts/stage-config.jsonindex 6c1541bd39..b6ae522911 100644--- a/data.reference/prompts/stage-config.json+++ b/data.reference/prompts/stage-config.json@@ -466,7 +466,7 @@},"pipeline-season-episodes": {"name": "Pipeline — Season Episode Breakdown",- "description": "Plan the episode-by-episode breakdown for one season of a multi-season series. Slots N episodes between the season's pickup state and ending hook, respecting prior seasons' continuity, the protagonist's whole-series arc, and a balanced mix of pilot / complication / midpoint / b-plot / all-is-lost / finale arc roles.",+ "description": "Plan the episode-by-episode breakdown for one season of a multi-season series. Slots N episodes between the season's pickup state and ending hook, respecting prior seasons' continuity, the protagonist's whole-series arc, and a balanced mix of pilot / complication / midpoint / b-plot / all-is-lost / climax / finale arc roles.","model": "default","returnsJson": true,"variables": []diff --git a/data.reference/prompts/stages/importer-issue-proposal.md b/data.reference/prompts/stages/importer-issue-proposal.mdindex d56fcc9793..91f6209c55 100644--- a/data.reference/prompts/stages/importer-issue-proposal.md+++ b/data.reference/prompts/stages/importer-issue-proposal.md@@ -50,14 +50,15 @@ Comic scripts mark issues with `ISSUE N` or `#N` or similar headers — honor thFor each issue:- **`title`** — short, evocative (3–8 words). Use the source's chapter / issue / act title verbatim if present, else distill from the issue's content. Do NOT use generic titles like "Issue 1" or "Chapter 3".- **`arcPosition`** — 1-indexed integer. Contiguous (1, 2, 3, …) — do not skip numbers.-- **`arcRole`** — one of `pilot`, `complication`, `midpoint`, `b-plot`, `all-is-lost`, `finale`. Use:+- **`arcRole`** — one of `pilot`, `complication`, `midpoint`, `b-plot`, `all-is-lost`, `climax`, `finale`. Use:- `pilot` — the opening issue that establishes the world + protagonist.- `complication` — issues that escalate the conflict.- `midpoint` — the mid-arc tonal pivot (often a false victory or false defeat).- `b-plot` — issues that develop secondary characters or subplots.- - `all-is-lost` — the lowest point before the finale.- - `finale` — the closing issue.- Use roles sparingly — a 12-issue series might have one `pilot`, one `midpoint`, one `all-is-lost`, one `finale`, and the rest `complication` / `b-plot`. Omit `arcRole` (don't return the field) if no role fits cleanly.+ - `all-is-lost` — the lowest point before the decisive confrontation.+ - `climax` — the decisive confrontation and protagonist choice.+ - `finale` — the later closing issue: consequences, denouement, and the new state.+ Use roles sparingly — a 12-issue series might have one `pilot`, one `midpoint`, one `all-is-lost`, one `climax`, one later `finale`, and the rest `complication` / `b-plot`. Omit `arcRole` (don't return the field) if no role fits cleanly.- **`logline`** — one sentence. What changes in this issue.- **`synopsis`** — 1 paragraph. The major beats of this issue.- **`proseExcerpt`** — the **verbatim** contiguous span of the source text that belongs to this issue. This becomes the issue's `stages.prose.output` and feeds the downstream comicScript / teleplay / storyboards renderers. **Copy exact characters from the source — no paraphrasing, no summarization, no insertion of headers I didn't write.** The excerpt may be long (up to 500K characters per issue); err on the side of including more rather than less, since downstream stages can re-process.diff --git a/data.reference/prompts/stages/pipeline-arc-verify.md b/data.reference/prompts/stages/pipeline-arc-verify.mdindex afc34e0a19..634eacbb35 100644--- a/data.reference/prompts/stages/pipeline-arc-verify.md+++ b/data.reference/prompts/stages/pipeline-arc-verify.md@@ -110,7 +110,7 @@ Score each volume + each episode against the arc. Specifically check:3. **Dropped subplots.** A subplot introduced in an early volume's `endingHook` or episode `synopsis` that never resolves in a later volume or episode.4. **Episode-count vs. arc-weight mismatch.** A volume with `episodeCountTarget: 12` whose synopsis carries only 3 meaningful turns, or a short volume carrying a full novel's weight.5. **Unresolved hooks at the series finale.** The final volume fails to pay off the whole-arc logline, protagonist arc, or major themes.-6. **Arc-role imbalance.** Once episodes exist, a volume with 8 episodes and zero `pilot` / `finale` `arcRole` entries (or duplicate pilots/finales).+6. **Arc-role imbalance and climax order.** Once episodes exist, require one `pilot`, one `climax`, and one later `finale` `arcRole` per volume. Flag missing/duplicate structural roles, a finale before the climax, or a finale that merely repeats the climax instead of delivering consequences and denouement. Use each episode's `lengthProfile` when judging whether the decisive climax has enough room independently from the closing finale; `extended` is the preferred climax default.7. **Theme drift.** A theme is named in `arc.themes` but does not appear in any volume synopsis or episode logline.8. **Story-shape adherence.** If a Vonnegut shape was selected, verify the volume-level fortune trajectory traces that curve. The whole-series finale must land at the shape's terminal level.9. **Cross-record fact reconciliation.** Compare the full-arc summary,diff --git a/data.reference/prompts/stages/pipeline-idea-expansion.md b/data.reference/prompts/stages/pipeline-idea-expansion.mdindex a5acd9ab1e..a330473d93 100644--- a/data.reference/prompts/stages/pipeline-idea-expansion.md+++ b/data.reference/prompts/stages/pipeline-idea-expansion.md@@ -67,7 +67,8 @@ Write beats appropriate to the arc role above:- `midpoint` — flips a major premise or reveals new information- `b-plot` — advances a secondary thread while the A-plot rests- `all-is-lost` — strips the protagonist of their advantage at the lowest point-- `finale` — pays off the volume's ending hook and lands the emotional arc+- `climax` — forces the protagonist's decisive active choice and confrontation+- `finale` — follows the climax with consequences, pays off the volume's ending hook, and lands the emotional arc{{/arcRole}}{{#priorVolume}}diff --git a/data.reference/prompts/stages/pipeline-season-episodes.md b/data.reference/prompts/stages/pipeline-season-episodes.mdindex aec0c951ff..4aaa914828 100644--- a/data.reference/prompts/stages/pipeline-season-episodes.md+++ b/data.reference/prompts/stages/pipeline-season-episodes.md@@ -59,18 +59,19 @@ Pace the episodes you write so the season's fortune trajectory matches this placPlan an arc *within* the season that bends from "pickup state" (the natural starting point given prior seasons + the protagonist arc) to the **ending hook** in exactly `episodeCountTarget` beats. Common shapes:-- **5-act season** — pilot, complication, midpoint pivot, all-is-lost, finale.-- **8-episode arc** — pilot, complication, complication, midpoint, complication, complication, all-is-lost, finale.+- **6-beat season** — pilot, complication, midpoint pivot, all-is-lost, climax, finale.+- **8-episode arc** — pilot, complication, complication, midpoint, complication, all-is-lost, climax, finale.- **12+** — add B-plot episodes between the structural beats; don't waste the count on filler.### Structure rules (enforce while beating out the season)-- **Try-fail mandate.** 60%+ of the middle episodes (everything between pilot and finale) must end in complication, not clean success — "Yes, but…" (they get what they wanted, but it costs or backfires) or "No, and…" (they fail, and it gets worse). A run of clean wins stalls momentum.+- **Try-fail mandate.** 60%+ of the middle episodes (everything between pilot and climax) must end in complication, not clean success — "Yes, but…" (they get what they wanted, but it costs or backfires) or "No, and…" (they fail, and it gets worse). A run of clean wins stalls momentum.- **Beat rules.**- Catalyst / pilot inciting event is EXTERNAL — it happens TO the protagonist; they don't choose it.- The pivot into the season's main conflict (Break Into Two) is a protagonist CHOICE — they decide to engage.- The all-is-lost beat includes a DEATH — literal, or the death of a hope, a relationship, or an identity.-- **Finale = the protagonist's hardest ACTIVE choice** between what they WANT (external goal) and what they NEED (the truth). They drive the climax; it does not resolve itself around them.+- **Climax = the protagonist's hardest ACTIVE choice** between what they WANT (external goal) and what they NEED (the truth). They drive the decisive confrontation; it does not resolve itself around them.+- **Finale = consequence and denouement after the climax.** Pay off the season ending hook, land the emotional arc, and establish the new state without replaying the decisive confrontation.For each episode write:@@ -79,14 +80,14 @@ For each episode write:- **`logline`** — one sentence; the question / image this episode opens with → resolves to.- **`synopsis`** — 2–3 sentences. What *happens* in this episode at the arc level. Don't write scene blocking — keep it at the level a season planner needs.- **`primaryCharacters`** — array of CAPS character names from the bible who carry the episode. Usually 1–3; never empty for a main character series.-- **`arcRole`** — single token describing the episode's structural job in this season. Pick one of: `pilot` / `complication` / `midpoint` / `b-plot` / `all-is-lost` / `finale`. Used downstream to verify the season has balanced shape.+- **`arcRole`** — single token describing the episode's structural job in this season. Pick one of: `pilot` / `complication` / `midpoint` / `b-plot` / `all-is-lost` / `climax` / `finale`. Used downstream to verify the season has balanced shape. The `climax` must precede a distinct later `finale`.- **`lengthProfile`** — single token sizing this episode for downstream prose / script / video generation. Pick one of:- `teaser` — promo / cold-open / mini-issue (~8 pages comic / ~10 min episode). Use sparingly, mostly for B-plot or anthology beats.- `standard` — the working default (~22 pages / ~24 min). Use for most episodes.- - `extended` — premiere / set-piece episodes (~32 pages / ~36 min). Use for pilots that have to establish a lot of world, or mid-season turning points that earn extra runtime.- - `finale` — season climax (~44 pages / ~48 min). Reserve for the actual `arcRole: 'finale'` episode (and occasionally `all-is-lost` if the budget allows). Don't apply to every episode — finale-length used everywhere becomes meaningless.+ - `extended` — premiere / set-piece episodes (~32 pages / ~36 min). This is the preferred default for `arcRole: 'climax'`, giving the decisive confrontation room without forcing the denouement to share its issue.+ - `finale` — season-closing issue (~44 pages / ~48 min). Reserve for the actual `arcRole: 'finale'` episode (and occasionally `all-is-lost` if the budget allows). Don't apply to every episode — finale-length used everywhere becomes meaningless.- Default to `standard` when nothing argues for a different size.+ Default `climax` to `extended`, `finale` to `finale`, and all other roles to `standard` when nothing argues for a different size.## Output contractdiff --git a/scripts/migrations/003-update-pipeline-stage-prompts.js b/scripts/migrations/003-update-pipeline-stage-prompts.jsindex 7ab5157d3d..8a5e3df0e5 100644--- a/scripts/migrations/003-update-pipeline-stage-prompts.js+++ b/scripts/migrations/003-update-pipeline-stage-prompts.js@@ -54,11 +54,11 @@ export const ACCEPTED_OLD_MD5 = {};export const NEW_SHIPPED_MD5 = {- 'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f', // post-127 (scene markers)+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e', // post-127 (scene markers)'pipeline-prose.md': '4cb3ef48309f3673570cf80e4d544b54', // post-169 (cross-issue continuity)'pipeline-comic-script.md': '49af30c05f008b20f6998a0f113f7d87', // post-127 (scene markers)'pipeline-tv-script.md': '376f779f4687b598f1c92ca4e770fd5a', // retired upstream (no data.reference)- 'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b', // post-172 (structure rules)+ 'pipeline-season-episodes.md': '7c24df53c097c2525a52bfb766239647', // post-172 (structure rules)};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/004-augment-idea-expansion-context.js b/scripts/migrations/004-augment-idea-expansion-context.jsindex 438795c18d..d888869568 100644--- a/scripts/migrations/004-augment-idea-expansion-context.js+++ b/scripts/migrations/004-augment-idea-expansion-context.js@@ -22,7 +22,7 @@ export const ACCEPTED_OLD_MD5 = {};export const NEW_SHIPPED_MD5 = {- 'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f', // post-127 (scene markers)+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e', // post-127 (scene markers)};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/005-shape-aware-arc-prompts.js b/scripts/migrations/005-shape-aware-arc-prompts.jsindex a235cd74e9..d1be307b96 100644--- a/scripts/migrations/005-shape-aware-arc-prompts.js+++ b/scripts/migrations/005-shape-aware-arc-prompts.js@@ -52,9 +52,9 @@ export const ACCEPTED_OLD_MD5 = {export const NEW_SHIPPED_MD5 = {'pipeline-arc-overview.md': '5ed760caaf3cf88916ec28b220e2f590', // post-250 arc spine checkpoint- 'pipeline-arc-verify.md': 'a397f158fd9c0dca1c8dbe62df253f70', // post-274 planning economy+ 'pipeline-arc-verify.md': '4b60a322e35b536405d0fbf543580562', // post-276 distinct climax'pipeline-volume-verify.md': '9c0839d7fe1760c0891464afd4a3b8fd', // post-274 planning economy- 'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b', // post-172 (structure rules)+ 'pipeline-season-episodes.md': '7c24df53c097c2525a52bfb766239647', // post-276 distinct climax'pipeline-arc-resolve.md': '638b988c84b3e5599f7a2ce09fa149ce', // post-274 planning economy};diff --git a/scripts/migrations/019-arc-volume-prompts-canon-context.js b/scripts/migrations/019-arc-volume-prompts-canon-context.jsindex 79bcf02edc..76a83f7a50 100644--- a/scripts/migrations/019-arc-volume-prompts-canon-context.js+++ b/scripts/migrations/019-arc-volume-prompts-canon-context.js@@ -63,7 +63,7 @@ export const ACCEPTED_OLD_MD5 = {export const NEW_SHIPPED_MD5 = {'pipeline-arc-overview.md': '5ed760caaf3cf88916ec28b220e2f590', // post-250 arc spine checkpoint- 'pipeline-arc-verify.md': 'a397f158fd9c0dca1c8dbe62df253f70', // post-274 planning economy+ 'pipeline-arc-verify.md': '4b60a322e35b536405d0fbf543580562', // post-276 distinct climax'pipeline-arc-resolve.md': '638b988c84b3e5599f7a2ce09fa149ce', // post-274 planning economy'pipeline-volume-verify.md': '9c0839d7fe1760c0891464afd4a3b8fd', // post-274 planning economy};diff --git a/scripts/migrations/020-importer-screenplay-user-requested-count.js b/scripts/migrations/020-importer-screenplay-user-requested-count.jsindex b4dc5e618a..78c5977444 100644--- a/scripts/migrations/020-importer-screenplay-user-requested-count.js+++ b/scripts/migrations/020-importer-screenplay-user-requested-count.js@@ -25,7 +25,7 @@ const FILENAME = 'importer-issue-proposal.md';// Set by migration 016 (importer-fence-source).const OLD_SHIPPED_MD5 = '192f824a02885010d380aaacb4df67b5';// New screenplay-block hash after this migration runs.-const NEW_SHIPPED_MD5 = 'a6838832f8289932836db84ee565b870';+const NEW_SHIPPED_MD5 = '9ba2ff965fba61efb85a3568bb530055';const md5 = (text) => createHash('md5').update(text.replace(/\r\n/g, '\n').replace(/\r/g, '\n'))diff --git a/scripts/migrations/025-idea-stage-character-detail.js b/scripts/migrations/025-idea-stage-character-detail.jsindex ddf6bbba44..3e5c89f466 100644--- a/scripts/migrations/025-idea-stage-character-detail.js+++ b/scripts/migrations/025-idea-stage-character-detail.js@@ -35,7 +35,7 @@ export const ACCEPTED_OLD_MD5 = {// New shipped hash — what data.reference carries post-migration.export const NEW_SHIPPED_MD5 = {- 'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f', // post-127 (scene markers)+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e', // post-127 (scene markers)};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/054-source-agnostic-stage-prompts.js b/scripts/migrations/054-source-agnostic-stage-prompts.jsindex 03239ba7b0..4d839363b2 100644--- a/scripts/migrations/054-source-agnostic-stage-prompts.js+++ b/scripts/migrations/054-source-agnostic-stage-prompts.js@@ -33,7 +33,7 @@ export const ACCEPTED_OLD_MD5 = {// Post-change shipped hashes (the source-agnostic + tilde-fence templates this// migration installs). Mirror these into setup-data.js's drift table.export const NEW_SHIPPED_MD5 = {- 'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f', // post-127 (scene markers)+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e', // post-127 (scene markers)'pipeline-prose.md': '4cb3ef48309f3673570cf80e4d544b54', // post-169 (cross-issue continuity)'pipeline-comic-script.md': '49af30c05f008b20f6998a0f113f7d87', // post-127 (scene markers)'pipeline-teleplay.md': '2ea9974ac3803658b2314db1f5818b77', // post-128 (canonical scene list)diff --git a/scripts/migrations/098-idea-stage-ticking-clock.js b/scripts/migrations/098-idea-stage-ticking-clock.jsindex d8512ff781..83d2783277 100644--- a/scripts/migrations/098-idea-stage-ticking-clock.js+++ b/scripts/migrations/098-idea-stage-ticking-clock.js@@ -41,7 +41,7 @@ export const ACCEPTED_OLD_MD5 = {// migration edits this file, so the drift-catch test (NEW == live sample) stays// green. Latest: post-124 (scope-discipline + {{#paddingRisk}}).export const NEW_SHIPPED_MD5 = {- 'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f', // post-127 (scene markers)+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e', // post-127 (scene markers)};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/124-idea-stage-scope-discipline.js b/scripts/migrations/124-idea-stage-scope-discipline.jsindex d0df720b00..d265f26f7f 100644--- a/scripts/migrations/124-idea-stage-scope-discipline.js+++ b/scripts/migrations/124-idea-stage-scope-discipline.js@@ -37,7 +37,7 @@ export const ACCEPTED_OLD_MD5 = {// Mirror this into every earlier migration that tracks the same file// (003/004/025/054/098) so their drift-catch tests stay green.export const NEW_SHIPPED_MD5 = {- 'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f', // post-127 (scene markers)+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e', // post-127 (scene markers)};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/127-pipeline-scene-markers-prompts.js b/scripts/migrations/127-pipeline-scene-markers-prompts.jsindex 71f4a86616..70af23ed16 100644--- a/scripts/migrations/127-pipeline-scene-markers-prompts.js+++ b/scripts/migrations/127-pipeline-scene-markers-prompts.js@@ -29,7 +29,7 @@ export const ACCEPTED_OLD_MD5 = {};export const NEW_SHIPPED_MD5 = {- 'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f', // post-127 (scene markers)+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e', // post-127 (scene markers)'pipeline-prose.md': '4cb3ef48309f3673570cf80e4d544b54', // post-169 (cross-issue continuity)'pipeline-comic-script.md': '49af30c05f008b20f6998a0f113f7d87', // post-127 (scene markers)};diff --git a/scripts/migrations/172-structure-rules-season-episodes.js b/scripts/migrations/172-structure-rules-season-episodes.jsindex 95c4cafc32..393428ccdc 100644--- a/scripts/migrations/172-structure-rules-season-episodes.js+++ b/scripts/migrations/172-structure-rules-season-episodes.js@@ -31,7 +31,7 @@ export const ACCEPTED_OLD_MD5 = {// Post-change shipped hash (structure rules block added).export const NEW_SHIPPED_MD5 = {- 'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b',+ 'pipeline-season-episodes.md': '7c24df53c097c2525a52bfb766239647',};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/250-arc-spine-checkpoint-prompts.js b/scripts/migrations/250-arc-spine-checkpoint-prompts.jsindex 58f91819cd..510ab7bf52 100644--- a/scripts/migrations/250-arc-spine-checkpoint-prompts.js+++ b/scripts/migrations/250-arc-spine-checkpoint-prompts.js@@ -18,7 +18,7 @@ export const ACCEPTED_OLD_MD5 = {export const NEW_SHIPPED_MD5 = {'pipeline-arc-overview.md': '5ed760caaf3cf88916ec28b220e2f590',- 'pipeline-arc-verify.md': 'a397f158fd9c0dca1c8dbe62df253f70', // post-274 planning economy+ 'pipeline-arc-verify.md': '4b60a322e35b536405d0fbf543580562', // post-276 distinct climax};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/261-exhaustive-arc-verification.js b/scripts/migrations/261-exhaustive-arc-verification.jsindex 87306d0d64..e2a5f1ed14 100644--- a/scripts/migrations/261-exhaustive-arc-verification.js+++ b/scripts/migrations/261-exhaustive-arc-verification.js@@ -20,7 +20,7 @@ export const ACCEPTED_OLD_MD5 = {};export const NEW_SHIPPED_MD5 = {- 'pipeline-arc-verify.md': 'a397f158fd9c0dca1c8dbe62df253f70', // post-274 planning economy+ 'pipeline-arc-verify.md': '4b60a322e35b536405d0fbf543580562', // post-276 distinct climax};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/263-arc-verify-world-category-canon.js b/scripts/migrations/263-arc-verify-world-category-canon.jsindex af87238874..83c659d2e9 100644--- a/scripts/migrations/263-arc-verify-world-category-canon.js+++ b/scripts/migrations/263-arc-verify-world-category-canon.js@@ -26,7 +26,7 @@ export const ACCEPTED_OLD_MD5 = {};export const NEW_SHIPPED_MD5 = {- 'pipeline-arc-verify.md': 'a397f158fd9c0dca1c8dbe62df253f70',+ 'pipeline-arc-verify.md': '4b60a322e35b536405d0fbf543580562',};const { applyMigration, up } = makePromptReplaceMigration({diff --git a/scripts/migrations/275-pipeline-planning-economy.js b/scripts/migrations/275-pipeline-planning-economy.jsindex 99acd7994b..507d1ae625 100644--- a/scripts/migrations/275-pipeline-planning-economy.js+++ b/scripts/migrations/275-pipeline-planning-economy.js@@ -25,7 +25,7 @@ export const ACCEPTED_OLD_MD5 = {export const NEW_SHIPPED_MD5 = {'pipeline-arc-resolve.md': '638b988c84b3e5599f7a2ce09fa149ce',- 'pipeline-arc-verify.md': 'a397f158fd9c0dca1c8dbe62df253f70',+ 'pipeline-arc-verify.md': '4b60a322e35b536405d0fbf543580562','pipeline-volume-verify.md': '9c0839d7fe1760c0891464afd4a3b8fd',};diff --git a/scripts/migrations/276-distinct-climax-arc-role-prompts.js b/scripts/migrations/276-distinct-climax-arc-role-prompts.jsnew file mode 100644index 0000000000..035623459e--- /dev/null+++ b/scripts/migrations/276-distinct-climax-arc-role-prompts.js@@ -0,0 +1,33 @@+/**+ * Teach every arc-role planning prompt that climax and finale are distinct:+ * climax owns the decisive active choice; finale follows with consequences+ * and denouement. Hash replacement preserves customized installs.+ */++import { makePromptReplaceMigration } from './_lib.js';++export const ACCEPTED_OLD_MD5 = {+ 'pipeline-season-episodes.md': ['a88e8e78a949b7aaf500d03314e2ea0b'],+ 'pipeline-idea-expansion.md': ['d6fa86a435f978336661dcabca67258f'],+ 'pipeline-arc-verify.md': ['a397f158fd9c0dca1c8dbe62df253f70'],+ 'importer-issue-proposal.md': ['a6838832f8289932836db84ee565b870'],+};++export const NEW_SHIPPED_MD5 = {+ 'pipeline-season-episodes.md': '7c24df53c097c2525a52bfb766239647',+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e',+ 'pipeline-arc-verify.md': '4b60a322e35b536405d0fbf543580562',+ 'importer-issue-proposal.md': '9ba2ff965fba61efb85a3568bb530055',+};++const { applyMigration, up } = makePromptReplaceMigration({+ accepted: ACCEPTED_OLD_MD5,+ current: NEW_SHIPPED_MD5,+ label: 'distinct climax arc role prompts',+ customizedHint: (filename) =>+ ` To add the distinct climax role manually, diff data.reference/prompts/stages/${filename}\n` ++ ` against data/prompts/stages/${filename} and merge the climax/denouement guidance.`,+});++export { applyMigration };+export default { up };diff --git a/scripts/migrations/276-distinct-climax-arc-role-prompts.test.js b/scripts/migrations/276-distinct-climax-arc-role-prompts.test.jsnew file mode 100644index 0000000000..d027c78b59--- /dev/null+++ b/scripts/migrations/276-distinct-climax-arc-role-prompts.test.js@@ -0,0 +1,27 @@+import { readFileSync } from 'fs';+import { describe, expect, it } from 'vitest';++import { repoRoot, runPromptMigrationTests } from './_testHelpers.js';+import migration, {+ ACCEPTED_OLD_MD5,+ NEW_SHIPPED_MD5,+ applyMigration,+} from './276-distinct-climax-arc-role-prompts.js';++describe('migration 276 — distinct climax arc role prompts', () => {+ runPromptMigrationTests({+ migration,+ applyMigration,+ ACCEPTED_OLD_MD5,+ NEW_SHIPPED_MD5,+ prefix: 'migration-276-distinct-climax-',+ });++ it('keeps climax distinct from the later finale in every role prompt', () => {+ for (const filename of Object.keys(NEW_SHIPPED_MD5)) {+ const prompt = readFileSync(`${repoRoot}/data.reference/prompts/stages/${filename}`, 'utf8');+ expect(prompt).toContain('climax');+ expect(prompt).toContain('finale');+ }+ });+});diff --git a/scripts/setup-data-drift.test.js b/scripts/setup-data-drift.test.jsindex 42a9a34279..baef72ff80 100644--- a/scripts/setup-data-drift.test.js+++ b/scripts/setup-data-drift.test.js@@ -24,14 +24,15 @@ const migrationsDir = join(dirname(fileURLToPath(import.meta.url)), 'migrations'// sample-existence filter drops downstream — so its presence here documents// that the sweep itself is expected to carry it.const EXPECTED_STAGE_OLD = {- 'pipeline-idea-expansion.md': ['1ee44cf95851ff8debf18729ebcd40b4', '1f3c5d077a5ef9a4b610335d5e3edd9c', '41facefbc0c0549d456bef9111f95ab9', '49a208628290543ba2607a5ed48fdc8c', '93e9552c6662811e597a97296f3776a4', 'aee25112b2c596f643b17c559b772c22', 'b5c47c94ffc74637983c95761ab0c66c', 'c50f016639d41cd8244f5ff13429f997'],+ 'pipeline-idea-expansion.md': ['1ee44cf95851ff8debf18729ebcd40b4', '1f3c5d077a5ef9a4b610335d5e3edd9c', '41facefbc0c0549d456bef9111f95ab9', '49a208628290543ba2607a5ed48fdc8c', '93e9552c6662811e597a97296f3776a4', 'aee25112b2c596f643b17c559b772c22', 'b5c47c94ffc74637983c95761ab0c66c', 'c50f016639d41cd8244f5ff13429f997', 'd6fa86a435f978336661dcabca67258f'],'pipeline-prose.md': ['30ac30ec2b9d3e2a9eb869c181732cc6', '84523d531eeafa60959c65c553b2563f', 'bef1bc2767b78f585f2bd89f3d615130', 'bfea5aeeb471aae9749baee765b473a7', 'd1f8e3f1d214725b5aa67f309a81cd7d', '25e3d58c2741bd98acd5d08ba70d8a5e', '430d38ed2da59e0d4212e65edc499a74'],'writers-room-continue.md': ['93bfe80543ceca39842201a78b8393fa', '67663696c97ebaeb23de25f7410cfdd4'],'pipeline-comic-script.md': ['133d200d069c2e8173b7c129eea58f53', '1e0af305c27d0c80c4b482d2ebcb4a0d', '40e5fdc1a1e68a7419b7dad936366c1a', '7c05ecde539f04c9fa91e87543057204', 'a4303016c34b65e4b0e641fe71252de3', 'beab031951859ca13579cdb9c4dbe769', 'dea7d497d1cb38e7574f236f4ff8e644', 'e530fc76b89cedaef848ad7ec99c934c', 'e9ee70bf18888492edada6633cd9928a'],'pipeline-teleplay.md': ['1280ef6b1ad68fa44070ca7478ec2a5f', '2568e14beaa574d43f8018a5def51d04', '376f779f4687b598f1c92ca4e770fd5a', '3f6fecc25573ed054b47db392250034a', 'afa4215330bf856429d70d7e2f856605'],- 'pipeline-season-episodes.md': ['6e349ad26bed8a0ccb042571f03f03eb', 'c4928e2a5f833358116b29d2d669888d', '50c68a29c3ebc275db3095d06bd87100'],+ 'pipeline-season-episodes.md': ['6e349ad26bed8a0ccb042571f03f03eb', 'c4928e2a5f833358116b29d2d669888d', '50c68a29c3ebc275db3095d06bd87100', 'a88e8e78a949b7aaf500d03314e2ea0b'],'pipeline-arc-overview.md': ['6a3ecab43d1f46b7ef9aab6c69ea0326', 'd34d72b8e49ba303d38607845dd87f1c', '0a1f6ffa6908522e3690c5e9e53a6ee0', '612f8b04950e2ff26dd350dd76a062fe', '74d6c26548660d85fc345b2099c63b6c', '648e11352cd1565aee490de1f662bef0'],- 'pipeline-arc-verify.md': ['52e31abc93e3105176236fcaa5d1575a', 'ff56d8387162017e08d5d0491060ddd6', '36aa70cdfc25d7549573a4d556e7702c', '83347e7d923580a3062033ab39b3c14b', '68f6956d7e09ebdb3870d8726b1b2a7a', '9f32e91bd33b97d30e1cbb2e697f4fc3', '90712f66ec68061ebed2147044e5baee'],+ 'pipeline-arc-verify.md': ['52e31abc93e3105176236fcaa5d1575a', 'ff56d8387162017e08d5d0491060ddd6', '36aa70cdfc25d7549573a4d556e7702c', '83347e7d923580a3062033ab39b3c14b', '68f6956d7e09ebdb3870d8726b1b2a7a', '9f32e91bd33b97d30e1cbb2e697f4fc3', '90712f66ec68061ebed2147044e5baee', 'a397f158fd9c0dca1c8dbe62df253f70'],+ 'importer-issue-proposal.md': ['a6838832f8289932836db84ee565b870'],'pipeline-volume-verify.md': ['03f3c874cb80e1c98abcf03168fa7a92', 'c6ea28e972ad6e229bafb2d602b4dda3', '49458d36700cb94e34806d536ffe2940', '3e8a8f00d5faaee9d8e08a49d801b812'],'pipeline-arc-resolve.md': ['0611db539437083621e19bb88b005e8d', '0787128babf3c4c50e2f2cdb60214030', '5b340885c6e8f8afc63424d6b5bc7eb7', '87bc5c01f1a8a97b681727a38b05edc6', '8bb134554c122d1583c479ab3010e53d', '8e348f3d1894382889f9f0ee7d5c6792', '96f73a7e90526d65ef2bb100fb1cd4bf', 'a8677bbe1eb38f871fb152a5b0fec7c6', 'cc27b4da1d1a13c35e35d1c2d6183815', '31eca76b68f40de1b93734fe9bc9f4bb', '17fbb066d7957dc2e345df1795bb0d9d', 'ebd85d3a0b5949f16877c25ca498cce9', '2349bce80e9df8caafa391a6106327b6', 'aa2e463ebe0857859d79aa0c6ccb0256'],'pipeline-script-verify.md': ['ed6c8101644cfe56a100eb6bfe3587f3'],@@ -56,14 +57,15 @@ const EXPECTED_STAGE_OLD = {'pipeline-self-improve.md': ['ed0b0df42e0690d515b8dd88911931e4'],};const EXPECTED_STAGE_NEW = {- 'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f',+ 'pipeline-idea-expansion.md': 'a032e4a724251ed3e3495d33c4dbab8e','pipeline-prose.md': '4cb3ef48309f3673570cf80e4d544b54','writers-room-continue.md': '458dc5ff4732befc1fb90890bdc885c2','pipeline-comic-script.md': '49af30c05f008b20f6998a0f113f7d87','pipeline-teleplay.md': '2ea9974ac3803658b2314db1f5818b77',- 'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b',+ 'pipeline-season-episodes.md': '7c24df53c097c2525a52bfb766239647','pipeline-arc-overview.md': '5ed760caaf3cf88916ec28b220e2f590',- 'pipeline-arc-verify.md': 'a397f158fd9c0dca1c8dbe62df253f70',+ 'pipeline-arc-verify.md': '4b60a322e35b536405d0fbf543580562',+ 'importer-issue-proposal.md': '9ba2ff965fba61efb85a3568bb530055','pipeline-volume-verify.md': '9c0839d7fe1760c0891464afd4a3b8fd','pipeline-arc-resolve.md': '638b988c84b3e5599f7a2ce09fa149ce','pipeline-script-verify.md': '722c62462d05462603cf67ca0ed1dee8',diff --git a/server/lib/issueLength.js b/server/lib/issueLength.jsindex 72fdaa67ee..0472858481 100644--- a/server/lib/issueLength.js+++ b/server/lib/issueLength.js@@ -57,7 +57,7 @@ export const LENGTH_PROFILES = Object.freeze({}),finale: Object.freeze({label: 'Finale',- description: 'Season/series finale or annual — full-runtime climax with reveals and act-outs.',+ description: 'Season/series finale or annual — full-runtime closure with payoffs and act-outs.',pageTarget: 44,minutesTarget: 48,proseWordsMin: 6500,diff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.jsindex c10571a2bc..f2fb11a827 100644--- a/server/lib/schemaVersions.js+++ b/server/lib/schemaVersions.js@@ -78,7 +78,11 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({// makes the older peer reject the ahead-version issue transfer instead.// Per-category gate → only issue sync pauses with old peers; series/universes// keep flowing.- pipelineIssues: 2,+ // v3 = `issue.arcRole: "climax"` added (#4454). A <=v2 peer rejects the+ // ahead-version transfer; when its older snapshot is later received by a v3+ // peer, the merge preserves an existing climax role instead of letting the+ // older sanitizer's omission LWW-strip or overwrite it.+ pipelineIssues: 3,// v2 = `series.arc.readerMap` added (Unified Story Builder). Additive +// gracefully-degrading, but version-gated so a not-yet-upgraded peer can't// round-trip a series through its readerMap-unaware sanitizer and LWW-stripdiff --git a/server/lib/schemaVersions.test.js b/server/lib/schemaVersions.test.jsindex 4b12002178..e2b15d06af 100644--- a/server/lib/schemaVersions.test.js+++ b/server/lib/schemaVersions.test.js@@ -26,8 +26,8 @@ describe('PORTOS_SCHEMA_VERSIONS', () => {});it('declares pipeline collection layout versions', () => {- // pipelineIssues bumped to 2 when stages.audio.audioMode + cues[] were added.- expect(PORTOS_SCHEMA_VERSIONS.pipelineIssues).toBe(2);+ // pipelineIssues v3 adds the independently persisted climax arc role.+ expect(PORTOS_SCHEMA_VERSIONS.pipelineIssues).toBe(3);// pipelineSeries bumped to 12 when series.exportSettings was added (#2181)// (v2 = readerMap, v3 = tickingClock, v4 = styleGuide, v5 = coverImage,// v6 = characterArcs, v7 = factCritical + factReference,@@ -51,7 +51,7 @@ describe('buildPortosMeta', () => {const meta = await buildPortosMeta();expect(meta.portosVersion).toMatch(/^\d+\.\d+\.\d+/);expect(meta.schemaVersions.universes).toBe(9);- expect(meta.schemaVersions.pipelineIssues).toBe(2);+ expect(meta.schemaVersions.pipelineIssues).toBe(3);expect(meta.schemaVersions.pipelineSeries).toBe(12);});@@ -205,7 +205,7 @@ describe('scopeVersionDiff', () => {// Sender is ahead on mediaCollections only; a universe transfer scopes to// ['universes'] and stays compatible even though the union diff is not.const union = compareSchemaVersions(- { universes: 9, pipelineSeries: 2, pipelineIssues: 2, mediaCollections: 2 },+ { universes: 9, pipelineSeries: 2, pipelineIssues: 3, mediaCollections: 2 },PORTOS_SCHEMA_VERSIONS,);expect(union.compatible).toBe(false); // mediaCollections 2 > 1diff --git a/server/lib/storyArc.js b/server/lib/storyArc.jsindex 7bf9a011bc..990b7c4ed0 100644--- a/server/lib/storyArc.js+++ b/server/lib/storyArc.js@@ -107,7 +107,7 @@ export const FORESHADOW_LIMITS = Object.freeze({// Per-episode arc roles produced by the season-episodes generator and// persisted on the issue so downstream stages (idea-expansion in particular)// know whether they're writing a pilot vs. midpoint vs. finale episode.-export const ARC_ROLES = Object.freeze(['pilot', 'complication', 'midpoint', 'b-plot', 'all-is-lost', 'finale']);+export const ARC_ROLES = Object.freeze(['pilot', 'complication', 'midpoint', 'b-plot', 'all-is-lost', 'climax', 'finale']);// Kurt Vonnegut's eight story shapes. The client owns the sparkline rendering// but the points + descriptions live here too so prompt contexts have adiff --git a/server/routes/pipeline.test.js b/server/routes/pipeline.test.jsindex 5869800ad9..bb2bd29f48 100644--- a/server/routes/pipeline.test.js+++ b/server/routes/pipeline.test.js@@ -2093,6 +2093,21 @@ describe('pipeline routes', () => {expect(r.body.arcPosition).toBe(3);});+ it('exposes climax vocabulary and persists it through PATCH readback', async () => {+ const app = makeApp();+ const config = await request(app).get('/api/pipeline/config');+ expect(config.status).toBe(200);+ expect(config.body.arcRoles).toContain('climax');++ const ser = await request(app).post('/api/pipeline/series').send({ name: 'S', universeId: 'u-test' });+ const iss = await request(app).post(`/api/pipeline/series/${ser.body.id}/issues`).send({ title: 'Choice' });+ const patched = await request(app).patch(`/api/pipeline/issues/${iss.body.id}`).send({ arcRole: 'climax' });+ expect(patched.status).toBe(200);+ expect(patched.body.arcRole).toBe('climax');+ const readback = await request(app).get(`/api/pipeline/issues/${iss.body.id}`);+ expect(readback.body.arcRole).toBe('climax');+ });+it('PATCH /issues/:id preserves per-stage locked flags through validation', async () => {const app = makeApp();const ser = await request(app).post('/api/pipeline/series').send({ name: 'S', universeId: 'u-test' });diff --git a/server/routes/pipeline/issues.js b/server/routes/pipeline/issues.jsindex 5bf187a8ba..757b80d4aa 100644--- a/server/routes/pipeline/issues.js+++ b/server/routes/pipeline/issues.js@@ -379,6 +379,12 @@ const autoRunSchema = z.object({// Issue routes// =====================+// Server-owned issue vocabulary keeps client pickers aligned with persisted+// validation and importer/Creative Director contracts.+router.get('/config', (_req, res) => {+ res.json({ arcRoles: [...ARC_ROLES] });+});+// Recent issues across all series — used by the sidebar's dynamic Pipeline// child list. Routes through `listRecentIssues` which sorts the FULL issue// set by `updatedAt` desc before applying limit; `listIssues` woulddiff --git a/server/services/dataSync.js b/server/services/dataSync.jsindex 2ac7de3086..8c16c800b5 100644--- a/server/services/dataSync.js+++ b/server/services/dataSync.js@@ -474,13 +474,13 @@ async function getPipelineSnapshot({ exclude } = {}) {return { data, checksum: computeChecksum(data) };}-async function applyPipelineRemote(remoteData, source) {+async function applyPipelineRemote(remoteData, source, { senderSchemaVersions = null } = {}) {if (!remoteData) return { applied: false, count: 0 };// Routes through the service merge entry points so each incoming record// passes through the same sanitizer and LWW contract as local writes.const [seriesResult, issuesResult] = await Promise.all([mergeSeriesFromSync(remoteData.series || [], { source }),- mergeIssuesFromSync(remoteData.issues || [], { source }),+ mergeIssuesFromSync(remoteData.issues || [], { source, senderSchemaVersions }),]);const seriesChanged = seriesResult.count;diff --git a/server/services/pipeline/arcPlanner.test.js b/server/services/pipeline/arcPlanner.test.jsindex 11cd223501..211717a7a8 100644--- a/server/services/pipeline/arcPlanner.test.js+++ b/server/services/pipeline/arcPlanner.test.js@@ -421,7 +421,7 @@ describe('arcPlanner — generateSeasonEpisodes', () => {expect(out.episodes[0].logline).not.toMatch(/conseque$/);});- it('rejects the `custom` length sentinel and derives a finale-role fallback to `finale`', async () => {+ it('rejects the `custom` length sentinel and derives distinct climax/finale fallbacks', async () => {const { series, seasons } = await setupSeriesWithSeasons();stageRunnerSpy = vi.fn(async () => ({content: {@@ -429,6 +429,9 @@ describe('arcPlanner — generateSeasonEpisodes', () => {// LLM emitted `custom` without page/minute companions → reject sentinel,// fall back via arcRole. arcRole=finale → finale preset.{ number: 1, title: 'Finale', arcRole: 'finale', lengthProfile: 'custom' },+ // Climax independently defaults to extended rather than borrowing+ // the later finale's full-runtime profile.+ { number: 4, title: 'Climax', arcRole: 'climax', lengthProfile: 'custom' },// arcRole=midpoint and missing lengthProfile → default profile (standard).{ number: 2, title: 'Midpoint', arcRole: 'midpoint' },// Valid preset is kept as-is.@@ -440,6 +443,7 @@ describe('arcPlanner — generateSeasonEpisodes', () => {const out = await planner.generateSeasonEpisodes(series.id, seasons[0].id);const byTitle = Object.fromEntries(out.episodes.map((e) => [e.title, e]));expect(byTitle.Finale.lengthProfile).toBe('finale');+ expect(byTitle.Climax.lengthProfile).toBe('extended');expect(byTitle.Midpoint.lengthProfile).toBe('standard');expect(byTitle.Extra.lengthProfile).toBe('extended');});@@ -592,13 +596,14 @@ describe('arcPlanner — verifyArc', () => {// pilot and finale still reported "zero pilot/finale" on every pass — and// because the foundation gate's structure arm reverts whenever verifyArc// leaves any blocker, that permanent false positive stalled the gate.- it('renders each episode arcRole so the arc-role imbalance check can see it', async () => {+ it('renders climax and later finale roles with independent length profiles', async () => {const s = await setupSeries();await seriesSvc.updateSeries(s.id, { arc: { logline: 'L', summary: 'S' } });const sea = await seasonsSvc.createSeason(s.id, { title: 'V1' });await issuesSvc.createIssue({ seriesId: s.id, title: 'Ep 1', seasonId: sea.id, arcPosition: 1, arcRole: 'pilot' });await issuesSvc.createIssue({ seriesId: s.id, title: 'Ep 2', seasonId: sea.id, arcPosition: 2 });- await issuesSvc.createIssue({ seriesId: s.id, title: 'Ep 3', seasonId: sea.id, arcPosition: 3, arcRole: 'finale' });+ await issuesSvc.createIssue({ seriesId: s.id, title: 'Ep 3', seasonId: sea.id, arcPosition: 3, arcRole: 'climax', lengthProfile: 'extended' });+ await issuesSvc.createIssue({ seriesId: s.id, title: 'Ep 4', seasonId: sea.id, arcPosition: 4, arcRole: 'finale', lengthProfile: 'finale' });stageRunnerSpy = vi.fn(async () => ({ content: { issues: [] }, runId: 'r1', providerId: 'p', model: 'm' }));await planner.verifyArc(s.id);@@ -606,7 +611,8 @@ describe('arcPlanner — verifyArc', () => {const tree = JSON.parse(stageRunnerSpy.mock.calls[0][1].seasonsTreeJson);// null (not absent) for the middle episode — "no role" has to be legible as// a value, or the check can't tell an unset role from a dropped field.- expect(tree[0].episodes.map((e) => e.arcRole)).toEqual(['pilot', null, 'finale']);+ expect(tree[0].episodes.map((e) => e.arcRole)).toEqual(['pilot', null, 'climax', 'finale']);+ expect(tree[0].episodes.map((e) => e.lengthProfile)).toEqual(['standard', 'standard', 'extended', 'finale']);});it('drops malformed verify issues + defaults severity to medium', async () => {diff --git a/server/services/pipeline/arcPlanner/context.js b/server/services/pipeline/arcPlanner/context.jsindex d40e8e8143..1c0152c893 100644--- a/server/services/pipeline/arcPlanner/context.js+++ b/server/services/pipeline/arcPlanner/context.js@@ -33,11 +33,14 @@ export const ARC_ROLES = new Set(ARC_ROLE_LIST);// at prompt time. Limit to the canonical preset names.export const SEASON_LENGTH_PRESETS = new Set(LENGTH_PROFILE_NAMES.filter((n) => n !== 'custom'));-// Finale-role episodes should size like a finale even when the LLM omits-// (or misspells) lengthProfile. Other arcRoles fall back to the default-// profile so a missing/misspelled length doesn't cascade into the wrong-// size for the whole arc.-export const lengthProfileForArcRole = (arcRole) => (arcRole === 'finale' ? 'finale' : DEFAULT_LENGTH_PROFILE);+// Structural climax and denouement/finale are independent beats with+// independent runtime defaults. Preserve that distinction even when the LLM+// omits (or misspells) lengthProfile.+export const lengthProfileForArcRole = (arcRole) => {+ if (arcRole === 'climax') return 'extended';+ if (arcRole === 'finale') return 'finale';+ return DEFAULT_LENGTH_PROFILE;+};// Each prior season renders as its header (logline + synopsis) plus the// committed per-episode beats from `stages.idea.input` — that field was@@ -523,14 +526,15 @@ export function groupIssuesBySeasonTree(seasons, issues, { renderLeaf, seasonFie// `synopsis` (not `beats`) matches the prompt's existing language; it is sourced// from idea.input, which carries the LLM's logline+synopsis.export const renderVerifyIssueLeaf = (iss) => {- const targets = computeIssueTargets(iss);+ const lengthProfile = iss.lengthProfile || lengthProfileForArcRole(iss.arcRole);+ const targets = computeIssueTargets({ ...iss, lengthProfile });return {number: iss.number,title: iss.title,status: iss.status,arcPosition: iss.arcPosition,arcRole: iss.arcRole || null,- lengthProfile: iss.lengthProfile || null,+ lengthProfile,pageTarget: targets.pageTarget,minutesTarget: targets.minutesTarget,synopsis: (iss.stages?.idea?.input || '').trim() || null,diff --git a/server/services/pipeline/arcPlanner/verifyPromptContract.test.js b/server/services/pipeline/arcPlanner/verifyPromptContract.test.jsindex adf265e397..cc2c959cee 100644--- a/server/services/pipeline/arcPlanner/verifyPromptContract.test.js+++ b/server/services/pipeline/arcPlanner/verifyPromptContract.test.js@@ -34,7 +34,7 @@ const NON_FIELD_TOKENS = new Set([// Output-contract vocabulary.'issues', 'severity', 'high', 'medium', 'low',// `arcRole` VALUES, not field names.- 'pilot', 'finale', 'complication', 'midpoint', 'b-plot', 'all-is-lost',+ 'pilot', 'climax', 'finale', 'complication', 'midpoint', 'b-plot', 'all-is-lost', 'extended',]);const renderableFields = () => new Set([diff --git a/server/services/pipeline/issueSync.js b/server/services/pipeline/issueSync.jsindex 64bf98c208..8744d550b0 100644--- a/server/services/pipeline/issueSync.js+++ b/server/services/pipeline/issueSync.js@@ -24,8 +24,13 @@ import { store, readState, saveIssuesNow, renumberInline, sanitizeIssue } from '* valid id format). LWW by `updatedAt`; returns `{ applied, count }` where* `count` is the number of issues actually changed/added.*/-export async function mergeIssuesFromSync(remoteIssues, { source = { via: 'sync', peerId: null } } = {}) {+export async function mergeIssuesFromSync(remoteIssues, {+ source = { via: 'sync', peerId: null },+ senderSchemaVersions = null,+} = {}) {if (!Array.isArray(remoteIssues)) return { applied: false, count: 0 };+ const senderCannotRepresentClimax = senderSchemaVersions !== null+ && (Number(senderSchemaVersions?.pipelineIssues) || 0) < 3;// Series IDs whose issue set saw at least one delete-transition — drives a// post-write renumber so the receiver's issue numbering catches up with the// sender's (otherwise a synced tombstone would leave a gap).@@ -62,7 +67,7 @@ export async function mergeIssuesFromSync(remoteIssues, { source = { via: 'sync'// sanitized.seriesId may be either the existing local series or a// remote-only target; reject either way.if (ephemeralSeriesIds.has(remote.seriesId)) continue;- const sanitized = sanitizeIssue(remote);+ let sanitized = sanitizeIssue(remote);if (!sanitized) continue;// Strip inbound `ephemeral` — see mergeUniversesFromSync.if ('ephemeral' in sanitized) delete sanitized.ephemeral;@@ -94,6 +99,12 @@ export async function mergeIssuesFromSync(remoteIssues, { source = { via: 'sync'const localTs = local.updatedAt || '';const remoteTs = sanitized.updatedAt || '';if (remoteTs > localTs) {+ // An older sender cannot represent `climax`: its sanitizer either+ // omitted the role or coerced it to another legacy value. Accept its+ // newer fields while preserving the local v3-only role.+ if (senderCannotRepresentClimax && local.arcRole === 'climax' && sanitized.arcRole !== 'climax') {+ sanitized = { ...sanitized, arcRole: 'climax' };+ }// Non-blocking conflict journal — archive the losing local issue on// a true 3-way divergence; always advances the base hash. Never// throws into the merge (convergence wins).diff --git a/server/services/pipeline/issues.test.js b/server/services/pipeline/issues.test.jsindex b7c2335e73..2faf3fb6b1 100644--- a/server/services/pipeline/issues.test.js+++ b/server/services/pipeline/issues.test.js@@ -971,6 +971,41 @@ describe('pipeline issues service', () => {expect(live).toMatchObject({ title: 'Edited After Delete', deleted: false });});+ it.each([+ ['strips the unknown role', undefined],+ ['overwrites it with a legacy role', 'finale'],+ ])('preserves a local climax role when a pre-v3 sender %s', async (_case, remoteArcRole) => {+ const local = await svc.createIssue({ seriesId: 'ser-1', title: 'Decisive Choice' });+ const withClimax = await svc.updateIssue(local.id, { arcRole: 'climax' });+ const updatedAt = new Date(Date.now() + 60_000).toISOString();++ await svc.mergeIssuesFromSync([{+ ...withClimax,+ title: 'Older Peer Edit',+ arcRole: remoteArcRole,+ updatedAt,+ }], { senderSchemaVersions: { pipelineIssues: 2 } });++ expect(await svc.getIssue(local.id)).toMatchObject({+ title: 'Older Peer Edit',+ arcRole: 'climax',+ });+ });++ it('allows a v3 sender to intentionally replace climax', async () => {+ const local = await svc.createIssue({ seriesId: 'ser-1', title: 'Decisive Choice' });+ const withClimax = await svc.updateIssue(local.id, { arcRole: 'climax' });+ const updatedAt = new Date(Date.now() + 60_000).toISOString();++ await svc.mergeIssuesFromSync([{+ ...withClimax,+ arcRole: 'finale',+ updatedAt,+ }], { senderSchemaVersions: { pipelineIssues: 3 } });++ expect((await svc.getIssue(local.id)).arcRole).toBe('finale');+ });+it('synced RESURRECTION compacts collisions — issue restored mid-series gets a unique number', async () => {// Regression: local delete already compacts numbering (A=1, C=2 after// deleting B). When B's tombstone is overridden by a later remote editdiff --git a/server/services/sharing/importer.js b/server/services/sharing/importer.jsindex b7fde87168..1fec30a74d 100644--- a/server/services/sharing/importer.js+++ b/server/services/sharing/importer.js@@ -494,6 +494,7 @@ function relevantSchemaCategoriesForManifest(manifest) {async function applyAutoMerge(bucket, manifest, records, { availableAssetKeys = null } = {}) {let applied = 0;const overridden = [];+ const senderCannotRepresentClimax = (Number(manifest?.portosSchemaVersions?.pipelineIssues) || 0) < 3;// Records whose insert threw an UNEXPECTED (non-duplicate) error — they did// NOT land. Surfaced as a pending condition (like legacyCanonPendingFailures)// so processManifest leaves the cursor un-advanced and the watcher retries,@@ -557,6 +558,10 @@ async function applyAutoMerge(bucket, manifest, records, { availableAssetKeys =if (kind === 'series' && !record.universeId && existing.universeId) {record = { ...record, universeId: existing.universeId };}+ if (kind === 'issue' && senderCannotRepresentClimax+ && existing.arcRole === 'climax' && record.arcRole !== 'climax') {+ record = { ...record, arcRole: 'climax' };+ }// Non-blocking conflict journal for every synced record kind — a// share-bucket import that LWW-overwrites a locally-diverged record// archives the losing local version first. Issues are included nowdiff --git a/server/services/sharing/peerSync.test.js b/server/services/sharing/peerSync.test.jsindex 84db8b9d5a..4da4851f86 100644--- a/server/services/sharing/peerSync.test.js+++ b/server/services/sharing/peerSync.test.js@@ -3125,7 +3125,7 @@ describe('peerSync', () => {);expect(mergeIssuesFromSync).toHaveBeenCalledWith([expect.objectContaining({ id: 'i1' })],- { source: { via: 'peer-push', peerId: 'peer-a' } },+ { source: { via: 'peer-push', peerId: 'peer-a' }, senderSchemaVersions: {} },);});@@ -3687,7 +3687,7 @@ describe('peerSync', () => {record: { id: 's1', name: 'Foo' },assetManifest: [],sourceInstanceId: 'peer-a',- portosMeta: { portosVersion: '99.0.0', schemaVersions: { universes: 5, pipelineSeries: 1, pipelineIssues: 3 } },+ portosMeta: { portosVersion: '99.0.0', schemaVersions: { universes: 5, pipelineSeries: 1, pipelineIssues: 4 } },});expect(mergeSeriesFromSync).toHaveBeenCalled();expect(mergeIssuesFromSync).not.toHaveBeenCalled();@@ -3702,10 +3702,10 @@ describe('peerSync', () => {issues: [{ id: 'i1', seriesId: 's1', deleted: false, deletedAt: null }],assetManifest: [],sourceInstanceId: 'peer-a',- portosMeta: { portosVersion: '99.0.0', schemaVersions: { universes: 5, pipelineSeries: 1, pipelineIssues: 3 } },+ portosMeta: { portosVersion: '99.0.0', schemaVersions: { universes: 5, pipelineSeries: 1, pipelineIssues: 4 } },}).catch((err) => err);expect(rejection.code).toBe('PEER_SYNC_SCHEMA_VERSION_AHEAD');- expect(rejection.details.ahead).toEqual([{ category: 'pipelineIssues', senderV: 3, receiverV: 2 }]);+ expect(rejection.details.ahead).toEqual([{ category: 'pipelineIssues', senderV: 4, receiverV: 3 }]);expect(mergeSeriesFromSync).not.toHaveBeenCalled();expect(mergeIssuesFromSync).not.toHaveBeenCalled();});@@ -3756,10 +3756,10 @@ describe('peerSync', () => {issues: [{ id: 'i1', seriesId: 's1', deleted: false, deletedAt: null }],assetManifest: [],sourceInstanceId: 'peer-a',- portosMeta: { portosVersion: '99.0.0', schemaVersions: { universes: 5, pipelineSeries: 1, pipelineIssues: 3 } },+ portosMeta: { portosVersion: '99.0.0', schemaVersions: { universes: 5, pipelineSeries: 1, pipelineIssues: 4 } },}).catch((err) => err);expect(rejection.code).toBe('PEER_SYNC_SCHEMA_VERSION_AHEAD');- expect(rejection.details.ahead).toEqual([{ category: 'pipelineIssues', senderV: 3, receiverV: 2 }]);+ expect(rejection.details.ahead).toEqual([{ category: 'pipelineIssues', senderV: 4, receiverV: 3 }]);expect(mergeSeriesFromSync).not.toHaveBeenCalled();expect(mergeIssuesFromSync).not.toHaveBeenCalled();});@@ -3779,7 +3779,10 @@ describe('peerSync', () => {expect(mergeSeriesFromSync).toHaveBeenCalled();expect(mergeIssuesFromSync).toHaveBeenCalledWith([expect.objectContaining({ id: 'i1', deleted: true })],- { source: { via: 'peer-push', peerId: 'peer-a' } },+ {+ source: { via: 'peer-push', peerId: 'peer-a' },+ senderSchemaVersions: { universes: 5, pipelineSeries: 9, pipelineIssues: 9 },+ },);});});diff --git a/server/services/sharing/peerSyncReceive.js b/server/services/sharing/peerSyncReceive.jsindex 5d2019f669..6c52b55247 100644--- a/server/services/sharing/peerSyncReceive.js+++ b/server/services/sharing/peerSyncReceive.js@@ -293,7 +293,7 @@ export async function applyIncomingPush(payload) {// the parent is marked ephemeral, so without this gate a stale reverse// subscription could overwrite the private fork's issue stages.if (!localEphemeral && Array.isArray(issues) && issues.length > 0) {- await mergeIssuesFromSync(issues, { source });+ await mergeIssuesFromSync(issues, { source, senderSchemaVersions });}// Merge the bundled manuscript-review sibling doc, LWW-per-comment. Same// guards as the issue batch + linkedCollection below: skip for local-@@ -701,4 +701,4 @@ async function classifyLocalRecord(recordKind, recordId) {return c ? 'syncable' : 'missing';}return 'missing';-}\ No newline at end of file+}