Skip to content

Add distributed state, WASM runtime, registry federation, and AIOps protocols#504

Merged
hotlong merged 3 commits into
copilot/improve-microkernel-pluginsfrom
copilot/improve-plugin-lifecycle-architecture
Feb 3, 2026
Merged

Add distributed state, WASM runtime, registry federation, and AIOps protocols#504
hotlong merged 3 commits into
copilot/improve-microkernel-pluginsfrom
copilot/improve-plugin-lifecycle-architecture

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 3, 2026

Extends plugin system with cloud-native primitives for enterprise deployments: distributed state persistence, WebAssembly sandboxing, private registry federation, and AI-driven operations.

Distributed State Management

Added distributed state strategy to HotReloadConfigSchema with Redis/Etcd support:

{
  stateStrategy: 'distributed',
  distributedConfig: {
    provider: 'redis',
    endpoints: ['redis://cluster:6379'],
    keyPrefix: 'plugin:analytics:',
    ttl: 3600,
    replication: { enabled: true, minReplicas: 2 }
  }
}

Enables plugin state persistence across Kubernetes pods.

WASM Sandbox Runtime

Added RuntimeConfigSchema to SandboxConfig with four isolation engines:

  • v8-isolate: V8 isolate (default, lightweight)
  • wasm: WebAssembly with memory page limits + instruction counting
  • container: Docker/Podman isolation
  • process: Traditional process isolation
{
  runtime: {
    engine: 'wasm',
    engineConfig: {
      wasm: {
        maxMemoryPages: 256,      // 16MB
        instructionLimit: 1000000  // prevents runaway execution
      }
    }
  }
}

Registry Federation

Added RegistryConfigSchema for hybrid public/private marketplaces:

{
  type: 'hybrid',
  upstream: [
    { url: 'https://plugins.objectstack.com', syncPolicy: 'auto' }
  ],
  scope: ['@my-company'],
  storage: { backend: 's3', path: 'my-plugins' },
  mirrors: [{ url: 'https://mirror.example.com', priority: 1 }]
}

Supports npm-style scopes, upstream sync (auto/manual/proxy), and HA mirrors.

AI Low-Code Generation

Extended CodeGenerationRequestSchema with outputFormat enum:

  • source-code: Traditional TypeScript/JavaScript
  • low-code-schema: ObjectStack JSON/YAML schemas
  • dsl: Domain-specific language
{
  description: 'CRM with contacts management',
  outputFormat: 'low-code-schema',
  schemaOptions: {
    generateUI: true,          // views, dashboards, pages
    generateDataModels: true   // objects, fields
  }
}

AI generates platform-native metadata instead of raw code.

Runtime AIOps

New file ai/runtime-ops.zod.ts with autonomous operations protocols:

  • Anomaly Detection: ML-based with configurable algorithms
  • Self-Healing: Automated recovery (restart, scale, rollback, config tuning)
  • Auto-Scaling: Predictive scaling with look-ahead
  • Root Cause Analysis: Evidence-based RCA with confidence scoring
  • Performance Optimization: AI-suggested improvements with impact estimates
{
  selfHealing: {
    actions: [
      { id: 'restart', type: 'restart', trigger: { healthStatus: ['failed'] } }
    ],
    anomalyDetection: {
      metrics: ['cpu-usage', 'memory-usage'],
      algorithm: 'machine-learning'
    }
  },
  autoScaling: [{
    metric: 'cpu-usage',
    targetValue: 70,
    predictive: { enabled: true, lookAhead: 600 }
  }]
}

Files Changed

  • system/plugin-lifecycle-advanced.zod.ts - Distributed state
  • system/plugin-security-advanced.zod.ts - WASM runtime
  • hub/marketplace-enhanced.zod.ts - Registry federation
  • ai/plugin-development.zod.ts - Low-code generation
  • ai/runtime-ops.zod.ts - AIOps (new)

All schemas include comprehensive tests (78 new cases, 3232 total passing).

Original prompt

拉取请求: #503

作为全球顶级企业管理软件和低代码专家,我已对 objectstack-ai/spec 仓库中 PR #503 的相关代码和文档进行了深度扫描。

