Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

typing unit U5 (dev rework): the restart guard ignores share-trade lines

garrytan5a9efd087abc
diff --git a/src/core/link-temporal-evidence.ts b/src/core/link-temporal-evidence.ts
index fea4f6d0da..a041d88d8f 100644
--- a/src/core/link-temporal-evidence.ts
+++ b/src/core/link-temporal-evidence.ts
@@ -25,7 +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, U5_EXCHANGE_AFTER, U5_EXCHANGE_BEFORE, U5_LEAVE, U6_START, nonEmploymentRoleOnPage, typingUnitEnabled } from './link-typing-units.ts';
+import { GUARD_IGNORED_LINE, U4_NOT_EMPLOYMENT_ROLE, U5_EXCHANGE_AFTER, U5_EXCHANGE_BEFORE, U5_LEAVE, U6_START, nonEmploymentRoleOnPage, typingUnitEnabled } from './link-typing-units.ts';
export interface OwnedRow {
from_slug: string;
@@ -247,6 +247,7 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
if (hasExplicit(line.text)) continue;
const refs = referencesIn(line.text);
const eventLine = EVENT_CONTEXT.test(line.text.replace(/\[[^\]\n]*\]\([^)\s]*\)|\[\[[^\]\n]*\]\]/g, ' '));
+ const tradeLine = GUARD_IGNORED_LINE.test(line.text.replace(/\[[^\]\n]*\]\([^)\s]*\)|\[\[[^\]\n]*\]\]/g, ' '));
let prevEnd = 0;
let prevEnded = new Set<string>();
for (const ref of refs) {
@@ -276,7 +277,7 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
else if (prevEnded.has(r.link_type) && /^\s*(?:to|for)\s*$/i.test(between)) { kind = 'start'; rule = 'cue.after_end.to_for'; }
} else if (EVENT_START[r.link_type]?.test(window)) { kind = 'start'; rule = `cue.event.${r.link_type}`; }
if (!kind) {
- if (cues && !qualified && r.link_type === 'works_at') uncued.push({ target: other(r), date: line.date });
+ if (cues && !qualified && r.link_type === 'works_at' && !tradeLine) uncued.push({ target: other(r), date: line.date });
continue;
}
if (rule.startsWith('unit.u5.') || rule.startsWith('unit.u6.')) {
diff --git a/src/core/link-typing-units.ts b/src/core/link-typing-units.ts
index ab13b8c723..7202c2b121 100644
--- a/src/core/link-typing-units.ts
+++ b/src/core/link-typing-units.ts
@@ -230,6 +230,8 @@ const LEAVE_OBJECT = String.raw`(?:(?:her|his|their|my|a|the)\s+)?(?:time|stint|
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)`;
const IDIOM_LEAVE = String.raw`packed\s+(?:it|things)\s+in\s+(?:at|with)|call(?:ed|s|ing)?\s+(?:it\s+)?time\s+(?:on|at)|call(?:ed|s|ing)?\s+it\s+a\s+day\s+(?:at|with)|call(?:ed|s|ing)?\s+it\s+quits\s+(?:at|with)|bow(?:ed|s|ing)?\s+out\s+(?:of|from|at)|walk(?:ed|s|ing)?\s+(?:out\s+(?:of|on)|away\s+from)|thr(?:ew|ows|owing)\s+in\s+the\s+towel\s+(?:at|with)|hand(?:ed|s|ing)?\s+in\s+(?:(?:her|his|their|my)\s+)?(?:badge|keys|laptop)\s+(?:at|to)|clear(?:ed|s|ing)?\s+out\s+(?:(?:her|his|their|my)\s+)?desk\s+at|gave\s+up\s+(?:(?:her|his|their|my)\s+)?(?:job|role|post|position|seat)\s+at|left\s+(?:(?:her|his|their|my)\s+)?(?:job|role|post|position)\s+at|step(?:ped|s|ping)?\s+back\s+from|parted\s+company\s+with|said\s+(?:(?:her|his|their|my)\s+)?goodbyes?\s+to|bid(?:\s+a)?\s+farewell\s+to|exit\s+from`;
export const U5_LEAVE = new RegExp(String.raw`\b(?:${SPLIT_LEAVE}|${IDIOM_LEAVE})\s*$`, 'i');
+/** Lines about trading an organization's equity ("Traded shares of [X]") say nothing about a job: the U5 and U6 guards ignore them. */
+export const GUARD_IGNORED_LINE = /\b(?:shares?|stock|equity|stake|stock\s+options|secondary\s+market|bought|sold)\b/i;
/** U5: "traded [A] for [B]" ends A (the "for" then starts B). "Traded shares of [A]" is not an exchange. */
export const U5_EXCHANGE_BEFORE = /\b(?:traded|swapped|exchanged|ditched|dropped)\s*$/i;
export const U5_EXCHANGE_AFTER = /^\s+for\s+(?:\[|the\s+\[|an?\s+\[)/i;
diff --git a/test/helpers/typing-unit-examples.ts b/test/helpers/typing-unit-examples.ts
index e342483266..7d60c2577a 100644
--- a/test/helpers/typing-unit-examples.ts
+++ b/test/helpers/typing-unit-examples.ts
@@ -305,6 +305,10 @@ const U5: TypingExample[] = [
: { types: ['mentions', 'works_at'],
transitions: units.has('U5') ? ['works_at start 2015-01-02', 'works_at end 2018-03-04', 'works_at start 2020-08-11'] : ['works_at start 2015-01-02', 'works_at start 2020-08-11'],
live: { type: 'works_at', at: { '2019-01-01': !units.has('U5'), today: true } } } },
+ { id: 'u5-leave-not-guarded-by-share-trade', unit: 'U5', target: ACME,
+ content: JOB([`**2019-03-04** | linkedin — Called it a day at ${L(ACME)} and packed it in`, `**2021-07-15** | note — Traded shares of ${L(ACME)} on the secondary market`]),
+ off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] },
+ on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02', 'works_at end 2019-03-04'], live: { type: 'works_at', at: { today: false } } } },
{ id: 'u5-leave-not-guarded-by-event-mention', unit: 'U5', target: ACME,
content: JOB([`**2019-03-04** | linkedin — Parted company with ${L(ACME)}`, `**2021-05-06** | event — Back at ${L(ACME)} for the alumni dinner`]),
off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] },