Skip to content

Commit 233b07d

Browse files
talborenkibanamachineKiryous
authored andcommitted
feat: workflows feature flag (elastic#231837)
Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Kirill Chernakov <[email protected]>
1 parent 247991f commit 233b07d

File tree

23 files changed

+485
-153
lines changed

23 files changed

+485
-153
lines changed

docs/extend/plugin-list.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ mapped_pages:
100100
| [visTypeVislib](https://github.com/elastic/kibana/blob/main/src/platform/plugins/private/vis_types/vislib) | WARNING: Missing or empty README. |
101101
| [visTypeXy](https://github.com/elastic/kibana/blob/main/src/platform/plugins/private/vis_types/xy) | WARNING: Missing or empty README. |
102102
| [visualizations](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/visualizations) | WARNING: Missing or empty README. |
103-
| [workflowsExecutionEngine](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/workflows_execution_engine/README.md) | WARNING: Missing or empty README. |
104-
| [workflowsManagement](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/workflows_management/README.md) | This directory contains the foundational structure for the Workflows plugin. |
103+
| [workflowsExecutionEngine](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/workflows_execution_engine/README.md) | Stateless execution engine for workflows. |
104+
| [workflowsManagement](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/workflows_management/README.md) | This plugin contains the Workflows management application and APIs. |
105105

106106
## x-pack/plugins [_x_packplugins]
107107

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# @kbn/workflows
2+
3+
Common types, utilities, and constants for the Workflows platform feature.
4+
5+
This package contains shared code used by both the workflows execution engine and workflows management plugins. It provides the foundational types, schemas, and utilities needed for workflow operations across the platform.
6+
7+
## Overview
8+
9+
The `@kbn/workflows` package serves as the common foundation for all workflow-related functionality in Kibana. It includes:
10+
11+
- **Type Definitions**: Core TypeScript interfaces and types
12+
- **Workflow Specifications**: Schema definitions for workflow structure
13+
- **Utilities**: Helper functions and validation logic
14+
- **Constants**: Feature flags and configuration constants
15+
16+
## Feature Flags
17+
18+
This package exports feature flag constants that control workflow functionality:
19+
20+
```typescript
21+
import {
22+
WORKFLOWS_UI_SETTING_ID
23+
} from '@kbn/workflows';
24+
```
25+
26+
### Available Feature Flags
27+
28+
- `WORKFLOWS_UI_SETTING_ID` (`workflows:ui:enabled`): Controls the workflows management UI
29+
30+
## Types
31+
32+
### Core Types
33+
34+
The package exports essential workflow types:
35+
36+
```typescript
37+
import type {
38+
WorkflowDefinition,
39+
WorkflowExecution,
40+
WorkflowSpec,
41+
WorkflowStepType,
42+
WorkflowStepDefinition
43+
} from '@kbn/workflows';
44+
```
45+
46+
### Workflow Definition
47+
Represents the structure and configuration of a workflow:
48+
49+
```typescript
50+
interface WorkflowDefinition {
51+
id: string;
52+
name: string;
53+
description?: string;
54+
steps: WorkflowStepDefinition[];
55+
triggers?: WorkflowTrigger[];
56+
variables?: Record<string, any>;
57+
}
58+
```
59+
60+
### Workflow Execution
61+
Represents a runtime instance of a workflow:
62+
63+
```typescript
64+
interface WorkflowExecution {
65+
id: string;
66+
workflowId: string;
67+
status: ExecutionStatus;
68+
createdAt: string;
69+
completedAt?: string;
70+
context: Record<string, any>;
71+
steps: StepExecution[];
72+
}
73+
```
74+
75+
## Workflow Specification
76+
77+
The package includes comprehensive schema definitions for workflow structure:
78+
79+
- **Step Types**: Different types of workflow steps (action, condition, loop, etc.)
80+
- **Validation**: Schema validation for workflow definitions
81+
- **YAML Schema**: Generate YAML schema for workflow files
82+
83+
## Usage
84+
85+
### In Plugins
86+
87+
Workflow plugins use this package for shared functionality:
88+
89+
```typescript
90+
// In workflows execution engine
91+
import { WorkflowDefinition } from '@kbn/workflows';
92+
93+
// In workflows management
94+
import { WORKFLOWS_UI_SETTING_ID } from '@kbn/workflows/common/constants';
95+
```
96+
97+
### Type Safety
98+
99+
The package ensures type safety across all workflow operations:
100+
101+
```typescript
102+
import type { WorkflowDefinition } from '@kbn/workflows';
103+
104+
function processWorkflow(workflow: WorkflowDefinition) {
105+
// TypeScript ensures proper workflow structure
106+
const { id, name, steps } = workflow;
107+
// ...
108+
}
109+
```
110+
111+
## Architecture
112+
113+
The package is organized into several key areas:
114+
115+
- **`types/`**: Core TypeScript type definitions
116+
- **`spec/`**: Workflow specification and schema
117+
- **`common/`**: Shared constants and utilities
118+
119+
## Validation
120+
121+
The package provides validation utilities for workflow definitions:
122+
123+
```typescript
124+
import { validateWorkflowDefinition } from '@kbn/workflows';
125+
126+
const isValid = validateWorkflowDefinition(workflowDef);
127+
```
128+
129+
## Schema Generation
130+
131+
Generate YAML schemas for workflow files:
132+
133+
```typescript
134+
import { generateYamlSchema } from '@kbn/workflows';
135+
136+
const schema = generateYamlSchema();
137+
```
138+
139+
This enables IDE support and validation for workflow YAML files.
140+
141+
## Development
142+
143+
When extending workflow functionality:
144+
145+
1. Add new types to the appropriate type definition files
146+
2. Update schemas to reflect new workflow capabilities
147+
3. Export new functionality from the main index file
148+
4. Ensure backward compatibility with existing workflows
149+
150+
## Dependencies
151+
152+
This package has minimal dependencies to ensure it can be used across different contexts:
153+
154+
- Core Kibana types for integration
155+
- Schema validation libraries
156+
- Utility libraries for common operations
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
import { WORKFLOWS_UI_SETTING_ID } from './constants';
11+
12+
describe('Workflow Feature Flag Constants', () => {
13+
it('should export the correct UI setting ID', () => {
14+
expect(WORKFLOWS_UI_SETTING_ID).toBe('workflows:ui:enabled');
15+
});
16+
17+
it('should have consistent naming pattern', () => {
18+
expect(WORKFLOWS_UI_SETTING_ID).toMatch(/^workflows:/);
19+
expect(WORKFLOWS_UI_SETTING_ID).toMatch(/:enabled$/);
20+
});
21+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
/**
11+
* UI Setting ID for enabling / disabling the workflows management UI
12+
*/
13+
export const WORKFLOWS_UI_SETTING_ID = 'workflows:ui:enabled';

src/platform/packages/shared/kbn-workflows/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10+
export * from './spec/lib/generate_yaml_schema';
11+
export * from './spec/schema';
1012
export * from './types/latest';
1113
export * from './types/utils';
12-
export * from './spec/schema';
13-
export * from './spec/lib/generate_yaml_schema';
14+
export * from './common/constants';

src/platform/plugins/private/kibana_usage_collection/server/collectors/management/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
511511
type: 'boolean',
512512
_meta: { description: 'Non-default value of setting.' },
513513
},
514+
'workflows:ui:enabled': {
515+
type: 'boolean',
516+
_meta: { description: 'Non-default value of setting.' },
517+
},
514518
'banners:placement': {
515519
type: 'keyword',
516520
_meta: { description: 'Non-default value of setting.' },

src/platform/plugins/private/kibana_usage_collection/server/collectors/management/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface UsageStats {
5353
'onechat:a2a:enabled': boolean;
5454
'onechat:ui:enabled': boolean;
5555
'onechat:api:enabled': boolean;
56+
'workflows:ui:enabled': boolean;
5657
'visualization:heatmap:maxBuckets': number;
5758
'visualization:regionmap:showWarnings': boolean;
5859
'visualization:tileMap:maxPrecision': number;

src/platform/plugins/shared/telemetry/schema/oss_platform.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10811,6 +10811,12 @@
1081110811
"description": "Non-default value of setting."
1081210812
}
1081310813
},
10814+
"workflows:ui:enabled": {
10815+
"type": "boolean",
10816+
"_meta": {
10817+
"description": "Non-default value of setting."
10818+
}
10819+
},
1081410820
"banners:placement": {
1081510821
"type": "keyword",
1081610822
"_meta": {
Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,50 @@
1-
# Workflows Execution Engine
1+
# Workflows Execution Engine Plugin
2+
3+
Stateless execution engine for workflows.
4+
5+
The workflows execution engine is responsible for executing workflow definitions and managing their lifecycle. It provides the core runtime for workflow processing, step execution, and state management.
6+
7+
## Overview
8+
9+
The workflows execution engine plugin provides:
10+
11+
- **Workflow Execution**: Core runtime for executing workflow definitions
12+
- **Step Management**: Individual step execution and state tracking
13+
- **Context Management**: Runtime context and variable management
14+
- **Event Logging**: Comprehensive execution logging and monitoring
15+
- **Repository Layer**: Persistence for executions and state
16+
17+
## Architecture
18+
19+
The execution engine follows a modular architecture:
20+
21+
- **Plugin Core**: Main plugin setup and lifecycle management
22+
- **Step Factory**: Creates and manages different step types
23+
- **Context Manager**: Handles workflow and step execution context
24+
- **Event Logger**: Logs workflow execution events and state changes
25+
- **Repositories**: Data persistence layer for executions and logs
26+
27+
## Key Components
28+
29+
### Step Execution
30+
The engine supports various step types and provides a factory pattern for step creation and execution.
31+
32+
### Context Management
33+
Workflow context is managed throughout execution, allowing steps to access and modify shared state.
34+
35+
### Event Logging
36+
All workflow execution events are logged to Elasticsearch for monitoring and debugging.
37+
38+
## Dependencies
39+
40+
- **Task Manager**: For scheduled workflow execution
41+
- **Actions**: For connector-based step execution (*this is temporary*)
42+
43+
## Usage
44+
45+
The execution engine is primarily used by the workflows management plugin to execute workflow definitions. It provides APIs for:
46+
47+
- Starting workflow executions
48+
- Managing execution state
49+
- Retrieving execution logs and status
50+
- Handling step-by-step execution flow

0 commit comments

Comments
 (0)