Skip to content

Commit e4e156f

Browse files
committed
feat(conversation): expose intra-result graph relations
1 parent c45d580 commit e4e156f

14 files changed

Lines changed: 177 additions & 2 deletions

docs/diataxis/en/explanation/development-progress-dashboard.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The key result is that the current code has moved further than the old plan word
2020
- that `graphContext` now survives through conversation trace, snapshot persistence, and workspace export,
2121
- the grounding inspector now renders that persisted `graphContext` as structured graph evidence,
2222
- relation aggregation now spans the whole grouped knowledge-point set instead of only the leading anchor's local hint set,
23+
- direct grouped-knowledge-point relations are now preserved as first-class graph-context data instead of only implicit edge membership,
2324
- temporal-validity aggregation now preserves temporal edge kinds/details in addition to warning text,
2425
- supersession details now also influence explanation and next-action text instead of staying limited to warning-only evidence,
2526
- and grounding inspectability is now normalized per turn so later turns without grounding payload do not keep stale evidence-pane state alive.
@@ -41,7 +42,7 @@ Code-vs-plan reconciliation for this slice:
4142
| Answer area contraction to a single targeted answer | `agent_workspace.js` now keeps the full conversation result in runtime state while only rendering user-facing answer blocks (`structured_answer`, `main_markdown`, `html_artifact`) in the main chat surface. | Implemented current slice |
4243
| Hide developer-heavy evidence from the primary hit list | `workspace_panes.js` no longer renders inline knowledge previews or visible typed capability buttons in the left-side hit list; those flows now route into graph focus or the dedicated evidence pane. | Implemented current slice |
4344
| Durable evidence/claim inspector | `workspace_panes.js` now exposes a dedicated evidence pane for grounding metadata, `knowledge_run`, `knowledge_run_history`, `knowledge_run_compare`, and `flashcard_batch`; `agent_workspace.js` wires the API status strip into grounding inspection and normalizes per-turn inspectability so stale grounding is cleared on later turns without evidence payloads. | Implemented broader current slice |
44-
| DAG-native answer planning | `AgentConversationKnowledgePoint` now carries grouped `relationPath`, `relationKinds`, `relationPathAtomIds`, and `temporalValidity`; `conversationComposer.ts` now materializes an explicit `graphContext`; `KnowledgeLearningPlatform.ts` and `WorkspaceExportBundle.ts` now preserve it through trace, persistence, and export surfaces; `workspace_panes.js` now renders that persisted `graphContext` in the evidence pane as a structured graph explanation surface; relation and temporal aggregation now span the whole grouped knowledge-point set and preserve source-atom plus temporal-edge detail; supersession details now also flow into explanation and next-action text. | Implemented broader partial slice |
45+
| DAG-native answer planning | `AgentConversationKnowledgePoint` now carries grouped `relationPath`, `relationKinds`, `relationPathAtomIds`, and `temporalValidity`; `conversationComposer.ts` now materializes an explicit `graphContext`; `KnowledgeLearningPlatform.ts` and `WorkspaceExportBundle.ts` now preserve it through trace, persistence, and export surfaces; `workspace_panes.js` now renders that persisted `graphContext` in the evidence pane as a structured graph explanation surface; relation and temporal aggregation now span the whole grouped knowledge-point set and preserve source-atom plus temporal-edge detail; direct grouped-knowledge-point relations are now preserved and surfaced; supersession details now also flow into explanation and next-action text. | Implemented broader partial slice |
4546

4647
Immediate next direction from this point:
4748

