f96fdcb3b9
Lock health recording behind confirm-only state machines, reject public publishes for the health category, and ship the 14-day experiment Page Data templates with tests. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
1017 B
JavaScript
27 lines
1017 B
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
matchHealthIdleRules,
|
|
shouldForceActionChoice,
|
|
shouldRedirectOrdinaryChatToHealth,
|
|
} from './health-intent-rules.mjs';
|
|
|
|
test('rule hits blood pressure pairs without LLM', () => {
|
|
const hit = matchHealthIdleRules('血压 137/82');
|
|
assert.equal(hit.matched, true);
|
|
assert.equal(hit.extracted.systolic, 137);
|
|
assert.equal(hit.extracted.diastolic, 82);
|
|
assert.equal(shouldForceActionChoice(hit), false);
|
|
});
|
|
|
|
test('unmatched chatter forces a menu', () => {
|
|
const miss = matchHealthIdleRules('帮我看看明天天气');
|
|
assert.equal(miss.matched, false);
|
|
assert.equal(shouldForceActionChoice(miss, { confidence: 0.4, top1: 0.4, top2: 0.35 }), true);
|
|
});
|
|
|
|
test('ordinary chat health phrases only redirect and never imply a write', () => {
|
|
assert.equal(shouldRedirectOrdinaryChatToHealth('帮我记一下血压 128/76'), true);
|
|
assert.equal(shouldRedirectOrdinaryChatToHealth('做个旅游攻略页面'), false);
|
|
});
|