Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

typing unit U1: adviser wording, with local negation

garrytanc1b3233f9657
diff --git a/src/core/link-typing-units.ts b/src/core/link-typing-units.ts
index c909a42ace..30e889a571 100644
--- a/src/core/link-typing-units.ts
+++ b/src/core/link-typing-units.ts
@@ -61,9 +61,19 @@ export async function withTypingUnits<T>(units: Iterable<string>, fn: () => T |
/** A verb rule a unit adds. `id` is stable (`unit.u<N>.*`); it sits right after the core rule for the same verb. */
export interface UnitVerbRule { id: string; re: RegExp; verb: string; unit: TypingUnit; after: string }
+/**
+ * U1: the British `adviser` spelling and "advising [X]". A bare "adviser at [X]" is a job title ("financial adviser
+ * at [Bank]") and stays employment; a qualified advisory title ("technical adviser at [X]") advises.
+ */
+const U1_ADVISER_RE = /\b(?:adviser (?:to|for|of)|(?:strategic|technical|security|product|industry|senior|board|startup|outside|special|go-to-market) adviser (?:to|at|for|of)|(?:is|was|as|became|becomes|serves as|served as|serving as|now|currently|signed on as|brought on as|joined as) an? (?:\w+ )?adviser\b(?! at)|board of advisers|(?:now|currently|is|was|been|started|began|begun|also|still) advising|advising (?=\[))/i;
+
export const UNIT_VERB_RULES: readonly UnitVerbRule[] = [
+ { id: 'unit.u1.adviser', re: U1_ADVISER_RE, verb: 'advises', unit: 'U1', after: 'verb.advises' },
];
+/** Negation right before an advisory phrase ("not an advisor to", "no longer advises", "stopped advising"). */
+const U1_NEGATED_BEFORE = /\b(?:not|never|no\s+longer|nor|isn't|wasn't|aren't|hasn't|haven't|didn't|doesn't|stopped|ceased(?:\s+to\s+be)?|declined\s+to\s+(?:be|become)|turned\s+down\s+(?:being|becoming)?)\s+(?:(?:an?|the|her|his|their|any|longer|formally|officially|really|yet|be|been)\s+)*$/i;
+
/** The clause before `index`: back to a sentence, clause or timeline-entry break (at most 100 chars). */
export function clauseBefore(text: string, index: number): string {
const w = text.slice(Math.max(0, index - 100), index);
@@ -88,6 +98,10 @@ export interface VetoInput {
* match or rule. Returns the stable id of the veto (`unit.u<N>.*`).
*/
export function unitVerbVeto(v: VetoInput): string | null {
+ if (v.rule.verb === 'advises' && typingUnitEnabled('U1')) {
+ if (U1_NEGATED_BEFORE.test(v.context.slice(Math.max(0, v.start - 40), v.start))) return 'unit.u1.negated';
+ if (v.rule.id === 'unit.u1.adviser' && thirdPartyBefore(v.context, v.start)) return 'unit.u1.third_party';
+ }
return null;
}
diff --git a/test/helpers/typing-unit-examples.ts b/test/helpers/typing-unit-examples.ts
index 1503c201f7..c89c784c0c 100644
--- a/test/helpers/typing-unit-examples.ts
+++ b/test/helpers/typing-unit-examples.ts
@@ -59,4 +59,43 @@ export async function observe(ex: TypingExample, want: Expectation): Promise<Exp
return got;
}
-export const EXAMPLES: TypingExample[] = [];
+// ─── U1: adviser wording, with local negation ───────────────────────────
+const U1: TypingExample[] = [
+ { id: 'u1-is-an-adviser-to', unit: 'U1', target: ACME, content: page(`Alice is an adviser to ${L(ACME)}.`),
+ off: { types: ['mentions'] }, on: { types: ['advises'], tense: { advises: 'present' }, live: { type: 'advises', at: { today: true } } } },
+ { id: 'u1-serves-as-adviser', unit: 'U1', target: ACME, content: page(`Alice serves as an adviser to ${L(ACME)} on hiring.`),
+ off: { types: ['mentions'] }, on: { types: ['advises'] } },
+ { id: 'u1-now-advising', unit: 'U1', target: ACME, content: page(`Alice is now advising ${L(ACME)} on pricing.`),
+ off: { types: ['mentions'] }, on: { types: ['advises'] } },
+ { id: 'u1-advising-link', unit: 'U1', target: ACME, content: page(`Alice works at ${L(BETA)}.`, [`**2025-02-03** | note — Advising ${L(ACME)} on its launch`]),
+ off: { types: ['mentions'] }, on: { types: ['advises'] } },
+ { id: 'u1-technical-adviser-at', unit: 'U1', target: ACME, content: page(`Alice is a technical adviser at ${L(ACME)}.`),
+ off: { types: ['mentions'] }, on: { types: ['advises'] } },
+ { id: 'u1-job-title-financial-adviser-at', unit: 'U1', target: ACME, content: page(`Alice is a financial adviser at ${L(ACME)}.`),
+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },
+ { id: 'u1-negated-not-an-advisor', unit: 'U1', target: ACME, content: page(`Alice is not an advisor to ${L(ACME)}.`),
+ off: { types: ['advises'], tense: { advises: 'present' } }, on: { types: ['mentions'] } },
+ { id: 'u1-negated-no-longer-advises', unit: 'U1', target: ACME, content: page(`Alice no longer advises ${L(ACME)}.`),
+ off: { types: ['advises'], tense: { advises: 'past' }, live: { type: 'advises', at: { today: false } } }, on: { types: ['mentions'] } },
+ { id: 'u1-negated-not-an-adviser', unit: 'U1', target: ACME, content: page(`Alice is not an adviser to ${L(ACME)}.`),
+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },
+ { id: 'u1-stopped-advising', unit: 'U1', target: ACME, content: page(`Alice stopped advising ${L(ACME)} last year.`),
+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },
+ { id: 'u1-third-party-adviser', unit: 'U1', target: ACME, content: page(`Alice's husband is an adviser to ${L(ACME)}.`),
+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },
+ { id: 'u1-third-party-friend-advising', unit: 'U1', target: ACME, content: page(`Alice introduced a friend who is now advising ${L(ACME)}.`),
+ off: { types: ['mentions'] }, on: { types: ['mentions'] } },
+ { id: 'u1-concurrent-role', unit: 'U1', target: ACME, content: page(`Alice works at ${L(BETA)} and is an adviser to ${L(ACME)}.`),
+ off: { types: ['mentions'] }, on: { types: ['advises'] } },
+ { id: 'u1-concurrent-role-employer-kept', unit: null, target: BETA, content: page(`Alice works at ${L(BETA)} and is an adviser to ${L(ACME)}.`),
+ off: { types: ['works_at'], tense: { works_at: 'present' } } },
+ { id: 'u1-dated-start', unit: 'U1', target: ACME,
+ content: page(`Alice works at ${L(BETA)}. She is an adviser to ${L(ACME)}.`, [`**2024-05-06** | note — Began advising ${L(ACME)}`]),
+ off: { types: ['mentions'], transitions: [] },
+ on: { types: ['advises'], transitions: ['advises start 2024-05-06'], live: { type: 'advises', at: { '2024-01-01': false, today: true } } } },
+ { id: 'u1-employer-not-closed-by-advising-line', unit: null, target: BETA,
+ content: page(`Alice works at ${L(BETA)} as CTO.`, [`**2019-01-02** | linkedin — Joined ${L(BETA)} as CTO`, `**2024-05-06** | note — Now advising ${L(ACME)}`]),
+ off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2019-01-02'], live: { type: 'works_at', at: { today: true } } } },
+];
+
+export const EXAMPLES: TypingExample[] = [...U1];