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): anchor roster findings on the matched token + fix recurrence wording
[._.]/ Adam Eivy30de6f3b14f4
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex 4514b9af55..66948e5669 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -700,8 +700,17 @@ function buildRosterAppearances(ctx) {const matcher = characterMatcher(characterNameTokens(c));if (!matcher) continue;const appearedInIssues = [];+ // Capture the ACTUAL matched token (name OR alias) from the first issue the+ // character appears in, so a finding's anchorQuote lands on real prose — an+ // alias-only mention ("Bob" for canonical "Robert") must anchor on "Bob", not+ // the canonical name the editor would never find. `matcher` is non-global, so+ // exec starts at 0 on each section. Falls back to the name for unmatched rows.+ let anchorQuote = '';for (const s of sections) {- if (matcher.test(s.content || '')) appearedInIssues.push(s.number);+ const m = matcher.exec(s.content || '');+ if (!m) continue;+ appearedInIssues.push(s.number);+ if (!anchorQuote) anchorQuote = m[0];}rows.push({id: c.id || name,@@ -709,6 +718,7 @@ function buildRosterAppearances(ctx) {locked: c.locked === true,appearedInIssues,firstIssueNumber: appearedInIssues.length ? appearedInIssues[0] : null,+ anchorQuote: anchorQuote || name,});}return rows;@@ -969,12 +979,19 @@ export const EDITORIAL_CHECKS = [for (const r of rows) {const n = r.appearedInIssues.length;if (n === 0 || n >= minAppear) continue;+ const issuesList = r.appearedInIssues.join(', ');+ // "never recurs" is only true for a one-issue character; with a higher+ // minAppearancesToWarn, a 2+-issue character DOES recur (just under the+ // threshold), so word that case factually.+ const problem = n === 1+ ? `"${r.name}" is a named character who appears in only 1 issue (${issuesList}) — a named body readers are told to remember but who never recurs.`+ : `"${r.name}" is a named character who appears in only ${n} issues (${issuesList}) — fewer than your ${minAppear}-issue recurrence threshold, so they barely register as part of the cast.`;flag({severity: escalateSeverity(ctx.severityDefault, lengthBump),location: r.firstIssueNumber != null ? `Issue ${r.firstIssueNumber}: ${r.name}` : `Character: ${r.name}`,- problem: `"${r.name}" is a named character who appears in only ${n} issue${n === 1 ? '' : 's'} (${r.appearedInIssues.join(', ')}) — a named body readers are told to remember but who never recurs.`,+ problem,suggestion: `Cut "${r.name}", merge them into another character, or leave them unnamed (a description) unless they are meant to recur.`,- anchorQuote: r.name,+ anchorQuote: r.anchorQuote,issueNumber: r.firstIssueNumber,});}@@ -984,7 +1001,7 @@ export const EDITORIAL_CHECKS = [// the opening issue dilutes the ones that matter.if (sectionCount > 0 && maxFirst > 0) {const firstNumber = sections[0].number;- const inFirst = rows.filter((r) => r.appearedInIssues.includes(firstNumber)).map((r) => r.name);+ const inFirst = rows.filter((r) => r.appearedInIssues.includes(firstNumber));if (inFirst.length > maxFirst) {// Low by default; escalate to medium only when crowding is well over the// threshold (≥1.5×) — it's a pacing nudge, not a correctness error.@@ -992,9 +1009,11 @@ export const EDITORIAL_CHECKS = [flag({severity: escalateSeverity(ctx.severityDefault, heavy ? 1 : 0),location: `Issue ${firstNumber} (opening)`,- problem: `${inFirst.length} named characters appear in the opening issue (${inFirst.join(', ')}) — more than ${maxFirst}. Too many introductions at once makes it hard for readers to tell who matters.`,+ problem: `${inFirst.length} named characters appear in the opening issue (${inFirst.map((r) => r.name).join(', ')}) — more than ${maxFirst}. Too many introductions at once makes it hard for readers to tell who matters.`,suggestion: 'Introduce fewer named characters up front — delay, merge, or leave some unnamed until readers have anchored to the leads.',- anchorQuote: inFirst[0],+ // Anchor on a real matched token from the opening issue (these rows all+ // first appear there), not the canonical name which may be an alias-only mention.+ anchorQuote: inFirst[0].anchorQuote,issueNumber: firstNumber,});}diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex d44230cad9..c041837cb7 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -464,14 +464,30 @@ describe('roster.economy — deterministic check', () => {expect(throwaways(findings).some((f) => /"J\.R\."/.test(f.problem))).toBe(true);});- it('counts appearances via aliases, attributing to the canonical name', () => {+ it('counts appearances via aliases, anchoring on the matched alias not the canonical name', () => {const findings = runRoster([{ name: 'Robert', aliases: ['Bob'] }, { name: 'Aria' }],[sec(1, 'Bob arrived.'), sec(2, 'Aria stayed; Aria thought of him.')],);- // Robert appears only via "Bob" in issue 1 → throwaway, named as Robert.- const tw = throwaways(findings);- expect(tw.some((f) => /"Robert"/.test(f.problem))).toBe(true);+ // Robert appears only via "Bob" in issue 1 → throwaway named as Robert, but the+ // anchorQuote must be the prose token "Bob" so the editor's jump-to-highlight lands.+ const tw = throwaways(findings).find((f) => /"Robert"/.test(f.problem));+ expect(tw).toBeTruthy();+ expect(tw.anchorQuote).toBe('Bob');+ });++ it('words the throwaway finding for the recurrence threshold, not always "never recurs"', () => {+ // minAppearancesToWarn=3: a 2-issue character DOES recur but is under threshold.+ const findings = runRoster(+ [{ name: 'Bram' }, { name: 'Aria' }],+ [sec(1, 'Bram and Aria met.'), sec(2, 'Bram and Aria parted.'), sec(3, 'Aria went on.')],+ { minAppearancesToWarn: 3, maxFirstIssueCharacters: 0, maxCastPerIssue: 0 },+ );+ const f = findings.find((x) => /"Bram"/.test(x.problem)); // Bram in 1,2 (n=2); Aria in all 3+ expect(f).toBeTruthy();+ expect(f.problem).not.toMatch(/never recurs/);+ expect(f.problem).toMatch(/2 issues/);+ expect(f.problem).toMatch(/recurrence threshold/);});it('flags first-issue crowding and lists the introduced names', () => {