Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(graph): advisory, board, investor and observer roles are never employment

garrytan970c3088b6a9
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 06d8b7aa3b..ef1458d473 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 re
src/commands/bootstrap.ts 2134 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; +5 #5878: --refresh-skills dispatch and usage lines (logic in core/bootstrap/harness-skills.ts); +11 #5488: SUBCOMMAND_HELP harness entry (gate on --help / -h / help) — CLI help line, cannot move; +11 #4618 seat: --seat/--no-seat help lines and the runHooks parse (parse + notes live in core/bootstrap/hooks.ts parseSeatFlags)
src/core/minions/worker.ts 1774 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 retry; +9 Lane D: JobDeferredError routing (deferJob helper); +1 spend authorization: runWithJobSpend import (both handler seams call it in place of the bare handler)
src/commands/sources.ts 2031 ratchet +5 #5988: sources status/retry-held help rows describe Git holds (help lines cannot move); +2 #5988: sources status <id> filter and Git held files (view in persistence/connector-status.ts); +5 F0: sources refresh dispatch and help rows (command body in sources-refresh.ts, protocol in persistence/worktree-refresh.ts); +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); +4 #5984: sources status shows the managed sync backlog (logic in persistence/sync-drain.ts); v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (2031 measured)
-src/core/link-extraction.ts 2208 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); +3 eval-wave N12-6: Participants accepted as attendance evidence + LINK_EXTRACTOR_VERSION_TS bump note; +22 P5 wanted pages: AuthoredRef on body link candidates; -33 lowered: P5 moved machine-section ranges to core/machine-sections.ts and stated relation types to core/line-grammar.ts; +7 P5: ExtractPageLinksOptions interface + wikilinkAuthoredRef helper (keeps extractPageLinks under the function-size limit); +32 P5: per-edge verb attachment (attachedVerb, VERB_RULES) + joined-as works_at + extractor watermark note; P5 x temporal-edges merge: verb attachment reads the verb at the link's own position in the window (excerptAnchor) and the within-page dedup (now dedupeCandidates) drops a mention of a target the page also links with a typed edge; links joined only by commas/conjunctions share the verb before the first (coordinated)
+src/core/link-extraction.ts 2211 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); +3 eval-wave N12-6: Participants accepted as attendance evidence + LINK_EXTRACTOR_VERSION_TS bump note; +22 P5 wanted pages: AuthoredRef on body link candidates; -33 lowered: P5 moved machine-section ranges to core/machine-sections.ts and stated relation types to core/line-grammar.ts; +7 P5: ExtractPageLinksOptions interface + wikilinkAuthoredRef helper (keeps extractPageLinks under the function-size limit); +32 P5: per-edge verb attachment (attachedVerb, VERB_RULES) + joined-as works_at + extractor watermark note; P5 x temporal-edges merge: verb attachment reads the verb at the link's own position in the window (excerptAnchor) and the within-page dedup (now dedupeCandidates) drops a mention of a target the page also links with a typed edge; links joined only by commas/conjunctions share the verb before the first (coordinated); board roles (BOARD_RE, BOARD_AFTER_RE) resolve to invested_in for an investor page and advises otherwise, never works_at
src/core/embedding-migration.ts 1569 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_embed; +9 #5088: schema transition defers HNSW builds into the marker (deferred_ann_indexes), carry-forward on re-apply, verify blocks on pending/INVALID ANN indexes (build phase in embedding-ann-build.ts); +10 #5088: dim-pinned tables (query_cache, facts, and any later entry of TEXT_EMBEDDING_DIM_PINNED_TABLES) defer their HNSW through the same worklist (DEFERRED_ANN_TABLES, recordDeferredAnnIndexes); +25 wave 8 lane D1 #5885: takes in the dim-pinned column list, plan (takes_to_embed), status (takes_pending) and completion verify
src/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 refresh
src/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 read
diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.ts
index 7ad71f6629..531913f37e 100644
--- a/src/core/link-extraction.ts
+++ b/src/core/link-extraction.ts
@@ -733,7 +733,7 @@ export async function extractPageLinks(
}
const suppressPrior = idx !== undefined && idx >= 0 && inSuppressedRange(suppressedRanges, idx);
const legacy = inferLinkType(pageType, ctx, suppressPrior ? undefined : content, targetSlug,
- opts.targetType ? targetType ?? null : undefined, bodyReference && idx !== undefined && idx >= 0 ? excerptAnchor(content, idx, 240) : undefined);
+ opts.targetType ? targetType ?? null : undefined, bodyReference && idx !== undefined && idx >= 0 ? excerptAnchor(content, idx, 240) : undefined, content);
if (pack?.link_types.some(lt => lt.name === legacy && (lt.inference?.page_type || lt.inference?.target_type))) return { linkType: 'mentions' };
return { linkType: legacy };
};
@@ -1182,7 +1182,7 @@ const WORKS_AT_RE = /\b(?:joined\b[^.\n]{0,80}?\bas (?:an? |the )?(?:senior |sta
// Series A"), narrative verbs ("invests in", "investing in"), historical
// ("early investor in", "first check"), and portfolio framing ("portfolio
// company", "portfolio includes").
-const INVESTED_RE = /\b(?:invested in|invests in|investing in|invest in|investment in|investments in|backed by|funding from|funded by|raised from|led the (?:seed|Series|round|investment|round)|led .{0,30}(?:Series [A-Z]|seed|round|investment)|participated in (?:the )?(?:seed|Series|round)|wrote (?:a |the )?check|first check|early investor|portfolio (?:company|includes)|board seat (?:at|in|on)|term sheet for)\b/i;
+const INVESTED_RE = /\b(?:invested in|invests in|investing in|invest in|investment in|investments in|backed by|funding from|funded by|raised from|led the (?:seed|Series|round|investment|round)|led .{0,30}(?:Series [A-Z]|seed|round|investment)|participated in (?:the )?(?:seed|Series|round)|wrote (?:a |the )?check|first check|early investor|portfolio (?:company|includes)|board seat (?:at|in|on)|term sheet for|as an? (?:angel |early |lead )?investor|(?:board )?observer (?:at|to|of|on|with|seat)|as an? (?:board )?observer)\b/i;
// Founded patterns. Includes the noun-form "founder of" / "founders include"
// because that's how real prose identifies founders ("Carol Wilson is the
@@ -1202,7 +1202,7 @@ const FOUNDED_RE = /\b(?:founded|co-?founded|started the company|incorporated|fo
// narratives where the direct "advises" verb isn't used.
// - Advisor-qualified: "strategic advisor to|at", "technical advisor to|at",
// "security advisor to|at", "product advisor to|at", "industry advisor".
-const ADVISES_RE = /\b(?:advises|advised|advisor (?:to|at|for|of)|advisory (?:board|role|position|capacity|engagement|partnership|contract|relationship|work)|board advisor|on .{0,20} advisory board|joined .{0,20} advisory board|in an? advisory (?:capacity|role|position)|as an? (?:advisor|security advisor|technical advisor|strategic advisor|industry advisor|product advisor|board advisor|senior advisor)|(?:strategic|technical|security|product|industry|senior|board) advisor (?:to|at|for|of)|consults for|consulting role (?:at|with))\b/i;
+const ADVISES_RE = /\b(?:advises|advised|advising|advisor (?:to|at|for|of)|advisory (?:board|role|position|capacity|engagement|partnership|contract|relationship|work)|board advisor|on .{0,20} advisory board|joined .{0,20} advisory board|in an? advisory (?:capacity|role|position)|as an? (?:advisor|security advisor|technical advisor|strategic advisor|industry advisor|product advisor|board advisor|senior advisor)|(?:strategic|technical|security|product|industry|senior|board) advisor (?:to|at|for|of)|consults for|consulting role (?:at|with))\b/i;
// Chinese link type patterns for CJK entity mentions.
// NOTE: These patterns are Chinese-only (zh). Japanese and Korean link
@@ -1238,8 +1238,12 @@ const ADVISOR_ROLE_RE = /\b(?:full-time advisor|professional advisor|advises (?:
const EMPLOYEE_ROLE_RE = /\b(?:is an? (?:senior|staff|principal|lead|backend|frontend|full-?stack|ML|data|security|DevOps|platform)? ?engineer at|is an? (?:senior|staff|principal|lead)? ?(?:developer|designer|product manager|engineering manager|director|VP) (?:at|of)|holds? the (?:CTO|CEO|CFO|COO|CMO|CRO|VP) (?:role|position|seat|title) at|is the (?:CTO|CEO|CFO|COO|CMO|CRO) of|employee at|on the team at|works on .{0,30} at)\b/i;
+// Board roles ("joined the board of [X]", "board member at [X]", "[X]'s board") are never employment.
+// An investor's board seat is the investment; anyone else's is advisory (resolved in inferLinkType).
+const BOARD_RE = /\b(?:board (?:member|director|role|position) (?:of|at|for|with)|(?:join(?:s|ed|ing)?|serves? on|sits? on|named to|appointed to|elected to|seats? on) (?:the )?boards? (?:of|at)|board of directors (?:of|at)|(?:non-executive|independent) director (?:of|at)|chair(?:man|woman|person)? of the board (?:of|at)|as an? (?:board member|board director|independent director|non-executive director))\b/i;
+const BOARD_AFTER_RE = /(?:'s|’s) (?:advisory )?board\b/i;
const VERB_RULES: ReadonlyArray<readonly [RegExp, string]> = [
- [FOUNDED_RE, 'founded'], [INVESTED_RE, 'invested_in'], [ADVISES_RE, 'advises'], [WORKS_AT_RE, 'works_at'],
+ [FOUNDED_RE, 'founded'], [INVESTED_RE, 'invested_in'], [ADVISES_RE, 'advises'], [BOARD_RE, 'board'], [BOARD_AFTER_RE, 'board'], [WORKS_AT_RE, 'works_at'],
[ZH_FOUNDED_RE, 'founded'], [ZH_INVESTED_RE, 'invested_in'], [ZH_ADVISES_RE, 'advises'], [ZH_WORKS_AT_RE, 'works_at'], [ZH_CITED_RE, 'cited'],
];
@@ -1296,7 +1300,7 @@ function attachedVerb(context: string, targetSlug?: string, anchor?: number): st
* lists portfolio companies without repeating the investment verb each time
* ("Her current board seats reflect her portfolio: [Co A], [Co B], [Co C]").
*/
-export function inferLinkType(pageType: PageType, context: string, globalContext?: string, targetSlug?: string, targetType?: string | null, anchor?: number): string {
+export function inferLinkType(pageType: PageType, context: string, globalContext?: string, targetSlug?: string, targetType?: string | null, anchor?: number, pageText?: string): string {
if (pageType === 'media') {
return 'mentions';
}
@@ -1312,9 +1316,12 @@ export function inferLinkType(pageType: PageType, context: string, globalContext
// Per-edge verb rules, precedence founded > invested_in > advises > works_at
// (then the Chinese rules), over the verbs that belong to this link: in
// "works at [A] and also advises [B]", A is works_at and B advises.
+ // The role prior's timeline suppression does not apply here: whose board seat this is depends on the whole page.
+ const roleText = pageText ?? globalContext;
+ const board = () => (pageType === 'person' && roleText && PARTNER_ROLE_RE.test(roleText) ? 'invested_in' : 'advises');
const attached = attachedVerb(context, targetSlug, anchor);
- if (attached) return attached;
- if (attached === undefined) for (const [re, verb] of VERB_RULES) if (re.test(context)) return verb;
+ if (attached) return attached === 'board' ? board() : attached;
+ if (attached === undefined) for (const [re, verb] of VERB_RULES) if (re.test(context)) return verb === 'board' ? board() : verb;
// Page-role prior: only fires for person -> company links. Concept pages
// about VC topics naturally contain "venture capital" in their text, but
// their company refs are mentions, not investments. Partner pages mentioning
diff --git a/src/core/link-temporal-evidence.ts b/src/core/link-temporal-evidence.ts
index 53c7c3af6c..1461eed7db 100644
--- a/src/core/link-temporal-evidence.ts
+++ b/src/core/link-temporal-evidence.ts
@@ -68,10 +68,16 @@ const NOT_PERFECT = String.raw`(?<!\b(?:has|have|'s|’s)\s+(?:\w+\s+)?)`;
/** Advisory, board and investor roles ("took an advisory role with", "became an advisor at") are not jobs. */
const NOT_EMPLOYMENT_ROLE = String.raw`(?!(?:\w+\s+){0,2}?(?:advis\w*|board|investor|investing|investment|angel|observer)\b)`;
const OWNED = String.raw`(?:(?:her|his|their|my|the)\s+)?(?:time|stint|tenure|role|job|run)\s+`;
+/** A leave phrase whose object splits the phrasal verb: "wrapped their time up at", "handed their notice in at", "handed in her resignation at". */
+const LEAVE_OBJECT = String.raw`(?:(?:her|his|their|my|a|the)\s+)?(?:time|stint|tenure|role|job|run|things|it|notice|resignation)\s+`;
+const SPLIT_LEAVE = String.raw`(?:wrapped|wound|finished)\s+${LEAVE_OBJECT}up\s+(?:at|with)|(?:handed|turned|put)\s+(?:in\s+${LEAVE_OBJECT}|${LEAVE_OBJECT}in\s+)(?:at|to|with)|(?:gave|submitted|tendered)\s+${LEAVE_OBJECT}(?:at|to)`;
+/** "traded [A] for [B]": the exchange ends A; the "for" then starts B (see the natural-cue loop). */
+const EXCHANGE_BEFORE = /\b(?:traded|swapped|exchanged|ditched|dropped)\s*$/i;
+const EXCHANGE_AFTER = /^\s+for\s+(?:\[|the\s+\[|an?\s+\[)/i;
const EMPLOYMENT = {
- end: new RegExp(String.raw`\b(?:left|leaving|departed(?:\s+from)?|quit|resigned(?:\s+as\s+${ROLE})?(?:\s+from|\s+at)?|stepped\s+down(?:\s+as\s+${ROLE})?(?:\s+from|\s+at)?|stepped\s+away\s+from|moved\s+on\s+from|(?:moved|switched|transitioned|jumped)\s+(?:over\s+|out\s+)?from|(?:was\s+)?laid\s+off\s+(?:from|by|at)|(?:was\s+)?let\s+go\s+(?:from|by)|(?:was\s+)?fired\s+(?:from|by)|no\s+longer\s+(?:at|with|works\s+at|working\s+at)|exited|parted\s+ways\s+with|retired\s+from|(?:wrapped\s+up|finished|ended|concluded)\s+(?:${OWNED})?(?:at|with)|last\s+day\s+at|departure\s+from)\s*$`, 'i'),
- start: new RegExp(String.raw`\b(?:(?:re-?)?join(?:ed|s|ing)?(?:\s+${ROLE}(?:at|as))?|(?:was\s+)?hired\s+(?:by|at|as\s+${ROLE}at)|started\s+(?:at|with|working\s+(?:at|for)|(?:a\s+)?new\s+(?:role|job|position)\s+at)|became\s+${NOT_EMPLOYMENT_ROLE}${ROLE}(?:at|of)|promoted\s+to\s+${ROLE}(?:at|of)|signed\s+on\s+(?:at|with)|named\s+${ROLE}(?:at|of)|accepted\s+(?:an?\s+)?(?:offer|role|position|job)\s+(?:at|with|from)|took\s+(?:an?\s+|the\s+)?${NOT_EMPLOYMENT_ROLE}(?:\w+\s+){0,2}?(?:role|job|position)\s+(?:at|with)|came\s+(?:on\s+board|aboard)\s+(?:at|with)|went\s+to\s+work\s+(?:at|for)|returned\s+to)\s*$`, 'i'),
+ end: new RegExp(String.raw`\b(?:left|leaving|departed(?:\s+from)?|quit|resigned(?:\s+as\s+${ROLE})?(?:\s+from|\s+at)?|stepped\s+down(?:\s+as\s+${ROLE})?(?:\s+from|\s+at)?|stepped\s+away\s+from|moved\s+on\s+from|(?:moved|switched|transitioned|jumped)\s+(?:over\s+|out\s+)?from|(?:was\s+)?laid\s+off\s+(?:from|by|at)|(?:was\s+)?let\s+go\s+(?:from|by)|(?:was\s+)?fired\s+(?:from|by)|no\s+longer\s+(?:at|with|works\s+at|working\s+at)|exited|parted\s+ways\s+with|retired\s+from|(?:wrapped\s+up|finished|ended|concluded)\s+(?:${OWNED})?(?:at|with)|last\s+day\s+at|departure\s+from|${SPLIT_LEAVE}|step(?:ped|s|ping)?\s+back\s+from|walked\s+away\s+from|parted\s+company\s+with|called\s+it\s+quits\s+(?:at|with)|said\s+(?:(?:her|his|their|my)\s+)?goodbyes?\s+to|bid(?:\s+a)?\s+farewell\s+to)\s*$`, 'i'),
+ start: new RegExp(String.raw`\b(?:(?:re-?)?join(?:ed|s|ing)?(?:\s+${ROLE}(?:at|as))?|(?:was\s+)?hired\s+(?:by|at|as\s+${ROLE}at)|started\s+(?:at|with|working\s+(?:at|for)|(?:a\s+)?new\s+(?:role|job|position)\s+at)|became\s+${NOT_EMPLOYMENT_ROLE}${ROLE}(?:at|of)|promoted\s+to\s+${ROLE}(?:at|of)|signed\s+on\s+(?:at|with)|named\s+${ROLE}(?:at|of)|accepted\s+(?:an?\s+)?(?:offer|role|position|job)\s+(?:at|with|from)|took\s+(?:an?\s+|the\s+)?${NOT_EMPLOYMENT_ROLE}(?:\w+\s+){0,2}?(?:role|job|position)\s+(?:at|with)|came\s+(?:on\s+board|aboard)(?:\s+(?:at|with))?|got\s+on\s+board\s+(?:at|with)|(?:was\s+|got\s+|been\s+)?onboarded\s+(?:at|with|to|into|by)|hired\s+on\s+(?:at|with|by)|(?:was\s+)?brought\s+on(?:\s+board)?\s+(?:at|by|with)|joined\s+up\s+with|signed\s+up\s+(?:at|with)|began\s+(?:work(?:ing)?\s+)?(?:at|with|for)|went\s+to\s+(?:work\s+)?(?:at|for)|took\s+up\s+(?:an?\s+|the\s+)?${NOT_EMPLOYMENT_ROLE}(?:\w+\s+){0,2}?(?:role|job|post|position)\s+(?:at|with)|returned\s+to)\s*$`, 'i'),
past: new RegExp(String.raw`\b(?:previously(?:\s+worked)?\s+(?:at|with|for)|formerly(?:\s+${ROLE})?\s*(?:at|of|with)|former\s+${ROLE}(?:at|of|with)|ex-[\w-]+\s+(?:at|of)|used\s+to\s+work\s+(?:at|for)|${NOT_PERFECT}worked\s+(?:at|for|with)|${NOT_PERFECT}spent\s+(?:[\w-]+\s+){1,4}?(?:at|with)|(?:his|her|their|my)\s+(?:time|stint|tenure)\s+at|stint\s+at|was\s+${NOT_PAST_ROLE}${ROLE}(?:at|of)|alum(?:nus|na|ni)?\s+of)\s*$`, 'i'),
};
@@ -250,7 +256,7 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
if (r.link_type !== 'advises' || !ADVISORY_BOARD_AFTER.test(line.text.slice(ref.end))) continue;
kind = /\b(?:left|stepped\s+(?:down|off|away)\s+from|resigned\s+from)\s*$/i.test(window) ? 'end'
: /\b(?:(?:re-?)?joined|was\s+(?:added|named|appointed)\s+to)\s*$/i.test(window) ? 'start' : null;
- } else kind = cues.end.test(window) ? 'end'
+ } else kind = cues.end.test(window) || (EXCHANGE_BEFORE.test(window) && EXCHANGE_AFTER.test(line.text.slice(ref.end))) ? 'end'
: cues.start.test(window) || (prevEnded.has(r.link_type) && /^\s*(?:to|for)\s*$/i.test(between)) ? 'start' : null;
} else if (EVENT_START[r.link_type]?.test(window)) kind = 'start';
if (!kind) continue;
diff --git a/test/link-extraction.test.ts b/test/link-extraction.test.ts
index 4f1dd078a6..5122d6e5d9 100644
--- a/test/link-extraction.test.ts
+++ b/test/link-extraction.test.ts
@@ -764,12 +764,13 @@ describe('inferLinkType', () => {
expect(inferLinkType('person', 'Emily advises Acme on go-to-market.')).toBe('advises');
});
- test('"board member" alone is too ambiguous (investors also hold board seats) -> mentions', () => {
- // Tightened in v0.10.4 after BrainBench rich-prose surfaced that partner
- // bios ("She sits on the boards of [portfolio company]") were classified
- // as advises. Generic board language now requires explicit advisor/advise
- // rooting to count.
- expect(inferLinkType('person', 'Jane is a board member at Beta Health.')).toBe('mentions');
+ test('a board role is never employment: an investor\'s board seat is invested_in, anyone else\'s is advises', () => {
+ // v0.10.4 kept generic board language at mentions because partner bios
+ // ("She sits on the boards of [portfolio company]") read as advises. The
+ // page's investor role now decides instead, so a board line can never
+ // fall through to works_at (a board role is not a job).
+ expect(inferLinkType('person', 'Jane is a board member at Beta Health.')).toBe('advises');
+ expect(inferLinkType('person', 'She sits on the boards of Beta Health.', 'Jane is a partner at a venture fund.')).toBe('invested_in');
});
test('explicit advisor language -> advises', () => {
@@ -889,14 +890,11 @@ describe('inferLinkType', () => {
// ─── Regression guards: v0.10.5 expansions must not break tightened rules ───
- test('v0.10.5 regression: generic "board member" still resolves to mentions', () => {
- // This was the v0.10.4 tightening. The expanded ADVISES_RE must not
- // re-introduce the false-positive on partner bios.
- expect(inferLinkType('person', 'Jane is a board member at Beta Health.')).toBe('mentions');
- });
-
- test('v0.10.5 regression: "sits on the board" still mentions (not advises)', () => {
- expect(inferLinkType('person', 'She sits on the board of Acme.')).toBe('mentions');
+ test('v0.10.5 regression: a partner bio\'s board seats stay investments, never advises', () => {
+ // The v0.10.4 false positive: partner bios must not read as advisory.
+ const bio = 'Jane is a partner at a venture fund. She sits on the board of Acme.';
+ expect(inferLinkType('person', 'She sits on the board of Acme.', bio)).toBe('invested_in');
+ expect(inferLinkType('person', 'Jane is a board member at Beta Health.', bio)).toBe('invested_in');
});
test('v0.10.5 regression: "backs companies" still resolves to invested_in via partner prior', () => {
diff --git a/test/link-temporal-evidence.test.ts b/test/link-temporal-evidence.test.ts
index f433a9bc6f..d8cb4f779c 100644
--- a/test/link-temporal-evidence.test.ts
+++ b/test/link-temporal-evidence.test.ts
@@ -60,6 +60,33 @@ describe('dated timeline cues', () => {
expect(brief(ev.transitions)).toEqual(['acme-example:works_at:start:2024-06-01:timeline']);
});
+ const works = (line: string) => brief(derive('', `- **2024-05-01** | note — ${line}`,
+ [row('companies/acme-example', 'works_at'), row('companies/widget-co', 'works_at')]).transitions);
+ const A = '[Acme](companies/acme-example)', B = '[Widget](companies/widget-co)';
+
+ test('onboarding-style join verbs start employment', () => {
+ for (const line of [`was onboarded at ${A}`, `got onboarded with ${A}`, `came aboard ${A}`, `hired on at ${A}`, `was brought on at ${A}`,
+ `joined up with ${A}`, `began working at ${A}`, `took up a new post at ${A}`])
+ expect(works(line)).toEqual(['acme-example:works_at:start:2024-05-01:timeline']);
+ expect(works(`took up an advisory post at ${A}`)).toEqual([]);
+ });
+
+ test('leave phrases, including ones whose object splits the verb, end employment', () => {
+ for (const line of [`wrapped their time up at ${A}`, `wound things up at ${A}`, `handed in their notice at ${A}`, `handed their notice in at ${A}`,
+ `gave notice at ${A}`, `stepped back from ${A}`, `walked away from ${A}`, `said goodbye to ${A}`, `called it quits at ${A}`])
+ expect(works(line)).toEqual(['acme-example:works_at:end:2024-05-01:timeline']);
+ });
+
+ test('"traded [A] for [B]" ends A and starts B', () => {
+ for (const verb of ['traded', 'swapped', 'exchanged'])
+ expect(works(`${verb} ${A} for ${B}`)).toEqual(['acme-example:works_at:end:2024-05-01:timeline', 'widget-co:works_at:start:2024-05-01:timeline']);
+ });
+
+ test('look-alikes are not moves: traded shares, swapped notes, a stock, a board', () => {
+ for (const line of [`traded shares of ${A}`, `swapped notes with ${A}`, `traded ${A} stock`, `stepped back from the ${A} board`])
+ expect(works(line)).toEqual([]);
+ });
+
test('a meeting with a former employer is not a start', () => {
const ev = derive('', '- **2026-01-10** | cal — Coffee with the [Acme](companies/acme-example) team', [row('companies/acme-example', 'works_at')]);
expect(ev.transitions).toEqual([]);
diff --git a/test/link-type-attachment.test.ts b/test/link-type-attachment.test.ts
index 802c3526a4..fc16337ab3 100644
--- a/test/link-type-attachment.test.ts
+++ b/test/link-type-attachment.test.ts
@@ -3,7 +3,7 @@
* another link in the same context window does not type this link, and
* "joined [X] as <role>" reads as works_at. Pure, no engine.
*/
-import { expect, test } from 'bun:test';
+import { describe, expect, test } from 'bun:test';
import { extractPageLinks, inferLinkType, type SlugResolver } from '../src/core/link-extraction.ts';
const nullResolver: SlugResolver = { resolve: async () => null };
@@ -57,3 +57,26 @@ test('a verb right before a preposition and the next link belongs to that link:
const r = await extractPageLinks('people/alice-example', content, {}, 'person', { resolve: async () => null } as SlugResolver, {});
expect(r.candidates.map(c => [c.targetSlug, c.linkType])).toEqual([['companies/beta-example', 'works_at'], ['companies/acme-example', 'advises']]);
});
+
+describe('advisory, board, investor and observer roles are never employment', () => {
+ const typeOf = async (line: string, prose = '') => {
+ const r = await extractPageLinks('people/alice-example', `${prose}\n\n## Timeline\n\n- **2023-09-01** | note — ${line}`, {}, 'person', { resolve: async () => null } as SlugResolver, {});
+ return r.candidates.filter(c => c.targetSlug === 'companies/acme-example').map(c => c.linkType);
+ };
+ const advisory = ['Took an advisory role with [Acme](companies/acme-example)', 'Became a board member of [Acme](companies/acme-example)',
+ "Joined [Acme](companies/acme-example)'s board", 'Joined the board of [Acme](companies/acme-example)', 'Board director at [Acme](companies/acme-example)',
+ 'Took on a board role at [Acme](companies/acme-example)', 'Joined [Acme](companies/acme-example) as an independent director', 'Started advising [Acme](companies/acme-example)'];
+ test('a board or advisory role types advises, even on a page whose prose names a job elsewhere', async () => {
+ for (const line of advisory) {
+ expect(await typeOf(line)).toEqual(['advises']);
+ expect(await typeOf(line, 'Alice is the CTO of [Beta](companies/beta-example).')).toEqual(['advises']);
+ }
+ });
+ test('an observer or investor role types invested_in', async () => {
+ for (const line of ['Board observer at [Acme](companies/acme-example)', 'Became an observer at [Acme](companies/acme-example)', 'Joined [Acme](companies/acme-example) as an angel investor'])
+ expect(await typeOf(line)).toEqual(['invested_in']);
+ });
+ test("an investor's board seat is the investment", async () => {
+ expect(await typeOf('Joined the board of [Acme](companies/acme-example)', 'Alice is a general partner at a venture fund.')).toEqual(['invested_in']);
+ });
+});