Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
q2 typing: joint unit U25 (U2 with U5)
garrytan8c2567339e60
diff --git a/scripts/q2-typing-package.ts b/scripts/q2-typing-package.tsindex 4e517789bd..69a281e572 100644--- a/scripts/q2-typing-package.ts+++ b/scripts/q2-typing-package.ts@@ -3,8 +3,8 @@* 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 U2,U1,U5 # nested package arm (order = selection order)- * bun scripts/q2-typing-package.ts --base <ref> --arm U2 # one-unit arm (baseline + that unit; U34 = U3 with U4)+ * 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 none # the base with no unit (equivalence checks)* options: --branch <name> (default q2-typing/<base-short>/<arm-U2 | U2-U1-U5 | none>), --json*diff --git a/src/core/link-typing-units.ts b/src/core/link-typing-units.tsindex b735b716f1..ab13b8c723 100644--- a/src/core/link-typing-units.ts+++ b/src/core/link-typing-units.ts@@ -28,11 +28,12 @@ export function activeTypingUnits(): TypingUnit[] {}/**- * Joint units: ids that stand for several units measured together. U34 is U3 with U4: the development trace showed- * 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).+ * 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.*/-export const JOINT_TYPING_UNITS: Readonly<Record<string, readonly TypingUnit[]>> = { U34: ['U3', 'U4'] };+export const JOINT_TYPING_UNITS: Readonly<Record<string, readonly TypingUnit[]>> = { U25: ['U2', 'U5'], U34: ['U3', 'U4'] };export function parseTypingUnits(units: Iterable<string>): TypingUnit[] {const out: TypingUnit[] = [];diff --git a/test/q2-typing-package.test.ts b/test/q2-typing-package.test.tsindex f3e5bffe7e..9f790e82f9 100644--- a/test/q2-typing-package.test.ts+++ b/test/q2-typing-package.test.ts@@ -3,7 +3,8 @@ 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 { parseTypingUnits } from '../src/core/link-typing-units.ts';+import { TYPING_UNITS, parseTypingUnits, withTypingUnits } from '../src/core/link-typing-units.ts';+import { EXAMPLES, expected, observe } from './helpers/typing-unit-examples.ts';const source = readFileSync(join(import.meta.dir, '../src/core/link-typing-units.ts'), 'utf8');@@ -24,3 +25,17 @@ 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 });+ }+ });+});