@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,151 @@
1
+ # GitHub integration design
2
+
3
+ ## Purpose
4
+
5
+ GitHub is the first full external backend provider for Krate. It can support all three unified interfaces: issue tracking, CI/CD, and git forge. Krate should integrate through a GitHub App by default, with optional user-attributed actions when a user token is available and admitted.
6
+
7
+ ## Authentication model
8
+
9
+ Preferred auth:
10
+
11
+ ```yaml
12
+ kind: ExternalBackendProvider
13
+ spec:
14
+ providerType: github
15
+ auth:
16
+ mode: github-app
17
+ appIdSecretRef:
18
+ name: github-app-a5c
19
+ key: app-id
20
+ privateKeySecretRef:
21
+ name: github-app-a5c
22
+ key: private-key.pem
23
+ webhookSecretRef:
24
+ name: github-app-a5c
25
+ key: webhook-secret
26
+ ```
27
+
28
+ Flow:
29
+
30
+ 1. Krate signs a GitHub App JWT.
31
+ 2. Krate exchanges it for installation access tokens per org/repository installation.
32
+ 3. Tokens are cached only until expiry and never stored in status.
33
+ 4. User-attributed actions use GitHub App user access tokens when available and required.
34
+ 5. All actions still pass Krate org/RBAC/admission checks.
35
+
36
+ ## GitHub provider capabilities
37
+
38
+ ```yaml
39
+ capabilities:
40
+ issueTracking:
41
+ issues: true
42
+ comments: true
43
+ labels: true
44
+ milestones: true
45
+ projects: optional
46
+ cicd:
47
+ actionsWorkflowRuns: true
48
+ workflowJobs: true
49
+ checks: true
50
+ statuses: true
51
+ selfHostedRunners: optional
52
+ gitForge:
53
+ repositories: true
54
+ pullRequests: true
55
+ reviews: true
56
+ refs: true
57
+ commits: true
58
+ deployKeys: true
59
+ branchProtection: true
60
+ collaborators: true
61
+ ```
62
+
63
+ ## Installation binding
64
+
65
+ ```yaml
66
+ kind: ExternalBackendBinding
67
+ spec:
68
+ organizationRef: a5c
69
+ providerRef: github-a5c
70
+ externalRef:
71
+ owner: a5c-ai
72
+ repository: krate
73
+ installationId: 123456
74
+ interfaces:
75
+ issueTracking:
76
+ enabled: true
77
+ mode: bidirectional
78
+ cicd:
79
+ enabled: true
80
+ mode: external-owned
81
+ gitForge:
82
+ enabled: true
83
+ mode: bidirectional
84
+ ```
85
+
86
+ ## Webhook events
87
+
88
+ Recommended GitHub events:
89
+
90
+ | Interface | Events |
91
+ | --- | --- |
92
+ | Issue tracking | `issues`, `issue_comment`, `label`, `milestone`, `projects_v2_item` where available. |
93
+ | CI/CD | `workflow_run`, `workflow_job`, `check_run`, `check_suite`, `status`, `push`. |
94
+ | Git forge | `repository`, `pull_request`, `pull_request_review`, `pull_request_review_comment`, `push`, `create`, `delete`, `branch_protection_rule`, `deploy_key`. |
95
+ | Provider lifecycle | `installation`, `installation_repositories`, `meta`. |
96
+
97
+ Webhook delivery handling:
98
+
99
+ - validate signature before parsing;
100
+ - record delivery ID and event type;
101
+ - respond quickly with 2XX after enqueue;
102
+ - process asynchronously through Krate queue/controller;
103
+ - dedupe by provider, delivery ID, event, and installation;
104
+ - support redelivery and replay.
105
+
106
+ ## Backfill and repair
107
+
108
+ Backfill should run when:
109
+
110
+ - provider binding is created;
111
+ - webhook delivery is missed or failed;
112
+ - rate limit window recovers;
113
+ - manual `resync` is requested;
114
+ - native object has stale `lastSyncedAt`;
115
+ - provider installation changes repository access.
116
+
117
+ GitHub backfill strategy:
118
+
119
+ - GraphQL for list hydration where it reduces calls and provides cursors;
120
+ - REST for endpoints with first-class Actions, checks, deploy keys, webhooks, branch protection, and logs;
121
+ - conditional requests with ETags where useful;
122
+ - rate-limit aware scheduling by installation and org.
123
+
124
+ ## Write paths
125
+
126
+ | Action | Default mode |
127
+ | --- | --- |
128
+ | create/update issue | write-through or reviewed-write by policy. |
129
+ | comment on issue/PR | write-through for humans, reviewed-write for agents. |
130
+ | update labels | bidirectional with conflict detection. |
131
+ | rerun/cancel workflow | write-through after permission review. |
132
+ | create/update PR | reviewed-write for agents; write-through for authorized humans. |
133
+ | merge PR | external-owned or reviewed-write; require branch protection status. |
134
+ | deploy key update | Krate-owned or reviewed-write. |
135
+ | branch protection update | reviewed-write unless org policy says Krate-owned. |
136
+
137
+ ## GitHub-specific conflicts
138
+
139
+ - Issue and PR share number namespace; PR-backed issue projections must link to PR.
140
+ - Labels can be edited externally while Krate has pending desired changes.
141
+ - Branch protection fields may not map 1:1 to Krate `RefPolicy`.
142
+ - Workflow runs may be rerun externally while Krate still shows an old attempt.
143
+ - Force-push updates PR head SHA and invalidates cached diff/check context.
144
+
145
+ ## UI requirements
146
+
147
+ - Provider setup wizard for GitHub App app ID, private key, webhook secret, installation ID, owner, repository selection, and selected interfaces.
148
+ - Repository settings page shows GitHub binding and per-interface mode.
149
+ - Issue/PR/run pages show native GitHub link, sync status, and conflict banner.
150
+ - Actions/runs page can filter external GitHub Actions vs Krate-native pipelines.
151
+ - Webhook page shows delivery IDs, replay, redelivery, and backfill status.
@@ -0,0 +1,66 @@
1
+ # Issue tracking interface
2
+
3
+ ## Purpose
4
+
5
+ The issue tracking interface syncs externally managed work items into Krate and optionally writes changes back. It covers issues, comments, labels, milestones, assignees, projects, saved views, reactions, and issue events.
6
+
7
+ ## Provider contract
8
+
9
+ A provider implementing this interface should support some or all of:
10
+
11
+ ```ts
12
+ interface IssueTrackingProvider {
13
+ listIssues(cursor): Page<ExternalIssue>;
14
+ getIssue(ref): ExternalIssue;
15
+ createIssue(input): ExternalIssue;
16
+ updateIssue(ref, patch): ExternalIssue;
17
+ closeIssue(ref, reason): ExternalIssue;
18
+ listComments(issueRef, cursor): Page<ExternalComment>;
19
+ createComment(issueRef, input): ExternalComment;
20
+ updateComment(commentRef, patch): ExternalComment;
21
+ listLabels(cursor): Page<ExternalLabel>;
22
+ syncLabels(desired): SyncResult;
23
+ listEvents(issueRef, cursor): Page<ExternalIssueEvent>;
24
+ }
25
+ ```
26
+
27
+ Capabilities are negotiated; read-only providers can omit mutating operations.
28
+
29
+ ## Resource mapping
30
+
31
+ | External concept | Krate resource/projection |
32
+ | --- | --- |
33
+ | issue/work item | `Issue` |
34
+ | issue comment | `IssueComment` aggregated projection or `Issue.status.comments` summary |
35
+ | label | `IssueLabel` config/projection or labels on `Issue` |
36
+ | milestone | `Milestone` projection or metadata field |
37
+ | assignee | `User`/`Team` references plus external identity mapping |
38
+ | project field | `View`, `Selector`, or provider-specific field projection |
39
+ | linked PR | `PullRequest` edge |
40
+ | issue event | `ExternalSyncEvent` or issue activity stream |
41
+
42
+ ## GitHub mapping
43
+
44
+ GitHub Issues map naturally to Krate `Issue`. GitHub pull requests also have issue numbers and issue-like comments/labels, so the GitHub issue provider must avoid duplicating PR-backed issues. A GitHub issue with `pull_request` metadata should link to the `PullRequest` projection rather than become an independent work item unless the UI explicitly needs a combined activity view.
45
+
46
+ ## Sync rules
47
+
48
+ - Webhooks handle `issues`, `issue_comment`, `label`, `milestone`, and assignment events.
49
+ - Backfill/poll handles missed events and periodic consistency checks.
50
+ - Cursor sync stores provider cursor or `updated_at` high-water mark.
51
+ - Writes include idempotency keys where provider supports them; otherwise Krate stores write intent and native result.
52
+ - Conflicts create `ExternalSyncConflict` when local desired state and external state both changed since last sync.
53
+
54
+ ## User-facing changes
55
+
56
+ - Issue pages show external provider badges, native URLs, sync status, and conflict state.
57
+ - Editing an externally owned issue shows whether the change writes through, opens a reviewed change, or is disabled.
58
+ - Comments show source: Krate, GitHub, imported, or agent.
59
+ - Label management shows external ownership and drift.
60
+
61
+ ## Acceptance criteria
62
+
63
+ - A read-only issue provider can mirror issues and comments without write permissions.
64
+ - A bidirectional provider can update title/body/state/labels/comments and detect conflicts.
65
+ - GitHub PR-backed issues link to PRs instead of duplicating work items.
66
+ - Webhook replay and cursor backfill converge to the same state.
@@ -0,0 +1,204 @@
1
+ # Provider capability manifests
2
+
3
+ ## Purpose
4
+
5
+ Provider manifests make external backend support data-driven. Each adapter declares supported interfaces, operations, auth modes, webhook events, rate-limit model, object identity fields, and unsupported features. Krate uses the manifest to render UI, validate CRDs, run contract tests, and disable unsupported actions.
6
+
7
+ ## Manifest schema
8
+
9
+ ```yaml
10
+ apiVersion: krate.a5c.ai/v1alpha1
11
+ kind: ExternalProviderCapabilityManifest
12
+ metadata:
13
+ name: github-v1
14
+ spec:
15
+ providerType: github
16
+ displayName: GitHub
17
+ hosting:
18
+ - saas
19
+ - github-enterprise-server
20
+ authModes:
21
+ - github-app
22
+ - oauth-user
23
+ api:
24
+ rest: true
25
+ graphql: true
26
+ webhook: true
27
+ identity:
28
+ nativeIdFields: [id, number]
29
+ globalIdField: node_id
30
+ urlField: html_url
31
+ versionFields: [etag, updated_at, head_sha]
32
+ interfaces: {}
33
+ ```
34
+
35
+ ## Operation shape
36
+
37
+ ```yaml
38
+ operation: createPullRequest
39
+ supported: true
40
+ write: true
41
+ requires:
42
+ permissions:
43
+ - gitForge.pullRequests.write
44
+ authModes:
45
+ - github-app
46
+ - oauth-user
47
+ nativeScopes:
48
+ - pull_requests:write
49
+ idempotency:
50
+ mode: synthetic-key
51
+ rateLimitCost:
52
+ restRequests: 1
53
+ webhookConfirmation:
54
+ events: [pull_request]
55
+ ```
56
+
57
+ ## GitHub manifest sketch
58
+
59
+ ```yaml
60
+ providerType: github
61
+ interfaces:
62
+ issueTracking:
63
+ supported: true
64
+ objects: [Issue, IssueComment, Label, Milestone]
65
+ operations:
66
+ - listIssues
67
+ - getIssue
68
+ - createIssue
69
+ - updateIssue
70
+ - closeIssue
71
+ - listComments
72
+ - createComment
73
+ - updateComment
74
+ - listLabels
75
+ - syncLabels
76
+ webhooks: [issues, issue_comment, label, milestone]
77
+ cicd:
78
+ supported: true
79
+ objects: [WorkflowRun, WorkflowJob, CheckRun, CheckSuite, CommitStatus, Runner]
80
+ operations:
81
+ - listWorkflowRuns
82
+ - getWorkflowRun
83
+ - listWorkflowJobs
84
+ - rerunWorkflowRun
85
+ - cancelWorkflowRun
86
+ - listSelfHostedRunners
87
+ - createCheckRun
88
+ - updateCheckRun
89
+ webhooks: [workflow_run, workflow_job, check_run, check_suite, status]
90
+ gitForge:
91
+ supported: true
92
+ objects: [Repository, PullRequest, Review, Ref, Commit, DeployKey, BranchProtection, Collaborator]
93
+ operations:
94
+ - listRepositories
95
+ - getRepository
96
+ - createRepository
97
+ - updateRepository
98
+ - listPullRequests
99
+ - createPullRequest
100
+ - updatePullRequest
101
+ - mergePullRequest
102
+ - listRefs
103
+ - getCommit
104
+ - syncDeployKeys
105
+ - syncBranchProtection
106
+ webhooks: [repository, pull_request, pull_request_review, pull_request_review_comment, push, create, delete, deploy_key, branch_protection_rule]
107
+ ```
108
+
109
+ ## GitLab manifest sketch
110
+
111
+ ```yaml
112
+ providerType: gitlab
113
+ hosting: [saas, self-managed]
114
+ authModes: [oauth-user, project-token, group-token, personal-access-token]
115
+ interfaces:
116
+ issueTracking:
117
+ supported: true
118
+ objects: [Issue, Note, Label, Milestone]
119
+ webhooks: [Issues Hook, Note Hook]
120
+ cicd:
121
+ supported: true
122
+ objects: [Pipeline, Job, Artifact, Runner]
123
+ webhooks: [Pipeline Hook, Job Hook]
124
+ gitForge:
125
+ supported: true
126
+ objects: [Project, MergeRequest, Approval, Branch, Tag, DeployKey, ProtectedBranch]
127
+ webhooks: [Push Hook, Tag Push Hook, Merge Request Hook]
128
+ ```
129
+
130
+ ## Jira manifest sketch
131
+
132
+ ```yaml
133
+ providerType: jira
134
+ hosting: [cloud, data-center]
135
+ interfaces:
136
+ issueTracking:
137
+ supported: true
138
+ objects: [Issue, Comment, Project, Component, Version, Sprint, Board]
139
+ operations: [listIssues, getIssue, createIssue, updateIssue, transitionIssue, createComment, updateComment]
140
+ webhooks: [issue_created, issue_updated, issue_deleted, comment_created, comment_updated]
141
+ cicd:
142
+ supported: false
143
+ gitForge:
144
+ supported: false
145
+ notes:
146
+ bodyFormat: atlassian-document-format
147
+ ```
148
+
149
+ ## Buildkite manifest sketch
150
+
151
+ ```yaml
152
+ providerType: buildkite
153
+ interfaces:
154
+ issueTracking:
155
+ supported: false
156
+ cicd:
157
+ supported: true
158
+ objects: [Pipeline, Build, Job, Agent, Artifact]
159
+ operations: [listPipelines, listBuilds, getBuild, listJobs, getLog, rebuildBuild, cancelBuild, listAgents]
160
+ webhooks: [build.scheduled, build.running, build.finished, job.finished]
161
+ gitForge:
162
+ supported: false
163
+ ```
164
+
165
+ ## Custom provider manifest
166
+
167
+ Custom providers must declare exact operations and webhook normalization rules:
168
+
169
+ ```yaml
170
+ providerType: custom
171
+ adapterRef:
172
+ package: '@a5c-ai/krate-provider-acme'
173
+ version: 1.x
174
+ interfaces:
175
+ issueTracking:
176
+ supported: true
177
+ operations: [listIssues, getIssue]
178
+ cicd:
179
+ supported: false
180
+ gitForge:
181
+ supported: false
182
+ ```
183
+
184
+ ## UI use
185
+
186
+ The UI uses manifests to:
187
+
188
+ - show only supported interface checkboxes;
189
+ - explain unsupported actions;
190
+ - choose auth forms;
191
+ - show webhook event requirements;
192
+ - render provider-specific object labels;
193
+ - warn when selected sync mode requires unsupported write operations;
194
+ - drive setup wizard validation.
195
+
196
+ ## Test use
197
+
198
+ Contract tests use manifests to:
199
+
200
+ - generate provider capability tests;
201
+ - assert unsupported operations are disabled;
202
+ - run shared interface suites only for supported interfaces;
203
+ - validate provider fixture completeness;
204
+ - verify webhook event normalization coverage.
@@ -0,0 +1,139 @@
1
+ # Pluggable backend provider catalog
2
+
3
+ ## Purpose
4
+
5
+ This catalog lists likely external backend integrations and how each maps to Krate's three unified interfaces:
6
+
7
+ 1. issue tracking;
8
+ 2. CI/CD;
9
+ 3. git forge.
10
+
11
+ A backend can support one, two, or all three. Provider implementations should be capability-driven rather than hard-coded to GitHub semantics.
12
+
13
+ ## Provider matrix
14
+
15
+ | Provider | Issue tracking | CI/CD | Git forge | Notes |
16
+ | --- | --- | --- | --- | --- |
17
+ | GitHub | yes | yes | yes | first full provider; GitHub Apps, REST, GraphQL, webhooks, Actions, Checks. |
18
+ | GitLab | yes | yes | yes | issues, merge requests, pipelines/jobs, webhooks, project/group APIs; supports SaaS and self-managed. |
19
+ | Bitbucket Cloud | limited/yes | yes | yes | repositories, pull requests, pipelines, webhooks; issue support depends on workspace/repo configuration. |
20
+ | Bitbucket Data Center | limited/yes | external/limited | yes | repo/PR APIs and webhooks; CI often external Jenkins/Bamboo. |
21
+ | Azure DevOps | yes | yes | yes | Work Items, Boards, Git repos/PRs, Pipelines, service hooks. |
22
+ | Jira Cloud/Data Center | yes | no | no | work items/issues only; pairs well with GitHub/GitLab/Bitbucket or CI-only providers. |
23
+ | Linear | yes | no | no | GraphQL issue/workflow model and webhooks; no native git forge. |
24
+ | Buildkite | no | yes | no | builds, jobs, agents, artifacts, webhooks; pairs with GitHub/GitLab/Bitbucket. |
25
+ | CircleCI | no | yes | no | pipelines, workflows, jobs, webhooks, artifacts; pairs with git forge providers. |
26
+ | Jenkins | no | yes | no | jobs/builds/logs via remote API; webhook support usually plugin-specific. |
27
+ | Gitea | yes | limited/external | yes | current internal/default forge path; can also be external-managed. |
28
+ | Gerrit | no/limited | no | yes | code review and Git refs; often pairs with Jenkins/Buildkite. |
29
+ | Raw Git server | no | no | partial | clone/fetch/push/refs only; no issue/PR semantics unless paired. |
30
+ | Custom webhook backend | optional | optional | optional | provider adapter can normalize proprietary events into one interface. |
31
+
32
+ ## Provider profiles
33
+
34
+ ### Full forge providers
35
+
36
+ Full forge providers typically implement all three interfaces:
37
+
38
+ - GitHub;
39
+ - GitLab;
40
+ - Azure DevOps;
41
+ - partially Bitbucket when issue and pipeline features are enabled.
42
+
43
+ These providers can power repository pages end to end, but Krate should still let each interface be enabled independently.
44
+
45
+ ### Work tracking providers
46
+
47
+ Work tracking providers implement issue tracking only:
48
+
49
+ - Jira;
50
+ - Linear;
51
+ - Azure Boards if used separately from Azure Repos/Pipelines;
52
+ - custom ticket systems.
53
+
54
+ Krate maps these into issues/work items, labels, project fields, comments, assignees, and issue-triggered agent dispatch.
55
+
56
+ ### CI/CD providers
57
+
58
+ CI/CD providers implement pipeline/job/run functionality only:
59
+
60
+ - Buildkite;
61
+ - CircleCI;
62
+ - Jenkins;
63
+ - Azure Pipelines if used separately;
64
+ - GitHub Actions if GitHub forge is not used;
65
+ - GitLab CI if GitLab forge is not used.
66
+
67
+ Krate maps these into `Pipeline`, `Job`, logs, artifacts, checks, runners, and triggers.
68
+
69
+ ### Git forge providers
70
+
71
+ Git forge providers implement repos/PRs/refs/keys but may not own issues or CI:
72
+
73
+ - GitHub;
74
+ - GitLab;
75
+ - Bitbucket;
76
+ - Gitea;
77
+ - Gerrit;
78
+ - raw Git with limited semantics.
79
+
80
+ Krate maps these into repositories, pull requests/reviews, refs, commits, deploy keys, repository permissions, and branch protection.
81
+
82
+ ## Capability descriptor
83
+
84
+ Each provider adapter should expose a descriptor:
85
+
86
+ ```yaml
87
+ providerType: gitlab
88
+ version: v1
89
+ interfaces:
90
+ issueTracking:
91
+ supported: true
92
+ operations: [list, get, create, update, comment, label, transition]
93
+ webhookEvents: [issue, note]
94
+ cicd:
95
+ supported: true
96
+ operations: [listRuns, getRun, listJobs, getLog, retry, cancel]
97
+ webhookEvents: [pipeline, job]
98
+ gitForge:
99
+ supported: true
100
+ operations: [listRepos, getRepo, listPullRequests, createPullRequest, merge, listRefs]
101
+ webhookEvents: [push, mergeRequest, tagPush]
102
+ authModes: [oauth-app, personal-token, project-token, self-managed-token]
103
+ hosting: [saas, self-managed]
104
+ rateLimitModel: provider-specific
105
+ ```
106
+
107
+ ## Provider-specific notes
108
+
109
+ ### GitLab
110
+
111
+ GitLab should support issues, merge requests, pipelines/jobs, project/group webhooks, branches/tags, approvals, protected branches, deploy keys, and self-managed base URLs.
112
+
113
+ ### Bitbucket
114
+
115
+ Bitbucket should separate Cloud and Data Center adapters because authentication, APIs, webhook payloads, and feature availability differ.
116
+
117
+ ### Jira
118
+
119
+ Jira issue payloads use Atlassian Document Format for rich text in Cloud REST v3. Krate needs a markdown/ADF conversion layer for issue body/comments.
120
+
121
+ ### Linear
122
+
123
+ Linear is GraphQL-first and issue/workflow-oriented. It should support issue tracking with webhooks and a provider-specific field mapping for teams, cycles, projects, states, and labels.
124
+
125
+ ### Azure DevOps
126
+
127
+ Azure DevOps can support all three interfaces, but Work Items, Git repos/PRs, Pipelines, and Service Hooks are separate service areas. Krate should model them under one provider with separate interface credentials/scopes where needed.
128
+
129
+ ### Buildkite/CircleCI/Jenkins
130
+
131
+ These are CI/CD-only providers. They should map to `Pipeline`/`Job` and can be paired with GitHub/GitLab/Bitbucket/Gitea for repo and PR context.
132
+
133
+ ## Acceptance criteria
134
+
135
+ - Provider adapter selection is capability-driven.
136
+ - A single Krate repository can bind different providers per interface.
137
+ - A provider can be self-managed with custom base URLs.
138
+ - UI can explain unsupported operations before a user clicks them.
139
+ - Tests can run provider contract suites against fake adapters for each interface.
@@ -0,0 +1,78 @@
1
+ # Provider rollout and testing
2
+
3
+ ## Purpose
4
+
5
+ This document defines implementation slices and QA coverage for GitHub and future providers.
6
+
7
+ ## Rollout slices
8
+
9
+ ### Slice 1: provider registry and read-only GitHub binding
10
+
11
+ - Add `ExternalBackendProvider`, `ExternalBackendBinding`, and sync policy resources.
12
+ - Configure GitHub App Secret metadata.
13
+ - Validate auth and installation access.
14
+ - Show provider in org settings.
15
+
16
+ ### Slice 2: git forge read sync
17
+
18
+ - Sync repositories and pull requests read-only.
19
+ - Store external IDs and native URLs.
20
+ - Show GitHub badges and links.
21
+ - Backfill plus webhook convergence tests.
22
+
23
+ ### Slice 3: issue tracking sync
24
+
25
+ - Sync issues, comments, labels, milestones.
26
+ - Handle PR-backed issue identity.
27
+ - Add issue write-through for authorized humans.
28
+
29
+ ### Slice 4: CI/CD sync
30
+
31
+ - Sync workflow runs, jobs, checks, statuses.
32
+ - Show GitHub Actions runs beside Krate pipelines.
33
+ - Add logs/artifacts lazy fetch.
34
+
35
+ ### Slice 5: write intents and conflicts
36
+
37
+ - Add reviewed-write and write-through actions.
38
+ - Add `ExternalWriteIntent` and `ExternalSyncConflict` UI.
39
+ - Add agent write-back approval flow.
40
+
41
+ ### Slice 6: runner and advanced repo management
42
+
43
+ - Self-hosted runner inventory/registration if enabled.
44
+ - Deploy keys, collaborators, and branch protection sync.
45
+ - Rate-limit aware bulk backfill.
46
+
47
+ ## Test coverage
48
+
49
+ | Slice | Required tests |
50
+ | --- | --- |
51
+ | provider registry | auth Secret metadata, missing Secret, bad installation, no-token leak. |
52
+ | git forge read | repo/PR backfill, webhook update, duplicate delivery, cross-org denial. |
53
+ | issue sync | issue/comment/label update, PR-backed issue link, conflict. |
54
+ | CI/CD sync | workflow/job/check event, rerun/cancel permission, log lazy fetch. |
55
+ | write intents | approval required, provider write failure, confirmation, conflict. |
56
+ | advanced repo | deploy key sync, branch protection drift, runner registration token no-leak. |
57
+
58
+ ## Fixtures
59
+
60
+ Add fixtures for:
61
+
62
+ - GitHub App provider Secret metadata;
63
+ - installation binding;
64
+ - repository webhook payloads;
65
+ - issue/comment/label payloads;
66
+ - pull request/review payloads;
67
+ - workflow run/job/check payloads;
68
+ - deploy key/branch protection payloads;
69
+ - rate limit and abuse-limit responses;
70
+ - redelivery payloads.
71
+
72
+ ## Acceptance criteria
73
+
74
+ - GitHub can be enabled for one org/repository with selected interfaces.
75
+ - A provider implementing only one interface can still be represented.
76
+ - Webhook replay and backfill converge.
77
+ - Bidirectional writes are explicit, permission-checked, and audited.
78
+ - Future providers can be added by implementing one or more provider contracts.
@@ -0,0 +1,48 @@
1
+ # Research results
2
+
3
+ ## Purpose
4
+
5
+ This document records the GitHub research used to design Krate external backend integration. It intentionally focuses on official GitHub surfaces and the implications for Krate's provider abstractions.
6
+
7
+ ## GitHub integration surfaces
8
+
9
+ | Surface | Relevant GitHub capability | Krate implication |
10
+ | --- | --- | --- |
11
+ | GitHub Apps | authenticate as app, installation, or user; installation tokens; permission-scoped access | use GitHub App installation as default automation identity; use user tokens only for actor-attributed actions. |
12
+ | REST API | repositories, issues, pull requests, Actions, checks, webhooks, deploy keys, refs, commits | implement provider connectors with endpoint-specific permissions and rate-limit handling. |
13
+ | GraphQL API | precise data selection, node IDs, connections/cursors | use for efficient list/detail sync, cross-object hydration, and stable global IDs. |
14
+ | Webhooks | repository/org/app events with payloads and delivery IDs | use webhook-first sync for freshness and as trigger source. |
15
+ | Webhook delivery APIs | recent delivery inspection and redelivery | support replay/recovery and delivery audit. |
16
+ | Actions APIs | workflows, workflow runs, jobs, logs, self-hosted runners | map GitHub Actions into Krate pipeline/job/runner abstractions. |
17
+ | Checks/status APIs | checks, statuses, workflow check suites/runs | map external checks into Krate CI status and PR gates. |
18
+ | Deploy keys and Git access | repository-scoped SSH deploy keys and installation-token HTTP Git access | support external Git checkout/mirroring without PATs. |
19
+
20
+ ## Key findings
21
+
22
+ - GitHub's REST API covers repository management, issue management, pull requests/reviews, workflow runs, self-hosted runners, checks, deploy keys, refs, commits, and repository webhooks.
23
+ - GitHub webhooks should be subscribed narrowly; GitHub documents using secrets, HTTPS, event/action filtering, unique delivery IDs, fast 2XX responses, queues for asynchronous processing, and redelivery for recovery.
24
+ - GitHub App installation tokens expire and are permission-bound; user access tokens can attribute user actions but are limited by both app permissions and user permissions.
25
+ - GitHub GraphQL exposes precise object selection, node IDs, connections, and cursors; REST payloads often include `node_id`, which can bridge REST and GraphQL identities.
26
+ - GitHub Actions workflow runs can be viewed, rerun, canceled, and logged through REST; self-hosted runners can be listed, registered, and deleted through Actions APIs.
27
+ - GitHub pull requests are issue-like for labels, assignees, milestones, and comments, so issue and pull-request sync must coordinate shared issue-number identity.
28
+ - GitHub deploy keys are repository-scoped SSH keys and are separate from GitHub App installation-token HTTP Git access.
29
+
30
+ ## Sources
31
+
32
+ - GitHub REST API overview and repository endpoints.
33
+ - GitHub Issues REST endpoints.
34
+ - GitHub Pull Requests REST endpoints.
35
+ - GitHub Actions workflow run, workflow, checks, and self-hosted runner endpoints.
36
+ - GitHub Webhooks docs: events/payloads, best practices, validation, deliveries, redelivery.
37
+ - GitHub Apps auth docs: app JWT, installation tokens, user tokens, permissions.
38
+ - GitHub GraphQL docs: node IDs, precise queries, cursor pagination, schema.
39
+
40
+ ## Design impact
41
+
42
+ Krate should not create a GitHub-only data model. Instead, GitHub is the first provider implementation of three interfaces:
43
+
44
+ 1. issue tracking provider;
45
+ 2. CI/CD provider;
46
+ 3. git forge provider.
47
+
48
+ GitHub can support all three. Other providers may only support one or two. For example, Jira may support issue tracking only; Buildkite may support CI/CD only; a raw Git server may support git forge only.