@auto-engineer/job-graph-processor 1.26.0 → 1.27.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +33 -0
- package/README.md +9 -9
- package/dist/src/commands/process-job-graph.js +4 -4
- package/dist/src/commands/process-job-graph.js.map +1 -1
- package/dist/src/commands/process-job-graph.specs.js +6 -6
- package/dist/src/commands/process-job-graph.specs.js.map +1 -1
- package/dist/src/graph-processor.js +5 -5
- package/dist/src/graph-processor.js.map +1 -1
- package/dist/src/graph-processor.specs.js +14 -14
- package/dist/src/graph-processor.specs.js.map +1 -1
- package/dist/src/process-graph.js +2 -2
- package/dist/src/process-graph.js.map +1 -1
- package/dist/src/process-graph.specs.js +3 -3
- package/dist/src/process-graph.specs.js.map +1 -1
- package/dist/src/process-job-graph.e2e.specs.js +5 -5
- package/dist/src/process-job-graph.e2e.specs.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/commands/process-job-graph.specs.ts +6 -6
- package/src/commands/process-job-graph.ts +4 -4
- package/src/graph-processor.specs.ts +14 -14
- package/src/graph-processor.ts +5 -5
- package/src/process-graph.specs.ts +3 -3
- package/src/process-graph.ts +2 -2
- package/src/process-job-graph.e2e.specs.ts +5 -5
- package/ketchup-plan.md +0 -31
package/src/graph-processor.ts
CHANGED
|
@@ -39,16 +39,16 @@ export function createGraphProcessor(messageBus: MessageBus, options?: { dispatc
|
|
|
39
39
|
const { graphId, jobs, failurePolicy } = command.data;
|
|
40
40
|
|
|
41
41
|
if (graphs.has(graphId)) {
|
|
42
|
-
return { type: '
|
|
42
|
+
return { type: 'GraphFailed', data: { graphId, reason: `Graph ${graphId} already submitted` } };
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (!Array.isArray(jobs)) {
|
|
46
|
-
return { type: '
|
|
46
|
+
return { type: 'GraphFailed', data: { graphId, reason: 'jobs is required and must be an array' } };
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const validation = validateGraph(jobs);
|
|
50
50
|
if (!validation.valid) {
|
|
51
|
-
return { type: '
|
|
51
|
+
return { type: 'GraphFailed', data: { graphId, reason: validation.error } };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
let state = evolve(initialState(), {
|
|
@@ -81,7 +81,7 @@ export function createGraphProcessor(messageBus: MessageBus, options?: { dispatc
|
|
|
81
81
|
dispatch({ type: d.target, data: d.payload, correlationId: d.correlationId }).catch(() => {});
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
return { type: '
|
|
84
|
+
return { type: 'GraphDispatched', data: { graphId, dispatchedJobs: dispatched } };
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function onJobEvent(graphId: string, event: Event): void {
|
|
@@ -113,7 +113,7 @@ export function createGraphProcessor(messageBus: MessageBus, options?: { dispatc
|
|
|
113
113
|
|
|
114
114
|
if (isGraphComplete(state)) {
|
|
115
115
|
graphs.delete(graphId);
|
|
116
|
-
messageBus.publishEvent({ type: '
|
|
116
|
+
messageBus.publishEvent({ type: 'GraphProcessed', data: { graphId } });
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
|
|
|
2
2
|
import { handleProcessGraph } from './process-graph';
|
|
3
3
|
|
|
4
4
|
describe('handleProcessGraph', () => {
|
|
5
|
-
it('returns
|
|
5
|
+
it('returns GraphFailed when graph validation fails', async () => {
|
|
6
6
|
const result = await handleProcessGraph({
|
|
7
7
|
type: 'ProcessGraph',
|
|
8
8
|
data: {
|
|
@@ -13,7 +13,7 @@ describe('handleProcessGraph', () => {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
expect(result).toEqual({
|
|
16
|
-
type: '
|
|
16
|
+
type: 'GraphFailed',
|
|
17
17
|
data: {
|
|
18
18
|
graphId: 'g1',
|
|
19
19
|
reason: 'Graph must contain at least one job',
|
|
@@ -36,7 +36,7 @@ describe('handleProcessGraph', () => {
|
|
|
36
36
|
|
|
37
37
|
expect(result).toEqual([
|
|
38
38
|
{
|
|
39
|
-
type: '
|
|
39
|
+
type: 'JobDispatched',
|
|
40
40
|
data: { graphId: 'g1', jobId: 'a', target: 'build', payload: { src: './app' } },
|
|
41
41
|
},
|
|
42
42
|
]);
|
package/src/process-graph.ts
CHANGED
|
@@ -19,7 +19,7 @@ export async function handleProcessGraph(command: ProcessGraphCommand): Promise<
|
|
|
19
19
|
const validation = validateGraph(jobs);
|
|
20
20
|
if (!validation.valid) {
|
|
21
21
|
return {
|
|
22
|
-
type: '
|
|
22
|
+
type: 'GraphFailed',
|
|
23
23
|
data: { graphId, reason: validation.error },
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -36,7 +36,7 @@ export async function handleProcessGraph(command: ProcessGraphCommand): Promise<
|
|
|
36
36
|
|
|
37
37
|
const ready = getReadyJobs(state);
|
|
38
38
|
return ready.map((jobId) => ({
|
|
39
|
-
type: '
|
|
39
|
+
type: 'JobDispatched',
|
|
40
40
|
data: { graphId, jobId, target: jobById[jobId].target, payload: jobById[jobId].payload },
|
|
41
41
|
}));
|
|
42
42
|
}
|
|
@@ -48,7 +48,7 @@ describe('ProcessJobGraph E2E', () => {
|
|
|
48
48
|
await server.stop();
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
it('command dispatch returns ack and produces
|
|
51
|
+
it('command dispatch returns ack and produces GraphDispatched event', async () => {
|
|
52
52
|
const server = new PipelineServer({ port: 0 });
|
|
53
53
|
server.registerCommandHandlers(COMMANDS);
|
|
54
54
|
await server.start();
|
|
@@ -73,18 +73,18 @@ describe('ProcessJobGraph E2E', () => {
|
|
|
73
73
|
const messages = await fetchJson<StoredMessage[]>(`http://localhost:${server.port}/messages`);
|
|
74
74
|
const eventTypes = messages.filter((m) => m.messageType === 'event').map((m) => m.message.type);
|
|
75
75
|
|
|
76
|
-
expect(eventTypes).toContain('
|
|
76
|
+
expect(eventTypes).toContain('GraphDispatched');
|
|
77
77
|
|
|
78
78
|
await server.stop();
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
it('full lifecycle produces
|
|
81
|
+
it('full lifecycle produces GraphProcessed via correlation', async () => {
|
|
82
82
|
const server = new PipelineServer({ port: 0 });
|
|
83
83
|
server.registerCommandHandlers(COMMANDS);
|
|
84
84
|
await server.start();
|
|
85
85
|
|
|
86
86
|
const completed: Array<{ type: string; data: Record<string, unknown> }> = [];
|
|
87
|
-
server.getMessageBus().subscribeToEvent('
|
|
87
|
+
server.getMessageBus().subscribeToEvent('GraphProcessed', {
|
|
88
88
|
name: 'e2e-completion-tracker',
|
|
89
89
|
handle: (event) => {
|
|
90
90
|
completed.push(event);
|
|
@@ -114,7 +114,7 @@ describe('ProcessJobGraph E2E', () => {
|
|
|
114
114
|
|
|
115
115
|
await new Promise((r) => setTimeout(r, 100));
|
|
116
116
|
|
|
117
|
-
expect(completed).toEqual([{ type: '
|
|
117
|
+
expect(completed).toEqual([{ type: 'GraphProcessed', data: { graphId: 'e2e-g2' } }]);
|
|
118
118
|
|
|
119
119
|
await server.stop();
|
|
120
120
|
});
|
package/ketchup-plan.md
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Ketchup Plan: ProcessJobGraph Command Handler + E2E Tests
|
|
2
|
-
|
|
3
|
-
## TODO
|
|
4
|
-
|
|
5
|
-
(empty)
|
|
6
|
-
|
|
7
|
-
## DONE
|
|
8
|
-
|
|
9
|
-
### Bottle: Defensive input validation
|
|
10
|
-
|
|
11
|
-
- [x] Burst 1: guard submit against missing jobs array (ecd82695)
|
|
12
|
-
|
|
13
|
-
### Bottle: Dispatch target commands via dispatch callback
|
|
14
|
-
|
|
15
|
-
- [x] Burst 1: submit sends target commands for initial ready jobs (caa7abf9)
|
|
16
|
-
- [x] Burst 2: onJobEvent sends target commands for newly ready dependent jobs (0b4be016)
|
|
17
|
-
- [x] Burst 3: accept dispatch callback instead of using messageBus.sendCommand (2505b01e)
|
|
18
|
-
- [x] Burst 4: PipelineContext.sendCommand accepts optional correlationId override (0d858127)
|
|
19
|
-
- [x] Burst 5: process-job-graph handler wires ctx.sendCommand as dispatch (41f044c5)
|
|
20
|
-
|
|
21
|
-
### Bottle: Pipeline Command Handler + E2E Tests
|
|
22
|
-
|
|
23
|
-
- [x] Burst 1: Command handler + test for graph.dispatching (4e876184)
|
|
24
|
-
- [x] Burst 2: Test handler returns graph.failed when messageBus missing (4e876184)
|
|
25
|
-
- [x] Burst 3: Test handler returns graph.failed for invalid graph (4e876184)
|
|
26
|
-
- [x] Burst 4: Export COMMANDS array (772f16a4)
|
|
27
|
-
- [x] Burst 5: E2E — registry shows ProcessJobGraph (8da16e8a)
|
|
28
|
-
- [x] Burst 6: E2E — command callable, produces graph.dispatching (8da16e8a)
|
|
29
|
-
- [x] Burst 7: E2E — full lifecycle, graph.completed via correlation (8da16e8a)
|
|
30
|
-
- [x] Burst 8: Wire plugin into typical example (30ab6969)
|
|
31
|
-
- [x] Burst 9: Update README (c2a955a6)
|