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 (claude): NARA-correct soundex h/w rule, duplicate-name-safe crowding, gate near-typo escalation
[._.]/ Adam Eivy0d99daa55d03
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex 730455c2c9..b1f79eff08 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -26,7 +26,7 @@import { z } from 'zod';import { estimateTokens } from '../contextBudget.js';-import { analyzeNamePair, findFirstLetterClusters } from './nameSimilarity.js';+import { analyzeNamePair, findFirstLetterClusters, normalizeName } from './nameSimilarity.js';export const CHECK_SCOPES = Object.freeze(['series', 'issue', 'scene', 'noun']);export const CHECK_KINDS = Object.freeze(['deterministic', 'llm']);@@ -745,9 +745,11 @@ export const EDITORIAL_CHECKS = [// distance and phonetic match are already among the counted signals).if (signals.length < min) continue;// Severity scales with how confusable the pair really is, above the- // check's low floor: edit distance ≤1 is a near-typo (escalate 2), a- // phonetic match or 4+ signals is strong (escalate 1).- const steps = distance <= 1 ? 2 : (phoneticMatch || signals.length >= 4 ? 1 : 0);+ // check's low floor: a near-typo (edit distance ≤1, only when the+ // edit-distance signal is enabled) escalates 2, a phonetic match or 4++ // signals is strong (escalate 1).+ const nearTypo = signalOpts.minEditDistance > 0 && distance <= 1;+ const steps = nearTypo ? 2 : (phoneticMatch || signals.length >= 4 ? 1 : 0);findings.push({severity: escalateSeverity(ctx.severityDefault, steps),category: 'naming',@@ -765,10 +767,13 @@ export const EDITORIAL_CHECKS = [const ratio = cfg.maxShareFirstLetterRatio ?? 0.4;if (ratio > 0) {const primaries = tokens.filter((t) => !t.isAlias);- const byOwner = new Map(primaries.map((t) => [t.token, t]));const clusters = findFirstLetterClusters(primaries.map((t) => t.token), { minCount: 3, maxRatio: ratio });for (const cluster of clusters) {- const unlocked = cluster.names.filter((n) => !byOwner.get(n)?.locked);+ // Derive the unlocked members from the tokens (not a name-keyed map) so+ // two distinct characters sharing an identical name both count.+ const unlocked = primaries+ .filter((t) => !t.locked && normalizeName(t.token)[0] === cluster.letter)+ .map((t) => t.token);const renameHint = unlocked.length? `Consider renaming some of the unlocked ones (${unlocked.join(', ')}) so the cast doesn't blur together.`: 'All of these are locked — unlock one to rename it so the cast doesn\'t blur together.';diff --git a/server/lib/editorial/nameSimilarity.js b/server/lib/editorial/nameSimilarity.jsindex 762cc5862a..d6091c4417 100644--- a/server/lib/editorial/nameSimilarity.js+++ b/server/lib/editorial/nameSimilarity.js@@ -28,21 +28,25 @@ export function soundex(s) {const letters = normalizeName(s);if (!letters) return '';const first = letters[0];- // Code every letter; vowels and h/w/y are separators (undefined → no digit).- const codes = [...letters].map((ch) => SOUNDEX_CODES[ch]);let out = '';- // Walk from the second letter, collapsing runs of the same digit. A separator- // (vowel / h / w / y) breaks a run so two same-coded consonants split by a vowel- // are kept (per the standard algorithm). The first letter's own code is dropped- // but still seeds the "previous code" so an immediately-following same-coded- // consonant collapses into it.- let prev = codes[0];+ // Walk from the second letter, collapsing runs of the same digit. Per the+ // standard (NARA) algorithm: a vowel (or y) separates a run so two same-coded+ // consonants split by it both emit, while h and w are TRANSPARENT — they+ // neither emit nor break a run, so consonants separated only by h/w collapse to+ // one digit (e.g. "Ashcraft" → A261, the s/c pair split by h stays a single 2).+ // The first letter's own code is dropped but seeds `prev` so an immediately+ // following same-coded consonant collapses into it.+ let prev = SOUNDEX_CODES[first];for (let i = 1; i < letters.length && out.length < 3; i += 1) {- const code = codes[i];- if (code && code !== prev) out += code;- // Vowels/h/w/y (undefined code) reset the run so a later same digit can re-emit;- // a same-coded consonant run collapses (prev stays set).- prev = code === undefined ? undefined : code;+ const ch = letters[i];+ const code = SOUNDEX_CODES[ch];+ if (code !== undefined) {+ if (code !== prev) out += code;+ prev = code;+ } else if (ch !== 'h' && ch !== 'w') {+ prev = undefined; // vowel or y — separator+ }+ // h / w: transparent — leave `prev` unchanged}return (first + out).padEnd(4, '0').toUpperCase();}diff --git a/server/lib/editorial/nameSimilarity.test.js b/server/lib/editorial/nameSimilarity.test.jsindex 4f3f11268d..4fe4db142c 100644--- a/server/lib/editorial/nameSimilarity.test.js+++ b/server/lib/editorial/nameSimilarity.test.js@@ -41,8 +41,9 @@ describe('soundex', () => {expect(soundex('Rupert')).toBe('R163');expect(soundex('Smith')).toBe('S530');expect(soundex('Smyth')).toBe('S530');- expect(soundex('Tymczak')).toBe('T522');+ expect(soundex('Tymczak')).toBe('T522'); // vowel 'a' separates Z and K, so K is codedexpect(soundex('Pfister')).toBe('P236'); // adjacent same-code (p/f) collapses+ expect(soundex('Ashcraft')).toBe('A261'); // h is transparent: s/c (both 2) stay one digit});it('pads short names to four chars', () => {expect(soundex('Sam')).toBe('S500');