@defrex/autobuild 1.11.0 → 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 +186 -57
- package/docs/answering-blocked-builds.md +10 -2
- package/docs/architecture.md +76 -10
- package/docs/assets/headline-wide.png +0 -0
- package/docs/cli.md +1 -1
- package/docs/configuration.md +13 -11
- package/docs/dispatcher.md +5 -4
- package/docs/integration-tree.md +28 -16
- package/docs/operator-api.md +4 -4
- package/docs/operator-surfaces.md +38 -3
- 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/header.ts +10 -0
- package/packages/core/src/cli/dashboard/model.ts +81 -23
- package/packages/core/src/cli/dashboard/poll.ts +24 -34
- package/packages/core/src/cli/dashboard/render.ts +44 -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-frontend.ts +12 -3
- 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 +70 -9
- 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 +36 -28
- 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 +74 -30
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3064e337cc75f8d6.json +310 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/46196d8f0076496a.json +97 -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/dispatch-status.ts +139 -0
- 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 +9 -369
- package/packages/core/src/kernel/reducer-registry.ts +40 -125
- package/packages/core/src/kernel/reducer-revisions.ts +5 -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 +47 -41
- 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 +3796 -3670
- package/packages/core/src/store/reducer-values.ts +36 -204
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.11.1.json +35718 -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 +20 -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-journals.ts +117 -0
- 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/packages/core/src/web/repository-source.ts +6 -2
- package/skills/guide/SKILL.md +126 -47
- 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
|
@@ -29,9 +29,14 @@ import { readBuildFacts } from '../store/reduced-reads'
|
|
|
29
29
|
import {
|
|
30
30
|
buildPriority,
|
|
31
31
|
slotRequest,
|
|
32
|
+
slotState,
|
|
32
33
|
slotWaitText,
|
|
34
|
+
type CapacityBuild,
|
|
33
35
|
type SlotRequest,
|
|
36
|
+
type SlotState,
|
|
34
37
|
} from '../kernel/dispatch-capacity'
|
|
38
|
+
import { capacityBuildFromFacts } from '../kernel/capacity-build'
|
|
39
|
+
import { openBuildWorkspace, provisionMarkerReducer } from '../processes/dispatcher-selectors'
|
|
35
40
|
import { URGENT_MARK } from './dashboard/queue'
|
|
36
41
|
import {
|
|
37
42
|
ticketWaitStatus,
|
|
@@ -70,10 +75,11 @@ import type { BuildFacts } from '../processes/repo-view'
|
|
|
70
75
|
* presentation helper exposes that divergence without folding it into status
|
|
71
76
|
* or lease health.
|
|
72
77
|
*
|
|
73
|
-
*
|
|
74
|
-
* "
|
|
75
|
-
*
|
|
76
|
-
*
|
|
78
|
+
* Text output colors only the status word, with its shared tone (SPEC §14
|
|
79
|
+
* "Status words"), and only on an interactive terminal; it never does under
|
|
80
|
+
* `--json`, through a pipe or a redirect, or when a caller omits `color`. The
|
|
81
|
+
* word itself always carries the meaning, so the output is understandable
|
|
82
|
+
* without color, and machine readers never see an escape sequence.
|
|
77
83
|
*/
|
|
78
84
|
import { join } from 'node:path'
|
|
79
85
|
import type { AbEvent } from '../events/catalog'
|
|
@@ -98,7 +104,16 @@ import { sameLandingCandidate } from '../kernel/landing-state'
|
|
|
98
104
|
import type { PipelineSourceMeta } from '../config/pipeline-source'
|
|
99
105
|
import { openExecution } from '../processes/execution-settlement'
|
|
100
106
|
import { currentLandingWaitReasonFrom } from '../kernel/auto-merge'
|
|
101
|
-
import {
|
|
107
|
+
import {
|
|
108
|
+
autoMergeDisplay,
|
|
109
|
+
effectiveStatus,
|
|
110
|
+
statusBasis,
|
|
111
|
+
type AutoMergeDisplay,
|
|
112
|
+
type EffectiveStatus,
|
|
113
|
+
} from './dashboard/model'
|
|
114
|
+
import { buildStatusText, type DashboardTone } from './dashboard/vocabulary'
|
|
115
|
+
import { paint, paintTone } from './dashboard/tone-ansi'
|
|
116
|
+
import type { TerminalOut } from './terminal'
|
|
102
117
|
import { decideNextFromFacts } from '../kernel/engine'
|
|
103
118
|
import {
|
|
104
119
|
reduceBuild,
|
|
@@ -184,6 +199,11 @@ export interface BuildSummary {
|
|
|
184
199
|
/** A node's or parked build's runner request, admitted ahead of normal
|
|
185
200
|
* ticket claims (urgent work first: SPEC §12 "Slot admission order"). */
|
|
186
201
|
slotWait?: SlotRequest
|
|
202
|
+
/** The build's slot state by the rules the dispatcher admits work by
|
|
203
|
+
* (SPEC §12 "What holds a slot"). Absent for a `done` build, and unknown
|
|
204
|
+
* (never `none`) when absent on any other: a value from an older server,
|
|
205
|
+
* or a caller without the build's capacity facts. */
|
|
206
|
+
slot?: SlotState
|
|
187
207
|
/** The build's slot-admission priority when urgent; omitted means normal. */
|
|
188
208
|
priority?: 'urgent'
|
|
189
209
|
/** The build's ticket wait while it is requested, open, or ended and not
|
|
@@ -192,6 +212,9 @@ export interface BuildSummary {
|
|
|
192
212
|
/** Set when the open ticket wait's escalation is the only one open: the
|
|
193
213
|
* dashboards' `waiting` status. `status` stays the reducer's `blocked`. */
|
|
194
214
|
waitOnly?: true
|
|
215
|
+
/** The status word every surface shows (SPEC §14 "Status words"), with its
|
|
216
|
+
* tone and note. Absent for a `done` build, and from an older server. */
|
|
217
|
+
statusWord?: { word: string; tone: DashboardTone; note?: string }
|
|
195
218
|
/** Why the operator held the merge, while a hold that gave one stands. */
|
|
196
219
|
holdReason?: string
|
|
197
220
|
/** An operator reopened this leaf and it has not settled again (§15.7). */
|
|
@@ -424,6 +447,22 @@ function measurementSummary(state: BuildState): MeasurementSummary | undefined {
|
|
|
424
447
|
}
|
|
425
448
|
}
|
|
426
449
|
|
|
450
|
+
/** A nonterminal build's status word from its reduced state and slot. */
|
|
451
|
+
function summaryStatusWord(
|
|
452
|
+
state: BuildState,
|
|
453
|
+
slot: SlotState | undefined,
|
|
454
|
+
): BuildSummary['statusWord'] {
|
|
455
|
+
const status = effectiveStatus(state)
|
|
456
|
+
const basis = statusBasis(state)
|
|
457
|
+
if (status === 'done' || status === 'aborted' || basis === undefined) return undefined
|
|
458
|
+
const text = buildStatusText({ status, basis, ...(slot !== undefined ? { slot } : {}) })
|
|
459
|
+
return {
|
|
460
|
+
word: text.word,
|
|
461
|
+
tone: text.tone,
|
|
462
|
+
...(text.note !== undefined ? { note: text.note } : {}),
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
427
466
|
/**
|
|
428
467
|
* The summary over an ALREADY-reduced state — so `detail` reduces the log
|
|
429
468
|
* once and builds both projections from it, rather than reducing twice.
|
|
@@ -432,8 +471,10 @@ export function summarizeFrom(
|
|
|
432
471
|
record: BuildRecord,
|
|
433
472
|
state: BuildState,
|
|
434
473
|
now: Date,
|
|
435
|
-
|
|
474
|
+
capacity?: CapacityBuild,
|
|
436
475
|
): BuildSummary {
|
|
476
|
+
const slotWait = capacity ? slotRequest(capacity, now) : undefined
|
|
477
|
+
const slot = capacity ? slotState(capacity, now) : undefined
|
|
437
478
|
// `phase`, `round`, and `attempt` describe ONE phase occurrence, so they come
|
|
438
479
|
// from ONE source: the in-flight phase, else the last completed one — the
|
|
439
480
|
// same `currentPhase ?? lastCompletedPhase` the reducer uses to derive
|
|
@@ -457,6 +498,7 @@ export function summarizeFrom(
|
|
|
457
498
|
const heldBecause = holdReason(state.landing)
|
|
458
499
|
const reopened = reopenedSummary(state)
|
|
459
500
|
const ciFailure = currentCiFailure(state)
|
|
501
|
+
const word = summaryStatusWord(state, slot)
|
|
460
502
|
return {
|
|
461
503
|
slug: record.slug,
|
|
462
504
|
...buildVocabulary(state),
|
|
@@ -508,9 +550,11 @@ export function summarizeFrom(
|
|
|
508
550
|
lease: leaseInfo(record, now),
|
|
509
551
|
progress: buildProgress(record, state),
|
|
510
552
|
...(slotWait ? { slotWait } : {}),
|
|
553
|
+
...(slot ? { slot } : {}),
|
|
511
554
|
...(buildPriority(state) === 'urgent' ? { priority: 'urgent' as const } : {}),
|
|
512
555
|
...(wait !== undefined ? { wait } : {}),
|
|
513
556
|
...(effectiveStatus(state) === 'waiting' ? { waitOnly: true as const } : {}),
|
|
557
|
+
...(word !== undefined ? { statusWord: word } : {}),
|
|
514
558
|
...(heldBecause !== undefined ? { holdReason: heldBecause } : {}),
|
|
515
559
|
...(reopened !== undefined ? { reopened } : {}),
|
|
516
560
|
...(ciFailure !== undefined
|
|
@@ -533,7 +577,20 @@ export function summarizeFrom(
|
|
|
533
577
|
* happening now rather than the last thing that finished.
|
|
534
578
|
*/
|
|
535
579
|
export function summarize(record: BuildRecord, events: AbEvent[], now: Date): BuildSummary {
|
|
536
|
-
|
|
580
|
+
const state = reduceBuild(events)
|
|
581
|
+
return summarizeFrom(record, state, now, capacityFromEvents(record, state, events))
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/** A build's capacity facts from its whole log, as `buildDashboard` derives
|
|
585
|
+
* them: pure, for the event-array convenience callers. */
|
|
586
|
+
function capacityFromEvents(record: BuildRecord, state: BuildState, events: AbEvent[]) {
|
|
587
|
+
return {
|
|
588
|
+
record,
|
|
589
|
+
state,
|
|
590
|
+
workspace: openBuildWorkspace(events) !== null,
|
|
591
|
+
provisioning: provisionMarkerReducer.reduce(events) !== undefined,
|
|
592
|
+
restackDue: landingRestackDue(state, indexLog(events)),
|
|
593
|
+
} satisfies CapacityBuild
|
|
537
594
|
}
|
|
538
595
|
|
|
539
596
|
/** Summary plus the detail fields; `eventCount` appends the newest n events. */
|
|
@@ -551,10 +608,11 @@ export function detail(
|
|
|
551
608
|
decision?: BuildDecisionProjection,
|
|
552
609
|
streams?: readonly StreamRecord[],
|
|
553
610
|
): BuildDetail {
|
|
611
|
+
const state = reduceBuild(events)
|
|
554
612
|
return detailFromFacts(
|
|
555
613
|
record,
|
|
556
614
|
{
|
|
557
|
-
state
|
|
615
|
+
state,
|
|
558
616
|
runnerAttaches: buildReadFactsReducer.reduce(events).runnerAttaches,
|
|
559
617
|
log: indexLog(events),
|
|
560
618
|
observations: events
|
|
@@ -570,6 +628,7 @@ export function detail(
|
|
|
570
628
|
eventCount === undefined ? undefined : events.slice(-eventCount),
|
|
571
629
|
decision,
|
|
572
630
|
streams,
|
|
631
|
+
capacityFromEvents(record, state, events),
|
|
573
632
|
)
|
|
574
633
|
}
|
|
575
634
|
|
|
@@ -645,6 +704,7 @@ export function detailFromFacts(
|
|
|
645
704
|
events?: AbEvent[],
|
|
646
705
|
decision?: BuildDecisionProjection,
|
|
647
706
|
streams?: readonly StreamRecord[],
|
|
707
|
+
capacity?: CapacityBuild,
|
|
648
708
|
): BuildDetail {
|
|
649
709
|
const state = facts.state
|
|
650
710
|
const streamStatus = new Map<string, { stream?: string; status: 'open' | 'closed' }>()
|
|
@@ -657,7 +717,7 @@ export function detailFromFacts(
|
|
|
657
717
|
})
|
|
658
718
|
}
|
|
659
719
|
}
|
|
660
|
-
const summary = summarizeFrom(record, state, now)
|
|
720
|
+
const summary = summarizeFrom(record, state, now, capacity)
|
|
661
721
|
// §15.6-A: only the CURRENT cycle's results describe the current code.
|
|
662
722
|
// Without this filter an earlier cycle's passes read as current — wrong, and
|
|
663
723
|
// wrong in the reassuring direction.
|
|
@@ -866,16 +926,26 @@ function viaMarker(actor: Actor): string {
|
|
|
866
926
|
return `human (via ${actor.via.kind === 'session' ? `session ${actor.via.id}` : `mcp ${actor.via.client}`})`
|
|
867
927
|
}
|
|
868
928
|
|
|
869
|
-
|
|
929
|
+
/** A table cell: plain text, or text painted with escapes whose visible
|
|
930
|
+
* width is `plain`'s. Padding always goes outside the escapes. */
|
|
931
|
+
type Cell = string | { plain: string; painted: string }
|
|
932
|
+
|
|
933
|
+
function padColumns(rows: Cell[][]): string[] {
|
|
934
|
+
const plain = (cell: Cell) => (typeof cell === 'string' ? cell : cell.plain)
|
|
935
|
+
const painted = (cell: Cell) => (typeof cell === 'string' ? cell : cell.painted)
|
|
870
936
|
const widths: number[] = []
|
|
871
937
|
for (const row of rows) {
|
|
872
938
|
row.forEach((cell, i) => {
|
|
873
|
-
widths[i] = Math.max(widths[i] ?? 0, cell.length)
|
|
939
|
+
widths[i] = Math.max(widths[i] ?? 0, plain(cell).length)
|
|
874
940
|
})
|
|
875
941
|
}
|
|
876
942
|
return rows.map((row) =>
|
|
877
943
|
row
|
|
878
|
-
.map((cell, i) =>
|
|
944
|
+
.map((cell, i) =>
|
|
945
|
+
i === row.length - 1
|
|
946
|
+
? painted(cell)
|
|
947
|
+
: `${painted(cell)}${' '.repeat(Math.max(0, (widths[i] ?? 0) - plain(cell).length))}`,
|
|
948
|
+
)
|
|
879
949
|
.join(' ')
|
|
880
950
|
.trimEnd(),
|
|
881
951
|
)
|
|
@@ -886,12 +956,17 @@ function padColumns(rows: string[][]): string[] {
|
|
|
886
956
|
* is nothing to show, so an empty result is an honest answer rather than a
|
|
887
957
|
* blank that reads like a bug.
|
|
888
958
|
*/
|
|
889
|
-
export function renderSummaries(
|
|
959
|
+
export function renderSummaries(
|
|
960
|
+
summaries: BuildSummary[],
|
|
961
|
+
now: Date,
|
|
962
|
+
emptyNote: string,
|
|
963
|
+
opts: { color?: boolean } = {},
|
|
964
|
+
): string[] {
|
|
890
965
|
if (summaries.length === 0) return [emptyNote]
|
|
891
966
|
// The two free-text columns (ticket title, PR link) go last, where their
|
|
892
967
|
// width costs no alignment on the scannable columns to their left.
|
|
893
|
-
const rows:
|
|
894
|
-
['BUILD', 'STATUS', 'PHASE', 'LEASE', 'HEARTBEAT', 'PROGRESS', 'TICKET', 'PR'],
|
|
968
|
+
const rows: Cell[][] = [
|
|
969
|
+
['BUILD', 'STATUS', 'SLOT', 'PHASE', 'LEASE', 'HEARTBEAT', 'PROGRESS', 'TICKET', 'PR'],
|
|
895
970
|
]
|
|
896
971
|
for (const summary of summaries) {
|
|
897
972
|
const progressAge =
|
|
@@ -905,7 +980,8 @@ export function renderSummaries(summaries: BuildSummary[], now: Date, emptyNote:
|
|
|
905
980
|
: ''
|
|
906
981
|
rows.push([
|
|
907
982
|
summary.slug,
|
|
908
|
-
|
|
983
|
+
statusCell(summary, summary.priority === 'urgent' ? ` ${URGENT_MARK}` : '', opts.color),
|
|
984
|
+
slotText(summary) ?? '—',
|
|
909
985
|
summary.kind === 'integration'
|
|
910
986
|
? `${summary.optimization ? treeVocabulary.optimizationKind : treeVocabulary.integrationKind} ${summary.integration ?? ''}${slotWait}`
|
|
911
987
|
: `${phaseCell(summary)}${slotWait}${ticketWait}`,
|
|
@@ -941,14 +1017,64 @@ export function renderSummaries(summaries: BuildSummary[], now: Date, emptyNote:
|
|
|
941
1017
|
})
|
|
942
1018
|
}
|
|
943
1019
|
|
|
944
|
-
/**
|
|
945
|
-
*
|
|
946
|
-
function
|
|
947
|
-
|
|
1020
|
+
/** A summary's slot state in neutral raw terms, or undefined for a `done`
|
|
1021
|
+
* build. An absent value on any other build is `unknown`, never `none`. */
|
|
1022
|
+
function slotText(summary: BuildSummary, urgent = (text: string) => `${text} urgent`) {
|
|
1023
|
+
if (summary.status === 'done') return undefined
|
|
1024
|
+
const slot = summary.slot
|
|
1025
|
+
if (slot === undefined) return 'unknown'
|
|
1026
|
+
if (slot.state !== 'requested') return slot.state
|
|
1027
|
+
const text = `requested ${slot.request}`
|
|
1028
|
+
return slot.priority === 'urgent' ? urgent(text) : text
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/** The status word text renderers print with its note (SPEC §14 "Status
|
|
1032
|
+
* words"), or a `done` build's reducer status. A summary from an older server
|
|
1033
|
+
* carries no `statusWord`; its word is chosen from the fields it does carry. */
|
|
1034
|
+
function summaryStatusText(summary: BuildSummary): BuildSummary['statusWord'] | undefined {
|
|
1035
|
+
if (summary.statusWord !== undefined) return summary.statusWord
|
|
1036
|
+
const status: EffectiveStatus | undefined = summary.waitOnly
|
|
1037
|
+
? 'waiting'
|
|
1038
|
+
: summary.status === 'aborted'
|
|
1039
|
+
? 'cleaning'
|
|
1040
|
+
: summary.status === 'done'
|
|
1041
|
+
? undefined
|
|
1042
|
+
: summary.status
|
|
1043
|
+
if (status === undefined) return undefined
|
|
1044
|
+
const text = buildStatusText({
|
|
1045
|
+
status,
|
|
1046
|
+
...(summary.slot !== undefined ? { slot: summary.slot } : {}),
|
|
1047
|
+
})
|
|
1048
|
+
return {
|
|
1049
|
+
word: text.word,
|
|
1050
|
+
tone: text.tone,
|
|
1051
|
+
...(text.note !== undefined ? { note: text.note } : {}),
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/** The STATUS text: the word painted in its tone on a color terminal, its
|
|
1056
|
+
* note dim, and `suffix` plain. */
|
|
1057
|
+
function statusCell(summary: BuildSummary, suffix: string, color = false): Cell {
|
|
1058
|
+
const word = summaryStatusText(summary)
|
|
1059
|
+
if (word === undefined) return `${summary.status}${suffix}`
|
|
1060
|
+
const note = word.note !== undefined ? ` (${word.note})` : ''
|
|
1061
|
+
return {
|
|
1062
|
+
plain: `${word.word}${note}${suffix}`,
|
|
1063
|
+
painted: `${paintTone(word.word, word.tone, color)}${paint(note, 'dim', color && note !== '')}${suffix}`,
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/** Whether `ab builds` and `ab build status` color the status word: only on
|
|
1068
|
+
* an interactive terminal, and never under `--json`. */
|
|
1069
|
+
export function statusColor(
|
|
1070
|
+
terminal: Pick<TerminalOut, 'interactive'> | undefined,
|
|
1071
|
+
json: boolean,
|
|
1072
|
+
): boolean {
|
|
1073
|
+
return terminal?.interactive === true && !json
|
|
948
1074
|
}
|
|
949
1075
|
|
|
950
1076
|
/** Labeled sections, each omitted when absent ("when each is available"). */
|
|
951
|
-
export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
1077
|
+
export function renderDetail(d: BuildDetail, now: Date, opts: { color?: boolean } = {}): string[] {
|
|
952
1078
|
const lines: string[] = [`build ${d.slug}`]
|
|
953
1079
|
if (d.nodePolling)
|
|
954
1080
|
lines.push(
|
|
@@ -1035,7 +1161,10 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
1035
1161
|
lines.push(` unsafe merge ${proof.sha}: ${proof.missing.join(', ') || proof.build}`)
|
|
1036
1162
|
}
|
|
1037
1163
|
}
|
|
1038
|
-
|
|
1164
|
+
const status = statusCell(d, d.outcome !== undefined ? ` (${d.outcome})` : '', opts.color)
|
|
1165
|
+
lines.push(` status: ${typeof status === 'string' ? status : status.painted}`)
|
|
1166
|
+
const slot = slotText(d, (text) => `${text} (urgent)`)
|
|
1167
|
+
if (slot !== undefined) lines.push(` slot: ${slot}`)
|
|
1039
1168
|
lines.push(` phase: ${phaseCell(d)}`)
|
|
1040
1169
|
if (d.reopened !== undefined)
|
|
1041
1170
|
lines.push(
|
|
@@ -1317,6 +1446,8 @@ export function statusFilter(all?: boolean, queued?: boolean): BuildStatus[] {
|
|
|
1317
1446
|
export interface AbBuildsOpts extends StatusOpts {
|
|
1318
1447
|
queued?: boolean
|
|
1319
1448
|
all?: boolean
|
|
1449
|
+
/** Color the status word with its tone (`statusColor`); default plain. */
|
|
1450
|
+
color?: boolean
|
|
1320
1451
|
}
|
|
1321
1452
|
|
|
1322
1453
|
/** `ab builds` — this repo's builds, active by default. Read-only. */
|
|
@@ -1372,21 +1503,7 @@ export async function abBuilds(opts: AbBuildsOpts): Promise<void> {
|
|
|
1372
1503
|
// exactly — so it keeps its per-build history read (correct, just not
|
|
1373
1504
|
// accelerated).
|
|
1374
1505
|
const facts = (await readBuildFacts(store, record.slug)).value
|
|
1375
|
-
const summary = summarizeFrom(
|
|
1376
|
-
record,
|
|
1377
|
-
facts.state,
|
|
1378
|
-
now,
|
|
1379
|
-
slotRequest(
|
|
1380
|
-
{
|
|
1381
|
-
record,
|
|
1382
|
-
state: facts.state,
|
|
1383
|
-
workspace: facts.workspace !== null,
|
|
1384
|
-
provisioning: facts.provisionMarker !== undefined,
|
|
1385
|
-
restackDue: landingRestackDue(facts.state, facts.log),
|
|
1386
|
-
},
|
|
1387
|
-
now,
|
|
1388
|
-
),
|
|
1389
|
-
)
|
|
1506
|
+
const summary = summarizeFrom(record, facts.state, now, capacityBuildFromFacts(record, facts))
|
|
1390
1507
|
if (wanted.has(summary.status)) summaries.push(summary)
|
|
1391
1508
|
}
|
|
1392
1509
|
summaries.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
|
|
@@ -1406,7 +1523,9 @@ export async function abBuilds(opts: AbBuildsOpts): Promise<void> {
|
|
|
1406
1523
|
: 'active builds'
|
|
1407
1524
|
const hint =
|
|
1408
1525
|
opts.all === true ? '' : opts.queued === true ? ' — try --all' : ' — try --queued or --all'
|
|
1409
|
-
for (const line of renderSummaries(summaries, now, `no ${scope} for ${repo}${hint}
|
|
1526
|
+
for (const line of renderSummaries(summaries, now, `no ${scope} for ${repo}${hint}`, {
|
|
1527
|
+
color: opts.color === true,
|
|
1528
|
+
})) {
|
|
1410
1529
|
opts.stdout(line)
|
|
1411
1530
|
}
|
|
1412
1531
|
})
|
|
@@ -1415,6 +1534,8 @@ export async function abBuilds(opts: AbBuildsOpts): Promise<void> {
|
|
|
1415
1534
|
export interface AbBuildStatusOpts extends StatusOpts {
|
|
1416
1535
|
slug: string
|
|
1417
1536
|
events?: number
|
|
1537
|
+
/** Color the status word with its tone (`statusColor`); default plain. */
|
|
1538
|
+
color?: boolean
|
|
1418
1539
|
}
|
|
1419
1540
|
|
|
1420
1541
|
function _openWorkspacePath(events: AbEvent[]): string | undefined {
|
|
@@ -1612,7 +1733,15 @@ export async function abBuildStatus(opts: AbBuildStatusOpts): Promise<void> {
|
|
|
1612
1733
|
} catch {
|
|
1613
1734
|
streams = undefined
|
|
1614
1735
|
}
|
|
1615
|
-
const projected = detailFromFacts(
|
|
1736
|
+
const projected = detailFromFacts(
|
|
1737
|
+
record,
|
|
1738
|
+
facts,
|
|
1739
|
+
now,
|
|
1740
|
+
events,
|
|
1741
|
+
decision,
|
|
1742
|
+
streams,
|
|
1743
|
+
capacityBuildFromFacts(record, facts),
|
|
1744
|
+
)
|
|
1616
1745
|
// Operator visibility (SPEC §16.1): which autobuild.toml the build's
|
|
1617
1746
|
// pinned pipeline came from, alongside the effective-config revision.
|
|
1618
1747
|
const configArtifact = await context.store.getArtifact(
|
|
@@ -1665,7 +1794,7 @@ export async function abBuildStatus(opts: AbBuildStatusOpts): Promise<void> {
|
|
|
1665
1794
|
opts.stdout(JSON.stringify(d, null, 2))
|
|
1666
1795
|
return
|
|
1667
1796
|
}
|
|
1668
|
-
for (const line of renderDetail(d, now)) opts.stdout(line)
|
|
1797
|
+
for (const line of renderDetail(d, now, { color: opts.color === true })) opts.stdout(line)
|
|
1669
1798
|
})
|
|
1670
1799
|
}
|
|
1671
1800
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AccountRedactor, redactAccountStore } from '../store/account-redaction'
|
|
2
1
|
import { untilDeadline } from './watch-lifetime'
|
|
3
2
|
/**
|
|
4
3
|
* Production BuildStore composition for CLI commands.
|
|
@@ -8,49 +7,35 @@ import { untilDeadline } from './watch-lifetime'
|
|
|
8
7
|
* joins those seams to the production remote adapter and owns finite-command
|
|
9
8
|
* store lifecycle.
|
|
10
9
|
*/
|
|
11
|
-
import {
|
|
12
|
-
|
|
10
|
+
import {
|
|
11
|
+
composeProductionStore,
|
|
12
|
+
openStoreForRepoStateWith,
|
|
13
|
+
type OpenedStoreContext,
|
|
14
|
+
type OpenStoreForRepoStateOpts,
|
|
15
|
+
type StoreOpener,
|
|
16
|
+
} from './production-store'
|
|
13
17
|
import type { Exec } from '../ports/workspace/git-worktree'
|
|
14
18
|
import { RemoteBuildStore } from '../store/remote/client'
|
|
15
19
|
import { scopeLocalStoreToPhaseSession } from '../store/phase-session'
|
|
16
20
|
import type { BuildStore } from '../store/types'
|
|
17
21
|
import {
|
|
18
|
-
InvalidAmbientContextError,
|
|
19
22
|
resolveAmbientReadSession,
|
|
20
23
|
type AmbientReadSession,
|
|
21
24
|
type CliEnv,
|
|
22
25
|
type HarvestCliEnv,
|
|
23
26
|
} from './env'
|
|
24
27
|
import { resolveRepoState, type RepoStatePaths } from './repo-state'
|
|
25
|
-
import { resolveStore } from './store-ref'
|
|
26
|
-
|
|
27
|
-
/** Shared injection seam used by every command that opens a BuildStore. */
|
|
28
|
-
export type StoreOpener = (ref: string, token?: string) => BuildStore
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
// Bearer credentials are opaque. Only absence and the exact empty value mean
|
|
32
|
-
// "no token"; nonempty values are forwarded byte-for-byte.
|
|
33
|
-
return value !== undefined && value !== '' ? value : undefined
|
|
34
|
-
}
|
|
29
|
+
export type { StoreOpener } from './production-store'
|
|
35
30
|
|
|
36
31
|
/** Production local/remote composition. The low-level parser stays injectable
|
|
37
32
|
* and does not import the HTTP adapter. */
|
|
38
|
-
export const openProductionStore: StoreOpener = (ref, token) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
const raw = process.env.AB_ACCOUNT_CREDENTIAL_ENVS
|
|
45
|
-
if (!raw) return store
|
|
46
|
-
const names: unknown = JSON.parse(raw)
|
|
47
|
-
if (!Array.isArray(names) || !names.every((name) => typeof name === 'string'))
|
|
48
|
-
throw new Error('Invalid account credential variable inventory')
|
|
49
|
-
return redactAccountStore(
|
|
50
|
-
store,
|
|
51
|
-
new AccountRedactor(() => names.map((name) => process.env[name])),
|
|
33
|
+
export const openProductionStore: StoreOpener = (ref, token) =>
|
|
34
|
+
composeProductionStore(
|
|
35
|
+
ref,
|
|
36
|
+
token,
|
|
37
|
+
(url, remoteToken) => new RemoteBuildStore({ url, token: remoteToken }),
|
|
52
38
|
)
|
|
53
|
-
}
|
|
54
39
|
|
|
55
40
|
/** Apply validated ambient authority to a selected Store handle. Remote
|
|
56
41
|
* handles retain server-side project authorization; every handle receives
|
|
@@ -74,20 +59,7 @@ export function openProductionSessionStore(env: CliEnv | HarvestCliEnv): BuildSt
|
|
|
74
59
|
return scopeSelectedStoreToPhaseSession(openProductionStore(env.store, env.token), env.store, env)
|
|
75
60
|
}
|
|
76
61
|
|
|
77
|
-
export
|
|
78
|
-
store: BuildStore
|
|
79
|
-
token?: string
|
|
80
|
-
/** The validated ambient phase/Harvest identity this invocation carries, if
|
|
81
|
-
* any — the same value that scoped `store`. Exposed for commands whose
|
|
82
|
-
* repository selection also depends on ambient own-build authority. */
|
|
83
|
-
ambient?: AmbientReadSession
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface OpenStoreForRepoStateOpts {
|
|
87
|
-
env: Record<string, string | undefined>
|
|
88
|
-
openStore?: StoreOpener
|
|
89
|
-
useProjectCredential?: boolean
|
|
90
|
-
}
|
|
62
|
+
export type { OpenedStoreContext, OpenStoreForRepoStateOpts } from './production-store'
|
|
91
63
|
|
|
92
64
|
/** Open from an already canonicalized state selection. Dispatch uses this form
|
|
93
65
|
* so repository topology and relative overrides are decided exactly once. */
|
|
@@ -95,22 +67,7 @@ export function openStoreForRepoState(
|
|
|
95
67
|
state: RepoStatePaths,
|
|
96
68
|
opts: OpenStoreForRepoStateOpts,
|
|
97
69
|
): OpenedStoreContext {
|
|
98
|
-
|
|
99
|
-
if (opts.env.AB_JUDGE !== undefined)
|
|
100
|
-
throw new InvalidAmbientContextError('a judge session has no read authority')
|
|
101
|
-
const token =
|
|
102
|
-
opts.useProjectCredential !== false && isRemoteStoreRef(state.storeRef)
|
|
103
|
-
? projectToken(state.storeRef, state.repo, opts.env)
|
|
104
|
-
: optionalToken(opts.env.AB_TOKEN)
|
|
105
|
-
if (!token && isRemoteStoreRef(state.storeRef) && state.configStore === state.storeRef) {
|
|
106
|
-
throw new Error('No project credential for this service; run ab connect')
|
|
107
|
-
}
|
|
108
|
-
const store = (opts.openStore ?? openProductionStore)(state.storeRef, token)
|
|
109
|
-
return {
|
|
110
|
-
...state,
|
|
111
|
-
store,
|
|
112
|
-
...(token !== undefined ? { token } : {}),
|
|
113
|
-
}
|
|
70
|
+
return openStoreForRepoStateWith(state, opts, opts.openStore ?? openProductionStore)
|
|
114
71
|
}
|
|
115
72
|
|
|
116
73
|
export interface SessionlessStoreOpts extends OpenStoreForRepoStateOpts {
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { openLocalStore } from '../store/local/store'
|
|
10
10
|
import type { BuildStore } from '../store/types'
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
/** An http(s) reference names the remote HTTP adapter; anything else is a
|
|
13
|
+
* local filesystem path. */
|
|
14
|
+
export function isRemoteStoreRef(ref: string): boolean {
|
|
15
|
+
return /^https?:\/\//i.test(ref)
|
|
16
|
+
}
|
|
12
17
|
|
|
13
18
|
export interface ResolveStoreOpts {
|
|
14
19
|
/** Constructs the remote HTTP store (§7.2.2); production wiring is external. */
|
|
@@ -1440,7 +1440,7 @@ documentFields(configRootSchema, {
|
|
|
1440
1440
|
'Named observe-only hooks: the dispatcher delivers each matching watch record to a command or URL, in order and at least once.',
|
|
1441
1441
|
baseBranch: 'Branch used to cut builds, target PRs, and merge during reconciliation.',
|
|
1442
1442
|
capacity:
|
|
1443
|
-
'
|
|
1443
|
+
'Slots for this repository. A build holds one from admission (a ticket claim, a start request or an admitted slot request) until it waits on a human, another ticket, the forge or its children, or ends. A build whose outside wait ends is admitted again ahead of normal ticket claims, urgent work first (see [slot admission order](dispatcher.md#slot-admission-order)). Occupancy never exceeds capacity.',
|
|
1444
1444
|
ticketScanIntervalSeconds:
|
|
1445
1445
|
'Ticket-source ready scan cadence; tick spacing is the effective minimum.',
|
|
1446
1446
|
forge:
|