@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
package/docs/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Krate Documentation
2
+
3
+ Krate is an a5c.ai Kubernetes-native forge project.
4
+
5
+ Krate is a Kubernetes-native Git forge where repositories, pull requests, CI, hooks, and policy share Kubernetes identity, RBAC, admission, and declarative APIs.
6
+
7
+ ## Reading order
8
+
9
+ 1. [Product requirements](product-requirements.md) — positioning, personas, outcomes, and non-goals.
10
+ 2. [System requirements](system-requirements.md) — full-system integration, publish, install, upgrade, security, and release requirements.
11
+ 3. [Architecture spec](architecture-spec.md) — control-plane/data-plane decomposition and resource model.
12
+ 4. [User stories](user-stories.md) — persona- and workflow-oriented stories with acceptance criteria.
13
+ 5. [MVP roadmap](roadmap-mvp.md) — six-week MVP scope and release gates.
14
+ 6. [Installation and local development](install.md) — quickstart, Next.js UI, validation, and minikube dry-run.
15
+
16
+ ## Component specs
17
+
18
+ - [Control plane](components/control-plane.md)
19
+ - [Data plane](components/data-plane.md)
20
+ - [Identity, RBAC, and policy](components/identity-rbac-policy.md)
21
+ - [Runners and CI](components/runners-ci.md)
22
+ - [Hooks and events](components/hooks-events.md)
23
+ - [Web UI](components/web-ui.md) — implemented locally in `../apps/web`
24
+ - [Operations and publishing](components/operations-publishing.md)
25
+
26
+ ## Source of truth
27
+
28
+ These specs are derived from `krate-design.md`. The key architectural commitments are:
29
+
30
+ - CRDs are the declarative API contract, not the storage engine for high-cardinality social data.
31
+ - Pull requests, issues, reviews, pipelines, jobs, and runner activity are Kubernetes API resources served by an aggregated API server backed by Postgres.
32
+ - Git repository storage is backed by Gitea plus object storage metadata, not one PVC per repository.
33
+ - Human and CI permissions use Kubernetes identity and RBAC; Krate does not introduce PATs or a parallel authorization system.
34
+ - Every mutating UI action must expose the equivalent YAML and `kubectl` command.
35
+
36
+ ## Package and local lifecycle
37
+
38
+ - Product home: `https://a5c.ai/krate`
39
+ - Helm-style chart package: `../charts/krate`
40
+ - Next.js UI: `../apps/web` (`npm run dev`, `npm run ui:build`)
41
+ - Minikube setup script: `../scripts/setup-minikube.mjs`
42
+ - Demo resources: `../examples/minikube-demo.yaml`
43
+ - Deterministic gates: `npm run check`, `npm run e2e`, `npm run package:check`, `npm run ui:build`, and `npm run setup:minikube -- --dry-run`
44
+
45
+ - [KubeVela and OAM Integration](components/kubevela-oam.md)
46
+ - [OAM and KubeVela Ontology Assimilation](ontology/oam-kubevela.md)
47
+
48
+ ## Organization scoping
49
+
50
+ Krate is org-first: every repository, deployment, runner, agent, memory source, session, workspace, secret, and config grant belongs to an organization, and each organization maps to a Kubernetes namespace. See `docs/gaps.md` and `docs/agents/org-scoping-namespace-spec.md` for the remaining org-scoping requirements and agent memory implications.
51
+
52
+ ## QA and testing
53
+
54
+ - [QA automation and test strategy](tests/README.md) defines the product-wide test plan, framework, coverage model, E2E/browser/UI/unit strategy, CI gates, fixtures, security checks, reliability tests, and future agent QA plan.
55
+ - The current local all-up gate is `npm run check`; future gates should add browser, coverage, security, chart, and agent-specific suites without weakening the existing scripts.
56
+
57
+ ## External backend integrations
58
+
59
+ - [External backend integration docs](external/README.md) define GitHub-first integration and future provider support through three independent interfaces: issue tracking, CI/CD, and git forge. The docs cover research, provider model, CRDs, controllers, bidirectional sync, user-facing changes, security, and rollout/testing.
60
+
61
+ The external backend docs include a provider catalog and UI/CRD/controller specs for pluggable backends beyond GitHub, including issue-only, CI-only, git-forge-only, and full-forge providers.
@@ -0,0 +1,83 @@
1
+ # Agent dispatch integration docs
2
+
3
+ This directory captures the docs-only specification for adding agent orchestration to Krate git workspaces. The focus is a system-wide orchestration model: define agent stacks, bind tools/skills/subagents, connect them to triggers, run them on policy-controlled workspaces, and present each dispatch like a CI pipeline run with live Agent Mux chat/session access.
4
+
5
+ No controller, UI, API, CRD, runner, or workflow implementation is part of this change.
6
+
7
+ ## What this covers
8
+
9
+ - How to define reusable agent stacks such as a Claude Code based agent with model, approval mode, tools, MCP servers, skills, subagents, prompts, and runtime policy.
10
+ - How issue/session/workspace/dispatch relationships from Agent Mux kanban should become first-class system capabilities in Krate, not just UI widgets.
11
+ - How CI checks, incoming webhooks, issue/PR comments, labels, schedules, and manual actions should trigger agent dispatches.
12
+ - How agent dispatches should appear beside `Pipeline` and `Job` runs while also exposing Agent Mux transcript, session, runtime surfaces, approvals, artifacts, and workspace lifecycle actions.
13
+ - How context labels should inject reviewed prompt fragments into dispatch context without becoming hidden launch commands or secret channels.
14
+ - How Agent Mux can provide adapters, session streaming, chat, cancellation, run events, plugin/tool discovery, and workspace/session primitives while Krate remains the repository, policy, trigger, and audit source of truth.
15
+
16
+ ## Documents
17
+
18
+ - [Agent system overview](./system-overview.md) is the short entry point for the complete architecture, MVP target, invariants, and where to read next.
19
+ - [Agent glossary](./glossary.md) standardizes terminology across resources, UI, controllers, and Agent Mux boundaries.
20
+ - [Agent traceability matrix](./traceability-matrix.md) maps requirements to resources, controllers, UI surfaces, docs, implementation files, and validation gates.
21
+
22
+ - [Agent stack management spec](./agent-stack-management-spec.md) defines agent definitions, subagents, MCP tools, skills, trigger management, policy, and CI-like dispatch visibility.
23
+ - [UI/UX system spec](./ui-ux-system-spec.md) maps agent screens and interactions to app routes, custom resources, aggregated resources, controllers, API actions, and watch streams.
24
+ - [Integration design](./dispatching-design.md) defines the proposed Krate resources, trigger flow, work-item/session/workspace associations, chat/run UX, and implementation phases.
25
+ - [CI orchestration spec](./ci-orchestration-spec.md) keeps the CI-specific failed-check, repair, flaky-test, and release-gate requirements.
26
+ - [Source map](./agent-mux-source-map.md) maps relevant Babysitter Agent Mux paths, Krate CI paths, and repo docs to inspect before implementation.
27
+ - [Implementation blueprint](./implementation-blueprint.md) maps the specs onto concrete Krate source files, controllers, routes, CRDs, API endpoints, rollout order, and tests.
28
+ - [Resource contract examples](./resource-contract-examples.md) provides implementation-ready YAML and JSON examples for stacks, subagents, tools, MCP, skills, triggers, dispatches, approvals, and work-item links.
29
+ - [RBAC, service account, secret, and config management spec](./rbac-secrets-management-spec.md) defines native Kubernetes Roles, RoleBindings, ServiceAccounts, permission review, Secret grants, ConfigMap grants, audit, drift handling, and UI permission management for agents, runners, tools, skills, and users.
30
+ - [Agent CRD schema spec](./crd-schema-spec.md) maps agent resources onto Krate's existing `CONFIG_KINDS`, `AGGREGATED_KINDS`, schemas, labels, status conditions, and storage classes.
31
+ - [Controller reconciliation spec](./controller-reconciliation-spec.md) defines reconciler loops, watches, outputs, idempotency, failure handling, and UI projection integration.
32
+ - [API contract spec](./api-contract-spec.md) defines typed agent endpoints while preserving current controller/resource/watch API boundaries.
33
+ - [UI flow and state spec](./ui-flow-spec.md) defines stack builder, grant wizards, permission review, dispatch composer, run detail, and repository settings flows.
34
+ - [Security threat model](./security-threat-model.md) covers prompt injection, RBAC escalation, secret exfiltration, untrusted forks, MCP/tool abuse, session confusion, and write-back abuse.
35
+ - [Acceptance test matrix](./acceptance-test-matrix.md) maps resources, controllers, APIs, UI, e2e flows, and package/chart validation to concrete acceptance gates.
36
+ - [Storage and migration spec](./storage-migration-spec.md) defines etcd/Postgres/object-storage/native-Kubernetes storage boundaries, snapshots, indexes, retention, and migrations.
37
+ - [Chart and packaging spec](./chart-packaging-spec.md) maps agent features into Helm values, CRDs, RBAC, deployments, NetworkPolicy, examples, and package validation.
38
+ - [Agent Mux adapter contract](./agent-mux-adapter-contract.md) defines the launch/capability/event/session boundary between Krate and Agent Mux.
39
+ - [Implementation rollout slices](./implementation-rollout-slices.md) sequences docs, resources, UI, permission review, stack registry, dispatch, Agent Mux binding, approvals, triggers, workspaces, and hardening.
40
+ - [Context assembly and prompt safety spec](./context-assembly-spec.md) defines prompt layers, source provenance, redaction, context labels, bundle snapshots, and preview requirements.
41
+ - [Observability and audit spec](./observability-audit-spec.md) defines metrics, events, traces, audit records, alerts, and run-detail projections.
42
+ - [Repository page integration spec](./repository-page-integration-spec.md) maps agent affordances into the existing Code, Issues, Pull Requests, Runs, Hooks, Settings, and Inbox pages.
43
+ - [Tools, MCP, and skills spec](./tools-mcp-skills-spec.md) defines tool profiles, MCP servers, skills, capability requirements, health, UI, and launch behavior.
44
+ - [Subagent orchestration spec](./subagent-orchestration-spec.md) defines parent/child agent modes, context slicing, output contracts, permissions, telemetry, and UI lanes.
45
+ - [Artifacts and write-back spec](./artifacts-writeback-spec.md) defines durable artifacts, patch/review outputs, approval-gated write-back, idempotency, and failure handling.
46
+ - [Workspace lifecycle spec](./workspace-lifecycle-spec.md) defines workspace ownership, issue/session/run links, git/runtime state, lifecycle actions, trust isolation, and recovery.
47
+ - [Resource relationship map](./resource-relationship-map.md) shows how agent resources connect to existing Krate repositories, PRs, issues, pipelines, webhooks, identity, RBAC, secrets, and UI pages.
48
+ - [Operator runbook](./operator-runbook.md) explains safe enablement, preflight checks, troubleshooting, rollback, metrics, and support bundles.
49
+ - [Developer implementation checklist](./developer-implementation-checklist.md) maps rollout slices to concrete files, tasks, validation commands, documentation updates, and stop conditions.
50
+ - [MVP vertical slice spec](./mvp-vertical-slice-spec.md) defines the first coherent implementation target, included/deferred scope, acceptance criteria, tests, and non-negotiables.
51
+ - [Decision log and open questions](./decision-log-open-questions.md) records accepted architecture decisions and open implementation questions.
52
+
53
+ ## Current decision
54
+
55
+ Treat agents as configurable work executors attached to Krate's repository graph, not as a standalone chat dashboard. Krate should own repository-native objects such as repositories, issues, PRs, checks, pipelines, jobs, runner pools, workspaces, labels, trigger rules, context labels, native Kubernetes role/service-account projections, secret/config grants, approvals, artifacts, and audit records. Agent Mux should own adapter-specific execution, session lifecycle, transcript/event streaming, chat continuation, cancellation, plugins/tool surfaces, and runtime state projection.
56
+
57
+ The first implementation should optimize for these paths:
58
+
59
+ 1. Define an agent stack, for example `claude-code` with selected model, subagents, MCP servers, skills, allowed tools, approval mode, workspace policy, and runner pool.
60
+ 2. Connect that agent stack to CI triggers, incoming webhooks, issue/PR mentions, labels, schedules, and manual dispatch buttons.
61
+ 3. Dispatch an agent from a failed PR check, webhook, or issue and see it as a CI-like run with queue, runner, logs/events, artifacts, status, and approvals.
62
+ 4. Open the linked Agent Mux chat/session from the run to continue, approve, cancel, inspect tools, follow subagents, and manage the associated workspace.
63
+
64
+ ## Company brain memory additions
65
+
66
+ - [Shared memory company brain spec](./shared-memory-company-brain-spec.md) defines org-level Git-backed shared agent memory, Atlas-style graph/YAML/Markdown storage, memory resources, time-travel refs, update review, and UI requirements.
67
+ - [Memory context integration spec](./memory-context-integration-spec.md) defines how context bundles read graph records, Markdown frontmatter records, free-form grep excerpts, ontology reports, and historical memory snapshots.
68
+ - [Memory ontology and file schema spec](./memory-ontology-schema-spec.md) defines graph YAML, Markdown frontmatter, free-form notes, node/edge vocabulary, IDs, validation, indexes, and governance.
69
+ - [Memory operations runbook](./memory-operations-runbook.md) defines bootstrap, validation, current/historical dispatch, memory update, rollback, migration, dashboards, and alerts.
70
+
71
+ - [Org scoping and namespace spec](./org-scoping-namespace-spec.md) defines organization-first tenancy, one Kubernetes namespace per org, org-aware routes, labels, RBAC, cross-org rejection, and controller requirements.
72
+
73
+ - [Agent run memory import spec](./agent-run-memory-import-spec.md) defines how `MEMORY.md`, Agent Mux/Babysitter sessions, curated `.a5c` journals, task results, artifact manifests, and retrospectives become governed org memory.
74
+ - [Org route and resource model spec](./org-route-resource-model-spec.md) defines org-aware UI/API routes, resource refs, deployment scoping, namespace enforcement, and controller behavior.
75
+
76
+ - [Org memory UI implementation map](./org-memory-ui-implementation-map.md) maps company brain and agent pages onto the current `apps/web/app/orgs/[org]` route tree and API seams.
77
+ - [Org resource model delta spec](./org-resource-model-delta-spec.md) maps new agent/memory resources onto the existing `Organization`, `OrgNamespaceBinding`, `organizationRef`, CRD, and aggregated-resource model.
78
+
79
+ - [Org memory controller sequence spec](./org-memory-controller-sequence-spec.md) defines org bootstrap, memory bootstrap, dispatch, historical memory, tool calls, Babysitter import, memory update, cross-org denial, and watch/event sequences.
80
+ - [Org memory vertical slice spec](./org-memory-vertical-slice-spec.md) defines the smallest coherent implementation slice for org-scoped company brain memory and run imports.
81
+
82
+ - [Org memory API payload examples](./org-memory-api-payload-examples.md) provides concrete request/response contracts for summary, ref resolution, memory query, dispatch, run detail, run import, import detail, and stable errors.
83
+ - [Org memory E2E fixture plan](./org-memory-e2e-fixture-plan.md) defines deterministic org/repo/memory/`.a5c` fixtures and expected assertions for the vertical slice.
@@ -0,0 +1,193 @@
1
+ # Agent acceptance test matrix
2
+
3
+ ## Purpose
4
+
5
+ This matrix turns the docs into validation work for implementation. It follows existing Krate validation style: start with resource/controller unit tests, then API route tests, UI validation, package/chart checks, and e2e flows.
6
+
7
+ ## Existing validation anchors
8
+
9
+ Current commands to preserve:
10
+
11
+ - `npm run validate:docs`
12
+ - `npm run package:check`
13
+ - `npm run ui:validate`
14
+ - `npm test`
15
+ - `npm run e2e`
16
+ - `npm run check`
17
+
18
+ ## Resource/schema tests
19
+
20
+ | Scenario | Expected proof |
21
+ | --- | --- |
22
+ | Agent config kinds appear in `CONFIG_KINDS` | `resourceSchemaForKind()` returns plural, storage, required fields. |
23
+ | Agent execution kinds appear in `AGGREGATED_KINDS` | list schema returns postgres/object-storage intent. |
24
+ | Conditions use stable fields | schema accepts type/status/reason/message/observedGeneration. |
25
+ | `AgentSecretGrant` never stores values | schema rejects value-like fields. |
26
+ | `AgentDispatchAttempt` identity snapshot immutable | update attempts cannot mutate runtime identity after launch. |
27
+
28
+ ## Controller tests
29
+
30
+ | Controller | Scenario | Expected proof |
31
+ | --- | --- | --- |
32
+ | stack | missing tool Secret grant | `SecretsAdmitted=False`, `Ready=False`. |
33
+ | stack | all requirements satisfied | stack `Ready=True`. |
34
+ | rbac | role escalation attempted | no native binding apply; condition false; audit event. |
35
+ | secret/config | Secret key deleted | dependent stacks blocked; active runs marked stale. |
36
+ | trigger | duplicate failed check | second execution coalesces. |
37
+ | dispatch | Agent Mux unavailable | attempt remains queued/starting with retry condition. |
38
+ | dispatch | launch option rejected | attempt failed with adapter rejection reason. |
39
+ | workspace | missing worktree path | workspace missing state and recover/archive actions. |
40
+ | approval | artifact digest changed | approval decision rejected. |
41
+
42
+ ## API tests
43
+
44
+ | Route | Scenario | Expected proof |
45
+ | --- | --- | --- |
46
+ | `POST /api/agents/permissions/review` | missing Secret grant | `decision=denied`, reason includes missing grant, no secret value. |
47
+ | `POST /api/agents/runs` | valid manual dispatch | creates run + attempt before Agent Mux launch. |
48
+ | `POST /api/agents/runs` | denied RBAC | returns `403 POLICY_DENIED`. |
49
+ | `POST /api/agents/rules/:rule/dry-run` | matching CI event | returns prompt/context/dedupe/permission preview. |
50
+ | `POST /api/agents/approvals/:approval/decision` | valid approver | approval updated and write-back accepted. |
51
+ | `GET /api/watch/orgs/[org]/agentdispatchruns` | watch connected | emits initial SYNC event and resource updates. |
52
+
53
+ ## UI validation
54
+
55
+ | Surface | Scenario | Expected proof |
56
+ | --- | --- | --- |
57
+ | stack builder | missing Secret grant | blocking warning with suggested fix. |
58
+ | stack builder | ready stack | save/dispatch actions enabled by server state. |
59
+ | repo code page | manual dispatch | composer prefilled with repo/ref/path. |
60
+ | repo runs page | agent run exists | dispatch appears beside pipeline/job rows. |
61
+ | run detail | session pending | handoff state shown until session bound. |
62
+ | run detail | approval blocked | approval card and disabled write-back controls shown. |
63
+ | settings agents tab | ServiceAccount selected | RBAC/grants/runner policy visible. |
64
+ | secrets page | Secret listed | key names and consumers visible, no values. |
65
+ | permissions page | drifted RoleBinding | drift warning and fix path visible. |
66
+
67
+ ## E2E flows
68
+
69
+ ### Manual dispatch from code
70
+
71
+ 1. Create `AgentStack`, ServiceAccount, grants, and workspace policy.
72
+ 2. Open repository code page.
73
+ 3. Dispatch agent with selected path.
74
+ 4. Verify `AgentDispatchRun`, attempt, context bundle, permission snapshot, and run detail link.
75
+
76
+ ### Failed CI repair
77
+
78
+ 1. Create failed `Pipeline`/`Job` event.
79
+ 2. Trigger rule matches and creates `AgentTriggerExecution`.
80
+ 3. Dispatch appears beside pipeline.
81
+ 4. Agent produces patch artifact.
82
+ 5. Write-back requires approval.
83
+
84
+ ### Missing secret remediation
85
+
86
+ 1. Enable tool requiring Secret.
87
+ 2. Stack builder shows missing grant.
88
+ 3. Create `AgentSecretGrant` from wizard.
89
+ 4. Stack readiness turns ready.
90
+ 5. Dispatch proceeds.
91
+
92
+ ### Untrusted fork denial
93
+
94
+ 1. Simulate fork PR event.
95
+ 2. Rule selects repair stack.
96
+ 3. Permission review denies privileged ServiceAccount/Secret.
97
+ 4. UI shows untrusted-fork reason and no launch occurs.
98
+
99
+ ### Approval write-back
100
+
101
+ 1. Agent creates PR comment request.
102
+ 2. Approval inbox shows action.
103
+ 3. Maintainer approves comment only.
104
+ 4. Controller posts comment idempotently and records audit.
105
+
106
+ ## Package/chart tests
107
+
108
+ | Scenario | Expected proof |
109
+ | --- | --- |
110
+ | Agent CRDs in chart | `package:check` includes required CRDs and examples. |
111
+ | Helm values include feature gates | values validation covers Agent Mux URL, default ServiceAccount, grants. |
112
+ | Examples stay valid | examples use known kinds and required fields. |
113
+ | Docs stay linked | `validate:docs` sees all agent docs in README index. |
114
+
115
+ ## Done gate for first implementation slice
116
+
117
+ The first implementation slice is not complete until these are green:
118
+
119
+ - resource/schema tests for `AgentStack`, `AgentServiceAccount`, `AgentSecretGrant`, `AgentDispatchRun`;
120
+ - permission review API tests;
121
+ - stack builder missing-grant UI validation;
122
+ - manual dispatch API test;
123
+ - run detail pending-session UI validation;
124
+ - docs/package validation.
125
+
126
+ ## Company brain memory acceptance
127
+
128
+ | Area | Acceptance gate |
129
+ | --- | --- |
130
+ | Memory repository | can create/adopt `AgentMemoryRepository` and validate layout. |
131
+ | Ontology | invalid node kinds, edge kinds, dangling edges, and missing owners fail validation. |
132
+ | Context | dispatch bundle records requested ref, resolved commit, selected records, grep excerpts, and digests. |
133
+ | Historical refs | `refAt` resolves to the latest approved commit before timestamp and retries stay pinned. |
134
+ | Permissions | denied memory paths/kinds never leak content into preview, prompt, tools, or audit. |
135
+ | Tools | memory tools operate against dispatch snapshot and require explicit grants. |
136
+ | Updates | agent memory proposals become validated PR/update records before merge. |
137
+ | UI | `/agents/memory`, dispatch composer, run detail, and repository settings expose memory state and warnings. |
138
+
139
+ ## Org scoping acceptance
140
+
141
+ | Area | Acceptance gate |
142
+ | --- | --- |
143
+ | Namespace | creating an org creates or binds one Kubernetes namespace. |
144
+ | Repositories | repositories cannot be created without org scope. |
145
+ | Deployments | deployment/environment resources are org-scoped and namespace-bound. |
146
+ | Agents | stacks, triggers, runs, sessions, workspaces, and runners stay inside org scope. |
147
+ | Memory | company brain query/update/import cannot cross org boundaries. |
148
+ | Babysitter imports | `MEMORY.md`, sessions, journals, task results, and artifact manifests import only after redaction and org permission review. |
149
+ | UI | routes, breadcrumbs, search, and YAML panels show org and namespace. |
150
+
151
+ ## Run memory import acceptance details
152
+
153
+ | Scenario | Expected result |
154
+ | --- | --- |
155
+ | Import completed run with summary tier | creates normalized run/session/task files and opens review. |
156
+ | Import active run without policy | blocks with clear condition. |
157
+ | Import run from another org | fails with `CROSS_ORG_REF_DENIED`. |
158
+ | Import journal containing secret-like content | redacts or blocks before PR creation. |
159
+ | Import duplicate source digest | no duplicate PR; status points to existing memory commit. |
160
+ | Import with ontology error | branch may exist, merge blocked, validation report shown. |
161
+ | Query imported run memory from dispatch | selected content is pinned to memory commit and shown in context preview. |
162
+
163
+ ## Current app seam acceptance
164
+
165
+ | Area | Acceptance gate |
166
+ | --- | --- |
167
+ | Org navigation | `Agents` appears under existing org navigation and preserves current org switcher behavior. |
168
+ | Agent routes | `/orgs/[org]/agents/*` pages render only with org context and never use a global unscoped agent root as canonical. |
169
+ | Repository integration | existing repo Code, Issues, Pull Requests, Runs, Hooks, and Settings pages link to agent/memory flows with org and repo context. |
170
+ | Resource API | new agent/memory resources can be listed through `/api/orgs/[org]/resources` after resource model support. |
171
+ | Watch API | agent runs and memory imports can stream through org-scoped watch filters without cross-org leakage. |
172
+ | Route guard | run/memory detail pages reject resources whose org label or namespace does not match the route. |
173
+ | Advanced YAML | generated resource YAML includes namespace, org label, and `organizationRef`. |
174
+
175
+ ## Org memory vertical slice acceptance
176
+
177
+ | Flow | Acceptance gate |
178
+ | --- | --- |
179
+ | Bootstrap | org has namespace binding and memory repo health visible. |
180
+ | Configure | repository settings can attach an `AgentMemorySource`. |
181
+ | Dispatch | manual dispatch creates memory snapshot and context bundle. |
182
+ | Run detail | run shows memory commit, query manifest, selected excerpts, and digests. |
183
+ | Import | summary-only run import creates redacted, validated memory update. |
184
+ | Reuse | later dispatch can query imported run/session summary. |
185
+ | Isolation | another org receives `CROSS_ORG_REF_DENIED` and no memory content. |
186
+
187
+ ## E2E fixture reference
188
+
189
+ The deterministic fixture set for org memory is defined in [Org memory E2E fixture plan](./org-memory-e2e-fixture-plan.md). Acceptance tests should include duplicate repository slugs across orgs, a seed company brain repo, a redaction-bearing `.a5c` run, manual dispatch with memory, summary-only import, cross-org denial, and historical memory pinning.
190
+
191
+ ## QA matrix reference
192
+
193
+ Product-wide test coverage expectations live in `docs/tests/product-test-matrix.md`. Agent-specific rows in this matrix should be treated as future required coverage once agent resources, Agent Mux integration, company brain memory, and `.a5c` imports move from docs to implementation.
@@ -0,0 +1,167 @@
1
+ # Agent Mux adapter contract spec
2
+
3
+ ## Purpose
4
+
5
+ Krate should integrate Agent Mux without copying its whole UI or owning adapter internals. This document defines the boundary between Krate controllers and Agent Mux gateway/session/runtime capabilities.
6
+
7
+ ## Ownership split
8
+
9
+ | Concern | Krate | Agent Mux |
10
+ | --- | --- | --- |
11
+ | Repository graph | source of truth | receives context only |
12
+ | Agent stack policy | source of truth | validates adapter-specific launch options |
13
+ | RBAC/Secret/Config grants | source of truth | receives admitted references only |
14
+ | Runner/workspace policy | source of truth | may use provided cwd/runtime metadata |
15
+ | Session/chat transcript | projection/link | source of truth |
16
+ | Tool/runtime events | normalizes into run events | source of truth |
17
+ | Cancellation/resume/fork/continue | policy gate and audit | execution primitive |
18
+ | Subagents | stack definitions and telemetry projection | native or emulated dispatch mechanism |
19
+
20
+ ## Required client module
21
+
22
+ Future file:
23
+
24
+ - `src/agent-mux-client.js`
25
+
26
+ Responsibilities:
27
+
28
+ - discover adapter capabilities;
29
+ - validate launch options before dispatch;
30
+ - launch a run/session;
31
+ - bind Agent Mux run/session IDs to `AgentDispatchAttempt`;
32
+ - subscribe to events/transcript updates;
33
+ - submit continuation messages;
34
+ - cancel, retry, resume, or fork where supported;
35
+ - forward approved tool/secret/network decisions;
36
+ - normalize runtime surfaces into Krate event/artifact/workspace projections.
37
+
38
+ The module should be a thin adapter. It should not contain repository policy, RBAC decisions, trigger matching, or write-back logic.
39
+
40
+ ## Capability handshake
41
+
42
+ Krate should request capabilities for:
43
+
44
+ - supported base agents;
45
+ - models/providers;
46
+ - session persistence;
47
+ - structured event stream;
48
+ - continuation/cancel/resume/fork support;
49
+ - approval modes;
50
+ - native tools;
51
+ - MCP support;
52
+ - skill loading;
53
+ - subagent dispatch;
54
+ - workspace/cwd support;
55
+ - transcript export;
56
+ - cost/token reporting.
57
+
58
+ Capability result should be snapshotted into `AgentStack.status.capabilities` and `AgentDispatchAttempt.spec.agentStackSnapshot`.
59
+
60
+ ## Launch request contract
61
+
62
+ Krate sends only admitted, redacted launch options:
63
+
64
+ ```json
65
+ {
66
+ "agent": "claude-code",
67
+ "adapter": "agent-mux.claude-code",
68
+ "model": "claude-sonnet-4-5",
69
+ "approvalMode": "prompt",
70
+ "prompt": {
71
+ "system": "...",
72
+ "developer": "...",
73
+ "task": "..."
74
+ },
75
+ "cwd": "/workspaces/krate-pr-42",
76
+ "contextBundle": {
77
+ "digest": "sha256:...",
78
+ "attachments": []
79
+ },
80
+ "tools": [],
81
+ "mcpServers": [],
82
+ "skills": [],
83
+ "subagents": [],
84
+ "runtimeIdentity": {
85
+ "serviceAccountRef": "agent-claude-code-ci-repair"
86
+ },
87
+ "secretRefs": [
88
+ {
89
+ "grant": "claude-code-anthropic-api-key",
90
+ "secretRef": "krate-secrets/anthropic-provider",
91
+ "keys": ["api-key"],
92
+ "mountPolicy": "env"
93
+ }
94
+ ],
95
+ "configRefs": [],
96
+ "metadata": {
97
+ "krateDispatchRun": "adr-01hx",
98
+ "krateAttempt": "ada-01hx-1",
99
+ "repository": "krate",
100
+ "sourceRef": "pullrequest/42"
101
+ }
102
+ }
103
+ ```
104
+
105
+ Secret values are never in the request body unless the Agent Mux deployment mode explicitly requires value materialization inside a trusted server-side process; even then values must not pass through browser/UI APIs.
106
+
107
+ ## Launch response contract
108
+
109
+ ```json
110
+ {
111
+ "agentMuxRunId": "run_01hx",
112
+ "agentMuxSessionId": "ses_01hx",
113
+ "status": "running",
114
+ "eventCursor": "0000001",
115
+ "capabilitiesSnapshotDigest": "sha256:..."
116
+ }
117
+ ```
118
+
119
+ Krate persists these IDs in `AgentDispatchAttempt.status` and renders links into run/session pages.
120
+
121
+ ## Event normalization
122
+
123
+ Agent Mux events should map into Krate event types:
124
+
125
+ | Agent Mux event | Krate projection |
126
+ | --- | --- |
127
+ | run queued/started | attempt phase, queue timing |
128
+ | session created | `AgentSession` link and `AgentMuxSessionBound=True` |
129
+ | assistant/user message | transcript projection only |
130
+ | tool call started/completed | event timeline and optional `AgentApproval` |
131
+ | subagent started/completed | child subagent lane/event/artifact |
132
+ | file changed/patch produced | `AgentArtifact` |
133
+ | runtime preview/dev server | `AgentWorkspace.status.runtime` |
134
+ | approval requested | `AgentApproval` |
135
+ | cost/tokens | `AgentDispatchRun.status.cost` |
136
+ | terminal result | attempt/run terminal phase |
137
+
138
+ ## Error handling
139
+
140
+ | Error | Krate behavior |
141
+ | --- | --- |
142
+ | gateway unavailable | keep attempt queued/starting with retry condition. |
143
+ | capability unavailable | stack `CapabilitiesResolved=False`. |
144
+ | launch rejected | fail attempt with adapter rejection and snapshot request digest. |
145
+ | session binding missing | show pending handoff and retry binding. |
146
+ | event stream disconnect | mark stream stale and reconnect from cursor when possible. |
147
+ | unsupported action | disable action based on capability, not UI-only logic. |
148
+
149
+ ## Security requirements
150
+
151
+ - Agent Mux receives only resources admitted by Krate policy.
152
+ - Krate stores Agent Mux IDs but does not treat Agent Mux storage as repository source of truth.
153
+ - Continuation messages must run permission review if they request new tools, files, secrets, configs, or write-back targets.
154
+ - Agent Mux transcript must not expose Secret values.
155
+ - Agent Mux approval prompts must map back to `AgentApproval` for audit when they affect Krate-owned actions.
156
+
157
+ ## UI embedding
158
+
159
+ Krate should embed Agent Mux primitives as panels:
160
+
161
+ - transcript/conversation panel;
162
+ - event/observability timeline;
163
+ - runtime/workspace panel;
164
+ - approval/tool activity panel;
165
+ - subagent tree/lane panel.
166
+
167
+ Krate navigation, breadcrumbs, permissions, and source-object hierarchy remain native Krate UI.