Slow Triage
Exact reviewed source / 40 of 64

prototype/tests/inference.test.mjs

SHA-256 of original bytes
652ced6ce232e489f5434149d645e693ce8ce532be9751696bb037af08aaa4dc
import test from 'node:test';
import assert from 'node:assert/strict';
import {readFile} from 'node:fs/promises';
import {embedTexts} from '../src/model.mjs';
import {runTriage,STEPS} from '../src/workflow.mjs';
let networkAttempts=0;
globalThis.fetch=async()=>{networkAttempts++;throw new Error('Network is blocked during this inference test.');};
test('real local embeddings have 384 dimensions and change with meaning',async()=>{
 const vectors=await embedTexts(['The app crashes during export.','The app crashes during export.','A quiet lake under the evening stars.']);
 assert.equal(vectors.length,3);assert.equal(vectors[0].length,384);
 assert.deepEqual(vectors[0],vectors[1]);assert.notDeepEqual(vectors[0],vectors[2]);
 assert.ok(Math.abs(vectors[0].reduce((sum,x)=>sum+x*x,0)-1)<1e-5);assert.equal(networkAttempts,0);
});
test('Mastra actually executes every stage and review decisions repeat',async()=>{
 const sample=JSON.parse(await readFile(new URL('../data/sample.json',import.meta.url),'utf8'));
 const first=await runTriage(sample),second=await runTriage(sample);
 assert.equal(first.execution.status,'success');
 for(const id of STEPS)assert.equal(first.execution.steps.find(step=>step.id===id)?.status,'success');
 assert.equal(first.items.length,10);
 assert.deepEqual(first.items.map(({suggestedLabel,needsReview,similarity,duplicateOf})=>({suggestedLabel,needsReview,similarity,duplicateOf})),second.items.map(({suggestedLabel,needsReview,similarity,duplicateOf})=>({suggestedLabel,needsReview,similarity,duplicateOf})));
 assert.ok(first.items.some(x=>x.needsReview));assert.ok(first.items.some(x=>!x.needsReview));assert.ok(first.items.some(x=>x.duplicateOf!==null));assert.equal(networkAttempts,0);
});
← prototype/tests/http.test.mjsprototype/tests/setup_test.py →