@defrex/autobuild 1.4.2 → 1.6.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 +512 -101
- package/bin/ab-dispatch-kernel.ts +1 -0
- package/docs/accounts.md +9 -0
- package/docs/agent-runtimes.md +1 -0
- package/docs/answering-blocked-builds.md +7 -3
- package/docs/architecture.md +313 -130
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +33 -3
- package/docs/cli.md +2 -1
- package/docs/configuration-overview.md +9 -0
- package/docs/configuration.md +217 -106
- package/docs/dispatcher-hosting.md +19 -3
- package/docs/dispatcher.md +11 -6
- package/docs/glossary.md +1 -1
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +91 -28
- package/docs/merge-policy.md +28 -9
- package/docs/operating.md +1 -1
- package/docs/operator-api.md +57 -20
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +89 -8
- package/docs/remote-store-protocol.md +39 -11
- package/docs/remote-ticket-protocol.md +126 -12
- package/docs/restacking.md +24 -6
- package/docs/seams.md +2 -2
- package/docs/setup.md +19 -13
- package/docs/spec-standard.md +2 -1
- package/docs/ticket-dependencies.md +26 -8
- package/docs/ticket-migration.md +70 -7
- package/docs/ticket-sources.md +82 -5
- package/docs/tickets.md +34 -2
- package/docs/troubleshooting.md +3 -3
- package/docs/verification.md +5 -5
- package/docs/website.md +8 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/hosted-readiness.ts +21 -0
- package/packages/core/src/cli/attention.ts +3 -0
- package/packages/core/src/cli/build-control.ts +36 -12
- package/packages/core/src/cli/connect.ts +9 -18
- package/packages/core/src/cli/context.ts +44 -0
- package/packages/core/src/cli/dashboard/configuration.ts +11 -0
- package/packages/core/src/cli/dashboard/model.ts +51 -11
- package/packages/core/src/cli/dashboard/poll.ts +14 -0
- package/packages/core/src/cli/dashboard/queue.ts +21 -0
- package/packages/core/src/cli/dashboard/render.ts +43 -22
- package/packages/core/src/cli/dispatch-frontend.ts +63 -30
- package/packages/core/src/cli/dispatch-mode.ts +35 -16
- package/packages/core/src/cli/dispatch-preflight.ts +4 -1
- package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
- package/packages/core/src/cli/dispatch-tickets.ts +47 -0
- package/packages/core/src/cli/dispatch-upgrade-controller.ts +3 -0
- package/packages/core/src/cli/dispatch.ts +522 -145
- package/packages/core/src/cli/help.ts +63 -24
- package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
- package/packages/core/src/cli/init-readiness-remote.ts +16 -3
- package/packages/core/src/cli/init-validation.ts +144 -42
- package/packages/core/src/cli/issue-links.ts +67 -0
- package/packages/core/src/cli/main.ts +32 -15
- package/packages/core/src/cli/pr-summary-publication.ts +38 -7
- package/packages/core/src/cli/publication-settlement.ts +36 -24
- package/packages/core/src/cli/repo-lease.ts +225 -0
- package/packages/core/src/cli/repository-status.ts +203 -49
- package/packages/core/src/cli/status.ts +42 -4
- package/packages/core/src/cli/terminals.ts +37 -2
- package/packages/core/src/cli/ticket-editor.ts +20 -6
- package/packages/core/src/cli/ticket.ts +264 -46
- package/packages/core/src/cli/triage-count-sampler.ts +59 -0
- package/packages/core/src/cli/wait.ts +4 -1
- package/packages/core/src/cli/watch.ts +19 -4
- package/packages/core/src/config/live.ts +45 -4
- package/packages/core/src/config/load.ts +9 -0
- package/packages/core/src/config/pipeline-source.ts +6 -2
- package/packages/core/src/config/ready-assignee.ts +86 -0
- package/packages/core/src/config/schema.ts +202 -38
- package/packages/core/src/distribution-packaging.ts +1 -1
- package/packages/core/src/events/catalog.ts +7 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/payloads.ts +85 -0
- package/packages/core/src/events/policy.ts +10 -0
- package/packages/core/src/events/repository.ts +93 -28
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +237 -230
- package/packages/core/src/kernel/build-identity.ts +12 -0
- package/packages/core/src/kernel/change-presence.ts +139 -6
- package/packages/core/src/kernel/dispatch-capacity.ts +189 -19
- package/packages/core/src/kernel/dispatch-status.ts +10 -1
- package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
- package/packages/core/src/kernel/engine.ts +17 -8
- package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
- package/packages/core/src/kernel/generators/build-log.ts +9 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
- package/packages/core/src/kernel/harvest.ts +4 -1
- package/packages/core/src/kernel/incremental-fixtures.ts +1 -0
- package/packages/core/src/kernel/integration-completeness.ts +104 -17
- package/packages/core/src/kernel/integration-landing.ts +17 -0
- package/packages/core/src/kernel/integration-state.ts +17 -0
- package/packages/core/src/kernel/issue-keywords.ts +202 -0
- package/packages/core/src/kernel/janitor-failure.ts +96 -5
- package/packages/core/src/kernel/kernel-git.ts +87 -0
- package/packages/core/src/kernel/landing-readiness.ts +25 -17
- package/packages/core/src/kernel/leaf-restack-state.ts +4 -2
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-issue-links.ts +142 -0
- package/packages/core/src/kernel/node-landing.ts +2 -1
- package/packages/core/src/kernel/node-parent.ts +6 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
- package/packages/core/src/kernel/pr-summary.ts +24 -0
- package/packages/core/src/kernel/read-deferrals.ts +75 -12
- package/packages/core/src/kernel/read-facts.ts +32 -1
- package/packages/core/src/kernel/reconcile-restack.ts +1 -1
- package/packages/core/src/kernel/reducer-registry.ts +37 -2
- package/packages/core/src/kernel/reducer.ts +147 -5
- package/packages/core/src/kernel/ticket-preparation.ts +16 -0
- package/packages/core/src/kernel/verify-budget.ts +43 -0
- package/packages/core/src/operator/index.ts +3 -1
- package/packages/core/src/operator/presentation.ts +3 -0
- package/packages/core/src/operator/protocol.ts +38 -2
- package/packages/core/src/operator/query.ts +69 -29
- package/packages/core/src/operator/registry.ts +47 -26
- package/packages/core/src/operator/tickets.ts +77 -10
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/plugins/registry.ts +1 -0
- package/packages/core/src/ports/forge/contract.ts +69 -0
- package/packages/core/src/ports/forge/create.ts +5 -0
- package/packages/core/src/ports/forge/fake.ts +184 -3
- package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
- package/packages/core/src/ports/forge/github.ts +175 -38
- package/packages/core/src/ports/forge/local-git.ts +14 -0
- package/packages/core/src/ports/forge/readiness.ts +10 -0
- package/packages/core/src/ports/forge-failure.ts +43 -0
- package/packages/core/src/ports/runner/claude.ts +7 -1
- package/packages/core/src/ports/runner/codex.ts +7 -2
- package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
- package/packages/core/src/ports/runner/pi.ts +7 -1
- package/packages/core/src/ports/runner/runtime.ts +3 -0
- package/packages/core/src/ports/runner/start-prompt.ts +37 -0
- package/packages/core/src/ports/tickets/contract.ts +320 -7
- package/packages/core/src/ports/tickets/create.ts +89 -20
- package/packages/core/src/ports/tickets/fake.ts +18 -0
- package/packages/core/src/ports/tickets/file-codec.ts +20 -0
- package/packages/core/src/ports/tickets/file.ts +43 -1
- package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
- package/packages/core/src/ports/tickets/github-issues.ts +431 -0
- package/packages/core/src/ports/tickets/github-validators.ts +194 -0
- package/packages/core/src/ports/tickets/github.ts +2029 -0
- package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
- package/packages/core/src/ports/tickets/issue-links.ts +86 -0
- package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
- package/packages/core/src/ports/tickets/linear.ts +66 -6
- package/packages/core/src/ports/tickets/migration.ts +290 -68
- package/packages/core/src/ports/tickets/operations.ts +98 -12
- package/packages/core/src/ports/tickets/priority.ts +55 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
- package/packages/core/src/ports/tickets/remote.ts +188 -13
- package/packages/core/src/ports/tickets/revision.ts +22 -1
- package/packages/core/src/ports/tickets/states.ts +43 -0
- package/packages/core/src/ports/tickets/tree.ts +58 -12
- package/packages/core/src/ports/tickets/update.ts +12 -2
- package/packages/core/src/ports/types.ts +194 -9
- package/packages/core/src/ports/workspace/commit-preservation.ts +163 -25
- package/packages/core/src/ports/workspace/git-worktree.ts +6 -2
- package/packages/core/src/ports/workspace/harvest-execution.ts +4 -2
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +121 -27
- package/packages/core/src/processes/build-runner.ts +101 -22
- package/packages/core/src/processes/dispatcher.ts +1046 -372
- package/packages/core/src/processes/execution-no-progress.ts +7 -0
- package/packages/core/src/processes/harvest-child.ts +4 -2
- package/packages/core/src/processes/harvest-execution-state.ts +104 -0
- package/packages/core/src/processes/harvest-runner.ts +263 -25
- package/packages/core/src/processes/harvest.ts +5 -8
- package/packages/core/src/processes/tick-publication.ts +12 -2
- package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
- package/packages/core/src/processes/workspace-preservation.ts +36 -1
- package/packages/core/src/runtime-identity.ts +10 -2
- package/packages/core/src/scenarios/harness.ts +149 -35
- package/packages/core/src/store/adapter.ts +7 -1
- package/packages/core/src/store/contract.ts +83 -2
- package/packages/core/src/store/digest.ts +32 -1
- package/packages/core/src/store/reduced-reads.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +4471 -3427
- package/packages/core/src/store/remote/protocol.ts +2 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
- package/packages/core/src/store/remote/released-reducer-values/1.6.0.json +27173 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +5 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
- package/packages/core/src/testing/index.ts +18 -1
- package/packages/core/src/testing/presence-history.ts +79 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1424 -33
- package/packages/core/src/testing/upgrade-generations.ts +77 -0
- package/skills/code-review/SKILL.md +4 -3
- package/skills/finalize/SKILL.md +18 -2
- package/skills/guide/SKILL.md +417 -143
- package/skills/guide/references/accounts.md +9 -0
- package/skills/guide/references/integration-tree.md +91 -28
- package/skills/guide/references/merge-policy.md +28 -9
- package/skills/guide/references/operator-api.md +57 -20
- package/skills/guide/references/plugin-authoring.md +89 -8
- package/skills/guide/references/remote-store-protocol.md +39 -11
- package/skills/guide/references/remote-ticket-protocol.md +126 -12
- package/skills/guide/references/restacking.md +24 -6
- package/skills/guide/references/setup.md +19 -13
- package/skills/guide/references/spec-standard.md +2 -1
- package/skills/guide/references/ticket-dependencies.md +26 -8
- package/skills/guide/references/ticket-migration.md +70 -7
- package/skills/harvest-review/SKILL.md +4 -3
- package/skills/implement/SKILL.md +20 -1
- package/skills/operate/SKILL.md +149 -35
- package/skills/plan/SKILL.md +1 -1
- package/skills/reconcile/SKILL.md +5 -4
- package/skills/spec/SKILL.md +15 -2
- package/skills/tickets/SKILL.md +116 -37
- package/templates/autobuild.toml +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -116,6 +116,19 @@ const parts = {
|
|
|
116
116
|
dashboard: dashboardFactsReducer,
|
|
117
117
|
deferral: currentDeferralObservationReducer,
|
|
118
118
|
}
|
|
119
|
+
/** Capacity of `replacedHeads`; supersession beyond it falls back to refusal. */
|
|
120
|
+
export const REPLACED_HEADS_CAP = 64
|
|
121
|
+
const OID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/
|
|
122
|
+
/** The published history each recorded rewrite replaced. */
|
|
123
|
+
function replacedShas(event: AbEvent): string[] {
|
|
124
|
+
const shas =
|
|
125
|
+
event.type === 'node.rewritten'
|
|
126
|
+
? [event.payload.previous]
|
|
127
|
+
: event.type === 'restack.rewritten' || event.type === 'reconcile.rewritten'
|
|
128
|
+
? [event.payload.oldHead, event.payload.localBranchHead]
|
|
129
|
+
: []
|
|
130
|
+
return [...new Set(shas)].filter((sha) => OID.test(sha))
|
|
131
|
+
}
|
|
119
132
|
export interface RunnerAttach {
|
|
120
133
|
seq: number
|
|
121
134
|
ts: string
|
|
@@ -158,6 +171,9 @@ export interface BuildReadAcc {
|
|
|
158
171
|
finalizePublicationRequested: boolean
|
|
159
172
|
workspaceFence?: Extract<AbEvent, { type: 'workspace.fenced' }>
|
|
160
173
|
workspacePreservation?: Extract<AbEvent, { type: 'workspace.commits-preserved' }>
|
|
174
|
+
/** Bounded record of the latest distinct shas a recorded rewrite replaced,
|
|
175
|
+
* newest last. Preserved branch heads it covers are superseded. */
|
|
176
|
+
replacedHeads: string[]
|
|
161
177
|
workspaceLoss?: Extract<AbEvent, { type: 'workspace.commits-lost' }>
|
|
162
178
|
latestWorkspace?: Extract<
|
|
163
179
|
AbEvent,
|
|
@@ -217,7 +233,7 @@ export interface BuildReadAcc {
|
|
|
217
233
|
}
|
|
218
234
|
export const buildReadFactsReducer = defineReducer({
|
|
219
235
|
rawEvents: true,
|
|
220
|
-
version:
|
|
236
|
+
version: 7 + Object.values(parts).reduce((sum, reducer) => sum + reducer.version, 0),
|
|
221
237
|
initial: (): BuildReadAcc => ({
|
|
222
238
|
runnerAttaches: [],
|
|
223
239
|
summaryRequests: summaryRequestsReducer.initial(),
|
|
@@ -251,6 +267,7 @@ export const buildReadFactsReducer = defineReducer({
|
|
|
251
267
|
reconcileBases: {},
|
|
252
268
|
reconcileHistory: [],
|
|
253
269
|
restackHistory: [],
|
|
270
|
+
replacedHeads: [],
|
|
254
271
|
candidateRecoveries: {},
|
|
255
272
|
candidateRecoverySeqs: {},
|
|
256
273
|
sessionStarts: [],
|
|
@@ -333,6 +350,13 @@ export const buildReadFactsReducer = defineReducer({
|
|
|
333
350
|
// branch over a durably acknowledged rewrite of the public branch.
|
|
334
351
|
if (event.type === 'reconcile.rewritten' || event.type === 'restack.rewritten')
|
|
335
352
|
delete acc.workspacePreservation
|
|
353
|
+
for (const sha of replacedShas(event)) {
|
|
354
|
+
const index = acc.replacedHeads.indexOf(sha)
|
|
355
|
+
if (index >= 0) acc.replacedHeads.splice(index, 1)
|
|
356
|
+
acc.replacedHeads.push(sha)
|
|
357
|
+
if (acc.replacedHeads.length > REPLACED_HEADS_CAP)
|
|
358
|
+
acc.replacedHeads.splice(0, acc.replacedHeads.length - REPLACED_HEADS_CAP)
|
|
359
|
+
}
|
|
336
360
|
if (event.type === 'session.started') {
|
|
337
361
|
const last = acc.sessionStarts.at(-1)
|
|
338
362
|
if (event.payload.continuation && last?.session === event.payload.continuation.predecessor)
|
|
@@ -510,6 +534,7 @@ export const buildReadFactsReducer = defineReducer({
|
|
|
510
534
|
latestWorkspace: acc.latestWorkspace,
|
|
511
535
|
workspaceFence: acc.workspaceFence,
|
|
512
536
|
workspacePreservation: acc.workspacePreservation,
|
|
537
|
+
replacedHeads: [...acc.replacedHeads],
|
|
513
538
|
workspaceLoss: acc.workspaceLoss,
|
|
514
539
|
planFeedback: structuredClone(acc.planFeedback),
|
|
515
540
|
findings: structuredClone(acc.findings),
|
|
@@ -553,6 +578,7 @@ import { repositoryAttentionReducer } from './repository-attention'
|
|
|
553
578
|
import { dispatchSettingsReducer } from './dispatch-settings'
|
|
554
579
|
import { harvestReducer } from './harvest'
|
|
555
580
|
import { forgeHealthReducer } from './forge-health'
|
|
581
|
+
import { kernelGitHealthReducer } from './kernel-git'
|
|
556
582
|
import { ticketSourceHealthReducer } from './ticket-source-health'
|
|
557
583
|
import { autoMergeDefaultReducer } from './auto-merge-default'
|
|
558
584
|
import { effectiveConfigReducer } from './service-facts'
|
|
@@ -604,6 +630,7 @@ export interface RepositoryReadAcc {
|
|
|
604
630
|
settings: ReturnType<typeof dispatchSettingsReducer.initial>
|
|
605
631
|
harvest: ReturnType<typeof harvestReducer.initial>
|
|
606
632
|
forgeHealth: ReturnType<typeof forgeHealthReducer.initial>
|
|
633
|
+
kernelGit: ReturnType<typeof kernelGitHealthReducer.initial>
|
|
607
634
|
ticketMigrations: ReturnType<typeof ticketMigrationsReducer.initial>
|
|
608
635
|
health: ReturnType<typeof ticketSourceHealthReducer.initial>
|
|
609
636
|
autoMerge: ReturnType<typeof autoMergeDefaultReducer.initial>
|
|
@@ -628,6 +655,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
628
655
|
dispatcherRunFactsReducer('version').version +
|
|
629
656
|
openHarvestExecutionsReducer.version +
|
|
630
657
|
forgeHealthReducer.version +
|
|
658
|
+
kernelGitHealthReducer.version +
|
|
631
659
|
repositoryAttentionReducer.version +
|
|
632
660
|
dispatchSettingsReducer.version +
|
|
633
661
|
harvestReducer.version +
|
|
@@ -658,6 +686,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
658
686
|
settings: dispatchSettingsReducer.initial(),
|
|
659
687
|
harvest: harvestReducer.initial(),
|
|
660
688
|
forgeHealth: forgeHealthReducer.initial(),
|
|
689
|
+
kernelGit: kernelGitHealthReducer.initial(),
|
|
661
690
|
ticketMigrations: ticketMigrationsReducer.initial(),
|
|
662
691
|
health: ticketSourceHealthReducer.initial(),
|
|
663
692
|
autoMerge: autoMergeDefaultReducer.initial(),
|
|
@@ -675,6 +704,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
675
704
|
acc.settings = dispatchSettingsReducer.advance(acc.settings, events)
|
|
676
705
|
acc.harvest = harvestReducer.advance(acc.harvest, events)
|
|
677
706
|
acc.forgeHealth = forgeHealthReducer.advance(acc.forgeHealth, events)
|
|
707
|
+
acc.kernelGit = kernelGitHealthReducer.advance(acc.kernelGit, events)
|
|
678
708
|
acc.ticketMigrations = ticketMigrationsReducer.advance(acc.ticketMigrations, events)
|
|
679
709
|
acc.health = ticketSourceHealthReducer.advance(acc.health, events)
|
|
680
710
|
acc.autoMerge = autoMergeDefaultReducer.advance(acc.autoMerge, events)
|
|
@@ -808,6 +838,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
808
838
|
settings: dispatchSettingsReducer.finish(acc.settings),
|
|
809
839
|
harvest: harvestReducer.finish(acc.harvest),
|
|
810
840
|
forgeHealth: forgeHealthReducer.finish(acc.forgeHealth),
|
|
841
|
+
kernelGit: kernelGitHealthReducer.finish(acc.kernelGit),
|
|
811
842
|
ticketMigrations: ticketMigrationsReducer.finish(acc.ticketMigrations),
|
|
812
843
|
health: ticketSourceHealthReducer.finish(acc.health),
|
|
813
844
|
autoMerge: autoMergeDefaultReducer.finish(acc.autoMerge),
|
|
@@ -115,7 +115,7 @@ export { retainReplay, restoreReplay } from './replay-retention'
|
|
|
115
115
|
import { restoreReplay } from './replay-retention'
|
|
116
116
|
|
|
117
117
|
/** Restore a sandbox-only change from durable bytes without remote write access. */
|
|
118
|
-
async function restoreChange(deps: RestackDeps, sha: string): Promise<boolean> {
|
|
118
|
+
export async function restoreChange(deps: RestackDeps, sha: string): Promise<boolean> {
|
|
119
119
|
const artifact = await deps.store.getArtifact(deps.slug, `reconcile-change-${sha}`)
|
|
120
120
|
if (artifact === null) return restoreReplay(deps, sha)
|
|
121
121
|
const content = new TextDecoder().decode(artifact.content)
|
|
@@ -31,7 +31,7 @@ import { dispatchFailureBudgetReducer } from '../processes/dispatch-failure-budg
|
|
|
31
31
|
import { ticketSourceHealthReducer } from './ticket-source-health'
|
|
32
32
|
/**
|
|
33
33
|
* Every incremental reducer, with its published version and the whole-array
|
|
34
|
-
* functions it backs. `reducer-registry.test.ts` snapshots the versions and
|
|
34
|
+
* functions it backs. `reducer-registry.integration.test.ts` snapshots the versions and
|
|
35
35
|
* the accumulator shapes, and scans `kernel/`, `store/` and `processes/` so a
|
|
36
36
|
* new event-array projection must be registered here or excluded with a reason.
|
|
37
37
|
*/
|
|
@@ -53,7 +53,10 @@ import {
|
|
|
53
53
|
lastExecutionOutcomeReducer,
|
|
54
54
|
openExecutionReducer,
|
|
55
55
|
} from '../processes/execution-settlement'
|
|
56
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
hostedHarvestAuthorityReducer,
|
|
58
|
+
openHarvestExecutionsReducer,
|
|
59
|
+
} from '../processes/harvest-execution-state'
|
|
57
60
|
import { infrastructureFailureResetReducer } from '../processes/infrastructure-failure-budget'
|
|
58
61
|
import { publicationStateReducer } from '../processes/publication-state'
|
|
59
62
|
import { sandboxStatesReducer } from '../processes/sandbox-state'
|
|
@@ -152,6 +155,7 @@ const REGISTERED: Record<string, Omit<RegisteredReducer, 'valueRead'>> = {
|
|
|
152
155
|
reducer: openHarvestExecutionsReducer,
|
|
153
156
|
covers: ['openHarvestExecutions'],
|
|
154
157
|
},
|
|
158
|
+
hostedHarvestAuthority: { reducer: hostedHarvestAuthorityReducer, covers: [] },
|
|
155
159
|
openTick: { reducer: openTickReducer('run-a'), covers: ['hasOpenTick'] },
|
|
156
160
|
dispatchFailureBudget: {
|
|
157
161
|
reducer: dispatchFailureBudgetReducer(false),
|
|
@@ -234,6 +238,7 @@ const repositoryValues = new Set([
|
|
|
234
238
|
'dispatchStatus',
|
|
235
239
|
'sandboxStates',
|
|
236
240
|
'openHarvestExecutions',
|
|
241
|
+
'hostedHarvestAuthority',
|
|
237
242
|
'openTick',
|
|
238
243
|
'autoMergeDefault',
|
|
239
244
|
])
|
|
@@ -267,6 +272,35 @@ const parameterized: Record<string, Pick<ValueCatalogEntry, 'args' | 'create'>>
|
|
|
267
272
|
create: ({ phase, round }) => phaseFailuresReducer(phase, round),
|
|
268
273
|
},
|
|
269
274
|
}
|
|
275
|
+
/** The node slugs one digest row names: a `build.created` target, or either
|
|
276
|
+
* side of a node parent move. Undecodable payloads name none. */
|
|
277
|
+
function digestNodeTargetsOf(event: { type: string; payload: unknown }): {
|
|
278
|
+
nodeTargets?: string[]
|
|
279
|
+
} {
|
|
280
|
+
const build = (target: unknown) =>
|
|
281
|
+
target !== null &&
|
|
282
|
+
typeof target === 'object' &&
|
|
283
|
+
'build' in target &&
|
|
284
|
+
typeof target.build === 'string'
|
|
285
|
+
? [target.build]
|
|
286
|
+
: []
|
|
287
|
+
const targetOf = (value: unknown) =>
|
|
288
|
+
value !== null && typeof value === 'object' && 'target' in value ? build(value.target) : []
|
|
289
|
+
const payload = event.payload
|
|
290
|
+
const nodeTargets =
|
|
291
|
+
event.type === 'build.created'
|
|
292
|
+
? targetOf(payload)
|
|
293
|
+
: (event.type === 'node.parent-requested' || event.type === 'node.parent-accepted') &&
|
|
294
|
+
payload !== null &&
|
|
295
|
+
typeof payload === 'object'
|
|
296
|
+
? [
|
|
297
|
+
...('old' in payload ? targetOf(payload.old) : []),
|
|
298
|
+
...('next' in payload ? targetOf(payload.next) : []),
|
|
299
|
+
]
|
|
300
|
+
: []
|
|
301
|
+
return nodeTargets.length ? { nodeTargets } : {}
|
|
302
|
+
}
|
|
303
|
+
|
|
270
304
|
export const REDUCERS: Record<string, RegisteredReducer> = Object.fromEntries(
|
|
271
305
|
Object.entries(REGISTERED).map(([name, entry]) => [
|
|
272
306
|
name,
|
|
@@ -299,6 +333,7 @@ export const REDUCERS: Record<string, RegisteredReducer> = Object.fromEntries(
|
|
|
299
333
|
? { nodeContribution: event.payload }
|
|
300
334
|
: {}),
|
|
301
335
|
...(event.type === 'build.created' ? { kind: event.payload.kind } : {}),
|
|
336
|
+
...digestNodeTargetsOf(event),
|
|
302
337
|
...(event.payload !== null &&
|
|
303
338
|
typeof event.payload === 'object' &&
|
|
304
339
|
'instance' in event.payload
|
|
@@ -14,10 +14,11 @@ import {
|
|
|
14
14
|
projectEvents,
|
|
15
15
|
type CompatibilityState,
|
|
16
16
|
} from '../events/compatibility'
|
|
17
|
-
import type { NativeSessionHandle } from '../ports/types'
|
|
17
|
+
import type { IssueLink, NativeSessionHandle } from '../ports/types'
|
|
18
18
|
import { advanceLanding, type LandingState } from './landing-state'
|
|
19
19
|
import { advanceIntegration, type IntegrationState } from './integration-state'
|
|
20
20
|
import { advanceNodeRestack, type NodeRestackState } from './node-restack-state'
|
|
21
|
+
import { mergeNodeIssueLinks, type NodeIssueLink } from './node-issue-links'
|
|
21
22
|
import { reconcileRewriteHead } from './reconcile-head'
|
|
22
23
|
/**
|
|
23
24
|
* The state reducer (SPEC §15.5, §3.4): state is a reduction of events — any
|
|
@@ -50,6 +51,20 @@ import { defineReducer, type IncrementalReducer } from './incremental'
|
|
|
50
51
|
/** An `escalation.raised` without a matching `escalation.answered` — the
|
|
51
52
|
* definition of `blocked` (§15.5). Matched by id, so answers may arrive in
|
|
52
53
|
* any order. */
|
|
54
|
+
/** A frozen issue link with its effective intent. `downgrade` records the
|
|
55
|
+
* agent fact that turned `closes` into `refs`. */
|
|
56
|
+
export interface BuildIssueLink {
|
|
57
|
+
issue: number
|
|
58
|
+
intent: 'closes' | 'refs'
|
|
59
|
+
downgrade?: { reason: string; seq: number }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface NodeIssueLinksState {
|
|
63
|
+
builds: string[]
|
|
64
|
+
links: NodeIssueLink[]
|
|
65
|
+
published?: { pr: number; issueLinks: IssueLink[]; seq: number }
|
|
66
|
+
}
|
|
67
|
+
|
|
53
68
|
export interface OpenEscalation {
|
|
54
69
|
id: string
|
|
55
70
|
phase: EscalationTarget
|
|
@@ -60,6 +75,9 @@ export interface OpenEscalation {
|
|
|
60
75
|
/** Policy guard identity. Absent only on historical policy raises. */
|
|
61
76
|
policyCause?: PolicyEscalationCause
|
|
62
77
|
deferral?: 'own-build-read'
|
|
78
|
+
/** Raised by `build.janitor-escalated`. Its routing is inert (`setup`
|
|
79
|
+
* target, no cause); the janitor's recovery closes it unanswered. */
|
|
80
|
+
janitor?: true
|
|
63
81
|
question: string
|
|
64
82
|
refs?: string[]
|
|
65
83
|
/** seq of the `escalation.raised` event — what `spec.revised` cites (§15.3). */
|
|
@@ -134,6 +152,8 @@ export interface OpenSession {
|
|
|
134
152
|
round?: number
|
|
135
153
|
/** Live-view stream id (SPEC §9); absent on historical events. */
|
|
136
154
|
stream?: string
|
|
155
|
+
/** Effective first message the bracket sent; absent on historical events. */
|
|
156
|
+
prompt?: string
|
|
137
157
|
/** seq of the `session.started` event. */
|
|
138
158
|
seq: number
|
|
139
159
|
}
|
|
@@ -216,6 +236,12 @@ export interface BuildState {
|
|
|
216
236
|
pollingActivity?: Record<string, string>
|
|
217
237
|
nodePolling?: EventPayload<'node.poll-checked'> & { checkedAt: string }
|
|
218
238
|
nodeComparison?: EventPayload<'node.compared'>
|
|
239
|
+
/** A node's issue-link union (SPEC "Forge issue links"). `builds` is the
|
|
240
|
+
* sorted set of child slugs whose `node.issue-links-recorded` folded in,
|
|
241
|
+
* the durable evidence that keeps a crash retry from recording twice;
|
|
242
|
+
* `links` is the running union; `published` is the last confirmed PR body
|
|
243
|
+
* readback. Absent until the first fact. */
|
|
244
|
+
nodeIssueLinks?: NodeIssueLinksState
|
|
219
245
|
|
|
220
246
|
/**
|
|
221
247
|
* §15.5: 'queued' until `runner.attached`, 'running' after;
|
|
@@ -230,6 +256,10 @@ export interface BuildState {
|
|
|
230
256
|
* a still-blocked build reports 'blocked' again. No information is lost.
|
|
231
257
|
*/
|
|
232
258
|
status: BuildStatus
|
|
259
|
+
/** The status this build would have without its janitor escalation; present
|
|
260
|
+
* only while one is open. The janitor reads it so its own escalation never
|
|
261
|
+
* gates the work that would recover it. */
|
|
262
|
+
statusWithoutJanitorEscalation?: BuildStatus
|
|
233
263
|
/** From `build.completed` — present only once status is 'done'. */
|
|
234
264
|
outcome?: BuildOutcome
|
|
235
265
|
/** currentPhase if one is started-but-not-completed, else the latest
|
|
@@ -263,6 +293,10 @@ export interface BuildState {
|
|
|
263
293
|
message: string
|
|
264
294
|
nextAttemptAt: string
|
|
265
295
|
attention?: true
|
|
296
|
+
/** Id of this episode's escalation, once raised. */
|
|
297
|
+
escalation?: string
|
|
298
|
+
/** The escalation was answered: attempt again without waiting out backoff. */
|
|
299
|
+
retryRequested?: true
|
|
266
300
|
}
|
|
267
301
|
landing?: LandingState
|
|
268
302
|
/** Historical auto-merge controls retained for replay compatibility. */
|
|
@@ -274,6 +308,10 @@ export interface BuildState {
|
|
|
274
308
|
* read it. Compare this against `restartSince`, exactly as engine.ts:707-708
|
|
275
309
|
* post-filters its own `finalizeCompleted`. */
|
|
276
310
|
finalizeCompletedSeq: number
|
|
311
|
+
/** Largest settlement key the dispatcher observed at the engine's leaf
|
|
312
|
+
* `wait awaiting-pr` decision (`pipeline.settled`); capacity evidence only,
|
|
313
|
+
* never a pipeline decision input. */
|
|
314
|
+
pipelineSettled?: number
|
|
277
315
|
/** Full-log `finalize.step-completed` facts, in event order (§5).
|
|
278
316
|
* Post-steps are failure-tolerant, so a completion counts whether `ok` is
|
|
279
317
|
* true or false. Current-spec membership is determined by
|
|
@@ -286,6 +324,13 @@ export interface BuildState {
|
|
|
286
324
|
/** Ticket assets the build froze: set by `build.created`, replaced by a
|
|
287
325
|
* `spec.revised` that carries `assets` (§6.3). Empty for historical logs. */
|
|
288
326
|
pinnedAssets: PinnedAsset[]
|
|
327
|
+
/** Forge issue links frozen by `build.created`, with any downgrade applied
|
|
328
|
+
* before the seal. Spec revisions never resample them. Empty for
|
|
329
|
+
* historical logs. */
|
|
330
|
+
issueLinks: BuildIssueLink[]
|
|
331
|
+
/** seq of the fact that closed the downgrade window: `issue-links.sealed`,
|
|
332
|
+
* `publication.requested {operation: 'finalize'}` or `finalize.completed`. */
|
|
333
|
+
issueLinksSealedSeq?: number
|
|
289
334
|
/** Latest spec artifact rev — `spec.imported`/`spec.authored` set it,
|
|
290
335
|
* `spec.revised` bumps it (§6.3: rev N+1 restarts leaves from plan and nodes from collection). */
|
|
291
336
|
specRev?: number
|
|
@@ -362,6 +407,8 @@ export interface BuildState {
|
|
|
362
407
|
dispatchFailures: Array<EventPayload<'dispatch.failed'> & { seq: number }>
|
|
363
408
|
/** Provider identities and failures are durable even after recovery clears the current error. */
|
|
364
409
|
executions: Array<EventPayload<'execution.started'> & { seq: number }>
|
|
410
|
+
/** The latest execution, while no instance-matched `execution.ended` follows it. */
|
|
411
|
+
openExecution?: EventPayload<'execution.started'> & { seq: number }
|
|
365
412
|
infrastructureFailures: Array<EventPayload<'infrastructure.failed'> & { seq: number }>
|
|
366
413
|
infrastructureFailure?: EventPayload<'infrastructure.failed'> & { seq: number }
|
|
367
414
|
cleanupAttempts: Array<EventPayload<'infrastructure.cleanup-attempted'> & { seq: number }>
|
|
@@ -411,6 +458,12 @@ export interface BuildAcc {
|
|
|
411
458
|
pollingActivity?: Record<string, string>
|
|
412
459
|
nodePolling?: EventPayload<'node.poll-checked'> & { checkedAt: string }
|
|
413
460
|
nodeComparison?: EventPayload<'node.compared'>
|
|
461
|
+
/** A node's issue-link union (SPEC "Forge issue links"). `builds` is the
|
|
462
|
+
* sorted set of child slugs whose `node.issue-links-recorded` folded in,
|
|
463
|
+
* the durable evidence that keeps a crash retry from recording twice;
|
|
464
|
+
* `links` is the running union; `published` is the last confirmed PR body
|
|
465
|
+
* readback. Absent until the first fact. */
|
|
466
|
+
nodeIssueLinks?: NodeIssueLinksState
|
|
414
467
|
|
|
415
468
|
attached: boolean
|
|
416
469
|
pausedFlag: boolean
|
|
@@ -431,13 +484,20 @@ export interface BuildAcc {
|
|
|
431
484
|
message: string
|
|
432
485
|
nextAttemptAt: string
|
|
433
486
|
attention?: true
|
|
487
|
+
/** Id of this episode's escalation, once raised. */
|
|
488
|
+
escalation?: string
|
|
489
|
+
/** The escalation was answered: attempt again without waiting out backoff. */
|
|
490
|
+
retryRequested?: true
|
|
434
491
|
}
|
|
435
492
|
landing?: LandingState
|
|
436
493
|
autoMerge: AutoMergeProjection
|
|
437
494
|
specRev?: number
|
|
438
495
|
restartSince: number
|
|
439
496
|
pinnedAssets: PinnedAsset[]
|
|
497
|
+
issueLinks: BuildIssueLink[]
|
|
498
|
+
issueLinksSealedSeq?: number
|
|
440
499
|
finalizeCompletedSeq: number
|
|
500
|
+
pipelineSettled?: number
|
|
441
501
|
finalizeSteps: BuildState['finalizeSteps']
|
|
442
502
|
plan: BuildState['plan']
|
|
443
503
|
implement: BuildState['implement']
|
|
@@ -467,7 +527,7 @@ export interface BuildAcc {
|
|
|
467
527
|
}
|
|
468
528
|
|
|
469
529
|
/** Bump when `BuildAcc`'s shape or the fold's semantics change. */
|
|
470
|
-
export const BUILD_REDUCER_VERSION =
|
|
530
|
+
export const BUILD_REDUCER_VERSION = 32
|
|
471
531
|
|
|
472
532
|
function initialBuildAcc(): BuildAcc {
|
|
473
533
|
return {
|
|
@@ -486,6 +546,7 @@ function initialBuildAcc(): BuildAcc {
|
|
|
486
546
|
autoMerge: { requested: false },
|
|
487
547
|
restartSince: 0,
|
|
488
548
|
pinnedAssets: [],
|
|
549
|
+
issueLinks: [],
|
|
489
550
|
finalizeCompletedSeq: 0,
|
|
490
551
|
finalizeSteps: [],
|
|
491
552
|
plan: { round: 0, approved: false },
|
|
@@ -628,9 +689,16 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
628
689
|
acc.janitor = {
|
|
629
690
|
...event.payload,
|
|
630
691
|
...(acc.janitor?.attention ? { attention: true as const } : {}),
|
|
692
|
+
...(acc.janitor?.escalation ? { escalation: acc.janitor.escalation } : {}),
|
|
631
693
|
}
|
|
632
694
|
if (event.type === 'build.janitor-failing' && acc.janitor) acc.janitor.attention = true
|
|
633
|
-
if (event.type === 'build.janitor-
|
|
695
|
+
if (event.type === 'build.janitor-escalated' && acc.janitor)
|
|
696
|
+
acc.janitor.escalation = event.payload.id
|
|
697
|
+
if (event.type === 'build.janitor-recovered') {
|
|
698
|
+
delete acc.janitor
|
|
699
|
+
for (const escalation of [...openEscalations.values()])
|
|
700
|
+
if (escalation.janitor) openEscalations.delete(escalation.id)
|
|
701
|
+
}
|
|
634
702
|
if (event.type === 'target.rewritten') acc.targetRewrite = event
|
|
635
703
|
if (
|
|
636
704
|
event.type === 'target.moved' ||
|
|
@@ -696,6 +764,29 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
696
764
|
case 'node.compared':
|
|
697
765
|
acc.nodeComparison = event.payload
|
|
698
766
|
break
|
|
767
|
+
case 'node.issue-links-recorded': {
|
|
768
|
+
// Idempotent by construction: a repeated fact for a recorded build
|
|
769
|
+
// re-merges the same links and leaves `builds` unchanged.
|
|
770
|
+
const current = acc.nodeIssueLinks ?? { builds: [], links: [] }
|
|
771
|
+
acc.nodeIssueLinks = {
|
|
772
|
+
...current,
|
|
773
|
+
builds: current.builds.includes(event.payload.build)
|
|
774
|
+
? current.builds
|
|
775
|
+
: [...current.builds, event.payload.build].sort(),
|
|
776
|
+
links: mergeNodeIssueLinks(current.links, event.payload.issueLinks),
|
|
777
|
+
}
|
|
778
|
+
break
|
|
779
|
+
}
|
|
780
|
+
case 'node.issue-links-published':
|
|
781
|
+
acc.nodeIssueLinks = {
|
|
782
|
+
...(acc.nodeIssueLinks ?? { builds: [], links: [] }),
|
|
783
|
+
published: {
|
|
784
|
+
pr: event.payload.pr,
|
|
785
|
+
issueLinks: event.payload.issueLinks.map(({ issue, intent }) => ({ issue, intent })),
|
|
786
|
+
seq: event.seq,
|
|
787
|
+
},
|
|
788
|
+
}
|
|
789
|
+
break
|
|
699
790
|
case 'node.rewritten':
|
|
700
791
|
if (acc.nodeComparison)
|
|
701
792
|
acc.nodeComparison = { ...acc.nodeComparison, headSha: event.payload.head }
|
|
@@ -710,6 +801,22 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
710
801
|
acc.target = event.payload.target
|
|
711
802
|
acc.baseBranch = event.payload.baseBranch
|
|
712
803
|
pinnedAssets = event.payload.assets ?? []
|
|
804
|
+
acc.issueLinks = (event.payload.issueLinks ?? []).map((link) => ({ ...link }))
|
|
805
|
+
break
|
|
806
|
+
case 'issue-link.downgraded': {
|
|
807
|
+
// One-way and only before the seal: a later, a repeated or an
|
|
808
|
+
// unknown downgrade is inert, so PR composition never changes.
|
|
809
|
+
const { issue, reason } = event.payload
|
|
810
|
+
if (acc.issueLinksSealedSeq !== undefined) break
|
|
811
|
+
acc.issueLinks = acc.issueLinks.map((link) =>
|
|
812
|
+
link.issue === issue && link.intent === 'closes'
|
|
813
|
+
? { issue, intent: 'refs', downgrade: { reason, seq: event.seq } }
|
|
814
|
+
: link,
|
|
815
|
+
)
|
|
816
|
+
break
|
|
817
|
+
}
|
|
818
|
+
case 'issue-links.sealed':
|
|
819
|
+
acc.issueLinksSealedSeq ??= event.seq
|
|
713
820
|
break
|
|
714
821
|
case 'workspace.provisioned':
|
|
715
822
|
case 'workspace.cleanup-required':
|
|
@@ -722,7 +829,10 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
722
829
|
case 'pr-summary.result':
|
|
723
830
|
case 'pr-summary.settled':
|
|
724
831
|
case 'finalize.step-started':
|
|
832
|
+
break
|
|
725
833
|
case 'publication.requested':
|
|
834
|
+
if (event.payload.operation === 'finalize') acc.issueLinksSealedSeq ??= event.seq
|
|
835
|
+
break
|
|
726
836
|
// Inert loss fact (AUT-328): the dispatcher released a workspace with a
|
|
727
837
|
// pending publication. Recovery runs through the existing
|
|
728
838
|
// abandoned-publication flow (abandonedPublicationPending), which re-runs
|
|
@@ -894,6 +1004,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
894
1004
|
phase: event.payload.phase,
|
|
895
1005
|
round: event.payload.round,
|
|
896
1006
|
stream: event.payload.stream,
|
|
1007
|
+
prompt: event.payload.prompt,
|
|
897
1008
|
seq: event.seq,
|
|
898
1009
|
})
|
|
899
1010
|
break
|
|
@@ -1089,11 +1200,15 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1089
1200
|
start({ phase: 'finalize', seq: event.seq })
|
|
1090
1201
|
break
|
|
1091
1202
|
case 'finalize.completed':
|
|
1203
|
+
acc.issueLinksSealedSeq ??= event.seq
|
|
1092
1204
|
pr = event.payload.pr
|
|
1093
1205
|
prState = 'open'
|
|
1094
1206
|
finalizeCompletedSeq = event.seq
|
|
1095
1207
|
complete('finalize', event.seq)
|
|
1096
1208
|
break
|
|
1209
|
+
case 'pipeline.settled':
|
|
1210
|
+
acc.pipelineSettled = Math.max(acc.pipelineSettled ?? 0, event.payload.cycle)
|
|
1211
|
+
break
|
|
1097
1212
|
case 'finalize.step-completed':
|
|
1098
1213
|
// §5: post-steps are independent and failure-tolerant — a completion
|
|
1099
1214
|
// counts whether `ok` is true or false. Retain full-log history with
|
|
@@ -1177,6 +1292,17 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1177
1292
|
seq: event.seq,
|
|
1178
1293
|
})
|
|
1179
1294
|
break
|
|
1295
|
+
case 'build.janitor-escalated':
|
|
1296
|
+
if (!openEscalations.has(event.payload.id))
|
|
1297
|
+
openEscalations.set(event.payload.id, {
|
|
1298
|
+
id: event.payload.id,
|
|
1299
|
+
phase: 'setup',
|
|
1300
|
+
source: 'policy',
|
|
1301
|
+
janitor: true,
|
|
1302
|
+
question: event.payload.question,
|
|
1303
|
+
seq: event.seq,
|
|
1304
|
+
})
|
|
1305
|
+
break
|
|
1180
1306
|
case 'escalation.raised': {
|
|
1181
1307
|
const escalation: OpenEscalation = {
|
|
1182
1308
|
id: event.payload.id,
|
|
@@ -1215,6 +1341,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1215
1341
|
: {}),
|
|
1216
1342
|
answeredSeq: event.seq,
|
|
1217
1343
|
})
|
|
1344
|
+
if (open.janitor && acc.janitor?.escalation === open.id) acc.janitor.retryRequested = true
|
|
1218
1345
|
if (
|
|
1219
1346
|
event.payload.reviewRoundCeiling !== undefined &&
|
|
1220
1347
|
open.source === 'policy' &&
|
|
@@ -1297,21 +1424,26 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1297
1424
|
discardRequest,
|
|
1298
1425
|
pending,
|
|
1299
1426
|
} = acc
|
|
1427
|
+
const latestExecution = acc.executions.at(-1)
|
|
1300
1428
|
|
|
1301
1429
|
// §15.5 precedence: aborted/done (terminal, latest wins) > paused >
|
|
1302
1430
|
// blocked > running > queued. See BuildState.status for the paused+blocked
|
|
1303
1431
|
// overlap rule.
|
|
1304
|
-
const
|
|
1432
|
+
const statusOf = (escalations: readonly OpenEscalation[]): BuildStatus =>
|
|
1305
1433
|
terminal ??
|
|
1306
1434
|
(pausedFlag
|
|
1307
1435
|
? 'paused'
|
|
1308
|
-
:
|
|
1436
|
+
: escalations.length > 0 || integrationFailed(acc)
|
|
1309
1437
|
? 'blocked'
|
|
1310
1438
|
: acc.kind === 'node' && acc.nodeOpened !== undefined
|
|
1311
1439
|
? 'collecting'
|
|
1312
1440
|
: attached
|
|
1313
1441
|
? 'running'
|
|
1314
1442
|
: 'queued')
|
|
1443
|
+
const status = statusOf(acc.openEscalations)
|
|
1444
|
+
const statusWithoutJanitorEscalation = acc.openEscalations.some((e) => e.janitor)
|
|
1445
|
+
? statusOf(acc.openEscalations.filter((e) => !e.janitor))
|
|
1446
|
+
: undefined
|
|
1315
1447
|
|
|
1316
1448
|
const active = currentPhase ?? lastCompletedPhase
|
|
1317
1449
|
|
|
@@ -1326,8 +1458,10 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1326
1458
|
pollingActivity: acc.pollingActivity,
|
|
1327
1459
|
nodePolling: acc.nodePolling,
|
|
1328
1460
|
nodeComparison: acc.nodeComparison,
|
|
1461
|
+
...(acc.nodeIssueLinks !== undefined ? { nodeIssueLinks: acc.nodeIssueLinks } : {}),
|
|
1329
1462
|
nodeRestack: acc.nodeRestack,
|
|
1330
1463
|
status,
|
|
1464
|
+
...(statusWithoutJanitorEscalation !== undefined ? { statusWithoutJanitorEscalation } : {}),
|
|
1331
1465
|
outcome: acc.outcome,
|
|
1332
1466
|
phase: active?.phase,
|
|
1333
1467
|
round: acc.round,
|
|
@@ -1343,6 +1477,7 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1343
1477
|
landing: acc.landing,
|
|
1344
1478
|
autoMerge: acc.autoMerge,
|
|
1345
1479
|
finalizeCompletedSeq: acc.finalizeCompletedSeq,
|
|
1480
|
+
...(acc.pipelineSettled !== undefined ? { pipelineSettled: acc.pipelineSettled } : {}),
|
|
1346
1481
|
finalizeSteps: acc.finalizeSteps,
|
|
1347
1482
|
lastEvent,
|
|
1348
1483
|
lastSeq: Math.max(lastEvent?.seq ?? 0, acc.compatibility.lastSeq),
|
|
@@ -1352,6 +1487,10 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1352
1487
|
? { drainingExecutions: structuredClone(acc.drainingExecutions) }
|
|
1353
1488
|
: {}),
|
|
1354
1489
|
pinnedAssets: acc.pinnedAssets,
|
|
1490
|
+
issueLinks: acc.issueLinks,
|
|
1491
|
+
...(acc.issueLinksSealedSeq !== undefined
|
|
1492
|
+
? { issueLinksSealedSeq: acc.issueLinksSealedSeq }
|
|
1493
|
+
: {}),
|
|
1355
1494
|
specRev: acc.specRev,
|
|
1356
1495
|
restartSince: acc.restartSince,
|
|
1357
1496
|
plan: acc.plan,
|
|
@@ -1367,6 +1506,9 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1367
1506
|
setupFailure: acc.setupFailure,
|
|
1368
1507
|
dispatchFailures: acc.dispatchFailures,
|
|
1369
1508
|
executions: acc.executions,
|
|
1509
|
+
...(latestExecution && !acc.endedExecutionInstances[latestExecution.instance]
|
|
1510
|
+
? { openExecution: latestExecution }
|
|
1511
|
+
: {}),
|
|
1370
1512
|
infrastructureFailures: acc.infrastructureFailures,
|
|
1371
1513
|
infrastructureFailure: acc.infrastructureFailure,
|
|
1372
1514
|
cleanupAttempts: acc.cleanupAttempts,
|
|
@@ -64,3 +64,19 @@ export const ticketPreparationReducer = defineReducer<
|
|
|
64
64
|
},
|
|
65
65
|
finish: (acc) => structuredClone(acc),
|
|
66
66
|
})
|
|
67
|
+
|
|
68
|
+
/** The one operator line for a durably abandoned attempt. An unconfirmed
|
|
69
|
+
* claim is never reported as applied: its provider outcome is unknown. An
|
|
70
|
+
* event written before claim certainty was recorded says so. */
|
|
71
|
+
export function abandonedPreparationDiagnostic(
|
|
72
|
+
attempt: { attempt: string; ticket: TicketRef; claimed?: boolean },
|
|
73
|
+
reason?: string,
|
|
74
|
+
): string {
|
|
75
|
+
const claim =
|
|
76
|
+
attempt.claimed === true
|
|
77
|
+
? 'claim confirmed'
|
|
78
|
+
: attempt.claimed === false
|
|
79
|
+
? 'claim unconfirmed (provider outcome unknown; it may have applied the claim)'
|
|
80
|
+
: 'claim certainty not recorded (provider outcome unknown)'
|
|
81
|
+
return `ticket ${attempt.ticket.id} (${attempt.ticket.source}): preparation ${attempt.attempt} abandoned; ${claim}; ticket unchanged — ${reason ?? 'no reason recorded'}`
|
|
82
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escalation wording for the build-wide `maxVerifyAttempts` budget. It
|
|
3
|
+
* describes, and never decides: the engine counts distinct failed attempts and
|
|
4
|
+
* hands this module the same failed records it counted, so the attempts listed
|
|
5
|
+
* are exactly the attempts that consumed the budget.
|
|
6
|
+
*
|
|
7
|
+
* The question claims a step failed repeatedly only when that step failed in
|
|
8
|
+
* every counted cycle; otherwise it names the latest failed cycle's steps.
|
|
9
|
+
*/
|
|
10
|
+
import type { VerifyRecord } from './log-index'
|
|
11
|
+
|
|
12
|
+
type CountedFailure = Pick<VerifyRecord, 'step' | 'attempt'>
|
|
13
|
+
|
|
14
|
+
export function verifyBudgetExhaustedQuestion(
|
|
15
|
+
limit: number,
|
|
16
|
+
fails: readonly CountedFailure[],
|
|
17
|
+
): string {
|
|
18
|
+
const byAttempt = new Map<number, string[]>()
|
|
19
|
+
for (const fail of fails) {
|
|
20
|
+
const steps = byAttempt.get(fail.attempt) ?? []
|
|
21
|
+
if (!steps.includes(fail.step)) steps.push(fail.step)
|
|
22
|
+
byAttempt.set(fail.attempt, steps)
|
|
23
|
+
}
|
|
24
|
+
const attempts = [...byAttempt.keys()].sort((a, b) => a - b)
|
|
25
|
+
const label = (steps: readonly string[]) => steps.map((step) => `verify:${step}`).join(', ')
|
|
26
|
+
const history = attempts
|
|
27
|
+
.map((attempt) => `attempt ${attempt} (${label(byAttempt.get(attempt)!)})`)
|
|
28
|
+
.join(', ')
|
|
29
|
+
const cycles =
|
|
30
|
+
attempts.length === 1
|
|
31
|
+
? '1 failed verify cycle counts'
|
|
32
|
+
: `${attempts.length} failed verify cycles count`
|
|
33
|
+
const latest = attempts.at(-1)
|
|
34
|
+
const latestSteps = latest === undefined ? [] : byAttempt.get(latest)!
|
|
35
|
+
const everyCycle = latestSteps.filter((step) =>
|
|
36
|
+
attempts.every((attempt) => byAttempt.get(attempt)!.includes(step)),
|
|
37
|
+
)
|
|
38
|
+
const diagnosis =
|
|
39
|
+
everyCycle.length > 0
|
|
40
|
+
? `${label(everyCycle)} failed in every counted cycle.`
|
|
41
|
+
: `No single step failed in every counted cycle; the latest failed cycle, attempt ${latest}, failed ${label(latestSteps)}.`
|
|
42
|
+
return `maxVerifyAttempts (${limit}) exhausted: ${cycles} against the build-wide budget: ${history}. ${diagnosis}`
|
|
43
|
+
}
|
|
@@ -89,6 +89,7 @@ export type {
|
|
|
89
89
|
} from './tickets'
|
|
90
90
|
export {
|
|
91
91
|
openOperatorTickets,
|
|
92
|
+
operatorControlTickets,
|
|
92
93
|
prepareOperatorTicketAssets,
|
|
93
94
|
listOperatorTicketStates,
|
|
94
95
|
createOperatorTicketState,
|
|
@@ -122,7 +123,8 @@ export { reduceBuild } from '../kernel/reducer'
|
|
|
122
123
|
export { TicketOperationError } from '../ports/tickets/operations'
|
|
123
124
|
export { humanActor, type Via } from '../events/envelope'
|
|
124
125
|
export type { HarvestStatusView } from '../cli/harvest'
|
|
125
|
-
export
|
|
126
|
+
export { OPERATOR_PRESENCE_UNAVAILABLE } from '../cli/repository-status'
|
|
127
|
+
export type { RepositoryOperatorStatus, RepositoryStatus } from '../cli/repository-status'
|
|
126
128
|
export type { BuildSummary } from '../cli/status'
|
|
127
129
|
export type { SessionRecord } from '../store/types'
|
|
128
130
|
|
|
@@ -13,6 +13,7 @@ export {
|
|
|
13
13
|
repositoryActionAvailability,
|
|
14
14
|
} from '../cli/dashboard/actions'
|
|
15
15
|
export type { DashboardActionAvailability, DashboardBuildControl } from '../cli/dashboard/actions'
|
|
16
|
+
export { NO_DISPATCHER_RUN_LINE, activeCounterText } from '../cli/dashboard/configuration'
|
|
16
17
|
export type {
|
|
17
18
|
DashboardBuild,
|
|
18
19
|
DashboardHarvest,
|
|
@@ -38,3 +39,5 @@ export type { DashboardHandoff } from '../cli/dashboard/handoff'
|
|
|
38
39
|
export { formatRollback } from '../cli/dashboard/rollback'
|
|
39
40
|
export type { DashboardRollback } from '../cli/dashboard/rollback'
|
|
40
41
|
export { handPushedLabel, handPushedText } from '../cli/dashboard/hand-pushed'
|
|
42
|
+
export { URGENT_MARK, queuedTickets } from '../cli/dashboard/queue'
|
|
43
|
+
export type { QueuedTicket } from '../cli/dashboard/queue'
|