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.
- package/LICENSE +674 -21
- package/README.md +260 -1626
- package/dist/src/agent_workspace.contract.parity.test.js +159 -0
- package/dist/src/agent_workspace.frontend.test.js +10388 -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/android.knowledgebase.picker.contract.test.js +102 -0
- package/dist/src/appimage.patchelf.test.js +113 -0
- package/dist/src/appimage.portability.test.js +156 -0
- package/dist/src/backend/FileLoader.js +18 -4
- package/dist/src/backend/FileLoader.test.js +125 -0
- package/dist/src/backend/GraphBuilder.identity.test.js +86 -0
- package/dist/src/backend/GraphBuilder.js +66 -18
- package/dist/src/backend/GraphBuilder.matching.test.js +127 -0
- package/dist/src/backend/GraphMetrics.js +0 -3
- package/dist/src/backend/ResourceIdentity.js +155 -0
- package/dist/src/backend/ResourceIdentity.test.js +113 -0
- package/dist/src/backend/algorithms/CycleDetection.js +0 -1
- package/dist/src/backend/algorithms/HybridEngine.js +0 -3
- package/dist/src/backend/algorithms/LayoutEngine.js +0 -1
- package/dist/src/backend/algorithms/StatisticalAnalyzer.js +0 -4
- package/dist/src/backend/algorithms/TopologicalSort.js +0 -2
- package/dist/src/backend/build_dag.js +0 -1
- package/dist/src/capacitor.bridge.serialization.contract.test.js +3 -0
- package/dist/src/capacitor.runtime.contract.test.js +11 -2
- package/dist/src/copy.assets.contract.test.js +130 -0
- package/dist/src/core/Graph.js +138 -42
- package/dist/src/core/Graph.test.js +74 -0
- package/dist/src/core/NoteConnection.js +2 -2
- package/dist/src/core/PathBridge.js +293 -5
- package/dist/src/core/ResourceReference.js +17 -0
- package/dist/src/desktop.godot.pack.test.js +142 -0
- package/dist/src/desktop.runtime.graph.test.js +66 -0
- package/dist/src/export/WorkspaceExportBundle.js +1174 -0
- package/dist/src/export/WorkspaceExportBundle.test.js +1541 -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 +524 -0
- package/dist/src/foundation.sqlite.runtime.contract.test.js +88 -0
- package/dist/src/frontend/README.md +260 -1626
- package/dist/src/frontend/agent_workspace.js +6011 -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 +2178 -62
- 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 +672 -268
- package/dist/src/frontend/knowledge_projection_contract.js +230 -0
- package/dist/src/frontend/knowledge_projection_store.js +214 -0
- package/dist/src/frontend/layout_gpu.js +12 -4
- package/dist/src/frontend/libs/path_core.js +158 -42
- package/dist/src/frontend/locales/en.json +753 -5
- package/dist/src/frontend/locales/zh.json +753 -5
- package/dist/src/frontend/main.mjs +60 -0
- package/dist/src/frontend/markdown_runtime.js +827 -0
- package/dist/src/frontend/mobile_budget_runtime.js +33 -0
- package/dist/src/frontend/mobile_exact_analyzer.js +393 -0
- package/dist/src/frontend/mobile_identity_contract.js +221 -0
- package/dist/src/frontend/mobile_semantic_comparator.js +264 -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 +113 -2
- package/dist/src/frontend/path_app.js +2108 -130
- 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 +393 -33
- 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 +1 -1
- package/dist/src/frontend/source_manager.js +297 -22
- package/dist/src/frontend/storage_provider.js +661 -71
- package/dist/src/frontend/styles.css +2814 -72
- package/dist/src/frontend/workbench_state.mjs +101 -0
- package/dist/src/frontend/workspace_panes.js +10272 -0
- package/dist/src/frontend.locale.contract.test.js +62 -0
- package/dist/src/frontend.runtime.assets.contract.test.js +81 -0
- package/dist/src/godot.sidecar.bootstrap.contract.test.js +244 -0
- package/dist/src/graph.answer.operator.contract.test.js +72 -0
- package/dist/src/index.js +6 -2
- package/dist/src/index.knowledge-root.test.js +118 -0
- package/dist/src/indexing/IndexLifecycle.js +217 -0
- package/dist/src/indexing/IndexLifecycle.test.js +73 -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 +172 -0
- package/dist/src/knowledge_projection.contract.test.js +134 -0
- package/dist/src/knowledge_projection_store.test.js +200 -0
- package/dist/src/learning/AnswerQualityEvaluation.js +153 -0
- package/dist/src/learning/AnswerQualityEvaluation.test.js +118 -0
- package/dist/src/learning/KnowledgeLearningPlatform.js +11181 -0
- package/dist/src/learning/KnowledgeLearningPlatform.persistence.test.js +745 -0
- package/dist/src/learning/KnowledgeLearningPlatform.program-f.test.js +99 -0
- package/dist/src/learning/KnowledgeLearningPlatform.test.js +3208 -0
- package/dist/src/learning/KnowledgeWorkspaceConversationRegression.js +2998 -0
- package/dist/src/learning/KnowledgeWorkspaceConversationRegression.test.js +3936 -0
- package/dist/src/learning/MeasurementEvidenceConflicts.test.js +78 -0
- package/dist/src/learning/PublicAnswerContract.test.js +85 -0
- package/dist/src/learning/PublicEvidenceSelection.test.js +94 -0
- package/dist/src/learning/PublicMeasurementDisclosure.test.js +54 -0
- package/dist/src/learning/agentConversationExecution.js +211 -0
- package/dist/src/learning/agentConversationExecution.test.js +209 -0
- package/dist/src/learning/agentConversationSerialization.js +266 -0
- package/dist/src/learning/agentConversationSerialization.test.js +165 -0
- package/dist/src/learning/agentResponseBudget.js +179 -0
- package/dist/src/learning/agentResponseBudget.test.js +97 -0
- package/dist/src/learning/agentWorkspaceCapabilityContracts.js +65 -0
- package/dist/src/learning/answerReleaseReview.js +5260 -0
- package/dist/src/learning/answerReleaseReview.test.js +4174 -0
- package/dist/src/learning/answerTaskPlan.js +473 -0
- package/dist/src/learning/api.js +2 -0
- package/dist/src/learning/conversationComposer.js +1721 -0
- package/dist/src/learning/conversationComposer.test.js +3220 -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 +1368 -0
- package/dist/src/learning/evidenceContextAssembler.test.js +6332 -0
- package/dist/src/learning/graphAnswerCoverage.js +37 -0
- package/dist/src/learning/graphAnswerCoverage.test.js +93 -0
- package/dist/src/learning/graphAnswerCoverageCalibration.js +59 -0
- package/dist/src/learning/graphAnswerCoverageCalibration.test.js +46 -0
- package/dist/src/learning/graphAnswerFacts.js +94 -0
- package/dist/src/learning/graphAnswerFacts.test.js +39 -0
- package/dist/src/learning/graphAnswerPlan.js +908 -0
- package/dist/src/learning/graphAnswerPlan.test.js +907 -0
- package/dist/src/learning/graphAnswerQualityCalibration.js +255 -0
- package/dist/src/learning/graphAnswerQualityCalibration.test.js +72 -0
- package/dist/src/learning/graphAnswerQualityPolicy.js +30 -0
- package/dist/src/learning/graphClaimMatcher.js +104 -0
- package/dist/src/learning/graphConditionedContext.js +109 -0
- package/dist/src/learning/graphConditionedContext.test.js +99 -0
- package/dist/src/learning/graphContextAssembler.js +860 -0
- package/dist/src/learning/graphContextAssembler.test.js +1033 -0
- package/dist/src/learning/graphExpansionPolicy.js +22 -0
- package/dist/src/learning/graphExpansionPolicy.test.js +33 -0
- package/dist/src/learning/identityMetadata.test.js +26 -0
- package/dist/src/learning/index.js +29 -0
- package/dist/src/learning/mobileAnswerProjection.js +104 -0
- package/dist/src/learning/mobileAnswerProjection.test.js +102 -0
- package/dist/src/learning/queryBackend.js +1922 -0
- package/dist/src/learning/queryBackend.test.js +976 -0
- package/dist/src/learning/ragContextPack.js +356 -0
- package/dist/src/learning/ragContextPack.test.js +311 -0
- package/dist/src/learning/ragEvidenceQuality.js +96 -0
- package/dist/src/learning/ragEvidenceQuality.test.js +29 -0
- package/dist/src/learning/ragPublicText.js +101 -0
- package/dist/src/learning/ragPublicText.test.js +57 -0
- package/dist/src/learning/ragSufficiencyJudge.js +171 -0
- package/dist/src/learning/ragSufficiencyJudge.test.js +177 -0
- package/dist/src/learning/ragSufficiencyProviderJudge.js +217 -0
- package/dist/src/learning/ragSufficiencyProviderJudge.test.js +207 -0
- package/dist/src/learning/requestNormalization.js +304 -0
- package/dist/src/learning/requestNormalization.test.js +101 -0
- package/dist/src/learning/runtimeCapability.js +4677 -0
- package/dist/src/learning/runtimeCapability.test.js +3635 -0
- package/dist/src/learning/store.js +1344 -0
- package/dist/src/learning/store.test.js +1425 -0
- package/dist/src/learning/tutorAdapter.js +2 -0
- package/dist/src/learning/types.js +2 -0
- package/dist/src/learning/vectorAccelerationAdapter.js +958 -0
- package/dist/src/learning/vectorAccelerationAdapter.test.js +412 -0
- package/dist/src/learning/workspaceHydration.js +168 -0
- package/dist/src/learning/workspaceHydration.test.js +30 -0
- package/dist/src/lfs.asset.policy.contract.test.js +153 -0
- package/dist/src/license.policy.contract.test.js +71 -0
- package/dist/src/markdown/MarkdownGateway.js +4 -0
- package/dist/src/markdown/MarkdownGateway.test.js +59 -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/SseResponseWriter.js +122 -0
- package/dist/src/middleware/SseResponseWriter.test.js +54 -0
- package/dist/src/middleware/auth.js +38 -0
- package/dist/src/middleware/auth.test.js +33 -0
- package/dist/src/middleware/body-parser.js +45 -0
- package/dist/src/middleware/cors.js +44 -0
- package/dist/src/middleware/index.js +22 -0
- package/dist/src/middleware/request-trace.js +96 -0
- package/dist/src/mobile.android.evidence.contract.test.js +146 -0
- package/dist/src/mobile.android.signing.contract.test.js +66 -0
- package/dist/src/mobile.artifact.contract.test.js +144 -0
- package/dist/src/mobile.budget.contract.test.js +90 -0
- package/dist/src/mobile.canonical-id.readiness.test.js +54 -0
- package/dist/src/mobile.graph.parity.contract.test.js +207 -0
- package/dist/src/mobile.identity.contract.test.js +66 -0
- package/dist/src/mobile.identity.corpus.manifest.test.js +72 -0
- package/dist/src/mobile.identity.corpus.test.js +40 -0
- package/dist/src/mobile.native.recovery.contract.test.js +64 -0
- package/dist/src/mobile.pipeline.test.js +11 -1
- package/dist/src/mobile.profile.contract.test.js +225 -0
- package/dist/src/mobile.semantic.parity.test.js +92 -0
- package/dist/src/mobile_exact_analyzer.test.js +113 -0
- package/dist/src/notemd/AppConfigToml.js +6 -4
- package/dist/src/notemd/ContentGenerator.js +4 -9
- package/dist/src/notemd/FileProcessor.js +4 -9
- package/dist/src/notemd/MermaidProcessor.js +400 -50
- package/dist/src/notemd/NotemdService.js +506 -26
- package/dist/src/notemd/PromptManager.js +15 -0
- package/dist/src/notemd/Translator.js +4 -9
- 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/progressReporter.js +9 -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 +262 -39
- package/dist/src/notemd.workflow.pipeline.test.js +162 -0
- package/dist/src/pathbridge.handshake.contract.test.js +45 -2
- package/dist/src/pathbridge.host-adapter.contract.test.js +133 -0
- package/dist/src/pathcore.bundle.contract.test.js +8 -0
- 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 +86 -0
- package/dist/src/platform/MobileBudget.js +11 -0
- package/dist/src/platform/PlatformCapabilities.js +59 -0
- package/dist/src/platform/PlatformCapabilities.test.js +36 -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 +97 -0
- package/dist/src/resources/ResourceRegistry.js +263 -0
- package/dist/src/resources/ResourceRegistry.test.js +97 -0
- package/dist/src/resources/types.js +2 -0
- package/dist/src/routes/agentWorkspaceDiagnostics.js +173 -0
- package/dist/src/routes/index.js +19 -0
- package/dist/src/routes/knowledge.js +981 -0
- package/dist/src/routes/knowledgePayload.js +185 -0
- package/dist/src/routes/knowledgePayload.test.js +53 -0
- package/dist/src/routes/markdown.js +295 -0
- package/dist/src/routes/notemd.js +1321 -0
- package/dist/src/routes/registry.contract.test.js +133 -0
- package/dist/src/routes/registry.shadow.contract.test.js +22 -0
- package/dist/src/routes/render.js +248 -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.capabilities.test.js +18 -2
- package/dist/src/runtime.transport.adapter.contract.test.js +81 -0
- package/dist/src/server.js +10342 -1325
- package/dist/src/server.migration.test.js +584 -10
- 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.build.lock.contract.test.js +201 -0
- package/dist/src/sidecar.freshness.contract.test.js +184 -0
- package/dist/src/sidecar.replacement.boundary.contract.test.js +131 -0
- package/dist/src/sidecar.supply.readiness.contract.test.js +155 -0
- package/dist/src/simulation.worker.offline.test.js +104 -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/storage.provider.capacitor.content.contract.test.js +4 -1
- package/dist/src/storage.provider.contract.test.js +152 -1
- package/dist/src/tauri.frontend.build.contract.test.js +68 -0
- package/dist/src/tauri.sidecar.cleanup.contract.test.js +21 -0
- package/dist/src/tauri.window.evidence.execution.test.js +68 -0
- package/dist/src/utils/RuntimePaths.js +10 -13
- package/dist/src/utils/RuntimePaths.test.js +27 -0
- package/dist/src/utils/platform.js +153 -0
- package/dist/src/windows.installer.build.test.js +109 -0
- package/dist/src/windows.installer.payload.test.js +76 -0
- package/dist/src/windows.installer.runtime.test.js +69 -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 +135 -0
- package/dist/src/workspace/WorkspaceRegistry.test.js +29 -0
- package/dist/src/workspace/types.js +2 -0
- package/package.json +80 -15
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Route Registry Contract Tests
|
|
5
|
+
* Verifies the modular route registration and dispatch infrastructure.
|
|
6
|
+
*/
|
|
7
|
+
const index_1 = require("./index");
|
|
8
|
+
const constants_1 = require("../notemd/constants");
|
|
9
|
+
function createMockContext() {
|
|
10
|
+
const scheduleKnowledgeLearningPlatformWarmup = jest.fn();
|
|
11
|
+
return {
|
|
12
|
+
knowledgeLearningPlatform: {
|
|
13
|
+
getKnowledgeState: async () => ({ documents: 0 })
|
|
14
|
+
},
|
|
15
|
+
scheduleKnowledgeLearningPlatformWarmup,
|
|
16
|
+
knowledgeIngestor: { ingestKnowledge: async () => ({}), averageIngestLatencyMs: () => 0, getDiagnostics: () => ({}) },
|
|
17
|
+
knowledgeQuerier: { queryKnowledge: async () => ({}), getDiagnosticsSummary: () => ({}) },
|
|
18
|
+
conversationManager: { getDiagnosticsSummary: () => ({}) },
|
|
19
|
+
masteryEngine: { getDiagnosticsSummary: () => ({}) },
|
|
20
|
+
qualityEvaluator: { getDiagnosticsSummary: () => ({}) },
|
|
21
|
+
tutorRouter: { getDiagnosticsSummary: () => ({}) },
|
|
22
|
+
memoryPolicyManager: { getDiagnosticsSummary: () => ({}) },
|
|
23
|
+
notemdService: {},
|
|
24
|
+
loadNotemdSettings: async () => structuredClone(constants_1.DEFAULT_SETTINGS),
|
|
25
|
+
persistNotemdSettings: async () => structuredClone(constants_1.DEFAULT_SETTINGS),
|
|
26
|
+
notemdHttp: {},
|
|
27
|
+
LOOPBACK_HOST: '127.0.0.1',
|
|
28
|
+
finalPort: 3000,
|
|
29
|
+
KNOWLEDGE_GRAPH_STORE_BACKEND: 'file',
|
|
30
|
+
KNOWLEDGE_GRAPHDB_ADAPTER_PROVIDER: 'none',
|
|
31
|
+
KNOWLEDGE_GRAPHDB_ADAPTER_ID: '',
|
|
32
|
+
KNOWLEDGE_GRAPHDB_FALLBACK_ENABLED: false,
|
|
33
|
+
KNOWLEDGE_GRAPHDB_OPERATION_MODE: 'read_write',
|
|
34
|
+
kbRoot: '/tmp/test-kb',
|
|
35
|
+
runtimeDataDir: '/tmp/test-runtime-data',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
describe('Route Registry', () => {
|
|
39
|
+
const ctx = createMockContext();
|
|
40
|
+
const routes = (0, index_1.registerAllRoutes)(ctx);
|
|
41
|
+
test('registers all route groups', () => {
|
|
42
|
+
expect(routes.length).toBeGreaterThanOrEqual(70);
|
|
43
|
+
});
|
|
44
|
+
test('every route has required fields', () => {
|
|
45
|
+
for (const route of routes) {
|
|
46
|
+
expect(route.method).toMatch(/^(GET|POST|PUT|DELETE)$/);
|
|
47
|
+
expect(route.path).toBeTruthy();
|
|
48
|
+
expect(typeof route.handler).toBe('function');
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
test('knowledge routes are registered', () => {
|
|
52
|
+
const knowledgeRoutes = routes.filter(r => r.path.startsWith('/api/knowledge'));
|
|
53
|
+
expect(knowledgeRoutes.length).toBeGreaterThanOrEqual(30);
|
|
54
|
+
// Verify key endpoints exist
|
|
55
|
+
const paths = new Set(knowledgeRoutes.map(r => `${r.method} ${r.path}`));
|
|
56
|
+
expect(paths.has('GET /api/knowledge/state')).toBe(true);
|
|
57
|
+
expect(paths.has('GET /api/knowledge/workflow-artifacts')).toBe(true);
|
|
58
|
+
expect(paths.has('POST /api/knowledge/workflow-artifacts/review-follow-up')).toBe(true);
|
|
59
|
+
expect(paths.has('POST /api/knowledge/ingest')).toBe(true);
|
|
60
|
+
expect(paths.has('POST /api/knowledge/query')).toBe(true);
|
|
61
|
+
expect(paths.has('POST /api/knowledge/export/workspace')).toBe(true);
|
|
62
|
+
expect(paths.has('POST /api/knowledge/session/graph-focus-diagnostics')).toBe(true);
|
|
63
|
+
expect(paths.has('POST /api/knowledge/conversation')).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
test('notemd routes are registered', () => {
|
|
66
|
+
const notemdRoutes = routes.filter(r => r.path.startsWith('/api/notemd'));
|
|
67
|
+
expect(notemdRoutes.length).toBeGreaterThanOrEqual(10);
|
|
68
|
+
const paths = new Set(notemdRoutes.map(r => `${r.method} ${r.path}`));
|
|
69
|
+
expect(paths.has('GET /api/notemd/settings')).toBe(true);
|
|
70
|
+
expect(paths.has('POST /api/notemd/process-file')).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
test('render routes are registered', () => {
|
|
73
|
+
const renderRoutes = routes.filter(r => r.path.startsWith('/api/render') || r.path.startsWith('/api/clipboard'));
|
|
74
|
+
expect(renderRoutes.map(route => route.path).sort()).toEqual(['/api/render/math', '/api/render/mermaid']);
|
|
75
|
+
});
|
|
76
|
+
test('no duplicate method+path combinations', () => {
|
|
77
|
+
const seen = new Set();
|
|
78
|
+
for (const route of routes) {
|
|
79
|
+
const key = `${route.method} ${route.path}`;
|
|
80
|
+
expect(seen.has(key)).toBe(false);
|
|
81
|
+
seen.add(key);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
test('all GET routes have idempotent paths', () => {
|
|
85
|
+
const getRoutes = routes.filter(r => r.method === 'GET');
|
|
86
|
+
for (const route of getRoutes) {
|
|
87
|
+
expect(route.path).toMatch(/^\/api\//);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
test('domain diagnostics are exposed via context', () => {
|
|
91
|
+
// All 7 domain classes are available through ServerContext
|
|
92
|
+
expect(ctx.knowledgeIngestor).toBeDefined();
|
|
93
|
+
expect(ctx.knowledgeQuerier).toBeDefined();
|
|
94
|
+
expect(ctx.conversationManager).toBeDefined();
|
|
95
|
+
expect(ctx.masteryEngine).toBeDefined();
|
|
96
|
+
expect(ctx.qualityEvaluator).toBeDefined();
|
|
97
|
+
expect(ctx.tutorRouter).toBeDefined();
|
|
98
|
+
expect(ctx.memoryPolicyManager).toBeDefined();
|
|
99
|
+
});
|
|
100
|
+
test('domain diagnostics have required methods', () => {
|
|
101
|
+
expect(typeof ctx.knowledgeIngestor.getDiagnostics).toBe('function');
|
|
102
|
+
expect(typeof ctx.knowledgeQuerier.getDiagnosticsSummary).toBe('function');
|
|
103
|
+
expect(typeof ctx.conversationManager.getDiagnosticsSummary).toBe('function');
|
|
104
|
+
expect(typeof ctx.masteryEngine.getDiagnosticsSummary).toBe('function');
|
|
105
|
+
expect(typeof ctx.qualityEvaluator.getDiagnosticsSummary).toBe('function');
|
|
106
|
+
expect(typeof ctx.tutorRouter.getDiagnosticsSummary).toBe('function');
|
|
107
|
+
expect(typeof ctx.memoryPolicyManager.getDiagnosticsSummary).toBe('function');
|
|
108
|
+
});
|
|
109
|
+
test('knowledge routes can be dispatched', async () => {
|
|
110
|
+
const stateRoute = routes.find(r => r.method === 'GET' && r.path === '/api/knowledge/state');
|
|
111
|
+
expect(stateRoute).toBeDefined();
|
|
112
|
+
// Mock request/response
|
|
113
|
+
const mockRes = {
|
|
114
|
+
_statusCode: 0,
|
|
115
|
+
_headers: {},
|
|
116
|
+
_body: '',
|
|
117
|
+
writeHead(code, headers) {
|
|
118
|
+
this._statusCode = code;
|
|
119
|
+
this._headers = headers;
|
|
120
|
+
},
|
|
121
|
+
end(data) {
|
|
122
|
+
this._body = data;
|
|
123
|
+
},
|
|
124
|
+
setHeader(_name, _value) { },
|
|
125
|
+
getHeader(_name) { return ''; },
|
|
126
|
+
};
|
|
127
|
+
await stateRoute.handler({ url: '/api/knowledge/state', method: 'GET', headers: {} }, mockRes, ctx);
|
|
128
|
+
// The handler should produce a JSON response
|
|
129
|
+
expect(mockRes._statusCode).toBeGreaterThanOrEqual(200);
|
|
130
|
+
expect(mockRes._statusCode).toBeLessThan(600);
|
|
131
|
+
expect(ctx.scheduleKnowledgeLearningPlatformWarmup).toHaveBeenCalledWith('knowledge_state_request');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
describe('route registry shadow parity gate', () => {
|
|
9
|
+
const repoRoot = node_path_1.default.resolve(__dirname, '..', '..');
|
|
10
|
+
const serverSource = node_fs_1.default.readFileSync(node_path_1.default.join(repoRoot, 'src', 'server.ts'), 'utf8');
|
|
11
|
+
const packageJson = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(repoRoot, 'package.json'), 'utf8'));
|
|
12
|
+
test('supports an explicit legacy mode without changing the default registry mode', () => {
|
|
13
|
+
expect(serverSource.includes('NOTE_CONNECTION_ROUTE_DISPATCH_MODE')).toBe(true);
|
|
14
|
+
expect(serverSource.includes("ROUTE_DISPATCH_MODE === 'registry'")).toBe(true);
|
|
15
|
+
expect(serverSource.includes("registeredRoute && (USE_REGISTRY_DISPATCH || requestPath.startsWith('/api/notemd/'))")).toBe(true);
|
|
16
|
+
expect(/(?:get|post)Pathname === '\/api\/notemd\//.test(serverSource)).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
test('ships an executable parity harness as a release gate', () => {
|
|
19
|
+
expect(packageJson.scripts?.['verify:route:shadow']).toBe('npm run build:mini && node scripts/verify-route-registry-shadow.js');
|
|
20
|
+
expect(node_fs_1.default.existsSync(node_path_1.default.join(repoRoot, 'scripts', 'verify-route-registry-shadow.js'))).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.registerRenderRoutes = registerRenderRoutes;
|
|
37
|
+
const isPngBuffer = (value) => value.length >= 8
|
|
38
|
+
&& value[0] === 0x89
|
|
39
|
+
&& value[1] === 0x50
|
|
40
|
+
&& value[2] === 0x4e
|
|
41
|
+
&& value[3] === 0x47
|
|
42
|
+
&& value[4] === 0x0d
|
|
43
|
+
&& value[5] === 0x0a
|
|
44
|
+
&& value[6] === 0x1a
|
|
45
|
+
&& value[7] === 0x0a;
|
|
46
|
+
const CrashLogger_1 = require("../backend/utils/CrashLogger");
|
|
47
|
+
const RenderMaterializer_1 = require("../platform/RenderMaterializer");
|
|
48
|
+
function normalizeMermaidRendererPreference(value) {
|
|
49
|
+
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
50
|
+
if (normalized === 'local') {
|
|
51
|
+
return 'local';
|
|
52
|
+
}
|
|
53
|
+
if (normalized === 'frontend' || normalized === 'bridge') {
|
|
54
|
+
return 'frontend';
|
|
55
|
+
}
|
|
56
|
+
return 'auto';
|
|
57
|
+
}
|
|
58
|
+
function registerRenderRoutes(ctx) {
|
|
59
|
+
const json = (res, code, data) => {
|
|
60
|
+
res.writeHead(code, { 'Content-Type': 'application/json' });
|
|
61
|
+
res.end(JSON.stringify(data));
|
|
62
|
+
};
|
|
63
|
+
const fail = (res, error, label) => {
|
|
64
|
+
console.error(error);
|
|
65
|
+
CrashLogger_1.CrashLogger.log(error, label);
|
|
66
|
+
json(res, 500, { success: false, error: String(error) });
|
|
67
|
+
};
|
|
68
|
+
const readBody = (req) => new Promise((resolve, reject) => {
|
|
69
|
+
const chunks = [];
|
|
70
|
+
req.on('data', (c) => chunks.push(c));
|
|
71
|
+
req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
72
|
+
req.on('error', reject);
|
|
73
|
+
});
|
|
74
|
+
const parseOptionalPositiveDimension = (value) => {
|
|
75
|
+
const numeric = Number(value);
|
|
76
|
+
if (!Number.isFinite(numeric) || numeric <= 0) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return Math.floor(numeric);
|
|
80
|
+
};
|
|
81
|
+
const parseOptionalPositiveScale = (value) => {
|
|
82
|
+
const numeric = Number(value);
|
|
83
|
+
if (!Number.isFinite(numeric) || numeric <= 0) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
return numeric;
|
|
87
|
+
};
|
|
88
|
+
const renderMermaidWithPreference = async (source, options) => {
|
|
89
|
+
const includeSvg = options.includeStages || options.includeSvg;
|
|
90
|
+
const { normalizeMermaidDefinition } = await Promise.resolve().then(() => __importStar(require('../reader_renderer')));
|
|
91
|
+
const normalizedSource = normalizeMermaidDefinition(source);
|
|
92
|
+
const pathBridge = typeof ctx.getPathBridge === 'function' ? ctx.getPathBridge() : null;
|
|
93
|
+
if (options.rendererPreference !== 'local'
|
|
94
|
+
&& pathBridge
|
|
95
|
+
&& typeof pathBridge.requestFrontendMermaidRender === 'function') {
|
|
96
|
+
try {
|
|
97
|
+
const frontendRendered = await pathBridge.requestFrontendMermaidRender({
|
|
98
|
+
source,
|
|
99
|
+
theme: 'dark',
|
|
100
|
+
maxWidth: options.maxWidth,
|
|
101
|
+
maxHeight: options.maxHeight,
|
|
102
|
+
renderScale: options.renderScale,
|
|
103
|
+
includeStages: options.includeStages,
|
|
104
|
+
includeSvg,
|
|
105
|
+
});
|
|
106
|
+
const frontendResult = {
|
|
107
|
+
pngBase64: frontendRendered.pngBase64,
|
|
108
|
+
width: frontendRendered.width,
|
|
109
|
+
height: frontendRendered.height,
|
|
110
|
+
renderer: frontendRendered.renderer || 'frontend-bridge',
|
|
111
|
+
normalizedSource,
|
|
112
|
+
};
|
|
113
|
+
if (includeSvg && typeof frontendRendered.svg === 'string' && frontendRendered.svg.trim()) {
|
|
114
|
+
frontendResult.svg = frontendRendered.svg;
|
|
115
|
+
}
|
|
116
|
+
if (options.includeStages && Array.isArray(frontendRendered.stages)) {
|
|
117
|
+
frontendResult.stages = frontendRendered.stages;
|
|
118
|
+
}
|
|
119
|
+
return frontendResult;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (options.rendererPreference === 'frontend') {
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
console.warn('[Render Route] Frontend Mermaid renderer unavailable, falling back to local resvg.', error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const { collectMermaidRenderStageSnapshots, renderMermaidPng, } = await Promise.resolve().then(() => __importStar(require('../reader_renderer')));
|
|
129
|
+
const localRendered = await renderMermaidPng(source, {
|
|
130
|
+
theme: 'dark',
|
|
131
|
+
maxWidth: options.maxWidth,
|
|
132
|
+
maxHeight: options.maxHeight,
|
|
133
|
+
renderScale: options.renderScale,
|
|
134
|
+
});
|
|
135
|
+
const localResult = {
|
|
136
|
+
pngBase64: localRendered.pngBase64,
|
|
137
|
+
width: localRendered.width,
|
|
138
|
+
height: localRendered.height,
|
|
139
|
+
renderer: 'local-resvg',
|
|
140
|
+
normalizedSource,
|
|
141
|
+
};
|
|
142
|
+
if (includeSvg && typeof localRendered.svg === 'string' && localRendered.svg.trim()) {
|
|
143
|
+
localResult.svg = localRendered.svg;
|
|
144
|
+
}
|
|
145
|
+
if (options.includeStages) {
|
|
146
|
+
localResult.stages = await collectMermaidRenderStageSnapshots(source, {
|
|
147
|
+
theme: 'dark',
|
|
148
|
+
maxWidth: options.maxWidth,
|
|
149
|
+
maxHeight: options.maxHeight,
|
|
150
|
+
renderScale: options.renderScale,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return localResult;
|
|
154
|
+
};
|
|
155
|
+
return [
|
|
156
|
+
{
|
|
157
|
+
method: 'POST',
|
|
158
|
+
path: '/api/render/math',
|
|
159
|
+
handler: async (req, res) => {
|
|
160
|
+
try {
|
|
161
|
+
const body = await readBody(req);
|
|
162
|
+
const payload = JSON.parse(body);
|
|
163
|
+
const expression = typeof payload?.expression === 'string'
|
|
164
|
+
? payload.expression
|
|
165
|
+
: (typeof payload?.source === 'string' ? payload.source : '');
|
|
166
|
+
if (!expression.trim()) {
|
|
167
|
+
const hasExpressionField = Object.prototype.hasOwnProperty.call(payload || {}, 'expression');
|
|
168
|
+
json(res, 400, hasExpressionField
|
|
169
|
+
? { success: false, error: 'Missing expression' }
|
|
170
|
+
: { error: 'Missing source' });
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const { renderMathPng } = await Promise.resolve().then(() => __importStar(require('../reader_renderer')));
|
|
174
|
+
const result = await renderMathPng(expression, {
|
|
175
|
+
displayMode: payload?.displayMode !== false,
|
|
176
|
+
maxWidth: parseOptionalPositiveDimension(payload?.maxWidth),
|
|
177
|
+
maxHeight: parseOptionalPositiveDimension(payload?.maxHeight),
|
|
178
|
+
renderScale: parseOptionalPositiveScale(payload?.renderScale),
|
|
179
|
+
});
|
|
180
|
+
const materialization = (0, RenderMaterializer_1.resolveRenderMaterializationDecision)({
|
|
181
|
+
exportProfileId: payload?.exportProfileId,
|
|
182
|
+
platformTarget: payload?.platformTarget,
|
|
183
|
+
});
|
|
184
|
+
json(res, 200, {
|
|
185
|
+
success: true,
|
|
186
|
+
pngBase64: result.pngBase64,
|
|
187
|
+
width: result.width,
|
|
188
|
+
height: result.height,
|
|
189
|
+
materialization,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
fail(res, e, 'POST /api/render/math');
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
method: 'POST',
|
|
199
|
+
path: '/api/render/mermaid',
|
|
200
|
+
handler: async (req, res) => {
|
|
201
|
+
let source = '';
|
|
202
|
+
try {
|
|
203
|
+
const body = await readBody(req);
|
|
204
|
+
const payload = JSON.parse(body);
|
|
205
|
+
source = typeof payload?.source === 'string'
|
|
206
|
+
? payload.source
|
|
207
|
+
: (typeof payload?.diagram === 'string' ? payload.diagram : '');
|
|
208
|
+
if (!source.trim()) {
|
|
209
|
+
json(res, 400, { error: 'Missing source' });
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const includeStages = payload?.includeStages === true;
|
|
213
|
+
const materialization = (0, RenderMaterializer_1.resolveRenderMaterializationDecision)({
|
|
214
|
+
exportProfileId: payload?.exportProfileId,
|
|
215
|
+
platformTarget: payload?.platformTarget,
|
|
216
|
+
includeSvg: payload?.includeSvg === true,
|
|
217
|
+
includeStages,
|
|
218
|
+
rendererPreference: payload?.renderer,
|
|
219
|
+
});
|
|
220
|
+
const rendererPreference = normalizeMermaidRendererPreference(materialization.rendererPreference);
|
|
221
|
+
const responsePayload = await renderMermaidWithPreference(source, {
|
|
222
|
+
rendererPreference,
|
|
223
|
+
includeStages: materialization.includeStages,
|
|
224
|
+
includeSvg: materialization.includeSvg,
|
|
225
|
+
maxWidth: parseOptionalPositiveDimension(payload?.maxWidth),
|
|
226
|
+
maxHeight: parseOptionalPositiveDimension(payload?.maxHeight),
|
|
227
|
+
renderScale: parseOptionalPositiveScale(payload?.renderScale),
|
|
228
|
+
});
|
|
229
|
+
responsePayload.materialization = materialization;
|
|
230
|
+
json(res, 200, responsePayload);
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
try {
|
|
234
|
+
const { normalizeMermaidDefinition } = await Promise.resolve().then(() => __importStar(require('../reader_renderer')));
|
|
235
|
+
json(res, 500, {
|
|
236
|
+
success: false,
|
|
237
|
+
error: String(e),
|
|
238
|
+
normalizedSource: normalizeMermaidDefinition(source),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
fail(res, e, 'POST /api/render/mermaid');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__runtimeRunbookRouteOpsTestUtils = void 0;
|
|
4
|
+
exports.createRuntimeRunbookRouteOps = createRuntimeRunbookRouteOps;
|
|
5
|
+
const learning_1 = require("../learning");
|
|
6
|
+
function normalizeVerificationStatus(value) {
|
|
7
|
+
const normalized = String(value || '').trim().toLowerCase();
|
|
8
|
+
return (normalized === 'pass'
|
|
9
|
+
|| normalized === 'warn'
|
|
10
|
+
|| normalized === 'fail')
|
|
11
|
+
? normalized
|
|
12
|
+
: 'unknown';
|
|
13
|
+
}
|
|
14
|
+
function buildRuntimeRunbookVerifyFallbackResult(input) {
|
|
15
|
+
return {
|
|
16
|
+
generatedAt: input.generatedAt,
|
|
17
|
+
requestedCheckId: input.requestedCheckId,
|
|
18
|
+
selectedCheckId: '',
|
|
19
|
+
effectiveCheckId: '',
|
|
20
|
+
selectedCheckStatus: 'unknown',
|
|
21
|
+
selectedCheckEscalation: 'normal',
|
|
22
|
+
selectedCheckPriorityScore: 0,
|
|
23
|
+
selectedCheckMessage: 'No verification history available yet.',
|
|
24
|
+
verificationTargets: Array.isArray(input.runbook.verificationTargets)
|
|
25
|
+
? input.runbook.verificationTargets
|
|
26
|
+
: [],
|
|
27
|
+
selectedCheckEscalationActions: [],
|
|
28
|
+
traceSummary: {
|
|
29
|
+
returnedRecords: 0,
|
|
30
|
+
errorRequests: 0,
|
|
31
|
+
errorRatioPct: 0,
|
|
32
|
+
p95DurationMs: 0,
|
|
33
|
+
},
|
|
34
|
+
selectedCheckHistory: {
|
|
35
|
+
returnedRecords: 0,
|
|
36
|
+
activeRiskStreak: 0,
|
|
37
|
+
activeFailStreak: 0,
|
|
38
|
+
trendStatus: 'insufficient_data',
|
|
39
|
+
},
|
|
40
|
+
selectedCheckRemediation: {
|
|
41
|
+
latestStatus: '',
|
|
42
|
+
trendStatus: 'insufficient_data',
|
|
43
|
+
riskRatioPct: 0,
|
|
44
|
+
},
|
|
45
|
+
queryVectorAccelerationIndexSyncHealth: input.buildIndexSyncHealthSummary(input.runtimeCapabilityMatrix),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function createRuntimeRunbookRouteOps(deps) {
|
|
49
|
+
return {
|
|
50
|
+
getRunbook: async (request = {}) => {
|
|
51
|
+
const generatedAt = new Date().toISOString();
|
|
52
|
+
const runtimePayload = await deps.buildRuntimePayload(generatedAt);
|
|
53
|
+
return (0, learning_1.buildRuntimeCapabilityRunbook)(runtimePayload.runtimeCapabilityMatrix, String(request.checkId || '').trim());
|
|
54
|
+
},
|
|
55
|
+
verify: async (request = {}) => {
|
|
56
|
+
const requestedCheckId = deps.normalizeCheckId(request.checkId || '');
|
|
57
|
+
const sinceMinutes = Math.max(0, Math.floor(Number(request.sinceMinutes || 1440)));
|
|
58
|
+
const traceLimit = Math.max(1, Math.floor(Number(request.limit || 20)));
|
|
59
|
+
const generatedAt = new Date().toISOString();
|
|
60
|
+
const runtimePayload = await deps.buildRuntimePayload(generatedAt);
|
|
61
|
+
const runbook = (0, learning_1.buildRuntimeCapabilityRunbook)(runtimePayload.runtimeCapabilityMatrix, requestedCheckId);
|
|
62
|
+
const selectedCheckId = deps.normalizeCheckId(String(runbook.selectedCheck?.checkId || requestedCheckId));
|
|
63
|
+
if (selectedCheckId) {
|
|
64
|
+
const replayResult = await deps.replayVerificationForCheck({
|
|
65
|
+
checkId: selectedCheckId,
|
|
66
|
+
sinceMinutes,
|
|
67
|
+
traceLimit,
|
|
68
|
+
});
|
|
69
|
+
if (replayResult) {
|
|
70
|
+
const resolvedCheckId = deps.normalizeCheckId(String(replayResult.resolvedCheckId || selectedCheckId));
|
|
71
|
+
return {
|
|
72
|
+
...replayResult,
|
|
73
|
+
selectedCheckId: resolvedCheckId || selectedCheckId,
|
|
74
|
+
effectiveCheckId: resolvedCheckId || selectedCheckId,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return buildRuntimeRunbookVerifyFallbackResult({
|
|
79
|
+
generatedAt,
|
|
80
|
+
requestedCheckId,
|
|
81
|
+
runbook,
|
|
82
|
+
runtimeCapabilityMatrix: runtimePayload.runtimeCapabilityMatrix,
|
|
83
|
+
buildIndexSyncHealthSummary: deps.buildIndexSyncHealthSummary,
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
getHistory: async (request = {}) => deps.queryHistory({
|
|
87
|
+
limit: deps.parseHistoryLimit(request.limit),
|
|
88
|
+
checkId: deps.normalizeCheckId(request.checkId || ''),
|
|
89
|
+
sinceMinutes: deps.parseHistorySinceMinutes(request.sinceMinutes),
|
|
90
|
+
status: deps.normalizeVerificationStatus(request.status || ''),
|
|
91
|
+
}),
|
|
92
|
+
getChecks: async (request = {}) => deps.queryChecks({
|
|
93
|
+
limit: deps.parseChecksLimit(request.limit),
|
|
94
|
+
sinceMinutes: deps.parseHistorySinceMinutes(request.sinceMinutes),
|
|
95
|
+
status: deps.normalizeVerificationStatus(request.status || ''),
|
|
96
|
+
checkQuery: String(request.checkQuery || '').trim(),
|
|
97
|
+
}),
|
|
98
|
+
getActionQueue: async (request = {}) => deps.queryActionQueue({
|
|
99
|
+
checksQuery: {
|
|
100
|
+
limit: deps.parseChecksLimit(request.limit),
|
|
101
|
+
sinceMinutes: deps.parseHistorySinceMinutes(request.sinceMinutes),
|
|
102
|
+
status: deps.normalizeVerificationStatus(request.status || ''),
|
|
103
|
+
checkQuery: String(request.checkQuery || '').trim(),
|
|
104
|
+
},
|
|
105
|
+
queueLimit: deps.parseActionQueueLimit(request.queueLimit),
|
|
106
|
+
priorityFilter: deps.normalizeActionQueuePriorityFilter(request.priority || ''),
|
|
107
|
+
categoryFilter: deps.normalizeActionQueueCategoryFilter(request.category || ''),
|
|
108
|
+
checkIdFilter: deps.normalizeCheckId(request.checkId || ''),
|
|
109
|
+
remediationStatusFilter: deps.normalizeActionQueueRemediationStatusFilter(request.remediationStatus || ''),
|
|
110
|
+
remediationTrendFilter: deps.normalizeActionQueueRemediationTrendFilter(request.remediationTrend || ''),
|
|
111
|
+
}),
|
|
112
|
+
getRemediationHistory: async (request = {}) => deps.queryRemediationHistory({
|
|
113
|
+
limit: deps.parseRemediationLimit(request.limit),
|
|
114
|
+
sinceMinutes: deps.parseHistorySinceMinutes(request.sinceMinutes),
|
|
115
|
+
status: deps.normalizeRemediationStatusQuery(request.status || ''),
|
|
116
|
+
source: deps.normalizeRemediationSource(request.source || ''),
|
|
117
|
+
checkId: deps.normalizeCheckId(request.checkId || ''),
|
|
118
|
+
}),
|
|
119
|
+
getReplaySchedule: async () => deps.getReplaySchedule(),
|
|
120
|
+
recordRemediationEvent: async (payload, requestId = '') => {
|
|
121
|
+
const record = deps.normalizeRemediationEventPayload(payload, requestId);
|
|
122
|
+
deps.appendRemediationEventRecord(record);
|
|
123
|
+
deps.triggerReplayScheduleFromEvent();
|
|
124
|
+
return {
|
|
125
|
+
record,
|
|
126
|
+
summary: {
|
|
127
|
+
totalRecords: Math.max(0, Math.floor(Number(deps.getRemediationEventCount() || 0))),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
replayRemediationEvent: async (payload) => {
|
|
132
|
+
const replayOptions = deps.normalizeRemediationReplayRequestPayload(payload);
|
|
133
|
+
return deps.replayRemediationEvents(replayOptions);
|
|
134
|
+
},
|
|
135
|
+
updateReplaySchedule: async (payload) => deps.updateReplaySchedule(payload),
|
|
136
|
+
tickReplaySchedule: async (payload = {}) => {
|
|
137
|
+
const tickOptions = deps.normalizeReplayScheduleTickPayload(payload);
|
|
138
|
+
return deps.tickReplaySchedule({
|
|
139
|
+
force: tickOptions.force,
|
|
140
|
+
dryRunOverride: tickOptions.dryRunOverride,
|
|
141
|
+
actor: 'modular_route',
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
exports.__runtimeRunbookRouteOpsTestUtils = {
|
|
147
|
+
buildRuntimeRunbookVerifyFallbackResult,
|
|
148
|
+
normalizeVerificationStatus,
|
|
149
|
+
};
|