@defrex/autobuild 1.7.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 +316 -47
- package/docs/answering-blocked-builds.md +44 -3
- package/docs/architecture.md +62 -7
- package/docs/cli.md +1 -0
- package/docs/configuration-overview.md +1 -1
- package/docs/configuration.md +49 -9
- package/docs/dispatcher.md +1 -1
- 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 +26 -5
- package/docs/operator-surfaces.md +10 -0
- package/docs/plugin-authoring.md +1 -1
- package/docs/remote-store-protocol.md +9 -1
- package/docs/restacking.md +23 -4
- package/docs/ticket-dependencies.md +9 -4
- package/docs/tickets.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.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/help.ts +69 -7
- 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/status.ts +178 -12
- package/packages/core/src/cli/terminals.ts +197 -4
- package/packages/core/src/cli/wait.ts +1 -0
- package/packages/core/src/cli/watch.ts +71 -0
- package/packages/core/src/config/landing.ts +12 -0
- package/packages/core/src/config/path-selectors.ts +68 -0
- package/packages/core/src/config/schema.ts +40 -58
- package/packages/core/src/events/catalog.ts +17 -3
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/head-paths-limits.ts +25 -0
- package/packages/core/src/events/payloads.ts +315 -20
- package/packages/core/src/events/policy.ts +21 -0
- package/packages/core/src/events/repository.ts +30 -1
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +247 -6
- 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/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-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 +28 -1
- package/packages/core/src/kernel/reducer-registry.ts +22 -1
- package/packages/core/src/kernel/reducer.ts +316 -17
- 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 +12 -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 +15 -2
- package/packages/core/src/operator/registry.ts +97 -5
- package/packages/core/src/operator/repository-events.ts +67 -0
- package/packages/core/src/ports/tickets/fake.ts +5 -0
- package/packages/core/src/ports/types.ts +3 -2
- package/packages/core/src/processes/build-execution-state.ts +30 -1
- package/packages/core/src/processes/build-runner.ts +150 -18
- package/packages/core/src/processes/dispatcher.ts +739 -97
- package/packages/core/src/processes/execution-no-progress.ts +22 -2
- 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/store/digest.ts +41 -2
- package/packages/core/src/store/reduced-reads.ts +4 -1
- package/packages/core/src/store/reducer-value-shapes.json +10108 -8432
- package/packages/core/src/store/remote/client.ts +28 -2
- package/packages/core/src/store/remote/protocol.ts +11 -1
- package/packages/core/src/store/remote/released-clients.json +11 -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 +2 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +16 -0
- package/packages/core/src/testing/reduced-read-budget.ts +347 -0
- package/skills/code-review/SKILL.md +8 -0
- package/skills/finalize/SKILL.md +4 -0
- package/skills/guide/SKILL.md +125 -26
- 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 +26 -5
- package/skills/guide/references/plugin-authoring.md +1 -1
- package/skills/guide/references/remote-store-protocol.md +9 -1
- package/skills/guide/references/restacking.md +23 -4
- package/skills/guide/references/ticket-dependencies.md +9 -4
- package/skills/implement/SKILL.md +15 -1
- package/skills/operate/SKILL.md +104 -13
- 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 +5 -4
- 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,12 +231,21 @@ 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. */
|
|
@@ -201,7 +268,9 @@ export interface BuildDetail extends BuildSummary {
|
|
|
201
268
|
/** Latest provider execution and current lifecycle failure. Full history is
|
|
202
269
|
* available with --events. */
|
|
203
270
|
execution?: EventPayload<'execution.started'> & { seq: number }
|
|
204
|
-
infrastructureFailure?: EventPayload<'infrastructure.failed'> & {
|
|
271
|
+
infrastructureFailure?: EventPayload<'infrastructure.failed'> & {
|
|
272
|
+
seq: number
|
|
273
|
+
}
|
|
205
274
|
cleanupPending: boolean
|
|
206
275
|
verify: VerifyProgress
|
|
207
276
|
lastEvent?: { type: string; seq: number; ts: string; actor: Actor }
|
|
@@ -272,6 +341,7 @@ export function summarizeFrom(
|
|
|
272
341
|
const active = state.currentPhase ?? state.lastCompletedPhase
|
|
273
342
|
const round = active?.round
|
|
274
343
|
const attempt = active?.attempt
|
|
344
|
+
const wait = ticketWaitStatus(state)
|
|
275
345
|
return {
|
|
276
346
|
slug: record.slug,
|
|
277
347
|
...buildVocabulary(state),
|
|
@@ -287,7 +357,10 @@ export function summarizeFrom(
|
|
|
287
357
|
: {}),
|
|
288
358
|
...(state.kind === 'node' ? { integrationState: state.integration } : {}),
|
|
289
359
|
...(state.kind === 'node'
|
|
290
|
-
? {
|
|
360
|
+
? {
|
|
361
|
+
nodeRestack: state.nodeRestack,
|
|
362
|
+
handPushedCommits: projectHandPushed(state.nodeRestack),
|
|
363
|
+
}
|
|
291
364
|
: {}),
|
|
292
365
|
// record.ticket is a TicketRef already carrying id/title/url — no artifact
|
|
293
366
|
// read and no ticket-provider call (live ticket state is out of scope).
|
|
@@ -315,6 +388,8 @@ export function summarizeFrom(
|
|
|
315
388
|
lease: leaseInfo(record, now),
|
|
316
389
|
progress: buildProgress(record, state),
|
|
317
390
|
...(slotWait ? { slotWait } : {}),
|
|
391
|
+
...(wait !== undefined ? { wait } : {}),
|
|
392
|
+
...(effectiveStatus(state) === 'waiting' ? { waitOnly: true as const } : {}),
|
|
318
393
|
}
|
|
319
394
|
}
|
|
320
395
|
|
|
@@ -360,6 +435,16 @@ export function detail(
|
|
|
360
435
|
)
|
|
361
436
|
}
|
|
362
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
|
+
|
|
363
448
|
export function detailFromFacts(
|
|
364
449
|
record: BuildRecord,
|
|
365
450
|
facts: Pick<BuildFacts, 'state' | 'open'> &
|
|
@@ -376,7 +461,10 @@ export function detailFromFacts(
|
|
|
376
461
|
if (streams !== undefined) {
|
|
377
462
|
for (const record of streams) {
|
|
378
463
|
if (record.scope.kind !== 'build') continue
|
|
379
|
-
streamStatus.set(record.label, {
|
|
464
|
+
streamStatus.set(record.label, {
|
|
465
|
+
stream: record.id,
|
|
466
|
+
status: record.status,
|
|
467
|
+
})
|
|
380
468
|
}
|
|
381
469
|
}
|
|
382
470
|
const summary = summarizeFrom(record, state, now)
|
|
@@ -405,10 +493,30 @@ export function detailFromFacts(
|
|
|
405
493
|
autoMerge: autoMergeDisplay(state),
|
|
406
494
|
...(state.landing && Object.keys(state.landing).length ? { landing: state.landing } : {}),
|
|
407
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),
|
|
408
513
|
...(state.verifyStage.superseded.length
|
|
409
514
|
? { supersededEscalations: state.verifyStage.superseded }
|
|
410
515
|
: {}),
|
|
411
516
|
openEscalations: state.openEscalations,
|
|
517
|
+
...(state.kind !== 'node' && facts.log && leafRestackStatus(facts.log.restack)
|
|
518
|
+
? { restack: leafRestackStatus(facts.log.restack) }
|
|
519
|
+
: {}),
|
|
412
520
|
...(state.issueLinks.length > 0
|
|
413
521
|
? {
|
|
414
522
|
issueLinks: state.issueLinks,
|
|
@@ -598,12 +706,14 @@ export function renderSummaries(summaries: BuildSummary[], now: Date, emptyNote:
|
|
|
598
706
|
summary.progress.lastEventAt === undefined
|
|
599
707
|
? '—'
|
|
600
708
|
: relativeTime(summary.progress.lastEventAt, now)
|
|
709
|
+
const ticketWait =
|
|
710
|
+
summary.wait?.state === 'waiting' ? `, ${waitingOnText(summary.wait.tickets)}` : ''
|
|
601
711
|
rows.push([
|
|
602
712
|
summary.slug,
|
|
603
|
-
summary
|
|
713
|
+
summaryStatus(summary),
|
|
604
714
|
summary.kind === 'integration'
|
|
605
715
|
? `integration ${summary.integration ?? ''}${summary.slotWait ? `, ${slotWaitText(summary.slotWait)}` : ''}`
|
|
606
|
-
: `${phaseCell(summary)}${summary.slotWait ? `, ${slotWaitText(summary.slotWait)}` : ''}`,
|
|
716
|
+
: `${phaseCell(summary)}${summary.slotWait ? `, ${slotWaitText(summary.slotWait)}` : ''}${ticketWait}`,
|
|
607
717
|
healthWord(summary.lease.health),
|
|
608
718
|
summary.progress.heartbeatAt === undefined
|
|
609
719
|
? '—'
|
|
@@ -616,6 +726,12 @@ export function renderSummaries(summaries: BuildSummary[], now: Date, emptyNote:
|
|
|
616
726
|
return padColumns(rows)
|
|
617
727
|
}
|
|
618
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
|
+
|
|
619
735
|
/** Labeled sections, each omitted when absent ("when each is available"). */
|
|
620
736
|
export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
621
737
|
const lines: string[] = [`build ${d.slug}`]
|
|
@@ -692,7 +808,7 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
692
808
|
lines.push(` unsafe merge ${proof.sha}: ${proof.missing.join(', ') || proof.build}`)
|
|
693
809
|
}
|
|
694
810
|
}
|
|
695
|
-
lines.push(` status: ${d
|
|
811
|
+
lines.push(` status: ${summaryStatus(d)}${d.outcome !== undefined ? ` (${d.outcome})` : ''}`)
|
|
696
812
|
lines.push(` phase: ${phaseCell(d)}`)
|
|
697
813
|
if (d.reviewRoundCeilings !== undefined) {
|
|
698
814
|
const ceilings = [
|
|
@@ -766,12 +882,36 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
766
882
|
` pr: #${d.pr.number}${d.pr.state !== undefined ? ` (${d.pr.state})` : ''} ${d.pr.url}`,
|
|
767
883
|
)
|
|
768
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
|
+
)
|
|
769
907
|
if (d.decision?.kind === 'awaiting-pr') {
|
|
770
908
|
// The deferral reason (a durable observation about WHY consent could not
|
|
771
909
|
// be applied) takes precedence; otherwise the auto-merge state itself is
|
|
772
910
|
// what the parked operator needs — off names the missing consent.
|
|
773
911
|
const consent = d.decision.reason ?? `auto merge ${d.autoMerge}`
|
|
774
912
|
lines.push(` waiting: on PR — ${consent}`)
|
|
913
|
+
if (d.landingUndecided !== undefined)
|
|
914
|
+
lines.push(` landing: undecided — ${d.landingUndecided}`)
|
|
775
915
|
} else if (d.decision?.kind === 'repository-completion') {
|
|
776
916
|
lines.push(
|
|
777
917
|
` waiting: repository-level completion after the PR was ${d.decision.prState}; no runner re-attachment is pending`,
|
|
@@ -779,6 +919,7 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
779
919
|
} else if (d.decision?.kind === 'unavailable') {
|
|
780
920
|
lines.push(` decision: unavailable — ${d.decision.diagnostic}`)
|
|
781
921
|
}
|
|
922
|
+
if (d.landingDeferred !== undefined) lines.push(` landing: undecided — ${d.landingDeferred}`)
|
|
782
923
|
|
|
783
924
|
if (d.execution !== undefined) {
|
|
784
925
|
lines.push(
|
|
@@ -1040,6 +1181,23 @@ function decideFromConfig(facts: BuildFacts, config: Config): BuildDecisionProje
|
|
|
1040
1181
|
return { kind: 'awaiting-pr', ...(reason !== undefined ? { reason } : {}) }
|
|
1041
1182
|
}
|
|
1042
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
|
+
|
|
1043
1201
|
/** Load the build-owned configuration for the current work-owner decision.
|
|
1044
1202
|
*
|
|
1045
1203
|
* Source order: the store's deposited `build-runner-effective-config` artifact
|
|
@@ -1054,7 +1212,7 @@ function decideFromConfig(facts: BuildFacts, config: Config): BuildDecisionProje
|
|
|
1054
1212
|
* the operator cannot access. An unavailable decision is a reportable
|
|
1055
1213
|
* degradation, never a reason to guess from the current main branch or to make
|
|
1056
1214
|
* the read-only command fail. */
|
|
1057
|
-
async function projectBuildDecision(
|
|
1215
|
+
export async function projectBuildDecision(
|
|
1058
1216
|
slug: string,
|
|
1059
1217
|
facts: BuildFacts,
|
|
1060
1218
|
store: Pick<BuildStore, 'getArtifact'>,
|
|
@@ -1077,8 +1235,9 @@ async function projectBuildDecision(
|
|
|
1077
1235
|
state.verify.configPin?.artifact.rev,
|
|
1078
1236
|
)
|
|
1079
1237
|
if (artifact !== null) {
|
|
1238
|
+
let decision: BuildDecisionProjection
|
|
1080
1239
|
try {
|
|
1081
|
-
|
|
1240
|
+
decision = decideFromConfig(facts, parseEffectiveBuildConfig(artifact))
|
|
1082
1241
|
} catch (error) {
|
|
1083
1242
|
const message = error instanceof Error ? error.message : String(error)
|
|
1084
1243
|
return {
|
|
@@ -1086,6 +1245,13 @@ async function projectBuildDecision(
|
|
|
1086
1245
|
diagnostic: `the deposited ${BUILD_EFFECTIVE_CONFIG_ARTIFACT} artifact could not be read: ${message}`,
|
|
1087
1246
|
}
|
|
1088
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
|
|
1089
1255
|
}
|
|
1090
1256
|
|
|
1091
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
|
+
}
|
|
@@ -518,6 +518,7 @@ export async function abWait(opts: AbWaitOpts): Promise<number> {
|
|
|
518
518
|
event.type === 'integration.landed' ||
|
|
519
519
|
event.type === 'integration.verification-failed' ||
|
|
520
520
|
event.type === 'node.item-conflicted' ||
|
|
521
|
+
event.type === 'landing.consent-revoked' ||
|
|
521
522
|
(event.type === 'restack.replayed' && event.payload.conflicted)
|
|
522
523
|
)
|
|
523
524
|
return conditions
|