Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(links): frontmatter paths with spaces, capitals or dots resolve by exact slug (#6701, #6623)
time-attack864d22d8bebf
diff --git a/docs/architecture/key-files/graph-and-facts.md b/docs/architecture/key-files/graph-and-facts.mdindex 47292c3507..1bdbcfb816 100644--- a/docs/architecture/key-files/graph-and-facts.md+++ b/docs/architecture/key-files/graph-and-facts.md@@ -105,7 +105,7 @@ rejection of serve-only flags before a brain opens.- `src/core/fence-shared.ts` — shared pipe-table primitives for the `## Takes` (`takes-fence.ts`) and `## Facts` (`facts-fence.ts`) fences: `parseRowCells`, `isSeparatorRow`, `stripStrikethrough`, `parseStringCell`, `escapeFenceCell`, and the rewrite guard (#6385 R12) `assertFenceRewritable` / `FenceRewriteRefusal` that `upsertFactRow`, `upsertTakeRow`, `supersedeRow` and `mergePhantomFenceRows` throw when their input fence parses with warnings (the message names the fence only; the warnings, which embed row text, stay on the error). `parseRowCells` is escape-aware: `\|` stays inside its cell and decodes back to a literal `|` (exact inverse of `escapeFenceCell`), while any other backslash passes through verbatim so existing fence text (e.g. Windows paths) is byte-stable across a render → parse cycle. This matters because the fence is canonical and reconcile is wipe-and-reinsert — a pipe inside a cell shifting the column layout would corrupt every row behind it on the next reconcile. `escapeFenceCell` also encodes fence-marker text (`gbrain:facts:begin` and the three siblings) by lengthening the ampersand run before `#58;` (`gbrain:X` → `gbrain:X`, a literal `gbrain:X` → `gbrain&#58;X`), and `decodeFenceCell` (the decoder `parseRowCells` and `fence-repair/raw-rows.ts` share) removes exactly one level, so a claim that quotes a marker never becomes a live marker and a literal entity round-trips byte-identically; the lexical fail-closed privacy rule is unchanged. Pinned by the escape cases in `test/facts-fence.test.ts` + the full render → parse → reconcile round-trip in `test/e2e/facts-fence-reconcile-postgres.test.ts`.-- `src/core/link-extraction.ts` — shared library for the graph layer. `extractEntityRefs` (canonical) matches `[Name](../people/slug)` markdown links and Obsidian `[[people/slug|Name]]` wikilinks; `extractPageLinks`, `resolveMarkdownLinkSlug` (one markdown href resolved from a page exactly as `extractPageLinks` resolves it; the writer's link validator, `src/core/output/validators/link.ts`, uses it so its dangling-link verdict matches the graph), `inferLinkType` heuristics (attended/works_at/invested_in/founded/advises/source/mentions), `parseTimelineEntries`, `isAutoLinkEnabled`. In `inferLinkType` a per-edge verb counts only when it belongs to the link being typed (`attachedVerb`: a match with another link between it and this one, or written immediately before another link, is that link's), then precedence founded > invested_in > advises > works_at decides; `joined [X] as <role>` reads as works_at. `attendanceEvidenceRanges` accepts an `Attendees:`/`Participants:` line (plain or bold) and a `## Attendees`/`## Participants` link-list section (`Participants` since gbrain-evals N12-6, with a `LINK_EXTRACTOR_VERSION_TS` bump so meeting pages re-extract). Markdown links, bare-slug prose refs, and slash-shaped wikilinks match ANY dir-shaped path (`ANY_DIR_SEGMENT`), not a directory whitelist — nonexistent targets are dropped by the persist paths' page-existence checks (`resolveCandidateSources`, put_page's allSlugs filter, `addLinksBatch` INNER JOINs) and counted as `skippedMissingTarget` in the extract summaries; the `DIR_PATTERN` whitelist is only the typed fast-path for pass-2b wikilinks (non-whitelisted `[[dir/...]]` get an equivalent direct typed candidate in pass 2c, plus the flag-gated suffix rescue for non-exact matches). Used by extract.ts, operations.ts auto-link post-hook, and backlinks.ts. **Opt-in global-basename wikilink resolution** (default off): `WIKILINK_GENERIC_RE` catches bare `[[name]]` wikilinks outside `DIR_PATTERN` (third pass `2c` in `extractEntityRefs`); `EntityRef.needsResolution: true` tags refs from this pass (the ref's `slug` is the wikilink TARGET, `name` the optional display alias). `SlugResolver` gains optional `resolveBasenameMatches(name): Promise<string[]>` (multi-match by design — emits one edge per matching page). The single shared basename matcher is `buildBasenameIndex(slugs)` + `queryBasenameIndex(index, name)` + `normalizeBasename` (keys raw/lower/slugified tail, stable-sorted shorter-first then lexical), used by `makeResolver`, the FS `resolveBasenameMatchesFromSlugs`, AND the doctor check so they cannot drift. `makeResolver` step 1 falls back to `resolveSlugWithAlias` (rename aliases) for a slug-shaped value with no live page; its fuzzy title step and live keyword step (source-scoped) accept a person/company/fund/organization candidate only under `sameEntityName`, so a near-name stays unresolved instead of linking to a different entity (`test/entity-resolution-near-names.test.ts`). With `link_resolution.global_basename` on, `extractFrontmatterLinks` passes `resolve(name, dirHint, { globalBasename, selfSlug })`, and a unique basename match (self excluded) resolves right after the exact steps and before the fuzzy and live keyword steps, the exact-name-first precedence of `resolveEntitySlug` (#5749, `test/link-resolution-basename-before-search.test.ts`). `makeResolver(engine, {mode, sourceId})` builds the index lazily via `engine.getAllSlugs({sourceId})` — source-scoped so a bare `[[name]]` never resolves to a same-tail page in a different source. `extractPageLinks` gains `opts.globalBasename` (routes `needsResolution` refs through `resolveBasenameMatches` keyed on `ref.slug`, emits candidates tagged `linkType: 'wikilink_basename'` + `linkSource: 'wikilink-resolved'`, skips self-loops) and `opts.skipFrontmatter`. All three surfaces (FS extract, DB extract, `put_page` auto-link) tag provenance with `link_source='wikilink-resolved'`; `put_page` includes it in its reconcilable-edge set so stale basename edges are removed when the wikilink or the flag goes away. Exports `WIKILINK_BASENAME_LINK_TYPE` + `isGlobalBasenameEnabled(engine)` (resolution order: env `GBRAIN_LINK_RESOLUTION_GLOBAL_BASENAME` → DB config `link_resolution.global_basename` → default false). `gbrain doctor`'s `link_resolution_opportunity` check surfaces a paste-ready enable hint when ≥5 bare wikilinks would resolve AND ≥20% match. Migration v113 widens `links_link_source_check` to admit `'wikilink-resolved'`; v114 then opens it to any kebab-case provenance (`^[a-z][a-z0-9]*(-[a-z0-9]+)*$`, ≤64 chars) so external derivers register their own tag (e.g. `citation-graph`) without a migration. `LINK_EXTRACTOR_VERSION_TS` also lives here (bump like `CHUNKER_VERSION` to invalidate prior extract-stale stamps). Pinned by `test/link-extraction.test.ts`, `test/extract-fs.test.ts`, `test/doctor.test.ts`, `test/e2e/global-basename-pglite.test.ts`. #6191: `inferLinkType` applies `link-target-roles.ts` `targetTakesVerb` to every per-edge and fallback verb: `works_at` never types a link to a person, meeting, calendar-event, media, image or transcript target (unknown type: a `people/`, `meetings/`, `calendar/`, `cal/` slug), `founded`/`invested_in` never a temporal or media one; a refused verb keeps scanning lower-precedence rules, then `mentions` (`test/link-type-target-guard.test.ts`).+- `src/core/link-extraction.ts` — shared library for the graph layer. `extractEntityRefs` (canonical) matches `[Name](../people/slug)` markdown links and Obsidian `[[people/slug|Name]]` wikilinks; `extractPageLinks`, `resolveMarkdownLinkSlug` (one markdown href resolved from a page exactly as `extractPageLinks` resolves it; the writer's link validator, `src/core/output/validators/link.ts`, uses it so its dangling-link verdict matches the graph), `inferLinkType` heuristics (attended/works_at/invested_in/founded/advises/source/mentions), `parseTimelineEntries`, `isAutoLinkEnabled`. In `inferLinkType` a per-edge verb counts only when it belongs to the link being typed (`attachedVerb`: a match with another link between it and this one, or written immediately before another link, is that link's), then precedence founded > invested_in > advises > works_at decides; `joined [X] as <role>` reads as works_at. `attendanceEvidenceRanges` accepts an `Attendees:`/`Participants:` line (plain or bold) and a `## Attendees`/`## Participants` link-list section (`Participants` since gbrain-evals N12-6, with a `LINK_EXTRACTOR_VERSION_TS` bump so meeting pages re-extract). Markdown links, bare-slug prose refs, and slash-shaped wikilinks match ANY dir-shaped path (`ANY_DIR_SEGMENT`), not a directory whitelist — nonexistent targets are dropped by the persist paths' page-existence checks (`resolveCandidateSources`, put_page's allSlugs filter, `addLinksBatch` INNER JOINs) and counted as `skippedMissingTarget` in the extract summaries; the `DIR_PATTERN` whitelist is only the typed fast-path for pass-2b wikilinks (non-whitelisted `[[dir/...]]` get an equivalent direct typed candidate in pass 2c, plus the flag-gated suffix rescue for non-exact matches). Used by extract.ts, operations.ts auto-link post-hook, and backlinks.ts. **Opt-in global-basename wikilink resolution** (default off): `WIKILINK_GENERIC_RE` catches bare `[[name]]` wikilinks outside `DIR_PATTERN` (third pass `2c` in `extractEntityRefs`); `EntityRef.needsResolution: true` tags refs from this pass (the ref's `slug` is the wikilink TARGET, `name` the optional display alias). `SlugResolver` gains optional `resolveBasenameMatches(name): Promise<string[]>` (multi-match by design — emits one edge per matching page). The single shared basename matcher is `buildBasenameIndex(slugs)` + `queryBasenameIndex(index, name)` + `normalizeBasename` (keys raw/lower/slugified tail, stable-sorted shorter-first then lexical), used by `makeResolver`, the FS `resolveBasenameMatchesFromSlugs`, AND the doctor check so they cannot drift. `makeResolver` step 1 and the FS frontmatter resolver in `commands/extract.ts` try the same exact candidates from `exactSlugCandidates(value)` (a `/` value itself when it matches `EXACT_SLUG_SHAPE_RE`, dots allowed, then `slugifyPath(value)`, the slug sync mints for an Obsidian path with spaces, capitals or `.md`), and `makeResolver` falls back to `resolveSlugWithAlias` (rename aliases) for a candidate with no live page; its fuzzy title step and live keyword step (source-scoped) accept a person/company/fund/organization candidate only under `sameEntityName`, so a near-name stays unresolved instead of linking to a different entity (`test/entity-resolution-near-names.test.ts`). With `link_resolution.global_basename` on, `extractFrontmatterLinks` passes `resolve(name, dirHint, { globalBasename, selfSlug })`, and a unique basename match (self excluded) resolves right after the exact steps and before the fuzzy and live keyword steps, the exact-name-first precedence of `resolveEntitySlug` (#5749, `test/link-resolution-basename-before-search.test.ts`). `makeResolver(engine, {mode, sourceId})` builds the index lazily via `engine.getAllSlugs({sourceId})` — source-scoped so a bare `[[name]]` never resolves to a same-tail page in a different source. `extractPageLinks` gains `opts.globalBasename` (routes `needsResolution` refs through `resolveBasenameMatches` keyed on `ref.slug`, emits candidates tagged `linkType: 'wikilink_basename'` + `linkSource: 'wikilink-resolved'`, skips self-loops) and `opts.skipFrontmatter`. All three surfaces (FS extract, DB extract, `put_page` auto-link) tag provenance with `link_source='wikilink-resolved'`; `put_page` includes it in its reconcilable-edge set so stale basename edges are removed when the wikilink or the flag goes away. Exports `WIKILINK_BASENAME_LINK_TYPE` + `isGlobalBasenameEnabled(engine)` (resolution order: env `GBRAIN_LINK_RESOLUTION_GLOBAL_BASENAME` → DB config `link_resolution.global_basename` → default false). `gbrain doctor`'s `link_resolution_opportunity` check surfaces a paste-ready enable hint when ≥5 bare wikilinks would resolve AND ≥20% match. Migration v113 widens `links_link_source_check` to admit `'wikilink-resolved'`; v114 then opens it to any kebab-case provenance (`^[a-z][a-z0-9]*(-[a-z0-9]+)*$`, ≤64 chars) so external derivers register their own tag (e.g. `citation-graph`) without a migration. `LINK_EXTRACTOR_VERSION_TS` also lives here (bump like `CHUNKER_VERSION` to invalidate prior extract-stale stamps). Pinned by `test/link-extraction.test.ts`, `test/extract-fs.test.ts`, `test/doctor.test.ts`, `test/e2e/global-basename-pglite.test.ts`. #6191: `inferLinkType` applies `link-target-roles.ts` `targetTakesVerb` to every per-edge and fallback verb: `works_at` never types a link to a person, meeting, calendar-event, media, image or transcript target (unknown type: a `people/`, `meetings/`, `calendar/`, `cal/` slug), `founded`/`invested_in` never a temporal or media one; a refused verb keeps scanning lower-precedence rules, then `mentions` (`test/link-type-target-guard.test.ts`).- `src/core/timeline-dedup-repair.ts` — schema-drift self-heal for `idx_timeline_dedup`. A master-merge migration renumbering can leave a brain's version counter stamped past the index change while the index keeps an old shape — and every `addTimelineEntry` batch then fails its `ON CONFLICT` inference, silently breaking timeline writes brain-wide. The version counter can't detect this, so the repair is keyed off the actual index SHAPE. Canonical shape is `(page_id, date, md5(summary), source)` — md5-keyed (migration v138) because a raw long/incompressible summary would overflow the btree v4 row cap (~2704 bytes) and abort every timeline insert for that page; both engines' insert sites infer `ON CONFLICT` on the md5 tuple, so `EXPECTED_COLUMNS` MUST carry the md5 form (a raw-shape expectation would make the repair revert v138 on every migrate pass). `checkTimelineDedupIndex(engine)` returns `{tablePresent, indexPresent, columns, needsRepair}` (read-only; powers the `timeline_dedup_index` doctor check; the indexdef column parser is paren-depth-aware so `md5(summary)` — or any future expression column — parses as ONE column instead of flagging a correct index as drifted forever) and `repairTimelineDedupIndex(engine)` dedupes-then-rebuilds to the canonical shape (raw-summary grouping ⟺ md5 grouping modulo negligible collisions). `runMigrations` invokes the repair on every pass (including the no-pending early-return path); idempotent no-op when the index already matches. `gbrain apply-migrations --force-schema` triggers it on demand. Pinned by `test/timeline-dedup-repair.test.ts`.diff --git a/src/commands/extract.ts b/src/commands/extract.tsindex 88cb7383e6..039f394151 100644--- a/src/commands/extract.ts+++ b/src/commands/extract.ts@@ -60,7 +60,7 @@ import {attendanceEvidenceRanges, hasAttendanceEvidence, resolvedLinkCandidate, orientCanonicalAttendance, extractMarkdownLinks,extractFrontmatterLinks, isGlobalBasenameEnabled, isCrossSourceLinksEnabled,WIKILINK_BASENAME_LINK_TYPE,- buildBasenameIndex, queryBasenameIndex, stripCodeBlocks, normalizeBasename,+ buildBasenameIndex, queryBasenameIndex, stripCodeBlocks, normalizeBasename, exactSlugCandidates,parseInlineCitationTimelineEntries,type UnresolvedFrontmatterRef, type LinkCandidate, type LinkExtractionPack,} from '../core/link-extraction.ts';@@ -621,12 +621,11 @@ export async function extractLinksFromFile(async resolve(name: string, dirHint?: string | string[]): Promise<string | null> {if (!name) return null;const trimmed = name.trim();- // Same broadened slug-shape as makeResolver step 1: accepts- // digit-leading folders (`90-people/nicolai`) and nested paths.- // Exact Set membership guards it — no false positives.- if (/\//.test(trimmed) && /^[a-z0-9][a-z0-9/_-]*$/.test(trimmed) && allSlugs.has(trimmed)) {- return canonical(trimmed);- }+ // Same exact candidates as makeResolver step 1 (slug-shaped value,+ // then the slug sync mints for the path). Exact Set membership+ // guards it, so no false positives.+ const exact = exactSlugCandidates(trimmed).find(candidate => allSlugs.has(candidate));+ if (exact) return canonical(exact);const hints = Array.isArray(dirHint) ? dirHint : (dirHint ? [dirHint] : []);// Both slug grammars, as in makeResolver step 2 (#4855): the folded// basename form and the unfolded page-slug form sync mints.diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.tsindex eb0bb9fe0c..84c7a63ad3 100644--- a/src/core/link-extraction.ts+++ b/src/core/link-extraction.ts@@ -1670,6 +1670,25 @@ export function queryBasenameIndex(idx: Map<string, string[]>, name: string): streturn hit ? [...hit].sort(basenameSort) : [];}+/** A value already in page-slug shape: lowercase alnum start, then alnum, `/`, `_`, `.`, `-`. */+export const EXACT_SLUG_SHAPE_RE = /^[a-z0-9][a-z0-9/_.-]*$/;++/**+ * The exact page slugs a path-shaped frontmatter value can name, in lookup+ * order: the value itself when it is slug-shaped (`companies/acme.io`,+ * `90-people/nicolai`), then `slugifyPath(value)`, the slug sync mints for+ * that file path (`sources/voice/2030-01-01 1200 Call with Mira` →+ * `sources/voice/2030-01-01-1200-call-with-mira`; strips `.md`). Values+ * without `/` get none: bare names go through the dir-hint and fuzzy steps.+ */+export function exactSlugCandidates(value: string): string[] {+ if (!value.includes('/')) return [];+ const candidates = EXACT_SLUG_SHAPE_RE.test(value) ? [value] : [];+ const minted = slugifyPath(value);+ if (minted.includes('/') && !candidates.includes(minted)) candidates.push(minted);+ return candidates;+}+/*** Create a resolver scoped to a single extract run or single put_page call.*@@ -1774,29 +1793,23 @@ export function makeResolver(const hints = Array.isArray(dirHint) ? dirHint : (dirHint ? [dirHint] : []);- // Step 1: already a slug? Try an exact page lookup for any slug-shaped- // value (contains '/', slug charset). Broadened beyond the original- // single-segment lowercase-leading form (`^[a-z][a-z0-9-]*\/[a-z0-9]...`)- // to also accept digit-leading folders (`90-people/nicolai`,- // `01-trading/...`) and nested paths (`a/b/c`) — common in PARA-numbered- // vaults. This is an EXACT getPage match only — no fuzzy — so it never- // produces a false positive; a non-existent slug just falls through to- // the steps below. Fixes frontmatter `related: [[dir/slug]]` values- // (unwrapped by unwrapWikilink) that name a real page the strict regex- // could not reach and whose full-path fuzzy score is below threshold.- if (/\//.test(trimmed) && /^[a-z0-9][a-z0-9/_-]*$/.test(trimmed)) {+ // Step 1: a path-shaped value names its page exactly. Try each exact+ // candidate (the value itself when slug-shaped, then the slug sync+ // mints for that path), then a rename alias. Exact lookups only, so a+ // miss falls through to the steps below and never invents an edge.+ for (const candidate of exactSlugCandidates(trimmed)) {// Same source scope as the basename index above (#972): a wikilink in// source A must not resolve to a same-slug page in source B.- const page = await engine.getPage(trimmed, opts.sourceId ? { sourceId: opts.sourceId } : undefined); // gbrain-allow-unscoped-getpage: read-only wikilink resolution; unscoped-when-no-source is the documented single-source behavior+ const page = await engine.getPage(candidate, opts.sourceId ? { sourceId: opts.sourceId } : undefined); // gbrain-allow-unscoped-getpage: read-only wikilink resolution; unscoped-when-no-source is the documented single-source behaviorif (page) {- cache.set(cacheKey, trimmed);- return trimmed;+ cache.set(cacheKey, candidate);+ return candidate;}// A renamed page leaves `old -> new` in slug_aliases; links written// against the old slug keep resolving to the page that moved.if (typeof engine.resolveSlugWithAlias === 'function') {- const canonical = await engine.resolveSlugWithAlias(trimmed, opts.sourceId ?? 'default');- if (canonical !== trimmed && await engine.getPage(canonical, { sourceId: opts.sourceId ?? 'default' })) {+ const canonical = await engine.resolveSlugWithAlias(candidate, opts.sourceId ?? 'default');+ if (canonical !== candidate && await engine.getPage(canonical, { sourceId: opts.sourceId ?? 'default' })) {cache.set(cacheKey, canonical);return canonical;}diff --git a/test/extract.test.ts b/test/extract.test.tsindex 19e95dee91..d4498fbf0c 100644--- a/test/extract.test.ts+++ b/test/extract.test.ts@@ -140,6 +140,14 @@ describe('extractLinksFromFile', () => {expect(related[0].to_slug).toBe('90-people/nicolai');});+ it('frontmatter related: to an Obsidian path or a dotted slug resolves on the fs resolver (#6701, #6623)', async () => {+ const content = '---\nrelated: ["[[sources/voice/2030-01-01 1200 Call with Mira]]", companies/acme.io]\ntype: concept\n---\nContent.';+ const allSlugs = new Set(['wiki/note', 'sources/voice/2030-01-01-1200-call-with-mira', 'companies/acme.io']);+ const links = await extractLinksFromFile(content, 'wiki/note.md', allSlugs, { includeFrontmatter: true });+ expect(links.filter(l => l.link_type === 'related_to').map(l => l.to_slug).sort())+ .toEqual(['companies/acme.io', 'sources/voice/2030-01-01-1200-call-with-mira']);+ });+it('frontmatter extraction is default OFF (back-compat)', async () => {// Without includeFrontmatter, fs-source no longer auto-extracts frontmatter.// Matches db-source behavior. User opts in with --include-frontmatter flag.diff --git a/test/link-extraction.test.ts b/test/link-extraction.test.tsindex 7c92fc71f6..ccc07beefc 100644--- a/test/link-extraction.test.ts+++ b/test/link-extraction.test.ts@@ -1837,6 +1837,44 @@ describe('makeResolver — slug-path exact getPage (step 1 broadened)', () => {});});+describe('makeResolver — exact path candidates for dotted and Obsidian-path values (#6701, #6623)', () => {+ function countingEngine(slugs: string[]): BrainEngine & { fuzzyCalls: () => number } {+ const lookup = new Set(slugs);+ let fuzzy = 0;+ return {+ async getPage(slug: string) { return lookup.has(slug) ? { slug } as any : null; },+ async findByTitleFuzzy() { fuzzy++; return null; },+ async searchKeyword() { return []; },+ fuzzyCalls: () => fuzzy,+ } as unknown as BrainEngine & { fuzzyCalls: () => number };+ }++ test('an Obsidian path with spaces and capitals resolves to the slug sync minted, without fuzzy', async () => {+ const engine = countingEngine(['sources/voice/2030-01-01-1200-call-with-mira']);+ const r = makeResolver(engine);+ expect(await r.resolve('sources/voice/2030-01-01 1200 Call with Mira')).toBe('sources/voice/2030-01-01-1200-call-with-mira');+ expect(engine.fuzzyCalls()).toBe(0);+ });++ test('a path with a .md suffix resolves to its page', async () => {+ const r = makeResolver(countingEngine(['people/mira-example']));+ expect(await r.resolve('people/Mira Example.md')).toBe('people/mira-example');+ });++ test('a dotted slug resolves by exact lookup', async () => {+ const engine = countingEngine(['companies/acme.io', 'notes/v1.0.0']);+ const r = makeResolver(engine);+ expect(await r.resolve('companies/acme.io')).toBe('companies/acme.io');+ expect(await r.resolve('notes/v1.0.0')).toBe('notes/v1.0.0');+ expect(engine.fuzzyCalls()).toBe(0);+ });++ test('a path with no page still falls through to null', async () => {+ const r = makeResolver(countingEngine(['people/mira-example']));+ expect(await r.resolve('people/Someone Else')).toBeNull();+ });+});+describe('extractFrontmatterLinks — [[wikilink]] related: values (end-to-end)', () => {function fakeEngine(slugs: string[],diff --git a/test/wanted-links.test.ts b/test/wanted-links.test.tsindex b72dbc5729..5080e97038 100644--- a/test/wanted-links.test.ts+++ b/test/wanted-links.test.ts@@ -86,6 +86,31 @@ describe('unmanaged brain', () => {}, 120_000);});+describe('frontmatter links to dotted slugs and Obsidian paths (#6623, #6701)', () => {+ let engine: PGLiteEngine;+ beforeAll(async () => {+ engine = new PGLiteEngine();+ await engine.connect({});+ await engine.initSchema();+ }, 60_000);+ afterAll(async () => { await engine.disconnect(); }, 60_000);++ test('related: to existing targets creates the edges, leaves no wanted row and the sweep settles', async () => {+ // Titles are unrelated to the slugs so the title fuzzy step cannot mask the exact-slug step.+ const targets = ['requests/x/template-1.0.0-alignment', 'companies/acme.io', 'sources/voice/2030-01-01-1200-call-with-mira'];+ await engine.putPage(targets[0]!, { type: 'note', title: 'Roadmap notes', compiled_truth: 'Target.', timeline: '' });+ await engine.putPage(targets[1]!, { type: 'company', title: 'Example Co', compiled_truth: 'Target.', timeline: '' });+ await engine.putPage(targets[2]!, { type: 'note', title: 'Quarterly sync', compiled_truth: 'Target.', timeline: '' });+ await engine.putPage('products/p1', { type: 'note', title: 'P1', compiled_truth: 'P1.', timeline: '',+ frontmatter: { related: [targets[0], targets[1], 'sources/voice/2030-01-01 1200 Call with Mira'] } });+ await extractStaleFromDB(engine, { dryRun: false, jsonMode: true, quiet: true, catchUp: true, includeFrontmatter: true });+ expect(await engine.executeRaw(`SELECT t.slug AS target FROM links l JOIN pages f ON f.id=l.from_page_id JOIN pages t ON t.id=l.to_page_id+ WHERE f.slug='products/p1' ORDER BY t.slug`)).toEqual([...targets].sort().map(target => ({ target })));+ expect(await engine.executeRaw('SELECT target_ref FROM wanted_links')).toEqual([]);+ expect(await engine.countStalePagesForExtraction({ versionTs: LINK_EXTRACTOR_VERSION_TS })).toBe(0);+ }, 120_000);+});+describe('#6228/#6225 targets no page can have, unmanaged brain', () => {let engine: PGLiteEngine;beforeAll(async () => {