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-1340
[._.]/ Adam Eivye8c308a088de
diff --cc server/services/pipeline/editorial/checkRunner.jsindex 75548b534b,57b0d38a0e..cc825f63d6--- a/server/services/pipeline/editorial/checkRunner.js+++ b/server/services/pipeline/editorial/checkRunner.js@@@ -15,26 -15,55 +15,64 @@@* late-connecting clients via lib/sseUtils.js.*/- import { randomUUID } from 'crypto';+ import { randomUUID, createHash } from 'crypto';import { createSseRunner } from '../../../lib/sseUtils.js';-import { runStagedLLM } from '../../../lib/stageRunner.js';+import { runStagedLLM, resolveStageContext } from '../../../lib/stageRunner.js';+import { planManuscriptPass } from '../../../lib/contextBudget.js';- import { getEnabledChecks, getEnabledCheckRows } from '../../../lib/editorial/index.js';+ import { getEnabledChecks, getEnabledCheckRows, getCheck } from '../../../lib/editorial/index.js';import { getSettings } from '../../settings.js';import { getSeries } from '../series.js';import { listIssues } from '../issues.js';import { getSeriesCanon } from '../seriesCanon.js';-import { collectManuscriptSections, sectionsCorpus } from '../arcPlanner.js';+import { collectManuscriptSections, sectionsCorpus, manuscriptSectionHeader } from '../arcPlanner.js';- import { seedReviewFromFindings } from '../manuscriptReview.js';+ import { seedReviewFromFindings, getReview } from '../manuscriptReview.js';+ import { canonicalStringify } from '../../../lib/objects.js';++ // Source-content fingerprinting for finding staleness (#1345). Each finding is+ // stamped with a hash of the exact content its check analyzed; the manuscript+ // editor / triage view flags a finding `stale` once that content drifts.+ //+ // Two segments cover the inputs the checks actually read: a manuscript-consuming+ // check (`needsManuscript`) hashes the stitched corpus + canon + style guide; a+ // canon-only check hashes canon + the arc's ticking clock — so a canon-only+ // finding (naming, object-attachment, ticking-clock) doesn't go stale on a pure+ // prose edit, and a manuscript finding doesn't go stale on a ticking-clock edit.+ // `canonicalStringify` (key-sorted) keeps the hash stable across machines so a+ // synced finding isn't falsely flagged stale after an import re-orders keys.+ //+ // NOTE: the input set is derived from `needsManuscript` + a fixed series field+ // set, NOT a per-check source declaration — so editing the style guide or ticking+ // clock marks ALL findings in that segment stale, not only the checks that read+ // it. That over-flag is the deliberate SAFE direction (never under-flag): a check+ // added later that reads `styleGuide` still auto-stales, whereas a per-check+ // allow-list would silently false-fresh it. Precise-and-safe scoping via declared+ // per-check sources is tracked in #1387. NUL separates the segments so they can't+ // run together ambiguously.+ const HASH_SEP = '\u0000';+ const sha256 = (text) => createHash('sha256').update(text || '').digest('hex');+ function computeSourceHashes(manuscript, canon, series) {+ const canonStr = canonicalStringify(canon ?? null);+ const styleGuide = canonicalStringify(series?.styleGuide ?? null);+ const tickingClock = canonicalStringify(series?.arc?.tickingClock ?? null);+ return {+ // Manuscript checks (style.reading-level / style.conformance + the prose/object+ // LLM checks) read the corpus + canon + style guide.+ withManuscript: sha256([manuscript || '', canonStr, styleGuide].join(HASH_SEP)),+ // Canon-only checks read canon; arc.ticking-clock-hygiene also reads the arc's+ // ticking clock (folded in here since it's the only non-canon input they consult).+ canonOnly: sha256([canonStr, tickingClock].join(HASH_SEP)),+ };+ }+ const hashForCheck = (hashes, needsManuscript) => (needsManuscript ? hashes.withManuscript : hashes.canonOnly);+// Output room reserved for an editorial check's findings JSON. Sized for the+// editorial output (a bounded findings list — far smaller than the completeness+// pass's full-page rewrites), NOT the 8_000-token contextBudget default: that+// default exceeds the 8_192-token fallback window, so inheriting it would drive+// the usable input budget to 0 on an unknown/small local provider — the exact+// case this chunking targets — and silently feed the model an empty manuscript.+const EDITORIAL_OUTPUT_RESERVE_TOKENS = 2_000;+/*** Run the enabled editorial checks for a series and seed their findings into the* manuscript review.diff --cc server/services/pipeline/editorial/checkRunner.test.jsindex 974daeb9b2,b84998d13d..ba2b13cec0--- a/server/services/pipeline/editorial/checkRunner.test.js+++ b/server/services/pipeline/editorial/checkRunner.test.js@@@ -44,12 -41,19 +44,19 @@@ const seedReviewFromFindings = vi.fn(as}return { comments: seedStore };});- vi.mock('../manuscriptReview.js', () => ({ seedReviewFromFindings: (...a) => seedReviewFromFindings(...a) }));+ // `getReview` is backed by a mutable fixture the staleness tests set per-case.+ let reviewState = { comments: [] };+ vi.mock('../manuscriptReview.js', () => ({+ seedReviewFromFindings: (...a) => seedReviewFromFindings(...a),+ getReview: async () => reviewState,+ }));- const { runEditorialChecks, buildEditorialCheckPlan } = await import('./checkRunner.js');+ const { runEditorialChecks, buildEditorialCheckPlan, getReviewWithStaleness } = await import('./checkRunner.js');-const { runStagedLLM } = await import('../../../lib/stageRunner.js');+const { runStagedLLM, resolveStageContext } = await import('../../../lib/stageRunner.js');const { collectManuscriptSections } = await import('../arcPlanner.js');- const { listChecks } = await import('../../../lib/editorial/index.js');+ const { getSeriesCanon } = await import('../seriesCanon.js');+ const { getSeries } = await import('../series.js');+ const { listChecks, getCheck } = await import('../../../lib/editorial/index.js');// Build a `pipelineEditorialChecks.checks` map that disables every check// matching `predicate` — keeps these fixtures robust as the registry grows@@@ -62,10 -66,11 +69,12 @@@ const disableWhere = (predicate) => (beforeEach(() => {seedStore.length = 0;+ reviewState = { comments: [] };seedReviewFromFindings.mockClear();runStagedLLM.mockClear();+ resolveStageContext.mockClear();collectManuscriptSections.mockClear();+ getSeriesCanon.mockClear();});describe('runEditorialChecks', () => {