@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,333 @@
|
|
|
1
|
+
# Org memory API payload examples
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This document provides implementation-ready request and response examples for the org-scoped company brain memory vertical slice. The examples are intentionally explicit about org, namespace, commit, digest, redaction, and validation fields so API, UI, controller, and test work can share the same contract.
|
|
6
|
+
|
|
7
|
+
## `GET /api/orgs/[org]/agents/summary`
|
|
8
|
+
|
|
9
|
+
Response:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"organization": "a5c",
|
|
14
|
+
"namespace": "krate-org-a5c",
|
|
15
|
+
"agents": {
|
|
16
|
+
"dispatchRuns": { "running": 2, "failed": 1, "succeeded24h": 12 },
|
|
17
|
+
"approvals": { "pending": 3 },
|
|
18
|
+
"blockedStacks": 1
|
|
19
|
+
},
|
|
20
|
+
"memory": {
|
|
21
|
+
"repository": "org-company-brain",
|
|
22
|
+
"phase": "Ready",
|
|
23
|
+
"currentCommit": "abcdef1234567890",
|
|
24
|
+
"ontologyDigest": "sha256:ontology",
|
|
25
|
+
"indexDigest": "sha256:index",
|
|
26
|
+
"importsAwaitingReview": 2,
|
|
27
|
+
"updatesAwaitingReview": 1,
|
|
28
|
+
"lastIndexedAt": "2026-05-11T08:00:00Z"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## `POST /api/orgs/[org]/agents/memory/resolve-ref`
|
|
34
|
+
|
|
35
|
+
Request for current memory:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"memoryRepository": "org-company-brain",
|
|
40
|
+
"mode": "current",
|
|
41
|
+
"requested": "main"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Request for memory at a timestamp:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"memoryRepository": "org-company-brain",
|
|
50
|
+
"mode": "ref-at-time",
|
|
51
|
+
"requestedAt": "2026-05-09T08:00:00Z",
|
|
52
|
+
"resolutionPolicy": "latest-commit-before-or-at",
|
|
53
|
+
"requireApprovedCommit": true
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Response:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"organization": "a5c",
|
|
62
|
+
"memoryRepository": "org-company-brain",
|
|
63
|
+
"mode": "ref-at-time",
|
|
64
|
+
"requestedAt": "2026-05-09T08:00:00Z",
|
|
65
|
+
"resolvedCommit": "13579bdf2468",
|
|
66
|
+
"resolvedRef": "refs/heads/main",
|
|
67
|
+
"currentCommit": "abcdef1234567890",
|
|
68
|
+
"staleBySeconds": 172800,
|
|
69
|
+
"ontologyDigest": "sha256:ontology-at-commit",
|
|
70
|
+
"indexDigest": "sha256:index-at-commit",
|
|
71
|
+
"conditions": [
|
|
72
|
+
{ "type": "Resolved", "status": "True", "reason": "CommitFound" }
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## `POST /api/orgs/[org]/agents/memory/query`
|
|
78
|
+
|
|
79
|
+
Request:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"memoryRepository": "org-company-brain",
|
|
84
|
+
"requestedRef": "main",
|
|
85
|
+
"resolvedCommit": "abcdef1234567890",
|
|
86
|
+
"query": {
|
|
87
|
+
"text": "playwright flaky checks in krate",
|
|
88
|
+
"modes": ["graph", "grep"],
|
|
89
|
+
"graph": {
|
|
90
|
+
"kinds": ["Runbook", "Decision", "Incident", "AgentPractice", "BabysitterRun"],
|
|
91
|
+
"edgeDepth": 2
|
|
92
|
+
},
|
|
93
|
+
"grep": {
|
|
94
|
+
"paths": ["runbooks/**", "babysitter/runs/**", "babysitter/retrospectives/**"],
|
|
95
|
+
"maxMatches": 25,
|
|
96
|
+
"includeLineContext": true
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"limits": {
|
|
100
|
+
"maxBytes": 64000,
|
|
101
|
+
"maxRecords": 40
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Response:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"organization": "a5c",
|
|
111
|
+
"snapshotPreview": {
|
|
112
|
+
"memoryRepository": "org-company-brain",
|
|
113
|
+
"resolvedCommit": "abcdef1234567890",
|
|
114
|
+
"queryManifestDigest": "sha256:query",
|
|
115
|
+
"selectedRecordsDigest": "sha256:records",
|
|
116
|
+
"selectedExcerptsDigest": "sha256:excerpts"
|
|
117
|
+
},
|
|
118
|
+
"records": [
|
|
119
|
+
{
|
|
120
|
+
"kind": "Runbook",
|
|
121
|
+
"id": "runbook:ci-playwright-flake",
|
|
122
|
+
"path": "runbooks/ci/playwright-flake.md",
|
|
123
|
+
"title": "Playwright flake triage",
|
|
124
|
+
"owners": ["team:platform"],
|
|
125
|
+
"digest": "sha256:record"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"excerpts": [
|
|
129
|
+
{
|
|
130
|
+
"path": "babysitter/retrospectives/01KR1Z.md",
|
|
131
|
+
"lineStart": 18,
|
|
132
|
+
"lineEnd": 24,
|
|
133
|
+
"text": "Redacted bounded excerpt suitable for prompt preview.",
|
|
134
|
+
"digest": "sha256:excerpt"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
"redaction": { "status": "redacted", "secretPatternCount": 0 },
|
|
138
|
+
"limits": { "truncated": false, "bytes": 18340 }
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## `POST /api/orgs/[org]/agents/dispatch`
|
|
143
|
+
|
|
144
|
+
Request:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"repository": "krate",
|
|
149
|
+
"ref": "refs/heads/main",
|
|
150
|
+
"source": {
|
|
151
|
+
"kind": "manual-code-dispatch",
|
|
152
|
+
"path": "docs/agents"
|
|
153
|
+
},
|
|
154
|
+
"agentStack": "claude-code-ci-repair",
|
|
155
|
+
"task": {
|
|
156
|
+
"kind": "docs-update",
|
|
157
|
+
"prompt": "Improve the agent memory docs."
|
|
158
|
+
},
|
|
159
|
+
"memory": {
|
|
160
|
+
"repositoryRef": "org-company-brain",
|
|
161
|
+
"requestedRef": "main",
|
|
162
|
+
"queryMode": "graph-and-grep",
|
|
163
|
+
"queryText": "krate agent memory docs"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Response:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"organization": "a5c",
|
|
173
|
+
"dispatchRun": "adr-01hx",
|
|
174
|
+
"attempt": "ada-01hx-1",
|
|
175
|
+
"contextBundle": "acb-01hx",
|
|
176
|
+
"memorySnapshot": "ams-01hx",
|
|
177
|
+
"phase": "Queued",
|
|
178
|
+
"links": {
|
|
179
|
+
"runDetail": "/orgs/a5c/agents/runs/adr-01hx",
|
|
180
|
+
"repositoryRuns": "/orgs/a5c/repositories/krate/runs"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## `GET /api/orgs/[org]/agents/runs/[run]`
|
|
186
|
+
|
|
187
|
+
Response excerpt:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"organization": "a5c",
|
|
192
|
+
"run": {
|
|
193
|
+
"name": "adr-01hx",
|
|
194
|
+
"phase": "Running",
|
|
195
|
+
"repository": "krate",
|
|
196
|
+
"agentStack": "claude-code-ci-repair"
|
|
197
|
+
},
|
|
198
|
+
"attempts": [
|
|
199
|
+
{ "name": "ada-01hx-1", "phase": "Running", "agentMuxSessionId": "mux-session-123" }
|
|
200
|
+
],
|
|
201
|
+
"contextBundle": {
|
|
202
|
+
"name": "acb-01hx",
|
|
203
|
+
"digest": "sha256:context",
|
|
204
|
+
"memorySnapshot": "ams-01hx"
|
|
205
|
+
},
|
|
206
|
+
"memorySnapshot": {
|
|
207
|
+
"name": "ams-01hx",
|
|
208
|
+
"memoryRepository": "org-company-brain",
|
|
209
|
+
"requestedRef": "main",
|
|
210
|
+
"resolvedCommit": "abcdef1234567890",
|
|
211
|
+
"queryManifestDigest": "sha256:query",
|
|
212
|
+
"selectedRecordsDigest": "sha256:records",
|
|
213
|
+
"selectedExcerptsDigest": "sha256:excerpts"
|
|
214
|
+
},
|
|
215
|
+
"artifacts": []
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## `POST /api/orgs/[org]/agents/memory/import-babysitter-run`
|
|
220
|
+
|
|
221
|
+
Request:
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"source": {
|
|
226
|
+
"kind": "babysitter-run",
|
|
227
|
+
"repository": "krate",
|
|
228
|
+
"runId": "01KR1ZCPQVVPJAJDNBQHGPWZZY",
|
|
229
|
+
"sessionId": "019e-example",
|
|
230
|
+
"a5cRunPath": ".a5c/runs/01KR1ZCPQVVPJAJDNBQHGPWZZY"
|
|
231
|
+
},
|
|
232
|
+
"memoryRepository": "org-company-brain",
|
|
233
|
+
"retentionTier": "summary-only",
|
|
234
|
+
"include": {
|
|
235
|
+
"memoryMd": true,
|
|
236
|
+
"sessionSummary": true,
|
|
237
|
+
"journal": "none",
|
|
238
|
+
"taskResults": "summarized",
|
|
239
|
+
"artifactManifests": "digest-only",
|
|
240
|
+
"retrospectives": true
|
|
241
|
+
},
|
|
242
|
+
"targetPath": "babysitter/runs/01KR1ZCPQVVPJAJDNBQHGPWZZY",
|
|
243
|
+
"validationPolicy": {
|
|
244
|
+
"redactSecrets": true,
|
|
245
|
+
"detectPromptInjection": true,
|
|
246
|
+
"requireReview": true
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Response:
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"organization": "a5c",
|
|
256
|
+
"import": "import-01kr1z",
|
|
257
|
+
"phase": "Collecting",
|
|
258
|
+
"sourceDigest": "sha256:source",
|
|
259
|
+
"retentionTier": "summary-only",
|
|
260
|
+
"links": {
|
|
261
|
+
"detail": "/orgs/a5c/agents/memory/imports/import-01kr1z"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## `GET /api/orgs/[org]/agents/memory/imports/[import]`
|
|
267
|
+
|
|
268
|
+
Response excerpt:
|
|
269
|
+
|
|
270
|
+
```json
|
|
271
|
+
{
|
|
272
|
+
"organization": "a5c",
|
|
273
|
+
"import": {
|
|
274
|
+
"name": "import-01kr1z",
|
|
275
|
+
"phase": "AwaitingReview",
|
|
276
|
+
"retentionTier": "summary-only",
|
|
277
|
+
"sourceDigest": "sha256:source",
|
|
278
|
+
"redactionDigest": "sha256:redaction",
|
|
279
|
+
"validationReportDigest": "sha256:validation",
|
|
280
|
+
"targetBranch": "krate/memory-import/01kr1z",
|
|
281
|
+
"pullRequestRef": "a5c-ai/company-brain/124"
|
|
282
|
+
},
|
|
283
|
+
"generatedFiles": [
|
|
284
|
+
{ "path": "babysitter/runs/01KR1Z/run.yaml", "digest": "sha256:run" },
|
|
285
|
+
{ "path": "babysitter/sessions/2026/05/11/019e-example.md", "digest": "sha256:session" }
|
|
286
|
+
],
|
|
287
|
+
"conditions": [
|
|
288
|
+
{ "type": "SecretsRedacted", "status": "True", "reason": "NoSecretsDetected" },
|
|
289
|
+
{ "type": "OntologyValid", "status": "True", "reason": "ValidationPassed" },
|
|
290
|
+
{ "type": "ReviewReady", "status": "True", "reason": "PullRequestCreated" }
|
|
291
|
+
]
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Error examples
|
|
296
|
+
|
|
297
|
+
Cross-org denial:
|
|
298
|
+
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"error": {
|
|
302
|
+
"code": "CROSS_ORG_REF_DENIED",
|
|
303
|
+
"message": "Referenced memory repository is not in the requested organization.",
|
|
304
|
+
"referenceKind": "AgentMemoryRepository",
|
|
305
|
+
"organization": "a5c"
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Missing organization route:
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"error": {
|
|
315
|
+
"code": "ORG_REQUIRED",
|
|
316
|
+
"message": "Choose an organization before opening repository memory.",
|
|
317
|
+
"path": "/api/orgs/{org}/memory"
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Redaction blocked import:
|
|
323
|
+
|
|
324
|
+
```json
|
|
325
|
+
{
|
|
326
|
+
"error": {
|
|
327
|
+
"code": "MEMORY_IMPORT_REDACTION_BLOCKED",
|
|
328
|
+
"message": "Import removed too much sensitive content to create a useful memory summary.",
|
|
329
|
+
"import": "import-01kr1z",
|
|
330
|
+
"condition": "RedactionTooBroad"
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Org memory controller sequence spec
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This document defines the controller and API sequences for org-scoped company brain memory. It ties together `Organization`, namespace binding, memory repository bootstrap, memory context query, historical refs, Agent Mux dispatch, `.a5c` import, and memory update review.
|
|
6
|
+
|
|
7
|
+
## Sequence principles
|
|
8
|
+
|
|
9
|
+
- Resolve org before any resource lookup that can cross tenant boundaries.
|
|
10
|
+
- Use the org namespace for all ServiceAccount, Secret, ConfigMap, runner, and workspace side effects.
|
|
11
|
+
- Resolve Git refs to commits before context assembly or memory import review.
|
|
12
|
+
- Store digests for every selected memory source, generated import file, validation report, and update patch.
|
|
13
|
+
- Keep Agent Mux execution behind Krate admission; Agent Mux never decides org access.
|
|
14
|
+
- Treat company brain memory as untrusted context until redacted and rendered with provenance.
|
|
15
|
+
|
|
16
|
+
## Org bootstrap sequence
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
admin creates Organization
|
|
20
|
+
-> org-controller validates slug and namespaceName
|
|
21
|
+
-> org-controller creates or verifies namespace
|
|
22
|
+
-> org-controller writes OrgNamespaceBinding
|
|
23
|
+
-> RBAC controller creates org admin RoleBindings
|
|
24
|
+
-> memory controller creates optional AgentMemoryRepository skeleton
|
|
25
|
+
-> UI shows org dashboard and empty repository/agents/memory states
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Required status conditions:
|
|
29
|
+
|
|
30
|
+
- `NamespaceReady`;
|
|
31
|
+
- `OrgRbacReady`;
|
|
32
|
+
- `DefaultPoliciesReady`;
|
|
33
|
+
- `MemoryRepositoryReady` when memory bootstrap is enabled;
|
|
34
|
+
- `Ready`.
|
|
35
|
+
|
|
36
|
+
## Memory repository bootstrap sequence
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
admin creates AgentMemoryRepository
|
|
40
|
+
-> memory controller verifies organizationRef and namespace
|
|
41
|
+
-> memory controller creates/adopts internal Git repo
|
|
42
|
+
-> memory controller commits default layout and ontology when empty
|
|
43
|
+
-> indexer builds graph/search/ontology reports
|
|
44
|
+
-> status records currentCommit, ontologyDigest, indexDigest
|
|
45
|
+
-> UI enables /orgs/[org]/agents/memory
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Failure handling:
|
|
49
|
+
|
|
50
|
+
- Git repo unavailable: `Ready=False`, `reason=MemoryRepositoryUnavailable`.
|
|
51
|
+
- Layout invalid: `Ready=False`, `reason=MemoryLayoutInvalid`.
|
|
52
|
+
- Ontology invalid: reads may be degraded, update merges blocked.
|
|
53
|
+
|
|
54
|
+
## Dispatch with current memory sequence
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
user opens /orgs/[org]/repositories/[repo]/code
|
|
58
|
+
-> UI requests dispatch preview
|
|
59
|
+
-> API resolves org, repo, stack, memory source policy
|
|
60
|
+
-> permission review checks repo, stack, runner, secrets, config, memory
|
|
61
|
+
-> memory controller resolves default branch to commit
|
|
62
|
+
-> context assembler queries graph/frontmatter/grep sources
|
|
63
|
+
-> redactor bounds and redacts results
|
|
64
|
+
-> AgentMemorySnapshot and AgentMemoryQuery are created
|
|
65
|
+
-> AgentContextBundle stores memory snapshot digests
|
|
66
|
+
-> AgentDispatchRun and AgentDispatchAttempt are created
|
|
67
|
+
-> Agent Mux launch receives admitted tool/session options
|
|
68
|
+
-> run detail streams events and shows memory provenance
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Idempotency key:
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
org + repository + source event + stack generation + memory resolved commit + context digest + attempt number
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Dispatch with historical memory sequence
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
user selects memory from two days ago
|
|
81
|
+
-> UI converts relative input to absolute timestamp
|
|
82
|
+
-> API calls resolve-ref with mode ref-at-time
|
|
83
|
+
-> memory controller selects latest approved commit <= timestamp
|
|
84
|
+
-> UI shows resolved commit, age, and diff summary against current
|
|
85
|
+
-> context assembly uses historical commit for all memory queries
|
|
86
|
+
-> memory tools are scoped to historical AgentMemorySnapshot
|
|
87
|
+
-> run retry reuses same snapshot unless user refreshes memory
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Blocking cases:
|
|
91
|
+
|
|
92
|
+
- no commit exists before timestamp;
|
|
93
|
+
- commit exists but failed ontology validation and policy requires valid ontology;
|
|
94
|
+
- selected stack requires current-only memory;
|
|
95
|
+
- actor lacks `memory.snapshots.diff` for preview diff.
|
|
96
|
+
|
|
97
|
+
## Agent memory tool call sequence
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
agent calls memory.docs.grep through Agent Mux
|
|
101
|
+
-> Agent Mux forwards tool request to Krate memory tool gateway
|
|
102
|
+
-> gateway resolves dispatch attempt and AgentMemorySnapshot
|
|
103
|
+
-> gateway checks tool grant and snapshot path/kind scope
|
|
104
|
+
-> memory query runs against pinned commit
|
|
105
|
+
-> result is redacted, bounded, digested, and audited
|
|
106
|
+
-> response returns excerpts with source paths and commit
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The gateway must reject tool calls that ask for current branch state when the run is pinned to a historical snapshot unless the user explicitly refreshed context.
|
|
110
|
+
|
|
111
|
+
## Babysitter run import sequence
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
user chooses Import run memory from run detail
|
|
115
|
+
-> API creates AgentRunMemoryImport in org namespace
|
|
116
|
+
-> import controller verifies run/session/repo org ownership
|
|
117
|
+
-> import controller collects admitted MEMORY.md, session summary, journal, task, artifact metadata
|
|
118
|
+
-> source digests are computed
|
|
119
|
+
-> content is redacted and prompt-injection scanned
|
|
120
|
+
-> normalized Markdown/YAML files are generated
|
|
121
|
+
-> ontology/frontmatter/path/owner validation runs
|
|
122
|
+
-> memory update branch/PR is created
|
|
123
|
+
-> reviewer approves and merges
|
|
124
|
+
-> memory index rebuilds
|
|
125
|
+
-> source run links to merged memory commit
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Idempotency key:
|
|
129
|
+
|
|
130
|
+
```text
|
|
131
|
+
organizationRef + source run ID + source digest + retention tier + targetPath
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Memory update review sequence
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
agent proposes memory update artifact
|
|
138
|
+
-> artifact controller records digest and source run
|
|
139
|
+
-> memory controller creates AgentMemoryUpdate
|
|
140
|
+
-> validation checks ontology, frontmatter, owners, edges, paths, redaction
|
|
141
|
+
-> reviewer sees diff, source evidence, and validation report
|
|
142
|
+
-> approval controller records decision
|
|
143
|
+
-> memory controller merges or rejects update
|
|
144
|
+
-> memory repository currentCommit and indexes update
|
|
145
|
+
-> audit links update to source run/session/actor
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Memory updates must not change the context snapshot of the run that proposed them. They only affect future dispatches or explicit refreshed retries.
|
|
149
|
+
|
|
150
|
+
## Cross-org denial sequence
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
request references org a5c and memory repo in org other
|
|
154
|
+
-> API resolves both refs
|
|
155
|
+
-> admission detects org mismatch
|
|
156
|
+
-> checks OrgSharingPolicy
|
|
157
|
+
-> no policy found
|
|
158
|
+
-> returns CROSS_ORG_REF_DENIED
|
|
159
|
+
-> audit records denied kind and actor without leaking private target details
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Watch and event sequence
|
|
163
|
+
|
|
164
|
+
Org-scoped watch streams should publish:
|
|
165
|
+
|
|
166
|
+
- `AgentMemoryRepository.status` changes;
|
|
167
|
+
- `AgentMemorySnapshot` creation;
|
|
168
|
+
- `AgentMemoryQuery` completion;
|
|
169
|
+
- `AgentRunMemoryImport` phase/condition updates;
|
|
170
|
+
- `AgentMemoryUpdate` review and merge events;
|
|
171
|
+
- `AgentDispatchRun` memory provenance changes.
|
|
172
|
+
|
|
173
|
+
Watch payloads must include org and namespace and must be filtered before streaming to the client.
|
|
174
|
+
|
|
175
|
+
## Acceptance criteria
|
|
176
|
+
|
|
177
|
+
- Each sequence has a clear org resolution step before side effects.
|
|
178
|
+
- Every Git ref is resolved to a commit before context or import review.
|
|
179
|
+
- Every memory or run import write path produces a reviewable update with validation status.
|
|
180
|
+
- Cross-org references fail closed and produce non-leaky errors.
|
|
181
|
+
- Watch streams can update UI without polling and without cross-org leakage.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Org memory E2E fixture plan
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This document defines deterministic fixtures for testing the org-scoped memory vertical slice. The fixtures should let future implementation prove org isolation, memory snapshotting, run import, and UI visibility without requiring a live external GitHub organization.
|
|
6
|
+
|
|
7
|
+
## Fixture topology
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
Cluster
|
|
11
|
+
-> Organization a5c / namespace krate-org-a5c
|
|
12
|
+
-> Repository krate
|
|
13
|
+
-> AgentStack claude-code-ci-repair
|
|
14
|
+
-> AgentMemoryRepository org-company-brain
|
|
15
|
+
-> AgentMemorySource krate-ci-memory
|
|
16
|
+
-> RunnerPool trusted-linux
|
|
17
|
+
-> Organization other / namespace krate-org-other
|
|
18
|
+
-> Repository krate
|
|
19
|
+
-> AgentMemoryRepository other-company-brain
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The duplicate repository slug is intentional. It tests org-aware routing and legacy ambiguity handling.
|
|
23
|
+
|
|
24
|
+
## Memory repository fixture
|
|
25
|
+
|
|
26
|
+
`org-company-brain` initial tree:
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
.company-brain/
|
|
30
|
+
README.md
|
|
31
|
+
babysitter/MEMORY.md
|
|
32
|
+
ontology/node-kinds.yaml
|
|
33
|
+
ontology/edge-kinds.yaml
|
|
34
|
+
runbooks/ci/playwright-flake.md
|
|
35
|
+
repositories/krate.md
|
|
36
|
+
babysitter/retrospectives/seed.md
|
|
37
|
+
indexes/ontology-report.json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`runbooks/ci/playwright-flake.md` frontmatter:
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
id: runbook:ci-playwright-flake
|
|
44
|
+
kind: Runbook
|
|
45
|
+
title: Playwright flake triage
|
|
46
|
+
status: approved
|
|
47
|
+
owners: [team:platform]
|
|
48
|
+
repoRefs: [repository:krate]
|
|
49
|
+
tags: [ci, playwright]
|
|
50
|
+
updatedAt: 2026-05-11T08:00:00Z
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## `.a5c` run fixture
|
|
54
|
+
|
|
55
|
+
Fixture path:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
.a5c/runs/01KR-FIXTURE/
|
|
59
|
+
run.json
|
|
60
|
+
journal/000001.json
|
|
61
|
+
journal/000002.json
|
|
62
|
+
tasks/task-1/task.json
|
|
63
|
+
tasks/task-1/result.json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Minimum `run.json` fields:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"id": "01KR-FIXTURE",
|
|
71
|
+
"organizationRef": "a5c",
|
|
72
|
+
"repository": "krate",
|
|
73
|
+
"process": "docs-memory-fixture",
|
|
74
|
+
"status": "completed",
|
|
75
|
+
"startedAt": "2026-05-11T08:00:00Z",
|
|
76
|
+
"completedAt": "2026-05-11T08:15:00Z"
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Journal fixture should include one harmless event and one secret-like value to prove redaction:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"sequence": 2,
|
|
85
|
+
"eventType": "task.output",
|
|
86
|
+
"timestamp": "2026-05-11T08:05:00Z",
|
|
87
|
+
"message": "Token-like content sk-test-fixture-redact-me must be redacted."
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Seed resources
|
|
92
|
+
|
|
93
|
+
Required resources:
|
|
94
|
+
|
|
95
|
+
- `Organization/a5c`;
|
|
96
|
+
- `OrgNamespaceBinding/a5c`;
|
|
97
|
+
- `Organization/other`;
|
|
98
|
+
- `OrgNamespaceBinding/other`;
|
|
99
|
+
- `Repository/krate` in both orgs;
|
|
100
|
+
- `AgentStack/claude-code-ci-repair` in `a5c`;
|
|
101
|
+
- `AgentMemoryRepository/org-company-brain` in `a5c`;
|
|
102
|
+
- `AgentMemorySource/krate-ci-memory` in `a5c`;
|
|
103
|
+
- `AgentServiceAccount/agent-claude-code-ci-repair` in `a5c`;
|
|
104
|
+
- `RunnerPool/trusted-linux` in `a5c`.
|
|
105
|
+
|
|
106
|
+
## Test cases
|
|
107
|
+
|
|
108
|
+
### Org route ambiguity
|
|
109
|
+
|
|
110
|
+
1. Request legacy `/repositories/krate/code`.
|
|
111
|
+
2. Fixture has `krate` in `a5c` and `other`.
|
|
112
|
+
3. Expect an explicit org picker or `ORG_REQUIRED`, not silent selection.
|
|
113
|
+
|
|
114
|
+
### Memory query preview
|
|
115
|
+
|
|
116
|
+
1. Request `/api/orgs/a5c/agents/memory/query` for `playwright flaky checks`.
|
|
117
|
+
2. Expect `runbook:ci-playwright-flake` and no `other` org records.
|
|
118
|
+
3. Expect resolved commit and digests.
|
|
119
|
+
|
|
120
|
+
### Manual dispatch with memory
|
|
121
|
+
|
|
122
|
+
1. Dispatch from `/orgs/a5c/repositories/krate/code`.
|
|
123
|
+
2. Expect `AgentMemorySnapshot`, `AgentContextBundle`, and `AgentDispatchRun`.
|
|
124
|
+
3. Expect run detail to show memory commit and selected records.
|
|
125
|
+
|
|
126
|
+
### Summary-only run import
|
|
127
|
+
|
|
128
|
+
1. Import `.a5c/runs/01KR-FIXTURE` with `summary-only` tier.
|
|
129
|
+
2. Expect secret-like journal content not present in generated memory.
|
|
130
|
+
3. Expect `SecretsRedacted=True`, `OntologyValid=True`, `ReviewReady=True`.
|
|
131
|
+
4. Expect generated run/session summary files and artifact manifest digest only.
|
|
132
|
+
|
|
133
|
+
### Cross-org memory denial
|
|
134
|
+
|
|
135
|
+
1. Dispatch in `a5c` requests `other-company-brain`.
|
|
136
|
+
2. Expect `CROSS_ORG_REF_DENIED`.
|
|
137
|
+
3. Expect no content from `other` in preview, context, transcript, tool output, or audit details.
|
|
138
|
+
|
|
139
|
+
### Historical memory pin
|
|
140
|
+
|
|
141
|
+
1. Resolve `refAt` before a fixture update commit.
|
|
142
|
+
2. Dispatch with resolved historical commit.
|
|
143
|
+
3. Update current memory.
|
|
144
|
+
4. Retry run.
|
|
145
|
+
5. Expect retry to use original commit and show stale warning.
|
|
146
|
+
|
|
147
|
+
## Assertions
|
|
148
|
+
|
|
149
|
+
- Every created resource includes `organizationRef`.
|
|
150
|
+
- Every UI route includes `/orgs/a5c` or `/orgs/other`.
|
|
151
|
+
- Every memory source includes resolved commit and digest fields.
|
|
152
|
+
- Every redacted import omits raw secret-like values.
|
|
153
|
+
- Every cross-org denial emits an audit event with org and denied kind but no private target content.
|
|
154
|
+
|
|
155
|
+
## Out of scope for fixture
|
|
156
|
+
|
|
157
|
+
- External GitHub API calls.
|
|
158
|
+
- Real Agent Mux runtime execution.
|
|
159
|
+
- Raw artifact byte retention.
|
|
160
|
+
- Cross-org sharing policy allow path.
|
|
161
|
+
- Vector search.
|