@defrex/autobuild 1.0.0-beta.1 → 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/SPEC.md +285 -53
- package/bin/ab-build-runner.ts +10 -8
- package/docs/architecture.md +173 -23
- package/docs/configuration.md +35 -4
- 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 +21 -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/render.ts +106 -5
- package/packages/core/src/cli/dashboard/transcript.ts +2 -1
- package/packages/core/src/cli/dispatch-frontend.ts +6 -0
- package/packages/core/src/cli/dispatch.ts +44 -14
- package/packages/core/src/cli/help.ts +16 -1
- 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/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 +145 -20
- 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 +17 -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 +137 -24
- 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 +47 -4
- package/skills/guide/references/remote-store-protocol.md +11 -0
- package/skills/guide/references/restacking.md +42 -7
- package/skills/guide/references/setup.md +21 -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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integrationBarCells } from './integration-row'
|
|
2
|
+
import { capacityExplanation } from '../../kernel/dispatch-capacity'
|
|
1
3
|
import { treeVocabulary, consentQueue } from './tree'
|
|
2
4
|
/**
|
|
3
5
|
* The dashboard's other pure half: model → `string[]`. No terminal, no state,
|
|
@@ -29,7 +31,7 @@ import type {
|
|
|
29
31
|
PipelineStep,
|
|
30
32
|
} from './model'
|
|
31
33
|
import { landingPolicyDisplay } from './landing-display'
|
|
32
|
-
import { dashboardBuildControl } from './actions'
|
|
34
|
+
import { dashboardBuildControl, pauseResumeHelp } from './actions'
|
|
33
35
|
import type { DashboardSession } from './detail'
|
|
34
36
|
import type { TranscriptPresentation, TranscriptTurn } from './transcript'
|
|
35
37
|
import { projectSessionDocument, projectSessionParts } from './session-view'
|
|
@@ -371,6 +373,34 @@ function renderBuild(
|
|
|
371
373
|
// The slug is the sole flexible segment; narrow frames truncate it before
|
|
372
374
|
// the right-pinned lifecycle status.
|
|
373
375
|
const lines = [rightPinnedLine(leftPrefix, paint(build.slug, 'bold', color), rightStr, width)]
|
|
376
|
+
if (build.integrationRow) {
|
|
377
|
+
const row = build.integrationRow
|
|
378
|
+
const { bar, counts } = integrationProgress(row, color)
|
|
379
|
+
lines.push(
|
|
380
|
+
...packLines(
|
|
381
|
+
[
|
|
382
|
+
paint(`integration → ${row.destination}`, 'bold', color),
|
|
383
|
+
bar,
|
|
384
|
+
...(row.parentDistance ? [paint(row.parentDistance, 'dim', color)] : []),
|
|
385
|
+
...counts,
|
|
386
|
+
...(row.verified ? [paint('· verified', 'green', color)] : []),
|
|
387
|
+
],
|
|
388
|
+
width,
|
|
389
|
+
' ',
|
|
390
|
+
),
|
|
391
|
+
)
|
|
392
|
+
lines.push(
|
|
393
|
+
...packLines(
|
|
394
|
+
row.steps.map((s) => renderStep(s, color, now)),
|
|
395
|
+
width,
|
|
396
|
+
' ',
|
|
397
|
+
),
|
|
398
|
+
)
|
|
399
|
+
if (row.alert)
|
|
400
|
+
for (const line of wrappedText(row.alert.text, Math.max(1, width - 4), ''))
|
|
401
|
+
lines.push(paint(` ! ${line}`, row.alert.tone, color))
|
|
402
|
+
return lines
|
|
403
|
+
}
|
|
374
404
|
if (build.target)
|
|
375
405
|
lines.push(
|
|
376
406
|
truncate(
|
|
@@ -631,6 +661,9 @@ function sessionLines(session: DashboardSession, selected: boolean, opts: Render
|
|
|
631
661
|
`runtime ${session.runtime}`,
|
|
632
662
|
...(session.model !== undefined ? [`model ${session.model}`] : []),
|
|
633
663
|
session.status,
|
|
664
|
+
...(session.cause ? [`cause ${session.cause}`] : []),
|
|
665
|
+
...(session.fallbackReason ? [`fresh session: ${session.fallbackReason}`] : []),
|
|
666
|
+
...(session.predecessor ? [`continued from ${session.predecessor}`] : []),
|
|
634
667
|
...(session.stream !== undefined ? [`stream ${session.stream} (${session.streamStatus})`] : []),
|
|
635
668
|
...(session.reclaimedBy !== undefined
|
|
636
669
|
? [
|
|
@@ -667,6 +700,27 @@ interface DetailBodyLayout {
|
|
|
667
700
|
|
|
668
701
|
export type DetailFocusTarget = 'session' | 'message'
|
|
669
702
|
|
|
703
|
+
function integrationProgress(row: NonNullable<DashboardBuild['integrationRow']>, color: boolean) {
|
|
704
|
+
const children = row.children
|
|
705
|
+
let bar = paint('┄'.repeat(22), 'dim', color)
|
|
706
|
+
let counts = [paint('children unknown', 'dim', color)]
|
|
707
|
+
if (children.known) {
|
|
708
|
+
const cells = integrationBarCells(children.landed, children.building, children.queued)
|
|
709
|
+
bar =
|
|
710
|
+
paint('━'.repeat(cells[0]!), 'green', color) +
|
|
711
|
+
paint('━'.repeat(cells[1]!), 'cyan', color) +
|
|
712
|
+
paint('─'.repeat(children.total ? cells[2]! : 22), 'dim', color)
|
|
713
|
+
counts = children.total
|
|
714
|
+
? [
|
|
715
|
+
paint(`${children.landed}/${children.total} landed`, 'green', color),
|
|
716
|
+
...(children.building ? [paint(`· ${children.building} building`, 'cyan', color)] : []),
|
|
717
|
+
...(children.queued ? [paint(`· ${children.queued} queued`, 'dim', color)] : []),
|
|
718
|
+
]
|
|
719
|
+
: [paint('no children yet', 'dim', color)]
|
|
720
|
+
}
|
|
721
|
+
return { bar, counts }
|
|
722
|
+
}
|
|
723
|
+
|
|
670
724
|
function detailBody(
|
|
671
725
|
build: DashboardBuild,
|
|
672
726
|
view: Extract<NonNullable<DashboardModel['view']>, { kind: 'detail' }>,
|
|
@@ -674,12 +728,17 @@ function detailBody(
|
|
|
674
728
|
): DetailBodyLayout {
|
|
675
729
|
const { color, width } = opts
|
|
676
730
|
const body: string[] = []
|
|
731
|
+
if (dashboardBuildControl(build.status)) body.push(...wrappedText(pauseResumeHelp, width, ' '))
|
|
677
732
|
if (build.ticketId !== undefined) body.push(` ticket ${displayText(build.ticketId)}`)
|
|
678
|
-
if (build.target)
|
|
733
|
+
if (build.target && !build.integrationDetail)
|
|
679
734
|
body.push(
|
|
680
735
|
` ${build.kind ?? treeVocabulary.work} · ${treeVocabulary.target} ${build.target}${build.integration ? ` · ${build.integration}` : ''}`,
|
|
681
736
|
)
|
|
682
|
-
if (
|
|
737
|
+
if (
|
|
738
|
+
!build.integrationDetail &&
|
|
739
|
+
build.tree &&
|
|
740
|
+
(build.kind === 'integration' || build.tree.consent)
|
|
741
|
+
) {
|
|
683
742
|
const tree = build.tree
|
|
684
743
|
body.push(
|
|
685
744
|
` ${treeVocabulary.branch} ${tree.branch ?? 'unknown'} · ${treeVocabulary.restack} ${tree.restack}`,
|
|
@@ -700,6 +759,48 @@ function detailBody(
|
|
|
700
759
|
` ${treeVocabulary.landing} ${tree.reason ?? (tree.ready ? treeVocabulary.readyToLand : treeVocabulary.notReady)}`,
|
|
701
760
|
)
|
|
702
761
|
}
|
|
762
|
+
if (build.integrationDetail && build.integrationRow) {
|
|
763
|
+
const detail = build.integrationDetail
|
|
764
|
+
const field = (label: string, text: string) =>
|
|
765
|
+
body.push(...wrapDisplay(`${label} ${text}`, width, ' '))
|
|
766
|
+
field('Integration', detail.destination)
|
|
767
|
+
const progress = integrationProgress(build.integrationRow, color)
|
|
768
|
+
body.push(...packLines(['Progress', progress.bar, ...progress.counts], width, ' '))
|
|
769
|
+
field('Branch', `${detail.branch} · restack ${detail.restack}`)
|
|
770
|
+
if (detail.parentDistance) field('Parent', detail.parentDistance.replace(/^parent /, ''))
|
|
771
|
+
for (const path of detail.conflictFiles ?? []) field('Conflict', path)
|
|
772
|
+
body.push(
|
|
773
|
+
...packLines(
|
|
774
|
+
['Steps', ...build.integrationRow.steps.map((s) => renderStep(s, color, opts.now))],
|
|
775
|
+
width,
|
|
776
|
+
' ',
|
|
777
|
+
),
|
|
778
|
+
)
|
|
779
|
+
const open = detail.children.filter((c) => !c.landed).length
|
|
780
|
+
body.push(
|
|
781
|
+
'',
|
|
782
|
+
paint(
|
|
783
|
+
`Children ${open} open · ${detail.children.length - open} landed${detail.membershipKnown ? '' : ' · membership unknown'}`,
|
|
784
|
+
'bold',
|
|
785
|
+
color,
|
|
786
|
+
),
|
|
787
|
+
)
|
|
788
|
+
for (const child of detail.children) {
|
|
789
|
+
const id = displayText(child.id)
|
|
790
|
+
const state = displayText(child.state)
|
|
791
|
+
const tone = child.landed ? 'green' : state === 'queued' ? 'dim' : 'cyan'
|
|
792
|
+
const prefix = ` ${paint(child.landed ? '[x]' : state === 'queued' ? '[ ]' : '[>]', tone, color)} ${paint(id, 'blue', color)} `
|
|
793
|
+
const right = paint(state, tone, color)
|
|
794
|
+
if (visibleLength(prefix) + visibleLength(right) + 2 <= width)
|
|
795
|
+
body.push(rightPinnedLine(prefix, displayText(child.title), right, width))
|
|
796
|
+
else body.push(...packLines([id, right], width, ' '))
|
|
797
|
+
}
|
|
798
|
+
for (const diagnostic of detail.diagnostics) field('Membership', diagnostic)
|
|
799
|
+
body.push('')
|
|
800
|
+
field('Verification', detail.verification)
|
|
801
|
+
for (const result of detail.verifySteps) field(result.step, result.outcome)
|
|
802
|
+
field('Landing', detail.landing)
|
|
803
|
+
}
|
|
703
804
|
if (build.kind !== 'integration') body.push(` landing ${landingPolicyDisplay(build.landing)}`)
|
|
704
805
|
const ceiling = reviewRoundCeilingText(build)
|
|
705
806
|
if (ceiling !== undefined) body.push(` ${ceiling}`)
|
|
@@ -723,7 +824,7 @@ function detailBody(
|
|
|
723
824
|
body.push(...wrappedText(build.abortProgress, width, ' '))
|
|
724
825
|
} else if (build.dispatch !== undefined) {
|
|
725
826
|
body.push('', paint('Dispatch', 'bold', color), ...wrappedText(build.dispatch, width, ' '))
|
|
726
|
-
} else {
|
|
827
|
+
} else if (!build.integrationDetail) {
|
|
727
828
|
body.push('', paint('Pipeline', 'bold', color))
|
|
728
829
|
body.push(...build.steps.map((item) => ` ${detailStep(item, opts)}`))
|
|
729
830
|
}
|
|
@@ -1464,7 +1565,7 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1464
1565
|
paint('Autobuild', 'bold', color),
|
|
1465
1566
|
displayText(basename(model.repo)),
|
|
1466
1567
|
paint(
|
|
1467
|
-
`queue ${model.queued} | active ${model.active.current}/${model.active.limit} | ` +
|
|
1568
|
+
`queue ${model.queued} | active ${model.active.current}/${model.active.limit}${capacityExplanation(model.capacity)} | ` +
|
|
1468
1569
|
`observations ${model.observations.current}/${model.observations.limit}`,
|
|
1469
1570
|
'dim',
|
|
1470
1571
|
color,
|
|
@@ -95,7 +95,8 @@ export function parseTranscript(content: string): TranscriptPresentation {
|
|
|
95
95
|
"Producer boundary record: this session was kept live for continuation; only this round's final turn was deposited.",
|
|
96
96
|
turns: [
|
|
97
97
|
{
|
|
98
|
-
prompt:
|
|
98
|
+
prompt:
|
|
99
|
+
typeof boundary.prompt === 'string' ? boundary.prompt : '(producer round invocation)',
|
|
99
100
|
text: boundary.text,
|
|
100
101
|
...(usage(boundary.usage) !== undefined ? { usage: usage(boundary.usage)! } : {}),
|
|
101
102
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dispatchCapacity } from '../kernel/dispatch-capacity'
|
|
1
2
|
import { forgeReadinessWarnings } from '../kernel/dispatch-status'
|
|
2
3
|
import { RepositoryPollCache } from './dashboard/repository-poll'
|
|
3
4
|
import {
|
|
@@ -390,6 +391,11 @@ export class DispatchFrontend {
|
|
|
390
391
|
(state) => state.kind !== 'node' && state.status !== 'done' && state.status !== 'aborted',
|
|
391
392
|
).length,
|
|
392
393
|
capacity: config.capacity,
|
|
394
|
+
capacityProjection: dispatchCapacity(
|
|
395
|
+
snapshot.capacityBuilds ?? [],
|
|
396
|
+
config.capacity,
|
|
397
|
+
this.clock(),
|
|
398
|
+
),
|
|
393
399
|
observationCount: this.observationCount,
|
|
394
400
|
observationLimit: config.policy.harvestThreshold,
|
|
395
401
|
...(status.availableUpgrade !== undefined
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { formatDispatcherError } from '../runtime-identity'
|
|
2
|
+
|
|
3
|
+
import { isDeepStrictEqual } from 'node:util'
|
|
4
|
+
import { guardForge } from '../kernel/guarded-forge'
|
|
5
|
+
import { dispatchCapacity } from '../kernel/dispatch-capacity'
|
|
1
6
|
import { openTicketSource } from './ticket'
|
|
2
7
|
import {
|
|
3
8
|
inspectForgeReadiness,
|
|
@@ -824,6 +829,12 @@ class DispatchLoop {
|
|
|
824
829
|
repo: this.repoIdentity,
|
|
825
830
|
resident: opts.once !== true,
|
|
826
831
|
})
|
|
832
|
+
wiring.forge = guardForge(wiring.forge, {
|
|
833
|
+
store: this.repoView,
|
|
834
|
+
repo: this.repoIdentity,
|
|
835
|
+
name: config.forge,
|
|
836
|
+
now: wiring.clock,
|
|
837
|
+
})
|
|
827
838
|
this.dispatcher = new Dispatcher({
|
|
828
839
|
store: this.repoView,
|
|
829
840
|
tickets: wiring.tickets,
|
|
@@ -2930,7 +2941,14 @@ class DispatchLoop {
|
|
|
2930
2941
|
events: RepositoryEventWrite[],
|
|
2931
2942
|
): Promise<RepoTickFinish | null> {
|
|
2932
2943
|
try {
|
|
2933
|
-
|
|
2944
|
+
// Closing a durable boundary must not depend on a subsequent view read.
|
|
2945
|
+
// The next operational tick refreshes the view before any decisions.
|
|
2946
|
+
return await this.wiring.store.finishRepoTick(
|
|
2947
|
+
this.repoIdentity,
|
|
2948
|
+
this.runId,
|
|
2949
|
+
completion,
|
|
2950
|
+
events,
|
|
2951
|
+
)
|
|
2934
2952
|
} catch (error) {
|
|
2935
2953
|
const observation = (await this.wiring.store.getRepo(this.repoIdentity).catch(() => null))
|
|
2936
2954
|
?.tick
|
|
@@ -2947,13 +2965,13 @@ class DispatchLoop {
|
|
|
2947
2965
|
(finished.outcome === 'completed' &&
|
|
2948
2966
|
completion.outcome === 'completed' &&
|
|
2949
2967
|
Object.entries(completion.counters).some(
|
|
2950
|
-
([key, value]) =>
|
|
2968
|
+
([key, value]) =>
|
|
2969
|
+
!isDeepStrictEqual(finished.counters[key as keyof typeof finished.counters], value),
|
|
2951
2970
|
))
|
|
2952
2971
|
)
|
|
2953
2972
|
throw error
|
|
2954
|
-
//
|
|
2955
|
-
//
|
|
2956
|
-
await this.repoView.refresh()
|
|
2973
|
+
// Metadata confirms the exact committed boundary. The next operational
|
|
2974
|
+
// tick refreshes facts before making decisions.
|
|
2957
2975
|
return { observation, events: [] }
|
|
2958
2976
|
}
|
|
2959
2977
|
}
|
|
@@ -2962,20 +2980,27 @@ class DispatchLoop {
|
|
|
2962
2980
|
const failed = {
|
|
2963
2981
|
actor: DISPATCHER,
|
|
2964
2982
|
type: 'dispatcher.tick-failed' as const,
|
|
2965
|
-
payload: { run: this.runId, error:
|
|
2983
|
+
payload: { run: this.runId, error: formatDispatcherError(error) },
|
|
2966
2984
|
}
|
|
2967
2985
|
if (this.tickStartedAt === undefined) {
|
|
2968
|
-
await this.
|
|
2986
|
+
await this.wiring.store.appendRepo(this.repoIdentity, failed)
|
|
2969
2987
|
return
|
|
2970
2988
|
}
|
|
2971
|
-
const result = await this.finishTick(
|
|
2989
|
+
const result = await this.finishTick(
|
|
2972
2990
|
{
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2991
|
+
outcome: 'failed',
|
|
2992
|
+
error: failed.payload.error,
|
|
2993
|
+
forgeRequests: this.dispatcher.lastForgeRequests,
|
|
2976
2994
|
},
|
|
2977
|
-
|
|
2978
|
-
|
|
2995
|
+
[
|
|
2996
|
+
{
|
|
2997
|
+
actor: DISPATCHER,
|
|
2998
|
+
type: 'dispatcher.tick-started',
|
|
2999
|
+
payload: { run: this.runId, startedAt: this.tickStartedAt },
|
|
3000
|
+
},
|
|
3001
|
+
failed,
|
|
3002
|
+
],
|
|
3003
|
+
)
|
|
2979
3004
|
if (result === null) {
|
|
2980
3005
|
this.superseded = true
|
|
2981
3006
|
return
|
|
@@ -3638,6 +3663,11 @@ class DispatchLoop {
|
|
|
3638
3663
|
(state) => state.kind !== 'node' && state.status !== 'done' && state.status !== 'aborted',
|
|
3639
3664
|
).length,
|
|
3640
3665
|
capacity: configSnapshot.config.capacity,
|
|
3666
|
+
capacityProjection: dispatchCapacity(
|
|
3667
|
+
buildSnapshot.capacityBuilds ?? [],
|
|
3668
|
+
configSnapshot.config.capacity,
|
|
3669
|
+
this.wiring.clock(),
|
|
3670
|
+
),
|
|
3641
3671
|
observationCount: this.observationCount,
|
|
3642
3672
|
observationLimit: configSnapshot.config.policy.harvestThreshold,
|
|
3643
3673
|
},
|
|
@@ -4040,7 +4070,7 @@ class DispatchLoop {
|
|
|
4040
4070
|
startup = false
|
|
4041
4071
|
} catch (error) {
|
|
4042
4072
|
if (this.forgePublicationFailed) throw error
|
|
4043
|
-
const message =
|
|
4073
|
+
const message = formatDispatcherError(error)
|
|
4044
4074
|
await this.publishTickFailure(error)
|
|
4045
4075
|
this.warn(`tick failed: ${message}`)
|
|
4046
4076
|
}
|
|
@@ -346,7 +346,7 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
|
|
|
346
346
|
' flushed as soon as it is written.',
|
|
347
347
|
' --store <ref> Override the BuildStore path or URL.',
|
|
348
348
|
'',
|
|
349
|
-
'Default filter — actionable attention only. Builds: escalation.raised, integration.landed,',
|
|
349
|
+
'Default filter — actionable attention only. Builds: escalation.raised, phase.deferral-escalated, integration.landed,',
|
|
350
350
|
'node.item-conflicted, conflicted restack.replayed, derived build.consent-ready and',
|
|
351
351
|
'build.merge-decision (a current actionable merge-gate deferral or unsafe forge outcome).',
|
|
352
352
|
'Consent and held ready landings use only build.consent-ready, once per readiness episode.',
|
|
@@ -504,6 +504,9 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
|
|
|
504
504
|
' ab pause <slug> [--store <ref>]',
|
|
505
505
|
' ab pause --all [--store <ref>] [--json]',
|
|
506
506
|
'',
|
|
507
|
+
'Pause immediately suspends a live agent session after its bounded stop delay.',
|
|
508
|
+
'Resume continues where it stopped when supported; remote and unsupported',
|
|
509
|
+
'sessions rerun fresh. Without a live agent, pause waits for the next boundary.',
|
|
507
510
|
'Durably request that an active build pause. --store overrides the BuildStore',
|
|
508
511
|
'path or URL. This command is sessionless; a phase may not control its own build.',
|
|
509
512
|
'',
|
|
@@ -600,6 +603,18 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
|
|
|
600
603
|
'may not control its own build.',
|
|
601
604
|
]),
|
|
602
605
|
},
|
|
606
|
+
{
|
|
607
|
+
name: 'restack',
|
|
608
|
+
audience: 'human',
|
|
609
|
+
summary: 'Request a node restack onto its current parent.',
|
|
610
|
+
detail: page([
|
|
611
|
+
'Usage: ab restack <node> [--store <ref>]',
|
|
612
|
+
'',
|
|
613
|
+
'Records durable demand, coalescing repeated pending requests.',
|
|
614
|
+
'Paused or blocked nodes wait for normal safety gates. Leaves, terminal nodes',
|
|
615
|
+
'and nodes without an open branch are refused. This command is sessionless.',
|
|
616
|
+
]),
|
|
617
|
+
},
|
|
603
618
|
...(['hold', 'land'] as const).map((name) => ({
|
|
604
619
|
name,
|
|
605
620
|
audience: 'human' as const,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { requestNodeRestack } from '../operator/restack'
|
|
2
|
+
import { withSessionlessStore } from './store-opening'
|
|
1
3
|
import { abLandings } from './landings'
|
|
2
4
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
3
5
|
import { preparePinnedAssets } from '../store/ticket-assets'
|
|
@@ -112,6 +114,7 @@ export const SESSIONLESS_COMMANDS = new Set([
|
|
|
112
114
|
'wait',
|
|
113
115
|
'mcp',
|
|
114
116
|
'repository',
|
|
117
|
+
'restack',
|
|
115
118
|
'pause',
|
|
116
119
|
'resume',
|
|
117
120
|
'hold',
|
|
@@ -1045,6 +1048,40 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1045
1048
|
})
|
|
1046
1049
|
}
|
|
1047
1050
|
|
|
1051
|
+
case 'restack': {
|
|
1052
|
+
const usage = 'usage: ab restack <node> [--store <ref>]'
|
|
1053
|
+
const parsed = parseArgs(rest, { store: 'value' }, usage)
|
|
1054
|
+
if (parsed.positionals.length !== 1) throw new Error(usage)
|
|
1055
|
+
if (
|
|
1056
|
+
deps.processEnv?.AB_SESSION?.trim() &&
|
|
1057
|
+
deps.processEnv?.AB_BUILD?.trim() === parsed.positionals[0]
|
|
1058
|
+
)
|
|
1059
|
+
throw new Error(
|
|
1060
|
+
'cannot restack a node from its own phase session (AB_SESSION/AB_BUILD conflict)',
|
|
1061
|
+
)
|
|
1062
|
+
if (!deps.exec) throw new Error('restack requires an exec seam')
|
|
1063
|
+
const result = await withSessionlessStore(
|
|
1064
|
+
{
|
|
1065
|
+
targetRepo: deps.workspacePath,
|
|
1066
|
+
env: deps.processEnv ?? {},
|
|
1067
|
+
exec: deps.exec,
|
|
1068
|
+
...(stringFlag(parsed, 'store') ? { storeRef: stringFlag(parsed, 'store') } : {}),
|
|
1069
|
+
...(deps.openStore ? { openStore: deps.openStore } : {}),
|
|
1070
|
+
},
|
|
1071
|
+
({ store, repo }) =>
|
|
1072
|
+
requestNodeRestack({
|
|
1073
|
+
store,
|
|
1074
|
+
repo,
|
|
1075
|
+
slug: parsed.positionals[0]!,
|
|
1076
|
+
user: deps.processEnv?.USER?.trim() || deps.processEnv?.USERNAME?.trim() || 'operator',
|
|
1077
|
+
}),
|
|
1078
|
+
)
|
|
1079
|
+
deps.stdout(
|
|
1080
|
+
`restack requested for ${result.slug}${result.waiting ? '; waiting for normal safety gates' : ''}`,
|
|
1081
|
+
)
|
|
1082
|
+
return 0
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1048
1085
|
case 'abort': {
|
|
1049
1086
|
const usage = 'usage: ab abort <slug> [--store <ref>]'
|
|
1050
1087
|
const parsed = parseArgs(rest, { store: 'value' }, usage)
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ForgeRequestDeferred } from '../ports/forge-request-context'
|
|
2
|
+
import { stat } from 'node:fs/promises'
|
|
3
|
+
import { deferMixedVersion, MixedVersionDeferral } from '../kernel/mixed-version'
|
|
1
4
|
import { suspendNativeLanding } from '../kernel/landing-publication'
|
|
2
5
|
import { completeAutomaticReconcile } from '../kernel/leaf-restack-completion'
|
|
3
6
|
import { readBuildFacts, readPhaseFailures } from '../store/reduced-reads'
|
|
@@ -23,6 +26,26 @@ export interface PublicationSettlementDeps {
|
|
|
23
26
|
clock?: Clock
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
/** Hosted guests have a separate ref database. Refresh a real dispatcher cache
|
|
30
|
+
* too, when this deployment retains one; origin-only dispatchers have none. */
|
|
31
|
+
async function confirmDispatcherCache(
|
|
32
|
+
deps: PublicationSettlementDeps,
|
|
33
|
+
branch: string,
|
|
34
|
+
sha: string,
|
|
35
|
+
) {
|
|
36
|
+
if (!deps.forge.confirmPublication) return
|
|
37
|
+
try {
|
|
38
|
+
if (!(await stat(deps.workspacePath)).isDirectory()) return
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (['ENOENT', 'ENOTDIR'].includes((error as NodeJS.ErrnoException).code ?? '')) return
|
|
41
|
+
throw error
|
|
42
|
+
}
|
|
43
|
+
const repository = await deps.exec(['git', 'rev-parse', '--git-dir'], { cwd: deps.workspacePath })
|
|
44
|
+
if (repository.exitCode !== 0 || !repository.stdout.trim()) return
|
|
45
|
+
if (!(await deps.forge.confirmPublication(deps.workspacePath, branch, sha)))
|
|
46
|
+
throw new Error(`dispatcher publication readback did not confirm ${sha}`)
|
|
47
|
+
}
|
|
48
|
+
|
|
26
49
|
/** Settle one durable request after the caller has observed environment
|
|
27
50
|
* completion and released its exact execution lease. External effects precede
|
|
28
51
|
* completion facts, making every crash gap safely retryable.
|
|
@@ -37,6 +60,7 @@ export async function settlePendingPublication(
|
|
|
37
60
|
): Promise<void> {
|
|
38
61
|
const publication = deps.publication
|
|
39
62
|
if (publication === undefined) return
|
|
63
|
+
if (await deferMixedVersion(deps.store, slug)) return
|
|
40
64
|
await completeAutomaticReconcile(deps.store, slug)
|
|
41
65
|
let events = (await readBuildFacts(deps.store, slug)).value
|
|
42
66
|
const request = events.publication.latestUncompletedRequest()
|
|
@@ -82,6 +106,8 @@ export async function settlePendingPublication(
|
|
|
82
106
|
localExpected: transaction.localBranchHead,
|
|
83
107
|
archives,
|
|
84
108
|
})
|
|
109
|
+
if (result.kind === 'published')
|
|
110
|
+
await confirmDispatcherCache(deps, request.payload.branch, request.payload.sha)
|
|
85
111
|
const latest = (await readBuildFacts(deps.store, slug)).value
|
|
86
112
|
if (
|
|
87
113
|
(result.kind === 'published' || result.rewritten === true) &&
|
|
@@ -155,6 +181,8 @@ export async function settlePendingPublication(
|
|
|
155
181
|
localExpected: transaction.localBranchHead,
|
|
156
182
|
archives,
|
|
157
183
|
})
|
|
184
|
+
if (result.kind === 'published')
|
|
185
|
+
await confirmDispatcherCache(deps, request.payload.branch, request.payload.sha)
|
|
158
186
|
const history = (await readBuildFacts(deps.store, slug)).value.reconcileHistory
|
|
159
187
|
if (
|
|
160
188
|
(result.kind === 'published' || result.rewritten === true) &&
|
|
@@ -208,10 +236,17 @@ export async function settlePendingPublication(
|
|
|
208
236
|
// Consulted for every uncompleted request, not only abandoned ones: a guest
|
|
209
237
|
// that pushed its branch before dying is owed its completion fact, not a
|
|
210
238
|
// re-push or a loss record.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
239
|
+
if (!publication.isPublished)
|
|
240
|
+
throw new Error(
|
|
241
|
+
'workspace provider lacks authoritative publication inspection; upgrade the provider',
|
|
242
|
+
)
|
|
243
|
+
const probe = () =>
|
|
244
|
+
publication.isPublished!({
|
|
245
|
+
ref: events.workspace?.ref,
|
|
246
|
+
sha: request.payload.sha,
|
|
247
|
+
branch: request.payload.branch,
|
|
248
|
+
})
|
|
249
|
+
const alreadyPublished = await probe()
|
|
215
250
|
if (abandoned && !alreadyPublished) {
|
|
216
251
|
// Last-chance backstop (AUT-328): the workspace is gone with this request
|
|
217
252
|
// uncompleted. Record the loss durably (deduped per request) instead of
|
|
@@ -249,9 +284,17 @@ export async function settlePendingPublication(
|
|
|
249
284
|
if (ref === undefined)
|
|
250
285
|
throw new Error(`build ${slug} has a publication request but no open workspace`)
|
|
251
286
|
await suspendNativeLanding({ ...deps, slug }, `publication:${request.seq}`)
|
|
252
|
-
|
|
287
|
+
try {
|
|
288
|
+
await publication.publish({ ref, sha: request.payload.sha, branch: request.payload.branch })
|
|
289
|
+
} catch (error) {
|
|
290
|
+
if (!(await probe())) throw error
|
|
291
|
+
}
|
|
292
|
+
if (!(await probe()))
|
|
293
|
+
throw new Error(`publication readback did not confirm ${request.payload.sha}`)
|
|
253
294
|
}
|
|
254
295
|
} catch (error) {
|
|
296
|
+
if (error instanceof ForgeRequestDeferred) throw error
|
|
297
|
+
if (error instanceof MixedVersionDeferral) return
|
|
255
298
|
if (request.payload.operation !== 'finalize-step') throw error
|
|
256
299
|
const detail = error instanceof Error ? error.message : String(error)
|
|
257
300
|
const note = `finalize publication failed: ${detail}`
|
|
@@ -271,6 +314,7 @@ export async function settlePendingPublication(
|
|
|
271
314
|
})
|
|
272
315
|
return
|
|
273
316
|
}
|
|
317
|
+
await confirmDispatcherCache(deps, request.payload.branch, request.payload.sha)
|
|
274
318
|
events = (await readBuildFacts(deps.store, slug)).value
|
|
275
319
|
if (events.publication.requestCompleted(request)) return
|
|
276
320
|
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dispatchCapacity,
|
|
3
|
+
type DispatchCapacity,
|
|
4
|
+
type CapacityBuild,
|
|
5
|
+
} from '../kernel/dispatch-capacity'
|
|
6
|
+
import { forgeHealthReducer, type ForgeDegradation } from '../kernel/forge-health'
|
|
7
|
+
import { forgeHotspot, type ForgeRequestCounts } from '../ports/forge-telemetry'
|
|
8
|
+
import { configSchema } from '../config/schema'
|
|
9
|
+
import type { BuildStore } from '../store/types'
|
|
10
|
+
import { readBuildFacts } from '../store/reduced-reads'
|
|
1
11
|
import { forgeReadinessWarnings, reduceDispatchStatus } from '../kernel/dispatch-status'
|
|
2
12
|
import { readRepositoryFacts, type RepositoryReadFacts } from '../store/reduced-reads'
|
|
3
13
|
import {
|
|
@@ -19,8 +29,12 @@ import { withSessionlessStore, type StoreOpener } from './store-opening'
|
|
|
19
29
|
/** Script-facing projection returned by `ab repository status`. */
|
|
20
30
|
export interface RepositoryStatus extends DispatchSettings {
|
|
21
31
|
repo: string
|
|
32
|
+
capacity?: DispatchCapacity
|
|
22
33
|
warningLines?: string[]
|
|
23
34
|
dispatcher: DispatcherLiveness
|
|
35
|
+
forgeRequests?: ForgeRequestCounts
|
|
36
|
+
forgeRequestHotspot?: string
|
|
37
|
+
forgeDegradation?: ForgeDegradation
|
|
24
38
|
ticketSourceDegradation?: TicketSourceDegradation
|
|
25
39
|
/** Live operator sandboxes (AUT-340); released environments are omitted. */
|
|
26
40
|
sandboxes: Array<{
|
|
@@ -90,10 +104,21 @@ export function projectRepositoryStatus(
|
|
|
90
104
|
? forgeReadinessWarnings(reduceDispatchStatus(events, latestRun.payload.run))
|
|
91
105
|
: []
|
|
92
106
|
return {
|
|
107
|
+
...(forgeHealthReducer.reduce(events)
|
|
108
|
+
? { forgeDegradation: forgeHealthReducer.reduce(events) }
|
|
109
|
+
: {}),
|
|
93
110
|
...(active === undefined ? {} : { ticketSourceDegradation: active }),
|
|
94
111
|
repo,
|
|
95
112
|
...(warningLines.length ? { warningLines } : {}),
|
|
96
113
|
dispatcher,
|
|
114
|
+
...(() => {
|
|
115
|
+
const tick = (dispatcher.holder ?? dispatcher.expiredHolder ?? dispatcher.latestRun)?.lastTick
|
|
116
|
+
const forgeRequests =
|
|
117
|
+
tick?.outcome === 'completed' ? tick.counters.forgeRequests : tick?.forgeRequests
|
|
118
|
+
return forgeRequests
|
|
119
|
+
? { forgeRequests, forgeRequestHotspot: forgeHotspot(forgeRequests) }
|
|
120
|
+
: {}
|
|
121
|
+
})(),
|
|
97
122
|
...reduceDispatchSettings(events),
|
|
98
123
|
sandboxes: sandboxStates(events)
|
|
99
124
|
.filter((state) => state.state !== 'released')
|
|
@@ -118,7 +143,16 @@ export function repositoryStatusFromFacts(
|
|
|
118
143
|
repo,
|
|
119
144
|
...(warningLines.length ? { warningLines } : {}),
|
|
120
145
|
dispatcher,
|
|
146
|
+
...(() => {
|
|
147
|
+
const tick = (dispatcher.holder ?? dispatcher.expiredHolder ?? dispatcher.latestRun)?.lastTick
|
|
148
|
+
const forgeRequests =
|
|
149
|
+
tick?.outcome === 'completed' ? tick.counters.forgeRequests : tick?.forgeRequests
|
|
150
|
+
return forgeRequests
|
|
151
|
+
? { forgeRequests, forgeRequestHotspot: forgeHotspot(forgeRequests) }
|
|
152
|
+
: {}
|
|
153
|
+
})(),
|
|
121
154
|
...facts.settings,
|
|
155
|
+
...(facts.forgeHealth ? { forgeDegradation: facts.forgeHealth } : {}),
|
|
122
156
|
...(facts.health === undefined ? {} : { ticketSourceDegradation: facts.health }),
|
|
123
157
|
sandboxes: facts.sandboxes
|
|
124
158
|
.filter((state) => state.state !== 'released')
|
|
@@ -142,15 +176,35 @@ export function repositoryStatusFromFacts(
|
|
|
142
176
|
}
|
|
143
177
|
|
|
144
178
|
export function renderRepositoryStatus(status: RepositoryStatus): string[] {
|
|
179
|
+
const tick = (
|
|
180
|
+
status.dispatcher.holder ??
|
|
181
|
+
status.dispatcher.expiredHolder ??
|
|
182
|
+
status.dispatcher.latestRun
|
|
183
|
+
)?.lastTick
|
|
184
|
+
const requests = tick?.outcome === 'completed' ? tick.counters.forgeRequests : tick?.forgeRequests
|
|
185
|
+
const hotspot = forgeHotspot(requests)
|
|
145
186
|
const setting = (enabled: boolean): string => (enabled ? 'ON' : 'OFF')
|
|
146
187
|
const active = status.ticketSourceDegradation
|
|
147
188
|
return [
|
|
189
|
+
requests
|
|
190
|
+
? `forge requests: ${requests.total} (${requests.unattributed} unattributed)${hotspot ? `; hotspot ${hotspot}` : ''}`
|
|
191
|
+
: 'forge requests: unavailable',
|
|
192
|
+
...(status.forgeDegradation
|
|
193
|
+
? [
|
|
194
|
+
`forge ${status.forgeDegradation.forge}: degraded — ${status.forgeDegradation.message}; reset ${status.forgeDegradation.resetAt}`,
|
|
195
|
+
]
|
|
196
|
+
: []),
|
|
148
197
|
...(active === undefined
|
|
149
198
|
? []
|
|
150
199
|
: [
|
|
151
200
|
`ticket source ${active.source}: ${active.cause} (${active.operation}) — ${active.message}${'resetAt' in active ? `; reset ${active.resetAt}` : ''}`,
|
|
152
201
|
]),
|
|
153
202
|
`repository: ${status.repo}`,
|
|
203
|
+
...(status.capacity
|
|
204
|
+
? [
|
|
205
|
+
`capacity: ${status.capacity.occupied}/${status.capacity.effective} effective; ${status.capacity.configured} configured; ${status.capacity.borrowingNodes.length} node${status.capacity.borrowingNodes.length === 1 ? '' : 's'} using descendant-held slots${status.capacity.borrowingNodes.length ? `: ${status.capacity.borrowingNodes.join(', ')}` : ''}`,
|
|
206
|
+
]
|
|
207
|
+
: []),
|
|
154
208
|
...(status.warningLines ?? []),
|
|
155
209
|
`dispatcher: ${status.dispatcher.state}${status.dispatcher.holder ? ` — ${formatDispatcherIdentity(status.dispatcher.holder)}` : ' — no dispatcher holds the repository'}`,
|
|
156
210
|
...(status.dispatcher.expiredHolder
|
|
@@ -182,6 +236,42 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
|
|
|
182
236
|
]
|
|
183
237
|
}
|
|
184
238
|
|
|
239
|
+
/** Capacity is optional when no held dispatcher has a retrievable configuration. */
|
|
240
|
+
export async function readRepositoryCapacity(
|
|
241
|
+
store: BuildStore,
|
|
242
|
+
repo: string,
|
|
243
|
+
facts: RepositoryReadFacts,
|
|
244
|
+
dispatcher: DispatcherLiveness,
|
|
245
|
+
now: Date,
|
|
246
|
+
): Promise<DispatchCapacity | undefined> {
|
|
247
|
+
if (
|
|
248
|
+
dispatcher.state === 'held' &&
|
|
249
|
+
facts.status?.effectiveConfig &&
|
|
250
|
+
facts.status.run === dispatcher.holder?.run
|
|
251
|
+
) {
|
|
252
|
+
const ref = facts.status.effectiveConfig
|
|
253
|
+
const artifact = await store.getRepoArtifact(repo, ref.kind, ref.rev)
|
|
254
|
+
if (artifact) {
|
|
255
|
+
const config = configSchema.parse(JSON.parse(new TextDecoder().decode(artifact.content)))
|
|
256
|
+
const builds: CapacityBuild[] = []
|
|
257
|
+
const records = await store.listBuildsForRepo(repo)
|
|
258
|
+
const digests = await store.getRepoBuildDigests(repo)
|
|
259
|
+
for (const record of records) {
|
|
260
|
+
if (digests.get(record.slug)?.terminal) continue
|
|
261
|
+
const build = (await readBuildFacts(store, record.slug)).value
|
|
262
|
+
builds.push({
|
|
263
|
+
record,
|
|
264
|
+
state: build.state,
|
|
265
|
+
workspace: build.workspace !== null,
|
|
266
|
+
provisioning: build.provisionMarker !== undefined,
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
return dispatchCapacity(builds, config.capacity, now)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return undefined
|
|
273
|
+
}
|
|
274
|
+
|
|
185
275
|
/**
|
|
186
276
|
* `ab repository status` — read the durable dispatcher controls without
|
|
187
277
|
* creating a repository stream or starting any dispatcher work.
|
|
@@ -191,11 +281,16 @@ export async function abRepositoryStatus(opts: RepositoryStatusOpts): Promise<vo
|
|
|
191
281
|
// A fresh store has no repository row. Do not call ensureRepo: this query's
|
|
192
282
|
// empty-stream defaults must remain a genuinely read-only operation.
|
|
193
283
|
const { dispatcher } = await readDispatcherLiveness(store, repo, opts.now?.())
|
|
194
|
-
const
|
|
284
|
+
const facts = (await readRepositoryFacts(store, repo)).value
|
|
285
|
+
const status = repositoryStatusFromFacts(repo, facts, dispatcher)
|
|
286
|
+
const capacity = await readRepositoryCapacity(
|
|
287
|
+
store,
|
|
195
288
|
repo,
|
|
196
|
-
|
|
289
|
+
facts,
|
|
197
290
|
dispatcher,
|
|
291
|
+
opts.now?.() ?? new Date(),
|
|
198
292
|
)
|
|
293
|
+
if (capacity) status.capacity = capacity
|
|
199
294
|
if (opts.json === true) {
|
|
200
295
|
opts.stdout(JSON.stringify(status, null, 2))
|
|
201
296
|
return
|