@a5c-ai/krate 5.0.1-staging.f672fe79b
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 +29 -0
- package/README.md +183 -0
- package/bin/krate-demo.mjs +23 -0
- package/bin/krate-server.mjs +14 -0
- package/dist/krate-controller-ui.json +2407 -0
- package/dist/krate-lifecycle.json +201 -0
- package/dist/krate-runtime-snapshot.json +2955 -0
- package/dist/krate-summary.json +687 -0
- package/docs/README.md +61 -0
- package/docs/agents/README.md +83 -0
- package/docs/agents/acceptance-test-matrix.md +193 -0
- package/docs/agents/agent-mux-adapter-contract.md +167 -0
- package/docs/agents/agent-mux-source-map.md +310 -0
- package/docs/agents/agent-run-memory-import-spec.md +256 -0
- package/docs/agents/agent-stack-management-spec.md +421 -0
- package/docs/agents/api-contract-spec.md +309 -0
- package/docs/agents/artifacts-writeback-spec.md +145 -0
- package/docs/agents/chart-packaging-spec.md +128 -0
- package/docs/agents/ci-orchestration-spec.md +140 -0
- package/docs/agents/context-assembly-spec.md +219 -0
- package/docs/agents/controller-reconciliation-spec.md +255 -0
- package/docs/agents/crd-schema-spec.md +315 -0
- package/docs/agents/decision-log-open-questions.md +169 -0
- package/docs/agents/developer-implementation-checklist.md +329 -0
- package/docs/agents/dispatching-design.md +262 -0
- package/docs/agents/glossary.md +66 -0
- package/docs/agents/implementation-blueprint.md +324 -0
- package/docs/agents/implementation-rollout-slices.md +251 -0
- package/docs/agents/memory-context-integration-spec.md +194 -0
- package/docs/agents/memory-ontology-schema-spec.md +253 -0
- package/docs/agents/memory-operations-runbook.md +121 -0
- package/docs/agents/mvp-vertical-slice-spec.md +146 -0
- package/docs/agents/observability-audit-spec.md +265 -0
- package/docs/agents/operator-runbook.md +174 -0
- package/docs/agents/org-memory-api-payload-examples.md +333 -0
- package/docs/agents/org-memory-controller-sequence-spec.md +181 -0
- package/docs/agents/org-memory-e2e-fixture-plan.md +161 -0
- package/docs/agents/org-memory-ui-implementation-map.md +114 -0
- package/docs/agents/org-memory-vertical-slice-spec.md +168 -0
- package/docs/agents/org-resource-model-delta-spec.md +111 -0
- package/docs/agents/org-route-resource-model-spec.md +183 -0
- package/docs/agents/org-scoping-namespace-spec.md +114 -0
- package/docs/agents/rbac-secrets-management-spec.md +406 -0
- package/docs/agents/repository-page-integration-spec.md +255 -0
- package/docs/agents/resource-contract-examples.md +808 -0
- package/docs/agents/resource-relationship-map.md +190 -0
- package/docs/agents/security-threat-model.md +188 -0
- package/docs/agents/shared-memory-company-brain-spec.md +358 -0
- package/docs/agents/storage-migration-spec.md +168 -0
- package/docs/agents/subagent-orchestration-spec.md +152 -0
- package/docs/agents/system-overview.md +88 -0
- package/docs/agents/tools-mcp-skills-spec.md +189 -0
- package/docs/agents/traceability-matrix.md +79 -0
- package/docs/agents/ui-flow-spec.md +211 -0
- package/docs/agents/ui-ux-system-spec.md +426 -0
- package/docs/agents/workspace-lifecycle-spec.md +166 -0
- package/docs/architecture-spec.md +78 -0
- package/docs/components/control-plane.md +78 -0
- package/docs/components/data-plane.md +69 -0
- package/docs/components/hooks-events.md +67 -0
- package/docs/components/identity-rbac-policy.md +73 -0
- package/docs/components/kubevela-oam.md +70 -0
- package/docs/components/operations-publishing.md +81 -0
- package/docs/components/runners-ci.md +66 -0
- package/docs/components/web-ui.md +94 -0
- package/docs/external/README.md +47 -0
- package/docs/external/bidirectional-sync-design.md +134 -0
- package/docs/external/cicd-interface.md +64 -0
- package/docs/external/external-backend-controllers.md +170 -0
- package/docs/external/external-backend-crds.md +234 -0
- package/docs/external/external-backend-ui-spec.md +151 -0
- package/docs/external/external-backend-ux-flows.md +115 -0
- package/docs/external/external-object-mapping.md +125 -0
- package/docs/external/git-forge-interface.md +68 -0
- package/docs/external/github-integration-design.md +151 -0
- package/docs/external/issue-tracking-interface.md +66 -0
- package/docs/external/provider-capability-manifests.md +204 -0
- package/docs/external/provider-catalog.md +139 -0
- package/docs/external/provider-rollout-testing.md +78 -0
- package/docs/external/research-results.md +48 -0
- package/docs/external/security-auth-permissions.md +81 -0
- package/docs/external/sync-state-machines.md +108 -0
- package/docs/external/unified-external-backend-model.md +107 -0
- package/docs/external/user-facing-changes.md +67 -0
- package/docs/gaps.md +161 -0
- package/docs/install.md +94 -0
- package/docs/krate-design.md +334 -0
- package/docs/local-minikube.md +55 -0
- package/docs/ontology/README.md +32 -0
- package/docs/ontology/bounded-contexts.md +29 -0
- package/docs/ontology/events-and-hooks.md +32 -0
- package/docs/ontology/oam-kubevela.md +32 -0
- package/docs/ontology/operations-and-release.md +25 -0
- package/docs/ontology/personas-and-actors.md +32 -0
- package/docs/ontology/policies-and-invariants.md +33 -0
- package/docs/ontology/problem-space.md +30 -0
- package/docs/ontology/resource-contracts.md +40 -0
- package/docs/ontology/resource-taxonomy.md +42 -0
- package/docs/ontology/runners-and-ci.md +29 -0
- package/docs/ontology/solution-space.md +24 -0
- package/docs/ontology/storage-and-data-boundaries.md +29 -0
- package/docs/ontology/validation-matrix.md +24 -0
- package/docs/ontology/web-ui-excellent-flows.md +32 -0
- package/docs/ontology/workflows.md +39 -0
- package/docs/ontology/world.md +35 -0
- package/docs/product-requirements.md +62 -0
- package/docs/roadmap-mvp.md +87 -0
- package/docs/system-requirements.md +90 -0
- package/docs/tests/README.md +53 -0
- package/docs/tests/agent-qa-plan.md +63 -0
- package/docs/tests/browser-ui-tests.md +62 -0
- package/docs/tests/ci-quality-gates.md +48 -0
- package/docs/tests/coverage-model.md +64 -0
- package/docs/tests/e2e-scenario-tests.md +53 -0
- package/docs/tests/fixtures-test-data.md +63 -0
- package/docs/tests/observability-reliability-tests.md +54 -0
- package/docs/tests/product-test-matrix.md +145 -0
- package/docs/tests/qa-adoption-roadmap.md +130 -0
- package/docs/tests/qa-automation-plan.md +101 -0
- package/docs/tests/security-compliance-tests.md +57 -0
- package/docs/tests/test-framework-tools.md +88 -0
- package/docs/tests/test-suite-layout.md +121 -0
- package/docs/tests/unit-integration-tests.md +48 -0
- package/docs/todo-kyverno +714 -0
- package/docs/user-stories.md +78 -0
- package/examples/minikube-demo.yaml +190 -0
- package/examples/oam-application.yaml +23 -0
- package/examples/policy-kyverno-pr-title.yaml +18 -0
- package/package.json +63 -0
- package/scripts/build.mjs +29 -0
- package/scripts/setup-minikube.mjs +65 -0
- package/scripts/smoke.mjs +37 -0
- package/scripts/validate-doc-coverage.mjs +152 -0
- package/scripts/validate-package.mjs +93 -0
- package/scripts/validate-ui.mjs +207 -0
- package/src/agent-approval-controller.js +123 -0
- package/src/agent-context-bundles.js +242 -0
- package/src/agent-dispatch-controller.js +86 -0
- package/src/agent-mux-client.js +280 -0
- package/src/agent-permission-review.js +162 -0
- package/src/agent-stack-controller.js +296 -0
- package/src/agent-trigger-controller.js +108 -0
- package/src/api-controller.js +206 -0
- package/src/argocd-gitops.js +43 -0
- package/src/auth.js +265 -0
- package/src/component-catalog.js +41 -0
- package/src/control-plane.js +136 -0
- package/src/controller-client.js +38 -0
- package/src/controller-ui.js +538 -0
- package/src/data-plane.js +178 -0
- package/src/gitea-backend.js +95 -0
- package/src/handoff.js +98 -0
- package/src/hooks-events.js +63 -0
- package/src/http-server.js +151 -0
- package/src/identity-policy.js +86 -0
- package/src/index.js +30 -0
- package/src/kubernetes-controller.js +812 -0
- package/src/kubernetes-resource-gateway.js +48 -0
- package/src/operations.js +112 -0
- package/src/resource-model.js +203 -0
- package/src/runners-ci.js +48 -0
- package/src/runtime.js +196 -0
- package/src/web-ui.js +40 -0
- package/tests/agent-approval-controller.test.js +173 -0
- package/tests/agent-context-bundles.test.js +278 -0
- package/tests/agent-dispatch-controller.test.js +176 -0
- package/tests/agent-mux-client.test.js +204 -0
- package/tests/agent-permission-review.test.js +209 -0
- package/tests/agent-resources.test.js +212 -0
- package/tests/agent-stack-controller.test.js +221 -0
- package/tests/agent-trigger-controller.test.js +211 -0
- package/tests/deployment.test.js +395 -0
- package/tests/e2e/lifecycle.test.js +117 -0
- package/tests/krate.test.js +727 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# Agent API contract spec
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This document defines future HTTP contracts for agent orchestration while preserving the current Krate API shape:
|
|
6
|
+
|
|
7
|
+
- `GET /api/controller` returns the `createControllerUiModel()` snapshot.
|
|
8
|
+
- `GET/POST /api/controller/resources` lists and applies arbitrary Krate resources.
|
|
9
|
+
- `GET/DELETE /api/controller/resources/[kind]/[name]` reads and deletes resources.
|
|
10
|
+
- `GET /api/watch/orgs/[org]/[[...resource]]` streams Krate live events as SSE.
|
|
11
|
+
|
|
12
|
+
Typed agent APIs should delegate to the same controller/resource gateway and never bypass resource admission.
|
|
13
|
+
|
|
14
|
+
## Response conventions
|
|
15
|
+
|
|
16
|
+
Successful resource response:
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"kind": "AgentStack",
|
|
21
|
+
"metadata": { "name": "claude-code-ci-repair" },
|
|
22
|
+
"spec": {},
|
|
23
|
+
"status": { "phase": "Ready", "conditions": [] }
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Error response:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"error": {
|
|
32
|
+
"code": "POLICY_DENIED",
|
|
33
|
+
"message": "Secret grant is missing for github-commenter.",
|
|
34
|
+
"correlationId": "krate-...",
|
|
35
|
+
"resource": "AgentStack/krate-system/claude-code-ci-repair",
|
|
36
|
+
"reasons": [
|
|
37
|
+
{
|
|
38
|
+
"code": "MissingSecretGrant",
|
|
39
|
+
"field": "spec.permissionRefs.secretGrants",
|
|
40
|
+
"message": "Secret krate-secrets/github-writeback:token is required."
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Recommended status codes:
|
|
48
|
+
|
|
49
|
+
| Code | Use |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| `200` | read/action completed |
|
|
52
|
+
| `201` | resource created |
|
|
53
|
+
| `202` | async action accepted |
|
|
54
|
+
| `400` | invalid request body or field |
|
|
55
|
+
| `401` | unauthenticated |
|
|
56
|
+
| `403` | RBAC/policy/admission denied |
|
|
57
|
+
| `404` | resource not found |
|
|
58
|
+
| `409` | generation conflict, dedupe conflict, active run conflict |
|
|
59
|
+
| `422` | valid JSON but invalid resource spec |
|
|
60
|
+
| `429` | concurrency/rate limit |
|
|
61
|
+
| `503` | controller/gateway unavailable |
|
|
62
|
+
|
|
63
|
+
## Resource CRUD
|
|
64
|
+
|
|
65
|
+
These can initially use the existing generic API:
|
|
66
|
+
|
|
67
|
+
- `GET /api/controller/resources?kind=AgentStack`
|
|
68
|
+
- `POST /api/controller/resources`
|
|
69
|
+
- `GET /api/controller/resources/AgentStack/claude-code-ci-repair`
|
|
70
|
+
- `DELETE /api/controller/resources/AgentStack/claude-code-ci-repair`
|
|
71
|
+
|
|
72
|
+
Typed routes can wrap the generic API for better UX and validation:
|
|
73
|
+
|
|
74
|
+
- `GET /api/agents/stacks`
|
|
75
|
+
- `POST /api/agents/stacks`
|
|
76
|
+
- `GET /api/agents/stacks/:name`
|
|
77
|
+
- `PATCH /api/agents/stacks/:name`
|
|
78
|
+
- `DELETE /api/agents/stacks/:name`
|
|
79
|
+
|
|
80
|
+
## Permission review
|
|
81
|
+
|
|
82
|
+
`POST /api/agents/permissions/review`
|
|
83
|
+
|
|
84
|
+
Request:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"repository": "krate",
|
|
89
|
+
"ref": "refs/pull/42/head",
|
|
90
|
+
"actor": "tmusk",
|
|
91
|
+
"agentStack": "claude-code-ci-repair",
|
|
92
|
+
"triggerSource": "pull-request-comment",
|
|
93
|
+
"taskKind": "ci-repair",
|
|
94
|
+
"runnerPool": "untrusted-linux"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Response:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"decision": "denied",
|
|
103
|
+
"runtimeIdentity": { "serviceAccountRef": "agent-claude-code-ci-repair", "ready": true },
|
|
104
|
+
"runnerIdentity": { "runnerPool": "untrusted-linux", "serviceAccountRef": "runner-untrusted-linux", "ready": true },
|
|
105
|
+
"requiredRoles": [],
|
|
106
|
+
"requiredSecrets": [],
|
|
107
|
+
"requiredConfigs": [],
|
|
108
|
+
"missingGrants": [],
|
|
109
|
+
"approvalRequirements": [],
|
|
110
|
+
"yamlPreview": [],
|
|
111
|
+
"reasons": []
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The UI should call this endpoint for stack save, trigger dry-run, manual dispatch, and grant wizards.
|
|
116
|
+
|
|
117
|
+
## Manual dispatch
|
|
118
|
+
|
|
119
|
+
`POST /api/agents/runs`
|
|
120
|
+
|
|
121
|
+
Request:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"repository": "krate",
|
|
126
|
+
"ref": "refs/heads/staging",
|
|
127
|
+
"agentStack": "claude-code-ci-repair",
|
|
128
|
+
"taskKind": "manual-repair",
|
|
129
|
+
"prompt": "Investigate the failing docs validation.",
|
|
130
|
+
"contextLabels": ["ci-failure-summary"],
|
|
131
|
+
"runtimeIdentity": { "serviceAccountRef": "agent-claude-code-ci-repair" },
|
|
132
|
+
"sourceRefs": { "path": "docs/agents", "actor": "tmusk" },
|
|
133
|
+
"workspacePolicy": { "mode": "isolated-worktree" },
|
|
134
|
+
"writeBackPolicy": { "requireApproval": true }
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Response:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"run": { "kind": "AgentDispatchRun", "metadata": { "name": "adr-01hx" }, "status": { "phase": "queued" } },
|
|
143
|
+
"attempt": { "kind": "AgentDispatchAttempt", "metadata": { "name": "ada-01hx-1" } },
|
|
144
|
+
"links": { "detail": "/agents/runs/adr-01hx" }
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Dispatch actions
|
|
149
|
+
|
|
150
|
+
- `POST /api/agents/runs/:run/cancel`
|
|
151
|
+
- `POST /api/agents/runs/:run/retry`
|
|
152
|
+
- `POST /api/agents/runs/:run/resume`
|
|
153
|
+
- `POST /api/agents/runs/:run/fork`
|
|
154
|
+
- `POST /api/agents/runs/:run/continue`
|
|
155
|
+
|
|
156
|
+
Action request:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"reason": "user-requested",
|
|
161
|
+
"message": "Continue with the focused test failure only.",
|
|
162
|
+
"expectedGeneration": 12
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Action response:
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"accepted": true,
|
|
171
|
+
"run": "adr-01hx",
|
|
172
|
+
"attempt": "ada-01hx-2",
|
|
173
|
+
"phase": "queued"
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Approvals
|
|
178
|
+
|
|
179
|
+
- `GET /api/agents/approvals`
|
|
180
|
+
- `POST /api/agents/approvals/:approval/decision`
|
|
181
|
+
|
|
182
|
+
Decision request:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"decision": "approved",
|
|
187
|
+
"comment": "Post the diagnosis only; do not push the patch.",
|
|
188
|
+
"approvedActionSubset": ["pull-request-comment"],
|
|
189
|
+
"expectedArtifactDigest": "sha256:..."
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Decision response:
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"approval": "approval-01hx",
|
|
198
|
+
"phase": "approved",
|
|
199
|
+
"writeBack": { "accepted": true, "idempotencyKey": "approval-01hx:sha256:..." }
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Trigger rules
|
|
204
|
+
|
|
205
|
+
- `GET /api/agents/rules`
|
|
206
|
+
- `POST /api/agents/rules`
|
|
207
|
+
- `POST /api/agents/rules/:rule/dry-run`
|
|
208
|
+
- `POST /api/agents/rules/:rule/lifecycle`
|
|
209
|
+
- `POST /api/agents/rules/:rule/replay-delivery`
|
|
210
|
+
|
|
211
|
+
Dry-run response must include matcher result, rendered prompt preview, context bundle plan, permission review, dedupe key, and expected actions.
|
|
212
|
+
|
|
213
|
+
## Secret/config grants
|
|
214
|
+
|
|
215
|
+
- `GET /api/agents/secrets`
|
|
216
|
+
- `GET /api/agents/configmaps`
|
|
217
|
+
- `POST /api/agents/secrets/grants`
|
|
218
|
+
- `POST /api/agents/config/grants`
|
|
219
|
+
- `GET /api/agents/capability-requirements`
|
|
220
|
+
|
|
221
|
+
Grant APIs should only expose Secret metadata and key names, never values.
|
|
222
|
+
|
|
223
|
+
## Watch/SSE contracts
|
|
224
|
+
|
|
225
|
+
Current route:
|
|
226
|
+
|
|
227
|
+
- `GET /api/watch/orgs/[org]/agentdispatchruns`
|
|
228
|
+
- `GET /api/watch/orgs/[org]/agentapprovals`
|
|
229
|
+
- `GET /api/watch/orgs/[org]/agentworkspaces`
|
|
230
|
+
- `GET /api/watch/orgs/[org]/agenttriggerrules`
|
|
231
|
+
|
|
232
|
+
SSE events should preserve the current `event: krate` style and include resource path and event payload. Typed agent pages may wrap this with a client helper, but the server path should remain Kubernetes-watch aligned.
|
|
233
|
+
|
|
234
|
+
## UI model additions
|
|
235
|
+
|
|
236
|
+
`GET /api/controller` should eventually include:
|
|
237
|
+
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"views": {
|
|
241
|
+
"agents": {
|
|
242
|
+
"activeRuns": [],
|
|
243
|
+
"pendingApprovals": [],
|
|
244
|
+
"stackReadiness": [],
|
|
245
|
+
"missingPermissions": [],
|
|
246
|
+
"repositoryAffordances": {}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
This lets existing server components continue using `fetchControllerUiModel()` while typed agent routes are added incrementally.
|
|
253
|
+
|
|
254
|
+
## Memory API contracts
|
|
255
|
+
|
|
256
|
+
Typed routes should preserve the generic controller API while adding focused memory actions:
|
|
257
|
+
|
|
258
|
+
| Endpoint | Method | Purpose |
|
|
259
|
+
| --- | --- | --- |
|
|
260
|
+
| `/api/agents/memory/orgs/[org]/repositories` | `GET` | list visible `AgentMemoryRepository` resources and health. |
|
|
261
|
+
| `/api/agents/memory/query` | `POST` | run admitted graph/frontmatter/grep query and create `AgentMemoryQuery`. |
|
|
262
|
+
| `/api/agents/memory/resolve-ref` | `POST` | resolve branch, tag, SHA, snapshot tag, or `refAt` timestamp to commit. |
|
|
263
|
+
| `/api/agents/memory/snapshots` | `POST` | create `AgentMemorySnapshot` for a dispatch context. |
|
|
264
|
+
| `/api/agents/memory/diff` | `POST` | diff two memory refs or snapshots. |
|
|
265
|
+
| `/api/agents/memory/updates` | `POST` | create proposed `AgentMemoryUpdate` from agent artifact or UI edit. |
|
|
266
|
+
| `/api/agents/memory/updates/[id]/approve` | `POST` | approve an update. |
|
|
267
|
+
| `/api/agents/memory/updates/[id]/merge` | `POST` | merge an approved update after validation. |
|
|
268
|
+
| `/api/agents/memory/ontology/validate` | `POST` | validate ontology, graph YAML, frontmatter, and generated indexes. |
|
|
269
|
+
|
|
270
|
+
All responses must include permission-review status, selected commit, digests, and redaction/truncation summaries when content is returned.
|
|
271
|
+
|
|
272
|
+
## Org-scoped memory API requirements
|
|
273
|
+
|
|
274
|
+
Memory APIs must be org-addressed or receive an explicit org in the request body. Preferred routes:
|
|
275
|
+
|
|
276
|
+
| Endpoint | Method | Purpose |
|
|
277
|
+
| --- | --- | --- |
|
|
278
|
+
| `/api/orgs/[org]/agents/memory/import-babysitter-run` | `POST` | import curated `MEMORY.md`, session, journal, task, and artifact metadata into org memory. |
|
|
279
|
+
| `/api/orgs/[org]/agents/memory/query` | `POST` | query memory within org scope. |
|
|
280
|
+
| `/api/orgs/[org]/agents/memory/resolve-ref` | `POST` | resolve current, explicit, snapshot, or timestamp refs for org memory. |
|
|
281
|
+
|
|
282
|
+
The server must reject requests where repository, deployment, memory repository, ServiceAccount, Secret, ConfigMap, session, or run belongs to a different org namespace.
|
|
283
|
+
|
|
284
|
+
## Org route compatibility rules
|
|
285
|
+
|
|
286
|
+
- New API surfaces should be org-addressed first.
|
|
287
|
+
- Compatibility endpoints must resolve org before permission review and must fail if a repository, run, session, deployment, or memory source is ambiguous.
|
|
288
|
+
- Watch endpoints should accept org filters and must not stream cross-org records without explicit admin scope.
|
|
289
|
+
- Error bodies for org mismatch should identify the denied reference type, not leak private resource names from another org.
|
|
290
|
+
|
|
291
|
+
## Org-scoped error contract
|
|
292
|
+
|
|
293
|
+
Org-aware APIs should use stable errors:
|
|
294
|
+
|
|
295
|
+
| Code | Meaning |
|
|
296
|
+
| --- | --- |
|
|
297
|
+
| `ORG_REQUIRED` | request did not include resolvable org context. |
|
|
298
|
+
| `ORG_NOT_FOUND` | actor cannot see the requested org or it does not exist. |
|
|
299
|
+
| `ORG_REQUIRED` | org-scoped route was missing an organization. |
|
|
300
|
+
| `ORG_NAMESPACE_MISMATCH` | resource namespace does not match org binding. |
|
|
301
|
+
| `CROSS_ORG_REF_DENIED` | referenced resource belongs to another org and no sharing policy applies. |
|
|
302
|
+
| `MEMORY_IMPORT_REDACTION_BLOCKED` | import redaction was too broad or unsafe. |
|
|
303
|
+
| `MEMORY_IMPORT_VALIDATION_FAILED` | normalized memory failed ontology/frontmatter/path validation. |
|
|
304
|
+
|
|
305
|
+
Error responses must avoid leaking private names from other orgs. They can include the denied reference kind and policy reason.
|
|
306
|
+
|
|
307
|
+
## Payload example reference
|
|
308
|
+
|
|
309
|
+
Concrete JSON payloads for the org memory vertical slice are defined in [Org memory API payload examples](./org-memory-api-payload-examples.md). API implementation and tests should treat those examples as canonical fixtures for field names, digest fields, links, and stable error shapes.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Agent artifacts and write-back spec
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Agents produce diagnoses, patches, review comments, reports, test results, and release recommendations. Krate must treat these as durable artifacts with explicit approval and write-back paths, not opaque chat text.
|
|
6
|
+
|
|
7
|
+
## Artifact resources
|
|
8
|
+
|
|
9
|
+
| Artifact kind | Resource | Typical source | Write-back target |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| diagnosis | `AgentArtifact` | CI/run analysis | PR/issue comment |
|
|
12
|
+
| patch | `AgentArtifact` | repair agent | branch push or PR update |
|
|
13
|
+
| review | `AgentReviewArtifact` | reviewer agent | PR review/comments |
|
|
14
|
+
| test report | `AgentArtifact` | validation subagent | pipeline/job summary |
|
|
15
|
+
| release report | `AgentArtifact` | release-check agent | release approval item |
|
|
16
|
+
| subagent output | `AgentArtifact` | child agent | parent run summary |
|
|
17
|
+
| workspace diff | `AgentArtifact` | workspace controller | review/apply flow |
|
|
18
|
+
|
|
19
|
+
## Artifact metadata
|
|
20
|
+
|
|
21
|
+
Required fields:
|
|
22
|
+
|
|
23
|
+
- dispatch run and attempt;
|
|
24
|
+
- producing agent/subagent;
|
|
25
|
+
- kind;
|
|
26
|
+
- digest;
|
|
27
|
+
- object storage ref or inline safe summary;
|
|
28
|
+
- source context digest;
|
|
29
|
+
- permission snapshot digest;
|
|
30
|
+
- target object refs;
|
|
31
|
+
- validation status;
|
|
32
|
+
- retention policy;
|
|
33
|
+
- redaction status.
|
|
34
|
+
|
|
35
|
+
## Patch artifacts
|
|
36
|
+
|
|
37
|
+
Patch artifacts should include:
|
|
38
|
+
|
|
39
|
+
- base ref/SHA;
|
|
40
|
+
- target branch/workspace;
|
|
41
|
+
- file list;
|
|
42
|
+
- diff digest;
|
|
43
|
+
- generated patch object ref;
|
|
44
|
+
- test evidence;
|
|
45
|
+
- conflicts/rebase status;
|
|
46
|
+
- unsafe file warnings;
|
|
47
|
+
- apply strategy: comment-only, branch update, PR update, local workspace only.
|
|
48
|
+
|
|
49
|
+
Patch artifacts never push themselves. They create write-back requests.
|
|
50
|
+
|
|
51
|
+
## Review artifacts
|
|
52
|
+
|
|
53
|
+
`AgentReviewArtifact` should support:
|
|
54
|
+
|
|
55
|
+
- review decision: pending, approved, changes-requested, comment-only;
|
|
56
|
+
- inline comments with file/line anchors;
|
|
57
|
+
- summary comment;
|
|
58
|
+
- risk checklist;
|
|
59
|
+
- confidence score;
|
|
60
|
+
- target PR/check refs;
|
|
61
|
+
- provider integration status;
|
|
62
|
+
- approval state before submission.
|
|
63
|
+
|
|
64
|
+
## Write-back actions
|
|
65
|
+
|
|
66
|
+
Supported actions:
|
|
67
|
+
|
|
68
|
+
- issue comment;
|
|
69
|
+
- PR comment;
|
|
70
|
+
- PR review submission;
|
|
71
|
+
- branch push;
|
|
72
|
+
- create branch;
|
|
73
|
+
- open PR;
|
|
74
|
+
- check rerun;
|
|
75
|
+
- workflow rerun;
|
|
76
|
+
- release note/report;
|
|
77
|
+
- deployment/release approval request.
|
|
78
|
+
|
|
79
|
+
Every write-back action must have:
|
|
80
|
+
|
|
81
|
+
- explicit target;
|
|
82
|
+
- artifact digest;
|
|
83
|
+
- actor/approver;
|
|
84
|
+
- idempotency key;
|
|
85
|
+
- policy decision;
|
|
86
|
+
- audit event;
|
|
87
|
+
- rollback/repair note where possible.
|
|
88
|
+
|
|
89
|
+
## Approval model
|
|
90
|
+
|
|
91
|
+
Write-back may be:
|
|
92
|
+
|
|
93
|
+
- denied by policy;
|
|
94
|
+
- allowed automatically by narrow repository policy;
|
|
95
|
+
- require approval always;
|
|
96
|
+
- require approval only for untrusted refs;
|
|
97
|
+
- require approval based on action class.
|
|
98
|
+
|
|
99
|
+
Approval UI must show:
|
|
100
|
+
|
|
101
|
+
- artifact preview;
|
|
102
|
+
- target object;
|
|
103
|
+
- exact mutation;
|
|
104
|
+
- actor and agent;
|
|
105
|
+
- context/permission digests;
|
|
106
|
+
- risk warnings;
|
|
107
|
+
- allow subset controls where applicable.
|
|
108
|
+
|
|
109
|
+
## Idempotency
|
|
110
|
+
|
|
111
|
+
Idempotency key format:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
<approval-uid>:<action-type>:<target-kind>:<target-name>:<artifact-digest>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Repeated apply with same key must not duplicate comments, pushes, reviews, or reruns.
|
|
118
|
+
|
|
119
|
+
## UI surfaces
|
|
120
|
+
|
|
121
|
+
- Run detail: artifacts tab/list with approval/write-back controls.
|
|
122
|
+
- PR page: review artifacts, patch proposals, comments, check reruns.
|
|
123
|
+
- Issue page: diagnosis/report artifacts and linked dispatches.
|
|
124
|
+
- Runs page: diagnosis/test report artifacts beside failed jobs.
|
|
125
|
+
- Inbox: pending write-back approvals.
|
|
126
|
+
- Workspace page: workspace diff and patch artifacts.
|
|
127
|
+
|
|
128
|
+
## Failure modes
|
|
129
|
+
|
|
130
|
+
| Failure | Behavior |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| artifact digest mismatch | reject approval/write-back |
|
|
133
|
+
| target PR changed | require rebase/refresh before write-back |
|
|
134
|
+
| branch push rejected | keep artifact, mark write-back failed, suggest rebase |
|
|
135
|
+
| review comment anchor stale | show stale anchor and allow comment-only fallback |
|
|
136
|
+
| check rerun denied | mark approval applied=false with RBAC reason |
|
|
137
|
+
| artifact contains suspected secret | block write-back until redaction/remediation |
|
|
138
|
+
|
|
139
|
+
## Acceptance criteria
|
|
140
|
+
|
|
141
|
+
- Agent output becomes durable artifacts, not just transcript text.
|
|
142
|
+
- Privileged write-back is gated by approval/policy.
|
|
143
|
+
- Artifact digest is checked before write-back.
|
|
144
|
+
- Duplicate approvals do not duplicate side effects.
|
|
145
|
+
- PR/issue/pipeline pages show related artifacts in context.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Agent chart and packaging spec
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This document defines how the agent orchestration docs should map into the Helm chart and package surfaces. It is grounded in the current chart:
|
|
6
|
+
|
|
7
|
+
- CRDs live under `charts/krate/crds/`.
|
|
8
|
+
- Deployments, services, RBAC, ServiceAccount, NetworkPolicy, and auth Secret templates live under `charts/krate/templates/`.
|
|
9
|
+
- `charts/krate/values.yaml` already contains `externalDependencies`, `auth`, `apiService`, `rbac`, `serviceAccount`, `networkPolicy`, `arc`, `kyverno`, and `gatekeeper` blocks.
|
|
10
|
+
- `scripts/validate-package.mjs` checks required files, CRDs, values terms, and npm package contents.
|
|
11
|
+
|
|
12
|
+
## Chart values to add
|
|
13
|
+
|
|
14
|
+
```yaml
|
|
15
|
+
agents:
|
|
16
|
+
enabled: false
|
|
17
|
+
agentMux:
|
|
18
|
+
enabled: false
|
|
19
|
+
gatewayUrl: ""
|
|
20
|
+
existingSecret: ""
|
|
21
|
+
streamTimeoutSeconds: 300
|
|
22
|
+
defaults:
|
|
23
|
+
runnerPool: untrusted-linux
|
|
24
|
+
runtimeServiceAccount: ""
|
|
25
|
+
workspacePolicy: isolated-worktree-default
|
|
26
|
+
approvalMode: prompt
|
|
27
|
+
retention:
|
|
28
|
+
dispatchRunsDays: 90
|
|
29
|
+
transcriptsDays: 30
|
|
30
|
+
contextBundlesDays: 30
|
|
31
|
+
artifactsDays: 180
|
|
32
|
+
auditDays: 365
|
|
33
|
+
permissions:
|
|
34
|
+
manageNativeRbac: true
|
|
35
|
+
allowClusterRoleBindings: false
|
|
36
|
+
requireBindEscalateReview: true
|
|
37
|
+
secrets:
|
|
38
|
+
enableGrantManagement: true
|
|
39
|
+
allowUiSecretCreation: true
|
|
40
|
+
showConfigMapValues: false
|
|
41
|
+
featureGates:
|
|
42
|
+
triggerRules: false
|
|
43
|
+
manualDispatch: false
|
|
44
|
+
workspaceLifecycle: false
|
|
45
|
+
writeBackApprovals: false
|
|
46
|
+
subagentTelemetry: false
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
These should be off by default until controllers exist.
|
|
50
|
+
|
|
51
|
+
## CRD packaging
|
|
52
|
+
|
|
53
|
+
Add CRDs in a dedicated file such as `charts/krate/crds/agent-resources.yaml` or split by domain:
|
|
54
|
+
|
|
55
|
+
- `agent-config-resources.yaml`
|
|
56
|
+
- `agent-execution-resources.yaml`
|
|
57
|
+
- `agent-rbac-grant-resources.yaml`
|
|
58
|
+
|
|
59
|
+
Required CRD groups:
|
|
60
|
+
|
|
61
|
+
- stack/tool/MCP/skill/subagent/context/workspace policy;
|
|
62
|
+
- trigger rules;
|
|
63
|
+
- ServiceAccount/RoleBinding/SecretGrant/ConfigGrant;
|
|
64
|
+
- dispatch/run/attempt/session/workspace/approval/artifact projections if CRD-backed for MVP.
|
|
65
|
+
|
|
66
|
+
If execution resources are served by the aggregated API only, the chart must still install APIService/openapi surfaces and examples; do not create etcd-backed high-cardinality CRDs by accident.
|
|
67
|
+
|
|
68
|
+
## Template changes
|
|
69
|
+
|
|
70
|
+
### ServiceAccount and RBAC
|
|
71
|
+
|
|
72
|
+
Current chart has `templates/serviceaccount.yaml` and `templates/rbac.yaml`. Agent implementation should extend them to include:
|
|
73
|
+
|
|
74
|
+
- controller permissions for agent config resources;
|
|
75
|
+
- read/watch permissions for native ServiceAccounts/Roles/RoleBindings where enabled;
|
|
76
|
+
- Secret/ConfigMap metadata access only where grants are enabled;
|
|
77
|
+
- no blanket Secret read for the web pod;
|
|
78
|
+
- separate controller role from web role if agents need broader reconciliation permissions.
|
|
79
|
+
|
|
80
|
+
### Deployments
|
|
81
|
+
|
|
82
|
+
Current deployments already set auth-related env vars. Agent additions should include:
|
|
83
|
+
|
|
84
|
+
- `KRATE_AGENTS_ENABLED`;
|
|
85
|
+
- `KRATE_AGENT_MUX_GATEWAY_URL`;
|
|
86
|
+
- `KRATE_AGENT_DEFAULT_RUNNER_POOL`;
|
|
87
|
+
- `KRATE_AGENT_DEFAULT_SERVICE_ACCOUNT`;
|
|
88
|
+
- retention env vars;
|
|
89
|
+
- feature gate env vars;
|
|
90
|
+
- secret/config grant management flags.
|
|
91
|
+
|
|
92
|
+
### NetworkPolicy
|
|
93
|
+
|
|
94
|
+
Agent Mux gateway and MCP traffic should be explicit egress rules, not broad outbound allow. The UI should surface when network policy blocks an MCP server or Agent Mux gateway.
|
|
95
|
+
|
|
96
|
+
### Secrets
|
|
97
|
+
|
|
98
|
+
Agent Mux gateway credentials should use `existingSecret` by default. The chart must not render provider secrets from plaintext values except for local-dev/demo modes.
|
|
99
|
+
|
|
100
|
+
## Examples
|
|
101
|
+
|
|
102
|
+
Add examples later under `examples/agents/`:
|
|
103
|
+
|
|
104
|
+
- `agent-stack-claude-code.yaml`;
|
|
105
|
+
- `agent-rbac-grants.yaml`;
|
|
106
|
+
- `agent-trigger-ci-repair.yaml`;
|
|
107
|
+
- `agent-manual-dispatch.yaml`;
|
|
108
|
+
- `agent-permission-review-denied.yaml`.
|
|
109
|
+
|
|
110
|
+
Package validation should eventually require at least one agent stack example and one SecretGrant/ConfigGrant example.
|
|
111
|
+
|
|
112
|
+
## Validation updates
|
|
113
|
+
|
|
114
|
+
When implementation starts, update `scripts/validate-package.mjs` to check:
|
|
115
|
+
|
|
116
|
+
- agent CRD file exists;
|
|
117
|
+
- required agent CRD kinds are included;
|
|
118
|
+
- values include `agents`, `agentMux`, `retention`, `permissions`, `secrets`, `featureGates`;
|
|
119
|
+
- npm pack includes new docs and examples;
|
|
120
|
+
- chart templates do not give web pods broad Secret read;
|
|
121
|
+
- chart templates consume new values.
|
|
122
|
+
|
|
123
|
+
## Release safety
|
|
124
|
+
|
|
125
|
+
- Agent features should be disabled by default until a vertical slice is implemented.
|
|
126
|
+
- Installing the chart with `agents.enabled=false` should behave exactly as today.
|
|
127
|
+
- Enabling agents without Agent Mux gateway configured should show degraded readiness, not crash the whole app.
|
|
128
|
+
- Missing RBAC permissions should disable agent actions but keep repository browsing available.
|