@defrex/autobuild 1.0.0-beta.2 → 1.0.0-beta.4
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/SPEC.md +342 -23
- package/bin/ab-dispatch-generation.ts +93 -0
- package/docs/answering-blocked-builds.md +21 -3
- package/docs/architecture.md +170 -7
- package/docs/configuration.md +173 -5
- package/docs/integration-tree.md +91 -4
- package/docs/integration.md +54 -0
- package/docs/operator-api.md +58 -5
- package/docs/remote-store-protocol.md +9 -1
- package/docs/remote-ticket-protocol.md +5 -0
- package/docs/restacking.md +4 -1
- package/docs/setup.md +24 -0
- package/docs/spec-standard.md +94 -5
- package/docs/ticket-migration.md +50 -4
- package/package.json +3 -3
- 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 +108 -5
- 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 +11 -6
- package/packages/core/src/cli/dashboard/integration-row.ts +15 -8
- package/packages/core/src/cli/dashboard/model.ts +41 -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 +57 -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 +6 -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 +609 -60
- package/packages/core/src/cli/dispatcher-liveness.ts +1 -1
- package/packages/core/src/cli/harvest.ts +28 -11
- package/packages/core/src/cli/help.ts +7 -3
- 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 +26 -53
- 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 +74 -4
- package/packages/core/src/cli/runtime-spawn.ts +16 -0
- package/packages/core/src/cli/status.ts +57 -3
- package/packages/core/src/cli/ticket.ts +35 -11
- 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/live.ts +1 -0
- package/packages/core/src/config/schema.ts +8 -4
- 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 +55 -9
- package/packages/core/src/events/policy.ts +26 -0
- package/packages/core/src/events/repository.ts +205 -4
- package/packages/core/src/events/runtime.ts +16 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +6537 -4053
- package/packages/core/src/kernel/change-presence.ts +7 -1
- package/packages/core/src/kernel/dispatch-capacity.ts +12 -4
- 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-completeness.ts +54 -16
- 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-parent.ts +35 -10
- package/packages/core/src/kernel/node-polling.ts +160 -0
- package/packages/core/src/kernel/read-facts.ts +47 -5
- package/packages/core/src/kernel/reducer-registry.ts +6 -0
- package/packages/core/src/kernel/reducer.ts +75 -14
- package/packages/core/src/kernel/service-facts.ts +11 -4
- package/packages/core/src/kernel/ticket-migrations.ts +139 -0
- package/packages/core/src/operator/presentation.ts +7 -0
- package/packages/core/src/operator/query.ts +13 -3
- package/packages/core/src/operator/registry.ts +1 -1
- package/packages/core/src/operator/tickets.ts +30 -26
- 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/tickets/linear.ts +180 -12
- package/packages/core/src/ports/tickets/migration.ts +92 -9
- package/packages/core/src/ports/types.ts +17 -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 +418 -59
- 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 +183 -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 +8915 -6344
- package/packages/core/src/store/remote/client.ts +43 -0
- package/packages/core/src/store/repo-state-events.ts +21 -3
- package/packages/core/src/store/types.ts +7 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +3 -2
- package/skills/guide/SKILL.md +234 -24
- package/skills/guide/references/integration-tree.md +91 -4
- package/skills/guide/references/operator-api.md +53 -4
- package/skills/guide/references/plugin-authoring.md +45 -4
- package/skills/guide/references/remote-store-protocol.md +9 -1
- package/skills/guide/references/remote-ticket-protocol.md +5 -0
- package/skills/guide/references/restacking.md +4 -1
- package/skills/guide/references/setup.md +24 -0
- package/skills/guide/references/spec-standard.md +94 -5
- package/skills/guide/references/ticket-migration.md +50 -4
- package/skills/harvest/SKILL.md +4 -0
- package/skills/harvest-review/SKILL.md +4 -0
- package/skills/operate/SKILL.md +78 -8
- package/skills/spec/SKILL.md +35 -5
- package/skills/tickets/SKILL.md +19 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ticketMigrationsReducer } from './ticket-migrations'
|
|
2
|
+
import { dispatchUpgradeReducer } from './dispatch-upgrade'
|
|
1
3
|
import {
|
|
2
4
|
advanceCompatibility,
|
|
3
5
|
initialCompatibility,
|
|
@@ -57,6 +59,7 @@ export const buildStreamSeedReducer = defineReducer<BuildStreamSeed, AbEvent, Bu
|
|
|
57
59
|
rawEvents: true,
|
|
58
60
|
version:
|
|
59
61
|
4 +
|
|
62
|
+
ticketMigrationsReducer.version +
|
|
60
63
|
leafRestackReducer.version +
|
|
61
64
|
buildReducer.version +
|
|
62
65
|
currentDeferralObservationReducer.version,
|
|
@@ -112,7 +115,16 @@ const parts = {
|
|
|
112
115
|
dashboard: dashboardFactsReducer,
|
|
113
116
|
deferral: currentDeferralObservationReducer,
|
|
114
117
|
}
|
|
118
|
+
export interface RunnerAttach {
|
|
119
|
+
seq: number
|
|
120
|
+
ts: string
|
|
121
|
+
instance: string
|
|
122
|
+
host: string
|
|
123
|
+
resumedFromSeq?: number
|
|
124
|
+
runtime: import('../events/runtime').RuntimeIdentity | null
|
|
125
|
+
}
|
|
115
126
|
export interface BuildReadAcc {
|
|
127
|
+
runnerAttaches: RunnerAttach[]
|
|
116
128
|
summaryRequests: ReturnType<typeof summaryRequestsReducer.initial>
|
|
117
129
|
summaryBoundary: ReturnType<typeof summaryBoundaryReducer.initial>
|
|
118
130
|
hostedImages: ReturnType<typeof hostedPrAttachmentsReducer.initial>
|
|
@@ -188,8 +200,9 @@ export interface BuildReadAcc {
|
|
|
188
200
|
}
|
|
189
201
|
export const buildReadFactsReducer = defineReducer({
|
|
190
202
|
rawEvents: true,
|
|
191
|
-
version:
|
|
203
|
+
version: 4 + Object.values(parts).reduce((sum, reducer) => sum + reducer.version, 0),
|
|
192
204
|
initial: (): BuildReadAcc => ({
|
|
205
|
+
runnerAttaches: [],
|
|
193
206
|
summaryRequests: summaryRequestsReducer.initial(),
|
|
194
207
|
summaryBoundary: summaryBoundaryReducer.initial(),
|
|
195
208
|
hostedImages: hostedPrAttachmentsReducer.initial(),
|
|
@@ -261,6 +274,14 @@ export const buildReadFactsReducer = defineReducer({
|
|
|
261
274
|
acc.dashboard = dashboardFactsReducer.advance(acc.dashboard, events)
|
|
262
275
|
acc.deferral = currentDeferralObservationReducer.advance(acc.deferral, events)
|
|
263
276
|
for (const event of projectEvents(events)) {
|
|
277
|
+
if (event.type === 'runner.attached')
|
|
278
|
+
acc.runnerAttaches.push({ seq: event.seq, ts: event.ts, ...event.payload, runtime: null })
|
|
279
|
+
if (event.type === 'runner.runtime-recorded') {
|
|
280
|
+
const attach = acc.runnerAttaches.find(
|
|
281
|
+
(a) => a.seq === event.payload.attachedSeq && a.instance === event.payload.instance,
|
|
282
|
+
)
|
|
283
|
+
if (attach) attach.runtime = event.payload.runtime
|
|
284
|
+
}
|
|
264
285
|
if (event.type === 'plan-review.verdict' || event.type === 'code-review.verdict')
|
|
265
286
|
acc.summaryHistory.push({
|
|
266
287
|
kind: 'review',
|
|
@@ -382,6 +403,7 @@ export const buildReadFactsReducer = defineReducer({
|
|
|
382
403
|
}
|
|
383
404
|
},
|
|
384
405
|
finish: (acc: BuildReadAcc) => ({
|
|
406
|
+
runnerAttaches: structuredClone(acc.runnerAttaches),
|
|
385
407
|
summaryRequests: summaryRequestsReducer.finish(acc.summaryRequests),
|
|
386
408
|
summaryBoundary: summaryBoundaryReducer.finish(acc.summaryBoundary),
|
|
387
409
|
hostedImages: [...hostedPrAttachmentsReducer.finish(acc.hostedImages)],
|
|
@@ -465,6 +487,7 @@ export interface RepositoryReadAcc {
|
|
|
465
487
|
Extract<RepositoryEvent, { type: 'change-presence.observed' }>['payload']
|
|
466
488
|
>
|
|
467
489
|
|
|
490
|
+
upgrades: ReturnType<typeof dispatchUpgradeReducer.initial>
|
|
468
491
|
openHarvest: ReturnType<typeof openHarvestExecutionsReducer.initial>
|
|
469
492
|
attention: ReturnType<typeof repositoryAttentionReducer.initial>
|
|
470
493
|
harvestFailures: Record<
|
|
@@ -492,6 +515,7 @@ export interface RepositoryReadAcc {
|
|
|
492
515
|
settings: ReturnType<typeof dispatchSettingsReducer.initial>
|
|
493
516
|
harvest: ReturnType<typeof harvestReducer.initial>
|
|
494
517
|
forgeHealth: ReturnType<typeof forgeHealthReducer.initial>
|
|
518
|
+
ticketMigrations: ReturnType<typeof ticketMigrationsReducer.initial>
|
|
495
519
|
health: ReturnType<typeof ticketSourceHealthReducer.initial>
|
|
496
520
|
autoMerge: ReturnType<typeof autoMergeDefaultReducer.initial>
|
|
497
521
|
config: ReturnType<typeof effectiveConfigReducer.initial>
|
|
@@ -508,6 +532,8 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
508
532
|
rawEvents: true,
|
|
509
533
|
version:
|
|
510
534
|
4 +
|
|
535
|
+
ticketMigrationsReducer.version +
|
|
536
|
+
dispatchUpgradeReducer.version +
|
|
511
537
|
dispatcherRunFactsReducer('version').version +
|
|
512
538
|
openHarvestExecutionsReducer.version +
|
|
513
539
|
forgeHealthReducer.version +
|
|
@@ -522,6 +548,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
522
548
|
initial: (): RepositoryReadAcc => ({
|
|
523
549
|
compatibility: initialCompatibility(),
|
|
524
550
|
presence: {},
|
|
551
|
+
upgrades: dispatchUpgradeReducer.initial(),
|
|
525
552
|
recentRuns: [],
|
|
526
553
|
openHarvest: openHarvestExecutionsReducer.initial(),
|
|
527
554
|
attention: repositoryAttentionReducer.initial(),
|
|
@@ -537,6 +564,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
537
564
|
settings: dispatchSettingsReducer.initial(),
|
|
538
565
|
harvest: harvestReducer.initial(),
|
|
539
566
|
forgeHealth: forgeHealthReducer.initial(),
|
|
567
|
+
ticketMigrations: ticketMigrationsReducer.initial(),
|
|
540
568
|
health: ticketSourceHealthReducer.initial(),
|
|
541
569
|
autoMerge: autoMergeDefaultReducer.initial(),
|
|
542
570
|
config: effectiveConfigReducer.initial(),
|
|
@@ -546,11 +574,13 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
546
574
|
}),
|
|
547
575
|
fold(acc: RepositoryReadAcc, events: readonly RepositoryEvent[]) {
|
|
548
576
|
advanceCompatibility(acc.compatibility, events)
|
|
577
|
+
acc.upgrades = dispatchUpgradeReducer.advance(acc.upgrades, events)
|
|
549
578
|
acc.attention = repositoryAttentionReducer.advance(acc.attention, events)
|
|
550
579
|
acc.openHarvest = openHarvestExecutionsReducer.advance(acc.openHarvest, events)
|
|
551
580
|
acc.settings = dispatchSettingsReducer.advance(acc.settings, events)
|
|
552
581
|
acc.harvest = harvestReducer.advance(acc.harvest, events)
|
|
553
582
|
acc.forgeHealth = forgeHealthReducer.advance(acc.forgeHealth, events)
|
|
583
|
+
acc.ticketMigrations = ticketMigrationsReducer.advance(acc.ticketMigrations, events)
|
|
554
584
|
acc.health = ticketSourceHealthReducer.advance(acc.health, events)
|
|
555
585
|
acc.autoMerge = autoMergeDefaultReducer.advance(acc.autoMerge, events)
|
|
556
586
|
acc.config = effectiveConfigReducer.advance(acc.config, events)
|
|
@@ -577,6 +607,12 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
577
607
|
if (event.type === 'harvest.execution.authorized')
|
|
578
608
|
acc.harvestAuthorizations[JSON.stringify(event.payload.execution)] ??= event
|
|
579
609
|
if (event.type === 'harvest.resumed') acc.latestHarvestResumedSeq = event.seq
|
|
610
|
+
if (event.type === 'harvest.session.started' && event.payload.continuation) {
|
|
611
|
+
const prior = acc.harvestSessions.find(
|
|
612
|
+
(s) => s.session === event.payload.continuation!.predecessor,
|
|
613
|
+
)
|
|
614
|
+
if (prior) prior.status = 'ended'
|
|
615
|
+
}
|
|
580
616
|
if (event.type === 'harvest.session.started')
|
|
581
617
|
acc.harvestSessions.push({
|
|
582
618
|
run: event.payload.run,
|
|
@@ -585,16 +621,18 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
585
621
|
step: event.payload.step,
|
|
586
622
|
round: event.payload.round,
|
|
587
623
|
status: 'open',
|
|
624
|
+
...(event.payload.continuation ? { continuation: event.payload.continuation } : {}),
|
|
588
625
|
...(event.payload.stream === undefined ? {} : { stream: event.payload.stream }),
|
|
589
626
|
streamStatus: event.payload.stream === undefined ? 'closed' : 'open',
|
|
590
627
|
})
|
|
591
|
-
if (event.type === 'harvest.session.ended') {
|
|
628
|
+
if (event.type === 'harvest.session.ended' || event.type === 'harvest.session.suspended') {
|
|
592
629
|
acc.harvestSessionEndings[JSON.stringify(event.payload.session)] ??= event.seq
|
|
593
630
|
const session = acc.harvestSessions.findLast(
|
|
594
631
|
(session) => session.session === event.payload.session && session.status === 'open',
|
|
595
632
|
)
|
|
596
633
|
if (session) {
|
|
597
|
-
session.status = 'ended'
|
|
634
|
+
session.status = event.type === 'harvest.session.suspended' ? 'suspended' : 'ended'
|
|
635
|
+
session.transcript = event.payload.transcript
|
|
598
636
|
session.streamStatus = 'closed'
|
|
599
637
|
}
|
|
600
638
|
}
|
|
@@ -645,6 +683,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
645
683
|
finish: (acc: RepositoryReadAcc) => ({
|
|
646
684
|
compatibility: structuredClone(acc.compatibility),
|
|
647
685
|
presence: structuredClone(acc.presence),
|
|
686
|
+
upgrades: dispatchUpgradeReducer.finish(acc.upgrades),
|
|
648
687
|
harvestFailures: structuredClone(acc.harvestFailures),
|
|
649
688
|
harvestVerdicts: structuredClone(acc.harvestVerdicts),
|
|
650
689
|
harvestAuthorizations: structuredClone(acc.harvestAuthorizations),
|
|
@@ -659,6 +698,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
659
698
|
settings: dispatchSettingsReducer.finish(acc.settings),
|
|
660
699
|
harvest: harvestReducer.finish(acc.harvest),
|
|
661
700
|
forgeHealth: forgeHealthReducer.finish(acc.forgeHealth),
|
|
701
|
+
ticketMigrations: ticketMigrationsReducer.finish(acc.ticketMigrations),
|
|
662
702
|
health: ticketSourceHealthReducer.finish(acc.health),
|
|
663
703
|
autoMerge: autoMergeDefaultReducer.finish(acc.autoMerge),
|
|
664
704
|
config: effectiveConfigReducer.finish(acc.config),
|
|
@@ -685,6 +725,7 @@ export function optionalValue<A, E, V>(reducer: IncrementalReducer<A, E, V>) {
|
|
|
685
725
|
|
|
686
726
|
/** One run's correlation facts. History for unrelated runs never enters this value. */
|
|
687
727
|
export interface DispatcherRunFacts {
|
|
728
|
+
runtime?: RepositoryEvent
|
|
688
729
|
start?: RepositoryEvent
|
|
689
730
|
latestStart?: RepositoryEvent
|
|
690
731
|
stop?: RepositoryEvent
|
|
@@ -695,7 +736,7 @@ export interface DispatcherRunFacts {
|
|
|
695
736
|
}
|
|
696
737
|
export function dispatcherRunFactsReducer(run: string) {
|
|
697
738
|
return defineReducer<DispatcherRunFacts, RepositoryEvent, DispatcherRunFacts>({
|
|
698
|
-
version:
|
|
739
|
+
version: 3,
|
|
699
740
|
initial: () => ({}),
|
|
700
741
|
fold(acc, events) {
|
|
701
742
|
for (const event of projectEvents(events)) {
|
|
@@ -711,7 +752,8 @@ function foldDispatcherRunFact(acc: DispatcherRunFacts, event: RepositoryEvent):
|
|
|
711
752
|
if (event.type === 'dispatcher.run-started') {
|
|
712
753
|
acc.start ??= event
|
|
713
754
|
acc.latestStart = event
|
|
714
|
-
} else if (event.type === 'dispatcher.
|
|
755
|
+
} else if (event.type === 'dispatcher.runtime-recorded') acc.runtime = event
|
|
756
|
+
else if (event.type === 'dispatcher.run-stopped') acc.stop = event
|
|
715
757
|
else if (event.type === 'dispatcher.stop-requested') acc.stopRequest ??= event
|
|
716
758
|
else if (
|
|
717
759
|
event.type === 'dispatcher.tick-started' ||
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ticketMigrationsReducer } from './ticket-migrations'
|
|
2
|
+
import { dispatchUpgradeReducer } from './dispatch-upgrade'
|
|
1
3
|
import { forgeHealthReducer } from './forge-health'
|
|
2
4
|
import { decodeStoredEvent } from '../events/compatibility'
|
|
3
5
|
import { nodeRestackReducer } from './node-restack-state'
|
|
@@ -85,6 +87,7 @@ export interface RegisteredReducer {
|
|
|
85
87
|
/** Parameterized reducers are registered with representative arguments; the
|
|
86
88
|
* accumulator shape does not depend on them. */
|
|
87
89
|
const REGISTERED: Record<string, Omit<RegisteredReducer, 'valueRead'>> = {
|
|
90
|
+
ticketMigrations: { reducer: ticketMigrationsReducer, covers: [] },
|
|
88
91
|
nodeRestack: { reducer: nodeRestackReducer, covers: ['advanceNodeRestack'] },
|
|
89
92
|
leafRestack: { reducer: leafRestackReducer, covers: ['advanceLeafRestack'] },
|
|
90
93
|
baseBranchValue: { reducer: optionalValue(baseBranchReducer), covers: [] },
|
|
@@ -96,6 +99,7 @@ const REGISTERED: Record<string, Omit<RegisteredReducer, 'valueRead'>> = {
|
|
|
96
99
|
covers: [],
|
|
97
100
|
},
|
|
98
101
|
dispatcherRunFacts: { reducer: dispatcherRunFactsReducer('run-a'), covers: [] },
|
|
102
|
+
dispatchUpgrade: { reducer: dispatchUpgradeReducer, covers: [] },
|
|
99
103
|
repositoryAttention: { reducer: repositoryAttentionReducer, covers: [] },
|
|
100
104
|
repositoryReadFacts: { reducer: repositoryReadFactsReducer, covers: [] },
|
|
101
105
|
buildStreamSeed: { reducer: buildStreamSeedReducer, covers: [] },
|
|
@@ -211,8 +215,10 @@ const valueExclusions: Record<string, string> = {
|
|
|
211
215
|
),
|
|
212
216
|
}
|
|
213
217
|
const repositoryValues = new Set([
|
|
218
|
+
'ticketMigrations',
|
|
214
219
|
'forgeHealthValue',
|
|
215
220
|
'repositoryReadFacts',
|
|
221
|
+
'dispatchUpgrade',
|
|
216
222
|
'dispatcherRunFacts',
|
|
217
223
|
'repositoryAttention',
|
|
218
224
|
'effectiveConfig',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { advancePollingActivity } from './node-polling'
|
|
2
|
+
import { integrationFailed } from './integration-state'
|
|
1
3
|
import {
|
|
2
4
|
advanceCompatibility,
|
|
3
5
|
initialCompatibility,
|
|
@@ -179,7 +181,17 @@ export interface AutoMergeProjection {
|
|
|
179
181
|
|
|
180
182
|
export type ObservationRecord = EventPayload<'observation.recorded'>
|
|
181
183
|
|
|
184
|
+
export interface DrainExecution {
|
|
185
|
+
correlations?: string[]
|
|
186
|
+
relaunch?: EventPayload<'execution.relaunch-requested'>
|
|
187
|
+
authorization?: EventPayload<'execution.drain-authorized'>
|
|
188
|
+
correlation: string
|
|
189
|
+
ended?: true
|
|
190
|
+
suspended?: true
|
|
191
|
+
}
|
|
192
|
+
|
|
182
193
|
export interface BuildState {
|
|
194
|
+
drainingExecutions?: Record<string, DrainExecution>
|
|
183
195
|
compatibility: CompatibilityState
|
|
184
196
|
compatibilityDeferredBoundary?: number
|
|
185
197
|
kind?: 'work' | 'node'
|
|
@@ -190,6 +202,8 @@ export interface BuildState {
|
|
|
190
202
|
nodeOpened?: EventPayload<'node.opened'>
|
|
191
203
|
nodeRestack?: NodeRestackState
|
|
192
204
|
integration?: IntegrationState
|
|
205
|
+
pollingActivity?: Record<string, string>
|
|
206
|
+
nodePolling?: EventPayload<'node.poll-checked'> & { checkedAt: string }
|
|
193
207
|
nodeComparison?: EventPayload<'node.compared'>
|
|
194
208
|
|
|
195
209
|
/**
|
|
@@ -261,11 +275,11 @@ export interface BuildState {
|
|
|
261
275
|
* `spec.revised` that carries `assets` (§6.3). Empty for historical logs. */
|
|
262
276
|
pinnedAssets: PinnedAsset[]
|
|
263
277
|
/** Latest spec artifact rev — `spec.imported`/`spec.authored` set it,
|
|
264
|
-
* `spec.revised` bumps it (§6.3: rev N+1 restarts
|
|
278
|
+
* `spec.revised` bumps it (§6.3: rev N+1 restarts leaves from plan and nodes from collection). */
|
|
265
279
|
specRev?: number
|
|
266
280
|
/** seq of the latest `spec.revised`, else 0 — the restart boundary (§6.3).
|
|
267
|
-
* Rev N+1 restarts
|
|
268
|
-
*
|
|
281
|
+
* Rev N+1 restarts leaves from plan and nodes from collection; earlier
|
|
282
|
+
* approvals and results describe the previous spec revision. Mirrors
|
|
269
283
|
* engine.ts's `restartSeq` (engine.ts:126). */
|
|
270
284
|
restartSince: number
|
|
271
285
|
/** `approved` ≡ the latest `plan-review.verdict` is 'approve' (§10);
|
|
@@ -365,6 +379,8 @@ export function discardInFlight(state: Pick<BuildState, 'discardRequest'>): bool
|
|
|
365
379
|
* trip through `JSON.stringify` — the foundation for incremental advancement
|
|
366
380
|
* and cached state. */
|
|
367
381
|
export interface BuildAcc {
|
|
382
|
+
endedExecutionInstances: Record<string, true>
|
|
383
|
+
drainingExecutions: Record<string, DrainExecution>
|
|
368
384
|
compatibility: CompatibilityState
|
|
369
385
|
compatibilityDeferredBoundary: number
|
|
370
386
|
kind?: 'work' | 'node'
|
|
@@ -375,6 +391,8 @@ export interface BuildAcc {
|
|
|
375
391
|
nodeOpened?: EventPayload<'node.opened'>
|
|
376
392
|
nodeRestack?: NodeRestackState
|
|
377
393
|
integration?: IntegrationState
|
|
394
|
+
pollingActivity?: Record<string, string>
|
|
395
|
+
nodePolling?: EventPayload<'node.poll-checked'> & { checkedAt: string }
|
|
378
396
|
nodeComparison?: EventPayload<'node.compared'>
|
|
379
397
|
|
|
380
398
|
attached: boolean
|
|
@@ -430,10 +448,12 @@ export interface BuildAcc {
|
|
|
430
448
|
}
|
|
431
449
|
|
|
432
450
|
/** Bump when `BuildAcc`'s shape or the fold's semantics change. */
|
|
433
|
-
export const BUILD_REDUCER_VERSION =
|
|
451
|
+
export const BUILD_REDUCER_VERSION = 21
|
|
434
452
|
|
|
435
453
|
function initialBuildAcc(): BuildAcc {
|
|
436
454
|
return {
|
|
455
|
+
endedExecutionInstances: {},
|
|
456
|
+
drainingExecutions: {},
|
|
437
457
|
compatibility: initialCompatibility(),
|
|
438
458
|
compatibilityDeferredBoundary: 0,
|
|
439
459
|
attached: false,
|
|
@@ -479,9 +499,47 @@ function initialBuildAcc(): BuildAcc {
|
|
|
479
499
|
function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
480
500
|
advanceCompatibility(acc.compatibility, events)
|
|
481
501
|
events = projectEvents(events)
|
|
482
|
-
for (const event of events)
|
|
502
|
+
for (const event of events) {
|
|
483
503
|
if (event.type === 'build.compatibility-deferred')
|
|
484
504
|
acc.compatibilityDeferredBoundary = event.payload.boundary
|
|
505
|
+
if (event.type === 'execution.drain-authorized') {
|
|
506
|
+
const previous = acc.drainingExecutions[event.payload.instance]
|
|
507
|
+
if (
|
|
508
|
+
previous?.correlation === event.payload.correlation ||
|
|
509
|
+
previous?.correlations?.includes(event.payload.correlation)
|
|
510
|
+
)
|
|
511
|
+
continue
|
|
512
|
+
acc.drainingExecutions[event.payload.instance] = {
|
|
513
|
+
...previous,
|
|
514
|
+
correlations: [
|
|
515
|
+
...(previous?.correlations ?? []),
|
|
516
|
+
...(previous ? [previous.correlation] : []),
|
|
517
|
+
],
|
|
518
|
+
correlation: event.payload.correlation,
|
|
519
|
+
...(acc.endedExecutionInstances[event.payload.instance]
|
|
520
|
+
? { ended: true as const }
|
|
521
|
+
: { authorization: event.payload }),
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (event.type === 'execution.relaunch-requested') {
|
|
525
|
+
const entry = acc.drainingExecutions[event.payload.instance]
|
|
526
|
+
if (entry?.authorization?.correlation === event.payload.correlation && !entry.ended)
|
|
527
|
+
entry.relaunch = event.payload
|
|
528
|
+
}
|
|
529
|
+
if (event.type === 'session.suspended' && event.payload.cause === 'shutdown')
|
|
530
|
+
for (const entry of Object.values(acc.drainingExecutions))
|
|
531
|
+
if (entry.authorization && !entry.ended) entry.suspended = true
|
|
532
|
+
if (event.type === 'execution.ended') acc.endedExecutionInstances[event.payload.instance] = true
|
|
533
|
+
if (event.type === 'execution.ended' && acc.drainingExecutions[event.payload.instance]) {
|
|
534
|
+
const entry = acc.drainingExecutions[event.payload.instance]!
|
|
535
|
+
entry.ended = true
|
|
536
|
+
delete entry.authorization
|
|
537
|
+
}
|
|
538
|
+
if (event.type === 'execution.drain-settled') {
|
|
539
|
+
const entry = acc.drainingExecutions[event.payload.instance]
|
|
540
|
+
if (entry?.correlation === event.payload.correlation) delete entry.authorization
|
|
541
|
+
}
|
|
542
|
+
}
|
|
485
543
|
let attached = acc.attached
|
|
486
544
|
let pausedFlag = acc.pausedFlag
|
|
487
545
|
let terminal = acc.terminal
|
|
@@ -543,6 +601,8 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
543
601
|
|
|
544
602
|
let lastEvent = acc.lastEvent
|
|
545
603
|
for (const event of events) {
|
|
604
|
+
acc.pollingActivity ??= {}
|
|
605
|
+
advancePollingActivity(acc.pollingActivity, event)
|
|
546
606
|
acc.landing ??= {}
|
|
547
607
|
if (event.type === 'build.janitor-attempt-failed')
|
|
548
608
|
acc.janitor = {
|
|
@@ -580,6 +640,9 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
580
640
|
case 'node.opened':
|
|
581
641
|
acc.nodeOpened = event.payload
|
|
582
642
|
break
|
|
643
|
+
case 'node.poll-checked':
|
|
644
|
+
acc.nodePolling = { ...event.payload, checkedAt: event.ts }
|
|
645
|
+
break
|
|
583
646
|
case 'node.compared':
|
|
584
647
|
acc.nodeComparison = event.payload
|
|
585
648
|
break
|
|
@@ -738,7 +801,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
738
801
|
case 'spec.revised':
|
|
739
802
|
specRev = event.payload.artifact.rev
|
|
740
803
|
if (event.payload.assets !== undefined) pinnedAssets = event.payload.assets
|
|
741
|
-
// §6.3: rev N+1 restarts
|
|
804
|
+
// §6.3: rev N+1 restarts leaves from plan and nodes from collection. The restart boundary
|
|
742
805
|
// invalidates every approval and result at or before it, so it is also
|
|
743
806
|
// a verify cycle boundary. Finalize post-steps remain in full-log
|
|
744
807
|
// history; consumers use this boundary to select the current spec,
|
|
@@ -1146,14 +1209,7 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1146
1209
|
terminal ??
|
|
1147
1210
|
(pausedFlag
|
|
1148
1211
|
? 'paused'
|
|
1149
|
-
: acc.openEscalations.length > 0 ||
|
|
1150
|
-
(acc.integration?.cycle &&
|
|
1151
|
-
acc.nodeComparison?.headSha === acc.integration.cycle.head &&
|
|
1152
|
-
acc.nodeComparison?.parentSha === acc.integration.cycle.parent &&
|
|
1153
|
-
acc.verify.results.some(
|
|
1154
|
-
(result) =>
|
|
1155
|
-
result.restackId === acc.integration!.cycle!.id && result.outcome === 'fail',
|
|
1156
|
-
))
|
|
1212
|
+
: acc.openEscalations.length > 0 || integrationFailed(acc)
|
|
1157
1213
|
? 'blocked'
|
|
1158
1214
|
: acc.kind === 'node' && acc.nodeOpened !== undefined
|
|
1159
1215
|
? 'collecting'
|
|
@@ -1171,6 +1227,8 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1171
1227
|
mergedSha: acc.mergedSha,
|
|
1172
1228
|
nodeOpened: acc.nodeOpened,
|
|
1173
1229
|
integration: acc.integration,
|
|
1230
|
+
pollingActivity: acc.pollingActivity,
|
|
1231
|
+
nodePolling: acc.nodePolling,
|
|
1174
1232
|
nodeComparison: acc.nodeComparison,
|
|
1175
1233
|
nodeRestack: acc.nodeRestack,
|
|
1176
1234
|
status,
|
|
@@ -1193,6 +1251,9 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1193
1251
|
lastSeq: Math.max(lastEvent?.seq ?? 0, acc.compatibility.lastSeq),
|
|
1194
1252
|
compatibility: structuredClone(acc.compatibility),
|
|
1195
1253
|
compatibilityDeferredBoundary: acc.compatibilityDeferredBoundary,
|
|
1254
|
+
...(Object.keys(acc.drainingExecutions).length
|
|
1255
|
+
? { drainingExecutions: structuredClone(acc.drainingExecutions) }
|
|
1256
|
+
: {}),
|
|
1196
1257
|
pinnedAssets: acc.pinnedAssets,
|
|
1197
1258
|
specRev: acc.specRev,
|
|
1198
1259
|
restartSince: acc.restartSince,
|
|
@@ -48,7 +48,7 @@ export interface BuildDelegationFacts {
|
|
|
48
48
|
export interface HarvestDelegationFacts {
|
|
49
49
|
lastSeq: number
|
|
50
50
|
runs: Record<string, true>
|
|
51
|
-
sessions: Record<string, Record<string, SessionFacts>>
|
|
51
|
+
sessions: Record<string, Record<string, SessionFacts & { suspended?: true }>>
|
|
52
52
|
authorizations: Record<string, Record<string, { seq: number; leaseHolder: string }>>
|
|
53
53
|
releases: Record<string, string[]>
|
|
54
54
|
endings: Record<string, EndingFact[]>
|
|
@@ -82,7 +82,7 @@ export const harvestDelegationReducer = defineReducer<
|
|
|
82
82
|
RepositoryEvent,
|
|
83
83
|
HarvestDelegationFacts
|
|
84
84
|
>({
|
|
85
|
-
version:
|
|
85
|
+
version: 2,
|
|
86
86
|
initial: () => ({
|
|
87
87
|
lastSeq: 0,
|
|
88
88
|
runs: {},
|
|
@@ -104,7 +104,11 @@ export const harvestDelegationReducer = defineReducer<
|
|
|
104
104
|
leaseHolder: event.payload.leaseHolder,
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
if (
|
|
107
|
+
if (
|
|
108
|
+
event.type === 'harvest.session.started' ||
|
|
109
|
+
event.type === 'harvest.session.ended' ||
|
|
110
|
+
event.type === 'harvest.session.suspended'
|
|
111
|
+
) {
|
|
108
112
|
const runKey = delegationFactKey(event.payload.run)
|
|
109
113
|
acc.sessions[runKey] ??= {}
|
|
110
114
|
const run = acc.sessions[runKey]!
|
|
@@ -112,7 +116,10 @@ export const harvestDelegationReducer = defineReducer<
|
|
|
112
116
|
run[sessionKey] ??= { starts: [], endings: [] }
|
|
113
117
|
const session = run[sessionKey]!
|
|
114
118
|
if (event.type === 'harvest.session.started') session.starts.push(event.seq)
|
|
115
|
-
else
|
|
119
|
+
else {
|
|
120
|
+
session.endings.push({ seq: event.seq, at: event.ts })
|
|
121
|
+
if (event.type === 'harvest.session.suspended') session.suspended = true
|
|
122
|
+
}
|
|
116
123
|
}
|
|
117
124
|
if (event.type === 'harvest.execution.released' || event.type === 'harvest.execution.ended') {
|
|
118
125
|
const key = delegationFactKey(event.payload.execution)
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { readRepositoryFacts } from '../store/reduced-reads'
|
|
2
|
+
import type { TicketRef } from '../ontology'
|
|
3
|
+
import type { Actor } from '../events/envelope'
|
|
4
|
+
import type { RepositoryEvent, RepositoryEventPayload } from '../events/repository'
|
|
5
|
+
import { validateRepositoryEventWrite } from '../events/repository'
|
|
6
|
+
import type { BuildStore } from '../store/types'
|
|
7
|
+
import { defineReducer } from './incremental'
|
|
8
|
+
|
|
9
|
+
type Migration = RepositoryEventPayload<'tickets.migration-recorded'>
|
|
10
|
+
export interface TicketMigrations {
|
|
11
|
+
migrations: Migration[]
|
|
12
|
+
}
|
|
13
|
+
const key = (ref: TicketRef) => JSON.stringify([ref.source, ref.id])
|
|
14
|
+
function stable(value: Migration): string {
|
|
15
|
+
return JSON.stringify([value.from, value.to, Object.entries(value.mapping).sort()])
|
|
16
|
+
}
|
|
17
|
+
function add(state: TicketMigrations, migration: Migration) {
|
|
18
|
+
const previous = state.migrations.find((m) => m.identity === migration.identity)
|
|
19
|
+
if (previous) {
|
|
20
|
+
if (stable(previous) !== stable(migration))
|
|
21
|
+
throw new Error(`conflicting ticket migration ${migration.identity}`)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
for (const old of state.migrations)
|
|
25
|
+
if (old.from !== old.to && migration.from !== migration.to && old.from === migration.from)
|
|
26
|
+
for (const [id, next] of Object.entries(migration.mapping))
|
|
27
|
+
if (Object.hasOwn(old.mapping, id) && (old.to !== migration.to || old.mapping[id] !== next))
|
|
28
|
+
throw new Error(`conflicting ticket migration for ${migration.from}:${id}`)
|
|
29
|
+
state.migrations.push(migration)
|
|
30
|
+
// Reject cycles even before any build consults the evidence.
|
|
31
|
+
for (const m of state.migrations)
|
|
32
|
+
for (const id of Object.keys(m.mapping)) walk(state, { source: m.from, id })
|
|
33
|
+
}
|
|
34
|
+
function walk(
|
|
35
|
+
state: TicketMigrations,
|
|
36
|
+
original: TicketRef,
|
|
37
|
+
destination?: string,
|
|
38
|
+
build = 'unknown',
|
|
39
|
+
): TicketRef {
|
|
40
|
+
let current = original
|
|
41
|
+
const visited = new Set<string>()
|
|
42
|
+
while (current.source !== destination) {
|
|
43
|
+
if (visited.has(key(current)))
|
|
44
|
+
throw new Error(`ticket migration cycle at ${current.source}:${current.id}`)
|
|
45
|
+
visited.add(key(current))
|
|
46
|
+
const routes = state.migrations.filter((m) => m.from === current.source && m.from !== m.to)
|
|
47
|
+
const route = routes.find((m) => Object.hasOwn(m.mapping, current.id))
|
|
48
|
+
if (!route) {
|
|
49
|
+
if (destination === undefined) return current
|
|
50
|
+
throw new Error(
|
|
51
|
+
`build ${build} ticket ${original.source}:${original.id}: ${routes.length ? 'recorded migration does not cover id' : 'configured ticket source differs from the frozen node source'}; record continuity with ab ticket migration record <export-dir>`,
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
if (route.to === current.source && route.mapping[current.id] === current.id) return current
|
|
55
|
+
current = { ...current, source: route.to, id: route.mapping[current.id]! }
|
|
56
|
+
}
|
|
57
|
+
return current
|
|
58
|
+
}
|
|
59
|
+
export const ticketMigrationsReducer = defineReducer<
|
|
60
|
+
TicketMigrations,
|
|
61
|
+
RepositoryEvent,
|
|
62
|
+
TicketMigrations
|
|
63
|
+
>({
|
|
64
|
+
version: 1,
|
|
65
|
+
initial: () => ({ migrations: [] }),
|
|
66
|
+
fold(acc, events) {
|
|
67
|
+
for (const event of events)
|
|
68
|
+
if (event.type === 'tickets.migration-recorded') add(acc, event.payload)
|
|
69
|
+
},
|
|
70
|
+
finish: (acc) => acc,
|
|
71
|
+
})
|
|
72
|
+
export function resolveTicketRef(
|
|
73
|
+
state: TicketMigrations,
|
|
74
|
+
ref: TicketRef,
|
|
75
|
+
destination: string,
|
|
76
|
+
build?: string,
|
|
77
|
+
): TicketRef {
|
|
78
|
+
// Preserve the pre-existing database/hosted adapter compatibility.
|
|
79
|
+
const hosted = destination === 'hosted' || destination === 'database'
|
|
80
|
+
const compatible = ref.source === 'database' && hosted ? { ...ref, source: 'hosted' } : ref
|
|
81
|
+
const current = walk(
|
|
82
|
+
state,
|
|
83
|
+
compatible,
|
|
84
|
+
destination === 'database' ? 'hosted' : destination,
|
|
85
|
+
build,
|
|
86
|
+
)
|
|
87
|
+
return destination === 'database' ? { ...current, source: 'database' } : current
|
|
88
|
+
}
|
|
89
|
+
export function migrationIdentity(state: TicketMigrations, destination: string) {
|
|
90
|
+
return (ref: TicketRef, build?: string): string => {
|
|
91
|
+
try {
|
|
92
|
+
return key(resolveTicketRef(state, ref, destination, build))
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (state.migrations.some((m) => m.from === ref.source && m.from !== m.to)) throw error
|
|
95
|
+
return key(ref)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Comparison only for all-history scans. Uncovered history remains in its
|
|
100
|
+
* original namespace and cannot alias a current-source ticket. Live claims,
|
|
101
|
+
* frozen membership and current-ticket operations must use strict resolution. */
|
|
102
|
+
export function historicalTicketIdentity(state: TicketMigrations, destination: string) {
|
|
103
|
+
const identity = migrationIdentity(state, destination)
|
|
104
|
+
return (ref: TicketRef, build?: string): string => {
|
|
105
|
+
try {
|
|
106
|
+
return identity(ref, build)
|
|
107
|
+
} catch {
|
|
108
|
+
return key(ref)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export async function readTicketMigrations(
|
|
113
|
+
store: BuildStore,
|
|
114
|
+
repo: string,
|
|
115
|
+
): Promise<TicketMigrations> {
|
|
116
|
+
return (await readRepositoryFacts(store, repo)).value.ticketMigrations
|
|
117
|
+
}
|
|
118
|
+
export async function currentTicketRef(
|
|
119
|
+
store: BuildStore,
|
|
120
|
+
repo: string,
|
|
121
|
+
destination: string,
|
|
122
|
+
ref: TicketRef,
|
|
123
|
+
build?: string,
|
|
124
|
+
) {
|
|
125
|
+
return resolveTicketRef(await readTicketMigrations(store, repo), ref, destination, build)
|
|
126
|
+
}
|
|
127
|
+
export async function recordTicketMigration(
|
|
128
|
+
store: BuildStore,
|
|
129
|
+
repo: string,
|
|
130
|
+
actor: Actor,
|
|
131
|
+
migration: Migration,
|
|
132
|
+
) {
|
|
133
|
+
validateRepositoryEventWrite({ actor, type: 'tickets.migration-recorded', payload: migration })
|
|
134
|
+
const state = structuredClone(await readTicketMigrations(store, repo))
|
|
135
|
+
const repeated = state.migrations.some((m) => m.identity === migration.identity)
|
|
136
|
+
add(state, migration)
|
|
137
|
+
if (!repeated)
|
|
138
|
+
await store.appendRepo(repo, { actor, type: 'tickets.migration-recorded', payload: migration })
|
|
139
|
+
}
|
|
@@ -26,3 +26,10 @@ export type {
|
|
|
26
26
|
|
|
27
27
|
export type { IntegrationDetail, IntegrationChild } from '../cli/dashboard/integration-detail'
|
|
28
28
|
export { displayText } from '../cli/dashboard/cells'
|
|
29
|
+
|
|
30
|
+
export { formatHandoff } from '../cli/dashboard/handoff'
|
|
31
|
+
export type { DashboardHandoff } from '../cli/dashboard/handoff'
|
|
32
|
+
|
|
33
|
+
export { formatRollback } from '../cli/dashboard/rollback'
|
|
34
|
+
export type { DashboardRollback } from '../cli/dashboard/rollback'
|
|
35
|
+
export { handPushedLabel, handPushedText } from '../cli/dashboard/hand-pushed'
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { migrationIdentity } from '../kernel/ticket-migrations'
|
|
2
|
+
import { enrichDrainingRow, projectHandoffs } from '../cli/dashboard/handoff'
|
|
1
3
|
import { enrichIntegrationRows } from '../cli/dashboard/integration-row'
|
|
2
4
|
import { dispatchCapacity, type CapacityBuild } from '../kernel/dispatch-capacity'
|
|
3
5
|
import { forgeReadinessWarnings } from '../kernel/dispatch-status'
|
|
@@ -277,7 +279,7 @@ export async function getOperatorBuild(opts: {
|
|
|
277
279
|
const record = await requireBuild(opts.store, opts.repo, opts.slug)
|
|
278
280
|
const facts = (await readBuildFacts(opts.store, opts.slug)).value
|
|
279
281
|
const state = facts.state
|
|
280
|
-
const { config } = await effectiveConfig(opts.store, opts.repo)
|
|
282
|
+
const { config, repositoryEvents } = await effectiveConfig(opts.store, opts.repo)
|
|
281
283
|
let dashboardRow: DashboardBuild | null = null
|
|
282
284
|
if (!projectsNoDashboardRow(state)) {
|
|
283
285
|
const pinned = await readPinnedConfig(opts.store, opts.slug, config)
|
|
@@ -285,7 +287,10 @@ export async function getOperatorBuild(opts: {
|
|
|
285
287
|
// Implied by the gate; kept as an explicit check (not an assertion) so the
|
|
286
288
|
// code never lies if `effectiveStatus` and `projectBuild` ever drift.
|
|
287
289
|
if (row !== null) {
|
|
288
|
-
dashboardRow =
|
|
290
|
+
dashboardRow = enrichDrainingRow(
|
|
291
|
+
decorateWithPinnedMeta(row, pinned),
|
|
292
|
+
projectHandoffs(repositoryEvents.upgrades).draining,
|
|
293
|
+
)
|
|
289
294
|
if (row.integrationDetail) {
|
|
290
295
|
const records = await opts.store.listBuildsForRepo(opts.repo)
|
|
291
296
|
const digests = await readBuildDigests(opts.store, opts.repo)
|
|
@@ -428,7 +433,12 @@ async function dashboardFromView(
|
|
|
428
433
|
...forgeReadinessWarnings(status),
|
|
429
434
|
...(status.warningNotice !== undefined ? [status.warningNotice] : []),
|
|
430
435
|
]
|
|
431
|
-
const capacityProjection = dispatchCapacity(
|
|
436
|
+
const capacityProjection = dispatchCapacity(
|
|
437
|
+
capacityBuilds,
|
|
438
|
+
config.capacity,
|
|
439
|
+
opts.clock(),
|
|
440
|
+
migrationIdentity(repositoryEvents.ticketMigrations, config.tickets.source),
|
|
441
|
+
)
|
|
432
442
|
const model = buildDashboardFromProjected(
|
|
433
443
|
enrichIntegrationRows(projected, records),
|
|
434
444
|
{
|
|
@@ -625,7 +625,7 @@ export const TOOLS: readonly ToolEntry[] = [
|
|
|
625
625
|
),
|
|
626
626
|
defineTool(
|
|
627
627
|
'builds.answer',
|
|
628
|
-
'Answer a blocked build’s open escalations: guidance text, a bare retry, a dismissal of the cited findings, a review-round ceiling, or a spec revision (destructive — replaces the spec and
|
|
628
|
+
'Answer a blocked build’s open escalations: guidance text, a bare retry, a dismissal of the cited findings, a review-round ceiling, or a spec revision (destructive — replaces the spec). Leaves require an escalation and restart from plan; idle collecting or verification-failed nodes may revise without an escalation and recollect for verification.',
|
|
629
629
|
buildsAnswerInput,
|
|
630
630
|
'The controlBuild answer result: {kind: "answered", slug, count, resolution, resumed, …} describing how many escalations were answered and with what.',
|
|
631
631
|
async (raw, ctx) => {
|