noteconnection 1.6.8 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -21
- package/README.md +258 -64
- package/dist/src/agent_workspace.contract.parity.test.js +475 -0
- package/dist/src/agent_workspace.frontend.test.js +9989 -0
- package/dist/src/agent_workspace.locale.contract.test.js +95 -0
- package/dist/src/agent_workspace.runtime.behavior.test.js +5072 -0
- package/dist/src/copy.assets.contract.test.js +130 -0
- package/dist/src/core/PathBridge.js +28 -3
- package/dist/src/export/WorkspaceExportBundle.js +1130 -0
- package/dist/src/export/WorkspaceExportBundle.test.js +1480 -0
- package/dist/src/export/index.js +18 -0
- package/dist/src/export/types.js +2 -0
- package/dist/src/fixrisk.issue.verifier.contract.test.js +3 -1
- package/dist/src/foundation.ann.runtime.contract.test.js +81 -0
- package/dist/src/foundation.release.evidence.contract.test.js +406 -0
- package/dist/src/foundation.sqlite.runtime.contract.test.js +82 -0
- package/dist/src/frontend/README.md +258 -64
- package/dist/src/frontend/agent_workspace.js +5353 -0
- package/dist/src/frontend/agent_workspace_runtime.js +4434 -0
- package/dist/src/frontend/analysis.js +31 -4
- package/dist/src/frontend/app.js +3597 -141
- package/dist/src/frontend/focus_mode_interactions.js +33 -0
- package/dist/src/frontend/godot_future_path_renderer.js +540 -0
- package/dist/src/frontend/godot_tree_interactions.js +178 -0
- package/dist/src/frontend/graph_state.mjs +105 -0
- package/dist/src/frontend/hosted_future_path_runtime.js +157 -0
- package/dist/src/frontend/i18n.mjs +186 -0
- package/dist/src/frontend/index.html +641 -266
- package/dist/src/frontend/layout_gpu.js +12 -4
- package/dist/src/frontend/locales/en.json +721 -5
- package/dist/src/frontend/locales/zh.json +721 -5
- package/dist/src/frontend/main.mjs +60 -0
- package/dist/src/frontend/markdown_runtime.js +827 -0
- package/dist/src/frontend/notemd.css +49 -0
- package/dist/src/frontend/notemd.html +7 -1
- package/dist/src/frontend/notemd.js +64 -0
- package/dist/src/frontend/path.html +107 -0
- package/dist/src/frontend/path_app.js +2189 -150
- package/dist/src/frontend/path_layout.mjs +143 -0
- package/dist/src/frontend/path_mermaid_utils.mjs +108 -0
- package/dist/src/frontend/path_modules_bridge.js +486 -0
- package/dist/src/frontend/path_state.mjs +118 -0
- package/dist/src/frontend/path_styles.css +146 -0
- package/dist/src/frontend/path_worker_bridge.mjs +85 -0
- package/dist/src/frontend/reader.js +522 -27
- package/dist/src/frontend/runtime_bridge.js +67 -54
- package/dist/src/frontend/runtime_bridge.mjs +279 -0
- package/dist/src/frontend/settings.js +130 -12
- package/dist/src/frontend/simulationWorker.js +241 -6
- package/dist/src/frontend/source_manager.js +190 -21
- package/dist/src/frontend/styles.css +2853 -72
- package/dist/src/frontend/workbench_state.mjs +101 -0
- package/dist/src/frontend/workspace_panes.js +10168 -0
- package/dist/src/frontend.locale.contract.test.js +62 -0
- package/dist/src/godot.sidecar.bootstrap.contract.test.js +244 -0
- package/dist/src/indexing/IndexLifecycle.js +195 -0
- package/dist/src/indexing/IndexLifecycle.test.js +49 -0
- package/dist/src/indexing/SegmentBuilder.js +64 -0
- package/dist/src/indexing/UnitBuilder.js +48 -0
- package/dist/src/indexing/types.js +2 -0
- package/dist/src/knowledge.api.contract.test.js +170 -0
- package/dist/src/learning/KnowledgeLearningPlatform.js +10386 -0
- package/dist/src/learning/KnowledgeLearningPlatform.persistence.test.js +327 -0
- package/dist/src/learning/KnowledgeLearningPlatform.program-f.test.js +99 -0
- package/dist/src/learning/KnowledgeLearningPlatform.test.js +2971 -0
- package/dist/src/learning/KnowledgeWorkspaceConversationRegression.js +2974 -0
- package/dist/src/learning/KnowledgeWorkspaceConversationRegression.test.js +3928 -0
- package/dist/src/learning/answerReleaseReview.js +4319 -0
- package/dist/src/learning/answerReleaseReview.test.js +2888 -0
- package/dist/src/learning/api.js +2 -0
- package/dist/src/learning/conversationComposer.js +1480 -0
- package/dist/src/learning/conversationComposer.test.js +1817 -0
- package/dist/src/learning/domains/ConversationManager.js +53 -0
- package/dist/src/learning/domains/KnowledgeIngestor.js +238 -0
- package/dist/src/learning/domains/KnowledgeQuerier.js +187 -0
- package/dist/src/learning/domains/MasteryEngine.js +387 -0
- package/dist/src/learning/domains/MemoryPolicyManager.js +408 -0
- package/dist/src/learning/domains/QualityEvaluator.js +307 -0
- package/dist/src/learning/domains/TutorRouter.js +313 -0
- package/dist/src/learning/domains/index.js +33 -0
- package/dist/src/learning/domains/types.js +7 -0
- package/dist/src/learning/errors.js +29 -0
- package/dist/src/learning/evidenceContextAssembler.js +1176 -0
- package/dist/src/learning/evidenceContextAssembler.test.js +6332 -0
- package/dist/src/learning/graphContextAssembler.js +870 -0
- package/dist/src/learning/graphContextAssembler.test.js +1033 -0
- package/dist/src/learning/index.js +28 -0
- package/dist/src/learning/queryBackend.js +1898 -0
- package/dist/src/learning/queryBackend.test.js +955 -0
- package/dist/src/learning/ragContextPack.js +257 -0
- package/dist/src/learning/ragContextPack.test.js +160 -0
- package/dist/src/learning/ragPublicText.js +38 -0
- package/dist/src/learning/ragSufficiencyJudge.js +161 -0
- package/dist/src/learning/ragSufficiencyJudge.test.js +177 -0
- package/dist/src/learning/ragSufficiencyProviderJudge.js +227 -0
- package/dist/src/learning/ragSufficiencyProviderJudge.test.js +156 -0
- package/dist/src/learning/requestNormalization.js +198 -0
- package/dist/src/learning/runtimeCapability.js +4677 -0
- package/dist/src/learning/runtimeCapability.test.js +3635 -0
- package/dist/src/learning/store.js +1240 -0
- package/dist/src/learning/store.test.js +1126 -0
- package/dist/src/learning/tutorAdapter.js +2 -0
- package/dist/src/learning/types.js +2 -0
- package/dist/src/learning/vectorAccelerationAdapter.js +942 -0
- package/dist/src/learning/vectorAccelerationAdapter.test.js +382 -0
- package/dist/src/lfs.asset.policy.contract.test.js +153 -0
- package/dist/src/license.policy.contract.test.js +66 -0
- package/dist/src/memory/MemoryGovernance.js +74 -0
- package/dist/src/memory/MemoryGovernance.test.js +46 -0
- package/dist/src/memory/types.js +2 -0
- package/dist/src/mermaid.frontend.guard.contract.test.js +77 -0
- package/dist/src/middleware/auth.js +17 -0
- package/dist/src/middleware/body-parser.js +45 -0
- package/dist/src/middleware/cors.js +44 -0
- package/dist/src/middleware/index.js +21 -0
- package/dist/src/middleware/request-trace.js +96 -0
- package/dist/src/notemd/AppConfigToml.js +6 -4
- package/dist/src/notemd/MermaidProcessor.js +400 -50
- package/dist/src/notemd/NotemdService.js +498 -13
- package/dist/src/notemd/PromptManager.js +15 -0
- package/dist/src/notemd/cli/commands.js +357 -0
- package/dist/src/notemd/cli/dispatcher.js +225 -0
- package/dist/src/notemd/cli/index.js +169 -0
- package/dist/src/notemd/cli/parser.js +68 -0
- package/dist/src/notemd/cli/types.js +2 -0
- package/dist/src/notemd/constants.js +43 -0
- package/dist/src/notemd/diagram/diagramGenerationService.js +78 -0
- package/dist/src/notemd/diagram/diagramSpec.js +79 -0
- package/dist/src/notemd/diagram/diagramSpecResponseParser.js +131 -0
- package/dist/src/notemd/diagram/intent.js +95 -0
- package/dist/src/notemd/diagram/planner.js +71 -0
- package/dist/src/notemd/diagram/prompts/diagramSpecPrompt.js +42 -0
- package/dist/src/notemd/diagram/types.js +18 -0
- package/dist/src/notemd/index.js +26 -0
- package/dist/src/notemd/operations/capabilityManifest.js +23 -0
- package/dist/src/notemd/operations/cliContracts.js +17 -0
- package/dist/src/notemd/operations/configProfileCommands.js +85 -0
- package/dist/src/notemd/operations/registry.contract.test.js +95 -0
- package/dist/src/notemd/operations/registry.js +991 -0
- package/dist/src/notemd/operations/types.js +2 -0
- package/dist/src/notemd/providerDiagnostics.js +220 -0
- package/dist/src/notemd/providerProfiles.js +42 -0
- package/dist/src/notemd/providerTemplates.js +231 -0
- package/dist/src/notemd/search/DuckDuckGoProvider.js +39 -0
- package/dist/src/notemd/search/SearchManager.js +13 -0
- package/dist/src/notemd/search/SearchProvider.js +2 -0
- package/dist/src/notemd/search/TavilyProvider.js +44 -0
- package/dist/src/notemd.agent.manifest.test.js +85 -0
- package/dist/src/notemd.api.contract.test.js +14 -1
- package/dist/src/notemd.app_config_toml.test.js +2 -1
- package/dist/src/notemd.batch.workflow.test.js +117 -0
- package/dist/src/notemd.cli.e2e.test.js +136 -0
- package/dist/src/notemd.core.test.js +51 -0
- package/dist/src/notemd.diagram.pipeline.test.js +233 -0
- package/dist/src/notemd.providerTemplates.test.js +34 -0
- package/dist/src/notemd.server.integration.test.js +143 -35
- package/dist/src/notemd.workflow.pipeline.test.js +162 -0
- package/dist/src/pathbridge.handshake.contract.test.js +16 -2
- package/dist/src/pathmode.background.contract.test.js +69 -0
- package/dist/src/pathmode.settings.api.contract.test.js +9 -0
- package/dist/src/pkg.sidecar.contract.test.js +9 -3
- package/dist/src/platform/ExportProfile.js +58 -0
- package/dist/src/platform/PlatformCapabilities.js +45 -0
- package/dist/src/platform/PlatformCapabilities.test.js +30 -0
- package/dist/src/platform/RenderMaterializer.js +33 -0
- package/dist/src/platform/RenderMaterializer.test.js +32 -0
- package/dist/src/query_backend.external_http.integration.test.js +410 -0
- package/dist/src/reader_renderer.js +404 -3
- package/dist/src/reader_renderer.test.js +87 -0
- package/dist/src/release.godot.mirror.contract.test.js +73 -0
- package/dist/src/resources/ResourceRegistry.js +223 -0
- package/dist/src/resources/ResourceRegistry.test.js +61 -0
- package/dist/src/resources/types.js +2 -0
- package/dist/src/routes/agentWorkspaceDiagnostics.js +173 -0
- package/dist/src/routes/data.js +267 -0
- package/dist/src/routes/diagnostics.js +51 -0
- package/dist/src/routes/index.js +23 -0
- package/dist/src/routes/knowledge.js +968 -0
- package/dist/src/routes/markdown.js +287 -0
- package/dist/src/routes/notemd.js +565 -0
- package/dist/src/routes/registry.contract.test.js +130 -0
- package/dist/src/routes/render.js +285 -0
- package/dist/src/routes/runtimeRunbookRouteOps.js +149 -0
- package/dist/src/routes/runtimeRunbookRouteOps.test.js +194 -0
- package/dist/src/routes/settings.js +6 -0
- package/dist/src/routes/staticFiles.js +94 -0
- package/dist/src/routes/types.js +2 -0
- package/dist/src/runtime.transport.adapter.contract.test.js +81 -0
- package/dist/src/server.js +11090 -1549
- package/dist/src/server.migration.test.js +193 -21
- package/dist/src/server.port.fallback.contract.test.js +63 -0
- package/dist/src/session/SessionStateStore.js +81 -0
- package/dist/src/session/SessionStateStore.test.js +58 -0
- package/dist/src/session/types.js +2 -0
- package/dist/src/settings.runtime.contract.test.js +50 -0
- package/dist/src/shared/types.contract.test.js +107 -0
- package/dist/src/shared/types.js +22 -0
- package/dist/src/sidecar.replacement.boundary.contract.test.js +128 -0
- package/dist/src/sidecar.supply.readiness.contract.test.js +144 -0
- package/dist/src/source_manager.loadflow.test.js +46 -0
- package/dist/src/startup.layout.snapshot.contract.test.js +57 -0
- package/dist/src/tauri.frontend.build.contract.test.js +60 -0
- package/dist/src/tauri.sidecar.cleanup.contract.test.js +21 -0
- package/dist/src/utils/RuntimePaths.js +4 -13
- package/dist/src/utils/platform.js +153 -0
- package/dist/src/workflows/WorkflowArtifactStore.js +96 -0
- package/dist/src/workflows/WorkflowArtifactStore.test.js +80 -0
- package/dist/src/workflows/types.js +2 -0
- package/dist/src/workspace/WorkspaceRegistry.js +122 -0
- package/dist/src/workspace/WorkspaceRegistry.test.js +29 -0
- package/dist/src/workspace/types.js +2 -0
- package/package.json +61 -10
|
@@ -0,0 +1,1480 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const WorkspaceExportBundle_1 = require("./WorkspaceExportBundle");
|
|
4
|
+
describe('WorkspaceExportBundle', () => {
|
|
5
|
+
test('builds deterministic slim bundles with readiness failures when projections lack indexed units', () => {
|
|
6
|
+
const bundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
|
|
7
|
+
request: {
|
|
8
|
+
workspaceId: 'optics',
|
|
9
|
+
exportProfileId: 'mobile-slim',
|
|
10
|
+
},
|
|
11
|
+
workspace: {
|
|
12
|
+
workspaceId: 'optics',
|
|
13
|
+
corpusId: 'optics',
|
|
14
|
+
name: 'optics',
|
|
15
|
+
sourcePathPrefix: 'knowledge_base/optics',
|
|
16
|
+
languages: ['zh', 'en'],
|
|
17
|
+
exportProfileId: 'mobile-slim',
|
|
18
|
+
status: 'active',
|
|
19
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
20
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
21
|
+
},
|
|
22
|
+
bindings: [],
|
|
23
|
+
resources: [],
|
|
24
|
+
projections: [
|
|
25
|
+
{
|
|
26
|
+
projectionId: 'projection_1',
|
|
27
|
+
resourceId: 'resource_1',
|
|
28
|
+
projectionKind: 'knowledge_document',
|
|
29
|
+
stableKey: 'knowledge_document:doc_a',
|
|
30
|
+
status: 'active',
|
|
31
|
+
documentId: 'doc_a',
|
|
32
|
+
sourcePath: 'Knowledge_Base/optics/doc_a.md',
|
|
33
|
+
workspaceId: 'optics',
|
|
34
|
+
corpusId: 'optics',
|
|
35
|
+
metadata: {},
|
|
36
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
37
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
38
|
+
deletedAt: null,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
indexSummary: {
|
|
42
|
+
totalUnits: 0,
|
|
43
|
+
totalSegments: 0,
|
|
44
|
+
states: {
|
|
45
|
+
pending: 0,
|
|
46
|
+
indexing: 0,
|
|
47
|
+
indexed: 0,
|
|
48
|
+
failed: 0,
|
|
49
|
+
disabled: 0,
|
|
50
|
+
},
|
|
51
|
+
activeDocuments: 0,
|
|
52
|
+
activeAtomUnits: 0,
|
|
53
|
+
},
|
|
54
|
+
units: [],
|
|
55
|
+
segments: [],
|
|
56
|
+
atoms: [],
|
|
57
|
+
evidenceSpans: [],
|
|
58
|
+
relationEdges: [],
|
|
59
|
+
temporalEdges: [],
|
|
60
|
+
sessionStates: [],
|
|
61
|
+
conversationSessions: [],
|
|
62
|
+
conversationTurns: [],
|
|
63
|
+
conversationInvocations: [],
|
|
64
|
+
workflowArtifacts: [],
|
|
65
|
+
memoryEntries: [],
|
|
66
|
+
memoryAuditRecords: [],
|
|
67
|
+
generatedAt: '2026-05-26T00:00:00.000Z',
|
|
68
|
+
});
|
|
69
|
+
const secondBundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
|
|
70
|
+
request: {
|
|
71
|
+
workspaceId: 'optics',
|
|
72
|
+
exportProfileId: 'mobile-slim',
|
|
73
|
+
},
|
|
74
|
+
workspace: bundle.workspace,
|
|
75
|
+
bindings: bundle.bindings,
|
|
76
|
+
resources: bundle.resources,
|
|
77
|
+
projections: bundle.projections,
|
|
78
|
+
indexSummary: bundle.index.summary,
|
|
79
|
+
units: bundle.index.units,
|
|
80
|
+
segments: bundle.index.segments,
|
|
81
|
+
atoms: bundle.graph.atoms,
|
|
82
|
+
evidenceSpans: bundle.graph.evidenceSpans,
|
|
83
|
+
relationEdges: bundle.graph.relationEdges,
|
|
84
|
+
temporalEdges: bundle.graph.temporalEdges,
|
|
85
|
+
sessionStates: bundle.runtime.sessionStates,
|
|
86
|
+
conversationSessions: bundle.runtime.conversationSessions,
|
|
87
|
+
conversationTurns: bundle.runtime.conversationTurns,
|
|
88
|
+
conversationInvocations: bundle.runtime.conversationInvocations,
|
|
89
|
+
workflowArtifacts: bundle.runtime.workflowArtifacts,
|
|
90
|
+
memoryEntries: bundle.memory.entries,
|
|
91
|
+
memoryAuditRecords: bundle.memory.auditRecords,
|
|
92
|
+
generatedAt: '2026-05-26T00:00:00.000Z',
|
|
93
|
+
});
|
|
94
|
+
expect(bundle.manifest.packagingMode).toBe('slim');
|
|
95
|
+
expect(bundle.readiness.ready).toBe(false);
|
|
96
|
+
expect(bundle.readiness.missingIndexedProjectionIds).toEqual(['projection_1']);
|
|
97
|
+
expect(bundle.manifest.deterministicHash).toBe(secondBundle.manifest.deterministicHash);
|
|
98
|
+
});
|
|
99
|
+
test('preserves conversation graph context in exported runtime turns', () => {
|
|
100
|
+
const bundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
|
|
101
|
+
request: {
|
|
102
|
+
workspaceId: 'optics',
|
|
103
|
+
exportProfileId: 'mobile-slim',
|
|
104
|
+
},
|
|
105
|
+
workspace: {
|
|
106
|
+
workspaceId: 'optics',
|
|
107
|
+
corpusId: 'optics',
|
|
108
|
+
name: 'optics',
|
|
109
|
+
sourcePathPrefix: 'knowledge_base/optics',
|
|
110
|
+
languages: ['zh', 'en'],
|
|
111
|
+
exportProfileId: 'mobile-slim',
|
|
112
|
+
status: 'active',
|
|
113
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
114
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
115
|
+
},
|
|
116
|
+
bindings: [],
|
|
117
|
+
resources: [],
|
|
118
|
+
projections: [],
|
|
119
|
+
indexSummary: {
|
|
120
|
+
totalUnits: 0,
|
|
121
|
+
totalSegments: 0,
|
|
122
|
+
states: {
|
|
123
|
+
pending: 0,
|
|
124
|
+
indexing: 0,
|
|
125
|
+
indexed: 0,
|
|
126
|
+
failed: 0,
|
|
127
|
+
disabled: 0,
|
|
128
|
+
},
|
|
129
|
+
activeDocuments: 0,
|
|
130
|
+
activeAtomUnits: 0,
|
|
131
|
+
},
|
|
132
|
+
units: [],
|
|
133
|
+
segments: [],
|
|
134
|
+
atoms: [],
|
|
135
|
+
evidenceSpans: [],
|
|
136
|
+
relationEdges: [],
|
|
137
|
+
temporalEdges: [],
|
|
138
|
+
sessionStates: [],
|
|
139
|
+
conversationSessions: [
|
|
140
|
+
{
|
|
141
|
+
sessionId: 'session_graph_context',
|
|
142
|
+
userId: 'user_graph_context',
|
|
143
|
+
workspaceId: 'optics',
|
|
144
|
+
corpusId: 'optics',
|
|
145
|
+
namespace: 'conversation',
|
|
146
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
147
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
148
|
+
turnIds: ['turn_graph_context_1'],
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
conversationTurns: [
|
|
152
|
+
{
|
|
153
|
+
turnId: 'turn_graph_context_1',
|
|
154
|
+
invocationId: 'invocation_graph_context_1',
|
|
155
|
+
sessionId: 'session_graph_context',
|
|
156
|
+
userId: 'user_graph_context',
|
|
157
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
158
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
159
|
+
request: {
|
|
160
|
+
userId: 'user_graph_context',
|
|
161
|
+
sessionId: 'session_graph_context',
|
|
162
|
+
message: 'compare reflection vs absorption',
|
|
163
|
+
},
|
|
164
|
+
response: {
|
|
165
|
+
userId: 'user_graph_context',
|
|
166
|
+
sessionId: 'session_graph_context',
|
|
167
|
+
assistantMessage: 'Reflection differs from absorption.',
|
|
168
|
+
answer: 'Reflection differs from absorption.',
|
|
169
|
+
assistantBlocks: [],
|
|
170
|
+
knowledgePoints: [
|
|
171
|
+
{
|
|
172
|
+
atomId: 'atom_reflection',
|
|
173
|
+
atomIds: ['atom_reflection'],
|
|
174
|
+
documentId: 'doc_reflection',
|
|
175
|
+
sourcePath: 'Knowledge_Base/optics/reflection.md',
|
|
176
|
+
title: 'Reflection',
|
|
177
|
+
summary: 'Reflection redirects optical energy.',
|
|
178
|
+
evidenceSnippet: 'Reflection redirects optical energy.',
|
|
179
|
+
score: 0.9,
|
|
180
|
+
citation: null,
|
|
181
|
+
capabilities: [],
|
|
182
|
+
relationPath: [
|
|
183
|
+
{
|
|
184
|
+
edgeId: 'edge_reflection_reference',
|
|
185
|
+
sourceAtomId: 'atom_reflection',
|
|
186
|
+
targetAtomId: 'atom_transmission',
|
|
187
|
+
relationKind: 'reference',
|
|
188
|
+
confidence: 0.8,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
relationPathAtomIds: ['atom_transmission'],
|
|
192
|
+
relationKinds: ['reference'],
|
|
193
|
+
temporalValidity: {
|
|
194
|
+
isValid: true,
|
|
195
|
+
checkedAt: '2026-05-26T00:00:00.000Z',
|
|
196
|
+
reasons: ['atom_active'],
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
citations: [],
|
|
201
|
+
recalledMemories: [],
|
|
202
|
+
memoryActions: [],
|
|
203
|
+
summary: {
|
|
204
|
+
generatedAt: '2026-05-26T00:00:00.000Z',
|
|
205
|
+
topK: 6,
|
|
206
|
+
returnedKnowledgePoints: 1,
|
|
207
|
+
returnedCitations: 0,
|
|
208
|
+
recalledMemoryCount: 0,
|
|
209
|
+
appliedMemoryCount: 0,
|
|
210
|
+
queryEvidenceCoverageRatioPct: 0,
|
|
211
|
+
},
|
|
212
|
+
trace: {
|
|
213
|
+
sessionId: 'session_graph_context',
|
|
214
|
+
invocationId: 'invocation_graph_context_1',
|
|
215
|
+
retrieval: {
|
|
216
|
+
retrievalModes: ['keyword', 'graph'],
|
|
217
|
+
asOf: '2026-05-26T00:00:00.000Z',
|
|
218
|
+
totalActiveAtoms: 1,
|
|
219
|
+
modeWeights: {
|
|
220
|
+
keyword: 0.5,
|
|
221
|
+
graph: 0.5,
|
|
222
|
+
temporal: 0,
|
|
223
|
+
},
|
|
224
|
+
latencyMs: 4,
|
|
225
|
+
evidenceCoverageRatio: 0,
|
|
226
|
+
},
|
|
227
|
+
recalledMemoryCount: 0,
|
|
228
|
+
appliedMemoryCount: 0,
|
|
229
|
+
usedScope: {
|
|
230
|
+
source: 'scoped',
|
|
231
|
+
workspaceId: 'optics',
|
|
232
|
+
corpusId: 'optics',
|
|
233
|
+
documentIds: ['doc_reflection'],
|
|
234
|
+
atomIds: ['atom_reflection'],
|
|
235
|
+
sourcePathPrefixes: ['Knowledge_Base/optics'],
|
|
236
|
+
languages: ['en'],
|
|
237
|
+
matchedAtomCount: 1,
|
|
238
|
+
},
|
|
239
|
+
graphContext: {
|
|
240
|
+
anchorAtomId: 'atom_reflection',
|
|
241
|
+
anchorTitle: 'Reflection',
|
|
242
|
+
anchorDocumentId: 'doc_reflection',
|
|
243
|
+
supportingAtomIds: ['atom_transmission'],
|
|
244
|
+
supportingTitles: ['Transmission'],
|
|
245
|
+
relationKinds: ['reference'],
|
|
246
|
+
relationSummaries: [
|
|
247
|
+
{
|
|
248
|
+
relationKind: 'reference',
|
|
249
|
+
edgeIds: ['edge_reflection_reference'],
|
|
250
|
+
sourceAtomIds: ['atom_reflection'],
|
|
251
|
+
targetAtomIds: ['atom_transmission'],
|
|
252
|
+
averageConfidence: 0.8,
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
knowledgePointRelations: [
|
|
256
|
+
{
|
|
257
|
+
edgeId: 'edge_reflection_reference',
|
|
258
|
+
relationKind: 'reference',
|
|
259
|
+
sourceAtomId: 'atom_reflection',
|
|
260
|
+
sourceTitle: 'Reflection',
|
|
261
|
+
targetAtomId: 'atom_transmission',
|
|
262
|
+
targetTitle: 'Transmission',
|
|
263
|
+
confidence: 0.8,
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
connectionPaths: [
|
|
267
|
+
{
|
|
268
|
+
sourceAtomId: 'atom_foundation',
|
|
269
|
+
sourceTitle: 'Foundation Note',
|
|
270
|
+
targetAtomId: 'atom_reflection',
|
|
271
|
+
targetTitle: 'Reflection',
|
|
272
|
+
pathAtomIds: ['atom_foundation', 'atom_bridge', 'atom_reflection'],
|
|
273
|
+
pathTitles: ['Foundation Note', 'Bridge Layer', 'Reflection'],
|
|
274
|
+
pathEdges: [
|
|
275
|
+
{
|
|
276
|
+
fromAtomId: 'atom_foundation',
|
|
277
|
+
toAtomId: 'atom_bridge',
|
|
278
|
+
relationKind: 'prerequisite',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
fromAtomId: 'atom_bridge',
|
|
282
|
+
toAtomId: 'atom_reflection',
|
|
283
|
+
relationKind: 'reference',
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
length: 2,
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
predecessorWindow: [
|
|
290
|
+
{
|
|
291
|
+
atomId: 'atom_bridge',
|
|
292
|
+
title: 'Bridge Layer',
|
|
293
|
+
relationKind: 'prerequisite',
|
|
294
|
+
confidence: 0.91,
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
successorWindow: [
|
|
298
|
+
{
|
|
299
|
+
atomId: 'atom_application',
|
|
300
|
+
title: 'Application Example',
|
|
301
|
+
relationKind: 'sequence',
|
|
302
|
+
confidence: 0.73,
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
evidenceSourceRefs: [
|
|
306
|
+
'Knowledge_Base/optics/foundation.md:8',
|
|
307
|
+
'Knowledge_Base/optics/reflection.md:12',
|
|
308
|
+
],
|
|
309
|
+
diagnostics: {
|
|
310
|
+
graphOpsAvailable: true,
|
|
311
|
+
usedFallback: false,
|
|
312
|
+
selectedAnchorReason: 'title_mention',
|
|
313
|
+
candidateCount: 3,
|
|
314
|
+
supportNodeCount: 2,
|
|
315
|
+
supportNodeLimit: 3,
|
|
316
|
+
pathDepthLimit: 6,
|
|
317
|
+
missingConnectionPathSourceAtomIds: [],
|
|
318
|
+
missingPredecessorAtomIds: [],
|
|
319
|
+
missingSuccessorAtomIds: [],
|
|
320
|
+
},
|
|
321
|
+
temporalValidity: {
|
|
322
|
+
checkedAt: '2026-05-26T00:00:00.000Z',
|
|
323
|
+
allPointsValid: true,
|
|
324
|
+
warningReasons: [],
|
|
325
|
+
invalidKnowledgePointTitles: [],
|
|
326
|
+
edgeKinds: ['supersedes'],
|
|
327
|
+
details: [
|
|
328
|
+
{
|
|
329
|
+
edgeId: 'temporal_reflection_supersedes',
|
|
330
|
+
edgeKind: 'supersedes',
|
|
331
|
+
sourceAtomId: 'atom_reflection_old',
|
|
332
|
+
targetAtomId: 'atom_reflection',
|
|
333
|
+
validFrom: '2026-05-25T00:00:00.000Z',
|
|
334
|
+
isActive: true,
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
conversationInvocations: [],
|
|
344
|
+
workflowArtifacts: [],
|
|
345
|
+
memoryEntries: [],
|
|
346
|
+
memoryAuditRecords: [],
|
|
347
|
+
generatedAt: '2026-05-26T00:00:00.000Z',
|
|
348
|
+
});
|
|
349
|
+
expect(bundle.runtime.conversationTurns).toHaveLength(1);
|
|
350
|
+
expect(bundle.runtime.conversationTurns[0].response.trace.graphContext).toEqual(expect.objectContaining({
|
|
351
|
+
anchorAtomId: 'atom_reflection',
|
|
352
|
+
relationKinds: ['reference'],
|
|
353
|
+
relationSummaries: expect.arrayContaining([
|
|
354
|
+
expect.objectContaining({
|
|
355
|
+
relationKind: 'reference',
|
|
356
|
+
sourceAtomIds: ['atom_reflection'],
|
|
357
|
+
}),
|
|
358
|
+
]),
|
|
359
|
+
knowledgePointRelations: expect.arrayContaining([
|
|
360
|
+
expect.objectContaining({
|
|
361
|
+
relationKind: 'reference',
|
|
362
|
+
sourceTitle: 'Reflection',
|
|
363
|
+
targetTitle: 'Transmission',
|
|
364
|
+
}),
|
|
365
|
+
]),
|
|
366
|
+
connectionPaths: expect.arrayContaining([
|
|
367
|
+
expect.objectContaining({
|
|
368
|
+
sourceTitle: 'Foundation Note',
|
|
369
|
+
targetTitle: 'Reflection',
|
|
370
|
+
pathTitles: ['Foundation Note', 'Bridge Layer', 'Reflection'],
|
|
371
|
+
length: 2,
|
|
372
|
+
}),
|
|
373
|
+
]),
|
|
374
|
+
predecessorWindow: expect.arrayContaining([
|
|
375
|
+
expect.objectContaining({
|
|
376
|
+
atomId: 'atom_bridge',
|
|
377
|
+
title: 'Bridge Layer',
|
|
378
|
+
relationKind: 'prerequisite',
|
|
379
|
+
}),
|
|
380
|
+
]),
|
|
381
|
+
successorWindow: expect.arrayContaining([
|
|
382
|
+
expect.objectContaining({
|
|
383
|
+
atomId: 'atom_application',
|
|
384
|
+
title: 'Application Example',
|
|
385
|
+
relationKind: 'sequence',
|
|
386
|
+
}),
|
|
387
|
+
]),
|
|
388
|
+
evidenceSourceRefs: ['Knowledge_Base/optics/foundation.md:8', 'Knowledge_Base/optics/reflection.md:12'],
|
|
389
|
+
diagnostics: expect.objectContaining({
|
|
390
|
+
graphOpsAvailable: true,
|
|
391
|
+
selectedAnchorReason: 'title_mention',
|
|
392
|
+
pathDepthLimit: 6,
|
|
393
|
+
}),
|
|
394
|
+
temporalValidity: expect.objectContaining({
|
|
395
|
+
edgeKinds: ['supersedes'],
|
|
396
|
+
details: expect.arrayContaining([
|
|
397
|
+
expect.objectContaining({
|
|
398
|
+
edgeId: 'temporal_reflection_supersedes',
|
|
399
|
+
edgeKind: 'supersedes',
|
|
400
|
+
sourceAtomId: 'atom_reflection_old',
|
|
401
|
+
}),
|
|
402
|
+
]),
|
|
403
|
+
}),
|
|
404
|
+
}));
|
|
405
|
+
});
|
|
406
|
+
test('deep clones RAG context and sufficiency review in exported runtime turns', () => {
|
|
407
|
+
const ragContextPack = {
|
|
408
|
+
replayId: 'ragctx_0123456789abcdef',
|
|
409
|
+
query: 'what is water glass?',
|
|
410
|
+
generatedAt: '2026-05-26T00:00:00.000Z',
|
|
411
|
+
sourceBoundary: 'full_document',
|
|
412
|
+
budget: {
|
|
413
|
+
maxFragments: 8,
|
|
414
|
+
maxCharsPerFragment: 800,
|
|
415
|
+
maxTotalChars: 2400,
|
|
416
|
+
},
|
|
417
|
+
fragments: [
|
|
418
|
+
{
|
|
419
|
+
fragmentId: 'fragment_water_glass_direct',
|
|
420
|
+
role: 'direct_support',
|
|
421
|
+
text: 'A water glass is a transparent drinking vessel that contains water.',
|
|
422
|
+
atomId: 'atom_water_glass',
|
|
423
|
+
documentId: 'doc_water_glass',
|
|
424
|
+
sourcePath: 'Knowledge_Base/waterglass/water-glass.md',
|
|
425
|
+
title: 'Water Glass',
|
|
426
|
+
headingPath: ['Water Glass', 'Definition'],
|
|
427
|
+
startLine: 3,
|
|
428
|
+
endLine: 3,
|
|
429
|
+
charCount: 64,
|
|
430
|
+
tokenEstimate: 16,
|
|
431
|
+
truncated: false,
|
|
432
|
+
citationIds: ['evidence_water_glass'],
|
|
433
|
+
relationEdgeIds: [],
|
|
434
|
+
score: 0.92,
|
|
435
|
+
sourceBoundary: 'direct_span_only',
|
|
436
|
+
},
|
|
437
|
+
],
|
|
438
|
+
sourceDecisions: [
|
|
439
|
+
{
|
|
440
|
+
documentId: 'doc_water_glass',
|
|
441
|
+
sourcePath: 'Knowledge_Base/waterglass/water-glass.md',
|
|
442
|
+
sourceBoundary: 'full_document',
|
|
443
|
+
status: 'read',
|
|
444
|
+
charsRead: 240,
|
|
445
|
+
fragmentsSelected: 1,
|
|
446
|
+
},
|
|
447
|
+
],
|
|
448
|
+
totalCharCount: 64,
|
|
449
|
+
tokenEstimate: 16,
|
|
450
|
+
};
|
|
451
|
+
const ragSufficiencyReview = {
|
|
452
|
+
reviewedAt: '2026-05-26T00:00:00.000Z',
|
|
453
|
+
status: 'sufficient',
|
|
454
|
+
score: 0.86,
|
|
455
|
+
reasons: ['answerable_from_context'],
|
|
456
|
+
deterministic: false,
|
|
457
|
+
recoveryAttempted: false,
|
|
458
|
+
llmJudgeUsed: true,
|
|
459
|
+
degradationState: 'none',
|
|
460
|
+
};
|
|
461
|
+
const ragRecovery = {
|
|
462
|
+
attempted: true,
|
|
463
|
+
strategy: 'expanded_context_pack',
|
|
464
|
+
reason: 'borderline',
|
|
465
|
+
beforeStatus: 'borderline',
|
|
466
|
+
afterStatus: 'sufficient',
|
|
467
|
+
beforeScore: 0.58,
|
|
468
|
+
afterScore: 0.86,
|
|
469
|
+
beforeReasons: ['document_augmentation_missing'],
|
|
470
|
+
afterReasons: ['answerable_from_context'],
|
|
471
|
+
beforeFragmentCount: 14,
|
|
472
|
+
afterFragmentCount: 16,
|
|
473
|
+
addedFragmentCount: 2,
|
|
474
|
+
addedRoleCounts: {
|
|
475
|
+
parent_context: 2,
|
|
476
|
+
},
|
|
477
|
+
beforeSourceDecisionStatusCounts: {
|
|
478
|
+
fragment_dropped: 3,
|
|
479
|
+
},
|
|
480
|
+
afterSourceDecisionStatusCounts: {
|
|
481
|
+
fragment_dropped: 1,
|
|
482
|
+
fragment_included: 15,
|
|
483
|
+
},
|
|
484
|
+
};
|
|
485
|
+
const ragFailureClassifications = [
|
|
486
|
+
{
|
|
487
|
+
stage: 'context_assembly',
|
|
488
|
+
code: 'context_budget_limited',
|
|
489
|
+
severity: 'warning',
|
|
490
|
+
message: 'RAG context was budget-limited before release.',
|
|
491
|
+
evidence: ['fragment_dropped'],
|
|
492
|
+
},
|
|
493
|
+
];
|
|
494
|
+
const answerClaimCitations = [
|
|
495
|
+
{
|
|
496
|
+
claimId: 'answer_claim_1',
|
|
497
|
+
text: 'A water glass is a transparent drinking vessel.',
|
|
498
|
+
citationIds: ['evidence_water_glass'],
|
|
499
|
+
fragmentIds: ['fragment_water_glass_direct'],
|
|
500
|
+
sourcePaths: ['Knowledge_Base/waterglass/water-glass.md'],
|
|
501
|
+
supportStatus: 'supported',
|
|
502
|
+
},
|
|
503
|
+
];
|
|
504
|
+
const bundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
|
|
505
|
+
request: {
|
|
506
|
+
workspaceId: 'waterglass',
|
|
507
|
+
exportProfileId: 'mobile-slim',
|
|
508
|
+
},
|
|
509
|
+
workspace: {
|
|
510
|
+
workspaceId: 'waterglass',
|
|
511
|
+
corpusId: 'waterglass',
|
|
512
|
+
name: 'waterglass',
|
|
513
|
+
sourcePathPrefix: 'Knowledge_Base/waterglass',
|
|
514
|
+
languages: ['en'],
|
|
515
|
+
exportProfileId: 'mobile-slim',
|
|
516
|
+
status: 'active',
|
|
517
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
518
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
519
|
+
},
|
|
520
|
+
bindings: [],
|
|
521
|
+
resources: [],
|
|
522
|
+
projections: [],
|
|
523
|
+
indexSummary: {
|
|
524
|
+
totalUnits: 0,
|
|
525
|
+
totalSegments: 0,
|
|
526
|
+
states: {
|
|
527
|
+
pending: 0,
|
|
528
|
+
indexing: 0,
|
|
529
|
+
indexed: 0,
|
|
530
|
+
failed: 0,
|
|
531
|
+
disabled: 0,
|
|
532
|
+
},
|
|
533
|
+
activeDocuments: 0,
|
|
534
|
+
activeAtomUnits: 0,
|
|
535
|
+
},
|
|
536
|
+
units: [],
|
|
537
|
+
segments: [],
|
|
538
|
+
atoms: [],
|
|
539
|
+
evidenceSpans: [],
|
|
540
|
+
relationEdges: [],
|
|
541
|
+
temporalEdges: [],
|
|
542
|
+
sessionStates: [],
|
|
543
|
+
conversationSessions: [],
|
|
544
|
+
conversationTurns: [
|
|
545
|
+
{
|
|
546
|
+
turnId: 'turn_rag_context_1',
|
|
547
|
+
invocationId: 'invocation_rag_context_1',
|
|
548
|
+
sessionId: 'session_rag_context',
|
|
549
|
+
userId: 'user_rag_context',
|
|
550
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
551
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
552
|
+
request: {
|
|
553
|
+
userId: 'user_rag_context',
|
|
554
|
+
sessionId: 'session_rag_context',
|
|
555
|
+
message: 'what is water glass?',
|
|
556
|
+
},
|
|
557
|
+
response: {
|
|
558
|
+
userId: 'user_rag_context',
|
|
559
|
+
sessionId: 'session_rag_context',
|
|
560
|
+
assistantMessage: 'A water glass is a transparent drinking vessel.',
|
|
561
|
+
answer: 'A water glass is a transparent drinking vessel.',
|
|
562
|
+
assistantBlocks: [],
|
|
563
|
+
knowledgePoints: [],
|
|
564
|
+
citations: [],
|
|
565
|
+
recalledMemories: [],
|
|
566
|
+
memoryActions: [],
|
|
567
|
+
summary: {
|
|
568
|
+
generatedAt: '2026-05-26T00:00:00.000Z',
|
|
569
|
+
topK: 6,
|
|
570
|
+
returnedKnowledgePoints: 0,
|
|
571
|
+
returnedCitations: 0,
|
|
572
|
+
recalledMemoryCount: 0,
|
|
573
|
+
appliedMemoryCount: 0,
|
|
574
|
+
queryEvidenceCoverageRatioPct: 0,
|
|
575
|
+
},
|
|
576
|
+
trace: {
|
|
577
|
+
sessionId: 'session_rag_context',
|
|
578
|
+
invocationId: 'invocation_rag_context_1',
|
|
579
|
+
retrieval: {
|
|
580
|
+
retrievalModes: ['keyword'],
|
|
581
|
+
asOf: '2026-05-26T00:00:00.000Z',
|
|
582
|
+
totalActiveAtoms: 1,
|
|
583
|
+
modeWeights: {
|
|
584
|
+
keyword: 1,
|
|
585
|
+
graph: 0,
|
|
586
|
+
temporal: 0,
|
|
587
|
+
},
|
|
588
|
+
latencyMs: 2,
|
|
589
|
+
evidenceCoverageRatio: 1,
|
|
590
|
+
},
|
|
591
|
+
recalledMemoryCount: 0,
|
|
592
|
+
appliedMemoryCount: 0,
|
|
593
|
+
usedScope: {
|
|
594
|
+
source: 'scoped',
|
|
595
|
+
workspaceId: 'waterglass',
|
|
596
|
+
corpusId: 'waterglass',
|
|
597
|
+
documentIds: ['doc_water_glass'],
|
|
598
|
+
atomIds: ['atom_water_glass'],
|
|
599
|
+
sourcePathPrefixes: ['Knowledge_Base/waterglass'],
|
|
600
|
+
languages: ['en'],
|
|
601
|
+
matchedAtomCount: 1,
|
|
602
|
+
},
|
|
603
|
+
ragContextPack,
|
|
604
|
+
ragSufficiencyReview,
|
|
605
|
+
ragRecovery,
|
|
606
|
+
ragFailureClassifications,
|
|
607
|
+
answerClaimCitations,
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
],
|
|
612
|
+
conversationInvocations: [],
|
|
613
|
+
workflowArtifacts: [],
|
|
614
|
+
memoryEntries: [],
|
|
615
|
+
memoryAuditRecords: [],
|
|
616
|
+
generatedAt: '2026-05-26T00:00:00.000Z',
|
|
617
|
+
});
|
|
618
|
+
ragContextPack.fragments[0].text = 'mutated after export';
|
|
619
|
+
ragContextPack.sourceDecisions[0].reason = 'mutated_after_export';
|
|
620
|
+
ragSufficiencyReview.reasons.push('mutated_after_export');
|
|
621
|
+
ragRecovery.addedRoleCounts.parent_context = 999;
|
|
622
|
+
ragRecovery.beforeReasons.push('mutated_after_export');
|
|
623
|
+
ragRecovery.afterReasons.push('mutated_after_export');
|
|
624
|
+
ragRecovery.beforeSourceDecisionStatusCounts.fragment_dropped = 999;
|
|
625
|
+
ragRecovery.afterSourceDecisionStatusCounts.fragment_included = 999;
|
|
626
|
+
ragFailureClassifications[0].evidence.push('mutated_after_export');
|
|
627
|
+
answerClaimCitations[0].citationIds.push('mutated_after_export');
|
|
628
|
+
answerClaimCitations[0].fragmentIds.push('mutated_after_export');
|
|
629
|
+
answerClaimCitations[0].sourcePaths.push('mutated_after_export');
|
|
630
|
+
const exportedTrace = bundle.runtime.conversationTurns[0].response.trace;
|
|
631
|
+
expect(exportedTrace.ragContextPack.replayId).toBe('ragctx_0123456789abcdef');
|
|
632
|
+
expect(exportedTrace.ragContextPack.fragments[0].text).toBe('A water glass is a transparent drinking vessel that contains water.');
|
|
633
|
+
expect(exportedTrace.ragContextPack.sourceDecisions[0].reason).toBeUndefined();
|
|
634
|
+
expect(exportedTrace.ragSufficiencyReview.reasons).toEqual(['answerable_from_context']);
|
|
635
|
+
expect(exportedTrace.ragRecovery.addedRoleCounts.parent_context).toBe(2);
|
|
636
|
+
expect(exportedTrace.ragRecovery.beforeReasons).toEqual(['document_augmentation_missing']);
|
|
637
|
+
expect(exportedTrace.ragRecovery.afterReasons).toEqual(['answerable_from_context']);
|
|
638
|
+
expect(exportedTrace.ragRecovery.beforeSourceDecisionStatusCounts.fragment_dropped).toBe(3);
|
|
639
|
+
expect(exportedTrace.ragRecovery.afterSourceDecisionStatusCounts.fragment_included).toBe(15);
|
|
640
|
+
expect(exportedTrace.ragFailureClassifications).toEqual([
|
|
641
|
+
expect.objectContaining({
|
|
642
|
+
stage: 'context_assembly',
|
|
643
|
+
code: 'context_budget_limited',
|
|
644
|
+
evidence: ['fragment_dropped'],
|
|
645
|
+
}),
|
|
646
|
+
]);
|
|
647
|
+
expect(exportedTrace.answerClaimCitations).toEqual([
|
|
648
|
+
expect.objectContaining({
|
|
649
|
+
claimId: 'answer_claim_1',
|
|
650
|
+
citationIds: ['evidence_water_glass'],
|
|
651
|
+
fragmentIds: ['fragment_water_glass_direct'],
|
|
652
|
+
sourcePaths: ['Knowledge_Base/waterglass/water-glass.md'],
|
|
653
|
+
supportStatus: 'supported',
|
|
654
|
+
}),
|
|
655
|
+
]);
|
|
656
|
+
});
|
|
657
|
+
test('adds durable knowledge-run graph reports to the exported runtime surface', () => {
|
|
658
|
+
const bundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
|
|
659
|
+
request: {
|
|
660
|
+
workspaceId: 'optics',
|
|
661
|
+
exportProfileId: 'mobile-slim',
|
|
662
|
+
},
|
|
663
|
+
workspace: {
|
|
664
|
+
workspaceId: 'optics',
|
|
665
|
+
corpusId: 'optics',
|
|
666
|
+
name: 'optics',
|
|
667
|
+
sourcePathPrefix: 'knowledge_base/optics',
|
|
668
|
+
languages: ['zh', 'en'],
|
|
669
|
+
exportProfileId: 'mobile-slim',
|
|
670
|
+
status: 'active',
|
|
671
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
672
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
673
|
+
},
|
|
674
|
+
bindings: [],
|
|
675
|
+
resources: [],
|
|
676
|
+
projections: [],
|
|
677
|
+
indexSummary: {
|
|
678
|
+
totalUnits: 0,
|
|
679
|
+
totalSegments: 0,
|
|
680
|
+
states: {
|
|
681
|
+
pending: 0,
|
|
682
|
+
indexing: 0,
|
|
683
|
+
indexed: 0,
|
|
684
|
+
failed: 0,
|
|
685
|
+
disabled: 0,
|
|
686
|
+
},
|
|
687
|
+
activeDocuments: 0,
|
|
688
|
+
activeAtomUnits: 0,
|
|
689
|
+
},
|
|
690
|
+
units: [],
|
|
691
|
+
segments: [],
|
|
692
|
+
atoms: [],
|
|
693
|
+
evidenceSpans: [],
|
|
694
|
+
relationEdges: [],
|
|
695
|
+
temporalEdges: [],
|
|
696
|
+
sessionStates: [],
|
|
697
|
+
conversationSessions: [],
|
|
698
|
+
conversationTurns: [],
|
|
699
|
+
conversationInvocations: [],
|
|
700
|
+
workflowArtifacts: [
|
|
701
|
+
{
|
|
702
|
+
artifactId: 'workflow_artifact_knowledge_run_2',
|
|
703
|
+
kind: 'knowledge_run',
|
|
704
|
+
sessionId: 'session_knowledge_run_2',
|
|
705
|
+
userId: 'user_optics',
|
|
706
|
+
workspaceId: 'optics',
|
|
707
|
+
corpusId: 'optics',
|
|
708
|
+
title: 'Knowledge run: Absorption',
|
|
709
|
+
sourceResourceIds: ['resource_absorption'],
|
|
710
|
+
sourceProjectionIds: ['projection_absorption'],
|
|
711
|
+
summary: 'Generated 2 evidence claim(s) and 1 review card(s) with status caution.',
|
|
712
|
+
payload: {
|
|
713
|
+
answerReleaseReview: {
|
|
714
|
+
reviewedAt: '2026-05-27T00:00:00.000Z',
|
|
715
|
+
decision: 'revise',
|
|
716
|
+
revised: true,
|
|
717
|
+
originalAnswer: 'No scoped knowledge points matched "Absorption".',
|
|
718
|
+
publicAnswer: 'Absorption: optical energy is attenuated inside the material.',
|
|
719
|
+
reason: 'Draft answer had usable evidence but required contraction before public release.',
|
|
720
|
+
failedGateIds: ['claim_grounding_alignment', 'internal_diagnostic_leakage'],
|
|
721
|
+
leakedInternalFragments: ['No scoped knowledge points matched'],
|
|
722
|
+
gates: [],
|
|
723
|
+
},
|
|
724
|
+
knowledgeRun: {
|
|
725
|
+
runId: 'knowledge_run_2',
|
|
726
|
+
generatedAt: '2026-05-27T00:00:00.000Z',
|
|
727
|
+
status: 'caution',
|
|
728
|
+
scope: {
|
|
729
|
+
source: 'scoped',
|
|
730
|
+
workspaceId: 'optics',
|
|
731
|
+
corpusId: 'optics',
|
|
732
|
+
documentIds: [],
|
|
733
|
+
atomIds: [],
|
|
734
|
+
sourcePathPrefixes: ['Knowledge_Base/optics'],
|
|
735
|
+
languages: ['en'],
|
|
736
|
+
matchedAtomCount: 2,
|
|
737
|
+
scopeSource: 'explicit_request',
|
|
738
|
+
},
|
|
739
|
+
quality: {
|
|
740
|
+
score: 72,
|
|
741
|
+
status: 'caution',
|
|
742
|
+
gates: [],
|
|
743
|
+
},
|
|
744
|
+
summary: {
|
|
745
|
+
claimCount: 2,
|
|
746
|
+
weakClaimCount: 1,
|
|
747
|
+
reviewCardCount: 1,
|
|
748
|
+
completedReviewCardCount: 0,
|
|
749
|
+
remainingReviewCardCount: 1,
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
graphContext: {
|
|
753
|
+
anchorAtomId: 'atom_absorption',
|
|
754
|
+
anchorTitle: 'Absorption',
|
|
755
|
+
supportingAtomIds: ['atom_attenuation'],
|
|
756
|
+
supportingTitles: ['Attenuation coupling'],
|
|
757
|
+
relationKinds: ['contrast'],
|
|
758
|
+
relationSummaries: [],
|
|
759
|
+
connectionPaths: [],
|
|
760
|
+
predecessorWindow: [],
|
|
761
|
+
successorWindow: [],
|
|
762
|
+
evidenceSourceRefs: ['Knowledge_Base/optics/absorption.md:18'],
|
|
763
|
+
diagnostics: {
|
|
764
|
+
graphOpsAvailable: false,
|
|
765
|
+
usedFallback: true,
|
|
766
|
+
selectedAnchorReason: 'retrieval_score',
|
|
767
|
+
candidateCount: 2,
|
|
768
|
+
supportNodeCount: 1,
|
|
769
|
+
supportNodeLimit: 2,
|
|
770
|
+
pathDepthLimit: 6,
|
|
771
|
+
missingConnectionPathSourceAtomIds: ['atom_attenuation'],
|
|
772
|
+
missingPredecessorAtomIds: [],
|
|
773
|
+
missingSuccessorAtomIds: ['atom_absorption_future'],
|
|
774
|
+
},
|
|
775
|
+
temporalValidity: {
|
|
776
|
+
checkedAt: '2026-05-27T00:00:00.000Z',
|
|
777
|
+
allPointsValid: false,
|
|
778
|
+
warningReasons: ['temporal_edge_expired'],
|
|
779
|
+
invalidKnowledgePointTitles: ['Attenuation coupling'],
|
|
780
|
+
},
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
status: 'active',
|
|
784
|
+
createdAt: '2026-05-27T00:00:00.000Z',
|
|
785
|
+
updatedAt: '2026-05-27T00:00:00.000Z',
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
artifactId: 'workflow_artifact_knowledge_run_1',
|
|
789
|
+
kind: 'knowledge_run',
|
|
790
|
+
sessionId: 'session_knowledge_run_1',
|
|
791
|
+
userId: 'user_optics',
|
|
792
|
+
workspaceId: 'optics',
|
|
793
|
+
corpusId: 'optics',
|
|
794
|
+
title: 'Knowledge run: Reflection',
|
|
795
|
+
sourceResourceIds: ['resource_reflection'],
|
|
796
|
+
sourceProjectionIds: ['projection_reflection'],
|
|
797
|
+
summary: 'Generated 1 evidence claim(s) and 1 review card(s) with status pass.',
|
|
798
|
+
payload: {
|
|
799
|
+
knowledgeRun: {
|
|
800
|
+
runId: 'knowledge_run_1',
|
|
801
|
+
generatedAt: '2026-05-28T00:00:00.000Z',
|
|
802
|
+
status: 'pass',
|
|
803
|
+
scope: {
|
|
804
|
+
source: 'scoped',
|
|
805
|
+
workspaceId: 'optics',
|
|
806
|
+
corpusId: 'optics',
|
|
807
|
+
documentIds: [],
|
|
808
|
+
atomIds: [],
|
|
809
|
+
sourcePathPrefixes: ['Knowledge_Base/optics'],
|
|
810
|
+
languages: ['en'],
|
|
811
|
+
matchedAtomCount: 1,
|
|
812
|
+
scopeSource: 'explicit_request',
|
|
813
|
+
},
|
|
814
|
+
quality: {
|
|
815
|
+
score: 100,
|
|
816
|
+
status: 'pass',
|
|
817
|
+
gates: [],
|
|
818
|
+
},
|
|
819
|
+
summary: {
|
|
820
|
+
claimCount: 1,
|
|
821
|
+
weakClaimCount: 0,
|
|
822
|
+
reviewCardCount: 1,
|
|
823
|
+
completedReviewCardCount: 0,
|
|
824
|
+
remainingReviewCardCount: 1,
|
|
825
|
+
},
|
|
826
|
+
answerReleaseReview: {
|
|
827
|
+
reviewedAt: '2026-05-28T00:00:00.000Z',
|
|
828
|
+
decision: 'release',
|
|
829
|
+
revised: false,
|
|
830
|
+
originalAnswer: 'Reflection redirects optical energy.',
|
|
831
|
+
publicAnswer: 'Reflection redirects optical energy.',
|
|
832
|
+
reason: 'Draft answer satisfied the public-release gates.',
|
|
833
|
+
failedGateIds: [],
|
|
834
|
+
leakedInternalFragments: [],
|
|
835
|
+
gates: [],
|
|
836
|
+
},
|
|
837
|
+
},
|
|
838
|
+
graphContext: {
|
|
839
|
+
anchorAtomId: 'atom_reflection',
|
|
840
|
+
anchorTitle: 'Reflection',
|
|
841
|
+
supportingAtomIds: ['atom_foundation'],
|
|
842
|
+
supportingTitles: ['Foundation Note'],
|
|
843
|
+
relationKinds: ['prerequisite'],
|
|
844
|
+
relationSummaries: [],
|
|
845
|
+
connectionPaths: [
|
|
846
|
+
{
|
|
847
|
+
sourceAtomId: 'atom_foundation',
|
|
848
|
+
sourceTitle: 'Foundation Note',
|
|
849
|
+
targetAtomId: 'atom_reflection',
|
|
850
|
+
targetTitle: 'Reflection',
|
|
851
|
+
pathAtomIds: ['atom_foundation', 'atom_reflection'],
|
|
852
|
+
pathTitles: ['Foundation Note', 'Reflection'],
|
|
853
|
+
pathEdges: [],
|
|
854
|
+
length: 1,
|
|
855
|
+
},
|
|
856
|
+
],
|
|
857
|
+
predecessorWindow: [
|
|
858
|
+
{
|
|
859
|
+
atomId: 'atom_foundation',
|
|
860
|
+
title: 'Foundation Note',
|
|
861
|
+
relationKind: 'prerequisite',
|
|
862
|
+
confidence: 0.91,
|
|
863
|
+
},
|
|
864
|
+
],
|
|
865
|
+
successorWindow: [],
|
|
866
|
+
evidenceSourceRefs: ['Knowledge_Base/optics/reflection.md:12'],
|
|
867
|
+
diagnostics: {
|
|
868
|
+
graphOpsAvailable: true,
|
|
869
|
+
usedFallback: false,
|
|
870
|
+
selectedAnchorReason: 'title_mention',
|
|
871
|
+
candidateCount: 1,
|
|
872
|
+
supportNodeCount: 1,
|
|
873
|
+
supportNodeLimit: 2,
|
|
874
|
+
pathDepthLimit: 6,
|
|
875
|
+
missingConnectionPathSourceAtomIds: [],
|
|
876
|
+
missingPredecessorAtomIds: [],
|
|
877
|
+
missingSuccessorAtomIds: [],
|
|
878
|
+
},
|
|
879
|
+
temporalValidity: {
|
|
880
|
+
checkedAt: '2026-05-28T00:00:00.000Z',
|
|
881
|
+
allPointsValid: true,
|
|
882
|
+
warningReasons: [],
|
|
883
|
+
invalidKnowledgePointTitles: [],
|
|
884
|
+
},
|
|
885
|
+
},
|
|
886
|
+
},
|
|
887
|
+
status: 'active',
|
|
888
|
+
createdAt: '2026-05-28T00:00:00.000Z',
|
|
889
|
+
updatedAt: '2026-05-28T00:00:00.000Z',
|
|
890
|
+
},
|
|
891
|
+
],
|
|
892
|
+
memoryEntries: [],
|
|
893
|
+
memoryAuditRecords: [],
|
|
894
|
+
generatedAt: '2026-05-28T00:00:00.000Z',
|
|
895
|
+
});
|
|
896
|
+
expect(bundle.runtime.knowledgeRunReports).toEqual([
|
|
897
|
+
expect.objectContaining({
|
|
898
|
+
artifactId: 'workflow_artifact_knowledge_run_1',
|
|
899
|
+
runId: 'knowledge_run_1',
|
|
900
|
+
qualityStatus: 'pass',
|
|
901
|
+
qualityScore: 100,
|
|
902
|
+
answerReleaseReview: expect.objectContaining({
|
|
903
|
+
reviewedAt: '2026-05-28T00:00:00.000Z',
|
|
904
|
+
decision: 'release',
|
|
905
|
+
revised: false,
|
|
906
|
+
failedGateIds: [],
|
|
907
|
+
leakedInternalFragmentCount: 0,
|
|
908
|
+
reason: 'Draft answer satisfied the public-release gates.',
|
|
909
|
+
}),
|
|
910
|
+
graphSignal: expect.objectContaining({
|
|
911
|
+
graphOpsAvailable: true,
|
|
912
|
+
usedFallback: false,
|
|
913
|
+
connectionPathCount: 1,
|
|
914
|
+
temporalWarningCount: 0,
|
|
915
|
+
missingLookupCount: 0,
|
|
916
|
+
}),
|
|
917
|
+
}),
|
|
918
|
+
expect.objectContaining({
|
|
919
|
+
artifactId: 'workflow_artifact_knowledge_run_2',
|
|
920
|
+
runId: 'knowledge_run_2',
|
|
921
|
+
qualityStatus: 'caution',
|
|
922
|
+
qualityScore: 72,
|
|
923
|
+
answerReleaseReview: expect.objectContaining({
|
|
924
|
+
reviewedAt: '2026-05-27T00:00:00.000Z',
|
|
925
|
+
decision: 'revise',
|
|
926
|
+
revised: true,
|
|
927
|
+
failedGateIds: ['claim_grounding_alignment', 'internal_diagnostic_leakage'],
|
|
928
|
+
leakedInternalFragmentCount: 1,
|
|
929
|
+
reason: 'Draft answer had usable evidence but required contraction before public release.',
|
|
930
|
+
}),
|
|
931
|
+
graphSignal: expect.objectContaining({
|
|
932
|
+
graphOpsAvailable: false,
|
|
933
|
+
usedFallback: true,
|
|
934
|
+
connectionPathCount: 0,
|
|
935
|
+
temporalWarningCount: 1,
|
|
936
|
+
missingLookupCount: 2,
|
|
937
|
+
}),
|
|
938
|
+
}),
|
|
939
|
+
]);
|
|
940
|
+
expect(bundle.runtime.knowledgeRunAnswerReleaseAuditSummary).toEqual({
|
|
941
|
+
totalRuns: 2,
|
|
942
|
+
reviewedRunCount: 2,
|
|
943
|
+
unreviewedRunCount: 0,
|
|
944
|
+
decisionCounts: {
|
|
945
|
+
release: 1,
|
|
946
|
+
revise: 1,
|
|
947
|
+
abstain: 0,
|
|
948
|
+
other: 0,
|
|
949
|
+
},
|
|
950
|
+
revisedRunCount: 1,
|
|
951
|
+
runsWithFailedGates: 1,
|
|
952
|
+
runsWithLeakedInternalFragments: 1,
|
|
953
|
+
leakedInternalFragmentTotalCount: 1,
|
|
954
|
+
failedGateCounts: [
|
|
955
|
+
{
|
|
956
|
+
gateId: 'claim_grounding_alignment',
|
|
957
|
+
count: 1,
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
gateId: 'internal_diagnostic_leakage',
|
|
961
|
+
count: 1,
|
|
962
|
+
},
|
|
963
|
+
],
|
|
964
|
+
latestReviewedAt: '2026-05-28T00:00:00.000Z',
|
|
965
|
+
reviewTrend: {
|
|
966
|
+
windowSize: 4,
|
|
967
|
+
recentWindow: {
|
|
968
|
+
reviewedRunCount: 2,
|
|
969
|
+
decisionCounts: {
|
|
970
|
+
release: 1,
|
|
971
|
+
revise: 1,
|
|
972
|
+
abstain: 0,
|
|
973
|
+
other: 0,
|
|
974
|
+
},
|
|
975
|
+
revisedRunCount: 1,
|
|
976
|
+
runsWithFailedGates: 1,
|
|
977
|
+
runsWithLeakedInternalFragments: 1,
|
|
978
|
+
latestReviewedAt: '2026-05-28T00:00:00.000Z',
|
|
979
|
+
earliestReviewedAt: '2026-05-27T00:00:00.000Z',
|
|
980
|
+
},
|
|
981
|
+
priorWindow: {
|
|
982
|
+
reviewedRunCount: 0,
|
|
983
|
+
decisionCounts: {
|
|
984
|
+
release: 0,
|
|
985
|
+
revise: 0,
|
|
986
|
+
abstain: 0,
|
|
987
|
+
other: 0,
|
|
988
|
+
},
|
|
989
|
+
revisedRunCount: 0,
|
|
990
|
+
runsWithFailedGates: 0,
|
|
991
|
+
runsWithLeakedInternalFragments: 0,
|
|
992
|
+
latestReviewedAt: '',
|
|
993
|
+
earliestReviewedAt: '',
|
|
994
|
+
},
|
|
995
|
+
},
|
|
996
|
+
failedGateAging: [
|
|
997
|
+
{
|
|
998
|
+
gateId: 'claim_grounding_alignment',
|
|
999
|
+
failureCount: 1,
|
|
1000
|
+
latestReviewedAt: '2026-05-27T00:00:00.000Z',
|
|
1001
|
+
oldestReviewedAt: '2026-05-27T00:00:00.000Z',
|
|
1002
|
+
reviewedRunsSinceLastFailure: 1,
|
|
1003
|
+
occurrencesInRecentWindow: 1,
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
gateId: 'internal_diagnostic_leakage',
|
|
1007
|
+
failureCount: 1,
|
|
1008
|
+
latestReviewedAt: '2026-05-27T00:00:00.000Z',
|
|
1009
|
+
oldestReviewedAt: '2026-05-27T00:00:00.000Z',
|
|
1010
|
+
reviewedRunsSinceLastFailure: 1,
|
|
1011
|
+
occurrencesInRecentWindow: 1,
|
|
1012
|
+
},
|
|
1013
|
+
],
|
|
1014
|
+
comparison: {
|
|
1015
|
+
metricShifts: [
|
|
1016
|
+
{
|
|
1017
|
+
metricId: 'reviewed_runs',
|
|
1018
|
+
recentValue: 2,
|
|
1019
|
+
priorValue: 0,
|
|
1020
|
+
delta: 2,
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
metricId: 'release_decisions',
|
|
1024
|
+
recentValue: 1,
|
|
1025
|
+
priorValue: 0,
|
|
1026
|
+
delta: 1,
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
metricId: 'revise_decisions',
|
|
1030
|
+
recentValue: 1,
|
|
1031
|
+
priorValue: 0,
|
|
1032
|
+
delta: 1,
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
metricId: 'abstain_decisions',
|
|
1036
|
+
recentValue: 0,
|
|
1037
|
+
priorValue: 0,
|
|
1038
|
+
delta: 0,
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
metricId: 'other_decisions',
|
|
1042
|
+
recentValue: 0,
|
|
1043
|
+
priorValue: 0,
|
|
1044
|
+
delta: 0,
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
metricId: 'revised_runs',
|
|
1048
|
+
recentValue: 1,
|
|
1049
|
+
priorValue: 0,
|
|
1050
|
+
delta: 1,
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
metricId: 'failed_gate_runs',
|
|
1054
|
+
recentValue: 1,
|
|
1055
|
+
priorValue: 0,
|
|
1056
|
+
delta: 1,
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
metricId: 'leaked_runs',
|
|
1060
|
+
recentValue: 1,
|
|
1061
|
+
priorValue: 0,
|
|
1062
|
+
delta: 1,
|
|
1063
|
+
},
|
|
1064
|
+
],
|
|
1065
|
+
gateShifts: [
|
|
1066
|
+
{
|
|
1067
|
+
gateId: 'claim_grounding_alignment',
|
|
1068
|
+
recentWindowCount: 1,
|
|
1069
|
+
priorWindowCount: 0,
|
|
1070
|
+
delta: 1,
|
|
1071
|
+
failureCount: 1,
|
|
1072
|
+
latestReviewedAt: '2026-05-27T00:00:00.000Z',
|
|
1073
|
+
reviewedRunsSinceLastFailure: 1,
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
gateId: 'internal_diagnostic_leakage',
|
|
1077
|
+
recentWindowCount: 1,
|
|
1078
|
+
priorWindowCount: 0,
|
|
1079
|
+
delta: 1,
|
|
1080
|
+
failureCount: 1,
|
|
1081
|
+
latestReviewedAt: '2026-05-27T00:00:00.000Z',
|
|
1082
|
+
reviewedRunsSinceLastFailure: 1,
|
|
1083
|
+
},
|
|
1084
|
+
],
|
|
1085
|
+
latestPair: {
|
|
1086
|
+
latestRunId: 'knowledge_run_1',
|
|
1087
|
+
previousRunId: 'knowledge_run_2',
|
|
1088
|
+
latestReviewedAt: '2026-05-28T00:00:00.000Z',
|
|
1089
|
+
previousReviewedAt: '2026-05-27T00:00:00.000Z',
|
|
1090
|
+
latestDecision: 'release',
|
|
1091
|
+
previousDecision: 'revise',
|
|
1092
|
+
decisionChanged: true,
|
|
1093
|
+
latestRevised: false,
|
|
1094
|
+
previousRevised: true,
|
|
1095
|
+
revisedChanged: true,
|
|
1096
|
+
latestLeakedInternalFragmentCount: 0,
|
|
1097
|
+
previousLeakedInternalFragmentCount: 1,
|
|
1098
|
+
leakedInternalFragmentDelta: -1,
|
|
1099
|
+
newlyFailedGateIds: [],
|
|
1100
|
+
resolvedFailedGateIds: ['claim_grounding_alignment', 'internal_diagnostic_leakage'],
|
|
1101
|
+
persistentFailedGateIds: [],
|
|
1102
|
+
},
|
|
1103
|
+
},
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
1106
|
+
test('keeps knowledge-run export reports backward-compatible when answer release review is absent', () => {
|
|
1107
|
+
const bundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
|
|
1108
|
+
request: {
|
|
1109
|
+
workspaceId: 'optics',
|
|
1110
|
+
exportProfileId: 'mobile-slim',
|
|
1111
|
+
},
|
|
1112
|
+
workspace: {
|
|
1113
|
+
workspaceId: 'optics',
|
|
1114
|
+
corpusId: 'optics',
|
|
1115
|
+
name: 'optics',
|
|
1116
|
+
sourcePathPrefix: 'knowledge_base/optics',
|
|
1117
|
+
languages: ['zh', 'en'],
|
|
1118
|
+
exportProfileId: 'mobile-slim',
|
|
1119
|
+
status: 'active',
|
|
1120
|
+
createdAt: '2026-05-28T00:00:00.000Z',
|
|
1121
|
+
updatedAt: '2026-05-28T00:00:00.000Z',
|
|
1122
|
+
},
|
|
1123
|
+
bindings: [],
|
|
1124
|
+
resources: [],
|
|
1125
|
+
projections: [],
|
|
1126
|
+
indexSummary: {
|
|
1127
|
+
totalUnits: 0,
|
|
1128
|
+
totalSegments: 0,
|
|
1129
|
+
states: {
|
|
1130
|
+
pending: 0,
|
|
1131
|
+
indexing: 0,
|
|
1132
|
+
indexed: 0,
|
|
1133
|
+
failed: 0,
|
|
1134
|
+
disabled: 0,
|
|
1135
|
+
},
|
|
1136
|
+
activeDocuments: 0,
|
|
1137
|
+
activeAtomUnits: 0,
|
|
1138
|
+
},
|
|
1139
|
+
units: [],
|
|
1140
|
+
segments: [],
|
|
1141
|
+
atoms: [],
|
|
1142
|
+
evidenceSpans: [],
|
|
1143
|
+
relationEdges: [],
|
|
1144
|
+
temporalEdges: [],
|
|
1145
|
+
sessionStates: [],
|
|
1146
|
+
conversationSessions: [],
|
|
1147
|
+
conversationTurns: [],
|
|
1148
|
+
conversationInvocations: [],
|
|
1149
|
+
workflowArtifacts: [
|
|
1150
|
+
{
|
|
1151
|
+
artifactId: 'workflow_artifact_knowledge_run_without_review',
|
|
1152
|
+
kind: 'knowledge_run',
|
|
1153
|
+
sessionId: 'session_knowledge_run_without_review',
|
|
1154
|
+
userId: 'user_optics',
|
|
1155
|
+
workspaceId: 'optics',
|
|
1156
|
+
corpusId: 'optics',
|
|
1157
|
+
title: 'Knowledge run: No review',
|
|
1158
|
+
sourceResourceIds: [],
|
|
1159
|
+
sourceProjectionIds: [],
|
|
1160
|
+
summary: 'Generated 1 evidence claim(s) with legacy payload shape.',
|
|
1161
|
+
payload: {
|
|
1162
|
+
knowledgeRun: {
|
|
1163
|
+
runId: 'knowledge_run_without_review',
|
|
1164
|
+
generatedAt: '2026-05-28T00:00:00.000Z',
|
|
1165
|
+
status: 'pass',
|
|
1166
|
+
scope: {
|
|
1167
|
+
source: 'scoped',
|
|
1168
|
+
workspaceId: 'optics',
|
|
1169
|
+
corpusId: 'optics',
|
|
1170
|
+
documentIds: [],
|
|
1171
|
+
atomIds: [],
|
|
1172
|
+
sourcePathPrefixes: ['Knowledge_Base/optics'],
|
|
1173
|
+
languages: ['en'],
|
|
1174
|
+
matchedAtomCount: 1,
|
|
1175
|
+
scopeSource: 'explicit_request',
|
|
1176
|
+
},
|
|
1177
|
+
quality: {
|
|
1178
|
+
score: 90,
|
|
1179
|
+
status: 'pass',
|
|
1180
|
+
gates: [],
|
|
1181
|
+
},
|
|
1182
|
+
summary: {
|
|
1183
|
+
claimCount: 1,
|
|
1184
|
+
weakClaimCount: 0,
|
|
1185
|
+
reviewCardCount: 0,
|
|
1186
|
+
completedReviewCardCount: 0,
|
|
1187
|
+
remainingReviewCardCount: 0,
|
|
1188
|
+
},
|
|
1189
|
+
},
|
|
1190
|
+
graphContext: {
|
|
1191
|
+
diagnostics: {
|
|
1192
|
+
graphOpsAvailable: true,
|
|
1193
|
+
usedFallback: false,
|
|
1194
|
+
selectedAnchorReason: 'title_mention',
|
|
1195
|
+
supportNodeCount: 0,
|
|
1196
|
+
supportNodeLimit: 0,
|
|
1197
|
+
pathDepthLimit: 0,
|
|
1198
|
+
missingConnectionPathSourceAtomIds: [],
|
|
1199
|
+
missingPredecessorAtomIds: [],
|
|
1200
|
+
missingSuccessorAtomIds: [],
|
|
1201
|
+
},
|
|
1202
|
+
temporalValidity: {
|
|
1203
|
+
checkedAt: '2026-05-28T00:00:00.000Z',
|
|
1204
|
+
allPointsValid: true,
|
|
1205
|
+
warningReasons: [],
|
|
1206
|
+
invalidKnowledgePointTitles: [],
|
|
1207
|
+
},
|
|
1208
|
+
},
|
|
1209
|
+
},
|
|
1210
|
+
status: 'active',
|
|
1211
|
+
createdAt: '2026-05-28T00:00:00.000Z',
|
|
1212
|
+
updatedAt: '2026-05-28T00:00:00.000Z',
|
|
1213
|
+
},
|
|
1214
|
+
],
|
|
1215
|
+
memoryEntries: [],
|
|
1216
|
+
memoryAuditRecords: [],
|
|
1217
|
+
generatedAt: '2026-05-28T00:00:00.000Z',
|
|
1218
|
+
});
|
|
1219
|
+
expect(bundle.runtime.knowledgeRunReports).toHaveLength(1);
|
|
1220
|
+
expect(bundle.runtime.knowledgeRunReports[0]).toEqual(expect.objectContaining({
|
|
1221
|
+
artifactId: 'workflow_artifact_knowledge_run_without_review',
|
|
1222
|
+
runId: 'knowledge_run_without_review',
|
|
1223
|
+
qualityStatus: 'pass',
|
|
1224
|
+
qualityScore: 90,
|
|
1225
|
+
}));
|
|
1226
|
+
expect(Object.prototype.hasOwnProperty.call(bundle.runtime.knowledgeRunReports[0], 'answerReleaseReview')).toBe(false);
|
|
1227
|
+
expect(bundle.runtime.knowledgeRunAnswerReleaseAuditSummary).toEqual({
|
|
1228
|
+
totalRuns: 1,
|
|
1229
|
+
reviewedRunCount: 0,
|
|
1230
|
+
unreviewedRunCount: 1,
|
|
1231
|
+
decisionCounts: {
|
|
1232
|
+
release: 0,
|
|
1233
|
+
revise: 0,
|
|
1234
|
+
abstain: 0,
|
|
1235
|
+
other: 0,
|
|
1236
|
+
},
|
|
1237
|
+
revisedRunCount: 0,
|
|
1238
|
+
runsWithFailedGates: 0,
|
|
1239
|
+
runsWithLeakedInternalFragments: 0,
|
|
1240
|
+
leakedInternalFragmentTotalCount: 0,
|
|
1241
|
+
failedGateCounts: [],
|
|
1242
|
+
latestReviewedAt: '',
|
|
1243
|
+
reviewTrend: {
|
|
1244
|
+
windowSize: 4,
|
|
1245
|
+
recentWindow: {
|
|
1246
|
+
reviewedRunCount: 0,
|
|
1247
|
+
decisionCounts: {
|
|
1248
|
+
release: 0,
|
|
1249
|
+
revise: 0,
|
|
1250
|
+
abstain: 0,
|
|
1251
|
+
other: 0,
|
|
1252
|
+
},
|
|
1253
|
+
revisedRunCount: 0,
|
|
1254
|
+
runsWithFailedGates: 0,
|
|
1255
|
+
runsWithLeakedInternalFragments: 0,
|
|
1256
|
+
latestReviewedAt: '',
|
|
1257
|
+
earliestReviewedAt: '',
|
|
1258
|
+
},
|
|
1259
|
+
priorWindow: {
|
|
1260
|
+
reviewedRunCount: 0,
|
|
1261
|
+
decisionCounts: {
|
|
1262
|
+
release: 0,
|
|
1263
|
+
revise: 0,
|
|
1264
|
+
abstain: 0,
|
|
1265
|
+
other: 0,
|
|
1266
|
+
},
|
|
1267
|
+
revisedRunCount: 0,
|
|
1268
|
+
runsWithFailedGates: 0,
|
|
1269
|
+
runsWithLeakedInternalFragments: 0,
|
|
1270
|
+
latestReviewedAt: '',
|
|
1271
|
+
earliestReviewedAt: '',
|
|
1272
|
+
},
|
|
1273
|
+
},
|
|
1274
|
+
failedGateAging: [],
|
|
1275
|
+
comparison: {
|
|
1276
|
+
metricShifts: [
|
|
1277
|
+
{
|
|
1278
|
+
metricId: 'reviewed_runs',
|
|
1279
|
+
recentValue: 0,
|
|
1280
|
+
priorValue: 0,
|
|
1281
|
+
delta: 0,
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
metricId: 'release_decisions',
|
|
1285
|
+
recentValue: 0,
|
|
1286
|
+
priorValue: 0,
|
|
1287
|
+
delta: 0,
|
|
1288
|
+
},
|
|
1289
|
+
{
|
|
1290
|
+
metricId: 'revise_decisions',
|
|
1291
|
+
recentValue: 0,
|
|
1292
|
+
priorValue: 0,
|
|
1293
|
+
delta: 0,
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
metricId: 'abstain_decisions',
|
|
1297
|
+
recentValue: 0,
|
|
1298
|
+
priorValue: 0,
|
|
1299
|
+
delta: 0,
|
|
1300
|
+
},
|
|
1301
|
+
{
|
|
1302
|
+
metricId: 'other_decisions',
|
|
1303
|
+
recentValue: 0,
|
|
1304
|
+
priorValue: 0,
|
|
1305
|
+
delta: 0,
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
metricId: 'revised_runs',
|
|
1309
|
+
recentValue: 0,
|
|
1310
|
+
priorValue: 0,
|
|
1311
|
+
delta: 0,
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
metricId: 'failed_gate_runs',
|
|
1315
|
+
recentValue: 0,
|
|
1316
|
+
priorValue: 0,
|
|
1317
|
+
delta: 0,
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
metricId: 'leaked_runs',
|
|
1321
|
+
recentValue: 0,
|
|
1322
|
+
priorValue: 0,
|
|
1323
|
+
delta: 0,
|
|
1324
|
+
},
|
|
1325
|
+
],
|
|
1326
|
+
gateShifts: [],
|
|
1327
|
+
latestPair: null,
|
|
1328
|
+
},
|
|
1329
|
+
});
|
|
1330
|
+
});
|
|
1331
|
+
test('derives graph-focus reports from session-state panel diagnostics', () => {
|
|
1332
|
+
const bundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
|
|
1333
|
+
request: {
|
|
1334
|
+
workspaceId: 'optics',
|
|
1335
|
+
exportProfileId: 'mobile-slim',
|
|
1336
|
+
},
|
|
1337
|
+
workspace: {
|
|
1338
|
+
workspaceId: 'optics',
|
|
1339
|
+
corpusId: 'optics',
|
|
1340
|
+
name: 'optics',
|
|
1341
|
+
sourcePathPrefix: 'knowledge_base/optics',
|
|
1342
|
+
languages: ['zh', 'en'],
|
|
1343
|
+
exportProfileId: 'mobile-slim',
|
|
1344
|
+
status: 'active',
|
|
1345
|
+
createdAt: '2026-05-28T00:00:00.000Z',
|
|
1346
|
+
updatedAt: '2026-05-28T00:00:00.000Z',
|
|
1347
|
+
},
|
|
1348
|
+
bindings: [],
|
|
1349
|
+
resources: [],
|
|
1350
|
+
projections: [],
|
|
1351
|
+
indexSummary: {
|
|
1352
|
+
totalUnits: 0,
|
|
1353
|
+
totalSegments: 0,
|
|
1354
|
+
states: {
|
|
1355
|
+
pending: 0,
|
|
1356
|
+
indexing: 0,
|
|
1357
|
+
indexed: 0,
|
|
1358
|
+
failed: 0,
|
|
1359
|
+
disabled: 0,
|
|
1360
|
+
},
|
|
1361
|
+
activeDocuments: 0,
|
|
1362
|
+
activeAtomUnits: 0,
|
|
1363
|
+
},
|
|
1364
|
+
units: [],
|
|
1365
|
+
segments: [],
|
|
1366
|
+
atoms: [],
|
|
1367
|
+
evidenceSpans: [],
|
|
1368
|
+
relationEdges: [],
|
|
1369
|
+
temporalEdges: [],
|
|
1370
|
+
sessionStates: [
|
|
1371
|
+
{
|
|
1372
|
+
sessionStateId: 'session_state_1',
|
|
1373
|
+
sessionId: 'session_optics_1',
|
|
1374
|
+
userId: 'user_optics',
|
|
1375
|
+
workspaceId: 'optics',
|
|
1376
|
+
corpusId: 'optics',
|
|
1377
|
+
mode: 'grounded_conversation',
|
|
1378
|
+
activeResourceIds: [],
|
|
1379
|
+
activeProjectionIds: [],
|
|
1380
|
+
retrievalSettings: {
|
|
1381
|
+
topK: 6,
|
|
1382
|
+
queryBackend: 'local_hybrid',
|
|
1383
|
+
persistMemory: true,
|
|
1384
|
+
},
|
|
1385
|
+
memorySettings: {
|
|
1386
|
+
namespace: 'conversation',
|
|
1387
|
+
enabled: true,
|
|
1388
|
+
},
|
|
1389
|
+
exportProfileId: 'mobile-slim',
|
|
1390
|
+
panelState: {
|
|
1391
|
+
graphFocusReports: [
|
|
1392
|
+
{
|
|
1393
|
+
recordedAt: '2026-05-28T00:00:00.000Z',
|
|
1394
|
+
title: 'Blocks Citation',
|
|
1395
|
+
requestedSourcePath: 'Knowledge_Base/optics/old.md',
|
|
1396
|
+
resolvedSourcePath: 'Knowledge_Base/optics/blocks.md',
|
|
1397
|
+
candidateSourcePaths: [
|
|
1398
|
+
'Knowledge_Base/optics/old.md',
|
|
1399
|
+
'Knowledge_Base/optics/blocks.md',
|
|
1400
|
+
],
|
|
1401
|
+
attemptedSourcePaths: [
|
|
1402
|
+
'Knowledge_Base/optics/old.md',
|
|
1403
|
+
'Knowledge_Base/optics/blocks.md',
|
|
1404
|
+
],
|
|
1405
|
+
fallbackSourcePathUsed: true,
|
|
1406
|
+
matchedSpanCount: 1,
|
|
1407
|
+
highlightTermCount: 1,
|
|
1408
|
+
highlightedNodeCount: 1,
|
|
1409
|
+
markdownRuntimeAvailable: true,
|
|
1410
|
+
storageProviderAvailable: true,
|
|
1411
|
+
readSucceeded: true,
|
|
1412
|
+
renderSucceeded: true,
|
|
1413
|
+
usedFallback: false,
|
|
1414
|
+
failureReason: '',
|
|
1415
|
+
},
|
|
1416
|
+
{
|
|
1417
|
+
recordedAt: '2026-05-28T00:05:00.000Z',
|
|
1418
|
+
title: 'Missing Runtime',
|
|
1419
|
+
requestedSourcePath: 'Knowledge_Base/optics/missing.md',
|
|
1420
|
+
resolvedSourcePath: '',
|
|
1421
|
+
candidateSourcePaths: ['Knowledge_Base/optics/missing.md'],
|
|
1422
|
+
attemptedSourcePaths: [],
|
|
1423
|
+
fallbackSourcePathUsed: false,
|
|
1424
|
+
matchedSpanCount: 1,
|
|
1425
|
+
highlightTermCount: 1,
|
|
1426
|
+
highlightedNodeCount: 0,
|
|
1427
|
+
markdownRuntimeAvailable: false,
|
|
1428
|
+
storageProviderAvailable: false,
|
|
1429
|
+
readSucceeded: false,
|
|
1430
|
+
renderSucceeded: false,
|
|
1431
|
+
usedFallback: true,
|
|
1432
|
+
failureReason: 'missing_markdown_runtime',
|
|
1433
|
+
},
|
|
1434
|
+
],
|
|
1435
|
+
},
|
|
1436
|
+
createdAt: '2026-05-28T00:00:00.000Z',
|
|
1437
|
+
updatedAt: '2026-05-28T00:05:00.000Z',
|
|
1438
|
+
},
|
|
1439
|
+
],
|
|
1440
|
+
conversationSessions: [],
|
|
1441
|
+
conversationTurns: [],
|
|
1442
|
+
conversationInvocations: [],
|
|
1443
|
+
workflowArtifacts: [],
|
|
1444
|
+
memoryEntries: [],
|
|
1445
|
+
memoryAuditRecords: [],
|
|
1446
|
+
generatedAt: '2026-05-28T00:05:00.000Z',
|
|
1447
|
+
});
|
|
1448
|
+
expect(bundle.runtime.graphFocusReports).toEqual([
|
|
1449
|
+
expect.objectContaining({
|
|
1450
|
+
sessionStateId: 'session_state_1',
|
|
1451
|
+
sessionId: 'session_optics_1',
|
|
1452
|
+
title: 'Blocks Citation',
|
|
1453
|
+
requestedSourcePath: 'Knowledge_Base/optics/old.md',
|
|
1454
|
+
resolvedSourcePath: 'Knowledge_Base/optics/blocks.md',
|
|
1455
|
+
signal: expect.objectContaining({
|
|
1456
|
+
usedFallback: false,
|
|
1457
|
+
fallbackSourcePathUsed: true,
|
|
1458
|
+
candidateSourcePathCount: 2,
|
|
1459
|
+
attemptedSourcePathCount: 2,
|
|
1460
|
+
renderSucceeded: true,
|
|
1461
|
+
}),
|
|
1462
|
+
}),
|
|
1463
|
+
expect.objectContaining({
|
|
1464
|
+
sessionStateId: 'session_state_1',
|
|
1465
|
+
sessionId: 'session_optics_1',
|
|
1466
|
+
title: 'Missing Runtime',
|
|
1467
|
+
requestedSourcePath: 'Knowledge_Base/optics/missing.md',
|
|
1468
|
+
resolvedSourcePath: '',
|
|
1469
|
+
signal: expect.objectContaining({
|
|
1470
|
+
usedFallback: true,
|
|
1471
|
+
fallbackSourcePathUsed: false,
|
|
1472
|
+
candidateSourcePathCount: 1,
|
|
1473
|
+
attemptedSourcePathCount: 0,
|
|
1474
|
+
renderSucceeded: false,
|
|
1475
|
+
failureReason: 'missing_markdown_runtime',
|
|
1476
|
+
}),
|
|
1477
|
+
}),
|
|
1478
|
+
]);
|
|
1479
|
+
});
|
|
1480
|
+
});
|