@a5c-ai/krate 5.0.1-staging.660d2b90f → 5.0.1-staging.69cb593ea
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/Dockerfile +31 -29
- package/bin/krate-demo.mjs +0 -0
- package/bin/krate-server.mjs +0 -0
- package/dist/krate-controller-ui.json +808 -10
- package/dist/krate-lifecycle.json +1 -1
- package/dist/krate-runtime-snapshot.json +223 -53
- package/dist/krate-summary.json +40 -3
- package/docs/agents/gaps-agent-mux-to-krate-crds.md +298 -0
- package/docs/architecture-v2.md +431 -0
- package/docs/openapi.yaml +1275 -0
- package/docs/requirements-v2.md +238 -0
- package/docs/sdk-api-reference.md +782 -0
- package/docs/system-spec-v2.md +352 -0
- package/docs/todos.md +4 -0
- package/docs/web-console-spec.md +433 -0
- package/package.json +1 -1
- package/scripts/validate-ui.mjs +305 -207
- package/src/agent-adapter-controller.js +169 -0
- package/src/agent-approval-controller.js +47 -0
- package/src/agent-dispatch-controller.js +130 -7
- package/src/agent-gateway-config-controller.js +147 -0
- package/src/agent-memory-controller.js +357 -0
- package/src/agent-memory-import.js +327 -0
- package/src/agent-memory-query.js +292 -0
- package/src/agent-memory-repository-source-controller.js +255 -0
- package/src/agent-mux-client.js +1 -1
- package/src/agent-permission-review.js +102 -14
- package/src/agent-project-controller.js +117 -0
- package/src/agent-provider-config-controller.js +150 -0
- package/src/agent-secret-config-grant-controller.js +282 -0
- package/src/agent-session-transcript-controller.js +189 -0
- package/src/agent-stack-controller.js +52 -1
- package/src/agent-subagent-controller.js +160 -0
- package/src/agent-transport-binding-controller.js +121 -0
- package/src/agent-trigger-controller.js +273 -0
- package/src/agent-workspace-controller.js +702 -0
- package/src/agent-writeback-controller.js +302 -0
- package/src/api-controller.js +338 -3
- package/src/async-controller.js +207 -0
- package/src/audit-controller.js +191 -0
- package/src/auth.js +48 -6
- package/src/controller-client.js +112 -38
- package/src/controller-ui.js +96 -16
- package/src/data-plane.js +3 -2
- package/src/event-bus.js +61 -0
- package/src/external/conflict-controller.js +225 -0
- package/src/external/github/auth.js +96 -0
- package/src/external/github/cicd.js +180 -0
- package/src/external/github/git-forge.js +240 -0
- package/src/external/github/index.js +144 -0
- package/src/external/github/issue-tracking.js +163 -0
- package/src/external/provider-adapter.js +161 -0
- package/src/external/provider-resource-factory.js +161 -0
- package/src/external/sync-controller.js +235 -0
- package/src/external/webhook-controller.js +144 -0
- package/src/external/write-controller.js +283 -0
- package/src/gitea-backend.js +36 -0
- package/src/gitea-service.js +173 -0
- package/src/http-server.js +226 -0
- package/src/index.js +27 -0
- package/src/kubernetes-controller-async.js +531 -0
- package/src/kubernetes-controller.js +156 -84
- package/src/notification-controller.js +178 -0
- package/src/org-scoping.js +5 -0
- package/src/resource-model.js +26 -8
- package/src/runner-controller.js +272 -0
- package/src/snapshot-cache.js +157 -0
- package/tests/agent-adapter-controller.test.js +361 -0
- package/tests/agent-dispatch-controller.test.js +139 -0
- package/tests/agent-gateway-config-controller.test.js +386 -0
- package/tests/agent-memory-controller.test.js +308 -0
- package/tests/agent-memory-import-snapshot.test.js +477 -0
- package/tests/agent-memory-query.test.js +404 -0
- package/tests/agent-memory-repository-source.test.js +514 -0
- package/tests/agent-permission-review-v2.test.js +317 -0
- package/tests/agent-project-controller.test.js +302 -0
- package/tests/agent-provider-config-controller.test.js +376 -0
- package/tests/agent-resources.test.js +35 -19
- package/tests/agent-secret-config-grant.test.js +231 -0
- package/tests/agent-session-transcript-controller.test.js +499 -0
- package/tests/agent-subagent-controller.test.js +201 -0
- package/tests/agent-transport-binding-controller.test.js +294 -0
- package/tests/agent-trigger-routes.test.js +190 -0
- package/tests/agent-trigger-sources.test.js +245 -0
- package/tests/agent-workspace-controller.test.js +181 -0
- package/tests/agent-writeback.test.js +292 -0
- package/tests/approval-persistence.test.js +171 -0
- package/tests/async-controller.test.js +252 -0
- package/tests/audit-controller.test.js +227 -0
- package/tests/codespace-controller.test.js +318 -0
- package/tests/controller-client.test.js +133 -0
- package/tests/deployment.test.js +43 -29
- package/tests/e2e/lifecycle.test.js +5 -2
- package/tests/event-bus-integration.test.js +190 -0
- package/tests/external-github-forge.test.js +560 -0
- package/tests/external-github-issues-cicd.test.js +520 -0
- package/tests/external-integration.test.js +470 -0
- package/tests/external-persistence.test.js +340 -0
- package/tests/external-provider-adapter.test.js +365 -0
- package/tests/external-resource-model.test.js +215 -0
- package/tests/external-webhook-sync.test.js +287 -0
- package/tests/external-write-conflict.test.js +353 -0
- package/tests/gitea-service.test.js +253 -0
- package/tests/health-check-real.test.js +165 -0
- package/tests/integration/full-flow.test.js +266 -0
- package/tests/krate.test.js +58 -6
- package/tests/memory-search-wiring.test.js +270 -0
- package/tests/notification-controller.test.js +196 -0
- package/tests/notification-integration.test.js +179 -0
- package/tests/org-scoping.test.js +687 -0
- package/tests/runner-controller.test.js +327 -0
- package/tests/runner-integration.test.js +231 -0
- package/tests/session-cookie-hmac.test.js +151 -0
- package/tests/snapshot-performance.test.js +315 -0
- package/tests/sse-events.test.js +107 -0
- package/tests/webhook-trigger.test.js +198 -0
- package/tests/workspace-volumes.test.js +312 -0
- package/tests/writeback-persistence.test.js +207 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification controller integration tests
|
|
3
|
+
*
|
|
4
|
+
* Exercises end-to-end notification workflows: creating from dispatch/approval
|
|
5
|
+
* events, org filtering, read-state transitions, and unread counts.
|
|
6
|
+
*/
|
|
7
|
+
import assert from 'node:assert/strict';
|
|
8
|
+
import test from 'node:test';
|
|
9
|
+
import { createNotificationController } from '../src/notification-controller.js';
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// createNotification from dispatch run completed event
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
test('createNotification from dispatch run completed event produces run-complete notification', () => {
|
|
16
|
+
const ctrl = createNotificationController();
|
|
17
|
+
const notif = ctrl.createNotification({
|
|
18
|
+
type: 'AgentDispatchRun',
|
|
19
|
+
status: 'completed',
|
|
20
|
+
name: 'deploy-run-001',
|
|
21
|
+
org: 'acme',
|
|
22
|
+
});
|
|
23
|
+
assert.equal(notif.type, 'run-complete');
|
|
24
|
+
assert.equal(notif.severity, 'info');
|
|
25
|
+
assert.equal(notif.org, 'acme');
|
|
26
|
+
assert.match(notif.title, /completed/i);
|
|
27
|
+
assert.equal(notif.read, false);
|
|
28
|
+
assert.ok(notif.id, 'notification must have an id');
|
|
29
|
+
assert.ok(notif.createdAt, 'notification must have a createdAt timestamp');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('createNotification from dispatch run failed event produces run-complete with error severity', () => {
|
|
33
|
+
const ctrl = createNotificationController();
|
|
34
|
+
const notif = ctrl.createNotification({
|
|
35
|
+
type: 'AgentDispatchRun',
|
|
36
|
+
status: 'failed',
|
|
37
|
+
name: 'deploy-run-002',
|
|
38
|
+
org: 'acme',
|
|
39
|
+
});
|
|
40
|
+
assert.equal(notif.type, 'run-complete');
|
|
41
|
+
assert.equal(notif.severity, 'error');
|
|
42
|
+
assert.match(notif.title, /failed/i);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// createNotification from approval pending event
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
test('createNotification from approval pending event produces approval-needed notification', () => {
|
|
50
|
+
const ctrl = createNotificationController();
|
|
51
|
+
const notif = ctrl.createNotification({
|
|
52
|
+
type: 'AgentApproval',
|
|
53
|
+
status: 'pending',
|
|
54
|
+
action: 'shell-exec',
|
|
55
|
+
org: 'acme',
|
|
56
|
+
});
|
|
57
|
+
assert.equal(notif.type, 'approval-needed');
|
|
58
|
+
assert.equal(notif.severity, 'warning');
|
|
59
|
+
assert.match(notif.title, /approval/i);
|
|
60
|
+
assert.match(notif.title, /shell-exec/i);
|
|
61
|
+
assert.equal(notif.org, 'acme');
|
|
62
|
+
assert.equal(notif.read, false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('createNotification from approval event stores notification in the controller registry', () => {
|
|
66
|
+
const ctrl = createNotificationController();
|
|
67
|
+
const notif = ctrl.createNotification({
|
|
68
|
+
type: 'AgentApproval',
|
|
69
|
+
status: 'pending',
|
|
70
|
+
action: 'file-write',
|
|
71
|
+
org: 'beta-org',
|
|
72
|
+
});
|
|
73
|
+
const listed = ctrl.listNotifications('beta-org');
|
|
74
|
+
assert.equal(listed.length, 1);
|
|
75
|
+
assert.equal(listed[0].id, notif.id);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// listNotifications filters by org
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
test('listNotifications filters by org and excludes notifications from other orgs', () => {
|
|
83
|
+
const ctrl = createNotificationController();
|
|
84
|
+
|
|
85
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-a1', org: 'org-alpha' });
|
|
86
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-a2', org: 'org-alpha' });
|
|
87
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-b1', org: 'org-beta' });
|
|
88
|
+
ctrl.createNotification({ type: 'AgentApproval', status: 'pending', action: 'tool-use', org: 'org-beta' });
|
|
89
|
+
|
|
90
|
+
const alpha = ctrl.listNotifications('org-alpha');
|
|
91
|
+
const beta = ctrl.listNotifications('org-beta');
|
|
92
|
+
|
|
93
|
+
assert.equal(alpha.length, 2, 'org-alpha should have 2 notifications');
|
|
94
|
+
assert.equal(beta.length, 2, 'org-beta should have 2 notifications');
|
|
95
|
+
assert.ok(alpha.every((n) => n.org === 'org-alpha'), 'all alpha notifications have correct org');
|
|
96
|
+
assert.ok(beta.every((n) => n.org === 'org-beta'), 'all beta notifications have correct org');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('listNotifications returns empty array for org with no notifications', () => {
|
|
100
|
+
const ctrl = createNotificationController();
|
|
101
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-1', org: 'org-a' });
|
|
102
|
+
const result = ctrl.listNotifications('org-with-no-data');
|
|
103
|
+
assert.deepEqual(result, []);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
// getUnreadCount after marking as read
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
test('getUnreadCount decrements after marking individual notification as read', () => {
|
|
111
|
+
const ctrl = createNotificationController();
|
|
112
|
+
const n1 = ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-1', org: 'org-a' });
|
|
113
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-2', org: 'org-a' });
|
|
114
|
+
ctrl.createNotification({ type: 'AgentApproval', status: 'pending', action: 'tool', org: 'org-a' });
|
|
115
|
+
|
|
116
|
+
assert.equal(ctrl.getUnreadCount('org-a'), 3);
|
|
117
|
+
|
|
118
|
+
ctrl.markAsRead(n1.id);
|
|
119
|
+
assert.equal(ctrl.getUnreadCount('org-a'), 2);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('getUnreadCount reaches zero after markAllAsRead', () => {
|
|
123
|
+
const ctrl = createNotificationController();
|
|
124
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-1', org: 'org-a' });
|
|
125
|
+
ctrl.createNotification({ type: 'AgentApproval', status: 'pending', action: 'tool', org: 'org-a' });
|
|
126
|
+
ctrl.createNotification({ type: 'ExternalSyncConflict', resourceRef: 'my-repo', org: 'org-a' });
|
|
127
|
+
|
|
128
|
+
assert.equal(ctrl.getUnreadCount('org-a'), 3);
|
|
129
|
+
ctrl.markAllAsRead('org-a');
|
|
130
|
+
assert.equal(ctrl.getUnreadCount('org-a'), 0);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('getUnreadCount is isolated per org', () => {
|
|
134
|
+
const ctrl = createNotificationController();
|
|
135
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-1', org: 'org-a' });
|
|
136
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-2', org: 'org-b' });
|
|
137
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-3', org: 'org-b' });
|
|
138
|
+
|
|
139
|
+
ctrl.markAllAsRead('org-a');
|
|
140
|
+
|
|
141
|
+
assert.equal(ctrl.getUnreadCount('org-a'), 0);
|
|
142
|
+
assert.equal(ctrl.getUnreadCount('org-b'), 2, 'org-b unread count should be unaffected by org-a markAllAsRead');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('listNotifications with unreadOnly reflects mark-as-read state', () => {
|
|
146
|
+
const ctrl = createNotificationController();
|
|
147
|
+
const n1 = ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'r1', org: 'org-a' });
|
|
148
|
+
ctrl.createNotification({ type: 'AgentApproval', status: 'pending', action: 'tool', org: 'org-a' });
|
|
149
|
+
|
|
150
|
+
ctrl.markAsRead(n1.id);
|
|
151
|
+
|
|
152
|
+
const unread = ctrl.listNotifications('org-a', { unreadOnly: true });
|
|
153
|
+
assert.equal(unread.length, 1, 'only one unread notification should remain');
|
|
154
|
+
assert.equal(unread[0].read, false);
|
|
155
|
+
assert.notEqual(unread[0].id, n1.id, 'the read notification should not appear in unread list');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
// Multiple notification types across one org
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
|
|
162
|
+
test('org receives notifications of multiple types in one controller instance', () => {
|
|
163
|
+
const ctrl = createNotificationController();
|
|
164
|
+
const org = 'mixed-org';
|
|
165
|
+
|
|
166
|
+
ctrl.createNotification({ type: 'AgentDispatchRun', status: 'completed', name: 'run-x', org });
|
|
167
|
+
ctrl.createNotification({ type: 'AgentApproval', status: 'pending', action: 'file-delete', org });
|
|
168
|
+
ctrl.createNotification({ type: 'ExternalSyncConflict', resourceRef: 'repo-y', org });
|
|
169
|
+
ctrl.createNotification({ type: 'KrateWorkspace', claimed: true, name: 'ws-z', claimedBy: 'run-x', org });
|
|
170
|
+
|
|
171
|
+
const all = ctrl.listNotifications(org);
|
|
172
|
+
assert.equal(all.length, 4);
|
|
173
|
+
|
|
174
|
+
const types = all.map((n) => n.type);
|
|
175
|
+
assert.ok(types.includes('run-complete'));
|
|
176
|
+
assert.ok(types.includes('approval-needed'));
|
|
177
|
+
assert.ok(types.includes('conflict-detected'));
|
|
178
|
+
assert.ok(types.includes('workspace-ready'));
|
|
179
|
+
});
|