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,153 @@
|
|
|
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
|
+
const fs = __importStar(require("fs"));
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
describe('LFS asset policy contracts', () => {
|
|
39
|
+
const repoRoot = path.resolve(__dirname, '..');
|
|
40
|
+
const packageJsonPath = path.join(repoRoot, 'package.json');
|
|
41
|
+
const gitattributesPath = path.join(repoRoot, '.gitattributes');
|
|
42
|
+
const deadNodeSidecarPath = path.join(repoRoot, 'src-tauri', 'bin', 'node-x86_64-pc-windows-msvc.exe');
|
|
43
|
+
const deadGraphPayloadPaths = [
|
|
44
|
+
path.join(repoRoot, 'src', 'frontend', 'data.js'),
|
|
45
|
+
path.join(repoRoot, 'src', 'frontend', 'graph_data.json'),
|
|
46
|
+
];
|
|
47
|
+
const policyUtilsPath = path.join(repoRoot, 'scripts', 'lfs-asset-policy-utils.js');
|
|
48
|
+
let policyUtils;
|
|
49
|
+
function readJson(filePath) {
|
|
50
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
51
|
+
}
|
|
52
|
+
beforeAll(() => {
|
|
53
|
+
policyUtils = require(policyUtilsPath);
|
|
54
|
+
});
|
|
55
|
+
test('repository head no longer keeps removed LFS residues for dead node sidecar or bundled graph payloads', () => {
|
|
56
|
+
const gitattributes = fs.readFileSync(gitattributesPath, 'utf8');
|
|
57
|
+
expect(gitattributes).not.toContain('src-tauri/bin/node-x86_64-pc-windows-msvc.exe');
|
|
58
|
+
expect(gitattributes).not.toContain('src/frontend/data.js');
|
|
59
|
+
expect(gitattributes).not.toContain('src/frontend/graph_data.json');
|
|
60
|
+
expect(fs.existsSync(deadNodeSidecarPath)).toBe(false);
|
|
61
|
+
deadGraphPayloadPaths.forEach((filePath) => {
|
|
62
|
+
expect(fs.existsSync(filePath)).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
test('unexpected-only mode tolerates current legacy protected entries while keeping protected roots explicit', () => {
|
|
66
|
+
const result = policyUtils.evaluateLfsAssetPolicy({
|
|
67
|
+
gitattributesText: [
|
|
68
|
+
'src-tauri/bin/server-x86_64-pc-windows-msvc.exe filter=lfs diff=lfs merge=lfs -text',
|
|
69
|
+
'src-tauri/bin/server-x86_64-unknown-linux-gnu filter=lfs diff=lfs merge=lfs -text',
|
|
70
|
+
'src-tauri/bin/server-aarch64-apple-darwin filter=lfs diff=lfs merge=lfs -text',
|
|
71
|
+
'src-tauri/bin/godot-x86_64-pc-windows-msvc.exe filter=lfs diff=lfs merge=lfs -text',
|
|
72
|
+
'assets/demo-large.zip filter=lfs diff=lfs merge=lfs -text',
|
|
73
|
+
].join('\n'),
|
|
74
|
+
lfsLsFilesText: [
|
|
75
|
+
'bbbbbbbbbb - src-tauri/bin/server-x86_64-unknown-linux-gnu',
|
|
76
|
+
].join('\n'),
|
|
77
|
+
mode: 'unexpected-only',
|
|
78
|
+
});
|
|
79
|
+
expect(policyUtils.PROTECTED_LFS_ROOTS).toEqual(['src/frontend/', 'src-tauri/bin/']);
|
|
80
|
+
expect(result.unexpectedProtectedPaths).toEqual([]);
|
|
81
|
+
expect(result.legacyProtectedPaths).toEqual([
|
|
82
|
+
'src-tauri/bin/godot-x86_64-pc-windows-msvc.exe',
|
|
83
|
+
'src-tauri/bin/server-aarch64-apple-darwin',
|
|
84
|
+
'src-tauri/bin/server-x86_64-pc-windows-msvc.exe',
|
|
85
|
+
'src-tauri/bin/server-x86_64-unknown-linux-gnu',
|
|
86
|
+
]);
|
|
87
|
+
});
|
|
88
|
+
test('unexpected-only mode flags new protected LFS paths outside the approved legacy allowlist', () => {
|
|
89
|
+
const result = policyUtils.evaluateLfsAssetPolicy({
|
|
90
|
+
gitattributesText: [
|
|
91
|
+
'src-tauri/bin/new-helper.exe filter=lfs diff=lfs merge=lfs -text',
|
|
92
|
+
].join('\n'),
|
|
93
|
+
mode: 'unexpected-only',
|
|
94
|
+
});
|
|
95
|
+
expect(result.unexpectedProtectedPaths).toEqual(['src-tauri/bin/new-helper.exe']);
|
|
96
|
+
});
|
|
97
|
+
test('unexpected-only mode now treats bundled graph payload LFS paths as drift to be removed', () => {
|
|
98
|
+
const result = policyUtils.evaluateLfsAssetPolicy({
|
|
99
|
+
gitattributesText: [
|
|
100
|
+
'src/frontend/data.js filter=lfs diff=lfs merge=lfs -text',
|
|
101
|
+
'src/frontend/graph_data.json filter=lfs diff=lfs merge=lfs -text',
|
|
102
|
+
].join('\n'),
|
|
103
|
+
mode: 'unexpected-only',
|
|
104
|
+
});
|
|
105
|
+
expect(result.unexpectedProtectedPaths).toEqual([
|
|
106
|
+
'src/frontend/data.js',
|
|
107
|
+
'src/frontend/graph_data.json',
|
|
108
|
+
]);
|
|
109
|
+
});
|
|
110
|
+
test('deleted working-tree residues listed by git lfs ls-files are ignored once the rule and file are gone', () => {
|
|
111
|
+
const result = policyUtils.evaluateLfsAssetPolicy({
|
|
112
|
+
gitattributesText: '',
|
|
113
|
+
lfsLsFilesText: 'aaaaaaaaaa - src-tauri/bin/node-x86_64-pc-windows-msvc.exe',
|
|
114
|
+
existingRepoPaths: [],
|
|
115
|
+
mode: 'unexpected-only',
|
|
116
|
+
});
|
|
117
|
+
expect(result.protectedTrackedPaths).toEqual([]);
|
|
118
|
+
expect(result.unexpectedProtectedPaths).toEqual([]);
|
|
119
|
+
});
|
|
120
|
+
test('strict mode is ready for the future no-LFS end state', () => {
|
|
121
|
+
const result = policyUtils.evaluateLfsAssetPolicy({
|
|
122
|
+
gitattributesText: 'src/frontend/data.js filter=lfs diff=lfs merge=lfs -text',
|
|
123
|
+
mode: 'strict',
|
|
124
|
+
});
|
|
125
|
+
expect(result.strictViolations).toEqual(['src/frontend/data.js']);
|
|
126
|
+
});
|
|
127
|
+
test('package scripts expose local policy verification and future strict mode', () => {
|
|
128
|
+
const packageJson = readJson(packageJsonPath);
|
|
129
|
+
const scripts = packageJson.scripts || {};
|
|
130
|
+
expect(scripts['verify:lfs:policy']).toBe('node scripts/verify-lfs-asset-policy.js');
|
|
131
|
+
expect(scripts['verify:lfs:policy:strict']).toBe('node scripts/verify-lfs-asset-policy.js --strict');
|
|
132
|
+
});
|
|
133
|
+
test('legacy allowlist no longer preserves the unused node sidecar path', () => {
|
|
134
|
+
expect(policyUtils.LEGACY_ALLOWED_PROTECTED_LFS_PATHS).not.toContain('src-tauri/bin/node-x86_64-pc-windows-msvc.exe');
|
|
135
|
+
expect(policyUtils.LEGACY_ALLOWED_PROTECTED_LFS_PATHS).not.toContain('src/frontend/data.js');
|
|
136
|
+
expect(policyUtils.LEGACY_ALLOWED_PROTECTED_LFS_PATHS).not.toContain('src/frontend/graph_data.json');
|
|
137
|
+
});
|
|
138
|
+
test('current legacy LFS scope is limited to desktop binary placeholders rather than markdown-worker or bridge source', () => {
|
|
139
|
+
const gitattributes = fs.readFileSync(gitattributesPath, 'utf8');
|
|
140
|
+
const tracked = policyUtils.evaluateLfsAssetPolicy({
|
|
141
|
+
gitattributesText: gitattributes,
|
|
142
|
+
mode: 'unexpected-only',
|
|
143
|
+
});
|
|
144
|
+
expect(tracked.legacyProtectedPaths).toEqual([
|
|
145
|
+
'src-tauri/bin/godot-x86_64-pc-windows-msvc.exe',
|
|
146
|
+
'src-tauri/bin/server-aarch64-apple-darwin',
|
|
147
|
+
'src-tauri/bin/server-x86_64-pc-windows-msvc.exe',
|
|
148
|
+
'src-tauri/bin/server-x86_64-unknown-linux-gnu',
|
|
149
|
+
]);
|
|
150
|
+
expect(gitattributes).not.toContain('src-tauri/bin/markdown-worker');
|
|
151
|
+
expect(gitattributes).not.toContain('src/core/PathBridge.ts');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
const fs = __importStar(require("fs"));
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
function readJson(filePath) {
|
|
39
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
40
|
+
}
|
|
41
|
+
describe('license policy contract', () => {
|
|
42
|
+
const repoRoot = path.resolve(__dirname, '..');
|
|
43
|
+
const packageJsonPath = path.join(repoRoot, 'package.json');
|
|
44
|
+
const tauriCargoTomlPath = path.join(repoRoot, 'src-tauri', 'Cargo.toml');
|
|
45
|
+
const licensePath = path.join(repoRoot, 'LICENSE');
|
|
46
|
+
const readmePath = path.join(repoRoot, 'README.md');
|
|
47
|
+
const chineseReadmePath = path.join(repoRoot, 'README_zh.md');
|
|
48
|
+
test('root package manifest is pinned to GPL-3.0-only', () => {
|
|
49
|
+
const pkg = readJson(packageJsonPath);
|
|
50
|
+
expect(pkg.license).toBe('GPL-3.0-only');
|
|
51
|
+
});
|
|
52
|
+
test('tauri crate manifest is pinned to GPL-3.0-only', () => {
|
|
53
|
+
const cargoToml = fs.readFileSync(tauriCargoTomlPath, 'utf8');
|
|
54
|
+
expect(cargoToml).toContain('license = "GPL-3.0-only"');
|
|
55
|
+
});
|
|
56
|
+
test('repository license artifact ships GNU GPL v3 text', () => {
|
|
57
|
+
const license = fs.readFileSync(licensePath, 'utf8');
|
|
58
|
+
expect(license).toContain('GNU GENERAL PUBLIC LICENSE');
|
|
59
|
+
expect(license).toContain('Version 3, 29 June 2007');
|
|
60
|
+
});
|
|
61
|
+
test('README license sections advertise GPL-3.0-only in both locales', () => {
|
|
62
|
+
const readme = fs.readFileSync(readmePath, 'utf8');
|
|
63
|
+
const chineseReadme = fs.readFileSync(chineseReadmePath, 'utf8');
|
|
64
|
+
expect(readme).toContain('## License');
|
|
65
|
+
expect(readme).toContain('GNU General Public License v3.0');
|
|
66
|
+
expect(readme).toContain('GPL-3.0-only');
|
|
67
|
+
expect(chineseReadme).toContain('## 开源许可');
|
|
68
|
+
expect(chineseReadme).toContain('GNU General Public License v3.0');
|
|
69
|
+
expect(chineseReadme).toContain('GPL-3.0-only');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -697,6 +697,10 @@ class MarkdownGateway {
|
|
|
697
697
|
candidates.push(path.join(path.dirname(process.execPath), binaryName));
|
|
698
698
|
candidates.push(path.join(path.dirname(process.execPath), '..', 'Resources', binaryName));
|
|
699
699
|
}
|
|
700
|
+
// Tauri removes the target triple from installed external binary names.
|
|
701
|
+
const installedBinaryName = process.platform === 'win32' ? 'markdown-worker.exe' : 'markdown-worker';
|
|
702
|
+
candidates.push(path.join(path.dirname(process.execPath), installedBinaryName));
|
|
703
|
+
candidates.push(path.join(path.dirname(process.execPath), '..', 'Resources', installedBinaryName));
|
|
700
704
|
for (const candidate of candidates) {
|
|
701
705
|
try {
|
|
702
706
|
if (!candidate) {
|
|
@@ -37,6 +37,7 @@ const fs = __importStar(require("fs"));
|
|
|
37
37
|
const os = __importStar(require("os"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const MarkdownGateway_1 = require("./MarkdownGateway");
|
|
40
|
+
const { resolveHostMarkdownWorkerBinaryName } = require('../../scripts/tauri-sidecar-utils');
|
|
40
41
|
class TempDir {
|
|
41
42
|
constructor(prefix) {
|
|
42
43
|
this.path = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), `${prefix}-`));
|
|
@@ -192,4 +193,62 @@ describe('MarkdownGateway', () => {
|
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
195
|
});
|
|
196
|
+
const testUnix = process.platform === 'win32' ? test.skip : test;
|
|
197
|
+
testUnix.each(['beside-server', 'Resources', 'explicit-override', 'build-filename'])('buildIndex discovers the %s worker and preserves lookup priority', async (location) => {
|
|
198
|
+
const installedDirectory = ctx.temp.mkdir('installed/bin');
|
|
199
|
+
const originalExecPath = process.execPath;
|
|
200
|
+
const originalWorkerPath = process.env.NOTE_CONNECTION_MARKDOWN_WORKER_PATH;
|
|
201
|
+
const writeWorker = (workerPath, anchorId) => {
|
|
202
|
+
fs.mkdirSync(path.dirname(workerPath), { recursive: true });
|
|
203
|
+
fs.writeFileSync(workerPath, `#!/usr/bin/env node
|
|
204
|
+
const fs = require('fs');
|
|
205
|
+
let input = '';
|
|
206
|
+
process.stdin.on('data', chunk => { input += chunk; });
|
|
207
|
+
process.stdin.on('end', () => {
|
|
208
|
+
const request = JSON.parse(input);
|
|
209
|
+
if (request.kind !== 'build_index') process.exit(1);
|
|
210
|
+
const content = fs.readFileSync(request.filePath);
|
|
211
|
+
const block = { id: 0, type: 'heading', startByte: 0, endByte: content.length, startLine: 1, endLine: 1, anchorId: ${JSON.stringify(anchorId)} };
|
|
212
|
+
process.stdout.write(JSON.stringify({ ok: true, index: { totalBytes: content.length, totalLines: 1, blocks: [block], anchors: [], wikiLinks: [] } }));
|
|
213
|
+
});
|
|
214
|
+
`, { mode: 0o755 });
|
|
215
|
+
};
|
|
216
|
+
try {
|
|
217
|
+
process.execPath = path.join(installedDirectory, 'server');
|
|
218
|
+
delete process.env.NOTE_CONNECTION_MARKDOWN_WORKER_PATH;
|
|
219
|
+
const installedWorker = location === 'Resources'
|
|
220
|
+
? path.join(installedDirectory, '..', 'Resources', 'markdown-worker')
|
|
221
|
+
: path.join(installedDirectory, 'markdown-worker');
|
|
222
|
+
writeWorker(installedWorker, 'installed-worker');
|
|
223
|
+
if (location === 'explicit-override' || location === 'build-filename') {
|
|
224
|
+
writeWorker(path.join(ctx.projectRoot, 'src-tauri', 'bin', resolveHostMarkdownWorkerBinaryName()), 'build-worker');
|
|
225
|
+
}
|
|
226
|
+
if (location === 'explicit-override') {
|
|
227
|
+
const explicitWorker = path.join(ctx.temp.path, 'explicit-worker');
|
|
228
|
+
writeWorker(explicitWorker, 'explicit-worker');
|
|
229
|
+
process.env.NOTE_CONNECTION_MARKDOWN_WORKER_PATH = explicitWorker;
|
|
230
|
+
}
|
|
231
|
+
const filePath = ctx.temp.file(path.join('project', 'Knowledge_Base', 'installed.md'), '# Installed markdown worker');
|
|
232
|
+
const index = await ctx.gateway.buildIndex({ filePath }, {
|
|
233
|
+
markdownEngine: 'pulldown',
|
|
234
|
+
chunkBlockSize: 8,
|
|
235
|
+
prefetchBlocks: 2,
|
|
236
|
+
indexCacheTtlSec: 1800,
|
|
237
|
+
maxDocBytes: 32 * 1024 * 1024,
|
|
238
|
+
});
|
|
239
|
+
expect(index.engine).toBe('pulldown');
|
|
240
|
+
expect(index.fallbackReason).toBeUndefined();
|
|
241
|
+
const chunk = await ctx.gateway.getChunk({ indexId: index.indexId, startBlock: 0, blockCount: 1 });
|
|
242
|
+
const expectedAnchor = location === 'explicit-override' ? 'explicit-worker'
|
|
243
|
+
: location === 'build-filename' ? 'build-worker' : 'installed-worker';
|
|
244
|
+
expect(chunk.blocks[0].anchorId).toBe(expectedAnchor);
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
process.execPath = originalExecPath;
|
|
248
|
+
if (originalWorkerPath === undefined)
|
|
249
|
+
delete process.env.NOTE_CONNECTION_MARKDOWN_WORKER_PATH;
|
|
250
|
+
else
|
|
251
|
+
process.env.NOTE_CONNECTION_MARKDOWN_WORKER_PATH = originalWorkerPath;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
195
254
|
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeGovernedMemoryType = normalizeGovernedMemoryType;
|
|
4
|
+
exports.normalizeGovernedMemoryPurpose = normalizeGovernedMemoryPurpose;
|
|
5
|
+
exports.classifyMemoryEntry = classifyMemoryEntry;
|
|
6
|
+
exports.computeGovernedMemoryWeight = computeGovernedMemoryWeight;
|
|
7
|
+
exports.buildMemoryAuditRecord = buildMemoryAuditRecord;
|
|
8
|
+
function normalizeGovernedMemoryType(value) {
|
|
9
|
+
const normalized = String(value || '').trim().toLowerCase();
|
|
10
|
+
if (normalized === 'study' || normalized === 'note' || normalized === 'system') {
|
|
11
|
+
return normalized;
|
|
12
|
+
}
|
|
13
|
+
return 'fact';
|
|
14
|
+
}
|
|
15
|
+
function normalizeGovernedMemoryPurpose(value) {
|
|
16
|
+
const normalized = String(value || '').trim().toLowerCase();
|
|
17
|
+
if (normalized === 'internalized' || normalized === 'supplementary' || normalized === 'systemic') {
|
|
18
|
+
return normalized;
|
|
19
|
+
}
|
|
20
|
+
return 'memorized';
|
|
21
|
+
}
|
|
22
|
+
function classifyMemoryEntry(entry) {
|
|
23
|
+
const tags = Array.isArray(entry.tags) ? entry.tags.map((tag) => String(tag || '').trim().toLowerCase()) : [];
|
|
24
|
+
const rawText = `${entry.key} ${entry.value} ${tags.join(' ')}`.toLowerCase();
|
|
25
|
+
const memoryType = normalizeGovernedMemoryType(entry.memoryType
|
|
26
|
+
|| (tags.includes('study') || rawText.includes('quiz') || rawText.includes('review') ? 'study'
|
|
27
|
+
: tags.includes('note') || rawText.includes('note') ? 'note'
|
|
28
|
+
: tags.includes('system') ? 'system'
|
|
29
|
+
: 'fact'));
|
|
30
|
+
const memoryPurpose = normalizeGovernedMemoryPurpose(entry.memoryPurpose
|
|
31
|
+
|| (memoryType === 'study' ? 'internalized'
|
|
32
|
+
: memoryType === 'system' ? 'systemic'
|
|
33
|
+
: memoryType === 'note' ? 'supplementary'
|
|
34
|
+
: 'memorized'));
|
|
35
|
+
return {
|
|
36
|
+
memoryType,
|
|
37
|
+
memoryPurpose,
|
|
38
|
+
classificationConfidence: Math.max(0.45, Math.min(0.98, Number(entry.confidence || 0.72))),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function computeGovernedMemoryWeight(entry) {
|
|
42
|
+
const { memoryType, memoryPurpose } = classifyMemoryEntry(entry);
|
|
43
|
+
const typeWeight = memoryType === 'study'
|
|
44
|
+
? 1.25
|
|
45
|
+
: memoryType === 'note'
|
|
46
|
+
? 1.1
|
|
47
|
+
: memoryType === 'system'
|
|
48
|
+
? 0.7
|
|
49
|
+
: 1;
|
|
50
|
+
const purposeWeight = memoryPurpose === 'internalized'
|
|
51
|
+
? 1.35
|
|
52
|
+
: memoryPurpose === 'supplementary'
|
|
53
|
+
? 0.92
|
|
54
|
+
: memoryPurpose === 'systemic'
|
|
55
|
+
? 0.75
|
|
56
|
+
: 1;
|
|
57
|
+
return Number((typeWeight * purposeWeight).toFixed(4));
|
|
58
|
+
}
|
|
59
|
+
function buildMemoryAuditRecord(nextId, params) {
|
|
60
|
+
const classification = classifyMemoryEntry(params.entry);
|
|
61
|
+
return {
|
|
62
|
+
auditId: nextId('memory_audit'),
|
|
63
|
+
userId: params.userId,
|
|
64
|
+
operation: params.operation,
|
|
65
|
+
layer: params.layer,
|
|
66
|
+
memoryKey: params.entry.key,
|
|
67
|
+
memoryType: classification.memoryType,
|
|
68
|
+
memoryPurpose: classification.memoryPurpose,
|
|
69
|
+
reason: params.reason,
|
|
70
|
+
scopeWorkspaceId: params.scopeWorkspaceId || null,
|
|
71
|
+
scopeCorpusId: params.scopeCorpusId || null,
|
|
72
|
+
recordedAt: params.recordedAt,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const MemoryGovernance_1 = require("./MemoryGovernance");
|
|
4
|
+
describe('MemoryGovernance', () => {
|
|
5
|
+
test('classifies study memories and raises their retrieval weight', () => {
|
|
6
|
+
const entry = {
|
|
7
|
+
key: 'quiz_note',
|
|
8
|
+
value: 'Review this quiz correction before the next session.',
|
|
9
|
+
tags: ['study', 'review'],
|
|
10
|
+
confidence: 0.84,
|
|
11
|
+
references: ['atom_1'],
|
|
12
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
13
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
14
|
+
};
|
|
15
|
+
const classification = (0, MemoryGovernance_1.classifyMemoryEntry)(entry);
|
|
16
|
+
expect(classification.memoryType).toBe('study');
|
|
17
|
+
expect(classification.memoryPurpose).toBe('internalized');
|
|
18
|
+
expect((0, MemoryGovernance_1.computeGovernedMemoryWeight)(entry)).toBeGreaterThan(1);
|
|
19
|
+
});
|
|
20
|
+
test('builds audit records with explicit scope fields', () => {
|
|
21
|
+
const entry = {
|
|
22
|
+
key: 'memory_1',
|
|
23
|
+
value: 'Scoped note',
|
|
24
|
+
tags: ['note'],
|
|
25
|
+
confidence: 0.7,
|
|
26
|
+
references: [],
|
|
27
|
+
scopeWorkspaceId: 'optics',
|
|
28
|
+
scopeCorpusId: 'optics',
|
|
29
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
30
|
+
updatedAt: '2026-05-26T00:00:00.000Z',
|
|
31
|
+
};
|
|
32
|
+
const audit = (0, MemoryGovernance_1.buildMemoryAuditRecord)((prefix = 'memory_audit') => `${prefix}_1`, {
|
|
33
|
+
userId: 'user_a',
|
|
34
|
+
operation: 'write',
|
|
35
|
+
layer: 'session',
|
|
36
|
+
entry,
|
|
37
|
+
reason: 'test',
|
|
38
|
+
scopeWorkspaceId: 'optics',
|
|
39
|
+
scopeCorpusId: 'optics',
|
|
40
|
+
recordedAt: '2026-05-26T00:01:00.000Z',
|
|
41
|
+
});
|
|
42
|
+
expect(audit.scopeWorkspaceId).toBe('optics');
|
|
43
|
+
expect(audit.scopeCorpusId).toBe('optics');
|
|
44
|
+
expect(audit.memoryKey).toBe('memory_1');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
const fs = __importStar(require("fs"));
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
describe('mermaid frontend guard contract', () => {
|
|
39
|
+
const repoRoot = path.resolve(__dirname, '..');
|
|
40
|
+
const appPath = path.join(repoRoot, 'src', 'frontend', 'app.js');
|
|
41
|
+
const readerPath = path.join(repoRoot, 'src', 'frontend', 'reader.js');
|
|
42
|
+
const stylesPath = path.join(repoRoot, 'src', 'frontend', 'styles.css');
|
|
43
|
+
test('installs a global Mermaid artifact suppression observer for leaked error SVGs', () => {
|
|
44
|
+
const source = fs.readFileSync(appPath, 'utf8');
|
|
45
|
+
expect(source).toContain('function suppressMermaidErrorArtifacts(root, context = {})');
|
|
46
|
+
expect(source).toContain('function installMermaidErrorArtifactObserver()');
|
|
47
|
+
expect(source).toContain('function installMermaidRuntimeGuards()');
|
|
48
|
+
expect(source).toContain('function exposeMermaidDebugInterface()');
|
|
49
|
+
expect(source).toContain('installMermaidErrorArtifactObserver();');
|
|
50
|
+
expect(source).toContain("normalized.includes('syntax error in text')");
|
|
51
|
+
expect(source).toContain("normalized.includes('mermaid version')");
|
|
52
|
+
expect(source).toContain('captureRuntimeState: () => ({');
|
|
53
|
+
expect(source).toContain('function isProtectedMermaidSuppressionHost(host)');
|
|
54
|
+
expect(source).toContain('root !== document.body');
|
|
55
|
+
expect(source).toContain("host.id === 'reading-body'");
|
|
56
|
+
});
|
|
57
|
+
test('reader mermaid suppression never selects the page root as a removable host', () => {
|
|
58
|
+
const source = fs.readFileSync(readerPath, 'utf8');
|
|
59
|
+
expect(source).toContain('isProtectedMermaidSuppressionHost(host)');
|
|
60
|
+
expect(source).toContain('root !== document.body');
|
|
61
|
+
expect(source).toContain("host.id === 'graph-wrapper'");
|
|
62
|
+
expect(source).toContain('Reader Mermaid offscreen host mount root is unavailable.');
|
|
63
|
+
expect(source).toContain('ensureReaderStructure()');
|
|
64
|
+
expect(source).toContain("replacementBody.id = 'reading-body'");
|
|
65
|
+
expect(source).toContain('this.contentBox.appendChild(replacementBody);');
|
|
66
|
+
expect(source).toContain('lookupNodeDataById(nodeId)');
|
|
67
|
+
expect(source).toContain("typeof graphData !== 'undefined'");
|
|
68
|
+
expect(source).toContain('isReaderBodyVisiblyEmpty()');
|
|
69
|
+
expect(source).toContain('Markdown protocol path completed without visible content. Falling back to raw markdown render.');
|
|
70
|
+
});
|
|
71
|
+
test('ships compact inline and toast styles for suppressed Mermaid errors', () => {
|
|
72
|
+
const source = fs.readFileSync(stylesPath, 'utf8');
|
|
73
|
+
expect(source).toContain('.mermaid-inline-guard');
|
|
74
|
+
expect(source).toContain('.mermaid-error-toast-stack');
|
|
75
|
+
expect(source).toContain('.mermaid-error-toast');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SseResponseWriter = void 0;
|
|
4
|
+
/** Owns backpressure and the single terminal outcome of one HTTP event stream. */
|
|
5
|
+
class SseResponseWriter {
|
|
6
|
+
constructor(destination, policy = {
|
|
7
|
+
maxBufferedBytes: 64 * 1024 * 1024 + 256 * 1024,
|
|
8
|
+
drainTimeoutMs: 15000,
|
|
9
|
+
}) {
|
|
10
|
+
this.destination = destination;
|
|
11
|
+
this.policy = policy;
|
|
12
|
+
this.pending = [];
|
|
13
|
+
this.queuedBytes = 0;
|
|
14
|
+
this.blocked = false;
|
|
15
|
+
this.finishing = false;
|
|
16
|
+
this.finished = false;
|
|
17
|
+
this.onDrain = () => {
|
|
18
|
+
clearTimeout(this.timer);
|
|
19
|
+
this.timer = undefined;
|
|
20
|
+
this.blocked = false;
|
|
21
|
+
try {
|
|
22
|
+
while (this.pending.length && !this.blocked && !this.failure) {
|
|
23
|
+
const frame = this.pending.shift();
|
|
24
|
+
this.queuedBytes -= Buffer.byteLength(frame);
|
|
25
|
+
this.send(frame);
|
|
26
|
+
}
|
|
27
|
+
if (this.finishing && !this.blocked && !this.failure)
|
|
28
|
+
this.destination.end();
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
this.fail(error instanceof Error ? error : new Error(String(error)));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
this.onError = (error) => { this.fail(error); };
|
|
35
|
+
this.onClose = () => {
|
|
36
|
+
if (!this.finished)
|
|
37
|
+
this.fail(new Error('sse_closed'));
|
|
38
|
+
this.cleanup();
|
|
39
|
+
};
|
|
40
|
+
this.onFinish = () => {
|
|
41
|
+
if (this.failure)
|
|
42
|
+
return;
|
|
43
|
+
this.finished = true;
|
|
44
|
+
this.cleanup();
|
|
45
|
+
this.resolveCompletion?.();
|
|
46
|
+
};
|
|
47
|
+
if (!Number.isFinite(policy.maxBufferedBytes) || policy.maxBufferedBytes < 1
|
|
48
|
+
|| !Number.isFinite(policy.drainTimeoutMs) || policy.drainTimeoutMs < 1)
|
|
49
|
+
throw new TypeError('Invalid SSE delivery policy');
|
|
50
|
+
destination.on('drain', this.onDrain);
|
|
51
|
+
destination.on('error', this.onError);
|
|
52
|
+
destination.once('close', this.onClose);
|
|
53
|
+
destination.once('finish', this.onFinish);
|
|
54
|
+
}
|
|
55
|
+
get pendingBytes() { return this.failure || this.finished ? 0 : this.queuedBytes + this.destination.writableLength; }
|
|
56
|
+
write(frame) {
|
|
57
|
+
if (this.failure)
|
|
58
|
+
throw this.failure;
|
|
59
|
+
if (this.finishing || this.finished || this.destination.destroyed || this.destination.writableEnded)
|
|
60
|
+
throw new Error('sse_closed');
|
|
61
|
+
const bytes = Buffer.byteLength(frame);
|
|
62
|
+
if (this.pending.length >= 128 || this.pendingBytes + bytes > this.policy.maxBufferedBytes) {
|
|
63
|
+
this.fail(new Error('sse_buffer_limit'));
|
|
64
|
+
throw this.failure;
|
|
65
|
+
}
|
|
66
|
+
if (this.blocked) {
|
|
67
|
+
this.pending.push(frame);
|
|
68
|
+
this.queuedBytes += bytes;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.send(frame);
|
|
72
|
+
}
|
|
73
|
+
finish() {
|
|
74
|
+
if (this.failure)
|
|
75
|
+
return Promise.reject(this.failure);
|
|
76
|
+
if (this.finished)
|
|
77
|
+
return Promise.resolve();
|
|
78
|
+
if (this.completion)
|
|
79
|
+
return this.completion;
|
|
80
|
+
this.finishing = true;
|
|
81
|
+
this.completion = new Promise((resolve, reject) => {
|
|
82
|
+
this.resolveCompletion = resolve;
|
|
83
|
+
this.rejectCompletion = reject;
|
|
84
|
+
});
|
|
85
|
+
if (!this.blocked && this.pending.length === 0)
|
|
86
|
+
this.destination.end();
|
|
87
|
+
return this.completion;
|
|
88
|
+
}
|
|
89
|
+
send(frame) {
|
|
90
|
+
try {
|
|
91
|
+
if (!this.destination.write(frame)) {
|
|
92
|
+
this.blocked = true;
|
|
93
|
+
this.timer = setTimeout(() => this.fail(new Error('sse_drain_timeout')), this.policy.drainTimeoutMs);
|
|
94
|
+
this.timer.unref();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
this.fail(error instanceof Error ? error : new Error(String(error)));
|
|
99
|
+
throw this.failure;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
fail(error) {
|
|
103
|
+
if (this.failure || this.finished)
|
|
104
|
+
return;
|
|
105
|
+
this.failure = error;
|
|
106
|
+
this.pending.length = 0;
|
|
107
|
+
this.queuedBytes = 0;
|
|
108
|
+
clearTimeout(this.timer);
|
|
109
|
+
this.destination.removeListener('drain', this.onDrain);
|
|
110
|
+
this.rejectCompletion?.(error);
|
|
111
|
+
// Preserve the error for finish(); destroy without an unhandled second error event.
|
|
112
|
+
this.destination.destroy();
|
|
113
|
+
}
|
|
114
|
+
cleanup() {
|
|
115
|
+
clearTimeout(this.timer);
|
|
116
|
+
this.destination.removeListener('drain', this.onDrain);
|
|
117
|
+
this.destination.removeListener('error', this.onError);
|
|
118
|
+
this.destination.removeListener('close', this.onClose);
|
|
119
|
+
this.destination.removeListener('finish', this.onFinish);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.SseResponseWriter = SseResponseWriter;
|