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

address review (codex): measure attribution on de-quoted text; reject capitalized post-quote subject as a tag

Adam Eivya26b6deeb797
diff --git a/server/lib/editorial/dialogue.js b/server/lib/editorial/dialogue.js
index 155ca03289..c868430d83 100644
--- a/server/lib/editorial/dialogue.js
+++ b/server/lib/editorial/dialogue.js
@@ -186,13 +186,21 @@ export function findSaidBookisms(text, opts = {}) {
re.lastIndex = 0;
let m;
while ((m = re.exec(text)) !== null) {
- const form = m[verbGroup].toLowerCase();
+ const matched = m[verbGroup];
+ const form = matched.toLowerCase();
const info = kindByForm.get(form);
if (!info) continue;
// For the after-quote pass, gate on the in-quote terminal punctuation so an
// action beat following a complete sentence ("…." She smiled.) isn't flagged
// as a misused tag. The before-quote pass has no punctuation to weigh.
- if (punctGroup !== null && !punctAllowsTag(info.kind, m[punctGroup] || '')) continue;
+ if (punctGroup !== null) {
+ if (!punctAllowsTag(info.kind, m[punctGroup] || '')) continue;
+ // A real after-quote tag verb is lowercase — a clause continuation
+ // ("…," she opined / "…," opined Marlon). A CAPITALIZED word after the
+ // quote is the subject of a NEW sentence (narration), e.g.
+ // `"Run!" Thunder rolled overhead.` — not a tag. Skip it.
+ if (matched[0] !== matched[0].toLowerCase()) continue;
+ }
const key = `${info.base}@${m.index}`;
if (seen.has(key)) continue;
seen.add(key);
@@ -222,10 +230,13 @@ const hasQuotedSpan = (para) => {
// A dialogue paragraph is "attributed" when it carries a speech tag (plain or
// ornate) OR an action beat — substantial non-quoted prose that grounds who is
-// speaking. The beat threshold is on the non-quoted character count.
+// speaking. Both signals are measured on the NON-QUOTED remainder: a tag word
+// that appears INSIDE the dialogue ("I said no.") is spoken text, not
+// attribution, so the tag regexes must run on the narration around the quote,
+// not the whole paragraph.
function isAttributed(para, beatChars) {
- if (PLAIN_TAG_RE.test(para) || (ORNATE_TAG_RE && ORNATE_TAG_RE.test(para))) return true;
const beat = para.replace(QUOTED_SPAN_RE, ' ').replace(/\s+/g, ' ').trim();
+ if (PLAIN_TAG_RE.test(beat) || (ORNATE_TAG_RE && ORNATE_TAG_RE.test(beat))) return true;
return beat.length >= beatChars;
}
diff --git a/server/lib/editorial/dialogue.test.js b/server/lib/editorial/dialogue.test.js
index 4dc9a9740e..91b5f9675e 100644
--- a/server/lib/editorial/dialogue.test.js
+++ b/server/lib/editorial/dialogue.test.js
@@ -35,6 +35,13 @@ describe('findSaidBookisms', () => {
expect(findSaidBookisms('The engine growled as it turned over.')).toEqual([]);
});
+ it('does NOT flag a capitalized new-sentence subject after a quote (narration, not a tag)', () => {
+ // "Thunder" is a bookism-list word, but here it's the subject of a new
+ // narrated sentence after "Run!" — a real tag verb is lowercase.
+ expect(findSaidBookisms('"Run!" Thunder rolled overhead.')).toEqual([]);
+ expect(findSaidBookisms('"Stop!" Hiss of steam filled the room.')).toEqual([]);
+ });
+
it('does NOT flag plain "said" / "asked" tags', () => {
expect(findSaidBookisms('"Hello," she said. "How are you?" he asked.')).toEqual([]);
});
@@ -119,6 +126,23 @@ describe('findUnattributedDialogueRuns', () => {
expect(findUnattributedDialogueRuns(short)).toEqual([]);
});
+ it('does NOT treat a tag word INSIDE the quote as attribution', () => {
+ // "I said no." contains "said", but it's spoken text, not a tag — the run
+ // must still be detected (attribution is measured on the narration, not the
+ // quoted dialogue).
+ const withTagWordInQuote = [
+ '"You came back."',
+ '"I said no."',
+ '"After everything?"',
+ '"Especially after everything."',
+ '"And now?"',
+ '"Now we finish it."',
+ ].join('\n');
+ const runs = findUnattributedDialogueRuns(withTagWordInQuote);
+ expect(runs).toHaveLength(1);
+ expect(runs[0].count).toBe(6);
+ });
+
it('a speech tag re-anchors and breaks the run', () => {
const tagged = [
'"You came back."',