@lssm/example.analytics-dashboard 0.0.0-canary-20251217060433 → 0.0.0-canary-20251217062139

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 (137) hide show
  1. package/dist/dashboard/dashboard.contracts.d.ts +131 -131
  2. package/dist/dashboard/dashboard.contracts.js +5 -5
  3. package/dist/dashboard/dashboard.enum.js +5 -4
  4. package/dist/dashboard/dashboard.schema.d.ts +79 -79
  5. package/dist/dashboard/dashboard.schema.js +44 -42
  6. package/dist/docs/analytics-dashboard.docblock.js +3 -2
  7. package/dist/events.d.ts +40 -40
  8. package/dist/events.js +27 -24
  9. package/dist/index.d.ts +0 -1
  10. package/dist/libs/contracts/dist/capabilities/openbanking.js +84 -0
  11. package/dist/libs/contracts/dist/client/index.js +5 -0
  12. package/dist/libs/contracts/dist/client/react/feature-render.js +2 -0
  13. package/dist/libs/contracts/dist/client/react/form-render.js +4 -0
  14. package/dist/libs/contracts/dist/client/react/index.js +4 -0
  15. package/dist/libs/contracts/dist/contract-registry/index.js +1 -0
  16. package/dist/libs/contracts/dist/contract-registry/schemas.js +57 -0
  17. package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +91 -0
  18. package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +365 -0
  19. package/dist/libs/contracts/dist/docs/index.js +29 -0
  20. package/dist/libs/contracts/dist/docs/presentations.js +67 -0
  21. package/dist/libs/contracts/dist/docs/registry.js +42 -0
  22. package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +398 -0
  23. package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +83 -0
  24. package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +155 -0
  25. package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +101 -0
  26. package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -0
  27. package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +80 -0
  28. package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +57 -0
  29. package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +228 -0
  30. package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +357 -0
  31. package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +21 -0
  32. package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -0
  33. package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +281 -0
  34. package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +22 -0
  35. package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +79 -0
  36. package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +84 -0
  37. package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +57 -0
  38. package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +22 -0
  39. package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +40 -0
  40. package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +86 -0
  41. package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +22 -0
  42. package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +62 -0
  43. package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +155 -0
  44. package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -0
  45. package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +101 -0
  46. package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -0
  47. package/dist/libs/contracts/dist/events.js +9 -0
  48. package/dist/libs/contracts/dist/experiments/evaluator.js +1 -0
  49. package/dist/libs/contracts/dist/index.js +71 -0
  50. package/dist/libs/contracts/dist/install.js +2 -0
  51. package/dist/libs/contracts/dist/integrations/contracts.js +371 -0
  52. package/dist/libs/contracts/dist/integrations/index.js +18 -0
  53. package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +225 -0
  54. package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +157 -0
  55. package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -0
  56. package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +208 -0
  57. package/dist/libs/contracts/dist/integrations/openbanking/models.js +240 -0
  58. package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +24 -0
  59. package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -0
  60. package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -0
  61. package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -0
  62. package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -0
  63. package/dist/libs/contracts/dist/integrations/providers/index.js +11 -0
  64. package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -0
  65. package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -0
  66. package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -0
  67. package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -0
  68. package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -0
  69. package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -0
  70. package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -0
  71. package/dist/libs/contracts/dist/jsonschema.js +1 -0
  72. package/dist/libs/contracts/dist/knowledge/contracts.js +299 -0
  73. package/dist/libs/contracts/dist/knowledge/index.js +7 -0
  74. package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -0
  75. package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -0
  76. package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -0
  77. package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -0
  78. package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -0
  79. package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -0
  80. package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -0
  81. package/dist/libs/contracts/dist/llm/exporters.js +18 -0
  82. package/dist/libs/contracts/dist/llm/index.js +2 -0
  83. package/dist/libs/contracts/dist/llm/prompts.js +1 -0
  84. package/dist/libs/contracts/dist/onboarding-base.js +179 -0
  85. package/dist/libs/contracts/dist/openapi.js +1 -0
  86. package/dist/libs/contracts/dist/ownership.js +36 -0
  87. package/dist/libs/contracts/dist/presentations.js +1 -0
  88. package/dist/libs/contracts/dist/presentations.v2.js +7 -0
  89. package/dist/libs/contracts/dist/prompt.js +1 -0
  90. package/dist/libs/contracts/dist/promptRegistry.js +1 -0
  91. package/dist/libs/contracts/dist/regenerator/index.js +1 -0
  92. package/dist/libs/contracts/dist/regenerator/service.js +1 -0
  93. package/dist/libs/contracts/dist/registry.js +2 -0
  94. package/dist/libs/contracts/dist/resources.js +1 -0
  95. package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -0
  96. package/dist/libs/contracts/dist/schema/dist/FieldType.js +39 -0
  97. package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +222 -0
  98. package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +23 -0
  99. package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -0
  100. package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -0
  101. package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -0
  102. package/dist/libs/contracts/dist/schema/dist/index.js +6 -0
  103. package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -0
  104. package/dist/libs/contracts/dist/server/index.js +8 -0
  105. package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -0
  106. package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -0
  107. package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -0
  108. package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -0
  109. package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -0
  110. package/dist/libs/contracts/dist/server/provider-mcp.js +1 -0
  111. package/dist/libs/contracts/dist/server/rest-elysia.js +1 -0
  112. package/dist/libs/contracts/dist/server/rest-express.js +1 -0
  113. package/dist/libs/contracts/dist/server/rest-generic.js +1 -0
  114. package/dist/libs/contracts/dist/server/rest-next-app.js +1 -0
  115. package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -0
  116. package/dist/libs/contracts/dist/spec.js +25 -0
  117. package/dist/libs/contracts/dist/telemetry/index.js +1 -0
  118. package/dist/libs/contracts/dist/telemetry/tracker.js +1 -0
  119. package/dist/libs/contracts/dist/tests/index.js +1 -0
  120. package/dist/libs/contracts/dist/tests/runner.js +2 -0
  121. package/dist/libs/contracts/dist/workflow/index.js +1 -0
  122. package/dist/libs/contracts/dist/workflow/runner.js +1 -0
  123. package/dist/libs/schema/dist/EnumType.js +40 -0
  124. package/dist/libs/schema/dist/FieldType.js +39 -0
  125. package/dist/libs/schema/dist/ScalarTypeEnum.js +222 -0
  126. package/dist/libs/schema/dist/SchemaModel.js +24 -0
  127. package/dist/libs/schema/dist/entity/defineEntity.js +1 -0
  128. package/dist/libs/schema/dist/entity/index.js +2 -0
  129. package/dist/libs/schema/dist/entity/types.js +1 -0
  130. package/dist/libs/schema/dist/index.js +6 -0
  131. package/dist/query/query.contracts.d.ts +45 -45
  132. package/dist/query/query.contracts.js +3 -3
  133. package/dist/query/query.enum.d.ts +2 -2
  134. package/dist/query/query.enum.js +3 -2
  135. package/dist/query/query.schema.d.ts +34 -34
  136. package/dist/query/query.schema.js +34 -32
  137. package/package.json +10 -10