docs/diataxis/zh/explanation/development-progress-dashboard.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
-`graphContext` 现在也会沿着 conversation trace、snapshot persistence 与 workspace export 一起传播;
2323
- grounding inspector 现在会把持久化的 `graphContext` 渲染为结构化图解释面;
2424
- 关系聚合现在已覆盖整批 grouped knowledge points,而不再只看首个 anchor 的局部提示;
25+
- grouped knowledge points 之间的直接关系现在也会作为一等 `graphContext` 数据被保留,而不再只是隐式 edge 归属;
2526
- 时序有效性聚合现在除 warning text 外,还会保留 temporal edge kind/detail;
2627
- supersession 细节现在也会影响 explanation / next-action 文本,而不再只停留在 warning-only evidence;
2728
- grounding 检查入口现在按当前回合标准化判断,因此后续无 grounding payload 的回合不会继续保留陈旧的 evidence pane 状态。
@@ -43,7 +44,7 @@
4344
| 主回答区收缩为单一 targeted answer | `agent_workspace.js` 现在会保留完整 conversation result 到 runtime state,但主聊天面仅渲染用户面的回答块(`structured_answer``main_markdown``html_artifact`)。 | 当前切片已实现 |
4445
| 主命中列表不暴露开发者导向 evidence / action | `workspace_panes.js` 已不再在左侧命中列表中渲染 inline preview 或可见 typed capability button;这些流程现在会路由到 graph focus 或专门的 evidence pane。 | 当前切片已实现 |
4546
| durable evidence / claim inspector | `workspace_panes.js` 现已提供专门的 evidence pane,用于承接 grounding metadata、`knowledge_run``knowledge_run_history``knowledge_run_compare``flashcard_batch``agent_workspace.js` 也已把 API 状态条接成 grounding inspection 入口,并按当前回合规范清理陈旧 grounding 状态。 | 当前切片已更完整实现 |
46-
| DAG-native answer planning | `AgentConversationKnowledgePoint` 现已保留 grouped `relationPath``relationKinds``relationPathAtomIds``temporalValidity``conversationComposer.ts` 现已显式构建 `graphContext``KnowledgeLearningPlatform.ts``WorkspaceExportBundle.ts` 也已在 trace / persistence / export 中保留它;`workspace_panes.js` 现在会在 evidence pane 中把该 `graphContext` 渲染成结构化图解释面;关系与时序聚合也已扩展到整批 grouped knowledge points,并保留 source-atom 与 temporal-edge 细节;supersession 细节现在也会进入 explanation / next-action 文本。 | 当前切片已更宽的部分实现 |
47+
| DAG-native answer planning | `AgentConversationKnowledgePoint` 现已保留 grouped `relationPath``relationKinds``relationPathAtomIds``temporalValidity``conversationComposer.ts` 现已显式构建 `graphContext``KnowledgeLearningPlatform.ts``WorkspaceExportBundle.ts` 也已在 trace / persistence / export 中保留它;`workspace_panes.js` 现在会在 evidence pane 中把该 `graphContext` 渲染成结构化图解释面;关系与时序聚合也已扩展到整批 grouped knowledge points,并保留 source-atom 与 temporal-edge 细节;grouped knowledge points 之间的直接关系现在也会被保留并展示;supersession 细节现在也会进入 explanation / next-action 文本。 | 当前切片已更宽的部分实现 |
4748

4849
从这里出发的即时推进方向:
4950

docs/solutions/knowledge-workspace-dag-alignment-2026-06-10.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,12 @@ What the current slice now adds:
189189
- `buildAgentConversationGraphContext()` is no longer limited to the leading grouped knowledge point's local relation hints:
190190
- it now aggregates `relationPath` signals across the whole grouped knowledge-point set,
191191
- relation summaries now preserve `sourceAtomIds` as well as `targetAtomIds`,
192+
- direct relations between grouped knowledge points are now materialized as first-class `knowledgePointRelations`,
192193
- supporting atom ids are assembled from the whole grouped set instead of the leading anchor only.
193194
- `workspace_panes.js` now projects that persisted `graphContext` into the evidence pane as a structured graph explanation surface:
194195
- anchor identity
195196
- relation kinds and relation summaries
197+
- direct grouped-knowledge-point relations
196198
- relation source atoms
197199
- supporting titles and atom ids
198200
- temporal-validity status and warning reasons
@@ -315,6 +317,7 @@ Shipped characteristics:
315317
- the resulting `graphContext` now survives through conversation trace, snapshot persistence, and workspace export.
316318
- the evidence pane now renders that `graphContext` directly for user inspection,
317319
- relation aggregation now spans the whole grouped knowledge-point set and preserves relation source atoms,
320+
- direct grouped-knowledge-point relations are now preserved and surfaced through the same `graphContext`,
318321
- temporal-validity aggregation now preserves temporal edge kinds/details in addition to warning text,
319322
- grounding-pane state now clears cleanly when a later turn has no grounding payload.
320323

