noteconnection 1.7.0 → 1.9.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.
Files changed (328) hide show
  1. package/LICENSE +674 -21
  2. package/README.md +260 -1626
  3. package/dist/src/agent_workspace.contract.parity.test.js +159 -0
  4. package/dist/src/agent_workspace.frontend.test.js +10388 -0
  5. package/dist/src/agent_workspace.locale.contract.test.js +95 -0
  6. package/dist/src/agent_workspace.runtime.behavior.test.js +5072 -0
  7. package/dist/src/android.knowledgebase.picker.contract.test.js +102 -0
  8. package/dist/src/appimage.patchelf.test.js +113 -0
  9. package/dist/src/appimage.portability.test.js +156 -0
  10. package/dist/src/backend/FileLoader.js +18 -4
  11. package/dist/src/backend/FileLoader.test.js +125 -0
  12. package/dist/src/backend/GraphBuilder.identity.test.js +86 -0
  13. package/dist/src/backend/GraphBuilder.js +66 -18
  14. package/dist/src/backend/GraphBuilder.matching.test.js +127 -0
  15. package/dist/src/backend/GraphMetrics.js +0 -3
  16. package/dist/src/backend/ResourceIdentity.js +155 -0
  17. package/dist/src/backend/ResourceIdentity.test.js +113 -0
  18. package/dist/src/backend/algorithms/CycleDetection.js +0 -1
  19. package/dist/src/backend/algorithms/HybridEngine.js +0 -3
  20. package/dist/src/backend/algorithms/LayoutEngine.js +0 -1
  21. package/dist/src/backend/algorithms/StatisticalAnalyzer.js +0 -4
  22. package/dist/src/backend/algorithms/TopologicalSort.js +0 -2
  23. package/dist/src/backend/build_dag.js +0 -1
  24. package/dist/src/capacitor.bridge.serialization.contract.test.js +3 -0
  25. package/dist/src/capacitor.runtime.contract.test.js +11 -2
  26. package/dist/src/copy.assets.contract.test.js +130 -0
  27. package/dist/src/core/Graph.js +138 -42
  28. package/dist/src/core/Graph.test.js +74 -0
  29. package/dist/src/core/NoteConnection.js +2 -2
  30. package/dist/src/core/PathBridge.js +293 -5
  31. package/dist/src/core/ResourceReference.js +17 -0
  32. package/dist/src/desktop.godot.pack.test.js +142 -0
  33. package/dist/src/desktop.runtime.graph.test.js +66 -0
  34. package/dist/src/export/WorkspaceExportBundle.js +1174 -0
  35. package/dist/src/export/WorkspaceExportBundle.test.js +1541 -0
  36. package/dist/src/export/index.js +18 -0
  37. package/dist/src/export/types.js +2 -0
  38. package/dist/src/fixrisk.issue.verifier.contract.test.js +3 -1
  39. package/dist/src/foundation.ann.runtime.contract.test.js +81 -0
  40. package/dist/src/foundation.release.evidence.contract.test.js +524 -0
  41. package/dist/src/foundation.sqlite.runtime.contract.test.js +88 -0
  42. package/dist/src/frontend/README.md +260 -1626
  43. package/dist/src/frontend/agent_workspace.js +6011 -0
  44. package/dist/src/frontend/agent_workspace_runtime.js +4434 -0
  45. package/dist/src/frontend/analysis.js +31 -4
  46. package/dist/src/frontend/app.js +2178 -62
  47. package/dist/src/frontend/focus_mode_interactions.js +33 -0
  48. package/dist/src/frontend/godot_future_path_renderer.js +540 -0
  49. package/dist/src/frontend/godot_tree_interactions.js +178 -0
  50. package/dist/src/frontend/graph_state.mjs +105 -0
  51. package/dist/src/frontend/hosted_future_path_runtime.js +157 -0
  52. package/dist/src/frontend/i18n.mjs +186 -0
  53. package/dist/src/frontend/index.html +672 -268
  54. package/dist/src/frontend/knowledge_projection_contract.js +230 -0
  55. package/dist/src/frontend/knowledge_projection_store.js +214 -0
  56. package/dist/src/frontend/layout_gpu.js +12 -4
  57. package/dist/src/frontend/libs/path_core.js +158 -42
  58. package/dist/src/frontend/locales/en.json +753 -5
  59. package/dist/src/frontend/locales/zh.json +753 -5
  60. package/dist/src/frontend/main.mjs +60 -0
  61. package/dist/src/frontend/markdown_runtime.js +827 -0
  62. package/dist/src/frontend/mobile_budget_runtime.js +33 -0
  63. package/dist/src/frontend/mobile_exact_analyzer.js +393 -0
  64. package/dist/src/frontend/mobile_identity_contract.js +221 -0
  65. package/dist/src/frontend/mobile_semantic_comparator.js +264 -0
  66. package/dist/src/frontend/notemd.css +49 -0
  67. package/dist/src/frontend/notemd.html +7 -1
  68. package/dist/src/frontend/notemd.js +64 -0
  69. package/dist/src/frontend/path.html +113 -2
  70. package/dist/src/frontend/path_app.js +2108 -130
  71. package/dist/src/frontend/path_layout.mjs +143 -0
  72. package/dist/src/frontend/path_mermaid_utils.mjs +108 -0
  73. package/dist/src/frontend/path_modules_bridge.js +486 -0
  74. package/dist/src/frontend/path_state.mjs +118 -0
  75. package/dist/src/frontend/path_styles.css +146 -0
  76. package/dist/src/frontend/path_worker_bridge.mjs +85 -0
  77. package/dist/src/frontend/reader.js +393 -33
  78. package/dist/src/frontend/runtime_bridge.js +67 -54
  79. package/dist/src/frontend/runtime_bridge.mjs +279 -0
  80. package/dist/src/frontend/settings.js +130 -12
  81. package/dist/src/frontend/simulationWorker.js +1 -1
  82. package/dist/src/frontend/source_manager.js +297 -22
  83. package/dist/src/frontend/storage_provider.js +661 -71
  84. package/dist/src/frontend/styles.css +2814 -72
  85. package/dist/src/frontend/workbench_state.mjs +101 -0
  86. package/dist/src/frontend/workspace_panes.js +10272 -0
  87. package/dist/src/frontend.locale.contract.test.js +62 -0
  88. package/dist/src/frontend.runtime.assets.contract.test.js +81 -0
  89. package/dist/src/godot.sidecar.bootstrap.contract.test.js +244 -0
  90. package/dist/src/graph.answer.operator.contract.test.js +72 -0
  91. package/dist/src/index.js +6 -2
  92. package/dist/src/index.knowledge-root.test.js +118 -0
  93. package/dist/src/indexing/IndexLifecycle.js +217 -0
  94. package/dist/src/indexing/IndexLifecycle.test.js +73 -0
  95. package/dist/src/indexing/SegmentBuilder.js +64 -0
  96. package/dist/src/indexing/UnitBuilder.js +48 -0
  97. package/dist/src/indexing/types.js +2 -0
  98. package/dist/src/knowledge.api.contract.test.js +172 -0
  99. package/dist/src/knowledge_projection.contract.test.js +134 -0
  100. package/dist/src/knowledge_projection_store.test.js +200 -0
  101. package/dist/src/learning/AnswerQualityEvaluation.js +153 -0
  102. package/dist/src/learning/AnswerQualityEvaluation.test.js +118 -0
  103. package/dist/src/learning/KnowledgeLearningPlatform.js +11181 -0
  104. package/dist/src/learning/KnowledgeLearningPlatform.persistence.test.js +745 -0
  105. package/dist/src/learning/KnowledgeLearningPlatform.program-f.test.js +99 -0
  106. package/dist/src/learning/KnowledgeLearningPlatform.test.js +3208 -0
  107. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.js +2998 -0
  108. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.test.js +3936 -0
  109. package/dist/src/learning/MeasurementEvidenceConflicts.test.js +78 -0
  110. package/dist/src/learning/PublicAnswerContract.test.js +85 -0
  111. package/dist/src/learning/PublicEvidenceSelection.test.js +94 -0
  112. package/dist/src/learning/PublicMeasurementDisclosure.test.js +54 -0
  113. package/dist/src/learning/agentConversationExecution.js +211 -0
  114. package/dist/src/learning/agentConversationExecution.test.js +209 -0
  115. package/dist/src/learning/agentConversationSerialization.js +266 -0
  116. package/dist/src/learning/agentConversationSerialization.test.js +165 -0
  117. package/dist/src/learning/agentResponseBudget.js +179 -0
  118. package/dist/src/learning/agentResponseBudget.test.js +97 -0
  119. package/dist/src/learning/agentWorkspaceCapabilityContracts.js +65 -0
  120. package/dist/src/learning/answerReleaseReview.js +5260 -0
  121. package/dist/src/learning/answerReleaseReview.test.js +4174 -0
  122. package/dist/src/learning/answerTaskPlan.js +473 -0
  123. package/dist/src/learning/api.js +2 -0
  124. package/dist/src/learning/conversationComposer.js +1721 -0
  125. package/dist/src/learning/conversationComposer.test.js +3220 -0
  126. package/dist/src/learning/domains/ConversationManager.js +53 -0
  127. package/dist/src/learning/domains/KnowledgeIngestor.js +238 -0
  128. package/dist/src/learning/domains/KnowledgeQuerier.js +187 -0
  129. package/dist/src/learning/domains/MasteryEngine.js +387 -0
  130. package/dist/src/learning/domains/MemoryPolicyManager.js +408 -0
  131. package/dist/src/learning/domains/QualityEvaluator.js +307 -0
  132. package/dist/src/learning/domains/TutorRouter.js +313 -0
  133. package/dist/src/learning/domains/index.js +33 -0
  134. package/dist/src/learning/domains/types.js +7 -0
  135. package/dist/src/learning/errors.js +29 -0
  136. package/dist/src/learning/evidenceContextAssembler.js +1368 -0
  137. package/dist/src/learning/evidenceContextAssembler.test.js +6332 -0
  138. package/dist/src/learning/graphAnswerCoverage.js +37 -0
  139. package/dist/src/learning/graphAnswerCoverage.test.js +93 -0
  140. package/dist/src/learning/graphAnswerCoverageCalibration.js +59 -0
  141. package/dist/src/learning/graphAnswerCoverageCalibration.test.js +46 -0
  142. package/dist/src/learning/graphAnswerFacts.js +94 -0
  143. package/dist/src/learning/graphAnswerFacts.test.js +39 -0
  144. package/dist/src/learning/graphAnswerPlan.js +908 -0
  145. package/dist/src/learning/graphAnswerPlan.test.js +907 -0
  146. package/dist/src/learning/graphAnswerQualityCalibration.js +255 -0
  147. package/dist/src/learning/graphAnswerQualityCalibration.test.js +72 -0
  148. package/dist/src/learning/graphAnswerQualityPolicy.js +30 -0
  149. package/dist/src/learning/graphClaimMatcher.js +104 -0
  150. package/dist/src/learning/graphConditionedContext.js +109 -0
  151. package/dist/src/learning/graphConditionedContext.test.js +99 -0
  152. package/dist/src/learning/graphContextAssembler.js +860 -0
  153. package/dist/src/learning/graphContextAssembler.test.js +1033 -0
  154. package/dist/src/learning/graphExpansionPolicy.js +22 -0
  155. package/dist/src/learning/graphExpansionPolicy.test.js +33 -0
  156. package/dist/src/learning/identityMetadata.test.js +26 -0
  157. package/dist/src/learning/index.js +29 -0
  158. package/dist/src/learning/mobileAnswerProjection.js +104 -0
  159. package/dist/src/learning/mobileAnswerProjection.test.js +102 -0
  160. package/dist/src/learning/queryBackend.js +1922 -0
  161. package/dist/src/learning/queryBackend.test.js +976 -0
  162. package/dist/src/learning/ragContextPack.js +356 -0
  163. package/dist/src/learning/ragContextPack.test.js +311 -0
  164. package/dist/src/learning/ragEvidenceQuality.js +96 -0
  165. package/dist/src/learning/ragEvidenceQuality.test.js +29 -0
  166. package/dist/src/learning/ragPublicText.js +101 -0
  167. package/dist/src/learning/ragPublicText.test.js +57 -0
  168. package/dist/src/learning/ragSufficiencyJudge.js +171 -0
  169. package/dist/src/learning/ragSufficiencyJudge.test.js +177 -0
  170. package/dist/src/learning/ragSufficiencyProviderJudge.js +217 -0
  171. package/dist/src/learning/ragSufficiencyProviderJudge.test.js +207 -0
  172. package/dist/src/learning/requestNormalization.js +304 -0
  173. package/dist/src/learning/requestNormalization.test.js +101 -0
  174. package/dist/src/learning/runtimeCapability.js +4677 -0
  175. package/dist/src/learning/runtimeCapability.test.js +3635 -0
  176. package/dist/src/learning/store.js +1344 -0
  177. package/dist/src/learning/store.test.js +1425 -0
  178. package/dist/src/learning/tutorAdapter.js +2 -0
  179. package/dist/src/learning/types.js +2 -0
  180. package/dist/src/learning/vectorAccelerationAdapter.js +958 -0
  181. package/dist/src/learning/vectorAccelerationAdapter.test.js +412 -0
  182. package/dist/src/learning/workspaceHydration.js +168 -0
  183. package/dist/src/learning/workspaceHydration.test.js +30 -0
  184. package/dist/src/lfs.asset.policy.contract.test.js +153 -0
  185. package/dist/src/license.policy.contract.test.js +71 -0
  186. package/dist/src/markdown/MarkdownGateway.js +4 -0
  187. package/dist/src/markdown/MarkdownGateway.test.js +59 -0
  188. package/dist/src/memory/MemoryGovernance.js +74 -0
  189. package/dist/src/memory/MemoryGovernance.test.js +46 -0
  190. package/dist/src/memory/types.js +2 -0
  191. package/dist/src/mermaid.frontend.guard.contract.test.js +77 -0
  192. package/dist/src/middleware/SseResponseWriter.js +122 -0
  193. package/dist/src/middleware/SseResponseWriter.test.js +54 -0
  194. package/dist/src/middleware/auth.js +38 -0
  195. package/dist/src/middleware/auth.test.js +33 -0
  196. package/dist/src/middleware/body-parser.js +45 -0
  197. package/dist/src/middleware/cors.js +44 -0
  198. package/dist/src/middleware/index.js +22 -0
  199. package/dist/src/middleware/request-trace.js +96 -0
  200. package/dist/src/mobile.android.evidence.contract.test.js +146 -0
  201. package/dist/src/mobile.android.signing.contract.test.js +66 -0
  202. package/dist/src/mobile.artifact.contract.test.js +144 -0
  203. package/dist/src/mobile.budget.contract.test.js +90 -0
  204. package/dist/src/mobile.canonical-id.readiness.test.js +54 -0
  205. package/dist/src/mobile.graph.parity.contract.test.js +207 -0
  206. package/dist/src/mobile.identity.contract.test.js +66 -0
  207. package/dist/src/mobile.identity.corpus.manifest.test.js +72 -0
  208. package/dist/src/mobile.identity.corpus.test.js +40 -0
  209. package/dist/src/mobile.native.recovery.contract.test.js +64 -0
  210. package/dist/src/mobile.pipeline.test.js +11 -1
  211. package/dist/src/mobile.profile.contract.test.js +225 -0
  212. package/dist/src/mobile.semantic.parity.test.js +92 -0
  213. package/dist/src/mobile_exact_analyzer.test.js +113 -0
  214. package/dist/src/notemd/AppConfigToml.js +6 -4
  215. package/dist/src/notemd/ContentGenerator.js +4 -9
  216. package/dist/src/notemd/FileProcessor.js +4 -9
  217. package/dist/src/notemd/MermaidProcessor.js +400 -50
  218. package/dist/src/notemd/NotemdService.js +506 -26
  219. package/dist/src/notemd/PromptManager.js +15 -0
  220. package/dist/src/notemd/Translator.js +4 -9
  221. package/dist/src/notemd/cli/commands.js +357 -0
  222. package/dist/src/notemd/cli/dispatcher.js +225 -0
  223. package/dist/src/notemd/cli/index.js +169 -0
  224. package/dist/src/notemd/cli/parser.js +68 -0
  225. package/dist/src/notemd/cli/types.js +2 -0
  226. package/dist/src/notemd/constants.js +43 -0
  227. package/dist/src/notemd/diagram/diagramGenerationService.js +78 -0
  228. package/dist/src/notemd/diagram/diagramSpec.js +79 -0
  229. package/dist/src/notemd/diagram/diagramSpecResponseParser.js +131 -0
  230. package/dist/src/notemd/diagram/intent.js +95 -0
  231. package/dist/src/notemd/diagram/planner.js +71 -0
  232. package/dist/src/notemd/diagram/prompts/diagramSpecPrompt.js +42 -0
  233. package/dist/src/notemd/diagram/types.js +18 -0
  234. package/dist/src/notemd/index.js +26 -0
  235. package/dist/src/notemd/operations/capabilityManifest.js +23 -0
  236. package/dist/src/notemd/operations/cliContracts.js +17 -0
  237. package/dist/src/notemd/operations/configProfileCommands.js +85 -0
  238. package/dist/src/notemd/operations/registry.contract.test.js +95 -0
  239. package/dist/src/notemd/operations/registry.js +991 -0
  240. package/dist/src/notemd/operations/types.js +2 -0
  241. package/dist/src/notemd/progressReporter.js +9 -0
  242. package/dist/src/notemd/providerDiagnostics.js +220 -0
  243. package/dist/src/notemd/providerProfiles.js +42 -0
  244. package/dist/src/notemd/providerTemplates.js +231 -0
  245. package/dist/src/notemd/search/DuckDuckGoProvider.js +39 -0
  246. package/dist/src/notemd/search/SearchManager.js +13 -0
  247. package/dist/src/notemd/search/SearchProvider.js +2 -0
  248. package/dist/src/notemd/search/TavilyProvider.js +44 -0
  249. package/dist/src/notemd.agent.manifest.test.js +85 -0
  250. package/dist/src/notemd.api.contract.test.js +14 -1
  251. package/dist/src/notemd.app_config_toml.test.js +2 -1
  252. package/dist/src/notemd.batch.workflow.test.js +117 -0
  253. package/dist/src/notemd.cli.e2e.test.js +136 -0
  254. package/dist/src/notemd.core.test.js +51 -0
  255. package/dist/src/notemd.diagram.pipeline.test.js +233 -0
  256. package/dist/src/notemd.providerTemplates.test.js +34 -0
  257. package/dist/src/notemd.server.integration.test.js +262 -39
  258. package/dist/src/notemd.workflow.pipeline.test.js +162 -0
  259. package/dist/src/pathbridge.handshake.contract.test.js +45 -2
  260. package/dist/src/pathbridge.host-adapter.contract.test.js +133 -0
  261. package/dist/src/pathcore.bundle.contract.test.js +8 -0
  262. package/dist/src/pathmode.background.contract.test.js +69 -0
  263. package/dist/src/pathmode.settings.api.contract.test.js +9 -0
  264. package/dist/src/pkg.sidecar.contract.test.js +9 -3
  265. package/dist/src/platform/ExportProfile.js +86 -0
  266. package/dist/src/platform/MobileBudget.js +11 -0
  267. package/dist/src/platform/PlatformCapabilities.js +59 -0
  268. package/dist/src/platform/PlatformCapabilities.test.js +36 -0
  269. package/dist/src/platform/RenderMaterializer.js +33 -0
  270. package/dist/src/platform/RenderMaterializer.test.js +32 -0
  271. package/dist/src/query_backend.external_http.integration.test.js +410 -0
  272. package/dist/src/reader_renderer.js +404 -3
  273. package/dist/src/reader_renderer.test.js +87 -0
  274. package/dist/src/release.godot.mirror.contract.test.js +97 -0
  275. package/dist/src/resources/ResourceRegistry.js +263 -0
  276. package/dist/src/resources/ResourceRegistry.test.js +97 -0
  277. package/dist/src/resources/types.js +2 -0
  278. package/dist/src/routes/agentWorkspaceDiagnostics.js +173 -0
  279. package/dist/src/routes/index.js +19 -0
  280. package/dist/src/routes/knowledge.js +981 -0
  281. package/dist/src/routes/knowledgePayload.js +185 -0
  282. package/dist/src/routes/knowledgePayload.test.js +53 -0
  283. package/dist/src/routes/markdown.js +295 -0
  284. package/dist/src/routes/notemd.js +1321 -0
  285. package/dist/src/routes/registry.contract.test.js +133 -0
  286. package/dist/src/routes/registry.shadow.contract.test.js +22 -0
  287. package/dist/src/routes/render.js +248 -0
  288. package/dist/src/routes/runtimeRunbookRouteOps.js +149 -0
  289. package/dist/src/routes/runtimeRunbookRouteOps.test.js +194 -0
  290. package/dist/src/routes/settings.js +6 -0
  291. package/dist/src/routes/staticFiles.js +94 -0
  292. package/dist/src/routes/types.js +2 -0
  293. package/dist/src/runtime.capabilities.test.js +18 -2
  294. package/dist/src/runtime.transport.adapter.contract.test.js +81 -0
  295. package/dist/src/server.js +10342 -1325
  296. package/dist/src/server.migration.test.js +584 -10
  297. package/dist/src/server.port.fallback.contract.test.js +63 -0
  298. package/dist/src/session/SessionStateStore.js +81 -0
  299. package/dist/src/session/SessionStateStore.test.js +58 -0
  300. package/dist/src/session/types.js +2 -0
  301. package/dist/src/settings.runtime.contract.test.js +50 -0
  302. package/dist/src/shared/types.contract.test.js +107 -0
  303. package/dist/src/shared/types.js +22 -0
  304. package/dist/src/sidecar.build.lock.contract.test.js +201 -0
  305. package/dist/src/sidecar.freshness.contract.test.js +184 -0
  306. package/dist/src/sidecar.replacement.boundary.contract.test.js +131 -0
  307. package/dist/src/sidecar.supply.readiness.contract.test.js +155 -0
  308. package/dist/src/simulation.worker.offline.test.js +104 -0
  309. package/dist/src/source_manager.loadflow.test.js +46 -0
  310. package/dist/src/startup.layout.snapshot.contract.test.js +57 -0
  311. package/dist/src/storage.provider.capacitor.content.contract.test.js +4 -1
  312. package/dist/src/storage.provider.contract.test.js +152 -1
  313. package/dist/src/tauri.frontend.build.contract.test.js +68 -0
  314. package/dist/src/tauri.sidecar.cleanup.contract.test.js +21 -0
  315. package/dist/src/tauri.window.evidence.execution.test.js +68 -0
  316. package/dist/src/utils/RuntimePaths.js +10 -13
  317. package/dist/src/utils/RuntimePaths.test.js +27 -0
  318. package/dist/src/utils/platform.js +153 -0
  319. package/dist/src/windows.installer.build.test.js +109 -0
  320. package/dist/src/windows.installer.payload.test.js +76 -0
  321. package/dist/src/windows.installer.runtime.test.js +69 -0
  322. package/dist/src/workflows/WorkflowArtifactStore.js +96 -0
  323. package/dist/src/workflows/WorkflowArtifactStore.test.js +80 -0
  324. package/dist/src/workflows/types.js +2 -0
  325. package/dist/src/workspace/WorkspaceRegistry.js +135 -0
  326. package/dist/src/workspace/WorkspaceRegistry.test.js +29 -0
  327. package/dist/src/workspace/types.js +2 -0
  328. package/package.json +80 -15
