@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,78 @@
1
+ # Architecture Spec
2
+
3
+ ## Overview
4
+
5
+ Krate splits forge responsibilities into a Kubernetes API control plane, Argo CD GitOps reconciliation, and a Gitea-backed Git data plane. The control plane provides resource semantics, RBAC, admission, watch, and declarative automation. Argo CD owns application sync/prune/self-heal, while Gitea serves Git traffic, repository storage, SSH keys, collaborators/teams, branch protection, webhooks, object storage metadata, and code search hooks.
6
+
7
+ ## Control plane
8
+
9
+ Krate keeps the HTTP API controller role separate from Kubernetes resource ownership. The Krate API controller owns route-level orchestration, request validation, workflow-shaped responses, degraded-state errors, and UI affordances. It delegates Kubernetes intent to a narrow resource gateway, and that gateway calls the Kubernetes resource client for list/get/apply/delete/watch and SubjectAccessReview checks. The Kubernetes resource client is the only layer that shells out to `kubectl` in the local implementation and does not own UI flow decisions or product workflows. Git smart-HTTP and SSH traffic remain outside those control-plane roles and cross only the Git data-plane boundary.
10
+
11
+ The control plane exposes two API classes:
12
+
13
+ - CRDs for low-cardinality declarative configuration: `Repository`, `WebhookSubscription`, `RefPolicy`, `BranchProtection`, `RunnerPool`, `View`, and `Selector`.
14
+ - Aggregated API resources for high-cardinality records: `PullRequest`, `Issue`, `Review`, `Pipeline`, `Job`, and `WebhookDelivery`.
15
+
16
+ The aggregated API server must preserve `kubectl` ergonomics while storing records in Postgres. This avoids using etcd as the database for comments, reviews, CI logs, and delivery records.
17
+
18
+ ## Data plane
19
+
20
+ The data plane consists of:
21
+
22
+ - Gitea backend: Kubernetes-hosted Git server for smart-HTTP/SSH, repository APIs, SSH deploy keys, collaborators/teams, protected branches, and webhooks.
23
+ - Repository storage: Gitea-managed persistent storage on Kubernetes volumes.
24
+ - Object Storage: LFS objects, archives, artifacts, and large immutable blobs.
25
+ - Code Search: Zoekt service/indexer per repository cohort in documented post-MVP roadmap stages.
26
+
27
+ Routing resolves repository identity to the Gitea backend and records object/search placement separately. A single Gitea backend is enough for MVP, but the API and status model must not prevent future scale-out.
28
+
29
+ ## Scaling model
30
+
31
+ - `git-upload-pack` reads scale horizontally on request rate.
32
+ - `git-receive-pack` writes target the Gitea backend and keep the receive path warm for backlog handling.
33
+ - Search indexers scale independently from Gitea backends and API servers.
34
+ - Runner pools scale by queue depth with `warmReplicas` and `maxReplicas`.
35
+
36
+ ## Identity and authz flow
37
+
38
+ 1. A human signs in with OIDC.
39
+ 2. The UI exchanges or maps that identity into Kubernetes-compatible user/group identity.
40
+ 3. Server Components and route handlers call the API server with the user identity.
41
+ 4. Kubernetes RBAC and admission decide whether the action is allowed.
42
+ 5. CI jobs receive projected ServiceAccount tokens scoped to the pipeline/job context.
43
+
44
+ ## Policy model
45
+
46
+ - Branch and ref policy: `RefPolicy` CRDs reconcile into Gitea-backed branch protection and receive-pack policy checks.
47
+ - Outbound integrations: `WebhookSubscription` resources delivered through a durable queue and represented as `WebhookDelivery` records.
48
+ - Resource policy: Kubernetes admission webhooks validate and mutate Krate API resources directly.
49
+
50
+ ## UI architecture
51
+
52
+ The UI uses Next.js App Router. Server Components fetch directly from the Kubernetes/aggregated API. Watch streams are converted to SSE through route handlers. The Git proxy route streams smart-HTTP to the Gitea-backed data plane. Monaco or CodeMirror powers diff and code views.
53
+
54
+ ## Deployment topology
55
+
56
+ Minimum deployment includes:
57
+
58
+ - APIService and aggregated API server.
59
+ - CRDs and conversion/defaulting as needed.
60
+ - Postgres.
61
+ - Controllers/operators.
62
+ - Gitea backend.
63
+ - Argo CD Application for GitOps reconciliation.
64
+ - Object storage configuration.
65
+ - Next.js UI.
66
+ - Optional NATS, Kyverno, ARC, and ingress components depending on profile.
67
+
68
+ ## Implemented controller boundary proof
69
+
70
+ The executable MVP keeps four controller-adjacent roles separate in code and tests:
71
+
72
+ - `krate-api-controller` is the HTTP/application facade. It owns request validation, workflow-shaped repository DTOs, API errors, degraded-state responses, and UI snapshot composition. It must not shell out to `kubectl`, own watch internals, or schedule reconciliation loops.
73
+ - `kubernetes-resource-gateway` is the narrow application port for Kubernetes resource operations. It owns list/get/apply/delete/watch delegation and Repository manifest application, but not page-flow or forge DTO decisions.
74
+ - `kubernetes-resource-client` owns local `kubectl` execution, SubjectAccessReview checks, Kubernetes API discovery, resource apply/delete, and watch streams.
75
+ - `krate-kubernetes-reconciler` owns Repository status projection, Gitea hosting intent, policy projection, and data-plane sync intent. It must not own HTTP routes or browser flows.
76
+
77
+ `tests/krate.test.js` locks these boundaries with contract tests, while `scripts/validate-ui.mjs` checks that the UI model exposes the API controller, resource gateway, Kubernetes client, Kubernetes reconciler, and Git data-plane lanes.
78
+
@@ -0,0 +1,78 @@
1
+ # Control Plane Component Requirements
2
+
3
+ ## Purpose
4
+
5
+ The control plane makes Krate a Kubernetes API extension rather than a forge with Kubernetes integrations. It owns resource semantics, RBAC, admission, watch behavior, reconciliation entry points, and storage boundaries.
6
+
7
+ ## Responsibilities
8
+
9
+ - Serve low-cardinality configuration as CRDs.
10
+ - Serve high-cardinality social and execution records through an aggregated API server backed by Postgres.
11
+ - Preserve Kubernetes API ergonomics for `kubectl`, controllers, admission, and watch clients.
12
+ - Coordinate with repository, PR, runner, webhook, and policy controllers.
13
+
14
+ ## API and resource surface
15
+
16
+ CRDs:
17
+
18
+ - `Repository`
19
+ - `WebhookSubscription`
20
+ - `RefPolicy`
21
+ - `BranchProtection`
22
+ - `View` and `Selector`
23
+
24
+ Aggregated resources:
25
+
26
+ - `PullRequest`
27
+ - `Issue`
28
+ - `Review`
29
+ - `Pipeline`
30
+ - `Job`
31
+ - `RunnerPool`
32
+ - `WebhookDelivery`
33
+
34
+ ## Requirements
35
+
36
+ - The aggregated API server must support Kubernetes discovery and normal verbs for relevant resources.
37
+ - High-cardinality resources must not store primary records in etcd.
38
+ - Resource schemas must expose status fields that controllers and UI can watch.
39
+ - Status updates must be safe for concurrent controller writes.
40
+ - API resources must be label-selectable for workflows such as similar run search and failed webhook queries.
41
+
42
+ ## Dependencies
43
+
44
+ - kube-apiserver aggregation layer.
45
+ - Postgres for high-cardinality records.
46
+ - etcd for CRD-backed config only.
47
+ - Admission webhook ecosystem.
48
+ - Controllers for repositories, PRs, runners, and webhooks.
49
+
50
+ ## Security and policy
51
+
52
+ - Authorization must be Kubernetes RBAC, not app-local permission logic.
53
+ - Admission must be able to validate PR, issue, pipeline, and job resources.
54
+ - Audit logs must identify the Kubernetes user/group or ServiceAccount behind each mutation.
55
+
56
+ ## Scaling and performance
57
+
58
+ - API server must support watch streams for UI and controller clients.
59
+ - Postgres indexes must support list, watch bookmarks, labels, field selectors, and common PR/pipeline queries.
60
+ - API latency targets must be separated from Git data-plane latency targets.
61
+
62
+ ## Failure modes
63
+
64
+ - Postgres unavailable: aggregated resources are degraded; CRD config remains discoverable.
65
+ - APIService unavailable: UI and kubectl operations for aggregated resources fail clearly.
66
+ - Admission failure: resource creation must fail closed for enforcing policies and expose actionable status.
67
+
68
+ ## Observability
69
+
70
+ - Request latency, error rate, watch count, storage latency, admission latency, and reconciliation lag.
71
+ - Kubernetes events for controller and API storage errors.
72
+
73
+ ## Acceptance criteria
74
+
75
+ - `kubectl get repositories` and `kubectl get pullrequests` work.
76
+ - Creating a PR can be blocked by a Kyverno policy.
77
+ - PR/comment/review scale tests do not grow etcd as the primary database.
78
+ - UI can watch PR and pipeline updates through the same API resources.
@@ -0,0 +1,69 @@
1
+ # Data Plane Component Requirements
2
+
3
+ ## Purpose
4
+
5
+ The data plane serves Git repositories through a Kubernetes-hosted Gitea backend while avoiding the impossible one-PVC-per-repository model. It separates Kubernetes resource intent from Gitea repository hosting, persistent storage, object storage metadata, and code search hooks.
6
+
7
+ ## Responsibilities
8
+
9
+ - Terminate smart-HTTP and SSH Git traffic through Gitea.
10
+ - Map repository identity to the Gitea backend and integration plan.
11
+ - Store repositories in Gitea-managed persistent Kubernetes storage.
12
+ - Store LFS objects, archives, and other large immutable objects in object storage.
13
+ - Expose indexing hooks for Zoekt search.
14
+
15
+ ## API and resource surface
16
+
17
+ - Repository status must include Gitea backend integration and health.
18
+ - Gitea integration API must support route lookup, repo initialization, access checks, deploy keys, permissions, webhooks, and maintenance operations.
19
+ - Gitea must expose smart-HTTP and SSH entry points and API-backed repository integration.
20
+
21
+ ## Requirements
22
+
23
+ - MVP must support a Kubernetes-hosted Gitea backend for `git-upload-pack`, `git-receive-pack`, SSH keys, permissions, protected branches, and webhooks.
24
+ - Architecture must allow Gitea backend scale-out without changing repository APIs.
25
+ - Writes must keep warm capacity; push traffic must not scale from zero.
26
+ - Reads may scale horizontally behind HPA.
27
+ - Receive-pack must evaluate compiled ref policy before accepting protected ref updates.
28
+
29
+ ## Dependencies
30
+
31
+ - RWX storage class such as EFS or CephFS.
32
+ - Object storage for LFS and archives.
33
+ - Repository operator for Gitea initialization and integration planning.
34
+ - Identity/RBAC checks from control plane.
35
+ - Optional Zoekt search service.
36
+
37
+ ## Security and policy
38
+
39
+ - Git operations must authorize against Kubernetes identity and repository policy.
40
+ - Custom hook execution must be sandboxed through WASM.
41
+ - Gitea backend pods must mount only needed config, credentials, and repository storage.
42
+
43
+ ## Scaling and performance
44
+
45
+ - Each Gitea backend target is capacity-planned by repository count, storage, and I/O profiles.
46
+ - `git-upload-pack` scales on request rate.
47
+ - `git-receive-pack` scales on backlog with warm minimums.
48
+ - Search indexing must not starve Git read/write traffic.
49
+
50
+ ## Failure modes
51
+
52
+ - Gitea backend unavailable: affected repositories show degraded status and API routes return actionable errors.
53
+ - RWX volume degraded: writes pause or fail closed to protect repository integrity.
54
+ - Object store unavailable: LFS/archive operations degrade separately from core Git refs where possible.
55
+ - Gitea route cannot resolve repository: request fails with correlation ID and resource status pointer.
56
+
57
+ ## Observability
58
+
59
+ - Git operation latency and error rate by operation, repository, and Gitea backend.
60
+ - Gitea repository storage usage, inode usage, I/O wait, queue depth, and policy rejection count.
61
+ - Gitea route-cache hit rate and backend health.
62
+
63
+ ## Acceptance criteria
64
+
65
+ - `git clone`, `git fetch`, and `git push` work against a repository created by `kubectl`.
66
+ - A protected branch update can be blocked by `RefPolicy`.
67
+ - Read traffic can scale without adding repository PVCs.
68
+ - Repository status exposes Gitea backend integration and health.
69
+
@@ -0,0 +1,67 @@
1
+ # Hooks and Events Component Requirements
2
+
3
+ ## Purpose
4
+
5
+ Krate separates three commonly conflated hook mechanisms: server-side Git hooks, outbound HTTP webhooks, and Kubernetes admission webhooks. Each must have its own lifecycle, security model, observability, and UI surface.
6
+
7
+ ## Responsibilities
8
+
9
+ - Model branch/ref behavior with `RefPolicy`.
10
+ - Compile server-side policies into Gitea-backed receive-pack policy config.
11
+ - Execute custom Git hooks in a WASM sandbox.
12
+ - Deliver outbound webhooks durably with retries, signing, and replay.
13
+ - Surface admission policies affecting Krate resources.
14
+
15
+ ## API and resource surface
16
+
17
+ - `RefPolicy`: require commit signing, block force-pushes, require linear history, and future custom WASM hooks.
18
+ - `WebhookSubscription`: endpoint, events, scope, secret reference, retry policy.
19
+ - `WebhookDelivery`: request, response, status, latency, retry chain, replay metadata.
20
+ - Admission policies: Kyverno/Gatekeeper/native policies applying to Krate resources.
21
+
22
+ ## Requirements
23
+
24
+ - Server-side Git policy must run inside receive-pack and fail closed for protected refs.
25
+ - Outbound delivery must use durable queueing with exponential backoff.
26
+ - Deliveries must be HMAC-signed.
27
+ - Delivery logs must be queryable with `kubectl` and visible in UI.
28
+ - Admission policies must show in a repo Hooks & Policies view when they affect the repository.
29
+
30
+ ## Dependencies
31
+
32
+ - Gitea repositories and Git receive-pack.
33
+ - ConfigMap or mounted policy bundle distribution.
34
+ - NATS JetStream or equivalent durable queue.
35
+ - Secret storage for webhook signing.
36
+ - Kyverno, Gatekeeper, or Kubernetes admission APIs.
37
+
38
+ ## Security and policy
39
+
40
+ - Custom hooks must not shell out or mount broad secrets.
41
+ - Webhook secrets must support rotation.
42
+ - Replay must use current secrets and record a new delivery attempt.
43
+ - Policy authoring must support audit mode before enforce mode.
44
+
45
+ ## Scaling and performance
46
+
47
+ - Git hook evaluation must add bounded latency to receive-pack.
48
+ - Webhook queueing must absorb bursts without blocking Git operations.
49
+ - Delivery log queries must be indexed by repo, subscription, status, event type, and time.
50
+
51
+ ## Failure modes
52
+
53
+ - Policy compilation fails: old valid policy remains active and status reports stale/error.
54
+ - Webhook endpoint down: retries continue and delivery status records failure chain.
55
+ - Queue unavailable: new deliveries fail or buffer according to configured durability mode.
56
+ - Admission policy misconfigured: audit preview helps identify impact before enforcement.
57
+
58
+ ## Observability
59
+
60
+ - Hook evaluation latency, policy rejection count, webhook delivery success/failure, retry count, endpoint latency, policy violation count.
61
+
62
+ ## Acceptance criteria
63
+
64
+ - `RefPolicy` can block force-push to main.
65
+ - Webhook test delivery appears in `WebhookDelivery` within seconds.
66
+ - Failed deliveries expose request, response, latency, retries, and replay action.
67
+ - Kyverno PR policy appears in the Hooks tab and can block PR creation.
@@ -0,0 +1,73 @@
1
+ # Identity, RBAC, and Policy Component Requirements
2
+
3
+ ## Purpose
4
+
5
+ Krate inherits Kubernetes identity, RBAC, admission, and audit so the forge does not create a parallel permission system. Human actions and CI actions must be attributable to Kubernetes users, groups, or ServiceAccounts.
6
+
7
+ ## Responsibilities
8
+
9
+ - Authenticate humans with GitHub OAuth, optional installation-configured SSO, or a delegated identity proxy.
10
+ - Store `User`, `Team`, `Invite`, `IdentityMapping`, and `AuthProvider` resources as the Krate source of truth.
11
+ - Manage native Kubernetes `ServiceAccount`, `Role`, `ClusterRole`, `RoleBinding`, and `ClusterRoleBinding` projections for users, teams, agents, and runners.
12
+ - Map human users and groups into Kubernetes identities and repository identities.
13
+ - Use TokenRequest or equivalent delegation for UI-to-API calls.
14
+ - Issue scoped ServiceAccount identities for CI jobs, agent dispatch attempts, and runner pools.
15
+ - Enforce trust tiers and policy through admission.
16
+
17
+ ## API and resource surface
18
+
19
+ - `User`, `Team`, `Invite`, `IdentityMapping`, and `AuthProvider` CRDs.
20
+ - RBAC Roles/ClusterRoles for forge resources.
21
+ - ServiceAccounts for runner pools, jobs, and agent stacks.
22
+ - Agent RBAC management resources such as `AgentServiceAccount`, `AgentRoleBinding`, `AgentSecretGrant`, and `AgentConfigGrant`.
23
+ - Admission policies for `PullRequest`, `Pipeline`, `Job`, and related resources.
24
+ - Policy templates for common PR and runner constraints.
25
+
26
+ ## Requirements
27
+
28
+ - No core workflow may require PATs.
29
+ - UI permission checks must be server-enforced by Kubernetes API calls.
30
+ - Fork PR pipelines must run as untrusted jobs with no secrets and no cluster API access.
31
+ - Runner trust tier must be admitted and enforced before scheduling.
32
+ - Activity records must be traceable to Kubernetes identity.
33
+
34
+ ## Dependencies
35
+
36
+ - GitHub OAuth app and optional OIDC/SSO provider configured through Helm values.
37
+ - Kubernetes TokenRequest API.
38
+ - Kubernetes RBAC.
39
+ - Kyverno, Gatekeeper, or native ValidatingAdmissionPolicy where available.
40
+ - Runner controller and scheduler.
41
+
42
+ ## Security and policy
43
+
44
+ - Secrets may only be mounted into trusted jobs or agent dispatches that satisfy repo/ref/pipeline/trigger constraints and explicit Secret grants.
45
+ - ConfigMaps used by tools, skills, MCP servers, agents, and runners must be admitted through explicit ConfigMap grants when they affect execution.
46
+ - Untrusted jobs must not be able to mutate cluster resources.
47
+ - Policy bypass must require explicit RBAC grants and be auditable.
48
+ - Admission failures must return clear user-facing messages.
49
+
50
+ ## Scaling and performance
51
+
52
+ - Token exchange and authorization must not become the UI bottleneck.
53
+ - RBAC and admission checks must be cached only where safe and must respect revocation semantics.
54
+
55
+ ## Failure modes
56
+
57
+ - OIDC provider unavailable: new logins fail; existing sessions follow configured token lifetime.
58
+ - TokenRequest fails: UI actions fail closed.
59
+ - Admission webhook unavailable: enforcement policies fail according to Kubernetes failure policy.
60
+ - RBAC misconfiguration: UI must surface denied actions without hiding the underlying resource.
61
+
62
+ ## Observability
63
+
64
+ - Auth failures, token exchange latency, RBAC denied counts, admission decisions, and trust-tier violations.
65
+ - Audit events for privileged changes and policy bypass.
66
+
67
+ ## Acceptance criteria
68
+
69
+ - An admin can invite users, manage teams, map sign-in identities, grant repository access, manage agent/runner ServiceAccounts, and bind native Kubernetes roles from the Krate UI.
70
+ - A user can perform allowed PR actions based on Kubernetes RBAC.
71
+ - A user is denied forbidden actions by the API server, not UI-only logic.
72
+ - An untrusted fork PR cannot access secrets or privileged agent/runner ServiceAccounts.
73
+ - A Kyverno policy can require PR descriptions or reviewer rules.
@@ -0,0 +1,70 @@
1
+ # KubeVela and OAM Integration
2
+
3
+ Krate expands from a Git forge into an application delivery forge by installing KubeVela as an optional-but-first-class control-plane dependency and by assimilating the Open Application Model (OAM) into the Krate ontology.
4
+
5
+ ## Scope
6
+
7
+ Krate will install and manage KubeVela from the deployed stack when `kubevela.enabled=true`. The default deployment path uses Argo CD to install the upstream `vela-core` Helm chart into `vela-system`, keeping the dependency GitOps-managed beside the Krate chart. KubeVela remains the owner of OAM runtime reconciliation; Krate wraps the experience with forge-native repository, pull request, environment, and pipeline flows.
8
+
9
+ ## OAM Concepts Assimilated
10
+
11
+ - **Application**: the deployable unit composed from components, traits, workflow, policies, and scopes.
12
+ - **Component**: the reusable workload module selected by a developer or platform team.
13
+ - **Trait**: operational behavior attached to a component, such as ingress, scaler, rollout, or service binding.
14
+ - **Scope**: grouping/boundary metadata for components, such as environment, network, or health grouping.
15
+ - **Workflow step**: ordered delivery operation; Krate maps PR checks, preview deployment, promotion, rollback, and teardown into workflow steps.
16
+ - **Definition**: platform capability catalog entry, exposed by KubeVela as component, trait, policy, and workflow step definitions.
17
+
18
+
19
+ ## OAM Spec Traceability
20
+
21
+ Krate tracks the upstream OAM v0.3.0 model entities directly while using KubeVela's newer delivery extensions where available:
22
+
23
+ | OAM spec entity | KubeVela/Kubernetes surface | Krate UI responsibility |
24
+ | --- | --- | --- |
25
+ | `Application` | `applications.core.oam.dev` in the forge namespace | Create from a repository, show status, workflow, component, trait, and scope projection. |
26
+ | `ComponentDefinition` | `componentdefinitions.core.oam.dev` in `vela-system` | Populate component-type selectors instead of hard-coding only `webservice`. |
27
+ | `WorkloadDefinition` | `workloaddefinitions.core.oam.dev` in `vela-system` when installed | Explain the Kubernetes workload implementation behind a component. |
28
+ | `TraitDefinition` | `traitdefinitions.core.oam.dev` in `vela-system` | Attach operational overlays such as scaler, ingress, rollout, and service binding. |
29
+ | `ScopeDefinition` | `scopedefinitions.core.oam.dev` in `vela-system` when installed | Expose grouping boundaries such as health scopes or environment scopes. |
30
+ | KubeVela policy/workflow extensions | `policydefinitions.core.oam.dev`, `policies.core.oam.dev`, `workflowstepdefinitions.core.oam.dev`, and `workflows.core.oam.dev` | Wrap promotion, approval, rollback, topology, and override flows as forge actions. |
31
+ | KubeVela runtime graph | `applicationrevisions.core.oam.dev` and cluster-scoped `resourcetrackers.core.oam.dev` | Show revision success and applied-resource ownership without Krate owning reconciliation. |
32
+
33
+ The OAM spec notes that `Application` supersedes the earlier `ApplicationConfiguration` name. Krate uses `Application.core.oam.dev/v1beta1` for all generated manifests and keeps ApplicationConfiguration only as legacy terminology in documentation.
34
+
35
+ ## Deployment Contract
36
+
37
+ Krate chart values define the KubeVela dependency:
38
+
39
+ ```yaml
40
+ kubevela:
41
+ enabled: true
42
+ namespace: vela-system
43
+ chart:
44
+ repoURL: https://kubevela.github.io/charts
45
+ chart: vela-core
46
+ targetRevision: "1.10.8"
47
+ addons:
48
+ fluxcd:
49
+ enabled: true
50
+ onlyHelmComponents: true
51
+ ```
52
+
53
+ The chart renders an Argo CD `Application` for KubeVela. The Krate controller discovers KubeVela CRDs through Kubernetes API discovery and exposes definition resources, OAM Applications, ApplicationRevisions, standalone Policy/Workflow resources, and cluster-scoped ResourceTrackers through the same `/api/controller` model used by repositories, issues, PRs, and pipelines.
54
+
55
+ ## Forge Experience
56
+
57
+ Krate UI wraps KubeVela as an application delivery surface:
58
+
59
+ 1. A repository page can propose an OAM Application from the repo, branch, image, Helm chart, or service template.
60
+ 2. Pull requests can attach a preview OAM Application and show the KubeVela workflow status beside checks and reviews.
61
+ 3. The Applications page lists OAM Applications, components, traits, policies, and workflow steps without requiring users to learn raw CRDs first.
62
+ 4. YAML remains available for escape hatches: every generated OAM resource shows the Kubernetes object and `kubectl apply` equivalent.
63
+ 5. Promotion and rollback are modeled as forge actions but delegated to KubeVela Application workflow/status reconciliation.
64
+
65
+ ## Boundaries
66
+
67
+ - Krate owns forge UX, repository-to-application intent, GitOps handoff, PR annotations, and Kubernetes-native API projection.
68
+ - KubeVela owns OAM Application reconciliation, component/trait/policy/workflow definitions, and runtime status.
69
+ - Argo CD owns installing KubeVela and reconciling Krate chart manifests.
70
+ - Gitea owns Git hosting, SSH keys, repo permissions, issues, and pull requests.
@@ -0,0 +1,81 @@
1
+ # Operations and Publishing Component Requirements
2
+
3
+ ## Purpose
4
+
5
+ Operations and publishing turn Krate from an architecture into an installable, upgradeable, observable system. The MVP must ship as a Helm chart with a reproducible demo and production-shaped configuration paths.
6
+
7
+ ## Responsibilities
8
+
9
+ - Package images, charts, CRDs, APIService, controllers, UI, Gitea backend, and Argo CD workloads.
10
+ - Document install profiles and dependencies.
11
+ - Define upgrade, rollback, backup, restore, and support expectations.
12
+ - Provide release readiness gates and smoke tests.
13
+
14
+ ## Publish surface
15
+
16
+ - Container images for aggregated API server, controllers, Gitea backend, UI, webhook delivery worker, and optional indexers.
17
+ - Helm chart with CRDs, RBAC, ServiceAccounts, Deployments, Services, APIService, Gitea backend, Argo CD Application, config, and optional templates.
18
+ - Example manifests for repository, PR policy, runner pool, webhook, and demo workflow.
19
+
20
+ ## Requirements
21
+
22
+ - `helm install krate` must install the MVP in a documented cluster profile.
23
+ - Chart values must allow BYO Argo CD, Gitea, Postgres, object storage, RWX storage class, ingress, OIDC provider, ARC, NATS, Kyverno, and Gatekeeper.
24
+ - Demo mode must be explicit and not confused with production defaults.
25
+ - Production install docs must call out HA, storage, backup, secrets, and network requirements.
26
+ - Upgrade docs must describe CRD, Postgres, controller, Gitea backend, and Argo CD rollouts.
27
+
28
+ ## Dependencies
29
+
30
+ - Kubernetes cluster with API aggregation support.
31
+ - RWX storage provider.
32
+ - Postgres.
33
+ - Object storage.
34
+ - OIDC provider.
35
+ - Optional NATS JetStream, ARC, Kyverno/Gatekeeper, ingress controller, cert-manager.
36
+
37
+ ## Security and policy
38
+
39
+ - Helm chart must install least-privilege RBAC.
40
+ - Secrets must be configurable through existing cluster secret management.
41
+ - Default network policies should separate API, UI, data-plane, and storage paths where possible.
42
+ - Release artifacts must be signed or checksummed.
43
+
44
+ ## Scaling and performance
45
+
46
+ - Chart values must expose replica counts and autoscaling knobs for API server, UI, Gitea backend, runner workers, and delivery workers.
47
+ - Gitea backend sizing guidance must include repository count, storage, and I/O considerations.
48
+ - Runner pool defaults must distinguish trusted warm capacity from untrusted cold starts.
49
+
50
+ ## Failure modes
51
+
52
+ - Failed install: Helm output and events identify missing dependencies.
53
+ - Failed migration: release blocks or rolls back before incompatible controllers start.
54
+ - Failed Gitea rollout: receive-pack writes are protected from corruption.
55
+ - Failed dependency: status pages and docs point to the exact degraded capability.
56
+
57
+ ## Observability
58
+
59
+ - Default ServiceMonitor/PodMonitor templates where Prometheus is available.
60
+ - Example dashboards for API, Git data plane, runners, webhooks, and storage.
61
+ - Log correlation IDs across UI, API, Gitea backend, and delivery worker.
62
+
63
+ ## Acceptance criteria
64
+
65
+ - Clean install creates all required Kubernetes resources.
66
+ - Smoke test creates repository, pushes code, opens PR, runs CI, and applies a policy.
67
+ - Backup and restore docs exist and are testable.
68
+ - Release checklist gates chart, images, CRDs, migration, security, and docs.
69
+
70
+ ## Repository package artifacts
71
+
72
+ The repository now includes a verified Kubernetes package lifecycle:
73
+
74
+ - `charts/krate` provides the Helm-style chart surface with CRDs, APIService, RBAC, service accounts, workloads, services, a Gitea backend, an Argo CD Application surface, and network policy defaults.
75
+ - `examples/minikube-demo.yaml` and `examples/policy-kyverno-pr-title.yaml` provide demo install resources.
76
+ - `scripts/setup-minikube.mjs` provides dry-run and apply modes for local minikube setup.
77
+ - `npm run e2e` validates the chart and minikube command plan without requiring a live cluster.
78
+ - `npm run package:check` validates chart structure and npm pack contents.
79
+
80
+ This is a production-shaped package contract for the executable Kubernetes-native model. Controller image build/publish, chart packaging, npm package validation, generated dist/example artifacts, UI build artifacts, and AKS Helm deployments for develop/staging/main are wired through `.github/workflows/publish.yml` with safe PR/branch/tag gates. Live-cluster conformance now runs through the branch deployment lane for `krate-develop.a5c.ai`, `krate-staging.a5c.ai`, and `krate.a5c.ai`.
81
+
@@ -0,0 +1,66 @@
1
+ # Runners and CI Component Requirements
2
+
3
+ ## Purpose
4
+
5
+ Krate treats runners as a first-class forge domain while delegating execution to systems such as ARC, Tekton, or Buildkite Agent. The forge owns identity, caching, trust boundaries, cost attribution, and run UX.
6
+
7
+ ## Responsibilities
8
+
9
+ - Define `RunnerPool`, `Pipeline`, and `Job` resources.
10
+ - Schedule jobs into trusted or untrusted pools.
11
+ - Integrate with ARC for MVP execution.
12
+ - Provide live run state, logs, rerun controls, queue metrics, and cost visibility.
13
+ - Scope caches by repository and pool.
14
+
15
+ ## API and resource surface
16
+
17
+ - `RunnerPool`: image, resources, node selector, scaling policy, allowed repos, trust tier, serviceAccountRef, cache backend, warm/max replicas.
18
+ - `Pipeline`: CI invocation, workflow file, repository/ref, runner pool, resume controls, status.
19
+ - `Job`: step execution, runner pod owner, logs/status, identity, cache bindings.
20
+
21
+ ## Requirements
22
+
23
+ - Trusted pools default to warm replicas for low latency.
24
+ - Untrusted pools may scale from zero for safety and cost.
25
+ - Admission must prevent untrusted code from scheduling on trusted pools.
26
+ - BuildKit cache must be scoped per repo and pool, never shared across trust tiers.
27
+ - Rerun failed and rerun from step must create new Pipeline resources.
28
+
29
+ ## Dependencies
30
+
31
+ - ARC for MVP.
32
+ - KEDA for queue-depth scaling.
33
+ - Kubernetes Pods and ServiceAccounts.
34
+ - S3-compatible cache backend.
35
+ - Watch/SSE bridge for UI updates.
36
+
37
+ ## Security and policy
38
+
39
+ - Job pods receive projected ServiceAccount tokens scoped to repo/ref/pipeline, and agent runner pods receive identities admitted by `AgentServiceAccount`/`AgentRoleBinding` policy.
40
+ - Trusted jobs may receive configured secrets through explicit Secret grants; untrusted jobs receive none.
41
+ - Runner images and node selectors must be policy-controlled.
42
+ - Cost and cache data must not leak across tenants.
43
+
44
+ ## Scaling and performance
45
+
46
+ - Pool dashboard must show warm/total replicas, queue depth, p50/p95 wait time, and last-hour cost.
47
+ - KEDA scales between `warmReplicas` and `maxReplicas` based on queue depth.
48
+ - Log streaming must be near real-time through Kubernetes Pod log watch and SSE.
49
+
50
+ ## Failure modes
51
+
52
+ - Queue saturation: UI explains bottleneck with queue and node events.
53
+ - Image pull failure: live run view surfaces pod events and failing image.
54
+ - Node pressure: pool dashboard links to scheduling and node pressure signals.
55
+ - Cache backend unavailable: jobs run without cache or fail according to pool policy.
56
+
57
+ ## Observability
58
+
59
+ - Queue depth, wait latency, job duration, pod scheduling latency, image pull latency, cache hit rate, cost by pool/repo, failure signatures.
60
+
61
+ ## Acceptance criteria
62
+
63
+ - ARC-backed workflow runs for a repository.
64
+ - Fork PR jobs are admitted only into untrusted pools.
65
+ - Live run view streams logs and step status.
66
+ - Similar-failure search works by `failure.signature` labels.