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
Plan — #1284 Editorial check registry + runner (backbone)
Context
PortOS's series pipeline has editorial logic scattered across manuscriptReview.js,
completenessPass.js, editorialAnalysis.js, and canonReadiness.js with no shared
way to register a new "check," declare its scope, run it, and collect findings. Every
new editorial rule the roadmap wants (name similarity, scene balance, POV-without-arc,
info-dumping, …) currently has no home.
#1284 is the backbone of epic #1283: a single extensible check registry + runner
(mirroring apiRegistry.js / navManifest.js / widgetRegistry.jsx) that lets each
editorial rule — deterministic or LLM-driven — plug in, declare scope, emit findings into
the existing manuscriptReview store, be toggled/configured, and run inside
seriesAutopilot. The dedicated management UI is a separate issue (#1285) — this PR
makes findings land in the existing manuscript-review store/UI; it ships no new React
page. Two reference checks (1 deterministic, 1 LLM) prove both paths.
Scope decisions (defaults — adjust at approval)
- Backbone only, no new UI page. Findings surface in the existing manuscript-review UI via the store. The Editorial Checks catalog/config/triage page is #1285.
- Two reference checks:
naming.dissimilar-names— deterministic, scopeseries, categorynaming. Flags character-name pairs that are too similar (shared first letter / same length / similar vowel skeleton) from canon characters. Configurable thresholds.prose.info-dumping— LLM, scopeissue, categoryexposition. Flags "as-you-know-Bob" exposition dumps in drafted prose via a new prompt stage.
checkIdon findings. Add an optionalcheckIdfield to the manuscript-review comment shape and fold it into the dedup key so findings group per-check and dismissals stay suppressed per-check. Additive + optional ⇒ backward-compatible with syncedmanuscript-review.jsonand with existing completeness findings (absent →'').
Key reuse (verified)
- Findings store:
server/services/pipeline/manuscriptReview.js—seedReviewFromFindings(seriesId, findings, { runId, mode })(serialized per-series write queue +findingKeydedup + dismiss-suppression),getReview(seriesId),sanitizeComment(the shape),findingKey(${issueNumber??''}|${anchorQuote}|${problem}). - Registry + fail-fast guard pattern:
server/lib/navManifest.js(module-load loop that throws on missing fields / bad enum / dup id) andserver/lib/apiRegistry.js(static array- resolver merging persisted state).
- LLM call:
runStagedLLM(stageName, vars, { providerOverride, modelOverride, returnsJson, source })fromserver/lib/stageRunner.js(same pathcompletenessPass.jsuses). Provider/model resolved viagetActiveProvider()+resolveModel(); supports local + API providers. - Manuscript assembly + ctx:
collectManuscriptSections(seriesId)+sectionsCorpus(sections)buildArcBaseContext/getSeriesCanonfromserver/services/pipeline/arcPlanner/context.js&completenessPass.js. Canon characters viagetSeriesCanon(series).
- SSE run-tracking:
server/services/pipeline/manuscriptCompletenessRunner.js+server/lib/sseUtils.js(attachSseClient,broadcastSse, run-recordMap). - Routes:
server/routes/pipeline/editorial.js(Router,asyncHandler,validateRequest,mapServiceError,seriesSvc.getSeries), mounted under/api/pipeline/byserver/routes/pipeline/index.js. - Autopilot loop:
server/services/pipeline/seriesAutopilot.jsrunEditorial()(L539–594),L840–863),buildDryRunPlan()(providerOverrideOpts(record). - Settings:
getSettings()/saveSettings()fromserver/services/settings.js; per-check state undersettings.pipelineEditorialChecks.checks[id] = { enabled, config }. - Stage propagation (no migration needed):
scripts/setup-data.jsJSON_MERGE_TARGETSmerges newstagesentries fromdata.reference/prompts/stage-config.jsoninto existing installs, and copies missing.mdfiles. Migrations are only for modifying shipped prompts — a brand-new stage is fully covered by the existing merge/copy.
New files
server/lib/editorial/checkRegistry.jsEDITORIAL_CHECKSarray. Entry:{ id, label, description, scope, kind, category, severityDefault, configSchema (Zod), gate?(ctx), run(ctx) }.- Module-load fail-fast guards (mirror navManifest): missing required fields;
scope ∈ {series,issue,scene,noun};kind ∈ {deterministic,llm}; duplicate id. - The two reference checks (deterministic
naming.dissimilar-namescomputes inline; LLMprose.info-dumpingcallsrunStagedLLM('pipeline-editorial-info-dumping', …)). - Helpers:
getCheck(id),listChecks(),resolveCheckState(settings)(registry defaults merged with persisted enabled/config, validated through eachconfigSchema),getEnabledChecks(settings, subsetIds?).
server/lib/editorial/index.js— barrel (export * from './checkRegistry.js').server/lib/editorial/README.md— catalog rows (Module Organization rule).server/services/pipeline/editorial/checkRunner.jsrunEditorialChecks(seriesId, { checkIds?, providerOverride, modelOverride, signal, onProgress }): build shared ctx once (series, issues, universe canon, manuscript), run each enabled check (deterministic inline; llm via stage), tag every finding withcheckId, persist viaseedReviewFromFindings(seriesId, findings, { runId, mode: 'merge' }). Returns{ runId, findings, perCheck }.- SSE run-tracking mirroring
manuscriptCompletenessRunner.js:startRun,attachSseClient,getStatus,cancelRun; framesstart | check:start | check:complete | complete | error | canceled. buildEditorialCheckPlan(seriesId, settings)— dry-run plan (which checks would run).
data.reference/prompts/stages/pipeline-editorial-info-dumping.md— LLM stage prompt (returns JSON findings). New file → auto-copied to installs.- Tests:
server/lib/editorial/checkRegistry.test.js— shape invariants, dup-id throw, invalid-enum throw,gatefiltering, deterministic naming-check output.server/services/pipeline/editorial/checkRunner.test.js— re-run dedup (no dupes),checkIdpresent on findings, dry-run plan shape.
Modified files
server/services/pipeline/manuscriptReview.js— add optionalcheckIdtosanitizeComment(defaultnull); fold intofindingKey(${checkId??''}|${issueNumber??''}|${anchorQuote}|${problem}). Keep existing completeness findings deduping unchanged (absent checkId →'').server/routes/pipeline/editorial.js— add:GET /editorial/checks→ registry + resolved enabled/config state.PATCH /editorial/checks/:id→ enable/disable/config (Zod-validated).POST /series/:id/editorial/checks/run→ start run (body: optionalcheckIds), SSE.GET /series/:id/editorial/checks/run/progress(SSE attach),.../status,.../cancel(mirror the existing analyze endpoints).
server/services/pipeline/seriesAutopilot.js— add the check-runner pass into the bounded editorial loop (after manuscriptCompleteness, behind the same round/budget gates); add akind: 'editorialChecks'line tobuildDryRunPlan().server/lib/validation.js—editorialCheckConfigSchema(PATCH:enabled?,config?),editorialChecksRunSchema(checkIds?: string[]),pipelineEditorialChecksSettingsSchema; wire the settings slice into the existingPUT /api/settingspartial-validation pattern (server/routes/settings.js).server/lib/index.js+server/lib/README.md— export + documenteditorial/..changelog/NEXT.md— user-facing entry under the appropriate heading.
Verification
cd server && npm test— new registry + runner suites pass; existing manuscriptReview / autopilot / validation /lib/index.test.js(barrel) suites stay green.node -e "import('./server/lib/editorial/index.js').then(()=>console.log('ok'))"— confirms the new module + barrel load (catches missing-import / cross-module link bugs that vitest false-greens).- Boot guard: a temporarily-malformed registry entry throws at module load (manual sanity).
- Manual end-to-end (dev box, optional):
GET /api/pipeline/editorial/checkslists both checks with default state;POST /api/pipeline/series/:id/editorial/checks/runstreams SSE and the resulting findings appear in the existing manuscript-review for that series withcheckIdset; a re-run does not duplicate them.
Ship
/do:next Phase 5–7: re-sync main, log changelog, /simplify + /do:pr --no-merge --review-with=… (multi-file feature → external review), gate merge on a clean status, merge
with Closes #1284, clean up worktree + close issue.