@defrex/autobuild 1.0.0-beta.3 → 1.0.0

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 (168) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +362 -56
  3. package/bin/ab-dispatch-generation.ts +93 -0
  4. package/docs/agent-runtimes.md +157 -0
  5. package/docs/answering-blocked-builds.md +21 -3
  6. package/docs/architecture.md +166 -7
  7. package/docs/build-store.md +123 -0
  8. package/docs/builds.md +82 -0
  9. package/docs/cli.md +48 -0
  10. package/docs/configuration-overview.md +93 -0
  11. package/docs/configuration.md +1778 -188
  12. package/docs/dispatcher-hosting.md +115 -0
  13. package/docs/dispatcher.md +59 -0
  14. package/docs/forges.md +121 -0
  15. package/docs/getting-started.md +60 -0
  16. package/docs/glossary.md +60 -0
  17. package/docs/hosted-service.md +2 -2
  18. package/docs/intake.md +48 -0
  19. package/docs/integration-overview.md +81 -0
  20. package/docs/integration-tree.md +87 -2
  21. package/docs/integration.md +54 -0
  22. package/docs/operating.md +114 -0
  23. package/docs/operator-api.md +64 -11
  24. package/docs/operator-surfaces.md +90 -0
  25. package/docs/overview.md +49 -0
  26. package/docs/plugin-authoring.md +426 -0
  27. package/docs/remote-store-protocol.md +12 -9
  28. package/docs/restacking.md +4 -1
  29. package/docs/seams.md +66 -0
  30. package/docs/setup.md +28 -6
  31. package/docs/skills.md +119 -0
  32. package/docs/spec-standard.md +23 -5
  33. package/docs/ticket-sources.md +132 -0
  34. package/docs/tickets.md +69 -0
  35. package/docs/troubleshooting.md +111 -0
  36. package/docs/upgrading.md +50 -0
  37. package/docs/verification.md +146 -0
  38. package/docs/website.md +47 -5
  39. package/docs/workspaces.md +152 -0
  40. package/package.json +5 -4
  41. package/packages/core/src/cli/artifact.ts +5 -4
  42. package/packages/core/src/cli/attention.ts +2 -0
  43. package/packages/core/src/cli/binary-direct.ts +190 -0
  44. package/packages/core/src/cli/binary-lifecycle.ts +46 -0
  45. package/packages/core/src/cli/binary.ts +24 -210
  46. package/packages/core/src/cli/build-control.ts +105 -2
  47. package/packages/core/src/cli/context.ts +41 -1
  48. package/packages/core/src/cli/dashboard/hand-pushed.ts +24 -0
  49. package/packages/core/src/cli/dashboard/handoff.ts +64 -0
  50. package/packages/core/src/cli/dashboard/integration-detail.ts +3 -0
  51. package/packages/core/src/cli/dashboard/model.ts +34 -10
  52. package/packages/core/src/cli/dashboard/render.ts +24 -2
  53. package/packages/core/src/cli/dashboard/rollback.ts +30 -0
  54. package/packages/core/src/cli/dispatch-args.ts +53 -0
  55. package/packages/core/src/cli/dispatch-crash-budget.ts +15 -0
  56. package/packages/core/src/cli/dispatch-frontend.ts +52 -5
  57. package/packages/core/src/cli/dispatch-handoff.ts +276 -0
  58. package/packages/core/src/cli/dispatch-launch-contract.ts +170 -0
  59. package/packages/core/src/cli/dispatch-launcher.ts +580 -0
  60. package/packages/core/src/cli/dispatch-parent-watch.ts +44 -0
  61. package/packages/core/src/cli/dispatch-preflight.ts +272 -0
  62. package/packages/core/src/cli/dispatch-presentation-job.ts +46 -0
  63. package/packages/core/src/cli/dispatch-presentation-ownership.ts +9 -0
  64. package/packages/core/src/cli/dispatch-process.ts +22 -90
  65. package/packages/core/src/cli/dispatch-readiness.ts +47 -0
  66. package/packages/core/src/cli/dispatch-repository-feed.ts +5 -1
  67. package/packages/core/src/cli/dispatch-runtime-cache.ts +522 -0
  68. package/packages/core/src/cli/dispatch-runtime-dependencies.ts +291 -0
  69. package/packages/core/src/cli/dispatch-runtime-use.ts +336 -0
  70. package/packages/core/src/cli/dispatch-upgrade-controller.ts +221 -0
  71. package/packages/core/src/cli/dispatch-upgrade-install.ts +258 -0
  72. package/packages/core/src/cli/dispatch-upgrade-source.ts +309 -0
  73. package/packages/core/src/cli/dispatch-upgrade-target.ts +190 -0
  74. package/packages/core/src/cli/dispatch.ts +604 -60
  75. package/packages/core/src/cli/dispatcher-liveness.ts +1 -1
  76. package/packages/core/src/cli/env.ts +1 -1
  77. package/packages/core/src/cli/harvest.ts +28 -11
  78. package/packages/core/src/cli/help.ts +10 -5
  79. package/packages/core/src/cli/installation.ts +5 -3
  80. package/packages/core/src/cli/main-checkout.ts +59 -0
  81. package/packages/core/src/cli/main.ts +15 -45
  82. package/packages/core/src/cli/node-verification-provenance.ts +97 -0
  83. package/packages/core/src/cli/repo-state.ts +3 -58
  84. package/packages/core/src/cli/repository-status.ts +67 -3
  85. package/packages/core/src/cli/runtime-spawn.ts +16 -0
  86. package/packages/core/src/cli/status.ts +57 -3
  87. package/packages/core/src/cli/upgrade-followup.ts +25 -0
  88. package/packages/core/src/cli/wait.ts +3 -0
  89. package/packages/core/src/cli/watch.ts +7 -0
  90. package/packages/core/src/config/landing.ts +8 -0
  91. package/packages/core/src/config/live.ts +1 -0
  92. package/packages/core/src/config/reference-metadata.ts +31 -0
  93. package/packages/core/src/config/reference.ts +342 -0
  94. package/packages/core/src/config/roles.ts +1 -1
  95. package/packages/core/src/config/schema.ts +352 -10
  96. package/packages/core/src/distribution-packaging.ts +116 -0
  97. package/packages/core/src/events/catalog.ts +6 -0
  98. package/packages/core/src/events/payloads.ts +53 -9
  99. package/packages/core/src/events/policy.ts +25 -0
  100. package/packages/core/src/events/repository.ts +184 -4
  101. package/packages/core/src/events/runtime.ts +16 -0
  102. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +2515 -78
  103. package/packages/core/src/kernel/dispatch-drain-recovery.ts +121 -0
  104. package/packages/core/src/kernel/dispatch-status.ts +4 -2
  105. package/packages/core/src/kernel/dispatch-upgrade.ts +171 -0
  106. package/packages/core/src/kernel/dispatcher-liveness.ts +7 -0
  107. package/packages/core/src/kernel/generators/repository-journals.ts +82 -0
  108. package/packages/core/src/kernel/guarded-forge.ts +1 -1
  109. package/packages/core/src/kernel/harvest.ts +98 -4
  110. package/packages/core/src/kernel/integration-attention.ts +20 -0
  111. package/packages/core/src/kernel/integration-state.ts +80 -11
  112. package/packages/core/src/kernel/landing-readiness.ts +6 -1
  113. package/packages/core/src/kernel/mixed-version.ts +34 -0
  114. package/packages/core/src/kernel/node-polling.ts +160 -0
  115. package/packages/core/src/kernel/read-facts.ts +40 -5
  116. package/packages/core/src/kernel/reducer-registry.ts +3 -0
  117. package/packages/core/src/kernel/reducer.ts +75 -14
  118. package/packages/core/src/kernel/service-facts.ts +11 -4
  119. package/packages/core/src/ontology.ts +2 -2
  120. package/packages/core/src/open-map.ts +3 -1
  121. package/packages/core/src/operator/presentation.ts +7 -0
  122. package/packages/core/src/operator/query.ts +6 -2
  123. package/packages/core/src/operator/registry.ts +1 -1
  124. package/packages/core/src/plugins/load.ts +4 -1
  125. package/packages/core/src/plugins/runtime-snapshot.ts +128 -0
  126. package/packages/core/src/ports/forge/contract.ts +29 -0
  127. package/packages/core/src/ports/forge/github.ts +189 -61
  128. package/packages/core/src/ports/forge-failure.ts +1 -0
  129. package/packages/core/src/ports/forge-telemetry.ts +3 -0
  130. package/packages/core/src/ports/runner/session-env.ts +1 -0
  131. package/packages/core/src/ports/types.ts +10 -0
  132. package/packages/core/src/ports/workspace/distribution-archive.ts +22 -149
  133. package/packages/core/src/ports/workspace/distribution-release.ts +56 -0
  134. package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
  135. package/packages/core/src/ports/workspace/local-build-execution.ts +37 -17
  136. package/packages/core/src/processes/build-child-exit.ts +5 -26
  137. package/packages/core/src/processes/build-runner.ts +81 -11
  138. package/packages/core/src/processes/dispatcher.ts +254 -23
  139. package/packages/core/src/processes/execution-no-progress.ts +6 -0
  140. package/packages/core/src/processes/execution-relaunch.ts +30 -0
  141. package/packages/core/src/processes/execution-settlement.ts +16 -7
  142. package/packages/core/src/processes/harvest-runner.ts +328 -292
  143. package/packages/core/src/processes/process-group-reaper.ts +17 -10
  144. package/packages/core/src/runtime-identity.ts +22 -3
  145. package/packages/core/src/store/contract.ts +153 -0
  146. package/packages/core/src/store/local/store.ts +197 -72
  147. package/packages/core/src/store/reduced-reads.ts +8 -0
  148. package/packages/core/src/store/reducer-value-shapes.json +5783 -3305
  149. package/packages/core/src/store/remote/client.ts +43 -0
  150. package/packages/core/src/store/repo-state-events.ts +20 -3
  151. package/packages/core/src/store/types.ts +7 -0
  152. package/skills/finalize/SKILL.md +3 -1
  153. package/skills/guide/SKILL.md +273 -48
  154. package/skills/guide/references/integration-tree.md +87 -2
  155. package/skills/guide/references/operator-api.md +71 -14
  156. package/skills/guide/references/plugin-authoring.md +231 -266
  157. package/skills/guide/references/remote-store-protocol.md +12 -9
  158. package/skills/guide/references/restacking.md +4 -1
  159. package/skills/guide/references/setup.md +28 -6
  160. package/skills/guide/references/spec-standard.md +23 -5
  161. package/skills/harvest/SKILL.md +4 -0
  162. package/skills/harvest-review/SKILL.md +4 -0
  163. package/skills/implement/SKILL.md +4 -2
  164. package/skills/operate/SKILL.md +104 -35
  165. package/skills/plan/SKILL.md +12 -4
  166. package/skills/spec/SKILL.md +20 -2
  167. package/skills/tickets/SKILL.md +20 -1
  168. package/templates/hosted-service/package.json +2 -2