src/agent_workspace.frontend.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function createI18nStub() {
7373
'agentWorkspace.evidence.graphSupportingTitlesLabel': 'Supporting titles',
7474
'agentWorkspace.evidence.graphSupportingAtomsLabel': 'Supporting atoms',
7575
'agentWorkspace.evidence.graphRelationSummariesLabel': 'Relation summaries',
76+
'agentWorkspace.evidence.graphKnowledgePointRelationsLabel': 'Knowledge-point relations',
7677
'agentWorkspace.evidence.graphRelationTargetsLabel': 'Targets: {count}',
7778
'agentWorkspace.evidence.graphRelationSourcesLabel': 'Sources: {sources}',
7879
'agentWorkspace.evidence.graphRelationConfidenceLabel': 'Avg confidence: {confidence}',
@@ -803,6 +804,7 @@ function createI18nStub() {
803804
'agentWorkspace.evidence.graphSupportingTitlesLabel': '支撑标题',
804805
'agentWorkspace.evidence.graphSupportingAtomsLabel': '支撑原子',
805806
'agentWorkspace.evidence.graphRelationSummariesLabel': '关系摘要',
807+
'agentWorkspace.evidence.graphKnowledgePointRelationsLabel': '知识点关系',
806808
'agentWorkspace.evidence.graphRelationTargetsLabel': '目标数:{count}',
807809
'agentWorkspace.evidence.graphRelationSourcesLabel': '来源:{sources}',
808810
'agentWorkspace.evidence.graphRelationConfidenceLabel': '平均置信度:{confidence}',

src/export/WorkspaceExportBundle.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ describe('WorkspaceExportBundle', () => {
254254
averageConfidence: 0.8,
255255
},
256256
],
257+
knowledgePointRelations: [
258+
{
259+
edgeId: 'edge_reflection_reference',
260+
relationKind: 'reference',
261+
sourceAtomId: 'atom_reflection',
262+
sourceTitle: 'Reflection',
263+
targetAtomId: 'atom_transmission',
264+
targetTitle: 'Transmission',
265+
confidence: 0.8,
266+
},
267+
],
257268
temporalValidity: {
258269
checkedAt: '2026-05-26T00:00:00.000Z',
259270
allPointsValid: true,
@@ -294,6 +305,13 @@ describe('WorkspaceExportBundle', () => {
294305
sourceAtomIds: ['atom_reflection'],
295306
}),
296307
]),
308+
knowledgePointRelations: expect.arrayContaining([
309+
expect.objectContaining({
310+
relationKind: 'reference',
311+
sourceTitle: 'Reflection',
312+
targetTitle: 'Transmission',
313+
}),
314+
]),
297315
temporalValidity: expect.objectContaining({
298316
edgeKinds: ['supersedes'],
299317
details: expect.arrayContaining([

src/export/WorkspaceExportBundle.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ function sortAndCloneConversationTurns(records: AgentConversationTurnRecord[]):
256256
targetAtomIds: Array.isArray(summary.targetAtomIds) ? [...summary.targetAtomIds] : [],
257257
}))
258258
: [],
259+
knowledgePointRelations: Array.isArray((record.response.trace as any).graphContext.knowledgePointRelations)
260+
? (record.response.trace as any).graphContext.knowledgePointRelations.map((relation: any) => ({
261+
...relation,
262+
}))
263+
: [],
259264
temporalValidity: (record.response.trace as any).graphContext.temporalValidity
260265
? {
261266
...(record.response.trace as any).graphContext.temporalValidity,

src/frontend/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@
446446
"graphSupportingTitlesLabel": "Supporting titles",
447447
"graphSupportingAtomsLabel": "Supporting atoms",
448448
"graphRelationSummariesLabel": "Relation summaries",
449+
"graphKnowledgePointRelationsLabel": "Knowledge-point relations",
449450
"graphRelationTargetsLabel": "Targets: {count}",
450451
"graphRelationSourcesLabel": "Sources: {sources}",
451452
"graphRelationConfidenceLabel": "Avg confidence: {confidence}",

src/frontend/locales/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@
446446
"graphSupportingTitlesLabel": "支撑标题",
447447
"graphSupportingAtomsLabel": "支撑原子",
448448
"graphRelationSummariesLabel": "关系摘要",
449+
"graphKnowledgePointRelationsLabel": "知识点关系",
449450
"graphRelationTargetsLabel": "目标数:{count}",
450451
"graphRelationSourcesLabel": "来源:{sources}",
451452
"graphRelationConfidenceLabel": "平均置信度:{confidence}",

src/frontend/workspace_panes.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,11 @@
590590
.map((item) => item && typeof item === 'object' ? item : null)
591591
.filter(Boolean)
592592
: [];
593+
const knowledgePointRelations = Array.isArray(graphContext.knowledgePointRelations)
594+
? graphContext.knowledgePointRelations
595+
.map((item) => item && typeof item === 'object' ? item : null)
596+
.filter(Boolean)
597+
: [];
593598
const temporalValidity = graphContext.temporalValidity && typeof graphContext.temporalValidity === 'object'
594599
? graphContext.temporalValidity
595600
: null;
@@ -659,6 +664,21 @@
659664
`;
660665
}).join('')
661666
: `<li class="agent-pane-list-empty">${escapeHtml(noneLabel)}</li>`;
667+
const knowledgePointRelationHtml = knowledgePointRelations.length > 0
668+
? knowledgePointRelations.map((relation) => {
669+
const relationLabel = `${String(relation.sourceTitle || noneLabel)} -> ${humanizeEvidenceRelationKind(relation.relationKind)} -> ${String(relation.targetTitle || noneLabel)}`;
670+
const relationAtoms = `${String(relation.sourceAtomId || noneLabel)} -> ${String(relation.targetAtomId || noneLabel)}`;
671+
return `
672+
<li class="agent-pane-list-item">
673+
<div>
674+
<div class="agent-pane-list-label">${escapeHtml(relationLabel)}</div>
675+
<div class="agent-pane-summary">${escapeHtml(relationAtoms)}</div>
676+
</div>
677+
<span class="agent-pane-meta">${escapeHtml(formatEvidenceConfidence(relation.confidence))}</span>
678+
</li>
679+
`;
680+
}).join('')
681+
: '';
662682

663683
const temporalEdgeKinds = temporalValidity && Array.isArray(temporalValidity.edgeKinds)
664684
? temporalValidity.edgeKinds
@@ -719,6 +739,7 @@
719739
<ul class="agent-pane-list">${buildEvidenceMetricListHtml(contextMetrics)}</ul>
720740
<div class="agent-pane-section-title">${escapeHtml(translate('agentWorkspace.evidence.graphRelationSummariesLabel', 'Relation summaries'))}</div>
721741
<ul class="agent-pane-list">${relationSummaryHtml}</ul>
742+
${knowledgePointRelationHtml ? `<div class="agent-pane-section-title">${escapeHtml(translate('agentWorkspace.evidence.graphKnowledgePointRelationsLabel', 'Knowledge-point relations'))}</div><ul class="agent-pane-list">${knowledgePointRelationHtml}</ul>` : ''}
722743
${temporalMetrics.length > 0 ? `<div class="agent-pane-section-title">${escapeHtml(translate('agentWorkspace.evidence.graphTemporalLabel', 'Temporal validity'))}</div><ul class="agent-pane-list">${buildEvidenceMetricListHtml(temporalMetrics)}</ul>` : ''}
723744
${temporalDetailHtml ? `<div class="agent-pane-section-title">${escapeHtml(translate('agentWorkspace.evidence.graphTemporalDetailsLabel', 'Temporal edge details'))}</div><ul class="agent-pane-list">${temporalDetailHtml}</ul>` : ''}
724745
`;

src/learning/KnowledgeLearningPlatform.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,23 @@ describe('KnowledgeLearningPlatform', () => {
18201820
relationKind: 'reference',
18211821
}),
18221822
]));
1823+
expect((response.trace.graphContext as any).knowledgePointRelations).toEqual(expect.arrayContaining([
1824+
expect.objectContaining({
1825+
relationKind: 'reference',
1826+
sourceTitle: 'Reflection',
1827+
targetTitle: 'Transmission',
1828+
}),
1829+
]));
1830+
expect(
1831+
structuredBlock && 'explanationMarkdown' in structuredBlock
1832+
? String(structuredBlock.explanationMarkdown || '')
1833+
: ''
1834+
).toContain('Reflection -> reference -> Transmission');
1835+
expect(
1836+
structuredBlock && 'nextActionsMarkdown' in structuredBlock
1837+
? String(structuredBlock.nextActionsMarkdown || '')
1838+
: ''
1839+
).toContain('Follow the direct graph path between Reflection and Transmission');
18231840
expect((response.knowledgePoints[0] as any).relationKinds).toContain('reference');
18241841
});
18251842

0 commit comments

Comments
 (0)