@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.
Files changed (174) hide show
  1. package/Dockerfile +29 -0
  2. package/README.md +183 -0
  3. package/bin/krate-demo.mjs +23 -0
  4. package/bin/krate-server.mjs +14 -0
  5. package/dist/krate-controller-ui.json +2407 -0
  6. package/dist/krate-lifecycle.json +201 -0
  7. package/dist/krate-runtime-snapshot.json +2955 -0
  8. package/dist/krate-summary.json +687 -0
  9. package/docs/README.md +61 -0
  10. package/docs/agents/README.md +83 -0
  11. package/docs/agents/acceptance-test-matrix.md +193 -0
  12. package/docs/agents/agent-mux-adapter-contract.md +167 -0
  13. package/docs/agents/agent-mux-source-map.md +310 -0
  14. package/docs/agents/agent-run-memory-import-spec.md +256 -0
  15. package/docs/agents/agent-stack-management-spec.md +421 -0
  16. package/docs/agents/api-contract-spec.md +309 -0
  17. package/docs/agents/artifacts-writeback-spec.md +145 -0
  18. package/docs/agents/chart-packaging-spec.md +128 -0
  19. package/docs/agents/ci-orchestration-spec.md +140 -0
  20. package/docs/agents/context-assembly-spec.md +219 -0
  21. package/docs/agents/controller-reconciliation-spec.md +255 -0
  22. package/docs/agents/crd-schema-spec.md +315 -0
  23. package/docs/agents/decision-log-open-questions.md +169 -0
  24. package/docs/agents/developer-implementation-checklist.md +329 -0
  25. package/docs/agents/dispatching-design.md +262 -0
  26. package/docs/agents/glossary.md +66 -0
  27. package/docs/agents/implementation-blueprint.md +324 -0
  28. package/docs/agents/implementation-rollout-slices.md +251 -0
  29. package/docs/agents/memory-context-integration-spec.md +194 -0
  30. package/docs/agents/memory-ontology-schema-spec.md +253 -0
  31. package/docs/agents/memory-operations-runbook.md +121 -0
  32. package/docs/agents/mvp-vertical-slice-spec.md +146 -0
  33. package/docs/agents/observability-audit-spec.md +265 -0
  34. package/docs/agents/operator-runbook.md +174 -0
  35. package/docs/agents/org-memory-api-payload-examples.md +333 -0
  36. package/docs/agents/org-memory-controller-sequence-spec.md +181 -0
  37. package/docs/agents/org-memory-e2e-fixture-plan.md +161 -0
  38. package/docs/agents/org-memory-ui-implementation-map.md +114 -0
  39. package/docs/agents/org-memory-vertical-slice-spec.md +168 -0
  40. package/docs/agents/org-resource-model-delta-spec.md +111 -0
  41. package/docs/agents/org-route-resource-model-spec.md +183 -0
  42. package/docs/agents/org-scoping-namespace-spec.md +114 -0
  43. package/docs/agents/rbac-secrets-management-spec.md +406 -0
  44. package/docs/agents/repository-page-integration-spec.md +255 -0
  45. package/docs/agents/resource-contract-examples.md +808 -0
  46. package/docs/agents/resource-relationship-map.md +190 -0
  47. package/docs/agents/security-threat-model.md +188 -0
  48. package/docs/agents/shared-memory-company-brain-spec.md +358 -0
  49. package/docs/agents/storage-migration-spec.md +168 -0
  50. package/docs/agents/subagent-orchestration-spec.md +152 -0
  51. package/docs/agents/system-overview.md +88 -0
  52. package/docs/agents/tools-mcp-skills-spec.md +189 -0
  53. package/docs/agents/traceability-matrix.md +79 -0
  54. package/docs/agents/ui-flow-spec.md +211 -0
  55. package/docs/agents/ui-ux-system-spec.md +426 -0
  56. package/docs/agents/workspace-lifecycle-spec.md +166 -0
  57. package/docs/architecture-spec.md +78 -0
  58. package/docs/components/control-plane.md +78 -0
  59. package/docs/components/data-plane.md +69 -0
  60. package/docs/components/hooks-events.md +67 -0
  61. package/docs/components/identity-rbac-policy.md +73 -0
  62. package/docs/components/kubevela-oam.md +70 -0
  63. package/docs/components/operations-publishing.md +81 -0
  64. package/docs/components/runners-ci.md +66 -0
  65. package/docs/components/web-ui.md +94 -0
  66. package/docs/external/README.md +47 -0
  67. package/docs/external/bidirectional-sync-design.md +134 -0
  68. package/docs/external/cicd-interface.md +64 -0
  69. package/docs/external/external-backend-controllers.md +170 -0
  70. package/docs/external/external-backend-crds.md +234 -0
  71. package/docs/external/external-backend-ui-spec.md +151 -0
  72. package/docs/external/external-backend-ux-flows.md +115 -0
  73. package/docs/external/external-object-mapping.md +125 -0
  74. package/docs/external/git-forge-interface.md +68 -0
  75. package/docs/external/github-integration-design.md +151 -0
  76. package/docs/external/issue-tracking-interface.md +66 -0
  77. package/docs/external/provider-capability-manifests.md +204 -0
  78. package/docs/external/provider-catalog.md +139 -0
  79. package/docs/external/provider-rollout-testing.md +78 -0
  80. package/docs/external/research-results.md +48 -0
  81. package/docs/external/security-auth-permissions.md +81 -0
  82. package/docs/external/sync-state-machines.md +108 -0
  83. package/docs/external/unified-external-backend-model.md +107 -0
  84. package/docs/external/user-facing-changes.md +67 -0
  85. package/docs/gaps.md +161 -0
  86. package/docs/install.md +94 -0
  87. package/docs/krate-design.md +334 -0
  88. package/docs/local-minikube.md +55 -0
  89. package/docs/ontology/README.md +32 -0
  90. package/docs/ontology/bounded-contexts.md +29 -0
  91. package/docs/ontology/events-and-hooks.md +32 -0
  92. package/docs/ontology/oam-kubevela.md +32 -0
  93. package/docs/ontology/operations-and-release.md +25 -0
  94. package/docs/ontology/personas-and-actors.md +32 -0
  95. package/docs/ontology/policies-and-invariants.md +33 -0
  96. package/docs/ontology/problem-space.md +30 -0
  97. package/docs/ontology/resource-contracts.md +40 -0
  98. package/docs/ontology/resource-taxonomy.md +42 -0
  99. package/docs/ontology/runners-and-ci.md +29 -0
  100. package/docs/ontology/solution-space.md +24 -0
  101. package/docs/ontology/storage-and-data-boundaries.md +29 -0
  102. package/docs/ontology/validation-matrix.md +24 -0
  103. package/docs/ontology/web-ui-excellent-flows.md +32 -0
  104. package/docs/ontology/workflows.md +39 -0
  105. package/docs/ontology/world.md +35 -0
  106. package/docs/product-requirements.md +62 -0
  107. package/docs/roadmap-mvp.md +87 -0
  108. package/docs/system-requirements.md +90 -0
  109. package/docs/tests/README.md +53 -0
  110. package/docs/tests/agent-qa-plan.md +63 -0
  111. package/docs/tests/browser-ui-tests.md +62 -0
  112. package/docs/tests/ci-quality-gates.md +48 -0
  113. package/docs/tests/coverage-model.md +64 -0
  114. package/docs/tests/e2e-scenario-tests.md +53 -0
  115. package/docs/tests/fixtures-test-data.md +63 -0
  116. package/docs/tests/observability-reliability-tests.md +54 -0
  117. package/docs/tests/product-test-matrix.md +145 -0
  118. package/docs/tests/qa-adoption-roadmap.md +130 -0
  119. package/docs/tests/qa-automation-plan.md +101 -0
  120. package/docs/tests/security-compliance-tests.md +57 -0
  121. package/docs/tests/test-framework-tools.md +88 -0
  122. package/docs/tests/test-suite-layout.md +121 -0
  123. package/docs/tests/unit-integration-tests.md +48 -0
  124. package/docs/todo-kyverno +714 -0
  125. package/docs/user-stories.md +78 -0
  126. package/examples/minikube-demo.yaml +190 -0
  127. package/examples/oam-application.yaml +23 -0
  128. package/examples/policy-kyverno-pr-title.yaml +18 -0
  129. package/package.json +63 -0
  130. package/scripts/build.mjs +29 -0
  131. package/scripts/setup-minikube.mjs +65 -0
  132. package/scripts/smoke.mjs +37 -0
  133. package/scripts/validate-doc-coverage.mjs +152 -0
  134. package/scripts/validate-package.mjs +93 -0
  135. package/scripts/validate-ui.mjs +207 -0
  136. package/src/agent-approval-controller.js +123 -0
  137. package/src/agent-context-bundles.js +242 -0
  138. package/src/agent-dispatch-controller.js +86 -0
  139. package/src/agent-mux-client.js +280 -0
  140. package/src/agent-permission-review.js +162 -0
  141. package/src/agent-stack-controller.js +296 -0
  142. package/src/agent-trigger-controller.js +108 -0
  143. package/src/api-controller.js +206 -0
  144. package/src/argocd-gitops.js +43 -0
  145. package/src/auth.js +265 -0
  146. package/src/component-catalog.js +41 -0
  147. package/src/control-plane.js +136 -0
  148. package/src/controller-client.js +38 -0
  149. package/src/controller-ui.js +538 -0
  150. package/src/data-plane.js +178 -0
  151. package/src/gitea-backend.js +95 -0
  152. package/src/handoff.js +98 -0
  153. package/src/hooks-events.js +63 -0
  154. package/src/http-server.js +151 -0
  155. package/src/identity-policy.js +86 -0
  156. package/src/index.js +30 -0
  157. package/src/kubernetes-controller.js +812 -0
  158. package/src/kubernetes-resource-gateway.js +48 -0
  159. package/src/operations.js +112 -0
  160. package/src/resource-model.js +203 -0
  161. package/src/runners-ci.js +48 -0
  162. package/src/runtime.js +196 -0
  163. package/src/web-ui.js +40 -0
  164. package/tests/agent-approval-controller.test.js +173 -0
  165. package/tests/agent-context-bundles.test.js +278 -0
  166. package/tests/agent-dispatch-controller.test.js +176 -0
  167. package/tests/agent-mux-client.test.js +204 -0
  168. package/tests/agent-permission-review.test.js +209 -0
  169. package/tests/agent-resources.test.js +212 -0
  170. package/tests/agent-stack-controller.test.js +221 -0
  171. package/tests/agent-trigger-controller.test.js +211 -0
  172. package/tests/deployment.test.js +395 -0
  173. package/tests/e2e/lifecycle.test.js +117 -0
  174. package/tests/krate.test.js +727 -0