@@ -0,0 +1,398 @@
1
+ import { a } from "../registry.js";
2
+
3
+ //#region ../../libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js
4
+ const t = [{
5
+ id: `docs.tech.PHASE_1_QUICKSTART`,
6
+ title: `Phase 1: API Reference Index`,
7
+ summary: `Quick reference for all new Phase 1 APIs.`,
8
+ kind: `reference`,
9
+ visibility: `public`,
10
+ route: `/docs/tech/PHASE_1_QUICKSTART`,
11
+ tags: [`tech`, `PHASE_1_QUICKSTART`],
12
+ body: `# Phase 1: API Reference Index
13
+
14
+ Quick reference for all new Phase 1 APIs.
15
+
16
+ ---
17
+
18
+ ## @lssm/lib.multi-tenancy
19
+
20
+ ### RLS
21
+ \`\`\`typescript
22
+ import { createRlsMiddleware, type TenantIdProvider } from '@lssm/lib.multi-tenancy/rls';
23
+ \`\`\`
24
+
25
+ ### Provisioning
26
+ \`\`\`typescript
27
+ import {
28
+ TenantProvisioningService,
29
+ type CreateTenantInput,
30
+ type TenantProvisioningConfig
31
+ } from '@lssm/lib.multi-tenancy/provisioning';
32
+ \`\`\`
33
+
34
+ ### Isolation
35
+ \`\`\`typescript
36
+ import { IsolationValidator } from '@lssm/lib.multi-tenancy/isolation';
37
+ \`\`\`
38
+
39
+ ---
40
+
41
+ ## @lssm/lib.observability
42
+
43
+ ### Tracing
44
+ \`\`\`typescript
45
+ import {
46
+ getTracer,
47
+ traceAsync,
48
+ traceSync,
49
+ createTracingMiddleware
50
+ } from '@lssm/lib.observability/tracing';
51
+ \`\`\`
52
+
53
+ ### Metrics
54
+ \`\`\`typescript
55
+ import {
56
+ getMeter,
57
+ createCounter,
58
+ createUpDownCounter,
59
+ createHistogram,
60
+ standardMetrics
61
+ } from '@lssm/lib.observability/metrics';
62
+ \`\`\`
63
+
64
+ ### Logging
65
+ \`\`\`typescript
66
+ import {
67
+ Logger,
68
+ logger,
69
+ type LogLevel,
70
+ type LogEntry
71
+ } from '@lssm/lib.observability/logging';
72
+ \`\`\`
73
+
74
+ ---
75
+
76
+ ## @lssm/lib.resilience
77
+
78
+ ### Circuit Breaker
79
+ \`\`\`typescript
80
+ import {
81
+ CircuitBreaker,
82
+ type CircuitState,
83
+ type CircuitBreakerConfig
84
+ } from '@lssm/lib.resilience/circuit-breaker';
85
+ \`\`\`
86
+
87
+ ### Retry
88
+ \`\`\`typescript
89
+ import { retry } from '@lssm/lib.resilience/retry';
90
+ \`\`\`
91
+
92
+ ### Timeout
93
+ \`\`\`typescript
94
+ import { timeout } from '@lssm/lib.resilience/timeout';
95
+ \`\`\`
96
+
97
+ ### Fallback
98
+ \`\`\`typescript
99
+ import { fallback } from '@lssm/lib.resilience/fallback';
100
+ \`\`\`
101
+
102
+ ---
103
+
104
+ ## Enhanced: @lssm/lib.contracts
105
+
106
+ ### DataViews
107
+ \`\`\`typescript
108
+ import { DataViewQueryGenerator } from '@lssm/lib.contracts/data-views/query-generator';
109
+ import { DataViewRuntime } from '@lssm/lib.contracts/data-views/runtime';
110
+ \`\`\`
111
+
112
+ ### Workflows
113
+ \`\`\`typescript
114
+ import { SLAMonitor, type SLABreachEvent } from '@lssm/lib.contracts/workflow/sla-monitor';
115
+ import { PrismaStateStore } from '@lssm/lib.contracts/workflow/adapters/db-adapter';
116
+ \`\`\`
117
+
118
+ ---
119
+
120
+ ## Enhanced: @lssm/lib.design-system
121
+
122
+ ### DataView Components
123
+ \`\`\`typescript
124
+ import { DataViewRenderer } from '@lssm/lib.design-system/components/data-view/DataViewRenderer';
125
+ // Also available: DataViewList, DataViewTable, DataViewDetail
126
+ \`\`\`
127
+
128
+ ---
129
+
130
+ ## Usage Examples
131
+
132
+ ### Complete Workflow with All Features
133
+
134
+ \`\`\`typescript
135
+ import { WorkflowRunner } from '@lssm/lib.contracts/workflow/runner';
136
+ import { PrismaStateStore } from '@lssm/lib.contracts/workflow/adapters/db-adapter';
137
+ import { SLAMonitor } from '@lssm/lib.contracts/workflow/sla-monitor';
138
+ import { CircuitBreaker } from '@lssm/lib.resilience/circuit-breaker';
139
+ import { traceAsync } from '@lssm/lib.observability/tracing';
140
+
141
+ const runner = new WorkflowRunner({
142
+ registry,
143
+ stateStore: new PrismaStateStore(db),
144
+ opExecutor: async (op, input, ctx) => {
145
+ return traceAsync(\`op.\${op.name}\`, async (span) => {
146
+ span.setAttribute('operation', op.name);
147
+ const breaker = getCircuitBreaker(op.name);
148
+ return breaker.execute(() => executeOperation(op, input, ctx));
149
+ });
150
+ },
151
+ eventEmitter: (event, payload) => {
152
+ if (event.startsWith('workflow.')) {
153
+ logger.info(event, payload);
154
+ }
155
+ },
156
+ });
157
+
158
+ const monitor = new SLAMonitor((event, payload) => {
159
+ logger.warn('SLA_BREACH', payload);
160
+ alertOps(payload);
161
+ });
162
+
163
+ // Start workflow
164
+ const workflowId = await runner.start('payment.flow', 1);
165
+
166
+ // Monitor SLA
167
+ const state = await runner.getState(workflowId);
168
+ const spec = registry.get('payment.flow', 1);
169
+ monitor.check(state, spec!);
170
+ \`\`\`
171
+
172
+ ### Complete DataView with Observability
173
+
174
+ \`\`\`typescript
175
+ import { DataViewRenderer } from '@lssm/lib.design-system';
176
+ import { DataViewQueryGenerator } from '@lssm/lib.contracts/data-views/query-generator';
177
+ import { traceAsync } from '@lssm/lib.observability/tracing';
178
+ import { MyDataView } from './specs/users.data-view';
179
+
180
+ export function UserListPage() {
181
+ const [page, setPage] = useState(1);
182
+ const [users, setUsers] = useState([]);
183
+
184
+ const loadUsers = async () => {
185
+ return traceAsync('load_users', async (span) => {
186
+ const generator = new DataViewQueryGenerator(MyDataView);
187
+ const query = generator.generate({ pagination: { page, pageSize: 20 } });
188
+
189
+ span.setAttribute('page', page);
190
+ const result = await api.execute(query);
191
+ setUsers(result.data);
192
+ });
193
+ };
194
+
195
+ return (
196
+ <DataViewRenderer
197
+ spec={MyDataView}
198
+ items={users}
199
+ pagination={{ page, pageSize: 20, total: users.length }}
200
+ onPageChange={setPage}
201
+ />
202
+ );
203
+ }
204
+ \`\`\`
205
+
206
+ ### Complete Multi-Tenant Setup
207
+
208
+ \`\`\`typescript
209
+ // 1. RLS Middleware
210
+ import { createRlsMiddleware } from '@lssm/lib.multi-tenancy/rls';
211
+ db.$use(createRlsMiddleware(() => req.tenantId));
212
+
213
+ // 2. Tenant Provisioning
214
+ import { TenantProvisioningService } from '@lssm/lib.multi-tenancy/provisioning';
215
+ const service = new TenantProvisioningService({ db });
216
+
217
+ // 3. Create new tenant
218
+ await service.provision({
219
+ id: 'acme',
220
+ name: 'Acme Corp',
221
+ slug: 'acme',
222
+ ownerEmail: 'admin@acme.com',
223
+ });
224
+
225
+ // 4. Validate isolation in tests
226
+ import { IsolationValidator } from '@lssm/lib.multi-tenancy/isolation';
227
+
228
+ test('queries are isolated', () => {
229
+ const isValid = IsolationValidator.validateQuery(
230
+ 'User',
231
+ 'findMany',
232
+ { where: { tenantId: 'acme' } },
233
+ 'acme'
234
+ );
235
+ expect(isValid).toBe(true);
236
+ });
237
+ \`\`\`
238
+
239
+ ---
240
+
241
+ ## Testing
242
+
243
+ ### Test Circuit Breakers
244
+
245
+ \`\`\`typescript
246
+ import { CircuitBreaker } from '@lssm/lib.resilience/circuit-breaker';
247
+
248
+ test('circuit opens after threshold', async () => {
249
+ const breaker = new CircuitBreaker({
250
+ failureThreshold: 3,
251
+ resetTimeoutMs: 5000,
252
+ });
253
+
254
+ // Trigger failures
255
+ for (let i = 0; i < 3; i++) {
256
+ await expect(
257
+ breaker.execute(() => Promise.reject('error'))
258
+ ).rejects.toThrow();
259
+ }
260
+
261
+ // Circuit should be open
262
+ await expect(
263
+ breaker.execute(() => Promise.resolve('ok'))
264
+ ).rejects.toThrow('CircuitBreaker is OPEN');
265
+ });
266
+ \`\`\`
267
+
268
+ ### Test Workflow Retry
269
+
270
+ \`\`\`typescript
271
+ test('workflow retries on failure', async () => {
272
+ let attempts = 0;
273
+ const opExecutor = async () => {
274
+ attempts++;
275
+ if (attempts < 3) throw new Error('fail');
276
+ return 'success';
277
+ };
278
+
279
+ const runner = new WorkflowRunner({ /* ... */ opExecutor });
280
+ await runner.executeStep(workflowId);
281
+
282
+ expect(attempts).toBe(3);
283
+ });
284
+ \`\`\`
285
+
286
+ ---
287
+
288
+ ## Common Patterns
289
+
290
+ ### Pattern: Resilient External Call
291
+
292
+ \`\`\`typescript
293
+ import { CircuitBreaker } from '@lssm/lib.resilience/circuit-breaker';
294
+ import { retry } from '@lssm/lib.resilience/retry';
295
+ import { timeout } from '@lssm/lib.resilience/timeout';
296
+ import { traceAsync } from '@lssm/lib.observability/tracing';
297
+
298
+ const breaker = new CircuitBreaker({ failureThreshold: 5, resetTimeoutMs: 30000 });
299
+
300
+ export async function callExternalAPI(input: any) {
301
+ return traceAsync('external_api_call', async (span) => {
302
+ span.setAttribute('service', 'stripe');
303
+
304
+ return breaker.execute(() =>
305
+ retry(
306
+ () => timeout(() => stripe.api.call(input), 5000),
307
+ 3,
308
+ 1000,
309
+ true
310
+ )
311
+ );
312
+ });
313
+ }
314
+ \`\`\`
315
+
316
+ **Benefits**: Circuit breaker + retry + timeout + tracing in one place.
317
+
318
+ ---
319
+
320
+ ### Pattern: Tenant-Aware Operation
321
+
322
+ \`\`\`typescript
323
+ import { traceAsync } from '@lssm/lib.observability/tracing';
324
+
325
+ export async function listUsers(tenantId: string) {
326
+ return traceAsync('list_users', async (span) => {
327
+ span.setAttribute('tenant_id', tenantId);
328
+
329
+ // RLS middleware will inject WHERE tenantId = ?
330
+ return db.user.findMany();
331
+ });
332
+ }
333
+ \`\`\`
334
+
335
+ ---
336
+
337
+ ### Pattern: Monitored Workflow
338
+
339
+ \`\`\`typescript
340
+ import { WorkflowRunner } from '@lssm/lib.contracts/workflow/runner';
341
+ import { SLAMonitor } from '@lssm/lib.contracts/workflow/sla-monitor';
342
+ import { logger } from '@lssm/lib.observability/logging';
343
+
344
+ const monitor = new SLAMonitor((event, payload) => {
345
+ logger.warn('workflow.sla_breach', payload);
346
+ });
347
+
348
+ // In workflow poller
349
+ const state = await runner.getState(workflowId);
350
+ const spec = registry.get(state.workflowName, state.workflowVersion);
351
+ if (spec) {
352
+ monitor.check(state, spec);
353
+ }
354
+ \`\`\`
355
+
356
+ ---
357
+
358
+ ## Next Steps
359
+
360
+ 1. **Implement one quick win** (30 minutes)
361
+ 2. **Add tests for new functionality** (1 hour)
362
+ 3. **Deploy to staging and verify observability** (1 hour)
363
+ 4. **Roll out to production** (monitor closely)
364
+ 5. **Read full documentation** at https://contractspec.lssm.tech/docs
365
+
366
+ ---
367
+
368
+ **Questions?** See \`/docs/guides/phase-1-migration\` or reach out via https://contractspec.lssm.tech/contact
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+ `
395
+ }];
396
+ a(t);
397
+
398
+ //#endregion
@@ -0,0 +1,83 @@
1
+ import { a } from "../registry.js";
2
+
3
+ //#region ../../libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js
4
+ const t = [{
5
+ id: `docs.tech.PHASE_2_AI_NATIVE_OPERATIONS`,
6
+ title: `Phase 2: AI-Native Operations`,
7
+ summary: `_Last updated: 2025-11-20_`,
8
+ kind: `reference`,
9
+ visibility: `public`,
10
+ route: `/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS`,
11
+ tags: [`tech`, `PHASE_2_AI_NATIVE_OPERATIONS`],
12
+ body: `# Phase 2: AI-Native Operations
13
+
14
+ _Last updated: 2025-11-20_
15
+
16
+ Phase 2 turns ContractSpec into an AI-first operations stack. The new libraries below are the building blocks used by support bots, growth agents, and human-in-the-loop flows.
17
+
18
+ ## Libraries
19
+
20
+ ### @lssm/lib.ai-agent
21
+
22
+ - **Spec + Registry**: \`defineAgent\`, \`AgentRegistry\` keep agent definitions type-safe.
23
+ - **Runner**: \`AgentRunner\` drives LLM conversations, tool calls, retries, escalation, and telemetry hooks.
24
+ - **Tools**: \`ToolExecutor\` standardizes schema validation + timeouts.
25
+ - **Memory**: \`InMemoryAgentMemory\` + interfaces for plugging persistent stores.
26
+ - **Approvals**: new \`ApprovalWorkflow\` + \`InMemoryApprovalStore\` capture low-confidence decisions and surface them to reviewers.
27
+
28
+ ### @lssm/lib.support-bot
29
+
30
+ Composable support automation primitives:
31
+
32
+ - \`TicketClassifier\` → heuristics + optional LLM validation for category, priority, sentiment.
33
+ - \`TicketResolver\` → RAG pipeline backed by knowledge spaces.
34
+ - \`AutoResponder\` → tone-aware drafts with citations.
35
+ - \`SupportFeedbackLoop\` → tracks resolution rates.
36
+ - \`createSupportTools\` → ready-made tool definitions for AgentRunner.
37
+
38
+ ### @lssm/lib.content-gen
39
+
40
+ Content generators that consume a \`ContentBrief\` and output production-ready assets:
41
+
42
+ - \`BlogGenerator\`, \`LandingPageGenerator\`, \`EmailCampaignGenerator\`, \`SocialPostGenerator\`.
43
+ - \`SeoOptimizer\` builds metadata + schema markup.
44
+
45
+ ### @lssm/lib.analytics
46
+
47
+ Queryless analytics helpers:
48
+
49
+ - \`FunnelAnalyzer\` – conversion/drop-off per step.
50
+ - \`CohortTracker\` – retention + LTV per cohort.
51
+ - \`ChurnPredictor\` – recency/frequency/error scoring.
52
+ - \`GrowthHypothesisGenerator\` – surfaces experiment ideas from metric trends.
53
+
54
+ ### @lssm/lib.growth
55
+
56
+ A/B testing toolkit:
57
+
58
+ - \`ExperimentRegistry\` + \`ExperimentRunner\` – deterministic bucketing.
59
+ - \`ExperimentTracker\` – persist exposures + metrics.
60
+ - \`StatsEngine\` – Welch’s t-test + improvement calculations.
61
+
62
+ ### Human-in-the-loop UI
63
+
64
+ \`@lssm/lib.design-system\` now exposes:
65
+
66
+ - \`ApprovalQueue\` – list + act on pending approvals.
67
+ - \`AgentMonitor\` – live view of agent sessions with confidence + status.
68
+
69
+ ## Examples
70
+
71
+ - \`examples/ai-support-bot/setup.ts\` shows ticket classification → resolution → response draft.
72
+ - \`examples/content-generation/generate.ts\` produces blog, landing, email, social, SEO output from one brief.
73
+
74
+ ## Next Steps
75
+
76
+ 1. Wire these libraries into vertical apps (H-Circle, ArtisanOS, etc.).
77
+ 2. Add background workers that consume the new analytics/growth trackers.
78
+ 3. Expand web-landing to highlight these Phase 2 capabilities (see separate TODO).
79
+ `
80
+ }];
81
+ a(t);
82
+
83
+ //#endregion
@@ -0,0 +1,155 @@
1
+ import { a } from "../registry.js";
2
+
3
+ //#region ../../libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js
4
+ const t = [{
5
+ id: `docs.tech.PHASE_3_AUTO_EVOLUTION`,
6
+ title: `Phase 3: Auto-Evolution Technical Notes`,
7
+ summary: `**Status**: In progress`,
8
+ kind: `reference`,
9
+ visibility: `public`,
10
+ route: `/docs/tech/PHASE_3_AUTO_EVOLUTION`,
11
+ tags: [`tech`, `PHASE_3_AUTO_EVOLUTION`],
12
+ body: `# Phase 3: Auto-Evolution Technical Notes
13
+
14
+ **Status**: In progress
15
+ **Last updated**: 2025-11-21
16
+
17
+ Phase 3 introduces self-learning capabilities that analyze production telemetry, suggest new specs, safely roll out variants, and generate golden tests from real traffic. This document captures the main building blocks delivered in this iteration.
18
+
19
+ ---
20
+
21
+ ## 1. Libraries
22
+
23
+ ### @lssm/lib.evolution
24
+
25
+ - \`SpecAnalyzer\` converts raw telemetry samples into usage stats + anomalies.
26
+ - \`SpecGenerator\` produces \`SpecSuggestion\` objects and validates confidence thresholds.
27
+ - \`SpecSuggestionOrchestrator\` routes proposals through the AI approval workflow and writes approved specs to \`packages/libs/contracts/src/generated\`.
28
+ - Storage adapters:
29
+ - \`InMemorySpecSuggestionRepository\` for tests.
30
+ - \`PrismaSpecSuggestionRepository\` persists to the new Prisma model (see §4).
31
+ - \`FileSystemSuggestionWriter\` emits JSON envelopes for git review.
32
+
33
+ ### @lssm/lib.observability
34
+
35
+ - Added intent detection modules:
36
+ - \`IntentAggregator\` batches telemetry into rolling windows.
37
+ - \`IntentDetector\` surfaces latency/error/throughput regressions and sequential intents.
38
+ - \`EvolutionPipeline\` orchestrates aggregation → detection → intent events and exposes hooks for downstream orchestrators.
39
+ - \`createTracingMiddleware\` now accepts \`resolveOperation\`/\`onSample\` hooks to feed telemetry samples into the pipeline.
40
+
41
+ ### @lssm/lib.growth
42
+
43
+ - New \`spec-experiments\` module:
44
+ - \`SpecExperimentRegistry\`, \`SpecExperimentRunner\`, \`SpecExperimentAdapter\`.
45
+ - \`SpecExperimentAnalyzer\` + \`SpecExperimentController\` handle guardrails and staged rollouts.
46
+ - Helper \`createSpecVariantResolver\` plugs directly into \`HandlerCtx.specVariantResolver\`.
47
+ - \`SpecVariantResolver\` is now a first-class concept in \`@lssm/lib.contracts\`. The runtime will attempt to execute variant specs before falling back to the registered handler.
48
+
49
+ ### @lssm/lib.testing
50
+
51
+ - \`TrafficRecorder\` + \`TrafficStore\` capture production requests with sampling and sanitization hooks.
52
+ - \`GoldenTestGenerator\` converts \`TrafficSnapshot\`s into Vitest/Jest suites.
53
+ - \`generateVitestSuite\` / \`generateJestSuite\` output self-contained test files, and \`runGoldenTests\` offers a programmatic harness for CI pipelines.
54
+
55
+ ---
56
+
57
+ ## 2. Telemetry → Intent → Spec Pipeline
58
+
59
+ 1. \`createTracingMiddleware({ onSample })\` emits \`TelemetrySample\`s for every HTTP request.
60
+ 2. \`IntentAggregator\` groups samples into statistical windows (default 15 minutes).
61
+ 3. \`IntentDetector\` raises signals for:
62
+ - Error spikes
63
+ - Latency regressions
64
+ - Throughput drops
65
+ - Sequential workflows that hint at missing specs
66
+ 4. \`EvolutionPipeline\` emits \`intent.detected\` events and hands them to \`SpecGenerator\`.
67
+ 5. \`SpecSuggestionOrchestrator\` persists suggestions, triggers approval workflows, and—upon approval—writes JSON envelopes to \`packages/.../contracts/src/generated\`.
68
+
69
+ ---
70
+
71
+ ## 3. Spec Experiments & Rollouts
72
+
73
+ 1. Register spec experiments in \`SpecExperimentRegistry\` with control + variant bindings.
74
+ 2. Expose bucketed specs by attaching \`createSpecVariantResolver\` to \`HandlerCtx.specVariantResolver\` inside adapters.
75
+ 3. Record outcomes via \`SpecExperimentAdapter.trackOutcome()\` (latency + error metrics).
76
+ 4. \`SpecExperimentController\` uses guardrails from config and \`SpecExperimentAnalyzer\` to:
77
+ - Auto-rollback on error/latency breaches.
78
+ - Advance rollout stages (1% → 10% → 50% → 100%) when metrics stay green.
79
+
80
+ ---
81
+
82
+ ## 4. Data Models (Prisma)
83
+
84
+ File: \`packages/libs/database/prisma/schema.prisma\`
85
+
86
+ - \`SpecSuggestion\` – stores serialized suggestion payloads + statuses.
87
+ - \`IntentSnapshot\` – captured detector output for auditing/training.
88
+ - \`TrafficSnapshot\` – persisted production traffic (input/output/error blobs).
89
+ - \`SpecExperiment\` / \`SpecExperimentMetric\` – rollout state + metrics for each variant.
90
+
91
+ > Run \`bun database generate\` after pulling to refresh the Prisma client.
92
+
93
+ ---
94
+
95
+ ## 5. Golden Test Workflow
96
+
97
+ 1. Capture traffic via middleware or direct \`TrafficRecorder.record\`.
98
+ 2. Use the new CLI command to materialize suites:
99
+
100
+ \`\`\`bash
101
+ contractspec test generate \\
102
+ --operation billing.createInvoice \\
103
+ --output tests/billing.createInvoice.golden.test.ts \\
104
+ --runner-import ./tests/run-operation \\
105
+ --runner-fn runBillingCommand \\
106
+ --from-production \\
107
+ --days 7 \\
108
+ --sample-rate 0.05
109
+ \`\`\`
110
+
111
+ 3. Generated files import your runner and assert against recorded outputs (or expected errors for negative paths).
112
+
113
+ ---
114
+
115
+ ## 6. Operational Notes
116
+
117
+ - **Approvals**: By default, every suggestion still requires human approval. \`EvolutionConfig.autoApproveThreshold\` can be tuned per environment but should remain conservative (<0.3) until OverlaySpec tooling lands.
118
+ - **Sampling**: Keep \`TrafficRecorder.sampleRate\` ≤ 0.05 in production to avoid sensitive payload storage; scrub PII through the \`sanitize\` callback before persistence.
119
+ - **Rollouts**: Guardrails default to 5% error-rate and 750ms P99 latency. Override per experiment to match SLOs.
120
+
121
+ ---
122
+
123
+ ## 7. Next Steps
124
+
125
+ 1. Wire \`SpecExperimentAdapter.trackOutcome\` into adapters (REST, GraphQL, Workers) so every execution logs metrics automatically.
126
+ 2. Add a UI for reviewing \`SpecSuggestion\` objects alongside approval status.
127
+ 3. Expand \`TrafficRecorder\` to ship directly to the Prisma-backed store (currently in-memory by default).
128
+ 4. Integrate \`EvolutionPipeline\` events with the Regenerator to close the loop (auto-open proposals + attach evidence).
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+ `
152
+ }];
153
+ a(t);
154
+
155
+ //#endregion