Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
typing unit U4: advisory, board and investor roles are not employment starts
garrytan0044223c7ae9
diff --git a/scripts/q2-typing-dev.ts b/scripts/q2-typing-dev.tsindex 6d70c1e074..d3ca174e35 100644--- a/scripts/q2-typing-dev.ts+++ b/scripts/q2-typing-dev.ts@@ -171,7 +171,7 @@ export function compareDumps(base: Dump, arm: Dump) {const key = (p: PersonDump) => `${p.seed}:${p.slug}`;const armBy = new Map(arm.people.map(p => [key(p), p]));const steals: Array<Row> = []; const gains: Array<Row> = []; const moves: Array<Row> = [];- const newWrong: string[] = []; const fixed: string[] = []; const missing: string[] = [];+ const newWrong: string[] = []; const removedWrong: string[] = []; const fixed: string[] = []; const missing: string[] = [];const liveLost: string[] = []; const liveGained: string[] = [];for (const b of base.people) {const a = armBy.get(key(b));@@ -182,6 +182,7 @@ export function compareDumps(base: Dump, arm: Dump) {for (const t of at) if (!bt.has(t) && !gold.has(t)) newWrong.push(`s${b.seed} ${t}`);for (const t of at) if (!bt.has(t) && gold.has(t)) fixed.push(`s${b.seed} ${t}`);for (const t of bt) if (!at.has(t) && gold.has(t)) missing.push(`s${b.seed} ${t}`);+ for (const t of bt) if (!at.has(t) && !gold.has(t)) removedWrong.push(`s${b.seed} ${t}`);const targets = new Set([...b.links, ...a.links].map(x => x.to));for (const to of targets) {const tb = typesOf(b, to); const ta = typesOf(a, to);@@ -204,7 +205,7 @@ export function compareDumps(base: Dump, arm: Dump) {if (!lb.has(c) && la.has(c)) liveGained.push(`s${b.seed} ${b.slug} -> ${c}`);}}- return { steals, gains, moves, newWrong, fixed, missing, liveLost, liveGained };+ return { steals, gains, moves, newWrong, removedWrong, fixed, missing, liveLost, liveGained };}function printCompare(base: Dump, arm: Dump, json: boolean): void {@@ -214,11 +215,12 @@ function printCompare(base: Dump, arm: Dump, json: boolean): void {...rows.map(r => `| ${r.seed} | ${r.subject} | ${r.target} | ${r.ledger} | ${r.gold} | ${r.base} | ${r.arm} |`)].join('\n') : '(none)';const list = (xs: string[]) => xs.length ? xs.map(x => `- ${x}`).join('\n') : '(none)';console.log(`base ${base.root} units ${base.units?.join(',') ?? 'default'}; arm ${arm.root} units ${arm.units?.join(',') ?? 'default'}; phrasing ${arm.phrasing}`);- console.log(`steals ${c.steals.length}, gains ${c.gains.length}, other moves ${c.moves.length}, new wrong transitions ${c.newWrong.length}, fixed ${c.fixed.length}, missing correct ${c.missing.length}, live lost ${c.liveLost.length}, live gained ${c.liveGained.length}`);+ console.log(`steals ${c.steals.length}, gains ${c.gains.length}, other moves ${c.moves.length}, new wrong transitions ${c.newWrong.length}, wrong removed ${c.removedWrong.length}, fixed ${c.fixed.length}, missing correct ${c.missing.length}, live lost ${c.liveLost.length}, live gained ${c.liveGained.length}`);console.log(`\n### Type steals (base matched the ledger, arm does not)\n${table(c.steals)}`);console.log(`\n### Type gains\n${table(c.gains)}`);console.log(`\n### Other type moves\n${table(c.moves)}`);console.log(`\n### New wrong transitions\n${list(c.newWrong)}`);+ console.log(`\n### Wrong transitions removed\n${list(c.removedWrong)}`);console.log(`\n### Fixed transitions\n${list(c.fixed)}`);console.log(`\n### Missing correct transitions\n${list(c.missing)}`);console.log(`\n### Current employers lost from the live read\n${list(c.liveLost)}`);diff --git a/src/core/link-temporal-evidence.ts b/src/core/link-temporal-evidence.tsindex 5e64a5deae..7f65ec4be1 100644--- a/src/core/link-temporal-evidence.ts+++ b/src/core/link-temporal-evidence.ts@@ -25,6 +25,7 @@ import {type TransitionKind, type TransitionProducer,} from './link-validity.ts';import { KNOWN_LINK_TYPES } from './search/relational-intent.ts';+import { U4_NOT_EMPLOYMENT_ROLE, typingUnitEnabled } from './link-typing-units.ts';export interface OwnedRow {from_slug: string;@@ -67,9 +68,12 @@ const NOT_PAST_ROLE = String.raw`(?!(?:promoted|hired|named|appointed|made|electconst NOT_PERFECT = String.raw`(?<!\b(?:has|have|'s|’s)\s+(?:\w+\s+)?)`;const OWNED = String.raw`(?:(?:her|his|their|my|the)\s+)?(?:time|stint|tenure|role|job|run)\s+`;+/** Employment start cues; `notJob` guards the "became … at/of" and "took … role at" forms (U4). */+const employmentStart = (notJob: string) => 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+${notJob}${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+)?${notJob}(?:\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');+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+${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+)?(?:\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'),+ start: employmentStart(''),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'),};@@ -105,9 +109,12 @@ const EVENT_START: Record<string, RegExp> = {founded: /\b(?:founded|co-?founded|started)\s*$/i,};+/** U4 (src/core/link-typing-units.ts): the employment cues with advisory, board and investor roles kept out of the start cue. */+const EMPLOYMENT_U4 = { ...EMPLOYMENT, start: employmentStart(U4_NOT_EMPLOYMENT_ROLE) };+type CueSet = { end: RegExp; start: RegExp; past: RegExp };function cuesFor(linkType: string): CueSet | null {- if (linkType === 'works_at') return EMPLOYMENT;+ if (linkType === 'works_at') return typingUnitEnabled('U4') ? EMPLOYMENT_U4 : EMPLOYMENT;if (linkType === 'advises') return ADVISORY;if (linkType === 'yc_partner') return PARTNER;return null;diff --git a/src/core/link-typing-units.ts b/src/core/link-typing-units.tsindex 08fb98ddc5..213cc701f3 100644--- a/src/core/link-typing-units.ts+++ b/src/core/link-typing-units.ts@@ -145,3 +145,11 @@ export function unitOfRule(id: string | null | undefined): TypingUnit | null {const m = /^unit\.u(\d)\./.exec(id ?? '');return m ? (`U${m[1]}` as TypingUnit) : null;}++// ─── Temporal cue hooks (link-temporal-evidence.ts) ─────────────────────++/**+ * U4: advisory, board and investor roles are not jobs. Inserted into the "became … at/of" and "took … role at"+ * employment start cues, so "Became an advisor at [X]" or "Took an advisory role with [X]" never starts a works_at stint.+ */+export const U4_NOT_EMPLOYMENT_ROLE = String.raw`(?!(?:\w+\s+){0,2}?(?:advis\w*|board|investor|investing|investment|angel|observer|non-executive|independent|trustee)\b)`;diff --git a/test/helpers/typing-unit-examples.ts b/test/helpers/typing-unit-examples.tsindex 01df6ecc56..f585f296cb 100644--- a/test/helpers/typing-unit-examples.ts+++ b/test/helpers/typing-unit-examples.ts@@ -23,8 +23,8 @@ export interface Expectation {export interface TypingExample {id: string;- /** The unit this example measures, or null for a control that no unit may change. */- unit: TypingUnit | null;+ /** The unit (or units, for a joint effect) this example measures, or null for a control that no unit may change. */+ unit: TypingUnit | TypingUnit[] | null;target: string;content: string;pageType?: 'person' | 'company' | 'concept';@@ -41,7 +41,8 @@ export const page = (prose: string, timeline: string[] = []) =>timeline.length ? `${prose}\n\n## Timeline\n\n${timeline.map(l => `- ${l}`).join('\n')}\n` : `${prose}\n`;export function expected(ex: TypingExample, units: ReadonlySet<TypingUnit>): Expectation {- if (!ex.unit || !ex.on || !units.has(ex.unit)) return ex.off;+ const mine = ex.unit === null ? [] : Array.isArray(ex.unit) ? ex.unit : [ex.unit];+ if (!ex.on || !mine.some(u => units.has(u))) return ex.off;return typeof ex.on === 'function' ? ex.on(units) : ex.on;}@@ -141,10 +142,45 @@ const U3: TypingExample[] = [content: page(`Alice is VP engineering at ${L(BETA)} and a board director at ${L(ACME)}.`), off: { types: ['works_at'] }, on: { types: ['mentions'] } },// The set-F interaction: a board line is the only statement about the company. Master reads a job that starts on// the board date; U4 alone keeps the job but drops its start (live on every date); U3 removes the job.- { id: 'u34-board-only-target', unit: 'U3', target: ACME,+ { id: 'u34-board-only-target', unit: ['U3', 'U4'], target: ACME,content: page(`Alice works at ${L(BETA)} as engineer.`, [`**2022-03-04** | note — Became a board director at ${L(ACME)}`]),off: { types: ['works_at'], transitions: ['works_at start 2022-03-04'], live: { type: 'works_at', at: { '2020-01-01': false, today: true } } },- on: { types: ['mentions'], transitions: [] } },+ on: units => units.has('U3') ? { types: ['mentions'], transitions: [] }+ : { types: ['works_at'], transitions: [], live: { type: 'works_at', at: { '2020-01-01': true, today: true } } } },];-export const EXAMPLES: TypingExample[] = [...U1, ...U3];+// ─── U4: advisory, board and investor roles are not employment starts ──+const E5_PAGE = (line: string, target = ACME) => page(`Alice works at ${L(ACME)} as CTO.`,+ [`**2015-01-02** | linkedin — Joined ${L(ACME)} as CTO`, `**2021-06-07** | ${line.replace('{X}', L(target))}`]);+const U4: TypingExample[] = [+ { id: 'u4-became-advisor-at-employer', unit: 'U4', target: ACME, content: E5_PAGE('note — Became an advisor at {X}'),+ off: { types: ['advises', 'mentions', 'works_at'], transitions: ['works_at start 2015-01-02', 'works_at start 2021-06-07', 'advises start 2021-06-07'] },+ on: { types: ['advises', 'mentions', 'works_at'], transitions: ['works_at start 2015-01-02', 'advises start 2021-06-07'],+ live: { type: 'works_at', at: { '2016-01-01': true, today: true } } } },+ { id: 'u4-took-advisory-role-with-employer', unit: 'U4', target: ACME, content: E5_PAGE('linkedin — Took an advisory role with {X}'),+ off: { types: ['advises', 'mentions', 'works_at'], transitions: ['works_at start 2015-01-02', 'works_at start 2021-06-07'] },+ on: { types: ['advises', 'mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] } },+ // U3 retypes the board line (mentions) but leaves its start cue; U4 drops the start (the job, stated in prose, stays undated).+ { id: 'u4-took-board-role-at-other-employer', unit: ['U3', 'U4'], target: BETA,+ content: page(`Alice works at ${L(ACME)} as CTO. She also works at ${L(BETA)}.`, [`**2021-06-07** | linkedin — Took a board role at ${L(BETA)}`]),+ off: { types: ['works_at'], transitions: ['works_at start 2021-06-07'], live: { type: 'works_at', at: { '2020-01-01': false, today: true } } },+ on: units => ({ types: units.has('U3') ? ['mentions', 'works_at'] : ['works_at'], transitions: units.has('U4') ? [] : ['works_at start 2021-06-07'],+ live: { type: 'works_at', at: { '2020-01-01': units.has('U4'), today: true } } }) },+ { id: 'u4-became-board-observer-of', unit: 'U4', target: BETA,+ content: page(`Alice works at ${L(BETA)}.`, [`**2021-06-07** | note — Became a board observer of ${L(BETA)}`]),+ off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2021-06-07'] }, on: { types: ['mentions', 'works_at'], transitions: [] } },+ { id: 'u4-became-cto-still-starts', unit: null, target: ACME, content: E5_PAGE('linkedin — Became CTO at {X}'),+ off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02', 'works_at start 2021-06-07'] } },+ { id: 'u4-took-new-role-still-starts', unit: null, target: BETA,+ content: page(`Alice works at ${L(BETA)}.`, [`**2021-06-07** | linkedin — Took a new engineering role at ${L(BETA)}`]),+ off: { types: ['works_at'], transitions: ['works_at start 2021-06-07'] } },+ // Unsupported, frozen: an advisory-services job title reads as an advisory role (no start with U4).+ { id: 'u4-advisory-services-job-lookalike', unit: 'U4', target: BETA,+ content: page(`Alice works at ${L(BETA)}.`, [`**2021-06-07** | linkedin — Became head of advisory services at ${L(BETA)}`]),+ off: { types: ['works_at'], transitions: ['works_at start 2021-06-07'] }, on: { types: ['works_at'], transitions: [] } },+ { id: 'u4-advisory-start-kept', unit: null, target: GLOBEX,+ content: page(`Alice works at ${L(ACME)}. She advises ${L(GLOBEX)}.`, [`**2021-06-07** | note — Became an advisor to ${L(GLOBEX)}`]),+ off: { types: ['advises'], transitions: ['advises start 2021-06-07'] } },+];++export const EXAMPLES: TypingExample[] = [...U1, ...U3, ...U4];