@@ -0,0 +1,1541 @@
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
+ graphAnswerPlan: {
838
+ intent: 'definition',
839
+ depth: 'standard',
840
+ anchorAtomId: 'atom_reflection',
841
+ leadClaimId: 'claim_reflection',
842
+ requiredRoles: ['definition', 'mechanism'],
843
+ omittedCandidates: [],
844
+ answerTaskPlan: {
845
+ schemaVersion: '1',
846
+ primarySubject: 'Reflection',
847
+ requestedDepth: 'standard',
848
+ subtasks: [
849
+ { subtaskId: 'definition', kind: 'definition', subject: 'Reflection', required: true, expectedOutput: 'direct_answer' },
850
+ { subtaskId: 'learning_route', kind: 'learning_route', subject: 'Reflection', required: true, expectedOutput: 'ordered_nodes' },
851
+ ],
852
+ learningRoute: [
853
+ { nodeId: 'atom_foundation', title: 'Foundation', role: 'prerequisite', order: 1, orderingBasis: 'explicit_prerequisite', evidenceRefs: ['edge_1'], reason: 'foundation' },
854
+ { nodeId: 'atom_reflection', title: 'Reflection', role: 'core', order: 2, orderingBasis: 'explicit_prerequisite', evidenceRefs: ['claim_reflection'], reason: 'core' },
855
+ { nodeId: 'atom_measurement', title: 'Measurement', role: 'application', order: 3, orderingBasis: 'source_order', evidenceRefs: ['claim_measurement'], reason: 'application' },
856
+ ],
857
+ },
858
+ claims: [
859
+ { claimId: 'claim_reflection', required: true },
860
+ { claimId: 'claim_mechanism', required: true },
861
+ ],
862
+ },
863
+ graphAnswerCoverage: {
864
+ passed: true,
865
+ applicable: true,
866
+ requiredClaimIds: ['claim_reflection', 'claim_mechanism'],
867
+ coveredClaimIds: ['claim_reflection', 'claim_mechanism'],
868
+ missingRequiredClaimIds: [],
869
+ coverageScore: 1,
870
+ },
871
+ answerTaskCoverage: {
872
+ passed: true,
873
+ applicable: true,
874
+ coveredSubtaskIds: ['definition', 'learning_route'],
875
+ missingRequiredSubtaskIds: [],
876
+ subtaskCoverage: [],
877
+ learningRouteNodeCount: 3,
878
+ coverageScore: 1,
879
+ },
880
+ },
881
+ graphContext: {
882
+ anchorAtomId: 'atom_reflection',
883
+ anchorTitle: 'Reflection',
884
+ supportingAtomIds: ['atom_foundation'],
885
+ supportingTitles: ['Foundation Note'],
886
+ relationKinds: ['prerequisite'],
887
+ relationSummaries: [],
888
+ connectionPaths: [
889
+ {
890
+ sourceAtomId: 'atom_foundation',
891
+ sourceTitle: 'Foundation Note',
892
+ targetAtomId: 'atom_reflection',
893
+ targetTitle: 'Reflection',
894
+ pathAtomIds: ['atom_foundation', 'atom_reflection'],
895
+ pathTitles: ['Foundation Note', 'Reflection'],
896
+ pathEdges: [],
897
+ length: 1,
898
+ },
899
+ ],
900
+ predecessorWindow: [
901
+ {
902
+ atomId: 'atom_foundation',
903
+ title: 'Foundation Note',
904
+ relationKind: 'prerequisite',
905
+ confidence: 0.91,
906
+ },
907
+ ],
908
+ successorWindow: [],
909
+ evidenceSourceRefs: ['Knowledge_Base/optics/reflection.md:12'],
910
+ diagnostics: {
911
+ graphOpsAvailable: true,
912
+ usedFallback: false,
913
+ selectedAnchorReason: 'title_mention',
914
+ candidateCount: 1,
915
+ supportNodeCount: 1,
916
+ supportNodeLimit: 2,
917
+ pathDepthLimit: 6,
918
+ missingConnectionPathSourceAtomIds: [],
919
+ missingPredecessorAtomIds: [],
920
+ missingSuccessorAtomIds: [],
921
+ },
922
+ temporalValidity: {
923
+ checkedAt: '2026-05-28T00:00:00.000Z',
924
+ allPointsValid: true,
925
+ warningReasons: [],
926
+ invalidKnowledgePointTitles: [],
927
+ },
928
+ },
929
+ },
930
+ status: 'active',
931
+ createdAt: '2026-05-28T00:00:00.000Z',
932
+ updatedAt: '2026-05-28T00:00:00.000Z',
933
+ },
934
+ ],
935
+ memoryEntries: [],
936
+ memoryAuditRecords: [],
937
+ generatedAt: '2026-05-28T00:00:00.000Z',
938
+ });
939
+ expect(bundle.runtime.knowledgeRunReports).toEqual([
940
+ expect.objectContaining({
941
+ artifactId: 'workflow_artifact_knowledge_run_1',
942
+ runId: 'knowledge_run_1',
943
+ qualityStatus: 'pass',
944
+ qualityScore: 100,
945
+ answerReleaseReview: expect.objectContaining({
946
+ reviewedAt: '2026-05-28T00:00:00.000Z',
947
+ decision: 'release',
948
+ revised: false,
949
+ failedGateIds: [],
950
+ leakedInternalFragmentCount: 0,
951
+ reason: 'Draft answer satisfied the public-release gates.',
952
+ }),
953
+ graphSignal: expect.objectContaining({
954
+ graphOpsAvailable: true,
955
+ usedFallback: false,
956
+ connectionPathCount: 1,
957
+ temporalWarningCount: 0,
958
+ missingLookupCount: 0,
959
+ }),
960
+ graphAnswerPlan: {
961
+ intent: 'definition',
962
+ depth: 'standard',
963
+ anchorAtomId: 'atom_reflection',
964
+ claimCount: 2,
965
+ requiredClaimCount: 2,
966
+ requiredRoles: ['definition', 'mechanism'],
967
+ coverageScore: 1,
968
+ missingRequiredClaimIds: [],
969
+ },
970
+ answerTask: {
971
+ primarySubject: 'Reflection',
972
+ subtaskCount: 2,
973
+ requiredSubtaskCount: 2,
974
+ missingRequiredSubtaskIds: [],
975
+ learningRouteNodeCount: 3,
976
+ coverageScore: 1,
977
+ },
978
+ }),
979
+ expect.objectContaining({
980
+ artifactId: 'workflow_artifact_knowledge_run_2',
981
+ runId: 'knowledge_run_2',
982
+ qualityStatus: 'caution',
983
+ qualityScore: 72,
984
+ answerReleaseReview: expect.objectContaining({
985
+ reviewedAt: '2026-05-27T00:00:00.000Z',
986
+ decision: 'revise',
987
+ revised: true,
988
+ failedGateIds: ['claim_grounding_alignment', 'internal_diagnostic_leakage'],
989
+ leakedInternalFragmentCount: 1,
990
+ reason: 'Draft answer had usable evidence but required contraction before public release.',
991
+ }),
992
+ graphSignal: expect.objectContaining({
993
+ graphOpsAvailable: false,
994
+ usedFallback: true,
995
+ connectionPathCount: 0,
996
+ temporalWarningCount: 1,
997
+ missingLookupCount: 2,
998
+ }),
999
+ }),
1000
+ ]);
1001
+ expect(bundle.runtime.knowledgeRunAnswerReleaseAuditSummary).toEqual({
1002
+ totalRuns: 2,
1003
+ reviewedRunCount: 2,
1004
+ unreviewedRunCount: 0,
1005
+ decisionCounts: {
1006
+ release: 1,
1007
+ revise: 1,
1008
+ abstain: 0,
1009
+ other: 0,
1010
+ },
1011
+ revisedRunCount: 1,
1012
+ runsWithFailedGates: 1,
1013
+ runsWithLeakedInternalFragments: 1,
1014
+ leakedInternalFragmentTotalCount: 1,
1015
+ failedGateCounts: [
1016
+ {
1017
+ gateId: 'claim_grounding_alignment',
1018
+ count: 1,
1019
+ },
1020
+ {
1021
+ gateId: 'internal_diagnostic_leakage',
1022
+ count: 1,
1023
+ },
1024
+ ],
1025
+ latestReviewedAt: '2026-05-28T00:00:00.000Z',
1026
+ reviewTrend: {
1027
+ windowSize: 4,
1028
+ recentWindow: {
1029
+ reviewedRunCount: 2,
1030
+ decisionCounts: {
1031
+ release: 1,
1032
+ revise: 1,
1033
+ abstain: 0,
1034
+ other: 0,
1035
+ },
1036
+ revisedRunCount: 1,
1037
+ runsWithFailedGates: 1,
1038
+ runsWithLeakedInternalFragments: 1,
1039
+ latestReviewedAt: '2026-05-28T00:00:00.000Z',
1040
+ earliestReviewedAt: '2026-05-27T00:00:00.000Z',
1041
+ },
1042
+ priorWindow: {
1043
+ reviewedRunCount: 0,
1044
+ decisionCounts: {
1045
+ release: 0,
1046
+ revise: 0,
1047
+ abstain: 0,
1048
+ other: 0,
1049
+ },
1050
+ revisedRunCount: 0,
1051
+ runsWithFailedGates: 0,
1052
+ runsWithLeakedInternalFragments: 0,
1053
+ latestReviewedAt: '',
1054
+ earliestReviewedAt: '',
1055
+ },
1056
+ },
1057
+ failedGateAging: [
1058
+ {
1059
+ gateId: 'claim_grounding_alignment',
1060
+ failureCount: 1,
1061
+ latestReviewedAt: '2026-05-27T00:00:00.000Z',
1062
+ oldestReviewedAt: '2026-05-27T00:00:00.000Z',
1063
+ reviewedRunsSinceLastFailure: 1,
1064
+ occurrencesInRecentWindow: 1,
1065
+ },
1066
+ {
1067
+ gateId: 'internal_diagnostic_leakage',
1068
+ failureCount: 1,
1069
+ latestReviewedAt: '2026-05-27T00:00:00.000Z',
1070
+ oldestReviewedAt: '2026-05-27T00:00:00.000Z',
1071
+ reviewedRunsSinceLastFailure: 1,
1072
+ occurrencesInRecentWindow: 1,
1073
+ },
1074
+ ],
1075
+ comparison: {
1076
+ metricShifts: [
1077
+ {
1078
+ metricId: 'reviewed_runs',
1079
+ recentValue: 2,
1080
+ priorValue: 0,
1081
+ delta: 2,
1082
+ },
1083
+ {
1084
+ metricId: 'release_decisions',
1085
+ recentValue: 1,
1086
+ priorValue: 0,
1087
+ delta: 1,
1088
+ },
1089
+ {
1090
+ metricId: 'revise_decisions',
1091
+ recentValue: 1,
1092
+ priorValue: 0,
1093
+ delta: 1,
1094
+ },
1095
+ {
1096
+ metricId: 'abstain_decisions',
1097
+ recentValue: 0,
1098
+ priorValue: 0,
1099
+ delta: 0,
1100
+ },
1101
+ {
1102
+ metricId: 'other_decisions',
1103
+ recentValue: 0,
1104
+ priorValue: 0,
1105
+ delta: 0,
1106
+ },
1107
+ {
1108
+ metricId: 'revised_runs',
1109
+ recentValue: 1,
1110
+ priorValue: 0,
1111
+ delta: 1,
1112
+ },
1113
+ {
1114
+ metricId: 'failed_gate_runs',
1115
+ recentValue: 1,
1116
+ priorValue: 0,
1117
+ delta: 1,
1118
+ },
1119
+ {
1120
+ metricId: 'leaked_runs',
1121
+ recentValue: 1,
1122
+ priorValue: 0,
1123
+ delta: 1,
1124
+ },
1125
+ ],
1126
+ gateShifts: [
1127
+ {
1128
+ gateId: 'claim_grounding_alignment',
1129
+ recentWindowCount: 1,
1130
+ priorWindowCount: 0,
1131
+ delta: 1,
1132
+ failureCount: 1,
1133
+ latestReviewedAt: '2026-05-27T00:00:00.000Z',
1134
+ reviewedRunsSinceLastFailure: 1,
1135
+ },
1136
+ {
1137
+ gateId: 'internal_diagnostic_leakage',
1138
+ recentWindowCount: 1,
1139
+ priorWindowCount: 0,
1140
+ delta: 1,
1141
+ failureCount: 1,
1142
+ latestReviewedAt: '2026-05-27T00:00:00.000Z',
1143
+ reviewedRunsSinceLastFailure: 1,
1144
+ },
1145
+ ],
1146
+ latestPair: {
1147
+ latestRunId: 'knowledge_run_1',
1148
+ previousRunId: 'knowledge_run_2',
1149
+ latestReviewedAt: '2026-05-28T00:00:00.000Z',
1150
+ previousReviewedAt: '2026-05-27T00:00:00.000Z',
1151
+ latestDecision: 'release',
1152
+ previousDecision: 'revise',
1153
+ decisionChanged: true,
1154
+ latestRevised: false,
1155
+ previousRevised: true,
1156
+ revisedChanged: true,
1157
+ latestLeakedInternalFragmentCount: 0,
1158
+ previousLeakedInternalFragmentCount: 1,
1159
+ leakedInternalFragmentDelta: -1,
1160
+ newlyFailedGateIds: [],
1161
+ resolvedFailedGateIds: ['claim_grounding_alignment', 'internal_diagnostic_leakage'],
1162
+ persistentFailedGateIds: [],
1163
+ },
1164
+ },
1165
+ });
1166
+ });
1167
+ test('keeps knowledge-run export reports backward-compatible when answer release review is absent', () => {
1168
+ const bundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
1169
+ request: {
1170
+ workspaceId: 'optics',
1171
+ exportProfileId: 'mobile-slim',
1172
+ },
1173
+ workspace: {
1174
+ workspaceId: 'optics',
1175
+ corpusId: 'optics',
1176
+ name: 'optics',
1177
+ sourcePathPrefix: 'knowledge_base/optics',
1178
+ languages: ['zh', 'en'],
1179
+ exportProfileId: 'mobile-slim',
1180
+ status: 'active',
1181
+ createdAt: '2026-05-28T00:00:00.000Z',
1182
+ updatedAt: '2026-05-28T00:00:00.000Z',
1183
+ },
1184
+ bindings: [],
1185
+ resources: [],
1186
+ projections: [],
1187
+ indexSummary: {
1188
+ totalUnits: 0,
1189
+ totalSegments: 0,
1190
+ states: {
1191
+ pending: 0,
1192
+ indexing: 0,
1193
+ indexed: 0,
1194
+ failed: 0,
1195
+ disabled: 0,
1196
+ },
1197
+ activeDocuments: 0,
1198
+ activeAtomUnits: 0,
1199
+ },
1200
+ units: [],
1201
+ segments: [],
1202
+ atoms: [],
1203
+ evidenceSpans: [],
1204
+ relationEdges: [],
1205
+ temporalEdges: [],
1206
+ sessionStates: [],
1207
+ conversationSessions: [],
1208
+ conversationTurns: [],
1209
+ conversationInvocations: [],
1210
+ workflowArtifacts: [
1211
+ {
1212
+ artifactId: 'workflow_artifact_knowledge_run_without_review',
1213
+ kind: 'knowledge_run',
1214
+ sessionId: 'session_knowledge_run_without_review',
1215
+ userId: 'user_optics',
1216
+ workspaceId: 'optics',
1217
+ corpusId: 'optics',
1218
+ title: 'Knowledge run: No review',
1219
+ sourceResourceIds: [],
1220
+ sourceProjectionIds: [],
1221
+ summary: 'Generated 1 evidence claim(s) with legacy payload shape.',
1222
+ payload: {
1223
+ knowledgeRun: {
1224
+ runId: 'knowledge_run_without_review',
1225
+ generatedAt: '2026-05-28T00:00:00.000Z',
1226
+ status: 'pass',
1227
+ scope: {
1228
+ source: 'scoped',
1229
+ workspaceId: 'optics',
1230
+ corpusId: 'optics',
1231
+ documentIds: [],
1232
+ atomIds: [],
1233
+ sourcePathPrefixes: ['Knowledge_Base/optics'],
1234
+ languages: ['en'],
1235
+ matchedAtomCount: 1,
1236
+ scopeSource: 'explicit_request',
1237
+ },
1238
+ quality: {
1239
+ score: 90,
1240
+ status: 'pass',
1241
+ gates: [],
1242
+ },
1243
+ summary: {
1244
+ claimCount: 1,
1245
+ weakClaimCount: 0,
1246
+ reviewCardCount: 0,
1247
+ completedReviewCardCount: 0,
1248
+ remainingReviewCardCount: 0,
1249
+ },
1250
+ },
1251
+ graphContext: {
1252
+ diagnostics: {
1253
+ graphOpsAvailable: true,
1254
+ usedFallback: false,
1255
+ selectedAnchorReason: 'title_mention',
1256
+ supportNodeCount: 0,
1257
+ supportNodeLimit: 0,
1258
+ pathDepthLimit: 0,
1259
+ missingConnectionPathSourceAtomIds: [],
1260
+ missingPredecessorAtomIds: [],
1261
+ missingSuccessorAtomIds: [],
1262
+ },
1263
+ temporalValidity: {
1264
+ checkedAt: '2026-05-28T00:00:00.000Z',
1265
+ allPointsValid: true,
1266
+ warningReasons: [],
1267
+ invalidKnowledgePointTitles: [],
1268
+ },
1269
+ },
1270
+ },
1271
+ status: 'active',
1272
+ createdAt: '2026-05-28T00:00:00.000Z',
1273
+ updatedAt: '2026-05-28T00:00:00.000Z',
1274
+ },
1275
+ ],
1276
+ memoryEntries: [],
1277
+ memoryAuditRecords: [],
1278
+ generatedAt: '2026-05-28T00:00:00.000Z',
1279
+ });
1280
+ expect(bundle.runtime.knowledgeRunReports).toHaveLength(1);
1281
+ expect(bundle.runtime.knowledgeRunReports[0]).toEqual(expect.objectContaining({
1282
+ artifactId: 'workflow_artifact_knowledge_run_without_review',
1283
+ runId: 'knowledge_run_without_review',
1284
+ qualityStatus: 'pass',
1285
+ qualityScore: 90,
1286
+ }));
1287
+ expect(Object.prototype.hasOwnProperty.call(bundle.runtime.knowledgeRunReports[0], 'answerReleaseReview')).toBe(false);
1288
+ expect(bundle.runtime.knowledgeRunAnswerReleaseAuditSummary).toEqual({
1289
+ totalRuns: 1,
1290
+ reviewedRunCount: 0,
1291
+ unreviewedRunCount: 1,
1292
+ decisionCounts: {
1293
+ release: 0,
1294
+ revise: 0,
1295
+ abstain: 0,
1296
+ other: 0,
1297
+ },
1298
+ revisedRunCount: 0,
1299
+ runsWithFailedGates: 0,
1300
+ runsWithLeakedInternalFragments: 0,
1301
+ leakedInternalFragmentTotalCount: 0,
1302
+ failedGateCounts: [],
1303
+ latestReviewedAt: '',
1304
+ reviewTrend: {
1305
+ windowSize: 4,
1306
+ recentWindow: {
1307
+ reviewedRunCount: 0,
1308
+ decisionCounts: {
1309
+ release: 0,
1310
+ revise: 0,
1311
+ abstain: 0,
1312
+ other: 0,
1313
+ },
1314
+ revisedRunCount: 0,
1315
+ runsWithFailedGates: 0,
1316
+ runsWithLeakedInternalFragments: 0,
1317
+ latestReviewedAt: '',
1318
+ earliestReviewedAt: '',
1319
+ },
1320
+ priorWindow: {
1321
+ reviewedRunCount: 0,
1322
+ decisionCounts: {
1323
+ release: 0,
1324
+ revise: 0,
1325
+ abstain: 0,
1326
+ other: 0,
1327
+ },
1328
+ revisedRunCount: 0,
1329
+ runsWithFailedGates: 0,
1330
+ runsWithLeakedInternalFragments: 0,
1331
+ latestReviewedAt: '',
1332
+ earliestReviewedAt: '',
1333
+ },
1334
+ },
1335
+ failedGateAging: [],
1336
+ comparison: {
1337
+ metricShifts: [
1338
+ {
1339
+ metricId: 'reviewed_runs',
1340
+ recentValue: 0,
1341
+ priorValue: 0,
1342
+ delta: 0,
1343
+ },
1344
+ {
1345
+ metricId: 'release_decisions',
1346
+ recentValue: 0,
1347
+ priorValue: 0,
1348
+ delta: 0,
1349
+ },
1350
+ {
1351
+ metricId: 'revise_decisions',
1352
+ recentValue: 0,
1353
+ priorValue: 0,
1354
+ delta: 0,
1355
+ },
1356
+ {
1357
+ metricId: 'abstain_decisions',
1358
+ recentValue: 0,
1359
+ priorValue: 0,
1360
+ delta: 0,
1361
+ },
1362
+ {
1363
+ metricId: 'other_decisions',
1364
+ recentValue: 0,
1365
+ priorValue: 0,
1366
+ delta: 0,
1367
+ },
1368
+ {
1369
+ metricId: 'revised_runs',
1370
+ recentValue: 0,
1371
+ priorValue: 0,
1372
+ delta: 0,
1373
+ },
1374
+ {
1375
+ metricId: 'failed_gate_runs',
1376
+ recentValue: 0,
1377
+ priorValue: 0,
1378
+ delta: 0,
1379
+ },
1380
+ {
1381
+ metricId: 'leaked_runs',
1382
+ recentValue: 0,
1383
+ priorValue: 0,
1384
+ delta: 0,
1385
+ },
1386
+ ],
1387
+ gateShifts: [],
1388
+ latestPair: null,
1389
+ },
1390
+ });
1391
+ });
1392
+ test('derives graph-focus reports from session-state panel diagnostics', () => {
1393
+ const bundle = (0, WorkspaceExportBundle_1.buildWorkspaceExportBundle)({
1394
+ request: {
1395
+ workspaceId: 'optics',
1396
+ exportProfileId: 'mobile-slim',
1397
+ },
1398
+ workspace: {
1399
+ workspaceId: 'optics',
1400
+ corpusId: 'optics',
1401
+ name: 'optics',
1402
+ sourcePathPrefix: 'knowledge_base/optics',
1403
+ languages: ['zh', 'en'],
1404
+ exportProfileId: 'mobile-slim',
1405
+ status: 'active',
1406
+ createdAt: '2026-05-28T00:00:00.000Z',
1407
+ updatedAt: '2026-05-28T00:00:00.000Z',
1408
+ },
1409
+ bindings: [],
1410
+ resources: [],
1411
+ projections: [],
1412
+ indexSummary: {
1413
+ totalUnits: 0,
1414
+ totalSegments: 0,
1415
+ states: {
1416
+ pending: 0,
1417
+ indexing: 0,
1418
+ indexed: 0,
1419
+ failed: 0,
1420
+ disabled: 0,
1421
+ },
1422
+ activeDocuments: 0,
1423
+ activeAtomUnits: 0,
1424
+ },
1425
+ units: [],
1426
+ segments: [],
1427
+ atoms: [],
1428
+ evidenceSpans: [],
1429
+ relationEdges: [],
1430
+ temporalEdges: [],
1431
+ sessionStates: [
1432
+ {
1433
+ sessionStateId: 'session_state_1',
1434
+ sessionId: 'session_optics_1',
1435
+ userId: 'user_optics',
1436
+ workspaceId: 'optics',
1437
+ corpusId: 'optics',
1438
+ mode: 'grounded_conversation',
1439
+ activeResourceIds: [],
1440
+ activeProjectionIds: [],
1441
+ retrievalSettings: {
1442
+ topK: 6,
1443
+ queryBackend: 'local_hybrid',
1444
+ persistMemory: true,
1445
+ },
1446
+ memorySettings: {
1447
+ namespace: 'conversation',
1448
+ enabled: true,
1449
+ },
1450
+ exportProfileId: 'mobile-slim',
1451
+ panelState: {
1452
+ graphFocusReports: [
1453
+ {
1454
+ recordedAt: '2026-05-28T00:00:00.000Z',
1455
+ title: 'Blocks Citation',
1456
+ requestedSourcePath: 'Knowledge_Base/optics/old.md',
1457
+ resolvedSourcePath: 'Knowledge_Base/optics/blocks.md',
1458
+ candidateSourcePaths: [
1459
+ 'Knowledge_Base/optics/old.md',
1460
+ 'Knowledge_Base/optics/blocks.md',
1461
+ ],
1462
+ attemptedSourcePaths: [
1463
+ 'Knowledge_Base/optics/old.md',
1464
+ 'Knowledge_Base/optics/blocks.md',
1465
+ ],
1466
+ fallbackSourcePathUsed: true,
1467
+ matchedSpanCount: 1,
1468
+ highlightTermCount: 1,
1469
+ highlightedNodeCount: 1,
1470
+ markdownRuntimeAvailable: true,
1471
+ storageProviderAvailable: true,
1472
+ readSucceeded: true,
1473
+ renderSucceeded: true,
1474
+ usedFallback: false,
1475
+ failureReason: '',
1476
+ },
1477
+ {
1478
+ recordedAt: '2026-05-28T00:05:00.000Z',
1479
+ title: 'Missing Runtime',
1480
+ requestedSourcePath: 'Knowledge_Base/optics/missing.md',
1481
+ resolvedSourcePath: '',
1482
+ candidateSourcePaths: ['Knowledge_Base/optics/missing.md'],
1483
+ attemptedSourcePaths: [],
1484
+ fallbackSourcePathUsed: false,
1485
+ matchedSpanCount: 1,
1486
+ highlightTermCount: 1,
1487
+ highlightedNodeCount: 0,
1488
+ markdownRuntimeAvailable: false,
1489
+ storageProviderAvailable: false,
1490
+ readSucceeded: false,
1491
+ renderSucceeded: false,
1492
+ usedFallback: true,
1493
+ failureReason: 'missing_markdown_runtime',
1494
+ },
1495
+ ],
1496
+ },
1497
+ createdAt: '2026-05-28T00:00:00.000Z',
1498
+ updatedAt: '2026-05-28T00:05:00.000Z',
1499
+ },
1500
+ ],
1501
+ conversationSessions: [],
1502
+ conversationTurns: [],
1503
+ conversationInvocations: [],
1504
+ workflowArtifacts: [],
1505
+ memoryEntries: [],
1506
+ memoryAuditRecords: [],
1507
+ generatedAt: '2026-05-28T00:05:00.000Z',
1508
+ });
1509
+ expect(bundle.runtime.graphFocusReports).toEqual([
1510
+ expect.objectContaining({
1511
+ sessionStateId: 'session_state_1',
1512
+ sessionId: 'session_optics_1',
1513
+ title: 'Blocks Citation',
1514
+ requestedSourcePath: 'Knowledge_Base/optics/old.md',
1515
+ resolvedSourcePath: 'Knowledge_Base/optics/blocks.md',
1516
+ signal: expect.objectContaining({
1517
+ usedFallback: false,
1518
+ fallbackSourcePathUsed: true,
1519
+ candidateSourcePathCount: 2,
1520
+ attemptedSourcePathCount: 2,
1521
+ renderSucceeded: true,
1522
+ }),
1523
+ }),
1524
+ expect.objectContaining({
1525
+ sessionStateId: 'session_state_1',
1526
+ sessionId: 'session_optics_1',
1527
+ title: 'Missing Runtime',
1528
+ requestedSourcePath: 'Knowledge_Base/optics/missing.md',
1529
+ resolvedSourcePath: '',
1530
+ signal: expect.objectContaining({
1531
+ usedFallback: true,
1532
+ fallbackSourcePathUsed: false,
1533
+ candidateSourcePathCount: 1,
1534
+ attemptedSourcePathCount: 0,
1535
+ renderSucceeded: false,
1536
+ failureReason: 'missing_markdown_runtime',
1537
+ }),
1538
+ }),
1539
+ ]);
1540
+ });
1541
+ });