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
address review (codex): fold arc-coverage completeness into the editorialArcs staleness hash
[._.]/ Adam Eivyf4dab98283aa
diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.jsindex 6c40e9ba6a..8e7c08b649 100644--- a/server/services/pipeline/editorial/checkRunner.js+++ b/server/services/pipeline/editorial/checkRunner.js@@ -63,7 +63,12 @@ const SOURCE_RESOLVERS = {// injected `editorialArcs` is the stable projection (name/arcDirection/issueCount/// isProtagonist) — NOT the raw getSeriesEditorial output, which carries a// per-call `generatedAt` timestamp that would re-stale every finding each run.- editorialArcs: ({ editorialArcs }) => canonicalStringify(editorialArcs ?? null),+ // The `complete` flag is folded in too: a prose edit that stales the analysis+ // (without re-running it) leaves the projection byte-identical but flips+ // completeness, and pov.justified's "absent from arcs" finding depends on that+ // flag — so a finding must go stale when it changes, not only when the arcs do.+ editorialArcs: ({ editorialArcs, editorialArcsComplete }) =>+ canonicalStringify({ arcs: editorialArcs ?? null, complete: editorialArcsComplete === true }),};// Stable projection of the series editorial aggregate down to the arc fields a@@ -78,6 +83,16 @@ function projectEditorialArcs(editorial) {isProtagonist: c?.isProtagonist === true,}));}++// True only when every analyzable issue has a fresh, complete analysis — the+// signal pov.justified uses to tell "absent because arc-less" from "absent+// because not-yet-analyzed" (#1295). Injected into ctx for the check AND folded+// into the editorialArcs fingerprint above so a prose edit that stales coverage+// (without changing the arc projection) still stales the POV findings.+function editorialCoverageComplete(editorial) {+ const cov = editorial?.coverage;+ return !!cov && cov.withContent > 0 && cov.analyzed >= cov.withContent && (cov.stale || 0) === 0;+}for (const token of EDITORIAL_SOURCES) {if (typeof SOURCE_RESOLVERS[token] !== 'function') {throw new Error(`checkRunner: editorial source "${token}" has no fingerprint resolver — keep SOURCE_RESOLVERS in sync with EDITORIAL_SOURCES`);@@ -181,17 +196,12 @@ export async function runEditorialChecks(seriesId, options = {}) {// Whether every analyzable issue has been analyzed and is fresh — gates the// pov.justified "absent from detected arcs" finding so a partially-analyzed// series (canceled/early-stopped batch) doesn't flag a not-yet-analyzed POV- // holder as arc-less (#1295). Derived, not fingerprinted: it moves in lockstep- // with the editorialArcs projection that already drives staleness.- const cov = editorial?.coverage;- const editorialArcsComplete = !!cov- && cov.withContent > 0- && cov.analyzed >= cov.withContent- && (cov.stale || 0) === 0;+ // holder as arc-less (#1295). Folded into the editorialArcs fingerprint below.+ const editorialArcsComplete = editorialCoverageComplete(editorial);// Resolve every source token once — each finding's fingerprint reads from this// so the editor flags it `stale` when the content that check actually read (its// declared `sources`) drifts (#1345, #1387).- const resolvedSources = resolveSources({ manuscript, canon, series, reverseOutline, editorialArcs });+ const resolvedSources = resolveSources({ manuscript, canon, series, reverseOutline, editorialArcs, editorialArcsComplete });const baseCtx = {seriesId,series,@@ -355,7 +365,8 @@ export async function getReviewWithStaleness(seriesId) {]);const reverseOutline = Array.isArray(outline?.scenes) ? outline.scenes : [];const editorialArcs = projectEditorialArcs(editorial);- const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series, reverseOutline, editorialArcs });+ const editorialArcsComplete = editorialCoverageComplete(editorial);+ const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series, reverseOutline, editorialArcs, editorialArcsComplete });return {...review,comments: review.comments.map((c) => {diff --git a/server/services/pipeline/editorial/checkRunner.test.js b/server/services/pipeline/editorial/checkRunner.test.jsindex cb7b81a2f0..a7cf4a1ac6 100644--- a/server/services/pipeline/editorial/checkRunner.test.js+++ b/server/services/pipeline/editorial/checkRunner.test.js@@ -375,6 +375,33 @@ describe('getReviewWithStaleness (#1345)', () => {expect(review.comments.find((c) => c.checkId === 'scene.component-balance').stale).toBe(false);});+ it('stales a pov.justified finding when arc coverage flips incomplete even if the arc projection is byte-identical (#1295)', async () => {+ // A prose edit that stales the editorial analysis (without re-running it)+ // leaves the arc projection unchanged but flips coverage-complete. The+ // "no detected arc" verdict depends on that flag, so the finding must go+ // stale — folding `complete` into the editorialArcs fingerprint is what+ // catches it (the projection alone wouldn't).+ outlineState = { scenes: [+ { id: 'scene-001', issueNumber: 1, heading: 'Solo A', anchorQuote: 'q1', povCharacter: 'Solo', components: { narrative: true } },+ { id: 'scene-002', issueNumber: 1, heading: 'Solo B', anchorQuote: 'q2', povCharacter: 'Solo', components: { narrative: true } },+ ] };+ editorialState = {+ characters: [{ name: 'Solo', arcDirection: 'flat', issueCount: 1, isProtagonist: false }],+ coverage: { analyzed: 1, total: 1, withContent: 1, stale: 0, noContent: 0 },+ };+ await seedReviewFromRun();+ expect(reviewState.comments.find((c) => c.checkId === 'pov.justified')).toBeTruthy();+ // Identical arc projection, but the analysis is now stale (coverage incomplete).+ editorialState = {+ characters: [{ name: 'Solo', arcDirection: 'flat', issueCount: 1, isProtagonist: false }],+ coverage: { analyzed: 1, total: 1, withContent: 1, stale: 1, noContent: 0 },+ };+ const review = await getReviewWithStaleness('s1');+ expect(review.comments.find((c) => c.checkId === 'pov.justified').stale).toBe(true);+ // A canon-only finding is unaffected by the coverage flip.+ expect(review.comments.find((c) => c.checkId === 'naming.dissimilar-names').stale).toBe(false);+ });+it('stales a custom-check finding when its authored prompt changes, even if the manuscript is unchanged (#1387)', async () => {// A custom check's run logic is its prompt (user data), so a prompt edit must// stale its prior findings — the manuscript source alone can't catch that.