@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
|
@@ -106,6 +106,9 @@ export async function observePresence(
|
|
|
106
106
|
return projectPresence(await presenceWitness(git, head), landings, aliases, includeForeign)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/** Full reachable history of a sampled head. In-memory only: it is the
|
|
110
|
+
* compaction source for a {@link PresenceProbe} and is never persisted. Older
|
|
111
|
+
* observations may still carry one as historical evidence. */
|
|
109
112
|
export interface PresenceWitness {
|
|
110
113
|
version: 1
|
|
111
114
|
commits: string[]
|
|
@@ -127,14 +130,144 @@ export async function presenceWitness(git: NodeGit, head: string): Promise<Prese
|
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
/** Durable, query-scoped presence evidence for one sampled head. It records
|
|
134
|
+
* only the SHAs and direct trailers in the reverse proof closure of
|
|
135
|
+
* `questions`, so its size never depends on the destination's reachable
|
|
136
|
+
* commit count, unrelated landings, or repository history. */
|
|
137
|
+
export interface PresenceProbe {
|
|
138
|
+
version: 1
|
|
139
|
+
/** Sorted unique identities this observation answers. */
|
|
140
|
+
questions: ChangeIdentity[]
|
|
141
|
+
/** Sorted unique SHAs whose reachability from head was tested. */
|
|
142
|
+
commits: string[]
|
|
143
|
+
/** Sorted subset of `commits` reachable from head. */
|
|
144
|
+
reachable: string[]
|
|
145
|
+
/** Sorted build identities whose direct trailer was tested. */
|
|
146
|
+
builds: `build:${string}`[]
|
|
147
|
+
/** Sorted subset of `builds` found as trailers in head's history. */
|
|
148
|
+
trailers: `build:${string}`[]
|
|
149
|
+
}
|
|
150
|
+
export interface PresenceNeeds {
|
|
151
|
+
commits: string[]
|
|
152
|
+
builds: `build:${string}`[]
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const transportedBy = (landing: LandingEvidence): ChangeIdentity[] =>
|
|
156
|
+
landing.contribution ?? [`build:${landing.slug}`]
|
|
157
|
+
|
|
158
|
+
/** The reverse proof closure of `query`: every SHA and direct trailer whose
|
|
159
|
+
* reachability could derive a queried identity. A landing enters only when it
|
|
160
|
+
* transports a closure identity, and contributes only its own two keys. */
|
|
161
|
+
export function presenceNeeds(
|
|
162
|
+
query: Iterable<ChangeIdentity>,
|
|
163
|
+
landings: LandingEvidence[],
|
|
164
|
+
aliases: Map<string, string>,
|
|
165
|
+
): PresenceNeeds {
|
|
166
|
+
const transporters = new Map<ChangeIdentity, LandingEvidence[]>()
|
|
167
|
+
for (const landing of landings)
|
|
168
|
+
for (const item of new Set(transportedBy(landing))) {
|
|
169
|
+
const entries = transporters.get(item) ?? []
|
|
170
|
+
entries.push(landing)
|
|
171
|
+
transporters.set(item, entries)
|
|
172
|
+
}
|
|
173
|
+
const keysOf = new Map<string, string[]>()
|
|
174
|
+
for (const key of aliases.keys()) {
|
|
175
|
+
const original = originalForeign(key, aliases)
|
|
176
|
+
const keys = keysOf.get(original) ?? []
|
|
177
|
+
keys.push(key)
|
|
178
|
+
keysOf.set(original, keys)
|
|
179
|
+
}
|
|
180
|
+
const commits = new Set<string>()
|
|
181
|
+
const builds = new Set<`build:${string}`>()
|
|
182
|
+
const visited = new Set<ChangeIdentity>()
|
|
183
|
+
const pending = [...query]
|
|
184
|
+
while (pending.length) {
|
|
185
|
+
const identity = pending.pop()!
|
|
186
|
+
if (visited.has(identity)) continue
|
|
187
|
+
visited.add(identity)
|
|
188
|
+
if (identity.startsWith('build:')) builds.add(identity as `build:${string}`)
|
|
189
|
+
else {
|
|
190
|
+
const sha = identity.slice('foreign:'.length)
|
|
191
|
+
commits.add(sha)
|
|
192
|
+
for (const key of keysOf.get(sha) ?? []) commits.add(key)
|
|
193
|
+
}
|
|
194
|
+
for (const landing of transporters.get(identity) ?? [])
|
|
195
|
+
pending.push(`build:${landing.slug}`, `foreign:${landing.sha}`)
|
|
196
|
+
}
|
|
197
|
+
return { commits: [...commits].sort(), builds: [...builds].sort() }
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function covers(probe: PresenceProbe, needs: PresenceNeeds): boolean {
|
|
201
|
+
const commits = new Set(probe.commits)
|
|
202
|
+
const builds = new Set(probe.builds)
|
|
203
|
+
return (
|
|
204
|
+
needs.commits.every((sha) => commits.has(sha)) && needs.builds.every((id) => builds.has(id))
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Whether a stored probe can answer `query` under the current landings. The
|
|
209
|
+
* needs of every stored question must be covered, because the persisted
|
|
210
|
+
* answers are recomputed for all of them. */
|
|
211
|
+
export function answers(
|
|
212
|
+
probe: PresenceProbe,
|
|
213
|
+
query: Iterable<ChangeIdentity>,
|
|
214
|
+
landings: LandingEvidence[],
|
|
215
|
+
aliases: Map<string, string>,
|
|
216
|
+
): boolean {
|
|
217
|
+
const questions = new Set(probe.questions)
|
|
218
|
+
for (const id of query) if (!questions.has(id)) return false
|
|
219
|
+
return covers(probe, presenceNeeds(probe.questions, landings, aliases))
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function compactProbe(
|
|
223
|
+
witness: PresenceWitness,
|
|
224
|
+
questions: Iterable<ChangeIdentity>,
|
|
225
|
+
landings: LandingEvidence[],
|
|
226
|
+
aliases: Map<string, string>,
|
|
227
|
+
): PresenceProbe {
|
|
228
|
+
const normalized = normalizeIdentities(questions)
|
|
229
|
+
const needs = presenceNeeds(normalized, landings, aliases)
|
|
230
|
+
const reachable = new Set(witness.commits)
|
|
231
|
+
const trailers = new Set(witness.identities)
|
|
232
|
+
return {
|
|
233
|
+
version: 1,
|
|
234
|
+
questions: normalized,
|
|
235
|
+
commits: needs.commits,
|
|
236
|
+
reachable: needs.commits.filter((sha) => reachable.has(sha)),
|
|
237
|
+
builds: needs.builds,
|
|
238
|
+
trailers: needs.builds.filter((id) => trailers.has(id)),
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Presence answers for only the probe's questions. The unrestricted
|
|
243
|
+
* expansion is local: it is never returned, persisted, or hashed. */
|
|
244
|
+
export function projectProbe(
|
|
245
|
+
probe: PresenceProbe,
|
|
246
|
+
landings: LandingEvidence[],
|
|
247
|
+
aliases = new Map<string, string>(),
|
|
248
|
+
): ChangeIdentity[] {
|
|
249
|
+
const present = new Set(
|
|
250
|
+
projectPresence(
|
|
251
|
+
{ version: 1, commits: probe.reachable, identities: probe.trailers },
|
|
252
|
+
landings,
|
|
253
|
+
aliases,
|
|
254
|
+
),
|
|
255
|
+
)
|
|
256
|
+
return normalizeIdentities(probe.questions.filter((id) => present.has(id)))
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function probeEvidence(probe: PresenceProbe, identities: ChangeIdentity[]): string {
|
|
260
|
+
const sorted = <T extends string>(items: Iterable<T>) => [...new Set(items)].sort()
|
|
261
|
+
return `presence-v4:${createHash('sha256')
|
|
132
262
|
.update(
|
|
133
263
|
JSON.stringify([
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
264
|
+
probe.version,
|
|
265
|
+
sorted(probe.questions),
|
|
266
|
+
sorted(probe.commits),
|
|
267
|
+
sorted(probe.reachable),
|
|
268
|
+
sorted(probe.builds),
|
|
269
|
+
sorted(probe.trailers),
|
|
270
|
+
sorted(identities),
|
|
138
271
|
]),
|
|
139
272
|
)
|
|
140
273
|
.digest('hex')}`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TicketRef } from '../ontology'
|
|
2
2
|
import type { BuildRecord } from '../store/types'
|
|
3
3
|
import type { BuildState } from './reducer'
|
|
4
|
-
import { integrationNeedsRunner } from './integration-state'
|
|
4
|
+
import { integrationAdmissible, integrationNeedsRunner } from './integration-state'
|
|
5
5
|
|
|
6
6
|
/** Repository-scoped, reduced facts. Provisioning reserves a slot before a workspace exists. */
|
|
7
7
|
export interface CapacityBuild {
|
|
@@ -11,24 +11,55 @@ export interface CapacityBuild {
|
|
|
11
11
|
provisioning?: boolean
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/** The runner a node has durably requested and does not yet hold. */
|
|
15
|
+
export type SlotRequest = 'verification' | 'reconcile'
|
|
16
|
+
|
|
14
17
|
export interface DispatchCapacity {
|
|
15
18
|
configured: number
|
|
16
19
|
occupied: number
|
|
17
20
|
effective: number
|
|
18
21
|
borrowingNodes: string[]
|
|
22
|
+
/** Nodes admitted ahead of new ticket claims; omitted when none wait, and by an older server. */
|
|
23
|
+
waitingNodes?: { slug: string; request: SlotRequest }[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A workspace, a provisioning marker or a live lease holds runner capacity. */
|
|
27
|
+
function allocated(build: CapacityBuild, now: Date): boolean {
|
|
28
|
+
return (
|
|
29
|
+
build.workspace ||
|
|
30
|
+
!!build.provisioning ||
|
|
31
|
+
(build.record.lease !== undefined && Date.parse(build.record.lease.expiresAt) > now.getTime())
|
|
32
|
+
)
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
export function occupiesCapacity(build: CapacityBuild, now: Date): boolean {
|
|
22
|
-
const { state
|
|
36
|
+
const { state } = build
|
|
23
37
|
if (state.status === 'done' || state.status === 'aborted') return false
|
|
24
38
|
return (
|
|
25
39
|
state.kind !== 'node' ||
|
|
26
40
|
!!state.nodeRestack?.conflict ||
|
|
27
|
-
(integrationNeedsRunner(state) &&
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
(integrationNeedsRunner(state) && allocated(build, now))
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A node's durable request for a runner it does not hold yet. Admission
|
|
46
|
+
* outranks new ticket claims, so this never depends on when a tick saw it. */
|
|
47
|
+
export function slotRequest(build: CapacityBuild, now: Date): SlotRequest | undefined {
|
|
48
|
+
const { state } = build
|
|
49
|
+
if (
|
|
50
|
+
state.kind !== 'node' ||
|
|
51
|
+
state.status === 'done' ||
|
|
52
|
+
state.status === 'aborted' ||
|
|
53
|
+
state.status === 'paused' ||
|
|
54
|
+
state.status === 'blocked' ||
|
|
55
|
+
// Mixed-version deferral withholds every decision, admission included.
|
|
56
|
+
(state.compatibility?.decisiveFacts ?? 0) > 0 ||
|
|
57
|
+
allocated(build, now)
|
|
31
58
|
)
|
|
59
|
+
return undefined
|
|
60
|
+
if (state.nodeRestack?.conflict) return state.openEscalations.length ? undefined : 'reconcile'
|
|
61
|
+
if (integrationAdmissible(state) && integrationNeedsRunner(state)) return 'verification'
|
|
62
|
+
return undefined
|
|
32
63
|
}
|
|
33
64
|
|
|
34
65
|
type Identity = (ref: TicketRef, build?: string) => string
|
|
@@ -97,12 +128,7 @@ export function dispatchCapacity(
|
|
|
97
128
|
.filter((build) => {
|
|
98
129
|
if (build.state.kind !== 'node' || !occupiesCapacity(build, now)) return false
|
|
99
130
|
// A waiting conflict owns capacity too, but only allocated runner work borrows.
|
|
100
|
-
if (
|
|
101
|
-
!build.workspace &&
|
|
102
|
-
!build.provisioning &&
|
|
103
|
-
!(build.record.lease && Date.parse(build.record.lease.expiresAt) > now.getTime())
|
|
104
|
-
)
|
|
105
|
-
return false
|
|
131
|
+
if (!allocated(build, now)) return false
|
|
106
132
|
const admission = nodeCapacity(unique, build.record.slug, now, identity)
|
|
107
133
|
return (
|
|
108
134
|
occupied > configured &&
|
|
@@ -112,16 +138,56 @@ export function dispatchCapacity(
|
|
|
112
138
|
})
|
|
113
139
|
.map((build) => build.record.slug)
|
|
114
140
|
.sort()
|
|
141
|
+
const waitingNodes = unique
|
|
142
|
+
.flatMap((build) => {
|
|
143
|
+
const request = slotRequest(build, now)
|
|
144
|
+
return request ? [{ slug: build.record.slug, request }] : []
|
|
145
|
+
})
|
|
146
|
+
.sort((a, b) => (a.slug < b.slug ? -1 : a.slug > b.slug ? 1 : 0))
|
|
115
147
|
return {
|
|
116
148
|
configured,
|
|
117
149
|
occupied,
|
|
118
150
|
effective: borrowingNodes.length ? Math.max(configured, occupied) : configured,
|
|
119
151
|
borrowingNodes,
|
|
152
|
+
...(waitingNodes.length ? { waitingNodes } : {}),
|
|
120
153
|
}
|
|
121
154
|
}
|
|
122
155
|
|
|
156
|
+
/** Slots left for new ticket claims. A verification request reserves one slot
|
|
157
|
+
* until the node holds it; a reconcile request already occupies one. Never
|
|
158
|
+
* more than the configured budget minus occupied builds. */
|
|
159
|
+
export function intakeCapacity(capacity: DispatchCapacity): number {
|
|
160
|
+
const reserved = (capacity.waitingNodes ?? []).filter(
|
|
161
|
+
(node) => node.request === 'verification',
|
|
162
|
+
).length
|
|
163
|
+
return capacity.configured - capacity.occupied - reserved
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Shared wording for one node waiting on a runner slot. */
|
|
167
|
+
export function slotWaitText(request: SlotRequest): string {
|
|
168
|
+
return `${request} waiting for a slot ahead of new ticket claims`
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Shared wording for every node waiting on a runner slot, or `''`. */
|
|
172
|
+
export function waitingExplanation(
|
|
173
|
+
capacity?: DispatchCapacity,
|
|
174
|
+
opts: { requests?: boolean } = {},
|
|
175
|
+
): string {
|
|
176
|
+
const waiting = capacity?.waitingNodes ?? []
|
|
177
|
+
if (!waiting.length) return ''
|
|
178
|
+
return `${waiting.length} node${waiting.length === 1 ? '' : 's'} waiting for a slot ahead of new ticket claims: ${waiting.map((node) => (opts.requests ? `${node.slug} (${node.request})` : node.slug)).join(', ')}`
|
|
179
|
+
}
|
|
180
|
+
|
|
123
181
|
/** Shared wording for the terminal and browser control lines. */
|
|
124
182
|
export function capacityExplanation(capacity?: DispatchCapacity): string {
|
|
125
|
-
if (!capacity
|
|
126
|
-
|
|
183
|
+
if (!capacity) return ''
|
|
184
|
+
const clauses: string[] = []
|
|
185
|
+
if (capacity.borrowingNodes.length)
|
|
186
|
+
clauses.push(
|
|
187
|
+
`${capacity.borrowingNodes.length} node${capacity.borrowingNodes.length === 1 ? '' : 's'} using descendant-held slots: ${capacity.borrowingNodes.join(', ')}`,
|
|
188
|
+
)
|
|
189
|
+
const waiting = waitingExplanation(capacity)
|
|
190
|
+
if (waiting) clauses.push(waiting)
|
|
191
|
+
if (!clauses.length) return ''
|
|
192
|
+
return ` (${capacity.configured} configured; ${clauses.join('; ')})`
|
|
127
193
|
}
|
|
@@ -14,9 +14,13 @@ export interface DispatchStatus {
|
|
|
14
14
|
queued?: number
|
|
15
15
|
/** Standing count from newer tick facts; absent for historical events. */
|
|
16
16
|
creationWithheld?: number
|
|
17
|
+
/** Display-only triage-state count from newer interactive tick facts;
|
|
18
|
+
* absent when the dispatcher published none (unknown). */
|
|
19
|
+
triage?: number
|
|
17
20
|
yieldedHolder?: string
|
|
18
21
|
availableUpgrade?: string
|
|
19
22
|
forgeReadinessFailures?: RepositoryEventPayload<'dispatcher.forge-readiness-failed'>[]
|
|
23
|
+
/** Startup configuration warnings, including forge capability gaps. */
|
|
20
24
|
roleWarnings: string[]
|
|
21
25
|
diagnostics: string[]
|
|
22
26
|
/** Latest notice of warning/failure severity, retained independently from routine notices. */
|
|
@@ -111,6 +115,8 @@ export function reduceDispatchStatus(
|
|
|
111
115
|
case 'dispatcher.tick-completed':
|
|
112
116
|
state.queued = event.payload.queued
|
|
113
117
|
state.creationWithheld = event.payload.counters.creationWithheld
|
|
118
|
+
if (event.payload.triage !== undefined) state.triage = event.payload.triage
|
|
119
|
+
else delete state.triage
|
|
114
120
|
state.diagnostics = [
|
|
115
121
|
...event.payload.janitorDiagnostics,
|
|
116
122
|
...event.payload.ticketDiagnostics,
|
|
@@ -134,6 +140,9 @@ export function reduceDispatchStatus(
|
|
|
134
140
|
}
|
|
135
141
|
state.warningNotice = state.notice
|
|
136
142
|
break
|
|
143
|
+
case 'dispatcher.summary-handoff':
|
|
144
|
+
// Routine guest yield for PR-summary publication: no notice at all.
|
|
145
|
+
break
|
|
137
146
|
case 'dispatcher.harvest-runner-failed':
|
|
138
147
|
state.notice = errorNotice('harvest runner failed', event.payload.error)
|
|
139
148
|
state.warningNotice = state.notice
|
|
@@ -165,7 +174,7 @@ export function reduceDispatchStatus(
|
|
|
165
174
|
|
|
166
175
|
/** Bump when `DispatchStatus`'s shape or fold semantics change (it is its own
|
|
167
176
|
* accumulator: `lastSeq` makes the fold skip already-seen events). */
|
|
168
|
-
export const DISPATCH_STATUS_REDUCER_VERSION =
|
|
177
|
+
export const DISPATCH_STATUS_REDUCER_VERSION = 5
|
|
169
178
|
|
|
170
179
|
/** The incremental form of `reduceDispatchStatus` for one run. The run is a
|
|
171
180
|
* parameter, so this is a factory. */
|
|
@@ -25,6 +25,82 @@ export interface DispatchUpgradeState {
|
|
|
25
25
|
lastRollback?: Fact<'dispatcher.runtime-rolled-back'>
|
|
26
26
|
holds: Record<string, Fact<'dispatcher.runtime-rolled-back'>>
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Retention window for every map in the dispatch-upgrade state. The state is
|
|
30
|
+
* read on every dispatch tick, dashboard poll and status read, so it must not
|
|
31
|
+
* grow with the number of dispatcher generations. Every decision reads the
|
|
32
|
+
* authoritative generation, its immediate predecessor, the run that just
|
|
33
|
+
* started, a recently observed lease owner, or the newest handoffs, so recent
|
|
34
|
+
* runs suffice. Eviction never drops the authoritative run, the run holding the
|
|
35
|
+
* newest accepted handoff (each handoff captures every then-open remote
|
|
36
|
+
* execution), or the three newest settled runs (status's latest earlier
|
|
37
|
+
* outcome). Full history stays in the repository journal.
|
|
38
|
+
*/
|
|
39
|
+
export const UPGRADE_HISTORY_LIMIT = 16
|
|
40
|
+
|
|
41
|
+
/** The newest fact sequence recorded on a run, or -1 when it has none. */
|
|
42
|
+
export function upgradeRunRecency(run: UpgradeRun): number {
|
|
43
|
+
return Math.max(
|
|
44
|
+
-1,
|
|
45
|
+
...[
|
|
46
|
+
run.resolved,
|
|
47
|
+
run.detected,
|
|
48
|
+
run.failure,
|
|
49
|
+
run.prepared,
|
|
50
|
+
run.request,
|
|
51
|
+
run.handoff,
|
|
52
|
+
run.released,
|
|
53
|
+
run.takeover,
|
|
54
|
+
run.completed,
|
|
55
|
+
].map((fact) => fact?.seq ?? -1),
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const settledSeq = (run: UpgradeRun) => (run.completed ?? run.failure)?.seq ?? -1
|
|
60
|
+
// Runs without an accepted handoff go first, then completed handoffs; runs
|
|
61
|
+
// still draining an accepted handoff go last.
|
|
62
|
+
const evictionTier = (run: UpgradeRun) => (!run.handoff ? 0 : run.completed ? 1 : 2)
|
|
63
|
+
|
|
64
|
+
function retainRuns(acc: DispatchUpgradeState, touched: string) {
|
|
65
|
+
while (Object.keys(acc.runs).length > UPGRADE_HISTORY_LIMIT) {
|
|
66
|
+
const entries = Object.entries(acc.runs)
|
|
67
|
+
// The newest accepted handoff carries the remote captures authorization needs.
|
|
68
|
+
let newestHandoff: string | undefined
|
|
69
|
+
for (const [id, run] of entries)
|
|
70
|
+
if (
|
|
71
|
+
run.handoff &&
|
|
72
|
+
(!newestHandoff || run.handoff.seq > acc.runs[newestHandoff]!.handoff!.seq)
|
|
73
|
+
)
|
|
74
|
+
newestHandoff = id
|
|
75
|
+
// Status's latest earlier outcome excludes at most the current and
|
|
76
|
+
// live-handoff runs, so the three newest settled runs always contain it.
|
|
77
|
+
const settled = new Set(
|
|
78
|
+
entries
|
|
79
|
+
.filter(([, run]) => settledSeq(run) >= 0)
|
|
80
|
+
.sort(([, a], [, b]) => settledSeq(b) - settledSeq(a))
|
|
81
|
+
.slice(0, 3)
|
|
82
|
+
.map(([id]) => id),
|
|
83
|
+
)
|
|
84
|
+
let victim: string | undefined
|
|
85
|
+
let victimRank: [number, number] = [0, 0]
|
|
86
|
+
for (const [id, run] of entries) {
|
|
87
|
+
if (id === touched || id === acc.authoritativeRun || id === newestHandoff || settled.has(id))
|
|
88
|
+
continue
|
|
89
|
+
const rank: [number, number] = [evictionTier(run), upgradeRunRecency(run)]
|
|
90
|
+
if (
|
|
91
|
+
victim === undefined ||
|
|
92
|
+
rank[0] < victimRank[0] ||
|
|
93
|
+
(rank[0] === victimRank[0] &&
|
|
94
|
+
(rank[1] < victimRank[1] || (rank[1] === victimRank[1] && id < victim)))
|
|
95
|
+
) {
|
|
96
|
+
victim = id
|
|
97
|
+
victimRank = rank
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
delete acc.runs[victim!]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
28
104
|
function same(a: Handoff, b: Handoff): boolean {
|
|
29
105
|
return (
|
|
30
106
|
a.correlation === b.correlation &&
|
|
@@ -42,20 +118,41 @@ export const dispatchUpgradeReducer = defineReducer<
|
|
|
42
118
|
RepositoryEvent,
|
|
43
119
|
DispatchUpgradeState
|
|
44
120
|
>({
|
|
45
|
-
version:
|
|
121
|
+
version: 7,
|
|
46
122
|
initial: () => ({ runs: {}, holds: {}, lineages: {}, rollbackIds: [] }),
|
|
47
123
|
fold(acc, events) {
|
|
48
124
|
for (const event of events) {
|
|
49
|
-
if (event.type === 'dispatcher.run-started' && event.payload.lineage)
|
|
50
|
-
|
|
125
|
+
if (event.type === 'dispatcher.run-started' && event.payload.lineage) {
|
|
126
|
+
const started = event.payload.run
|
|
127
|
+
// Reinsert so key order is start order. Dispatch run ids are
|
|
128
|
+
// non-integer strings (`<host>-dispatch-<id>`), so JavaScript keeps
|
|
129
|
+
// insertion order; integer-like ids would only change which entry
|
|
130
|
+
// goes first, not the bound.
|
|
131
|
+
delete acc.lineages[started]
|
|
132
|
+
acc.lineages[started] = event.payload.lineage
|
|
133
|
+
for (const run of Object.keys(acc.lineages)) {
|
|
134
|
+
if (Object.keys(acc.lineages).length <= UPGRADE_HISTORY_LIMIT) break
|
|
135
|
+
if (run !== acc.authoritativeRun && run !== started) delete acc.lineages[run]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
51
138
|
// Starts and yielded ticks are not proof of repository authority.
|
|
52
139
|
if (event.type === 'dispatcher.tick-started') acc.authoritativeRun = event.payload.run
|
|
53
140
|
if (event.type === 'dispatcher.runtime-rolled-back') {
|
|
54
141
|
if (acc.rollbackIds.includes(event.payload.correlation)) continue
|
|
55
142
|
acc.rollbackIds.push(event.payload.correlation)
|
|
143
|
+
// Duplicate appends happen only next to the original, so a recent
|
|
144
|
+
// window of correlations still deduplicates them.
|
|
145
|
+
while (acc.rollbackIds.length > UPGRADE_HISTORY_LIMIT) acc.rollbackIds.shift()
|
|
56
146
|
acc.authoritativeRun = event.payload.run
|
|
57
147
|
acc.lastRollback = event
|
|
58
148
|
acc.holds[event.payload.lineage] = event
|
|
149
|
+
const current = acc.lineages[acc.authoritativeRun]
|
|
150
|
+
while (Object.keys(acc.holds).length > UPGRADE_HISTORY_LIMIT) {
|
|
151
|
+
const oldest = Object.entries(acc.holds)
|
|
152
|
+
.filter(([lineage]) => lineage !== current && lineage !== event.payload.lineage)
|
|
153
|
+
.reduce((a, b) => (b[1].seq < a[1].seq ? b : a))
|
|
154
|
+
delete acc.holds[oldest[0]]
|
|
155
|
+
}
|
|
59
156
|
continue
|
|
60
157
|
}
|
|
61
158
|
if (event.type === 'dispatcher.rollback-hold-cleared') {
|
|
@@ -70,8 +167,9 @@ export const dispatchUpgradeReducer = defineReducer<
|
|
|
70
167
|
if (event.type !== 'dispatcher.upgrade-target-resolved' && !('correlation' in event.payload))
|
|
71
168
|
continue
|
|
72
169
|
if (!('run' in event.payload) || typeof event.payload.run !== 'string') continue
|
|
73
|
-
|
|
74
|
-
|
|
170
|
+
const run = event.payload.run
|
|
171
|
+
acc.runs[run] ??= { outstanding: {}, drained: 0, suspended: 0 }
|
|
172
|
+
const state = acc.runs[run]!
|
|
75
173
|
switch (event.type) {
|
|
76
174
|
case 'dispatcher.upgrade-target-resolved':
|
|
77
175
|
state.resolved = event
|
|
@@ -165,6 +263,7 @@ export const dispatchUpgradeReducer = defineReducer<
|
|
|
165
263
|
state.completed ??= event
|
|
166
264
|
break
|
|
167
265
|
}
|
|
266
|
+
retainRuns(acc, run)
|
|
168
267
|
}
|
|
169
268
|
},
|
|
170
269
|
finish: (acc) => structuredClone(acc),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveApprovedVerifySelection } from './plan-verify-selection'
|
|
2
2
|
import { activeVerifyStage } from './verify-stages'
|
|
3
|
+
import { verifyBudgetExhaustedQuestion } from './verify-budget'
|
|
3
4
|
import { verifyMemberKey } from './verify-stage-state'
|
|
4
5
|
import { mixedVersionDeferred } from './mixed-version'
|
|
5
6
|
import { integrationCurrent, integrationConfig, integrationFailed } from './integration-state'
|
|
@@ -575,13 +576,14 @@ function decideNextInternal(state: BuildState, log: LogIndex, config: Config): D
|
|
|
575
576
|
) {
|
|
576
577
|
// Exhaustion escalates once per failure: an exact policy raise for this
|
|
577
578
|
// verify target after the last failure (answered or not) suppresses replay;
|
|
578
|
-
// a NEW failure re-arms it.
|
|
579
|
+
// a NEW failure re-arms it. The question lists the counted failed attempts
|
|
580
|
+
// and their steps; the target stays the last failed step.
|
|
579
581
|
return {
|
|
580
582
|
kind: 'raise-escalation',
|
|
581
583
|
source: 'policy',
|
|
582
584
|
policyCause: 'verify-failure-limit',
|
|
583
585
|
phase: verifyPhase(lastFail.step),
|
|
584
|
-
question:
|
|
586
|
+
question: verifyBudgetExhaustedQuestion(config.policy.maxVerifyAttempts, fails),
|
|
585
587
|
}
|
|
586
588
|
}
|
|
587
589
|
if (pendingFail !== undefined && (stage === undefined || stage.settled)) {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { KERNEL } from '../events/envelope'
|
|
2
|
+
import type { ForgeRejection } from '../ports/forge-failure'
|
|
3
|
+
import { ForgeRequestDeferred } from '../ports/forge-request-context'
|
|
4
|
+
import { readBuildFacts, type CurrentBuildFacts } from '../store/reduced-reads'
|
|
5
|
+
import type { BuildStore } from '../store/types'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A forge that refuses a dispatcher-side finalize PR create for a reason a
|
|
9
|
+
* retry cannot fix (a 4xx validation answer such as GitHub's "No commits
|
|
10
|
+
* between") is a question for the operator, not a provider failure. One
|
|
11
|
+
* escalation is raised per rejection; while it is open the request is parked
|
|
12
|
+
* without calling the forge, and each answer authorizes exactly one more
|
|
13
|
+
* attempt. Escalation ids are keyed by the publication request and the seq
|
|
14
|
+
* of the answer that authorized the attempt (0 for the first), so a crash
|
|
15
|
+
* between the rejection and its fact, or repeated ticks, never raise twice.
|
|
16
|
+
*/
|
|
17
|
+
type FinalizeRequest = {
|
|
18
|
+
seq: number
|
|
19
|
+
payload: { branch: string; sha: string }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function finalizePrEscalationPrefix(requestSeq: number) {
|
|
23
|
+
return `publication:finalize:${requestSeq}:`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function finalizePrEscalationId(requestSeq: number, anchor: number) {
|
|
27
|
+
return `${finalizePrEscalationPrefix(requestSeq)}${anchor}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Returns the anchor for the next PR-create attempt, or throws: deferred
|
|
31
|
+
* while a rejection awaits its answer, plainly once the build is ending. */
|
|
32
|
+
export function finalizePrRejectionGate(facts: CurrentBuildFacts, request: FinalizeRequest) {
|
|
33
|
+
const prefix = finalizePrEscalationPrefix(request.seq)
|
|
34
|
+
const open = facts.state.openEscalations.find((e) => e.id.startsWith(prefix))
|
|
35
|
+
const answered = facts.state.answeredEscalations.filter((e) => e.id.startsWith(prefix))
|
|
36
|
+
const latest = answered.at(-1)
|
|
37
|
+
const ending =
|
|
38
|
+
facts.state.status === 'aborted' ||
|
|
39
|
+
facts.state.status === 'done' ||
|
|
40
|
+
facts.state.discardRequest !== undefined ||
|
|
41
|
+
facts.state.pendingCommands.some((command) => command.command === 'abort') ||
|
|
42
|
+
latest?.resolution === 'abort'
|
|
43
|
+
if ((open !== undefined || latest !== undefined) && ending)
|
|
44
|
+
throw new Error(
|
|
45
|
+
`finalize PR create was rejected by the forge and the build is ending; not retrying (${(open ?? latest)!.id})`,
|
|
46
|
+
)
|
|
47
|
+
if (open !== undefined)
|
|
48
|
+
throw new ForgeRequestDeferred(
|
|
49
|
+
`finalize PR create rejected by the forge; awaiting an answer to ${open.id}`,
|
|
50
|
+
)
|
|
51
|
+
return latest?.answeredSeq ?? 0
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface FinalizePrRejectionDeps {
|
|
55
|
+
store: BuildStore
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Record the rejection once, then park the request. Always throws. */
|
|
59
|
+
export async function raiseFinalizePrRejection(
|
|
60
|
+
deps: FinalizePrRejectionDeps,
|
|
61
|
+
slug: string,
|
|
62
|
+
request: FinalizeRequest,
|
|
63
|
+
baseBranch: string,
|
|
64
|
+
anchor: number,
|
|
65
|
+
rejection: ForgeRejection,
|
|
66
|
+
): Promise<never> {
|
|
67
|
+
const id = finalizePrEscalationId(request.seq, anchor)
|
|
68
|
+
for (;;) {
|
|
69
|
+
const facts = (await readBuildFacts(deps.store, slug)).value
|
|
70
|
+
if (
|
|
71
|
+
facts.state.openEscalations.some((e) => e.id === id) ||
|
|
72
|
+
facts.state.answeredEscalations.some((e) => e.id === id)
|
|
73
|
+
)
|
|
74
|
+
break
|
|
75
|
+
const raised = await deps.store.appendIfCurrent(slug, facts.state.lastSeq, {
|
|
76
|
+
actor: KERNEL,
|
|
77
|
+
type: 'escalation.raised',
|
|
78
|
+
payload: {
|
|
79
|
+
id,
|
|
80
|
+
phase: 'finalize',
|
|
81
|
+
round: 1,
|
|
82
|
+
source: 'policy',
|
|
83
|
+
policyCause: 'non-retryable-phase-failure',
|
|
84
|
+
question:
|
|
85
|
+
`finalize could not open the pull request: ${rejection.forge} rejected the PR create ` +
|
|
86
|
+
`with HTTP ${rejection.status}: ${rejection.forgeMessage}. Branch ${request.payload.branch} ` +
|
|
87
|
+
`at ${request.payload.sha} → ${baseBranch}. No sandbox or provider recovery is needed. ` +
|
|
88
|
+
`Answer retry to re-attempt the PR create once (for example after pushing commits or ` +
|
|
89
|
+
`fixing the base), give guidance, or abort.`,
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
if (raised) break
|
|
93
|
+
}
|
|
94
|
+
throw new ForgeRequestDeferred(`finalize PR create rejected; escalated ${id}`)
|
|
95
|
+
}
|
|
@@ -240,6 +240,11 @@ export function randomStatusJournal(seed: number, length: number): RepositoryEve
|
|
|
240
240
|
},
|
|
241
241
|
}),
|
|
242
242
|
() => ({ type: 'dispatcher.forge-recovered', payload: { forge: 'github' } }),
|
|
243
|
+
() => ({
|
|
244
|
+
type: 'dispatcher.kernel-git-unavailable',
|
|
245
|
+
payload: { executable: 'git', detail: 'Executable not found in $PATH: "git"' },
|
|
246
|
+
}),
|
|
247
|
+
() => ({ type: 'dispatcher.kernel-git-recovered', payload: { executable: 'git' } }),
|
|
243
248
|
() => ({
|
|
244
249
|
type: 'dispatcher.run-started',
|
|
245
250
|
payload: {
|
|
@@ -254,6 +259,8 @@ export function randomStatusJournal(seed: number, length: number): RepositoryEve
|
|
|
254
259
|
payload: {
|
|
255
260
|
run,
|
|
256
261
|
queued: i,
|
|
262
|
+
// Deterministic (no rand draw) so the other templates' sequence holds.
|
|
263
|
+
...(i % 2 === 0 ? { triage: i } : {}),
|
|
257
264
|
counters: { ...counters, creationWithheld: 1 },
|
|
258
265
|
janitorDiagnostics: ['j'],
|
|
259
266
|
ticketDiagnostics: [],
|
|
@@ -278,7 +285,14 @@ export function randomStatusJournal(seed: number, length: number): RepositoryEve
|
|
|
278
285
|
type: 'dispatcher.operator-reported',
|
|
279
286
|
payload: { run, level: pick(rand, ['info', 'warning']), message: 'm' },
|
|
280
287
|
}),
|
|
281
|
-
|
|
288
|
+
// Shares a slot deterministically (no rand draw) so the sequence holds.
|
|
289
|
+
() =>
|
|
290
|
+
i % 5 !== 0
|
|
291
|
+
? { type: 'dispatcher.upgrade-available', payload: { run, version: '1.0.0' } }
|
|
292
|
+
: {
|
|
293
|
+
type: 'dispatcher.summary-handoff',
|
|
294
|
+
payload: { run, slug: 'b', status: 'verifying' },
|
|
295
|
+
},
|
|
282
296
|
() => ({
|
|
283
297
|
type: 'dispatcher.run-stopped',
|
|
284
298
|
payload: { run, outcome: pick(rand, ['normal', 'abnormal']) },
|
|
@@ -44,6 +44,8 @@ export interface HarvestProposalReservation {
|
|
|
44
44
|
proposalKey: string
|
|
45
45
|
id: string
|
|
46
46
|
seq: number
|
|
47
|
+
/** The reservation fact's time: the earliest the id could first be used. */
|
|
48
|
+
reservedAt: string
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
export interface HarvestRecoveryRequest {
|
|
@@ -220,7 +222,7 @@ export interface HarvestAcc {
|
|
|
220
222
|
}
|
|
221
223
|
|
|
222
224
|
/** Bump when `HarvestAcc`'s shape or fold semantics change. */
|
|
223
|
-
export const HARVEST_REDUCER_VERSION =
|
|
225
|
+
export const HARVEST_REDUCER_VERSION = 4
|
|
224
226
|
|
|
225
227
|
function foldHarvest(acc: HarvestAcc, events: readonly RepositoryEvent[]): void {
|
|
226
228
|
const order = acc.runs
|
|
@@ -590,6 +592,7 @@ function foldHarvest(acc: HarvestAcc, events: readonly RepositoryEvent[]): void
|
|
|
590
592
|
proposalKey: event.payload.proposalKey,
|
|
591
593
|
id: event.payload.id,
|
|
592
594
|
seq: event.seq,
|
|
595
|
+
reservedAt: event.ts,
|
|
593
596
|
})
|
|
594
597
|
break
|
|
595
598
|
}
|