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
Merge remote-tracking branch 'origin/main' into next/issue-2171
Adam Eivycf43ca15f69f
diff --cc .changelog/NEXT.mdindex 7e03410fa5,422220312d..a5528aad8b--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@@ -47,7 -48,7 +48,8 @@@## Creative Writing Quality Engine+- **[issue-2171] Series Autopilot can now iterate a series to quality — an opt-in revision loop that revises the weakest issue under a keep/revert score gate and stops on plateau, hedged-convergence, or a cycle cap.** Autopilot used to cap editorial convergence at 2 rounds and then *pause* for a human, with craft findings advisory-only. A new opt-in `revisionCycle` step (off by default; enable + tune min/max cycles and the plateau delta in the Autopilot options drawer, persisted like the other gate settings) sits between the editorial-health gate and canon/visuals and cycles the manuscript toward publishable quality unattended. Each cycle: **(1)** judges every drafted issue (composing the Phase 3 judge #2167, cache-aware so only stale content bills), **(2)** picks the weakest issue — the Phase 5 Elo ranking (#2169) when a fresh one exists, else the lowest composite `qualityScore` — **(3)** runs the Phase 4 adversarial-cut pass (#2168) and auto-applies the safe cut types (OVER-EXPLAIN + REDUNDANT) through the snapshotted stage-write path, **(4)** builds a structured revision brief (PROBLEM / **WHAT TO KEEP** — the strongest sentences, so a rewrite can't gut the good material / WHAT TO CHANGE / VOICE RULES / TARGET) from the judge output + cut list, then **(5)** re-judges and applies a **keep/revert gate** — a revision is kept only when `qualityScore` did not regress, else the pre-revision text is restored through the serialized write path (never a force over a concurrent human edit). The loop stops on **plateau** (mean series score moves less than a configurable delta after a minimum cycle count), **maxCycles** (a cost ceiling, default 1–3), or **qualification-aware convergence** — remaining findings classified as hedged trade-offs ("individually fine", "deliberate choice", "costs of ambition") rather than actionable defects; majority-hedged ⇒ converged. Every judge/cut/re-judge call is budget-gated and billed against the cos daily action cap exactly like the existing steps, budget exhaustion pauses the run, and resume is a pure function of state (cycle counters live in run state, no stored cursor). Every keep/revert decision is logged as a single-line experiment-ledger entry. Pure brief-assembly and stop-condition/keep-revert logic are unit-tested. Gated on the already-consented Series Autopilot — never fires at boot (AI-provider policy). (`server/services/pipeline/seriesAutopilot.js`, `server/services/pipeline/editorial/revisionBrief.js`, `server/services/pipeline/editorial/revisionStop.js`, `server/lib/pipelineValidation.js`, `server/routes/pipeline/autopilot.js`, `client/src/components/pipeline/AutopilotPanel.jsx`)+ - **[issue-2180] Series invention now generates several distinct concepts under an anti-generic banlist, then user-picks (interactive) or judge-picks (autonomous) the winner — concept diversity at the seed is the cheapest quality lever in the pipeline.** Autonomous series invention used to produce ONE concept with no anti-generic pressure; autonovel's seed stage generates many concepts under an explicit banlist ("no chosen-one prophecies, no dark lords, no medieval-Europe-with-elves, no magic academies, no love triangles"), then selects. The `pipeline-series-generate` stage now invents **N genuinely distinct candidate concepts** (default 5, clamped 2–8), each carrying craft facets — HOOK / WORLD / CONFLICT ENGINE + COST / TENSION (personal AND larger-scale) / THEME (genre-neutral, not every series has magic) — under an **anti-generic banlist** that merges a shipped default list with the universe's own `influences.avoid` (case-insensitive dedupe, so an author's "steer clear of X" gets a hard veto at the seed). **Interactive mode** (the "Generate with AI" button on the New Series form) now presents the candidates for **user pick** — a deep-linkable card selection (`?concept=` is the URL source of truth) that pre-fills the form; the rejected candidates stay in memory (and in run history) so the user can switch without regenerating. **Autonomous mode** (CoS-driven invention) **judge-picks** the winner via a new one-call forced-rank stage `pipeline-series-concept-judge` ("which concept would a reader who has seen a thousand pitches stop scrolling for?" — ties forbidden), reusing the writer/judge split (#2167) resolved from the generation stage's `judgeProvider`/`judgeModel`; it **falls back to the first candidate** when no judge is configured or the call fails, so invention never blocks. Seed-faithful expansion is untouched — when the user typed their own idea it's still expanded, never replaced with a "better" concept. Runs ONLY from an explicit user action or the already-consented autonomous path — never at boot (AI-provider policy). Candidate normalization, banlist merge, forced-rank parsing, and judge-pick fallback are unit-tested; the modified prompt ships a hash-keyed migration (customized prompts preserved + warned) and the new judge stage a seed migration. (`server/services/pipeline/seriesGenerate.js`, `data.reference/prompts/stages/pipeline-series-generate.md`, `data.reference/prompts/stages/pipeline-series-concept-judge.md`, `server/routes/pipeline/series.js`, `server/services/creative/tools/pipeline.js`, `scripts/migrations/179-series-multi-concept-ideation.js`, `scripts/migrations/180-series-concept-judge-stage.js`, `client/src/pages/Pipeline.jsx`, `client/src/services/apiPipeline.js`)- **[issue-2169] Two comparative-quality mechanisms build on the calibrated judge — a multi-candidate draft gate, and head-to-head Elo ranking of a series' issues.** Both compose the Phase 3 judge (#2167) to escape autonovel's "rubric trap" (absolute 1-10 scores collapse into a 2-point band; comparison forces the discrimination the judge can't avoid). **(1) Multi-candidate draft gate** — a new opt-in per-stage config (`draftAttempts` 1–3, default **1 = off**; optional `draftGateThreshold`, schema parity added to `stageConfigUpdateSchema`) makes `generateStage` generate → judge → re-roll a FRESH draft while the composite `qualityScore` is below the threshold, up to the attempt cap, and keep the best-scoring attempt. Every attempt persists (rejected drafts stay recoverable in run history) and a per-attempt scorecard lands on `stage.draftGate` (`{ winner, threshold, attempts:[{ runId, qualityScore, rejected }] }`) — never silently discarded. Only the judgeable stages (prose/comicScript/teleplay) gate; the single-shot path is byte-for-byte unchanged when off. When run from Series Autopilot each re-roll bills one cos action and stops re-rolling when the daily budget is spent (keeping the best so far); a manual regenerate is never cos-billed. Canon extraction runs once, on the winning draft. **(2) Head-to-head Elo ranking** — a new `comparativeRank.js` + forced-pick `pipeline-judge-compare.md` stage prompt ("you are not allowed to call it a tie" — quote the deciding passage) runs a Swiss-style tournament (~4 rounds, K=32 Elo) across the series' drafted issues, each side truncated to a comparable budget via `contextBudget.js`. The ranking + per-match records persist at `data/pipeline-comparative-rank/{seriesId}.json`, content-hash-pinned for staleness (reuses `computeSourceContentHash`), with the weakest-N slice as the revision-priority order Phase 7 consumes. A tie/hedge/garbage pick from the judge falls through to a deterministic, balanced tiebreak. Surfaced as a new **Rankings** tab on the Reader Map page (`?tab=rank`) — an Elo table with the weakest issues flagged as revision priorities. Runs ONLY from the explicit "Rank issues" action or an autopilot step — never at boot (AI-provider policy). Pure Elo math + Swiss pairing + tie-refusal parsing + staleness are unit-tested. (`server/services/pipeline/editorial/comparativeRank.js`, `server/services/pipeline/textStages.js`, `server/services/pipeline/issues.js`, `server/services/pipeline/seriesAutopilot.js`, `server/lib/pipelineValidation.js`, `server/routes/pipeline/editorial.js`, `data.reference/prompts/stages/pipeline-judge-compare.md`, `client/src/components/pipeline/ComparativeRankView.jsx`, `client/src/pages/PipelineSeriesRoadmap.jsx`, `client/src/services/apiPipeline.js`)