// 心跳自愈判定纯函数单测(看板 949)—— 仓库无 vitest,走 node 内置测试跑(零第三方依赖): // node --test tests/streamSelfHeal.test.mjs // 契约:仅「后端生成中 且 前端流式态丢失」自愈 —— 与迟到收尾仲裁(后端 true 且前端 true // 才拦截)判定域互补,两机制不同时动作。 import test from 'node:test' import assert from 'node:assert/strict' import { shouldSelfHealStreaming } from '../src/composables/ai/streamSelfHeal.ts' test('自愈:后端生成中而前端流式态丢失(force_send 竞态误杀场景)', () => { assert.equal(shouldSelfHealStreaming(true, false), true) }) test('不自愈:后端生成中且前端仍在流式(迟到仲裁管辖域)', () => { assert.equal(shouldSelfHealStreaming(true, true), false) }) test('不自愈:后端已终止(真收尾,收敛语义正确)', () => { assert.equal(shouldSelfHealStreaming(false, true), false) assert.equal(shouldSelfHealStreaming(false, false), false) })