noteconnection 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/LICENSE +674 -21
  2. package/README.md +242 -62
  3. package/dist/src/agent_workspace.contract.parity.test.js +475 -0
  4. package/dist/src/agent_workspace.frontend.test.js +9989 -0
  5. package/dist/src/agent_workspace.locale.contract.test.js +95 -0
  6. package/dist/src/agent_workspace.runtime.behavior.test.js +5072 -0
  7. package/dist/src/copy.assets.contract.test.js +130 -0
  8. package/dist/src/core/PathBridge.js +28 -3
  9. package/dist/src/export/WorkspaceExportBundle.js +1130 -0
  10. package/dist/src/export/WorkspaceExportBundle.test.js +1480 -0
  11. package/dist/src/export/index.js +18 -0
  12. package/dist/src/export/types.js +2 -0
  13. package/dist/src/fixrisk.issue.verifier.contract.test.js +3 -1
  14. package/dist/src/foundation.ann.runtime.contract.test.js +81 -0
  15. package/dist/src/foundation.release.evidence.contract.test.js +406 -0
  16. package/dist/src/foundation.sqlite.runtime.contract.test.js +82 -0
  17. package/dist/src/frontend/README.md +242 -62
  18. package/dist/src/frontend/agent_workspace.js +5353 -0
  19. package/dist/src/frontend/agent_workspace_runtime.js +4434 -0
  20. package/dist/src/frontend/analysis.js +31 -4
  21. package/dist/src/frontend/app.js +2178 -62
  22. package/dist/src/frontend/focus_mode_interactions.js +33 -0
  23. package/dist/src/frontend/godot_future_path_renderer.js +540 -0
  24. package/dist/src/frontend/godot_tree_interactions.js +178 -0
  25. package/dist/src/frontend/graph_state.mjs +105 -0
  26. package/dist/src/frontend/hosted_future_path_runtime.js +157 -0
  27. package/dist/src/frontend/i18n.mjs +186 -0
  28. package/dist/src/frontend/index.html +641 -266
  29. package/dist/src/frontend/layout_gpu.js +12 -4
  30. package/dist/src/frontend/locales/en.json +721 -5
  31. package/dist/src/frontend/locales/zh.json +721 -5
  32. package/dist/src/frontend/main.mjs +60 -0
  33. package/dist/src/frontend/markdown_runtime.js +827 -0
  34. package/dist/src/frontend/notemd.css +49 -0
  35. package/dist/src/frontend/notemd.html +7 -1
  36. package/dist/src/frontend/notemd.js +64 -0
  37. package/dist/src/frontend/path.html +107 -0
  38. package/dist/src/frontend/path_app.js +2108 -130
  39. package/dist/src/frontend/path_layout.mjs +143 -0
  40. package/dist/src/frontend/path_mermaid_utils.mjs +108 -0
  41. package/dist/src/frontend/path_modules_bridge.js +486 -0
  42. package/dist/src/frontend/path_state.mjs +118 -0
  43. package/dist/src/frontend/path_styles.css +146 -0
  44. package/dist/src/frontend/path_worker_bridge.mjs +85 -0
  45. package/dist/src/frontend/reader.js +393 -33
  46. package/dist/src/frontend/runtime_bridge.js +67 -54
  47. package/dist/src/frontend/runtime_bridge.mjs +279 -0
  48. package/dist/src/frontend/settings.js +130 -12
  49. package/dist/src/frontend/source_manager.js +190 -21
  50. package/dist/src/frontend/styles.css +2720 -72
  51. package/dist/src/frontend/workbench_state.mjs +101 -0
  52. package/dist/src/frontend/workspace_panes.js +10168 -0
  53. package/dist/src/frontend.locale.contract.test.js +62 -0
  54. package/dist/src/godot.sidecar.bootstrap.contract.test.js +244 -0
  55. package/dist/src/indexing/IndexLifecycle.js +195 -0
  56. package/dist/src/indexing/IndexLifecycle.test.js +49 -0
  57. package/dist/src/indexing/SegmentBuilder.js +64 -0
  58. package/dist/src/indexing/UnitBuilder.js +48 -0
  59. package/dist/src/indexing/types.js +2 -0
  60. package/dist/src/knowledge.api.contract.test.js +170 -0
  61. package/dist/src/learning/KnowledgeLearningPlatform.js +10386 -0
  62. package/dist/src/learning/KnowledgeLearningPlatform.persistence.test.js +327 -0
  63. package/dist/src/learning/KnowledgeLearningPlatform.program-f.test.js +99 -0
  64. package/dist/src/learning/KnowledgeLearningPlatform.test.js +2971 -0
  65. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.js +2974 -0
  66. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.test.js +3928 -0
  67. package/dist/src/learning/answerReleaseReview.js +4319 -0
  68. package/dist/src/learning/answerReleaseReview.test.js +2888 -0
  69. package/dist/src/learning/api.js +2 -0
  70. package/dist/src/learning/conversationComposer.js +1480 -0
  71. package/dist/src/learning/conversationComposer.test.js +1817 -0
  72. package/dist/src/learning/domains/ConversationManager.js +53 -0
  73. package/dist/src/learning/domains/KnowledgeIngestor.js +238 -0
  74. package/dist/src/learning/domains/KnowledgeQuerier.js +187 -0
  75. package/dist/src/learning/domains/MasteryEngine.js +387 -0
  76. package/dist/src/learning/domains/MemoryPolicyManager.js +408 -0
  77. package/dist/src/learning/domains/QualityEvaluator.js +307 -0
  78. package/dist/src/learning/domains/TutorRouter.js +313 -0
  79. package/dist/src/learning/domains/index.js +33 -0
  80. package/dist/src/learning/domains/types.js +7 -0
  81. package/dist/src/learning/errors.js +29 -0
  82. package/dist/src/learning/evidenceContextAssembler.js +1176 -0
  83. package/dist/src/learning/evidenceContextAssembler.test.js +6332 -0
  84. package/dist/src/learning/graphContextAssembler.js +870 -0
  85. package/dist/src/learning/graphContextAssembler.test.js +1033 -0
  86. package/dist/src/learning/index.js +28 -0
  87. package/dist/src/learning/queryBackend.js +1898 -0
  88. package/dist/src/learning/queryBackend.test.js +955 -0
  89. package/dist/src/learning/ragContextPack.js +257 -0
  90. package/dist/src/learning/ragContextPack.test.js +160 -0
  91. package/dist/src/learning/ragPublicText.js +38 -0
  92. package/dist/src/learning/ragSufficiencyJudge.js +161 -0
  93. package/dist/src/learning/ragSufficiencyJudge.test.js +177 -0
  94. package/dist/src/learning/ragSufficiencyProviderJudge.js +227 -0
  95. package/dist/src/learning/ragSufficiencyProviderJudge.test.js +156 -0
  96. package/dist/src/learning/requestNormalization.js +198 -0
  97. package/dist/src/learning/runtimeCapability.js +4677 -0
  98. package/dist/src/learning/runtimeCapability.test.js +3635 -0
  99. package/dist/src/learning/store.js +1240 -0
  100. package/dist/src/learning/store.test.js +1126 -0
  101. package/dist/src/learning/tutorAdapter.js +2 -0
  102. package/dist/src/learning/types.js +2 -0
  103. package/dist/src/learning/vectorAccelerationAdapter.js +942 -0
  104. package/dist/src/learning/vectorAccelerationAdapter.test.js +382 -0
  105. package/dist/src/lfs.asset.policy.contract.test.js +153 -0
  106. package/dist/src/license.policy.contract.test.js +66 -0
  107. package/dist/src/memory/MemoryGovernance.js +74 -0
  108. package/dist/src/memory/MemoryGovernance.test.js +46 -0
  109. package/dist/src/memory/types.js +2 -0
  110. package/dist/src/mermaid.frontend.guard.contract.test.js +77 -0
  111. package/dist/src/middleware/auth.js +17 -0
  112. package/dist/src/middleware/body-parser.js +45 -0
  113. package/dist/src/middleware/cors.js +44 -0
  114. package/dist/src/middleware/index.js +21 -0
  115. package/dist/src/middleware/request-trace.js +96 -0
  116. package/dist/src/notemd/AppConfigToml.js +6 -4
  117. package/dist/src/notemd/MermaidProcessor.js +400 -50
  118. package/dist/src/notemd/NotemdService.js +498 -13
  119. package/dist/src/notemd/PromptManager.js +15 -0
  120. package/dist/src/notemd/cli/commands.js +357 -0
  121. package/dist/src/notemd/cli/dispatcher.js +225 -0
  122. package/dist/src/notemd/cli/index.js +169 -0
  123. package/dist/src/notemd/cli/parser.js +68 -0
  124. package/dist/src/notemd/cli/types.js +2 -0
  125. package/dist/src/notemd/constants.js +43 -0
  126. package/dist/src/notemd/diagram/diagramGenerationService.js +78 -0
  127. package/dist/src/notemd/diagram/diagramSpec.js +79 -0
  128. package/dist/src/notemd/diagram/diagramSpecResponseParser.js +131 -0
  129. package/dist/src/notemd/diagram/intent.js +95 -0
  130. package/dist/src/notemd/diagram/planner.js +71 -0
  131. package/dist/src/notemd/diagram/prompts/diagramSpecPrompt.js +42 -0
  132. package/dist/src/notemd/diagram/types.js +18 -0
  133. package/dist/src/notemd/index.js +26 -0
  134. package/dist/src/notemd/operations/capabilityManifest.js +23 -0
  135. package/dist/src/notemd/operations/cliContracts.js +17 -0
  136. package/dist/src/notemd/operations/configProfileCommands.js +85 -0
  137. package/dist/src/notemd/operations/registry.contract.test.js +95 -0
  138. package/dist/src/notemd/operations/registry.js +991 -0
  139. package/dist/src/notemd/operations/types.js +2 -0
  140. package/dist/src/notemd/providerDiagnostics.js +220 -0
  141. package/dist/src/notemd/providerProfiles.js +42 -0
  142. package/dist/src/notemd/providerTemplates.js +231 -0
  143. package/dist/src/notemd/search/DuckDuckGoProvider.js +39 -0
  144. package/dist/src/notemd/search/SearchManager.js +13 -0
  145. package/dist/src/notemd/search/SearchProvider.js +2 -0
  146. package/dist/src/notemd/search/TavilyProvider.js +44 -0
  147. package/dist/src/notemd.agent.manifest.test.js +85 -0
  148. package/dist/src/notemd.api.contract.test.js +14 -1
  149. package/dist/src/notemd.app_config_toml.test.js +2 -1
  150. package/dist/src/notemd.batch.workflow.test.js +117 -0
  151. package/dist/src/notemd.cli.e2e.test.js +136 -0
  152. package/dist/src/notemd.core.test.js +51 -0
  153. package/dist/src/notemd.diagram.pipeline.test.js +233 -0
  154. package/dist/src/notemd.providerTemplates.test.js +34 -0
  155. package/dist/src/notemd.server.integration.test.js +143 -35
  156. package/dist/src/notemd.workflow.pipeline.test.js +162 -0
  157. package/dist/src/pathbridge.handshake.contract.test.js +16 -2
  158. package/dist/src/pathmode.background.contract.test.js +69 -0
  159. package/dist/src/pathmode.settings.api.contract.test.js +9 -0
  160. package/dist/src/pkg.sidecar.contract.test.js +9 -3
  161. package/dist/src/platform/ExportProfile.js +58 -0
  162. package/dist/src/platform/PlatformCapabilities.js +45 -0
  163. package/dist/src/platform/PlatformCapabilities.test.js +30 -0
  164. package/dist/src/platform/RenderMaterializer.js +33 -0
  165. package/dist/src/platform/RenderMaterializer.test.js +32 -0
  166. package/dist/src/query_backend.external_http.integration.test.js +410 -0
  167. package/dist/src/reader_renderer.js +404 -3
  168. package/dist/src/reader_renderer.test.js +87 -0
  169. package/dist/src/release.godot.mirror.contract.test.js +73 -0
  170. package/dist/src/resources/ResourceRegistry.js +223 -0
  171. package/dist/src/resources/ResourceRegistry.test.js +61 -0
  172. package/dist/src/resources/types.js +2 -0
  173. package/dist/src/routes/agentWorkspaceDiagnostics.js +173 -0
  174. package/dist/src/routes/data.js +267 -0
  175. package/dist/src/routes/diagnostics.js +51 -0
  176. package/dist/src/routes/index.js +23 -0
  177. package/dist/src/routes/knowledge.js +968 -0
  178. package/dist/src/routes/markdown.js +287 -0
  179. package/dist/src/routes/notemd.js +565 -0
  180. package/dist/src/routes/registry.contract.test.js +130 -0
  181. package/dist/src/routes/render.js +285 -0
  182. package/dist/src/routes/runtimeRunbookRouteOps.js +149 -0
  183. package/dist/src/routes/runtimeRunbookRouteOps.test.js +194 -0
  184. package/dist/src/routes/settings.js +6 -0
  185. package/dist/src/routes/staticFiles.js +94 -0
  186. package/dist/src/routes/types.js +2 -0
  187. package/dist/src/runtime.transport.adapter.contract.test.js +81 -0
  188. package/dist/src/server.js +11090 -1549
  189. package/dist/src/server.migration.test.js +193 -21
  190. package/dist/src/server.port.fallback.contract.test.js +63 -0
  191. package/dist/src/session/SessionStateStore.js +81 -0
  192. package/dist/src/session/SessionStateStore.test.js +58 -0
  193. package/dist/src/session/types.js +2 -0
  194. package/dist/src/settings.runtime.contract.test.js +50 -0
  195. package/dist/src/shared/types.contract.test.js +107 -0
  196. package/dist/src/shared/types.js +22 -0
  197. package/dist/src/sidecar.replacement.boundary.contract.test.js +128 -0
  198. package/dist/src/sidecar.supply.readiness.contract.test.js +144 -0
  199. package/dist/src/source_manager.loadflow.test.js +46 -0
  200. package/dist/src/startup.layout.snapshot.contract.test.js +57 -0
  201. package/dist/src/tauri.frontend.build.contract.test.js +60 -0
  202. package/dist/src/tauri.sidecar.cleanup.contract.test.js +21 -0
  203. package/dist/src/utils/RuntimePaths.js +4 -13
  204. package/dist/src/utils/platform.js +153 -0
  205. package/dist/src/workflows/WorkflowArtifactStore.js +96 -0
  206. package/dist/src/workflows/WorkflowArtifactStore.test.js +80 -0
  207. package/dist/src/workflows/types.js +2 -0
  208. package/dist/src/workspace/WorkspaceRegistry.js +122 -0
  209. package/dist/src/workspace/WorkspaceRegistry.test.js +29 -0
  210. package/dist/src/workspace/types.js +2 -0
  211. package/package.json +53 -10
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./WorkspaceExportBundle"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -57,8 +57,10 @@ describe('fixrisk issue verifier contract', () => {
57
57
  expect(script).toContain("'FR-013'");
58
58
  expect(script).toContain("'FR-014'");
59
59
  expect(script).toContain("'FR-015'");
60
- expect(script).toContain('actions/setup-java@v5');
60
+ expect(script).toContain('actions/setup-java@v4');
61
61
  expect(script).toContain('java-version');
62
+ expect(script).toContain('setup-node pins Node 24 baseline');
63
+ expect(script).toContain('no FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 transition override');
62
64
  expect(script).toContain('verify-capacitor-evidence-freshness.js');
63
65
  expect(script).toContain('NOTE_CONNECTION_REQUIRE_LARGE_GRAPH_EVIDENCE');
64
66
  expect(script).toContain('NOTE_CONNECTION_MIN_EVIDENCE_NODE_COUNT');
@@ -0,0 +1,81 @@
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('foundation ann runtime verification contract', () => {
39
+ const repoRoot = path.resolve(__dirname, '..');
40
+ const packageJsonPath = path.join(repoRoot, 'package.json');
41
+ const scriptPath = path.join(repoRoot, 'scripts', 'verify-foundation-ann-runtime.js');
42
+ function readJson(filePath) {
43
+ const raw = fs.readFileSync(filePath, 'utf8');
44
+ return JSON.parse(raw);
45
+ }
46
+ test('keeps the host-level ann runtime verifier wired in package scripts', () => {
47
+ const packageJson = readJson(packageJsonPath);
48
+ expect(packageJson.scripts?.['verify:foundation:ann-runtime']).toBe('npm run build && node scripts/ensure-sidecar-ready.js && node scripts/verify-foundation-ann-runtime.js');
49
+ expect(packageJson.scripts?.['verify:foundation:ann-runtime:matrix']).toBe('npm run build && node scripts/ensure-sidecar-ready.js && node scripts/verify-foundation-ann-runtime.js --matrix');
50
+ expect(packageJson.scripts?.['verify:foundation:ann-runtime:release']).toBe('npm run build && node scripts/ensure-sidecar-ready.js && node scripts/verify-foundation-ann-runtime.js --matrix --release-gates');
51
+ });
52
+ test('verifier script covers smoke/medium/heavy ann profiles, report evidence, release gates, and restart continuity', () => {
53
+ const source = fs.readFileSync(scriptPath, 'utf8');
54
+ expect(source).toContain('WORKLOAD_PROFILES');
55
+ expect(source).toContain("profileId: 'medium'");
56
+ expect(source).toContain("profileId: 'heavy'");
57
+ expect(source).toContain("options.suiteKind = 'matrix'");
58
+ expect(source).toContain("arg === '--release-gates'");
59
+ expect(source).toContain('startReferenceAnnService');
60
+ expect(source).toContain('/sync-index');
61
+ expect(source).toContain('/select-candidates');
62
+ expect(source).toContain('dist_node_runtime');
63
+ expect(source).toContain('packaged_sidecar');
64
+ expect(source).toContain('/api/knowledge/ingest');
65
+ expect(source).toContain('/api/knowledge/query');
66
+ expect(source).toContain('/api/knowledge/query-backend-diagnostics');
67
+ expect(source).toContain("configuredBackend || '') === 'local_vector'");
68
+ expect(source).toContain("String(runtime.backendId || '') === 'local-vector-v1'");
69
+ expect(source).toContain("String(acceleration.mode || '') === 'ann_prefilter'");
70
+ expect(source).toContain("String(acceleration.adapterId || '') === 'external-http-vector-acceleration-v1'");
71
+ expect(source).toContain("String(acceleration.representationStatus || '') === 'aligned'");
72
+ expect(source).toContain('anchorkey');
73
+ expect(source).toContain('foundation-ann-runtime-report-latest.json');
74
+ expect(source).toContain('writeStructuredReport');
75
+ expect(source).toContain('collectScenarioPerformance');
76
+ expect(source).toContain('buildReleaseGateSummary');
77
+ expect(source).toContain('minExpectedRecall');
78
+ expect(source).toContain('maxQueryP95Ms');
79
+ expect(source).toContain('queryDurationMs');
80
+ });
81
+ });
@@ -0,0 +1,406 @@
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 os = __importStar(require("os"));
38
+ const path = __importStar(require("path"));
39
+ describe('foundation release evidence freshness contract', () => {
40
+ const repoRoot = path.resolve(__dirname, '..');
41
+ const packageJsonPath = path.join(repoRoot, 'package.json');
42
+ const scriptPath = path.join(repoRoot, 'scripts', 'verify-foundation-release-evidence.js');
43
+ function readJson(filePath) {
44
+ const raw = fs.readFileSync(filePath, 'utf8');
45
+ return JSON.parse(raw);
46
+ }
47
+ function createTempReportRoot() {
48
+ return fs.mkdtempSync(path.join(os.tmpdir(), 'noteconnection-foundation-release-evidence-'));
49
+ }
50
+ function writeJson(filePath, value) {
51
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
52
+ fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
53
+ }
54
+ function buildPassingSqliteReport(verifiedAt, host = { platform: 'win32', arch: 'x64', evidenceHostId: 'windows-ci-a' }) {
55
+ return {
56
+ verifiedAt,
57
+ host,
58
+ suiteKind: 'soak',
59
+ soakCycles: 5,
60
+ profileRuns: [
61
+ {
62
+ workloadProfile: {
63
+ profileId: 'heavy',
64
+ documentCount: 180,
65
+ },
66
+ modes: [
67
+ {
68
+ mode: 'dist_node_runtime',
69
+ suiteKind: 'soak',
70
+ profileId: 'heavy',
71
+ restartCycleCount: 5,
72
+ performance: {
73
+ queryDurationMs: { count: 8, p95Ms: 120 },
74
+ },
75
+ soak: {
76
+ pass: true,
77
+ gates: [
78
+ { gateId: 'startup_p95', passed: true },
79
+ { gateId: 'query_p95', passed: true },
80
+ ],
81
+ },
82
+ },
83
+ {
84
+ mode: 'packaged_sidecar',
85
+ suiteKind: 'soak',
86
+ profileId: 'heavy',
87
+ restartCycleCount: 5,
88
+ performance: {
89
+ queryDurationMs: { count: 8, p95Ms: 180 },
90
+ },
91
+ soak: {
92
+ pass: true,
93
+ gates: [
94
+ { gateId: 'startup_p95', passed: true },
95
+ { gateId: 'query_p95', passed: true },
96
+ ],
97
+ },
98
+ },
99
+ ],
100
+ },
101
+ ],
102
+ };
103
+ }
104
+ function buildPassingAnnReport(verifiedAt, host = { platform: 'win32', arch: 'x64', evidenceHostId: 'windows-ci-a' }) {
105
+ return {
106
+ verifiedAt,
107
+ host,
108
+ suiteKind: 'matrix',
109
+ releaseGatesEnabled: true,
110
+ releaseThresholds: {
111
+ minExpectedRecall: 1,
112
+ },
113
+ profileRuns: ['smoke', 'medium', 'heavy'].map((profileId) => ({
114
+ workloadProfile: {
115
+ profileId,
116
+ documentCount: profileId === 'heavy' ? 260 : profileId === 'medium' ? 140 : 40,
117
+ },
118
+ modes: ['dist_node_runtime', 'packaged_sidecar'].map((mode) => ({
119
+ mode,
120
+ profileId,
121
+ performance: {
122
+ queryDurationMs: { count: 8, p95Ms: 240 },
123
+ },
124
+ expectedRecall: {
125
+ expectedQueryCount: 6,
126
+ matchedQueryCount: 6,
127
+ ratio: 1,
128
+ },
129
+ releaseGates: {
130
+ pass: true,
131
+ expectedRecall: {
132
+ expectedQueryCount: 6,
133
+ matchedQueryCount: 6,
134
+ ratio: 1,
135
+ },
136
+ gates: [
137
+ { gateId: 'startup_p95', passed: true },
138
+ { gateId: 'query_p95', passed: true },
139
+ { gateId: 'expected_recall', passed: true },
140
+ ],
141
+ },
142
+ })),
143
+ })),
144
+ };
145
+ }
146
+ function buildNonReleaseAnnReport(verifiedAt) {
147
+ return {
148
+ verifiedAt,
149
+ suiteKind: 'single',
150
+ releaseGatesEnabled: false,
151
+ profileRuns: [
152
+ {
153
+ workloadProfile: {
154
+ profileId: 'smoke',
155
+ documentCount: 40,
156
+ },
157
+ modes: [],
158
+ },
159
+ ],
160
+ };
161
+ }
162
+ test('keeps the release evidence verifier wired in package scripts and migration contracts', () => {
163
+ const packageJson = readJson(packageJsonPath);
164
+ expect(packageJson.scripts?.['verify:foundation:release-evidence']).toBe('node scripts/verify-foundation-release-evidence.js');
165
+ expect(packageJson.scripts?.['verify:foundation:release-evidence:strict']).toBe('node scripts/verify-foundation-release-evidence.js --min-report-count 3');
166
+ expect(packageJson.scripts?.['verify:foundation:release-evidence:multi-host']).toBe('node scripts/verify-foundation-release-evidence.js --min-report-count 3 --min-host-count 2');
167
+ expect(packageJson.scripts?.['test:migration']).toContain('src/foundation.release.evidence.contract.test.ts');
168
+ });
169
+ test('verifier script validates latest sqlite soak and ANN release-gate reports with bounded freshness', () => {
170
+ const source = fs.readFileSync(scriptPath, 'utf8');
171
+ expect(source).toContain('foundation-sqlite-runtime-report-latest.json');
172
+ expect(source).toContain('foundation-ann-runtime-report-latest.json');
173
+ expect(source).toContain('foundation-release-evidence-report-latest.json');
174
+ expect(source).toContain('NOTE_CONNECTION_FOUNDATION_RELEASE_EVIDENCE_MAX_AGE_HOURS');
175
+ expect(source).toContain('NOTE_CONNECTION_FOUNDATION_RELEASE_EVIDENCE_MIN_REPORT_COUNT');
176
+ expect(source).toContain('NOTE_CONNECTION_FOUNDATION_RELEASE_EVIDENCE_MIN_HOST_COUNT');
177
+ expect(source).toContain('--min-report-count');
178
+ expect(source).toContain('--min-host-count');
179
+ expect(source).toContain('foundation-sqlite-runtime-report-');
180
+ expect(source).toContain('foundation-ann-runtime-report-');
181
+ expect(source).toContain('verify:foundation:sqlite-runtime:release');
182
+ expect(source).toContain('verify:foundation:ann-runtime:release');
183
+ expect(source).toContain("suiteKind === 'soak'");
184
+ expect(source).toContain("suiteKind === 'matrix'");
185
+ expect(source).toContain('releaseGatesEnabled');
186
+ expect(source).toContain('expectedRecall');
187
+ expect(source).toContain('minimumReportCount');
188
+ expect(source).toContain('minimumHostCount');
189
+ expect(source).toContain('dist_node_runtime');
190
+ expect(source).toContain('packaged_sidecar');
191
+ });
192
+ test('bounded integer parsing uses defaults for missing environment values', () => {
193
+ const verifier = require(scriptPath);
194
+ expect(verifier.parseBoundedInteger('', { min: 1, max: 10, default: 7 })).toBe(7);
195
+ expect(verifier.parseBoundedInteger(undefined, { min: 1, max: 10, default: 7 })).toBe(7);
196
+ });
197
+ test('accepts fresh passing sqlite soak and ANN release-gate reports', () => {
198
+ const verifier = require(scriptPath);
199
+ const tempRoot = createTempReportRoot();
200
+ const sqliteReportPath = path.join(tempRoot, 'foundation-sqlite-runtime-report-latest.json');
201
+ const annReportPath = path.join(tempRoot, 'foundation-ann-runtime-report-latest.json');
202
+ const now = new Date('2026-06-06T00:00:00.000Z');
203
+ try {
204
+ writeJson(sqliteReportPath, buildPassingSqliteReport('2026-06-05T23:00:00.000Z'));
205
+ writeJson(annReportPath, buildPassingAnnReport('2026-06-05T22:00:00.000Z'));
206
+ const result = verifier.verifyFoundationReleaseEvidence({
207
+ sqliteReportPath,
208
+ annReportPath,
209
+ now,
210
+ maxAgeHours: 24,
211
+ });
212
+ expect(result.ok).toBe(true);
213
+ expect(result.errors).toEqual([]);
214
+ expect(result.summary.sqlite).toMatchObject({
215
+ suiteKind: 'soak',
216
+ requiredProfiles: ['heavy'],
217
+ });
218
+ expect(result.summary.ann).toMatchObject({
219
+ suiteKind: 'matrix',
220
+ requiredProfiles: ['smoke', 'medium', 'heavy'],
221
+ });
222
+ }
223
+ finally {
224
+ fs.rmSync(tempRoot, { recursive: true, force: true });
225
+ }
226
+ });
227
+ test('rejects stale release evidence even when runtime gates passed', () => {
228
+ const verifier = require(scriptPath);
229
+ const tempRoot = createTempReportRoot();
230
+ const sqliteReportPath = path.join(tempRoot, 'foundation-sqlite-runtime-report-latest.json');
231
+ const annReportPath = path.join(tempRoot, 'foundation-ann-runtime-report-latest.json');
232
+ const now = new Date('2026-06-06T00:00:00.000Z');
233
+ try {
234
+ writeJson(sqliteReportPath, buildPassingSqliteReport('2026-06-01T00:00:00.000Z'));
235
+ writeJson(annReportPath, buildPassingAnnReport('2026-06-05T22:00:00.000Z'));
236
+ const result = verifier.verifyFoundationReleaseEvidence({
237
+ sqliteReportPath,
238
+ annReportPath,
239
+ now,
240
+ maxAgeHours: 24,
241
+ });
242
+ expect(result.ok).toBe(false);
243
+ expect(result.errors.join('\n')).toContain('sqlite release evidence is stale');
244
+ }
245
+ finally {
246
+ fs.rmSync(tempRoot, { recursive: true, force: true });
247
+ }
248
+ });
249
+ test('accepts repeated sqlite and ANN release evidence when enough fresh history reports exist', () => {
250
+ const verifier = require(scriptPath);
251
+ const tempRoot = createTempReportRoot();
252
+ const sqliteReportPath = path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-latest.json');
253
+ const annReportPath = path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-latest.json');
254
+ const now = new Date('2026-06-06T00:00:00.000Z');
255
+ try {
256
+ writeJson(sqliteReportPath, buildPassingSqliteReport('2026-06-05T23:00:00.000Z'));
257
+ writeJson(path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-2026-06-05T22-30-00-000Z.json'), buildPassingSqliteReport('2026-06-05T22:30:00.000Z'));
258
+ writeJson(annReportPath, buildPassingAnnReport('2026-06-05T22:00:00.000Z'));
259
+ writeJson(path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-2026-06-05T21-30-00-000Z.json'), buildPassingAnnReport('2026-06-05T21:30:00.000Z'));
260
+ const result = verifier.verifyFoundationReleaseEvidence({
261
+ sqliteReportPath,
262
+ annReportPath,
263
+ now,
264
+ maxAgeHours: 24,
265
+ minReportCount: 2,
266
+ });
267
+ expect(result.ok).toBe(true);
268
+ expect(result.errors).toEqual([]);
269
+ expect(result.summary.sqlite).toMatchObject({
270
+ minimumReportCount: 2,
271
+ reportCount: 2,
272
+ });
273
+ expect(result.summary.ann).toMatchObject({
274
+ minimumReportCount: 2,
275
+ reportCount: 2,
276
+ });
277
+ }
278
+ finally {
279
+ fs.rmSync(tempRoot, { recursive: true, force: true });
280
+ }
281
+ });
282
+ test('accepts multi-host release evidence when enough fresh reports cover distinct hosts', () => {
283
+ const verifier = require(scriptPath);
284
+ const tempRoot = createTempReportRoot();
285
+ const sqliteReportPath = path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-latest.json');
286
+ const annReportPath = path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-latest.json');
287
+ const windowsHost = { platform: 'win32', arch: 'x64', evidenceHostId: 'windows-ci-a' };
288
+ const linuxHost = { platform: 'linux', arch: 'x64', evidenceHostId: 'linux-ci-b' };
289
+ const now = new Date('2026-06-06T00:00:00.000Z');
290
+ try {
291
+ writeJson(sqliteReportPath, buildPassingSqliteReport('2026-06-05T23:00:00.000Z', windowsHost));
292
+ writeJson(path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-2026-06-05T22-30-00-000Z.json'), buildPassingSqliteReport('2026-06-05T22:30:00.000Z', linuxHost));
293
+ writeJson(annReportPath, buildPassingAnnReport('2026-06-05T22:00:00.000Z', windowsHost));
294
+ writeJson(path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-2026-06-05T21-30-00-000Z.json'), buildPassingAnnReport('2026-06-05T21:30:00.000Z', linuxHost));
295
+ const result = verifier.verifyFoundationReleaseEvidence({
296
+ sqliteReportPath,
297
+ annReportPath,
298
+ now,
299
+ maxAgeHours: 24,
300
+ minReportCount: 2,
301
+ minHostCount: 2,
302
+ });
303
+ expect(result.ok).toBe(true);
304
+ expect(result.errors).toEqual([]);
305
+ expect(result.summary.sqlite).toMatchObject({
306
+ minimumReportCount: 2,
307
+ reportCount: 2,
308
+ minimumHostCount: 2,
309
+ hostCount: 2,
310
+ });
311
+ expect(result.summary.ann).toMatchObject({
312
+ minimumReportCount: 2,
313
+ reportCount: 2,
314
+ minimumHostCount: 2,
315
+ hostCount: 2,
316
+ });
317
+ }
318
+ finally {
319
+ fs.rmSync(tempRoot, { recursive: true, force: true });
320
+ }
321
+ });
322
+ test('rejects multi-host release evidence when repeated reports come from one host', () => {
323
+ const verifier = require(scriptPath);
324
+ const tempRoot = createTempReportRoot();
325
+ const sqliteReportPath = path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-latest.json');
326
+ const annReportPath = path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-latest.json');
327
+ const windowsHost = { platform: 'win32', arch: 'x64', evidenceHostId: 'windows-ci-a' };
328
+ const now = new Date('2026-06-06T00:00:00.000Z');
329
+ try {
330
+ writeJson(sqliteReportPath, buildPassingSqliteReport('2026-06-05T23:00:00.000Z', windowsHost));
331
+ writeJson(path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-2026-06-05T22-30-00-000Z.json'), buildPassingSqliteReport('2026-06-05T22:30:00.000Z', windowsHost));
332
+ writeJson(annReportPath, buildPassingAnnReport('2026-06-05T22:00:00.000Z', windowsHost));
333
+ writeJson(path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-2026-06-05T21-30-00-000Z.json'), buildPassingAnnReport('2026-06-05T21:30:00.000Z', windowsHost));
334
+ const result = verifier.verifyFoundationReleaseEvidence({
335
+ sqliteReportPath,
336
+ annReportPath,
337
+ now,
338
+ maxAgeHours: 24,
339
+ minReportCount: 2,
340
+ minHostCount: 2,
341
+ });
342
+ expect(result.ok).toBe(false);
343
+ expect(result.errors.join('\n')).toContain('sqlite release evidence history covers 1 host(s), expected at least 2');
344
+ expect(result.errors.join('\n')).toContain('ann release evidence history covers 1 host(s), expected at least 2');
345
+ }
346
+ finally {
347
+ fs.rmSync(tempRoot, { recursive: true, force: true });
348
+ }
349
+ });
350
+ test('rejects strict repeated evidence when only latest reports exist', () => {
351
+ const verifier = require(scriptPath);
352
+ const tempRoot = createTempReportRoot();
353
+ const sqliteReportPath = path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-latest.json');
354
+ const annReportPath = path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-latest.json');
355
+ const now = new Date('2026-06-06T00:00:00.000Z');
356
+ try {
357
+ writeJson(sqliteReportPath, buildPassingSqliteReport('2026-06-05T23:00:00.000Z'));
358
+ writeJson(annReportPath, buildPassingAnnReport('2026-06-05T22:00:00.000Z'));
359
+ const result = verifier.verifyFoundationReleaseEvidence({
360
+ sqliteReportPath,
361
+ annReportPath,
362
+ now,
363
+ maxAgeHours: 24,
364
+ minReportCount: 2,
365
+ });
366
+ expect(result.ok).toBe(false);
367
+ expect(result.errors.join('\n')).toContain('sqlite release evidence history has 1 report(s), expected at least 2');
368
+ expect(result.errors.join('\n')).toContain('ann release evidence history has 1 report(s), expected at least 2');
369
+ }
370
+ finally {
371
+ fs.rmSync(tempRoot, { recursive: true, force: true });
372
+ }
373
+ });
374
+ test('does not fail default freshness verification because older non-release history reports exist', () => {
375
+ const verifier = require(scriptPath);
376
+ const tempRoot = createTempReportRoot();
377
+ const sqliteReportPath = path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-latest.json');
378
+ const annReportPath = path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-latest.json');
379
+ const now = new Date('2026-06-06T00:00:00.000Z');
380
+ try {
381
+ writeJson(sqliteReportPath, buildPassingSqliteReport('2026-06-05T23:00:00.000Z'));
382
+ writeJson(path.join(tempRoot, 'sqlite', 'foundation-sqlite-runtime-report-2026-05-30T00-00-00-000Z.json'), buildPassingSqliteReport('2026-05-30T00:00:00.000Z'));
383
+ writeJson(annReportPath, buildPassingAnnReport('2026-06-05T22:00:00.000Z'));
384
+ writeJson(path.join(tempRoot, 'ann', 'foundation-ann-runtime-report-2026-06-05T21-00-00-000Z.json'), buildNonReleaseAnnReport('2026-06-05T21:00:00.000Z'));
385
+ const result = verifier.verifyFoundationReleaseEvidence({
386
+ sqliteReportPath,
387
+ annReportPath,
388
+ now,
389
+ maxAgeHours: 24,
390
+ });
391
+ expect(result.ok).toBe(true);
392
+ expect(result.summary.sqlite).toMatchObject({
393
+ minimumReportCount: 1,
394
+ reportCount: 1,
395
+ });
396
+ expect(result.summary.ann).toMatchObject({
397
+ minimumReportCount: 1,
398
+ reportCount: 1,
399
+ });
400
+ expect(result.warnings.join('\n')).toContain('ann release evidence history report ignored');
401
+ }
402
+ finally {
403
+ fs.rmSync(tempRoot, { recursive: true, force: true });
404
+ }
405
+ });
406
+ });
@@ -0,0 +1,82 @@
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('foundation sqlite runtime verification contract', () => {
39
+ const repoRoot = path.resolve(__dirname, '..');
40
+ const packageJsonPath = path.join(repoRoot, 'package.json');
41
+ const scriptPath = path.join(repoRoot, 'scripts', 'verify-foundation-sqlite-runtime.js');
42
+ function readJson(filePath) {
43
+ const raw = fs.readFileSync(filePath, 'utf8');
44
+ return JSON.parse(raw);
45
+ }
46
+ test('keeps the host-level sqlite runtime verifier wired in package scripts', () => {
47
+ const packageJson = readJson(packageJsonPath);
48
+ expect(packageJson.scripts?.['verify:foundation:sqlite-runtime']).toBe('npm run build && node scripts/ensure-sidecar-ready.js && node scripts/verify-foundation-sqlite-runtime.js');
49
+ expect(packageJson.scripts?.['verify:foundation:sqlite-runtime:heavy']).toBe('npm run build && node scripts/ensure-sidecar-ready.js && node scripts/verify-foundation-sqlite-runtime.js --heavy');
50
+ expect(packageJson.scripts?.['verify:foundation:sqlite-runtime:matrix']).toBe('npm run build && node scripts/ensure-sidecar-ready.js && node scripts/verify-foundation-sqlite-runtime.js --matrix');
51
+ expect(packageJson.scripts?.['verify:foundation:sqlite-runtime:soak']).toBe('npm run build && node scripts/ensure-sidecar-ready.js && node scripts/verify-foundation-sqlite-runtime.js --soak');
52
+ expect(packageJson.scripts?.['verify:foundation:sqlite-runtime:release']).toBe('npm run build && node scripts/ensure-sidecar-ready.js && node scripts/verify-foundation-sqlite-runtime.js --soak');
53
+ });
54
+ test('verifier script covers smoke/medium/heavy profiles, soak gates, and matrix runs across dist runtime and packaged sidecar restart continuity', () => {
55
+ const source = fs.readFileSync(scriptPath, 'utf8');
56
+ expect(source).toContain('WORKLOAD_PROFILES');
57
+ expect(source).toContain("profileId: 'medium'");
58
+ expect(source).toContain("profileId: 'heavy'");
59
+ expect(source).toContain("arg === '--matrix'");
60
+ expect(source).toContain("arg === '--soak'");
61
+ expect(source).toContain('--soak-cycles');
62
+ expect(source).toContain('dist_node_runtime');
63
+ expect(source).toContain('packaged_sidecar');
64
+ expect(source).toContain('knowledge_graph_store.graphdb.v1.sqlite');
65
+ expect(source).toContain('/api/knowledge/ingest');
66
+ expect(source).toContain('/api/knowledge/store-diagnostics');
67
+ expect(source).toContain('/api/knowledge/foundation/readiness');
68
+ expect(source).toContain('/api/knowledge/query');
69
+ expect(source).toContain("graphBackendSignalKind === 'embedded_graphdb'");
70
+ expect(source).toContain("storageEngine === 'sqlite'");
71
+ expect(source).toContain("usingFallback !== true");
72
+ expect(source).toContain("genericQuery: 'persist graph content restart sqlite proof'");
73
+ expect(source).toContain('graphDbLastSnapshotMetadata');
74
+ expect(source).toContain('heavy_runtime_anchor_');
75
+ expect(source).toContain("options.suiteKind === 'matrix'");
76
+ expect(source).toContain('foundation-sqlite-runtime-report-latest.json');
77
+ expect(source).toContain('restartCycles');
78
+ expect(source).toContain('maxStartupP95Ms');
79
+ expect(source).toContain('maxQueryMaxMs');
80
+ expect(source).toContain('computeRequestTimeoutMs');
81
+ });
82
+ });