Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Adds two AI protocol specifications to enable intelligent automation and ML-powered decision making in ObjectStack applications.

AI Workflow Automation (ai/workflow-automation.zod.ts)

Core capabilities:

  • Triggers: record_created, record_updated, field_changed, scheduled, manual, webhook, batch
  • AI Tasks: classify, extract, summarize, generate, predict, translate, sentiment, entity_recognition, anomaly_detection, recommendation
  • Execution: Sequential/parallel modes, batch processing, conditional execution, retry logic
  • Post-processing: Field updates, notifications, flow triggers, webhooks

Example usage:

const workflow: AIWorkflowAutomation = {
  name: 'auto_triage_tickets',
  objectName: 'support_ticket',
  trigger: 'record_created',
  aiTasks: [
    {
      type: 'classify',
      inputFields: ['description'],
      outputField: 'category',
      classes: ['bug', 'feature', 'question']
    },
    {
      type: 'sentiment',
      inputFields: ['description'],
      outputField: 'urgency_score'
    }
  ],
  postActions: [{
    type: 'field_update',
    name: 'route_to_team',
    config: { /* ... */ }
  }]
}

Predictive Analytics (ai/predictive.zod.ts)

Model types: classification, regression, clustering, forecasting, anomaly_detection, recommendation, ranking

Features:

  • Feature engineering with 8 transformation types (normalize, one-hot encode, log transform, etc.)
  • Hyperparameters for tree-based, neural network, clustering, time-series algorithms
  • Training configuration: cross-validation, early stopping, GPU support
  • Evaluation metrics: accuracy/precision/recall/F1/AUC, MSE/RMSE/MAE/R², silhouette score, MAPE
  • Auto-retraining with drift detection
  • Model explainability

Example usage:

const model: PredictiveModel = {
  name: 'lead_conversion_predictor',
  type: 'classification',
  objectName: 'lead',
  target: 'converted',
  features: [
    { name: 'engagement_score', field: 'engagement_score', dataType: 'numeric', transformation: 'standardize' },
    { name: 'company_size', field: 'employee_count', dataType: 'numeric', transformation: 'log_transform' },
    { name: 'industry', field: 'industry', dataType: 'categorical', transformation: 'one_hot_encode' }
  ],
  hyperparameters: { numTrees: 200, maxDepth: 8, learningRate: 0.1 },
  autoRetrain: true,
  enableExplainability: true
}

Technical notes

  • All schemas follow Zod-first design with runtime validation and TypeScript inference
  • 75 test cases cover real-world scenarios (support automation, lead scoring, document processing, forecasting)
  • Generated 18 JSON schemas and 18 MDX documentation files
  • Resolved naming collision with existing license Feature schema by using ModelFeature
  • No breaking changes: all 1401 existing tests pass
Original prompt

管理
⚠️ 需要增强的部分

  1. AI 工作流自动化 (优先级: 中等)

// 建议新增: src/ai/workflow-automation.zod.ts
export const AIWorkflowSchema = z.object({
trigger: z.enum(['record_created', 'field_changed', 'scheduled']),
aiTasks: z.array(z.object({
type: z.enum(['classify', 'extract', 'summarize', 'generate', 'predict']),
model: z.string(),
inputFields: z.array(z.string()),
outputField: z.string(),
})),
});
影响: 智能业务流程自动化

  1. 预测分析协议 (优先级: 低)

// 建议新增: src/ai/predictive.zod.ts
export const PredictiveModelSchema = z.object({
type: z.enum(['classification', 'regression', 'clustering', 'forecasting']),
features: z.array(z.string()),
target: z.string(),
hyperparameters: z.record(z.any()).optional(),
});
影响: 数据驱动决策


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Jan 23, 2026

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

