@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,190 @@
1
+ # Agent resource relationship map
2
+
3
+ ## Purpose
4
+
5
+ This document shows how the agent resources relate to Krate's existing repository, CI, webhook, identity, and UI resources. It is a navigation aid for implementers and reviewers.
6
+
7
+ ## Existing Krate anchors
8
+
9
+ | Existing kind/surface | Agent relationship |
10
+ | --- | --- |
11
+ | `Repository` | root scope for stacks, triggers, workspaces, runs, permissions, and artifacts. |
12
+ | `PullRequest` | source for diagnosis/review/repair dispatches and write-back targets. |
13
+ | `Issue` | work item source for agent sessions, workspace links, and board flow. |
14
+ | `Pipeline` / `Job` | CI source and sibling display model for `AgentDispatchRun`. |
15
+ | `RunnerPool` | execution placement and trust tier for dispatch attempts. |
16
+ | `WebhookSubscription` / `WebhookDelivery` | incoming event source for `AgentTriggerRule`. |
17
+ | `User` / `Team` / `RepositoryPermission` | human identity and authorization inputs. |
18
+ | Native `ServiceAccount` / RBAC | authoritative agent, runner, and user permission enforcement. |
19
+ | Native `Secret` / `ConfigMap` | runtime secret/config sources admitted through grants. |
20
+
21
+ ## Configuration relationship graph
22
+
23
+ ```text
24
+ Repository
25
+ -> AgentStack
26
+ -> AgentToolProfile
27
+ -> AgentCapabilityRequirement
28
+ -> AgentSecretGrant / AgentConfigGrant
29
+ -> AgentMcpServer
30
+ -> AgentCapabilityRequirement
31
+ -> AgentSecretGrant / AgentConfigGrant
32
+ -> AgentSkill
33
+ -> AgentCapabilityRequirement
34
+ -> AgentSecretGrant / AgentConfigGrant
35
+ -> AgentSubagent
36
+ -> AgentToolProfile subset
37
+ -> AgentSkill subset
38
+ -> AgentMcpServer subset
39
+ -> AgentWorkspacePolicy
40
+ -> AgentServiceAccount
41
+ -> AgentRoleBinding
42
+ -> AgentContextLabel
43
+ -> AgentTriggerRule
44
+ -> AgentStack
45
+ -> AgentContextLabel
46
+ -> RunnerPool
47
+ ```
48
+
49
+ ## Execution relationship graph
50
+
51
+ ```text
52
+ WebhookDelivery / Pipeline / Job / Issue / PullRequest / manual UI action
53
+ -> AgentTriggerExecution
54
+ -> AgentContextBundle
55
+ -> permission review snapshot
56
+ -> AgentDispatchRun
57
+ -> AgentDispatchAttempt
58
+ -> AgentMuxRunId / AgentMuxSessionId
59
+ -> AgentSession
60
+ -> AgentWorkspace
61
+ -> AgentArtifact / AgentReviewArtifact
62
+ -> AgentApproval
63
+ -> WorkItemSessionLink
64
+ -> WorkItemWorkspaceLink
65
+ ```
66
+
67
+ ## Source-to-run relationships
68
+
69
+ | Source | Creates/links | Notes |
70
+ | --- | --- | --- |
71
+ | failed `Job` | `AgentTriggerExecution`, `AgentDispatchRun` | shows beside pipeline/job row. |
72
+ | PR comment/mention | `AgentTriggerExecution`, `AgentContextBundle` | actor and comment are source refs. |
73
+ | issue label | `AgentTriggerExecution`, work-item links | label cannot grant permissions. |
74
+ | manual Code dispatch | `AgentContextBundle`, `AgentDispatchRun` | selected path/ref included. |
75
+ | webhook replay | new `AgentTriggerExecution` | dedupe may coalesce with existing run. |
76
+ | approval decision | write-back action and audit event | references artifact digest. |
77
+
78
+ ## Permission relationship graph
79
+
80
+ ```text
81
+ User / Team / AgentStack / RunnerPool
82
+ -> AgentServiceAccount
83
+ -> AgentRoleBinding
84
+ -> native Role / ClusterRole
85
+ -> native RoleBinding / ClusterRoleBinding
86
+ -> AgentSecretGrant
87
+ -> native Secret metadata + selected keys
88
+ -> AgentConfigGrant
89
+ -> native ConfigMap metadata + selected keys
90
+ -> AgentCapabilityRequirement
91
+ -> stack readiness and dispatch permission review
92
+ ```
93
+
94
+ ## UI relationship map
95
+
96
+ | UI page | Primary resources | Secondary resources |
97
+ | --- | --- | --- |
98
+ | `/agents` | dispatches, approvals, stack readiness | trigger health, workspace attention |
99
+ | `/agents/stacks` | `AgentStack` | tools, MCP, skills, subagents, grants |
100
+ | `/agents/runs` | `AgentDispatchRun` | attempts, sessions, artifacts, approvals |
101
+ | `/agents/rules` | `AgentTriggerRule` | executions, deliveries, dry-runs |
102
+ | `/agents/workspaces` | `AgentWorkspace` | sessions, runs, issues, PRs |
103
+ | `/agents/approvals` | `AgentApproval` | artifacts, write-back targets |
104
+ | `/agents/secrets` | `AgentSecretGrant`, `AgentConfigGrant` | consumers, rotations, missing grants |
105
+ | `/orgs/[org]/repositories/[repo]/code` | repository path/ref | context bundle, dispatch composer |
106
+ | `/orgs/[org]/repositories/[repo]/pull-requests` | PR, checks | run/artifact/approval/write-back links |
107
+ | `/orgs/[org]/repositories/[repo]/runs` | pipelines/jobs | agent dispatch rows and artifacts |
108
+ | `/orgs/[org]/repositories/[repo]/settings/agents` | stack/rule/grant policy | generated YAML and permission review |
109
+
110
+ ## Label and index strategy
111
+
112
+ All agent resources should use common labels so generic list/watch APIs can power repository pages:
113
+
114
+ - `krate.a5c.ai/repository`;
115
+ - `krate.a5c.ai/source-kind`;
116
+ - `krate.a5c.ai/source-name`;
117
+ - `krate.a5c.ai/agent-stack`;
118
+ - `krate.a5c.ai/dispatch-run`;
119
+ - `krate.a5c.ai/trigger-rule`;
120
+ - `krate.a5c.ai/workspace`;
121
+ - `krate.a5c.ai/service-account`;
122
+ - `krate.a5c.ai/runner-pool`.
123
+
124
+ ## Deletion impact rules
125
+
126
+ Deleting or disabling a resource should show dependent resources first:
127
+
128
+ | Delete/disable target | Must warn about |
129
+ | --- | --- |
130
+ | `AgentStack` | trigger rules, active runs, sessions, workspace links. |
131
+ | `AgentToolProfile` | stacks and subagents that require it. |
132
+ | `AgentMcpServer` | skills/stacks/subagents and missing capability requirements. |
133
+ | `AgentSkill` | stacks/subagents using prompt fragments or output contracts. |
134
+ | `AgentSecretGrant` | tools/MCP/skills/model providers that become blocked. |
135
+ | `AgentConfigGrant` | skills/tools/MCP servers that become blocked. |
136
+ | `AgentServiceAccount` | stacks, runner pools, active attempts. |
137
+ | `AgentWorkspace` | sessions, runs, artifacts, work item links. |
138
+ | `AgentArtifact` | approvals/write-back records that reference its digest. |
139
+
140
+ ## Acceptance criteria
141
+
142
+ - Implementers can trace every UI affordance to resources and controllers.
143
+ - Repository pages can query by labels rather than bespoke UI state.
144
+ - Deletion warnings identify dependent stacks/rules/runs/grants/artifacts.
145
+ - Permission review can explain a missing capability through the relationship graph.
146
+
147
+ ## Memory relationship graph
148
+
149
+ ```text
150
+ Organization
151
+ -> AgentMemoryRepository
152
+ -> AgentMemoryOntology
153
+ -> AgentMemorySource
154
+ -> Repository / Team / AgentStack / AgentTriggerRule
155
+ -> AgentMemoryAssociation
156
+ -> Repository / Service / AgentStack / Tool / Skill / Subagent / Issue / PullRequest
157
+
158
+ AgentTriggerExecution / manual dispatch
159
+ -> AgentContextBundle
160
+ -> AgentMemorySnapshot
161
+ -> AgentMemoryQuery
162
+ -> selected graph records
163
+ -> selected Markdown records
164
+ -> selected grep excerpts
165
+ -> AgentDispatchRun
166
+ -> AgentMemoryUpdate
167
+ -> AgentApproval
168
+ -> memory repository PR / merge commit
169
+ ```
170
+
171
+ Deleting a memory source must warn about stacks, trigger rules, and dispatch composers that rely on it. Deleting or disabling a memory repository must block new required-memory dispatches while preserving historical `AgentMemorySnapshot` records.
172
+
173
+ ## Org-scoped relationship root
174
+
175
+ ```text
176
+ Organization
177
+ -> Kubernetes Namespace
178
+ -> Repository
179
+ -> Deployment / Environment
180
+ -> AgentStack / AgentTriggerRule / RunnerPool
181
+ -> AgentMemoryRepository
182
+ -> MEMORY.md
183
+ -> BabysitterSession
184
+ -> BabysitterRun
185
+ -> RunJournalEvent
186
+ -> RunTaskResult
187
+ -> ArtifactManifest
188
+ ```
189
+
190
+ All relationship queries should include org. A resource without org scope is either installation/platform state or invalid for product data.
@@ -0,0 +1,188 @@
1
+ # Agent security threat model
2
+
3
+ ## Purpose
4
+
5
+ Agent orchestration expands Krate from CI and repository management into autonomous tool execution. This document identifies threats and required mitigations for the docs-defined agent system.
6
+
7
+ ## Security boundaries
8
+
9
+ | Boundary | Risk |
10
+ | --- | --- |
11
+ | User/browser to Krate API | forged UI actions, stale permissions, hidden local state |
12
+ | Krate API to Kubernetes API | RBAC bypass, privilege escalation, admission gaps |
13
+ | Krate controllers to Agent Mux | overbroad launch options, secret leakage, session confusion |
14
+ | Agent Mux to tool/runtime | tool abuse, command injection, MCP abuse |
15
+ | Runner/workspace to repository | untrusted code exfiltration, cross-run contamination |
16
+ | Trigger source to dispatch | label/comment prompt injection, webhook replay, dedupe bypass |
17
+ | Secret/ConfigMap grant to dispatch | credential overexposure, stale grants, rotation mismatch |
18
+ | Agent output to write-back | unauthorized PR comments, branch pushes, release actions |
19
+
20
+ ## Threats and mitigations
21
+
22
+ ### Prompt injection through labels/comments/context
23
+
24
+ Threat:
25
+
26
+ - Issue labels, PR comments, webhook payloads, or context labels inject hidden instructions or secret requests.
27
+
28
+ Mitigations:
29
+
30
+ - Context labels are reviewed resources, not raw hidden prompt text.
31
+ - Prompt preview shows all injected fragments and provenance.
32
+ - Secret/config access is controlled by grants, never by prompt content.
33
+ - Trigger dry-run shows rendered prompt and source payload summary.
34
+
35
+ ### Privilege escalation through roles
36
+
37
+ Threat:
38
+
39
+ - A user grants an agent or runner a stronger Role/ClusterRole than they can bind.
40
+
41
+ Mitigations:
42
+
43
+ - `AgentRoleBinding` apply requires bind/escalate checks.
44
+ - Role templates show generated YAML before apply.
45
+ - Escalation attempts set conditions and audit events.
46
+ - Native Kubernetes RBAC remains authoritative.
47
+
48
+ ### Secret exfiltration by tools or MCP servers
49
+
50
+ Threat:
51
+
52
+ - Tool, skill, MCP server, or agent code reads secrets not required for the task.
53
+
54
+ Mitigations:
55
+
56
+ - Secrets require explicit `AgentSecretGrant` by subject, purpose, repo/ref, trigger source, and mount policy.
57
+ - Agent launch passes only admitted references/mounts.
58
+ - Untrusted refs receive no privileged secrets.
59
+ - UI never shows Secret values; audit records only metadata and key names.
60
+
61
+ ### ConfigMap misuse
62
+
63
+ Threat:
64
+
65
+ - Non-secret config changes execution behavior or contains sensitive values.
66
+
67
+ Mitigations:
68
+
69
+ - `AgentConfigGrant` gates ConfigMap usage.
70
+ - Sensitive keys are metadata-only in UI.
71
+ - ConfigMap consumers and breakage warnings are visible before deletion/change.
72
+
73
+ ### Untrusted fork execution
74
+
75
+ Threat:
76
+
77
+ - Forked PR code runs on trusted runner or accesses privileged ServiceAccount/secrets.
78
+
79
+ Mitigations:
80
+
81
+ - Trust tier is part of trigger and runner admission.
82
+ - Fork refs force untrusted runner pools and unprivileged ServiceAccounts.
83
+ - Secret grants must explicitly allow untrusted refs; default deny.
84
+
85
+ ### MCP/tool abuse
86
+
87
+ Threat:
88
+
89
+ - MCP server or native tool performs network, filesystem, or API actions beyond user intent.
90
+
91
+ Mitigations:
92
+
93
+ - `AgentToolProfile` defines filesystem/network/native tool policy.
94
+ - MCP servers declare required roles, Secret refs, ConfigMap refs, and allowed stacks.
95
+ - Tool approval policies gate privileged invocations.
96
+ - Runtime events stream tool calls into audit/observability.
97
+
98
+ ### Agent Mux session confusion
99
+
100
+ Threat:
101
+
102
+ - A chat/session is linked to the wrong repository, workspace, dispatch attempt, or actor.
103
+
104
+ Mitigations:
105
+
106
+ - `AgentDispatchAttempt.status.agentMuxRunId` and `agentMuxSessionId` are bound once and audited.
107
+ - Run detail always shows source breadcrumbs.
108
+ - Continuation requests include dispatch/run/session IDs and permission review context.
109
+
110
+ ### Write-back abuse
111
+
112
+ Threat:
113
+
114
+ - Agent posts comments, pushes branches, approves reviews, reruns checks, or publishes release artifacts without sufficient authorization.
115
+
116
+ Mitigations:
117
+
118
+ - Write-back is an explicit action with `AgentApproval` unless narrowly allowed by repository policy.
119
+ - Approval records include actor, approver, artifact digest, target, and source event.
120
+ - Write-back idempotency keys prevent duplicate comments/pushes/reruns.
121
+
122
+ ### Replay and dedupe bypass
123
+
124
+ Threat:
125
+
126
+ - Webhook replay, repeated labels, or schedule storms create duplicate costly runs.
127
+
128
+ Mitigations:
129
+
130
+ - `WebhookDelivery` is durable before trigger evaluation.
131
+ - `AgentTriggerExecution` records dedupe/coalescing decisions.
132
+ - Dedupe keys include source object, commit SHA, failure signature, rule, and context digest.
133
+
134
+ ### Workspace contamination
135
+
136
+ Threat:
137
+
138
+ - One agent attempt sees or mutates another run's workspace state.
139
+
140
+ Mitigations:
141
+
142
+ - Workspace policy selects isolated worktrees for untrusted or write-capable tasks.
143
+ - Workspace links record ownership and active sessions/runs.
144
+ - Missing/dirty/rebase states block unsafe write-back until resolved.
145
+
146
+ ## Required audits
147
+
148
+ Every dispatch should preserve:
149
+
150
+ - actor and Kubernetes identity;
151
+ - source event and trigger rule;
152
+ - stack generation and permission snapshot digest;
153
+ - runtime and runner ServiceAccounts;
154
+ - Secret/ConfigMap grant names and key names only;
155
+ - tool/MCP/skill/subagent availability;
156
+ - Agent Mux run/session IDs;
157
+ - approvals and write-back decisions;
158
+ - artifacts and digests.
159
+
160
+ ## Security acceptance criteria
161
+
162
+ - A fork PR cannot access privileged Secret grants or trusted ServiceAccounts.
163
+ - A label/comment cannot grant roles, secrets, configs, or write-back permission by itself.
164
+ - A stack with missing tool/skill/MCP Secret access cannot dispatch.
165
+ - Secret values are never visible in UI responses, status, logs, prompt previews, or audit events.
166
+ - Role binding escalation is denied by server-side review.
167
+ - Write-back to PRs, branches, checks, releases, or deployment surfaces is approval-gated and audited.
168
+
169
+ ## Company brain memory threats
170
+
171
+ | Threat | Mitigation |
172
+ | --- | --- |
173
+ | prompt injection stored in memory | treat memory as untrusted input, scan risky instructions, render provenance, and separate memory from system/developer prompt layers. |
174
+ | stale memory drives bad action | show pinned commit and stale warning; allow diff against current; require explicit refresh. |
175
+ | unauthorized knowledge exposure | enforce `AgentMemorySource` path/kind grants and redact denied content before preview, prompt, transcript, or audit. |
176
+ | malicious memory update | require validation, source-run link, owners, review, PR diff, and merge permission. |
177
+ | secret leakage into memory | secret scan on reads and writes; block merge and redact selected context. |
178
+ | historical run escapes pinned memory | memory tools default to `AgentMemorySnapshot`; current-memory access requires refresh/approval. |
179
+
180
+ ## Org boundary threats
181
+
182
+ | Threat | Mitigation |
183
+ | --- | --- |
184
+ | repository slug collision leaks data | non-org repository routes are not served; users must choose an organization explicitly. |
185
+ | cross-org Secret/ConfigMap mount | namespace and `organizationRef` admission checks before dispatch. |
186
+ | cross-org memory query | `AgentMemorySource` and memory APIs require org match and path/kind grant. |
187
+ | run journal imports leak another org | `AgentRunMemoryImport` resolves source repo/run/session ownership before reading `.a5c` material. |
188
+ | shared controller writes to wrong namespace | side effects use resolved org namespace and audit namespace. |