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
fix([story-builder-issue-llm-seeding]): distinguish ineligible-skip from transient failure in arc issue-gen
[._.]/ Adam Eivy4ef106d67df3
diff --git a/client/src/pages/StoryBuilder.jsx b/client/src/pages/StoryBuilder.jsxindex 833a4ebda3..e09acf3b49 100644--- a/client/src/pages/StoryBuilder.jsx+++ b/client/src/pages/StoryBuilder.jsx@@ -691,14 +691,25 @@ function IssuesPanel({ session, series, issues, onChanged }) {setGenerating(false);if (!res) return;const created = res.createdIssues?.length || 0;- const skipped = (res.seasons || []).filter((s) => s.skipped);- const skipReason = skipped.length ? skipped[0].reason : null;+ const seasons = res.seasons || [];+ // Skipped = genuinely ineligible (locked / no synopsis); failed = a+ // transient provider/LLM error. Surface them separately so an infra+ // failure never reads as a config skip. Distinct reasons are deduped so a+ // multi-season batch shows every cause, not just the first.+ const skipped = seasons.filter((s) => s.skipped);+ const failed = seasons.filter((s) => s.failed);+ const reasons = (list) => [...new Set(list.map((s) => s.reason).filter(Boolean))].join('; ');+ const noun = (n) => (n === 1 ? 'season' : 'seasons');if (created > 0) {toast.success(`Created ${created} issue${created === 1 ? '' : 's'} from the arc`);- // Surface partial-batch skips so a locked/empty season doesn't fail silently.- if (skipReason) toast.error(`Skipped ${skipped.length} season${skipped.length === 1 ? '' : 's'}: ${skipReason}`);+ if (skipped.length) toast.error(`Skipped ${skipped.length} ${noun(skipped.length)}: ${reasons(skipped)}`);+ if (failed.length) toast.error(`Couldn't generate ${failed.length} ${noun(failed.length)}: ${reasons(failed)}`);+ } else if (failed.length) {+ toast.error(`Couldn't generate issues — ${reasons(failed) || 'a provider error occurred'}`);+ } else if (skipped.length) {+ toast.error(`No issues created — ${reasons(skipped)}`);} else {- toast.error(skipReason ? `No issues created — ${skipReason}` : 'No issues were generated');+ toast.error('No issues were generated');}onChanged();};diff --git a/server/services/storyBuilder.js b/server/services/storyBuilder.jsindex 7dfc2a14e7..cd76d9a615 100644--- a/server/services/storyBuilder.js+++ b/server/services/storyBuilder.js@@ -39,6 +39,7 @@ import {import {generateArcOverview, generateArcFromSource, generateReaderMap, refineReaderMap, commitSeasonsWithRemap,collectIssueSourceText, generateSeasonEpisodes, commitEpisodesToIssues,+ ERR_VALIDATION as ARC_ERR_VALIDATION,} from './pipeline/arcPlanner.js';const TYPE_SCHEMA_VERSION = 1;@@ -433,9 +434,13 @@ export async function setIssueLock(id, issueId, locked) {* else the session's saved picker choice (session.llm).** Batch semantics: generateSeasonEpisodes throws on a locked season or one- * with no synopsis/logline. In a multi-season run one ineligible season must- * not abort the rest, so each season is caught independently and reported as- * `skipped` with its reason — the eligible seasons still produce issues.+ * with no synopsis/logline. In a multi-season run one bad season must not+ * abort the rest, so each season is caught independently — the eligible+ * seasons still produce issues. A caught season reports `skipped: true` when+ * it was genuinely ineligible (ARC_ERR_VALIDATION) and `failed: true` for any+ * other (transient provider/LLM) error, so the client never frames an infra+ * failure as a config skip. Successful seasons carry `skipped: false,+ * failed: false`.** `options.seasonId` scopes generation to a single season; omit to cover every* season on the arc.@@ -474,14 +479,26 @@ export async function generateIssuesFromArc(id, options = {}) {const res = await generateSeasonEpisodes(session.seriesId, season.id, {providerOverride: reqProviderId,modelOverride: reqModel,- }).catch((err) => ({ error: err?.message || 'Failed to generate episodes' }));+ }).catch((err) => ({ error: err }));if (res.error) {- seasonResults.push({ seasonId: season.id, title: label, created: 0, skipped: true, reason: res.error });+ // generateSeasonEpisodes throws ARC_ERR_VALIDATION for genuinely+ // ineligible seasons (locked, or no synopsis/logline) — those are+ // `skipped` (expected config state). Any OTHER throw is a transient+ // failure (provider down, timeout, non-JSON) and is reported as+ // `failed` so the client never frames an infra error as "ineligible".+ // We still don't abort the batch — a blip on one season must not+ // discard issues already created for the others.+ const ineligible = res.error?.code === ARC_ERR_VALIDATION;+ const reason = res.error?.message || 'Failed to generate episodes';+ seasonResults.push({+ seasonId: season.id, title: label, created: 0,+ skipped: ineligible, failed: !ineligible, reason,+ });continue;}const issues = await commitEpisodesToIssues(session.seriesId, season.id, res.episodes);createdIssues.push(...issues);- seasonResults.push({ seasonId: season.id, title: label, created: issues.length, skipped: false, runId: res.runId });+ seasonResults.push({ seasonId: season.id, title: label, created: issues.length, skipped: false, failed: false, runId: res.runId });}return { createdIssues, seasons: seasonResults };diff --git a/server/services/storyBuilder.test.js b/server/services/storyBuilder.test.jsindex c81dfaf083..e04bafa5e9 100644--- a/server/services/storyBuilder.test.js+++ b/server/services/storyBuilder.test.js@@ -389,9 +389,32 @@ describe('generateIssuesFromArc (issues step)', () => {expect(res.createdIssues).toHaveLength(1);const locked = res.seasons.find((r) => r.seasonId === seasons[0].id);const open = res.seasons.find((r) => r.seasonId === seasons[1].id);- expect(locked).toMatchObject({ skipped: true, created: 0 });+ // A locked season is an ineligible-config skip, not a failure.+ expect(locked).toMatchObject({ skipped: true, failed: false, created: 0 });expect(locked.reason).toMatch(/locked/i);- expect(open).toMatchObject({ skipped: false, created: 1 });+ expect(open).toMatchObject({ skipped: false, failed: false, created: 1 });+ });++ it('reports a transient provider/LLM error as failed (not skipped)', async () => {+ const s = await sb.createStorySession({ title: 'Flaky' });+ const seasons = await seedSeasons(s.seriesId, [+ { number: 1, title: 'Vol 1', synopsis: 'open' },+ { number: 2, title: 'Vol 2', synopsis: 'rises' },+ ]);+ // Vol 1's episodes pass throws a plain (non-validation) error — provider+ // down / timeout. Vol 2 succeeds. The batch must not abort, and Vol 1 must+ // be `failed`, not `skipped`.+ stageRunnerSpy = vi.fn(async (stage, vars) => {+ if (vars?.season?.title === 'Vol 1') throw new Error('provider unavailable');+ return { content: { episodes: [{ number: 1, title: 'V2 E1', arcRole: 'pilot' }] }, runId: 'r', providerId: 'p', model: 'm' };+ });+ const res = await sb.generateIssuesFromArc(s.id);+ expect(res.createdIssues).toHaveLength(1);+ const bad = res.seasons.find((r) => r.seasonId === seasons[0].id);+ const good = res.seasons.find((r) => r.seasonId === seasons[1].id);+ expect(bad).toMatchObject({ skipped: false, failed: true, created: 0 });+ expect(bad.reason).toMatch(/provider unavailable/);+ expect(good).toMatchObject({ skipped: false, failed: false, created: 1 });});it('scopes to a single season when seasonId is given', async () => {