@@ -1,3 +1,9 @@
1
+ import {
2
+ clientIdentityError,
3
+ classifyClient,
4
+ releaseVersion,
5
+ supportedClientRangeSchema,
6
+ } from './compatibility'
1
7
  import { stampCompatibility, buildEventPolicy, repositoryEventPolicy } from '../../events/policy'
2
8
  import { READ_CATALOG_IDENTITY, projectStoredEvents } from '../../events/compatibility'
3
9
  import { CATALOG_IDENTITY_HEADER } from './version'
@@ -197,6 +203,43 @@ export class RemoteBuildStore implements BuildStore {
197
203
  }
198
204
  }
199
205
 
206
+ async inspectDispatcherOverlap(signal: AbortSignal) {
207
+ const response = await this.raw('GET', '/health', undefined, signal)
208
+ if (response.status === 404 || response.status === 405)
209
+ return { compatible: false, evidence: 'hosted admission metadata unavailable' }
210
+ if (!response.ok) throw await this.toError(response)
211
+ const health = (await response.json().catch(() => null)) as {
212
+ autobuildVersion?: string
213
+ protocolVersion?: string
214
+ supportedClientRange?: unknown
215
+ } | null
216
+ const range = supportedClientRangeSchema.safeParse(health?.supportedClientRange)
217
+ if (
218
+ !range.success ||
219
+ !health?.autobuildVersion ||
220
+ !releaseVersion(health.autobuildVersion) ||
221
+ !health.protocolVersion
222
+ )
223
+ return { compatible: false, evidence: 'hosted admission metadata unavailable' }
224
+ if (classifyClient(this.identity.autobuildVersion, range.data) !== 'supported')
225
+ return {
226
+ compatible: false,
227
+ evidence: `hosted service rejects client ${this.identity.autobuildVersion}; supported >=${range.data.minVersion} <${range.data.maxVersionExclusive}`,
228
+ }
229
+ const error = clientIdentityError(
230
+ this.identity.autobuildVersion,
231
+ this.identity.protocolVersion,
232
+ health.autobuildVersion,
233
+ health.protocolVersion,
234
+ )
235
+ return {
236
+ compatible: !error,
237
+ evidence:
238
+ error ??
239
+ `hosted service ${health.autobuildVersion} admits client ${this.identity.autobuildVersion} protocol ${this.identity.protocolVersion}`,
240
+ }
241
+ }
242
+
200
243
  scopeBuild(slug: string): BuildScopedStore {
201
244
  return createBuildScopedStore(this, slug)
202
245
  }