Project Deployment Review Updated (UTC)
spec Ready Ready Preview, Comment Jan 23, 2026 8:44am

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…alytics

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add AI workflow automation schema to project Add AI workflow automation and predictive analytics protocols Jan 23, 2026
Copilot AI requested a review from hotlong January 23, 2026 08:43
@hotlong hotlong marked this pull request as ready for review January 23, 2026 09:27
Copilot AI review requested due to automatic review settings January 23, 2026 09:27
@github-actions github-actions bot added documentation Improvements or additions to documentation tests protocol:ai labels Jan 23, 2026
@github-actions
Copy link
Contributor

This PR is very large. Consider breaking it into smaller PRs for easier review.

Copy link
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

This PR introduces AI workflow automation and predictive analytics protocol schemas to the ObjectStack spec, with matching JSON Schemas, documentation, and tests. It extends the AI surface area to support intelligent workflows (triggers, tasks, post-actions) and ML model definitions (features, training, evaluation, drift, prediction IO).

Changes:

  • Added AIWorkflowAutomation protocol schemas, batch/execution result types, re-exports, and comprehensive scenario-based tests.
  • Added PredictiveModel / predictive analytics schemas (features, hyperparameters, training, metrics, prediction request/response, drift), plus exhaustive tests.
  • Generated and wired corresponding JSON Schema definitions and MDX reference documentation for all new AI protocol components.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/spec/src/ai/workflow-automation.zod.ts Defines Zod-first schemas and inferred types for AI workflow triggers, tasks, schedules, post-actions, workflow definition, batch execution, and execution results.
packages/spec/src/ai/workflow-automation.test.ts Adds extensive Vitest coverage for workflow automation schemas, including edge cases and real-world workflows.
packages/spec/src/ai/predictive.zod.ts Defines Zod schemas and inferred types for predictive model types, features, hyperparameters, training config, evaluation metrics, model definition, prediction IO, and drift detection.
packages/spec/src/ai/predictive.test.ts Provides broad test coverage for predictive schemas across model types and realistic ML use cases.
packages/spec/src/ai/index.ts Re-exports new workflow automation and predictive analytics schemas from the AI module entrypoint.
packages/spec/json-schema/WorkflowSchedule.json JSON Schema for WorkflowSchedule, mirroring the schedule Zod schema used by AI workflows.
packages/spec/json-schema/WorkflowFieldCondition.json JSON Schema for WorkflowFieldCondition, used to constrain field_changed workflow triggers.
packages/spec/json-schema/TrainingConfig.json JSON Schema for TrainingConfig, representing training data splits, strategy, and resource limits.
packages/spec/json-schema/PredictiveModelType.json JSON Schema enum for predictive model types (classification, regression, etc.).
packages/spec/json-schema/PredictiveModel.json JSON Schema for PredictiveModel, aligning with the predictive model Zod schema.
packages/spec/json-schema/PredictionResult.json JSON Schema for PredictionResult; currently treats prediction as optional, unlike the Zod schema (see comment).
packages/spec/json-schema/PredictionRequest.json JSON Schema for PredictionRequest, describing model name, record IDs, direct input data, and return flags.
packages/spec/json-schema/PostProcessingAction.json JSON Schema for PostProcessingAction, used in AI workflow post-action definitions.
packages/spec/json-schema/ModelFeature.json JSON Schema for ModelFeature, capturing feature identity, source, type, and transformation.
packages/spec/json-schema/ModelDrift.json JSON Schema for ModelDrift, mirroring drift detection configuration/result schema.
packages/spec/json-schema/Hyperparameters.json JSON Schema for Hyperparameters, covering general, tree-based, NN, clustering, and time-series params.
packages/spec/json-schema/EvaluationMetrics.json JSON Schema for EvaluationMetrics, including classification, regression, clustering, and time-series metrics.
packages/spec/json-schema/BatchAIWorkflowExecution.json JSON Schema for BatchAIWorkflowExecution, specifying workflow name, record IDs, and batch options.
packages/spec/json-schema/AIWorkflowTrigger.json JSON Schema enum for AIWorkflowTrigger values.
packages/spec/json-schema/AIWorkflowExecutionResult.json JSON Schema for AIWorkflowExecutionResult, describing workflow run outcome and per-task results.
packages/spec/json-schema/AIWorkflowAutomation.json JSON Schema for AIWorkflowAutomation, matching the workflow automation Zod schema.
packages/spec/json-schema/AITaskType.json JSON Schema enum for AITaskType values.
packages/spec/json-schema/AITask.json JSON Schema for AITask, reflecting the AI task Zod schema structure.
content/docs/references/ai/WorkflowSchedule.mdx MDX reference doc for WorkflowSchedule, detailing schedule fields used by AI workflows.
content/docs/references/ai/WorkflowFieldCondition.mdx MDX reference doc for WorkflowFieldCondition, describing field-based trigger conditions.
content/docs/references/ai/TrainingConfig.mdx MDX reference doc for TrainingConfig, documenting training strategy and split fields.
content/docs/references/ai/PredictiveModelType.mdx MDX listing the allowed PredictiveModelType enum values.
content/docs/references/ai/PredictiveModel.mdx MDX reference for PredictiveModel, summarizing all model configuration properties.
content/docs/references/ai/PredictionResult.mdx MDX doc for PredictionResult; currently documents prediction as optional, diverging from the Zod schema.
content/docs/references/ai/PredictionRequest.mdx MDX reference for PredictionRequest, documenting request fields and semantics.
content/docs/references/ai/PostProcessingAction.mdx MDX reference for PostProcessingAction, describing action types and configuration.
content/docs/references/ai/ModelFeature.mdx MDX reference for ModelFeature, documenting feature identity, type, and transformation.
content/docs/references/ai/ModelDrift.mdx MDX reference for ModelDrift, explaining drift types, severity, and metrics.
content/docs/references/ai/Hyperparameters.mdx MDX reference for Hyperparameters, covering standard ML hyperparameter fields.
content/docs/references/ai/EvaluationMetrics.mdx MDX reference for EvaluationMetrics, listing supported metric fields.
content/docs/references/ai/BatchAIWorkflowExecution.mdx MDX reference for BatchAIWorkflowExecution, documenting batch execution options.
content/docs/references/ai/AIWorkflowTrigger.mdx MDX listing allowed AIWorkflowTrigger values.
content/docs/references/ai/AIWorkflowExecutionResult.mdx MDX reference for AIWorkflowExecutionResult, summarizing workflow run result properties.
content/docs/references/ai/AIWorkflowAutomation.mdx MDX reference for AIWorkflowAutomation, documenting workflow identity, triggers, tasks, and options.
content/docs/references/ai/AITaskType.mdx MDX listing allowed AITaskType values.
content/docs/references/ai/AITask.mdx MDX reference for AITask, describing task configuration fields.
content/docs/references/ai/WorkflowSchedule.mdx MDX reference for WorkflowSchedule, used by AIWorkflow docs.
content/docs/references/ai/WorkflowFieldCondition.mdx MDX reference for workflow field conditions (used in AI workflows).

Comment on lines +247 to +252
export const PredictionResultSchema = z.object({
modelName: z.string(),
modelVersion: z.string(),
recordId: z.string().optional(),
prediction: z.any().describe('The predicted value'),
confidence: z.number().optional().describe('Confidence score (0-1)'),
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

PredictionResultSchema currently requires prediction (z.any()) at the Zod level, but the generated JSON Schema (PredictionResult.json) and MDX docs (PredictionResult.mdx) treat prediction as optional (not listed in required and documented without the required checkmark). This discrepancy means CLI/runtime validation and JSON-schema–driven tooling/IDE hints will disagree on whether prediction must be present. Consider aligning these by either making prediction optional in the Zod schema or marking it as required in the JSON schema/docs, depending on the intended contract for prediction results.

Copilot uses AI. Check for mistakes.
@hotlong hotlong merged commit c636886 into main Jan 23, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:ai size/xl tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants