@defrex/autobuild 0.13.0 → 1.0.0-beta.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.
- package/README.md +5 -3
- package/SPEC.md +673 -99
- package/bin/ab-dispatch-kernel.ts +4 -6
- package/docs/architecture.md +322 -75
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +112 -12
- package/docs/hosted-service.md +20 -2
- package/docs/integration-tree.md +117 -0
- package/docs/landing-policy.md +150 -0
- package/docs/mcp.md +24 -0
- package/docs/migration-1.0.md +68 -0
- package/docs/operator-api.md +20 -9
- package/docs/remote-store-protocol.md +114 -9
- package/docs/remote-ticket-protocol.md +26 -5
- package/docs/restacking.md +79 -0
- package/docs/setup.md +49 -6
- package/docs/ticket-dependencies.md +69 -0
- package/docs/ticket-migration.md +8 -0
- package/package.json +4 -3
- package/packages/core/src/cli/attention.ts +40 -163
- package/packages/core/src/cli/build-control.ts +75 -55
- package/packages/core/src/cli/bulk-control.ts +3 -2
- package/packages/core/src/cli/context.ts +68 -78
- package/packages/core/src/cli/dashboard/actions.ts +6 -3
- package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
- package/packages/core/src/cli/dashboard/live.ts +5 -0
- package/packages/core/src/cli/dashboard/model.ts +178 -40
- package/packages/core/src/cli/dashboard/poll.ts +15 -9
- package/packages/core/src/cli/dashboard/refresh.ts +176 -0
- package/packages/core/src/cli/dashboard/render.ts +78 -28
- package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
- package/packages/core/src/cli/dashboard/selection.ts +7 -1
- package/packages/core/src/cli/dashboard/tree.ts +107 -0
- package/packages/core/src/cli/dispatch-frontend.ts +173 -169
- package/packages/core/src/cli/dispatch-process.ts +14 -7
- package/packages/core/src/cli/dispatch-repository-feed.ts +196 -0
- package/packages/core/src/cli/dispatch.ts +397 -214
- package/packages/core/src/cli/dispatcher-liveness.ts +41 -21
- package/packages/core/src/cli/harvest.ts +71 -39
- package/packages/core/src/cli/help.ts +49 -32
- package/packages/core/src/cli/historical-build-state.ts +27 -0
- package/packages/core/src/cli/init-validation.ts +43 -2
- package/packages/core/src/cli/keyboard.ts +6 -0
- package/packages/core/src/cli/landings.ts +18 -0
- package/packages/core/src/cli/main.ts +52 -18
- package/packages/core/src/cli/mcp.ts +9 -0
- package/packages/core/src/cli/pr-attachments.ts +10 -13
- package/packages/core/src/cli/pr-summary-publication.ts +27 -60
- package/packages/core/src/cli/pr-summary.ts +43 -13
- package/packages/core/src/cli/publication-settlement.ts +177 -21
- package/packages/core/src/cli/repository-status.ts +49 -2
- package/packages/core/src/cli/status.ts +133 -36
- package/packages/core/src/cli/terminal-restore.ts +54 -0
- package/packages/core/src/cli/terminal.ts +16 -2
- package/packages/core/src/cli/terminals.ts +121 -219
- package/packages/core/src/cli/ticket-editor.ts +10 -3
- package/packages/core/src/cli/ticket.ts +115 -20
- package/packages/core/src/cli/upgrade-commit.ts +4 -0
- package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
- package/packages/core/src/cli/upgrade-landing.ts +69 -0
- package/packages/core/src/cli/upgrade.ts +16 -0
- package/packages/core/src/cli/wait.ts +194 -91
- package/packages/core/src/cli/watch.ts +111 -109
- package/packages/core/src/config/landing.ts +22 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/pipeline-source.ts +4 -3
- package/packages/core/src/config/schema.ts +3 -0
- package/packages/core/src/events/catalog.ts +48 -3
- package/packages/core/src/events/payloads.ts +295 -6
- package/packages/core/src/events/repository.ts +38 -3
- package/packages/core/src/integration/harness.ts +11 -2
- package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +3330 -119
- package/packages/core/src/kernel/auto-merge-default.ts +1 -0
- package/packages/core/src/kernel/auto-merge.ts +29 -4
- package/packages/core/src/kernel/build-identity.ts +94 -0
- package/packages/core/src/kernel/change-presence.ts +179 -0
- package/packages/core/src/kernel/dispatch-status.ts +17 -1
- package/packages/core/src/kernel/dispatcher-liveness.ts +10 -4
- package/packages/core/src/kernel/engine.ts +89 -2
- package/packages/core/src/kernel/generators/build-log.ts +23 -0
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +25 -3
- package/packages/core/src/kernel/harvest.ts +25 -23
- package/packages/core/src/kernel/integration-completeness.ts +81 -0
- package/packages/core/src/kernel/integration-landing.ts +263 -0
- package/packages/core/src/kernel/integration-stack.ts +36 -0
- package/packages/core/src/kernel/integration-state.ts +135 -0
- package/packages/core/src/kernel/landing-policy.ts +47 -0
- package/packages/core/src/kernel/landing-publication.ts +41 -0
- package/packages/core/src/kernel/landing-readiness.ts +67 -0
- package/packages/core/src/kernel/landing-state.ts +96 -0
- package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
- package/packages/core/src/kernel/log-index-value.ts +38 -0
- package/packages/core/src/kernel/log-index.ts +35 -5
- package/packages/core/src/kernel/node-landing.ts +439 -0
- package/packages/core/src/kernel/node-parent.ts +184 -0
- package/packages/core/src/kernel/node-restack-state.ts +191 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
- package/packages/core/src/kernel/node-restack.ts +274 -0
- package/packages/core/src/kernel/read-facts.ts +704 -0
- package/packages/core/src/kernel/reconcile-head.ts +51 -0
- package/packages/core/src/kernel/reconcile-restack.ts +560 -0
- package/packages/core/src/kernel/reducer-registry.ts +153 -3
- package/packages/core/src/kernel/reducer.ts +121 -6
- package/packages/core/src/kernel/repository-attention.ts +179 -0
- package/packages/core/src/kernel/service-facts.ts +135 -0
- package/packages/core/src/kernel/snapshot-parent.ts +33 -0
- package/packages/core/src/kernel/terminal-guard.ts +133 -0
- package/packages/core/src/ontology.ts +9 -1
- package/packages/core/src/operator/annotations.ts +12 -0
- package/packages/core/src/operator/control.ts +11 -6
- package/packages/core/src/operator/index.ts +6 -0
- package/packages/core/src/operator/landings.ts +35 -0
- package/packages/core/src/operator/presentation.ts +1 -0
- package/packages/core/src/operator/protocol.ts +12 -3
- package/packages/core/src/operator/query.ts +40 -21
- package/packages/core/src/operator/read-view.ts +4 -13
- package/packages/core/src/operator/registry.ts +48 -19
- package/packages/core/src/operator/requests.ts +3 -22
- package/packages/core/src/operator/sandbox.ts +10 -9
- package/packages/core/src/operator/tickets.ts +57 -11
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/ports/forge/contract.ts +91 -3
- package/packages/core/src/ports/forge/fake.ts +142 -4
- package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
- package/packages/core/src/ports/forge/github-readiness.ts +421 -0
- package/packages/core/src/ports/forge/github.ts +631 -35
- package/packages/core/src/ports/forge/local-git.ts +119 -5
- package/packages/core/src/ports/forge/readiness.ts +99 -0
- package/packages/core/src/ports/tickets/contract.ts +41 -0
- package/packages/core/src/ports/tickets/create.ts +8 -1
- package/packages/core/src/ports/tickets/fake.ts +32 -1
- package/packages/core/src/ports/tickets/file-codec.ts +7 -0
- package/packages/core/src/ports/tickets/file.ts +18 -1
- package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
- package/packages/core/src/ports/tickets/linear.ts +124 -4
- package/packages/core/src/ports/tickets/migration.ts +25 -1
- package/packages/core/src/ports/tickets/operations.ts +7 -2
- package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
- package/packages/core/src/ports/tickets/remote.ts +10 -1
- package/packages/core/src/ports/tickets/revision.ts +3 -1
- package/packages/core/src/ports/tickets/tree.ts +148 -0
- package/packages/core/src/ports/tickets/update.ts +15 -2
- package/packages/core/src/ports/types.ts +135 -5
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
- package/packages/core/src/processes/build-child.ts +6 -6
- package/packages/core/src/processes/build-runner.ts +586 -87
- package/packages/core/src/processes/dispatch-failure-budget.ts +5 -4
- package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
- package/packages/core/src/processes/dispatcher.ts +2239 -357
- package/packages/core/src/processes/execution-no-progress.ts +46 -1
- package/packages/core/src/processes/harvest-execution-state.ts +15 -9
- package/packages/core/src/processes/harvest-runner.ts +34 -70
- package/packages/core/src/processes/harvest.ts +38 -15
- package/packages/core/src/processes/infrastructure-failure-budget.ts +13 -15
- package/packages/core/src/processes/orchestrator-tick.ts +2 -2
- package/packages/core/src/processes/publication-loss.ts +35 -21
- package/packages/core/src/processes/publication-state.ts +30 -5
- package/packages/core/src/processes/repo-view.ts +244 -1130
- package/packages/core/src/processes/tick-publication.ts +110 -0
- package/packages/core/src/store/adapter.ts +23 -0
- package/packages/core/src/store/build-scope.ts +35 -0
- package/packages/core/src/store/contract.ts +909 -0
- package/packages/core/src/store/digest.ts +52 -4
- package/packages/core/src/store/local/schema.ts +26 -13
- package/packages/core/src/store/local/store.ts +296 -55
- package/packages/core/src/store/memory.ts +181 -30
- package/packages/core/src/store/phase-session.ts +34 -0
- package/packages/core/src/store/reduced-reads.ts +240 -0
- package/packages/core/src/store/reducer-value-shapes.json +18323 -0
- package/packages/core/src/store/reducer-value-validation.ts +96 -0
- package/packages/core/src/store/reducer-values.ts +145 -0
- package/packages/core/src/store/remote/client.ts +85 -0
- package/packages/core/src/store/remote/compatibility.ts +21 -9
- package/packages/core/src/store/remote/index.ts +19 -0
- package/packages/core/src/store/remote/protocol.ts +27 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/repo-state-events.ts +3 -1
- package/packages/core/src/store/repo-tick.ts +72 -0
- package/packages/core/src/store/session-handle.ts +34 -0
- package/packages/core/src/store/snapshots.ts +10 -0
- package/packages/core/src/store/subscribe.ts +1 -1
- package/packages/core/src/store/ticket-assets.ts +4 -4
- package/packages/core/src/store/types.ts +71 -6
- package/packages/core/src/testing/dispatch-read-budget.ts +215 -0
- package/packages/core/src/testing/index.ts +10 -0
- package/packages/core/src/testing/reduced-read-budget.ts +502 -0
- package/packages/core/src/testing/refresh-scheduler.ts +32 -0
- package/skills/guide/SKILL.md +116 -62
- package/skills/guide/references/integration-tree.md +117 -0
- package/skills/guide/references/landing-policy.md +150 -0
- package/skills/guide/references/migration-1.0.md +68 -0
- package/skills/guide/references/operator-api.md +13 -6
- package/skills/guide/references/plugin-authoring.md +34 -0
- package/skills/guide/references/remote-store-protocol.md +114 -9
- package/skills/guide/references/remote-ticket-protocol.md +26 -5
- package/skills/guide/references/restacking.md +79 -0
- package/skills/guide/references/setup.md +49 -6
- package/skills/guide/references/ticket-dependencies.md +69 -0
- package/skills/guide/references/ticket-migration.md +8 -0
- package/skills/operate/SKILL.md +55 -5
- package/skills/reconcile/SKILL.md +55 -48
- package/skills/spec/SKILL.md +67 -1
- package/skills/tickets/SKILL.md +55 -2
- package/templates/autobuild.toml +3 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import { suspendNativeLanding } from '../kernel/landing-publication'
|
|
2
|
+
import { completeAutomaticReconcile } from '../kernel/leaf-restack-completion'
|
|
3
|
+
import { readBuildFacts, readPhaseFailures } from '../store/reduced-reads'
|
|
1
4
|
import type { IdSource } from '../ids'
|
|
2
5
|
import { DISPATCHER, KERNEL } from '../events/envelope'
|
|
3
6
|
import type { Forge, WorkspacePublication } from '../ports/types'
|
|
4
7
|
import type { Exec } from '../ports/workspace/git-worktree'
|
|
5
|
-
import { openExecution } from '../processes/execution-settlement'
|
|
6
|
-
import {
|
|
7
|
-
latestUncompletedPublicationRequest,
|
|
8
|
-
publicationLostRecorded,
|
|
9
|
-
publicationRequestCompleted,
|
|
10
|
-
publicationRequestSettled,
|
|
11
|
-
} from '../processes/publication-state'
|
|
12
8
|
import { systemClock, type BuildStore, type Clock } from '../store/types'
|
|
13
9
|
import { completeFinalizePr } from './terminals'
|
|
14
10
|
|
|
@@ -41,11 +37,174 @@ export async function settlePendingPublication(
|
|
|
41
37
|
): Promise<void> {
|
|
42
38
|
const publication = deps.publication
|
|
43
39
|
if (publication === undefined) return
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
await completeAutomaticReconcile(deps.store, slug)
|
|
41
|
+
let events = (await readBuildFacts(deps.store, slug)).value
|
|
42
|
+
const request = events.publication.latestUncompletedRequest()
|
|
46
43
|
if (request === undefined) return
|
|
47
44
|
|
|
48
|
-
|
|
45
|
+
if (request.payload.operation === 'restack') {
|
|
46
|
+
const record = await deps.store.getBuild(slug)
|
|
47
|
+
const clock = deps.clock ?? systemClock
|
|
48
|
+
if (
|
|
49
|
+
events.state.sessions.open.length > 0 ||
|
|
50
|
+
(events.open !== null &&
|
|
51
|
+
record?.lease !== undefined &&
|
|
52
|
+
new Date(record.lease.expiresAt).getTime() > clock().getTime())
|
|
53
|
+
)
|
|
54
|
+
return
|
|
55
|
+
if (publication.rewrite === undefined)
|
|
56
|
+
throw new Error('workspace provider lacks trusted restack publication')
|
|
57
|
+
const ref = events.workspace?.ref
|
|
58
|
+
if (ref === undefined) throw new Error('restack publication requires its retained workspace')
|
|
59
|
+
const transaction = request.payload.rewrite
|
|
60
|
+
const active = events.log.restack.active
|
|
61
|
+
const intended = events.log.restack.intent
|
|
62
|
+
if (
|
|
63
|
+
transaction.headSha !== request.payload.sha ||
|
|
64
|
+
active?.id !== transaction.id ||
|
|
65
|
+
intended?.id !== transaction.id ||
|
|
66
|
+
intended.headSha !== request.payload.sha ||
|
|
67
|
+
intended.targetBase !== transaction.targetBase ||
|
|
68
|
+
intended.oldHead !== transaction.oldHead ||
|
|
69
|
+
intended.branch !== request.payload.branch
|
|
70
|
+
)
|
|
71
|
+
throw new Error('restack publication request does not match its durable intent')
|
|
72
|
+
const archives = [...new Set([...events.gitTips, request.payload.sha])].map((sha) => ({
|
|
73
|
+
ref: `refs/autobuild/archive/${slug}/${sha}`,
|
|
74
|
+
sha,
|
|
75
|
+
}))
|
|
76
|
+
await suspendNativeLanding({ ...deps, slug }, `publication:${request.seq}`)
|
|
77
|
+
const result = await publication.rewrite({
|
|
78
|
+
ref,
|
|
79
|
+
sha: request.payload.sha,
|
|
80
|
+
branch: transaction.branch,
|
|
81
|
+
expected: transaction.oldHead,
|
|
82
|
+
localExpected: transaction.localBranchHead,
|
|
83
|
+
archives,
|
|
84
|
+
})
|
|
85
|
+
const latest = (await readBuildFacts(deps.store, slug)).value
|
|
86
|
+
if (
|
|
87
|
+
(result.kind === 'published' || result.rewritten === true) &&
|
|
88
|
+
!latest.restackHistory.some(
|
|
89
|
+
(e) => e.type === 'restack.rewritten' && e.payload.id === transaction.id,
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
await deps.store.append(slug, {
|
|
93
|
+
actor: DISPATCHER,
|
|
94
|
+
type: 'restack.rewritten',
|
|
95
|
+
payload: {
|
|
96
|
+
...transaction,
|
|
97
|
+
archives,
|
|
98
|
+
...(result.kind === 'lease-mismatch' ? { observedHead: result.actual } : {}),
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
if (result.kind === 'lease-mismatch') {
|
|
102
|
+
await deps.store.append(slug, {
|
|
103
|
+
actor: DISPATCHER,
|
|
104
|
+
type: 'restack.contended',
|
|
105
|
+
payload: { id: transaction.id, request: request.seq, actual: result.actual },
|
|
106
|
+
})
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
const settled = await readBuildFacts(deps.store, slug)
|
|
110
|
+
if (!settled.value.publication.requestCompleted(request))
|
|
111
|
+
await deps.store.appendIfCurrent(slug, settled.cursor, {
|
|
112
|
+
actor: DISPATCHER,
|
|
113
|
+
type: 'restack.completed',
|
|
114
|
+
payload: transaction,
|
|
115
|
+
})
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (request.payload.operation === 'reconcile' && request.payload.rewrite !== undefined) {
|
|
120
|
+
const record = await deps.store.getBuild(slug)
|
|
121
|
+
const clock = deps.clock ?? systemClock
|
|
122
|
+
if (
|
|
123
|
+
events.open !== null &&
|
|
124
|
+
record?.lease !== undefined &&
|
|
125
|
+
new Date(record.lease.expiresAt).getTime() > clock().getTime()
|
|
126
|
+
)
|
|
127
|
+
return
|
|
128
|
+
if (publication.rewrite === undefined)
|
|
129
|
+
throw new Error(
|
|
130
|
+
'workspace provider lacks trusted reconcile rewrite/archive publication; upgrade the provider before retrying',
|
|
131
|
+
)
|
|
132
|
+
const ref = events.workspace?.ref
|
|
133
|
+
if (ref === undefined) throw new Error('reconcile publication requires its retained workspace')
|
|
134
|
+
const transaction = request.payload.rewrite
|
|
135
|
+
const intended = events.reconcileHistory.findLast(
|
|
136
|
+
(event) => event.type === 'reconcile.publish-intended' && event.payload.id === transaction.id,
|
|
137
|
+
)
|
|
138
|
+
if (
|
|
139
|
+
intended?.type !== 'reconcile.publish-intended' ||
|
|
140
|
+
intended.payload.headSha !== request.payload.sha ||
|
|
141
|
+
intended.payload.oldHead !== transaction.oldHead ||
|
|
142
|
+
intended.payload.targetBase !== transaction.targetBase
|
|
143
|
+
)
|
|
144
|
+
throw new Error('reconcile request does not match its durable resolved intent')
|
|
145
|
+
if (events.reconcileBases[String(transaction.attempt)] !== transaction.targetBase)
|
|
146
|
+
throw new Error('reconcile publication target differs from the recorded start')
|
|
147
|
+
const tips = new Set([...events.gitTips, request.payload.sha])
|
|
148
|
+
const archives = [...tips].map((sha) => ({ ref: `refs/autobuild/archive/${slug}/${sha}`, sha }))
|
|
149
|
+
await suspendNativeLanding({ ...deps, slug }, `publication:${request.seq}`)
|
|
150
|
+
const result = await publication.rewrite({
|
|
151
|
+
ref,
|
|
152
|
+
sha: request.payload.sha,
|
|
153
|
+
branch: request.payload.branch,
|
|
154
|
+
expected: transaction.oldHead,
|
|
155
|
+
localExpected: transaction.localBranchHead,
|
|
156
|
+
archives,
|
|
157
|
+
})
|
|
158
|
+
const history = (await readBuildFacts(deps.store, slug)).value.reconcileHistory
|
|
159
|
+
if (
|
|
160
|
+
(result.kind === 'published' || result.rewritten === true) &&
|
|
161
|
+
!history.some((e) => e.type === 'reconcile.rewritten' && e.payload.id === transaction.id)
|
|
162
|
+
)
|
|
163
|
+
await deps.store.append(slug, {
|
|
164
|
+
actor: DISPATCHER,
|
|
165
|
+
type: 'reconcile.rewritten',
|
|
166
|
+
payload: {
|
|
167
|
+
...transaction,
|
|
168
|
+
headSha: request.payload.sha,
|
|
169
|
+
archives,
|
|
170
|
+
...(result.kind === 'lease-mismatch' ? { observedHead: result.actual } : {}),
|
|
171
|
+
},
|
|
172
|
+
})
|
|
173
|
+
if (result.kind === 'lease-mismatch') {
|
|
174
|
+
await deps.store.append(slug, {
|
|
175
|
+
actor: DISPATCHER,
|
|
176
|
+
type: 'reconcile.contended',
|
|
177
|
+
payload: { id: transaction.id, request: request.seq, actual: result.actual },
|
|
178
|
+
})
|
|
179
|
+
const failures = await readPhaseFailures(deps.store, slug, 'reconcile', transaction.attempt)
|
|
180
|
+
await deps.store.append(slug, {
|
|
181
|
+
actor: KERNEL,
|
|
182
|
+
type: 'phase.failed',
|
|
183
|
+
payload: {
|
|
184
|
+
phase: 'reconcile',
|
|
185
|
+
round: transaction.attempt,
|
|
186
|
+
attempt: failures.count + 1,
|
|
187
|
+
willRetry: true,
|
|
188
|
+
error: `reconcile publication lost its expected-head lease to ${result.actual ?? '(deleted)'}; replay again onto frozen base ${transaction.targetBase}`,
|
|
189
|
+
},
|
|
190
|
+
})
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
if (!(await readBuildFacts(deps.store, slug)).value.publication.requestCompleted(request))
|
|
194
|
+
await deps.store.append(slug, {
|
|
195
|
+
actor: DISPATCHER,
|
|
196
|
+
type: 'reconcile.completed',
|
|
197
|
+
payload: {
|
|
198
|
+
headSha: request.payload.sha,
|
|
199
|
+
rewriteId: transaction.id,
|
|
200
|
+
artifact: request.payload.artifact,
|
|
201
|
+
},
|
|
202
|
+
})
|
|
203
|
+
await completeAutomaticReconcile(deps.store, slug)
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const abandoned = events.publication.requestSettled(request)
|
|
49
208
|
// Consulted for every uncompleted request, not only abandoned ones: a guest
|
|
50
209
|
// that pushed its branch before dying is owed its completion fact, not a
|
|
51
210
|
// re-push or a loss record.
|
|
@@ -59,7 +218,7 @@ export async function settlePendingPublication(
|
|
|
59
218
|
// returning silently — the exact drop that lost the validate-hosted-
|
|
60
219
|
// dispatcher generation-1 work. The finalize-step publish-failure path
|
|
61
220
|
// below is unchanged: it already settles loudly via its failed outcome.
|
|
62
|
-
if (!
|
|
221
|
+
if (!events.publication.lostRecorded(request)) {
|
|
63
222
|
await deps.store.append(slug, {
|
|
64
223
|
actor: DISPATCHER,
|
|
65
224
|
type: 'publication.lost',
|
|
@@ -85,14 +244,11 @@ export async function settlePendingPublication(
|
|
|
85
244
|
const leaseLive =
|
|
86
245
|
record?.lease !== undefined &&
|
|
87
246
|
new Date(record.lease.expiresAt).getTime() > clock().getTime()
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
for (const event of events) {
|
|
91
|
-
if (event.type === 'workspace.provisioned') ref = event.payload.ref
|
|
92
|
-
else if (event.type === 'workspace.released') ref = undefined
|
|
93
|
-
}
|
|
247
|
+
if (events.open !== null && leaseLive) return
|
|
248
|
+
const ref = events.workspace?.ref
|
|
94
249
|
if (ref === undefined)
|
|
95
250
|
throw new Error(`build ${slug} has a publication request but no open workspace`)
|
|
251
|
+
await suspendNativeLanding({ ...deps, slug }, `publication:${request.seq}`)
|
|
96
252
|
await publication.publish({ ref, sha: request.payload.sha, branch: request.payload.branch })
|
|
97
253
|
}
|
|
98
254
|
} catch (error) {
|
|
@@ -115,8 +271,8 @@ export async function settlePendingPublication(
|
|
|
115
271
|
})
|
|
116
272
|
return
|
|
117
273
|
}
|
|
118
|
-
events = await deps.store
|
|
119
|
-
if (
|
|
274
|
+
events = (await readBuildFacts(deps.store, slug)).value
|
|
275
|
+
if (events.publication.requestCompleted(request)) return
|
|
120
276
|
|
|
121
277
|
if (request.payload.operation === 'implement') {
|
|
122
278
|
await deps.store.append(slug, {
|
|
@@ -157,7 +313,7 @@ export async function settlePendingPublication(
|
|
|
157
313
|
const newline = text.indexOf('\n')
|
|
158
314
|
const title = (newline === -1 ? text : text.slice(0, newline)).replace(/^#+\s*/, '').trim()
|
|
159
315
|
if (title === '') throw new Error(`empty PR title for ${slug}`)
|
|
160
|
-
const created = events.
|
|
316
|
+
const created = events.lastCreated
|
|
161
317
|
if (created?.type !== 'build.created') throw new Error(`missing build.created for ${slug}`)
|
|
162
318
|
|
|
163
319
|
await completeFinalizePr(
|
|
@@ -178,7 +334,7 @@ export async function settlePendingPublication(
|
|
|
178
334
|
events,
|
|
179
335
|
{
|
|
180
336
|
branch: request.payload.branch,
|
|
181
|
-
baseBranch: created.payload.baseBranch,
|
|
337
|
+
baseBranch: events.state.baseBranch ?? created.payload.baseBranch,
|
|
182
338
|
title,
|
|
183
339
|
body: newline === -1 ? '' : text.slice(newline + 1).replace(/^\n+/, ''),
|
|
184
340
|
mergeMessage: text,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { forgeReadinessWarnings, reduceDispatchStatus } from '../kernel/dispatch-status'
|
|
2
|
+
import { readRepositoryFacts, type RepositoryReadFacts } from '../store/reduced-reads'
|
|
1
3
|
import {
|
|
2
4
|
formatDispatcherIdentity,
|
|
3
5
|
projectDispatcherLiveness,
|
|
@@ -17,6 +19,7 @@ import { withSessionlessStore, type StoreOpener } from './store-opening'
|
|
|
17
19
|
/** Script-facing projection returned by `ab repository status`. */
|
|
18
20
|
export interface RepositoryStatus extends DispatchSettings {
|
|
19
21
|
repo: string
|
|
22
|
+
warningLines?: string[]
|
|
20
23
|
dispatcher: DispatcherLiveness
|
|
21
24
|
ticketSourceDegradation?: TicketSourceDegradation
|
|
22
25
|
/** Live operator sandboxes (AUT-340); released environments are omitted. */
|
|
@@ -81,9 +84,15 @@ export function projectRepositoryStatus(
|
|
|
81
84
|
}
|
|
82
85
|
publications.reverse()
|
|
83
86
|
const active = reduceTicketSourceHealth(events)
|
|
87
|
+
const latestRun = events.findLast((event) => event.type === 'dispatcher.run-started')
|
|
88
|
+
const warningLines =
|
|
89
|
+
latestRun?.type === 'dispatcher.run-started'
|
|
90
|
+
? forgeReadinessWarnings(reduceDispatchStatus(events, latestRun.payload.run))
|
|
91
|
+
: []
|
|
84
92
|
return {
|
|
85
93
|
...(active === undefined ? {} : { ticketSourceDegradation: active }),
|
|
86
94
|
repo,
|
|
95
|
+
...(warningLines.length ? { warningLines } : {}),
|
|
87
96
|
dispatcher,
|
|
88
97
|
...reduceDispatchSettings(events),
|
|
89
98
|
sandboxes: sandboxStates(events)
|
|
@@ -99,6 +108,39 @@ export function projectRepositoryStatus(
|
|
|
99
108
|
}
|
|
100
109
|
}
|
|
101
110
|
|
|
111
|
+
export function repositoryStatusFromFacts(
|
|
112
|
+
repo: string,
|
|
113
|
+
facts: RepositoryReadFacts,
|
|
114
|
+
dispatcher: DispatcherLiveness,
|
|
115
|
+
): RepositoryStatus {
|
|
116
|
+
const warningLines = facts.status ? forgeReadinessWarnings(facts.status) : []
|
|
117
|
+
return {
|
|
118
|
+
repo,
|
|
119
|
+
...(warningLines.length ? { warningLines } : {}),
|
|
120
|
+
dispatcher,
|
|
121
|
+
...facts.settings,
|
|
122
|
+
...(facts.health === undefined ? {} : { ticketSourceDegradation: facts.health }),
|
|
123
|
+
sandboxes: facts.sandboxes
|
|
124
|
+
.filter((state) => state.state !== 'released')
|
|
125
|
+
.map((state) => ({
|
|
126
|
+
operator: state.operator,
|
|
127
|
+
environmentId: state.environmentId,
|
|
128
|
+
provider: state.provider,
|
|
129
|
+
state: state.state === 'stopped' ? ('stopped' as const) : ('live' as const),
|
|
130
|
+
lastEvidenceAt: state.lastEvidenceTs,
|
|
131
|
+
})),
|
|
132
|
+
publications: [...facts.publications].reverse().map((event) => ({
|
|
133
|
+
operator: event.payload.operator,
|
|
134
|
+
branch: event.payload.branch,
|
|
135
|
+
sha: event.payload.sha,
|
|
136
|
+
prNumber: event.payload.pr.number,
|
|
137
|
+
prUrl: event.payload.pr.url,
|
|
138
|
+
...(event.payload.session !== undefined ? { session: event.payload.session } : {}),
|
|
139
|
+
at: event.ts,
|
|
140
|
+
})),
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
102
144
|
export function renderRepositoryStatus(status: RepositoryStatus): string[] {
|
|
103
145
|
const setting = (enabled: boolean): string => (enabled ? 'ON' : 'OFF')
|
|
104
146
|
const active = status.ticketSourceDegradation
|
|
@@ -109,6 +151,7 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
|
|
|
109
151
|
`ticket source ${active.source}: ${active.cause} (${active.operation}) — ${active.message}${'resetAt' in active ? `; reset ${active.resetAt}` : ''}`,
|
|
110
152
|
]),
|
|
111
153
|
`repository: ${status.repo}`,
|
|
154
|
+
...(status.warningLines ?? []),
|
|
112
155
|
`dispatcher: ${status.dispatcher.state}${status.dispatcher.holder ? ` — ${formatDispatcherIdentity(status.dispatcher.holder)}` : ' — no dispatcher holds the repository'}`,
|
|
113
156
|
...(status.dispatcher.expiredHolder
|
|
114
157
|
? [`expired dispatcher: ${formatDispatcherIdentity(status.dispatcher.expiredHolder)}`]
|
|
@@ -147,8 +190,12 @@ export async function abRepositoryStatus(opts: RepositoryStatusOpts): Promise<vo
|
|
|
147
190
|
await withSessionlessStore(opts, async ({ store, repo }) => {
|
|
148
191
|
// A fresh store has no repository row. Do not call ensureRepo: this query's
|
|
149
192
|
// empty-stream defaults must remain a genuinely read-only operation.
|
|
150
|
-
const {
|
|
151
|
-
const status =
|
|
193
|
+
const { dispatcher } = await readDispatcherLiveness(store, repo, opts.now?.())
|
|
194
|
+
const status = repositoryStatusFromFacts(
|
|
195
|
+
repo,
|
|
196
|
+
(await readRepositoryFacts(store, repo)).value,
|
|
197
|
+
dispatcher,
|
|
198
|
+
)
|
|
152
199
|
if (opts.json === true) {
|
|
153
200
|
opts.stdout(JSON.stringify(status, null, 2))
|
|
154
201
|
return
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { indexLog } from '../kernel/log-index'
|
|
2
|
+
import { projectTree, type TreeProjection } from './dashboard/tree'
|
|
3
|
+
import { buildVocabulary } from './dashboard/model'
|
|
4
|
+
import { readBuildDigests } from '../store/reduced-reads'
|
|
5
|
+
import { readBuildFacts } from '../store/reduced-reads'
|
|
6
|
+
import type { BuildFacts } from '../processes/repo-view'
|
|
1
7
|
/**
|
|
2
8
|
* `ab builds` and `ab build status <slug>` — the read-only query surface on
|
|
3
9
|
* build state (SPEC §8.2, §15.5). Their invocation forms require no session,
|
|
@@ -44,9 +50,9 @@ import {
|
|
|
44
50
|
} from '../processes/build-execution-state'
|
|
45
51
|
import type { PipelineSourceMeta } from '../config/pipeline-source'
|
|
46
52
|
import { openExecution } from '../processes/execution-settlement'
|
|
47
|
-
import {
|
|
53
|
+
import { currentAutoMergeDeferralFrom } from '../kernel/auto-merge'
|
|
48
54
|
import { autoMergeDisplay, type AutoMergeDisplay } from './dashboard/model'
|
|
49
|
-
import {
|
|
55
|
+
import { decideNextFromFacts } from '../kernel/engine'
|
|
50
56
|
import {
|
|
51
57
|
reduceBuild,
|
|
52
58
|
type BuildState,
|
|
@@ -91,6 +97,11 @@ export interface LeaseInfo {
|
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
export interface BuildSummary {
|
|
100
|
+
kind?: 'integration' | 'work'
|
|
101
|
+
target?: string
|
|
102
|
+
integration?: ReturnType<typeof buildVocabulary>['integration']
|
|
103
|
+
integrationState?: BuildState['integration']
|
|
104
|
+
nodeRestack?: BuildState['nodeRestack']
|
|
94
105
|
slug: string
|
|
95
106
|
ticket?: TicketRef
|
|
96
107
|
/** The reducer's effective status (§15.5) — never mixed with lease health. */
|
|
@@ -136,6 +147,9 @@ export type BuildDecisionProjection =
|
|
|
136
147
|
| { kind: 'unavailable'; diagnostic: string }
|
|
137
148
|
|
|
138
149
|
export interface BuildDetail extends BuildSummary {
|
|
150
|
+
tree?: TreeProjection
|
|
151
|
+
/** Immutable policy provenance and durable command/native application state. */
|
|
152
|
+
landing?: BuildState['landing']
|
|
139
153
|
/** Current work-owner decision. Open PRs use the build-owned config; ended
|
|
140
154
|
* PRs project the repository completion path directly from durable state. */
|
|
141
155
|
decision?: BuildDecisionProjection
|
|
@@ -225,6 +239,9 @@ export function summarizeFrom(record: BuildRecord, state: BuildState, now: Date)
|
|
|
225
239
|
const attempt = active?.attempt
|
|
226
240
|
return {
|
|
227
241
|
slug: record.slug,
|
|
242
|
+
...buildVocabulary(state),
|
|
243
|
+
...(state.kind === 'node' ? { integrationState: state.integration } : {}),
|
|
244
|
+
...(state.kind === 'node' ? { nodeRestack: state.nodeRestack } : {}),
|
|
228
245
|
// record.ticket is a TicketRef already carrying id/title/url — no artifact
|
|
229
246
|
// read and no ticket-provider call (live ticket state is out of scope).
|
|
230
247
|
...(record.ticket !== undefined ? { ticket: record.ticket } : {}),
|
|
@@ -271,7 +288,33 @@ export function detail(
|
|
|
271
288
|
decision?: BuildDecisionProjection,
|
|
272
289
|
streams?: readonly StreamRecord[],
|
|
273
290
|
): BuildDetail {
|
|
274
|
-
|
|
291
|
+
return detailFromFacts(
|
|
292
|
+
record,
|
|
293
|
+
{
|
|
294
|
+
state: reduceBuild(events),
|
|
295
|
+
log: indexLog(events),
|
|
296
|
+
observations: events
|
|
297
|
+
.filter((event) => event.type === 'observation.recorded')
|
|
298
|
+
.map((event) => event.payload),
|
|
299
|
+
open: openExecution(events),
|
|
300
|
+
},
|
|
301
|
+
now,
|
|
302
|
+
eventCount === undefined ? undefined : events.slice(-eventCount),
|
|
303
|
+
decision,
|
|
304
|
+
streams,
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function detailFromFacts(
|
|
309
|
+
record: BuildRecord,
|
|
310
|
+
facts: Pick<BuildFacts, 'state' | 'open'> &
|
|
311
|
+
Partial<Pick<BuildFacts, 'log'>> & { observations: BuildState['observations'] },
|
|
312
|
+
now: Date,
|
|
313
|
+
events?: AbEvent[],
|
|
314
|
+
decision?: BuildDecisionProjection,
|
|
315
|
+
streams?: readonly StreamRecord[],
|
|
316
|
+
): BuildDetail {
|
|
317
|
+
const state = facts.state
|
|
275
318
|
const streamStatus = new Map<string, { stream?: string; status: 'open' | 'closed' }>()
|
|
276
319
|
if (streams !== undefined) {
|
|
277
320
|
for (const record of streams) {
|
|
@@ -300,7 +343,9 @@ export function detail(
|
|
|
300
343
|
}))
|
|
301
344
|
return {
|
|
302
345
|
...summary,
|
|
346
|
+
...(facts.log ? { tree: projectTree(record, state, facts.log.restack) } : {}),
|
|
303
347
|
autoMerge: autoMergeDisplay(state),
|
|
348
|
+
...(state.landing && Object.keys(state.landing).length ? { landing: state.landing } : {}),
|
|
304
349
|
...(decision !== undefined ? { decision } : {}),
|
|
305
350
|
openEscalations: state.openEscalations,
|
|
306
351
|
...(state.reviewRoundCeilings.plan !== undefined || state.reviewRoundCeilings.code !== undefined
|
|
@@ -316,15 +361,13 @@ export function detail(
|
|
|
316
361
|
}),
|
|
317
362
|
// Observations are historical facts rather than a derived current-state
|
|
318
363
|
// opinion. Preserve event order and exact optional evidence fields.
|
|
319
|
-
observations:
|
|
320
|
-
|
|
321
|
-
.
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
...(event.payload.refs !== undefined ? { refs: event.payload.refs } : {}),
|
|
327
|
-
})),
|
|
364
|
+
observations: facts.observations.map((observation) => ({
|
|
365
|
+
id: observation.id,
|
|
366
|
+
kind: observation.kind,
|
|
367
|
+
summary: observation.summary,
|
|
368
|
+
...(observation.files !== undefined ? { files: observation.files } : {}),
|
|
369
|
+
...(observation.refs !== undefined ? { refs: observation.refs } : {}),
|
|
370
|
+
})),
|
|
328
371
|
...(state.setupFailure !== undefined
|
|
329
372
|
? {
|
|
330
373
|
setupFailure: {
|
|
@@ -338,7 +381,7 @@ export function detail(
|
|
|
338
381
|
...(state.executions.at(-1) !== undefined ? { execution: state.executions.at(-1)! } : {}),
|
|
339
382
|
// Durable supervision: a recorded execution with no following end is the
|
|
340
383
|
// source of truth for whether a guest may still be running.
|
|
341
|
-
executionOpen:
|
|
384
|
+
executionOpen: facts.open !== null,
|
|
342
385
|
...(state.infrastructureFailure !== undefined
|
|
343
386
|
? { infrastructureFailure: state.infrastructureFailure }
|
|
344
387
|
: {}),
|
|
@@ -364,7 +407,7 @@ export function detail(
|
|
|
364
407
|
: {}),
|
|
365
408
|
// getEvents returns seq-ordered events, so the newest n slice out already
|
|
366
409
|
// chronological — which is what the AC asks for.
|
|
367
|
-
...(
|
|
410
|
+
...(events !== undefined ? { events } : {}),
|
|
368
411
|
...(state.outcome !== undefined ? { outcome: state.outcome } : {}),
|
|
369
412
|
}
|
|
370
413
|
}
|
|
@@ -476,13 +519,15 @@ export function renderSummaries(summaries: BuildSummary[], now: Date, emptyNote:
|
|
|
476
519
|
rows.push([
|
|
477
520
|
summary.slug,
|
|
478
521
|
summary.status,
|
|
479
|
-
|
|
522
|
+
summary.kind === 'integration'
|
|
523
|
+
? `integration ${summary.integration ?? ''}`
|
|
524
|
+
: phaseCell(summary),
|
|
480
525
|
healthWord(summary.lease.health),
|
|
481
526
|
summary.progress.heartbeatAt === undefined
|
|
482
527
|
? '—'
|
|
483
528
|
: relativeTime(summary.progress.heartbeatAt, now),
|
|
484
529
|
`${progressAge}${isDiverged(summary.progress, now) ? ' diverged' : ''}`,
|
|
485
|
-
ticketCell(summary)
|
|
530
|
+
`${ticketCell(summary)}${summary.target ? ` target ${summary.target}` : ''}`,
|
|
486
531
|
prCell(summary),
|
|
487
532
|
])
|
|
488
533
|
}
|
|
@@ -497,6 +542,52 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
497
542
|
lines.push(` ticket: ${d.ticket.id}${title}`)
|
|
498
543
|
if (d.ticket.url !== undefined) lines.push(` ticket url: ${d.ticket.url}`)
|
|
499
544
|
}
|
|
545
|
+
if (d.target)
|
|
546
|
+
lines.push(
|
|
547
|
+
` ${d.kind ?? 'work'} · target ${d.target}${d.integration ? ` · ${d.integration}` : ''}`,
|
|
548
|
+
)
|
|
549
|
+
if (d.integrationState) {
|
|
550
|
+
const integration = d.integrationState
|
|
551
|
+
lines.push(` open children: ${integration.observation?.openChildren.join(', ') || 'none'}`)
|
|
552
|
+
if (integration.observation?.diagnostics.length)
|
|
553
|
+
lines.push(` completeness unavailable: ${integration.observation.diagnostics.join('; ')}`)
|
|
554
|
+
if (integration.cycle)
|
|
555
|
+
lines.push(
|
|
556
|
+
` verification head: ${integration.cycle.head} · parent ${integration.cycle.parent}`,
|
|
557
|
+
)
|
|
558
|
+
if (d.integration === 'verification failed')
|
|
559
|
+
lines.push(' repair: file a child ticket targeting this node')
|
|
560
|
+
}
|
|
561
|
+
if (d.nodeRestack) {
|
|
562
|
+
const node = d.nodeRestack
|
|
563
|
+
const move = node.parentRequest ?? node.parentChange
|
|
564
|
+
if (move)
|
|
565
|
+
lines.push(
|
|
566
|
+
` reparenting: ${move.old.target?.ticket.id ?? move.old.branch} → ${move.next.target?.ticket.id ?? move.next.branch}`,
|
|
567
|
+
)
|
|
568
|
+
if (node.parentRejection) lines.push(` target change refused: ${node.parentRejection.reason}`)
|
|
569
|
+
if (node.inventory) {
|
|
570
|
+
lines.push(` node head: ${node.inventory.head}`)
|
|
571
|
+
lines.push(` build changes: ${node.inventory.builds.join(', ') || 'none'}`)
|
|
572
|
+
lines.push(` foreign changes (node-owned): ${node.inventory.foreign.join(', ') || 'none'}`)
|
|
573
|
+
}
|
|
574
|
+
if (!node.active && node.observedParent && node.observedParent.sha !== node.contributionBase)
|
|
575
|
+
lines.push(` node restack pending: parent ${node.observedParent.sha}`)
|
|
576
|
+
if (node.active) {
|
|
577
|
+
lines.push(
|
|
578
|
+
` node ${node.active.operation}: ${node.active.id} · ${node.items.length}/${node.active.changes.length} changes · parent ${node.active.parent}`,
|
|
579
|
+
)
|
|
580
|
+
if (node.conflict) {
|
|
581
|
+
const change = node.active.changes[node.conflict.index]!
|
|
582
|
+
lines.push(
|
|
583
|
+
` conflict item ${node.conflict.index + 1}: ${change.sha} · ${change.build ?? 'foreign'}`,
|
|
584
|
+
)
|
|
585
|
+
}
|
|
586
|
+
for (const proof of node.active.merges)
|
|
587
|
+
if (proof.missing.length || proof.build)
|
|
588
|
+
lines.push(` unsafe merge ${proof.sha}: ${proof.missing.join(', ') || proof.build}`)
|
|
589
|
+
}
|
|
590
|
+
}
|
|
500
591
|
lines.push(` status: ${d.status}${d.outcome !== undefined ? ` (${d.outcome})` : ''}`)
|
|
501
592
|
lines.push(` phase: ${phaseCell(d)}`)
|
|
502
593
|
if (d.reviewRoundCeilings !== undefined) {
|
|
@@ -702,10 +793,11 @@ export interface StatusOpts {
|
|
|
702
793
|
}
|
|
703
794
|
|
|
704
795
|
/** Statuses a bare `ab builds` shows: the ones an operator can still act on. */
|
|
705
|
-
const ACTIVE_STATUSES: BuildStatus[] = ['running', 'paused', 'blocked']
|
|
796
|
+
const ACTIVE_STATUSES: BuildStatus[] = ['running', 'collecting', 'paused', 'blocked']
|
|
706
797
|
|
|
707
798
|
export function statusFilter(all?: boolean, queued?: boolean): BuildStatus[] {
|
|
708
|
-
if (all === true)
|
|
799
|
+
if (all === true)
|
|
800
|
+
return ['queued', 'running', 'collecting', 'paused', 'blocked', 'done', 'aborted']
|
|
709
801
|
return queued === true ? [...ACTIVE_STATUSES, 'queued'] : ACTIVE_STATUSES
|
|
710
802
|
}
|
|
711
803
|
|
|
@@ -742,7 +834,7 @@ export async function abBuilds(opts: AbBuildsOpts): Promise<void> {
|
|
|
742
834
|
// round trip and the listing's store cost stays flat as finished builds
|
|
743
835
|
// accumulate. The `--all` scope includes terminal statuses, so it takes no
|
|
744
836
|
// digest read and skips nothing — byte-for-byte the old loop.
|
|
745
|
-
const digests = opts.all === true ? undefined : await store
|
|
837
|
+
const digests = opts.all === true ? undefined : await readBuildDigests(store, identity)
|
|
746
838
|
const summaries: BuildSummary[] = []
|
|
747
839
|
for (const record of records) {
|
|
748
840
|
if (digests !== undefined && record.repo === identity) {
|
|
@@ -766,7 +858,11 @@ export async function abBuilds(opts: AbBuildsOpts): Promise<void> {
|
|
|
766
858
|
// entry under `identity` — `getRepoBuildDigests` groups by `record.repo`
|
|
767
859
|
// exactly — so it keeps its per-build history read (correct, just not
|
|
768
860
|
// accelerated).
|
|
769
|
-
const summary =
|
|
861
|
+
const summary = summarizeFrom(
|
|
862
|
+
record,
|
|
863
|
+
(await readBuildFacts(store, record.slug)).value.state,
|
|
864
|
+
now,
|
|
865
|
+
)
|
|
770
866
|
if (wanted.has(summary.status)) summaries.push(summary)
|
|
771
867
|
}
|
|
772
868
|
summaries.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
|
|
@@ -797,7 +893,7 @@ export interface AbBuildStatusOpts extends StatusOpts {
|
|
|
797
893
|
events?: number
|
|
798
894
|
}
|
|
799
895
|
|
|
800
|
-
function
|
|
896
|
+
function _openWorkspacePath(events: AbEvent[]): string | undefined {
|
|
801
897
|
let path: string | undefined
|
|
802
898
|
for (const event of events) {
|
|
803
899
|
if (event.type === 'workspace.provisioned') {
|
|
@@ -812,15 +908,11 @@ function openWorkspacePath(events: AbEvent[]): string | undefined {
|
|
|
812
908
|
/** The kernel tail both config sources share, so the deposited artifact and
|
|
813
909
|
* the workspace file cannot drift in what they compute — the sources differ
|
|
814
910
|
* only in where the config comes from, never in what is decided with it. */
|
|
815
|
-
function decideFromConfig(
|
|
816
|
-
|
|
817
|
-
state: BuildState,
|
|
818
|
-
config: Config,
|
|
819
|
-
): BuildDecisionProjection {
|
|
820
|
-
const decision = decideNext(events, config)
|
|
911
|
+
function decideFromConfig(facts: BuildFacts, config: Config): BuildDecisionProjection {
|
|
912
|
+
const decision = decideNextFromFacts(facts.state, facts.log, config)
|
|
821
913
|
if (decision.kind !== 'wait') return { kind: 'runner-work' }
|
|
822
914
|
if (decision.reason !== 'awaiting-pr') return { kind: 'parked', reason: decision.reason }
|
|
823
|
-
const reason =
|
|
915
|
+
const reason = currentAutoMergeDeferralFrom(facts.deferral, facts.state)
|
|
824
916
|
return { kind: 'awaiting-pr', ...(reason !== undefined ? { reason } : {}) }
|
|
825
917
|
}
|
|
826
918
|
|
|
@@ -840,10 +932,10 @@ function decideFromConfig(
|
|
|
840
932
|
* the read-only command fail. */
|
|
841
933
|
async function projectBuildDecision(
|
|
842
934
|
slug: string,
|
|
843
|
-
|
|
935
|
+
facts: BuildFacts,
|
|
844
936
|
store: Pick<BuildStore, 'getArtifact'>,
|
|
845
937
|
): Promise<BuildDecisionProjection | undefined> {
|
|
846
|
-
const state =
|
|
938
|
+
const state = facts.state
|
|
847
939
|
const active =
|
|
848
940
|
state.status === 'running' || state.status === 'paused' || state.status === 'blocked'
|
|
849
941
|
if (!active) return undefined
|
|
@@ -858,7 +950,7 @@ async function projectBuildDecision(
|
|
|
858
950
|
const artifact = await store.getArtifact(slug, BUILD_EFFECTIVE_CONFIG_ARTIFACT)
|
|
859
951
|
if (artifact !== null) {
|
|
860
952
|
try {
|
|
861
|
-
return decideFromConfig(
|
|
953
|
+
return decideFromConfig(facts, parseEffectiveBuildConfig(artifact))
|
|
862
954
|
} catch (error) {
|
|
863
955
|
const message = error instanceof Error ? error.message : String(error)
|
|
864
956
|
return {
|
|
@@ -870,7 +962,7 @@ async function projectBuildDecision(
|
|
|
870
962
|
|
|
871
963
|
// Source 2 — the local workspace, exactly as before, only when no artifact
|
|
872
964
|
// is deposited.
|
|
873
|
-
const workspace =
|
|
965
|
+
const workspace = facts.workspace?.path ?? facts.workspace?.ref
|
|
874
966
|
if (workspace === undefined) {
|
|
875
967
|
return {
|
|
876
968
|
kind: 'unavailable',
|
|
@@ -879,7 +971,7 @@ async function projectBuildDecision(
|
|
|
879
971
|
}
|
|
880
972
|
|
|
881
973
|
try {
|
|
882
|
-
return decideFromConfig(
|
|
974
|
+
return decideFromConfig(facts, await loadConfig(join(workspace, 'autobuild.toml')))
|
|
883
975
|
} catch {
|
|
884
976
|
// The raw error deliberately stays here: ENOENT/ENOTDIR messages embed the
|
|
885
977
|
// recorded workspace path, which for a remote build is a guest location.
|
|
@@ -944,8 +1036,13 @@ export async function abBuildStatus(opts: AbBuildStatusOpts): Promise<void> {
|
|
|
944
1036
|
const now = (opts.now ?? (() => new Date()))()
|
|
945
1037
|
await withAmbientReadStore(opts, async (context) => {
|
|
946
1038
|
const record = await requireReadableBuild(opts, context)
|
|
947
|
-
const
|
|
948
|
-
const
|
|
1039
|
+
const current = await readBuildFacts(context.store, opts.slug)
|
|
1040
|
+
const facts = current.value
|
|
1041
|
+
const events =
|
|
1042
|
+
opts.events === undefined
|
|
1043
|
+
? undefined
|
|
1044
|
+
: await context.store.getEvents(opts.slug, Math.max(0, current.cursor - opts.events))
|
|
1045
|
+
const decision = await projectBuildDecision(opts.slug, facts, context.store)
|
|
949
1046
|
// Stream enrichment is presentation (SPEC §9): an unavailable read
|
|
950
1047
|
// degrades to payload-carried ids without a status, never a failure.
|
|
951
1048
|
let streams: StreamRecord[] | undefined
|
|
@@ -957,7 +1054,7 @@ export async function abBuildStatus(opts: AbBuildStatusOpts): Promise<void> {
|
|
|
957
1054
|
} catch {
|
|
958
1055
|
streams = undefined
|
|
959
1056
|
}
|
|
960
|
-
const projected =
|
|
1057
|
+
const projected = detailFromFacts(record, facts, now, events, decision, streams)
|
|
961
1058
|
// Operator visibility (SPEC §16.1): which autobuild.toml the build's
|
|
962
1059
|
// pinned pipeline came from, alongside the effective-config revision.
|
|
963
1060
|
const configArtifact = await context.store.getArtifact(
|