@defrex/autobuild 1.0.0-beta.0 → 1.0.0-beta.2
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 +9 -4
- package/SPEC.md +295 -62
- package/bin/ab-build-runner.ts +10 -8
- package/docs/architecture.md +179 -25
- package/docs/configuration.md +41 -6
- package/docs/hosted-service.md +35 -0
- package/docs/integration-tree.md +81 -4
- package/docs/landing-policy.md +11 -0
- package/docs/migration-1.0.md +9 -0
- package/docs/operator-api.md +18 -0
- package/docs/remote-store-protocol.md +11 -0
- package/docs/restacking.md +42 -7
- package/docs/setup.md +25 -0
- package/docs/ticket-dependencies.md +6 -45
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +4 -1
- package/packages/core/src/cli/binary.ts +17 -1
- package/packages/core/src/cli/context.ts +53 -1
- package/packages/core/src/cli/dashboard/actions.ts +4 -0
- package/packages/core/src/cli/dashboard/detail.ts +45 -1
- package/packages/core/src/cli/dashboard/facts.ts +7 -2
- package/packages/core/src/cli/dashboard/integration-detail.ts +142 -0
- package/packages/core/src/cli/dashboard/integration-row.ts +248 -0
- package/packages/core/src/cli/dashboard/landing-display.ts +64 -0
- package/packages/core/src/cli/dashboard/model.ts +140 -16
- package/packages/core/src/cli/dashboard/poll.ts +40 -4
- package/packages/core/src/cli/dashboard/refresh.ts +20 -13
- package/packages/core/src/cli/dashboard/render.ts +106 -5
- package/packages/core/src/cli/dashboard/transcript.ts +2 -1
- package/packages/core/src/cli/dispatch-frontend.ts +22 -12
- package/packages/core/src/cli/dispatch.ts +59 -25
- package/packages/core/src/cli/help.ts +19 -2
- package/packages/core/src/cli/main.ts +37 -0
- package/packages/core/src/cli/publication-settlement.ts +49 -5
- package/packages/core/src/cli/repository-status.ts +97 -2
- package/packages/core/src/cli/status.ts +24 -1
- package/packages/core/src/cli/terminals.ts +94 -93
- package/packages/core/src/cli/wait.ts +11 -2
- package/packages/core/src/cli/watch.ts +12 -0
- package/packages/core/src/config/schema.ts +3 -0
- package/packages/core/src/events/catalog.ts +38 -0
- package/packages/core/src/events/compatibility.ts +183 -0
- package/packages/core/src/events/native-session.ts +13 -0
- package/packages/core/src/events/payloads.ts +148 -2
- package/packages/core/src/events/policy.ts +209 -0
- package/packages/core/src/events/repository.ts +48 -0
- package/packages/core/src/integration/harness.ts +4 -4
- package/packages/core/src/kernel/__snapshots__/{reducer-registry.test.ts.snap → reducer-accumulator-shapes.json} +771 -538
- package/packages/core/src/kernel/change-presence.ts +4 -2
- package/packages/core/src/kernel/dispatch-capacity.ts +119 -0
- package/packages/core/src/kernel/dispatcher-liveness.ts +5 -1
- package/packages/core/src/kernel/engine.ts +25 -5
- package/packages/core/src/kernel/forge-health.ts +19 -0
- package/packages/core/src/kernel/generators/build-log.ts +18 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +1 -1
- package/packages/core/src/kernel/generators/repository-journals.ts +10 -0
- package/packages/core/src/kernel/guarded-forge.ts +159 -0
- package/packages/core/src/kernel/incremental.ts +4 -2
- package/packages/core/src/kernel/integration-completeness.ts +61 -0
- package/packages/core/src/kernel/integration-landing.ts +5 -4
- package/packages/core/src/kernel/janitor-failure.ts +36 -0
- package/packages/core/src/kernel/landing-publication.ts +35 -15
- package/packages/core/src/kernel/landing-state.ts +7 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +1 -1
- package/packages/core/src/kernel/log-index.ts +12 -1
- package/packages/core/src/kernel/mixed-version.ts +52 -0
- package/packages/core/src/kernel/node-landing.ts +14 -11
- package/packages/core/src/kernel/node-restack-demand.ts +29 -0
- package/packages/core/src/kernel/node-restack-state.ts +46 -16
- package/packages/core/src/kernel/node-restack-transaction.ts +151 -8
- package/packages/core/src/kernel/node-restack.ts +34 -10
- package/packages/core/src/kernel/publication.ts +22 -0
- package/packages/core/src/kernel/read-deferrals.ts +111 -0
- package/packages/core/src/kernel/read-facts.ts +27 -6
- package/packages/core/src/kernel/reconcile-restack.ts +23 -2
- package/packages/core/src/kernel/reducer-registry.ts +15 -2
- package/packages/core/src/kernel/reducer.ts +196 -10
- package/packages/core/src/kernel/repository-attention.ts +38 -1
- package/packages/core/src/kernel/terminal-guard.ts +11 -4
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/index.ts +2 -0
- package/packages/core/src/operator/presentation.ts +5 -0
- package/packages/core/src/operator/query.ts +45 -11
- package/packages/core/src/operator/registry.ts +17 -1
- package/packages/core/src/operator/restack.ts +51 -0
- package/packages/core/src/plugin-sdk/index.ts +10 -0
- package/packages/core/src/plugins/load.ts +3 -4
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/ports/forge/contract.ts +23 -0
- package/packages/core/src/ports/forge/fake.ts +6 -2
- package/packages/core/src/ports/forge/git-rewrite.ts +92 -64
- package/packages/core/src/ports/forge/github-transport.ts +45 -2
- package/packages/core/src/ports/forge/github.ts +56 -17
- package/packages/core/src/ports/forge/local-git.ts +7 -2
- package/packages/core/src/ports/forge-failure.ts +40 -0
- package/packages/core/src/ports/forge-request-context.ts +35 -0
- package/packages/core/src/ports/forge-telemetry.ts +16 -0
- package/packages/core/src/ports/runner/claude.ts +136 -9
- package/packages/core/src/ports/runner/codex.ts +112 -7
- package/packages/core/src/ports/runner/contract.ts +78 -0
- package/packages/core/src/ports/runner/fake.ts +59 -1
- package/packages/core/src/ports/runner/native-cli-fixture.ts +86 -0
- package/packages/core/src/ports/runner/native-process-fixture.ts +38 -0
- package/packages/core/src/ports/runner/native-session.ts +110 -0
- package/packages/core/src/ports/runner/pi-rpc.ts +7 -1
- package/packages/core/src/ports/runner/pi.ts +162 -2
- package/packages/core/src/ports/types.ts +53 -5
- package/packages/core/src/ports/workspace/git-worktree.ts +45 -51
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +28 -12
- package/packages/core/src/processes/build-child-exit.ts +50 -2
- package/packages/core/src/processes/build-child.ts +15 -7
- package/packages/core/src/processes/build-runner.ts +909 -213
- package/packages/core/src/processes/dispatcher.ts +652 -334
- package/packages/core/src/processes/execution-no-progress.ts +15 -0
- package/packages/core/src/processes/pause-execution-fixture.ts +37 -0
- package/packages/core/src/processes/phase-failure-budget.ts +2 -1
- package/packages/core/src/processes/publication-loss.ts +7 -3
- package/packages/core/src/processes/repo-view.ts +53 -6
- package/packages/core/src/processes/tick-publication.ts +6 -2
- package/packages/core/src/runtime-identity.ts +37 -0
- package/packages/core/src/store/adapter.ts +4 -2
- package/packages/core/src/store/build-scope.ts +9 -0
- package/packages/core/src/store/contract.ts +203 -16
- package/packages/core/src/store/digest.ts +20 -2
- package/packages/core/src/store/local/schema.ts +6 -0
- package/packages/core/src/store/local/store.ts +57 -4
- package/packages/core/src/store/memory.ts +83 -2
- package/packages/core/src/store/new-build.ts +2 -2
- package/packages/core/src/store/phase-session.ts +13 -0
- package/packages/core/src/store/reduced-reads.ts +43 -4
- package/packages/core/src/store/reducer-value-shapes.json +8238 -5764
- package/packages/core/src/store/reducer-value-validation.ts +103 -3
- package/packages/core/src/store/reducer-values.ts +21 -6
- package/packages/core/src/store/remote/client.ts +146 -20
- package/packages/core/src/store/remote/compatibility.ts +6 -0
- package/packages/core/src/store/remote/index.ts +2 -0
- package/packages/core/src/store/remote/protocol.ts +19 -0
- package/packages/core/src/store/remote/version.ts +2 -0
- package/packages/core/src/store/repo-state-events.ts +3 -1
- package/packages/core/src/store/repo-tick.ts +6 -1
- package/packages/core/src/store/session-handle.ts +8 -0
- package/packages/core/src/store/snapshots.ts +21 -5
- package/packages/core/src/store/types.ts +19 -1
- package/packages/core/src/testing/dispatch-read-budget.ts +17 -2
- package/packages/core/src/testing/index.ts +7 -0
- package/packages/core/src/testing/newer-writer.ts +37 -0
- package/packages/core/src/testing/reduced-read-budget.ts +3 -0
- package/skills/guide/SKILL.md +144 -27
- package/skills/guide/references/integration-tree.md +81 -4
- package/skills/guide/references/landing-policy.md +11 -0
- package/skills/guide/references/migration-1.0.md +9 -0
- package/skills/guide/references/operator-api.md +18 -0
- package/skills/guide/references/plugin-authoring.md +55 -7
- package/skills/guide/references/remote-store-protocol.md +11 -0
- package/skills/guide/references/restacking.md +42 -7
- package/skills/guide/references/setup.md +25 -0
- package/skills/guide/references/ticket-dependencies.md +6 -45
- package/skills/implement/SKILL.md +4 -2
- package/skills/operate/SKILL.md +63 -6
- package/skills/reconcile/SKILL.md +3 -1
- package/skills/spec/SKILL.md +49 -39
- package/skills/tickets/SKILL.md +15 -43
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { Config } from '../../config/schema'
|
|
2
|
+
import type { BuildState } from '../../kernel/reducer'
|
|
3
|
+
import type { LeafRestackState } from '../../kernel/leaf-restack-state'
|
|
4
|
+
import {
|
|
5
|
+
integrationComplete,
|
|
6
|
+
integrationCurrent,
|
|
7
|
+
integrationCycleVerified,
|
|
8
|
+
} from '../../kernel/integration-state'
|
|
9
|
+
import { landingReady } from '../../kernel/landing-readiness'
|
|
10
|
+
import type { BuildRecord } from '../../store/types'
|
|
11
|
+
import type { DashboardBuild, PipelineStep } from './model'
|
|
12
|
+
import { nodeLandingPolicyDisplay } from './landing-display'
|
|
13
|
+
|
|
14
|
+
/** Shared list progress and five integration steps. */
|
|
15
|
+
export interface IntegrationRow {
|
|
16
|
+
parentDistance?: string
|
|
17
|
+
destination: string
|
|
18
|
+
children:
|
|
19
|
+
| { known: false }
|
|
20
|
+
| { known: true; landed: number; building: number; queued: number; total: number }
|
|
21
|
+
verified: boolean
|
|
22
|
+
steps: PipelineStep[]
|
|
23
|
+
alert?: { tone: 'red' | 'yellow'; text: string }
|
|
24
|
+
openChildren: string[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function projectIntegrationRow(
|
|
28
|
+
record: BuildRecord,
|
|
29
|
+
state: BuildState,
|
|
30
|
+
restack: LeafRestackState,
|
|
31
|
+
config: Config,
|
|
32
|
+
): IntegrationRow | undefined {
|
|
33
|
+
if (state.kind !== 'node') return undefined
|
|
34
|
+
const destination = state.target
|
|
35
|
+
? `${state.target.ticket.id} ${state.target.build}`
|
|
36
|
+
: (state.baseBranch ?? 'unknown destination')
|
|
37
|
+
const observation = state.integration?.observation
|
|
38
|
+
const openChildren = [...new Set(observation?.openChildren ?? [])]
|
|
39
|
+
const landed = new Set(observation?.contributions ?? []).size
|
|
40
|
+
const known = !!observation && observation.diagnostics.length === 0
|
|
41
|
+
const complete = integrationComplete(state)
|
|
42
|
+
const current = integrationCurrent(state)
|
|
43
|
+
const verified = current && integrationCycleVerified(state)
|
|
44
|
+
const cycle = state.integration?.cycle
|
|
45
|
+
const selected: string[] = cycle ? JSON.parse(cycle.config).verify.steps : []
|
|
46
|
+
const expected = [...new Set(selected)]
|
|
47
|
+
const receipts =
|
|
48
|
+
current && cycle
|
|
49
|
+
? state.verify.results.filter(
|
|
50
|
+
(r) =>
|
|
51
|
+
r.seq > cycle.seq &&
|
|
52
|
+
r.restackId === cycle.id &&
|
|
53
|
+
r.headSha === cycle.head &&
|
|
54
|
+
r.baseSha === cycle.parent &&
|
|
55
|
+
expected.includes(r.step),
|
|
56
|
+
)
|
|
57
|
+
: []
|
|
58
|
+
const failure = receipts.find((r) => r.outcome === 'fail')
|
|
59
|
+
const passed = new Set(
|
|
60
|
+
receipts.filter((r) => r.outcome === 'pass' || r.outcome === 'skipped').map((r) => r.step),
|
|
61
|
+
).size
|
|
62
|
+
const ready = landingReady(state, restack)
|
|
63
|
+
const mode = nodeLandingPolicyDisplay(state, config.landing)
|
|
64
|
+
const step = (
|
|
65
|
+
label: string,
|
|
66
|
+
done: boolean,
|
|
67
|
+
active: boolean,
|
|
68
|
+
qualifier?: PipelineStep['qualifier'],
|
|
69
|
+
): PipelineStep => ({
|
|
70
|
+
label,
|
|
71
|
+
state: done ? 'done' : active ? 'current' : 'pending',
|
|
72
|
+
...(qualifier ? { qualifier } : {}),
|
|
73
|
+
})
|
|
74
|
+
const conflicted = state.nodeRestack?.conflict || (restack.active && restack.replay?.conflicted)
|
|
75
|
+
const alert: IntegrationRow['alert'] = state.janitor?.attention
|
|
76
|
+
? { tone: 'red', text: `Janitor failing: ${state.janitor.message}` }
|
|
77
|
+
: conflicted
|
|
78
|
+
? {
|
|
79
|
+
tone: 'red',
|
|
80
|
+
text: `restack onto ${destination} conflicted — open the detail view for files`,
|
|
81
|
+
}
|
|
82
|
+
: failure
|
|
83
|
+
? {
|
|
84
|
+
tone: 'red',
|
|
85
|
+
text: `${failure.step} failed — file a repair child targeting ${record.ticket?.id ?? record.slug}`,
|
|
86
|
+
}
|
|
87
|
+
: ready && mode === 'consent' && state.landing?.command?.kind !== 'land'
|
|
88
|
+
? {
|
|
89
|
+
tone: 'yellow',
|
|
90
|
+
text: `ready to land into ${destination} — press l, or ab land ${record.slug}`,
|
|
91
|
+
}
|
|
92
|
+
: undefined
|
|
93
|
+
return {
|
|
94
|
+
destination,
|
|
95
|
+
parentDistance: nodeParentDistance(state),
|
|
96
|
+
openChildren,
|
|
97
|
+
children: known
|
|
98
|
+
? {
|
|
99
|
+
known: true,
|
|
100
|
+
landed,
|
|
101
|
+
building: 0,
|
|
102
|
+
queued: openChildren.length,
|
|
103
|
+
total: landed + openChildren.length,
|
|
104
|
+
}
|
|
105
|
+
: { known: false },
|
|
106
|
+
verified,
|
|
107
|
+
steps: [
|
|
108
|
+
step('spec', state.specRev !== undefined, false),
|
|
109
|
+
step('open', !!state.nodeOpened, !state.nodeOpened),
|
|
110
|
+
step('collect', complete, !!state.nodeOpened && !complete),
|
|
111
|
+
step(
|
|
112
|
+
'verify',
|
|
113
|
+
verified,
|
|
114
|
+
current && !verified,
|
|
115
|
+
failure ? 'failed' : current && !verified ? `${passed}/${expected.length}` : undefined,
|
|
116
|
+
),
|
|
117
|
+
step('land', !!state.integration?.landing, ready, mode),
|
|
118
|
+
],
|
|
119
|
+
...(alert ? { alert } : {}),
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Recomputed from the whole already-read repository, even on an empty parent delta.
|
|
124
|
+
* Never mutate cached rows or snapshots; leaf identity is preserved. */
|
|
125
|
+
export function enrichIntegrationRows(
|
|
126
|
+
rows: readonly DashboardBuild[],
|
|
127
|
+
records: readonly BuildRecord[] = [],
|
|
128
|
+
): DashboardBuild[] {
|
|
129
|
+
return rows.map((row) => {
|
|
130
|
+
const list = row.integrationRow
|
|
131
|
+
const identity = row.collectionIdentity
|
|
132
|
+
if (!list || !identity) return row
|
|
133
|
+
const live = (id: string, source: string) =>
|
|
134
|
+
rows
|
|
135
|
+
.filter((child) => {
|
|
136
|
+
const match = child.collectionIdentity
|
|
137
|
+
return (
|
|
138
|
+
match &&
|
|
139
|
+
match.repo === identity.repo &&
|
|
140
|
+
match.targetBuild === row.slug &&
|
|
141
|
+
match.targetSource === identity.source &&
|
|
142
|
+
match.targetId === identity.id &&
|
|
143
|
+
(match.id ? match.source === source && match.id === id : child.slug === id) &&
|
|
144
|
+
match.status !== 'queued' &&
|
|
145
|
+
match.status !== 'done' &&
|
|
146
|
+
match.status !== 'aborted'
|
|
147
|
+
)
|
|
148
|
+
})
|
|
149
|
+
.sort(
|
|
150
|
+
(a, b) =>
|
|
151
|
+
(b.collectionIdentity?.createdAt ?? '').localeCompare(
|
|
152
|
+
a.collectionIdentity?.createdAt ?? '',
|
|
153
|
+
) || b.slug.localeCompare(a.slug),
|
|
154
|
+
)[0]
|
|
155
|
+
const building = list.openChildren.filter((id) => live(id, identity.source ?? '')).length
|
|
156
|
+
const detail = row.integrationDetail
|
|
157
|
+
const projected = detail?.children.map((child) => {
|
|
158
|
+
const active = child.landed ? undefined : live(child.id, child.source)
|
|
159
|
+
const historical = child.builds?.length
|
|
160
|
+
? records.find((r) => r.repo === identity.repo && child.builds?.includes(r.slug))
|
|
161
|
+
: undefined
|
|
162
|
+
return {
|
|
163
|
+
...child,
|
|
164
|
+
id: historical?.ticket?.id ?? child.id,
|
|
165
|
+
source: historical?.ticket?.source ?? child.source,
|
|
166
|
+
title:
|
|
167
|
+
child.title === 'title unavailable'
|
|
168
|
+
? (active?.collectionIdentity?.title ?? historical?.ticket?.title ?? child.title)
|
|
169
|
+
: child.title,
|
|
170
|
+
state: child.landed ? 'landed' : (active?.collectionIdentity?.phase ?? 'queued'),
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
// Historical contribution records can resolve several build slugs to the
|
|
174
|
+
// same ticket, including a reopened ticket that is also currently open.
|
|
175
|
+
const byTicket = new Map<string, import('./integration-detail').IntegrationChild>()
|
|
176
|
+
for (const child of projected ?? []) {
|
|
177
|
+
const key = JSON.stringify([child.source, child.id])
|
|
178
|
+
const previous = byTicket.get(key)
|
|
179
|
+
const preferred = previous && !previous.landed ? previous : child
|
|
180
|
+
byTicket.set(
|
|
181
|
+
key,
|
|
182
|
+
previous
|
|
183
|
+
? {
|
|
184
|
+
...preferred,
|
|
185
|
+
title:
|
|
186
|
+
preferred.title === 'title unavailable'
|
|
187
|
+
? previous.title === 'title unavailable'
|
|
188
|
+
? child.title
|
|
189
|
+
: previous.title
|
|
190
|
+
: preferred.title,
|
|
191
|
+
builds: [...new Set([...(previous.builds ?? []), ...(child.builds ?? [])])].sort(),
|
|
192
|
+
}
|
|
193
|
+
: child,
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
const children = detail
|
|
197
|
+
? [...byTicket.values()].sort(
|
|
198
|
+
(a, b) =>
|
|
199
|
+
Number(a.landed) - Number(b.landed) ||
|
|
200
|
+
a.source.localeCompare(b.source) ||
|
|
201
|
+
a.id.localeCompare(b.id),
|
|
202
|
+
)
|
|
203
|
+
: undefined
|
|
204
|
+
const changed = children && JSON.stringify(children) !== JSON.stringify(detail?.children)
|
|
205
|
+
if ((!list.children.known || list.children.building === building) && !changed) return row
|
|
206
|
+
return {
|
|
207
|
+
...row,
|
|
208
|
+
integrationRow: list.children.known
|
|
209
|
+
? {
|
|
210
|
+
...list,
|
|
211
|
+
children: { ...list.children, building, queued: list.openChildren.length - building },
|
|
212
|
+
}
|
|
213
|
+
: list,
|
|
214
|
+
...(detail && children ? { integrationDetail: { ...detail, children } } : {}),
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Largest-remainder allocation keeps the track exactly 22 terminal cells. */
|
|
220
|
+
export function integrationBarCells(landed: number, building: number, queued: number): number[] {
|
|
221
|
+
const total = landed + building + queued
|
|
222
|
+
if (!total) return [0, 0, 22]
|
|
223
|
+
const raw = [landed, building, queued].map((n) => (n * 22) / total)
|
|
224
|
+
const cells = raw.map(Math.floor)
|
|
225
|
+
const remaining = 22 - cells.reduce((a, b) => a + b, 0)
|
|
226
|
+
const order = raw
|
|
227
|
+
.map((n, i) => ({ i, remainder: n - cells[i]! }))
|
|
228
|
+
.sort((a, b) => b.remainder - a.remainder || a.i - b.i)
|
|
229
|
+
for (const part of order.slice(0, remaining)) cells[part.i]! += 1
|
|
230
|
+
return cells
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function nodeParentDistance(state: BuildState): string {
|
|
234
|
+
const node = state.nodeRestack
|
|
235
|
+
const distance = node?.distance
|
|
236
|
+
const count =
|
|
237
|
+
distance &&
|
|
238
|
+
distance.base === node?.contributionBase &&
|
|
239
|
+
distance.branch === state.baseBranch &&
|
|
240
|
+
distance.parent === (node?.observedParent?.sha ?? state.nodeComparison?.parentSha)
|
|
241
|
+
? distance.count
|
|
242
|
+
: null
|
|
243
|
+
return count === null
|
|
244
|
+
? 'parent distance unknown'
|
|
245
|
+
: count === 0
|
|
246
|
+
? 'parent current'
|
|
247
|
+
: `parent ${count} commit${count === 1 ? '' : 's'} ahead`
|
|
248
|
+
}
|
|
@@ -1,6 +1,70 @@
|
|
|
1
|
+
import { evaluateLandingPolicy } from '../../kernel/landing-policy'
|
|
1
2
|
import type { BuildState } from '../../kernel/reducer'
|
|
2
3
|
|
|
3
4
|
export function landingPolicyDisplay(landing: BuildState['landing']): string {
|
|
4
5
|
if (landing?.command?.kind === 'hold') return 'held'
|
|
5
6
|
return landing?.decision?.mode ?? 'policy pending'
|
|
6
7
|
}
|
|
8
|
+
|
|
9
|
+
/** Prospective display only: absent labels are unknown, never an empty set.
|
|
10
|
+
* Follow reachable first matches; repeated excluded labels are unreachable. */
|
|
11
|
+
export function nodeLandingPolicyDisplay(
|
|
12
|
+
state: BuildState,
|
|
13
|
+
rules: readonly import('../../config/schema').LandingRule[],
|
|
14
|
+
): 'held' | 'auto' | 'consent' | 'policy pending' {
|
|
15
|
+
if (state.landing?.command?.kind === 'hold') return 'held'
|
|
16
|
+
if (state.landing?.decision) return state.landing.decision.mode
|
|
17
|
+
const into = state.target
|
|
18
|
+
? { kind: 'node' as const, ticket: state.target.ticket.id }
|
|
19
|
+
: { kind: 'root' as const }
|
|
20
|
+
const input = { from: 'node' as const, into, labels: [] as string[] }
|
|
21
|
+
const excluded = new Set<string>()
|
|
22
|
+
const modes = new Set<string>()
|
|
23
|
+
for (const rule of rules) {
|
|
24
|
+
if (rule.from && rule.from !== 'node') continue
|
|
25
|
+
if (
|
|
26
|
+
rule.into &&
|
|
27
|
+
(rule.into === 'root'
|
|
28
|
+
? into.kind !== 'root'
|
|
29
|
+
: into.kind !== 'node' || (rule.into !== 'node' && rule.into !== into.ticket))
|
|
30
|
+
)
|
|
31
|
+
continue
|
|
32
|
+
if (rule.label) {
|
|
33
|
+
if (excluded.has(rule.label)) continue
|
|
34
|
+
modes.add(evaluateLandingPolicy(rules, { ...input, labels: [rule.label] }).mode)
|
|
35
|
+
excluded.add(rule.label)
|
|
36
|
+
} else {
|
|
37
|
+
modes.add(evaluateLandingPolicy(rules, input).mode)
|
|
38
|
+
return modes.size === 1 ? ([...modes][0] as 'auto' | 'consent') : 'policy pending'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
modes.add(evaluateLandingPolicy(rules, input).mode)
|
|
42
|
+
return modes.size === 1 ? ([...modes][0] as 'auto' | 'consent') : 'policy pending'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Explain the durable rule when available; unknown labels must not invent a match. */
|
|
46
|
+
export function nodeLandingRuleDisplay(
|
|
47
|
+
state: BuildState,
|
|
48
|
+
rules: readonly import('../../config/schema').LandingRule[],
|
|
49
|
+
): string {
|
|
50
|
+
const recorded = state.landing?.decision?.rule
|
|
51
|
+
if (recorded) {
|
|
52
|
+
if ('default' in recorded) return 'default rule for integration builds: consent'
|
|
53
|
+
return `rule ${recorded.index + 1}: ${JSON.stringify(recorded.snapshot)}`
|
|
54
|
+
}
|
|
55
|
+
const into = state.target
|
|
56
|
+
? { kind: 'node' as const, ticket: state.target.ticket.id }
|
|
57
|
+
: { kind: 'root' as const }
|
|
58
|
+
const candidates = [
|
|
59
|
+
evaluateLandingPolicy(rules, { from: 'node', into, labels: [] }),
|
|
60
|
+
...rules
|
|
61
|
+
.filter((r) => r.label)
|
|
62
|
+
.map((r) => evaluateLandingPolicy(rules, { from: 'node', into, labels: [r.label!] })),
|
|
63
|
+
]
|
|
64
|
+
const unique = new Map(candidates.map((c) => [JSON.stringify(c.rule), c.rule]))
|
|
65
|
+
if (unique.size !== 1) return 'rule pending ticket labels'
|
|
66
|
+
const rule = [...unique.values()][0]!
|
|
67
|
+
return 'default' in rule
|
|
68
|
+
? 'default rule for integration builds: consent'
|
|
69
|
+
: `rule ${rule.index + 1}: ${JSON.stringify(rule.snapshot)}`
|
|
70
|
+
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { projectIntegrationDetail, type IntegrationDetail } from './integration-detail'
|
|
2
|
+
import {
|
|
3
|
+
projectIntegrationRow,
|
|
4
|
+
enrichIntegrationRows,
|
|
5
|
+
type IntegrationRow,
|
|
6
|
+
} from './integration-row'
|
|
7
|
+
import { dispatchCapacity, type DispatchCapacity } from '../../kernel/dispatch-capacity'
|
|
8
|
+
import { openBuildWorkspace, provisionMarkerReducer } from '../../processes/dispatcher-selectors'
|
|
1
9
|
import { projectTree, treeVocabulary, type TreeProjection } from './tree'
|
|
2
10
|
export { treeVocabulary, consentQueue } from './tree'
|
|
3
11
|
import { landingAuthorized } from '../../kernel/landing-state'
|
|
@@ -6,7 +14,6 @@ import {
|
|
|
6
14
|
integrationFailed,
|
|
7
15
|
integrationCurrent,
|
|
8
16
|
integrationCycleVerified,
|
|
9
|
-
integrationNeedsRunner,
|
|
10
17
|
} from '../../kernel/integration-state'
|
|
11
18
|
import type { RepositoryReadFacts } from '../../store/reduced-reads'
|
|
12
19
|
/**
|
|
@@ -121,7 +128,15 @@ export interface PipelineStep {
|
|
|
121
128
|
* a verify/finalize step preserves its outcome alongside lifecycle `state`;
|
|
122
129
|
* `waiting` annotates merge. Rendered inside the `(…)` note, so outcome
|
|
123
130
|
* distinctions never rely on color alone. */
|
|
124
|
-
qualifier?:
|
|
131
|
+
qualifier?:
|
|
132
|
+
| 'failed'
|
|
133
|
+
| 'skipped'
|
|
134
|
+
| 'waiting'
|
|
135
|
+
| 'consent'
|
|
136
|
+
| 'auto'
|
|
137
|
+
| 'held'
|
|
138
|
+
| 'policy pending'
|
|
139
|
+
| `${number}/${number}`
|
|
125
140
|
/** Round (plan/implement loops) or attempt (verify/reconcile). Rendered as
|
|
126
141
|
* `/n` riding the elapsed time when > 1 — supersedes the old `r2`/`a2`. */
|
|
127
142
|
count?: number
|
|
@@ -157,6 +172,20 @@ export interface DashboardHarvest {
|
|
|
157
172
|
}
|
|
158
173
|
|
|
159
174
|
export interface DashboardBuild {
|
|
175
|
+
integrationRow?: IntegrationRow
|
|
176
|
+
integrationDetail?: IntegrationDetail
|
|
177
|
+
collectionIdentity?: {
|
|
178
|
+
repo: string
|
|
179
|
+
source?: string
|
|
180
|
+
id?: string
|
|
181
|
+
targetBuild?: string
|
|
182
|
+
targetSource?: string
|
|
183
|
+
targetId?: string
|
|
184
|
+
status: BuildState['status']
|
|
185
|
+
title?: string
|
|
186
|
+
phase?: string
|
|
187
|
+
createdAt?: string
|
|
188
|
+
}
|
|
160
189
|
tree?: TreeProjection
|
|
161
190
|
kind?: 'integration' | 'work'
|
|
162
191
|
target?: string
|
|
@@ -279,8 +308,9 @@ export interface DashboardModel {
|
|
|
279
308
|
repo: string
|
|
280
309
|
/** Ready tickets waiting for a slot — the dispatcher's standing queue depth. */
|
|
281
310
|
queued: number
|
|
282
|
-
/**
|
|
311
|
+
/** Shared occupied/effective slot counter; idle integration nodes are free. */
|
|
283
312
|
active: DashboardCounter
|
|
313
|
+
capacity?: DispatchCapacity
|
|
284
314
|
/** Recorded observation occurrences not claimed by a Harvest snapshot,
|
|
285
315
|
* against the configured count-pressure trigger. */
|
|
286
316
|
observations: DashboardCounter
|
|
@@ -411,7 +441,15 @@ export function autoMergeConsentReason(slug: string): string {
|
|
|
411
441
|
*/
|
|
412
442
|
interface StepExtra {
|
|
413
443
|
producedOutput?: boolean
|
|
414
|
-
qualifier?:
|
|
444
|
+
qualifier?:
|
|
445
|
+
| 'failed'
|
|
446
|
+
| 'skipped'
|
|
447
|
+
| 'waiting'
|
|
448
|
+
| 'consent'
|
|
449
|
+
| 'auto'
|
|
450
|
+
| 'held'
|
|
451
|
+
| 'policy pending'
|
|
452
|
+
| `${number}/${number}`
|
|
415
453
|
count?: number
|
|
416
454
|
timing?: StepTiming
|
|
417
455
|
reason?: string
|
|
@@ -568,6 +606,33 @@ export function projectBuildFromFacts(
|
|
|
568
606
|
slug: record.slug,
|
|
569
607
|
...buildVocabulary(state),
|
|
570
608
|
tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
|
|
609
|
+
integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
|
|
610
|
+
integrationDetail: projectIntegrationDetail(
|
|
611
|
+
record,
|
|
612
|
+
state,
|
|
613
|
+
facts.log.restack,
|
|
614
|
+
config,
|
|
615
|
+
pipeline,
|
|
616
|
+
),
|
|
617
|
+
...(state.janitor?.attention
|
|
618
|
+
? { setupError: `Janitor failing: ${state.janitor.message}` }
|
|
619
|
+
: {}),
|
|
620
|
+
collectionIdentity: {
|
|
621
|
+
repo: record.repo,
|
|
622
|
+
source: record.ticket?.source,
|
|
623
|
+
id: record.ticket?.id,
|
|
624
|
+
targetBuild: state.target?.build,
|
|
625
|
+
targetSource: state.target?.ticket.source,
|
|
626
|
+
targetId: state.target?.ticket.id,
|
|
627
|
+
status: state.status,
|
|
628
|
+
title: record.ticket?.title,
|
|
629
|
+
phase:
|
|
630
|
+
state.currentPhase?.phase ??
|
|
631
|
+
buildVocabulary(state).integration ??
|
|
632
|
+
state.phase ??
|
|
633
|
+
state.status,
|
|
634
|
+
createdAt: record.createdAt,
|
|
635
|
+
},
|
|
571
636
|
status,
|
|
572
637
|
alsoPaused: false,
|
|
573
638
|
...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
|
|
@@ -585,6 +650,33 @@ export function projectBuildFromFacts(
|
|
|
585
650
|
slug: record.slug,
|
|
586
651
|
...buildVocabulary(state),
|
|
587
652
|
tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
|
|
653
|
+
integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
|
|
654
|
+
integrationDetail: projectIntegrationDetail(
|
|
655
|
+
record,
|
|
656
|
+
state,
|
|
657
|
+
facts.log.restack,
|
|
658
|
+
config,
|
|
659
|
+
pipeline,
|
|
660
|
+
),
|
|
661
|
+
...(state.janitor?.attention
|
|
662
|
+
? { setupError: `Janitor failing: ${state.janitor.message}` }
|
|
663
|
+
: {}),
|
|
664
|
+
collectionIdentity: {
|
|
665
|
+
repo: record.repo,
|
|
666
|
+
source: record.ticket?.source,
|
|
667
|
+
id: record.ticket?.id,
|
|
668
|
+
targetBuild: state.target?.build,
|
|
669
|
+
targetSource: state.target?.ticket.source,
|
|
670
|
+
targetId: state.target?.ticket.id,
|
|
671
|
+
status: state.status,
|
|
672
|
+
title: record.ticket?.title,
|
|
673
|
+
phase:
|
|
674
|
+
state.currentPhase?.phase ??
|
|
675
|
+
buildVocabulary(state).integration ??
|
|
676
|
+
state.phase ??
|
|
677
|
+
state.status,
|
|
678
|
+
createdAt: record.createdAt,
|
|
679
|
+
},
|
|
588
680
|
status,
|
|
589
681
|
alsoPaused: false,
|
|
590
682
|
...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
|
|
@@ -870,8 +962,9 @@ export function projectBuildFromFacts(
|
|
|
870
962
|
steps[steps.length - 1] = { ...steps[steps.length - 1]!, reason }
|
|
871
963
|
}
|
|
872
964
|
|
|
873
|
-
const setupError =
|
|
874
|
-
state.
|
|
965
|
+
const setupError = state.janitor?.attention
|
|
966
|
+
? `Janitor failing: ${state.janitor.message}`
|
|
967
|
+
: state.infrastructureFailure !== undefined
|
|
875
968
|
? `${state.infrastructureFailure.provider} ${state.infrastructureFailure.operation} failed ` +
|
|
876
969
|
`(attempt ${state.infrastructureFailure.attempt}, ${state.infrastructureFailure.cause}${
|
|
877
970
|
state.infrastructureFailure.cleanupPending ? ', cleanup pending' : ''
|
|
@@ -895,6 +988,24 @@ export function projectBuildFromFacts(
|
|
|
895
988
|
slug: record.slug,
|
|
896
989
|
...buildVocabulary(state),
|
|
897
990
|
tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
|
|
991
|
+
integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
|
|
992
|
+
integrationDetail: projectIntegrationDetail(record, state, facts.log.restack, config, pipeline),
|
|
993
|
+
collectionIdentity: {
|
|
994
|
+
repo: record.repo,
|
|
995
|
+
source: record.ticket?.source,
|
|
996
|
+
id: record.ticket?.id,
|
|
997
|
+
targetBuild: state.target?.build,
|
|
998
|
+
targetSource: state.target?.ticket.source,
|
|
999
|
+
targetId: state.target?.ticket.id,
|
|
1000
|
+
status: state.status,
|
|
1001
|
+
title: record.ticket?.title,
|
|
1002
|
+
phase:
|
|
1003
|
+
state.currentPhase?.phase ??
|
|
1004
|
+
buildVocabulary(state).integration ??
|
|
1005
|
+
state.phase ??
|
|
1006
|
+
state.status,
|
|
1007
|
+
createdAt: record.createdAt,
|
|
1008
|
+
},
|
|
898
1009
|
status,
|
|
899
1010
|
alsoPaused: state.status === 'paused' && status === 'blocked',
|
|
900
1011
|
...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
|
|
@@ -1164,6 +1275,7 @@ export function projectHarvest(
|
|
|
1164
1275
|
}
|
|
1165
1276
|
|
|
1166
1277
|
interface DashboardFrameHeader {
|
|
1278
|
+
capacityProjection?: DispatchCapacity
|
|
1167
1279
|
repo: string
|
|
1168
1280
|
queued: number
|
|
1169
1281
|
observationCount: number
|
|
@@ -1191,7 +1303,7 @@ export function buildDashboardFromProjected(
|
|
|
1191
1303
|
header: DashboardHeader,
|
|
1192
1304
|
repositoryEvents: RepositoryEvent[] | RepositoryReadFacts = [],
|
|
1193
1305
|
): DashboardModel {
|
|
1194
|
-
const builds =
|
|
1306
|
+
const builds = enrichIntegrationRows(projectedBuilds).sort((a, b) => a.slug.localeCompare(b.slug))
|
|
1195
1307
|
const harvestProjection = projectRepositoryHarvest(repositoryEvents)
|
|
1196
1308
|
const settings = Array.isArray(repositoryEvents)
|
|
1197
1309
|
? reduceDispatchSettings(repositoryEvents)
|
|
@@ -1199,7 +1311,11 @@ export function buildDashboardFromProjected(
|
|
|
1199
1311
|
return {
|
|
1200
1312
|
repo: header.repo,
|
|
1201
1313
|
queued: header.queued,
|
|
1202
|
-
active: {
|
|
1314
|
+
active: {
|
|
1315
|
+
current: header.capacityProjection?.occupied ?? header.activeCount,
|
|
1316
|
+
limit: header.capacityProjection?.effective ?? header.capacity,
|
|
1317
|
+
},
|
|
1318
|
+
...(header.capacityProjection ? { capacity: header.capacityProjection } : {}),
|
|
1203
1319
|
observations: { current: header.observationCount, limit: header.observationLimit },
|
|
1204
1320
|
drained: !settings.intake,
|
|
1205
1321
|
repositoryPaused: settings.paused,
|
|
@@ -1227,17 +1343,25 @@ export function buildDashboard(
|
|
|
1227
1343
|
const builds = entries
|
|
1228
1344
|
.map(({ record, state, events }) => projectBuild(record, state, config, events))
|
|
1229
1345
|
.filter((build): build is DashboardBuild => build !== null)
|
|
1230
|
-
const
|
|
1231
|
-
({ state }) =>
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1346
|
+
const capacityProjection = dispatchCapacity(
|
|
1347
|
+
entries.map(({ record, state, events }) => ({
|
|
1348
|
+
record,
|
|
1349
|
+
state,
|
|
1350
|
+
workspace: openBuildWorkspace(events) !== null,
|
|
1351
|
+
provisioning: provisionMarkerReducer.reduce(events) !== undefined,
|
|
1352
|
+
})),
|
|
1353
|
+
config.capacity,
|
|
1354
|
+
new Date(),
|
|
1355
|
+
)
|
|
1356
|
+
const activeCount = capacityProjection.occupied
|
|
1237
1357
|
return buildDashboardFromProjected(
|
|
1238
|
-
|
|
1358
|
+
enrichIntegrationRows(
|
|
1359
|
+
builds,
|
|
1360
|
+
entries.map((e) => e.record),
|
|
1361
|
+
),
|
|
1239
1362
|
{
|
|
1240
1363
|
...header,
|
|
1364
|
+
capacityProjection,
|
|
1241
1365
|
activeCount,
|
|
1242
1366
|
capacity: config.capacity,
|
|
1243
1367
|
observationLimit: config.policy.harvestThreshold,
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { enrichIntegrationRows } from './integration-row'
|
|
2
|
+
import type { CapacityBuild } from '../../kernel/dispatch-capacity'
|
|
3
|
+
import {
|
|
4
|
+
openBuildWorkspaceReducer,
|
|
5
|
+
provisionMarkerReducer,
|
|
6
|
+
} from '../../processes/dispatcher-selectors'
|
|
1
7
|
import type { Config } from '../../config/schema'
|
|
2
8
|
import { composeBuildConfig } from '../../config/live'
|
|
3
9
|
import type { PipelineSourceMeta } from '../../config/pipeline-source'
|
|
@@ -27,6 +33,7 @@ export interface DashboardBuildReader {
|
|
|
27
33
|
export interface DashboardPollSnapshot {
|
|
28
34
|
/** Monotonic process-local cache revision. */
|
|
29
35
|
revision: number
|
|
36
|
+
capacityBuilds?: CapacityBuild[]
|
|
30
37
|
/** Every dashboard-visible row, including acknowledged abort cleanup. Objects
|
|
31
38
|
* are reused while their streams are unchanged. */
|
|
32
39
|
builds: DashboardBuild[]
|
|
@@ -37,6 +44,9 @@ export interface DashboardPollSnapshot {
|
|
|
37
44
|
|
|
38
45
|
interface LiveEntry {
|
|
39
46
|
kind: 'live'
|
|
47
|
+
record: BuildRecord
|
|
48
|
+
workspace: ReturnType<typeof openBuildWorkspaceReducer.initial>
|
|
49
|
+
provisionMarker: ReturnType<typeof provisionMarkerReducer.initial>
|
|
40
50
|
events: AbEvent[]
|
|
41
51
|
/** The reducer accumulator `state` was derived from; the next delta is
|
|
42
52
|
* folded into a copy of it instead of re-reducing the whole log. */
|
|
@@ -48,6 +58,7 @@ interface LiveEntry {
|
|
|
48
58
|
/** A fully completed build can never become visible again, so its log is discarded. */
|
|
49
59
|
interface TerminalEntry {
|
|
50
60
|
kind: 'terminal'
|
|
61
|
+
record: BuildRecord
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
type PollEntry = LiveEntry | TerminalEntry
|
|
@@ -204,7 +215,7 @@ export class DashboardBuildPollCache {
|
|
|
204
215
|
for (const record of records) {
|
|
205
216
|
const current = this.entries.get(record.slug)
|
|
206
217
|
if (current?.kind === 'terminal') {
|
|
207
|
-
next.set(record.slug, current)
|
|
218
|
+
next.set(record.slug, { ...current, record })
|
|
208
219
|
continue
|
|
209
220
|
}
|
|
210
221
|
|
|
@@ -220,9 +231,10 @@ export class DashboardBuildPollCache {
|
|
|
220
231
|
fullEnrichment || configChanged || current.build?.ticketId !== record.ticket?.id
|
|
221
232
|
? {
|
|
222
233
|
...current,
|
|
234
|
+
record,
|
|
223
235
|
build: await this.projectRow(record, current.state, current.events, config),
|
|
224
236
|
}
|
|
225
|
-
: current,
|
|
237
|
+
: { ...current, record },
|
|
226
238
|
)
|
|
227
239
|
continue
|
|
228
240
|
}
|
|
@@ -231,11 +243,20 @@ export class DashboardBuildPollCache {
|
|
|
231
243
|
const acc = buildReducer.advance(current?.acc ?? buildReducer.initial(), delta)
|
|
232
244
|
const state = buildReducer.finish(acc)
|
|
233
245
|
if (isTerminal(state)) {
|
|
234
|
-
next.set(record.slug, { kind: 'terminal' })
|
|
246
|
+
next.set(record.slug, { kind: 'terminal', record })
|
|
235
247
|
continue
|
|
236
248
|
}
|
|
237
249
|
next.set(record.slug, {
|
|
238
250
|
kind: 'live',
|
|
251
|
+
record,
|
|
252
|
+
workspace: openBuildWorkspaceReducer.advance(
|
|
253
|
+
current?.workspace ?? openBuildWorkspaceReducer.initial(),
|
|
254
|
+
delta,
|
|
255
|
+
),
|
|
256
|
+
provisionMarker: provisionMarkerReducer.advance(
|
|
257
|
+
current?.provisionMarker ?? provisionMarkerReducer.initial(),
|
|
258
|
+
delta,
|
|
259
|
+
),
|
|
239
260
|
events,
|
|
240
261
|
acc,
|
|
241
262
|
state,
|
|
@@ -255,12 +276,27 @@ export class DashboardBuildPollCache {
|
|
|
255
276
|
private snapshot(): DashboardPollSnapshot {
|
|
256
277
|
const builds: DashboardBuild[] = []
|
|
257
278
|
const states = new Map<string, BuildState>()
|
|
279
|
+
const capacityBuilds: CapacityBuild[] = []
|
|
258
280
|
for (const [slug, entry] of this.entries) {
|
|
259
281
|
if (entry.kind === 'terminal') continue
|
|
282
|
+
capacityBuilds.push({
|
|
283
|
+
record: entry.record,
|
|
284
|
+
state: entry.state,
|
|
285
|
+
workspace: entry.workspace.open !== null,
|
|
286
|
+
provisioning: entry.provisionMarker.marker !== null,
|
|
287
|
+
})
|
|
260
288
|
states.set(slug, entry.state)
|
|
261
289
|
if (entry.build !== null) builds.push(entry.build)
|
|
262
290
|
}
|
|
263
291
|
builds.sort((a, b) => a.slug.localeCompare(b.slug))
|
|
264
|
-
return {
|
|
292
|
+
return {
|
|
293
|
+
revision: this.committedRevision,
|
|
294
|
+
builds: enrichIntegrationRows(
|
|
295
|
+
builds,
|
|
296
|
+
[...this.entries.values()].map((e) => e.record),
|
|
297
|
+
),
|
|
298
|
+
states,
|
|
299
|
+
capacityBuilds,
|
|
300
|
+
}
|
|
265
301
|
}
|
|
266
302
|
}
|