@lssm/lib.evolution 0.4.0 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/spec-analyzer.js +1 -2
- package/dist/approval/integration.js +1 -2
- package/dist/generator/ai-spec-generator.js +19 -0
- package/dist/generator/spec-generator.js +1 -2
- package/dist/index.js +1 -1
- package/package.json +19 -13
- package/dist/ai-agent/dist/approval/index.js +0 -1
- package/dist/ai-agent/dist/approval/workflow.js +0 -1
- package/dist/analyzer/spec-analyzer.d.ts +0 -35
- package/dist/analyzer/spec-analyzer.d.ts.map +0 -1
- package/dist/analyzer/spec-analyzer.js.map +0 -1
- package/dist/approval/integration.d.ts +0 -43
- package/dist/approval/integration.d.ts.map +0 -1
- package/dist/approval/integration.js.map +0 -1
- package/dist/generator/spec-generator.d.ts +0 -47
- package/dist/generator/spec-generator.d.ts.map +0 -1
- package/dist/generator/spec-generator.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/lifecycle/dist/index.js +0 -1
- package/dist/lifecycle/dist/types/axes.js +0 -2
- package/dist/lifecycle/dist/types/axes.js.map +0 -1
- package/dist/lifecycle/dist/types/milestones.js +0 -1
- package/dist/lifecycle/dist/types/signals.js +0 -1
- package/dist/lifecycle/dist/types/stages.js +0 -2
- package/dist/lifecycle/dist/types/stages.js.map +0 -1
- package/dist/lifecycle/dist/utils/formatters.js +0 -1
- package/dist/observability/dist/index.js +0 -1
- package/dist/observability/dist/intent/detector.js +0 -1
- package/dist/observability/dist/lifecycle/dist/index.js +0 -1
- package/dist/observability/dist/lifecycle/dist/types/axes.js +0 -2
- package/dist/observability/dist/lifecycle/dist/types/axes.js.map +0 -1
- package/dist/observability/dist/lifecycle/dist/types/milestones.js +0 -1
- package/dist/observability/dist/lifecycle/dist/types/signals.js +0 -1
- package/dist/observability/dist/lifecycle/dist/types/stages.js +0 -2
- package/dist/observability/dist/lifecycle/dist/types/stages.js.map +0 -1
- package/dist/observability/dist/lifecycle/dist/utils/formatters.js +0 -1
- package/dist/observability/dist/logging/index.js +0 -2
- package/dist/observability/dist/logging/index.js.map +0 -1
- package/dist/observability/dist/metrics/index.js +0 -2
- package/dist/observability/dist/metrics/index.js.map +0 -1
- package/dist/observability/dist/pipeline/evolution-pipeline.js +0 -1
- package/dist/observability/dist/pipeline/lifecycle-pipeline.js +0 -1
- package/dist/observability/dist/tracing/index.js +0 -1
- package/dist/observability/dist/tracing/middleware.js +0 -1
- package/dist/types.d.ts +0 -132
- package/dist/types.d.ts.map +0 -1
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import"
|
|
2
|
-
//# sourceMappingURL=spec-analyzer.js.map
|
|
1
|
+
import"@lssm/lib.observability";import{randomUUID as e}from"node:crypto";import{LifecycleStage as t}from"@lssm/lib.lifecycle";const n={minSampleSize:50,errorRateThreshold:.05,latencyP99ThresholdMs:750};var r=class{logger;minSampleSize;errorRateThreshold;latencyP99ThresholdMs;throughputDropThreshold;constructor(e={}){this.logger=e.logger,this.minSampleSize=e.minSampleSize??n.minSampleSize,this.errorRateThreshold=e.errorRateThreshold??n.errorRateThreshold,this.latencyP99ThresholdMs=e.latencyP99ThresholdMs??n.latencyP99ThresholdMs,this.throughputDropThreshold=e.throughputDropThreshold??.2}analyzeSpecUsage(e){if(!e.length)return this.logger?.debug(`SpecAnalyzer.analyzeSpecUsage.skip`,{reason:`no-samples`}),[];let t=new Map;for(let n of e){let e=this.operationKey(n),r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.values()].filter(e=>{let t=e.length>=this.minSampleSize;return t||this.logger?.debug(`SpecAnalyzer.analyzeSpecUsage.skipOperation`,{operation:this.operationKey(e[0]),sampleSize:e.length,minSampleSize:this.minSampleSize}),t}).map(e=>this.buildUsageStats(e))}detectAnomalies(e,t){let n=[];if(!e.length)return this.logger?.debug(`SpecAnalyzer.detectAnomalies.skip`,{reason:`no-stats`}),n;let r=new Map((t??[]).map(e=>[this.operationKey(e.operation),e]));for(let t of e){let e=[];if(t.errorRate>=this.errorRateThreshold){e.push({type:`telemetry`,description:`Error rate ${t.errorRate.toFixed(2)} exceeded threshold ${this.errorRateThreshold}`,data:{errorRate:t.errorRate}}),n.push({operation:t.operation,severity:this.toSeverity(t.errorRate/this.errorRateThreshold),metric:`error-rate`,description:`Error rate spike`,detectedAt:new Date,threshold:this.errorRateThreshold,observedValue:t.errorRate,evidence:e});continue}if(t.p99LatencyMs>=this.latencyP99ThresholdMs){e.push({type:`telemetry`,description:`P99 latency ${t.p99LatencyMs}ms exceeded threshold ${this.latencyP99ThresholdMs}ms`,data:{p99LatencyMs:t.p99LatencyMs}}),n.push({operation:t.operation,severity:this.toSeverity(t.p99LatencyMs/this.latencyP99ThresholdMs),metric:`latency`,description:`Latency regression detected`,detectedAt:new Date,threshold:this.latencyP99ThresholdMs,observedValue:t.p99LatencyMs,evidence:e});continue}let i=r.get(this.operationKey(t.operation));if(i){let r=(i.totalCalls-t.totalCalls)/i.totalCalls;r>=this.throughputDropThreshold&&(e.push({type:`telemetry`,description:`Throughput dropped by ${(r*100).toFixed(1)}% compared to baseline`,data:{baselineCalls:i.totalCalls,currentCalls:t.totalCalls}}),n.push({operation:t.operation,severity:this.toSeverity(r/this.throughputDropThreshold),metric:`throughput`,description:`Usage drop detected`,detectedAt:new Date,threshold:this.throughputDropThreshold,observedValue:r,evidence:e}))}}return n}toIntentPatterns(t,n){let r=new Map(n.map(e=>[this.operationKey(e.operation),e]));return t.map(t=>{let n=r.get(this.operationKey(t.operation)),i={score:Math.min(1,(t.observedValue??0)/(t.threshold??1)),sampleSize:n?.totalCalls??0,pValue:void 0};return{id:e(),type:this.mapMetricToIntent(t.metric),description:t.description,operation:t.operation,confidence:i,metadata:{observedValue:t.observedValue,threshold:t.threshold},evidence:t.evidence}})}suggestOptimizations(e,t,n){let r=new Map(this.groupByOperation(t)),i=[];for(let t of e){let e=this.operationKey(t.operation),a=r.get(e)??[];for(let e of a)if(e.metric===`latency`)i.push(this.applyLifecycleContext({operation:t.operation,category:`performance`,summary:`Latency regression detected`,justification:`P99 latency at ${t.p99LatencyMs}ms`,recommendedActions:[`Add batching or caching layer`,`Replay golden tests to capture slow inputs`]},n?.stage));else if(e.metric===`error-rate`){let e=Object.entries(t.topErrors).sort((e,t)=>t[1]-e[1])[0]?.[0];i.push(this.applyLifecycleContext({operation:t.operation,category:`error-handling`,summary:`Error spike detected`,justification:e?`Dominant error code ${e}`:`Increase in failures`,recommendedActions:[`Generate regression spec from failing payloads`,`Add policy guardrails before rollout`]},n?.stage))}else e.metric===`throughput`&&i.push(this.applyLifecycleContext({operation:t.operation,category:`performance`,summary:`Throughput drop detected`,justification:`Significant traffic reduction relative to baseline`,recommendedActions:[`Validate routing + feature flag bucketing`,`Backfill spec variant to rehydrate demand`]},n?.stage))}return i}operationKey(e){let t=`operation`in e?e.operation:e;return`${t.name}.v${t.version}${t.tenantId?`@${t.tenantId}`:``}`}buildUsageStats(e){let t=e.map(e=>e.durationMs).sort((e,t)=>e-t),n=e.filter(e=>!e.success),r=e.length,a=(r-n.length)/r,o=n.length/r,s=t.reduce((e,t)=>e+t,0)/r,c=n.reduce((e,t)=>(t.errorCode&&(e[t.errorCode]=(e[t.errorCode]??0)+1),e),{}),l=e.map(e=>e.timestamp.getTime()),u=new Date(Math.min(...l)),d=new Date(Math.max(...l));return{operation:e[0].operation,totalCalls:r,successRate:a,errorRate:o,averageLatencyMs:s,p95LatencyMs:i(t,.95),p99LatencyMs:i(t,.99),maxLatencyMs:Math.max(...t),lastSeenAt:d,windowStart:u,windowEnd:d,topErrors:c}}toSeverity(e){return e>=2?`high`:e>=1.3?`medium`:`low`}mapMetricToIntent(e){switch(e){case`error-rate`:return`error-spike`;case`latency`:return`latency-regression`;case`throughput`:return`throughput-drop`;default:return`schema-mismatch`}}groupByOperation(e){let t=new Map;for(let n of e){let e=this.operationKey(n.operation),r=t.get(e)??[];r.push(n),t.set(e,r)}return t}applyLifecycleContext(e,t){if(t===void 0)return e;let n=o[a(t)]?.[e.category];return n?{...e,lifecycleStage:t,lifecycleNotes:n.message,recommendedActions:s([...e.recommendedActions,...n.supplementalActions])}:{...e,lifecycleStage:t}}};function i(e,t){return e.length?e.length===1?e[0]:e[Math.min(e.length-1,Math.floor(t*e.length))]:0}const a=e=>e<=2?`early`:e===t.ProductMarketFit?`pmf`:e===t.GrowthScaleUp||e===t.ExpansionPlatform?`scale`:`mature`,o={early:{performance:{message:`Favor guardrails that protect learning velocity before heavy rewrites.`,supplementalActions:[`Wrap risky changes behind progressive delivery flags`]},"error-handling":{message:`Make failures loud and recoverable so you can learn faster.`,supplementalActions:[`Add auto-rollbacks or manual kill switches`]}},pmf:{performance:{message:`Stabilize the core use case to avoid regressions while demand grows.`,supplementalActions:[`Instrument regression tests on critical specs`]}},scale:{performance:{message:`Prioritize resilience and multi-tenant safety as volumes expand.`,supplementalActions:[`Introduce workload partitioning or isolation per tenant`]},"error-handling":{message:`Contain blast radius with policy fallbacks and circuit breakers.`,supplementalActions:[`Add circuit breakers to high-risk operations`]}},mature:{performance:{message:`Optimize for margins and predictable SLAs.`,supplementalActions:[`Capture unit-cost impacts alongside latency fixes`]},"error-handling":{message:`Prevent regressions with automated regression specs before deploy.`,supplementalActions:[`Run auto-evolution simulations on renewal scenarios`]}}},s=e=>{let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n};export{r as SpecAnalyzer};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
//# sourceMappingURL=integration.js.map
|
|
1
|
+
import{mkdir as e,writeFile as t}from"node:fs/promises";import{join as n}from"node:path";import"@lssm/lib.ai-agent/approval";var r=class{constructor(e){this.options=e}async submit(e,t,n){return await this.options.repository.create(e),t&&this.options.approval&&await this.options.approval.requestApproval({sessionId:t.sessionId,agentId:t.agentId,tenantId:t.tenantId,toolName:`evolution.apply_suggestion`,toolCallId:e.id,toolArgs:{suggestionId:e.id},reason:n??e.proposal.summary,payload:{suggestionId:e.id}}),e}async approve(e,t,n){let r=await this.ensureSuggestion(e);await this.options.repository.updateStatus(e,`approved`,{reviewer:t,notes:n,decidedAt:new Date}),this.options.writer&&await this.options.writer.write({...r,status:`approved`,approvals:{reviewer:t,notes:n,decidedAt:new Date,status:`approved`}})}async reject(e,t,n){await this.options.repository.updateStatus(e,`rejected`,{reviewer:t,notes:n,decidedAt:new Date})}list(e){return this.options.repository.list(e)}async ensureSuggestion(e){let t=await this.options.repository.getById(e);if(!t)throw Error(`Spec suggestion ${e} not found`);return t}},i=class{outputDir;filenameTemplate;constructor(e={}){this.outputDir=e.outputDir??n(process.cwd(),`packages/libs/contracts/src/generated`),this.filenameTemplate=e.filenameTemplate??(e=>`${e.target?.name??e.intent.id}.v${e.target?.version??`next`}.suggestion.json`)}async write(r){await e(this.outputDir,{recursive:!0});let i=this.filenameTemplate(r),a=n(this.outputDir,i),s=o(r);return await t(a,JSON.stringify(s,null,2)),a}},a=class{items=new Map;async create(e){this.items.set(e.id,e)}async getById(e){return this.items.get(e)}async updateStatus(e,t,n){let r=await this.getById(e);r&&this.items.set(e,{...r,status:t,approvals:{reviewer:n?.reviewer,notes:n?.notes,decidedAt:n?.decidedAt,status:t}})}async list(e){let t=[...this.items.values()];return e?t.filter(t=>!(e.status&&t.status!==e.status||e.operationName&&t.target?.name!==e.operationName)):t}};function o(e){let{proposal:t,...n}=e,{spec:r,...i}=t;return{...n,proposal:{...i,specMeta:r?.meta},createdAt:e.createdAt.toISOString(),intent:{...e.intent,confidence:{...e.intent.confidence},evidence:e.intent.evidence}}}export{i as FileSystemSuggestionWriter,a as InMemorySpecSuggestionRepository,r as SpecSuggestionOrchestrator};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{randomUUID as e}from"node:crypto";import{Output as t,generateText as n}from"ai";import*as r from"zod";const i=r.object({summary:r.string().describe(`Brief summary of the proposed change`),rationale:r.string().describe(`Detailed explanation of why this change is needed`),changeType:r.enum([`new-spec`,`revision`,`policy-update`,`schema-update`]).describe(`Type of change being proposed`),recommendedActions:r.array(r.string()).describe(`List of specific actions to implement the change`),estimatedImpact:r.enum([`low`,`medium`,`high`]).describe(`Estimated impact of implementing this change`),riskLevel:r.enum([`low`,`medium`,`high`]).describe(`Risk level associated with this change`),diff:r.string().optional().describe(`Optional diff or code snippet showing the change`)});var a=class{model;config;systemPrompt;constructor(e){this.model=e.model,this.config=e.evolutionConfig??{},this.systemPrompt=e.systemPrompt??`You are a ContractSpec evolution expert. Your role is to analyze telemetry data, anomalies, and usage patterns to suggest improvements to API contracts and specifications.
|
|
2
|
+
|
|
3
|
+
When generating suggestions:
|
|
4
|
+
1. Be specific and actionable
|
|
5
|
+
2. Consider backwards compatibility
|
|
6
|
+
3. Prioritize stability and reliability
|
|
7
|
+
4. Explain the rationale clearly
|
|
8
|
+
5. Estimate impact and risk accurately`}async generateFromIntent(e,r={}){let a=this.buildPrompt(e,r),{output:o}=await n({model:this.model,system:this.systemPrompt,prompt:a,output:t.object({schema:i})});return this.buildSuggestion(e,o)}async generateBatch(e,t={}){let n=t.maxConcurrent??3,r=[];for(let t=0;t<e.length;t+=n){let i=e.slice(t,t+n),a=await Promise.all(i.map(e=>this.generateFromIntent(e)));r.push(...a)}return r}async enhanceSuggestion(e){let r=`Review and enhance this spec suggestion:
|
|
9
|
+
|
|
10
|
+
Intent: ${e.intent.type} - ${e.intent.description}
|
|
11
|
+
Current Summary: ${e.proposal.summary}
|
|
12
|
+
Current Rationale: ${e.proposal.rationale}
|
|
13
|
+
|
|
14
|
+
Evidence:
|
|
15
|
+
${e.evidence.map(e=>`- ${e.type}: ${e.description}`).join(`
|
|
16
|
+
`)}
|
|
17
|
+
|
|
18
|
+
Please provide an improved version with more specific recommendations.`,{output:a}=await n({model:this.model,system:this.systemPrompt,prompt:r,output:t.object({schema:i})});return{...e,proposal:{...e.proposal,summary:a.summary,rationale:a.rationale,changeType:a.changeType,diff:a.diff,metadata:{...e.proposal.metadata,aiEnhanced:!0,recommendedActions:a.recommendedActions,estimatedImpact:a.estimatedImpact,riskLevel:a.riskLevel}}}}buildPrompt(e,t){let n=[`Analyze this intent pattern and generate a spec suggestion:`,``,`Intent Type: ${e.type}`,`Description: ${e.description}`,`Confidence: ${(e.confidence.score*100).toFixed(0)}% (sample size: ${e.confidence.sampleSize})`];if(e.operation&&n.push(`Operation: ${e.operation.name} v${e.operation.version}`),e.evidence.length>0){n.push(``,`Evidence:`);for(let t of e.evidence)n.push(`- [${t.type}] ${t.description}`)}return e.metadata&&n.push(``,`Metadata: ${JSON.stringify(e.metadata,null,2)}`),t.existingSpec&&n.push(``,`Existing Spec:`,"```json",JSON.stringify(t.existingSpec,null,2),"```"),t.additionalContext&&n.push(``,`Additional Context:`,t.additionalContext),n.join(`
|
|
19
|
+
`)}buildSuggestion(t,n){let r=new Date,i={summary:n.summary,rationale:n.rationale,changeType:n.changeType,diff:n.diff,metadata:{aiGenerated:!0,recommendedActions:n.recommendedActions,estimatedImpact:n.estimatedImpact,riskLevel:n.riskLevel}};return{id:e(),intent:t,target:t.operation,proposal:i,confidence:t.confidence.score,priority:this.calculatePriority(t,n),createdAt:r,createdBy:`ai-spec-generator`,status:this.determineInitialStatus(t),evidence:t.evidence,tags:[`ai-generated`,t.type]}}calculatePriority(e,t){let n=t.estimatedImpact===`high`?1:t.estimatedImpact===`medium`?.5:.25,r=e.confidence.score,i=e.type===`error-spike`?.3:e.type===`latency-regression`?.2:0,a=n*.4+r*.4+i;return a>=.7?`high`:a>=.4?`medium`:`low`}determineInitialStatus(e){return this.config.autoApproveThreshold&&e.confidence.score>=this.config.autoApproveThreshold&&!this.config.requireApproval?`approved`:`pending`}};function o(e){return new a(e)}export{a as AISpecGenerator,o as createAISpecGenerator};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import"
|
|
2
|
-
//# sourceMappingURL=spec-generator.js.map
|
|
1
|
+
import"@lssm/lib.observability";import{randomUUID as e}from"node:crypto";var t=class{config;logger;clock;getSpec;constructor(e={}){this.config=e.config??{},this.logger=e.logger,this.clock=e.clock??(()=>new Date),this.getSpec=e.getSpec}generateFromIntent(t,n={}){let r=this.clock(),i=n.summary??`${this.intentToVerb(t.type)} ${t.operation?.name??`operation`}`,a=n.rationale??[t.description,t.metadata?.observedValue?`Observed ${t.metadata.observedValue}`:void 0].filter(Boolean).join(` — `);return{id:e(),intent:t,target:t.operation,proposal:{summary:i,rationale:a,changeType:n.changeType??this.inferChangeType(t),kind:n.kind,spec:n.spec,diff:n.diff,metadata:n.metadata},confidence:t.confidence.score,priority:this.intentToPriority(t),createdAt:r,createdBy:n.createdBy??`auto-evolution`,status:n.status??`pending`,evidence:t.evidence,tags:n.tags}}generateVariant(e,t,r,i={}){if(!this.getSpec)throw Error(`SpecGenerator requires getSpec() to generate variants`);let a=this.getSpec(e.name,e.version);if(!a)throw Error(`Cannot generate variant; spec ${e.name}.v${e.version} not found`);let o=n(a,t);return this.generateFromIntent(r,{...i,spec:o})}validateSuggestion(e,t=this.config){let n=[];t.minConfidence!=null&&e.confidence<t.minConfidence&&n.push(`Confidence ${e.confidence.toFixed(2)} below minimum ${t.minConfidence}`),t.requireApproval&&e.status===`approved`&&n.push(`Suggestion cannot be auto-approved when approval is required`),e.proposal.spec&&!e.proposal.spec.meta?.name&&n.push(`Proposal spec must include meta.name`),e.proposal.summary||n.push(`Proposal summary is required`);let r=n.length===0;return r||this.logger?.warn(`SpecGenerator.validateSuggestion.failed`,{suggestionId:e.id,reasons:n}),{ok:r,reasons:n}}intentToVerb(e){switch(e){case`error-spike`:return`Stabilize`;case`latency-regression`:return`Optimize`;case`missing-operation`:return`Introduce`;case`throughput-drop`:return`Rebalance`;default:return`Adjust`}}intentToPriority(e){let t=e.confidence.score;return e.type===`error-spike`||t>=.8?`high`:t>=.5?`medium`:`low`}inferChangeType(e){switch(e.type){case`missing-operation`:return`new-spec`;case`schema-mismatch`:return`schema-update`;case`error-spike`:return`policy-update`;default:return`revision`}}};function n(e,t){return{...e,...t,meta:{...e.meta,...t.meta},io:{...e.io,...t.io},policy:{...e.policy,...t.policy},telemetry:{...e.telemetry,...t.telemetry},sideEffects:{...e.sideEffects,...t.sideEffects}}}export{t as SpecGenerator};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SpecAnalyzer as e}from"./analyzer/spec-analyzer.js";import{SpecGenerator as t}from"./generator/spec-generator.js";import{
|
|
1
|
+
import{SpecAnalyzer as e}from"./analyzer/spec-analyzer.js";import{SpecGenerator as t}from"./generator/spec-generator.js";import{AISpecGenerator as n,createAISpecGenerator as r}from"./generator/ai-spec-generator.js";import{FileSystemSuggestionWriter as i,InMemorySpecSuggestionRepository as a,SpecSuggestionOrchestrator as o}from"./approval/integration.js";export{n as AISpecGenerator,i as FileSystemSuggestionWriter,a as InMemorySpecSuggestionRepository,e as SpecAnalyzer,t as SpecGenerator,o as SpecSuggestionOrchestrator,r as createAISpecGenerator};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/lib.evolution",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -19,29 +19,35 @@
|
|
|
19
19
|
"lint": "bun lint:fix",
|
|
20
20
|
"lint:fix": "eslint src --fix",
|
|
21
21
|
"lint:check": "eslint src",
|
|
22
|
-
"test": "bun
|
|
22
|
+
"test": "bun test"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"@lssm/lib.
|
|
28
|
-
"@lssm/lib.
|
|
29
|
-
"@lssm/lib.
|
|
25
|
+
"ai": "beta",
|
|
26
|
+
"zod": "^4.1.13",
|
|
27
|
+
"@lssm/lib.ai-agent": "workspace:*",
|
|
28
|
+
"@lssm/lib.contracts": "workspace:*",
|
|
29
|
+
"@lssm/lib.lifecycle": "workspace:*",
|
|
30
|
+
"@lssm/lib.observability": "workspace:*",
|
|
31
|
+
"@lssm/lib.schema": "workspace:*"
|
|
30
32
|
},
|
|
31
33
|
"peerDependencies": {
|
|
32
|
-
"@prisma/client": "7.
|
|
34
|
+
"@prisma/client": "7.1.0"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
|
-
"@lssm/tool.tsdown": "
|
|
36
|
-
"@lssm/tool.typescript": "
|
|
37
|
-
"tsdown": "^0.
|
|
37
|
+
"@lssm/tool.tsdown": "workspace:*",
|
|
38
|
+
"@lssm/tool.typescript": "workspace:*",
|
|
39
|
+
"tsdown": "^0.17.4",
|
|
38
40
|
"typescript": "^5.9.3"
|
|
39
41
|
},
|
|
40
42
|
"exports": {
|
|
41
|
-
".": "./
|
|
43
|
+
".": "./src/index.ts",
|
|
42
44
|
"./*": "./*"
|
|
43
45
|
},
|
|
44
46
|
"publishConfig": {
|
|
45
|
-
"access": "public"
|
|
47
|
+
"access": "public",
|
|
48
|
+
"exports": {
|
|
49
|
+
".": "./dist/index.js",
|
|
50
|
+
"./*": "./*"
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
53
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./workflow.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{randomUUID as e}from"node:crypto";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { IntentPattern, OperationMetricSample, OptimizationHint, SpecAnomaly, SpecUsageStats } from "../types.js";
|
|
2
|
-
import { LifecycleStage } from "@lssm/lib.lifecycle";
|
|
3
|
-
import { Logger } from "@lssm/lib.observability";
|
|
4
|
-
|
|
5
|
-
//#region src/analyzer/spec-analyzer.d.ts
|
|
6
|
-
interface SpecAnalyzerOptions {
|
|
7
|
-
logger?: Logger;
|
|
8
|
-
minSampleSize?: number;
|
|
9
|
-
errorRateThreshold?: number;
|
|
10
|
-
latencyP99ThresholdMs?: number;
|
|
11
|
-
throughputDropThreshold?: number;
|
|
12
|
-
}
|
|
13
|
-
declare class SpecAnalyzer {
|
|
14
|
-
private readonly logger?;
|
|
15
|
-
private readonly minSampleSize;
|
|
16
|
-
private readonly errorRateThreshold;
|
|
17
|
-
private readonly latencyP99ThresholdMs;
|
|
18
|
-
private readonly throughputDropThreshold;
|
|
19
|
-
constructor(options?: SpecAnalyzerOptions);
|
|
20
|
-
analyzeSpecUsage(samples: OperationMetricSample[]): SpecUsageStats[];
|
|
21
|
-
detectAnomalies(stats: SpecUsageStats[], baseline?: SpecUsageStats[]): SpecAnomaly[];
|
|
22
|
-
toIntentPatterns(anomalies: SpecAnomaly[], stats: SpecUsageStats[]): IntentPattern[];
|
|
23
|
-
suggestOptimizations(stats: SpecUsageStats[], anomalies: SpecAnomaly[], lifecycleContext?: {
|
|
24
|
-
stage: LifecycleStage;
|
|
25
|
-
}): OptimizationHint[];
|
|
26
|
-
private operationKey;
|
|
27
|
-
private buildUsageStats;
|
|
28
|
-
private toSeverity;
|
|
29
|
-
private mapMetricToIntent;
|
|
30
|
-
private groupByOperation;
|
|
31
|
-
private applyLifecycleContext;
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { SpecAnalyzer, SpecAnalyzerOptions };
|
|
35
|
-
//# sourceMappingURL=spec-analyzer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec-analyzer.d.ts","names":[],"sources":["../../src/analyzer/spec-analyzer.ts"],"sourcesContent":[],"mappings":";;;;;UAciB,mBAAA;WACN;EADM,aAAA,CAAA,EAAA,MAAmB;EAmBvB,kBAAY,CAAA,EAAA,MAAA;EAOF,qBAAA,CAAA,EAAA,MAAA;EAUK,uBAAA,CAAA,EAAA,MAAA;;AAmCjB,cApDE,YAAA,CAoDF;EACI,iBAAA,MAAA;EACV,iBAAA,aAAA;EAsFU,iBAAA,kBAAA;EACJ,iBAAA,qBAAA;EACN,iBAAA,uBAAA;EA8BM,WAAA,CAAA,OAAA,CAAA,EArKY,mBAqKZ;EACI,gBAAA,CAAA,OAAA,EA5Ja,qBA4Jb,EAAA,CAAA,EA5JuC,cA4JvC,EAAA;EACiB,eAAA,CAAA,KAAA,EA1HrB,cA0HqB,EAAA,EAAA,QAAA,CAAA,EAzHjB,cAyHiB,EAAA,CAAA,EAxH3B,WAwH2B,EAAA;EAC3B,gBAAA,CAAA,SAAA,EAnCU,WAmCV,EAAA,EAAA,KAAA,EAlCM,cAkCN,EAAA,CAAA,EAjCA,aAiCA,EAAA;EAAgB,oBAAA,CAAA,KAAA,EAHV,cAGU,EAAA,EAAA,SAAA,EAFN,WAEM,EAAA,EAAA,iBAAA,EAAA;WADW;MAC3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec-analyzer.js","names":["DEFAULT_OPTIONS: Required<\n Pick<\n SpecAnalyzerOptions,\n 'minSampleSize' | 'errorRateThreshold' | 'latencyP99ThresholdMs'\n >\n>","anomalies: SpecAnomaly[]","evidence: SuggestionEvidence[]","confidence: PatternConfidence","hints: OptimizationHint[]","LifecycleStage","LIFECYCLE_HINTS: Record<\n StageBand,\n Partial<\n Record<\n OptimizationHint['category'],\n { message: string; supplementalActions: string[] }\n >\n >\n>","ordered: string[]"],"sources":["../../src/analyzer/spec-analyzer.ts"],"sourcesContent":["import { Logger } from '@lssm/lib.observability';\nimport { randomUUID } from 'node:crypto';\nimport { LifecycleStage } from '@lssm/lib.lifecycle';\nimport {\n type IntentPattern,\n type OperationCoordinate,\n type OperationMetricSample,\n type OptimizationHint,\n type PatternConfidence,\n type SpecAnomaly,\n type SpecUsageStats,\n type SuggestionEvidence,\n} from '../types';\n\nexport interface SpecAnalyzerOptions {\n logger?: Logger;\n minSampleSize?: number;\n errorRateThreshold?: number;\n latencyP99ThresholdMs?: number;\n throughputDropThreshold?: number;\n}\n\nconst DEFAULT_OPTIONS: Required<\n Pick<\n SpecAnalyzerOptions,\n 'minSampleSize' | 'errorRateThreshold' | 'latencyP99ThresholdMs'\n >\n> = {\n minSampleSize: 50,\n errorRateThreshold: 0.05,\n latencyP99ThresholdMs: 750,\n};\n\nexport class SpecAnalyzer {\n private readonly logger?: Logger;\n private readonly minSampleSize: number;\n private readonly errorRateThreshold: number;\n private readonly latencyP99ThresholdMs: number;\n private readonly throughputDropThreshold: number;\n\n constructor(options: SpecAnalyzerOptions = {}) {\n this.logger = options.logger;\n this.minSampleSize = options.minSampleSize ?? DEFAULT_OPTIONS.minSampleSize;\n this.errorRateThreshold =\n options.errorRateThreshold ?? DEFAULT_OPTIONS.errorRateThreshold;\n this.latencyP99ThresholdMs =\n options.latencyP99ThresholdMs ?? DEFAULT_OPTIONS.latencyP99ThresholdMs;\n this.throughputDropThreshold = options.throughputDropThreshold ?? 0.2;\n }\n\n analyzeSpecUsage(samples: OperationMetricSample[]): SpecUsageStats[] {\n if (!samples.length) {\n this.logger?.debug('SpecAnalyzer.analyzeSpecUsage.skip', {\n reason: 'no-samples',\n });\n return [];\n }\n\n const groups = new Map<string, OperationMetricSample[]>();\n for (const sample of samples) {\n const key = this.operationKey(sample);\n const arr = groups.get(key) ?? [];\n arr.push(sample);\n groups.set(key, arr);\n }\n\n const entries = [...groups.values()];\n const usable = entries.filter((samplesForOp) => {\n const valid = samplesForOp.length >= this.minSampleSize;\n if (!valid) {\n this.logger?.debug('SpecAnalyzer.analyzeSpecUsage.skipOperation', {\n operation: this.operationKey(samplesForOp[0]!),\n sampleSize: samplesForOp.length,\n minSampleSize: this.minSampleSize,\n });\n }\n return valid;\n });\n\n return usable.map((operationSamples) =>\n this.buildUsageStats(operationSamples)\n );\n }\n\n detectAnomalies(\n stats: SpecUsageStats[],\n baseline?: SpecUsageStats[]\n ): SpecAnomaly[] {\n const anomalies: SpecAnomaly[] = [];\n if (!stats.length) {\n this.logger?.debug('SpecAnalyzer.detectAnomalies.skip', {\n reason: 'no-stats',\n });\n return anomalies;\n }\n const baselineByOp = new Map(\n (baseline ?? []).map((item) => [this.operationKey(item.operation), item])\n );\n\n for (const stat of stats) {\n const evidence: SuggestionEvidence[] = [];\n\n if (stat.errorRate >= this.errorRateThreshold) {\n evidence.push({\n type: 'telemetry',\n description: `Error rate ${stat.errorRate.toFixed(2)} exceeded threshold ${this.errorRateThreshold}`,\n data: { errorRate: stat.errorRate },\n });\n anomalies.push({\n operation: stat.operation,\n severity: this.toSeverity(stat.errorRate / this.errorRateThreshold),\n metric: 'error-rate',\n description: 'Error rate spike',\n detectedAt: new Date(),\n threshold: this.errorRateThreshold,\n observedValue: stat.errorRate,\n evidence,\n });\n continue;\n }\n\n if (stat.p99LatencyMs >= this.latencyP99ThresholdMs) {\n evidence.push({\n type: 'telemetry',\n description: `P99 latency ${stat.p99LatencyMs}ms exceeded threshold ${this.latencyP99ThresholdMs}ms`,\n data: { p99LatencyMs: stat.p99LatencyMs },\n });\n anomalies.push({\n operation: stat.operation,\n severity: this.toSeverity(\n stat.p99LatencyMs / this.latencyP99ThresholdMs\n ),\n metric: 'latency',\n description: 'Latency regression detected',\n detectedAt: new Date(),\n threshold: this.latencyP99ThresholdMs,\n observedValue: stat.p99LatencyMs,\n evidence,\n });\n continue;\n }\n\n const baselineStat = baselineByOp.get(this.operationKey(stat.operation));\n if (baselineStat) {\n const drop =\n (baselineStat.totalCalls - stat.totalCalls) / baselineStat.totalCalls;\n if (drop >= this.throughputDropThreshold) {\n evidence.push({\n type: 'telemetry',\n description: `Throughput dropped by ${(drop * 100).toFixed(1)}% compared to baseline`,\n data: {\n baselineCalls: baselineStat.totalCalls,\n currentCalls: stat.totalCalls,\n },\n });\n anomalies.push({\n operation: stat.operation,\n severity: this.toSeverity(drop / this.throughputDropThreshold),\n metric: 'throughput',\n description: 'Usage drop detected',\n detectedAt: new Date(),\n threshold: this.throughputDropThreshold,\n observedValue: drop,\n evidence,\n });\n }\n }\n }\n\n return anomalies;\n }\n\n toIntentPatterns(\n anomalies: SpecAnomaly[],\n stats: SpecUsageStats[]\n ): IntentPattern[] {\n const statsByOp = new Map(\n stats.map((item) => [this.operationKey(item.operation), item])\n );\n return anomalies.map((anomaly) => {\n const stat = statsByOp.get(this.operationKey(anomaly.operation));\n const confidence: PatternConfidence = {\n score: Math.min(\n 1,\n (anomaly.observedValue ?? 0) / (anomaly.threshold ?? 1)\n ),\n sampleSize: stat?.totalCalls ?? 0,\n pValue: undefined,\n };\n return {\n id: randomUUID(),\n type: this.mapMetricToIntent(anomaly.metric),\n description: anomaly.description,\n operation: anomaly.operation,\n confidence,\n metadata: {\n observedValue: anomaly.observedValue,\n threshold: anomaly.threshold,\n },\n evidence: anomaly.evidence,\n };\n });\n }\n\n suggestOptimizations(\n stats: SpecUsageStats[],\n anomalies: SpecAnomaly[],\n lifecycleContext?: { stage: LifecycleStage }\n ): OptimizationHint[] {\n const anomaliesByOp = new Map<string, SpecAnomaly[]>(\n this.groupByOperation(anomalies)\n );\n const hints: OptimizationHint[] = [];\n\n for (const stat of stats) {\n const opKey = this.operationKey(stat.operation);\n const opAnomalies = anomaliesByOp.get(opKey) ?? [];\n for (const anomaly of opAnomalies) {\n if (anomaly.metric === 'latency') {\n hints.push(\n this.applyLifecycleContext(\n {\n operation: stat.operation,\n category: 'performance',\n summary: 'Latency regression detected',\n justification: `P99 latency at ${stat.p99LatencyMs}ms`,\n recommendedActions: [\n 'Add batching or caching layer',\n 'Replay golden tests to capture slow inputs',\n ],\n },\n lifecycleContext?.stage\n )\n );\n } else if (anomaly.metric === 'error-rate') {\n const topError = Object.entries(stat.topErrors).sort(\n (a, b) => b[1] - a[1]\n )[0]?.[0];\n hints.push(\n this.applyLifecycleContext(\n {\n operation: stat.operation,\n category: 'error-handling',\n summary: 'Error spike detected',\n justification: topError\n ? `Dominant error code ${topError}`\n : 'Increase in failures',\n recommendedActions: [\n 'Generate regression spec from failing payloads',\n 'Add policy guardrails before rollout',\n ],\n },\n lifecycleContext?.stage\n )\n );\n } else if (anomaly.metric === 'throughput') {\n hints.push(\n this.applyLifecycleContext(\n {\n operation: stat.operation,\n category: 'performance',\n summary: 'Throughput drop detected',\n justification:\n 'Significant traffic reduction relative to baseline',\n recommendedActions: [\n 'Validate routing + feature flag bucketing',\n 'Backfill spec variant to rehydrate demand',\n ],\n },\n lifecycleContext?.stage\n )\n );\n }\n }\n }\n return hints;\n }\n\n private operationKey(\n op:\n | OperationCoordinate\n | SpecUsageStats\n | SpecAnomaly\n | OperationMetricSample\n ) {\n const coordinate =\n 'operation' in op ? (op.operation as OperationCoordinate) : op;\n return `${coordinate.name}.v${coordinate.version}${\n coordinate.tenantId ? `@${coordinate.tenantId}` : ''\n }`;\n }\n\n private buildUsageStats(samples: OperationMetricSample[]): SpecUsageStats {\n const durations = samples.map((s) => s.durationMs).sort((a, b) => a - b);\n const errors = samples.filter((s) => !s.success);\n const totalCalls = samples.length;\n const successRate = (totalCalls - errors.length) / totalCalls;\n const errorRate = errors.length / totalCalls;\n const averageLatencyMs =\n durations.reduce((sum, value) => sum + value, 0) / totalCalls;\n\n const topErrors = errors.reduce<Record<string, number>>((acc, sample) => {\n if (!sample.errorCode) return acc;\n acc[sample.errorCode] = (acc[sample.errorCode] ?? 0) + 1;\n return acc;\n }, {});\n\n const timestamps = samples.map((s) => s.timestamp.getTime());\n const windowStart = new Date(Math.min(...timestamps));\n const windowEnd = new Date(Math.max(...timestamps));\n\n return {\n operation: samples[0]!.operation,\n totalCalls,\n successRate,\n errorRate,\n averageLatencyMs,\n p95LatencyMs: percentile(durations, 0.95),\n p99LatencyMs: percentile(durations, 0.99),\n maxLatencyMs: Math.max(...durations),\n lastSeenAt: windowEnd,\n windowStart,\n windowEnd,\n topErrors,\n };\n }\n\n private toSeverity(ratio: number): SpecAnomaly['severity'] {\n if (ratio >= 2) return 'high';\n if (ratio >= 1.3) return 'medium';\n return 'low';\n }\n\n private mapMetricToIntent(\n metric: SpecAnomaly['metric']\n ): IntentPattern['type'] {\n switch (metric) {\n case 'error-rate':\n return 'error-spike';\n case 'latency':\n return 'latency-regression';\n case 'throughput':\n return 'throughput-drop';\n default:\n return 'schema-mismatch';\n }\n }\n\n private groupByOperation<T extends { operation: OperationCoordinate }>(\n items: T[]\n ): Map<string, T[]> {\n const map = new Map<string, T[]>();\n for (const item of items) {\n const key = this.operationKey(item.operation);\n const arr = map.get(key) ?? [];\n arr.push(item);\n map.set(key, arr);\n }\n return map;\n }\n\n private applyLifecycleContext(\n hint: OptimizationHint,\n stage?: LifecycleStage\n ): OptimizationHint {\n if (stage === undefined) return hint;\n const band = mapStageBand(stage);\n const advice = LIFECYCLE_HINTS[band]?.[hint.category];\n if (!advice) {\n return { ...hint, lifecycleStage: stage };\n }\n return {\n ...hint,\n lifecycleStage: stage,\n lifecycleNotes: advice.message,\n recommendedActions: dedupeActions([\n ...hint.recommendedActions,\n ...advice.supplementalActions,\n ]),\n };\n }\n}\n\nfunction percentile(values: number[], p: number): number {\n if (!values.length) return 0;\n if (values.length === 1) return values[0]!;\n const idx = Math.min(values.length - 1, Math.floor(p * values.length));\n return values[idx]!;\n}\n\ntype StageBand = 'early' | 'pmf' | 'scale' | 'mature';\n\nconst mapStageBand = (stage: LifecycleStage): StageBand => {\n if (stage <= 2) return 'early';\n if (stage === LifecycleStage.ProductMarketFit) return 'pmf';\n if (\n stage === LifecycleStage.GrowthScaleUp ||\n stage === LifecycleStage.ExpansionPlatform\n ) {\n return 'scale';\n }\n return 'mature';\n};\n\nconst LIFECYCLE_HINTS: Record<\n StageBand,\n Partial<\n Record<\n OptimizationHint['category'],\n { message: string; supplementalActions: string[] }\n >\n >\n> = {\n early: {\n performance: {\n message:\n 'Favor guardrails that protect learning velocity before heavy rewrites.',\n supplementalActions: [\n 'Wrap risky changes behind progressive delivery flags',\n ],\n },\n 'error-handling': {\n message: 'Make failures loud and recoverable so you can learn faster.',\n supplementalActions: ['Add auto-rollbacks or manual kill switches'],\n },\n },\n pmf: {\n performance: {\n message:\n 'Stabilize the core use case to avoid regressions while demand grows.',\n supplementalActions: ['Instrument regression tests on critical specs'],\n },\n },\n scale: {\n performance: {\n message:\n 'Prioritize resilience and multi-tenant safety as volumes expand.',\n supplementalActions: [\n 'Introduce workload partitioning or isolation per tenant',\n ],\n },\n 'error-handling': {\n message:\n 'Contain blast radius with policy fallbacks and circuit breakers.',\n supplementalActions: ['Add circuit breakers to high-risk operations'],\n },\n },\n mature: {\n performance: {\n message: 'Optimize for margins and predictable SLAs.',\n supplementalActions: [\n 'Capture unit-cost impacts alongside latency fixes',\n ],\n },\n 'error-handling': {\n message:\n 'Prevent regressions with automated regression specs before deploy.',\n supplementalActions: [\n 'Run auto-evolution simulations on renewal scenarios',\n ],\n },\n },\n};\n\nconst dedupeActions = (actions: string[]): string[] => {\n const seen = new Set<string>();\n const ordered: string[] = [];\n for (const action of actions) {\n if (seen.has(action)) continue;\n seen.add(action);\n ordered.push(action);\n }\n return ordered;\n};\n"],"mappings":"oKAsBA,MAAMA,EAKF,CACF,cAAe,GACf,mBAAoB,IACpB,sBAAuB,IACxB,CAED,IAAa,EAAb,KAA0B,CACxB,OACA,cACA,mBACA,sBACA,wBAEA,YAAY,EAA+B,EAAE,CAAE,CAC7C,KAAK,OAAS,EAAQ,OACtB,KAAK,cAAgB,EAAQ,eAAiB,EAAgB,cAC9D,KAAK,mBACH,EAAQ,oBAAsB,EAAgB,mBAChD,KAAK,sBACH,EAAQ,uBAAyB,EAAgB,sBACnD,KAAK,wBAA0B,EAAQ,yBAA2B,GAGpE,iBAAiB,EAAoD,CACnE,GAAI,CAAC,EAAQ,OAIX,OAHA,KAAK,QAAQ,MAAM,qCAAsC,CACvD,OAAQ,aACT,CAAC,CACK,EAAE,CAGX,IAAM,EAAS,IAAI,IACnB,IAAK,IAAM,KAAU,EAAS,CAC5B,IAAM,EAAM,KAAK,aAAa,EAAO,CAC/B,EAAM,EAAO,IAAI,EAAI,EAAI,EAAE,CACjC,EAAI,KAAK,EAAO,CAChB,EAAO,IAAI,EAAK,EAAI,CAgBtB,MAbgB,CAAC,GAAG,EAAO,QAAQ,CAAC,CACb,OAAQ,GAAiB,CAC9C,IAAM,EAAQ,EAAa,QAAU,KAAK,cAQ1C,O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AS,EAAU,QACnB,IAAUC,EAAe,iBAAyB,MAEpD,IAAUA,EAAe,eACzB,IAAUA,EAAe,kBAElB,QAEF,SAGHC,EAQF,CACF,MAAO,CACL,YAAa,CACX,QACE,yEACF,oBAAqB,CACnB,uDACD,CACF,CACD,iBAAkB,CAChB,QAAS,8DACT,oBAAqB,CAAC,6CAA6C,CACpE,CACF,CACD,IAAK,CACH,YAAa,CACX,QACE,uEACF,oBAAqB,CAAC,gDAAgD,CACvE,CACF,CACD,MAAO,CACL,YAAa,CACX,QACE,mEACF,oBAAqB,CACnB,0DACD,CACF,CACD,iBAAkB,CAChB,QACE,mEACF,oBAAqB,CAAC,+CAA+C,CACtE,CACF,CACD,OAAQ,CACN,YAAa,CACX,QAAS,6CACT,oBAAqB,CACnB,oDACD,CACF,CACD,iBAAkB,CAChB,QACE,qEACF,oBAAqB,CACnB,sDACD,CACF,CACF,CACF,CAEK,EAAiB,GAAgC,CACrD,IAAM,EAAO,IAAI,IACXC,EAAoB,EAAE,CAC5B,IAAK,IAAM,KAAU,EACf,EAAK,IAAI,EAAO,GACpB,EAAK,IAAI,EAAO,CAChB,EAAQ,KAAK,EAAO,EAEtB,OAAO"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { SpecSuggestion, SpecSuggestionFilters, SpecSuggestionRepository, SpecSuggestionWriter, SuggestionStatus } from "../types.js";
|
|
2
|
-
import { ApprovalWorkflow } from "@lssm/lib.ai-agent/approval";
|
|
3
|
-
import { AgentSessionState } from "@lssm/lib.ai-agent/types";
|
|
4
|
-
|
|
5
|
-
//#region src/approval/integration.d.ts
|
|
6
|
-
interface SpecSuggestionOrchestratorOptions {
|
|
7
|
-
repository: SpecSuggestionRepository;
|
|
8
|
-
approval?: ApprovalWorkflow;
|
|
9
|
-
writer?: SpecSuggestionWriter;
|
|
10
|
-
}
|
|
11
|
-
declare class SpecSuggestionOrchestrator {
|
|
12
|
-
private readonly options;
|
|
13
|
-
constructor(options: SpecSuggestionOrchestratorOptions);
|
|
14
|
-
submit(suggestion: SpecSuggestion, session?: AgentSessionState, approvalReason?: string): Promise<SpecSuggestion>;
|
|
15
|
-
approve(id: string, reviewer: string, notes?: string): Promise<void>;
|
|
16
|
-
reject(id: string, reviewer: string, notes?: string): Promise<void>;
|
|
17
|
-
list(filters?: SpecSuggestionFilters): Promise<SpecSuggestion[]>;
|
|
18
|
-
private ensureSuggestion;
|
|
19
|
-
}
|
|
20
|
-
interface FileSystemSuggestionWriterOptions {
|
|
21
|
-
outputDir?: string;
|
|
22
|
-
filenameTemplate?: (suggestion: SpecSuggestion) => string;
|
|
23
|
-
}
|
|
24
|
-
declare class FileSystemSuggestionWriter implements SpecSuggestionWriter {
|
|
25
|
-
private readonly outputDir;
|
|
26
|
-
private readonly filenameTemplate;
|
|
27
|
-
constructor(options?: FileSystemSuggestionWriterOptions);
|
|
28
|
-
write(suggestion: SpecSuggestion): Promise<string>;
|
|
29
|
-
}
|
|
30
|
-
declare class InMemorySpecSuggestionRepository implements SpecSuggestionRepository {
|
|
31
|
-
private readonly items;
|
|
32
|
-
create(suggestion: SpecSuggestion): Promise<void>;
|
|
33
|
-
getById(id: string): Promise<SpecSuggestion | undefined>;
|
|
34
|
-
updateStatus(id: string, status: SuggestionStatus, metadata?: {
|
|
35
|
-
reviewer?: string;
|
|
36
|
-
notes?: string;
|
|
37
|
-
decidedAt?: Date;
|
|
38
|
-
}): Promise<void>;
|
|
39
|
-
list(filters?: SpecSuggestionFilters): Promise<SpecSuggestion[]>;
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
export { FileSystemSuggestionWriter, FileSystemSuggestionWriterOptions, InMemorySpecSuggestionRepository, SpecSuggestionOrchestrator, SpecSuggestionOrchestratorOptions };
|
|
43
|
-
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","names":[],"sources":["../../src/approval/integration.ts"],"sourcesContent":[],"mappings":";;;;;UAYiB,i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A;EAAiB,YAAA,CAAA,EAAA,EAAA,MAAA,EAAA,MAAA,EAUhC,gBAVgC,EAAA,QAWoB,CAXpB,EAAA;IAIP,QAAA,CAAA,EAAA,MAAA;IAAR,KAAA,CAAA,EAAA,MAAA;IAMjB,SAAA,CAAA,EACoD,IADpD;EACoD,CAAA,CAAA,EAC3D,OAD2D,CAAA,IAAA,CAAA;EAC3D,IAAA,CAAA,OAAA,CAAA,EAekB,qBAflB,CAAA,EAeuC,OAfvC,CAeuC,cAfvC,EAAA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","names":["options: SpecSuggestionOrchestratorOptions"],"sources":["../../src/approval/integration.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { ApprovalWorkflow } from '@lssm/lib.ai-agent/approval';\nimport type { AgentSessionState } from '@lssm/lib.ai-agent/types';\nimport {\n type SpecSuggestion,\n type SpecSuggestionFilters,\n type SpecSuggestionRepository,\n type SpecSuggestionWriter,\n type SuggestionStatus,\n} from '../types';\n\nexport interface SpecSuggestionOrchestratorOptions {\n repository: SpecSuggestionRepository;\n approval?: ApprovalWorkflow;\n writer?: SpecSuggestionWriter;\n}\n\nexport class SpecSuggestionOrchestrator {\n constructor(private readonly options: SpecSuggestionOrchestratorOptions) {}\n\n async submit(\n suggestion: SpecSuggestion,\n session?: AgentSessionState,\n approvalReason?: string\n ) {\n await this.options.repository.create(suggestion);\n if (session && this.options.approval) {\n await this.options.approval.requestApproval(\n session,\n approvalReason ?? suggestion.proposal.summary,\n { suggestionId: suggestion.id }\n );\n }\n return suggestion;\n }\n\n async approve(id: string, reviewer: string, notes?: string) {\n const suggestion = await this.ensureSuggestion(id);\n await this.options.repository.updateStatus(id, 'approved', {\n reviewer,\n notes,\n decidedAt: new Date(),\n });\n if (this.options.writer) {\n await this.options.writer.write({\n ...suggestion,\n status: 'approved',\n approvals: {\n reviewer,\n notes,\n decidedAt: new Date(),\n status: 'approved',\n },\n });\n }\n }\n\n async reject(id: string, reviewer: string, notes?: string) {\n await this.options.repository.updateStatus(id, 'rejected', {\n reviewer,\n notes,\n decidedAt: new Date(),\n });\n }\n\n list(filters?: SpecSuggestionFilters) {\n return this.options.repository.list(filters);\n }\n\n private async ensureSuggestion(id: string) {\n const suggestion = await this.options.repository.getById(id);\n if (!suggestion) throw new Error(`Spec suggestion ${id} not found`);\n return suggestion;\n }\n}\n\nexport interface FileSystemSuggestionWriterOptions {\n outputDir?: string;\n filenameTemplate?: (suggestion: SpecSuggestion) => string;\n}\n\nexport class FileSystemSuggestionWriter implements SpecSuggestionWriter {\n private readonly outputDir: string;\n private readonly filenameTemplate: NonNullable<\n FileSystemSuggestionWriterOptions['filenameTemplate']\n >;\n\n constructor(options: FileSystemSuggestionWriterOptions = {}) {\n this.outputDir =\n options.outputDir ??\n join(\n process.cwd(),\n 'packages/contractspec/packages/libs/contracts/src/generated'\n );\n this.filenameTemplate =\n options.filenameTemplate ??\n ((suggestion) =>\n `${suggestion.target?.name ?? suggestion.intent.id}.v${suggestion.target?.version ?? 'next'}.suggestion.json`);\n }\n\n async write(suggestion: SpecSuggestion): Promise<string> {\n await mkdir(this.outputDir, { recursive: true });\n const filename = this.filenameTemplate(suggestion);\n const filepath = join(this.outputDir, filename);\n const payload = serializeSuggestion(suggestion);\n await writeFile(filepath, JSON.stringify(payload, null, 2));\n return filepath;\n }\n}\n\nexport class InMemorySpecSuggestionRepository\n implements SpecSuggestionRepository\n{\n private readonly items = new Map<string, SpecSuggestion>();\n\n async create(suggestion: SpecSuggestion): Promise<void> {\n this.items.set(suggestion.id, suggestion);\n }\n\n async getById(id: string): Promise<SpecSuggestion | undefined> {\n return this.items.get(id);\n }\n\n async updateStatus(\n id: string,\n status: SuggestionStatus,\n metadata?: { reviewer?: string; notes?: string; decidedAt?: Date }\n ): Promise<void> {\n const suggestion = await this.getById(id);\n if (!suggestion) return;\n this.items.set(id, {\n ...suggestion,\n status,\n approvals: {\n reviewer: metadata?.reviewer,\n notes: metadata?.notes,\n decidedAt: metadata?.decidedAt,\n status,\n },\n });\n }\n\n async list(filters?: SpecSuggestionFilters) {\n const values = [...this.items.values()];\n if (!filters) return values;\n return values.filter((item) => {\n if (filters.status && item.status !== filters.status) return false;\n if (filters.operationName && item.target?.name !== filters.operationName)\n return false;\n return true;\n });\n }\n}\n\nfunction serializeSuggestion(suggestion: SpecSuggestion) {\n const { proposal, ...rest } = suggestion;\n const { spec, ...proposalRest } = proposal;\n return {\n ...rest,\n proposal: {\n ...proposalRest,\n specMeta: spec?.meta,\n },\n createdAt: suggestion.createdAt.toISOString(),\n intent: {\n ...suggestion.intent,\n confidence: { ...suggestion.intent.confidence },\n evidence: suggestion.intent.evidence,\n },\n };\n}\n\nfunction deserializeSuggestion(payload: unknown): SpecSuggestion | undefined {\n if (!payload || typeof payload !== 'object') return undefined;\n const raw = payload as Record<string, any>;\n return {\n ...raw,\n createdAt: raw.createdAt ? new Date(raw.createdAt) : new Date(),\n intent: {\n ...raw.intent,\n confidence: raw.intent?.confidence,\n evidence: raw.intent?.evidence ?? [],\n },\n proposal: {\n ...raw.proposal,\n metadata: {\n ...(raw.proposal?.metadata ?? {}),\n specMeta: raw.proposal?.specMeta,\n },\n },\n } as SpecSuggestion;\n}\n"],"mappings":"oIAkBA,IAAa,EAAb,KAAwC,CACtC,YAAY,EAA6D,CAA5C,KAAA,QAAA,EAE7B,MAAM,OACJ,EACA,EACA,EACA,CASA,OARA,MAAM,KAAK,QAAQ,WAAW,OAAO,EAAW,CAC5C,GAAW,KAAK,QAAQ,UAC1B,MAAM,KAAK,QAAQ,SAAS,gBAC1B,EACA,GAAkB,EAAW,SAAS,QACtC,CAAE,aAAc,EAAW,GAAI,CAChC,CAEI,EAGT,MAAM,QAAQ,EAAY,EAAkB,EAAgB,CAC1D,IAAM,EAAa,MAAM,KAAK,iBAAiB,EAAG,CAClD,MAAM,KAAK,QAAQ,WAAW,aAAa,EAAI,WAAY,CACzD,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AAM,KAAK,QAAQ,EAAG,CACpC,GACL,KAAK,MAAM,IAAI,EAAI,CACjB,GAAG,EACH,SACA,UAAW,CACT,SAAU,GAAU,SACpB,MAAO,GAAU,MACjB,UAAW,GAAU,UACrB,SACD,CACF,CAAC,CAGJ,MAAM,KAAK,EAAiC,CAC1C,IAAM,EAAS,CAAC,GAAG,KAAK,MAAM,QAAQ,CAAC,CAEvC,OADK,EACE,EAAO,OAAQ,GAEpB,EADI,EAAQ,QAAU,EAAK,SAAW,EAAQ,QAC1C,EAAQ,eAAiB,EAAK,QAAQ,OAAS,EAAQ,eAG3D,CANmB,IAUzB,SAAS,EAAoB,EAA4B,CACvD,GAAM,CAAE,WAAU,GAAG,GAAS,EACxB,CAAE,OAAM,GAAG,GAAiB,EAClC,MAAO,CACL,GAAG,EACH,SAAU,CACR,GAAG,EACH,SAAU,GAAM,KACjB,CACD,UAAW,EAAW,UAAU,aAAa,CAC7C,OAAQ,CACN,GAAG,EAAW,OACd,WAAY,CAAE,GAAG,EAAW,OAAO,WAAY,CAC/C,SAAU,EAAW,OAAO,SAC7B,CACF"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { EvolutionConfig, IntentPattern, OperationCoordinate, SpecSuggestion, SpecSuggestionProposal, SuggestionStatus } from "../types.js";
|
|
2
|
-
import { ContractSpec, ResourceRefDescriptor } from "@lssm/lib.contracts";
|
|
3
|
-
import { AnySchemaModel } from "@lssm/lib.schema";
|
|
4
|
-
import { Logger } from "@lssm/lib.observability";
|
|
5
|
-
|
|
6
|
-
//#region src/generator/spec-generator.d.ts
|
|
7
|
-
type AnyContract = ContractSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
|
|
8
|
-
interface SpecGeneratorOptions {
|
|
9
|
-
config?: EvolutionConfig;
|
|
10
|
-
logger?: Logger;
|
|
11
|
-
clock?: () => Date;
|
|
12
|
-
getSpec?: (name: string, version?: number) => AnyContract | undefined;
|
|
13
|
-
}
|
|
14
|
-
interface GenerateSpecOptions {
|
|
15
|
-
summary?: string;
|
|
16
|
-
rationale?: string;
|
|
17
|
-
changeType?: SpecSuggestionProposal['changeType'];
|
|
18
|
-
kind?: SpecSuggestionProposal['kind'];
|
|
19
|
-
spec?: AnyContract;
|
|
20
|
-
diff?: string;
|
|
21
|
-
metadata?: Record<string, unknown>;
|
|
22
|
-
status?: SuggestionStatus;
|
|
23
|
-
tags?: string[];
|
|
24
|
-
createdBy?: string;
|
|
25
|
-
}
|
|
26
|
-
type SpecPatch = Partial<ContractSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>> & {
|
|
27
|
-
meta?: Partial<AnyContract['meta']>;
|
|
28
|
-
};
|
|
29
|
-
declare class SpecGenerator {
|
|
30
|
-
private readonly config;
|
|
31
|
-
private readonly logger?;
|
|
32
|
-
private readonly clock;
|
|
33
|
-
private readonly getSpec?;
|
|
34
|
-
constructor(options?: SpecGeneratorOptions);
|
|
35
|
-
generateFromIntent(intent: IntentPattern, options?: GenerateSpecOptions): SpecSuggestion;
|
|
36
|
-
generateVariant(operation: OperationCoordinate, patch: SpecPatch, intent: IntentPattern, options?: Omit<GenerateSpecOptions, 'spec'>): SpecSuggestion;
|
|
37
|
-
validateSuggestion(suggestion: SpecSuggestion, config?: EvolutionConfig): {
|
|
38
|
-
ok: boolean;
|
|
39
|
-
reasons: string[];
|
|
40
|
-
};
|
|
41
|
-
private intentToVerb;
|
|
42
|
-
private intentToPriority;
|
|
43
|
-
private inferChangeType;
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
export { GenerateSpecOptions, SpecGenerator, SpecGeneratorOptions, SpecPatch };
|
|
47
|
-
//# sourceMappingURL=spec-generator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec-generator.d.ts","names":[],"sources":["../../src/generator/spec-generator.ts"],"sourcesContent":[],"mappings":";;;;;;KAaK,WAAA,GAAc,aACjB,gBACA,iBAAiB;UAGF,oBAAA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AEP,kBAAa,CAAA,UAAA,EA4EV,cA5EU,EAAA,MAAA,CAAA,EA6Ed,eA7Ec,CAAA,EAAA;IAMH,EAAA,EAAA,OAAA;IAQX,OAAA,EAAA,MAAA,EAAA;EACC,CAAA;EACR,QAAA,YAAA;EAyCU,QAAA,gBAAA;EACJ,QAAA,eAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec-generator.js","names":["reasons: string[]"],"sources":["../../src/generator/spec-generator.ts"],"sourcesContent":["import type { ContractSpec, ResourceRefDescriptor } from '@lssm/lib.contracts';\nimport type { AnySchemaModel } from '@lssm/lib.schema';\nimport { Logger } from '@lssm/lib.observability';\nimport { randomUUID } from 'node:crypto';\nimport {\n type EvolutionConfig,\n type IntentPattern,\n type OperationCoordinate,\n type SpecSuggestion,\n type SpecSuggestionProposal,\n type SuggestionStatus,\n} from '../types';\n\ntype AnyContract = ContractSpec<\n AnySchemaModel,\n AnySchemaModel | ResourceRefDescriptor<boolean>\n>;\n\nexport interface SpecGeneratorOptions {\n config?: EvolutionConfig;\n logger?: Logger;\n clock?: () => Date;\n getSpec?: (name: string, version?: number) => AnyContract | undefined;\n}\n\nexport interface GenerateSpecOptions {\n summary?: string;\n rationale?: string;\n changeType?: SpecSuggestionProposal['changeType'];\n kind?: SpecSuggestionProposal['kind'];\n spec?: AnyContract;\n diff?: string;\n metadata?: Record<string, unknown>;\n status?: SuggestionStatus;\n tags?: string[];\n createdBy?: string;\n}\n\nexport type SpecPatch = Partial<\n ContractSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>\n> & { meta?: Partial<AnyContract['meta']> };\n\nexport class SpecGenerator {\n private readonly config: EvolutionConfig;\n private readonly logger?: Logger;\n private readonly clock: () => Date;\n private readonly getSpec?: SpecGeneratorOptions['getSpec'];\n\n constructor(options: SpecGeneratorOptions = {}) {\n this.config = options.config ?? {};\n this.logger = options.logger;\n this.clock = options.clock ?? (() => new Date());\n this.getSpec = options.getSpec;\n }\n\n generateFromIntent(\n intent: IntentPattern,\n options: GenerateSpecOptions = {}\n ): SpecSuggestion {\n const now = this.clock();\n const summary =\n options.summary ??\n `${this.intentToVerb(intent.type)} ${intent.operation?.name ?? 'operation'}`;\n const rationale =\n options.rationale ??\n [\n intent.description,\n intent.metadata?.observedValue\n ? `Observed ${intent.metadata.observedValue}`\n : undefined,\n ]\n .filter(Boolean)\n .join(' — ');\n\n const suggestion: SpecSuggestion = {\n id: randomUUID(),\n intent,\n target: intent.operation,\n proposal: {\n summary,\n rationale,\n changeType: options.changeType ?? this.inferChangeType(intent),\n kind: options.kind,\n spec: options.spec,\n diff: options.diff,\n metadata: options.metadata,\n },\n confidence: intent.confidence.score,\n priority: this.intentToPriority(intent),\n createdAt: now,\n createdBy: options.createdBy ?? 'auto-evolution',\n status: options.status ?? 'pending',\n evidence: intent.evidence,\n tags: options.tags,\n };\n return suggestion;\n }\n\n generateVariant(\n operation: OperationCoordinate,\n patch: SpecPatch,\n intent: IntentPattern,\n options: Omit<GenerateSpecOptions, 'spec'> = {}\n ) {\n if (!this.getSpec) {\n throw new Error('SpecGenerator requires getSpec() to generate variants');\n }\n const base = this.getSpec(operation.name, operation.version);\n if (!base) {\n throw new Error(\n `Cannot generate variant; spec ${operation.name}.v${operation.version} not found`\n );\n }\n const merged = mergeContract(base, patch);\n return this.generateFromIntent(intent, { ...options, spec: merged });\n }\n\n validateSuggestion(\n suggestion: SpecSuggestion,\n config: EvolutionConfig = this.config\n ) {\n const reasons: string[] = [];\n if (\n config.minConfidence != null &&\n suggestion.confidence < config.minConfidence\n ) {\n reasons.push(\n `Confidence ${suggestion.confidence.toFixed(2)} below minimum ${config.minConfidence}`\n );\n }\n if (config.requireApproval && suggestion.status === 'approved') {\n reasons.push(\n 'Suggestion cannot be auto-approved when approval is required'\n );\n }\n if (suggestion.proposal.spec && !suggestion.proposal.spec.meta?.name) {\n reasons.push('Proposal spec must include meta.name');\n }\n if (!suggestion.proposal.summary) {\n reasons.push('Proposal summary is required');\n }\n const ok = reasons.length === 0;\n if (!ok) {\n this.logger?.warn('SpecGenerator.validateSuggestion.failed', {\n suggestionId: suggestion.id,\n reasons,\n });\n }\n return { ok, reasons };\n }\n\n private intentToVerb(intent: IntentPattern['type']) {\n switch (intent) {\n case 'error-spike':\n return 'Stabilize';\n case 'latency-regression':\n return 'Optimize';\n case 'missing-operation':\n return 'Introduce';\n case 'throughput-drop':\n return 'Rebalance';\n default:\n return 'Adjust';\n }\n }\n\n private intentToPriority(intent: IntentPattern) {\n const severity = intent.confidence.score;\n if (intent.type === 'error-spike' || severity >= 0.8) return 'high';\n if (severity >= 0.5) return 'medium';\n return 'low';\n }\n\n private inferChangeType(\n intent: IntentPattern\n ): SpecSuggestionProposal['changeType'] {\n switch (intent.type) {\n case 'missing-operation':\n return 'new-spec';\n case 'schema-mismatch':\n return 'schema-update';\n case 'error-spike':\n return 'policy-update';\n default:\n return 'revision';\n }\n }\n}\n\nfunction mergeContract(base: AnyContract, patch: SpecPatch): AnyContract {\n return {\n ...base,\n ...patch,\n meta: { ...base.meta, ...patch.meta },\n io: {\n ...base.io,\n ...patch.io,\n },\n policy: {\n ...base.policy,\n ...patch.policy,\n },\n telemetry: {\n ...base.telemetry,\n ...patch.telemetry,\n },\n sideEffects: {\n ...base.sideEffects,\n ...patch.sideEffects,\n },\n } as AnyContract;\n}\n"],"mappings":"gFA0CA,IAAa,EAAb,KAA2B,CACzB,OACA,OACA,MACA,QAEA,YAAY,EAAgC,EAAE,CAAE,CAC9C,KAAK,OAAS,EAAQ,QAAU,EAAE,CAClC,KAAK,OAAS,EAAQ,OACtB,KAAK,MAAQ,EAAQ,YAAgB,IAAI,MACzC,KAAK,QAAU,EAAQ,QAGzB,mBACE,EACA,EAA+B,EAAE,CACjB,CAChB,IAAM,EAAM,KAAK,OAAO,CAClB,EACJ,EAAQ,SACR,GAAG,KAAK,aAAa,EAAO,KAAK,CAAC,GAAG,EAAO,WAAW,MAAQ,cAC3D,EACJ,EAAQ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OANK,GACH,KAAK,QAAQ,KAAK,0CAA2C,CAC3D,aAAc,EAAW,GACzB,UACD,CAAC,CAEG,CAAE,KAAI,UAAS,CAGxB,aAAqB,EAA+B,CAClD,OAAQ,EAAR,CACE,IAAK,cACH,MAAO,YACT,IAAK,qBACH,MAAO,WACT,IAAK,oBACH,MAAO,YACT,IAAK,kBACH,MAAO,YACT,QACE,MAAO,UAIb,iBAAyB,EAAuB,CAC9C,IAAM,EAAW,EAAO,WAAW,MAGnC,OAFI,EAAO,OAAS,eAAiB,GAAY,GAAY,OACzD,GAAY,GAAY,SACrB,MAGT,gBACE,EACsC,CACtC,OAAQ,EAAO,KAAf,CACE,IAAK,oBACH,MAAO,WACT,IAAK,kBACH,MAAO,gBACT,IAAK,cACH,MAAO,gBACT,QACE,MAAO,cAKf,SAAS,EAAc,EAAmB,EAA+B,CACvE,MAAO,CACL,GAAG,EACH,GAAG,EACH,KAAM,CAAE,GAAG,EAAK,KAAM,GAAG,EAAM,KAAM,CACrC,GAAI,CACF,GAAG,EAAK,GACR,GAAG,EAAM,GACV,CACD,OAAQ,CACN,GAAG,EAAK,OACR,GAAG,EAAM,OACV,CACD,UAAW,CACT,GAAG,EAAK,UACR,GAAG,EAAM,UACV,CACD,YAAa,CACX,GAAG,EAAK,YACR,GAAG,EAAM,YACV,CACF"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AnomalySeverity, EvolutionConfig, IntentPattern, OperationCoordinate, OperationMetricSample, OptimizationHint, PatternConfidence, SpecAnomaly, SpecSuggestion, SpecSuggestionFilters, SpecSuggestionProposal, SpecSuggestionRepository, SpecSuggestionWriter, SpecUsageStats, SuggestionEvidence, SuggestionStatus } from "./types.js";
|
|
2
|
-
import { SpecAnalyzer, SpecAnalyzerOptions } from "./analyzer/spec-analyzer.js";
|
|
3
|
-
import { GenerateSpecOptions, SpecGenerator, SpecGeneratorOptions, SpecPatch } from "./generator/spec-generator.js";
|
|
4
|
-
import { FileSystemSuggestionWriter, FileSystemSuggestionWriterOptions, InMemorySpecSuggestionRepository, SpecSuggestionOrchestrator, SpecSuggestionOrchestratorOptions } from "./approval/integration.js";
|
|
5
|
-
export { AnomalySeverity, EvolutionConfig, FileSystemSuggestionWriter, FileSystemSuggestionWriterOptions, GenerateSpecOptions, InMemorySpecSuggestionRepository, IntentPattern, OperationCoordinate, OperationMetricSample, OptimizationHint, PatternConfidence, SpecAnalyzer, SpecAnalyzerOptions, SpecAnomaly, SpecGenerator, SpecGeneratorOptions, SpecPatch, SpecSuggestion, SpecSuggestionFilters, SpecSuggestionOrchestrator, SpecSuggestionOrchestratorOptions, SpecSuggestionProposal, SpecSuggestionRepository, SpecSuggestionWriter, SpecUsageStats, SuggestionEvidence, SuggestionStatus };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e,n as t}from"./types/stages.js";import"./types/axes.js";import"./types/signals.js";import"./types/milestones.js";import"./utils/formatters.js";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(e){return e.Sketch=`Sketch`,e.Prototype=`Prototype`,e.Mvp=`MVP`,e.V1=`V1`,e.Ecosystem=`Ecosystem`,e})({}),function(e){return e.Solo=`Solo`,e.TinyTeam=`TinyTeam`,e.FunctionalOrg=`FunctionalOrg`,e.MultiTeam=`MultiTeam`,e.Bureaucratic=`Bureaucratic`,e}({}),function(e){return e.Bootstrapped=`Bootstrapped`,e.PreSeed=`PreSeed`,e.Seed=`Seed`,e.SeriesAorB=`SeriesAorB`,e.LateStage=`LateStage`,e}({});
|
|
2
|
-
//# sourceMappingURL=axes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axes.js","names":["e"],"sources":["../../../../../lifecycle/dist/types/axes.js"],"sourcesContent":["let e=function(e){return e.Sketch=`Sketch`,e.Prototype=`Prototype`,e.Mvp=`MVP`,e.V1=`V1`,e.Ecosystem=`Ecosystem`,e}({}),t=function(e){return e.Solo=`Solo`,e.TinyTeam=`TinyTeam`,e.FunctionalOrg=`FunctionalOrg`,e.MultiTeam=`MultiTeam`,e.Bureaucratic=`Bureaucratic`,e}({}),n=function(e){return e.Bootstrapped=`Bootstrapped`,e.PreSeed=`PreSeed`,e.Seed=`Seed`,e.SeriesAorB=`SeriesAorB`,e.LateStage=`LateStage`,e}({});export{n as CapitalPhase,t as CompanyPhase,e as ProductPhase};\n//# sourceMappingURL=axes.js.map"],"mappings":"CAAM,SAAS,EAAE,CAAC,MAAO,GAAE,OAAO,SAAS,EAAE,UAAU,YAAY,EAAE,IAAI,MAAM,EAAE,GAAG,KAAK,EAAE,UAAU,YAAYA,IAAG,EAAE,CAAC,CAAG,SAAS,EAAE,CAAC,MAAO,GAAE,KAAK,OAAO,EAAE,SAAS,WAAW,EAAE,cAAc,gBAAgB,EAAE,UAAU,YAAY,EAAE,aAAa,eAAeA,GAAG,EAAE,CAAC,CAAG,SAAS,EAAE,CAAC,MAAO,GAAE,aAAa,eAAe,EAAE,QAAQ,UAAU,EAAE,KAAK,OAAO,EAAE,WAAW,aAAa,EAAE,UAAU,YAAYA,GAAG,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./stages.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./stages.js";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let e=function(e){return e[e.Exploration=0]=`Exploration`,e[e.ProblemSolutionFit=1]=`ProblemSolutionFit`,e[e.MvpEarlyTraction=2]=`MvpEarlyTraction`,e[e.ProductMarketFit=3]=`ProductMarketFit`,e[e.GrowthScaleUp=4]=`GrowthScaleUp`,e[e.ExpansionPlatform=5]=`ExpansionPlatform`,e[e.MaturityRenewal=6]=`MaturityRenewal`,e}({});e.Exploration,e.ProblemSolutionFit,e.MvpEarlyTraction,e.ProductMarketFit,e.GrowthScaleUp,e.ExpansionPlatform,e.MaturityRenewal;const t={[e.Exploration]:{id:e.Exploration,order:0,slug:`exploration`,name:`Exploration / Ideation`,question:`Is there a problem worth my time?`,signals:[`20+ discovery interviews`,`Clear problem statement`,`Named ICP`],traps:[`Branding before discovery`,`Premature tooling decisions`],focusAreas:[`Customer discovery`,`Problem definition`,`Segment clarity`]},[e.ProblemSolutionFit]:{id:e.ProblemSolutionFit,order:1,slug:`problem-solution-fit`,name:`Problem–Solution Fit`,question:`Do people care enough about this solution?`,signals:[`Prototype reuse`,`Referral energy`,`Pre-pay interest`],traps:[`“Market is huge” without users`,`Skipping qualitative loops`],focusAreas:[`Solution hypothesis`,`Value messaging`,`Feedback capture`]},[e.MvpEarlyTraction]:{id:e.MvpEarlyTraction,order:2,slug:`mvp-early-traction`,name:`MVP & Early Traction`,question:`Can we get real usage and learn fast?`,signals:[`20–50 named active users`,`Weekly releases`,`Noisy feedback`],traps:[`Overbuilt infra for 10 users`,`Undefined retention metric`],focusAreas:[`Activation`,`Cohort tracking`,`Feedback rituals`]},[e.ProductMarketFit]:{id:e.ProductMarketFit,order:3,slug:`product-market-fit`,name:`Product–Market Fit`,question:`Is this pulling us forward?`,signals:[`Retention without heroics`,`Organic word-of-mouth`,`Value stories`],traps:[`Hero growth that does not scale`,`Ignoring churn signals`],focusAreas:[`Retention`,`Reliability`,`ICP clarity`]},[e.GrowthScaleUp]:{id:e.GrowthScaleUp,order:4,slug:`growth-scale-up`,name:`Growth / Scale-up`,question:`Can we grow this repeatably?`,signals:[`Predictable channels`,`Specialized hires`,`Unit economics on track`],traps:[`Paid spend masking retention gaps`,`Infra debt blocking launches`],focusAreas:[`Ops systems`,`Growth loops`,`Reliability engineering`]},[e.ExpansionPlatform]:{id:e.ExpansionPlatform,order:5,slug:`expansion-platform`,name:`Expansion / Platform`,question:`What is the next growth curve?`,signals:[`Stable core metrics`,`Partner/API demand`,`Ecosystem pull`],traps:[`Platform theater before wedge is solid`],focusAreas:[`Partnerships`,`APIs`,`New market validation`]},[e.MaturityRenewal]:{id:e.MaturityRenewal,order:6,slug:`maturity-renewal`,name:`Maturity / Renewal`,question:`Optimize, reinvent, or sunset?`,signals:[`Margin focus`,`Portfolio bets`,`Narrative refresh`],traps:[`Assuming past success is enough`],focusAreas:[`Cost optimization`,`Reinvention bets`,`Sunset planning`]}};export{e,t as n};
|
|
2
|
-
//# sourceMappingURL=stages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stages.js","names":["e","t"],"sources":["../../../../../lifecycle/dist/types/stages.js"],"sourcesContent":["let e=function(e){return e[e.Exploration=0]=`Exploration`,e[e.ProblemSolutionFit=1]=`ProblemSolutionFit`,e[e.MvpEarlyTraction=2]=`MvpEarlyTraction`,e[e.ProductMarketFit=3]=`ProductMarketFit`,e[e.GrowthScaleUp=4]=`GrowthScaleUp`,e[e.ExpansionPlatform=5]=`ExpansionPlatform`,e[e.MaturityRenewal=6]=`MaturityRenewal`,e}({});const t=[e.Exploration,e.ProblemSolutionFit,e.MvpEarlyTraction,e.ProductMarketFit,e.GrowthScaleUp,e.ExpansionPlatform,e.MaturityRenewal],n={[e.Exploration]:{id:e.Exploration,order:0,slug:`exploration`,name:`Exploration / Ideation`,question:`Is there a problem worth my time?`,signals:[`20+ discovery interviews`,`Clear problem statement`,`Named ICP`],traps:[`Branding before discovery`,`Premature tooling decisions`],focusAreas:[`Customer discovery`,`Problem definition`,`Segment clarity`]},[e.ProblemSolutionFit]:{id:e.ProblemSolutionFit,order:1,slug:`problem-solution-fit`,name:`Problem–Solution Fit`,question:`Do people care enough about this solution?`,signals:[`Prototype reuse`,`Referral energy`,`Pre-pay interest`],traps:[`“Market is huge” without users`,`Skipping qualitative loops`],focusAreas:[`Solution hypothesis`,`Value messaging`,`Feedback capture`]},[e.MvpEarlyTraction]:{id:e.MvpEarlyTraction,order:2,slug:`mvp-early-traction`,name:`MVP & Early Traction`,question:`Can we get real usage and learn fast?`,signals:[`20–50 named active users`,`Weekly releases`,`Noisy feedback`],traps:[`Overbuilt infra for 10 users`,`Undefined retention metric`],focusAreas:[`Activation`,`Cohort tracking`,`Feedback rituals`]},[e.ProductMarketFit]:{id:e.ProductMarketFit,order:3,slug:`product-market-fit`,name:`Product–Market Fit`,question:`Is this pulling us forward?`,signals:[`Retention without heroics`,`Organic word-of-mouth`,`Value stories`],traps:[`Hero growth that does not scale`,`Ignoring churn signals`],focusAreas:[`Retention`,`Reliability`,`ICP clarity`]},[e.GrowthScaleUp]:{id:e.GrowthScaleUp,order:4,slug:`growth-scale-up`,name:`Growth / Scale-up`,question:`Can we grow this repeatably?`,signals:[`Predictable channels`,`Specialized hires`,`Unit economics on track`],traps:[`Paid spend masking retention gaps`,`Infra debt blocking launches`],focusAreas:[`Ops systems`,`Growth loops`,`Reliability engineering`]},[e.ExpansionPlatform]:{id:e.ExpansionPlatform,order:5,slug:`expansion-platform`,name:`Expansion / Platform`,question:`What is the next growth curve?`,signals:[`Stable core metrics`,`Partner/API demand`,`Ecosystem pull`],traps:[`Platform theater before wedge is solid`],focusAreas:[`Partnerships`,`APIs`,`New market validation`]},[e.MaturityRenewal]:{id:e.MaturityRenewal,order:6,slug:`maturity-renewal`,name:`Maturity / Renewal`,question:`Optimize, reinvent, or sunset?`,signals:[`Margin focus`,`Portfolio bets`,`Narrative refresh`],traps:[`Assuming past success is enough`],focusAreas:[`Cost optimization`,`Reinvention bets`,`Sunset planning`]}},r=e=>{let t=Object.values(n).find(t=>t.slug===e);if(!t)throw Error(`Unknown lifecycle stage slug: ${e}`);return t.id};export{n as LIFECYCLE_STAGE_META,t as LIFECYCLE_STAGE_ORDER,e as LifecycleStage,r as getLifecycleStageBySlug};\n//# sourceMappingURL=stages.js.map"],"mappings":"AAAA,IAAI,EAAE,SAAS,EAAE,CAAC,MAAO,GAAE,EAAE,YAAY,GAAG,cAAc,EAAE,EAAE,mBAAmB,GAAG,qBAAqB,EAAE,EAAE,iBAAiB,GAAG,mBAAmB,EAAE,EAAE,iBAAiB,GAAG,mBAAmB,EAAE,EAAE,cAAc,GAAG,gBAAgB,EAAE,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,EAAE,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,eAAe,0BAA0B,CAAC,EAAE,EAAE,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,MAAM,EAAE,KAAK,qBAAqB,KAAK,uBAAuB,SAAS,iCAAiC,QAAQ,CAAC,sBAAsB,qBAAqB,iBAAiB,CAAC,MAAM,CAAC,yCAAyC,CAAC,WAAW,CAAC,eAAe,OAAO,wBAAwB,CAAC,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,MAAM,EAAE,KAAK,mBAAmB,KAAK,qBAAqB,SAAS,iCAAiC,QAAQ,CAAC,eAAe,iBAAiB,oBAAoB,CAAC,MAAM,CAAC,kCAAkC,CAAC,WAAW,CAAC,oBAAoB,mBAAmB,kBAAkB,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../types/stages.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./tracing/index.js";import{i as e,n as t,t as n}from"./metrics/index.js";import{n as r}from"./logging/index.js";import"./tracing/middleware.js";import"./intent/detector.js";import"./pipeline/evolution-pipeline.js";import"./pipeline/lifecycle-pipeline.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{randomUUID as e}from"node:crypto";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./types/stages.js";import"./utils/formatters.js";import"./types/axes.js";import"./types/signals.js";import"./types/milestones.js";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(e){return e.Sketch=`Sketch`,e.Prototype=`Prototype`,e.Mvp=`MVP`,e.V1=`V1`,e.Ecosystem=`Ecosystem`,e})({}),function(e){return e.Solo=`Solo`,e.TinyTeam=`TinyTeam`,e.FunctionalOrg=`FunctionalOrg`,e.MultiTeam=`MultiTeam`,e.Bureaucratic=`Bureaucratic`,e}({}),function(e){return e.Bootstrapped=`Bootstrapped`,e.PreSeed=`PreSeed`,e.Seed=`Seed`,e.SeriesAorB=`SeriesAorB`,e.LateStage=`LateStage`,e}({});
|
|
2
|
-
//# sourceMappingURL=axes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axes.js","names":[],"sources":["../../../../../../../observability/dist/lifecycle/dist/types/axes.mjs"],"sourcesContent":["(function(e){return e.Sketch=`Sketch`,e.Prototype=`Prototype`,e.Mvp=`MVP`,e.V1=`V1`,e.Ecosystem=`Ecosystem`,e})({}),function(e){return e.Solo=`Solo`,e.TinyTeam=`TinyTeam`,e.FunctionalOrg=`FunctionalOrg`,e.MultiTeam=`MultiTeam`,e.Bureaucratic=`Bureaucratic`,e}({}),function(e){return e.Bootstrapped=`Bootstrapped`,e.PreSeed=`PreSeed`,e.Seed=`Seed`,e.SeriesAorB=`SeriesAorB`,e.LateStage=`LateStage`,e}({});\n//# sourceMappingURL=axes.mjs.map"],"mappings":"CAAC,SAAS,EAAE,CAAC,MAAO,GAAE,OAAO,SAAS,EAAE,UAAU,YAAY,EAAE,IAAI,MAAM,EAAE,GAAG,KAAK,EAAE,UAAU,YAAY,IAAI,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,MAAO,GAAE,KAAK,OAAO,EAAE,SAAS,WAAW,EAAE,cAAc,gBAAgB,EAAE,UAAU,YAAY,EAAE,aAAa,eAAe,GAAG,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,MAAO,GAAE,aAAa,eAAe,EAAE,QAAQ,UAAU,EAAE,KAAK,OAAO,EAAE,WAAW,aAAa,EAAE,UAAU,YAAY,GAAG,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./stages.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./stages.js";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let e=function(e){return e[e.Exploration=0]=`Exploration`,e[e.ProblemSolutionFit=1]=`ProblemSolutionFit`,e[e.MvpEarlyTraction=2]=`MvpEarlyTraction`,e[e.ProductMarketFit=3]=`ProductMarketFit`,e[e.GrowthScaleUp=4]=`GrowthScaleUp`,e[e.ExpansionPlatform=5]=`ExpansionPlatform`,e[e.MaturityRenewal=6]=`MaturityRenewal`,e}({});e.Exploration,e.ProblemSolutionFit,e.MvpEarlyTraction,e.ProductMarketFit,e.GrowthScaleUp,e.ExpansionPlatform,e.MaturityRenewal,e.Exploration,e.Exploration,e.ProblemSolutionFit,e.ProblemSolutionFit,e.MvpEarlyTraction,e.MvpEarlyTraction,e.ProductMarketFit,e.ProductMarketFit,e.GrowthScaleUp,e.GrowthScaleUp,e.ExpansionPlatform,e.ExpansionPlatform,e.MaturityRenewal,e.MaturityRenewal;
|
|
2
|
-
//# sourceMappingURL=stages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stages.js","names":["e"],"sources":["../../../../../../../observability/dist/lifecycle/dist/types/stages.mjs"],"sourcesContent":["let e=function(e){return e[e.Exploration=0]=`Exploration`,e[e.ProblemSolutionFit=1]=`ProblemSolutionFit`,e[e.MvpEarlyTraction=2]=`MvpEarlyTraction`,e[e.ProductMarketFit=3]=`ProductMarketFit`,e[e.GrowthScaleUp=4]=`GrowthScaleUp`,e[e.ExpansionPlatform=5]=`ExpansionPlatform`,e[e.MaturityRenewal=6]=`MaturityRenewal`,e}({});const t=[e.Exploration,e.ProblemSolutionFit,e.MvpEarlyTraction,e.ProductMarketFit,e.GrowthScaleUp,e.ExpansionPlatform,e.MaturityRenewal],n={[e.Exploration]:{id:e.Exploration,order:0,slug:`exploration`,name:`Exploration / Ideation`,question:`Is there a problem worth my time?`,signals:[`20+ discovery interviews`,`Clear problem statement`,`Named ICP`],traps:[`Branding before discovery`,`Premature tooling decisions`],focusAreas:[`Customer discovery`,`Problem definition`,`Segment clarity`]},[e.ProblemSolutionFit]:{id:e.ProblemSolutionFit,order:1,slug:`problem-solution-fit`,name:`Problem–Solution Fit`,question:`Do people care enough about this solution?`,signals:[`Prototype reuse`,`Referral energy`,`Pre-pay interest`],traps:[`“Market is huge” without users`,`Skipping qualitative loops`],focusAreas:[`Solution hypothesis`,`Value messaging`,`Feedback capture`]},[e.MvpEarlyTraction]:{id:e.MvpEarlyTraction,order:2,slug:`mvp-early-traction`,name:`MVP & Early Traction`,question:`Can we get real usage and learn fast?`,signals:[`20–50 named active users`,`Weekly releases`,`Noisy feedback`],traps:[`Overbuilt infra for 10 users`,`Undefined retention metric`],focusAreas:[`Activation`,`Cohort tracking`,`Feedback rituals`]},[e.ProductMarketFit]:{id:e.ProductMarketFit,order:3,slug:`product-market-fit`,name:`Product–Market Fit`,question:`Is this pulling us forward?`,signals:[`Retention without heroics`,`Organic word-of-mouth`,`Value stories`],traps:[`Hero growth that does not scale`,`Ignoring churn signals`],focusAreas:[`Retention`,`Reliability`,`ICP clarity`]},[e.GrowthScaleUp]:{id:e.GrowthScaleUp,order:4,slug:`growth-scale-up`,name:`Growth / Scale-up`,question:`Can we grow this repeatably?`,signals:[`Predictable channels`,`Specialized hires`,`Unit economics on track`],traps:[`Paid spend masking retention gaps`,`Infra debt blocking launches`],focusAreas:[`Ops systems`,`Growth loops`,`Reliability engineering`]},[e.ExpansionPlatform]:{id:e.ExpansionPlatform,order:5,slug:`expansion-platform`,name:`Expansion / Platform`,question:`What is the next growth curve?`,signals:[`Stable core metrics`,`Partner/API demand`,`Ecosystem pull`],traps:[`Platform theater before wedge is solid`],focusAreas:[`Partnerships`,`APIs`,`New market validation`]},[e.MaturityRenewal]:{id:e.MaturityRenewal,order:6,slug:`maturity-renewal`,name:`Maturity / Renewal`,question:`Optimize, reinvent, or sunset?`,signals:[`Margin focus`,`Portfolio bets`,`Narrative refresh`],traps:[`Assuming past success is enough`],focusAreas:[`Cost optimization`,`Reinvention bets`,`Sunset planning`]}};export{e,n,t};\n//# sourceMappingURL=stages.mjs.map"],"mappings":"AAAA,IAAI,EAAE,SAAS,EAAE,CAAC,MAAO,GAAE,EAAE,YAAY,GAAG,cAAc,EAAE,EAAE,mBAAmB,GAAG,qBAAqB,EAAE,EAAE,iBAAiB,GAAG,mBAAmB,EAAE,EAAE,iBAAiB,GAAG,mBAAmB,EAAE,EAAE,cAAc,GAAG,gBAAgB,EAAE,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,EAAE,gBAAgB,GAAG,kBAAkBA,GAAG,EAAE,CAAC,CAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAqB,EAAE,YAAiB,EAAE,YAA0U,EAAE,mBAAwB,EAAE,mBAA0V,EAAE,iBAAsB,EAAE,iBAA6U,EAAE,iBAAsB,EAAE,iBAA4T,EAAE,cAAmB,EAAE,cAA8U,EAAE,kBAAuB,EAAE,kBAA8S,EAAE,gBAAqB,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../types/stages.js";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{context as e,trace as t}from"@opentelemetry/api";var n=class{constructor(e){this.serviceName=e}log(n,r,i={}){let a=t.getSpan(e.active()),o=a?.spanContext().traceId,s=a?.spanContext().spanId,c={timestamp:new Date().toISOString(),service:this.serviceName,level:n,message:r,traceId:o,spanId:s,...i};console.log(JSON.stringify(c))}debug(e,t){this.log(`debug`,e,t)}info(e,t){this.log(`info`,e,t)}warn(e,t){this.log(`warn`,e,t)}error(e,t){this.log(`error`,e,t)}};new n(process.env.OTEL_SERVICE_NAME||`unknown-service`);export{n};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["t","e","n","r"],"sources":["../../../../../observability/dist/logging/index.mjs"],"sourcesContent":["import{context as e,trace as t}from\"@opentelemetry/api\";var n=class{constructor(e){this.serviceName=e}log(n,r,i={}){let a=t.getSpan(e.active()),o=a?.spanContext().traceId,s=a?.spanContext().spanId,c={timestamp:new Date().toISOString(),service:this.serviceName,level:n,message:r,traceId:o,spanId:s,...i};console.log(JSON.stringify(c))}debug(e,t){this.log(`debug`,e,t)}info(e,t){this.log(`info`,e,t)}warn(e,t){this.log(`warn`,e,t)}error(e,t){this.log(`error`,e,t)}};const r=new n(process.env.OTEL_SERVICE_NAME||`unknown-service`);export{n as Logger,r as logger};\n//# sourceMappingURL=index.mjs.map"],"mappings":"wDAAwD,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,KAAK,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAEA,EAAE,QAAQC,EAAE,QAAQ,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,QAAQ,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,UAAU,IAAI,MAAM,CAAC,aAAa,CAAC,QAAQ,KAAK,YAAY,MAAMC,EAAE,QAAQC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,IAAI,KAAK,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,IAAI,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,OAAO,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,IAAI,QAAQ,EAAE,EAAE,GAAW,IAAI,EAAE,QAAQ,IAAI,mBAAmB,kBAAkB"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{metrics as e}from"@opentelemetry/api";function t(t=`@lssm/lib.observability`){return e.getMeter(t)}function n(e,n,r){return t(r).createCounter(e,{description:n})}function r(e,n,r){return t(r).createHistogram(e,{description:n})}n(`http_requests_total`,`Total HTTP requests`),r(`http_request_duration_seconds`,`HTTP request duration`),n(`operation_errors_total`,`Total operation errors`),r(`workflow_duration_seconds`,`Workflow execution duration`);export{r as i,n,t};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["e","t","n"],"sources":["../../../../../observability/dist/metrics/index.mjs"],"sourcesContent":["import{metrics as e}from\"@opentelemetry/api\";function t(t=`@lssm/lib.observability`){return e.getMeter(t)}function n(e,n,r){return t(r).createCounter(e,{description:n})}function r(e,n,r){return t(r).createUpDownCounter(e,{description:n})}function i(e,n,r){return t(r).createHistogram(e,{description:n})}const a={httpRequests:n(`http_requests_total`,`Total HTTP requests`),httpDuration:i(`http_request_duration_seconds`,`HTTP request duration`),operationErrors:n(`operation_errors_total`,`Total operation errors`),workflowDuration:i(`workflow_duration_seconds`,`Workflow execution duration`)};export{n as createCounter,i as createHistogram,r as createUpDownCounter,t as getMeter,a as standardMetrics};\n//# sourceMappingURL=index.mjs.map"],"mappings":"6CAA6C,SAAS,EAAE,EAAE,0BAA0B,CAAC,OAAOA,EAAE,SAASC,EAAE,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,EAAE,CAAC,YAAYC,EAAE,CAAC,CAAsE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC,YAAYA,EAAE,CAAC,CAAuB,EAAE,sBAAsB,sBAAsB,CAAc,EAAE,gCAAgC,wBAAwB,CAAiB,EAAE,yBAAyB,yBAAyB,CAAkB,EAAE,4BAA4B,8BAA8B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../intent/detector.js";import"node:events";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../metrics/index.js";import"../lifecycle/dist/utils/formatters.js";import"../lifecycle/dist/index.js";import"node:events";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{context as e,trace as t}from"@opentelemetry/api";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index.js";import"../metrics/index.js";
|
package/dist/types.d.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { ContractSpec, OpKind, ResourceRefDescriptor } from "@lssm/lib.contracts";
|
|
2
|
-
import { AnySchemaModel } from "@lssm/lib.schema";
|
|
3
|
-
import { LifecycleStage } from "@lssm/lib.lifecycle";
|
|
4
|
-
|
|
5
|
-
//#region src/types.d.ts
|
|
6
|
-
type AnomalySeverity = 'low' | 'medium' | 'high';
|
|
7
|
-
type SuggestionStatus = 'pending' | 'approved' | 'rejected';
|
|
8
|
-
interface OperationCoordinate {
|
|
9
|
-
name: string;
|
|
10
|
-
version: number;
|
|
11
|
-
tenantId?: string;
|
|
12
|
-
}
|
|
13
|
-
interface OperationMetricSample {
|
|
14
|
-
operation: OperationCoordinate;
|
|
15
|
-
durationMs: number;
|
|
16
|
-
success: boolean;
|
|
17
|
-
timestamp: Date;
|
|
18
|
-
payloadSizeBytes?: number;
|
|
19
|
-
errorCode?: string;
|
|
20
|
-
errorMessage?: string;
|
|
21
|
-
actor?: string;
|
|
22
|
-
channel?: string;
|
|
23
|
-
traceId?: string;
|
|
24
|
-
metadata?: Record<string, unknown>;
|
|
25
|
-
}
|
|
26
|
-
interface SpecUsageStats {
|
|
27
|
-
operation: OperationCoordinate;
|
|
28
|
-
totalCalls: number;
|
|
29
|
-
successRate: number;
|
|
30
|
-
errorRate: number;
|
|
31
|
-
averageLatencyMs: number;
|
|
32
|
-
p95LatencyMs: number;
|
|
33
|
-
p99LatencyMs: number;
|
|
34
|
-
maxLatencyMs: number;
|
|
35
|
-
lastSeenAt: Date;
|
|
36
|
-
windowStart: Date;
|
|
37
|
-
windowEnd: Date;
|
|
38
|
-
topErrors: Record<string, number>;
|
|
39
|
-
}
|
|
40
|
-
interface SuggestionEvidence {
|
|
41
|
-
type: 'telemetry' | 'user-feedback' | 'simulation' | 'test';
|
|
42
|
-
description: string;
|
|
43
|
-
data?: Record<string, unknown>;
|
|
44
|
-
}
|
|
45
|
-
interface SpecAnomaly {
|
|
46
|
-
operation: OperationCoordinate;
|
|
47
|
-
severity: AnomalySeverity;
|
|
48
|
-
metric: 'latency' | 'error-rate' | 'throughput' | 'policy' | 'schema';
|
|
49
|
-
description: string;
|
|
50
|
-
detectedAt: Date;
|
|
51
|
-
threshold?: number;
|
|
52
|
-
observedValue?: number;
|
|
53
|
-
evidence: SuggestionEvidence[];
|
|
54
|
-
}
|
|
55
|
-
interface PatternConfidence {
|
|
56
|
-
score: number;
|
|
57
|
-
sampleSize: number;
|
|
58
|
-
pValue?: number;
|
|
59
|
-
}
|
|
60
|
-
interface IntentPattern {
|
|
61
|
-
id: string;
|
|
62
|
-
type: 'latency-regression' | 'error-spike' | 'missing-operation' | 'chained-intent' | 'throughput-drop' | 'schema-mismatch';
|
|
63
|
-
description: string;
|
|
64
|
-
operation?: OperationCoordinate;
|
|
65
|
-
confidence: PatternConfidence;
|
|
66
|
-
metadata?: Record<string, unknown>;
|
|
67
|
-
evidence: SuggestionEvidence[];
|
|
68
|
-
}
|
|
69
|
-
interface SpecSuggestionProposal {
|
|
70
|
-
summary: string;
|
|
71
|
-
rationale: string;
|
|
72
|
-
changeType: 'new-spec' | 'revision' | 'policy-update' | 'schema-update';
|
|
73
|
-
kind?: OpKind;
|
|
74
|
-
spec?: ContractSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
|
|
75
|
-
diff?: string;
|
|
76
|
-
metadata?: Record<string, unknown>;
|
|
77
|
-
}
|
|
78
|
-
interface SpecSuggestion {
|
|
79
|
-
id: string;
|
|
80
|
-
intent: IntentPattern;
|
|
81
|
-
target?: OperationCoordinate;
|
|
82
|
-
proposal: SpecSuggestionProposal;
|
|
83
|
-
confidence: number;
|
|
84
|
-
createdAt: Date;
|
|
85
|
-
createdBy: string;
|
|
86
|
-
status: SuggestionStatus;
|
|
87
|
-
evidence: SuggestionEvidence[];
|
|
88
|
-
priority: 'low' | 'medium' | 'high';
|
|
89
|
-
tags?: string[];
|
|
90
|
-
approvals?: {
|
|
91
|
-
reviewer?: string;
|
|
92
|
-
notes?: string;
|
|
93
|
-
decidedAt?: Date;
|
|
94
|
-
status?: SuggestionStatus;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
interface EvolutionConfig {
|
|
98
|
-
minConfidence?: number;
|
|
99
|
-
autoApproveThreshold?: number;
|
|
100
|
-
maxSuggestionsPerOperation?: number;
|
|
101
|
-
requireApproval?: boolean;
|
|
102
|
-
maxConcurrentExperiments?: number;
|
|
103
|
-
}
|
|
104
|
-
interface SpecSuggestionFilters {
|
|
105
|
-
status?: SuggestionStatus;
|
|
106
|
-
operationName?: string;
|
|
107
|
-
}
|
|
108
|
-
interface SpecSuggestionRepository {
|
|
109
|
-
create(suggestion: SpecSuggestion): Promise<void>;
|
|
110
|
-
getById(id: string): Promise<SpecSuggestion | undefined>;
|
|
111
|
-
updateStatus(id: string, status: SuggestionStatus, metadata?: {
|
|
112
|
-
reviewer?: string;
|
|
113
|
-
notes?: string;
|
|
114
|
-
decidedAt?: Date;
|
|
115
|
-
}): Promise<void>;
|
|
116
|
-
list(filters?: SpecSuggestionFilters): Promise<SpecSuggestion[]>;
|
|
117
|
-
}
|
|
118
|
-
interface SpecSuggestionWriter {
|
|
119
|
-
write(suggestion: SpecSuggestion): Promise<string>;
|
|
120
|
-
}
|
|
121
|
-
interface OptimizationHint {
|
|
122
|
-
operation: OperationCoordinate;
|
|
123
|
-
category: 'schema' | 'policy' | 'performance' | 'error-handling';
|
|
124
|
-
summary: string;
|
|
125
|
-
justification: string;
|
|
126
|
-
recommendedActions: string[];
|
|
127
|
-
lifecycleStage?: LifecycleStage;
|
|
128
|
-
lifecycleNotes?: string;
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
export { AnomalySeverity, EvolutionConfig, IntentPattern, OperationCoordinate, OperationMetricSample, OptimizationHint, PatternConfidence, SpecAnomaly, SpecSuggestion, SpecSuggestionFilters, SpecSuggestionProposal, SpecSuggestionRepository, SpecSuggestionWriter, SpecUsageStats, SuggestionEvidence, SuggestionStatus };
|
|
132
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
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