@@ -0,0 +1,315 @@
1
+ # Agent CRD schema spec
2
+
3
+ ## Purpose
4
+
5
+ This document defines the agent resource schema shape that should be added to Krate when implementation starts. It is grounded in the current Krate model:
6
+
7
+ - `src/resource-model.js` currently separates low-cardinality `CONFIG_KINDS` from high-cardinality `AGGREGATED_KINDS`.
8
+ - Every resource schema uses `apiVersion: krate.a5c.ai/v1alpha1`, `metadata.name`, `spec`, and `status.storage/phase/conditions`.
9
+ - `src/kubernetes-controller.js` exposes `KRATE_RESOURCES` through Kubernetes-style plural resources.
10
+ - `apps/web/app/api/controller/resources` already lists/applies resources through `createKrateApiController()`.
11
+
12
+ Agent resources should follow the same pattern rather than introducing a second API style.
13
+
14
+ ## Resource classification
15
+
16
+ ### Add to `CONFIG_KINDS`
17
+
18
+ These are declarative, low-cardinality, reviewable configuration resources:
19
+
20
+ | Kind | Plural | Context | Required spec | Storage |
21
+ | --- | --- | --- | --- | --- |
22
+ | `AgentStack` | `agentstacks` | `agents` | `baseAgent`, `adapter`, `runtimeIdentity` | etcd |
23
+ | `AgentSubagent` | `agentsubagents` | `agents` | `rolePrompt`, `taskKinds` | etcd |
24
+ | `AgentToolProfile` | `agenttoolprofiles` | `agents` | `filesystemPolicy`, `approvalPolicyByTool` | etcd |
25
+ | `AgentMcpServer` | `agentmcpservers` | `agents` | `transport`, `scope` | etcd |
26
+ | `AgentSkill` | `agentskills` | `agents` | `format`, `sourceRef` | etcd |
27
+ | `AgentTriggerRule` | `agenttriggerrules` | `agents` | `sources`, `agentStack`, `taskKind` | etcd |
28
+ | `AgentContextLabel` | `agentcontextlabels` | `agents` | `promptFragment`, `allowedSources` | etcd |
29
+ | `AgentWorkspacePolicy` | `agentworkspacepolicies` | `agents` | `mode`, `retentionPolicy` | etcd |
30
+ | `AgentServiceAccount` | `agentserviceaccounts` | `identity` | `namespace`, `serviceAccountName` | etcd |
31
+ | `AgentRoleBinding` | `agentrolebindings` | `identity` | `subject`, `roleRef`, `scope` | etcd |
32
+ | `AgentSecretGrant` | `agentsecretgrants` | `identity` | `subject`, `secretRef`, `purpose` | etcd |
33
+ | `AgentConfigGrant` | `agentconfiggrants` | `identity` | `subject`, `configMapRef`, `purpose` | etcd |
34
+
35
+ ### Add to `AGGREGATED_KINDS`
36
+
37
+ These are execution records or projections that can grow quickly:
38
+
39
+ | Kind | Plural | Context | Required spec | Storage |
40
+ | --- | --- | --- | --- | --- |
41
+ | `AgentDispatchRun` | `agentdispatchruns` | `agents` | `repository`, `sourceRefs`, `agentStack`, `taskKind` | postgres |
42
+ | `AgentDispatchAttempt` | `agentdispatchattempts` | `agents` | `agentDispatchRun`, `attemptReason`, `agentStackSnapshot` | postgres |
43
+ | `AgentSession` | `agentsessions` | `agents` | `agentMuxSessionId`, `dispatchRun` | postgres |
44
+ | `AgentWorkspace` | `agentworkspaces` | `agents` | `repository`, `workspacePath`, `ownership` | postgres |
45
+ | `AgentApproval` | `agentapprovals` | `agents` | `dispatchRun`, `action`, `requestedBy` | postgres |
46
+ | `AgentContextBundle` | `agentcontextbundles` | `agents` | `dispatchRun`, `digest`, `sources` | postgres/object storage |
47
+ | `AgentArtifact` | `agentartifacts` | `agents` | `dispatchRun`, `kind`, `digest` | postgres/object storage |
48
+ | `AgentReviewArtifact` | `agentreviewartifacts` | `agents` | `dispatchRun`, `targetRef`, `decision` | postgres |
49
+ | `AgentTriggerExecution` | `agenttriggerexecutions` | `agents` | `triggerRule`, `sourceEvent`, `decision` | postgres |
50
+ | `AgentCapabilityRequirement` | `agentcapabilityrequirements` | `agents` | `ownerRef`, `requiredRoles` | postgres projection |
51
+ | `WorkItemSessionLink` | `workitemsessionlinks` | `agents` | `workItemRef`, `agentSession` | postgres |
52
+ | `WorkItemWorkspaceLink` | `workitemworkspacelinks` | `agents` | `workItemRef`, `workspace` | postgres |
53
+
54
+ ## Shared schema conventions
55
+
56
+ Every agent kind should follow the current `resourceSchemaForKind()` contract:
57
+
58
+ ```yaml
59
+ apiVersion: krate.a5c.ai/v1alpha1
60
+ kind: AgentStack
61
+ metadata:
62
+ name: claude-code-ci-repair
63
+ namespace: krate-system
64
+ labels:
65
+ a5c.ai/owner: platform
66
+ krate.a5c.ai/repository: krate
67
+ spec: {}
68
+ status:
69
+ storage: etcd
70
+ phase: Ready
71
+ conditions: []
72
+ ```
73
+
74
+ Required shared fields:
75
+
76
+ - `metadata.name`: stable resource name.
77
+ - `metadata.namespace`: defaulted by `withKrateDefaults()` when missing.
78
+ - `metadata.labels`: searchable ownership, repository, stack, trigger, and source labels.
79
+ - `spec`: desired state or immutable execution request.
80
+ - `status.phase`: summary state for UI tables.
81
+ - `status.conditions`: typed readiness/blocked/drift details.
82
+ - `status.observedGeneration`: generation reconciled by the controller.
83
+
84
+ Condition shape:
85
+
86
+ ```yaml
87
+ - type: Ready
88
+ status: "False"
89
+ reason: MissingSecretGrant
90
+ message: github-commenter requires Secret krate-secrets/github-writeback:token.
91
+ observedGeneration: 4
92
+ lastTransitionTime: "2026-05-10T12:00:00Z"
93
+ ```
94
+
95
+ Condition types should be stable enums. `message` is for humans and must not be parsed by controllers.
96
+
97
+ ## Core config schemas
98
+
99
+ ### `AgentStack.spec`
100
+
101
+ ```yaml
102
+ baseAgent: claude-code
103
+ adapter: agent-mux.claude-code
104
+ provider: anthropic
105
+ model: claude-sonnet-4-5
106
+ prompt:
107
+ system: string
108
+ developer: string
109
+ agentsDocRef:
110
+ source: repository
111
+ path: AGENTS.md
112
+ approvalMode: prompt
113
+ runtimeIdentity:
114
+ serviceAccountRef: agent-claude-code-ci-repair
115
+ toolProfileRef: repo-write-safe
116
+ mcpServerRefs: []
117
+ skillRefs: []
118
+ subagentRefs: []
119
+ contextLabelRefs: []
120
+ workspacePolicyRef: isolated-worktree-default
121
+ runnerPool: untrusted-linux
122
+ permissionRefs:
123
+ roleBindings: []
124
+ secretGrants: []
125
+ configGrants: []
126
+ secretPolicy:
127
+ allowOnForks: false
128
+ allowedSecretRefs: []
129
+ writeBackPolicy:
130
+ requireApproval: true
131
+ allowedTargets: []
132
+ ```
133
+
134
+ `AgentStack.status.conditions` must include: `CapabilitiesResolved`, `RuntimeIdentityReady`, `RolesAdmitted`, `SecretsAdmitted`, `ConfigAdmitted`, `ToolsAdmitted`, `McpHealthy`, `SkillsValidated`, `SubagentsValid`, `PolicyAdmitted`, `Ready`.
135
+
136
+ ### `AgentTriggerRule.spec`
137
+
138
+ ```yaml
139
+ lifecycleState: active
140
+ sources: [ci, issue-comment]
141
+ match:
142
+ repository: krate
143
+ eventTypes: []
144
+ branches:
145
+ include: []
146
+ exclude: []
147
+ agentStack: claude-code-ci-repair
148
+ taskKind: ci-repair
149
+ promptTemplate: string
150
+ contextLabels: []
151
+ contextBundleTemplate:
152
+ include: []
153
+ maxBytes: 750000
154
+ redactSecrets: true
155
+ runnerPool: untrusted-linux
156
+ approvalPolicy:
157
+ requireFor: []
158
+ dedupePolicy:
159
+ key: string
160
+ window: 30m
161
+ concurrencyPolicy:
162
+ mode: coalesce
163
+ writeBackPolicy:
164
+ allowedTargets: []
165
+ ```
166
+
167
+ ### `AgentSecretGrant.spec`
168
+
169
+ ```yaml
170
+ subject:
171
+ kind: agent-stack
172
+ name: claude-code-ci-repair
173
+ serviceAccountRef: agent-claude-code-ci-repair
174
+ secretRef:
175
+ namespace: krate-secrets
176
+ name: anthropic-provider
177
+ keys: [api-key]
178
+ purpose: model-provider-token
179
+ allowedRepositories: [krate]
180
+ allowedRefs:
181
+ include: [refs/heads/main]
182
+ exclude: [refs/pull/*/head]
183
+ allowedTriggerSources: [manual, ci]
184
+ mountPolicy: env
185
+ requiredApproval: on-untrusted-ref
186
+ rotationPolicy:
187
+ maxAgeDays: 90
188
+ ```
189
+
190
+ ### `AgentConfigGrant.spec`
191
+
192
+ ```yaml
193
+ subject:
194
+ kind: skill
195
+ name: focused-test-selection
196
+ stackRef: claude-code-ci-repair
197
+ configMapRef:
198
+ namespace: krate-config
199
+ name: npm-test-policy
200
+ keys: [allowed-scripts.json]
201
+ purpose: skill-config
202
+ allowedRepositories: [krate]
203
+ mountPolicy: file
204
+ ```
205
+
206
+ ## Execution record schemas
207
+
208
+ ### `AgentDispatchRun.spec`
209
+
210
+ ```yaml
211
+ repository: krate
212
+ ref: refs/pull/42/head
213
+ branch: user/fix-ci
214
+ sha: abcdef1234567890
215
+ sourceEvent:
216
+ kind: WebhookDelivery
217
+ name: delivery-01hx
218
+ sourceRefs:
219
+ pullRequest: krate/42
220
+ pipeline: pipeline-01hx
221
+ job: job-01hx-test
222
+ triggerRule: failed-pr-check-repair
223
+ agentStack: claude-code-ci-repair
224
+ taskKind: ci-repair
225
+ contextBundleRef: acb-01hx
226
+ workspaceRef: workspace-krate-pr-42
227
+ runnerPool: untrusted-linux
228
+ approvalPolicy:
229
+ requireWriteBackApproval: true
230
+ ```
231
+
232
+ `status` must include queue times, attempt refs, Agent Mux IDs, source breadcrumbs, artifacts, approvals, cost, event cursor, permission snapshot digest, and terminal reason.
233
+
234
+ ### `AgentDispatchAttempt.spec`
235
+
236
+ ```yaml
237
+ agentDispatchRun: adr-01hx-ci-repair
238
+ attemptReason: initial
239
+ agentStackSnapshot:
240
+ name: claude-code-ci-repair
241
+ generation: 7
242
+ contextBundleDigest: sha256:...
243
+ permissionSnapshotDigest: sha256:...
244
+ workspaceRef: workspace-krate-pr-42
245
+ runnerPool: untrusted-linux
246
+ ```
247
+
248
+ `status.runtimeIdentity` and `status.runnerIdentity` are immutable after launch.
249
+
250
+ ## Labels and indexes
251
+
252
+ Required labels for list/watch performance:
253
+
254
+ - `krate.a5c.ai/repository`
255
+ - `krate.a5c.ai/agent-stack`
256
+ - `krate.a5c.ai/trigger-rule`
257
+ - `krate.a5c.ai/dispatch-run`
258
+ - `krate.a5c.ai/source-kind`
259
+ - `krate.a5c.ai/source-name`
260
+ - `krate.a5c.ai/runner-pool`
261
+ - `krate.a5c.ai/service-account`
262
+
263
+ These labels let existing `/api/controller/resources?kind=...` and `/api/watch/orgs/[org]/...` endpoints support repository-scoped views without inventing UI-only state.
264
+
265
+ ## Implementation notes
266
+
267
+ - Add resource definitions first to `src/resource-model.js` and `src/kubernetes-controller.js`.
268
+ - Keep initial schemas compatible with `resourceSchemaForKind()` before adding deeper OpenAPI validation.
269
+ - CRDs in `charts/krate/templates/crds.yaml` should be generated or hand-written from this matrix.
270
+ - UI resource tables can display these kinds immediately through the existing controller resources API.
271
+ - Future typed routes should delegate to the same controller/resource gateway to avoid bypassing Kubernetes-style behavior.
272
+
273
+ ## Company brain memory resources
274
+
275
+ Add memory resources alongside agent config and aggregated execution resources.
276
+
277
+ ### Add to `CONFIG_KINDS`
278
+
279
+ | Kind | Plural | Context | Required spec | Storage |
280
+ | --- | --- | --- | --- | --- |
281
+ | `AgentMemoryRepository` | `agentmemoryrepositories` | `agents` | `repositoryRef`, `defaultBranch`, `layoutProfile` | etcd |
282
+ | `AgentMemorySource` | `agentmemorysources` | `agents` | `repositoryRef`, `appliesTo`, `include` | etcd |
283
+ | `AgentMemoryOntology` | `agentmemoryontologies` | `agents` | `memoryRepository`, `ontologyPath` | etcd |
284
+ | `AgentMemoryAssociation` | `agentmemoryassociations` | `agents` | `memoryRef`, `targetRef`, `relationship` | etcd |
285
+
286
+ ### Add to `AGGREGATED_KINDS`
287
+
288
+ | Kind | Plural | Context | Required spec | Storage |
289
+ | --- | --- | --- | --- | --- |
290
+ | `AgentMemorySnapshot` | `agentmemorysnapshots` | `agents` | `memoryRepository`, `requestedRef`, `resolvedCommit` | postgres/object storage |
291
+ | `AgentMemoryQuery` | `agentmemoryqueries` | `agents` | `snapshotRef`, `requester`, `query` | postgres/object storage |
292
+ | `AgentMemoryUpdate` | `agentmemoryupdates` | `agents` | `memoryRepository`, `sourceRun`, `changes` | postgres/object storage |
293
+
294
+ `AgentDispatchRun`, `AgentDispatchAttempt`, and `AgentContextBundle` should link to memory snapshots by name and digest. Memory update resources should link back to source runs, artifacts, PRs, approvals, and audit events.
295
+
296
+ ## Organization and run-memory resources
297
+
298
+ Org scoping adds top-level tenancy resources and Babysitter memory import resources.
299
+
300
+ ### Add to `CONFIG_KINDS`
301
+
302
+ | Kind | Plural | Context | Required spec | Storage |
303
+ | --- | --- | --- | --- | --- |
304
+ | `Organization` | `organizations` | `core` | `namespaceName`, `slug` | etcd |
305
+ | `OrgNamespaceBinding` | `orgnamespacebindings` | `core` | `organizationRef`, `namespace` | etcd |
306
+ | `OrgSharingPolicy` | `orgsharingpolicies` | `core` | `sourceOrg`, `targetOrg`, `allowedRefs` | etcd |
307
+
308
+ ### Add to `AGGREGATED_KINDS`
309
+
310
+ | Kind | Plural | Context | Required spec | Storage |
311
+ | --- | --- | --- | --- | --- |
312
+ | `AgentRunMemoryImport` | `agentrunmemoryimports` | `agents` | `organizationRef`, `memoryRepository`, `source`, `include` | postgres/object storage |
313
+ | `AgentRunJournalEvent` | `agentrunjournalevents` | `agents` | `organizationRef`, `runRef`, `sequence`, `digest` | postgres/object storage |
314
+
315
+ All existing and proposed agent resources should gain `spec.organizationRef` or derive it from namespace plus labels. Product data without org scope should fail admission unless it is installation/platform state.
@@ -0,0 +1,169 @@
1
+ # Agent decision log and open questions
2
+
3
+ ## Purpose
4
+
5
+ This document records architecture decisions already made in the agent docs and tracks open questions that should be resolved before or during implementation. It helps keep future work aligned with the docs-only design.
6
+
7
+ ## Accepted decisions
8
+
9
+ ### Agents are repository-native, not a separate chat app
10
+
11
+ Decision:
12
+
13
+ - Agent state appears inside Code, Issues, Pull Requests, Runs, Hooks, Settings, Workspaces, Inbox, and global Agents pages.
14
+
15
+ Rationale:
16
+
17
+ - Krate is a forge/control-plane; agent dispatch is part of repository workflow.
18
+
19
+ ### Krate owns policy and graph; Agent Mux owns adapter/session runtime
20
+
21
+ Decision:
22
+
23
+ - Krate owns resources, triggers, RBAC, grants, context bundles, dispatch runs, approvals, artifacts, workspaces, and audit.
24
+ - Agent Mux owns adapter-specific launch/session/chat/runtime details.
25
+
26
+ Rationale:
27
+
28
+ - Keeps repository source of truth in Krate while reusing Agent Mux execution primitives.
29
+
30
+ ### Kubernetes RBAC remains authoritative
31
+
32
+ Decision:
33
+
34
+ - Krate can manage projections and UI forms, but enforcement must resolve to native users/groups/ServiceAccounts/Roles/RoleBindings and admission checks.
35
+
36
+ Rationale:
37
+
38
+ - Avoids a parallel permission system and aligns with existing Krate identity docs.
39
+
40
+ ### Secret access is explicit and purpose-scoped
41
+
42
+ Decision:
43
+
44
+ - Tools, skills, MCP servers, model providers, agents, and runners need explicit `AgentSecretGrant`/`AgentConfigGrant` resources.
45
+
46
+ Rationale:
47
+
48
+ - Prevents prompt or label text from implying credential access.
49
+
50
+ ### Dispatches look like CI runs
51
+
52
+ Decision:
53
+
54
+ - `AgentDispatchRun` should appear beside `Pipeline` and `Job` records while exposing Agent Mux chat/session.
55
+
56
+ Rationale:
57
+
58
+ - Users already understand run status, queueing, runner pools, logs, artifacts, and approvals.
59
+
60
+ ### Context bundles are durable and digest-addressed
61
+
62
+ Decision:
63
+
64
+ - Prompt/context assembly produces `AgentContextBundle` with provenance, redaction, limits, and digest.
65
+
66
+ Rationale:
67
+
68
+ - Required for audit, retries, approvals, and prompt safety.
69
+
70
+ ## Open questions before implementation
71
+
72
+ ### Aggregated API backing
73
+
74
+ Question:
75
+
76
+ - Should MVP execution resources be CRD-backed for speed, or immediately served through aggregated API/Postgres?
77
+
78
+ Default recommendation:
79
+
80
+ - Keep config resources CRD-backed; for MVP, execution resources may be represented by lightweight resources if existing infrastructure requires it, but design should not assume etcd for high-volume history.
81
+
82
+ ### Agent Mux deployment mode
83
+
84
+ Question:
85
+
86
+ - Is Agent Mux embedded in Krate controller/web process, sidecar, separate service, or external gateway?
87
+
88
+ Default recommendation:
89
+
90
+ - Treat it as external gateway first. Keep `src/agent-mux-client.js` thin so deployment mode can change.
91
+
92
+ ### Secret materialization boundary
93
+
94
+ Question:
95
+
96
+ - Does Agent Mux receive secret references only, or does a trusted server-side process materialize values before launch?
97
+
98
+ Default recommendation:
99
+
100
+ - Prefer references/projected mounts. If values must be materialized, do it only server-side in controller/runtime, never through browser/API responses.
101
+
102
+ ### First supported base agent
103
+
104
+ Question:
105
+
106
+ - Should the first stack target Claude Code only or support multiple adapters from day one?
107
+
108
+ Default recommendation:
109
+
110
+ - Implement one Claude Code diagnostic stack end-to-end, but keep `AgentStack.spec.baseAgent` and capability handshake generic.
111
+
112
+ ### Repository settings route shape
113
+
114
+ Question:
115
+
116
+ - Add `/orgs/[org]/repositories/[repo]/settings/agents` immediately or embed in existing `/orgs/[org]/repositories/[repo]/settings` first?
117
+
118
+ Default recommendation:
119
+
120
+ - Embed a minimal panel first if route scaffolding cost is high; add sub-route when typed pages are introduced.
121
+
122
+ ### UI component reuse from Agent Mux
123
+
124
+ Question:
125
+
126
+ - Copy, wrap, or depend on Agent Mux web UI primitives?
127
+
128
+ Default recommendation:
129
+
130
+ - Wrap/embed only session/transcript/observability primitives. Rebuild navigation/layout in Krate style.
131
+
132
+ ### Trigger auto-run default
133
+
134
+ Question:
135
+
136
+ - Should labels/comments auto-dispatch by default?
137
+
138
+ Default recommendation:
139
+
140
+ - No. Start with manual dispatch and dry-run trigger previews; make auto-run explicit per repository/rule.
141
+
142
+ ### Write-back scope for MVP
143
+
144
+ Question:
145
+
146
+ - Should MVP allow PR comments or branch pushes?
147
+
148
+ Default recommendation:
149
+
150
+ - No automatic write-back in MVP. Approval-gated comments can be the first write-back slice after run/session binding.
151
+
152
+ ## Questions to revisit after MVP
153
+
154
+ - Multi-tenant namespace strategy for agent resources.
155
+ - Whether subagents are native Agent Mux only or Krate-emulated by default.
156
+ - Whether Agent Mux transcripts are retained in Krate object storage or linked externally.
157
+ - How much of MCP server management belongs in global Agents pages versus repository settings.
158
+ - Whether to add generated OpenAPI schemas for typed agent routes.
159
+ - How to expose cost controls and quotas by team/repository/stack.
160
+
161
+ ## Decision update process
162
+
163
+ When an implementation decision changes:
164
+
165
+ 1. Update this document.
166
+ 2. Update the impacted spec.
167
+ 3. Update `implementation-rollout-slices.md` if sequencing changes.
168
+ 4. Update `acceptance-test-matrix.md` if validation expectations change.
169
+ 5. Reference the decision in PR summary.