omgkit 2.13.0 → 2.16.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/README.md +129 -10
- package/package.json +2 -2
- package/plugin/agents/api-designer.md +5 -0
- package/plugin/agents/architect.md +8 -0
- package/plugin/agents/brainstormer.md +4 -0
- package/plugin/agents/cicd-manager.md +6 -0
- package/plugin/agents/code-reviewer.md +6 -0
- package/plugin/agents/copywriter.md +2 -0
- package/plugin/agents/data-engineer.md +255 -0
- package/plugin/agents/database-admin.md +10 -0
- package/plugin/agents/debugger.md +10 -0
- package/plugin/agents/devsecops.md +314 -0
- package/plugin/agents/docs-manager.md +4 -0
- package/plugin/agents/domain-decomposer.md +181 -0
- package/plugin/agents/embedded-systems.md +397 -0
- package/plugin/agents/fullstack-developer.md +12 -0
- package/plugin/agents/game-systems-designer.md +375 -0
- package/plugin/agents/git-manager.md +10 -0
- package/plugin/agents/journal-writer.md +2 -0
- package/plugin/agents/ml-engineer.md +284 -0
- package/plugin/agents/observability-engineer.md +353 -0
- package/plugin/agents/oracle.md +9 -0
- package/plugin/agents/performance-engineer.md +290 -0
- package/plugin/agents/pipeline-architect.md +6 -0
- package/plugin/agents/planner.md +12 -0
- package/plugin/agents/platform-engineer.md +325 -0
- package/plugin/agents/project-manager.md +3 -0
- package/plugin/agents/researcher.md +5 -0
- package/plugin/agents/scientific-computing.md +426 -0
- package/plugin/agents/scout.md +3 -0
- package/plugin/agents/security-auditor.md +7 -0
- package/plugin/agents/sprint-master.md +17 -0
- package/plugin/agents/tester.md +10 -0
- package/plugin/agents/ui-ux-designer.md +12 -0
- package/plugin/agents/vulnerability-scanner.md +6 -0
- package/plugin/commands/data/pipeline.md +47 -0
- package/plugin/commands/data/quality.md +49 -0
- package/plugin/commands/domain/analyze.md +34 -0
- package/plugin/commands/domain/map.md +41 -0
- package/plugin/commands/game/balance.md +56 -0
- package/plugin/commands/game/optimize.md +62 -0
- package/plugin/commands/iot/provision.md +58 -0
- package/plugin/commands/ml/evaluate.md +47 -0
- package/plugin/commands/ml/train.md +48 -0
- package/plugin/commands/perf/benchmark.md +54 -0
- package/plugin/commands/perf/profile.md +49 -0
- package/plugin/commands/platform/blueprint.md +56 -0
- package/plugin/commands/security/audit.md +54 -0
- package/plugin/commands/security/scan.md +55 -0
- package/plugin/commands/sre/dashboard.md +53 -0
- package/plugin/registry.yaml +787 -0
- package/plugin/skills/ai-ml/experiment-tracking/SKILL.md +338 -0
- package/plugin/skills/ai-ml/feature-stores/SKILL.md +340 -0
- package/plugin/skills/ai-ml/llm-ops/SKILL.md +454 -0
- package/plugin/skills/ai-ml/ml-pipelines/SKILL.md +390 -0
- package/plugin/skills/ai-ml/model-monitoring/SKILL.md +398 -0
- package/plugin/skills/ai-ml/model-serving/SKILL.md +386 -0
- package/plugin/skills/event-driven/cqrs-patterns/SKILL.md +348 -0
- package/plugin/skills/event-driven/event-sourcing/SKILL.md +334 -0
- package/plugin/skills/event-driven/kafka-deep/SKILL.md +252 -0
- package/plugin/skills/event-driven/saga-orchestration/SKILL.md +335 -0
- package/plugin/skills/event-driven/schema-registry/SKILL.md +328 -0
- package/plugin/skills/event-driven/stream-processing/SKILL.md +313 -0
- package/plugin/skills/game/game-audio/SKILL.md +446 -0
- package/plugin/skills/game/game-networking/SKILL.md +490 -0
- package/plugin/skills/game/godot-patterns/SKILL.md +413 -0
- package/plugin/skills/game/shader-programming/SKILL.md +492 -0
- package/plugin/skills/game/unity-patterns/SKILL.md +488 -0
- package/plugin/skills/iot/device-provisioning/SKILL.md +405 -0
- package/plugin/skills/iot/edge-computing/SKILL.md +369 -0
- package/plugin/skills/iot/industrial-protocols/SKILL.md +438 -0
- package/plugin/skills/iot/mqtt-deep/SKILL.md +418 -0
- package/plugin/skills/iot/ota-updates/SKILL.md +426 -0
- package/plugin/skills/microservices/api-gateway-patterns/SKILL.md +201 -0
- package/plugin/skills/microservices/circuit-breaker-patterns/SKILL.md +246 -0
- package/plugin/skills/microservices/contract-testing/SKILL.md +284 -0
- package/plugin/skills/microservices/distributed-tracing/SKILL.md +246 -0
- package/plugin/skills/microservices/service-discovery/SKILL.md +304 -0
- package/plugin/skills/microservices/service-mesh/SKILL.md +181 -0
- package/plugin/skills/mobile-advanced/mobile-ci-cd/SKILL.md +407 -0
- package/plugin/skills/mobile-advanced/mobile-security/SKILL.md +403 -0
- package/plugin/skills/mobile-advanced/offline-first/SKILL.md +473 -0
- package/plugin/skills/mobile-advanced/push-notifications/SKILL.md +494 -0
- package/plugin/skills/mobile-advanced/react-native-deep/SKILL.md +374 -0
- package/plugin/skills/simulation/numerical-methods/SKILL.md +434 -0
- package/plugin/skills/simulation/parallel-computing/SKILL.md +382 -0
- package/plugin/skills/simulation/physics-engines/SKILL.md +377 -0
- package/plugin/skills/simulation/validation-verification/SKILL.md +479 -0
- package/plugin/skills/simulation/visualization-scientific/SKILL.md +365 -0
- package/plugin/stdrules/ALIGNMENT_PRINCIPLE.md +240 -0
- package/plugin/workflows/ai-engineering/agent-development.md +3 -3
- package/plugin/workflows/ai-engineering/fine-tuning.md +3 -3
- package/plugin/workflows/ai-engineering/model-evaluation.md +3 -3
- package/plugin/workflows/ai-engineering/prompt-engineering.md +2 -2
- package/plugin/workflows/ai-engineering/rag-development.md +4 -4
- package/plugin/workflows/ai-ml/data-pipeline.md +188 -0
- package/plugin/workflows/ai-ml/experiment-cycle.md +203 -0
- package/plugin/workflows/ai-ml/feature-engineering.md +208 -0
- package/plugin/workflows/ai-ml/model-deployment.md +199 -0
- package/plugin/workflows/ai-ml/monitoring-setup.md +227 -0
- package/plugin/workflows/api/api-design.md +1 -1
- package/plugin/workflows/api/api-testing.md +2 -2
- package/plugin/workflows/content/technical-docs.md +1 -1
- package/plugin/workflows/database/migration.md +1 -1
- package/plugin/workflows/database/optimization.md +1 -1
- package/plugin/workflows/database/schema-design.md +3 -3
- package/plugin/workflows/development/bug-fix.md +3 -3
- package/plugin/workflows/development/code-review.md +2 -1
- package/plugin/workflows/development/feature.md +3 -3
- package/plugin/workflows/development/refactor.md +2 -2
- package/plugin/workflows/event-driven/consumer-groups.md +190 -0
- package/plugin/workflows/event-driven/event-storming.md +172 -0
- package/plugin/workflows/event-driven/replay-testing.md +186 -0
- package/plugin/workflows/event-driven/saga-implementation.md +206 -0
- package/plugin/workflows/event-driven/schema-evolution.md +173 -0
- package/plugin/workflows/fullstack/authentication.md +4 -4
- package/plugin/workflows/fullstack/full-feature.md +4 -4
- package/plugin/workflows/game-dev/content-pipeline.md +218 -0
- package/plugin/workflows/game-dev/platform-submission.md +263 -0
- package/plugin/workflows/game-dev/playtesting.md +237 -0
- package/plugin/workflows/game-dev/prototype-to-production.md +205 -0
- package/plugin/workflows/microservices/contract-first.md +151 -0
- package/plugin/workflows/microservices/distributed-tracing.md +166 -0
- package/plugin/workflows/microservices/domain-decomposition.md +123 -0
- package/plugin/workflows/microservices/integration-testing.md +149 -0
- package/plugin/workflows/microservices/service-mesh-setup.md +153 -0
- package/plugin/workflows/microservices/service-scaffolding.md +151 -0
- package/plugin/workflows/omega/1000x-innovation.md +2 -2
- package/plugin/workflows/omega/100x-architecture.md +2 -2
- package/plugin/workflows/omega/10x-improvement.md +2 -2
- package/plugin/workflows/quality/performance-optimization.md +2 -2
- package/plugin/workflows/research/best-practices.md +1 -1
- package/plugin/workflows/research/technology-research.md +1 -1
- package/plugin/workflows/security/penetration-testing.md +3 -3
- package/plugin/workflows/security/security-audit.md +3 -3
- package/plugin/workflows/sprint/sprint-execution.md +2 -2
- package/plugin/workflows/sprint/sprint-retrospective.md +1 -1
- package/plugin/workflows/sprint/sprint-setup.md +1 -1
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Stream Processing
|
|
2
|
+
|
|
3
|
+
Real-time stream processing with Kafka Streams, Apache Flink, windowing, aggregations, and stateful processing.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Stream processing enables real-time analysis and transformation of continuous data streams.
|
|
8
|
+
|
|
9
|
+
## Core Concepts
|
|
10
|
+
|
|
11
|
+
### Stream vs Table
|
|
12
|
+
- **Stream**: Unbounded sequence of events
|
|
13
|
+
- **Table**: Point-in-time snapshot of state
|
|
14
|
+
- **Duality**: Streams and tables are interchangeable
|
|
15
|
+
|
|
16
|
+
### Processing Semantics
|
|
17
|
+
- **At-most-once**: May lose messages
|
|
18
|
+
- **At-least-once**: May duplicate messages
|
|
19
|
+
- **Exactly-once**: Each message processed once
|
|
20
|
+
|
|
21
|
+
### Time Concepts
|
|
22
|
+
- **Event Time**: When event occurred
|
|
23
|
+
- **Processing Time**: When event is processed
|
|
24
|
+
- **Ingestion Time**: When event entered system
|
|
25
|
+
|
|
26
|
+
## Kafka Streams
|
|
27
|
+
|
|
28
|
+
### Basic Topology
|
|
29
|
+
```java
|
|
30
|
+
StreamsBuilder builder = new StreamsBuilder();
|
|
31
|
+
|
|
32
|
+
// Read from topic
|
|
33
|
+
KStream<String, Order> orders = builder.stream("orders");
|
|
34
|
+
|
|
35
|
+
// Transform
|
|
36
|
+
KStream<String, EnrichedOrder> enrichedOrders = orders
|
|
37
|
+
.mapValues(order -> enrichOrder(order))
|
|
38
|
+
.filter((key, order) -> order.getAmount() > 100);
|
|
39
|
+
|
|
40
|
+
// Write to topic
|
|
41
|
+
enrichedOrders.to("enriched-orders");
|
|
42
|
+
|
|
43
|
+
// Build and start
|
|
44
|
+
KafkaStreams streams = new KafkaStreams(builder.build(), config);
|
|
45
|
+
streams.start();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Stateful Operations
|
|
49
|
+
```java
|
|
50
|
+
// Group by key and count
|
|
51
|
+
KTable<String, Long> orderCounts = orders
|
|
52
|
+
.groupByKey()
|
|
53
|
+
.count();
|
|
54
|
+
|
|
55
|
+
// Group by and aggregate
|
|
56
|
+
KTable<String, OrderStats> orderStats = orders
|
|
57
|
+
.groupBy((key, order) -> order.getCustomerId())
|
|
58
|
+
.aggregate(
|
|
59
|
+
OrderStats::new,
|
|
60
|
+
(customerId, order, stats) -> stats.add(order),
|
|
61
|
+
Materialized.with(Serdes.String(), orderStatsSerde)
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// Join streams
|
|
65
|
+
KStream<String, EnrichedOrder> enriched = orders.join(
|
|
66
|
+
customers,
|
|
67
|
+
(order, customer) -> new EnrichedOrder(order, customer),
|
|
68
|
+
JoinWindows.of(Duration.ofMinutes(5))
|
|
69
|
+
);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Windowing
|
|
73
|
+
```java
|
|
74
|
+
// Tumbling window (fixed, non-overlapping)
|
|
75
|
+
KTable<Windowed<String>, Long> hourlyCount = orders
|
|
76
|
+
.groupByKey()
|
|
77
|
+
.windowedBy(TimeWindows.of(Duration.ofHours(1)))
|
|
78
|
+
.count();
|
|
79
|
+
|
|
80
|
+
// Hopping window (fixed, overlapping)
|
|
81
|
+
KTable<Windowed<String>, Long> slidingCount = orders
|
|
82
|
+
.groupByKey()
|
|
83
|
+
.windowedBy(TimeWindows.of(Duration.ofMinutes(10))
|
|
84
|
+
.advanceBy(Duration.ofMinutes(1)))
|
|
85
|
+
.count();
|
|
86
|
+
|
|
87
|
+
// Session window (activity-based)
|
|
88
|
+
KTable<Windowed<String>, Long> sessionCount = orders
|
|
89
|
+
.groupByKey()
|
|
90
|
+
.windowedBy(SessionWindows.with(Duration.ofMinutes(30)))
|
|
91
|
+
.count();
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Apache Flink
|
|
95
|
+
|
|
96
|
+
### DataStream API
|
|
97
|
+
```java
|
|
98
|
+
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
|
|
99
|
+
|
|
100
|
+
DataStream<Order> orders = env
|
|
101
|
+
.addSource(new FlinkKafkaConsumer<>("orders", new OrderSchema(), props));
|
|
102
|
+
|
|
103
|
+
// Transform
|
|
104
|
+
DataStream<EnrichedOrder> enriched = orders
|
|
105
|
+
.filter(order -> order.getAmount() > 100)
|
|
106
|
+
.map(order -> enrichOrder(order));
|
|
107
|
+
|
|
108
|
+
// Window aggregation
|
|
109
|
+
DataStream<OrderStats> stats = orders
|
|
110
|
+
.keyBy(Order::getCustomerId)
|
|
111
|
+
.window(TumblingEventTimeWindows.of(Time.hours(1)))
|
|
112
|
+
.aggregate(new OrderAggregator());
|
|
113
|
+
|
|
114
|
+
// Sink
|
|
115
|
+
enriched.addSink(new FlinkKafkaProducer<>("enriched-orders", new EnrichedOrderSchema(), props));
|
|
116
|
+
|
|
117
|
+
env.execute("Order Processing");
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Stateful Processing
|
|
121
|
+
```java
|
|
122
|
+
public class OrderProcessor extends KeyedProcessFunction<String, Order, Alert> {
|
|
123
|
+
|
|
124
|
+
private ValueState<CustomerState> state;
|
|
125
|
+
|
|
126
|
+
@Override
|
|
127
|
+
public void open(Configuration parameters) {
|
|
128
|
+
state = getRuntimeContext().getState(
|
|
129
|
+
new ValueStateDescriptor<>("customer-state", CustomerState.class)
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@Override
|
|
134
|
+
public void processElement(Order order, Context ctx, Collector<Alert> out) throws Exception {
|
|
135
|
+
CustomerState current = state.value();
|
|
136
|
+
if (current == null) {
|
|
137
|
+
current = new CustomerState();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
current.addOrder(order);
|
|
141
|
+
|
|
142
|
+
if (current.detectFraud(order)) {
|
|
143
|
+
out.collect(new Alert(order.getCustomerId(), "Potential fraud"));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
state.update(current);
|
|
147
|
+
|
|
148
|
+
// Register timer for state cleanup
|
|
149
|
+
ctx.timerService().registerEventTimeTimer(
|
|
150
|
+
ctx.timestamp() + Duration.ofDays(1).toMillis()
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@Override
|
|
155
|
+
public void onTimer(long timestamp, OnTimerContext ctx, Collector<Alert> out) {
|
|
156
|
+
// Cleanup old state
|
|
157
|
+
state.clear();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Complex Event Processing
|
|
163
|
+
```java
|
|
164
|
+
// Detect pattern: 3 failed logins within 5 minutes
|
|
165
|
+
Pattern<LoginEvent, ?> pattern = Pattern.<LoginEvent>begin("first")
|
|
166
|
+
.where(event -> !event.isSuccess())
|
|
167
|
+
.next("second")
|
|
168
|
+
.where(event -> !event.isSuccess())
|
|
169
|
+
.next("third")
|
|
170
|
+
.where(event -> !event.isSuccess())
|
|
171
|
+
.within(Time.minutes(5));
|
|
172
|
+
|
|
173
|
+
PatternStream<LoginEvent> patternStream = CEP.pattern(loginEvents.keyBy(LoginEvent::getUserId), pattern);
|
|
174
|
+
|
|
175
|
+
DataStream<Alert> alerts = patternStream.select(
|
|
176
|
+
(Map<String, List<LoginEvent>> pattern) -> {
|
|
177
|
+
LoginEvent first = pattern.get("first").get(0);
|
|
178
|
+
return new Alert(first.getUserId(), "Multiple failed logins");
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## ksqlDB
|
|
184
|
+
|
|
185
|
+
### Stream Creation
|
|
186
|
+
```sql
|
|
187
|
+
-- Create stream from topic
|
|
188
|
+
CREATE STREAM orders (
|
|
189
|
+
order_id VARCHAR KEY,
|
|
190
|
+
customer_id VARCHAR,
|
|
191
|
+
amount DOUBLE,
|
|
192
|
+
created_at TIMESTAMP
|
|
193
|
+
) WITH (
|
|
194
|
+
KAFKA_TOPIC = 'orders',
|
|
195
|
+
VALUE_FORMAT = 'JSON',
|
|
196
|
+
TIMESTAMP = 'created_at'
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
-- Create derived stream
|
|
200
|
+
CREATE STREAM high_value_orders AS
|
|
201
|
+
SELECT *
|
|
202
|
+
FROM orders
|
|
203
|
+
WHERE amount > 1000;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Aggregations
|
|
207
|
+
```sql
|
|
208
|
+
-- Materialized view with aggregation
|
|
209
|
+
CREATE TABLE customer_order_totals AS
|
|
210
|
+
SELECT
|
|
211
|
+
customer_id,
|
|
212
|
+
COUNT(*) AS order_count,
|
|
213
|
+
SUM(amount) AS total_amount
|
|
214
|
+
FROM orders
|
|
215
|
+
GROUP BY customer_id
|
|
216
|
+
EMIT CHANGES;
|
|
217
|
+
|
|
218
|
+
-- Windowed aggregation
|
|
219
|
+
CREATE TABLE hourly_order_stats AS
|
|
220
|
+
SELECT
|
|
221
|
+
customer_id,
|
|
222
|
+
WINDOWSTART AS window_start,
|
|
223
|
+
WINDOWEND AS window_end,
|
|
224
|
+
COUNT(*) AS order_count,
|
|
225
|
+
SUM(amount) AS total_amount
|
|
226
|
+
FROM orders
|
|
227
|
+
WINDOW TUMBLING (SIZE 1 HOUR)
|
|
228
|
+
GROUP BY customer_id
|
|
229
|
+
EMIT CHANGES;
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Joins
|
|
233
|
+
```sql
|
|
234
|
+
-- Stream-Table join
|
|
235
|
+
CREATE STREAM enriched_orders AS
|
|
236
|
+
SELECT
|
|
237
|
+
o.order_id,
|
|
238
|
+
o.customer_id,
|
|
239
|
+
c.name AS customer_name,
|
|
240
|
+
o.amount
|
|
241
|
+
FROM orders o
|
|
242
|
+
JOIN customers c ON o.customer_id = c.customer_id;
|
|
243
|
+
|
|
244
|
+
-- Stream-Stream join
|
|
245
|
+
CREATE STREAM order_shipments AS
|
|
246
|
+
SELECT
|
|
247
|
+
o.order_id,
|
|
248
|
+
o.customer_id,
|
|
249
|
+
s.tracking_number
|
|
250
|
+
FROM orders o
|
|
251
|
+
INNER JOIN shipments s
|
|
252
|
+
WITHIN 7 DAYS
|
|
253
|
+
ON o.order_id = s.order_id;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Best Practices
|
|
257
|
+
|
|
258
|
+
1. **Handle Late Data**: Configure grace periods
|
|
259
|
+
2. **State Management**: Size state stores appropriately
|
|
260
|
+
3. **Checkpointing**: Enable for exactly-once
|
|
261
|
+
4. **Monitoring**: Track lag and processing time
|
|
262
|
+
5. **Testing**: Unit test topologies
|
|
263
|
+
|
|
264
|
+
## Windowing Strategies
|
|
265
|
+
|
|
266
|
+
### Tumbling Windows
|
|
267
|
+
```
|
|
268
|
+
|-------|-------|-------|
|
|
269
|
+
1hr 1hr 1hr
|
|
270
|
+
Non-overlapping, fixed size
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Hopping Windows
|
|
274
|
+
```
|
|
275
|
+
|-------|
|
|
276
|
+
|-------|
|
|
277
|
+
|-------|
|
|
278
|
+
Overlapping, fixed size
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Session Windows
|
|
282
|
+
```
|
|
283
|
+
|---| |---------| |--|
|
|
284
|
+
Activity-based, variable size
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Sliding Windows
|
|
288
|
+
```
|
|
289
|
+
Continuous, based on time range before event
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Anti-Patterns
|
|
293
|
+
|
|
294
|
+
- Large state without TTL
|
|
295
|
+
- Ignoring late arrivals
|
|
296
|
+
- Not handling out-of-order events
|
|
297
|
+
- Insufficient checkpointing
|
|
298
|
+
- Not monitoring consumer lag
|
|
299
|
+
|
|
300
|
+
## When to Use
|
|
301
|
+
|
|
302
|
+
- Real-time analytics
|
|
303
|
+
- Event-driven architectures
|
|
304
|
+
- Continuous ETL
|
|
305
|
+
- Fraud detection
|
|
306
|
+
- IoT data processing
|
|
307
|
+
|
|
308
|
+
## When NOT to Use
|
|
309
|
+
|
|
310
|
+
- Simple message passing
|
|
311
|
+
- Batch processing sufficient
|
|
312
|
+
- Very low latency requirements
|
|
313
|
+
- Small data volumes
|