@defrex/autobuild 1.6.0 → 1.8.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 +1 -1
- package/SPEC.md +423 -57
- package/docs/agent-runtimes.md +1 -1
- package/docs/answering-blocked-builds.md +44 -3
- package/docs/architecture.md +124 -29
- package/docs/cli.md +1 -0
- package/docs/configuration-overview.md +11 -1
- package/docs/configuration.md +334 -14
- package/docs/dispatcher.md +1 -1
- package/docs/forges.md +1 -0
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +7 -4
- package/docs/merge-policy.md +78 -6
- package/docs/migration-1.0.md +4 -2
- package/docs/operating.md +3 -2
- package/docs/operator-api.md +45 -13
- package/docs/operator-surfaces.md +16 -3
- package/docs/plugin-authoring.md +45 -7
- package/docs/remote-store-protocol.md +28 -7
- package/docs/restacking.md +35 -11
- package/docs/ticket-dependencies.md +9 -4
- package/docs/ticket-sources.md +34 -6
- package/docs/tickets.md +7 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/workspaces.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary-direct.ts +1 -0
- package/packages/core/src/cli/build-control.ts +65 -7
- package/packages/core/src/cli/context.ts +55 -14
- package/packages/core/src/cli/dashboard/actions.ts +13 -4
- package/packages/core/src/cli/dashboard/landing-display.ts +32 -8
- package/packages/core/src/cli/dashboard/model.ts +61 -8
- package/packages/core/src/cli/dashboard/render.ts +28 -3
- package/packages/core/src/cli/dashboard/tree.ts +9 -1
- package/packages/core/src/cli/dispatch-frontend.ts +10 -14
- package/packages/core/src/cli/dispatch-preflight.ts +1 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +145 -109
- package/packages/core/src/cli/dispatch.ts +9 -3
- package/packages/core/src/cli/help.ts +80 -11
- package/packages/core/src/cli/init-validation.ts +14 -1
- package/packages/core/src/cli/landings.ts +1 -1
- package/packages/core/src/cli/main.ts +60 -9
- package/packages/core/src/cli/publication-settlement.ts +10 -0
- package/packages/core/src/cli/repository-status.ts +37 -2
- package/packages/core/src/cli/status.ts +186 -12
- package/packages/core/src/cli/terminals.ts +197 -4
- package/packages/core/src/cli/ticket.ts +22 -4
- package/packages/core/src/cli/wait.ts +1 -0
- package/packages/core/src/cli/watch.ts +73 -0
- package/packages/core/src/config/landing.ts +12 -0
- package/packages/core/src/config/live.ts +4 -0
- package/packages/core/src/config/path-selectors.ts +68 -0
- package/packages/core/src/config/profiles.ts +96 -0
- package/packages/core/src/config/ready-assignee.ts +43 -11
- package/packages/core/src/config/roles.ts +33 -10
- package/packages/core/src/config/schema.ts +205 -81
- package/packages/core/src/events/catalog.ts +17 -3
- package/packages/core/src/events/compatibility.ts +4 -1
- package/packages/core/src/events/forge-degradation-policy.ts +16 -2
- package/packages/core/src/events/head-paths-limits.ts +25 -0
- package/packages/core/src/events/payloads.ts +323 -20
- package/packages/core/src/events/policy.ts +22 -0
- package/packages/core/src/events/repository.ts +47 -1
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +320 -130
- package/packages/core/src/kernel/build-creation.ts +29 -0
- package/packages/core/src/kernel/consent-revocation.ts +72 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +19 -8
- package/packages/core/src/kernel/engine.ts +48 -8
- package/packages/core/src/kernel/forge-health.ts +47 -0
- package/packages/core/src/kernel/guarded-forge.ts +76 -18
- package/packages/core/src/kernel/head-paths-state.ts +63 -0
- package/packages/core/src/kernel/head-paths.ts +401 -0
- package/packages/core/src/kernel/landing-policy-identity.ts +20 -0
- package/packages/core/src/kernel/landing-policy.ts +55 -2
- package/packages/core/src/kernel/landing-readiness.ts +104 -9
- package/packages/core/src/kernel/landing-state.ts +44 -4
- package/packages/core/src/kernel/leaf-restack-state.ts +50 -2
- package/packages/core/src/kernel/log-index.ts +27 -1
- package/packages/core/src/kernel/node-parent.ts +2 -0
- package/packages/core/src/kernel/node-polling.ts +13 -3
- package/packages/core/src/kernel/node-restack-state.ts +8 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +45 -0
- package/packages/core/src/kernel/read-deferrals.ts +3 -1
- package/packages/core/src/kernel/read-facts.ts +37 -2
- package/packages/core/src/kernel/reducer-registry.ts +22 -1
- package/packages/core/src/kernel/reducer.ts +332 -16
- package/packages/core/src/kernel/target-observation.ts +2 -5
- package/packages/core/src/kernel/terminal-guard.ts +52 -3
- package/packages/core/src/kernel/ticket-handbacks.ts +40 -0
- package/packages/core/src/kernel/ticket-preparation.ts +15 -1
- package/packages/core/src/kernel/ticket-wait.ts +345 -0
- package/packages/core/src/kernel/verify-applicability.ts +9 -19
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/index.ts +3 -0
- package/packages/core/src/operator/protocol.ts +25 -2
- package/packages/core/src/operator/query.ts +1 -1
- package/packages/core/src/operator/registry.ts +122 -10
- package/packages/core/src/operator/repository-events.ts +67 -0
- package/packages/core/src/operator/sandbox-host.ts +3 -0
- package/packages/core/src/operator/tickets.ts +15 -3
- package/packages/core/src/plugin-sdk/index.ts +4 -0
- package/packages/core/src/ports/forge/create.ts +6 -0
- package/packages/core/src/ports/forge/github-transport.ts +40 -3
- package/packages/core/src/ports/forge/github.ts +12 -1
- package/packages/core/src/ports/forge/workspace-ancestry.ts +60 -0
- package/packages/core/src/ports/forge-failure.ts +31 -2
- package/packages/core/src/ports/runner/routing.ts +66 -5
- package/packages/core/src/ports/tickets/assignees.ts +54 -0
- package/packages/core/src/ports/tickets/contract.ts +164 -4
- package/packages/core/src/ports/tickets/create.ts +17 -3
- package/packages/core/src/ports/tickets/fake.ts +5 -0
- package/packages/core/src/ports/tickets/github-fake.ts +18 -2
- package/packages/core/src/ports/tickets/github.ts +247 -29
- package/packages/core/src/ports/tickets/hosted-index.ts +1 -0
- package/packages/core/src/ports/tickets/operations.ts +6 -1
- package/packages/core/src/ports/tickets/tree.ts +12 -2
- package/packages/core/src/ports/tickets/update.ts +6 -2
- package/packages/core/src/ports/types.ts +36 -5
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +9 -0
- package/packages/core/src/processes/build-child.ts +28 -7
- package/packages/core/src/processes/build-execution-state.ts +34 -2
- package/packages/core/src/processes/build-runner.ts +165 -19
- package/packages/core/src/processes/dispatcher.ts +837 -115
- package/packages/core/src/processes/execution-no-progress.ts +22 -2
- package/packages/core/src/processes/harvest-child.ts +4 -0
- package/packages/core/src/processes/harvest-runner.ts +5 -0
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-state.ts +6 -1
- package/packages/core/src/processes/repo-view.ts +2 -0
- package/packages/core/src/scenarios/harness.ts +15 -1
- package/packages/core/src/store/digest.ts +41 -2
- package/packages/core/src/store/reduced-reads.ts +4 -1
- package/packages/core/src/store/reducer-value-shapes.json +10310 -8441
- package/packages/core/src/store/remote/client.ts +49 -10
- package/packages/core/src/store/remote/index.ts +4 -0
- package/packages/core/src/store/remote/protocol.ts +18 -1
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.7.0.json +27366 -0
- package/packages/core/src/store/remote/released-reducer-values/1.8.0.json +29043 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +3 -0
- package/packages/core/src/store/types.ts +27 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +84 -58
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/reduced-read-budget.ts +419 -9
- package/skills/code-review/SKILL.md +8 -0
- package/skills/finalize/SKILL.md +4 -0
- package/skills/guide/SKILL.md +241 -47
- package/skills/guide/references/integration-tree.md +7 -4
- package/skills/guide/references/merge-policy.md +78 -6
- package/skills/guide/references/migration-1.0.md +4 -2
- package/skills/guide/references/operator-api.md +45 -13
- package/skills/guide/references/plugin-authoring.md +45 -7
- package/skills/guide/references/remote-store-protocol.md +28 -7
- package/skills/guide/references/restacking.md +35 -11
- package/skills/guide/references/ticket-dependencies.md +9 -4
- package/skills/implement/SKILL.md +15 -1
- package/skills/operate/SKILL.md +133 -16
- package/skills/plan/SKILL.md +17 -2
- package/skills/plan-review/SKILL.md +8 -0
- package/skills/reconcile/SKILL.md +21 -5
- package/skills/tickets/SKILL.md +23 -6
- package/templates/hosted-service/package.json +2 -2
|
@@ -10,6 +10,13 @@ import { buildVocabulary } from './dashboard/model'
|
|
|
10
10
|
import { readBuildDigests } from '../store/reduced-reads'
|
|
11
11
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
12
12
|
import { slotRequest, slotWaitText, type SlotRequest } from '../kernel/dispatch-capacity'
|
|
13
|
+
import {
|
|
14
|
+
ticketWaitStatus,
|
|
15
|
+
ticketWaitText,
|
|
16
|
+
waitingOnText,
|
|
17
|
+
type TicketWaitStatus,
|
|
18
|
+
} from '../kernel/ticket-wait'
|
|
19
|
+
import type { LeafRestackState } from '../kernel/leaf-restack-state'
|
|
13
20
|
import { landingRestackDue } from '../kernel/engine'
|
|
14
21
|
import type { BuildFacts } from '../processes/repo-view'
|
|
15
22
|
/**
|
|
@@ -53,13 +60,21 @@ import { loadConfig } from '../config/load'
|
|
|
53
60
|
import type { Config } from '../config/schema'
|
|
54
61
|
import {
|
|
55
62
|
BUILD_EFFECTIVE_CONFIG_ARTIFACT,
|
|
63
|
+
EffectivePipelineUnreadable,
|
|
56
64
|
parseBuildConfigMetadata,
|
|
57
65
|
parseEffectiveBuildConfig,
|
|
66
|
+
readEffectivePipeline,
|
|
58
67
|
} from '../processes/build-execution-state'
|
|
68
|
+
import {
|
|
69
|
+
landingDeferralReason,
|
|
70
|
+
leafLandingCandidate,
|
|
71
|
+
leafLandingUndecidedReason,
|
|
72
|
+
} from '../kernel/landing-readiness'
|
|
73
|
+
import { sameLandingCandidate } from '../kernel/landing-state'
|
|
59
74
|
import type { PipelineSourceMeta } from '../config/pipeline-source'
|
|
60
75
|
import { openExecution } from '../processes/execution-settlement'
|
|
61
76
|
import { currentAutoMergeDeferralFrom } from '../kernel/auto-merge'
|
|
62
|
-
import { autoMergeDisplay, type AutoMergeDisplay } from './dashboard/model'
|
|
77
|
+
import { autoMergeDisplay, effectiveStatus, type AutoMergeDisplay } from './dashboard/model'
|
|
63
78
|
import { decideNextFromFacts } from '../kernel/engine'
|
|
64
79
|
import {
|
|
65
80
|
reduceBuild,
|
|
@@ -130,6 +145,12 @@ export interface BuildSummary {
|
|
|
130
145
|
progress: BuildProgress
|
|
131
146
|
/** A node's or parked build's runner request, admitted ahead of new ticket claims. */
|
|
132
147
|
slotWait?: SlotRequest
|
|
148
|
+
/** The build's ticket wait while it is requested, open, or ended and not
|
|
149
|
+
* yet resumed (SPEC §11 "Ticket waits"); omitted otherwise. */
|
|
150
|
+
wait?: TicketWaitStatus
|
|
151
|
+
/** Set when the open ticket wait's escalation is the only one open: the
|
|
152
|
+
* dashboards' `waiting` status. `status` stays the reducer's `blocked`. */
|
|
153
|
+
waitOnly?: true
|
|
133
154
|
}
|
|
134
155
|
|
|
135
156
|
export interface VerifyProgress {
|
|
@@ -158,14 +179,51 @@ export interface BuildObservation {
|
|
|
158
179
|
}
|
|
159
180
|
|
|
160
181
|
export type BuildDecisionProjection =
|
|
161
|
-
| {
|
|
162
|
-
|
|
182
|
+
| {
|
|
183
|
+
kind: 'awaiting-pr'
|
|
184
|
+
reason?: string
|
|
185
|
+
/** Set when status's own config read is the build's verify pin but the
|
|
186
|
+
* dispatcher's first read, the latest effective config, does not parse
|
|
187
|
+
* or cannot be read: the dispatcher then withholds every decision. */
|
|
188
|
+
pipelineUnreadable?: string
|
|
189
|
+
}
|
|
190
|
+
| {
|
|
191
|
+
kind: 'repository-completion'
|
|
192
|
+
prState: Extract<PrLifecycle, 'merged' | 'closed'>
|
|
193
|
+
}
|
|
163
194
|
| { kind: 'parked'; reason: string }
|
|
164
195
|
| { kind: 'runner-work' }
|
|
165
196
|
| { kind: 'unavailable'; diagnostic: string }
|
|
166
197
|
|
|
198
|
+
export interface LeafRestackStatus {
|
|
199
|
+
trigger: 'verify-entry' | 'awaiting-landing' | 'wait-resume'
|
|
200
|
+
state: 'replaying' | 'conflicted' | 'completed' | 'advanced'
|
|
201
|
+
onto: string
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** The open restack, else the newer of the last completed restack and the
|
|
205
|
+
* last wait-resume fast-forward. Reduced state only. */
|
|
206
|
+
export function leafRestackStatus(restack: LeafRestackState): LeafRestackStatus | undefined {
|
|
207
|
+
const { active, advanced, completed } = restack
|
|
208
|
+
if (active !== undefined)
|
|
209
|
+
return {
|
|
210
|
+
trigger: active.trigger,
|
|
211
|
+
state: restack.replay?.conflicted ? 'conflicted' : 'replaying',
|
|
212
|
+
onto: active.targetBase,
|
|
213
|
+
}
|
|
214
|
+
if (advanced !== undefined && (restack.advancedAt ?? 0) > (restack.completedAt ?? 0))
|
|
215
|
+
return { trigger: advanced.trigger, state: 'advanced', onto: advanced.to }
|
|
216
|
+
if (completed !== undefined)
|
|
217
|
+
return { trigger: completed.trigger, state: 'completed', onto: completed.targetBase }
|
|
218
|
+
return undefined
|
|
219
|
+
}
|
|
220
|
+
|
|
167
221
|
export interface BuildDetail extends BuildSummary {
|
|
168
|
-
nodePolling?: {
|
|
222
|
+
nodePolling?: {
|
|
223
|
+
mode: 'active' | 'idle'
|
|
224
|
+
intervalSeconds: number
|
|
225
|
+
lastChecked?: string
|
|
226
|
+
}
|
|
169
227
|
runnerAttaches: import('../kernel/read-facts').RunnerAttach[]
|
|
170
228
|
tree?: TreeProjection
|
|
171
229
|
/** Immutable policy provenance and durable command/native application state. */
|
|
@@ -173,18 +231,30 @@ export interface BuildDetail extends BuildSummary {
|
|
|
173
231
|
/** Current work-owner decision. Open PRs use the build-owned config; ended
|
|
174
232
|
* PRs project the repository completion path directly from durable state. */
|
|
175
233
|
decision?: BuildDecisionProjection
|
|
234
|
+
/** Why an open-PR leaf parked at awaiting-pr has no landing decision for its
|
|
235
|
+
* current candidate. */
|
|
236
|
+
landingUndecided?: string
|
|
237
|
+
/** Why an open-PR node's current integration candidate has no landing
|
|
238
|
+
* decision: a recorded deferral for unrecorded changed paths. */
|
|
239
|
+
landingDeferred?: string
|
|
176
240
|
/** The build's effective auto-merge display state (off, requested, enabled,
|
|
177
241
|
* cancelling) — the same projection the dashboards render, so `--json` and
|
|
178
242
|
* the text agree and `waiting: on PR` can say why it is waiting. */
|
|
179
243
|
autoMerge: AutoMergeDisplay
|
|
180
244
|
supersededEscalations?: BuildState['verifyStage']['superseded']
|
|
181
245
|
openEscalations: OpenEscalation[]
|
|
246
|
+
/** A work build's open or latest restack: why it ran (its trigger), the
|
|
247
|
+
* target base it moves onto, and where it stands. */
|
|
248
|
+
restack?: LeafRestackStatus
|
|
182
249
|
/** Per-loop review overrides for the current spec; omitted when none are set. */
|
|
183
250
|
reviewRoundCeilings?: { plan?: number; code?: number }
|
|
184
251
|
/** Frozen forge issue links with effective intent; omitted when none. */
|
|
185
252
|
issueLinks?: BuildState['issueLinks']
|
|
186
253
|
/** Present with `issueLinks`: whether finalize sealed them for the PR. */
|
|
187
254
|
issueLinksSealed?: boolean
|
|
255
|
+
/** The role profile frozen at claim; `configured: false` when the latest
|
|
256
|
+
* session found it removed and used the repository roles. Omitted when none. */
|
|
257
|
+
profile?: { name: string; configured: boolean }
|
|
188
258
|
suspendedSessions: OpenSession[]
|
|
189
259
|
sessionTotals: BuildState['sessions']['totals']
|
|
190
260
|
openSessions: StatusOpenSession[]
|
|
@@ -198,7 +268,9 @@ export interface BuildDetail extends BuildSummary {
|
|
|
198
268
|
/** Latest provider execution and current lifecycle failure. Full history is
|
|
199
269
|
* available with --events. */
|
|
200
270
|
execution?: EventPayload<'execution.started'> & { seq: number }
|
|
201
|
-
infrastructureFailure?: EventPayload<'infrastructure.failed'> & {
|
|
271
|
+
infrastructureFailure?: EventPayload<'infrastructure.failed'> & {
|
|
272
|
+
seq: number
|
|
273
|
+
}
|
|
202
274
|
cleanupPending: boolean
|
|
203
275
|
verify: VerifyProgress
|
|
204
276
|
lastEvent?: { type: string; seq: number; ts: string; actor: Actor }
|
|
@@ -269,6 +341,7 @@ export function summarizeFrom(
|
|
|
269
341
|
const active = state.currentPhase ?? state.lastCompletedPhase
|
|
270
342
|
const round = active?.round
|
|
271
343
|
const attempt = active?.attempt
|
|
344
|
+
const wait = ticketWaitStatus(state)
|
|
272
345
|
return {
|
|
273
346
|
slug: record.slug,
|
|
274
347
|
...buildVocabulary(state),
|
|
@@ -284,7 +357,10 @@ export function summarizeFrom(
|
|
|
284
357
|
: {}),
|
|
285
358
|
...(state.kind === 'node' ? { integrationState: state.integration } : {}),
|
|
286
359
|
...(state.kind === 'node'
|
|
287
|
-
? {
|
|
360
|
+
? {
|
|
361
|
+
nodeRestack: state.nodeRestack,
|
|
362
|
+
handPushedCommits: projectHandPushed(state.nodeRestack),
|
|
363
|
+
}
|
|
288
364
|
: {}),
|
|
289
365
|
// record.ticket is a TicketRef already carrying id/title/url — no artifact
|
|
290
366
|
// read and no ticket-provider call (live ticket state is out of scope).
|
|
@@ -312,6 +388,8 @@ export function summarizeFrom(
|
|
|
312
388
|
lease: leaseInfo(record, now),
|
|
313
389
|
progress: buildProgress(record, state),
|
|
314
390
|
...(slotWait ? { slotWait } : {}),
|
|
391
|
+
...(wait !== undefined ? { wait } : {}),
|
|
392
|
+
...(effectiveStatus(state) === 'waiting' ? { waitOnly: true as const } : {}),
|
|
315
393
|
}
|
|
316
394
|
}
|
|
317
395
|
|
|
@@ -357,6 +435,16 @@ export function detail(
|
|
|
357
435
|
)
|
|
358
436
|
}
|
|
359
437
|
|
|
438
|
+
/** A node's integration candidate whose decision is deferred, from reduced state. */
|
|
439
|
+
function nodeLandingDeferred(state: BuildState): { landingDeferred?: string } {
|
|
440
|
+
const cycle = state.integration?.cycle
|
|
441
|
+
if (state.kind !== 'node' || state.prState !== 'open' || !cycle) return {}
|
|
442
|
+
const candidate = { head: cycle.head, parent: cycle.parent, cycle: cycle.id }
|
|
443
|
+
if (sameLandingCandidate(candidate, state.landing?.decision?.candidate)) return {}
|
|
444
|
+
const reason = landingDeferralReason(state, candidate)
|
|
445
|
+
return reason === undefined ? {} : { landingDeferred: reason }
|
|
446
|
+
}
|
|
447
|
+
|
|
360
448
|
export function detailFromFacts(
|
|
361
449
|
record: BuildRecord,
|
|
362
450
|
facts: Pick<BuildFacts, 'state' | 'open'> &
|
|
@@ -373,7 +461,10 @@ export function detailFromFacts(
|
|
|
373
461
|
if (streams !== undefined) {
|
|
374
462
|
for (const record of streams) {
|
|
375
463
|
if (record.scope.kind !== 'build') continue
|
|
376
|
-
streamStatus.set(record.label, {
|
|
464
|
+
streamStatus.set(record.label, {
|
|
465
|
+
stream: record.id,
|
|
466
|
+
status: record.status,
|
|
467
|
+
})
|
|
377
468
|
}
|
|
378
469
|
}
|
|
379
470
|
const summary = summarizeFrom(record, state, now)
|
|
@@ -402,16 +493,37 @@ export function detailFromFacts(
|
|
|
402
493
|
autoMerge: autoMergeDisplay(state),
|
|
403
494
|
...(state.landing && Object.keys(state.landing).length ? { landing: state.landing } : {}),
|
|
404
495
|
...(decision !== undefined ? { decision } : {}),
|
|
496
|
+
...(decision?.kind === 'awaiting-pr' &&
|
|
497
|
+
state.kind !== 'node' &&
|
|
498
|
+
state.prState === 'open' &&
|
|
499
|
+
facts.log &&
|
|
500
|
+
!sameLandingCandidate(
|
|
501
|
+
leafLandingCandidate(state, facts.log.restack),
|
|
502
|
+
state.landing?.decision?.candidate,
|
|
503
|
+
)
|
|
504
|
+
? {
|
|
505
|
+
landingUndecided: leafLandingUndecidedReason(
|
|
506
|
+
state,
|
|
507
|
+
facts.log.restack,
|
|
508
|
+
decision.pipelineUnreadable,
|
|
509
|
+
),
|
|
510
|
+
}
|
|
511
|
+
: {}),
|
|
512
|
+
...nodeLandingDeferred(state),
|
|
405
513
|
...(state.verifyStage.superseded.length
|
|
406
514
|
? { supersededEscalations: state.verifyStage.superseded }
|
|
407
515
|
: {}),
|
|
408
516
|
openEscalations: state.openEscalations,
|
|
517
|
+
...(state.kind !== 'node' && facts.log && leafRestackStatus(facts.log.restack)
|
|
518
|
+
? { restack: leafRestackStatus(facts.log.restack) }
|
|
519
|
+
: {}),
|
|
409
520
|
...(state.issueLinks.length > 0
|
|
410
521
|
? {
|
|
411
522
|
issueLinks: state.issueLinks,
|
|
412
523
|
issueLinksSealed: state.issueLinksSealedSeq !== undefined,
|
|
413
524
|
}
|
|
414
525
|
: {}),
|
|
526
|
+
...(state.profile !== undefined ? { profile: { ...state.profile } } : {}),
|
|
415
527
|
...(state.reviewRoundCeilings.plan !== undefined || state.reviewRoundCeilings.code !== undefined
|
|
416
528
|
? { reviewRoundCeilings: { ...state.reviewRoundCeilings } }
|
|
417
529
|
: {}),
|
|
@@ -594,12 +706,14 @@ export function renderSummaries(summaries: BuildSummary[], now: Date, emptyNote:
|
|
|
594
706
|
summary.progress.lastEventAt === undefined
|
|
595
707
|
? '—'
|
|
596
708
|
: relativeTime(summary.progress.lastEventAt, now)
|
|
709
|
+
const ticketWait =
|
|
710
|
+
summary.wait?.state === 'waiting' ? `, ${waitingOnText(summary.wait.tickets)}` : ''
|
|
597
711
|
rows.push([
|
|
598
712
|
summary.slug,
|
|
599
|
-
summary
|
|
713
|
+
summaryStatus(summary),
|
|
600
714
|
summary.kind === 'integration'
|
|
601
715
|
? `integration ${summary.integration ?? ''}${summary.slotWait ? `, ${slotWaitText(summary.slotWait)}` : ''}`
|
|
602
|
-
: `${phaseCell(summary)}${summary.slotWait ? `, ${slotWaitText(summary.slotWait)}` : ''}`,
|
|
716
|
+
: `${phaseCell(summary)}${summary.slotWait ? `, ${slotWaitText(summary.slotWait)}` : ''}${ticketWait}`,
|
|
603
717
|
healthWord(summary.lease.health),
|
|
604
718
|
summary.progress.heartbeatAt === undefined
|
|
605
719
|
? '—'
|
|
@@ -612,6 +726,12 @@ export function renderSummaries(summaries: BuildSummary[], now: Date, emptyNote:
|
|
|
612
726
|
return padColumns(rows)
|
|
613
727
|
}
|
|
614
728
|
|
|
729
|
+
/** The status word text renderers print: `waiting` for a build whose only
|
|
730
|
+
* open escalation is its ticket wait, else the reducer status. */
|
|
731
|
+
function summaryStatus(summary: BuildSummary): string {
|
|
732
|
+
return summary.waitOnly ? 'waiting' : summary.status
|
|
733
|
+
}
|
|
734
|
+
|
|
615
735
|
/** Labeled sections, each omitted when absent ("when each is available"). */
|
|
616
736
|
export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
617
737
|
const lines: string[] = [`build ${d.slug}`]
|
|
@@ -637,6 +757,10 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
637
757
|
const sealed = d.issueLinksSealed === true ? ' (sealed)' : ''
|
|
638
758
|
lines.push(` issues: ${safeStatusText(describeIssueLinks(d.issueLinks))}${sealed}`)
|
|
639
759
|
}
|
|
760
|
+
if (d.profile !== undefined)
|
|
761
|
+
lines.push(
|
|
762
|
+
` profile: ${safeStatusText(d.profile.name)}${d.profile.configured ? '' : " (no longer configured — sessions use the repository's roles)"}`,
|
|
763
|
+
)
|
|
640
764
|
if (d.target)
|
|
641
765
|
lines.push(
|
|
642
766
|
` ${d.kind ?? 'work'} · target ${d.target}${d.integration ? ` · ${d.integration}` : ''}`,
|
|
@@ -684,7 +808,7 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
684
808
|
lines.push(` unsafe merge ${proof.sha}: ${proof.missing.join(', ') || proof.build}`)
|
|
685
809
|
}
|
|
686
810
|
}
|
|
687
|
-
lines.push(` status: ${d
|
|
811
|
+
lines.push(` status: ${summaryStatus(d)}${d.outcome !== undefined ? ` (${d.outcome})` : ''}`)
|
|
688
812
|
lines.push(` phase: ${phaseCell(d)}`)
|
|
689
813
|
if (d.reviewRoundCeilings !== undefined) {
|
|
690
814
|
const ceilings = [
|
|
@@ -758,12 +882,36 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
758
882
|
` pr: #${d.pr.number}${d.pr.state !== undefined ? ` (${d.pr.state})` : ''} ${d.pr.url}`,
|
|
759
883
|
)
|
|
760
884
|
}
|
|
885
|
+
if (d.tree !== undefined && (d.landing?.command || d.landing?.decision)) {
|
|
886
|
+
const command = d.landing.command
|
|
887
|
+
const consent =
|
|
888
|
+
command?.kind === 'hold'
|
|
889
|
+
? 'held'
|
|
890
|
+
: command?.kind === 'land'
|
|
891
|
+
? d.tree.consentedHead
|
|
892
|
+
? `consented at ${d.tree.consentedHead}`
|
|
893
|
+
: 'consented (head not recorded)'
|
|
894
|
+
: 'no consent recorded'
|
|
895
|
+
lines.push(` merge: ${consent} · current head ${d.tree.currentHead ?? 'unknown'}`)
|
|
896
|
+
}
|
|
897
|
+
if (d.wait !== undefined)
|
|
898
|
+
lines.push(
|
|
899
|
+
d.wait.state === 'waiting'
|
|
900
|
+
? ` waiting on: ${safeStatusText(ticketWaitText(d.wait, d.slug))}`
|
|
901
|
+
: ` waiting: ${safeStatusText(ticketWaitText(d.wait, d.slug))}`,
|
|
902
|
+
)
|
|
903
|
+
if (d.restack !== undefined)
|
|
904
|
+
lines.push(
|
|
905
|
+
` restack: ${d.restack.trigger} onto ${d.restack.onto.slice(0, 7)} — ${d.restack.state}`,
|
|
906
|
+
)
|
|
761
907
|
if (d.decision?.kind === 'awaiting-pr') {
|
|
762
908
|
// The deferral reason (a durable observation about WHY consent could not
|
|
763
909
|
// be applied) takes precedence; otherwise the auto-merge state itself is
|
|
764
910
|
// what the parked operator needs — off names the missing consent.
|
|
765
911
|
const consent = d.decision.reason ?? `auto merge ${d.autoMerge}`
|
|
766
912
|
lines.push(` waiting: on PR — ${consent}`)
|
|
913
|
+
if (d.landingUndecided !== undefined)
|
|
914
|
+
lines.push(` landing: undecided — ${d.landingUndecided}`)
|
|
767
915
|
} else if (d.decision?.kind === 'repository-completion') {
|
|
768
916
|
lines.push(
|
|
769
917
|
` waiting: repository-level completion after the PR was ${d.decision.prState}; no runner re-attachment is pending`,
|
|
@@ -771,6 +919,7 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
771
919
|
} else if (d.decision?.kind === 'unavailable') {
|
|
772
920
|
lines.push(` decision: unavailable — ${d.decision.diagnostic}`)
|
|
773
921
|
}
|
|
922
|
+
if (d.landingDeferred !== undefined) lines.push(` landing: undecided — ${d.landingDeferred}`)
|
|
774
923
|
|
|
775
924
|
if (d.execution !== undefined) {
|
|
776
925
|
lines.push(
|
|
@@ -1032,6 +1181,23 @@ function decideFromConfig(facts: BuildFacts, config: Config): BuildDecisionProje
|
|
|
1032
1181
|
return { kind: 'awaiting-pr', ...(reason !== undefined ? { reason } : {}) }
|
|
1033
1182
|
}
|
|
1034
1183
|
|
|
1184
|
+
/** Why the dispatcher's read of the latest effective config fails, or
|
|
1185
|
+
* undefined when it succeeds or none is deposited. */
|
|
1186
|
+
async function latestPipelineUnreadable(
|
|
1187
|
+
store: Pick<BuildStore, 'getArtifact'>,
|
|
1188
|
+
slug: string,
|
|
1189
|
+
): Promise<string | undefined> {
|
|
1190
|
+
try {
|
|
1191
|
+
await readEffectivePipeline(store, slug)
|
|
1192
|
+
return undefined
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
1195
|
+
return error instanceof EffectivePipelineUnreadable
|
|
1196
|
+
? `${BUILD_EFFECTIVE_CONFIG_ARTIFACT}@${error.revision}: ${message}`
|
|
1197
|
+
: `${BUILD_EFFECTIVE_CONFIG_ARTIFACT}: ${message}`
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1035
1201
|
/** Load the build-owned configuration for the current work-owner decision.
|
|
1036
1202
|
*
|
|
1037
1203
|
* Source order: the store's deposited `build-runner-effective-config` artifact
|
|
@@ -1046,7 +1212,7 @@ function decideFromConfig(facts: BuildFacts, config: Config): BuildDecisionProje
|
|
|
1046
1212
|
* the operator cannot access. An unavailable decision is a reportable
|
|
1047
1213
|
* degradation, never a reason to guess from the current main branch or to make
|
|
1048
1214
|
* the read-only command fail. */
|
|
1049
|
-
async function projectBuildDecision(
|
|
1215
|
+
export async function projectBuildDecision(
|
|
1050
1216
|
slug: string,
|
|
1051
1217
|
facts: BuildFacts,
|
|
1052
1218
|
store: Pick<BuildStore, 'getArtifact'>,
|
|
@@ -1069,8 +1235,9 @@ async function projectBuildDecision(
|
|
|
1069
1235
|
state.verify.configPin?.artifact.rev,
|
|
1070
1236
|
)
|
|
1071
1237
|
if (artifact !== null) {
|
|
1238
|
+
let decision: BuildDecisionProjection
|
|
1072
1239
|
try {
|
|
1073
|
-
|
|
1240
|
+
decision = decideFromConfig(facts, parseEffectiveBuildConfig(artifact))
|
|
1074
1241
|
} catch (error) {
|
|
1075
1242
|
const message = error instanceof Error ? error.message : String(error)
|
|
1076
1243
|
return {
|
|
@@ -1078,6 +1245,13 @@ async function projectBuildDecision(
|
|
|
1078
1245
|
diagnostic: `the deposited ${BUILD_EFFECTIVE_CONFIG_ARTIFACT} artifact could not be read: ${message}`,
|
|
1079
1246
|
}
|
|
1080
1247
|
}
|
|
1248
|
+
// With a verify pin, the artifact read above is not the dispatcher's first
|
|
1249
|
+
// read: it decides only after the latest effective config parses.
|
|
1250
|
+
if (decision.kind === 'awaiting-pr' && state.kind !== 'node' && state.verify.configPin) {
|
|
1251
|
+
const pipelineUnreadable = await latestPipelineUnreadable(store, slug)
|
|
1252
|
+
if (pipelineUnreadable !== undefined) return { ...decision, pipelineUnreadable }
|
|
1253
|
+
}
|
|
1254
|
+
return decision
|
|
1081
1255
|
}
|
|
1082
1256
|
|
|
1083
1257
|
// Source 2 — the local workspace, exactly as before, only when no artifact
|
|
@@ -3,7 +3,23 @@ import { compatibilityDiagnostic, MixedVersionDeferral } from '../kernel/mixed-v
|
|
|
3
3
|
import { suspendNativeLanding } from '../kernel/landing-publication'
|
|
4
4
|
import { validateNodeChange } from '../kernel/node-restack'
|
|
5
5
|
import { validateRestack, retainReplay } from '../kernel/reconcile-restack'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
readBuildFacts,
|
|
8
|
+
readBuildSelector,
|
|
9
|
+
readTerminalGuard,
|
|
10
|
+
type CurrentBuildFacts,
|
|
11
|
+
} from '../store/reduced-reads'
|
|
12
|
+
import {
|
|
13
|
+
leafLandingBase,
|
|
14
|
+
recordHeadPaths,
|
|
15
|
+
type HeadPathsInput,
|
|
16
|
+
type RecordedHeadPaths,
|
|
17
|
+
} from '../kernel/head-paths'
|
|
18
|
+
import {
|
|
19
|
+
consentRevocation,
|
|
20
|
+
resolutionPathsFor,
|
|
21
|
+
revocableConsent,
|
|
22
|
+
} from '../kernel/consent-revocation'
|
|
7
23
|
import { prIssueLinksForForge } from '../kernel/issue-keywords'
|
|
8
24
|
/**
|
|
9
25
|
* The three terminal commands — `ab done`, `ab verdict`, `ab escalate`
|
|
@@ -26,7 +42,7 @@ import { join } from 'node:path'
|
|
|
26
42
|
import { z } from 'zod'
|
|
27
43
|
import { loadConfig } from '../config/load'
|
|
28
44
|
import { readTerminalGuardBoundary } from '../store/reduced-reads'
|
|
29
|
-
import type
|
|
45
|
+
import { WAIT_TICKET_LIMIT, type EventPayload, type EventType } from '../events/payloads'
|
|
30
46
|
import type { EventWrite } from '../events/catalog'
|
|
31
47
|
import type { ArtifactInput } from '../store/types'
|
|
32
48
|
import type { EventEnvelope } from '../events/catalog'
|
|
@@ -87,6 +103,7 @@ async function terminalDeposit<T extends EventType>(
|
|
|
87
103
|
deps: TerminalDeps,
|
|
88
104
|
artifacts: ArtifactInput[],
|
|
89
105
|
makeEvent: (deposited: ArtifactMeta[]) => EventWrite<T>,
|
|
106
|
+
refuse?: (guard: { waitHeld?: string }) => string | undefined,
|
|
90
107
|
): Promise<{ event: EventEnvelope<T>; artifacts: ArtifactMeta[] }> {
|
|
91
108
|
for (;;) {
|
|
92
109
|
const boundary = await readTerminalGuardBoundary(
|
|
@@ -97,6 +114,8 @@ async function terminalDeposit<T extends EventType>(
|
|
|
97
114
|
deps.env.session,
|
|
98
115
|
)
|
|
99
116
|
if (boundary.value.diagnostic) throw new Error(boundary.value.diagnostic)
|
|
117
|
+
const refusal = refuse?.(boundary.value)
|
|
118
|
+
if (refusal !== undefined) throw new Error(refusal)
|
|
100
119
|
const deposited = await deps.store.appendWithArtifactsIfCurrent(
|
|
101
120
|
deps.env.build,
|
|
102
121
|
boundary.cursor,
|
|
@@ -152,11 +171,11 @@ function singleGitObjectId(output: string, command: string): string {
|
|
|
152
171
|
}
|
|
153
172
|
|
|
154
173
|
/** No `done` on a dirty worktree (D5) — the error lists the offending files. */
|
|
155
|
-
async function assertCleanWorktree(deps: TerminalDeps): Promise<void> {
|
|
174
|
+
async function assertCleanWorktree(deps: TerminalDeps, command = 'ab done'): Promise<void> {
|
|
156
175
|
const status = (await git(deps, ['status', '--porcelain'])).trimEnd()
|
|
157
176
|
if (status !== '') {
|
|
158
177
|
throw new Error(
|
|
159
|
-
`'
|
|
178
|
+
`'${command}' in ${deps.env.phase} requires a clean worktree (D5) — ` +
|
|
160
179
|
`commit or discard these first:\n${status}`,
|
|
161
180
|
)
|
|
162
181
|
}
|
|
@@ -213,6 +232,7 @@ async function implementationReviewBoundary(
|
|
|
213
232
|
)
|
|
214
233
|
const effectiveBase =
|
|
215
234
|
events.state.implement.commits?.base ??
|
|
235
|
+
events.state.implement.contributionBase ??
|
|
216
236
|
(provision?.type === 'workspace.provisioned' ? provision.payload.base.sha : undefined)
|
|
217
237
|
if (!effectiveBase) throw new Error('missing fresh-cut contribution provenance')
|
|
218
238
|
async function ancestor(base: string, tip: string): Promise<boolean> {
|
|
@@ -232,6 +252,32 @@ async function implementationReviewBoundary(
|
|
|
232
252
|
}
|
|
233
253
|
}
|
|
234
254
|
|
|
255
|
+
/** Record a produced candidate head's paths before the write that publishes
|
|
256
|
+
* it, through the same guarded deposit as the terminal itself. */
|
|
257
|
+
async function recordTerminalHeadPaths(
|
|
258
|
+
deps: TerminalDeps,
|
|
259
|
+
events: CurrentBuildFacts,
|
|
260
|
+
input: HeadPathsInput,
|
|
261
|
+
): Promise<RecordedHeadPaths> {
|
|
262
|
+
const recorded = await recordHeadPaths(
|
|
263
|
+
{
|
|
264
|
+
store: deps.store,
|
|
265
|
+
slug: deps.env.build,
|
|
266
|
+
exec: deps.exec,
|
|
267
|
+
workspacePath: deps.workspacePath,
|
|
268
|
+
actor: KERNEL,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
...input,
|
|
272
|
+
state: events.state,
|
|
273
|
+
deposit: (artifacts, makeEvent) => terminalDeposit(deps, artifacts, makeEvent),
|
|
274
|
+
},
|
|
275
|
+
)
|
|
276
|
+
// The terminal deposit retries until it lands; it never misses.
|
|
277
|
+
if (recorded === null) throw new Error('head path deposit missed its guarded boundary')
|
|
278
|
+
return recorded
|
|
279
|
+
}
|
|
280
|
+
|
|
235
281
|
function refOf(meta: ArtifactMeta | undefined): ArtifactRef {
|
|
236
282
|
if (meta === undefined) {
|
|
237
283
|
throw new Error('deposit produced no artifact meta — this is a store bug')
|
|
@@ -471,6 +517,11 @@ export async function done(deps: TerminalDeps, opts: DoneOpts = {}): Promise<Eve
|
|
|
471
517
|
if (remotePublication(events)) {
|
|
472
518
|
await assertCleanWorktree(deps)
|
|
473
519
|
const head = await git(deps, ['rev-parse', '--verify', 'HEAD^{commit}'])
|
|
520
|
+
await recordTerminalHeadPaths(deps, events, {
|
|
521
|
+
source: 'finalize',
|
|
522
|
+
head: head.trim(),
|
|
523
|
+
destination: await leafLandingBase(deps.store, deps.env.build, events.log.restack),
|
|
524
|
+
})
|
|
474
525
|
return await terminalDeposit(deps, [], () => ({
|
|
475
526
|
actor,
|
|
476
527
|
type: 'publication.requested',
|
|
@@ -482,6 +533,17 @@ export async function done(deps: TerminalDeps, opts: DoneOpts = {}): Promise<Eve
|
|
|
482
533
|
},
|
|
483
534
|
})).then(({ event }) => event)
|
|
484
535
|
}
|
|
536
|
+
const published = await readBuildSelector(store, env.build, 'publishedBranchHead')
|
|
537
|
+
if (published === undefined)
|
|
538
|
+
throw new Error(
|
|
539
|
+
'finalize publication requires a prior implement.completed, reconcile.completed, ' +
|
|
540
|
+
'or successful finalize publication head, but this build has none',
|
|
541
|
+
)
|
|
542
|
+
await recordTerminalHeadPaths(deps, events, {
|
|
543
|
+
source: 'finalize',
|
|
544
|
+
head: published,
|
|
545
|
+
destination: await leafLandingBase(deps.store, deps.env.build, events.log.restack),
|
|
546
|
+
})
|
|
485
547
|
return completeFinalizePr(deps, events, {
|
|
486
548
|
branch,
|
|
487
549
|
baseBranch,
|
|
@@ -549,6 +611,35 @@ export async function done(deps: TerminalDeps, opts: DoneOpts = {}): Promise<Eve
|
|
|
549
611
|
await retainReplay(restack, head, transaction.targetBase)
|
|
550
612
|
const conflicted =
|
|
551
613
|
events.reconcileReplay?.id === transaction.id && events.reconcileReplay.conflicted
|
|
614
|
+
const recorded = await recordTerminalHeadPaths(deps, events, {
|
|
615
|
+
source: 'reconcile',
|
|
616
|
+
head,
|
|
617
|
+
destination: transaction.targetBase,
|
|
618
|
+
resolution: [
|
|
619
|
+
{
|
|
620
|
+
change: transaction.changeSha,
|
|
621
|
+
parent: transaction.oldBase,
|
|
622
|
+
onto: transaction.targetBase,
|
|
623
|
+
head,
|
|
624
|
+
},
|
|
625
|
+
],
|
|
626
|
+
})
|
|
627
|
+
// Protected consent lapses when this resolution edited protected files.
|
|
628
|
+
// Once the revocation folds the consent is gone, so a retry adds none.
|
|
629
|
+
const revocation =
|
|
630
|
+
revocableConsent(events.state.landing) &&
|
|
631
|
+
consentRevocation(events.state.landing, {
|
|
632
|
+
source: 'reconcile',
|
|
633
|
+
previousHead: transaction.oldHead,
|
|
634
|
+
head,
|
|
635
|
+
resolution: await resolutionPathsFor(deps.store, env.build, recorded),
|
|
636
|
+
})
|
|
637
|
+
if (revocation)
|
|
638
|
+
await terminalDeposit(deps, [], () => ({
|
|
639
|
+
actor: KERNEL,
|
|
640
|
+
type: 'landing.consent-revoked',
|
|
641
|
+
payload: revocation,
|
|
642
|
+
}))
|
|
552
643
|
const { event: intended } = await terminalDeposit(
|
|
553
644
|
deps,
|
|
554
645
|
[{ kind: 'reconcile-notes', content: notes }],
|
|
@@ -926,3 +1017,105 @@ export async function escalate(
|
|
|
926
1017
|
},
|
|
927
1018
|
})).then(({ event }) => event)
|
|
928
1019
|
}
|
|
1020
|
+
|
|
1021
|
+
// ── ab wait-on (any leaf phase — SPEC §11 "Ticket waits") ────────────────────
|
|
1022
|
+
|
|
1023
|
+
export interface WaitOnOpts {
|
|
1024
|
+
tickets: string[]
|
|
1025
|
+
reason: string
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Declare that this build waits on other tickets. The declaration is this
|
|
1030
|
+
* session's terminal: it appends one `wait.requested` and returns. The
|
|
1031
|
+
* dispatcher, which holds the ticket source, validates the ids and either
|
|
1032
|
+
* enters the wait (the build parks without a slot) or refuses it (this phase
|
|
1033
|
+
* re-runs with the reason as guidance). Only checks that need no ticket
|
|
1034
|
+
* source run here, and every refusal writes nothing.
|
|
1035
|
+
*/
|
|
1036
|
+
export async function waitOn(
|
|
1037
|
+
deps: TerminalDeps,
|
|
1038
|
+
opts: WaitOnOpts,
|
|
1039
|
+
): Promise<EventEnvelope<'wait.requested'>> {
|
|
1040
|
+
const { env, store } = deps
|
|
1041
|
+
const tickets = opts.tickets.map((id) => id.trim())
|
|
1042
|
+
if (tickets.length === 0 || tickets.some((id) => id === ''))
|
|
1043
|
+
throw new Error("'ab wait-on' requires one or more nonblank ticket ids")
|
|
1044
|
+
const duplicate = tickets.find((id, index) => tickets.indexOf(id) !== index)
|
|
1045
|
+
if (duplicate !== undefined)
|
|
1046
|
+
throw new Error(`'ab wait-on' names ticket "${duplicate}" more than once`)
|
|
1047
|
+
if (tickets.length > WAIT_TICKET_LIMIT)
|
|
1048
|
+
throw new Error(`'ab wait-on' accepts at most ${WAIT_TICKET_LIMIT} ticket ids`)
|
|
1049
|
+
const reason = opts.reason.trim()
|
|
1050
|
+
if (reason === '')
|
|
1051
|
+
throw new Error("'ab wait-on' requires --reason <text> — it says why the build must wait")
|
|
1052
|
+
await assertNoPriorTerminal(store, env)
|
|
1053
|
+
const facts = (await readBuildFacts(store, env.build)).value
|
|
1054
|
+
if (facts.state.kind === 'node')
|
|
1055
|
+
throw new Error("'ab wait-on' is for work builds; a node build cannot declare a ticket wait")
|
|
1056
|
+
const own = (await store.getBuild(env.build))?.ticket?.id
|
|
1057
|
+
if (own !== undefined && tickets.includes(own))
|
|
1058
|
+
throw new Error(`ticket "${own}" is this build's own ticket; a build cannot wait on itself`)
|
|
1059
|
+
const id = deps.ids('wait')
|
|
1060
|
+
const publication =
|
|
1061
|
+
env.phase === 'implement' ? await publishBeforeWait(deps, facts, id) : undefined
|
|
1062
|
+
// Checked against the same prefix the append commits to, so concurrent
|
|
1063
|
+
// verifiers cannot both declare: the loser re-reads and is refused.
|
|
1064
|
+
const { event } = await terminalDeposit(
|
|
1065
|
+
deps,
|
|
1066
|
+
[],
|
|
1067
|
+
() => ({
|
|
1068
|
+
actor: agentActor(env.phase, env.session),
|
|
1069
|
+
type: 'wait.requested',
|
|
1070
|
+
payload: {
|
|
1071
|
+
id,
|
|
1072
|
+
phase: env.phase,
|
|
1073
|
+
round: env.round,
|
|
1074
|
+
tickets,
|
|
1075
|
+
reason,
|
|
1076
|
+
...(publication === undefined ? {} : { publication }),
|
|
1077
|
+
},
|
|
1078
|
+
}),
|
|
1079
|
+
(guard) => guard.waitHeld,
|
|
1080
|
+
)
|
|
1081
|
+
return event
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Publish an implement session's commits before its wait is declared, so a
|
|
1086
|
+
* resume restack replays only published work (SPEC §11 "Ticket waits").
|
|
1087
|
+
* Nothing to publish when HEAD is already the published head (or the
|
|
1088
|
+
* contribution base before any). A local workspace pushes before the fact,
|
|
1089
|
+
* like `ab done`: a failed push throws and writes nothing. A remote one
|
|
1090
|
+
* deposits `publication.requested {operation: 'wait'}`; the dispatcher
|
|
1091
|
+
* settles it and enters the wait only after `wait.published`.
|
|
1092
|
+
*/
|
|
1093
|
+
async function publishBeforeWait(
|
|
1094
|
+
deps: TerminalDeps,
|
|
1095
|
+
facts: CurrentBuildFacts,
|
|
1096
|
+
id: string,
|
|
1097
|
+
): Promise<EventPayload<'wait.requested'>['publication']> {
|
|
1098
|
+
const { env, store } = deps
|
|
1099
|
+
await assertCleanWorktree(deps, 'ab wait-on')
|
|
1100
|
+
const { branch, base, head } = await implementationReviewBoundary(deps, facts)
|
|
1101
|
+
const published = await readBuildSelector(store, env.build, 'publishedBranchHead')
|
|
1102
|
+
if (head === (published ?? base)) return undefined
|
|
1103
|
+
const scratchPaths = await scratchPathsTouchedInRange(deps.exec, deps.workspacePath, base, head)
|
|
1104
|
+
if (scratchPaths.length > 0) throw phaseScratchRejection(scratchPaths)
|
|
1105
|
+
if (remotePublication(facts)) {
|
|
1106
|
+
await terminalDeposit(
|
|
1107
|
+
deps,
|
|
1108
|
+
[],
|
|
1109
|
+
() => ({
|
|
1110
|
+
actor: agentActor(env.phase, env.session),
|
|
1111
|
+
type: 'publication.requested',
|
|
1112
|
+
payload: { operation: 'wait', id, branch, sha: head, base },
|
|
1113
|
+
}),
|
|
1114
|
+
(guard) => guard.waitHeld,
|
|
1115
|
+
)
|
|
1116
|
+
return { branch, base, sha: head, settlement: 'requested' }
|
|
1117
|
+
}
|
|
1118
|
+
await suspendNativeLanding({ ...deps, slug: env.build }, `wait:${id}`)
|
|
1119
|
+
await publishExact(deps.forge, deps.workspacePath, branch, head)
|
|
1120
|
+
return { branch, base, sha: head, settlement: 'published' }
|
|
1121
|
+
}
|