@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,358 @@
|
|
|
1
|
+
# Shared memory company brain spec
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Krate should manage repo-based shared agent memory as an org-level company brain. The company brain is an internal Git repository managed by Krate behind the scenes, but still inspectable, exportable, reviewable, and recoverable like any other repository. Agents can read it, query it, cite it in context, and propose updates to it through governed workflows.
|
|
6
|
+
|
|
7
|
+
This is docs-only product scope.
|
|
8
|
+
|
|
9
|
+
## Goals
|
|
10
|
+
|
|
11
|
+
- Make shared agent memory explicit, durable, reviewable, versioned, and auditable.
|
|
12
|
+
- Use Git, Markdown, YAML frontmatter, YAML graph records, and grep-searchable Markdown as the source of truth.
|
|
13
|
+
- Treat the memory repository as a private Atlas-style graph layer, not as an opaque vector store.
|
|
14
|
+
- Let context assembly pin memory to a commit, tag, branch, or timestamp-derived historical ref.
|
|
15
|
+
- Let agents propose memory updates as PRs or patch artifacts by default, not direct writes.
|
|
16
|
+
- Connect memory to repositories, agent stacks, tools, skills, subagents, triggers, CI runs, issues, PRs, and workspaces.
|
|
17
|
+
|
|
18
|
+
## Non-goals
|
|
19
|
+
|
|
20
|
+
- Do not replace repository code, `AGENTS.md`, issue history, PR discussions, CI artifacts, or run transcripts.
|
|
21
|
+
- Do not require every useful note to be promoted into a graph node before it can be searched.
|
|
22
|
+
- Do not let memory records grant tools, secrets, config, approval bypasses, or runner privileges.
|
|
23
|
+
- Do not store raw secrets, private keys, OAuth tokens, kubeconfigs, or unredacted credential material.
|
|
24
|
+
|
|
25
|
+
## Atlas alignment
|
|
26
|
+
|
|
27
|
+
Local Atlas research shows a useful shape for Krate memory:
|
|
28
|
+
|
|
29
|
+
- YAML graph records use `nodeKind`, `id`, `attributes`, and `edges`.
|
|
30
|
+
- Markdown pages can be indexed from YAML frontmatter plus body content.
|
|
31
|
+
- Edge extraction supports object maps and list forms.
|
|
32
|
+
- Context engineering already models `MemoryStore`, `ContextBundle`, memory hierarchy, compaction, and background consolidation.
|
|
33
|
+
- Private overlays are separate from public graph data and can reuse the same graph/index vocabulary with stricter RBAC.
|
|
34
|
+
|
|
35
|
+
Krate should model company brain as an org-private Atlas overlay with Kubernetes/RBAC-backed access control and Git-backed history.
|
|
36
|
+
|
|
37
|
+
## Memory repository layout
|
|
38
|
+
|
|
39
|
+
Recommended default layout:
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
.company-brain/
|
|
43
|
+
README.md
|
|
44
|
+
ontology/
|
|
45
|
+
node-kinds.yaml
|
|
46
|
+
edge-kinds.yaml
|
|
47
|
+
controlled-vocabulary.yaml
|
|
48
|
+
validation-rules.yaml
|
|
49
|
+
graph/
|
|
50
|
+
teams/
|
|
51
|
+
repositories/
|
|
52
|
+
services/
|
|
53
|
+
products/
|
|
54
|
+
runbooks/
|
|
55
|
+
decisions/
|
|
56
|
+
incidents/
|
|
57
|
+
agent-practices/
|
|
58
|
+
pages/
|
|
59
|
+
runbooks/
|
|
60
|
+
decisions/
|
|
61
|
+
incidents/
|
|
62
|
+
repositories/
|
|
63
|
+
agents/
|
|
64
|
+
stacks/
|
|
65
|
+
skills/
|
|
66
|
+
tools/
|
|
67
|
+
subagents/
|
|
68
|
+
notes/
|
|
69
|
+
meetings/
|
|
70
|
+
investigations/
|
|
71
|
+
scratch/
|
|
72
|
+
indexes/
|
|
73
|
+
graph-index.json
|
|
74
|
+
search-manifest.json
|
|
75
|
+
ontology-report.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`graph/` contains canonical typed YAML records. `runbooks/`, `decisions/`, `incidents/`, `repositories/`, and `pages/` contain Markdown records with YAML frontmatter. `notes/` contains free-form Markdown that can be searched with grep and later promoted into canonical records. `indexes/` is generated and reproducible from source files.
|
|
79
|
+
|
|
80
|
+
## Knowledge forms
|
|
81
|
+
|
|
82
|
+
| Form | Source of truth | Use |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| Graph YAML | `graph/**/*.yaml` | typed nodes, edges, ownership, dependencies, repository associations. |
|
|
85
|
+
| Markdown records | `**/*.md` with frontmatter | human-readable knowledge that is also graph-addressable. |
|
|
86
|
+
| Free-form Markdown | `notes/**/*.md`, `meetings/**/*.md`, `scratch/**/*.md` | broad grep search and raw institutional notes. |
|
|
87
|
+
| Ontology YAML | `ontology/**/*.yaml` | node kinds, edge kinds, controlled vocabulary, validation. |
|
|
88
|
+
| Derived indexes | `indexes/**/*` | fast lookup, search manifests, validation summaries; never authoritative. |
|
|
89
|
+
|
|
90
|
+
## Core resources
|
|
91
|
+
|
|
92
|
+
### `AgentMemoryRepository`
|
|
93
|
+
|
|
94
|
+
Declarative config for the org memory Git repository.
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
kind: AgentMemoryRepository
|
|
98
|
+
spec:
|
|
99
|
+
organization: a5c
|
|
100
|
+
visibility: internal
|
|
101
|
+
provider: github
|
|
102
|
+
repositoryRef:
|
|
103
|
+
owner: a5c-ai
|
|
104
|
+
name: company-brain
|
|
105
|
+
defaultBranch: main
|
|
106
|
+
managedByKrate: true
|
|
107
|
+
layoutProfile: atlas-md-yaml-v1
|
|
108
|
+
indexPolicy:
|
|
109
|
+
buildGraphIndex: true
|
|
110
|
+
buildSearchManifest: true
|
|
111
|
+
buildOntologyReport: true
|
|
112
|
+
status:
|
|
113
|
+
phase: Ready
|
|
114
|
+
currentCommit: abcdef1234567890
|
|
115
|
+
indexDigest: sha256:...
|
|
116
|
+
ontologyDigest: sha256:...
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `AgentMemorySource`
|
|
120
|
+
|
|
121
|
+
Read policy for repositories, teams, stacks, triggers, or users.
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
kind: AgentMemorySource
|
|
125
|
+
spec:
|
|
126
|
+
repositoryRef: org-company-brain
|
|
127
|
+
appliesTo:
|
|
128
|
+
repositories: [krate]
|
|
129
|
+
teams: [platform]
|
|
130
|
+
include:
|
|
131
|
+
graphKinds: [Repository, Service, Runbook, Decision, Incident, AgentPractice]
|
|
132
|
+
paths:
|
|
133
|
+
- graph/orgs/[org]/repositories/krate/**
|
|
134
|
+
- runbooks/ci/**
|
|
135
|
+
- decisions/platform/**
|
|
136
|
+
exclude:
|
|
137
|
+
paths:
|
|
138
|
+
- incidents/security/**
|
|
139
|
+
defaultQueryMode: graph-and-grep
|
|
140
|
+
maxContextBytes: 128000
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `AgentMemorySnapshot`
|
|
144
|
+
|
|
145
|
+
Immutable execution-time record of the memory ref and selected material.
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
kind: AgentMemorySnapshot
|
|
149
|
+
spec:
|
|
150
|
+
memoryRepository: org-company-brain
|
|
151
|
+
requestedRef: main
|
|
152
|
+
resolvedCommit: abcdef1234567890
|
|
153
|
+
refResolution:
|
|
154
|
+
mode: current
|
|
155
|
+
queryManifestDigest: sha256:...
|
|
156
|
+
selectedRecordsDigest: sha256:...
|
|
157
|
+
selectedDocumentsDigest: sha256:...
|
|
158
|
+
ontologyDigest: sha256:...
|
|
159
|
+
indexDigest: sha256:...
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### `AgentMemoryQuery`
|
|
163
|
+
|
|
164
|
+
Aggregated query record for graph and grep retrieval.
|
|
165
|
+
|
|
166
|
+
```yaml
|
|
167
|
+
kind: AgentMemoryQuery
|
|
168
|
+
spec:
|
|
169
|
+
snapshotRef: memory-snapshot-01hx
|
|
170
|
+
requester:
|
|
171
|
+
kind: AgentDispatchRun
|
|
172
|
+
name: adr-01hx
|
|
173
|
+
query:
|
|
174
|
+
text: flaky playwright failures in krate pipelines
|
|
175
|
+
modes: [graph, grep]
|
|
176
|
+
graph:
|
|
177
|
+
kinds: [Runbook, Decision, Incident, AgentPractice]
|
|
178
|
+
edgeDepth: 2
|
|
179
|
+
grep:
|
|
180
|
+
paths: [runbooks/**, incidents/**, notes/**]
|
|
181
|
+
maxMatches: 25
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `AgentMemoryUpdate`
|
|
185
|
+
|
|
186
|
+
Reviewable proposed mutation to the memory repository.
|
|
187
|
+
|
|
188
|
+
```yaml
|
|
189
|
+
kind: AgentMemoryUpdate
|
|
190
|
+
spec:
|
|
191
|
+
memoryRepository: org-company-brain
|
|
192
|
+
sourceRun: adr-01hx
|
|
193
|
+
updateKind: proposed-pr
|
|
194
|
+
baseCommit: abcdef1234567890
|
|
195
|
+
branchName: krate/agent-memory/adr-01hx
|
|
196
|
+
changes:
|
|
197
|
+
- path: runbooks/ci/playwright-flake.md
|
|
198
|
+
action: upsert
|
|
199
|
+
reason: Capture verified remediation from dispatch adr-01hx.
|
|
200
|
+
validationPolicy:
|
|
201
|
+
requireOntologyValid: true
|
|
202
|
+
requireFrontmatterValid: true
|
|
203
|
+
requireHumanApproval: true
|
|
204
|
+
status:
|
|
205
|
+
phase: AwaitingApproval
|
|
206
|
+
diffDigest: sha256:...
|
|
207
|
+
pullRequestRef: a5c-ai/company-brain/123
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### `AgentMemoryOntology`
|
|
211
|
+
|
|
212
|
+
Pointer to ontology policy and validation status.
|
|
213
|
+
|
|
214
|
+
```yaml
|
|
215
|
+
kind: AgentMemoryOntology
|
|
216
|
+
spec:
|
|
217
|
+
memoryRepository: org-company-brain
|
|
218
|
+
ontologyPath: ontology
|
|
219
|
+
requiredFields: [id, kind, title, owners, status]
|
|
220
|
+
allowedEdgeKindsRef: ontology/edge-kinds.yaml
|
|
221
|
+
controlledVocabularyRef: ontology/controlled-vocabulary.yaml
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### `AgentMemoryAssociation`
|
|
225
|
+
|
|
226
|
+
Bridge between memory records and Krate resources.
|
|
227
|
+
|
|
228
|
+
```yaml
|
|
229
|
+
kind: AgentMemoryAssociation
|
|
230
|
+
spec:
|
|
231
|
+
memoryRepository: org-company-brain
|
|
232
|
+
memoryRef:
|
|
233
|
+
id: runbook:ci-playwright-flake
|
|
234
|
+
path: runbooks/ci/playwright-flake.md
|
|
235
|
+
targetRef:
|
|
236
|
+
kind: Repository
|
|
237
|
+
name: krate
|
|
238
|
+
relationship: applies_to_repo
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Git-backed versioning
|
|
242
|
+
|
|
243
|
+
- Every memory read resolves to a commit SHA before context assembly.
|
|
244
|
+
- The default branch represents current approved memory.
|
|
245
|
+
- Dispatch snapshots store requested ref, resolved commit, ontology digest, index digest, query manifest, selected records, and selected excerpts.
|
|
246
|
+
- Time-travel memory resolves by finding the latest approved commit at or before the requested timestamp.
|
|
247
|
+
- Retrying a run uses the original memory snapshot unless the user explicitly refreshes memory.
|
|
248
|
+
- Updating memory from a historical run targets current `main` unless policy explicitly allows a different branch.
|
|
249
|
+
|
|
250
|
+
## Time-travel examples
|
|
251
|
+
|
|
252
|
+
Current memory:
|
|
253
|
+
|
|
254
|
+
```yaml
|
|
255
|
+
memory:
|
|
256
|
+
repositoryRef: org-company-brain
|
|
257
|
+
ref: main
|
|
258
|
+
queryMode: graph-and-grep
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Memory from two days ago:
|
|
262
|
+
|
|
263
|
+
```yaml
|
|
264
|
+
memory:
|
|
265
|
+
repositoryRef: org-company-brain
|
|
266
|
+
refAt: 2026-05-08T00:00:00Z
|
|
267
|
+
resolutionPolicy: latest-commit-before-or-at
|
|
268
|
+
queryMode: graph-and-grep
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Named snapshot:
|
|
272
|
+
|
|
273
|
+
```yaml
|
|
274
|
+
memory:
|
|
275
|
+
repositoryRef: org-company-brain
|
|
276
|
+
ref: refs/tags/memory/snapshots/2026-05-08T000000Z
|
|
277
|
+
queryMode: graph-only
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Required user flows
|
|
281
|
+
|
|
282
|
+
- Configure or adopt an org-level memory repository from `/agents/memory`.
|
|
283
|
+
- Associate memory paths and graph kinds with a repository from `/orgs/[org]/repositories/[repo]/settings/agents`.
|
|
284
|
+
- Preview selected memory records and grep excerpts in the dispatch composer.
|
|
285
|
+
- Run an agent with current memory, explicit ref, snapshot tag, or memory from a timestamp.
|
|
286
|
+
- Open run detail and inspect memory commit, query manifest, selected records, excerpts, redaction status, and stale-memory warning.
|
|
287
|
+
- Let an agent propose a memory update from a run and route it through validation plus PR review.
|
|
288
|
+
- Browse graph records and grep-search free-form docs from `/agents/memory` subject to permissions.
|
|
289
|
+
|
|
290
|
+
## Acceptance criteria
|
|
291
|
+
|
|
292
|
+
- Repository dispatch can include graph records and grep excerpts from allowed memory paths with visible provenance.
|
|
293
|
+
- Historical memory dispatches are commit-pinned and never silently refresh on retry.
|
|
294
|
+
- Agents can propose memory updates as reviewable PRs with ontology validation.
|
|
295
|
+
- UI warns when a stack, tool, or skill needs memory permissions it does not have.
|
|
296
|
+
- Past runs remain explainable even after the memory repository changes.
|
|
297
|
+
|
|
298
|
+
## Babysitter run memory artifacts
|
|
299
|
+
|
|
300
|
+
The company brain must also support durable Babysitter run memory for org-scoped orchestration. Krate should treat Babysitter's `MEMORY.md`, session summaries, journals, task results, and selected `.a5c` run artifacts as first-class memory sources when they are admitted into the org memory repository.
|
|
301
|
+
|
|
302
|
+
Recommended layout:
|
|
303
|
+
|
|
304
|
+
```text
|
|
305
|
+
.company-brain/
|
|
306
|
+
babysitter/
|
|
307
|
+
MEMORY.md
|
|
308
|
+
sessions/
|
|
309
|
+
2026/05/10/<session-id>.md
|
|
310
|
+
runs/
|
|
311
|
+
<run-id>/
|
|
312
|
+
run.yaml
|
|
313
|
+
journal/
|
|
314
|
+
000001.yaml
|
|
315
|
+
tasks/
|
|
316
|
+
<task-id>.yaml
|
|
317
|
+
artifacts/
|
|
318
|
+
manifest.yaml
|
|
319
|
+
retrospectives/
|
|
320
|
+
process-notes/
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Requirements:
|
|
324
|
+
|
|
325
|
+
- `MEMORY.md` is the org-level agent memory entrypoint for orchestration conventions, stable lessons, and runbooks.
|
|
326
|
+
- Raw `.a5c` files are not copied wholesale by default; Krate imports curated manifests, journals, session summaries, task results, and artifact digests according to retention and sensitivity policy.
|
|
327
|
+
- Run journals preserve event order, task IDs, source repository, agent stack, session IDs, artifacts, and final status.
|
|
328
|
+
- Session summaries and retrospectives can be promoted into canonical graph or Markdown memory records.
|
|
329
|
+
- Imported run memory is org-scoped and cannot be queried by agents in another org.
|
|
330
|
+
- Secret scans and prompt-injection checks run before `.a5c` artifacts become searchable memory.
|
|
331
|
+
|
|
332
|
+
### Babysitter memory resources
|
|
333
|
+
|
|
334
|
+
```yaml
|
|
335
|
+
kind: AgentRunMemoryImport
|
|
336
|
+
spec:
|
|
337
|
+
organizationRef: a5c
|
|
338
|
+
memoryRepository: org-company-brain
|
|
339
|
+
source:
|
|
340
|
+
kind: babysitter-run
|
|
341
|
+
a5cRunPath: .a5c/runs/01KR...
|
|
342
|
+
include:
|
|
343
|
+
memoryMd: true
|
|
344
|
+
sessionSummary: true
|
|
345
|
+
journal: curated
|
|
346
|
+
taskResults: true
|
|
347
|
+
artifactManifests: true
|
|
348
|
+
targetPath: babysitter/runs/01KR...
|
|
349
|
+
validationPolicy:
|
|
350
|
+
redactSecrets: true
|
|
351
|
+
requireReview: true
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
The memory repo stores durable knowledge and replayable context, not arbitrary private workspace dumps.
|
|
355
|
+
|
|
356
|
+
## Run memory import boundary
|
|
357
|
+
|
|
358
|
+
`AgentRunMemoryImport` is the only supported path for moving Babysitter operational state into the company brain. The import controller normalizes and redacts `MEMORY.md`, sessions, `.a5c` journals, task outputs, and artifact manifests before proposing changes to the org memory repo. Direct writes from a runner workspace into the memory repo are not allowed unless an org policy explicitly grants a trusted maintenance workflow.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Agent storage and migration spec
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This document defines how agent resources should be stored, indexed, migrated, and retained. It follows the current Krate split in `src/resource-model.js`: declarative configuration resources live in etcd/CRDs, while high-cardinality forge activity is served by the aggregated API/Postgres boundary.
|
|
6
|
+
|
|
7
|
+
## Storage classes
|
|
8
|
+
|
|
9
|
+
| Class | Resources | Backing store | Reason |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| Declarative config | stacks, tools, MCP servers, skills, triggers, context labels, ServiceAccounts, role bindings, grants | CRDs/etcd | GitOps-friendly, low-cardinality, reviewable. |
|
|
12
|
+
| Execution metadata | dispatch runs, attempts, sessions, workspaces, approvals, trigger executions, capability requirements | aggregated API/Postgres | high-cardinality, frequently updated, query-heavy. |
|
|
13
|
+
| Blob/artifact data | context bundles, logs, patches, transcripts, subagent outputs, review artifacts | object storage + metadata in Postgres | potentially large, immutable or append-heavy. |
|
|
14
|
+
| Native Kubernetes objects | ServiceAccounts, Roles, RoleBindings, Secrets, ConfigMaps | Kubernetes API | authoritative enforcement objects. |
|
|
15
|
+
| External runtime state | Agent Mux sessions/runs/events | Agent Mux storage/gateway | adapter-specific execution details. |
|
|
16
|
+
|
|
17
|
+
## Resource lifecycle
|
|
18
|
+
|
|
19
|
+
### Config resources
|
|
20
|
+
|
|
21
|
+
- Created through generic controller resources API or typed agent routes.
|
|
22
|
+
- Reconciled into status by controllers.
|
|
23
|
+
- Can be managed by GitOps through Helm/Argo CD.
|
|
24
|
+
- Should use `metadata.generation` and `status.observedGeneration`.
|
|
25
|
+
- Deleting a config resource must show dependent stacks/rules/runs before finalization.
|
|
26
|
+
|
|
27
|
+
### Execution resources
|
|
28
|
+
|
|
29
|
+
- Created by controllers or admitted API actions, not by GitOps by default.
|
|
30
|
+
- Must keep source breadcrumbs and immutable snapshots.
|
|
31
|
+
- Status updates are frequent and should not be CRD-heavy if volume grows.
|
|
32
|
+
- Retention policies should prune or archive old execution records while preserving audit summaries.
|
|
33
|
+
|
|
34
|
+
### Artifact resources
|
|
35
|
+
|
|
36
|
+
- Metadata stored in `AgentArtifact`, `AgentContextBundle`, or `AgentReviewArtifact`.
|
|
37
|
+
- Bytes stored in object storage.
|
|
38
|
+
- Digest and retention metadata are mandatory.
|
|
39
|
+
- Secret values and raw credentials are never stored as artifacts.
|
|
40
|
+
|
|
41
|
+
## Postgres tables for aggregated resources
|
|
42
|
+
|
|
43
|
+
Suggested logical tables:
|
|
44
|
+
|
|
45
|
+
| Table | Primary key | Important indexes |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| `agent_dispatch_runs` | `uid` | repository, status, stack, trigger, source kind/name, branch, created_at |
|
|
48
|
+
| `agent_dispatch_attempts` | `uid` | dispatch_run_uid, phase, agent_mux_run_id, agent_mux_session_id |
|
|
49
|
+
| `agent_sessions` | `uid` | agent_mux_session_id, dispatch_run_uid, workspace_uid |
|
|
50
|
+
| `agent_workspaces` | `uid` | repository, workspace_path, branch, status, ownership kind/name |
|
|
51
|
+
| `agent_approvals` | `uid` | dispatch_run_uid, phase, action_type, requested_by, approver |
|
|
52
|
+
| `agent_trigger_executions` | `uid` | trigger_rule, source_event_uid, dedupe_key, decision, created_at |
|
|
53
|
+
| `agent_capability_requirements` | `uid` | owner kind/name, stack, missing grant kind |
|
|
54
|
+
| `agent_artifacts` | `uid` | dispatch_run_uid, kind, digest, created_at |
|
|
55
|
+
| `agent_context_bundles` | `uid` | digest, dispatch_run_uid, source digest |
|
|
56
|
+
| `work_item_session_links` | `uid` | work_item_ref, agent_session_uid |
|
|
57
|
+
| `work_item_workspace_links` | `uid` | work_item_ref, workspace_uid |
|
|
58
|
+
|
|
59
|
+
## Immutable snapshots
|
|
60
|
+
|
|
61
|
+
Every `AgentDispatchAttempt` must snapshot:
|
|
62
|
+
|
|
63
|
+
- stack name and generation;
|
|
64
|
+
- expanded tool/MCP/skill/subagent refs;
|
|
65
|
+
- prompt/context labels and rendered prompt digest;
|
|
66
|
+
- context bundle digest and source manifest;
|
|
67
|
+
- permission review digest;
|
|
68
|
+
- runtime ServiceAccount and runner ServiceAccount;
|
|
69
|
+
- Secret/ConfigMap grant names, key names, and metadata versions;
|
|
70
|
+
- runner pool and workspace policy;
|
|
71
|
+
- Agent Mux launch options after redaction.
|
|
72
|
+
|
|
73
|
+
Snapshots protect retries from silently changing due to later stack or secret edits. Retry/resume may intentionally create a new snapshot.
|
|
74
|
+
|
|
75
|
+
## Retention policy
|
|
76
|
+
|
|
77
|
+
Default retention knobs should be chart values later:
|
|
78
|
+
|
|
79
|
+
| Data | Default | Notes |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| dispatch runs | 90 days | keep longer summaries for audit. |
|
|
82
|
+
| attempts/events | 90 days | compact old event streams into summaries. |
|
|
83
|
+
| transcripts | 30 days | configurable by repository/org. |
|
|
84
|
+
| context bundles | 30 days | shorter for large/log-heavy bundles. |
|
|
85
|
+
| patch/review artifacts | 180 days | linked to PR lifecycle. |
|
|
86
|
+
| approvals/audit summaries | 1 year | no secret values. |
|
|
87
|
+
| workspaces | policy-driven | cleanup after merge/close unless pinned. |
|
|
88
|
+
|
|
89
|
+
## Migration plan
|
|
90
|
+
|
|
91
|
+
### Phase 1: resource definitions
|
|
92
|
+
|
|
93
|
+
- Add agent kinds to `src/resource-model.js`.
|
|
94
|
+
- Add `KRATE_RESOURCES` entries in `src/kubernetes-controller.js`.
|
|
95
|
+
- Add CRDs under `charts/krate/crds/`.
|
|
96
|
+
- Validate generic list/apply/watch still works.
|
|
97
|
+
|
|
98
|
+
### Phase 2: aggregated schema
|
|
99
|
+
|
|
100
|
+
- Add tables for dispatches, attempts, approvals, workspaces, trigger executions, artifacts, and links.
|
|
101
|
+
- Backfill no data; first version starts empty.
|
|
102
|
+
- Ensure every table has repository/source/status/time indexes.
|
|
103
|
+
|
|
104
|
+
### Phase 3: snapshots and artifacts
|
|
105
|
+
|
|
106
|
+
- Add immutable context/permission snapshot metadata.
|
|
107
|
+
- Add object-storage references and digest validation.
|
|
108
|
+
- Add retention jobs but keep deletion disabled by default in dev/demo.
|
|
109
|
+
|
|
110
|
+
### Phase 4: migration hardening
|
|
111
|
+
|
|
112
|
+
- Add schema version resource or table.
|
|
113
|
+
- Migrations must be idempotent.
|
|
114
|
+
- Failed migrations block controller start but keep web read-only where possible.
|
|
115
|
+
|
|
116
|
+
## Consistency model
|
|
117
|
+
|
|
118
|
+
- Config resources are eventually reconciled into readiness conditions.
|
|
119
|
+
- Dispatch creation requires current permission review and stack status, but final launch uses immutable attempt snapshot.
|
|
120
|
+
- Agent Mux session state may lag; Krate run status should expose `AgentMuxSessionBound` and stream cursor.
|
|
121
|
+
- Watch reconnect should resume from current list state if event cursor is unavailable.
|
|
122
|
+
|
|
123
|
+
## Query requirements for UI
|
|
124
|
+
|
|
125
|
+
The storage layer must support:
|
|
126
|
+
|
|
127
|
+
- repository-scoped run list;
|
|
128
|
+
- source PR/issue/pipeline run list;
|
|
129
|
+
- global pending approvals;
|
|
130
|
+
- missing permission warnings by stack and repository;
|
|
131
|
+
- active sessions by workspace;
|
|
132
|
+
- Secret/ConfigMap consumer graph;
|
|
133
|
+
- trigger execution history and coalescing decisions;
|
|
134
|
+
- stale/drifted ServiceAccount/RoleBinding/grant summaries.
|
|
135
|
+
|
|
136
|
+
## Company brain storage class
|
|
137
|
+
|
|
138
|
+
The company brain uses Git as the source of truth and Krate resources as the control plane.
|
|
139
|
+
|
|
140
|
+
| Data | Backing store | Notes |
|
|
141
|
+
| --- | --- | --- |
|
|
142
|
+
| memory source files | internal Git repository | Markdown, YAML frontmatter, graph YAML, ontology YAML. |
|
|
143
|
+
| generated indexes | Git, object storage, or controller cache | reproducible from source commit. |
|
|
144
|
+
| memory config | CRDs/etcd | repository, source policy, ontology, associations. |
|
|
145
|
+
| memory snapshots and queries | Postgres/object storage | high-cardinality run-bound records and selected excerpts. |
|
|
146
|
+
| memory update artifacts | object storage + memory repo PR | proposed patches, validation reports, approvals. |
|
|
147
|
+
|
|
148
|
+
Dispatch snapshots must store the resolved memory commit so future retries and audits do not depend on mutable branch state.
|
|
149
|
+
|
|
150
|
+
## Babysitter memory storage
|
|
151
|
+
|
|
152
|
+
`.a5c` directories remain run-local operational state. The company brain stores admitted org memory derived from them:
|
|
153
|
+
|
|
154
|
+
| Source | Stored in memory repo | Notes |
|
|
155
|
+
| --- | --- | --- |
|
|
156
|
+
| `MEMORY.md` | `babysitter/MEMORY.md` | org-level orchestration entrypoint. |
|
|
157
|
+
| `.a5c/runs/*/run.json` | `babysitter/runs/<run>/run.yaml` | normalized metadata, org, repo, process, status. |
|
|
158
|
+
| `.a5c/runs/*/journal/*.json` | `babysitter/runs/<run>/journal/*.yaml` | curated/redacted ordered events. |
|
|
159
|
+
| `.a5c/runs/*/tasks/*/result.json` | `babysitter/runs/<run>/tasks/*.yaml` | task result summary and evidence refs. |
|
|
160
|
+
| `.a5c/artifacts/*` | artifact manifest/digest only by default | raw artifacts require explicit retention policy. |
|
|
161
|
+
|
|
162
|
+
Imports must preserve source digests and never mutate historical dispatch snapshots.
|
|
163
|
+
|
|
164
|
+
## Org-scoped backup and restore
|
|
165
|
+
|
|
166
|
+
Org backup must include declarative resources from the org namespace, aggregated API rows filtered by org, repository storage, deployment metadata, object artifacts, and the org company brain memory repository. Restore order is namespace and org binding first, then config resources, repositories, memory repo, Postgres rows, object artifacts, controllers, and finally watch/index rebuild.
|
|
167
|
+
|
|
168
|
+
`AgentMemorySnapshot` records must remain readable even if the current company brain repository has moved; snapshots store resolved commit and selected digests for this reason.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Agent subagent orchestration spec
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Krate should support parent agents that delegate to subagents for research, implementation, validation, review, and release checks. Subagents must be visible, policy-admitted, auditable, and linked to parent dispatch attempts.
|
|
6
|
+
|
|
7
|
+
## Model
|
|
8
|
+
|
|
9
|
+
`AgentSubagent` defines a reusable child-agent role. A parent `AgentStack` references subagents and sets concurrency/permission boundaries.
|
|
10
|
+
|
|
11
|
+
Subagents may run in two modes:
|
|
12
|
+
|
|
13
|
+
| Mode | Description | Owner |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| native Agent Mux subagent | adapter supports child-agent dispatch inside one session | Agent Mux executes; Krate projects telemetry |
|
|
16
|
+
| Krate-emulated child attempt | Krate creates child `AgentDispatchAttempt` or linked run | Krate schedules and links child execution |
|
|
17
|
+
|
|
18
|
+
Krate chooses mode based on adapter capabilities and stack policy.
|
|
19
|
+
|
|
20
|
+
## `AgentSubagent` fields
|
|
21
|
+
|
|
22
|
+
Important fields:
|
|
23
|
+
|
|
24
|
+
- `spec.name`;
|
|
25
|
+
- `spec.description`;
|
|
26
|
+
- `spec.rolePrompt`;
|
|
27
|
+
- `spec.taskKinds`;
|
|
28
|
+
- `spec.modelOverride`;
|
|
29
|
+
- `spec.toolRefs`;
|
|
30
|
+
- `spec.mcpServerRefs`;
|
|
31
|
+
- `spec.skillRefs`;
|
|
32
|
+
- `spec.runtimeIdentityOverride`;
|
|
33
|
+
- `spec.workspaceScope`: no-workspace, read-only, branch-local, isolated-worktree;
|
|
34
|
+
- `spec.maxParallelTasks`;
|
|
35
|
+
- `spec.contextPolicy`;
|
|
36
|
+
- `spec.outputContract`;
|
|
37
|
+
- `spec.approvalPolicy`.
|
|
38
|
+
|
|
39
|
+
## Context slicing
|
|
40
|
+
|
|
41
|
+
Subagents should not automatically receive full parent context.
|
|
42
|
+
|
|
43
|
+
Context policies:
|
|
44
|
+
|
|
45
|
+
- `summary-only`: parent sends task summary and source breadcrumbs;
|
|
46
|
+
- `selected-sources`: parent sends selected files/logs/artifacts;
|
|
47
|
+
- `full-redacted`: parent sends full redacted context bundle;
|
|
48
|
+
- `artifact-only`: parent sends specific artifacts;
|
|
49
|
+
- `no-context`: parent sends only role prompt and task.
|
|
50
|
+
|
|
51
|
+
Every child context slice gets a digest and provenance entry.
|
|
52
|
+
|
|
53
|
+
## Output contracts
|
|
54
|
+
|
|
55
|
+
Common contracts:
|
|
56
|
+
|
|
57
|
+
- markdown summary;
|
|
58
|
+
- checklist;
|
|
59
|
+
- JSON finding list;
|
|
60
|
+
- patch artifact;
|
|
61
|
+
- review comments;
|
|
62
|
+
- test report;
|
|
63
|
+
- release readiness report;
|
|
64
|
+
- risk assessment.
|
|
65
|
+
|
|
66
|
+
The parent run should record whether each subagent fulfilled its contract.
|
|
67
|
+
|
|
68
|
+
## Telemetry projection
|
|
69
|
+
|
|
70
|
+
Run detail should show a subagent tree/lane view with:
|
|
71
|
+
|
|
72
|
+
- subagent name and role;
|
|
73
|
+
- mode: native or Krate-emulated;
|
|
74
|
+
- status;
|
|
75
|
+
- context slice digest;
|
|
76
|
+
- tools/MCP/skills enabled;
|
|
77
|
+
- workspace scope;
|
|
78
|
+
- started/completed timestamps;
|
|
79
|
+
- output artifact links;
|
|
80
|
+
- parent decision impact.
|
|
81
|
+
|
|
82
|
+
## Permission model
|
|
83
|
+
|
|
84
|
+
Subagents inherit the parent stack by default but can only reduce permissions unless policy explicitly allows override.
|
|
85
|
+
|
|
86
|
+
Rules:
|
|
87
|
+
|
|
88
|
+
- tool set must be subset of parent admitted tools unless override is approved;
|
|
89
|
+
- Secret/ConfigMap grants must match child subject or parent stack policy;
|
|
90
|
+
- runtime ServiceAccount override requires `AgentRoleBinding` and permission review;
|
|
91
|
+
- untrusted source remains untrusted for every child;
|
|
92
|
+
- subagent output cannot directly write back without parent/approval gate.
|
|
93
|
+
|
|
94
|
+
## Scheduling and concurrency
|
|
95
|
+
|
|
96
|
+
Concurrency limits:
|
|
97
|
+
|
|
98
|
+
- per parent run;
|
|
99
|
+
- per subagent definition;
|
|
100
|
+
- per stack;
|
|
101
|
+
- per runner pool;
|
|
102
|
+
- per repository.
|
|
103
|
+
|
|
104
|
+
When limits are reached, child work is queued and visible in the subagent tree.
|
|
105
|
+
|
|
106
|
+
## Failure behavior
|
|
107
|
+
|
|
108
|
+
| Failure | Parent behavior |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| subagent unavailable | parent continues only if subagent optional; otherwise blocked/failed |
|
|
111
|
+
| output contract invalid | parent sees failed child and artifact validation error |
|
|
112
|
+
| child permission denied | parent gets permission warning and suggested fix |
|
|
113
|
+
| child timeout | parent can retry child or continue with partial results |
|
|
114
|
+
| child produces unsafe write-back | converted to `AgentApproval`, never auto-applied |
|
|
115
|
+
|
|
116
|
+
## UI flows
|
|
117
|
+
|
|
118
|
+
### Stack builder
|
|
119
|
+
|
|
120
|
+
- add/remove subagents;
|
|
121
|
+
- select task kinds;
|
|
122
|
+
- choose context policy;
|
|
123
|
+
- select tool/MCP/skill subset;
|
|
124
|
+
- show adapter support;
|
|
125
|
+
- show permission review for each child.
|
|
126
|
+
|
|
127
|
+
### Run detail
|
|
128
|
+
|
|
129
|
+
- show parent timeline and child lanes;
|
|
130
|
+
- allow expanding each child transcript/summary;
|
|
131
|
+
- show artifacts per child;
|
|
132
|
+
- show child failures with retry/ignore controls when supported.
|
|
133
|
+
|
|
134
|
+
## Audit requirements
|
|
135
|
+
|
|
136
|
+
Audit records must include:
|
|
137
|
+
|
|
138
|
+
- parent dispatch run and attempt;
|
|
139
|
+
- subagent definition generation;
|
|
140
|
+
- context slice digest;
|
|
141
|
+
- runtime identity;
|
|
142
|
+
- tools/MCP/skills/secrets/configs admitted;
|
|
143
|
+
- output artifact digest;
|
|
144
|
+
- parent decision that consumed child output.
|
|
145
|
+
|
|
146
|
+
## Acceptance criteria
|
|
147
|
+
|
|
148
|
+
- Parent run shows which subagents were invoked and why.
|
|
149
|
+
- Subagents cannot silently receive broader permissions than parent.
|
|
150
|
+
- Each child context slice and output artifact is digest-addressed.
|
|
151
|
+
- Failed or partial child work is visible in run detail.
|
|
152
|
+
- Native Agent Mux subagents and Krate-emulated child attempts project into the same UI model.
|