@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,81 @@
1
+ # Security, auth, and permissions
2
+
3
+ ## Purpose
4
+
5
+ External backend integration introduces provider tokens, webhooks, native permissions, and bidirectional writes. This document defines the security model.
6
+
7
+ ## Auth principles
8
+
9
+ - Prefer GitHub Apps over PATs.
10
+ - Store app IDs, private keys, webhook secrets, and client secrets in Kubernetes Secrets.
11
+ - Never store provider access tokens in resource status.
12
+ - Installation tokens are short-lived and cached in memory only when possible.
13
+ - User-attributed writes require both Krate authorization and provider user authorization.
14
+
15
+ ## Secret resources
16
+
17
+ ```yaml
18
+ kind: Secret
19
+ metadata:
20
+ name: github-app-a5c
21
+ namespace: krate-org-a5c
22
+ type: Opaque
23
+ stringData:
24
+ app-id: "..."
25
+ private-key.pem: "..."
26
+ webhook-secret: "..."
27
+ ```
28
+
29
+ `ExternalBackendProvider.spec.authRef` points to the Secret. UI displays only Secret name/key metadata.
30
+
31
+ ## Permission checks
32
+
33
+ Every write requires:
34
+
35
+ 1. Krate org/RBAC permission;
36
+ 2. provider binding allows interface and write mode;
37
+ 3. provider credentials have required native permission;
38
+ 4. actor attribution policy is satisfied;
39
+ 5. approval policy is satisfied for agents or high-risk writes;
40
+ 6. audit event is emitted.
41
+
42
+ ## Webhook security
43
+
44
+ - Require HTTPS in production.
45
+ - Validate provider signature before parsing payload.
46
+ - Enforce replay/dedupe by delivery ID and timestamp where available.
47
+ - Queue processing after quick 2XX response.
48
+ - Store raw payloads only according to retention and redaction policy.
49
+ - Avoid logging headers or payload fields containing secrets.
50
+
51
+ ## No-leak requirements
52
+
53
+ Provider secrets and tokens must not appear in:
54
+
55
+ - API responses;
56
+ - resource status;
57
+ - Kubernetes events;
58
+ - sync events;
59
+ - logs;
60
+ - UI;
61
+ - browser traces;
62
+ - memory/context bundles;
63
+ - test artifacts.
64
+
65
+ ## Agent interactions
66
+
67
+ Agents may propose external writes, but Krate owns approval and execution. Agent write-back to GitHub issues, PRs, checks, comments, labels, or branch updates must produce an `ExternalWriteIntent` and pass approval policy unless explicitly trusted.
68
+
69
+ ## Audit fields
70
+
71
+ Audit external operations with:
72
+
73
+ - org and namespace;
74
+ - provider and binding;
75
+ - interface;
76
+ - actor and optional provider user;
77
+ - native object ID/URL;
78
+ - action;
79
+ - write intent ID;
80
+ - result;
81
+ - digest of request/response with secrets removed.
@@ -0,0 +1,108 @@
1
+ # External sync state machines
2
+
3
+ ## Purpose
4
+
5
+ This document defines stable phases and transitions for provider setup, bindings, webhook deliveries, backfill, write intents, conflicts, and provider health. UI, controllers, tests, and audit should use these phases consistently.
6
+
7
+ ## Provider phases
8
+
9
+ | Phase | Meaning |
10
+ | --- | --- |
11
+ | `Pending` | resource created, not yet validated. |
12
+ | `Authenticating` | controller is checking credentials. |
13
+ | `Discovering` | capabilities, installation, and rate-limit metadata are being discovered. |
14
+ | `Ready` | provider can serve at least one enabled interface. |
15
+ | `Degraded` | provider is usable but has warnings such as rate limits or partial interface failure. |
16
+ | `Paused` | user paused sync/write operations. |
17
+ | `Failed` | provider cannot be used until configuration changes. |
18
+
19
+ ## Binding phases
20
+
21
+ | Phase | Meaning |
22
+ | --- | --- |
23
+ | `Pending` | binding accepted. |
24
+ | `ValidatingTarget` | target Krate repo/project/org is being validated. |
25
+ | `RegisteringWebhook` | provider webhook registration is in progress. |
26
+ | `Backfilling` | initial sync is running. |
27
+ | `Ready` | binding sync is active. |
28
+ | `Conflict` | sync conflicts exist but binding may continue. |
29
+ | `Paused` | sync paused for this binding. |
30
+ | `Failed` | binding cannot sync. |
31
+
32
+ ## Webhook delivery phases
33
+
34
+ | Phase | Meaning |
35
+ | --- | --- |
36
+ | `Received` | request accepted. |
37
+ | `SignatureRejected` | signature validation failed; no payload processing. |
38
+ | `Queued` | valid delivery queued. |
39
+ | `Normalizing` | provider payload is becoming canonical events. |
40
+ | `Processing` | sync controller is applying events. |
41
+ | `Succeeded` | event applied or safely deduped. |
42
+ | `Retrying` | transient failure. |
43
+ | `DeadLettered` | repeated failure needs operator action. |
44
+
45
+ ## Backfill phases
46
+
47
+ | Phase | Meaning |
48
+ | --- | --- |
49
+ | `Scheduled` | backfill requested. |
50
+ | `Listing` | provider objects are being paginated. |
51
+ | `Hydrating` | details are being fetched. |
52
+ | `Applying` | Krate projections are being updated. |
53
+ | `Checkpointing` | cursor/high-watermark is being persisted. |
54
+ | `Succeeded` | backfill completed. |
55
+ | `RateLimited` | paused until reset. |
56
+ | `Failed` | backfill failed. |
57
+
58
+ ## Write intent phases
59
+
60
+ | Phase | Meaning |
61
+ | --- | --- |
62
+ | `PendingApproval` | approval required before provider call. |
63
+ | `ReadyToSend` | admitted and queued for provider write. |
64
+ | `Sending` | provider call in progress. |
65
+ | `AwaitingConfirmation` | provider response accepted; waiting for webhook/read confirmation. |
66
+ | `Succeeded` | provider state confirmed. |
67
+ | `Conflict` | provider state changed or rejected due to version mismatch. |
68
+ | `Retrying` | transient failure. |
69
+ | `Rejected` | human or policy rejected the write. |
70
+ | `Failed` | non-retryable failure. |
71
+
72
+ ## Conflict phases
73
+
74
+ | Phase | Meaning |
75
+ | --- | --- |
76
+ | `Open` | conflict requires resolution. |
77
+ | `Resolving` | selected resolution is being applied. |
78
+ | `Resolved` | conflict closed and sync confirmed. |
79
+ | `Ignored` | unsupported or intentionally ignored field. |
80
+ | `Superseded` | newer sync state replaced this conflict. |
81
+
82
+ ## State transition invariants
83
+
84
+ - `SignatureRejected` deliveries never become `Processing`.
85
+ - `DeadLettered` deliveries require explicit replay or skip.
86
+ - `PendingApproval` write intents never call provider before approval.
87
+ - `Succeeded` write intents include provider native response or confirmation digest.
88
+ - `Conflict` states must link to `ExternalSyncConflict`.
89
+ - `Paused` provider/binding states block new backfills and writes but preserve webhook delivery records.
90
+
91
+ ## UI state mapping
92
+
93
+ | State | UI tone | Action |
94
+ | --- | --- | --- |
95
+ | `Ready` | good | normal actions. |
96
+ | `Degraded` | warning | show reason and retry/backfill actions. |
97
+ | `RateLimited` | warning | show reset time. |
98
+ | `Conflict` | danger/warning | link to conflict resolution. |
99
+ | `Paused` | neutral | resume action. |
100
+ | `Failed` | danger | show configuration fix. |
101
+ | `DeadLettered` | danger | replay or skip action. |
102
+
103
+ ## Acceptance criteria
104
+
105
+ - Every external backend resource has a stable phase and conditions.
106
+ - Tests assert phase transitions, not only final data shape.
107
+ - UI uses consistent status language across providers.
108
+ - Audit events include phase transitions for deliveries, writes, and conflicts.
@@ -0,0 +1,107 @@
1
+ # Unified external backend model
2
+
3
+ ## Purpose
4
+
5
+ Krate needs one provider model that can represent GitHub and future externally managed systems without assuming every backend is a full Git forge. A backend can support any combination of three provider interfaces:
6
+
7
+ - issue tracking;
8
+ - CI/CD;
9
+ - git forge.
10
+
11
+ ## Provider capability model
12
+
13
+ ```yaml
14
+ kind: ExternalBackendProvider
15
+ spec:
16
+ organizationRef: a5c
17
+ providerType: github
18
+ displayName: GitHub a5c-ai
19
+ baseUrl: https://github.com
20
+ apiBaseUrl: https://api.github.com
21
+ capabilities:
22
+ issueTracking: true
23
+ cicd: true
24
+ gitForge: true
25
+ authRef:
26
+ kind: Secret
27
+ name: github-app-a5c
28
+ syncPolicyRef: github-default-sync
29
+ ```
30
+
31
+ Provider capability does not mean every repository enables every capability. `ExternalBackendBinding` controls which Krate repositories or org scopes use which interface.
32
+
33
+ ## Three unified interfaces
34
+
35
+ | Interface | Krate domain | GitHub example | Other provider examples |
36
+ | --- | --- | --- | --- |
37
+ | Issue tracking | `Issue`, comments, labels, milestones, project/work-item fields | GitHub Issues/Projects | Jira, Linear, Azure Boards. |
38
+ | CI/CD | `Pipeline`, `Job`, checks, triggers, runners, artifacts/logs | GitHub Actions/Checks | Buildkite, CircleCI, Jenkins, Azure Pipelines. |
39
+ | Git forge | `Repository`, `PullRequest`, refs, commits, keys, collaborators, branch protection | GitHub repositories and PRs | GitLab, Bitbucket, Gitea, raw Git + custom PR layer. |
40
+
41
+ ## Ownership modes
42
+
43
+ | Mode | Meaning |
44
+ | --- | --- |
45
+ | `external-owned` | external backend is source of truth; Krate mirrors and can request changes through provider API. |
46
+ | `krate-owned` | Krate owns desired state and reconciles it to the provider. |
47
+ | `bidirectional` | both systems may change state; conflicts are detected and resolved by policy or user review. |
48
+ | `read-only` | Krate only imports state and never writes. |
49
+ | `write-through` | user changes in Krate are immediately applied to provider after admission. |
50
+ | `reviewed-write` | user/agent changes create a proposed change requiring approval. |
51
+
52
+ Ownership is configured per interface and sometimes per resource type. For example, GitHub can be external-owned for PR discussions, Krate-owned for deploy keys, and bidirectional for labels.
53
+
54
+ ## External identity fields
55
+
56
+ Every synced resource should store:
57
+
58
+ ```yaml
59
+ external:
60
+ providerRef: github-a5c
61
+ interface: gitForge
62
+ nativeId: "123456"
63
+ nativeNumber: 42
64
+ nodeId: PR_kwDO...
65
+ url: https://github.com/a5c-ai/krate/pull/42
66
+ apiUrl: https://api.github.com/repos/a5c-ai/krate/pulls/42
67
+ etag: W/"..."
68
+ cursor: opaque-cursor
69
+ lastSeenAt: 2026-05-11T12:00:00Z
70
+ lastSyncedAt: 2026-05-11T12:00:05Z
71
+ resourceVersion: provider-specific-version
72
+ ```
73
+
74
+ `nodeId` is optional but preferred for GitHub because REST and GraphQL can both reference global node IDs.
75
+
76
+ ## Binding model
77
+
78
+ ```yaml
79
+ kind: ExternalBackendBinding
80
+ spec:
81
+ organizationRef: a5c
82
+ providerRef: github-a5c
83
+ targetRef:
84
+ kind: Repository
85
+ name: krate
86
+ interfaces:
87
+ issueTracking:
88
+ enabled: true
89
+ mode: bidirectional
90
+ cicd:
91
+ enabled: true
92
+ mode: external-owned
93
+ gitForge:
94
+ enabled: true
95
+ mode: bidirectional
96
+ externalRef:
97
+ owner: a5c-ai
98
+ repository: krate
99
+ ```
100
+
101
+ ## Acceptance criteria
102
+
103
+ - A provider can support one, two, or all three interfaces.
104
+ - Krate resources preserve external native IDs and cursors.
105
+ - Sync mode is explicit by interface.
106
+ - Cross-org provider bindings are rejected unless an org sharing policy admits them.
107
+ - UI can explain whether an action is local, mirrored, write-through, or reviewed-write.
@@ -0,0 +1,67 @@
1
+ # User-facing changes
2
+
3
+ ## Purpose
4
+
5
+ External backend support should feel native in Krate while making ownership and sync status obvious. Users should know when data is mirrored from GitHub, when Krate can write back, and when a conflict requires attention.
6
+
7
+ ## Global UI changes
8
+
9
+ - Add `External Integrations` under org settings.
10
+ - Add provider badges to synced repositories, issues, PRs, runs, and settings.
11
+ - Add native provider links on detail pages.
12
+ - Add sync health cards on org dashboard.
13
+ - Add conflict and rate-limit attention items to Inbox/Insights.
14
+
15
+ ## Provider setup wizard
16
+
17
+ Steps:
18
+
19
+ 1. choose provider type, starting with GitHub;
20
+ 2. choose interfaces: issue tracking, CI/CD, git forge;
21
+ 3. configure auth: GitHub App app ID, private key Secret, webhook Secret, installation ID;
22
+ 4. choose repositories or org-wide scope;
23
+ 5. choose sync modes per interface;
24
+ 6. run permission/capability check;
25
+ 7. create `ExternalBackendProvider`, binding, and sync policy resources.
26
+
27
+ ## Repository settings
28
+
29
+ External backend section shows:
30
+
31
+ - provider and native URL;
32
+ - enabled interfaces and ownership modes;
33
+ - last webhook delivery and last backfill;
34
+ - conflicts and rate-limit warnings;
35
+ - managed vs mirrored settings;
36
+ - sync now, pause sync, replay webhook, disconnect actions.
37
+
38
+ ## Issue/PR/run pages
39
+
40
+ - Native GitHub links are visible but secondary.
41
+ - Sync state indicates current, stale, conflict, or degraded.
42
+ - Mutating controls show whether the action is local, write-through, or reviewed-write.
43
+ - Agent-generated external writes require explicit approval unless policy allows them.
44
+
45
+ ## Runs and CI
46
+
47
+ - GitHub Actions workflow runs appear beside Krate-native pipelines.
48
+ - External jobs show provider, native URL, status, logs/artifacts availability, rerun/cancel capability.
49
+ - External runners are labeled provider-managed, Krate-managed, or mirrored.
50
+
51
+ ## Conflict UI
52
+
53
+ Conflicts show:
54
+
55
+ - field name;
56
+ - Krate value;
57
+ - external value;
58
+ - last synced time;
59
+ - ownership mode;
60
+ - resolution actions: keep external, apply Krate, manual edit, ignore unsupported.
61
+
62
+ ## Acceptance criteria
63
+
64
+ - Users can configure GitHub without editing YAML, but YAML remains available.
65
+ - Users can tell which system owns each field/action.
66
+ - External sync failures are visible and actionable.
67
+ - Provider write actions are audited and permission-checked.
package/docs/gaps.md ADDED
@@ -0,0 +1,161 @@
1
+ # Product gaps
2
+
3
+ ## Org-scoped company brain and run memory gap
4
+
5
+ Krate needs an explicit org scoping layer across the product. Repositories, deployments, agent stacks, triggers, runners, workspaces, sessions, company brain memory, secrets, config, and audit should all resolve under an `Organization`, with one Kubernetes namespace per org by default.
6
+
7
+ Required gap closures:
8
+
9
+ - add `Organization` and namespace binding semantics to product/API/resource docs;
10
+ - make repository and deployment routes org-aware, with no non-org repository or deployment routes;
11
+ - require org labels and namespace refs on product resources;
12
+ - reject cross-org refs by default in controllers and admission;
13
+ - scope ServiceAccounts, Roles, RoleBindings, Secrets, ConfigMaps, runners, agents, and users to the org namespace;
14
+ - manage one dedicated company brain memory repo per org;
15
+ - store admitted `MEMORY.md`, Babysitter sessions, `.a5c` run journals, task results, artifact manifests, and retrospectives in that org memory repo;
16
+ - expose org memory and run imports in `/orgs/[org]/agents/memory`;
17
+ - support historical memory dispatch by resolving the org memory repo to a commit from a timestamp;
18
+ - include org, namespace, memory commit, session ID, run ID, and journal digest in audit records.
19
+
20
+ The org-scoped resource model and route model are now implementation requirements: `Organization` resources live in the platform namespace, while each org binds exactly one namespace that contains repositories, deployments, runners, identity mappings, issues, reviews, runs, automations, memory, secrets, config, and audit records.
21
+
22
+ ## Detailed gap matrix
23
+
24
+ | Gap | Why it matters | Docs now covering it |
25
+ | --- | --- | --- |
26
+ | Org namespace model | prevents repos, deployments, agents, memory, secrets, and sessions from mixing across tenants | `docs/agents/org-scoping-namespace-spec.md`, `docs/agents/org-route-resource-model-spec.md` |
27
+ | Org-aware routes | makes navigation GitHub-like and avoids ambiguous repository slugs | `docs/agents/org-route-resource-model-spec.md`, `docs/agents/ui-flow-spec.md` |
28
+ | Babysitter run memory import | turns useful `.a5c` run state into governed org memory without raw dumps | `docs/agents/agent-run-memory-import-spec.md` |
29
+ | `MEMORY.md` in company brain | provides a stable org orchestration entrypoint | `docs/agents/shared-memory-company-brain-spec.md` |
30
+ | Historical memory refs | enables reproducible runs with memory from a prior timestamp | `docs/agents/memory-context-integration-spec.md` |
31
+ | Org-scoped audit | makes cross-controller activity attributable and recoverable | `docs/agents/observability-audit-spec.md` |
32
+
33
+ ## Remaining implementation follow-ups
34
+
35
+ - Define retention tiers for raw `.a5c` journal content versus summarized memory records.
36
+ - Decide whether generated memory indexes are committed to the org memory repo or stored as object artifacts with digest refs.
37
+ - Add org-scoped agent memory routes and audit records after the route/resource foundation is in place.
38
+
39
+ ## Next implementation decomposition
40
+
41
+ The next docs-to-code decomposition should be:
42
+
43
+ 1. org resource model and namespace binding;
44
+ 2. org-first routes with no non-org repository or deployment route surface;
45
+ 3. org admission preflight and same-org reference checks;
46
+ 4. memory repository/source read-only UI;
47
+ 5. memory context snapshots and historical refs;
48
+ 6. `AgentRunMemoryImport` summary-only import;
49
+ 7. curated journal imports and retention tiers;
50
+ 8. memory update review, PR merge, and rollback.
51
+
52
+ This order avoids adding memory write paths before org isolation and admission are enforceable.
53
+
54
+ ## Current implementation alignment gaps
55
+
56
+ Current code already includes some org foundations:
57
+
58
+ - `src/resource-model.js` includes `Organization`, `OrgNamespaceBinding`, and `organizationRef` on core resources.
59
+ - `apps/web/app/orgs/[org]` contains org dashboard, repositories, deployments, runs, inbox, people, hooks, insights, and settings-like pages.
60
+ - `apps/web/app/api/orgs/[org]/resources` provides an org-scoped resource API seam.
61
+
62
+ Remaining gaps are therefore additive:
63
+
64
+ - add agent/memory resources to the existing resource model;
65
+ - add `/orgs/[org]/agents/*` route tree;
66
+ - add memory query/import/update APIs under existing org API structure;
67
+ - add route guards and same-org admission for new resources;
68
+ - add UI links from existing repository pages to agent dispatch and memory association flows;
69
+ - add `AgentRunMemoryImport` validation and review UI.
70
+
71
+ ## Docs-to-implementation readiness checklist
72
+
73
+ Before code work starts, the docs now require these checks to be true:
74
+
75
+ - resource model delta lists every new agent/memory kind and storage class;
76
+ - UI implementation map points every new surface at an existing or future org route;
77
+ - API contract defines org-scoped routes and stable errors;
78
+ - controller spec defines org preflight and memory import reconciliation;
79
+ - acceptance matrix includes cross-org denial and memory import scenarios;
80
+ - gaps file records current implementation seams and remaining additive work.
81
+
82
+ The main unresolved product choice is retention: how much `.a5c` journal detail should be imported by default beyond summary-only and curated-journal modes.
83
+
84
+ ## Vertical slice acceptance target
85
+
86
+ The first code milestone should follow `docs/agents/org-memory-vertical-slice-spec.md` exactly. Success means a single-org manual dispatch can consume company brain memory, show the memory snapshot in run detail, import a summary-only Babysitter/Agent Mux run into the same org memory repo, and prove cross-org memory denial.
87
+
88
+ Anything beyond that is a later slice unless it directly enables the vertical path.
89
+
90
+ ## Fixture-driven implementation proof
91
+
92
+ The future implementation should be considered incomplete until the fixture plan in `docs/agents/org-memory-e2e-fixture-plan.md` can run locally. The fixture intentionally includes duplicate repo slugs across orgs and secret-like `.a5c` journal content so route ambiguity, org isolation, and redaction are proven rather than assumed.
93
+
94
+ ## QA automation gaps
95
+
96
+ The QA strategy in `docs/tests` is intentionally broader than current implementation. Remaining gaps:
97
+
98
+ - Add browser automation framework and route smoke tests.
99
+ - Add coverage reporting and thresholds.
100
+ - Split current Node tests into unit, integration, API, and E2E directories as suites grow.
101
+ - Add deterministic fixtures under `tests/fixtures` for org, repository, memory, `.a5c`, Agent Mux, webhooks, runners, and deployments.
102
+ - Add security/no-secret scans over API responses, browser traces, memory imports, and artifacts.
103
+ - Add org-scoped agent/company-brain vertical-slice tests.
104
+ - Add live/staging gates for Gitea, Argo CD, KubeVela, NATS, ARC, object storage, and Agent Mux.
105
+ - Add release artifacts for coverage, browser traces, rendered manifests, and SBOM/signing when release gates mature.
106
+
107
+ ## QA adoption roadmap gaps
108
+
109
+ The docs now define a staged QA adoption roadmap. Implementation remains to:
110
+
111
+ - create `tests/fixtures` and helper fakes;
112
+ - add Playwright/browser route smoke;
113
+ - add coverage reporting and thresholds;
114
+ - add stable API error tests;
115
+ - add security/package hardening scans;
116
+ - automate the org-memory vertical slice;
117
+ - add live/staging reliability profiles;
118
+ - publish quality intelligence such as flaky tests and coverage trends.
119
+
120
+ ## External backend integration gaps
121
+
122
+ The `docs/external` specs define GitHub and future provider integration, but implementation remains to:
123
+
124
+ - add `ExternalBackendProvider`, `ExternalBackendBinding`, sync policy, delivery, event, sync state, write intent, conflict, and object-link resources;
125
+ - implement provider registry and GitHub App auth without PATs;
126
+ - add three provider interfaces: issue tracking, CI/CD, and git forge;
127
+ - add webhook ingest, signature validation, delivery replay, event normalization, and backfill;
128
+ - add bidirectional sync conflict handling and reviewed write intents;
129
+ - add UI provider setup, repository sync status, external badges, conflict resolution, and sync health;
130
+ - add tests and fixtures for GitHub webhooks, Actions, issues, PRs, repos, keys, branch protection, rate limits, and cross-org denial.
131
+
132
+ ## Expanded external backend gaps
133
+
134
+ Additional provider work now documented but not implemented:
135
+
136
+ - provider type registry and adapter descriptor loading;
137
+ - GitLab, Bitbucket Cloud/Data Center, Azure DevOps, Jira, Linear, Buildkite, CircleCI, Jenkins, Gitea external, Gerrit, raw Git, and custom provider profiles;
138
+ - org-scoped external backend settings UI and setup wizard;
139
+ - provider binding UI for mixed-interface backends;
140
+ - conflict and write-intent review UI;
141
+ - detailed `ExternalWebhookDelivery`, `ExternalSyncEvent`, `ExternalWriteIntent`, and `ExternalObjectLink` schemas;
142
+ - provider plugin contract and interface-specific sync controllers;
143
+ - rate-limit aware sync scheduling and status surfaces.
144
+
145
+
146
+
147
+ ----
148
+
149
+ [ ] - add tools mux to enforce external tool use granular permissions beyond amux support for sanboxing and policy enforcement.
150
+
151
+ ## External provider implementation-ready gaps
152
+
153
+ The external backend docs now define manifests, mappings, state machines, and UX flows. Remaining implementation gaps:
154
+
155
+ - create a provider capability manifest registry and loader;
156
+ - add `ExternalProviderCapabilityManifest` validation or bundled manifest files;
157
+ - implement external object envelope persistence on synced resources;
158
+ - implement rich text conversion and loss warnings for Jira/Linear/provider-specific formats;
159
+ - implement stable phase enums for providers, bindings, deliveries, backfills, writes, and conflicts;
160
+ - implement mixed-provider flows such as GitHub forge plus Buildkite CI;
161
+ - add UX acceptance tests for setup, conflict resolution, reviewed writes, webhook recovery, and rate limits.
@@ -0,0 +1,94 @@
1
+ # Installation and Local Development
2
+
3
+ Krate is a Kubernetes-native forge package with a local validation harness. You can run the deterministic harness, inspect the Next.js console, and dry-run the minikube install path while the install/runtime contract is expressed as Kubernetes resources, an Argo CD Application surface, and a Gitea-backed Git data plane.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js 20 or newer
8
+ - npm
9
+ - Optional for cluster dry-runs and live install experiments: Docker, minikube, kubectl, and Helm
10
+
11
+ ## Fast path
12
+
13
+ ```bash
14
+ npm install
15
+ npm run check
16
+ npm run dev
17
+ ```
18
+
19
+ `npm run dev` starts the Next.js console from `apps/web` and renders data from the executable Krate lifecycle snapshot.
20
+
21
+ ## Validation commands
22
+
23
+ ```bash
24
+ npm run build # writes dist/krate-summary.json and dist/krate-lifecycle.json
25
+ npm test # unit coverage for resource, component, and handoff behavior
26
+ npm run e2e # chart and minikube dry-run lifecycle coverage
27
+ npm run package:check # npm package and chart/package metadata checks
28
+ npm run smoke # Kubernetes contract smoke assertions
29
+ npm run ui:validate # UI file and data-contract validation
30
+ npm run ui:build # production Next.js build with deterministic standalone tracing
31
+ npm run check # all deterministic gates
32
+ ```
33
+
34
+ ## Next.js UI
35
+
36
+ ```bash
37
+ npm run ui:dev
38
+ npm run ui:build
39
+ ```
40
+
41
+ The UI covers overview, repositories/data plane, runners/CI, identity and policy, hooks/events, operations/install, and lifecycle validation. It imports the Krate Kubernetes/Gitea/Argo CD contract model from `src/index.js`; no cluster is required for local UI development.
42
+
43
+ The Next.js proxy protects all UI pages and authenticated API routes with the `krate_session` cookie. `/login` and `/api/auth/*` remain public entrypoints for starting and ending sessions.
44
+
45
+ ## Minikube package path
46
+
47
+ Preview the commands without mutating your machine:
48
+
49
+ ```bash
50
+ npm run setup:minikube -- --dry-run --json
51
+ ```
52
+
53
+ When you have minikube, kubectl, Helm, and Docker available and want to apply the package locally:
54
+
55
+ ```bash
56
+ npm run setup:minikube -- --apply
57
+ ```
58
+
59
+ This applies the Helm-style chart from `charts/krate` and demo resources from `examples/minikube-demo.yaml`.
60
+
61
+ ## Troubleshooting
62
+
63
+ - If `npm run ui:build` fails after dependency changes, rerun `npm install` and retry.
64
+ - `kubectl port-forward` does not inject delegated identity headers; it only tunnels TCP. For local browser login without an identity proxy, explicitly set `auth.delegatedIdentity.enabled=true` and `auth.delegatedIdentity.localDevelopment.enabled=true`, then use `/api/auth/delegated` on `localhost`. Leave local development login disabled outside local clusters.
65
+ - If minikube tools are missing, use `npm run setup:minikube -- --dry-run --json` to see the required tools and commands.
66
+ - If `npm run check` fails, run the individual command listed above to isolate whether the issue is docs, unit tests, e2e package validation, smoke, or UI build.
67
+
68
+ ## Current release surface
69
+
70
+ Krate now includes the verified Kubernetes-native runtime contract, Helm-style chart surface, Argo CD Application surface, Gitea backend integration, minikube handoff, production-shaped controller image build, and GitHub publishing workflow. The Dockerfile builds the runnable `bin/krate-server.mjs` controller API with a `/healthz` check plus the Next.js web app, and `.github/workflows/publish.yml` validates the full local gate before publishing or uploading package, dist, chart, example, UI, and image artifacts. Pull requests build images without pushing; branch/tag contexts can publish GHCR images, tagged releases can push the Helm chart to GHCR OCI, and commits to `develop`, `staging`, and `main` deploy the Helm chart to AKS at `krate-develop.a5c.ai`, `krate-staging.a5c.ai`, and `krate.a5c.ai`.
71
+
72
+ The local harness is intentionally deterministic: it validates resource contracts, Gitea API-shaped integration, Argo CD Application generation, lifecycle behavior, package surface, and UI without requiring external services. Live-cluster conformance remains the follow-up environment gate beyond this executable Kubernetes package.
73
+
74
+ ## Local runtime API
75
+
76
+ Run `npm run serve` to start the local stateful Krate API on port 3080. The API exposes `GET /healthz`, `GET /api/orgs/[org]/snapshot`, `GET /api/orgs/[org]/runtime-resources/:kind`, `POST /api/orgs/[org]/repositories`, `POST /api/orgs/[org]/pullrequests`, `POST /api/orgs/[org]/pullrequests/:name/checks/complete`, `POST /api/orgs/[org]/pullrequests/:name/reviews`, and `POST /api/orgs/[org]/pullrequests/:name/merge`.
77
+
78
+ These endpoints execute the same control-plane, runner, webhook, policy, and Kubernetes/Gitea integration code used by the tests; they are a deterministic harness for the cluster package contract, not a replacement architecture. GET /api/orgs/[org]/snapshot returns a KrateRuntimeSnapshot export with the etcd/postgres storage boundary, audit log, and events. POST /api/orgs/[org]/snapshot imports that export into the running local API so backup/restore behavior is executable in tests instead of only documented.
79
+
80
+ ## KubeVela / OAM delivery plane
81
+
82
+ Set kubevela.enabled=true to let the Krate chart create an Argo CD Application that installs KubeVela ela-core into ela-system. Krate then discovers core.oam.dev resources and exposes OAM Applications, component definitions, trait definitions, policy definitions, and workflow step definitions through the forge UI and controller JSON.
83
+
84
+
85
+ ## Optional Kyverno integration
86
+
87
+ Krate can run without Kyverno, connect to a platform-owned Kyverno install, or manage Kyverno through Argo CD for local/greenfield clusters. Use `externalDependencies.kyverno.mode`:
88
+
89
+ - `auto` (default): Krate discovers an existing Kyverno install when CRDs are readable, otherwise keeps native Krate policy resources available.
90
+ - `disabled`: no policy-engine dependency; Hooks & Policies shows native Krate policy resources only.
91
+ - `byo`: Krate requires/discovers Kyverno CRDs/controllers and reads policy reports/exceptions using the chart RBAC.
92
+ - `managed`: Krate renders an Argo CD `Application` for the upstream Kyverno Helm chart and still exposes all raw YAML/`kubectl` actions.
93
+
94
+ The first implementation slice is intentionally admission-safe and non-fatal: if Kyverno is absent, the controller model reports an auto-discovery degraded policy engine instead of breaking repository, run, or deployment flows. Enforce-mode product promises require the Krate aggregated API server path to remain behind kube-apiserver admission.