@@ -17,6 +17,20 @@ import {
17
17
  /** The anchor fact a bounded read's tail hangs from. */
18
18
  const RUN_STARTED = 'dispatcher.run-started'
19
19
 
20
+ /** Handoff correlation spans dispatcher generations. These facts must survive
21
+ * later run anchors, including failures that invalidate prepared requests. */
22
+ export const DISPATCH_HANDOFF_EVENT_TYPES = [
23
+ 'dispatcher.target-prepared',
24
+ 'dispatcher.yield-requested',
25
+ 'dispatcher.upgrade-failed',
26
+ 'dispatcher.handoff-started',
27
+ 'dispatcher.terminal-released',
28
+ 'dispatcher.takeover',
29
+ 'dispatcher.drain-deadline',
30
+ 'dispatcher.drain-settled',
31
+ 'dispatcher.handoff-completed',
32
+ ] as const satisfies readonly RepositoryEventType[]
33
+
20
34
  /** Durable, slow-growing repository event types: every fact a state reducer
21
35
  * may consult at full replay depth. Derived from the catalog groups so a new
22
36
  * harvest or sandbox event type joins automatically; the three dispatcher
@@ -24,6 +38,7 @@ const RUN_STARTED = 'dispatcher.run-started'
24
38
  * run-correlated `dispatcher.config-reloaded`. */
25
39
  export const REPOSITORY_STATE_EVENT_TYPES: readonly RepositoryEventType[] = [
26
40
  'tickets.migration-recorded',
41
+ ...DISPATCH_HANDOFF_EVENT_TYPES,
27
42
  'dispatcher.forge-degraded',
28
43
  'dispatcher.forge-recovered',
29
44
  ...Object.keys(changePresenceEventPayloadSchemas),
@@ -46,7 +61,9 @@ const LATEST_TYPES = new Set<string>(REPOSITORY_LATEST_EVENT_TYPES)
46
61
  * `dispatcher.run-started` contains everything those consumers keep. */
47
62
  export const REPOSITORY_RUN_SCOPED_EVENT_TYPES: readonly RepositoryEventType[] = [
48
63
  ...Object.keys(dispatcherStatusEventPayloadSchemas).filter(
49
- (type) => !REPOSITORY_LATEST_EVENT_TYPES.includes(type as RepositoryEventType),
64
+ (type) =>
65
+ !REPOSITORY_LATEST_EVENT_TYPES.includes(type as RepositoryEventType) &&
66
+ !REPOSITORY_STATE_EVENT_TYPES.includes(type as RepositoryEventType),
50
67
  ),
51
68
  'dispatcher.config-reloaded',
52
69
  ] as RepositoryEventType[]
@@ -106,7 +123,7 @@ export interface RepositoryStateEventsAcc {
106
123
  }
107
124
 
108
125
  /** Bump when `RepositoryStateEventsAcc` or its fold changes. */
109
- export const REPOSITORY_STATE_EVENTS_REDUCER_VERSION = 5
126
+ export const REPOSITORY_STATE_EVENTS_REDUCER_VERSION = 6
110
127
 
111
128
  const keeps = (event: RepositoryEvent, anchor: number | undefined): boolean =>
112
129
  STATE_TYPES.has(event.type) ||
@@ -154,7 +171,7 @@ export interface JournalViewAcc {
154
171
  }
155
172
 
156
173
  /** Bump when `JournalViewAcc` or its fold changes. */
157
- export const JOURNAL_VIEW_REDUCER_VERSION = 6
174
+ export const JOURNAL_VIEW_REDUCER_VERSION = 7
158
175
 
159
176
  /** Fold seq-ordered events into a journal view in place. */
160
177
  export function foldJournalView(acc: JournalViewAcc, events: readonly RepositoryEvent[]): void {
@@ -272,6 +272,13 @@ export interface SubscribeOptions {
272
272
  }
273
273
 
274
274
  export interface BuildStore {
275
+ /** Optional provider-owned evidence. Absent/unknown evidence requires
276
+ * cutover; journal write admission is checked separately before yield. */
277
+ inspectDispatcherOverlap?(signal: AbortSignal): Promise<{
278
+ compatible: boolean
279
+ evidence: string
280
+ }>
281
+
275
282
  /** Catalog used for event-derived batch answers, when known by this adapter. */
276
283
  readonly catalogIdentity?: string
277
284
  /** Reads cross a network boundary; presentation polling may use a relaxed cadence. */
@@ -9,6 +9,8 @@ The build is green: plan approved, code approved, every verify step passed.
9
9
  You write the PR description; the kernel opens the PR when you finish (you
10
10
  never touch the forge).
11
11
 
12
+ Guidance is an external operator answer, from the operator agent or a human.
13
+
12
14
  ## Session shape
13
15
 
14
16
  1. Run `ab context`. You get `.ab/spec.md`, `.ab/plan.md`, every verify report,
@@ -36,7 +38,7 @@ never touch the forge).
36
38
  `ab done` validates the deposit; the kernel opens the PR from it. One
37
39
  terminal command; if validation fails, fix what it names and rerun.
38
40
 
39
- `.ab/guidance.json`, when present, is a human operator's answer to the
41
+ `.ab/guidance.json`, when present, is an operator's answer to the
40
42
  escalation that blocked this build: the escalation id and the answer text. It
41
43
  is authoritative feedback for this attempt and the PR description must act on
42
44
  it, while the spec remains the contract this phase is measured against — if the