@defrex/autobuild 1.4.1 → 1.5.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 +440 -95
- 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 +2 -1
- package/docs/architecture.md +290 -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 +166 -101
- package/docs/dispatcher-hosting.md +19 -3
- package/docs/dispatcher.md +9 -4
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +91 -28
- package/docs/merge-policy.md +28 -9
- package/docs/operator-api.md +43 -18
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +85 -8
- package/docs/remote-store-protocol.md +25 -7
- package/docs/remote-ticket-protocol.md +126 -12
- package/docs/restacking.md +20 -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 +2 -2
- package/docs/verification.md +5 -5
- package/docs/website.md +8 -0
- package/docs/workspaces.md +1 -1
- package/package.json +5 -4
- package/packages/core/src/accounts/hosted-readiness.ts +21 -0
- package/packages/core/src/cli/attention.ts +1 -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 +40 -10
- package/packages/core/src/cli/dashboard/queue.ts +21 -0
- package/packages/core/src/cli/dashboard/render.ts +40 -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-repository-feed.ts +40 -11
- package/packages/core/src/cli/dispatch.ts +154 -47
- package/packages/core/src/cli/help.ts +59 -22
- 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/repository-status.ts +201 -49
- package/packages/core/src/cli/status.ts +41 -3
- 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/watch.ts +4 -0
- 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 +164 -36
- package/packages/core/src/distribution-packaging.ts +1 -1
- package/packages/core/src/events/catalog.ts +5 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/payloads.ts +70 -0
- package/packages/core/src/events/policy.ts +8 -0
- package/packages/core/src/events/repository.ts +91 -28
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +41 -0
- 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 +80 -14
- 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 +4 -2
- package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -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/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 +11 -0
- 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/log-index.ts +1 -1
- package/packages/core/src/kernel/node-issue-links.ts +142 -0
- 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 +31 -1
- package/packages/core/src/kernel/reducer.ts +90 -2
- package/packages/core/src/kernel/ticket-preparation.ts +12 -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 +66 -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 +72 -17
- 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 -11
- package/packages/core/src/ports/workspace/commit-preservation.ts +135 -13
- package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +132 -27
- package/packages/core/src/processes/build-runner.ts +99 -21
- package/packages/core/src/processes/dispatcher.ts +1080 -533
- package/packages/core/src/processes/execution-no-progress.ts +5 -0
- package/packages/core/src/processes/harvest-runner.ts +17 -8
- 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 +37 -2
- package/packages/core/src/runtime-identity.ts +10 -2
- package/packages/core/src/scenarios/harness.ts +4 -0
- 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/reducer-value-shapes.json +4187 -3391
- 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/index.ts +2 -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 +1197 -31
- 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 +382 -139
- 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 +43 -18
- package/skills/guide/references/plugin-authoring.md +85 -8
- package/skills/guide/references/remote-store-protocol.md +25 -7
- package/skills/guide/references/remote-ticket-protocol.md +126 -12
- package/skills/guide/references/restacking.md +20 -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 +103 -28
- 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 +114 -37
- package/templates/autobuild.toml +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -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
|
|
@@ -134,6 +149,8 @@ export interface OpenSession {
|
|
|
134
149
|
round?: number
|
|
135
150
|
/** Live-view stream id (SPEC §9); absent on historical events. */
|
|
136
151
|
stream?: string
|
|
152
|
+
/** Effective first message the bracket sent; absent on historical events. */
|
|
153
|
+
prompt?: string
|
|
137
154
|
/** seq of the `session.started` event. */
|
|
138
155
|
seq: number
|
|
139
156
|
}
|
|
@@ -216,6 +233,12 @@ export interface BuildState {
|
|
|
216
233
|
pollingActivity?: Record<string, string>
|
|
217
234
|
nodePolling?: EventPayload<'node.poll-checked'> & { checkedAt: string }
|
|
218
235
|
nodeComparison?: EventPayload<'node.compared'>
|
|
236
|
+
/** A node's issue-link union (SPEC "Forge issue links"). `builds` is the
|
|
237
|
+
* sorted set of child slugs whose `node.issue-links-recorded` folded in,
|
|
238
|
+
* the durable evidence that keeps a crash retry from recording twice;
|
|
239
|
+
* `links` is the running union; `published` is the last confirmed PR body
|
|
240
|
+
* readback. Absent until the first fact. */
|
|
241
|
+
nodeIssueLinks?: NodeIssueLinksState
|
|
219
242
|
|
|
220
243
|
/**
|
|
221
244
|
* §15.5: 'queued' until `runner.attached`, 'running' after;
|
|
@@ -286,6 +309,13 @@ export interface BuildState {
|
|
|
286
309
|
/** Ticket assets the build froze: set by `build.created`, replaced by a
|
|
287
310
|
* `spec.revised` that carries `assets` (§6.3). Empty for historical logs. */
|
|
288
311
|
pinnedAssets: PinnedAsset[]
|
|
312
|
+
/** Forge issue links frozen by `build.created`, with any downgrade applied
|
|
313
|
+
* before the seal. Spec revisions never resample them. Empty for
|
|
314
|
+
* historical logs. */
|
|
315
|
+
issueLinks: BuildIssueLink[]
|
|
316
|
+
/** seq of the fact that closed the downgrade window: `issue-links.sealed`,
|
|
317
|
+
* `publication.requested {operation: 'finalize'}` or `finalize.completed`. */
|
|
318
|
+
issueLinksSealedSeq?: number
|
|
289
319
|
/** Latest spec artifact rev — `spec.imported`/`spec.authored` set it,
|
|
290
320
|
* `spec.revised` bumps it (§6.3: rev N+1 restarts leaves from plan and nodes from collection). */
|
|
291
321
|
specRev?: number
|
|
@@ -411,6 +441,12 @@ export interface BuildAcc {
|
|
|
411
441
|
pollingActivity?: Record<string, string>
|
|
412
442
|
nodePolling?: EventPayload<'node.poll-checked'> & { checkedAt: string }
|
|
413
443
|
nodeComparison?: EventPayload<'node.compared'>
|
|
444
|
+
/** A node's issue-link union (SPEC "Forge issue links"). `builds` is the
|
|
445
|
+
* sorted set of child slugs whose `node.issue-links-recorded` folded in,
|
|
446
|
+
* the durable evidence that keeps a crash retry from recording twice;
|
|
447
|
+
* `links` is the running union; `published` is the last confirmed PR body
|
|
448
|
+
* readback. Absent until the first fact. */
|
|
449
|
+
nodeIssueLinks?: NodeIssueLinksState
|
|
414
450
|
|
|
415
451
|
attached: boolean
|
|
416
452
|
pausedFlag: boolean
|
|
@@ -437,6 +473,8 @@ export interface BuildAcc {
|
|
|
437
473
|
specRev?: number
|
|
438
474
|
restartSince: number
|
|
439
475
|
pinnedAssets: PinnedAsset[]
|
|
476
|
+
issueLinks: BuildIssueLink[]
|
|
477
|
+
issueLinksSealedSeq?: number
|
|
440
478
|
finalizeCompletedSeq: number
|
|
441
479
|
finalizeSteps: BuildState['finalizeSteps']
|
|
442
480
|
plan: BuildState['plan']
|
|
@@ -467,7 +505,7 @@ export interface BuildAcc {
|
|
|
467
505
|
}
|
|
468
506
|
|
|
469
507
|
/** Bump when `BuildAcc`'s shape or the fold's semantics change. */
|
|
470
|
-
export const BUILD_REDUCER_VERSION =
|
|
508
|
+
export const BUILD_REDUCER_VERSION = 30
|
|
471
509
|
|
|
472
510
|
function initialBuildAcc(): BuildAcc {
|
|
473
511
|
return {
|
|
@@ -486,6 +524,7 @@ function initialBuildAcc(): BuildAcc {
|
|
|
486
524
|
autoMerge: { requested: false },
|
|
487
525
|
restartSince: 0,
|
|
488
526
|
pinnedAssets: [],
|
|
527
|
+
issueLinks: [],
|
|
489
528
|
finalizeCompletedSeq: 0,
|
|
490
529
|
finalizeSteps: [],
|
|
491
530
|
plan: { round: 0, approved: false },
|
|
@@ -696,6 +735,29 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
696
735
|
case 'node.compared':
|
|
697
736
|
acc.nodeComparison = event.payload
|
|
698
737
|
break
|
|
738
|
+
case 'node.issue-links-recorded': {
|
|
739
|
+
// Idempotent by construction: a repeated fact for a recorded build
|
|
740
|
+
// re-merges the same links and leaves `builds` unchanged.
|
|
741
|
+
const current = acc.nodeIssueLinks ?? { builds: [], links: [] }
|
|
742
|
+
acc.nodeIssueLinks = {
|
|
743
|
+
...current,
|
|
744
|
+
builds: current.builds.includes(event.payload.build)
|
|
745
|
+
? current.builds
|
|
746
|
+
: [...current.builds, event.payload.build].sort(),
|
|
747
|
+
links: mergeNodeIssueLinks(current.links, event.payload.issueLinks),
|
|
748
|
+
}
|
|
749
|
+
break
|
|
750
|
+
}
|
|
751
|
+
case 'node.issue-links-published':
|
|
752
|
+
acc.nodeIssueLinks = {
|
|
753
|
+
...(acc.nodeIssueLinks ?? { builds: [], links: [] }),
|
|
754
|
+
published: {
|
|
755
|
+
pr: event.payload.pr,
|
|
756
|
+
issueLinks: event.payload.issueLinks.map(({ issue, intent }) => ({ issue, intent })),
|
|
757
|
+
seq: event.seq,
|
|
758
|
+
},
|
|
759
|
+
}
|
|
760
|
+
break
|
|
699
761
|
case 'node.rewritten':
|
|
700
762
|
if (acc.nodeComparison)
|
|
701
763
|
acc.nodeComparison = { ...acc.nodeComparison, headSha: event.payload.head }
|
|
@@ -710,6 +772,22 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
710
772
|
acc.target = event.payload.target
|
|
711
773
|
acc.baseBranch = event.payload.baseBranch
|
|
712
774
|
pinnedAssets = event.payload.assets ?? []
|
|
775
|
+
acc.issueLinks = (event.payload.issueLinks ?? []).map((link) => ({ ...link }))
|
|
776
|
+
break
|
|
777
|
+
case 'issue-link.downgraded': {
|
|
778
|
+
// One-way and only before the seal: a later, a repeated or an
|
|
779
|
+
// unknown downgrade is inert, so PR composition never changes.
|
|
780
|
+
const { issue, reason } = event.payload
|
|
781
|
+
if (acc.issueLinksSealedSeq !== undefined) break
|
|
782
|
+
acc.issueLinks = acc.issueLinks.map((link) =>
|
|
783
|
+
link.issue === issue && link.intent === 'closes'
|
|
784
|
+
? { issue, intent: 'refs', downgrade: { reason, seq: event.seq } }
|
|
785
|
+
: link,
|
|
786
|
+
)
|
|
787
|
+
break
|
|
788
|
+
}
|
|
789
|
+
case 'issue-links.sealed':
|
|
790
|
+
acc.issueLinksSealedSeq ??= event.seq
|
|
713
791
|
break
|
|
714
792
|
case 'workspace.provisioned':
|
|
715
793
|
case 'workspace.cleanup-required':
|
|
@@ -722,7 +800,10 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
722
800
|
case 'pr-summary.result':
|
|
723
801
|
case 'pr-summary.settled':
|
|
724
802
|
case 'finalize.step-started':
|
|
803
|
+
break
|
|
725
804
|
case 'publication.requested':
|
|
805
|
+
if (event.payload.operation === 'finalize') acc.issueLinksSealedSeq ??= event.seq
|
|
806
|
+
break
|
|
726
807
|
// Inert loss fact (AUT-328): the dispatcher released a workspace with a
|
|
727
808
|
// pending publication. Recovery runs through the existing
|
|
728
809
|
// abandoned-publication flow (abandonedPublicationPending), which re-runs
|
|
@@ -894,6 +975,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
894
975
|
phase: event.payload.phase,
|
|
895
976
|
round: event.payload.round,
|
|
896
977
|
stream: event.payload.stream,
|
|
978
|
+
prompt: event.payload.prompt,
|
|
897
979
|
seq: event.seq,
|
|
898
980
|
})
|
|
899
981
|
break
|
|
@@ -1089,6 +1171,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1089
1171
|
start({ phase: 'finalize', seq: event.seq })
|
|
1090
1172
|
break
|
|
1091
1173
|
case 'finalize.completed':
|
|
1174
|
+
acc.issueLinksSealedSeq ??= event.seq
|
|
1092
1175
|
pr = event.payload.pr
|
|
1093
1176
|
prState = 'open'
|
|
1094
1177
|
finalizeCompletedSeq = event.seq
|
|
@@ -1326,6 +1409,7 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1326
1409
|
pollingActivity: acc.pollingActivity,
|
|
1327
1410
|
nodePolling: acc.nodePolling,
|
|
1328
1411
|
nodeComparison: acc.nodeComparison,
|
|
1412
|
+
...(acc.nodeIssueLinks !== undefined ? { nodeIssueLinks: acc.nodeIssueLinks } : {}),
|
|
1329
1413
|
nodeRestack: acc.nodeRestack,
|
|
1330
1414
|
status,
|
|
1331
1415
|
outcome: acc.outcome,
|
|
@@ -1352,6 +1436,10 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1352
1436
|
? { drainingExecutions: structuredClone(acc.drainingExecutions) }
|
|
1353
1437
|
: {}),
|
|
1354
1438
|
pinnedAssets: acc.pinnedAssets,
|
|
1439
|
+
issueLinks: acc.issueLinks,
|
|
1440
|
+
...(acc.issueLinksSealedSeq !== undefined
|
|
1441
|
+
? { issueLinksSealedSeq: acc.issueLinksSealedSeq }
|
|
1442
|
+
: {}),
|
|
1355
1443
|
specRev: acc.specRev,
|
|
1356
1444
|
restartSince: acc.restartSince,
|
|
1357
1445
|
plan: acc.plan,
|
|
@@ -64,3 +64,15 @@ 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. */
|
|
70
|
+
export function abandonedPreparationDiagnostic(
|
|
71
|
+
attempt: Pick<TicketPreparation, 'attempt' | 'ticket' | 'claimed'>,
|
|
72
|
+
reason: string,
|
|
73
|
+
): string {
|
|
74
|
+
const claim = attempt.claimed
|
|
75
|
+
? 'claim confirmed'
|
|
76
|
+
: 'claim unconfirmed (provider outcome unknown; it may have applied the claim)'
|
|
77
|
+
return `ticket ${attempt.ticket.id} (${attempt.ticket.source}): preparation ${attempt.attempt} abandoned; ${claim}; ticket unchanged — ${reason}`
|
|
78
|
+
}
|
|
@@ -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'
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
|
+
import { issueLinksInputSchema } from '../ports/tickets/issue-links'
|
|
3
|
+
import { TICKET_MOVE_ROLES } from '../ports/tickets/lifecycle'
|
|
4
|
+
import { ticketPrioritySchema } from '../ports/tickets/priority'
|
|
5
|
+
|
|
6
|
+
const issueLinksField = issueLinksInputSchema
|
|
7
|
+
.optional()
|
|
8
|
+
.describe(
|
|
9
|
+
'Forge issues this ticket addresses: {issue, intent?}; intent "closes" (default) or "refs" for partial work. On update, a complete replacement; [] clears.',
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
const priorityField = ticketPrioritySchema
|
|
13
|
+
.optional()
|
|
14
|
+
.describe(
|
|
15
|
+
'Dispatch class: "urgent" is claimed before normal ready work (never preempting a running build); "normal" (the default) removes urgency. Sources that cannot store priority refuse urgent.',
|
|
16
|
+
)
|
|
2
17
|
|
|
3
18
|
export const buildListScopeSchema = z.enum(['active', 'queued', 'all'])
|
|
4
19
|
|
|
@@ -56,6 +71,8 @@ export const ticketCreateRequestSchema = z.strictObject({
|
|
|
56
71
|
labels: z.array(z.string()).optional(),
|
|
57
72
|
state: z.string().min(1).optional(),
|
|
58
73
|
blockedBy: z.array(z.string().min(1)).optional(),
|
|
74
|
+
issueLinks: issueLinksField,
|
|
75
|
+
priority: priorityField,
|
|
59
76
|
})
|
|
60
77
|
const expectedRevisionSchema = z
|
|
61
78
|
.string()
|
|
@@ -69,12 +86,16 @@ export const ticketUpdateRequestSchema = z
|
|
|
69
86
|
title: z.string().optional(),
|
|
70
87
|
body: z.string().optional(),
|
|
71
88
|
labels: z.array(z.string()).optional(),
|
|
89
|
+
issueLinks: issueLinksField,
|
|
90
|
+
priority: priorityField,
|
|
72
91
|
})
|
|
73
92
|
.refine(
|
|
74
93
|
(value) =>
|
|
75
94
|
value.title !== undefined ||
|
|
76
95
|
value.body !== undefined ||
|
|
77
96
|
value.labels !== undefined ||
|
|
97
|
+
value.issueLinks !== undefined ||
|
|
98
|
+
value.priority !== undefined ||
|
|
78
99
|
value.kind !== undefined ||
|
|
79
100
|
value.target !== undefined,
|
|
80
101
|
'update must name at least one field',
|
|
@@ -85,10 +106,25 @@ export const ticketPageSchema = z.strictObject({
|
|
|
85
106
|
offset: z.number().int().min(0).optional(),
|
|
86
107
|
order: z.enum(['oldest', 'newest']).optional(),
|
|
87
108
|
})
|
|
88
|
-
|
|
109
|
+
/** The unrefined move shape, so tool inputs can extend it; validate requests
|
|
110
|
+
* with `ticketMoveRequestSchema`, which requires exactly one target. */
|
|
111
|
+
export const ticketMoveRequestShape = z.strictObject({
|
|
89
112
|
expectedRevision: expectedRevisionSchema,
|
|
90
|
-
state: z.string().min(1),
|
|
113
|
+
state: z.string().min(1).optional(),
|
|
114
|
+
role: z
|
|
115
|
+
.enum(TICKET_MOVE_ROLES)
|
|
116
|
+
.optional()
|
|
117
|
+
.describe(
|
|
118
|
+
"Lifecycle role to move the ticket into, resolved through this repository's [tickets] configuration. Destructive for `ready`.",
|
|
119
|
+
),
|
|
91
120
|
})
|
|
121
|
+
export const exactlyOneMoveTarget = (value: { state?: string; role?: string }): boolean =>
|
|
122
|
+
(value.state === undefined) !== (value.role === undefined)
|
|
123
|
+
export const MOVE_TARGET_MESSAGE = 'move must name exactly one of state or role'
|
|
124
|
+
export const ticketMoveRequestSchema = ticketMoveRequestShape.refine(
|
|
125
|
+
exactlyOneMoveTarget,
|
|
126
|
+
MOVE_TARGET_MESSAGE,
|
|
127
|
+
)
|
|
92
128
|
export const ticketBlockerRequestSchema = z.strictObject({
|
|
93
129
|
expectedRevision: expectedRevisionSchema,
|
|
94
130
|
blockerIds: z.array(z.string().min(1)).min(1),
|
|
@@ -2,7 +2,7 @@ import { normalizeEffectiveConfigArtifact } from '../config/effective-artifact'
|
|
|
2
2
|
import { migrationIdentity } from '../kernel/ticket-migrations'
|
|
3
3
|
import { enrichDrainingRow, projectHandoffs } from '../cli/dashboard/handoff'
|
|
4
4
|
import { enrichIntegrationRows } from '../cli/dashboard/integration-row'
|
|
5
|
-
import { dispatchCapacity, type CapacityBuild } from '../kernel/dispatch-capacity'
|
|
5
|
+
import { dispatchCapacity, slotRequest, type CapacityBuild } from '../kernel/dispatch-capacity'
|
|
6
6
|
import { forgeReadinessWarnings } from '../kernel/dispatch-status'
|
|
7
7
|
import { readBuildDigests } from '../store/reduced-reads'
|
|
8
8
|
import {
|
|
@@ -43,7 +43,6 @@ import {
|
|
|
43
43
|
import type { BuildState } from '../kernel/reducer'
|
|
44
44
|
import { DISPATCHER_EFFECTIVE_CONFIG_ARTIFACT } from '../store/retention'
|
|
45
45
|
import { reduceDispatchStatus } from '../kernel/dispatch-status'
|
|
46
|
-
import { unclaimedObservationCount } from '../processes/harvest'
|
|
47
46
|
import type { RepoViewStore } from '../processes/repo-view'
|
|
48
47
|
import { withOperatorView } from './read-view'
|
|
49
48
|
import type { RepositoryEvent } from '../events/repository'
|
|
@@ -53,7 +52,11 @@ export type BuildListScope = 'active' | 'queued' | 'all'
|
|
|
53
52
|
|
|
54
53
|
export class OperatorQueryError extends Error {
|
|
55
54
|
constructor(
|
|
56
|
-
readonly code:
|
|
55
|
+
readonly code:
|
|
56
|
+
| 'not-found'
|
|
57
|
+
| 'effective-config-unavailable'
|
|
58
|
+
| 'no-dispatcher-run'
|
|
59
|
+
| 'external-ticket-source',
|
|
57
60
|
message: string,
|
|
58
61
|
) {
|
|
59
62
|
super(message)
|
|
@@ -109,7 +112,24 @@ async function listFromView(
|
|
|
109
112
|
// build therefore cannot change the emitted summaries.
|
|
110
113
|
if (digest.terminal !== undefined) continue
|
|
111
114
|
}
|
|
112
|
-
const
|
|
115
|
+
const facts = await view.buildFacts(record.slug)
|
|
116
|
+
const projected = summarizeFrom(
|
|
117
|
+
record,
|
|
118
|
+
facts.state,
|
|
119
|
+
opts.now,
|
|
120
|
+
facts.state.kind === 'node'
|
|
121
|
+
? slotRequest(
|
|
122
|
+
{
|
|
123
|
+
record,
|
|
124
|
+
state: facts.state,
|
|
125
|
+
workspace: facts.workspace !== null,
|
|
126
|
+
provisioning:
|
|
127
|
+
(await readBuildFacts(view, record.slug)).value.provisionMarker !== undefined,
|
|
128
|
+
},
|
|
129
|
+
opts.now,
|
|
130
|
+
)
|
|
131
|
+
: undefined,
|
|
132
|
+
)
|
|
113
133
|
if (statuses.has(projected.status)) output.push(projected)
|
|
114
134
|
}
|
|
115
135
|
return output.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
|
|
@@ -137,11 +157,13 @@ export async function effectiveConfig(
|
|
|
137
157
|
}> {
|
|
138
158
|
const repositoryEvents = journal ?? (await readRepositoryFacts(store, repo)).value
|
|
139
159
|
const status = repositoryEvents.status
|
|
140
|
-
if (status?.effectiveConfig === undefined)
|
|
160
|
+
if (status?.effectiveConfig === undefined) {
|
|
161
|
+
if (repositoryEvents.config.run === undefined) throw noDispatcherRunError(repo)
|
|
141
162
|
throw new OperatorQueryError(
|
|
142
163
|
'effective-config-unavailable',
|
|
143
|
-
`effective config unavailable for repository "${repo}"
|
|
164
|
+
`effective config unavailable for repository "${repo}"`,
|
|
144
165
|
)
|
|
166
|
+
}
|
|
145
167
|
const ref = status.effectiveConfig!
|
|
146
168
|
const artifact = await store.getRepoArtifact(repo, ref.kind, ref.rev)
|
|
147
169
|
if (artifact === null) {
|
|
@@ -157,6 +179,15 @@ export async function effectiveConfig(
|
|
|
157
179
|
}
|
|
158
180
|
}
|
|
159
181
|
|
|
182
|
+
/** No `dispatcher.run-started` is recorded: pipeline configuration is not
|
|
183
|
+
* merely unreadable, it has never existed. */
|
|
184
|
+
export function noDispatcherRunError(repo: string): OperatorQueryError {
|
|
185
|
+
return new OperatorQueryError(
|
|
186
|
+
'no-dispatcher-run',
|
|
187
|
+
`effective config unavailable for repository "${repo}": no dispatcher run is recorded`,
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
160
191
|
function latestDispatchConfigStatus(repositoryEvents: RepositoryEvent[]) {
|
|
161
192
|
let latestRun: string | undefined
|
|
162
193
|
for (const event of repositoryEvents) {
|
|
@@ -172,12 +203,7 @@ export function findEffectiveConfigRef(repositoryEvents: RepositoryEvent[]) {
|
|
|
172
203
|
|
|
173
204
|
export function selectEffectiveConfig(repositoryEvents: RepositoryEvent[], repo: string) {
|
|
174
205
|
const status = latestDispatchConfigStatus(repositoryEvents)
|
|
175
|
-
if (status === undefined)
|
|
176
|
-
throw new OperatorQueryError(
|
|
177
|
-
'effective-config-unavailable',
|
|
178
|
-
`effective config unavailable for repository "${repo}": no dispatcher run is recorded`,
|
|
179
|
-
)
|
|
180
|
-
}
|
|
206
|
+
if (status === undefined) throw noDispatcherRunError(repo)
|
|
181
207
|
if (status.effectiveConfig === undefined) {
|
|
182
208
|
throw new OperatorQueryError(
|
|
183
209
|
'effective-config-unavailable',
|
|
@@ -368,16 +394,16 @@ async function dashboardFromView(
|
|
|
368
394
|
view: RepoViewStore,
|
|
369
395
|
opts: { repo: string; clock: Clock },
|
|
370
396
|
): Promise<OperatorDashboardSnapshot> {
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
)
|
|
397
|
+
const facts = view.repositoryFacts()
|
|
398
|
+
// Only the absence of any run is an empty state; a run whose configuration
|
|
399
|
+
// is missing or unreadable still fails below. This branch reads nothing
|
|
400
|
+
// more: no build can exist before a dispatcher claims one.
|
|
401
|
+
if (facts.config.run === undefined) return noDispatcherRunSnapshot(opts.repo, facts, opts.clock)
|
|
402
|
+
const { config, repositoryEvents, status } = await effectiveConfig(view, opts.repo, facts)
|
|
376
403
|
const records = await view.listBuilds()
|
|
377
404
|
// One digest read covers every build of the repository (AUT-487): the
|
|
378
|
-
// row gate (a `done` digest means no row)
|
|
379
|
-
//
|
|
380
|
-
// builds accumulate. Row-rendering builds derive from the repository view's
|
|
405
|
+
// row gate (a `done` digest means no row) needs no per-build histories, so
|
|
406
|
+
// the snapshot's traffic stays flat as finished builds accumulate. Row-rendering builds derive from the repository view's
|
|
381
407
|
// reducer snapshots plus a delta read (AUT-650); every snapshot is a cache
|
|
382
408
|
// the event log regenerates, so the response equals a full replay's.
|
|
383
409
|
const digests = await readBuildDigests(view, opts.repo)
|
|
@@ -426,14 +452,8 @@ async function dashboardFromView(
|
|
|
426
452
|
)
|
|
427
453
|
if (row !== null) projected.push(decorateWithPinnedMeta(row, pinned))
|
|
428
454
|
}
|
|
429
|
-
// The unclaimed-observation count comes from the digests and the journal
|
|
430
|
-
// `effectiveConfig` already returned — no per-build history reads (AUT-487).
|
|
431
455
|
// The pure core writes nothing — a snapshot performs no store writes and
|
|
432
456
|
// never creates or locks the repository record.
|
|
433
|
-
const observationCount = unclaimedObservationCount({
|
|
434
|
-
digests,
|
|
435
|
-
harvestEvents: repositoryEvents.harvest,
|
|
436
|
-
})
|
|
437
457
|
const warningLines = [
|
|
438
458
|
...status.roleWarnings,
|
|
439
459
|
...forgeReadinessWarnings(status),
|
|
@@ -453,8 +473,7 @@ async function dashboardFromView(
|
|
|
453
473
|
activeCount: capacityProjection.occupied,
|
|
454
474
|
capacityProjection,
|
|
455
475
|
capacity: config.capacity,
|
|
456
|
-
|
|
457
|
-
observationLimit: config.policy.harvestThreshold,
|
|
476
|
+
...(status.triage !== undefined ? { triage: status.triage } : {}),
|
|
458
477
|
...(status.availableUpgrade !== undefined
|
|
459
478
|
? { availableUpgrade: status.availableUpgrade }
|
|
460
479
|
: {}),
|
|
@@ -462,8 +481,26 @@ async function dashboardFromView(
|
|
|
462
481
|
},
|
|
463
482
|
repositoryEvents,
|
|
464
483
|
)
|
|
484
|
+
return dashboardSnapshot(model, opts.clock)
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** The dashboard of a repository with no recorded dispatcher run: repository
|
|
488
|
+
* controls reduce from the journal, pipeline configuration is unknown. */
|
|
489
|
+
function noDispatcherRunSnapshot(
|
|
490
|
+
repo: string,
|
|
491
|
+
facts: RepositoryReadFacts,
|
|
492
|
+
clock: Clock,
|
|
493
|
+
): OperatorDashboardSnapshot {
|
|
494
|
+
const model: DashboardModel = {
|
|
495
|
+
...buildDashboardFromProjected([], { repo, queued: 0, activeCount: 0, capacity: 0 }, facts),
|
|
496
|
+
configuration: 'no-dispatcher-run',
|
|
497
|
+
}
|
|
498
|
+
return dashboardSnapshot(model, clock)
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function dashboardSnapshot(model: DashboardModel, clock: Clock): OperatorDashboardSnapshot {
|
|
465
502
|
return {
|
|
466
|
-
generatedAt:
|
|
503
|
+
generatedAt: clock().toISOString(),
|
|
467
504
|
model,
|
|
468
505
|
settingsHeader: {
|
|
469
506
|
intake: !model.drained,
|