From 96adb172eb74ff6481755633ffc4e59cb1afb049 Mon Sep 17 00:00:00 2001 From: jianf <2198972886@qq.com> Date: Sun, 1 Nov 2026 11:01:44 +0800 Subject: [PATCH] test(memory-b): add F8 checkpoint for width validation --- scripts/checkpoints.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/scripts/checkpoints.js b/scripts/checkpoints.js index aa94d62..fd72bda 100644 --- a/scripts/checkpoints.js +++ b/scripts/checkpoints.js @@ -441,6 +441,41 @@ await checkpoint('F7', 'store stats groups active and stale fingerprints with DB } }) +// ── F8: explicit width errors, provider width errors degrade ───────────── +await checkpoint('F8', 'dimension validation separates caller errors from provider degradation', async () => { + const explicitApp = makeApp() + const explicit = applyMemory(explicitApp.ctx, { + path: join(workspace, 'f8-explicit.db'), + embedder: { info: () => ({ fingerprint: 'fp-f8', dimension: 3 }), embedText: async () => [1, 0, 0] }, + }) + try { + await assert.rejects( + () => explicit.commit({ text: 'F8 caller error', vector: [1, 2], fingerprint: 'fp-f8' }), + /does not match the active space/, + ) + assert.equal(explicit.store.countBlocks(), 0, 'caller width error must not write a block') + await explicit.commit({ text: 'F8 matching caller vector', vector: [1, 2, 3], fingerprint: 'fp-f8' }) + assert.equal(explicit.store.countBlocks(), 1, 'matching explicit vector is accepted') + } finally { + await explicitApp.ctx.fiber.dispose() + } + + const providerApp = makeApp() + const provider = applyMemory(providerApp.ctx, { + path: join(workspace, 'f8-provider.db'), + embedder: { info: () => ({ fingerprint: 'fp-f8-provider', dimension: 3 }), embedText: async () => [1, 2] }, + }) + try { + const result = await provider.commit({ text: 'F8 provider error' }) + assert.equal(result.embedded, false, 'provider width error must degrade without throwing') + assert.equal(provider.store.countBlocks(), 1, 'degraded provider write still persists the block') + assert.equal(provider.store.allBlocks(1)[0].vector, '', 'the bad provider vector is not stored') + } finally { + await providerApp.ctx.fiber.dispose() + } + return 'caller wrong width: rejected/no row; matching width: accepted; provider wrong width: degraded/row retained/vector empty' +}) + // ── cleanup ─────────────────────────────────────────────────────────────── rmSync(workspace, { recursive: true, force: true })