@defrex/autobuild 1.11.1 → 1.12.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 +177 -54
- package/docs/answering-blocked-builds.md +10 -2
- package/docs/architecture.md +66 -6
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +13 -11
- package/docs/dispatcher.md +1 -1
- package/docs/integration-tree.md +28 -16
- package/docs/operator-api.md +4 -4
- package/docs/operator-surfaces.md +35 -0
- package/docs/optimization-nodes.md +3 -2
- package/docs/tickets.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/ambient-errors.ts +17 -0
- package/packages/core/src/cli/bounded-io.ts +174 -0
- package/packages/core/src/cli/dashboard/model.ts +81 -23
- package/packages/core/src/cli/dashboard/poll.ts +20 -31
- package/packages/core/src/cli/dashboard/render.ts +14 -37
- package/packages/core/src/cli/dashboard/row-text.ts +24 -7
- package/packages/core/src/cli/dashboard/tone-ansi.ts +39 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +161 -20
- package/packages/core/src/cli/dispatch-handoff.ts +41 -10
- package/packages/core/src/cli/dispatch-launch-contract.ts +5 -0
- package/packages/core/src/cli/dispatch-launcher-cadence.ts +80 -0
- package/packages/core/src/cli/dispatch-launcher.ts +9 -10
- package/packages/core/src/cli/dispatch-preflight.ts +12 -3
- package/packages/core/src/cli/dispatch-release-observer.ts +53 -0
- package/packages/core/src/cli/dispatch-runtime-cache.ts +204 -82
- package/packages/core/src/cli/dispatch-runtime-dependencies.ts +250 -43
- package/packages/core/src/cli/dispatch-upgrade-install.ts +36 -16
- package/packages/core/src/cli/dispatch-upgrade-source.ts +8 -2
- package/packages/core/src/cli/dispatch-yield-observer.ts +82 -0
- package/packages/core/src/cli/dispatch.ts +68 -5
- package/packages/core/src/cli/env.ts +2 -15
- package/packages/core/src/cli/help.ts +5 -4
- package/packages/core/src/cli/main.ts +4 -2
- package/packages/core/src/cli/production-store.ts +102 -0
- package/packages/core/src/cli/repo-state.ts +2 -3
- package/packages/core/src/cli/repository-status.ts +28 -22
- package/packages/core/src/cli/sessionless-store.ts +26 -0
- package/packages/core/src/cli/status.ts +169 -40
- package/packages/core/src/cli/store-opening.ts +15 -58
- package/packages/core/src/cli/store-ref.ts +6 -1
- package/packages/core/src/config/schema.ts +1 -1
- package/packages/core/src/distribution-packaging.ts +156 -18
- package/packages/core/src/events/catalog-identity.ts +28 -0
- package/packages/core/src/events/catalog.ts +3 -9
- package/packages/core/src/events/compatibility.ts +2 -30
- package/packages/core/src/events/payloads.ts +11 -0
- package/packages/core/src/events/policy.ts +3 -0
- package/packages/core/src/events/repository.ts +1 -1
- package/packages/core/src/events/sessions.ts +1 -1
- package/packages/core/src/events/validation-error.ts +12 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +9 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3064e337cc75f8d6.json +310 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a1e90a969d32a367.json +307 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/da3bc91c49211eab.json +310 -0
- package/packages/core/src/kernel/auto-merge-default.ts +2 -1
- package/packages/core/src/kernel/capacity-build.ts +21 -0
- package/packages/core/src/kernel/discard-in-flight.ts +13 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +354 -147
- package/packages/core/src/kernel/engine.ts +2 -8
- package/packages/core/src/kernel/measurement.ts +24 -0
- package/packages/core/src/kernel/read-facts.ts +8 -370
- package/packages/core/src/kernel/reducer-registry.ts +40 -125
- package/packages/core/src/kernel/reducer-revisions.ts +3 -0
- package/packages/core/src/kernel/reducer-value-entry.ts +98 -0
- package/packages/core/src/kernel/reducer-value-index.ts +75 -0
- package/packages/core/src/kernel/reducer.ts +57 -9
- package/packages/core/src/kernel/reopen-state.ts +10 -0
- package/packages/core/src/kernel/repository-read-facts.ts +375 -0
- package/packages/core/src/kernel/verify-stage-state.ts +145 -3
- package/packages/core/src/operator/presentation.ts +13 -0
- package/packages/core/src/operator/query.ts +40 -39
- package/packages/core/src/operator/registry.ts +3 -3
- package/packages/core/src/ports/workspace/fake.ts +15 -3
- package/packages/core/src/processes/dispatcher.ts +232 -75
- package/packages/core/src/processes/execution-no-progress.ts +1 -0
- package/packages/core/src/store/local/capabilities.ts +115 -0
- package/packages/core/src/store/local/store.ts +86 -56
- package/packages/core/src/store/reduced-reads.ts +9 -1
- package/packages/core/src/store/reducer-value-read.ts +235 -0
- package/packages/core/src/store/reducer-value-shapes.json +1437 -1349
- package/packages/core/src/store/reducer-values.ts +36 -204
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.12.0.json +35806 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
- package/packages/core/src/store/rollup-lease.ts +41 -0
- package/packages/core/src/store/rollups.ts +7 -38
- package/packages/core/src/store/snapshots.ts +1 -1
- package/packages/core/src/testing/dispatch-read-budget.ts +265 -4
- package/packages/core/src/testing/import-graph.ts +78 -0
- package/packages/core/src/testing/reduced-read-budget.ts +221 -22
- package/packages/core/src/testing/slot-agreement.ts +52 -0
- package/packages/core/src/web/assets/app.js +5 -5
- package/skills/guide/SKILL.md +115 -44
- package/skills/guide/references/integration-tree.md +28 -16
- package/skills/guide/references/operator-api.md +4 -4
- package/skills/guide/references/optimization-nodes.md +3 -2
- package/skills/operate/SKILL.md +38 -20
- package/templates/hosted-service/package.json +2 -2
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
type CapacityBuild,
|
|
7
7
|
} from '../../kernel/dispatch-capacity'
|
|
8
8
|
import type { DispatchStatus } from '../../kernel/dispatch-status'
|
|
9
|
-
import { migrationIdentity } from '../../kernel/ticket-migrations'
|
|
10
9
|
import {
|
|
11
10
|
openBuildWorkspaceReducer,
|
|
12
11
|
provisionMarkerReducer,
|
|
@@ -17,6 +16,7 @@ import type { PipelineSourceMeta } from '../../config/pipeline-source'
|
|
|
17
16
|
import type { AbEvent } from '../../events/catalog'
|
|
18
17
|
import { buildReducer, type BuildAcc, type BuildState } from '../../kernel/reducer'
|
|
19
18
|
import { landingRestackDue } from '../../kernel/engine'
|
|
19
|
+
import { capacityBuildFromFacts } from '../../kernel/capacity-build'
|
|
20
20
|
import { leafRestackReducer, type LeafRestackState } from '../../kernel/leaf-restack-state'
|
|
21
21
|
import {
|
|
22
22
|
BUILD_EFFECTIVE_CONFIG_ARTIFACT,
|
|
@@ -30,11 +30,7 @@ import type {
|
|
|
30
30
|
StreamRecord,
|
|
31
31
|
StreamScope,
|
|
32
32
|
} from '../../store/types'
|
|
33
|
-
import {
|
|
34
|
-
readBuildFacts,
|
|
35
|
-
type CurrentBuildFacts,
|
|
36
|
-
type RepositoryReadFacts,
|
|
37
|
-
} from '../../store/reduced-reads'
|
|
33
|
+
import { readBuildFacts, type RepositoryReadFacts } from '../../store/reduced-reads'
|
|
38
34
|
import { dispatchWarningLines, repositoryQueueDepth } from './header'
|
|
39
35
|
import {
|
|
40
36
|
projectBuild,
|
|
@@ -98,6 +94,7 @@ interface ReducedEntry {
|
|
|
98
94
|
state: BuildState
|
|
99
95
|
workspace: boolean
|
|
100
96
|
provisioning: boolean
|
|
97
|
+
provisioningSeq?: number
|
|
101
98
|
restackDue: boolean
|
|
102
99
|
build: DashboardBuild | null
|
|
103
100
|
}
|
|
@@ -111,18 +108,10 @@ export function isDashboardTerminal(state: BuildState): boolean {
|
|
|
111
108
|
return state.status === 'done'
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
): Required<CapacityBuild> {
|
|
119
|
-
return {
|
|
120
|
-
record,
|
|
121
|
-
state: value.state,
|
|
122
|
-
workspace: value.workspace !== null,
|
|
123
|
-
provisioning: value.provisionMarker !== undefined,
|
|
124
|
-
restackDue: landingRestackDue(value.state, value.log),
|
|
125
|
-
}
|
|
111
|
+
export { capacityBuildFromFacts }
|
|
112
|
+
|
|
113
|
+
function provisioningSeqOf(seq: number | undefined): Pick<CapacityBuild, 'provisioningSeq'> {
|
|
114
|
+
return seq === undefined ? {} : { provisioningSeq: seq }
|
|
126
115
|
}
|
|
127
116
|
|
|
128
117
|
/** The display-only reads that decorate one row: authoritative stream
|
|
@@ -243,20 +232,14 @@ export function repositoryDashboardHeader(input: {
|
|
|
243
232
|
(state) => state.kind !== 'node' && state.status !== 'done' && state.status !== 'aborted',
|
|
244
233
|
).length,
|
|
245
234
|
capacity: config.capacity,
|
|
246
|
-
capacityProjection: dispatchCapacity(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
{
|
|
252
|
-
urgentClaims: urgentClaimDemand(repositoryFacts),
|
|
253
|
-
openPrs: {
|
|
254
|
-
policy: config.policy,
|
|
255
|
-
engaged: repositoryFacts.openPrBackpressure !== undefined,
|
|
256
|
-
},
|
|
257
|
-
startRequests: startClaimDemand(repositoryFacts),
|
|
235
|
+
capacityProjection: dispatchCapacity(input.capacityBuilds, config.capacity, input.now, {
|
|
236
|
+
urgentClaims: urgentClaimDemand(repositoryFacts),
|
|
237
|
+
openPrs: {
|
|
238
|
+
policy: config.policy,
|
|
239
|
+
engaged: repositoryFacts.openPrBackpressure !== undefined,
|
|
258
240
|
},
|
|
259
|
-
|
|
241
|
+
startRequests: startClaimDemand(repositoryFacts),
|
|
242
|
+
}),
|
|
260
243
|
...(input.triage !== undefined ? { triage: input.triage } : {}),
|
|
261
244
|
...(status.availableUpgrade !== undefined ? { availableUpgrade: status.availableUpgrade } : {}),
|
|
262
245
|
...(warningLines.length > 0 ? { warningLines } : {}),
|
|
@@ -375,6 +358,9 @@ export class DashboardBuildPollCache {
|
|
|
375
358
|
state: value.state,
|
|
376
359
|
workspace: capacity.workspace,
|
|
377
360
|
provisioning: capacity.provisioning,
|
|
361
|
+
...(capacity.provisioningSeq !== undefined
|
|
362
|
+
? { provisioningSeq: capacity.provisioningSeq }
|
|
363
|
+
: {}),
|
|
378
364
|
restackDue: capacity.restackDue,
|
|
379
365
|
build:
|
|
380
366
|
current?.kind === 'reduced' &&
|
|
@@ -460,6 +446,9 @@ export class DashboardBuildPollCache {
|
|
|
460
446
|
workspace: entry.kind === 'reduced' ? entry.workspace : entry.workspace.open !== null,
|
|
461
447
|
provisioning:
|
|
462
448
|
entry.kind === 'reduced' ? entry.provisioning : entry.provisionMarker.marker !== null,
|
|
449
|
+
...provisioningSeqOf(
|
|
450
|
+
entry.kind === 'reduced' ? entry.provisioningSeq : entry.provisionMarker.marker?.seq,
|
|
451
|
+
),
|
|
463
452
|
restackDue:
|
|
464
453
|
entry.kind === 'reduced'
|
|
465
454
|
? entry.restackDue
|
|
@@ -45,6 +45,7 @@ import { displayText, layoutComposer, packAtomic, wrapDisplay } from './composer
|
|
|
45
45
|
import { cellWidth, graphemes, padEndCells } from './cells'
|
|
46
46
|
import {
|
|
47
47
|
HARVEST_TITLE,
|
|
48
|
+
buildRowStatus,
|
|
48
49
|
projectHarvestRowText,
|
|
49
50
|
projectHeaderText,
|
|
50
51
|
projectProgress,
|
|
@@ -52,14 +53,8 @@ import {
|
|
|
52
53
|
reviewRoundCeilingText,
|
|
53
54
|
type RowAttention,
|
|
54
55
|
} from './row-text'
|
|
55
|
-
import {
|
|
56
|
-
|
|
57
|
-
statusText,
|
|
58
|
-
stepLine,
|
|
59
|
-
stepTone,
|
|
60
|
-
viewerLabel,
|
|
61
|
-
type DashboardTone,
|
|
62
|
-
} from './vocabulary'
|
|
56
|
+
import { RESET, TONE_COLOR, paint, type ColorName } from './tone-ansi'
|
|
57
|
+
import { PROGRESS_VERIFIED, harvestStatusText, stepLine, stepTone, viewerLabel } from './vocabulary'
|
|
63
58
|
|
|
64
59
|
export { formatDuration } from './vocabulary'
|
|
65
60
|
|
|
@@ -107,34 +102,9 @@ export type DashboardRendererResolver = () => DashboardRenderer
|
|
|
107
102
|
|
|
108
103
|
// ── ANSI ─────────────────────────────────────────────────────────────────────
|
|
109
104
|
|
|
110
|
-
const ESC = '\x1b['
|
|
111
|
-
const RESET = `${ESC}0m`
|
|
112
105
|
/** Closes an OSC 8 hyperlink. `RESET` does NOT: it is an SGR reset, and the
|
|
113
106
|
* two families are independent — only this ends the link. */
|
|
114
107
|
const LINK_OFF = '\x1b]8;;\x07'
|
|
115
|
-
const CODES = {
|
|
116
|
-
dim: 2,
|
|
117
|
-
red: 31,
|
|
118
|
-
green: 32,
|
|
119
|
-
yellow: 33,
|
|
120
|
-
blue: 34,
|
|
121
|
-
cyan: 36,
|
|
122
|
-
bold: 1,
|
|
123
|
-
} as const
|
|
124
|
-
type ColorName = keyof typeof CODES
|
|
125
|
-
|
|
126
|
-
/** The terminal's colour for each shared tone. */
|
|
127
|
-
const TONE_COLOR: Record<DashboardTone, ColorName> = {
|
|
128
|
-
ok: 'green',
|
|
129
|
-
live: 'cyan',
|
|
130
|
-
held: 'yellow',
|
|
131
|
-
alert: 'red',
|
|
132
|
-
pending: 'dim',
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function paint(text: string, color: ColorName, on: boolean): string {
|
|
136
|
-
return on ? `${ESC}${CODES[color]}m${text}${RESET}` : text
|
|
137
|
-
}
|
|
138
108
|
|
|
139
109
|
/** OSC 8: the escape common terminals turn into a real hyperlink. In plain
|
|
140
110
|
* mode we emit the bare URL, which those same terminals linkify on sight —
|
|
@@ -356,7 +326,12 @@ function renderBuild(
|
|
|
356
326
|
if (text.pr !== undefined) rightTokens.push(link(text.pr.url, text.pr.text, color))
|
|
357
327
|
for (const flag of text.flags)
|
|
358
328
|
rightTokens.push(paint(`(${flag.term})`, TONE_COLOR[flag.tone], color))
|
|
359
|
-
|
|
329
|
+
// The status note (`(merge decision)`) hugs the word it explains; the
|
|
330
|
+
// padding goes ahead of both so the word still ends at the right edge.
|
|
331
|
+
const statusPad = ' '.repeat(Math.max(0, widths.status - cellWidth(text.status.word)))
|
|
332
|
+
const statusNote =
|
|
333
|
+
text.status.note !== undefined ? `${paint(`(${text.status.note})`, 'dim', color)} ` : ''
|
|
334
|
+
rightTokens.push(`${statusPad}${statusNote}${paint(text.status.word, statusColor, color)}`)
|
|
360
335
|
const rightStr = rightTokens.join(' ')
|
|
361
336
|
|
|
362
337
|
// The slug is the sole flexible segment; narrow frames truncate it before
|
|
@@ -497,8 +472,8 @@ function frameWidths(builds: DashboardBuild[], harvest: DashboardHarvest | undef
|
|
|
497
472
|
),
|
|
498
473
|
status: Math.max(
|
|
499
474
|
0,
|
|
500
|
-
...builds.map((b) => cellWidth(
|
|
501
|
-
...(harvest !== undefined ? [cellWidth(
|
|
475
|
+
...builds.map((b) => cellWidth(buildRowStatus(b).word)),
|
|
476
|
+
...(harvest !== undefined ? [cellWidth(harvestStatusText(harvest.status).word)] : []),
|
|
502
477
|
),
|
|
503
478
|
}
|
|
504
479
|
}
|
|
@@ -1001,11 +976,13 @@ function renderDetail(model: DashboardModel, opts: RenderOpts): string[] {
|
|
|
1001
976
|
const { color, width, height } = opts
|
|
1002
977
|
const draining = build.draining ? ` ${paint('(draining)', 'yellow', color)}` : ''
|
|
1003
978
|
const paused = build.alsoPaused ? ' (also paused)' : ''
|
|
979
|
+
const status = buildRowStatus(build)
|
|
980
|
+
const statusNote = status.note !== undefined ? ` (${status.note})` : ''
|
|
1004
981
|
const notice = upgradeNoticeLine(model, color, width)
|
|
1005
982
|
const top = [
|
|
1006
983
|
truncate(`${paint('Build', 'bold', color)} ${displayText(build.slug)}`, width),
|
|
1007
984
|
truncate(
|
|
1008
|
-
` status ${paint(
|
|
985
|
+
` status ${paint(`${status.word}${statusNote}`, TONE_COLOR[status.tone], color)}${paused}${draining}`,
|
|
1009
986
|
width,
|
|
1010
987
|
),
|
|
1011
988
|
...standbyLine(model, color, width),
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Layout (padding, truncation, wrapping, separators) stays with each frontend.
|
|
13
13
|
*/
|
|
14
|
-
import { capacityExplanation } from '../../kernel/dispatch-capacity'
|
|
14
|
+
import { capacityExplanation, type SlotState } from '../../kernel/dispatch-capacity'
|
|
15
15
|
import type { BuildRosterFinished } from '../../kernel/build-roster'
|
|
16
16
|
import type { DispatchHealth } from '../../kernel/dispatch-status'
|
|
17
17
|
import { NO_DISPATCHER_RUN_LINE, activeCounterText } from './configuration'
|
|
@@ -24,8 +24,9 @@ import { treeVocabulary } from './tree'
|
|
|
24
24
|
import {
|
|
25
25
|
dispatchedByText,
|
|
26
26
|
dispatcherModeWord,
|
|
27
|
+
buildStatusText,
|
|
27
28
|
finishedOutcomeText,
|
|
28
|
-
|
|
29
|
+
harvestStatusText,
|
|
29
30
|
stepMark,
|
|
30
31
|
stepTone,
|
|
31
32
|
type DashboardTone,
|
|
@@ -67,6 +68,9 @@ export interface DashboardRowText {
|
|
|
67
68
|
ticketUrl?: string
|
|
68
69
|
kind: 'work' | 'integration'
|
|
69
70
|
status: StatusText
|
|
71
|
+
/** The build's slot state, passed through from the projection; absent is
|
|
72
|
+
* unknown, never `none`. */
|
|
73
|
+
slot?: SlotState
|
|
70
74
|
/** The label of the step currently running. */
|
|
71
75
|
phase?: string
|
|
72
76
|
/** Ordered parenthesised annotations beside the status. */
|
|
@@ -231,6 +235,17 @@ function treeLines(build: DashboardBuild): string[] | undefined {
|
|
|
231
235
|
]
|
|
232
236
|
}
|
|
233
237
|
|
|
238
|
+
/** A build row's status word, tone and note (SPEC §14 "Status words"). */
|
|
239
|
+
export function buildRowStatus(
|
|
240
|
+
build: Pick<DashboardBuild, 'status' | 'slot' | 'statusBasis'>,
|
|
241
|
+
): StatusText {
|
|
242
|
+
return buildStatusText({
|
|
243
|
+
status: build.status,
|
|
244
|
+
...(build.slot !== undefined ? { slot: build.slot } : {}),
|
|
245
|
+
...(build.statusBasis !== undefined ? { basis: build.statusBasis } : {}),
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
|
|
234
249
|
/**
|
|
235
250
|
* Everything one build row says. Integration rows (an `integrationRow` is
|
|
236
251
|
* present) show their own steps, progress and alert, and hide the tree,
|
|
@@ -240,13 +255,14 @@ export function projectRowText(
|
|
|
240
255
|
build: DashboardBuild,
|
|
241
256
|
options: { repositoryPaused: boolean },
|
|
242
257
|
): DashboardRowText {
|
|
243
|
-
const status =
|
|
258
|
+
const status = buildRowStatus(build)
|
|
244
259
|
const row = build.integrationRow
|
|
245
260
|
const steps = (row?.steps ?? build.steps).map(stepText)
|
|
246
261
|
const phase = steps.find((step) => step.state === 'current')?.label
|
|
247
262
|
const flags: DashboardRowText['flags'] = [
|
|
248
|
-
// A repository hold changes no build lifecycle state:
|
|
249
|
-
// and only the rows the hold prevents from
|
|
263
|
+
// A repository hold changes no build lifecycle state: a newly claimed
|
|
264
|
+
// build still reads STARTING, and only the rows the hold prevents from
|
|
265
|
+
// launching are annotated.
|
|
250
266
|
...(options.repositoryPaused && build.status === 'queued'
|
|
251
267
|
? [{ term: 'held' as const, tone: 'held' as const }]
|
|
252
268
|
: []),
|
|
@@ -315,6 +331,7 @@ export function projectRowText(
|
|
|
315
331
|
: {}),
|
|
316
332
|
kind: build.kind === 'integration' ? 'integration' : 'work',
|
|
317
333
|
status,
|
|
334
|
+
...(build.slot !== undefined ? { slot: build.slot } : {}),
|
|
318
335
|
...(phase !== undefined ? { phase } : {}),
|
|
319
336
|
flags,
|
|
320
337
|
...(build.kind !== 'integration'
|
|
@@ -338,7 +355,7 @@ export function projectRowText(
|
|
|
338
355
|
}
|
|
339
356
|
|
|
340
357
|
export function projectHarvestRowText(harvest: DashboardHarvest): HarvestRowText {
|
|
341
|
-
const status =
|
|
358
|
+
const status = harvestStatusText(harvest.status)
|
|
342
359
|
return {
|
|
343
360
|
title: HARVEST_TITLE,
|
|
344
361
|
status,
|
|
@@ -451,7 +468,7 @@ export function projectAttention(
|
|
|
451
468
|
): AttentionItem[] {
|
|
452
469
|
const items: AttentionItem[] = []
|
|
453
470
|
if (harvest !== undefined && (harvest.status === 'escalated' || harvest.status === 'failed')) {
|
|
454
|
-
const status =
|
|
471
|
+
const status = harvestStatusText(harvest.status)
|
|
455
472
|
items.push({
|
|
456
473
|
kind: 'harvest',
|
|
457
474
|
tone: status.tone,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The terminal's ANSI colour for each shared tone. The dashboard renderer and
|
|
3
|
+
* the plain `ab builds` / `ab build status` text paint a tone through the same
|
|
4
|
+
* table, so a status word has one colour on every terminal surface.
|
|
5
|
+
*
|
|
6
|
+
* Pure: no IO and no `process`. Whether to paint is the caller's decision.
|
|
7
|
+
*/
|
|
8
|
+
import type { DashboardTone } from './vocabulary'
|
|
9
|
+
|
|
10
|
+
export const ESC = '\x1b['
|
|
11
|
+
export const RESET = `${ESC}0m`
|
|
12
|
+
|
|
13
|
+
export const CODES = {
|
|
14
|
+
dim: 2,
|
|
15
|
+
red: 31,
|
|
16
|
+
green: 32,
|
|
17
|
+
yellow: 33,
|
|
18
|
+
blue: 34,
|
|
19
|
+
cyan: 36,
|
|
20
|
+
bold: 1,
|
|
21
|
+
} as const
|
|
22
|
+
export type ColorName = keyof typeof CODES
|
|
23
|
+
|
|
24
|
+
/** The terminal's colour for each shared tone. */
|
|
25
|
+
export const TONE_COLOR: Record<DashboardTone, ColorName> = {
|
|
26
|
+
ok: 'green',
|
|
27
|
+
live: 'cyan',
|
|
28
|
+
held: 'yellow',
|
|
29
|
+
alert: 'red',
|
|
30
|
+
pending: 'dim',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function paint(text: string, color: ColorName, on: boolean): string {
|
|
34
|
+
return on ? `${ESC}${CODES[color]}m${text}${RESET}` : text
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function paintTone(text: string, tone: DashboardTone, on: boolean): string {
|
|
38
|
+
return paint(text, TONE_COLOR[tone], on)
|
|
39
|
+
}
|
|
@@ -12,43 +12,184 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Tones are presentation-neutral names. The terminal maps them to ANSI colours
|
|
14
14
|
* and the web maps them to `packages/ui` state tones, whose names are the same.
|
|
15
|
+
*
|
|
16
|
+
* Build status words come from one closed word→tone table
|
|
17
|
+
* (`BUILD_STATUS_TONE`, SPEC §14 "Status words"), chosen by
|
|
18
|
+
* `buildStatusText` from the row's slot state and a small `StatusBasis` of
|
|
19
|
+
* lifecycle facts. No frontend keeps its own word or tone map.
|
|
15
20
|
*/
|
|
16
21
|
import { displayText } from './cells'
|
|
17
22
|
import type { DashboardHarvest, EffectiveStatus, PipelineStep, StepState } from './model'
|
|
18
23
|
import type { RosterOutcome } from '../../kernel/build-roster'
|
|
24
|
+
import type { SlotState } from '../../kernel/dispatch-capacity'
|
|
19
25
|
|
|
20
26
|
/** The emphasis a term carries. Never the only carrier of meaning: every toned
|
|
21
27
|
* term also has its literal word or glyph. */
|
|
22
28
|
export type DashboardTone = 'ok' | 'live' | 'held' | 'alert' | 'pending'
|
|
23
29
|
|
|
24
|
-
/** Every lifecycle
|
|
30
|
+
/** Every lifecycle status a dashboard row routes on. */
|
|
25
31
|
export type DashboardStatus = EffectiveStatus | DashboardHarvest['status']
|
|
26
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The closed build status vocabulary (SPEC §14 "Status words"). Each tone
|
|
35
|
+
* falls wholly on one side of the slot line (§12 "What holds a slot"): every
|
|
36
|
+
* `ok` (green) word holds a slot, `live` (teal) requested one, and the rest
|
|
37
|
+
* hold none.
|
|
38
|
+
*/
|
|
39
|
+
export type BuildStatusWord =
|
|
40
|
+
| 'RUNNING'
|
|
41
|
+
| 'STARTING'
|
|
42
|
+
| 'PAUSING'
|
|
43
|
+
| 'ABORTING'
|
|
44
|
+
| 'QUEUED'
|
|
45
|
+
| 'WAITING'
|
|
46
|
+
| 'MERGING'
|
|
47
|
+
| 'PAUSED'
|
|
48
|
+
| 'COLLECTING'
|
|
49
|
+
| 'BLOCKED'
|
|
50
|
+
| 'CLEANING'
|
|
51
|
+
|
|
52
|
+
/** A harvest run's words. A harvest never holds a slot, so none is green. */
|
|
53
|
+
export type HarvestStatusWord = 'HARVESTING' | 'PAUSED' | 'SUSPENDED' | 'ESCALATED' | 'FAILED'
|
|
54
|
+
|
|
55
|
+
export const BUILD_STATUS_TONE: Readonly<Record<BuildStatusWord, DashboardTone>> = {
|
|
56
|
+
RUNNING: 'ok',
|
|
57
|
+
STARTING: 'ok',
|
|
58
|
+
PAUSING: 'ok',
|
|
59
|
+
ABORTING: 'ok',
|
|
60
|
+
QUEUED: 'live',
|
|
61
|
+
WAITING: 'held',
|
|
62
|
+
MERGING: 'held',
|
|
63
|
+
PAUSED: 'held',
|
|
64
|
+
COLLECTING: 'held',
|
|
65
|
+
BLOCKED: 'alert',
|
|
66
|
+
CLEANING: 'pending',
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const HARVEST_STATUS_TONE: Readonly<Record<HarvestStatusWord, DashboardTone>> = {
|
|
70
|
+
HARVESTING: 'live',
|
|
71
|
+
PAUSED: 'held',
|
|
72
|
+
SUSPENDED: 'held',
|
|
73
|
+
ESCALATED: 'alert',
|
|
74
|
+
FAILED: 'alert',
|
|
75
|
+
}
|
|
76
|
+
|
|
27
77
|
export interface StatusText {
|
|
78
|
+
/** The routing value: the build's effective status or the harvest status. */
|
|
28
79
|
status: DashboardStatus
|
|
29
80
|
/** The literal uppercase word (`RUNNING`, `BLOCKED`). */
|
|
30
|
-
word:
|
|
81
|
+
word: BuildStatusWord | HarvestStatusWord
|
|
31
82
|
tone: DashboardTone
|
|
83
|
+
/** Why the build shows its word (`resume`, `merge decision`, `on AUT-1`). */
|
|
84
|
+
note?: string
|
|
32
85
|
}
|
|
33
86
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The lifecycle facts a build's status word is chosen from, projected once
|
|
89
|
+
* from its reduced state. JSON-safe: no member is ever `undefined`.
|
|
90
|
+
*/
|
|
91
|
+
export interface StatusBasis {
|
|
92
|
+
/** The effective status with pending commands ignored. */
|
|
93
|
+
resting: 'queued' | 'running' | 'collecting' | 'paused' | 'blocked' | 'waiting' | 'cleaning'
|
|
94
|
+
/** A pause command is pending. */
|
|
95
|
+
pause?: true
|
|
96
|
+
/** An abort command is pending. */
|
|
97
|
+
abort?: true
|
|
98
|
+
/** A resume command is pending. */
|
|
99
|
+
resume?: true
|
|
100
|
+
/** A runner's execution is open. */
|
|
101
|
+
runner: boolean
|
|
102
|
+
node?: true
|
|
103
|
+
/** A finished pipeline: waiting for a merge decision, on hold, or merging
|
|
104
|
+
* (consent given, waiting for gates or the forge). */
|
|
105
|
+
settled?: 'decision' | 'hold' | 'merging'
|
|
106
|
+
/** A `revise-spec` answer waits for its revision. */
|
|
107
|
+
reviseSpec?: true
|
|
108
|
+
/** The open ticket wait's tickets, when the build rests `waiting`. */
|
|
109
|
+
waitTickets?: string[]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The basis a hand-built row without one implies from its status alone. */
|
|
113
|
+
function basisFromStatus(status: EffectiveStatus): StatusBasis {
|
|
114
|
+
switch (status) {
|
|
115
|
+
case 'pausing':
|
|
116
|
+
return { resting: 'running', pause: true, runner: true }
|
|
117
|
+
case 'aborting':
|
|
118
|
+
return { resting: 'running', abort: true, runner: true }
|
|
119
|
+
case 'resuming':
|
|
120
|
+
return { resting: 'paused', resume: true, runner: false }
|
|
121
|
+
default:
|
|
122
|
+
return { resting: status, runner: status === 'running' }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function buildWord(status: EffectiveStatus, word: BuildStatusWord, note?: string): StatusText {
|
|
127
|
+
return {
|
|
128
|
+
status,
|
|
129
|
+
word,
|
|
130
|
+
tone: BUILD_STATUS_TONE[word],
|
|
131
|
+
...(note !== undefined ? { note } : {}),
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* A nonterminal build's status word (SPEC §14 "Status words"): its slot state
|
|
137
|
+
* picks the tone, then lifecycle facts pick the word within it. A build that
|
|
138
|
+
* holds no slot is never green. When the slot is unknown (a value from an
|
|
139
|
+
* older server, or a caller without capacity facts), it is inferred from
|
|
140
|
+
* lifecycle facts.
|
|
141
|
+
*/
|
|
142
|
+
export function buildStatusText(input: {
|
|
143
|
+
status: EffectiveStatus
|
|
144
|
+
slot?: SlotState
|
|
145
|
+
basis?: StatusBasis
|
|
146
|
+
}): StatusText {
|
|
147
|
+
const { status } = input
|
|
148
|
+
const basis = input.basis ?? basisFromStatus(status)
|
|
149
|
+
if (basis.resting === 'cleaning') return buildWord(status, 'CLEANING')
|
|
150
|
+
const slot: SlotState | undefined =
|
|
151
|
+
input.slot ??
|
|
152
|
+
(((basis.resting === 'queued' || basis.resting === 'running') &&
|
|
153
|
+
basis.settled === undefined &&
|
|
154
|
+
basis.reviseSpec === undefined) ||
|
|
155
|
+
(basis.resting === 'collecting' && basis.runner)
|
|
156
|
+
? { state: 'held' }
|
|
157
|
+
: basis.resume && basis.resting === 'paused'
|
|
158
|
+
? { state: 'requested', request: 'resume' }
|
|
159
|
+
: undefined)
|
|
160
|
+
if (slot?.state === 'held') {
|
|
161
|
+
if (basis.abort) return buildWord(status, 'ABORTING')
|
|
162
|
+
if (basis.pause) return buildWord(status, 'PAUSING')
|
|
163
|
+
return buildWord(status, basis.runner ? 'RUNNING' : 'STARTING')
|
|
164
|
+
}
|
|
165
|
+
if (slot?.state === 'requested')
|
|
166
|
+
return buildWord(
|
|
167
|
+
status,
|
|
168
|
+
'QUEUED',
|
|
169
|
+
slot.priority === 'urgent' ? `urgent ${slot.request}` : slot.request,
|
|
170
|
+
)
|
|
171
|
+
// No slot: a pending pause or abort waits for its acknowledgement.
|
|
172
|
+
if (basis.resting === 'blocked') return buildWord(status, 'BLOCKED')
|
|
173
|
+
if (basis.resting === 'waiting')
|
|
174
|
+
return buildWord(
|
|
175
|
+
status,
|
|
176
|
+
'WAITING',
|
|
177
|
+
basis.waitTickets?.length ? `on ${basis.waitTickets.join(', ')}` : undefined,
|
|
178
|
+
)
|
|
179
|
+
if (basis.resting === 'paused') return buildWord(status, 'PAUSED')
|
|
180
|
+
if (basis.reviseSpec) return buildWord(status, 'WAITING', 'spec revision')
|
|
181
|
+
if (basis.settled === 'merging') return buildWord(status, 'MERGING')
|
|
182
|
+
if (basis.settled !== undefined)
|
|
183
|
+
return buildWord(status, 'WAITING', basis.settled === 'hold' ? 'on hold' : 'merge decision')
|
|
184
|
+
if (basis.resting === 'collecting' || basis.node) return buildWord(status, 'COLLECTING')
|
|
185
|
+
return buildWord(status, 'WAITING')
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** A harvest row's word: `HARVESTING` while it works, its stop otherwise. */
|
|
189
|
+
export function harvestStatusText(status: DashboardHarvest['status']): StatusText {
|
|
190
|
+
const word: HarvestStatusWord =
|
|
191
|
+
status === 'running' ? 'HARVESTING' : (status.toUpperCase() as HarvestStatusWord)
|
|
192
|
+
return { status, word, tone: HARVEST_STATUS_TONE[word] }
|
|
52
193
|
}
|
|
53
194
|
|
|
54
195
|
const STEP_MARK: Record<StepState, string> = {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { rollbackRuntimeRetained } from './dispatch-runtime-use'
|
|
2
2
|
import { join, resolve, dirname } from 'node:path'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { spawnExec } from '../ports/workspace/git-worktree'
|
|
6
|
-
import { parseDispatchArgs } from './dispatch-args'
|
|
7
|
-
import { readDispatchUpgrade, readDispatcherRunFacts } from '../store/reduced-reads'
|
|
3
|
+
import type { StoreOpener } from './production-store'
|
|
4
|
+
import type { readDispatcherRunFacts } from '../store/reduced-reads'
|
|
8
5
|
import { cachedRuntime } from './dispatch-runtime-cache'
|
|
9
6
|
import type {
|
|
10
7
|
GenerationLaunch,
|
|
@@ -18,6 +15,11 @@ import type { UpgradeRun } from '../kernel/dispatch-upgrade'
|
|
|
18
15
|
type DispatcherRunFacts = Awaited<ReturnType<typeof readDispatcherRunFacts>>['value']
|
|
19
16
|
import type { Handoff } from '../kernel/dispatch-upgrade'
|
|
20
17
|
|
|
18
|
+
/** Reader commands run in short-lived processes, so they initialize only what
|
|
19
|
+
* their operation needs: store, reducer and argument modules load at first
|
|
20
|
+
* use, and a reader with a journal never resolves repository configuration. */
|
|
21
|
+
const reducedReads = () => import('../store/reduced-reads')
|
|
22
|
+
|
|
21
23
|
/** Once a held run identifies its journal, readers retain that transport
|
|
22
24
|
* identity across rejected configuration edits. It conveys no lifecycle result. */
|
|
23
25
|
export async function openGenerationStore(
|
|
@@ -28,11 +30,21 @@ export async function openGenerationStore(
|
|
|
28
30
|
) {
|
|
29
31
|
if (launch.journal) {
|
|
30
32
|
const { storeRef, repo } = launch.journal
|
|
31
|
-
const token = /^https?:/i.test(storeRef)
|
|
32
|
-
|
|
33
|
+
const token = /^https?:/i.test(storeRef)
|
|
34
|
+
? (await import('./project-credentials')).projectToken(storeRef, repo, env)
|
|
35
|
+
: env.AB_TOKEN
|
|
36
|
+
const store = openStore
|
|
37
|
+
? openStore(storeRef, token)
|
|
38
|
+
: await (await import('./production-store')).openProductionStoreAsync(storeRef, token)
|
|
39
|
+
return { store, storeRef, repo }
|
|
33
40
|
}
|
|
41
|
+
const [{ parseDispatchArgs }, { spawnExec }, { openSessionlessStoreLazily }] = await Promise.all([
|
|
42
|
+
import('./dispatch-args'),
|
|
43
|
+
import('../ports/workspace/git-worktree'),
|
|
44
|
+
import('./sessionless-store'),
|
|
45
|
+
])
|
|
34
46
|
const args = parseDispatchArgs(argv.slice(1), env)
|
|
35
|
-
return
|
|
47
|
+
return openSessionlessStoreLazily({
|
|
36
48
|
targetRepo: launch.checkout,
|
|
37
49
|
exec: spawnExec,
|
|
38
50
|
env,
|
|
@@ -47,8 +59,9 @@ export async function readGenerationJournal(
|
|
|
47
59
|
launch: GenerationLaunch,
|
|
48
60
|
argv: string[],
|
|
49
61
|
env: Record<string, string | undefined>,
|
|
62
|
+
options: { openStore?: StoreOpener } = {},
|
|
50
63
|
) {
|
|
51
|
-
const opened = await openGenerationStore(launch, argv, env)
|
|
64
|
+
const opened = await openGenerationStore(launch, argv, env, options.openStore)
|
|
52
65
|
try {
|
|
53
66
|
await opened.store.ensureRepo(opened.repo)
|
|
54
67
|
return {
|
|
@@ -67,11 +80,13 @@ export async function readHandoff(
|
|
|
67
80
|
argv: string[],
|
|
68
81
|
env: Record<string, string | undefined>,
|
|
69
82
|
live = false,
|
|
83
|
+
options: { openStore?: StoreOpener } = {},
|
|
70
84
|
): Promise<Handoff | undefined> {
|
|
71
85
|
if (!launch.run || !launch.lineage) return undefined
|
|
72
|
-
const opened = await openGenerationStore(launch, argv, env)
|
|
86
|
+
const opened = await openGenerationStore(launch, argv, env, options.openStore)
|
|
73
87
|
try {
|
|
74
88
|
if (!(await opened.store.getRepo(opened.repo))) return undefined
|
|
89
|
+
const { readDispatchUpgrade, readDispatcherRunFacts } = await reducedReads()
|
|
75
90
|
const state = (await readDispatchUpgrade(opened.store, opened.repo)).value.runs[launch.run]
|
|
76
91
|
const selected = live ? state?.prepared : state?.handoff
|
|
77
92
|
if (!selected || (!live && state?.completed) || state?.failure) return undefined
|
|
@@ -169,6 +184,7 @@ export async function readUpgradeProjection(
|
|
|
169
184
|
let projection: UpgradeProjection = { version: 1, handoff: null, takeover: false }
|
|
170
185
|
let guards: UpgradeGuards | undefined
|
|
171
186
|
if (journal) {
|
|
187
|
+
const { readDispatchUpgrade, readDispatcherRunFacts } = await reducedReads()
|
|
172
188
|
const upgrades = (await readDispatchUpgrade(opened.store, opened.repo)).value
|
|
173
189
|
const state = upgrades.runs[launch.run!]
|
|
174
190
|
const facts =
|
|
@@ -177,6 +193,17 @@ export async function readUpgradeProjection(
|
|
|
177
193
|
: undefined
|
|
178
194
|
const rollbackRecorded =
|
|
179
195
|
!!launch.rollback && upgrades.rollbackIds.includes(launch.rollback.correlation)
|
|
196
|
+
// An outstanding preparation only paces launcher observation.
|
|
197
|
+
const detected = state?.detected?.payload
|
|
198
|
+
const preparing =
|
|
199
|
+
detected &&
|
|
200
|
+
detected.lineage === launch.lineage &&
|
|
201
|
+
state.prepared?.payload.correlation !== detected.correlation &&
|
|
202
|
+
state.failure?.payload.correlation !== detected.correlation &&
|
|
203
|
+
!state.request &&
|
|
204
|
+
!state.handoff
|
|
205
|
+
? detected.correlation
|
|
206
|
+
: undefined
|
|
180
207
|
guards = {
|
|
181
208
|
handoff: facts ? selectHandoff(launch, state, facts, true) : null,
|
|
182
209
|
rollbackRecorded,
|
|
@@ -197,6 +224,7 @@ export async function readUpgradeProjection(
|
|
|
197
224
|
accepted: !!state?.handoff,
|
|
198
225
|
successor: state?.request?.payload.successor,
|
|
199
226
|
released: !!state?.released,
|
|
227
|
+
...(preparing ? { preparing } : {}),
|
|
200
228
|
}
|
|
201
229
|
}
|
|
202
230
|
return condition
|
|
@@ -221,6 +249,7 @@ export async function recordPreflightFailure(
|
|
|
221
249
|
) {
|
|
222
250
|
const opened = await openGenerationStore(launch, argv, env)
|
|
223
251
|
try {
|
|
252
|
+
const { readDispatchUpgrade, readDispatcherRunFacts } = await reducedReads()
|
|
224
253
|
const state = (await readDispatchUpgrade(opened.store, opened.repo)).value.runs[launch.run!]
|
|
225
254
|
const facts = (await readDispatcherRunFacts(opened.store, opened.repo, launch.run!)).value
|
|
226
255
|
if (facts.stopRequest) return
|
|
@@ -256,6 +285,7 @@ export async function recoverTerminalRelease(
|
|
|
256
285
|
throw new Error('terminal recovery requires the owning launcher')
|
|
257
286
|
const opened = await openGenerationStore(launch, argv, env)
|
|
258
287
|
try {
|
|
288
|
+
const { readDispatchUpgrade, readDispatcherRunFacts } = await reducedReads()
|
|
259
289
|
const state = (await readDispatchUpgrade(opened.store, opened.repo)).value.runs[launch.run!]
|
|
260
290
|
const facts = (await readDispatcherRunFacts(opened.store, opened.repo, launch.run!)).value
|
|
261
291
|
if (
|
|
@@ -286,6 +316,7 @@ export async function recordRuntimeRollback(
|
|
|
286
316
|
run: string,
|
|
287
317
|
): Promise<void> {
|
|
288
318
|
const context = launch.rollback
|
|
319
|
+
const { readDispatchUpgrade } = await reducedReads()
|
|
289
320
|
if (launch.recovery) {
|
|
290
321
|
const recovery = launch.recovery
|
|
291
322
|
const state = (await readDispatchUpgrade(store, repo)).value.runs[recovery.predecessor]
|