swarmdo 1.4.8 → 1.5.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 (210) hide show
  1. package/.claude/helpers/statusline.cjs +7 -7
  2. package/README.md +3 -1
  3. package/package.json +5 -3
  4. package/v3/@swarmdo/cli/dist/src/commands/hooks.js +26 -24
  5. package/v3/@swarmdo/cli/dist/src/commands/index.js +4 -0
  6. package/v3/@swarmdo/cli/dist/src/commands/integrations.d.ts +14 -0
  7. package/v3/@swarmdo/cli/dist/src/commands/integrations.js +158 -0
  8. package/v3/@swarmdo/cli/dist/src/commands/memory.js +50 -1
  9. package/v3/@swarmdo/cli/dist/src/commands/providers.js +3 -0
  10. package/v3/@swarmdo/cli/dist/src/commands/release.d.ts +15 -0
  11. package/v3/@swarmdo/cli/dist/src/commands/release.js +224 -0
  12. package/v3/@swarmdo/cli/dist/src/commands/security.js +14 -0
  13. package/v3/@swarmdo/cli/dist/src/commands/transcript.js +82 -1
  14. package/v3/@swarmdo/cli/dist/src/commands/usage.js +80 -1
  15. package/v3/@swarmdo/cli/dist/src/config-lint/lint.js +11 -1
  16. package/v3/@swarmdo/cli/dist/src/init/statusline-generator.js +6 -6
  17. package/v3/@swarmdo/cli/dist/src/integrations/integrations.d.ts +54 -0
  18. package/v3/@swarmdo/cli/dist/src/integrations/integrations.js +162 -0
  19. package/v3/@swarmdo/cli/dist/src/mcp-tools/agent-execute-core.js +25 -3
  20. package/v3/@swarmdo/cli/dist/src/mcp-tools/agentdb-tools.js +8 -8
  21. package/v3/@swarmdo/cli/dist/src/memory/graph-edge-writer.d.ts +12 -0
  22. package/v3/@swarmdo/cli/dist/src/memory/graph-edge-writer.js +32 -1
  23. package/v3/@swarmdo/cli/dist/src/memory-vault/watch.d.ts +32 -0
  24. package/v3/@swarmdo/cli/dist/src/memory-vault/watch.js +66 -0
  25. package/v3/@swarmdo/cli/dist/src/providers/openrouter-config.d.ts +91 -0
  26. package/v3/@swarmdo/cli/dist/src/providers/openrouter-config.js +186 -0
  27. package/v3/@swarmdo/cli/dist/src/release/release.d.ts +72 -0
  28. package/v3/@swarmdo/cli/dist/src/release/release.js +86 -0
  29. package/v3/@swarmdo/cli/dist/src/resilience/backoff.d.ts +23 -0
  30. package/v3/@swarmdo/cli/dist/src/resilience/backoff.js +30 -0
  31. package/v3/@swarmdo/cli/dist/src/swarmvector/model-router.js +14 -0
  32. package/v3/@swarmdo/cli/dist/src/transcript/search.d.ts +39 -0
  33. package/v3/@swarmdo/cli/dist/src/transcript/search.js +67 -0
  34. package/v3/@swarmdo/cli/dist/src/usage/diff.d.ts +69 -0
  35. package/v3/@swarmdo/cli/dist/src/usage/diff.js +112 -0
  36. package/v3/@swarmdo/cli/package.json +4 -4
  37. package/v3/@swarmdo/cli-core/dist/src/index.js +1 -1
  38. package/v3/@swarmdo/codex/dist/cli.js +0 -0
  39. package/v3/@swarmdo/hooks/dist/cli/guidance-cli.js +0 -0
  40. package/v3/@swarmdo/hooks/dist/statusline/index.d.ts +3 -3
  41. package/v3/@swarmdo/hooks/dist/statusline/index.js +3 -3
  42. package/v3/@swarmdo/integration/dist/__tests__/agentic-flow-agent.test.js +4 -1
  43. package/v3/@swarmdo/neural/dist/flash-attention.d.ts +1 -1
  44. package/v3/@swarmdo/neural/dist/flash-attention.js +1 -1
  45. package/v3/@swarmdo/plugin-agent-federation/dist/plugin.js +1 -1
  46. package/v3/@swarmdo/plugin-agent-federation/dist/transport/midstream-aware-loader.js +2 -2
  47. package/v3/@swarmdo/providers/dist/swarmvector-provider.d.ts +1 -1
  48. package/v3/@swarmdo/providers/dist/swarmvector-provider.js +1 -1
  49. package/v3/@swarmdo/security/dist/input-validator.d.ts +6 -6
  50. package/v3/@swarmdo/shared/dist/hooks/safety/git-commit.js +1 -1
  51. package/v3/@swarmdo/shared/dist/mcp/transport/http.js +8 -1
  52. package/v3/vendor/agentdb/package.json +0 -1
  53. package/v3/vendor/agentic-flow/package.json +0 -1
  54. package/.claude/scheduled_tasks.lock +0 -1
  55. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/__init__.cpython-314.pyc +0 -0
  56. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/__main__.cpython-314.pyc +0 -0
  57. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/cli.cpython-314.pyc +0 -0
  58. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/compress.cpython-314.pyc +0 -0
  59. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/detect.cpython-314.pyc +0 -0
  60. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/validate.cpython-314.pyc +0 -0
  61. package/v3/@swarmdo/plugin-iot-cognitum/dist/application/index.d.ts +0 -2
  62. package/v3/@swarmdo/plugin-iot-cognitum/dist/application/index.js +0 -2
  63. package/v3/@swarmdo/plugin-iot-cognitum/dist/application/iot-coordinator.d.ts +0 -138
  64. package/v3/@swarmdo/plugin-iot-cognitum/dist/application/iot-coordinator.js +0 -418
  65. package/v3/@swarmdo/plugin-iot-cognitum/dist/bin.d.ts +0 -15
  66. package/v3/@swarmdo/plugin-iot-cognitum/dist/bin.js +0 -240
  67. package/v3/@swarmdo/plugin-iot-cognitum/dist/cli-commands.d.ts +0 -7
  68. package/v3/@swarmdo/plugin-iot-cognitum/dist/cli-commands.js +0 -508
  69. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-agent.d.ts +0 -54
  70. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-agent.js +0 -2
  71. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-fleet.d.ts +0 -46
  72. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-fleet.js +0 -2
  73. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-trust-level.d.ts +0 -18
  74. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-trust-level.js +0 -28
  75. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/index.d.ts +0 -5
  76. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/index.js +0 -2
  77. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/telemetry.d.ts +0 -35
  78. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/telemetry.js +0 -2
  79. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/device-repository.d.ts +0 -11
  80. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/device-repository.js +0 -2
  81. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/fleet-repository.d.ts +0 -9
  82. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/fleet-repository.js +0 -2
  83. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/index.d.ts +0 -5
  84. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/index.js +0 -2
  85. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/telemetry-repository.d.ts +0 -12
  86. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/telemetry-repository.js +0 -2
  87. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/trust-history-repository.d.ts +0 -19
  88. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/trust-history-repository.js +0 -2
  89. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/anomaly-detection-service.d.ts +0 -44
  90. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/anomaly-detection-service.js +0 -117
  91. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/device-lifecycle-service.d.ts +0 -70
  92. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/device-lifecycle-service.js +0 -194
  93. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/firmware-orchestration-service.d.ts +0 -69
  94. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/firmware-orchestration-service.js +0 -139
  95. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/fleet-topology-service.d.ts +0 -34
  96. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/fleet-topology-service.js +0 -101
  97. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/index.d.ts +0 -10
  98. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/index.js +0 -10
  99. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/mesh-service.d.ts +0 -64
  100. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/mesh-service.js +0 -70
  101. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/sona-integration-service.d.ts +0 -44
  102. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/sona-integration-service.js +0 -79
  103. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-ingestion-service.d.ts +0 -37
  104. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-ingestion-service.js +0 -39
  105. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-service.d.ts +0 -67
  106. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-service.js +0 -58
  107. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/witness-verification-service.d.ts +0 -45
  108. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/witness-verification-service.js +0 -63
  109. package/v3/@swarmdo/plugin-iot-cognitum/dist/index.d.ts +0 -26
  110. package/v3/@swarmdo/plugin-iot-cognitum/dist/index.js +0 -17
  111. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/agentdb-telemetry-repository.d.ts +0 -51
  112. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/agentdb-telemetry-repository.js +0 -110
  113. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-device-repository.d.ts +0 -13
  114. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-device-repository.js +0 -25
  115. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-fleet-repository.d.ts +0 -11
  116. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-fleet-repository.js +0 -19
  117. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-trust-history-repository.d.ts +0 -11
  118. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-trust-history-repository.js +0 -27
  119. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/index.d.ts +0 -6
  120. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/index.js +0 -6
  121. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/seed-client-factory.d.ts +0 -41
  122. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/seed-client-factory.js +0 -64
  123. package/v3/@swarmdo/plugin-iot-cognitum/dist/mcp-tools.d.ts +0 -8
  124. package/v3/@swarmdo/plugin-iot-cognitum/dist/mcp-tools.js +0 -703
  125. package/v3/@swarmdo/plugin-iot-cognitum/dist/plugin.d.ts +0 -23
  126. package/v3/@swarmdo/plugin-iot-cognitum/dist/plugin.js +0 -239
  127. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/anomaly-scan-worker.d.ts +0 -17
  128. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/anomaly-scan-worker.js +0 -42
  129. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/firmware-watch-worker.d.ts +0 -18
  130. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/firmware-watch-worker.js +0 -45
  131. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/health-probe-worker.d.ts +0 -19
  132. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/health-probe-worker.js +0 -50
  133. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/mesh-sync-worker.d.ts +0 -19
  134. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/mesh-sync-worker.js +0 -47
  135. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/telemetry-ingest-worker.d.ts +0 -17
  136. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/telemetry-ingest-worker.js +0 -40
  137. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/witness-audit-worker.d.ts +0 -18
  138. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/witness-audit-worker.js +0 -51
  139. package/v3/@swarmdo/testing/dist/fixtures/agent-fixtures.d.ts +0 -214
  140. package/v3/@swarmdo/testing/dist/fixtures/agent-fixtures.js +0 -595
  141. package/v3/@swarmdo/testing/dist/fixtures/agents.d.ts +0 -76
  142. package/v3/@swarmdo/testing/dist/fixtures/agents.js +0 -158
  143. package/v3/@swarmdo/testing/dist/fixtures/configurations.d.ts +0 -157
  144. package/v3/@swarmdo/testing/dist/fixtures/configurations.js +0 -337
  145. package/v3/@swarmdo/testing/dist/fixtures/index.d.ts +0 -10
  146. package/v3/@swarmdo/testing/dist/fixtures/index.js +0 -17
  147. package/v3/@swarmdo/testing/dist/fixtures/mcp-fixtures.d.ts +0 -329
  148. package/v3/@swarmdo/testing/dist/fixtures/mcp-fixtures.js +0 -714
  149. package/v3/@swarmdo/testing/dist/fixtures/memory-entries.d.ts +0 -159
  150. package/v3/@swarmdo/testing/dist/fixtures/memory-entries.js +0 -262
  151. package/v3/@swarmdo/testing/dist/fixtures/memory-fixtures.d.ts +0 -290
  152. package/v3/@swarmdo/testing/dist/fixtures/memory-fixtures.js +0 -547
  153. package/v3/@swarmdo/testing/dist/fixtures/swarm-fixtures.d.ts +0 -289
  154. package/v3/@swarmdo/testing/dist/fixtures/swarm-fixtures.js +0 -534
  155. package/v3/@swarmdo/testing/dist/fixtures/tasks.d.ts +0 -106
  156. package/v3/@swarmdo/testing/dist/fixtures/tasks.js +0 -229
  157. package/v3/@swarmdo/testing/dist/helpers/assertion-helpers.d.ts +0 -213
  158. package/v3/@swarmdo/testing/dist/helpers/assertion-helpers.js +0 -435
  159. package/v3/@swarmdo/testing/dist/helpers/assertions.d.ts +0 -135
  160. package/v3/@swarmdo/testing/dist/helpers/assertions.js +0 -217
  161. package/v3/@swarmdo/testing/dist/helpers/create-mock.d.ts +0 -96
  162. package/v3/@swarmdo/testing/dist/helpers/create-mock.js +0 -164
  163. package/v3/@swarmdo/testing/dist/helpers/index.d.ts +0 -14
  164. package/v3/@swarmdo/testing/dist/helpers/index.js +0 -22
  165. package/v3/@swarmdo/testing/dist/helpers/mock-factory.d.ts +0 -323
  166. package/v3/@swarmdo/testing/dist/helpers/mock-factory.js +0 -350
  167. package/v3/@swarmdo/testing/dist/helpers/setup-teardown.d.ts +0 -271
  168. package/v3/@swarmdo/testing/dist/helpers/setup-teardown.js +0 -446
  169. package/v3/@swarmdo/testing/dist/helpers/swarm-instance.d.ts +0 -142
  170. package/v3/@swarmdo/testing/dist/helpers/swarm-instance.js +0 -205
  171. package/v3/@swarmdo/testing/dist/helpers/test-application.d.ts +0 -190
  172. package/v3/@swarmdo/testing/dist/helpers/test-application.js +0 -138
  173. package/v3/@swarmdo/testing/dist/helpers/test-utils.d.ts +0 -274
  174. package/v3/@swarmdo/testing/dist/helpers/test-utils.js +0 -456
  175. package/v3/@swarmdo/testing/dist/index.d.ts +0 -42
  176. package/v3/@swarmdo/testing/dist/index.js +0 -66
  177. package/v3/@swarmdo/testing/dist/mocks/index.d.ts +0 -8
  178. package/v3/@swarmdo/testing/dist/mocks/index.js +0 -10
  179. package/v3/@swarmdo/testing/dist/mocks/mock-mcp-client.d.ts +0 -206
  180. package/v3/@swarmdo/testing/dist/mocks/mock-mcp-client.js +0 -575
  181. package/v3/@swarmdo/testing/dist/mocks/mock-services.d.ts +0 -287
  182. package/v3/@swarmdo/testing/dist/mocks/mock-services.js +0 -563
  183. package/v3/@swarmdo/testing/dist/regression/api-contract.d.ts +0 -109
  184. package/v3/@swarmdo/testing/dist/regression/api-contract.js +0 -374
  185. package/v3/@swarmdo/testing/dist/regression/index.d.ts +0 -18
  186. package/v3/@swarmdo/testing/dist/regression/index.js +0 -18
  187. package/v3/@swarmdo/testing/dist/regression/integration-regression.d.ts +0 -67
  188. package/v3/@swarmdo/testing/dist/regression/integration-regression.js +0 -334
  189. package/v3/@swarmdo/testing/dist/regression/performance-baseline.d.ts +0 -106
  190. package/v3/@swarmdo/testing/dist/regression/performance-baseline.js +0 -268
  191. package/v3/@swarmdo/testing/dist/regression/regression-runner.d.ts +0 -124
  192. package/v3/@swarmdo/testing/dist/regression/regression-runner.js +0 -227
  193. package/v3/@swarmdo/testing/dist/regression/security-regression.d.ts +0 -73
  194. package/v3/@swarmdo/testing/dist/regression/security-regression.js +0 -258
  195. package/v3/@swarmdo/testing/dist/setup.d.ts +0 -43
  196. package/v3/@swarmdo/testing/dist/setup.js +0 -91
  197. package/v3/@swarmdo/testing/dist/v2-compat/api-compat.test.d.ts +0 -10
  198. package/v3/@swarmdo/testing/dist/v2-compat/api-compat.test.js +0 -433
  199. package/v3/@swarmdo/testing/dist/v2-compat/cli-compat.test.d.ts +0 -10
  200. package/v3/@swarmdo/testing/dist/v2-compat/cli-compat.test.js +0 -352
  201. package/v3/@swarmdo/testing/dist/v2-compat/compatibility-validator.d.ts +0 -206
  202. package/v3/@swarmdo/testing/dist/v2-compat/compatibility-validator.js +0 -839
  203. package/v3/@swarmdo/testing/dist/v2-compat/hooks-compat.test.d.ts +0 -10
  204. package/v3/@swarmdo/testing/dist/v2-compat/hooks-compat.test.js +0 -428
  205. package/v3/@swarmdo/testing/dist/v2-compat/index.d.ts +0 -38
  206. package/v3/@swarmdo/testing/dist/v2-compat/index.js +0 -41
  207. package/v3/@swarmdo/testing/dist/v2-compat/mcp-compat.test.d.ts +0 -10
  208. package/v3/@swarmdo/testing/dist/v2-compat/mcp-compat.test.js +0 -419
  209. package/v3/@swarmdo/testing/dist/v2-compat/report-generator.d.ts +0 -34
  210. package/v3/@swarmdo/testing/dist/v2-compat/report-generator.js +0 -372
@@ -1,435 +0,0 @@
1
- /**
2
- * @swarmdo/testing - Assertion Helpers
3
- *
4
- * Custom Vitest matchers and assertion utilities for V3 module testing.
5
- * Implements London School TDD behavior verification patterns.
6
- */
7
- import { expect } from 'vitest';
8
- /**
9
- * Assert that a mock was called with arguments matching a pattern
10
- *
11
- * @example
12
- * assertCalledWithPattern(mockFn, { userId: expect.any(String) });
13
- */
14
- export function assertCalledWithPattern(mock, pattern) {
15
- const calls = mock.mock.calls;
16
- const matched = calls.some(call => {
17
- if (Array.isArray(pattern)) {
18
- return pattern.every((expected, i) => {
19
- if (typeof expected === 'object' && expected !== null && 'asymmetricMatch' in expected) {
20
- return expected.asymmetricMatch(call[i]);
21
- }
22
- return JSON.stringify(call[i]) === JSON.stringify(expected);
23
- });
24
- }
25
- const callArg = call[0];
26
- return Object.entries(pattern).every(([key, expected]) => {
27
- if (typeof expected === 'object' && expected !== null && 'asymmetricMatch' in expected) {
28
- return expected.asymmetricMatch(callArg[key]);
29
- }
30
- return JSON.stringify(callArg[key]) === JSON.stringify(expected);
31
- });
32
- });
33
- expect(matched).toBe(true);
34
- }
35
- /**
36
- * Assert that events were published in order
37
- *
38
- * @example
39
- * assertEventOrder(mockEventBus.publish, ['UserCreated', 'EmailSent']);
40
- */
41
- export function assertEventOrder(publishMock, expectedEventTypes) {
42
- const actualEventTypes = publishMock.mock.calls
43
- .map(call => call[0].type)
44
- .filter(type => expectedEventTypes.includes(type));
45
- expect(actualEventTypes).toEqual(expectedEventTypes);
46
- }
47
- /**
48
- * Assert that an event was published with specific payload
49
- *
50
- * @example
51
- * assertEventPublished(mockEventBus, 'UserCreated', { userId: '123' });
52
- */
53
- export function assertEventPublished(eventBusMock, eventType, expectedPayload) {
54
- const publishMock = 'publish' in eventBusMock ? eventBusMock.publish : eventBusMock;
55
- const calls = publishMock.mock.calls;
56
- const matchingEvent = calls.find(call => {
57
- const event = call[0];
58
- return event.type === eventType;
59
- });
60
- expect(matchingEvent).toBeDefined();
61
- if (expectedPayload && matchingEvent) {
62
- const actualPayload = matchingEvent[0].payload;
63
- expect(actualPayload).toMatchObject(expectedPayload);
64
- }
65
- }
66
- /**
67
- * Assert that no event of a specific type was published
68
- *
69
- * @example
70
- * assertEventNotPublished(mockEventBus, 'UserDeleted');
71
- */
72
- export function assertEventNotPublished(eventBusMock, eventType) {
73
- const publishMock = 'publish' in eventBusMock ? eventBusMock.publish : eventBusMock;
74
- const calls = publishMock.mock.calls;
75
- const matchingEvent = calls.find(call => {
76
- const event = call[0];
77
- return event.type === eventType;
78
- });
79
- expect(matchingEvent).toBeUndefined();
80
- }
81
- /**
82
- * Assert that mocks were called in a specific order
83
- *
84
- * @example
85
- * assertMocksCalledInOrder([mockValidate, mockSave, mockNotify]);
86
- */
87
- export function assertMocksCalledInOrder(mocks) {
88
- const orders = mocks.map(mock => {
89
- if (mock.mock.invocationCallOrder.length === 0) {
90
- return Infinity;
91
- }
92
- return Math.min(...mock.mock.invocationCallOrder);
93
- });
94
- for (let i = 1; i < orders.length; i++) {
95
- expect(orders[i]).toBeGreaterThan(orders[i - 1]);
96
- }
97
- }
98
- /**
99
- * Assert that a mock was called exactly n times with specific arguments
100
- *
101
- * @example
102
- * assertCalledNTimesWith(mockFn, 3, ['arg1', 'arg2']);
103
- */
104
- export function assertCalledNTimesWith(mock, times, args) {
105
- const matchingCalls = mock.mock.calls.filter(call => JSON.stringify(call) === JSON.stringify(args));
106
- expect(matchingCalls).toHaveLength(times);
107
- }
108
- /**
109
- * Assert that async operations completed within time limit
110
- *
111
- * @example
112
- * await assertCompletesWithin(async () => await slowOp(), 1000);
113
- */
114
- export async function assertCompletesWithin(operation, maxMs) {
115
- const start = performance.now();
116
- await operation();
117
- const duration = performance.now() - start;
118
- expect(duration).toBeLessThanOrEqual(maxMs);
119
- }
120
- /**
121
- * Assert that an operation throws a specific error
122
- *
123
- * @example
124
- * await assertThrowsError(
125
- * async () => await riskyOp(),
126
- * ValidationError,
127
- * 'Invalid input'
128
- * );
129
- */
130
- export async function assertThrowsError(operation, ErrorType, messagePattern) {
131
- let error;
132
- try {
133
- await operation();
134
- }
135
- catch (e) {
136
- error = e;
137
- }
138
- expect(error).toBeInstanceOf(ErrorType);
139
- if (messagePattern && error) {
140
- if (typeof messagePattern === 'string') {
141
- expect(error.message).toContain(messagePattern);
142
- }
143
- else {
144
- expect(error.message).toMatch(messagePattern);
145
- }
146
- }
147
- return error;
148
- }
149
- /**
150
- * Assert that no sensitive data appears in logs
151
- *
152
- * @example
153
- * assertNoSensitiveData(mockLogger.logs, ['password', 'token', 'secret']);
154
- */
155
- export function assertNoSensitiveData(logs, sensitivePatterns) {
156
- for (const log of logs) {
157
- const content = JSON.stringify(log).toLowerCase();
158
- for (const pattern of sensitivePatterns) {
159
- expect(content).not.toContain(pattern.toLowerCase());
160
- }
161
- }
162
- }
163
- /**
164
- * Assert that a value matches a snapshot with custom serialization
165
- *
166
- * @example
167
- * assertMatchesSnapshot(result, { ignoreFields: ['timestamp', 'id'] });
168
- */
169
- export function assertMatchesSnapshot(value, options = {}) {
170
- const { ignoreFields = [], transform } = options;
171
- let processed = value;
172
- if (ignoreFields.length > 0 && typeof processed === 'object' && processed !== null) {
173
- processed = removeFields(processed, ignoreFields);
174
- }
175
- if (transform) {
176
- processed = transform(processed);
177
- }
178
- expect(processed).toMatchSnapshot();
179
- }
180
- /**
181
- * Remove fields from object for snapshot comparison
182
- */
183
- function removeFields(obj, fields) {
184
- const result = { ...obj };
185
- for (const field of fields) {
186
- delete result[field];
187
- }
188
- for (const [key, value] of Object.entries(result)) {
189
- if (typeof value === 'object' && value !== null) {
190
- result[key] = removeFields(value, fields);
191
- }
192
- }
193
- return result;
194
- }
195
- /**
196
- * Assert that performance metrics meet V3 targets
197
- *
198
- * @example
199
- * assertV3PerformanceTargets({
200
- * searchSpeedup: 160,
201
- * memoryReduction: 0.55,
202
- * });
203
- */
204
- export function assertV3PerformanceTargets(metrics) {
205
- // Search speedup: 150x - 12500x
206
- if (metrics.searchSpeedup !== undefined) {
207
- expect(metrics.searchSpeedup).toBeGreaterThanOrEqual(150);
208
- expect(metrics.searchSpeedup).toBeLessThanOrEqual(12500);
209
- }
210
- // Flash attention speedup: 2.49x - 7.47x
211
- if (metrics.flashAttentionSpeedup !== undefined) {
212
- expect(metrics.flashAttentionSpeedup).toBeGreaterThanOrEqual(2.49);
213
- expect(metrics.flashAttentionSpeedup).toBeLessThanOrEqual(7.47);
214
- }
215
- // Memory reduction: >= 50%
216
- if (metrics.memoryReduction !== undefined) {
217
- expect(metrics.memoryReduction).toBeGreaterThanOrEqual(0.50);
218
- }
219
- // Startup time: < 500ms
220
- if (metrics.startupTimeMs !== undefined) {
221
- expect(metrics.startupTimeMs).toBeLessThan(500);
222
- }
223
- // Response time: sub-100ms
224
- if (metrics.responseTimeMs !== undefined) {
225
- expect(metrics.responseTimeMs).toBeLessThan(100);
226
- }
227
- }
228
- /**
229
- * Assert that a domain object is valid
230
- *
231
- * @example
232
- * assertValidDomainObject(user, UserSchema);
233
- */
234
- export function assertValidDomainObject(object, validator) {
235
- const result = validator(object);
236
- if (!result.valid) {
237
- throw new Error(`Invalid domain object: ${result.errors?.join(', ')}`);
238
- }
239
- }
240
- /**
241
- * Assert that a mock was only called with allowed arguments
242
- *
243
- * @example
244
- * assertOnlyCalledWithAllowed(mockFn, [['valid1'], ['valid2']]);
245
- */
246
- export function assertOnlyCalledWithAllowed(mock, allowedCalls) {
247
- const calls = mock.mock.calls;
248
- for (const call of calls) {
249
- const isAllowed = allowedCalls.some(allowed => JSON.stringify(call) === JSON.stringify(allowed));
250
- if (!isAllowed) {
251
- throw new Error(`Mock was called with unexpected arguments: ${JSON.stringify(call)}\n` +
252
- `Allowed: ${JSON.stringify(allowedCalls)}`);
253
- }
254
- }
255
- }
256
- /**
257
- * Assert that an array contains elements in partial order
258
- *
259
- * @example
260
- * assertPartialOrder(events, [
261
- * { type: 'Start' },
262
- * { type: 'Process' },
263
- * { type: 'End' },
264
- * ]);
265
- */
266
- export function assertPartialOrder(actual, expectedOrder) {
267
- let lastIndex = -1;
268
- for (const expected of expectedOrder) {
269
- const index = actual.findIndex((item, i) => i > lastIndex &&
270
- Object.entries(expected).every(([key, value]) => item[key] === value));
271
- if (index === -1) {
272
- throw new Error(`Expected to find ${JSON.stringify(expected)} after index ${lastIndex} in array`);
273
- }
274
- lastIndex = index;
275
- }
276
- }
277
- /**
278
- * Assert that all items in a collection pass a predicate
279
- *
280
- * @example
281
- * assertAllPass(results, result => result.success);
282
- */
283
- export function assertAllPass(items, predicate, message) {
284
- for (let i = 0; i < items.length; i++) {
285
- if (!predicate(items[i], i)) {
286
- throw new Error(message ?? `Item at index ${i} failed predicate: ${JSON.stringify(items[i])}`);
287
- }
288
- }
289
- }
290
- /**
291
- * Assert that none of the items in a collection pass a predicate
292
- *
293
- * @example
294
- * assertNonePass(results, result => result.error);
295
- */
296
- export function assertNonePass(items, predicate, message) {
297
- for (let i = 0; i < items.length; i++) {
298
- if (predicate(items[i], i)) {
299
- throw new Error(message ?? `Item at index ${i} passed predicate but should not have: ${JSON.stringify(items[i])}`);
300
- }
301
- }
302
- }
303
- /**
304
- * Assert that two arrays have the same elements regardless of order
305
- *
306
- * @example
307
- * assertSameElements([1, 2, 3], [3, 1, 2]);
308
- */
309
- export function assertSameElements(actual, expected) {
310
- expect(actual).toHaveLength(expected.length);
311
- const actualSorted = [...actual].sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
312
- const expectedSorted = [...expected].sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
313
- expect(actualSorted).toEqual(expectedSorted);
314
- }
315
- /**
316
- * Assert that a mock returns expected results in sequence
317
- *
318
- * @example
319
- * await assertMockReturnsSequence(mockFn, [1, 2, 3]);
320
- */
321
- export async function assertMockReturnsSequence(mock, expectedResults) {
322
- for (const expected of expectedResults) {
323
- const result = await mock();
324
- expect(result).toEqual(expected);
325
- }
326
- }
327
- /**
328
- * Assert state transition is valid
329
- *
330
- * @example
331
- * assertValidStateTransition(
332
- * 'pending',
333
- * 'running',
334
- * { pending: ['running', 'cancelled'], running: ['completed', 'failed'] }
335
- * );
336
- */
337
- export function assertValidStateTransition(from, to, allowedTransitions) {
338
- const allowed = allowedTransitions[from];
339
- if (!allowed || !allowed.includes(to)) {
340
- throw new Error(`Invalid state transition from '${from}' to '${to}'. ` +
341
- `Allowed transitions from '${from}': ${allowed?.join(', ') ?? 'none'}`);
342
- }
343
- }
344
- /**
345
- * Assert that a retry policy was followed
346
- *
347
- * @example
348
- * assertRetryPattern(mockFn, { attempts: 3, backoffPattern: 'exponential' });
349
- */
350
- export function assertRetryPattern(mock, options) {
351
- const calls = mock.mock.calls;
352
- expect(calls).toHaveLength(options.attempts);
353
- if (options.backoffPattern === 'exponential' && calls.length > 1) {
354
- // Check that intervals roughly follow exponential pattern
355
- const invocationOrder = mock.mock.invocationCallOrder;
356
- for (let i = 2; i < invocationOrder.length; i++) {
357
- const prevGap = invocationOrder[i - 1] - invocationOrder[i - 2];
358
- const currentGap = invocationOrder[i] - invocationOrder[i - 1];
359
- // Allow some variance in timing
360
- expect(currentGap).toBeGreaterThanOrEqual(prevGap * 0.8);
361
- }
362
- }
363
- }
364
- /**
365
- * Assert that a dependency was properly injected
366
- *
367
- * @example
368
- * assertDependencyInjected(service, 'repository', mockRepository);
369
- */
370
- export function assertDependencyInjected(subject, propertyName, expectedDependency) {
371
- expect(subject[propertyName]).toBe(expectedDependency);
372
- }
373
- /**
374
- * Custom Vitest matcher declarations
375
- * Note: Main declarations in setup.ts - these extend CustomMatchers
376
- */
377
- /**
378
- * Register custom Vitest matchers
379
- */
380
- export function registerCustomMatchers() {
381
- expect.extend({
382
- toHaveBeenCalledWithPattern(received, pattern) {
383
- const calls = received.mock.calls;
384
- const pass = calls.some(call => {
385
- const callArg = call[0];
386
- return Object.entries(pattern).every(([key, expected]) => JSON.stringify(callArg[key]) === JSON.stringify(expected));
387
- });
388
- return {
389
- pass,
390
- message: () => pass
391
- ? `Expected mock not to have been called with pattern ${JSON.stringify(pattern)}`
392
- : `Expected mock to have been called with pattern ${JSON.stringify(pattern)}`,
393
- };
394
- },
395
- toHaveEventType(received, eventType) {
396
- const pass = received.type === eventType;
397
- return {
398
- pass,
399
- message: () => pass
400
- ? `Expected event not to have type ${eventType}`
401
- : `Expected event to have type ${eventType}, but got ${received.type}`,
402
- };
403
- },
404
- toMeetV3PerformanceTargets(received) {
405
- const issues = [];
406
- if (received.searchSpeedup !== undefined) {
407
- if (received.searchSpeedup < 150) {
408
- issues.push(`Search speedup ${received.searchSpeedup}x is below minimum 150x`);
409
- }
410
- }
411
- if (received.flashAttentionSpeedup !== undefined) {
412
- if (received.flashAttentionSpeedup < 2.49) {
413
- issues.push(`Flash attention speedup ${received.flashAttentionSpeedup}x is below minimum 2.49x`);
414
- }
415
- }
416
- if (received.memoryReduction !== undefined) {
417
- if (received.memoryReduction < 0.50) {
418
- issues.push(`Memory reduction ${received.memoryReduction * 100}% is below target 50%`);
419
- }
420
- }
421
- if (received.startupTimeMs !== undefined) {
422
- if (received.startupTimeMs >= 500) {
423
- issues.push(`Startup time ${received.startupTimeMs}ms exceeds target 500ms`);
424
- }
425
- }
426
- return {
427
- pass: issues.length === 0,
428
- message: () => issues.length === 0
429
- ? 'Performance metrics meet V3 targets'
430
- : `Performance issues: ${issues.join('; ')}`,
431
- };
432
- },
433
- });
434
- }
435
- //# sourceMappingURL=assertion-helpers.js.map
@@ -1,135 +0,0 @@
1
- /**
2
- * V3 Swarmdo Custom Assertions
3
- *
4
- * London School TDD Custom Assertions
5
- * - Behavior-focused assertions
6
- * - Interaction verification helpers
7
- * - Contract testing utilities
8
- */
9
- import { type Mock } from 'vitest';
10
- /**
11
- * Assert that a mock was called in a specific sequence
12
- *
13
- * @example
14
- * assertCallSequence([
15
- * [mockRepo.findById, ['123']],
16
- * [mockValidator.validate, [user]],
17
- * [mockRepo.save, [user]],
18
- * ]);
19
- */
20
- export declare function assertCallSequence(sequence: Array<[Mock, unknown[]]>): void;
21
- /**
22
- * Assert that a mock was NOT called with specific arguments
23
- *
24
- * @example
25
- * assertNotCalledWith(mockRepo.save, [invalidUser]);
26
- */
27
- export declare function assertNotCalledWith(mock: Mock, args: unknown[]): void;
28
- /**
29
- * Assert interaction count for behavior verification
30
- *
31
- * @example
32
- * assertInteractionCount(mockService.process, 3);
33
- */
34
- export declare function assertInteractionCount(mock: Mock, expectedCount: number): void;
35
- /**
36
- * Assert that all mocks in a group were called
37
- *
38
- * @example
39
- * assertAllCalled([mockA.method, mockB.method, mockC.method]);
40
- */
41
- export declare function assertAllCalled(mocks: Mock[]): void;
42
- /**
43
- * Assert that none of the mocks were called
44
- *
45
- * @example
46
- * assertNoneCalled([mockA.method, mockB.method]);
47
- */
48
- export declare function assertNoneCalled(mocks: Mock[]): void;
49
- /**
50
- * Assert contract compliance
51
- * Verifies that an object implements expected interface
52
- *
53
- * @example
54
- * assertContractCompliance(userService, UserServiceContract);
55
- */
56
- export declare function assertContractCompliance<T extends object>(implementation: T, contract: ContractDefinition<T>): void;
57
- /**
58
- * Contract definition for interface compliance
59
- */
60
- export interface ContractDefinition<T> {
61
- methods: {
62
- [K in keyof T]?: {
63
- params: Array<{
64
- name: string;
65
- type: string;
66
- }>;
67
- returns: string;
68
- };
69
- };
70
- }
71
- /**
72
- * Assert async operation timing
73
- *
74
- * @example
75
- * await assertTimingWithin(async () => service.process(), 100);
76
- */
77
- export declare function assertTimingWithin(operation: () => Promise<unknown>, maxMs: number): Promise<void>;
78
- /**
79
- * Assert that an async operation completes within expected time range
80
- *
81
- * @example
82
- * await assertTimingRange(async () => service.process(), 50, 150);
83
- */
84
- export declare function assertTimingRange(operation: () => Promise<unknown>, minMs: number, maxMs: number): Promise<void>;
85
- /**
86
- * Assert error type and message
87
- *
88
- * @example
89
- * await assertThrowsWithMessage(
90
- * async () => service.validate(invalid),
91
- * ValidationError,
92
- * 'Invalid input'
93
- * );
94
- */
95
- export declare function assertThrowsWithMessage(operation: () => Promise<unknown>, ErrorType: new (...args: unknown[]) => Error, expectedMessage: string | RegExp): Promise<void>;
96
- /**
97
- * Assert domain event was published
98
- *
99
- * @example
100
- * await assertEventPublished(mockEventBus, 'UserCreated', { userId: '123' });
101
- */
102
- export declare function assertEventPublished(eventBusMock: Mock, eventType: string, expectedPayload?: Record<string, unknown>): void;
103
- /**
104
- * Assert that mock returns expected values in sequence
105
- *
106
- * @example
107
- * assertMockSequence(mockCounter.next, [1, 2, 3]);
108
- */
109
- export declare function assertMockSequence(mock: Mock, expectedValues: unknown[]): Promise<void>;
110
- /**
111
- * Security assertion - verify sensitive data handling
112
- *
113
- * @example
114
- * assertNoSensitiveDataLogged(mockLogger, ['password', 'token', 'secret']);
115
- */
116
- export declare function assertNoSensitiveDataLogged(loggerMock: Mock, sensitivePatterns: string[]): void;
117
- /**
118
- * Performance assertion - verify operation meets target
119
- *
120
- * @example
121
- * await assertPerformanceTarget(
122
- * async () => await search.execute(query),
123
- * { targetMs: 100, iterations: 10 }
124
- * );
125
- */
126
- export declare function assertPerformanceTarget(operation: () => Promise<unknown>, config: {
127
- targetMs: number;
128
- iterations: number;
129
- warmupIterations?: number;
130
- }): Promise<{
131
- averageMs: number;
132
- minMs: number;
133
- maxMs: number;
134
- }>;
135
- //# sourceMappingURL=assertions.d.ts.map