@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,234 @@
1
+ # External backend CRDs
2
+
3
+ ## Purpose
4
+
5
+ This document defines the resource contracts for external backend providers, bindings, sync state, write intents, conflicts, and webhook deliveries.
6
+
7
+ ## Config resources
8
+
9
+ ### `ExternalBackendProvider`
10
+
11
+ ```yaml
12
+ apiVersion: krate.a5c.ai/v1alpha1
13
+ kind: ExternalBackendProvider
14
+ metadata:
15
+ name: github-a5c
16
+ namespace: krate-org-a5c
17
+ spec:
18
+ organizationRef: a5c
19
+ providerType: github
20
+ displayName: GitHub a5c-ai
21
+ baseUrl: https://github.com
22
+ apiBaseUrl: https://api.github.com
23
+ authRef:
24
+ secretRef:
25
+ name: github-app-a5c
26
+ capabilities:
27
+ issueTracking: true
28
+ cicd: true
29
+ gitForge: true
30
+ status:
31
+ phase: Ready
32
+ conditions: []
33
+ ```
34
+
35
+ ### `ExternalBackendBinding`
36
+
37
+ ```yaml
38
+ kind: ExternalBackendBinding
39
+ spec:
40
+ organizationRef: a5c
41
+ providerRef: github-a5c
42
+ targetRef:
43
+ kind: Repository
44
+ name: krate
45
+ externalRef:
46
+ owner: a5c-ai
47
+ repository: krate
48
+ installationId: 123456
49
+ interfaces:
50
+ issueTracking:
51
+ enabled: true
52
+ mode: bidirectional
53
+ cicd:
54
+ enabled: true
55
+ mode: external-owned
56
+ gitForge:
57
+ enabled: true
58
+ mode: bidirectional
59
+ ```
60
+
61
+ ### `ExternalBackendSyncPolicy`
62
+
63
+ ```yaml
64
+ kind: ExternalBackendSyncPolicy
65
+ spec:
66
+ organizationRef: a5c
67
+ providerRef: github-a5c
68
+ webhookFirst: true
69
+ backfill:
70
+ interval: 15m
71
+ fullResyncInterval: 24h
72
+ writePolicy:
73
+ defaultMode: reviewed-write
74
+ agentWriteRequiresApproval: true
75
+ conflictPolicy:
76
+ defaultResolution: manual
77
+ ```
78
+
79
+ ## Aggregated resources
80
+
81
+ | Kind | Purpose |
82
+ | --- | --- |
83
+ | `ExternalWebhookDelivery` | provider webhook delivery record and processing state. |
84
+ | `ExternalSyncEvent` | normalized provider event. |
85
+ | `ExternalSyncState` | cursor/high-watermark per provider/interface/resource scope. |
86
+ | `ExternalWriteIntent` | Krate-originated write to provider. |
87
+ | `ExternalSyncConflict` | field/resource conflict requiring resolution. |
88
+ | `ExternalObjectLink` | external native ID/link attached to a Krate resource. |
89
+
90
+ ## Required labels
91
+
92
+ - `krate.a5c.ai/org`;
93
+ - `krate.a5c.ai/provider`;
94
+ - `krate.a5c.ai/interface`;
95
+ - `krate.a5c.ai/repository` when repository-scoped;
96
+ - `krate.a5c.ai/external-owner` when provider owner/org is known.
97
+
98
+ ## Status conditions
99
+
100
+ Providers and bindings should use:
101
+
102
+ - `AuthReady`;
103
+ - `InstallationReady`;
104
+ - `WebhookReady`;
105
+ - `IssueTrackingReady`;
106
+ - `CicdReady`;
107
+ - `GitForgeReady`;
108
+ - `RateLimited`;
109
+ - `BackfillHealthy`;
110
+ - `ConflictsPresent`;
111
+ - `Ready`.
112
+
113
+ ## Storage class
114
+
115
+ - provider/binding/sync policy: CRD/etcd;
116
+ - deliveries/events/state/write intents/conflicts/object links: aggregated API/Postgres;
117
+ - large payloads/logs/artifacts: object storage by digest;
118
+ - provider credentials: Kubernetes Secret in org namespace.
119
+
120
+ ## Detailed resource schemas
121
+
122
+ ### `ExternalWebhookDelivery.spec`
123
+
124
+ ```yaml
125
+ organizationRef: a5c
126
+ providerRef: github-a5c
127
+ bindingRef: github-krate
128
+ interfaceHints: [gitForge, issueTracking]
129
+ deliveryId: "github-delivery-guid"
130
+ eventType: pull_request
131
+ action: opened
132
+ receivedAt: 2026-05-11T12:00:00Z
133
+ signature:
134
+ algorithm: sha256
135
+ verified: true
136
+ source:
137
+ owner: a5c-ai
138
+ repository: krate
139
+ payloadRef:
140
+ storage: object
141
+ digest: sha256:payload
142
+ processing:
143
+ phase: Queued
144
+ attempts: 0
145
+ ```
146
+
147
+ ### `ExternalSyncEvent.spec`
148
+
149
+ ```yaml
150
+ organizationRef: a5c
151
+ providerRef: github-a5c
152
+ bindingRef: github-krate
153
+ sourceDelivery: github-delivery-guid
154
+ interface: gitForge
155
+ resourceKind: PullRequest
156
+ nativeId: "42"
157
+ nodeId: PR_kwDO...
158
+ action: opened
159
+ eventTime: 2026-05-11T12:00:00Z
160
+ normalized:
161
+ repository: krate
162
+ pullRequest: 42
163
+ headSha: abcdef1234
164
+ ```
165
+
166
+ ### `ExternalWriteIntent.spec`
167
+
168
+ ```yaml
169
+ organizationRef: a5c
170
+ providerRef: github-a5c
171
+ bindingRef: github-krate
172
+ interface: issueTracking
173
+ operation: createComment
174
+ source:
175
+ kind: UserAction
176
+ actor: user:alice
177
+ target:
178
+ kind: Issue
179
+ name: issue-42
180
+ nativeTarget:
181
+ owner: a5c-ai
182
+ repository: krate
183
+ issueNumber: 42
184
+ requestDigest: sha256:request
185
+ approvalPolicy:
186
+ required: false
187
+ idempotencyKey: a5c:issue-42:create-comment:01hx
188
+ ```
189
+
190
+ ### `ExternalObjectLink.spec`
191
+
192
+ ```yaml
193
+ organizationRef: a5c
194
+ providerRef: github-a5c
195
+ bindingRef: github-krate
196
+ localRef:
197
+ apiVersion: krate.a5c.ai/v1alpha1
198
+ kind: PullRequest
199
+ name: pr-42
200
+ external:
201
+ interface: gitForge
202
+ nativeId: "42"
203
+ nativeNumber: 42
204
+ nodeId: PR_kwDO...
205
+ url: https://github.com/a5c-ai/krate/pull/42
206
+ apiUrl: https://api.github.com/repos/a5c-ai/krate/pulls/42
207
+ etag: W/"..."
208
+ ```
209
+
210
+ ## Provider type registry
211
+
212
+ Provider types should be registered in a data-driven registry:
213
+
214
+ ```yaml
215
+ providerType: github
216
+ interfaces: [issueTracking, cicd, gitForge]
217
+ hosting: [saas, ghe]
218
+ authModes: [github-app, oauth-user]
219
+ webhookSignature: hmac-sha256
220
+ supportsGraphql: true
221
+ supportsRest: true
222
+ ```
223
+
224
+ Custom providers can be loaded later through plugin registration, but CRDs should not need a schema change for every provider.
225
+
226
+ ## Validation rules
227
+
228
+ - `providerType` must exist in registry or use `custom` with explicit adapter ref.
229
+ - enabled interface must be supported by provider descriptor.
230
+ - binding target must be in the same org.
231
+ - auth Secret must be in the org namespace.
232
+ - write mode must be compatible with provider operations.
233
+ - webhook endpoint must have a verification secret unless provider has a signed alternative.
234
+ - `ExternalWriteIntent` cannot reference raw Secret values.
@@ -0,0 +1,151 @@
1
+ # External backend UI specification
2
+
3
+ ## Purpose
4
+
5
+ This document defines the full UI for external backend integrations: provider setup, bindings, sync health, conflicts, write intents, webhooks, and per-resource provider status.
6
+
7
+ ## Navigation
8
+
9
+ Add org-scoped routes:
10
+
11
+ | Route | Purpose |
12
+ | --- | --- |
13
+ | `/orgs/[org]/settings/external-backends` | provider list, add provider, health summary. |
14
+ | `/orgs/[org]/settings/external-backends/[provider]` | provider detail, auth, capabilities, rate limits. |
15
+ | `/orgs/[org]/settings/external-backends/[provider]/bindings` | repository/project bindings and interface modes. |
16
+ | `/orgs/[org]/settings/external-backends/[provider]/webhooks` | webhook delivery log, replay, redelivery, failures. |
17
+ | `/orgs/[org]/settings/external-backends/[provider]/sync` | sync state, backfill, cursors, queues. |
18
+ | `/orgs/[org]/settings/external-backends/[provider]/conflicts` | conflicts and resolution. |
19
+ | `/orgs/[org]/settings/external-backends/[provider]/writes` | write intents, approvals, retries. |
20
+
21
+ Repository pages show external backend panels under Settings, Issues, Pull Requests, Runs, Hooks, and Code where relevant.
22
+
23
+ ## Provider list page
24
+
25
+ Cards show:
26
+
27
+ - provider name/type;
28
+ - enabled interfaces;
29
+ - auth health;
30
+ - webhook health;
31
+ - rate-limit/degraded state;
32
+ - last backfill;
33
+ - conflicts count;
34
+ - write intents needing attention;
35
+ - repositories bound.
36
+
37
+ Primary actions:
38
+
39
+ - add provider;
40
+ - resync all;
41
+ - pause/resume provider;
42
+ - open YAML.
43
+
44
+ ## Add provider wizard
45
+
46
+ Steps:
47
+
48
+ 1. Select provider type: GitHub, GitLab, Bitbucket, Azure DevOps, Jira, Linear, Buildkite, CircleCI, Jenkins, Gitea, Custom.
49
+ 2. Select hosting: SaaS or self-managed and base URLs.
50
+ 3. Select interfaces to enable.
51
+ 4. Configure auth and Secret refs.
52
+ 5. Validate credentials and capabilities.
53
+ 6. Select org/repository/project bindings.
54
+ 7. Choose sync ownership modes.
55
+ 8. Configure webhook endpoint and secret.
56
+ 9. Review generated YAML.
57
+ 10. Apply and start initial backfill.
58
+
59
+ ## Binding UI
60
+
61
+ Binding rows show:
62
+
63
+ - Krate target resource;
64
+ - external owner/project/repo key;
65
+ - enabled interfaces;
66
+ - mode per interface;
67
+ - last sync state;
68
+ - native provider URL;
69
+ - conflict count;
70
+ - actions: sync now, edit modes, disconnect, view YAML.
71
+
72
+ ## Resource badges
73
+
74
+ Synced resources display:
75
+
76
+ - provider icon/name;
77
+ - native URL;
78
+ - sync phase: current, stale, paused, conflict, degraded, write pending;
79
+ - ownership: mirrored, external-owned, Krate-owned, bidirectional;
80
+ - last synced time;
81
+ - pending write/conflict indicator.
82
+
83
+ ## Conflict resolution UI
84
+
85
+ Conflict detail shows:
86
+
87
+ - resource and native URL;
88
+ - field conflicts;
89
+ - local value;
90
+ - external value;
91
+ - last local generation;
92
+ - provider version/etag;
93
+ - policy recommendation;
94
+ - actions: keep external, apply Krate, manual edit, ignore unsupported, retry sync.
95
+
96
+ ## Write intent UI
97
+
98
+ Write intent detail shows:
99
+
100
+ - actor and source action;
101
+ - target provider/interface;
102
+ - native operation;
103
+ - request preview with secrets redacted;
104
+ - approval state;
105
+ - retry count;
106
+ - provider response summary;
107
+ - linked audit events;
108
+ - actions: approve, reject, retry, cancel, open native object.
109
+
110
+ ## Webhook and sync UI
111
+
112
+ Webhook page shows:
113
+
114
+ - delivery ID;
115
+ - event/action;
116
+ - repository/project;
117
+ - received time;
118
+ - signature status;
119
+ - processing phase;
120
+ - response code;
121
+ - normalized event ID;
122
+ - replay action.
123
+
124
+ Sync page shows:
125
+
126
+ - high-watermarks/cursors by interface/resource kind;
127
+ - current queue depth;
128
+ - rate-limit budget;
129
+ - backfill schedule;
130
+ - last full resync;
131
+ - paused/degraded reasons.
132
+
133
+ ## Repository settings integration
134
+
135
+ `/orgs/[org]/repositories/[repo]/settings` gains an External Backends section:
136
+
137
+ - current provider binding;
138
+ - interface modes;
139
+ - sync health;
140
+ - branch protection ownership;
141
+ - issue/PR/CI ownership;
142
+ - webhook delivery status;
143
+ - quick link to provider settings.
144
+
145
+ ## Acceptance criteria
146
+
147
+ - Users can configure a provider without writing YAML.
148
+ - YAML remains visible for every provider resource.
149
+ - UI never enables unsupported provider operations.
150
+ - Conflicts and write intents are first-class and actionable.
151
+ - Every synced resource shows provider ownership and native link.
@@ -0,0 +1,115 @@
1
+ # External backend UX flows
2
+
3
+ ## Purpose
4
+
5
+ This document turns the UI specification into user-facing flows that can become acceptance tests and implementation tickets.
6
+
7
+ ## Flow: connect GitHub provider
8
+
9
+ 1. Org admin opens `/orgs/a5c/settings/external-backends`.
10
+ 2. Clicks `Add provider`.
11
+ 3. Selects `GitHub`.
12
+ 4. Selects `GitHub App` auth.
13
+ 5. Enters or selects Kubernetes Secret refs for app ID, private key, and webhook secret.
14
+ 6. Enters installation ID or authorizes installation discovery.
15
+ 7. Selects interfaces: Issues, Actions/CI, Git forge.
16
+ 8. Runs capability check.
17
+ 9. Selects repositories to bind.
18
+ 10. Chooses sync modes per interface.
19
+ 11. Reviews YAML.
20
+ 12. Applies provider and binding.
21
+ 13. UI shows initial backfill progress and webhook status.
22
+
23
+ Acceptance:
24
+
25
+ - no token/private key value is shown after entry;
26
+ - unsupported operations are explained;
27
+ - provider and binding resources are created with org labels;
28
+ - initial backfill status appears.
29
+
30
+ ## Flow: connect Jira for issues only
31
+
32
+ 1. Admin selects `Jira` provider.
33
+ 2. UI shows only Issue Tracking interface.
34
+ 3. Admin configures base URL, auth Secret, and project keys.
35
+ 4. Chooses read-only or bidirectional issue sync.
36
+ 5. Applies binding to a Krate repository or org work board.
37
+ 6. Issue pages show Jira badge and native links.
38
+
39
+ Acceptance:
40
+
41
+ - CI/CD and git forge options are disabled;
42
+ - PR and pipeline pages do not claim Jira ownership;
43
+ - Jira rich text conversion warnings are visible when relevant.
44
+
45
+ ## Flow: combine GitHub forge with Buildkite CI
46
+
47
+ 1. Repository has GitHub binding for git forge and issue tracking.
48
+ 2. Admin adds Buildkite provider with CI/CD only.
49
+ 3. Admin binds Buildkite pipelines to the same Krate repository.
50
+ 4. Runs page shows GitHub PR context and Buildkite builds together.
51
+ 5. Agent trigger rules can match Buildkite failures and write PR comments through GitHub after approval.
52
+
53
+ Acceptance:
54
+
55
+ - separate provider badges are visible;
56
+ - CI actions go to Buildkite, PR comments go to GitHub;
57
+ - audit records show both providers when a flow crosses interfaces.
58
+
59
+ ## Flow: resolve sync conflict
60
+
61
+ 1. User opens Inbox or provider Conflicts page.
62
+ 2. Selects conflict for issue labels.
63
+ 3. UI shows local and external values and sync history.
64
+ 4. User chooses `Keep external`.
65
+ 5. Conflict controller updates Krate projection and closes conflict.
66
+ 6. Audit records decision.
67
+
68
+ Acceptance:
69
+
70
+ - no hidden overwrite occurs;
71
+ - user can inspect native provider link;
72
+ - resolved state is visible in resource detail.
73
+
74
+ ## Flow: reviewed external write from agent
75
+
76
+ 1. Agent proposes GitHub PR comment or label update.
77
+ 2. Krate creates `ExternalWriteIntent` with request digest.
78
+ 3. UI shows approval in Inbox and run detail.
79
+ 4. Reviewer approves.
80
+ 5. Write controller posts to GitHub.
81
+ 6. Webhook or read-back confirms write.
82
+ 7. Run detail and PR page show result.
83
+
84
+ Acceptance:
85
+
86
+ - agent cannot write directly without Krate approval policy;
87
+ - request preview is redacted;
88
+ - native URL and provider response summary are visible.
89
+
90
+ ## Flow: webhook recovery
91
+
92
+ 1. Webhook delivery fails processing and becomes `DeadLettered`.
93
+ 2. Provider page shows failed delivery.
94
+ 3. Operator opens delivery detail and sees normalized error.
95
+ 4. Operator chooses replay.
96
+ 5. Delivery re-enters queue and succeeds or remains dead-lettered with updated attempts.
97
+
98
+ Acceptance:
99
+
100
+ - duplicate replay is idempotent;
101
+ - raw payload access is permission-gated;
102
+ - sync state updates after replay.
103
+
104
+ ## Flow: provider rate limit
105
+
106
+ 1. Provider reaches low rate-limit threshold.
107
+ 2. Provider status becomes `Degraded` or `RateLimited`.
108
+ 3. Backfill pauses; webhook ingest continues.
109
+ 4. UI shows reset time and impacted interfaces.
110
+ 5. Sync resumes after reset.
111
+
112
+ Acceptance:
113
+
114
+ - user actions that require provider writes are disabled or queued by policy;
115
+ - status clearly separates webhook ingestion from API backfill.
@@ -0,0 +1,125 @@
1
+ # External object mapping spec
2
+
3
+ ## Purpose
4
+
5
+ This document defines canonical object mappings between provider-native objects and Krate resources. The goal is loss-aware sync: Krate should preserve provider identity and important provider-specific fields even when not all fields fit a first-class Krate resource.
6
+
7
+ ## Mapping principles
8
+
9
+ - Preserve native ID, URL, node/global ID, and provider version fields.
10
+ - Normalize common fields into Krate resources.
11
+ - Store unsupported provider-specific fields in an extension map with schema version.
12
+ - Avoid lossy writes unless the user explicitly accepts field loss.
13
+ - Keep provider-specific rich text formats as source plus rendered Markdown/HTML where safe.
14
+
15
+ ## Common external envelope
16
+
17
+ ```yaml
18
+ external:
19
+ providerRef: github-a5c
20
+ bindingRef: github-krate
21
+ interface: gitForge
22
+ nativeKind: pull_request
23
+ nativeId: "123456"
24
+ nativeNumber: 42
25
+ nodeId: PR_kwDO...
26
+ url: https://github.com/a5c-ai/krate/pull/42
27
+ apiUrl: https://api.github.com/repos/a5c-ai/krate/pulls/42
28
+ version:
29
+ etag: W/"..."
30
+ updatedAt: 2026-05-11T12:00:00Z
31
+ sha: abcdef1234
32
+ extensions:
33
+ providerType: github
34
+ schemaVersion: github-rest-2022-11-28
35
+ fields: {}
36
+ ```
37
+
38
+ ## Issue mapping
39
+
40
+ | Provider field | Krate field |
41
+ | --- | --- |
42
+ | title | `Issue.spec.title` |
43
+ | body/description | `Issue.spec.body` plus `external.extensions.bodyFormat` |
44
+ | state/status | `Issue.status.phase` and `Issue.spec.state` |
45
+ | labels | `Issue.metadata.labels` and issue label projection |
46
+ | assignees | `Issue.spec.assignees` via identity mapping |
47
+ | milestone/sprint/cycle | `Issue.spec.milestone` or extension |
48
+ | comments | issue activity/comment projection |
49
+ | timestamps | `status.createdAt`, `status.updatedAt`, `status.closedAt` |
50
+
51
+ Provider notes:
52
+
53
+ - Jira status transitions need a transition operation, not a simple `state` patch.
54
+ - Linear workflow states map to issue phase plus provider extension.
55
+ - GitHub PR-backed issues link to `PullRequest`.
56
+
57
+ ## Pipeline mapping
58
+
59
+ | Provider field | Krate field |
60
+ | --- | --- |
61
+ | workflow/pipeline name | `Pipeline.spec.workflow` |
62
+ | run/build ID | `Pipeline.external.nativeId` |
63
+ | branch/ref | `Pipeline.spec.ref` |
64
+ | sha | `Pipeline.spec.sha` |
65
+ | status/conclusion | `Pipeline.status.phase` and `status.conclusion` |
66
+ | jobs | `Job` projections |
67
+ | logs | lazy `Artifact`/log ref |
68
+ | artifacts | `AgentArtifact`/`Artifact` projection by digest or native URL |
69
+ | rerun/cancel | `ExternalWriteIntent` operation |
70
+
71
+ ## Pull request mapping
72
+
73
+ | Provider field | Krate field |
74
+ | --- | --- |
75
+ | title/body | `PullRequest.spec.title/body` |
76
+ | number/IID | `external.nativeNumber` |
77
+ | source branch | `PullRequest.spec.head` |
78
+ | target branch | `PullRequest.spec.base` |
79
+ | head SHA | `PullRequest.status.headSha` |
80
+ | merge state | `PullRequest.status.mergeState` |
81
+ | reviewers/reviews | `Review` projections |
82
+ | checks | linked `Pipeline`/`Job`/check projections |
83
+ | labels/assignees | shared issue-like fields where provider supports them |
84
+
85
+ ## Repository mapping
86
+
87
+ | Provider field | Krate field |
88
+ | --- | --- |
89
+ | owner/name/path | `Repository.metadata.name`, `spec.external.owner/path` |
90
+ | visibility | `Repository.spec.visibility` |
91
+ | default branch | `Repository.spec.defaultBranch` |
92
+ | clone URLs | `Repository.status.cloneUrls` |
93
+ | archived/disabled | `Repository.status.phase` and extension |
94
+ | permissions/collaborators | `RepositoryPermission` projections |
95
+ | deploy keys | `SSHKey`/deploy-key projections |
96
+ | branch protection | `BranchProtection`/`RefPolicy` projections |
97
+
98
+ ## Rich text conversion
99
+
100
+ Providers may use different body formats:
101
+
102
+ - Markdown: GitHub, GitLab, many Git forges;
103
+ - Atlassian Document Format: Jira Cloud;
104
+ - provider-specific markdown extensions: Linear/GitLab;
105
+ - HTML fragments: some legacy systems.
106
+
107
+ Krate stores:
108
+
109
+ ```yaml
110
+ body:
111
+ markdown: safe normalized markdown
112
+ sourceFormat: atlassian-document-format
113
+ sourceDigest: sha256:...
114
+ renderWarnings: []
115
+ ```
116
+
117
+ Writes should preserve source format when possible or mark conversion loss.
118
+
119
+ ## Acceptance criteria
120
+
121
+ - Every synced object has an external envelope.
122
+ - Unsupported provider fields are retained in extensions.
123
+ - Writes do not silently drop unsupported fields.
124
+ - Rich text conversion is explicit and testable.
125
+ - Mapping docs are used by provider contract tests.
@@ -0,0 +1,68 @@
1
+ # Git forge interface
2
+
3
+ ## Purpose
4
+
5
+ The git forge interface syncs repository, pull request, ref, commit, key, collaborator, and repository policy state. It is the broadest external backend interface and is supported by GitHub, GitLab, Bitbucket, Gitea, and similar systems.
6
+
7
+ ## Provider contract
8
+
9
+ ```ts
10
+ interface GitForgeProvider {
11
+ listRepositories(cursor): Page<ExternalRepository>;
12
+ getRepository(ref): ExternalRepository;
13
+ createRepository(input): ExternalRepository;
14
+ updateRepository(ref, patch): ExternalRepository;
15
+ listPullRequests(repoRef, cursor): Page<ExternalPullRequest>;
16
+ getPullRequest(ref): ExternalPullRequest;
17
+ createPullRequest(input): ExternalPullRequest;
18
+ updatePullRequest(ref, patch): ExternalPullRequest;
19
+ mergePullRequest(ref, options): ExternalPullRequest;
20
+ listRefs(repoRef, cursor): Page<ExternalRef>;
21
+ getCommit(repoRef, sha): ExternalCommit;
22
+ listDeployKeys(repoRef, cursor): Page<ExternalDeployKey>;
23
+ syncDeployKeys(repoRef, desired): SyncResult;
24
+ listCollaborators(repoRef, cursor): Page<ExternalCollaborator>;
25
+ syncBranchProtection(repoRef, desired): SyncResult;
26
+ }
27
+ ```
28
+
29
+ ## Resource mapping
30
+
31
+ | External concept | Krate resource/projection |
32
+ | --- | --- |
33
+ | repository | `Repository` |
34
+ | pull request / merge request | `PullRequest` |
35
+ | review | `Review` |
36
+ | PR comment/review thread | `ReviewComment` projection or activity stream |
37
+ | branch/tag/ref | `GitRef` projection or repository status |
38
+ | commit | `Commit` projection or lazy detail |
39
+ | deploy key/SSH key | `SSHKey` / `RepositoryPermission` / deploy-key projection |
40
+ | collaborator/team permission | `RepositoryPermission` |
41
+ | branch protection | `BranchProtection` / `RefPolicy` |
42
+ | repository webhook | `WebhookSubscription` |
43
+
44
+ ## GitHub mapping
45
+
46
+ GitHub repositories map to Krate `Repository`; GitHub pull requests map to `PullRequest`; PR reviews/comments map to `Review` and activity projections; deploy keys map to SSH key/deploy-key projections; branch protection maps to `BranchProtection` and `RefPolicy` where fields overlap.
47
+
48
+ ## Sync rules
49
+
50
+ - Webhooks handle `repository`, `pull_request`, `pull_request_review`, `pull_request_review_comment`, `push`, `create`, `delete`, `branch_protection_rule`, `deploy_key`, and membership/collaborator-related events where available.
51
+ - Backfill lists repositories, PRs, refs, branch protection, keys, and collaborators.
52
+ - PR sync must coordinate with issue sync because provider issue numbers and PR numbers may share namespace.
53
+ - Git operations can use provider clone URLs and provider credentials; Krate should not require PATs.
54
+ - Branch protection writes require explicit ownership mode and permission review.
55
+
56
+ ## User-facing changes
57
+
58
+ - Repository settings show whether GitHub or Krate owns each setting.
59
+ - PR pages show native provider link, sync state, and conflict status.
60
+ - SSH/deploy key panels show mirrored vs Krate-managed keys.
61
+ - Branch protection editor can operate read-only, write-through, or reviewed-write depending on sync policy.
62
+
63
+ ## Acceptance criteria
64
+
65
+ - A git-forge-only provider can sync repos/PRs/refs without issue or CI support.
66
+ - PR state converges from webhooks and periodic backfill.
67
+ - Branch protection/key writes are explicit and audited.
68
+ - GitHub issue/PR shared numbering does not create duplicate records.