Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
typing unit U2: ordinary job roles, a post-pass where inference returned mentions
garrytan1b5a85697a77
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex f586547a2e..ec447bd205 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -31,7 +31,7 @@ src/core/minions/handlers/subagent.ts 1925 ratchet merged: master v131 settle resrc/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 2042 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); +11 W-B4: sources shared-skills dispatch, its --help guard and help rows, and the shared_skills field/lines in sources status (body in sources-shared-skills.ts, view in shared-skills/source-opt-out.ts)-src/core/link-extraction.ts 2349 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; +109 Q2 Track C: stable verb-rule ids, traceLinkType/explainLinkType (reasons for every typing decision), per-occurrence typer hoisted out of extractPageLinks (makeTypeFor); unit logic lives in core/link-typing-units.ts; +25 Q2 Track C: typing-unit verb rules and vetoes in attachedVerb/traceLinkType, validity stints in explainLinkType; +4 U3: board-seat rule split out of INVESTED_RE (same verb and precedence) and investor-prior/link offsets passed to unit vetoes+src/core/link-extraction.ts 2360 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; +109 Q2 Track C: stable verb-rule ids, traceLinkType/explainLinkType (reasons for every typing decision), per-occurrence typer hoisted out of extractPageLinks (makeTypeFor); unit logic lives in core/link-typing-units.ts; +25 Q2 Track C: typing-unit verb rules and vetoes in attachedVerb/traceLinkType, validity stints in explainLinkType; +4 U3: board-seat rule split out of INVESTED_RE (same verb and precedence) and investor-prior/link offsets passed to unit vetoes; +11 U2: locateLink shared by attachedVerb and the U2 post-pass in traceLinkTypesrc/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 verifysrc/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 1915 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; +12 core memory: user-prompt context-pressure notice wiring (logic in core/context/pressure.ts; session-start composition in core/context/session-start-output.ts)diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.tsindex efc983333d..28e4b4eab6 100644--- a/src/core/link-extraction.ts+++ b/src/core/link-extraction.ts@@ -29,7 +29,7 @@ import { isIdentityEntity, sameEntityName } from './entities/resolve.ts';import type { SchemaPackManifest } from './schema-pack/manifest-v1.ts';import { inferLinkTypeFromPack, frontmatterLinkTypeFromPack, ownsAttendanceInference } from './schema-pack/link-inference.ts';import { PageRegexBudget } from './schema-pack/redos-guard.ts';-import { UNIT_VERB_RULES, typingUnitEnabled, unitOfRule, unitVerbVeto, type TypingUnit } from './link-typing-units.ts';+import { UNIT_VERB_RULES, typingUnitEnabled, u2RoleRule, unitOfRule, unitVerbVeto, type TypingUnit } from './link-typing-units.ts';import { deriveTemporalEvidence, rowKey, type DerivedTransition } from './link-temporal-evidence.ts';import { buildRelationshipState, relationSemantics, type AssertionTense, type Stint } from './link-validity.ts';@@ -1311,14 +1311,21 @@ const coordinated = (between: string) => {};const GLOBAL_VERB_RULES = VERB_RULES.map(r => ({ ...r, re: new RegExp(r.re.source, `${r.re.flags.replace('g', '')}g`) }));interface Attachment { rule: VerbRule | null; suppressed: string[]; otherLink: boolean }-function attachedVerb(context: string, targetSlug?: string, anchor?: number, explain = false, investorPrior: () => boolean = () => false): Attachment | undefined {+/** The link to `targetSlug` in the window: [linkStart, linkEnd) of its markup, or undefined when it is not there. */+function locateLink(context: string, targetSlug?: string, anchor?: number): { linkStart: number; linkEnd: number } | undefined {const fromAnchor = targetSlug && anchor !== undefined ? context.indexOf(targetSlug, anchor) : -1;const at = fromAnchor >= 0 ? fromAnchor : targetSlug ? context.indexOf(targetSlug) : -1;if (at < 0) return undefined;const open = context.lastIndexOf('[', at);const linkStart = open >= 0 && at - open <= 120 ? (context[open - 1] === '[' ? open - 1 : open) : at;const close = context.slice(at).search(/\)|\]\]/);- const linkEnd = close >= 0 ? at + close + (context[at + close] === ')' ? 1 : 2) : at + targetSlug!.length;+ return { linkStart, linkEnd: close >= 0 ? at + close + (context[at + close] === ')' ? 1 : 2) : at + targetSlug!.length };+}++function attachedVerb(context: string, targetSlug?: string, anchor?: number, explain = false, investorPrior: () => boolean = () => false): Attachment | undefined {+ const located = locateLink(context, targetSlug, anchor);+ if (!located) return undefined;+ const { linkStart, linkEnd } = located;const suppressed: string[] = [];let rule: VerbRule | null = null;let otherLink = false;@@ -1427,6 +1434,10 @@ export function traceLinkType(pageType: PageType, context: string, globalContextif (ADVISOR_ROLE_RE.test(globalContext)) return out('advises', 'prior.advisor', attachment, suppressed, 'prior.advisor');if (EMPLOYEE_ROLE_RE.test(globalContext)) return out('works_at', 'prior.employee', attachment, suppressed, 'prior.employee');}+ // U2 post-pass: an ordinary job title on the link's own clause, only where everything above returned mentions.+ const located = pageType === 'person' && !targetSlug?.startsWith('people/') && targetType !== 'person' ? locateLink(context, targetSlug, anchor) : undefined;+ const u2 = located ? u2RoleRule(context, located.linkStart, located.linkEnd, targetSlug!, pageText ?? globalContext ?? context) : null;+ if (u2) return out('works_at', u2, attachment, suppressed);return out('mentions', null, attachment, suppressed);}diff --git a/src/core/link-typing-units.ts b/src/core/link-typing-units.tsindex 213cc701f3..87c0cc0174 100644--- a/src/core/link-typing-units.ts+++ b/src/core/link-typing-units.ts@@ -146,6 +146,67 @@ export function unitOfRule(id: string | null | undefined): TypingUnit | null {return m ? (`U${m[1]}` as TypingUnit) : null;}+// ─── U2: ordinary job roles (post-pass where inference returned `mentions`) ──++/** Ordinary job titles. Board, advisory, investor and observer roles are deliberately absent. */+const EMPLOYMENT_ROLE = String.raw`(?:(?:senior|staff|principal|lead|junior|associate|founding|chief|executive|managing|general|deputy|interim|acting) )*(?:software engineer|engineer|developer|designer|programmer|architect|scientist|data scientist|researcher|analyst|product manager|engineering manager|program manager|project manager|manager|director|officer|counsel|marketer|recruiter|strategist|editor|producer|accountant|controller|specialist|coordinator|administrator|technician|intern|president|chief of staff|cto|ceo|coo|cfo|cmo|cro|cpo|vp|svp|evp|vp (?:of )?[a-z]+|vice president of [a-z]+|head of [a-z]+(?: [a-z]+)?|(?:product|design|engineering|tech|team|growth|sales|marketing|data|research) lead)`;+const EMPLOYMENT_AREA = String.raw`(?:engineering|product|design|sales|marketing|growth|operations|ops|finance|people|hr|recruiting|platform|infrastructure|infra|data|security|research|partnerships|business development|customer success|support|legal|strategy|the [a-z]+ team)`;+/** "<role> for/at/with [X]" introduced as the subject's own role: "is CTO for", "now designer for", "New role: CTO for". */+const U2_ROLE_BEFORE = new RegExp(String.raw`(?:^\s*|\b(?:is|was|as|now|currently|became|becomes|serves as|served as|serving as|works as|worked as|working as)\s+|[:—–-]\s*)(?:an?\s+|the\s+)?${EMPLOYMENT_ROLE}\s+(?:at|for|with)\s+(?:the\s+)?$`, 'i');+/** "led engineering at [X]". */+const U2_LED_AREA = new RegExp(String.raw`\b(?:led|leads|leading|ran|runs|running|managed|manages|managing|headed|heads|heading|oversaw|oversees|overseeing|owned|owns)\s+${EMPLOYMENT_AREA}\s+(?:at|for)\s+(?:the\s+)?$`, 'i');+/** A join, move or start right before the link: "signed on with [X]", "moved to [X]", "a new chapter at [X]". */+const U2_JOIN_BEFORE = /\b(?:re-?joined|joined|joins|joining|signed\s+(?:back\s+)?on\s+(?:with|at)|moved(?:\s+over)?\s+to|moves\s+to|switched\s+to|went\s+to|returned\s+to|came\s+back\s+to|(?:was\s+)?hired\s+(?:by|at|on\s+at)|started\s+(?:at|with)|start(?:ed|ing|s)?\s+(?:a\s+|her\s+|his\s+|their\s+|my\s+)?new\s+chapter\s+(?:at|with)|new\s+chapter\s+(?:at|with)|began\s+(?:working\s+)?(?:at|with|for)|onboarded\s+(?:at|with)|first\s+day\s+at|now\s+at|came\s+(?:on\s+board|aboard)\s+(?:at|with))\s+(?:the\s+)?$/i;+/** "… [X] as <role>" right after the link (with a join, move or start before it). */+const U2_AS_ROLE_AFTER = new RegExp(String.raw`^\s*,?\s*as\s+(?:an?\s+|the\s+|its\s+|their\s+)?${EMPLOYMENT_ROLE}\b`, 'i');+/** "[X] (<role>)": the whole parenthetical is an ordinary job title. */+const U2_PAREN_ROLE_AFTER = new RegExp(String.raw`^\s*\((?:as\s+)?(?:an?\s+|the\s+)?${EMPLOYMENT_ROLE}(?:\s+(?:for|of|at|in)\s+[^()]{1,40})?\)`, 'i');+/** Clauses that do not state the subject's own current or past job. */+const U2_NOT_A_JOB = /\b(?:not|never|no\s+longer|declined|turned\s+down|rejected|passed\s+on|didn't|did\s+not|isn't|wasn't|won't|nor|will|would|could|might|may|plans?\s+to|planning\s+to|hopes?\s+to|wants?\s+to|considering|considered|interview(?:ed|ing|s)?|offered|offer|candidate|applied|applying|in\s+talks|rumou?red|expected\s+to|set\s+to|about\s+to|if|board|observer|investor|investing|angel|advis\w*|non-executive|independent\s+director|trustee|chair(?:man|woman|person)?)\b/i;++/** Inside a dated timeline entry ("- **2021-03-04** | …"): the entry marker comes after the last line break or heading. */+function inDatedEntry(context: string, linkStart: number): boolean {+ const before = context.slice(Math.max(0, linkStart - 240), linkStart);+ const entry = [...before.matchAll(/(?:^|\s)[-*]\s+\*\*\d{4}-\d{2}-\d{2}\*\*|(?:^|\s)#{3}\s+\d{4}-\d{2}-\d{2}/g)].pop();+ if (!entry) return false;+ return !/\n|\s#{1,6}\s/.test(before.slice((entry.index ?? 0) + entry[0].length));+}++/** The page names some organization in an advisory, board or investor role ("Took an advisory role with [X]"). */+const ROLE_ELSEWHERE = /\b(?:advis\w*|board|observer|investor|investing|invested|angel|non-executive|trustee)\b/i;+const LINK_OPEN = /\[\[|\[[^\]\n]*\]\(/g;+function nonEmploymentRoleOnPage(pageText: string): boolean {+ for (const m of pageText.matchAll(LINK_OPEN)) if (ROLE_ELSEWHERE.test(clauseBefore(pageText, m.index ?? 0))) return true;+ return false;+}++/** How many dated timeline entries on the page mention `target`. */+const DATED_ENTRY_LINE = /^\s*(?:[-*]\s*\*\*\d{4}-\d{2}-\d{2}\*\*|#{3}\s+\d{4}-\d{2}-\d{2})/;+const datedMentions = (pageText: string, target: string) => pageText.split('\n').filter(l => DATED_ENTRY_LINE.test(l) && l.includes(target)).length;++/**+ * U2's rule id for a link at [linkStart, linkEnd) in `context`, or null. Reads only the link's own clause; runs after+ * the full existing inference returned `mentions` (traceLinkType), so it never overrides a verb, a stated type, a+ * pack rule or a role prior. Development rework (docs/eval/decisions/q2-parser-gaps/dev-units.md): it reads undated+ * lines only (a role on a dated join line with an unread leave kept former employers live), and it does not fire on a+ * page that names any organization in an advisory, board or investor role: there master's "became … at" / "took … role"+ * start cues read the advisory line as a new job, and a newly typed employer then meets that false start (E5 probe:+ * extra starts and wrong single-value closures). U4 removes that cause; U2 does not depend on it. Nor does it type an+ * organization that two or more dated entries mention: a later entry no cue reads may be the leave, and typing the+ * earlier role would keep a former employer live (stale summaries) and feed the single-value pass.+ */+export function u2RoleRule(context: string, linkStart: number, linkEnd: number, target: string, pageText: string): string | null {+ if (!typingUnitEnabled('U2')) return null;+ const before = clauseBefore(context, linkStart);+ const after = context.slice(linkEnd, linkEnd + 80);+ if (U2_NOT_A_JOB.test(before) || THIRD_PARTY.test(before) || inDatedEntry(context, linkStart)) return null;+ const rule = U2_ROLE_BEFORE.test(before) ? 'unit.u2.role_before'+ : U2_LED_AREA.test(before) ? 'unit.u2.led_area'+ : U2_PAREN_ROLE_AFTER.test(after) ? 'unit.u2.paren_role'+ : U2_JOIN_BEFORE.test(before) && U2_AS_ROLE_AFTER.test(after) ? 'unit.u2.join_as_role' : null;+ return rule && !nonEmploymentRoleOnPage(pageText) && datedMentions(pageText, target) < 2 ? rule : null;+}+// ─── Temporal cue hooks (link-temporal-evidence.ts) ─────────────────────/**diff --git a/test/helpers/typing-unit-examples.ts b/test/helpers/typing-unit-examples.tsindex f585f296cb..2952cc1282 100644--- a/test/helpers/typing-unit-examples.ts+++ b/test/helpers/typing-unit-examples.ts@@ -99,6 +99,84 @@ const U1: TypingExample[] = [off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2019-01-02'], live: { type: 'works_at', at: { today: true } } } },];+// ─── U2: ordinary job roles, post-pass on `mentions` (undated lines only) ─+const LONG_NAME = `[Acme ${'Holdings '.repeat(14)}](../${ACME}.md)`;+const U2: TypingExample[] = [+ { id: 'u2-role-for', unit: 'U2', target: ACME, content: page(`Alice is CTO for ${L(ACME)} these days.`),+ off: { types: ['mentions'] }, on: { types: ['works_at'], tense: { works_at: 'present' }, live: { type: 'works_at', at: { today: true } } } },+ { id: 'u2-works-as-role-for', unit: 'U2', target: ACME, content: page(`Alice works as a designer for ${L(ACME)}.`),+ off: { types: ['mentions'] }, on: { types: ['works_at'] } },+ { id: 'u2-led-area-at', unit: 'U2', target: ACME, content: page(`Alice led design at ${L(ACME)} for three years.`),+ off: { types: ['mentions'] }, on: { types: ['works_at'] } },+ { id: 'u2-now-at-paren', unit: 'U2', target: ACME, content: page(`Alice is now at ${L(ACME)} (product manager).`),+ off: { types: ['mentions'] }, on: { types: ['works_at'] } },+ { id: 'u2-signed-on-as', unit: 'U2', target: ACME, content: page(`Alice signed on with ${L(ACME)} as CTO and remains on the team.`),+ off: { types: ['mentions'] }, on: { types: ['works_at'] } },+ { id: 'u2-new-chapter-as', unit: 'U2', target: ACME, content: page(`Alice started a new chapter at ${L(ACME)} as designer and is still there.`),+ off: { types: ['mentions'] }, on: { types: ['works_at'] } },+ { id: 'u2-prose-typed-timeline-dates-it', unit: 'U2', target: ACME,+ content: page(`Alice signed on with ${L(ACME)} as data scientist.`, [`**2022-07-08** | linkedin — Signed on with ${L(ACME)} as data scientist`]),+ off: { types: ['mentions'], transitions: [] },+ on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2022-07-08'], live: { type: 'works_at', at: { '2022-01-01': false, today: true } } } },+ // Two or more dated entries about the organization: U2 does not type it (the later one may be a leave no cue reads).+ { id: 'u2-stale-summary-not-typed', unit: 'U2', target: ACME,+ content: page(`Alice works as a designer for ${L(ACME)}.`, [`**2014-01-02** | linkedin — Joined ${L(ACME)} (designer)`, `**2017-03-04** | linkedin — Closed the chapter at ${L(ACME)}`]),+ off: { types: ['mentions'], transitions: [] }, on: { types: ['mentions'], transitions: [] } },+ // Its cost: a rejoin the timeline dates is not typed from the prose role either.+ { id: 'u2-rejoin-not-typed', unit: 'U2', target: ACME,+ content: page(`Alice is designer for ${L(ACME)} again.`, [`**2014-01-02** | linkedin — Joined ${L(ACME)} as engineer`, `**2017-03-04** | linkedin — Left ${L(ACME)}`, `**2020-05-06** | linkedin — Returned to ${L(ACME)} as designer`]),+ off: { types: ['mentions'], transitions: [] }, on: { types: ['mentions'], transitions: [] } },+ // Dated entries are not read by U2: a former employer named only on a join line with an unread leave stays untyped.+ { id: 'u2-dated-join-not-read', unit: 'U2', target: ACME, content: page(`Alice A.`, [`**2022-07-08** | linkedin — Signed on with ${L(ACME)} as data scientist`]),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-dated-paren-move-not-read', unit: 'U2', target: ACME,+ content: page(`Alice A.`, [`**2016-02-03** | linkedin — Joined ${L(BETA)} as engineer`, `**2020-05-06** | linkedin — Moved from ${L(BETA)} to ${L(ACME)} (CTO)`]),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ // A page that names any organization in an advisory role is left alone (E5: the advisory line would start a job, and a+ // newly typed employer would then be closed by the single-value pass).+ { id: 'u2-employer-with-advisory-line-left-alone', unit: 'U2', target: ACME,+ content: page(`Alice is CTO for ${L(ACME)}.`, [`**2021-06-07** | linkedin — Took an advisory role with ${L(ACME)}`]),+ off: { types: ['advises', 'mentions'], transitions: [] }, on: { types: ['advises', 'mentions'], transitions: [] } },+ { id: 'u2-page-with-advisory-line-elsewhere-left-alone', unit: 'U2', target: ACME,+ content: page(`Alice is now at ${L(ACME)} (CTO). She also works at ${L(BETA)}.`, [`**2021-06-07** | note — Became an advisor at ${L(BETA)}`]),+ off: { types: ['mentions'], transitions: [] }, on: { types: ['mentions'], transitions: [] } },+ { id: 'u2-verb-typed-unchanged', unit: null, target: ACME, content: page(`Alice invested in ${L(ACME)} (CTO).`),+ off: { types: ['invested_in'] } },+ { id: 'u2-prior-unchanged', unit: null, target: ACME, content: page(`Alice is a seed investor. She met ${L(ACME)} (CTO).`),+ off: { types: ['invested_in'] } },+ { id: 'u2-third-party', unit: 'U2', target: ACME, content: page(`Alice's husband is CTO for ${L(ACME)}.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-third-party-friend-joined', unit: 'U2', target: ACME, content: page(`Alice's friend joined ${L(ACME)} as CTO.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-appositive-other-person', unit: 'U2', target: ACME, content: page(`Alice met Bob, CTO for ${L(ACME)}.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-negation', unit: 'U2', target: ACME, content: page(`Alice was never CTO for ${L(ACME)}.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-hypothetical', unit: 'U2', target: ACME, content: page(`Alice will join ${L(ACME)} as CTO next spring.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-interview', unit: 'U2', target: ACME, content: page(`Alice interviewed for CTO at ${L(ACME)}.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-board-director', unit: 'U2', target: ACME, content: page(`Alice is an independent director for ${L(ACME)}.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-observer-paren', unit: 'U2', target: ACME, content: page(`Alice joined ${L(ACME)} (board observer).`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-event-lookalike-speaker', unit: 'U2', target: ACME, content: page(`Alice spoke at ${L(ACME)} as keynote speaker.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-window-truncation', unit: 'U2', target: ACME, content: page(`Alice signed on with ${LONG_NAME} as CTO.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-repeated-target', unit: 'U2', target: ACME, content: page(`Alice is CTO for ${L(ACME)}. She first met ${L(ACME)} founders at a dinner in 2019.`),+ off: { types: ['mentions'] }, on: { types: ['mentions', 'works_at'] } },+ { id: 'u2-concurrent-roles-adviser-not-employment', unit: 'U1', target: BETA, content: page(`Alice is CTO for ${L(ACME)} and an adviser to ${L(BETA)}.`),+ off: { types: ['mentions'] }, on: { types: ['advises'] } },+ // Known cost of the advisory-page guard: a concurrent employer on a page with an advisory role stays untyped.+ { id: 'u2-concurrent-roles-employer', unit: 'U2', target: ACME, content: page(`Alice is CTO for ${L(ACME)} and an adviser to ${L(BETA)}.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+ { id: 'u2-concurrent-employers', unit: 'U2', target: ACME, content: page(`Alice is CTO for ${L(ACME)} and works at ${L(BETA)} on weekends.`),+ off: { types: ['mentions'] }, on: { types: ['works_at'] } },+ { id: 'u2-company-page', unit: 'U2', target: ACME, pageType: 'company', content: page(`Beta Corp is CTO for ${L(ACME)}.`),+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },+];+// ─── U3: board, observer and investor wording never types works_at ─────const INVESTOR_PAGE = 'Alice is a partner at a venture capital fund and a seed investor.';const U3: TypingExample[] = [@@ -183,4 +261,4 @@ const U4: TypingExample[] = [off: { types: ['advises'], transitions: ['advises start 2021-06-07'] } },];-export const EXAMPLES: TypingExample[] = [...U1, ...U3, ...U4];+export const EXAMPLES: TypingExample[] = [...U1, ...U2, ...U3, ...U4];