Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(timeline): parse dated ### headings as timeline entries on the DB path (#5562)
garrytanbef193a757c7
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex 15d5fab79f..25f497ce22 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -31,7 +31,7 @@ src/core/minions/handlers/subagent.ts 1918 ratchet merged: master v131 settle resrc/commands/bootstrap.ts 2126 ratchet grandfathered at merge (grew past the 1500 cap on master); raised for #4066 HOME_WORKSPACE_GUARD_EXEMPT (status/uninstall/harness); +5 for the harnessDetect test seam (bulk lives in core/bootstrap/harness.ts); +23 for the contract subcommand dispatcher glue (#4105 absorb — bulk lives in core/bootstrap/contract.ts); +codex hooks-consent gate + mcp+hooks receipt registration + uninstall arm; +42 ambient-writeback WP8: interview-time SURFACE_MULTIUSER audience apply (pre-init ordering) + applyDeclaredAudienceFromInterview; +3 #4897 harness usage clause documenting --source ID semantics; +11 #5488: SUBCOMMAND_HELP harness entry (gate on --help / -h / help) — CLI help line, cannot movesrc/core/minions/worker.ts 1764 ratchet grandfathered at merge (grew past the 1500 cap on master, #4170); grown v0.46.11.0 five-issue wave; security: durable queued authority and confined filesystem dispatch; typed readiness, configuration-blocked lifecycle and bounded release; post-validation readiness publication and confirmed isolated-execution stop evidence; latch typed lock-renewal faults before generic retrysrc/commands/sources.ts 2013 ratchet +6 fix wave 5 #5409: mirror-readonly/mirror-writable dispatch, help rows and the list --json mirror_read_only field (body in sources-mirror.ts); grown v0.46.22.0 phone wave: github source kind (#4104); +129 v0.47 gmail-loops: google source-kind flags + vault preflight + duplicate-account warn + access-mode validation; +8 set-path dispatch + help rows (#4739 — command body peeled to sources-set-path.ts); +29 #4698 adoption: --calendar-id flag + duplicate-account warn scoped to overlapping services; #5105: trusted writer administration route; company handlers and receipt status wiring; parsing stays in dedicated modules; canonical reconciliation: +5 engine-free sibling-command dispatch and help row, implementation remains in source-reconcile.ts; +4 fix wave 3 lane A: sources status connector recovery state and run counts (view lives in persistence/connector-status.ts); +3 fix wave 4 lane B: sources retry-held dispatch and help row (command body in sources-retry-held.ts) and the connector first-sync note on add; bodies in source-delete.ts and sources-set-path.ts)-src/core/link-extraction.ts 2144 ratchet grown v0.46.26.0 megawave: link-aware timeline split + delimiter-outside-links (#3957 #4062 #3737); +37 wave-k #3908 reimpl: isCrossSourceLinksEnabled config ladder; +10 wave #4277: parseTimelineEntries skips generated backlink receipts; +17 #4855: latin-fold in normalizeBasename + dir-hint step tries both slug grammars; +17: #4855 Latin stroke-letter fold; +5: #4873 ./-relative markdown links kept as live references; +34 wave review: `../y.md` sibling links resolve on the DB path + folded bare-wikilink grammar (#4873 class); +62 #4977: role-prior suppression in machine-list sections (rolePriorSuppressedRanges, EntityRef.index); +3 composed with #4985 (variation-selector strip) in the same wave; +4 #4995: markdown-link anchor strip + lowercase-candidate rationale comments; +6 pre-landing review: #4977 suppression on code-stripped content + truthful watermark/section-list comments; T2: source-qualified inference and atomic origin-scoped derived links; canonical attendance evidence, source-qualified orientation, strict attendee resolution, and relocated filesystem link scanner (command export preserved); +4: pack-owned fallback and ambiguous attendee guards Display-label attendance exclusion, indexed evidence membership, and bounded strict resolver caching; attendance-boundary review.; complete attendance resolution and fence-safe evidence traversal; frontmatter discovery, canonical basename admission and code-aware attendance comment masking; exclude inline HTML comment spans from admitted attendance ranges; +17 write-path wave: same-name rule for entity fuzzy matches + rename-alias fallback in makeResolver; +1 #5567: materialized marker ends bullet detail; +30 #5749: unique global-basename step before fuzzy and live keyword resolution (ResolveOptions, watermark note); #5765: bold **Attendees:** label accepted + LINK_EXTRACTOR_VERSION_TS bump note; +10 eval-wave N9-2/N9-3/N12-7: pack frontmatter mappings inherit FRONTMATTER_LINK_MAP direction, page-type-bound pack attended follows canonical attendance, LINK_EXTRACTOR_VERSION_TS bump note; +1 #5623: normalizeBasename collapses hyphen runs like slugifySegment (extractor watermark note)+src/core/link-extraction.ts 2155 ratchet grown v0.46.26.0 megawave: link-aware timeline split + delimiter-outside-links (#3957 #4062 #3737); +37 wave-k #3908 reimpl: isCrossSourceLinksEnabled config ladder; +10 wave #4277: parseTimelineEntries skips generated backlink receipts; +17 #4855: latin-fold in normalizeBasename + dir-hint step tries both slug grammars; +17: #4855 Latin stroke-letter fold; +5: #4873 ./-relative markdown links kept as live references; +34 wave review: `../y.md` sibling links resolve on the DB path + folded bare-wikilink grammar (#4873 class); +62 #4977: role-prior suppression in machine-list sections (rolePriorSuppressedRanges, EntityRef.index); +3 composed with #4985 (variation-selector strip) in the same wave; +4 #4995: markdown-link anchor strip + lowercase-candidate rationale comments; +6 pre-landing review: #4977 suppression on code-stripped content + truthful watermark/section-list comments; T2: source-qualified inference and atomic origin-scoped derived links; canonical attendance evidence, source-qualified orientation, strict attendee resolution, and relocated filesystem link scanner (command export preserved); +4: pack-owned fallback and ambiguous attendee guards Display-label attendance exclusion, indexed evidence membership, and bounded strict resolver caching; attendance-boundary review.; complete attendance resolution and fence-safe evidence traversal; frontmatter discovery, canonical basename admission and code-aware attendance comment masking; exclude inline HTML comment spans from admitted attendance ranges; +17 write-path wave: same-name rule for entity fuzzy matches + rename-alias fallback in makeResolver; +1 #5567: materialized marker ends bullet detail; +30 #5749: unique global-basename step before fuzzy and live keyword resolution (ResolveOptions, watermark note); #5765: bold **Attendees:** label accepted + LINK_EXTRACTOR_VERSION_TS bump note; +10 eval-wave N9-2/N9-3/N12-7: pack frontmatter mappings inherit FRONTMATTER_LINK_MAP direction, page-type-bound pack attended follows canonical attendance, LINK_EXTRACTOR_VERSION_TS bump note; +1 #5623: normalizeBasename collapses hyphen runs like slugifySegment (extractor watermark note); +11 #5562: parseTimelineEntries accepts dated ### headings (FS-extractor parity)src/core/embedding-migration.ts 1525 ratchet new row: crossed 1500 in v0.46.25.0 fix waves (#4305 #4306 chunk-model truth helpers); retired provider integration removed; safety wave: canonical projection readiness and fact-aware completion; file configuration publication retains lease-row locks; +8 transactional retained-vector rebuildability checks before destructive migration boundaries; archived eligibility: source-locked reconciliation and live/current smoke revalidation; +2 #5680: authorization_generation field and its carry-forward on same-target re-apply (settle idempotency); +10 #5226: plan carries chunks_to_restamp beside chunks_to_embedsrc/core/github-source.ts 1530 ratchet new row: crossed the 1500 unlisted cap in v0.46.23.0 review fix wave (scope-state gating, client hardening, symlink containment); merged reliability/shared-skills source integration; managed sweep lease wrapper; fix wave 3 lane A: config parser peeled to github-source-config.ts (-47), +account pin wiring and pinned-installation refreshsrc/commands/hook.ts 1903 ratchet cathedral-5 heartbeat extraction offsets part of the BrainBench-seam growth; grown v0.46.26.0 megawave hooks-ipc (#4245); +108 monthly backup check: banner + gated session-start note + detached spawn (backup/status-file readers); +28 ship-review egress hardening: per-harness capture dispatch (capture-spec), memorable gate + receipt + relay block, fail-closed unscanned/newest-guess skips; +79 ambient-writeback WP4: hookStop bank step (gate -> bankWritebackTurn -> IPC flush; gate/bank logic live in core/facts + corpus-segments); +41 adversarial fix wave: wide-tail retry when the 128KB window misses the user turn, by-design heartbeat outcome classes, source-in-name banking; +11 #5413 session-end skips claude-cli self-transcripts; +11 #5701: hook lanes pass allowOversize so a long session reaches the bounded tail readdiff --git a/src/core/link-extraction.ts b/src/core/link-extraction.tsindex 2f2dd1a421..37d1c34a0b 100644--- a/src/core/link-extraction.ts+++ b/src/core/link-extraction.ts@@ -1895,6 +1895,9 @@ const TIMELINE_LINE_RE = /^\s*(?:-\s*)?\*\*(\d{4}-\d{2}-\d{2})\*\*\s*([|\-–—// ASCII dates were never timeline entries and must stay that way.const TIMELINE_LINE_RE_CN = /^\s*(?:-\s*)?(?:\*\*)?(\d{4})年(\d{1,2})月(\d{1,2})日?(?:\*\*)?\s*([|\-–—]+)\s*(.+?)\s*$/;+// `### YYYY-MM-DD — summary` headings, as the FS extractor (timeline-extract.ts Format 2) accepts.+const TIMELINE_HEADING_RE = /^\s*###\s+(\d{4}-\d{2}-\d{2})\s*[\-–—]+\s*(.+?)\s*$/;+/*** Parse timeline entries from content. Looks at:* - The full content (most pages have a top-level "## Timeline" heading).@@ -1910,23 +1913,32 @@ export function parseTimelineEntries(content: string): TimelineCandidate[] {let i = 0;while (i < lines.length) {- // Try English format first, then Chinese- const m = TIMELINE_LINE_RE.exec(lines[i]);+ const headingMatch = TIMELINE_HEADING_RE.exec(lines[i]);+ const isHeadingEntry = headingMatch !== null;let date: string;let summary: string;- let separator: string;- if (m) {- date = m[1];- separator = m[2];- summary = m[3].trim();+ let separator = '';++ if (headingMatch) {+ date = headingMatch[1];+ summary = headingMatch[2].trim();} else {- const cm = TIMELINE_LINE_RE_CN.exec(lines[i]);- if (!cm) { i++; continue; }- // Normalize Chinese date to YYYY-MM-DD- date = `${cm[1]}-${cm[2].padStart(2, '0')}-${cm[3].padStart(2, '0')}`;- separator = cm[4];- summary = cm[5].trim();+ // Try English bullet format first, then Chinese.+ const lineMatch = TIMELINE_LINE_RE.exec(lines[i]);+ if (lineMatch) {+ date = lineMatch[1];+ separator = lineMatch[2];+ summary = lineMatch[3].trim();+ } else {+ const chineseMatch = TIMELINE_LINE_RE_CN.exec(lines[i]);+ if (!chineseMatch) { i++; continue; }+ // Normalize Chinese date to YYYY-MM-DD.+ date = `${chineseMatch[1]}-${chineseMatch[2].padStart(2, '0')}-${chineseMatch[3].padStart(2, '0')}`;+ separator = chineseMatch[4];+ summary = chineseMatch[5].trim();+ }}+if (!isValidDate(date) || summary.length === 0) { i++; continue; }// #4277: backlink materialization historically wrote dated navigation// receipts such as `- **2026-06-13** | Referenced in [Acme](../companies/acme.md)`.@@ -1942,7 +1954,7 @@ export function parseTimelineEntries(content: string): TimelineCandidate[] {// shape; split them exactly like the FS extractor (extractTimelineFromContent// Format 1) so FS- and DB-extracted rows share one (source, summary) shape// and the DB dedup index collapses re-extractions instead of duplicating.- // Dash-separated bullets (`- **DATE** - text`) are one summary — no split.+ // Dash-separated bullets and dated headings are one summary — no split.let source = 'markdown';if (separator.includes('|')) {const at = findTimelineSourceDelimiter(summary);@@ -1956,7 +1968,7 @@ export function parseTimelineEntries(content: string): TimelineCandidate[] {let j = i + 1;while (j < lines.length) {const next = lines[j];- if (TIMELINE_LINE_RE.test(next)) break;+ if (TIMELINE_LINE_RE.test(next) || TIMELINE_HEADING_RE.test(next)) break;if (/^#{1,6}\s/.test(next) || isMaterializedMarkerLine(next)) break; // #5567: a marker opens the next bulletif (next.trim().length === 0 && detailLines.length === 0) {// skip leading blank line; if we hit a blank after detail content@@ -1965,8 +1977,7 @@ export function parseTimelineEntries(content: string): TimelineCandidate[] {continue;}if (next.trim().length === 0 && detailLines.length > 0) break;- // Indented continuation lines are detail; flush-left non-list lines too.- if (/^\s+/.test(next) || (!next.startsWith('-') && !next.startsWith('*') && !next.startsWith('#'))) {+ if (isHeadingEntry || /^\s+/.test(next) || (!next.startsWith('-') && !next.startsWith('*') && !next.startsWith('#'))) {detailLines.push(next.trim());j++;continue;diff --git a/test/link-extraction.test.ts b/test/link-extraction.test.tsindex 1195b283a2..fcb3d4c306 100644--- a/test/link-extraction.test.ts+++ b/test/link-extraction.test.ts@@ -952,6 +952,44 @@ describe('parseTimelineEntries', () => {expect(entries.map(e => e.date)).toEqual(['2026-01-15', '2026-02-20', '2026-03-10']);});+ test('parses dated level-three headings used by compiled wiki pages', () => {+ const entries = parseTimelineEntries(+ '### 2026-08-07 — Example orchestration event',+ );+ expect(entries).toEqual([{+ date: '2026-08-07',+ summary: 'Example orchestration event',+ detail: '',+ source: 'markdown',+ }]);+ });++ test('captures body text below a dated heading as timeline detail', () => {+ const content = `## Evidence updates++### 2026-08-07 — Example orchestration event+- Evidence: [[sources/example-source|Example source]]+- Interpretation: bounded implementation lanes.++### 2026-08-08 — Follow-up review+Review completed.`;+ const entries = parseTimelineEntries(content);+ expect(entries).toEqual([+ {+ date: '2026-08-07',+ summary: 'Example orchestration event',+ detail: '- Evidence: [[sources/example-source|Example source]] - Interpretation: bounded implementation lanes.',+ source: 'markdown',+ },+ {+ date: '2026-08-08',+ summary: 'Follow-up review',+ detail: 'Review completed.',+ source: 'markdown',+ },+ ]);+ });+test('skips invalid dates (2026-13-45)', () => {const entries = parseTimelineEntries('- **2026-13-45** | Bad date');expect(entries.length).toBe(0);