Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

link typing: stable rule ids, explainLinkType, and the typing-unit switch (no behavior change)

garrytanefd1628eac6e
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 28fc737b55..ea54912161 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 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 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 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/link-extraction.ts 2320 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
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 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.ts
index 7ad71f6629..eab021eaa6 100644
--- a/src/core/link-extraction.ts
+++ b/src/core/link-extraction.ts
@@ -29,6 +29,9 @@ 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 type { TypingUnit } from './link-typing-units.ts';
+import { deriveTemporalEvidence, rowKey, type DerivedTransition } from './link-temporal-evidence.ts';
+import type { AssertionTense } from './link-validity.ts';
/**
* #3190: the slice of a schema-pack manifest link extraction consumes.
@@ -628,6 +631,8 @@ export interface ExtractPageLinksOptions {
lineGrammar?: { enabled?: boolean; allowUndeclaredTypes?: boolean };
targetType?: (slug: string, sourceId?: string) => string | undefined;
onResolvedFrontmatterTarget?: (slug: string) => void;
+ /** Receives every body-link typing decision with its reasons (explainLinkType, development reports). */
+ explain?: (e: LinkTypeExplanation) => void;
}
/** The authored reference of a wikilink at `idx`: a slug path, or a bare name keyed by its basename. */
@@ -645,6 +650,83 @@ export interface AuthoredRef {
targetSourceId?: string;
}
+/** One explained typing decision for a body link occurrence (explainLinkType, ExtractPageLinksOptions.explain). */
+export interface LinkTypeExplanation extends Omit<LinkTypeTrace, 'type'> {
+ target: string;
+ /** Offset of the link in the page content (-1 or undefined when unknown). */
+ index?: number;
+ context: string;
+ linkType: string;
+ /** A typed relation line's type (core/line-grammar.ts), which wins over everything below. */
+ stated: string | null;
+ /** The pack link type whose inference rule decided, if any. */
+ packRule: string | null;
+}
+
+type TypeFor = (ctx: string, targetSlug: string, idx?: number, sourceId?: string, bodyReference?: boolean) => Pick<LinkCandidate, 'linkType' | 'canonicalAttendance'>;
+
+/**
+ * The per-occurrence typer of extractPageLinks. Order: a typed relation line (stated type), then the active pack's
+ * inference rules, then meeting attendance, then inferLinkType's verb rules and role priors, then unit post-passes.
+ */
+function makeTypeFor(content: string, pageType: PageType, opts: ExtractPageLinksOptions, attendancePending: Set<number>, attendanceResolved: Set<number>): TypeFor {
+ // #3190: pack-aware verb inference. Pack-declared verbs win (page-type
+ // bindings, then pack regexes under the shared per-page ReDoS budget);
+ // the in-code inferLinkType stays the fall-through for everything the
+ // pack doesn't claim — matching the resolution order extract-ner already
+ // ships (schema-pack/link-inference.ts header). Pre-fix a user pack's
+ // `link_types[].inference.regex` (e.g. parent_of) was silently ignored
+ // here and every such edge landed as 'mentions'.
+ const pack = opts.pack ?? null;
+ const packBudget = pack ? new PageRegexBudget() : undefined;
+ const packOwnsAttendance = ownsAttendanceInference(pack);
+ // Timeline / See-also links never receive the page-role prior — see
+ // rolePriorSuppressedRanges (matched on the code-stripped content, so a
+ // fenced `## Timeline` never opens a range). idx is the link's position in
+ // `content` (stripCodeBlocks and the wikilink mask are length-preserving,
+ // so indices line up); idx < 0 / undefined keeps the old behavior.
+ const suppressedRanges = rolePriorSuppressedRanges(stripCodeBlocks(content));
+ const attendanceRanges = attendanceEvidenceRanges(content);
+ const statedType = statedRelationTypes(content, { ...opts.lineGrammar, declaredVerbs: pack?.link_types.map(lt => lt.name) });
+ return (ctx, targetSlug, idx, sourceId, bodyReference = true) => {
+ const explain = opts.explain;
+ const decide = (linkType: string, why: Partial<LinkTypeExplanation> = {}, canonicalAttendance?: boolean) => {
+ explain?.({ target: targetSlug, index: idx, context: ctx, linkType, stated: null, packRule: null, rule: null, attachment: 'none', suppressed: [], prior: null, unit: null, ...why });
+ return canonicalAttendance ? { linkType, canonicalAttendance } : { linkType };
+ };
+ const stated = bodyReference ? statedType(idx) : undefined; // a typed relation line wins (core/line-grammar.ts)
+ if (stated && !(stated === 'attended' && pageType === 'meeting')) return decide(stated, { stated });
+ const targetType = opts.targetType?.(targetSlug, sourceId);
+ if (pack) {
+ const packVerb = inferLinkTypeFromPack(pack, pageType as string, ctx, packBudget, targetType);
+ if (packVerb && (packOwnsAttendance || packVerb !== 'attended' || pageType !== 'meeting')) {
+ if (packVerb === 'attended' && pageType === 'meeting'
+ && (opts.targetType ? targetType !== 'person' : !targetSlug.startsWith('people/'))) return decide('mentions', { packRule: packVerb });
+ return decide(packVerb, { packRule: packVerb });
+ }
+ }
+ if (pageType === 'meeting') {
+ if (!bodyReference) return decide('mentions', { rule: 'page.meeting' });
+ if (packOwnsAttendance && pack?.link_types.some(lt => lt.name === 'attended' && (lt.inference?.page_type || lt.inference?.target_type))) return decide('mentions', { rule: 'page.meeting', packRule: 'attended' });
+ if (idx !== undefined && hasAttendanceEvidence(attendanceRanges, idx)) {
+ attendancePending.add(idx);
+ if (!opts.targetType || targetType !== undefined) attendanceResolved.add(idx);
+ }
+ if ((opts.targetType ? targetType === 'person' : targetSlug.startsWith('people/'))
+ && idx !== undefined && hasAttendanceEvidence(attendanceRanges, idx)) {
+ return decide('attended', { rule: 'page.meeting.attendance' }, true);
+ }
+ return decide('mentions', { rule: 'page.meeting' });
+ }
+ const suppressPrior = idx !== undefined && idx >= 0 && inSuppressedRange(suppressedRanges, idx);
+ const trace = traceLinkType(pageType, ctx, suppressPrior ? undefined : content, targetSlug,
+ opts.targetType ? targetType ?? null : undefined, bodyReference && idx !== undefined && idx >= 0 ? excerptAnchor(content, idx, 240) : undefined, content, !!explain);
+ const { type, ...why } = trace;
+ if (pack?.link_types.some(lt => lt.name === type && (lt.inference?.page_type || lt.inference?.target_type))) return decide('mentions', { ...why, packRule: type });
+ return decide(type, why);
+ };
+}
+
/**
* Result of extractPageLinks. `candidates` includes markdown refs + bare
* slug refs + frontmatter-derived edges (v0.13). `unresolved` lists
@@ -685,58 +767,11 @@ export async function extractPageLinks(
): Promise<PageLinksResult> {
const candidates: LinkCandidate[] = [];
- // #3190: pack-aware verb inference. Pack-declared verbs win (page-type
- // bindings, then pack regexes under the shared per-page ReDoS budget);
- // the in-code inferLinkType stays the fall-through for everything the
- // pack doesn't claim — matching the resolution order extract-ner already
- // ships (schema-pack/link-inference.ts header). Pre-fix a user pack's
- // `link_types[].inference.regex` (e.g. parent_of) was silently ignored
- // here and every such edge landed as 'mentions'.
const pack = opts.pack ?? null;
- const packBudget = pack ? new PageRegexBudget() : undefined;
- const packOwnsAttendance = ownsAttendanceInference(pack);
- // Timeline / See-also links never receive the page-role prior — see
- // rolePriorSuppressedRanges (matched on the code-stripped content, so a
- // fenced `## Timeline` never opens a range). idx is the link's position in
- // `content` (stripCodeBlocks and the wikilink mask are length-preserving,
- // so indices line up); idx < 0 / undefined keeps the old behavior.
- const suppressedRanges = rolePriorSuppressedRanges(stripCodeBlocks(content));
- const attendanceRanges = attendanceEvidenceRanges(content);
const attendancePending = new Set<number>();
const attendanceResolved = new Set<number>();
const attendanceAmbiguous = new Set<number>();
- const statedType = statedRelationTypes(content, { ...opts.lineGrammar, declaredVerbs: pack?.link_types.map(lt => lt.name) });
- const typeFor = (ctx: string, targetSlug: string, idx?: number, sourceId?: string, bodyReference = true): Pick<LinkCandidate, 'linkType' | 'canonicalAttendance'> => {
- const stated = bodyReference ? statedType(idx) : undefined; // a typed relation line wins (core/line-grammar.ts)
- if (stated && !(stated === 'attended' && pageType === 'meeting')) return { linkType: stated };
- const targetType = opts.targetType?.(targetSlug, sourceId);
- if (pack) {
- const packVerb = inferLinkTypeFromPack(pack, pageType as string, ctx, packBudget, targetType);
- if (packVerb && (packOwnsAttendance || packVerb !== 'attended' || pageType !== 'meeting')) {
- if (packVerb === 'attended' && pageType === 'meeting'
- && (opts.targetType ? targetType !== 'person' : !targetSlug.startsWith('people/'))) return { linkType: 'mentions' };
- return { linkType: packVerb };
- }
- }
- if (pageType === 'meeting') {
- if (!bodyReference) return { linkType: 'mentions' };
- if (packOwnsAttendance && pack?.link_types.some(lt => lt.name === 'attended' && (lt.inference?.page_type || lt.inference?.target_type))) return { linkType: 'mentions' };
- if (idx !== undefined && hasAttendanceEvidence(attendanceRanges, idx)) {
- attendancePending.add(idx);
- if (!opts.targetType || targetType !== undefined) attendanceResolved.add(idx);
- }
- if ((opts.targetType ? targetType === 'person' : targetSlug.startsWith('people/'))
- && idx !== undefined && hasAttendanceEvidence(attendanceRanges, idx)) {
- return { linkType: 'attended', canonicalAttendance: true };
- }
- return { linkType: 'mentions' };
- }
- 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);
- if (pack?.link_types.some(lt => lt.name === legacy && (lt.inference?.page_type || lt.inference?.target_type))) return { linkType: 'mentions' };
- return { linkType: legacy };
- };
+ const typeFor = makeTypeFor(content, pageType, opts, attendancePending, attendanceResolved);
// 1. Markdown entity refs.
for (const ref of extractEntityRefs(content)) {
@@ -1238,9 +1273,18 @@ 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;
-const VERB_RULES: ReadonlyArray<readonly [RegExp, string]> = [
- [FOUNDED_RE, 'founded'], [INVESTED_RE, 'invested_in'], [ADVISES_RE, 'advises'], [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'],
+/** A per-edge verb rule. `id` is stable: tests, explainLinkType and development reports name rules by it. */
+interface VerbRule { id: string; re: RegExp; verb: string }
+const VERB_RULES: ReadonlyArray<VerbRule> = [
+ { id: 'verb.founded', re: FOUNDED_RE, verb: 'founded' },
+ { id: 'verb.invested_in', re: INVESTED_RE, verb: 'invested_in' },
+ { id: 'verb.advises', re: ADVISES_RE, verb: 'advises' },
+ { id: 'verb.works_at', re: WORKS_AT_RE, verb: 'works_at' },
+ { id: 'verb.zh.founded', re: ZH_FOUNDED_RE, verb: 'founded' },
+ { id: 'verb.zh.invested_in', re: ZH_INVESTED_RE, verb: 'invested_in' },
+ { id: 'verb.zh.advises', re: ZH_ADVISES_RE, verb: 'advises' },
+ { id: 'verb.zh.works_at', re: ZH_WORKS_AT_RE, verb: 'works_at' },
+ { id: 'verb.zh.cited', re: ZH_CITED_RE, verb: 'cited' },
];
/**
@@ -1259,8 +1303,9 @@ const coordinated = (between: string) => {
const [lead, ...gaps] = between.split(INLINE_LINK_RE);
return !lead.trim() && gaps.length > 0 && gaps.every(gap => CONNECTOR_RE.test(gap));
};
-const GLOBAL_VERB_RULES = VERB_RULES.map(([re, verb]) => [new RegExp(re.source, `${re.flags.replace('g', '')}g`), verb] as const);
-function attachedVerb(context: string, targetSlug?: string, anchor?: number): string | null | undefined {
+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): Attachment | 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;
@@ -1268,16 +1313,41 @@ function attachedVerb(context: string, targetSlug?: string, anchor?: number): st
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;
- for (const [re, verb] of GLOBAL_VERB_RULES) {
- for (const m of context.matchAll(re)) {
+ const suppressed: string[] = [];
+ let rule: VerbRule | null = null;
+ let otherLink = false;
+ for (const r of GLOBAL_VERB_RULES) {
+ for (const m of context.matchAll(r.re)) {
const start = m.index ?? 0; const end = start + m[0].length;
- if (end <= linkStart && LINK_MARK_RE.test(context.slice(end, linkStart))
- && !coordinated(context.slice(end, linkStart))) continue;
- if (start >= linkEnd && (LINK_MARK_RE.test(context.slice(linkEnd, start)) || /^\s*(?:(?:with|at|to|for|of|in|on)\s+)?\[/i.test(context.slice(end)))) continue;
- return verb;
+ if ((end <= linkStart && LINK_MARK_RE.test(context.slice(end, linkStart)) && !coordinated(context.slice(end, linkStart)))
+ || (start >= linkEnd && (LINK_MARK_RE.test(context.slice(linkEnd, start)) || /^\s*(?:(?:with|at|to|for|of|in|on)\s+)?\[/i.test(context.slice(end))))) {
+ otherLink = true;
+ if (explain) suppressed.push(`${r.id}:other-link`);
+ continue;
+ }
+ if (rule) { suppressed.push(`${r.id}:outranked`); break; }
+ rule = r;
+ if (!explain) return { rule, suppressed, otherLink };
+ break;
}
}
- return null;
+ return { rule, suppressed: [...new Set(suppressed)], otherLink };
+}
+
+/** Why inferLinkType chose a type: the rule, how it attached, what it suppressed, and the prior. */
+export interface LinkTypeTrace {
+ type: string;
+ /** Stable id of the deciding rule (`verb.*`, `prior.*`, `page.*`, `unit.*`), or null for plain `mentions`. */
+ rule: string | null;
+ /** attached: the verb belongs to this link; window: the link was not located, plain precedence over the window;
+ * other-links: every verb in the window belongs to another link; none: no verb in the window. */
+ attachment: 'attached' | 'window' | 'other-links' | 'none';
+ /** Rule ids that matched but did not decide (`:other-link` belonged to another link, `:outranked` lost on precedence). */
+ suppressed: string[];
+ /** The page-role prior that decided (`prior.investor`, `prior.advisor`, `prior.employee`), if any. */
+ prior: string | null;
+ /** The typing unit that changed this decision (src/core/link-typing-units.ts), if any. */
+ unit: TypingUnit | null;
}
/**
@@ -1297,24 +1367,33 @@ function attachedVerb(context: string, targetSlug?: string, anchor?: number): st
* ("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 {
+ return traceLinkType(pageType, context, globalContext, targetSlug, targetType, anchor).type;
+}
+
+/** inferLinkType with its reasons. `pageText` is the whole page (role priors read `globalContext`, which timeline links do not get). */
+export function traceLinkType(pageType: PageType, context: string, globalContext?: string, targetSlug?: string, targetType?: string | null, anchor?: number, pageText?: string, explain = false): LinkTypeTrace {
+ const out = (type: string, rule: string | null, attachment: LinkTypeTrace['attachment'] = 'none', suppressed: string[] = [], prior: string | null = null): LinkTypeTrace =>
+ ({ type, rule, attachment, suppressed, prior, unit: null });
if (pageType === 'media') {
- return 'mentions';
+ return out('mentions', 'page.media');
}
// v0.27.1: image pages link to their text sibling via 'image_of' (the
// image is OF that meeting/note). Set explicitly by the import-image
// path-proximity helper, not by markdown extraction — but the type is
// declared here so graph-query knows the edge name.
- if ((pageType as string) === 'image') return 'image_of';
+ if ((pageType as string) === 'image') return out('image_of', 'page.image');
if ((pageType as string) === 'meeting') {
- return targetType !== undefined ? (targetType === 'person' ? 'attended' : 'mentions')
- : (!targetSlug || targetSlug.startsWith('people/') ? 'attended' : 'mentions');
+ return out(targetType !== undefined ? (targetType === 'person' ? 'attended' : 'mentions')
+ : (!targetSlug || targetSlug.startsWith('people/') ? 'attended' : 'mentions'), 'page.meeting');
}
// 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.
- 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;
+ const attached = attachedVerb(context, targetSlug, anchor, explain);
+ if (attached?.rule) return out(attached.rule.verb, attached.rule.id, 'attached', attached.suppressed);
+ if (attached === undefined) for (const r of VERB_RULES) if (r.re.test(context)) return out(r.verb, r.id, 'window');
+ const attachment = attached?.otherLink ? 'other-links' : 'none';
+ const suppressed = attached?.suppressed ?? [];
// 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
@@ -1325,11 +1404,48 @@ export function inferLinkType(pageType: PageType, context: string, globalContext
// employee/advisor match would mis-classify; keep investor first so those
// phrasings resolve correctly.
if (pageType === 'person' && globalContext && targetSlug?.startsWith('companies/')) {
- if (PARTNER_ROLE_RE.test(globalContext)) return 'invested_in';
- if (ADVISOR_ROLE_RE.test(globalContext)) return 'advises';
- if (EMPLOYEE_ROLE_RE.test(globalContext)) return 'works_at';
+ if (PARTNER_ROLE_RE.test(globalContext)) return out('invested_in', 'prior.investor', attachment, suppressed, 'prior.investor');
+ if (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');
}
- return 'mentions';
+ return out('mentions', null, attachment, suppressed);
+}
+
+/** explainLinkType's answer for one target: every occurrence's typing decision, the kept types, tense and dated transitions. */
+export interface LinkExplanation {
+ target: string;
+ occurrences: LinkTypeExplanation[];
+ /** The distinct types extractPageLinks emits for the target, sorted (a `mentions` row can sit beside a typed one). */
+ types: string[];
+ /** Tense per kept temporal type ('past' or 'present'). */
+ tense: Record<string, AssertionTense>;
+ /** Dated transitions for the kept types, each with the id of the cue that produced it. */
+ transitions: Array<DerivedTransition & { rule: string }>;
+}
+
+/**
+ * Why a page links to `target` with the type it does: a pure (database-free, deterministic) replay of
+ * extractPageLinks' typing and deriveTemporalEvidence for one page. Shared by tests and development reports.
+ * `content` is the page body (compiled truth and timeline); frontmatter links are skipped unless `frontmatter` is given.
+ */
+export async function explainLinkType(input: {
+ slug: string; content: string; pageType: PageType; target: string;
+ frontmatter?: Record<string, unknown>; lineGrammar?: ExtractPageLinksOptions['lineGrammar']; pack?: LinkExtractionPack | null;
+}): Promise<LinkExplanation> {
+ const occurrences: LinkTypeExplanation[] = [];
+ const resolver: SlugResolver = { resolve: async () => null };
+ const { candidates } = await extractPageLinks(input.slug, input.content, input.frontmatter ?? {}, input.pageType, resolver, {
+ skipFrontmatter: !input.frontmatter, lineGrammar: input.lineGrammar, pack: input.pack ?? null,
+ explain: e => { if (e.target === input.target) occurrences.push(e); },
+ });
+ const types = [...new Set(candidates.filter(c => c.targetSlug === input.target).map(c => c.linkType))].sort();
+ const transitions: LinkExplanation['transitions'] = [];
+ const evidence = deriveTemporalEvidence({ slug: input.slug, compiled_truth: input.content, timeline: '', frontmatter: input.frontmatter ?? {} },
+ candidates.map(c => ({ from_slug: c.fromSlug ?? input.slug, to_slug: c.targetSlug, link_type: c.linkType, link_source: c.linkSource ?? 'markdown', origin_field: c.originField ?? null })),
+ (t, rule) => { if (t.to_slug === input.target || t.from_slug === input.target) transitions.push({ ...t, rule }); });
+ const tense: Record<string, AssertionTense> = {};
+ for (const t of types) { const v = evidence.tense.get(rowKey({ from_slug: input.slug, to_slug: input.target, link_type: t })); if (v) tense[t] = v; }
+ return { target: input.target, occurrences, types, tense, transitions };
}
// ─── Frontmatter link extraction (v0.13) ────────────────────────
diff --git a/src/core/link-temporal-evidence.ts b/src/core/link-temporal-evidence.ts
index 4029bd42d4..5e64a5deae 100644
--- a/src/core/link-temporal-evidence.ts
+++ b/src/core/link-temporal-evidence.ts
@@ -190,7 +190,10 @@ export interface PageForEvidence {
frontmatter: Record<string, unknown> | null | undefined;
}
-export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly OwnedRow[]): TemporalEvidence {
+/** Receives each derived transition with the stable id of the cue that produced it (`cue.*`, `unit.*`). */
+export type TransitionExplainer = (t: DerivedTransition, rule: string) => void;
+
+export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly OwnedRow[], explain?: TransitionExplainer): TemporalEvidence {
const tense = new Map<string, AssertionTense>();
const transitions: DerivedTransition[] = [];
const unmatched: TemporalEvidence['unmatched'] = [];
@@ -199,9 +202,9 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
const temporalRows = rows.filter(r => relationSemantics(r.link_type) !== 'reference');
const other = (r: OwnedRow) => (r.from_slug === page.slug ? r.to_slug : r.from_slug);
const seen = new Set<string>();
- const push = (t: DerivedTransition) => {
+ const push = (t: DerivedTransition, rule: string) => {
const k = `${t.from_slug}\0${t.to_slug}\0${t.link_type}\0${t.kind}\0${t.occurred_on}\0${t.producer}`;
- if (!seen.has(k)) { seen.add(k); transitions.push(t); }
+ if (!seen.has(k)) { seen.add(k); transitions.push(t); explain?.(t, rule); }
};
// 1. Explicit grammar inside dated timeline entries.
@@ -217,7 +220,7 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
const resolved = target.includes('/') ? target : temporalRows.map(other).find(slug => refersTo(target, slug)) ?? null;
if (!resolved) { unmatched.push({ line: line.text, reason: 'no_target' }); continue; }
push({ from_slug: page.slug, to_slug: resolved, link_type: linkType, kind: m[1] === 'Started' ? 'start' : 'end',
- occurred_on: line.date, date_precision: 'day', producer: line.dream ? 'dream' : 'explicit', line_hash: lineHash(line.text) });
+ occurred_on: line.date, date_precision: 'day', producer: line.dream ? 'dream' : 'explicit', line_hash: lineHash(line.text) }, 'cue.explicit');
}
}
@@ -241,20 +244,24 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
for (const r of temporalRows) {
if (!refersTo(ref.target, other(r)) || !r.link_type) continue;
const cues = cuesFor(r.link_type);
+ const family = r.link_type === 'works_at' ? 'employment' : r.link_type === 'advises' ? 'advisory' : 'partner';
let kind: TransitionKind | null = null;
+ let rule = '';
if (cues) {
if (eventLine) continue;
if (qualified) {
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'
- : 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';
+ rule = `cue.advisory_board.${kind}`;
+ } else if (cues.end.test(window)) { kind = 'end'; rule = `cue.${family}.end`; }
+ else if (cues.start.test(window)) { kind = 'start'; rule = `cue.${family}.start`; }
+ 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) continue;
if (kind === 'end') endedHere.add(r.link_type);
push({ from_slug: r.from_slug, to_slug: r.to_slug, link_type: r.link_type, kind, occurred_on: line.date,
- date_precision: 'day', producer: line.dream ? 'dream' : 'timeline', line_hash: lineHash(line.text) });
+ date_precision: 'day', producer: line.dream ? 'dream' : 'timeline', line_hash: lineHash(line.text) }, rule);
}
prevEnded = endedHere;
}
@@ -275,7 +282,7 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
const d = normalizePartialDate(stringish(obj[key]));
if (!d) continue;
push({ from_slug: r.from_slug, to_slug: r.to_slug, link_type: r.link_type!, kind, occurred_on: d.date,
- date_precision: d.precision, producer: 'frontmatter', line_hash: lineHash(`${r.origin_field}:${name}:${key}`) });
+ date_precision: d.precision, producer: 'frontmatter', line_hash: lineHash(`${r.origin_field}:${name}:${key}`) }, `cue.frontmatter.${key}`);
}
}
}
diff --git a/src/core/link-typing-units.ts b/src/core/link-typing-units.ts
new file mode 100644
index 0000000000..69854e8fa8
--- /dev/null
+++ b/src/core/link-typing-units.ts
@@ -0,0 +1,57 @@
+/**
+ * Relationship-phrasing typing units (Q2 Track C).
+ *
+ * Each unit is one entailment-limited change to link typing (link-extraction.ts) or to the temporal cue lexicon
+ * (link-temporal-evidence.ts). A unit takes effect only when its id is in ENABLED_TYPING_UNITS; with the set empty,
+ * extraction behaves exactly as before the units existed. Which units ship is decided by the preregistered held-out
+ * verdict (docs/eval/decisions/q2-parser-gaps/, gbrain-evals docs/benchmarks/2026-10-06-q2-parser-gaps-preregistration.md);
+ * scripts/q2-typing-package.ts builds a branch whose one extra commit sets this constant.
+ *
+ * Policy, examples and the contributor recipe: docs/guides/temporal-edges.md, "Relationship phrasings".
+ */
+
+export const TYPING_UNITS = ['U1', 'U2', 'U3', 'U4', 'U5', 'U6'] as const;
+export type TypingUnit = typeof TYPING_UNITS[number];
+
+/** The units this build applies. Changed only by the package script after the verdict. */
+export const ENABLED_TYPING_UNITS: ReadonlySet<TypingUnit> = new Set<TypingUnit>([]);
+
+let override: ReadonlySet<TypingUnit> | null = null;
+
+export function typingUnitEnabled(unit: TypingUnit): boolean {
+ return (override ?? ENABLED_TYPING_UNITS).has(unit);
+}
+
+/** The unit set extraction uses right now (the test override, else ENABLED_TYPING_UNITS). */
+export function activeTypingUnits(): TypingUnit[] {
+ return TYPING_UNITS.filter(typingUnitEnabled);
+}
+
+export function parseTypingUnits(units: Iterable<string>): TypingUnit[] {
+ const out: TypingUnit[] = [];
+ for (const raw of units) {
+ const u = raw.trim().toUpperCase();
+ if (!u) continue;
+ if (!(TYPING_UNITS as readonly string[]).includes(u)) {
+ throw new Error(`Unknown typing unit "${raw}". The units are ${TYPING_UNITS.join(', ')} (src/core/link-typing-units.ts); pass a comma-separated subset.`);
+ }
+ if (!out.includes(u as TypingUnit)) out.push(u as TypingUnit);
+ }
+ return out;
+}
+
+/** Tests and development reports only: run extraction with `units` instead of ENABLED_TYPING_UNITS (null restores it). */
+export function setTypingUnitsForTests(units: Iterable<string> | null): void {
+ override = units === null ? null : new Set(parseTypingUnits(units));
+}
+
+/** Tests only: run `fn` with `units` enabled, then restore the previous set. */
+export async function withTypingUnits<T>(units: Iterable<string>, fn: () => T | Promise<T>): Promise<T> {
+ const previous = override;
+ setTypingUnitsForTests(units);
+ try {
+ return await fn();
+ } finally {
+ override = previous;
+ }
+}
diff --git a/test/link-typing-explain.test.ts b/test/link-typing-explain.test.ts
new file mode 100644
index 0000000000..c06b246eda
--- /dev/null
+++ b/test/link-typing-explain.test.ts
@@ -0,0 +1,71 @@
+/**
+ * explainLinkType / traceLinkType: every typing decision names its rule (stable ids), how the verb attached, what it
+ * suppressed, the prior, a stated type or pack rule, and the cue behind each dated transition.
+ */
+import { describe, expect, test } from 'bun:test';
+import { explainLinkType, inferLinkType, traceLinkType } from '../src/core/link-extraction.ts';
+
+const ACME = 'companies/acme-example';
+const WIDGET = 'companies/widget-example';
+const link = (slug: string, name = slug.split('/')[1]!) => `[${name}](../${slug}.md)`;
+
+describe('traceLinkType', () => {
+ test('an attached verb names its rule and the outranked alternatives', () => {
+ const ctx = `Alice invested in ${link(ACME)} and works at it.`;
+ const t = traceLinkType('person', ctx, undefined, ACME, undefined, ctx.indexOf(ACME), undefined, true);
+ expect(t).toMatchObject({ type: 'invested_in', rule: 'verb.invested_in', attachment: 'attached', prior: null, unit: null });
+ expect(t.suppressed).toContain('verb.works_at:outranked');
+ expect(inferLinkType('person', ctx, undefined, ACME, undefined, ctx.indexOf(ACME))).toBe(t.type);
+ });
+
+ test("a verb that belongs to another link is suppressed and the prior decides", () => {
+ const page = 'Alice is a senior engineer at a startup.';
+ const ctx = `Alice met ${link(ACME)} and also advises ${link(WIDGET)}.`;
+ const t = traceLinkType('person', ctx, page, ACME, undefined, ctx.indexOf(ACME), page, true);
+ expect(t).toMatchObject({ type: 'works_at', rule: 'prior.employee', prior: 'prior.employee', attachment: 'other-links' });
+ expect(t.suppressed).toContain('verb.advises:other-link');
+ });
+
+ test('page rules have ids too', () => {
+ expect(traceLinkType('media', 'x', undefined, ACME).rule).toBe('page.media');
+ expect(traceLinkType('person', 'no verbs here', undefined, ACME)).toMatchObject({ type: 'mentions', rule: null, attachment: 'none' });
+ });
+});
+
+describe('explainLinkType', () => {
+ test('stated type wins and is reported', async () => {
+ const e = await explainLinkType({ slug: 'people/alice-example', pageType: 'person', target: ACME,
+ content: `Alice example.\n\n## Roles\n\n- works_at [[${ACME}]]\n` });
+ expect(e.types).toEqual(['works_at']);
+ expect(e.occurrences[0]).toMatchObject({ linkType: 'works_at', stated: 'works_at', packRule: null });
+ });
+
+ test('transitions carry the cue that produced them', async () => {
+ const content = [
+ `Alice works at ${link(ACME)} as CTO.`, '', '## Timeline', '',
+ `- **2020-01-02** | Joined ${link(ACME)} as CTO`,
+ `- **2023-04-05** | Left ${link(ACME)}`,
+ ].join('\n');
+ const e = await explainLinkType({ slug: 'people/alice-example', pageType: 'person', target: ACME, content });
+ expect(e.types).toEqual(['mentions', 'works_at']);
+ expect(e.transitions.map(t => [t.kind, t.occurred_on, t.rule])).toEqual([
+ ['start', '2020-01-02', 'cue.employment.start'],
+ ['end', '2023-04-05', 'cue.employment.end'],
+ ]);
+ expect(e.occurrences.map(o => [o.linkType, o.rule, o.attachment])).toEqual([
+ ['works_at', 'verb.works_at', 'attached'], ['mentions', null, 'other-links'], ['mentions', null, 'none'],
+ ]);
+ });
+
+ test('explicit grammar and the "left [A] for [B]" start are named', async () => {
+ const content = [
+ `Alice works at ${link(WIDGET)}. Earlier, she worked at ${link(ACME)}.`, '', '## Timeline', '',
+ `- **2019-01-02** | note — Started works_at [[${ACME}]]`,
+ `- **2021-03-04** | Left ${link(ACME)} for ${link(WIDGET)}`,
+ ].join('\n');
+ const acme = await explainLinkType({ slug: 'people/alice-example', pageType: 'person', target: ACME, content });
+ const widget = await explainLinkType({ slug: 'people/alice-example', pageType: 'person', target: WIDGET, content });
+ expect(acme.transitions.map(t => t.rule)).toEqual(['cue.explicit', 'cue.employment.end']);
+ expect(widget.transitions.map(t => [t.kind, t.rule])).toEqual([['start', 'cue.after_end.to_for']]);
+ });
+});