这份提交(PR #503)引入了一套非常完善的企业级协议,涵盖了插件生命周期版本控制安全沙箱市场机制以及AI辅助开发,质量已经非常高。但为了达成“全球最新最顶流”的目标,我们需要在云原生架构WASM沙箱混合AI开发模式以及私有化企业生态方面做进一步的升维。

以下是具体的改进方案和开发计划:

1. 核心架构改进方案 (Microkernel & Plugin System)

A. 引入集群感知与分布式状态 (针对 PluginLifecycle)

目前的 HotReloadConfig 中状态保持策略仅限于 memorydisk,这在单体应用中可行,但在企业级 Kubernetes 集群环境下是不够的。

  • 改进建议:在 system/plugin-lifecycle-advanced.zod.ts 中扩展状态策略,支持分布式缓存(Redis/Etcd)。
  • 代码变更建议
    // 修改 HotReloadConfigSchema 的 stateStrategy
    stateStrategy: z.enum(['memory', 'disk', 'distributed', 'none']).default('memory'),
    // 新增 distributedConfig
    distributedConfig: z.object({
      provider: z.enum(['redis', 'etcd', 'custom']),
      keyPrefix: z.string().optional(),
      ttl: z.number().optional()
    }).optional()

B. 强化沙箱隔离技术 (针对 PluginSecurity)

目前的沙箱级别 (strict, paranoid) 比较抽象。为了达到极致的安全和性能,建议明确支持 WebAssembly (WASM)容器化 隔离。WASM 是未来企业级插件运行时的标准。

  • 改进建议:在 system/plugin-security-advanced.zod.ts 中明确运行时环境。
  • 代码变更建议
    // 在 SandboxConfigSchema 中新增 runtime 字段
    runtime: z.object({
      engine: z.enum(['v8-isolate', 'wasm', 'container', 'process']).default('v8-isolate'),
      resourceLimits: z.object({
        // 针对 WASM 的特定限制
        maxMemoryPages: z.number().optional(),
        instructionLimit: z.number().optional()
      }).optional()
    }).optional()

2. 生态系统与市场改进 (Marketplace & Ecosystem)

C. 企业级私有仓库与联邦机制 (针对 Marketplace)

顶级企业软件需要支持“私有市场”与“公共市场”的混合模式。企业客户希望管理自己的插件,同时从公共市场获取更新。

  • 改进建议:在 hub/marketplace-enhanced.zod.ts 中增加 Registry Federation (仓库联邦) 概念。
  • 代码变更建议
    // 新增 RegistryConfigSchema
    export const RegistryConfigSchema = z.object({
      type: z.enum(['public', 'private', 'hybrid']),
      upstream: z.array(z.object({
        url: z.string().url(),
        syncPolicy: z.enum(['manual', 'auto', 'proxy']),
        auth: z.object({ /* ... */ })
      })).optional(),
      scope: z.array(z.string()).describe('npm-style scopes managed by this registry (@my-corp)')
    });

3. AI 自动化开发推进 (AI Automation)

D. 从“生成代码”转向“生成低代码元数据”

目前的 ai/plugin-development.zod.ts 侧重于生成 TypeScript 代码。但在低代码平台中,AI 生成 DSL (领域特定语言)JSON Schema 配置 比生成原始代码更安全、更可控。

  • 改进建议:在 CodeGenerationRequestSchema 中增加 outputFormat,支持生成平台原生的元数据。
  • 代码变更建议
    // 修改 CodeGenerationRequestSchema
    outputFormat: z.enum(['source-code', 'low-code-schema', 'dsl']).default('source-code'),
    
    // 如果是 low-code-schema,生成的不是 .ts 文件,而是 .json/.yaml 的页面/模型定义

E. 运行时 AI 运维 (AIOps)

除了开发阶段,还需要运行时的 AI 介入。

  • 建议:新增 ai/runtime-ops.zod.ts,定义 自愈 (Self-Healing)智能扩缩容 协议。
    • PluginHealthStatus 变为 degraded 时,AI Agent 自动分析日志并尝试通过配置调整进行修复。

4. 推进计划 (Roadmap)

基于上述改进,我制定了以下阶段性开发计划:

  • Phase 1: 云原生内核升级 (Week 1-2)

    • 任务:实施 WASM 沙箱协议与分布式状态管理协议。
    • 目标:确保插件系统可以在 K8s 环境下安全、高可用地运行。
  • Phase 2: 混合云市场构建 (Week 3-4)

    • 任务:实现私有仓库协议与联邦同步机制。
    • 目标:满足大客户“内网开发,外网更新”的需求。
  • Phase 3: AI 低代码引擎 (Week 5-8)

    • 任务:训练/微调模型,使其能输出符合平台规范的 JSON Schema/DSL,而不仅仅是代码。
    • 目标:降低开发门槛,业务人员通过自然语言即可生成可用的管理后台页面。
  • Phase 4: 智能运维闭环 (Week 9+)

    • 任务:集成运行时监控数据给 AI 模型,实现故障预测与自动修复。

总结:PR #503 是一个非常扎实的基础。通过引入 WASM 支持、分布式状态和低代码元数据生成,我们将把这个框架从“优秀的插件系统”提升为“世界级的企业应用操作系统”。

您可以直接指示我针对上述任何一点创建具体的 PR 或代码实现。


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Error Error Feb 3, 2026 8:37am

Request Review

…code features

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Update enterprise protocol for plugin lifecycle and cloud-native enhancements Add distributed state, WASM runtime, registry federation, and AIOps protocols Feb 3, 2026
Copilot AI requested a review from hotlong February 3, 2026 08:40
@hotlong hotlong marked this pull request as ready for review February 3, 2026 08:52
Copilot AI review requested due to automatic review settings February 3, 2026 08:52
@hotlong hotlong merged commit 07de602 into copilot/improve-microkernel-plugins Feb 3, 2026
4 of 5 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends the spec protocols for enterprise plugin deployments by adding distributed state persistence options, configurable sandbox runtime engines (including WASM), registry federation primitives, and expanded AI protocols for low-code generation and runtime AIOps.

Changes:

  • Added distributed-state configuration to advanced plugin lifecycle hot reload settings.
  • Added sandbox runtime engine configuration (v8-isolate/wasm/container/process) to advanced plugin security.
  • Added registry federation schemas plus new/extended AI schemas for low-code output and runtime AIOps.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/spec/src/system/plugin-lifecycle-advanced.zod.ts Adds distributed state schema and wires it into hot reload config.
packages/spec/src/system/plugin-lifecycle-advanced.test.ts Adds test coverage for distributed state strategy/config parsing.
packages/spec/src/system/plugin-security-advanced.zod.ts Adds runtime engine configuration to sandbox settings.
packages/spec/src/system/plugin-security-advanced.test.ts Adds test coverage for runtime config + sandbox integration.
packages/spec/src/hub/marketplace-enhanced.zod.ts Adds registry federation schemas (upstreams, sync policy, storage, mirrors).
packages/spec/src/hub/marketplace-enhanced.test.ts Adds test coverage for registry federation schema parsing.
packages/spec/src/ai/plugin-development.zod.ts Extends code generation to support output formats (source-code / low-code-schema / dsl).
packages/spec/src/ai/plugin-development.test.ts Adds test coverage for new outputFormat and low-code schema outputs.
packages/spec/src/ai/runtime-ops.zod.ts Introduces AIOps runtime protocols: anomaly detection, self-healing, scaling, RCA, optimization, agent config.
packages/spec/src/ai/runtime-ops.test.ts Adds test coverage for new AIOps schemas.
packages/spec/src/ai/index.ts Exports the new runtime-ops protocol module.
packages/spec/json-schema/system/RuntimeConfig.json Adds JSON-schema stub entry for RuntimeConfig.
packages/spec/json-schema/system/DistributedStateConfig.json Adds JSON-schema stub entry for DistributedStateConfig.
packages/spec/json-schema/hub/RegistryUpstream.json Adds JSON-schema stub entry for RegistryUpstream.
packages/spec/json-schema/hub/RegistrySyncPolicy.json Adds JSON-schema stub entry for RegistrySyncPolicy.
packages/spec/json-schema/hub/RegistryConfig.json Adds JSON-schema stub entry for RegistryConfig.
packages/spec/json-schema/ai/AnomalyDetectionConfig.json Adds JSON-schema stub entry for AnomalyDetectionConfig.
packages/spec/json-schema/ai/SelfHealingAction.json Adds JSON-schema stub entry for SelfHealingAction.
packages/spec/json-schema/ai/SelfHealingConfig.json Adds JSON-schema stub entry for SelfHealingConfig.
packages/spec/json-schema/ai/AutoScalingPolicy.json Adds JSON-schema stub entry for AutoScalingPolicy.
packages/spec/json-schema/ai/RootCauseAnalysisRequest.json Adds JSON-schema stub entry for RootCauseAnalysisRequest.
packages/spec/json-schema/ai/RootCauseAnalysisResult.json Adds JSON-schema stub entry for RootCauseAnalysisResult.
packages/spec/json-schema/ai/PerformanceOptimization.json Adds JSON-schema stub entry for PerformanceOptimization.
packages/spec/json-schema/ai/AIOpsAgentConfig.json Adds JSON-schema stub entry for AIOpsAgentConfig.
content/docs/references/ai/meta.json Adds runtime-ops to the AI reference navigation metadata.
content/docs/references/ai/index.mdx Adds a docs card linking to the runtime-ops reference page.

Comment on lines +179 to +259
*/
engineConfig: z.object({
/**
* WASM-specific settings (when engine is "wasm")
*/
wasm: z.object({
/**
* Maximum memory pages (64KB per page)
*/
maxMemoryPages: z.number().int().min(1).max(65536).optional()
.describe('Maximum WASM memory pages (64KB each)'),

/**
* Instruction execution limit
*/
instructionLimit: z.number().int().min(1).optional()
.describe('Maximum instructions before timeout'),

/**
* Enable SIMD instructions
*/
enableSimd: z.boolean().default(false)
.describe('Enable WebAssembly SIMD support'),

/**
* Enable threads
*/
enableThreads: z.boolean().default(false)
.describe('Enable WebAssembly threads'),

/**
* Enable bulk memory operations
*/
enableBulkMemory: z.boolean().default(true)
.describe('Enable bulk memory operations'),
}).optional(),

/**
* Container-specific settings (when engine is "container")
*/
container: z.object({
/**
* Container image
*/
image: z.string().optional()
.describe('Container image to use'),

/**
* Container runtime
*/
runtime: z.enum(['docker', 'podman', 'containerd']).default('docker'),

/**
* Resource limits
*/
resources: z.object({
cpuLimit: z.string().optional().describe('CPU limit (e.g., "0.5", "2")'),
memoryLimit: z.string().optional().describe('Memory limit (e.g., "512m", "1g")'),
}).optional(),

/**
* Network mode
*/
networkMode: z.enum(['none', 'bridge', 'host']).default('bridge'),
}).optional(),

/**
* V8 Isolate-specific settings (when engine is "v8-isolate")
*/
v8Isolate: z.object({
/**
* Heap size limit in MB
*/
heapSizeMb: z.number().int().min(1).optional(),

/**
* Enable snapshot
*/
enableSnapshot: z.boolean().default(true),
}).optional(),
}).optional(),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RuntimeConfigSchema doesn’t currently constrain engineConfig based on the selected engine (and engineConfig can be omitted entirely). Consider using a discriminated union on engine (or a refine) so only the matching engine’s config is allowed/required, preventing conflicting configs like providing both wasm and container settings.

Suggested change
*/
engineConfig: z.object({
/**
* WASM-specific settings (when engine is "wasm")
*/
wasm: z.object({
/**
* Maximum memory pages (64KB per page)
*/
maxMemoryPages: z.number().int().min(1).max(65536).optional()
.describe('Maximum WASM memory pages (64KB each)'),
/**
* Instruction execution limit
*/
instructionLimit: z.number().int().min(1).optional()
.describe('Maximum instructions before timeout'),
/**
* Enable SIMD instructions
*/
enableSimd: z.boolean().default(false)
.describe('Enable WebAssembly SIMD support'),
/**
* Enable threads
*/
enableThreads: z.boolean().default(false)
.describe('Enable WebAssembly threads'),
/**
* Enable bulk memory operations
*/
enableBulkMemory: z.boolean().default(true)
.describe('Enable bulk memory operations'),
}).optional(),
/**
* Container-specific settings (when engine is "container")
*/
container: z.object({
/**
* Container image
*/
image: z.string().optional()
.describe('Container image to use'),
/**
* Container runtime
*/
runtime: z.enum(['docker', 'podman', 'containerd']).default('docker'),
/**
* Resource limits
*/
resources: z.object({
cpuLimit: z.string().optional().describe('CPU limit (e.g., "0.5", "2")'),
memoryLimit: z.string().optional().describe('Memory limit (e.g., "512m", "1g")'),
}).optional(),
/**
* Network mode
*/
networkMode: z.enum(['none', 'bridge', 'host']).default('bridge'),
}).optional(),
/**
* V8 Isolate-specific settings (when engine is "v8-isolate")
*/
v8Isolate: z.object({
/**
* Heap size limit in MB
*/
heapSizeMb: z.number().int().min(1).optional(),
/**
* Enable snapshot
*/
enableSnapshot: z.boolean().default(true),
}).optional(),
}).optional(),
*
* Only one engine-specific configuration block is allowed at a time to
* prevent conflicting settings (e.g., both WASM and container configs).
*/
engineConfig: z.union([
/**
* WASM-specific settings (when engine is "wasm")
*/
z.object({
wasm: z.object({
/**
* Maximum memory pages (64KB per page)
*/
maxMemoryPages: z.number().int().min(1).max(65536).optional()
.describe('Maximum WASM memory pages (64KB each)'),
/**
* Instruction execution limit
*/
instructionLimit: z.number().int().min(1).optional()
.describe('Maximum instructions before timeout'),
/**
* Enable SIMD instructions
*/
enableSimd: z.boolean().default(false)
.describe('Enable WebAssembly SIMD support'),
/**
* Enable threads
*/
enableThreads: z.boolean().default(false)
.describe('Enable WebAssembly threads'),
/**
* Enable bulk memory operations
*/
enableBulkMemory: z.boolean().default(true)
.describe('Enable bulk memory operations'),
}).optional(),
}),
/**
* Container-specific settings (when engine is "container")
*/
z.object({
container: z.object({
/**
* Container image
*/
image: z.string().optional()
.describe('Container image to use'),
/**
* Container runtime
*/
runtime: z.enum(['docker', 'podman', 'containerd']).default('docker'),
/**
* Resource limits
*/
resources: z.object({
cpuLimit: z.string().optional().describe('CPU limit (e.g., "0.5", "2")'),
memoryLimit: z.string().optional().describe('Memory limit (e.g., "512m", "1g")'),
}).optional(),
/**
* Network mode
*/
networkMode: z.enum(['none', 'bridge', 'host']).default('bridge'),
}).optional(),
}),
/**
* V8 Isolate-specific settings (when engine is "v8-isolate")
*/
z.object({
v8Isolate: z.object({
/**
* Heap size limit in MB
*/
heapSizeMb: z.number().int().min(1).optional(),
/**
* Enable snapshot
*/
enableSnapshot: z.boolean().default(true),
}).optional(),
}),
]).optional(),

Copilot uses AI. Check for mistakes.
Comment on lines +47 to +51
/**
* Sync interval in seconds (for auto sync)
*/
syncInterval: z.number().int().min(60).optional()
.describe('Auto-sync interval in seconds'),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syncInterval is described as "for auto sync" but is optional and not validated against syncPolicy. Add a refinement so syncInterval is required when syncPolicy === "auto" (and ideally rejected for manual/proxy to prevent misleading configs).

Copilot uses AI. Check for mistakes.
username: z.string().optional(),
password: z.string().optional(),
token: z.string().optional(),
apiKey: z.string().optional(),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auth validation is too permissive: configs like { type: "bearer" } or { type: "basic", username: "u" } currently pass. Add cross-field validation to require username+password for basic, token for bearer, apiKey for api-key, etc.

Suggested change
apiKey: z.string().optional(),
apiKey: z.string().optional(),
}).superRefine((value, ctx) => {
switch (value.type) {
case 'basic': {
if (!value.username) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['username'],
message: 'username is required when auth type is "basic"',
});
}
if (!value.password) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['password'],
message: 'password is required when auth type is "basic"',
});
}
break;
}
case 'bearer': {
if (!value.token) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['token'],
message: 'token is required when auth type is "bearer"',
});
}
break;
}
case 'api-key': {
if (!value.apiKey) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['apiKey'],
message: 'apiKey is required when auth type is "api-key"',
});
}
break;
}
case 'oauth2': {
if (!value.token) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['token'],
message: 'token is required when auth type is "oauth2"',
});
}
break;
}
case 'none':
default:
break;
}

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +103
trigger: z.object({
/**
* Health status that triggers this action
*/
healthStatus: z.array(PluginHealthStatusSchema).optional(),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SelfHealingActionSchema.trigger can be an empty object, which makes the action impossible to trigger (and likely indicates a misconfiguration). Add a refinement to require at least one of healthStatus, anomalyTypes, errorPatterns, or customCondition to be present/non-empty.

Copilot uses AI. Check for mistakes.
Comment on lines +241 to +245
minInstances: z.number().int().min(1).default(1),

/**
* Maximum instances
*/
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bounds allows minInstances and maxInstances independently, so minInstances > maxInstances currently passes validation. Add a cross-field check (refine/superRefine) to enforce minInstances <= maxInstances.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +45
outputFormat: z.enum([
'source-code', // Generate TypeScript/JavaScript source code
'low-code-schema', // Generate ObjectStack JSON/YAML schema definitions
'dsl', // Generate domain-specific language definitions
]).default('source-code')
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputFormat is added, but related fields (e.g., language, style, schemaOptions) aren’t constrained by it, so requests can contain incompatible combinations. Consider switching to a z.discriminatedUnion('outputFormat', ...) (or add refinements) to only allow/require fields relevant to each output format.

Copilot uses AI. Check for mistakes.
Comment on lines +223 to +227
/**
* Distributed state configuration (required when stateStrategy is "distributed")
*/
distributedConfig: DistributedStateConfigSchema.optional()
.describe('Configuration for distributed state management'),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distributedConfig is documented as required when stateStrategy is "distributed", but the schema currently allows { stateStrategy: "distributed" } without distributedConfig. Add a .refine/.superRefine to enforce distributedConfig when stateStrategy === "distributed" (and optionally disallow it for other strategies to avoid ambiguous configs).

Copilot uses AI. Check for mistakes.
Comment on lines +223 to +227
/**
* Custom metric query (when metric is "custom")
*/
customMetric: z.string().optional(),

Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customMetric is described as required when metric is "custom", but it’s optional with no validation. Add a refinement so customMetric is required when metric === "custom" (and optionally rejected for non-custom metrics).

Copilot uses AI. Check for mistakes.
Comment on lines +183 to 187
outputFormat: z.enum(['source-code', 'low-code-schema', 'dsl']),

/**
* Language used
* Main plugin code (for source-code format)
*/
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GeneratedCodeSchema now includes outputFormat, but code/language are optional regardless of the selected format, allowing incomplete outputs that omit expected fields. Consider modeling this as a discriminated union (or refine) so outputFormat: "source-code" requires code and language, and other formats require their corresponding payload.

Copilot uses AI. Check for mistakes.
Comment on lines +195 to +199
/**
* Low-code schema definitions (for low-code-schema format)
*/
schemas: z.array(z.object({
type: z.enum(['object', 'view', 'dashboard', 'app', 'workflow', 'api', 'page']),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For outputFormat: "low-code-schema", schemas is optional, so a response can claim low-code output without any schema artifacts. If files isn’t intended to be the sole carrier, add validation to require a non-empty schemas array when outputFormat === "low-code-schema" (or clarify/enforce the intended source of truth).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants