From bb6aa280ea0f14ff06b3b487999834567a8a65b2 Mon Sep 17 00:00:00 2001 From: liujieranjerry-lgtm Date: Mon, 23 Nov 2026 17:45:26 +0800 Subject: [PATCH] fix(reader): explain nested terms against the cards they came from MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A concept the reader reached from a card elsewhere in the chain was either re-explained from scratch (the model never saw the ancestor cards) or, because dedupe is global by term, handed back as the very card that raised the question — which reads as A explained by B explained by A. Pass the ancestor chain (farthest first, capped, cycle-safe) into both explain prompts so a nested answer is contextual, and when the requested term is itself one of those ancestors return that stored card with `route: "ancestor"` instead of silently re-using it. No extra model call, no store write, no schema change; the card shows a one-line reason and the top-level prompt is byte-identical. --- dsh-reader/client.js | 10 + dsh-reader/index.js | 46 ++++- dsh-reader/lib/explain.js | 27 ++- dsh-reader/src/client/app.js | 8 + dsh-reader/src/client/i18n.js | 2 + dsh-reader/test/ancestor-explain.test.mjs | 220 ++++++++++++++++++++++ dsh-reader/test/explain.test.mjs | 47 +++++ dsh-reader/test/host.test.mjs | 57 ++++++ 8 files changed, 412 insertions(+), 5 deletions(-) create mode 100644 dsh-reader/test/ancestor-explain.test.mjs diff --git a/dsh-reader/client.js b/dsh-reader/client.js index 4a02ce0..e58a215 100644 --- a/dsh-reader/client.js +++ b/dsh-reader/client.js @@ -225,6 +225,7 @@ const ZH = { 'action.copyDiagnostics': '复制诊断信息', 'label.readerError': '阅读器出错了', 'label.nestLimit': '嵌套最多 3 层', + 'label.ancestorRevisit': '这个词本链路上层已有解释,已为你打开原卡片(不重复生成)', 'label.conceptSaved': '已收下', 'label.pinned': '已固定', 'label.openFromSession': '请从会话中打开阅读视图', @@ -457,6 +458,7 @@ const EN = { 'action.copyDiagnostics': 'Copy diagnostics', 'label.readerError': 'The reader hit an error', 'label.nestLimit': 'Nesting is limited to 3 levels', + 'label.ancestorRevisit': 'This term is already explained one level up; showing that card instead of repeating it', 'label.conceptSaved': 'Saved', 'label.pinned': 'Pinned', 'label.openFromSession': 'Open the reader from a session', @@ -4267,6 +4269,13 @@ function ReaderView(props) { }) const concept = result.concept if (result.store) mergeStore(result.store) + if (result.ancestor) { + // The reader walked down the chain and asked about a term that raised it: + // show that card with the reason instead of pretending it is new. + setCards((current) => replaceTop(current, { id: concept.id, pinned: true, rect, hint: t('label.ancestorRevisit') })) + flash(t('label.ancestorRevisit')) + return + } setCards((current) => replaceTop(current, { id: concept.id, pinned: true, rect })) flash(`${t('label.conceptSaved')}:${concept.term}`) } catch (e) { @@ -6723,6 +6732,7 @@ function ReaderView(props) { chain.length ? h('div', { className: 'rd-muted', style: { fontSize: '11px', marginBottom: '7px' } }, chain.map((item) => item.term).join(' › ')) : null, + card.hint ? h('div', { className: 'rd-muted', style: { fontSize: '11px', marginBottom: '7px' } }, card.hint) : null, h('div', { className: 'rd-def' }, concept.definition || ''), concept.intuition ? h('div', { className: 'rd-sec' }, h('b', null, t('label.intuition') + ' '), concept.intuition) diff --git a/dsh-reader/index.js b/dsh-reader/index.js index be654a7..9782a8b 100644 --- a/dsh-reader/index.js +++ b/dsh-reader/index.js @@ -265,6 +265,27 @@ async function complete( return reply } +const MAX_ANCESTOR_DEPTH = 4 + +/** + * The cards the reader came through, farthest ancestor first. Parents are only + * ever set to an already-stored concept, but the walk keeps a visited set so a + * hand-edited or migrated store can never spin here. + */ +function ancestorChain(concepts, startId) { + const chain = [] + const seen = new Set() + let current = typeof startId === 'string' && startId ? concepts?.[startId] : null + while (current && chain.length < MAX_ANCESTOR_DEPTH) { + const id = typeof current.id === 'string' && current.id ? current.id : null + if (!id || seen.has(id)) break + seen.add(id) + chain.push(current) + current = current.parentId ? concepts?.[current.parentId] : null + } + return chain.reverse() +} + async function explainConcept(ctx, cwd, body) { const term = String(body?.term || '').trim() if (!term) throw httpError(400, 'term required') @@ -278,10 +299,29 @@ async function explainConcept(ctx, cwd, body) { return Array.isArray(concept.aliases) && concept.aliases.some((alias) => normalizeTerm(alias) === key) }) const model = pluginModel(store, ctx) + const ancestors = ancestorChain(store.concepts, body?.parentId) const depth = body?.depth === 'full' ? 'full' : 'quick' if (existing) { + // Asking about a concept that is already on the path the reader came down + // would hand back the very card that raised the question. Reuse it as a + // step back up instead of re-explaining it against itself. + if (ancestors.some((item) => item.id === existing.id)) { + return { + concept: existing, + reused: true, + ancestor: true, + route: 'ancestor', + chain: ancestors.map((item) => ({ id: item.id, term: item.term })), + } + } if (depth === 'full' && existing.depth !== 'full' && existing.source !== 'user') { - const { system, user } = buildExplainPrompt({ term: existing.term, sentence, paragraph, docTitle: body?.docTitle }) + const { system, user } = buildExplainPrompt({ + term: existing.term, + sentence, + paragraph, + docTitle: body?.docTitle, + ancestors, + }) const parsed = parseExplanation( await complete(ctx, { system, @@ -365,8 +405,8 @@ async function explainConcept(ctx, cwd, body) { const quick = depth === 'quick' const { system, user } = quick - ? buildQuickExplainPrompt({ term, sentence, docTitle: body?.docTitle }) - : buildExplainPrompt({ term, sentence, paragraph, docTitle: body?.docTitle }) + ? buildQuickExplainPrompt({ term, sentence, docTitle: body?.docTitle, ancestors }) + : buildExplainPrompt({ term, sentence, paragraph, docTitle: body?.docTitle, ancestors }) const quickEffort = quick ? await pickEffort(ctx, model.provider, model.model, 'low') : null // Single-flight: two readers explaining the same term share one model call. const inflightKey = `${cwd}|${key}|${depth}` diff --git a/dsh-reader/lib/explain.js b/dsh-reader/lib/explain.js index a8d2e12..d592767 100644 --- a/dsh-reader/lib/explain.js +++ b/dsh-reader/lib/explain.js @@ -8,6 +8,23 @@ function strings(value, limit) { return Array.isArray(value) ? value.filter((x) => typeof x === 'string' && x.trim()).slice(0, limit) : [] } +const NESTED_RULE = + '如果「词条」本身就是某个上层概念或它的别名,不要重复该概念已有的定义,改为说明它在这段话里具体指什么、与上层概念的差别。' + +/** Ancestors of the card the reader is looking at, farthest first. */ +function ancestorLines(ancestors) { + const list = (Array.isArray(ancestors) ? ancestors : []).filter((item) => item && text(item.term)) + if (list.length === 0) return [] + return [ + '', + '上层解释(从远到近,读者正在看这些卡片):', + ...list.map( + (item, index) => + `${index + 1}. ${text(item.term)}${text(item.definition) ? ':' + text(item.definition).slice(0, 120) : ''}`, + ), + ] +} + /** Turn one model reply into concept fields, tolerating fences and prose. */ export function parseExplanation(reply) { const raw = String(reply ?? '') @@ -109,22 +126,26 @@ export function buildAskPrompt({ concept, question, related = [], web = null }) } /** Compact first-pass explanation: two fields, low latency. */ -export function buildQuickExplainPrompt({ term, sentence, docTitle }) { +export function buildQuickExplainPrompt({ term, sentence, docTitle, ancestors = [] }) { + const layered = ancestorLines(ancestors) const system = [ '你是阅读助手。读者只需要快速理解这个词。', '只输出一个 JSON 对象:{"definition":"一句话定义,60 字以内","intuition":"一句话直觉或比喻,40 字以内","examples":["一个短例子"]}。', '不要展开长文;不确定就直说。', + ...(layered.length ? [NESTED_RULE] : []), ].join('') const user = [ `书名:${text(docTitle) || '未知'}`, `原文:${text(sentence).slice(0, 300)}`, `词条:${text(term)}`, + ...layered, ].join('\n') return { system, user } } /** Build the single-shot explanation prompt; never send more than one paragraph. */ -export function buildExplainPrompt({ term, sentence, paragraph, docTitle }) { +export function buildExplainPrompt({ term, sentence, paragraph, docTitle, ancestors = [] }) { + const layered = ancestorLines(ancestors) const system = [ '你是阅读助手,帮助读者理解正在读的书里的概念。', '只输出一个 JSON 对象,不要输出其他文字。字段:', @@ -133,12 +154,14 @@ export function buildExplainPrompt({ term, sentence, paragraph, docTitle }) { 'context:结合这本书的语境说明为什么这里用它,不超过 80 字;', 'examples:0-3 个短例子;related:0-3 个相关概念名。', '不确定时用“可能指 A 或 B”表达,禁止编造。', + ...(layered.length ? [NESTED_RULE] : []), ].join('') const user = [ `书名:${text(docTitle) || '未知'}`, `概念:${text(term)}`, `所在句:${text(sentence).slice(0, 240)}`, `所在段落:${text(paragraph).slice(0, 600)}`, + ...layered, '请输出 JSON。', ].join('\n') return { system, user } diff --git a/dsh-reader/src/client/app.js b/dsh-reader/src/client/app.js index 6c155e0..b8b577b 100644 --- a/dsh-reader/src/client/app.js +++ b/dsh-reader/src/client/app.js @@ -1015,6 +1015,13 @@ export function ReaderView(props) { }) const concept = result.concept if (result.store) mergeStore(result.store) + if (result.ancestor) { + // The reader walked down the chain and asked about a term that raised it: + // show that card with the reason instead of pretending it is new. + setCards((current) => replaceTop(current, { id: concept.id, pinned: true, rect, hint: t('label.ancestorRevisit') })) + flash(t('label.ancestorRevisit')) + return + } setCards((current) => replaceTop(current, { id: concept.id, pinned: true, rect })) flash(`${t('label.conceptSaved')}:${concept.term}`) } catch (e) { @@ -3471,6 +3478,7 @@ export function ReaderView(props) { chain.length ? h('div', { className: 'rd-muted', style: { fontSize: '11px', marginBottom: '7px' } }, chain.map((item) => item.term).join(' › ')) : null, + card.hint ? h('div', { className: 'rd-muted', style: { fontSize: '11px', marginBottom: '7px' } }, card.hint) : null, h('div', { className: 'rd-def' }, concept.definition || ''), concept.intuition ? h('div', { className: 'rd-sec' }, h('b', null, t('label.intuition') + ' '), concept.intuition) diff --git a/dsh-reader/src/client/i18n.js b/dsh-reader/src/client/i18n.js index daa449f..79c11ba 100644 --- a/dsh-reader/src/client/i18n.js +++ b/dsh-reader/src/client/i18n.js @@ -179,6 +179,7 @@ const ZH = { 'action.copyDiagnostics': '复制诊断信息', 'label.readerError': '阅读器出错了', 'label.nestLimit': '嵌套最多 3 层', + 'label.ancestorRevisit': '这个词本链路上层已有解释,已为你打开原卡片(不重复生成)', 'label.conceptSaved': '已收下', 'label.pinned': '已固定', 'label.openFromSession': '请从会话中打开阅读视图', @@ -411,6 +412,7 @@ const EN = { 'action.copyDiagnostics': 'Copy diagnostics', 'label.readerError': 'The reader hit an error', 'label.nestLimit': 'Nesting is limited to 3 levels', + 'label.ancestorRevisit': 'This term is already explained one level up; showing that card instead of repeating it', 'label.conceptSaved': 'Saved', 'label.pinned': 'Pinned', 'label.openFromSession': 'Open the reader from a session', diff --git a/dsh-reader/test/ancestor-explain.test.mjs b/dsh-reader/test/ancestor-explain.test.mjs new file mode 100644 index 0000000..afc58a5 --- /dev/null +++ b/dsh-reader/test/ancestor-explain.test.mjs @@ -0,0 +1,220 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { JSDOM } from 'jsdom' +import React from 'react' + +const here = path.dirname(fileURLToPath(import.meta.url)) +const dom = new JSDOM('
', { url: 'http://localhost' }) +const win = dom.window + +globalThis.window = win +globalThis.document = win.document +Object.defineProperty(globalThis, 'navigator', { value: win.navigator, configurable: true }) +globalThis.HTMLElement = win.HTMLElement +globalThis.Node = win.Node +globalThis.NodeFilter = win.NodeFilter +globalThis.MutationObserver = win.MutationObserver +globalThis.getComputedStyle = win.getComputedStyle +globalThis.requestAnimationFrame = (callback) => setTimeout(callback, 0) +globalThis.cancelAnimationFrame = (id) => clearTimeout(id) +globalThis.DOMParser = win.DOMParser +if (win.Range) { + win.Range.prototype.getBoundingClientRect = () => ({ left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 }) + win.Range.prototype.getClientRects = () => [] +} + +const tick = (ms = 25) => new Promise((resolve) => setTimeout(resolve, ms)) + +function json(value) { + return Promise.resolve({ + ok: true, + status: 200, + json: async () => value, + arrayBuffer: async () => new TextEncoder().encode('').buffer, + headers: { get: () => null }, + }) +} + +const parentConcept = { + id: 'parent', + term: '线性一致性', + definition: '所有节点看到同一份历史。', + depth: 'full', + source: 'agent', + status: 'ready', + createdAt: 1, + updatedAt: 1, + occurrences: [], +} + +let store +let lastExplainBody = null + +function resetStore() { + store = { + version: 2, + prefs: {}, + concepts: { parent: { ...parentConcept } }, + docs: { fp1: { path: 'book.md', size: 0, mtime: 0, positions: {}, annotations: [] } }, + } + lastExplainBody = null +} + +globalThis.fetch = async (url, init = {}) => { + const target = String(url) + if (target.includes('/api/list')) { + return json({ cwd: '/w', dir: '.', entries: [{ name: 'book.md', type: 'file', path: 'book.md' }] }) + } + if (target.includes('/api/models')) { + return json({ current: { provider: 'p', model: 'm' }, providers: [] }) + } + if (target.includes('/api/explain')) { + lastExplainBody = JSON.parse(init.body) + // What the route returns when the requested term is already one of the cards + // the reader came from: the stored card, flagged as a step back up. + return json({ + concept: store.concepts.parent, + reused: true, + ancestor: true, + route: 'ancestor', + chain: [{ id: 'parent', term: '线性一致性' }], + }) + } + if (target.includes('/api/store') && !target.includes('/api/mutate')) { + return json({ store }) + } + if (target.includes('/api/file')) { + const bytes = new TextEncoder() + .encode('# Title\n\n线性一致性是最强的一致性模型之一,这一段落足够长以便选中其中的词条。\n') + .buffer + return { + ok: true, + status: 200, + json: async () => ({}), + arrayBuffer: async () => bytes, + headers: { get: (name) => (name === 'x-doc-fingerprint' ? 'fp1' : null) }, + } + } + if (target.includes('/api/mutate')) { + return json({ store }) + } + return json({}) +} + +function loadBundle() { + const code = fs.readFileSync(path.join(here, '..', 'client.js'), 'utf8') + let entry = null + win.__ModuleLoader__ = { + load(registration) { + entry = registration + }, + } + new Function('window', code)(win) + const mod = entry.factory((name) => { + if (name === 'react') return React + throw new Error('unexpected module ' + name) + }) + let component = null + mod.apply({ + slots: { + inject(_key, callback) { + callback() + }, + register(_options, registered) { + component = registered + return () => {} + }, + }, + }) + return component +} + +class Boundary extends React.Component { + constructor(props) { + super(props) + this.state = { error: null } + } + static getDerivedStateFromError(error) { + return { error } + } + render() { + if (this.state.error) { + return React.createElement('pre', { id: 'err' }, String(this.state.error.stack || this.state.error)) + } + return this.props.children + } +} + +async function mountReader(t) { + resetStore() + Object.defineProperty(win.navigator, 'language', { value: 'zh-CN', configurable: true }) + Object.defineProperty(win.navigator, 'languages', { value: ['zh-CN'], configurable: true }) + const component = loadBundle() + const { createRoot } = await import('react-dom/client') + const container = document.getElementById('app') + const root = createRoot(container) + t.after(() => { + try { + root.unmount() + } catch { + /* already unmounted */ + } + }) + root.render(React.createElement(Boundary, null, React.createElement(component, { sessionId: 's1' }))) + await tick(200) + const entry = container.querySelector('.rd-entry') + assert.ok(entry, 'library row rendered: ' + (container.querySelector('#err')?.textContent || '').slice(0, 600)) + entry.dispatchEvent(new win.MouseEvent('click', { bubbles: true })) + await tick(80) + assert.ok(container.querySelector('.rd-prose'), 'document body rendered') + return container +} + +function selectInProse(container, needle) { + const walker = document.createTreeWalker(container.querySelector('.rd-prose'), 4) + let node + while ((node = walker.nextNode())) { + const at = (node.nodeValue || '').indexOf(needle) + if (at >= 0) { + const range = document.createRange() + range.setStart(node, at) + range.setEnd(node, at + needle.length) + const selection = win.getSelection() + selection.removeAllRanges() + selection.addRange(range) + node.parentElement.dispatchEvent(new win.MouseEvent('mouseup', { bubbles: true })) + return true + } + } + return false +} + +test('asking about a term that raised the current card reuses it with a visible reason', async (t) => { + const container = await mountReader(t) + assert.ok(selectInProse(container, '线性一致性'), 'selected the term in the prose') + await tick(60) + + const menu = container.querySelector('.rd-mini') + assert.ok(menu, 'selection menu opened') + const explain = Array.from(menu.querySelectorAll('button')).find((button) => + ['解释', 'Explain'].includes(button.textContent), + ) + assert.ok(explain, 'explain button present') + explain.dispatchEvent(new win.MouseEvent('click', { bubbles: true })) + await tick(80) + + assert.ok(lastExplainBody, 'the reader asked the route') + assert.equal(lastExplainBody.term, '线性一致性') + const card = container.querySelector('.rd-card') + assert.ok(card, 'a card is shown for the reused concept') + assert.equal(container.querySelector('.rd-skeleton'), null, 'the reused concept is not left pending') + assert.match( + card.textContent, + /上层已有解释|already explained one level up/, + 'the card says why it is the one from further up instead of pretending to be new', + ) + assert.match(card.textContent, /所有节点看到同一份历史/, 'the original explanation is what the reader sees') +}) diff --git a/dsh-reader/test/explain.test.mjs b/dsh-reader/test/explain.test.mjs index 0ed0b3f..52c4782 100644 --- a/dsh-reader/test/explain.test.mjs +++ b/dsh-reader/test/explain.test.mjs @@ -92,3 +92,50 @@ test('prompt carries the term, sentence and a bounded paragraph', () => { assert.match(user, /分布式系统/) assert.ok(user.length < 1200) }) + +test('ancestor cards are passed to the quick prompt, farthest first', () => { + const { system, user } = buildQuickExplainPrompt({ + term: '分区容忍', + sentence: 'S', + docTitle: '书', + ancestors: [ + { id: 'a', term: '分布式系统', definition: '多台机器协作' }, + { id: 'b', term: 'CAP', definition: '三角权衡' }, + ], + }) + assert.match(user, /上层解释/) + assert.match(user, /1\. 分布式系统:多台机器协作/) + assert.match(user, /2\. CAP:三角权衡/) + assert.match(system, /不要重复该概念已有的定义/) +}) + +test('ancestor cards are passed to the full prompt too', () => { + const { system, user } = buildExplainPrompt({ + term: '分区容忍', + sentence: 'S', + paragraph: 'P', + docTitle: '书', + ancestors: [{ id: 'b', term: 'CAP', definition: '三角权衡' }], + }) + assert.match(user, /上层解释/) + assert.match(user, /CAP:三角权衡/) + assert.match(system, /不要重复该概念已有的定义/) +}) + +test('a top-level explanation keeps the prompt unchanged', () => { + const plain = buildQuickExplainPrompt({ term: 'T', sentence: 'S', docTitle: '书' }) + const explicit = buildQuickExplainPrompt({ term: 'T', sentence: 'S', docTitle: '书', ancestors: [] }) + assert.deepEqual(explicit, plain) + assert.doesNotMatch(plain.user, /上层解释/) + assert.doesNotMatch(plain.system, /不要重复该概念已有的定义/) +}) + +test('ancestor definitions are trimmed so the prompt stays bounded', () => { + const { user } = buildQuickExplainPrompt({ + term: 'T', + sentence: 'S', + docTitle: '书', + ancestors: [{ id: 'a', term: '长概念', definition: '定义'.repeat(200) }], + }) + assert.ok(user.length < 1200, `prompt was ${user.length} chars`) +}) diff --git a/dsh-reader/test/host.test.mjs b/dsh-reader/test/host.test.mjs index 51201bd..5eb2ba5 100644 --- a/dsh-reader/test/host.test.mjs +++ b/dsh-reader/test/host.test.mjs @@ -235,6 +235,63 @@ test('explains a new concept once and reuses it afterwards', async (t) => { assert.equal(calls(), 1) }) +test('a nested explanation tells the model which cards it came from', async (t) => { + const { call, ctx } = await setup(t, { + llmText: '{"definition":"子定义","intuition":"","context":"","examples":[]}', + }) + const mutate = (body) => + call('/dsh-reader-live/api/mutate?sessionId=s1', { method: 'POST', body: JSON.stringify(body) }) + await mutate({ op: 'concept/upsert', concept: { id: 'root', term: '分布式系统', definition: '多台机器协作' } }) + await mutate({ op: 'concept/upsert', concept: { id: 'mid', term: 'CAP', definition: '三角权衡', parentId: 'root' } }) + const res = await call('/dsh-reader-live/api/explain?sessionId=s1', { + method: 'POST', + body: JSON.stringify({ term: '分区容忍', sentence: 's', paragraph: 'p', parentId: 'mid' }), + }) + const body = await res.json() + assert.equal(res.status, 200) + assert.equal(body.concept.parentId, 'mid') + const sent = ctx.lastStream.messages[0].content[0].text + assert.match(sent, /上层解释/) + assert.match(sent, /1\. 分布式系统:多台机器协作/) + assert.match(sent, /2\. CAP:三角权衡/) + assert.match(ctx.lastStream.system, /不要重复该概念已有的定义/) +}) + +test('asking again about the card that raised the current one steps back instead', async (t) => { + const { call, calls } = await setup(t) + const mutate = (body) => + call('/dsh-reader-live/api/mutate?sessionId=s1', { method: 'POST', body: JSON.stringify(body) }) + await mutate({ op: 'concept/upsert', concept: { id: 'a', term: '甲', definition: '甲的说明' } }) + await mutate({ op: 'concept/upsert', concept: { id: 'b', term: '乙', definition: '乙说的是甲', parentId: 'a' } }) + const before = calls() + const res = await call('/dsh-reader-live/api/explain?sessionId=s1', { + method: 'POST', + body: JSON.stringify({ term: '甲', sentence: 's', paragraph: 'p', parentId: 'b' }), + }) + const body = await res.json() + assert.equal(res.status, 200) + assert.equal(body.route, 'ancestor') + assert.equal(body.ancestor, true) + assert.equal(body.concept.id, 'a') + assert.equal(calls(), before, 'no model call for a term that is already explained above') +}) + +test('a cyclic parent chain does not hang the ancestor walk', async (t) => { + const { call } = await setup(t) + const mutate = (body) => + call('/dsh-reader-live/api/mutate?sessionId=s1', { method: 'POST', body: JSON.stringify(body) }) + await mutate({ op: 'concept/upsert', concept: { id: 'a', term: '甲', parentId: 'b' } }) + await mutate({ op: 'concept/upsert', concept: { id: 'b', term: '乙', parentId: 'a' } }) + const res = await call('/dsh-reader-live/api/explain?sessionId=s1', { + method: 'POST', + body: JSON.stringify({ term: '丙', sentence: 's', paragraph: 'p', parentId: 'a' }), + }) + assert.equal(res.status, 200) + const body = await res.json() + assert.equal(body.concept.term, '丙') + assert.equal(body.concept.parentId, 'a') +}) + test('explain keeps concepts that already existed', async (t) => { const { call } = await setup(t) await call('/dsh-reader-live/api/mutate?sessionId=s1', {