Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

revert(typing): remove units U2, U5 and U6 (held-out verdict); U1 and U34 ship

garrytan71ee39f28a85
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 58118c2a6e..18ec3d6ecc 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 2046 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); +4 #6188: uncommitted legacy fence-repair notices in sources status (logic in fence-repair/uncommitted.ts)
-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 traceLinkType
+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; +11 U2: locateLink shared by attachedVerb and the U2 post-pass in traceLinkType; -11 lowered: Q2 verdict reverted U2 (locateLink and the post-pass)
src/core/embedding-migration.ts 1587 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; +17 #5334: smoke check samples one representative chunk per distinct page (bounded index-ordered batch walk, longest chunk re-read under the page lock, title-prefixed bounded query); +1 #5334: the smoke-query length limits are shared with the worst-case budget
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 1916 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; +1 #5371: the stop-hook dirty probe ignores physical-root ownership metadata (root-metadata.ts, engine-free); 2 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/scripts/q2-typing-dev.ts b/scripts/q2-typing-dev.ts
index d3ca174e35..1bad563cbb 100644
--- a/scripts/q2-typing-dev.ts
+++ b/scripts/q2-typing-dev.ts
@@ -3,9 +3,9 @@
* Q2 typing units: development dumps and identity tables (development data only).
*
* bun scripts/q2-typing-dev.ts dump --evals <gbrain-evals checkout> --root <gbrain tree> \
- * --phrasing A|A2|A3|<dev phrasing JSON> [--seeds 3,5] [--units U1,U2|none] --out <dump.json>
+ * --phrasing A|A2|A3|<dev phrasing JSON> [--seeds 3,5] [--units U1,U3|none] --out <dump.json>
* bun scripts/q2-typing-dev.ts compare --base <dump.json> --arm <dump.json> [--json]
- * bun scripts/q2-typing-dev.ts world-v1 --evals <gbrain-evals checkout> --root <gbrain tree> [--units U1,U2|none] [--out <edges.json>]
+ * bun scripts/q2-typing-dev.ts world-v1 --evals <gbrain-evals checkout> --root <gbrain tree> [--units U1,U3|none] [--out <edges.json>]
*
* `dump` renders the temporal-edges world (gbrain-evals eval/generators/temporal-edges-gen.ts, E5 probe people
* included) for each development seed, writes every page through `put_page` on in-memory PGLite using the gbrain
diff --git a/scripts/q2-typing-package.ts b/scripts/q2-typing-package.ts
index 69a281e572..1733225054 100644
--- a/scripts/q2-typing-package.ts
+++ b/scripts/q2-typing-package.ts
@@ -3,10 +3,10 @@
* Build a typing-unit package ref (Q2 Track C): a local branch whose single extra commit on top of `--base` sets
* ENABLED_TYPING_UNITS in src/core/link-typing-units.ts to the given units, in the given order. Prints the commit SHA.
*
- * bun scripts/q2-typing-package.ts --base <ref> --units U25,U1,U34 # nested package arm (order = selection order)
- * bun scripts/q2-typing-package.ts --base <ref> --arm U2 # one-unit arm (baseline + that unit; joint units U25 = U2 with U5, U34 = U3 with U4)
+ * bun scripts/q2-typing-package.ts --base <ref> --units U34,U1 # nested package arm (order = selection order)
+ * bun scripts/q2-typing-package.ts --base <ref> --arm U1 # one-unit arm (baseline + that unit; joint unit U34 = U3 with U4)
* bun scripts/q2-typing-package.ts --base <ref> --units none # the base with no unit (equivalence checks)
- * options: --branch <name> (default q2-typing/<base-short>/<arm-U2 | U2-U1-U5 | none>), --json
+ * options: --branch <name> (default q2-typing/<base-short>/<arm-U1 | U3-U4-U1 | none>), --json
*
* The working tree, index and current branch are never touched (git plumbing on a temporary index). An existing
* branch is reused only when it already points at a commit with the same parent and tree; otherwise the script
@@ -52,13 +52,13 @@ function main(argv: readonly string[]): void {
const base = arg(argv, '--base');
const unitsArg = arg(argv, '--units');
const armArg = arg(argv, '--arm');
- if (!base) fail('--base is required.', 'the package is one commit on top of a base ref (the frozen build).', 'bun scripts/q2-typing-package.ts --base <ref> --units U2,U1');
- if ((unitsArg === undefined) === (armArg === undefined)) fail('Pass exactly one of --units and --arm.', '--units builds a nested package in the given order; --arm builds a one-unit arm.', 'bun scripts/q2-typing-package.ts --base <ref> --arm U2');
+ if (!base) fail('--base is required.', 'the package is one commit on top of a base ref (the frozen build).', 'bun scripts/q2-typing-package.ts --base <ref> --units U34,U1');
+ if ((unitsArg === undefined) === (armArg === undefined)) fail('Pass exactly one of --units and --arm.', '--units builds a nested package in the given order; --arm builds a one-unit arm.', 'bun scripts/q2-typing-package.ts --base <ref> --arm U1');
let units: TypingUnit[];
try {
units = armArg !== undefined ? parseTypingUnits([armArg]) : unitsArg === 'none' ? [] : parseTypingUnits(unitsArg!.split(','));
} catch (e) {
- fail(e instanceof Error ? e.message : String(e), 'only the units declared in src/core/link-typing-units.ts exist.', 'pass a comma-separated subset of U1..U6, or --units none');
+ fail(e instanceof Error ? e.message : String(e), 'only the units declared in src/core/link-typing-units.ts exist.', 'pass a comma-separated subset of U1, U3, U4 (or U34), or --units none');
}
if (armArg !== undefined && armArg.includes(',')) fail(`--arm takes one unit (got "${armArg}").`, 'a unit arm is the baseline plus one unit (or one joint unit such as U34).', 'use --units for several units');
const raw = (unitsArg ?? '').split(',').map(s => s.trim().toUpperCase()).filter(s => s && s !== 'NONE');
diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.ts
index 28e4b4eab6..efc983333d 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, u2RoleRule, unitOfRule, unitVerbVeto, type TypingUnit } from './link-typing-units.ts';
+import { UNIT_VERB_RULES, typingUnitEnabled, 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,21 +1311,14 @@ 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 }
-/** 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 {
+function attachedVerb(context: string, targetSlug?: string, anchor?: number, explain = false, investorPrior: () => boolean = () => 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;
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(/\)|\]\]/);
- 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 linkEnd = close >= 0 ? at + close + (context[at + close] === ')' ? 1 : 2) : at + targetSlug!.length;
const suppressed: string[] = [];
let rule: VerbRule | null = null;
let otherLink = false;
@@ -1434,10 +1427,6 @@ export function traceLinkType(pageType: PageType, context: string, globalContext
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');
}
- // 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-temporal-evidence.ts b/src/core/link-temporal-evidence.ts
index a041d88d8f..7f65ec4be1 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 { GUARD_IGNORED_LINE, U4_NOT_EMPLOYMENT_ROLE, U5_EXCHANGE_AFTER, U5_EXCHANGE_BEFORE, U5_LEAVE, U6_START, nonEmploymentRoleOnPage, typingUnitEnabled } from './link-typing-units.ts';
+import { U4_NOT_EMPLOYMENT_ROLE, typingUnitEnabled } from './link-typing-units.ts';
export interface OwnedRow {
from_slug: string;
@@ -209,10 +209,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 rules = new Map<DerivedTransition, string>();
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); rules.set(t, rule); }
+ if (!seen.has(k)) { seen.add(k); transitions.push(t); explain?.(t, rule); }
};
// 1. Explicit grammar inside dated timeline entries.
@@ -232,12 +231,6 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
}
}
- // U5 ends, U6 starts and the uncued plain references to works_at targets, for the guards after the loop.
- const u5 = typingUnitEnabled('U5');
- const u6 = typingUnitEnabled('U6') && !nonEmploymentRoleOnPage(content);
- const unitTransitions: Array<{ target: string; date: string; key: string }> = [];
- const uncued: Array<{ target: string; date: string }> = [];
-
// 2. Natural cues on dated lines, for relationships this page asserts.
// State relations take a cue only when it governs the reference itself:
// not on investing/meeting/event lines, not when the reference is
@@ -247,7 +240,6 @@ 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) {
@@ -270,19 +262,10 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
: /\b(?:(?:re-?)?joined|was\s+(?:added|named|appointed)\s+to)\s*$/i.test(window) ? 'start' : null;
rule = `cue.advisory_board.${kind}`;
} else if (cues.end.test(window)) { kind = 'end'; rule = `cue.${family}.end`; }
- else if (u5 && r.link_type === 'works_at' && U5_LEAVE.test(window)) { kind = 'end'; rule = 'unit.u5.leave'; }
- else if (u5 && r.link_type === 'works_at' && U5_EXCHANGE_BEFORE.test(window) && U5_EXCHANGE_AFTER.test(line.text.slice(ref.end))) { kind = 'end'; rule = 'unit.u5.exchange'; }
else if (cues.start.test(window)) { kind = 'start'; rule = `cue.${family}.start`; }
- else if (u6 && r.link_type === 'works_at' && U6_START.test(window)) { kind = 'start'; rule = 'unit.u6.start_framing'; }
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' && !tradeLine) uncued.push({ target: other(r), date: line.date });
- continue;
- }
- if (rule.startsWith('unit.u5.') || rule.startsWith('unit.u6.')) {
- unitTransitions.push({ target: other(r), date: line.date, key: `${r.from_slug}\0${r.to_slug}\0${r.link_type}\0${kind}\0${line.date}` });
- }
+ 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) }, rule);
@@ -291,15 +274,6 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
}
}
- // U5 restart guard and U6 leave guard: a leave or start a unit adds is dropped when a later dated line names the same
- // organization in plain words that no cue reads: for U5 a rejoin the lexicon cannot see (the leave would close a
- // current stint for good), for U6 a leave it cannot see (the start would open a former job for good).
- for (const e of unitTransitions) {
- if (!uncued.some(u => u.target === e.target && u.date > e.date)) continue;
- const at = transitions.findIndex(t => `${t.from_slug}\0${t.to_slug}\0${t.link_type}\0${t.kind}\0${t.occurred_on}` === e.key);
- if (at >= 0) transitions.splice(at, 1);
- }
-
// 3. Frontmatter since/until on relationship objects ({name, since, until}).
const fm = page.frontmatter ?? {};
for (const r of temporalRows) {
@@ -335,7 +309,6 @@ export function deriveTemporalEvidence(page: PageForEvidence, rows: readonly Own
}
tense.set(rowKey(r), past > 0 && present === 0 && r.link_source !== 'frontmatter' ? 'past' : 'present');
}
- if (explain) for (const t of transitions) explain(t, rules.get(t)!);
return { tense, transitions, unmatched };
}
diff --git a/src/core/link-typing-units.ts b/src/core/link-typing-units.ts
index e7f146cb61..b4fbdf01e3 100644
--- a/src/core/link-typing-units.ts
+++ b/src/core/link-typing-units.ts
@@ -2,18 +2,19 @@
* 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);
+ * (link-temporal-evidence.ts), active when its id is in ENABLED_TYPING_UNITS. The shipped units are U1 (adviser
+ * wording) and the joint unit U34 (board wording never types works_at; advisory, board and investor roles are not
+ * employment starts), confirmed by the preregistered held-out verdict (decision q2-parser-gaps-2026-10). U2, U5 and U6
+ * were tested and not shipped, and their code was removed (docs/eval/decisions/q2-parser-gaps/dev-units.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 const TYPING_UNITS = ['U1', 'U3', 'U4'] as const;
export type TypingUnit = typeof TYPING_UNITS[number];
-/** The units this build applies. Changed only by the package script after the verdict. */
+/** The units this build applies (the confirmed package P2). */
export const ENABLED_TYPING_UNITS: ReadonlySet<TypingUnit> = new Set<TypingUnit>(['U3', 'U4', 'U1']);
let override: ReadonlySet<TypingUnit> | null = null;
@@ -28,12 +29,11 @@ export function activeTypingUnits(): TypingUnit[] {
}
/**
- * Joint units: ids that stand for several units measured together (docs/eval/decisions/q2-parser-gaps/dev-units.md,
- * "Dependency units"). U34 is U3 with U4: U4 alone loses as-of accuracy wherever board wording still types works_at
- * (the set-F interaction), which U3 removes. U25 is U2 with U5: U2 alone lets the single-value pass close a former
- * employer whose leave only U5 reads at the new employer's start date (a wrong closure by date), which U5 removes.
+ * Joint units: ids that stand for several units measured together. U34 is U3 with U4: U4 alone loses as-of accuracy
+ * wherever board wording still types works_at (the set-F interaction), which U3 removes
+ * (docs/eval/decisions/q2-parser-gaps/dev-units.md, "Dependency units").
*/
-export const JOINT_TYPING_UNITS: Readonly<Record<string, readonly TypingUnit[]>> = { U25: ['U2', 'U5'], U34: ['U3', 'U4'] };
+export const JOINT_TYPING_UNITS: Readonly<Record<string, readonly TypingUnit[]>> = { U34: ['U3', 'U4'] };
export function parseTypingUnits(units: Iterable<string>): TypingUnit[] {
const out: TypingUnit[] = [];
@@ -156,67 +156,6 @@ 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;
-export 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) ─────────────────────
/**
@@ -224,26 +163,3 @@ export function u2RoleRule(context: string, linkStart: number, linkEnd: number,
* 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)`;
-
-/** U5: leaves an object splits ("wrapped her time up at", "handed in her notice at") and quitting idioms. */
-const LEAVE_OBJECT = String.raw`(?:(?:her|his|their|my|a|the)\s+)?(?:time|stint|tenure|role|job|run|things|it|notice|resignation)\s+`;
-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;
-
-/**
- * U6: start framings: a first day, week or month at, day one at, kicking off a role, job, position, chapter or stint
- * at, onboarding, "began working at/for", a new chapter at. Only dates a works_at relationship the page already
- * asserts (natural cues never create one). "First day of the [X] summit" and an event line never start a job.
- * Development rework (dev-units.md), the same two guards as U2/U5: a U6 start is dropped when a later dated entry names
- * the organization in words no cue reads (an unread leave would keep a former job open for good), and U6 does not fire
- * on a page that names any organization in an advisory, board or investor role (a newly dated employer then meets
- * master's advisory-line start: wrong single-value closures on the E5 probe). U4 removes that cause.
- */
-const START_ROLE = String.raw`(?:[\w&./-]+\s+){0,4}?`;
-export const U6_START = new RegExp(String.raw`\b(?:(?:(?:her|his|their|my|a|the)\s+)?(?:first\s+(?:day|week|month)|day\s+one)\s+(?:as\s+${START_ROLE})?(?:at|with)|kick(?:ed|s|ing)?[\s-]?off\s+(?:(?:a|her|his|their|my)\s+)?(?:new\s+)?(?:role|job|position|chapter|stint)\s+(?:at|with)|(?:was\s+|got\s+|been\s+)?onboarded\s+(?:at|with|to|into|by)|onboarding\s+(?:week|day|period)\s+(?:at|with)|began\s+(?:work(?:ing)?\s+)?(?:at|for)|start(?:ed|ing|s)?\s+(?:a\s+|her\s+|his\s+|their\s+|my\s+)?new\s+chapter\s+(?:at|with)|(?:a\s+)?new\s+chapter\s+(?:at|with))\s*$`, 'i');
diff --git a/test/fixtures/q2-typing-units/world-v1-confirmed-package.sha256 b/test/fixtures/q2-typing-units/world-v1-confirmed-package.sha256
new file mode 100644
index 0000000000..c04ce027af
--- /dev/null
+++ b/test/fixtures/q2-typing-units/world-v1-confirmed-package.sha256
@@ -0,0 +1 @@
+1763359f75ac050fc19e8fdd17a6694a8cf0e6a7fbd12c2b01ef5932f9ef96fd
diff --git a/test/helpers/typing-unit-examples.ts b/test/helpers/typing-unit-examples.ts
index 7d60c2577a..2432de7c34 100644
--- a/test/helpers/typing-unit-examples.ts
+++ b/test/helpers/typing-unit-examples.ts
@@ -93,6 +93,8 @@ const U1: TypingExample[] = [
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-after-untyped-role', unit: 'U1', target: BETA, content: page(`Alice is CTO for ${L(ACME)} and an adviser to ${L(BETA)}.`),
+ 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,
@@ -104,84 +106,6 @@ 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[] = [
@@ -266,96 +190,4 @@ const U4: TypingExample[] = [
off: { types: ['advises'], transitions: ['advises start 2021-06-07'] } },
];
-// ─── U5: leave idioms and exchange moves (dated ends), with a restart guard ─
-const JOB = (lines: string[]) => page(`Alice worked at ${L(ACME)}. She works at ${L(BETA)} now.`, [`**2015-01-02** | linkedin — Joined ${L(ACME)} as engineer`, ...lines]);
-const U5: TypingExample[] = [
- { id: 'u5-handed-in-notice', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | linkedin — Handed in her notice at ${L(ACME)}`]),
- 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: { '2016-01-01': true, '2020-01-01': false } } } },
- { id: 'u5-wrapped-time-up', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | linkedin — Wrapped her time up at ${L(ACME)}`]),
- 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'] } },
- { id: 'u5-packed-it-in', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | linkedin — Called it a day at ${L(ACME)} and packed it in`]),
- 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'] } },
- { id: 'u5-stepped-back-from', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | linkedin — Stepped back from ${L(ACME)}`]),
- 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'] } },
- { id: 'u5-parted-company-with', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | linkedin — Parted company with ${L(ACME)}`]),
- 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'] } },
- { id: 'u5-farewell', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | linkedin — Said goodbye to ${L(ACME)} after four years`]),
- 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'] } },
- { id: 'u5-exchange-ends-first', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | linkedin — Swapped ${L(ACME)} for ${L(BETA)} (designer)`]),
- 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'] } },
- { id: 'u5-exchange-starts-second', unit: 'U5', target: BETA, content: JOB([`**2019-03-04** | linkedin — Swapped ${L(ACME)} for ${L(BETA)} (designer)`]),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2019-03-04'], live: { type: 'works_at', at: { '2018-01-01': false, today: true } } } },
- { id: 'u5-traded-shares-control', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | note — Traded shares of ${L(ACME)} for cash`]),
- off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] }, on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] } },
- { id: 'u5-event-line-control', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | event — Said goodbye to ${L(ACME)} at the farewell dinner`]),
- off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] }, on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] } },
- { id: 'u5-qualified-control', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | note — Said goodbye to ${L(ACME)}'s old office`]),
- off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] }, on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'] } },
- // Unsupported, frozen: U5 does not resolve the subject (a third party's leave on the page dates the subject's stint).
- { id: 'u5-third-party-split-leave', unit: 'U5', target: ACME, content: JOB([`**2019-03-04** | note — Her manager handed in his notice at ${L(ACME)}`]),
- 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'] } },
- // Restart guard: a later plain mention no cue reads (an onboarding week) keeps the stint open; without the guard the
- // leave would close the current job for good (the dev trace's onboarding losses).
- { id: 'u56-rejoin-restart-guard', unit: ['U5', 'U6'], target: ACME,
- content: page(`Alice works at ${L(ACME)} as head of sales.`, [`**2015-01-02** | linkedin — Joined ${L(ACME)} as engineer`, `**2018-03-04** | linkedin — Parted company with ${L(ACME)}`, `**2020-08-11** | linkedin — Onboarding week at ${L(ACME)} as head of sales`]),
- off: { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'], live: { type: 'works_at', at: { '2019-01-01': true, today: true } } },
- on: units => !units.has('U6')
- ? { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02'], live: { type: 'works_at', at: { '2019-01-01': true, today: true } } }
- : { 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'] },
- 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 } } } },
-];
-
-// ─── U6: start framings (dated starts of an asserted works_at) ─────────
-const NOW_AT = (line: string) => page(`Alice works at ${L(ACME)} as designer.`, [`**2021-09-01** | ${line.replace('{X}', L(ACME))}`]);
-const U6: TypingExample[] = [
- { id: 'u6-first-day-at', unit: 'U6', target: ACME, content: NOW_AT('linkedin — First day at {X} as designer'),
- off: { types: ['mentions', 'works_at'], transitions: [] },
- on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2021-09-01'], live: { type: 'works_at', at: { '2021-01-01': false, today: true } } } },
- { id: 'u6-day-one', unit: 'U6', target: ACME, content: NOW_AT('linkedin — Day one with {X}'),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2021-09-01'] } },
- { id: 'u6-kicked-off-role', unit: 'U6', target: ACME, content: NOW_AT('linkedin — Kicked off a new role at {X}'),
- off: { types: ['works_at'], transitions: [] }, on: { types: ['works_at'], transitions: ['works_at start 2021-09-01'] } },
- { id: 'u6-onboarded-at', unit: 'U6', target: ACME, content: NOW_AT('linkedin — Onboarded at {X} this week'),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2021-09-01'] } },
- { id: 'u6-began-working-at', unit: 'U6', target: ACME, content: NOW_AT('linkedin — Began working at {X}'),
- off: { types: ['works_at'], transitions: [] }, on: { types: ['works_at'], transitions: ['works_at start 2021-09-01'] } },
- { id: 'u6-new-chapter-at', unit: 'U6', target: ACME, content: NOW_AT('linkedin — Starting a new chapter at {X} as designer'),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: ['works_at start 2021-09-01'] } },
- { id: 'u6-kickoff-without-employment-noun', unit: 'U6', target: ACME, content: NOW_AT('note — Kick-off at {X} for the new project'),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: [] } },
- { id: 'u6-first-day-of-summit', unit: 'U6', target: ACME, content: NOW_AT('event — First day of the {X} summit'),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: [] } },
- { id: 'u6-event-line-first-day', unit: 'U6', target: ACME, content: NOW_AT('event — First day at the {X} hackathon'),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: [] } },
- { id: 'u6-onboarding-call-qualified', unit: 'U6', target: ACME, content: NOW_AT("meeting — Onboarding call with the {X} alumni mentors"),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: [] } },
- { id: 'u6-began-working-with-collaboration', unit: 'U6', target: ACME, content: NOW_AT('note — Began working with {X} on a pilot'),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: [] } },
- // Leave guard: an unread leave after the start drops the U6 start (the former job would stay open for good); U5 reads
- // this leave, so with U5 the start and the end both date the stint.
- { id: 'u56-former-job-leave-guard', unit: ['U5', 'U6'], target: ACME,
- content: page(`Alice worked at ${L(ACME)}. She works at ${L(BETA)} now.`, [`**2015-01-02** | linkedin — First day at ${L(ACME)} as engineer`, `**2019-03-04** | linkedin — Parted company with ${L(ACME)}`]),
- off: { types: ['mentions', 'works_at'], transitions: [], live: { type: 'works_at', at: { '2016-01-01': false, today: false } } },
- on: units => units.has('U5') && units.has('U6')
- ? { types: ['mentions', 'works_at'], transitions: ['works_at start 2015-01-02', 'works_at end 2019-03-04'], live: { type: 'works_at', at: { '2016-01-01': true, today: false } } }
- : units.has('U5') ? { types: ['mentions', 'works_at'], transitions: ['works_at end 2019-03-04'], live: { type: 'works_at', at: { '2016-01-01': true, today: false } } }
- : { types: ['mentions', 'works_at'], transitions: [], live: { type: 'works_at', at: { '2016-01-01': false, today: false } } } },
- { id: 'u6-advisory-page-not-started', unit: 'U6', target: ACME,
- content: page(`Alice works at ${L(ACME)} as designer. She also works at ${L(BETA)}.`, [`**2021-09-01** | linkedin — First day at ${L(ACME)} as designer`, `**2023-02-03** | note — Became an advisor at ${L(BETA)}`]),
- off: { types: ['mentions', 'works_at'], transitions: [] }, on: { types: ['mentions', 'works_at'], transitions: [] } },
- { id: 'u6-untyped-target-not-started', unit: 'U6', target: BETA,
- content: page(`Alice works at ${L(ACME)}.`, [`**2021-09-01** | linkedin — First day at ${L(BETA)}`]),
- off: { types: ['mentions'], transitions: [] }, on: { types: ['mentions'], transitions: [] } },
-];
-
-export const EXAMPLES: TypingExample[] = [...U1, ...U2, ...U3, ...U4, ...U5, ...U6];
+export const EXAMPLES: TypingExample[] = [...U1, ...U3, ...U4];
diff --git a/test/link-typing-units-subsets.test.ts b/test/link-typing-units-subsets.test.ts
index edd468db45..c66dacb9b7 100644
--- a/test/link-typing-units-subsets.test.ts
+++ b/test/link-typing-units-subsets.test.ts
@@ -1,8 +1,9 @@
/**
- * Every subset of the typing units (2^6 = 64) passes the frozen examples (test/helpers/typing-unit-examples.ts), so
- * any package the selection procedure orders is a tested build. With no unit, extraction types the world-v1 corpus
- * byte-identically to master (digest of master c5fb0201, scripts/q2-typing-dev.ts world-v1); that check needs a
- * gbrain-evals checkout (GBRAIN_TEST_TYPING_EVALS_DIR, else ../gbrain-evals) and is skipped without one.
+ * Every subset of the shipped typing units (U1, U3, U4: 2^3 = 8) passes the frozen examples
+ * (test/helpers/typing-unit-examples.ts). With no unit, extraction types the world-v1 corpus byte-identically to master
+ * (digest of master c5fb0201); with the shipped package it types it as the confirmed package afcec1ad did
+ * (scripts/q2-typing-dev.ts world-v1). Those checks need a gbrain-evals checkout (GBRAIN_TEST_TYPING_EVALS_DIR, else
+ * ../gbrain-evals) and are skipped without one.
*/
import { describe, expect, test } from 'bun:test';
import { existsSync, readFileSync } from 'node:fs';
@@ -15,7 +16,7 @@ import { EXAMPLES, expected, observe } from './helpers/typing-unit-examples.ts';
const subsets: TypingUnit[][] = Array.from({ length: 1 << TYPING_UNITS.length }, (_, mask) => TYPING_UNITS.filter((_, i) => mask & (1 << i)));
-describe('typing units: all 64 subsets pass the frozen examples', () => {
+describe(`typing units: all ${subsets.length} subsets pass the frozen examples`, () => {
for (const units of subsets) {
test(`{${units.join(',')}}`, async () => {
await withTypingUnits(units, async () => {
@@ -38,3 +39,9 @@ test.skipIf(!haveWorld)('no unit: world-v1 typing is byte-identical to master',
const r = await withTypingUnits([], () => worldV1Edges(loadWorldV1(worldDir), extractPageLinks as never, deriveTemporalEvidence as never));
expect(r.sha256).toBe(master);
}, 60_000);
+
+test.skipIf(!haveWorld)('shipped package: world-v1 typing is byte-identical to the confirmed package afcec1ad', async () => {
+ const confirmed = readFileSync(join(import.meta.dir, 'fixtures/q2-typing-units/world-v1-confirmed-package.sha256'), 'utf8').trim();
+ const r = await worldV1Edges(loadWorldV1(worldDir), extractPageLinks as never, deriveTemporalEvidence as never);
+ expect(r.sha256).toBe(confirmed);
+}, 60_000);
diff --git a/test/link-typing-units.test.ts b/test/link-typing-units.test.ts
index f3ede5227a..633634ffab 100644
--- a/test/link-typing-units.test.ts
+++ b/test/link-typing-units.test.ts
@@ -1,6 +1,6 @@
/**
* Typing units (src/core/link-typing-units.ts): each example's frozen type, tense, transitions and as-of result with
- * no unit, with only its own unit, and with every unit (test/helpers/typing-unit-examples.ts).
+ * no unit, with only its own unit, and with every shipped unit (test/helpers/typing-unit-examples.ts).
*/
import { describe, expect, test } from 'bun:test';
import { TYPING_UNITS, ENABLED_TYPING_UNITS, activeTypingUnits, parseTypingUnits, withTypingUnits, type TypingUnit } from '../src/core/link-typing-units.ts';
@@ -22,16 +22,18 @@ describe('typing units: frozen examples', () => {
});
describe('typing unit switch', () => {
- test('the build ships with no unit enabled until the verdict', () => {
- expect([...ENABLED_TYPING_UNITS]).toEqual([]);
- expect(activeTypingUnits()).toEqual([]);
+ test('the build ships the confirmed package: U3, U4, U1', () => {
+ expect([...ENABLED_TYPING_UNITS]).toEqual(['U3', 'U4', 'U1']);
+ expect(activeTypingUnits()).toEqual(['U1', 'U3', 'U4']);
});
test('withTypingUnits restores the previous set', async () => {
- await withTypingUnits(['U2', 'U1'], () => expect(activeTypingUnits()).toEqual(['U1', 'U2']));
- expect(activeTypingUnits()).toEqual([]);
+ await withTypingUnits(['U3', 'U1'], () => expect(activeTypingUnits()).toEqual(['U1', 'U3']));
+ await withTypingUnits([], () => expect(activeTypingUnits()).toEqual([]));
+ expect(activeTypingUnits()).toEqual(['U1', 'U3', 'U4']);
});
- test('unknown unit ids are refused with the list of units', () => {
- expect(() => parseTypingUnits(['U7'])).toThrow(/Unknown typing unit "U7". The units are U1, U2, U3, U4, U5, U6/);
- expect(parseTypingUnits(['u2', ' U1 ', 'U2'])).toEqual(['U2', 'U1']);
+ test('unknown or removed unit ids are refused with the list of units', () => {
+ expect(() => parseTypingUnits(['U2'])).toThrow(/Unknown typing unit "U2". The units are U1, U3, U4 and the joint U34/);
+ expect(() => parseTypingUnits(['U25'])).toThrow(/Unknown typing unit "U25"/);
+ expect(parseTypingUnits(['u3', ' U1 ', 'U3'])).toEqual(['U3', 'U1']);
});
});
diff --git a/test/q2-typing-package.test.ts b/test/q2-typing-package.test.ts
index 9f790e82f9..9f445d5ba9 100644
--- a/test/q2-typing-package.test.ts
+++ b/test/q2-typing-package.test.ts
@@ -3,21 +3,20 @@ import { expect, test } from 'bun:test';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { packageBranchName, withEnabledUnits } from '../scripts/q2-typing-package.ts';
-import { TYPING_UNITS, parseTypingUnits, withTypingUnits } from '../src/core/link-typing-units.ts';
-import { EXAMPLES, expected, observe } from './helpers/typing-unit-examples.ts';
+import { parseTypingUnits } from '../src/core/link-typing-units.ts';
const source = readFileSync(join(import.meta.dir, '../src/core/link-typing-units.ts'), 'utf8');
test('the package commit changes exactly the ENABLED_TYPING_UNITS line, in the given order', () => {
- const next = withEnabledUnits(source, ['U2', 'U1', 'U5']);
+ const next = withEnabledUnits(source, ['U4', 'U1', 'U3']);
const changed = next.split('\n').filter((line, i) => line !== source.split('\n')[i]);
- expect(changed).toEqual([`export const ENABLED_TYPING_UNITS: ReadonlySet<TypingUnit> = new Set<TypingUnit>(['U2', 'U1', 'U5']);`]);
- expect(withEnabledUnits(next, [])).toBe(source);
+ expect(changed).toEqual([`export const ENABLED_TYPING_UNITS: ReadonlySet<TypingUnit> = new Set<TypingUnit>(['U4', 'U1', 'U3']);`]);
+ expect(withEnabledUnits(next, ['U3', 'U4', 'U1'])).toBe(source);
});
test('a joint unit expands in place and branch names say what the ref holds', () => {
- expect(parseTypingUnits(['U2', 'U34'])).toEqual(['U2', 'U3', 'U4']);
- expect(packageBranchName('abc123def', ['U2', 'U3', 'U4'], false)).toBe('q2-typing/abc123def/U2-U3-U4');
+ expect(parseTypingUnits(['U34', 'U1'])).toEqual(['U3', 'U4', 'U1']);
+ expect(packageBranchName('abc123def', ['U3', 'U4', 'U1'], false)).toBe('q2-typing/abc123def/U3-U4-U1');
expect(packageBranchName('abc123def', ['U3', 'U4'], true)).toBe('q2-typing/abc123def/arm-U3U4');
expect(packageBranchName('abc123def', [], false)).toBe('q2-typing/abc123def/none');
});
@@ -25,17 +24,3 @@ test('a joint unit expands in place and branch names say what the ref holds', ()
test('a units file without the declaration is refused with what to restore', () => {
expect(() => withEnabledUnits('export const X = 1;', ['U1'])).toThrow(/has no "export const ENABLED_TYPING_UNITS/);
});
-
-test('the amended family {U1, U25, U34, U6} expands to all six units and its package passes the frozen examples', async () => {
- const units = parseTypingUnits(['U1', 'U25', 'U34', 'U6']);
- expect(units).toEqual(['U1', 'U2', 'U5', 'U3', 'U4', 'U6']);
- expect([...units].sort()).toEqual([...TYPING_UNITS]);
- expect(withEnabledUnits(source, units)).toContain(`new Set<TypingUnit>(['U1', 'U2', 'U5', 'U3', 'U4', 'U6'])`);
- expect(packageBranchName('abc123def', parseTypingUnits(['U25']), true)).toBe('q2-typing/abc123def/arm-U2U5');
- await withTypingUnits(units, async () => {
- for (const ex of EXAMPLES) {
- const want = expected(ex, new Set(units));
- expect({ id: ex.id, ...(await observe(ex, want)) }).toEqual({ id: ex.id, ...want });
- }
- });
-});