Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(conversation-parser): one-off bold labels are not a conversation (N12-1)

garrytan7f723e4568e1
diff --git a/src/core/conversation-parser/builtins.ts b/src/core/conversation-parser/builtins.ts
index 3d05b1ca92..32862b390f 100644
--- a/src/core/conversation-parser/builtins.ts
+++ b/src/core/conversation-parser/builtins.ts
@@ -494,6 +494,9 @@ export const BUILTIN_PATTERNS: readonly PatternEntry[] = [
multi_line: false,
quick_reject: /^\*\*/,
score_full_body: true,
+ // N12-1: three or more one-off bold labels with no repeated speaker
+ // are a status note, not a transcript.
+ repeat_speaker_min_turns: 3,
test_positive: [
'**Alice Example:** Okay, start on.',
'**Participant 2:** he tried to reset it remotely the other night.',
diff --git a/src/core/conversation-parser/parse.ts b/src/core/conversation-parser/parse.ts
index 9973eceb9f..eaaf66f743 100644
--- a/src/core/conversation-parser/parse.ts
+++ b/src/core/conversation-parser/parse.ts
@@ -759,6 +759,24 @@ export function parseConversation(
const diag = { unrecognized_headings: [] as string[], date_fallback_count: 0 };
const messages = applyPattern(body, top.entry, dateCtx, diag);
+ // Structure gate (N12-1): enough turns with every speaker distinct is a
+ // list of labels, not a conversation.
+ const minTurns = top.entry.repeat_speaker_min_turns;
+ if (
+ minTurns !== undefined &&
+ messages.length >= minTurns &&
+ new Set(messages.map((m) => m.speaker)).size === messages.length
+ ) {
+ return {
+ messages: [],
+ phase: 'no_match',
+ patterns_scored: patternsScored,
+ unmatched_line_count: opts.diagnostic
+ ? body.split(/\r?\n/).filter((l) => l.trim().length > 0).length
+ : undefined,
+ };
+ }
+
// Timezone warning surface (D19).
let timezone_warning: string | undefined;
if (
diff --git a/src/core/conversation-parser/types.ts b/src/core/conversation-parser/types.ts
index 410107e7a5..113a47bbe9 100644
--- a/src/core/conversation-parser/types.ts
+++ b/src/core/conversation-parser/types.ts
@@ -240,6 +240,15 @@ export interface PatternEntry {
* real transcript stays ~1.0.
*/
score_full_body?: boolean;
+ /**
+ * Conversational-structure gate for broad label-shaped patterns
+ * (gbrain-evals N12-1). When the parsed body has at least this many
+ * turns and no speaker ever speaks twice, the page is a list of one-off
+ * labels (`**Status:** … **Owner:** … **Next step:** …`), not an
+ * exchange, and the orchestrator returns no_match. Density scoring
+ * cannot see this: a short status block clears the 0.05 floor.
+ */
+ repeat_speaker_min_turns?: number;
/** D7: module-load validation — known-positive sample lines. */
test_positive: string[];
/** D7: module-load validation — known-negative sample lines. */
diff --git a/test/conversation-parser/parse.test.ts b/test/conversation-parser/parse.test.ts
index a0ffde5147..e9fafe409b 100644
--- a/test/conversation-parser/parse.test.ts
+++ b/test/conversation-parser/parse.test.ts
@@ -768,6 +768,30 @@ describe('bold-name-no-time pattern (Circleback/Granola/Zoom, no timestamp)', ()
expect(r.messages[0].timestamp).toBe('1970-01-01T00:00:00Z');
});
+ // gbrain-evals N12-1: a status note with three one-off bold labels is
+ // not a conversation. Full-body density (3/26 ≈ 0.115) clears the floor,
+ // so the gate is structural: three or more turns with no speaker ever
+ // speaking twice is a list of labels, not an exchange.
+ test('REGRESSION (N12-1): a status note with one-off bold labels is no_match', () => {
+ const filler = Array.from({ length: 22 }, (_, i) => `Paragraph ${i + 1}: the team agreed in principle and will review the plan this week.`);
+ const body = ['# Project status', '', '**Status:** green', '**Owner:** Alice Example', '**Next step:** ship the draft', '', ...filler, ''].join('\n');
+ const r = parseConversation(body, { noFallback: true, noPolish: true, page: { frontmatter: { date: '2026-04-01' } } } as any);
+ expect(r.phase).toBe('no_match');
+ expect(r.messages).toEqual([]);
+ });
+
+ test('N12-1 control: a three-person exchange where someone speaks twice still parses', () => {
+ const body = [
+ '**Alice Example:** shall we start?',
+ '**Bob Example:** ready.',
+ '**Carol Example:** me too.',
+ '**Alice Example:** great, first item.',
+ ].join('\n');
+ const r = parseConversation(body, { fallbackDate: '2026-04-01' });
+ expect(r.matched_pattern_id).toBe('bold-name-no-time');
+ expect(r.messages).toHaveLength(4);
+ });
+
// REGRESSION: must NOT shadow bold-paren-time. A `**Name** (00:00): text`
// line has its colon OUTSIDE the bold markers, so it must still parse via
// bold-paren-time (the safety is the regex, not declaration order).