Skip to content

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

editorial: don't flag a character name against its own plural

[._.]/ Adam Eivy5c0d2044e9c0
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index c80eaebcd5..fe2394b3a9 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -54,3 +54,4 @@
- Editing a **shared or derived** port now persists too. When two port fields resolve to the same literal (e.g. the prod UI is served by the API, so `uiPort === apiPort`), the value-keyed rewrite couldn't tell them apart and the edit returned a 422. The PUT route now falls back to a **per-process-label-targeted** rewrite: it locates the specific process block in `ecosystem.config.cjs` and rewrites only the touched label's port (`api`/`ui`/`devUi`), leaving the sibling field — and any same-valued unrelated number — untouched. Edits to ports that live only under a process's `env`/`args` (no top-level field) persist as well, and an explicit `ports: { ui: N, devUi: N }` map with matching values is split correctly (only the edited key changes). A save that mixes a distinct port and a shared port is written **atomically** — both rewrites are computed in memory and the config file is written once, only when every edit is persistable — so a request that's rejected (422) never leaves the config half-changed. The 422 is reserved for the genuinely unpersistable case (the literal isn't in the touched process block — e.g. it lives in a shared `const PORTS = {…}` referenced via `ports: PORTS.server`, or is computed entirely at runtime), so a shared-value edit never falsely reports success while the displayed port silently reverts. For an app whose prod UI is **served by the API** (no separate UI port), the UI port can't be set on its own — it always follows the API port: the stored UI port is normalized to track the API port on every save (so it never freezes at a stale value), and you change it by changing the API port.
- **The character-name dissimilarity check no longer floods an epithet cast with thousands of false "confusable name" findings.** Two bugs compounded on a cast that uses article-led epithet names ("THE CABARET SINGER", "THE CHAPTER SEVENTEEN READER", …): (1) the check compared on the raw name, so 60+ "THE …" names all read as starting with the same letter and sharing the same 3-character opening; and (2) "same first letter" and "same opening" were counted as two independent similarity signals even though a shared 3-char opening always implies a shared first letter — so any two names sharing a prefix auto-reached the default 2-signal flag threshold. On one 24-issue series this produced ~2,100 spurious naming findings (and a "44 of 69 names start with T" crowding finding that was really just the article "THE"), driving the editorial health score to 0 and hard-pausing Series Autopilot at the health gate. The check now strips a leading article (the/a/an) before comparing names and counts the first-letter/opening overlap once, so it flags names readers would genuinely confuse and an epithet cast is judged on its real distinguishing words. (`server/lib/editorial/nameSimilarity.js`, `server/lib/editorial/checkRegistry.js`)
- **Deterministic editorial checks now self-heal — corrected or resolved findings clear instead of lingering forever.** The editorial-checks pass seeded every finding in `merge` mode, which only ever *adds* findings: an open finding a deterministic check no longer produces (because the check was fixed, or the underlying canon/manuscript changed) stayed open permanently. That let stale findings accumulate and could keep Series Autopilot's editorial-health gate blocked on problems that no longer exist. Deterministic checks (pure functions of their inputs) are now seeded in `fresh` mode scoped to each check's own id, so a finding the check no longer surfaces is auto-dismissed (a sync-safe status flip, never a deletion) — including when a check finds nothing at all that pass. LLM checks stay `merge`-only, since an absent LLM finding can be sampling variance rather than a real resolution; one check's reconciliation never touches another check's or the completeness pass's open comments. (`server/services/pipeline/editorial/checkRunner.js`)
+- **The name-dissimilarity check no longer flags a name against its own plural.** A role-noun cast ("THE POET" / "the poets", "a reader" / "readers", "a waiter" / "the waiters") tripped the check's edit-distance-1 rule — a single trailing "s" reads as a near-identical-spelling typo — and escalated each pair to a *high*-severity blocker, even though singular-vs-plural is a deliberate count distinction (an individual vs a crowd) a reader parses effortlessly. The check now recognizes singular/plural variants of the same noun (the three common English inflections: -s, -es, -ies) and treats the pair as inert, while two genuinely different words that merely both end in "s" still compare normally. (`server/lib/editorial/nameSimilarity.js`)
diff --git a/server/lib/editorial/nameSimilarity.js b/server/lib/editorial/nameSimilarity.js
index 74bb1ed85e..6285ba4739 100644
--- a/server/lib/editorial/nameSimilarity.js
+++ b/server/lib/editorial/nameSimilarity.js
@@ -104,12 +104,38 @@ export const DEFAULT_SIGNAL_OPTS = Object.freeze({
usePhonetic: true,
});
+// Reduce a normalized (letters-only) noun to a crude singular stem so a name and
+// its own plural ("reader"/"readers", "poet"/"poets", "drone"/"drones",
+// "city"/"cities") map to the same stem. Deliberately conservative — it only
+// undoes the three common English plural inflections and never shortens below 3
+// letters (so "is"/"" or "as"/"a" can't collapse). Not linguistically complete;
+// just enough to recognize a singular/plural variant of the SAME word.
+function singularStem(letters) {
+ if (typeof letters !== 'string' || letters.length < 4) return letters;
+ if (letters.endsWith('ies')) return `${letters.slice(0, -3)}y`; // cities → city
+ if (letters.endsWith('es') && letters.length > 4) return letters.slice(0, -2); // boxes → box
+ if (letters.endsWith('s') && !letters.endsWith('ss')) return letters.slice(0, -1); // poets → poet
+ return letters;
+}
+
+// Are two normalized names singular/plural variants of the SAME noun (e.g.
+// "reader"/"readers", "poet"/"poets")? Such a pair is a deliberate count
+// distinction a reader parses effortlessly (an individual vs a crowd), NOT a
+// confusable near-typo — so the check must not flag it. Requires the two to
+// actually DIFFER (equal forms are handled separately) and to share a singular
+// stem.
+function isSingularPluralPair(la, lb) {
+ if (!la || !lb || la === lb) return false;
+ return singularStem(la) === singularStem(lb);
+}
+
// Analyze a name pair in a single pass: the confusability `signals` (each one a
// reason a reader could blur the two on the page) plus the two metrics that also
// drive the check's severity — the Levenshtein `distance` and whether the names
// share a `phoneticMatch`. Computing them here once lets the caller score severity
// without re-running soundex/levenshtein. Returns empty/Infinity/false when either
-// name has no letters or the two normalize equal.
+// name has no letters, the two normalize equal, or they're singular/plural
+// variants of the same noun.
export function analyzeNamePair(a, b, opts = {}) {
const { minEditDistance, flagSameLength, vowelSkeletonCollision, usePhonetic } = {
...DEFAULT_SIGNAL_OPTS,
@@ -120,6 +146,9 @@ export function analyzeNamePair(a, b, opts = {}) {
const la = comparisonName(a);
const lb = comparisonName(b);
if (!la || !lb || la === lb) return { signals: [], distance: Infinity, phoneticMatch: false };
+ // A name and its own plural is a deliberate, readable count distinction, not a
+ // confusion — treat it as inert (same as equal forms).
+ if (isSingularPluralPair(la, lb)) return { signals: [], distance: Infinity, phoneticMatch: false };
const signals = [];
// "same opening" (first 3 chars) STRICTLY IMPLIES "same first letter", so
// counting both double-counts one similarity: any shared 3-char prefix would
diff --git a/server/lib/editorial/nameSimilarity.test.js b/server/lib/editorial/nameSimilarity.test.js
index 8910c1f64c..7a35973a98 100644
--- a/server/lib/editorial/nameSimilarity.test.js
+++ b/server/lib/editorial/nameSimilarity.test.js
@@ -97,6 +97,21 @@ describe('nameSimilaritySignals', () => {
expect(nameSimilaritySignals('Sam', 'Sid')).toContain('same first letter');
});
+ it('treats a singular/plural variant of the same noun as inert (not a near-typo)', () => {
+ // "readers"/"a reader", "poets"/"a poet", "waiter"/"waiters" are deliberate
+ // count distinctions a reader parses effortlessly — they must NOT flag (and
+ // especially must not escalate to high via the edit-distance-1 rule).
+ expect(nameSimilaritySignals('readers', 'a reader')).toEqual([]);
+ expect(nameSimilaritySignals('THE POET', 'poets')).toEqual([]);
+ expect(nameSimilaritySignals('a waiter', 'THE WAITERS')).toEqual([]);
+ expect(nameSimilaritySignals('city', 'cities')).toEqual([]);
+ expect(analyzeNamePair('readers', 'reader')).toEqual({ signals: [], distance: Infinity, phoneticMatch: false });
+ // But two DIFFERENT words that merely both end in "s" are not a plural pair —
+ // genuine confusability signals still apply.
+ expect(nameSimilaritySignals('Marcus', 'Atlas')).not.toContain('near-identical spelling (edit distance 1)');
+ expect(nameSimilaritySignals('Alina', 'Alana')).toContain('near-identical spelling (edit distance 1)');
+ });
+
it('strips a leading article before comparing (epithet casts)', () => {
// "THE CABARET SINGER" vs "THE CHAPTER SEVENTEEN READER" must NOT collide on
// the shared "THE" — compared on "cabaret…" / "chapter…" they share only a