test: version-coupling pins go major-agnostic — the 8.x literals broke at the 9.0.0 bump while the coupling law itself behaved correctly
Some checks are pending
CI / Node 22 (push) Waiting to run
CI / Node 24 (push) Waiting to run
CI / Bun (latest) (push) Waiting to run

This commit is contained in:
David Snelling 2026-08-04 10:05:34 -07:00
parent 3e6e523727
commit 8a6807e80b

View file

@ -63,7 +63,9 @@ describe('getBrainyVersion() — synchronously correct on first call', () => {
expect(v).toBe(PACKAGE_VERSION)
expect(v).not.toBe('3.14.0')
expect(v).not.toBe('0.0.0') // the unknown-read sentinel must not surface in a real install
expect(v.startsWith('8.')).toBe(true)
// Deliberately major-agnostic: the equality with PACKAGE_VERSION above already
// proves the sync read; this shape pin only guards against sentinel garbage.
expect(v).toMatch(/^\d+\.\d+\.\d+/)
})
})
@ -95,13 +97,16 @@ describe('version coupling at init() — no silent fallback', () => {
await brain.close()
})
it('does NOT throw for a realistic cor 3.x range (^8.0.0) on a COLD init', async () => {
it('does NOT throw for a realistic version-matched caret range on a COLD init', async () => {
// The actual regression: loadPlugins() is the first init step and makes the
// first getBrainyVersion() call, so a stale sync default would reject a
// correctly-matched native provider declaring the real 8.x range. A fresh
// brain registering a `^8.0.0` plugin must init cleanly.
// first getBrainyVersion() call, so a stale sync default ('3.14.0') would
// reject a correctly-matched native provider declaring the real caret range —
// it fails ^<current-major> just as it failed ^8, so the regression intent is
// preserved while the range stays major-agnostic. A fresh brain registering a
// `^<current-major>.0.0` plugin must init cleanly.
const major = PACKAGE_VERSION.split('.')[0]
const brain = memBrain()
brain.use(fakePlugin('@fake/cor-3x', { brainyRange: '^8.0.0' }))
brain.use(fakePlugin('@fake/cor-3x', { brainyRange: `^${major}.0.0` }))
await expect(brain.init()).resolves.toBeUndefined()
await brain.close()
})