@defrex/autobuild 1.0.0-beta.3 → 1.0.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 +362 -56
- package/bin/ab-dispatch-generation.ts +93 -0
- package/docs/agent-runtimes.md +157 -0
- package/docs/answering-blocked-builds.md +21 -3
- package/docs/architecture.md +166 -7
- package/docs/build-store.md +123 -0
- package/docs/builds.md +82 -0
- package/docs/cli.md +48 -0
- package/docs/configuration-overview.md +93 -0
- package/docs/configuration.md +1778 -188
- package/docs/dispatcher-hosting.md +115 -0
- package/docs/dispatcher.md +59 -0
- package/docs/forges.md +121 -0
- package/docs/getting-started.md +60 -0
- package/docs/glossary.md +60 -0
- package/docs/hosted-service.md +2 -2
- package/docs/intake.md +48 -0
- package/docs/integration-overview.md +81 -0
- package/docs/integration-tree.md +87 -2
- package/docs/integration.md +54 -0
- package/docs/operating.md +114 -0
- package/docs/operator-api.md +64 -11
- package/docs/operator-surfaces.md +90 -0
- package/docs/overview.md +49 -0
- package/docs/plugin-authoring.md +426 -0
- package/docs/remote-store-protocol.md +12 -9
- package/docs/restacking.md +4 -1
- package/docs/seams.md +66 -0
- package/docs/setup.md +28 -6
- package/docs/skills.md +119 -0
- package/docs/spec-standard.md +23 -5
- package/docs/ticket-sources.md +132 -0
- package/docs/tickets.md +69 -0
- package/docs/troubleshooting.md +111 -0
- package/docs/upgrading.md +50 -0
- package/docs/verification.md +146 -0
- package/docs/website.md +47 -5
- package/docs/workspaces.md +152 -0
- package/package.json +5 -4
- package/packages/core/src/cli/artifact.ts +5 -4
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary-direct.ts +190 -0
- package/packages/core/src/cli/binary-lifecycle.ts +46 -0
- package/packages/core/src/cli/binary.ts +24 -210
- package/packages/core/src/cli/build-control.ts +105 -2
- package/packages/core/src/cli/context.ts +41 -1
- package/packages/core/src/cli/dashboard/hand-pushed.ts +24 -0
- package/packages/core/src/cli/dashboard/handoff.ts +64 -0
- package/packages/core/src/cli/dashboard/integration-detail.ts +3 -0
- package/packages/core/src/cli/dashboard/model.ts +34 -10
- package/packages/core/src/cli/dashboard/render.ts +24 -2
- package/packages/core/src/cli/dashboard/rollback.ts +30 -0
- package/packages/core/src/cli/dispatch-args.ts +53 -0
- package/packages/core/src/cli/dispatch-crash-budget.ts +15 -0
- package/packages/core/src/cli/dispatch-frontend.ts +52 -5
- package/packages/core/src/cli/dispatch-handoff.ts +276 -0
- package/packages/core/src/cli/dispatch-launch-contract.ts +170 -0
- package/packages/core/src/cli/dispatch-launcher.ts +580 -0
- package/packages/core/src/cli/dispatch-parent-watch.ts +44 -0
- package/packages/core/src/cli/dispatch-preflight.ts +272 -0
- package/packages/core/src/cli/dispatch-presentation-job.ts +46 -0
- package/packages/core/src/cli/dispatch-presentation-ownership.ts +9 -0
- package/packages/core/src/cli/dispatch-process.ts +22 -90
- package/packages/core/src/cli/dispatch-readiness.ts +47 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +5 -1
- package/packages/core/src/cli/dispatch-runtime-cache.ts +522 -0
- package/packages/core/src/cli/dispatch-runtime-dependencies.ts +291 -0
- package/packages/core/src/cli/dispatch-runtime-use.ts +336 -0
- package/packages/core/src/cli/dispatch-upgrade-controller.ts +221 -0
- package/packages/core/src/cli/dispatch-upgrade-install.ts +258 -0
- package/packages/core/src/cli/dispatch-upgrade-source.ts +309 -0
- package/packages/core/src/cli/dispatch-upgrade-target.ts +190 -0
- package/packages/core/src/cli/dispatch.ts +604 -60
- package/packages/core/src/cli/dispatcher-liveness.ts +1 -1
- package/packages/core/src/cli/env.ts +1 -1
- package/packages/core/src/cli/harvest.ts +28 -11
- package/packages/core/src/cli/help.ts +10 -5
- package/packages/core/src/cli/installation.ts +5 -3
- package/packages/core/src/cli/main-checkout.ts +59 -0
- package/packages/core/src/cli/main.ts +15 -45
- package/packages/core/src/cli/node-verification-provenance.ts +97 -0
- package/packages/core/src/cli/repo-state.ts +3 -58
- package/packages/core/src/cli/repository-status.ts +67 -3
- package/packages/core/src/cli/runtime-spawn.ts +16 -0
- package/packages/core/src/cli/status.ts +57 -3
- package/packages/core/src/cli/upgrade-followup.ts +25 -0
- package/packages/core/src/cli/wait.ts +3 -0
- package/packages/core/src/cli/watch.ts +7 -0
- package/packages/core/src/config/landing.ts +8 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/reference-metadata.ts +31 -0
- package/packages/core/src/config/reference.ts +342 -0
- package/packages/core/src/config/roles.ts +1 -1
- package/packages/core/src/config/schema.ts +352 -10
- package/packages/core/src/distribution-packaging.ts +116 -0
- package/packages/core/src/events/catalog.ts +6 -0
- package/packages/core/src/events/payloads.ts +53 -9
- package/packages/core/src/events/policy.ts +25 -0
- package/packages/core/src/events/repository.ts +184 -4
- package/packages/core/src/events/runtime.ts +16 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +2515 -78
- package/packages/core/src/kernel/dispatch-drain-recovery.ts +121 -0
- package/packages/core/src/kernel/dispatch-status.ts +4 -2
- package/packages/core/src/kernel/dispatch-upgrade.ts +171 -0
- package/packages/core/src/kernel/dispatcher-liveness.ts +7 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +82 -0
- package/packages/core/src/kernel/guarded-forge.ts +1 -1
- package/packages/core/src/kernel/harvest.ts +98 -4
- package/packages/core/src/kernel/integration-attention.ts +20 -0
- package/packages/core/src/kernel/integration-state.ts +80 -11
- package/packages/core/src/kernel/landing-readiness.ts +6 -1
- package/packages/core/src/kernel/mixed-version.ts +34 -0
- package/packages/core/src/kernel/node-polling.ts +160 -0
- package/packages/core/src/kernel/read-facts.ts +40 -5
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer.ts +75 -14
- package/packages/core/src/kernel/service-facts.ts +11 -4
- package/packages/core/src/ontology.ts +2 -2
- package/packages/core/src/open-map.ts +3 -1
- package/packages/core/src/operator/presentation.ts +7 -0
- package/packages/core/src/operator/query.ts +6 -2
- package/packages/core/src/operator/registry.ts +1 -1
- package/packages/core/src/plugins/load.ts +4 -1
- package/packages/core/src/plugins/runtime-snapshot.ts +128 -0
- package/packages/core/src/ports/forge/contract.ts +29 -0
- package/packages/core/src/ports/forge/github.ts +189 -61
- package/packages/core/src/ports/forge-failure.ts +1 -0
- package/packages/core/src/ports/forge-telemetry.ts +3 -0
- package/packages/core/src/ports/runner/session-env.ts +1 -0
- package/packages/core/src/ports/types.ts +10 -0
- package/packages/core/src/ports/workspace/distribution-archive.ts +22 -149
- package/packages/core/src/ports/workspace/distribution-release.ts +56 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/local-build-execution.ts +37 -17
- package/packages/core/src/processes/build-child-exit.ts +5 -26
- package/packages/core/src/processes/build-runner.ts +81 -11
- package/packages/core/src/processes/dispatcher.ts +254 -23
- package/packages/core/src/processes/execution-no-progress.ts +6 -0
- package/packages/core/src/processes/execution-relaunch.ts +30 -0
- package/packages/core/src/processes/execution-settlement.ts +16 -7
- package/packages/core/src/processes/harvest-runner.ts +328 -292
- package/packages/core/src/processes/process-group-reaper.ts +17 -10
- package/packages/core/src/runtime-identity.ts +22 -3
- package/packages/core/src/store/contract.ts +153 -0
- package/packages/core/src/store/local/store.ts +197 -72
- package/packages/core/src/store/reduced-reads.ts +8 -0
- package/packages/core/src/store/reducer-value-shapes.json +5783 -3305
- package/packages/core/src/store/remote/client.ts +43 -0
- package/packages/core/src/store/repo-state-events.ts +20 -3
- package/packages/core/src/store/types.ts +7 -0
- package/skills/finalize/SKILL.md +3 -1
- package/skills/guide/SKILL.md +273 -48
- package/skills/guide/references/integration-tree.md +87 -2
- package/skills/guide/references/operator-api.md +71 -14
- package/skills/guide/references/plugin-authoring.md +231 -266
- package/skills/guide/references/remote-store-protocol.md +12 -9
- package/skills/guide/references/restacking.md +4 -1
- package/skills/guide/references/setup.md +28 -6
- package/skills/guide/references/spec-standard.md +23 -5
- package/skills/harvest/SKILL.md +4 -0
- package/skills/harvest-review/SKILL.md +4 -0
- package/skills/implement/SKILL.md +4 -2
- package/skills/operate/SKILL.md +104 -35
- package/skills/plan/SKILL.md +12 -4
- package/skills/spec/SKILL.md +20 -2
- package/skills/tickets/SKILL.md +20 -1
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { migrationIdentity, ticketMigrationsReducer } from '../../kernel/ticket-migrations'
|
|
2
|
+
import { projectRollback, type DashboardRollback } from './rollback'
|
|
3
|
+
import { dispatchUpgradeReducer, type DispatchUpgradeState } from '../../kernel/dispatch-upgrade'
|
|
4
|
+
import { enrichDrainingRow, projectHandoffs, type DashboardHandoff } from './handoff'
|
|
2
5
|
import { projectIntegrationDetail, type IntegrationDetail } from './integration-detail'
|
|
3
6
|
import {
|
|
4
7
|
projectIntegrationRow,
|
|
@@ -162,7 +165,7 @@ export interface DashboardHarvest {
|
|
|
162
165
|
/** A row always represents this concrete run; the repository gate lives in
|
|
163
166
|
* the header even when no run exists. */
|
|
164
167
|
run: string
|
|
165
|
-
status: 'running' | 'paused' | 'escalated' | 'failed'
|
|
168
|
+
status: 'running' | 'paused' | 'suspended' | 'escalated' | 'failed'
|
|
166
169
|
steps: PipelineStep[]
|
|
167
170
|
observations: number
|
|
168
171
|
rounds: number
|
|
@@ -173,6 +176,7 @@ export interface DashboardHarvest {
|
|
|
173
176
|
}
|
|
174
177
|
|
|
175
178
|
export interface DashboardBuild {
|
|
179
|
+
draining?: boolean
|
|
176
180
|
integrationRow?: IntegrationRow
|
|
177
181
|
integrationDetail?: IntegrationDetail
|
|
178
182
|
collectionIdentity?: {
|
|
@@ -306,6 +310,8 @@ export interface DashboardCounter {
|
|
|
306
310
|
}
|
|
307
311
|
|
|
308
312
|
export interface DashboardModel {
|
|
313
|
+
rollback?: DashboardRollback
|
|
314
|
+
handoffs?: DashboardHandoff[]
|
|
309
315
|
repo: string
|
|
310
316
|
/** Ready tickets waiting for a slot — the dispatcher's standing queue depth. */
|
|
311
317
|
queued: number
|
|
@@ -366,6 +372,7 @@ export function effectiveStatus(state: BuildState): EffectiveStatus | BuildState
|
|
|
366
372
|
if (state.status === 'done') return 'done'
|
|
367
373
|
if (state.status === 'aborted') return 'cleaning'
|
|
368
374
|
if (state.pendingCommands.some((command) => command.command === 'abort')) return 'aborting'
|
|
375
|
+
if (state.kind === 'node' && integrationFailed(state)) return 'blocked'
|
|
369
376
|
if (
|
|
370
377
|
(state.status === 'paused' || state.status === 'blocked') &&
|
|
371
378
|
state.openEscalations.length > 0
|
|
@@ -1033,6 +1040,9 @@ export function projectBuildFromFacts(
|
|
|
1033
1040
|
...(setupError !== undefined ? { setupError } : {}),
|
|
1034
1041
|
blockers: [
|
|
1035
1042
|
...state.openEscalations.map((e) => e.question),
|
|
1043
|
+
...(state.kind === 'node' && integrationFailed(state)
|
|
1044
|
+
? ['verification failed: file a repair child targeting this node']
|
|
1045
|
+
: []),
|
|
1036
1046
|
...(mergeWaitReason !== undefined ? [mergeWaitReason] : []),
|
|
1037
1047
|
],
|
|
1038
1048
|
...(state.reviewRoundCeilings.plan !== undefined || state.reviewRoundCeilings.code !== undefined
|
|
@@ -1128,7 +1138,9 @@ function projectHarvestRun(
|
|
|
1128
1138
|
const exhaustion = run.recoveryExhaustion
|
|
1129
1139
|
|
|
1130
1140
|
const occurrences = run.steps
|
|
1131
|
-
const
|
|
1141
|
+
const suspended = run.status === 'running' ? run.sessions.at(-1) : undefined
|
|
1142
|
+
const suspendedAt = suspended?.status === 'suspended' ? suspended.suspendedAt : undefined
|
|
1143
|
+
const stopped = run.status !== 'running' || suspendedAt !== undefined
|
|
1132
1144
|
const current = (name: string): boolean => {
|
|
1133
1145
|
if (stopped || state.paused) return false
|
|
1134
1146
|
const latest = [...occurrences].reverse().find((occurrence) => occurrence.step === name)
|
|
@@ -1167,12 +1179,10 @@ function projectHarvestRun(
|
|
|
1167
1179
|
// Both durable stop states freeze any open occurrence. A failure normally
|
|
1168
1180
|
// closes its step immediately afterward, but projecting the boundary itself
|
|
1169
1181
|
// must never make an errored row look like work is still accumulating time.
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
? Date.parse(failureStoppedAt)
|
|
1175
|
-
: undefined
|
|
1182
|
+
const stops = [state.pausedAt, failureStoppedAt, suspendedAt]
|
|
1183
|
+
.filter((at): at is string => at !== undefined)
|
|
1184
|
+
.map((at) => Date.parse(at))
|
|
1185
|
+
const frozenAt = stops.length > 0 ? Math.min(...stops) : undefined
|
|
1176
1186
|
const steps: PipelineStep[] = [
|
|
1177
1187
|
step('scan', hasOutcome('scan', 'completed'), current('scan'), {
|
|
1178
1188
|
qualifier: failedAt('scan') ? 'failed' : undefined,
|
|
@@ -1241,7 +1251,8 @@ function projectHarvestRun(
|
|
|
1241
1251
|
run: run.run,
|
|
1242
1252
|
// A paused gate freezes an open run. Attention statuses remain visible as
|
|
1243
1253
|
// FAILED/ESCALATED because the header now carries the gate state.
|
|
1244
|
-
status:
|
|
1254
|
+
status:
|
|
1255
|
+
state.paused && run.status === 'running' ? 'paused' : suspendedAt ? 'suspended' : run.status,
|
|
1245
1256
|
steps,
|
|
1246
1257
|
observations: run.observations.length,
|
|
1247
1258
|
rounds,
|
|
@@ -1303,14 +1314,27 @@ export function buildDashboardFromProjected(
|
|
|
1303
1314
|
projectedBuilds: readonly DashboardBuild[],
|
|
1304
1315
|
header: DashboardHeader,
|
|
1305
1316
|
repositoryEvents: RepositoryEvent[] | RepositoryReadFacts = [],
|
|
1317
|
+
// Filtered frontend feeds omit operational facts; use the durable reduced read there.
|
|
1318
|
+
upgrades?: DispatchUpgradeState,
|
|
1306
1319
|
): DashboardModel {
|
|
1307
|
-
const
|
|
1320
|
+
const upgradeState =
|
|
1321
|
+
upgrades ??
|
|
1322
|
+
(Array.isArray(repositoryEvents)
|
|
1323
|
+
? dispatchUpgradeReducer.reduce(repositoryEvents)
|
|
1324
|
+
: repositoryEvents.upgrades)
|
|
1325
|
+
const upgrade = projectHandoffs(upgradeState)
|
|
1326
|
+
const rollback = projectRollback(upgradeState)
|
|
1327
|
+
const builds = enrichIntegrationRows(
|
|
1328
|
+
projectedBuilds.map((row) => enrichDrainingRow(row, upgrade.draining)),
|
|
1329
|
+
).sort((a, b) => a.slug.localeCompare(b.slug))
|
|
1308
1330
|
const harvestProjection = projectRepositoryHarvest(repositoryEvents)
|
|
1309
1331
|
const settings = Array.isArray(repositoryEvents)
|
|
1310
1332
|
? reduceDispatchSettings(repositoryEvents)
|
|
1311
1333
|
: repositoryEvents.settings
|
|
1312
1334
|
return {
|
|
1313
1335
|
repo: header.repo,
|
|
1336
|
+
...(rollback ? { rollback } : {}),
|
|
1337
|
+
...(upgrade.handoffs.length ? { handoffs: upgrade.handoffs } : {}),
|
|
1314
1338
|
queued: header.queued,
|
|
1315
1339
|
active: {
|
|
1316
1340
|
current: header.capacityProjection?.occupied ?? header.activeCount,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { formatRollback } from './rollback'
|
|
2
|
+
import { formatHandoff } from './handoff'
|
|
3
|
+
import { handPushedLabel, handPushedText } from './hand-pushed'
|
|
1
4
|
import { integrationBarCells } from './integration-row'
|
|
2
5
|
import { capacityExplanation } from '../../kernel/dispatch-capacity'
|
|
3
6
|
import { treeVocabulary, consentQueue } from './tree'
|
|
@@ -268,6 +271,7 @@ const STATUS_COLOR: Record<DashboardBuild['status'] | DashboardHarvest['status']
|
|
|
268
271
|
collecting: 'cyan',
|
|
269
272
|
pausing: 'yellow',
|
|
270
273
|
paused: 'yellow',
|
|
274
|
+
suspended: 'yellow',
|
|
271
275
|
resuming: 'cyan',
|
|
272
276
|
blocked: 'red',
|
|
273
277
|
aborting: 'red',
|
|
@@ -364,6 +368,7 @@ function renderBuild(
|
|
|
364
368
|
}
|
|
365
369
|
// Blocked overrides paused visually, but the pause is still a fact the
|
|
366
370
|
// operator needs — so it rides along rather than being overwritten.
|
|
371
|
+
if (build.draining) rightTokens.push(paint('(draining)', 'yellow', color))
|
|
367
372
|
if (build.alsoPaused) rightTokens.push(paint('(paused)', 'yellow', color))
|
|
368
373
|
rightTokens.push(
|
|
369
374
|
paint(build.status.toUpperCase().padStart(widths.status), STATUS_COLOR[build.status], color),
|
|
@@ -766,6 +771,7 @@ function detailBody(
|
|
|
766
771
|
field('Integration', detail.destination)
|
|
767
772
|
const progress = integrationProgress(build.integrationRow, color)
|
|
768
773
|
body.push(...packLines(['Progress', progress.bar, ...progress.counts], width, ' '))
|
|
774
|
+
field(handPushedLabel, handPushedText(detail.handPushedCommits))
|
|
769
775
|
field('Branch', `${detail.branch} · restack ${detail.restack}`)
|
|
770
776
|
if (detail.parentDistance) field('Parent', detail.parentDistance.replace(/^parent /, ''))
|
|
771
777
|
for (const path of detail.conflictFiles ?? []) field('Conflict', path)
|
|
@@ -906,6 +912,16 @@ function upgradeNoticeLine(
|
|
|
906
912
|
)
|
|
907
913
|
}
|
|
908
914
|
|
|
915
|
+
function runtimeNoticeLines(model: DashboardModel, color: boolean, width: number): string[] {
|
|
916
|
+
const notices = [
|
|
917
|
+
...(model.rollback ? [formatRollback(model.rollback)] : []),
|
|
918
|
+
...(model.handoffs ?? []).map(formatHandoff),
|
|
919
|
+
]
|
|
920
|
+
return notices.flatMap((notice) =>
|
|
921
|
+
wrappedText(notice, width, ' ').map((line) => paint(line, 'yellow', color)),
|
|
922
|
+
)
|
|
923
|
+
}
|
|
924
|
+
|
|
909
925
|
function detailGeometry(
|
|
910
926
|
model: DashboardModel,
|
|
911
927
|
width: number,
|
|
@@ -917,7 +933,10 @@ function detailGeometry(
|
|
|
917
933
|
if (build === undefined) return undefined
|
|
918
934
|
const layout = detailBody(build, view, { color: false, width, height, now: 0 })
|
|
919
935
|
const topLength =
|
|
920
|
-
2 +
|
|
936
|
+
2 +
|
|
937
|
+
(model.standby === undefined ? 0 : 1) +
|
|
938
|
+
(model.availableUpgrade === undefined ? 0 : 1) +
|
|
939
|
+
runtimeNoticeLines(model, false, width).length
|
|
921
940
|
const controls =
|
|
922
941
|
model.resumeInput !== undefined || model.abortConfirmation !== undefined
|
|
923
942
|
? dashboardControls(model, false, width, controlsCapacity(height, topLength))
|
|
@@ -968,16 +987,18 @@ function renderDetail(model: DashboardModel, opts: RenderOpts): string[] {
|
|
|
968
987
|
const build = model.builds.find((candidate) => candidate.slug === view.slug)
|
|
969
988
|
if (build === undefined) return []
|
|
970
989
|
const { color, width, height } = opts
|
|
990
|
+
const draining = build.draining ? ` ${paint('(draining)', 'yellow', color)}` : ''
|
|
971
991
|
const paused = build.alsoPaused ? ' (also paused)' : ''
|
|
972
992
|
const notice = upgradeNoticeLine(model, color, width)
|
|
973
993
|
const top = [
|
|
974
994
|
truncate(`${paint('Build', 'bold', color)} ${displayText(build.slug)}`, width),
|
|
975
995
|
truncate(
|
|
976
|
-
` status ${paint(build.status.toUpperCase(), STATUS_COLOR[build.status], color)}${paused}`,
|
|
996
|
+
` status ${paint(build.status.toUpperCase(), STATUS_COLOR[build.status], color)}${paused}${draining}`,
|
|
977
997
|
width,
|
|
978
998
|
),
|
|
979
999
|
...standbyLine(model, color, width),
|
|
980
1000
|
...(notice === undefined ? [] : [notice]),
|
|
1001
|
+
...runtimeNoticeLines(model, color, width),
|
|
981
1002
|
]
|
|
982
1003
|
const { body } = detailBody(build, view, opts)
|
|
983
1004
|
const controls =
|
|
@@ -1595,6 +1616,7 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1595
1616
|
toggles,
|
|
1596
1617
|
...standbyLine(model, color, width),
|
|
1597
1618
|
...(upgradeNotice === undefined ? [] : [upgradeNotice]),
|
|
1619
|
+
...runtimeNoticeLines(model, color, width),
|
|
1598
1620
|
...warnings,
|
|
1599
1621
|
]
|
|
1600
1622
|
// Both structural separators are fixed frame chrome: one between the
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RuntimeIdentity } from '../../events/runtime'
|
|
2
|
+
import type { DispatchUpgradeState } from '../../kernel/dispatch-upgrade'
|
|
3
|
+
import { displayText } from './cells'
|
|
4
|
+
import { handoffRuntime } from './handoff'
|
|
5
|
+
|
|
6
|
+
export interface DashboardRollback {
|
|
7
|
+
correlation: string
|
|
8
|
+
lineage: string
|
|
9
|
+
failed: RuntimeIdentity
|
|
10
|
+
restored: RuntimeIdentity
|
|
11
|
+
ts: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Historical holds remain queryable, but only the authoritative lineage is visible. */
|
|
15
|
+
export function projectRollback(state: DispatchUpgradeState): DashboardRollback | undefined {
|
|
16
|
+
const lineage = state.authoritativeRun && state.lineages[state.authoritativeRun]
|
|
17
|
+
const hold = lineage ? state.holds[lineage] : undefined
|
|
18
|
+
if (!hold) return undefined
|
|
19
|
+
return {
|
|
20
|
+
correlation: hold.payload.correlation,
|
|
21
|
+
lineage: hold.payload.lineage,
|
|
22
|
+
failed: hold.payload.failed,
|
|
23
|
+
restored: hold.payload.restored,
|
|
24
|
+
ts: hold.ts,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function formatRollback(rollback: DashboardRollback): string {
|
|
29
|
+
return `rollback: failed ${handoffRuntime(rollback.failed)}; restored ${handoffRuntime(rollback.restored)}; held ${handoffRuntime(rollback.failed)}; at ${displayText(rollback.ts)}`
|
|
30
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseArgs, stringFlag } from './args'
|
|
2
|
+
export function parseDispatchArgs(
|
|
3
|
+
rest: readonly string[],
|
|
4
|
+
env: Record<string, string | undefined>,
|
|
5
|
+
) {
|
|
6
|
+
const usage =
|
|
7
|
+
'usage: ab dispatch [--once] [--interval <seconds>] [--store <ref>] [--repository <origin>] [--plain] [--intake | --no-intake] [--auto-merge | --no-auto-merge] (§3.3)'
|
|
8
|
+
const parsed = parseArgs(
|
|
9
|
+
rest,
|
|
10
|
+
{
|
|
11
|
+
once: 'boolean',
|
|
12
|
+
interval: 'value',
|
|
13
|
+
store: 'value',
|
|
14
|
+
repository: 'value',
|
|
15
|
+
plain: 'boolean',
|
|
16
|
+
intake: 'boolean',
|
|
17
|
+
'no-intake': 'boolean',
|
|
18
|
+
'auto-merge': 'boolean',
|
|
19
|
+
'no-auto-merge': 'boolean',
|
|
20
|
+
},
|
|
21
|
+
usage,
|
|
22
|
+
)
|
|
23
|
+
if (parsed.positionals.length > 0) throw new Error(usage)
|
|
24
|
+
|
|
25
|
+
const once = parsed.flags.has('once')
|
|
26
|
+
const plain = parsed.flags.has('plain')
|
|
27
|
+
const sawIntake = parsed.flags.has('intake')
|
|
28
|
+
const sawNoIntake = parsed.flags.has('no-intake')
|
|
29
|
+
const sawAutoMerge = parsed.flags.has('auto-merge')
|
|
30
|
+
const sawNoAutoMerge = parsed.flags.has('no-auto-merge')
|
|
31
|
+
if (sawIntake && sawNoIntake) {
|
|
32
|
+
throw new Error(`--intake and --no-intake cannot be combined — ${usage}`)
|
|
33
|
+
}
|
|
34
|
+
if (sawAutoMerge || sawNoAutoMerge) {
|
|
35
|
+
throw new Error(`Auto-merge flags are retired; configure [[landing]] policy — ${usage}`)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const interval = stringFlag(parsed, 'interval')
|
|
39
|
+
let intervalMs: number | undefined
|
|
40
|
+
if (interval !== undefined) {
|
|
41
|
+
const seconds = Number(interval)
|
|
42
|
+
if (!Number.isFinite(seconds) || seconds <= 0) {
|
|
43
|
+
throw new Error(`--interval requires a positive number of seconds — ${usage}`)
|
|
44
|
+
}
|
|
45
|
+
intervalMs = Math.round(seconds * 1000)
|
|
46
|
+
}
|
|
47
|
+
const storeRef = stringFlag(parsed, 'store')
|
|
48
|
+
const repository = stringFlag(parsed, 'repository') ?? env.AB_REPOSITORY
|
|
49
|
+
const intake = sawIntake ? true : sawNoIntake ? false : undefined
|
|
50
|
+
const defaultAutoMerge = sawAutoMerge ? true : sawNoAutoMerge ? false : undefined
|
|
51
|
+
|
|
52
|
+
return { once, plain, intake, defaultAutoMerge, intervalMs, storeRef, repository }
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Launcher-local supervision, anchored to the original durable takeover. */
|
|
2
|
+
export class DispatchCrashBudget {
|
|
3
|
+
private failures = 0
|
|
4
|
+
private readonly counted = new Set<string>()
|
|
5
|
+
constructor(readonly takeoverAt: string) {}
|
|
6
|
+
withinWindow(now: number): boolean {
|
|
7
|
+
const elapsed = now - Date.parse(this.takeoverAt)
|
|
8
|
+
return Number.isFinite(elapsed) && elapsed >= 0 && elapsed <= 10 * 60_000
|
|
9
|
+
}
|
|
10
|
+
failed(run: string, now: number): 'restart' | 'rollback' | undefined {
|
|
11
|
+
if (!this.withinWindow(now) || this.counted.has(run)) return undefined
|
|
12
|
+
this.counted.add(run)
|
|
13
|
+
return ++this.failures >= 3 ? 'rollback' : 'restart'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { migrationIdentity, ticketMigrationsReducer } from '../kernel/ticket-migrations'
|
|
2
|
+
import type { DispatchUpgradeState } from '../kernel/dispatch-upgrade'
|
|
3
|
+
import { releaseDispatchPresentation } from './dispatch-presentation-ownership'
|
|
4
|
+
import { readDispatchUpgrade } from '../store/reduced-reads'
|
|
5
|
+
import { DISPATCHER } from '../events/envelope'
|
|
6
|
+
import { launchContext } from './dispatch-launch-contract'
|
|
2
7
|
import { dispatchCapacity } from '../kernel/dispatch-capacity'
|
|
3
8
|
import { forgeReadinessWarnings } from '../kernel/dispatch-status'
|
|
4
9
|
import { RepositoryPollCache } from './dashboard/repository-poll'
|
|
@@ -122,13 +127,13 @@ export interface DispatchFrontendOptions {
|
|
|
122
127
|
* BuildStore, immutable repository identity, clock, and child supervision. */
|
|
123
128
|
export class DispatchFrontend {
|
|
124
129
|
private readonly standbyResolver: StandbyIdentityResolver
|
|
125
|
-
private readonly runId
|
|
130
|
+
private readonly runId: string
|
|
126
131
|
private readonly clock: Clock
|
|
127
132
|
private readonly region: LiveRegion
|
|
128
133
|
private readonly keyboard
|
|
129
134
|
private child: DispatchChildHandle | undefined
|
|
130
135
|
private readonly repositoryFeed: DispatchRepositoryFeed
|
|
131
|
-
private dispatchStatus: DispatchStatus
|
|
136
|
+
private dispatchStatus: DispatchStatus
|
|
132
137
|
private eventRefreshTail: Promise<void> = Promise.resolve()
|
|
133
138
|
private cache: DashboardBuildPollCache | undefined
|
|
134
139
|
private config: Config | undefined
|
|
@@ -157,6 +162,8 @@ export class DispatchFrontend {
|
|
|
157
162
|
private operatorStopRequested = false
|
|
158
163
|
|
|
159
164
|
constructor(private readonly opts: DispatchFrontendOptions) {
|
|
165
|
+
this.runId = launchContext(opts.env)?.run ?? crypto.randomUUID()
|
|
166
|
+
this.dispatchStatus = reduceDispatchStatus([], this.runId)
|
|
160
167
|
this.reader = presentationReader(opts.store, () => this.refresh?.admitted ?? true)
|
|
161
168
|
this.clock = opts.clock ?? systemClock
|
|
162
169
|
this.repositoryFeed = new DispatchRepositoryFeed(this.reader, opts.repo, this.clock)
|
|
@@ -271,6 +278,7 @@ export class DispatchFrontend {
|
|
|
271
278
|
}
|
|
272
279
|
|
|
273
280
|
private paint(): void {
|
|
281
|
+
if (this.presentationRestored) return
|
|
274
282
|
if (this.refresh !== undefined && !this.refresh.painting) return
|
|
275
283
|
if (this.model === undefined) return
|
|
276
284
|
const renderer = this.opts.resolveDashboardRenderer?.() ?? renderDashboard
|
|
@@ -303,6 +311,7 @@ export class DispatchFrontend {
|
|
|
303
311
|
|
|
304
312
|
private readonly repositoryPoll = new RepositoryPollCache<{
|
|
305
313
|
repositoryEvents: RepositoryEvent[]
|
|
314
|
+
upgrades: DispatchUpgradeState
|
|
306
315
|
status: DispatchStatus
|
|
307
316
|
config: Config
|
|
308
317
|
observationCount: number
|
|
@@ -321,6 +330,9 @@ export class DispatchFrontend {
|
|
|
321
330
|
nextPollMs: this.refresh?.intervalMs ?? 0,
|
|
322
331
|
read: async ({ fullEnrichment }) => {
|
|
323
332
|
const repositoryEvents = await this.events()
|
|
333
|
+
// Authority and rollback holds need the full durable reduction, not the
|
|
334
|
+
// low-volume replay feed (which deliberately discards per-tick facts).
|
|
335
|
+
const upgrades = (await readDispatchUpgrade(this.reader, this.opts.repo)).value
|
|
324
336
|
const status = this.dispatchStatus
|
|
325
337
|
const ref = status.effectiveConfig
|
|
326
338
|
if (ref === undefined) {
|
|
@@ -348,11 +360,11 @@ export class DispatchFrontend {
|
|
|
348
360
|
await this.standbyResolver.refresh(this.runId, status.yieldedHolder, this.clock())
|
|
349
361
|
await this.repositoryFeed.save()
|
|
350
362
|
if (!this.cache.isCurrent(snapshot)) return undefined
|
|
351
|
-
return { repositoryEvents, status, config, observationCount, snapshot }
|
|
363
|
+
return { repositoryEvents, upgrades, status, config, observationCount, snapshot }
|
|
352
364
|
},
|
|
353
365
|
})
|
|
354
366
|
if (frame === undefined) return
|
|
355
|
-
let { repositoryEvents, status } = frame
|
|
367
|
+
let { repositoryEvents, upgrades, status } = frame
|
|
356
368
|
const { config, snapshot } = frame
|
|
357
369
|
const standby = this.opts.once
|
|
358
370
|
? undefined
|
|
@@ -372,6 +384,7 @@ export class DispatchFrontend {
|
|
|
372
384
|
if (!validAbortConfirmation(snapshot.states.get(slug))) {
|
|
373
385
|
await this.dismissStaleAbortConfirmation(slug)
|
|
374
386
|
repositoryEvents = await this.events()
|
|
387
|
+
upgrades = (await readDispatchUpgrade(this.reader, this.opts.repo)).value
|
|
375
388
|
status = this.dispatchStatus
|
|
376
389
|
}
|
|
377
390
|
}
|
|
@@ -409,6 +422,7 @@ export class DispatchFrontend {
|
|
|
409
422
|
...(warningLines.length > 0 ? { warningLines } : {}),
|
|
410
423
|
},
|
|
411
424
|
repositoryEvents,
|
|
425
|
+
upgrades,
|
|
412
426
|
)
|
|
413
427
|
this.selection = reconcileSelection(previous, dashboardSelections(projected), this.selection)
|
|
414
428
|
if (
|
|
@@ -1060,7 +1074,7 @@ export class DispatchFrontend {
|
|
|
1060
1074
|
} catch {
|
|
1061
1075
|
// Final presentation remains best-effort.
|
|
1062
1076
|
} finally {
|
|
1063
|
-
this.region.finish()
|
|
1077
|
+
if (!this.presentationRestored) this.region.finish()
|
|
1064
1078
|
}
|
|
1065
1079
|
}
|
|
1066
1080
|
|
|
@@ -1098,6 +1112,36 @@ export class DispatchFrontend {
|
|
|
1098
1112
|
env: this.opts.env,
|
|
1099
1113
|
options,
|
|
1100
1114
|
})
|
|
1115
|
+
let releaseWork: Promise<void> | undefined
|
|
1116
|
+
let releaseAcknowledged = false
|
|
1117
|
+
const releaseTimer = setInterval(() => {
|
|
1118
|
+
if (releaseWork || releaseAcknowledged || this.operatorStopRequested) return
|
|
1119
|
+
releaseWork = (async () => {
|
|
1120
|
+
const state = (await readDispatchUpgrade(this.opts.store, this.opts.repo)).value.runs[
|
|
1121
|
+
this.runId
|
|
1122
|
+
]
|
|
1123
|
+
if (!state?.request || !state.handoff || state.failure) return
|
|
1124
|
+
if (state.released) {
|
|
1125
|
+
releaseAcknowledged = true
|
|
1126
|
+
return
|
|
1127
|
+
}
|
|
1128
|
+
if (!this.presentationRestored) {
|
|
1129
|
+
await this.finishPresentation()
|
|
1130
|
+
this.presentationRestored = true
|
|
1131
|
+
releaseDispatchPresentation()
|
|
1132
|
+
}
|
|
1133
|
+
await this.opts.store.appendRepo(this.opts.repo, {
|
|
1134
|
+
actor: DISPATCHER,
|
|
1135
|
+
type: 'dispatcher.terminal-released',
|
|
1136
|
+
payload: state.prepared!.payload,
|
|
1137
|
+
})
|
|
1138
|
+
releaseAcknowledged = true
|
|
1139
|
+
})()
|
|
1140
|
+
.catch(() => {})
|
|
1141
|
+
.finally(() => {
|
|
1142
|
+
releaseWork = undefined
|
|
1143
|
+
})
|
|
1144
|
+
}, 1_000)
|
|
1101
1145
|
const stop = (): void => this.requestOperatorStop()
|
|
1102
1146
|
this.opts.signal?.addEventListener('abort', stop, { once: true })
|
|
1103
1147
|
try {
|
|
@@ -1105,6 +1149,7 @@ export class DispatchFrontend {
|
|
|
1105
1149
|
if (this.opts.signal?.aborted) this.requestOperatorStop()
|
|
1106
1150
|
const result = await this.child.completed
|
|
1107
1151
|
if (
|
|
1152
|
+
!this.presentationRestored &&
|
|
1108
1153
|
!(result.outcome === 'normal' && result.exitCode === 0) &&
|
|
1109
1154
|
!(result.outcome === 'forced' && this.operatorStopRequested)
|
|
1110
1155
|
) {
|
|
@@ -1119,6 +1164,8 @@ export class DispatchFrontend {
|
|
|
1119
1164
|
)
|
|
1120
1165
|
}
|
|
1121
1166
|
} finally {
|
|
1167
|
+
clearInterval(releaseTimer)
|
|
1168
|
+
await releaseWork
|
|
1122
1169
|
this.opts.signal?.removeEventListener('abort', stop)
|
|
1123
1170
|
await this.child.stop()
|
|
1124
1171
|
await this.finishPresentation()
|