@defrex/autobuild 1.19.0 → 1.21.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 +88 -11
- package/docs/architecture.md +48 -8
- package/docs/assets/headline-wide.png +0 -0
- package/docs/dispatcher-hosting.md +6 -1
- package/docs/dispatcher.md +2 -2
- package/docs/merge-policy.md +2 -1
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +11 -4
- package/docs/process-ownership.md +43 -0
- package/docs/remote-store-protocol.md +7 -0
- package/docs/restacking.md +11 -2
- package/docs/setup.md +7 -2
- package/docs/troubleshooting.md +6 -0
- package/docs/verification.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/dashboard/model.ts +1 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +3 -0
- package/packages/core/src/cli/dispatch.ts +3 -0
- package/packages/core/src/events/repository.ts +45 -1
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +1 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3f0c4e6d1d54e5bf.json +92 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/b440840a01ea216f.json +115 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +47 -6
- package/packages/core/src/kernel/engine.ts +15 -2
- package/packages/core/src/kernel/janitor-failure.ts +1 -0
- package/packages/core/src/kernel/reducer-revisions.ts +3 -0
- package/packages/core/src/kernel/repository-read-facts.ts +6 -1
- package/packages/core/src/processes/build-runner.ts +67 -7
- package/packages/core/src/processes/check-termination.ts +44 -0
- package/packages/core/src/processes/dispatcher.ts +472 -57
- package/packages/core/src/processes/pass-stages.ts +94 -4
- package/packages/core/src/processes/publication-loss.ts +29 -0
- package/packages/core/src/processes/repo-view.ts +50 -10
- package/packages/core/src/store/contract.ts +43 -0
- package/packages/core/src/store/digest.ts +19 -1
- package/packages/core/src/store/reducer-value-shapes.json +5605 -5454
- package/packages/core/src/store/remote/protocol.ts +3 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.20.0.json +36469 -0
- package/packages/core/src/store/remote/released-reducer-values/1.21.0.json +36612 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -14
- package/packages/core/src/store/types.ts +5 -0
- package/packages/core/src/testing/reduced-read-budget.ts +412 -2
- package/skills/code-review/SKILL.md +5 -0
- package/skills/finalize/SKILL.md +5 -0
- package/skills/guide/SKILL.md +36 -9
- package/skills/guide/references/merge-policy.md +2 -1
- package/skills/guide/references/plugin-authoring.md +11 -4
- package/skills/guide/references/process-ownership.md +43 -0
- package/skills/guide/references/remote-store-protocol.md +7 -0
- package/skills/guide/references/restacking.md +11 -2
- package/skills/guide/references/setup.md +7 -2
- package/skills/harvest/SKILL.md +5 -0
- package/skills/harvest-review/SKILL.md +5 -0
- package/skills/implement/SKILL.md +5 -0
- package/skills/judge/SKILL.md +4 -0
- package/skills/operate/SKILL.md +12 -0
- package/skills/plan/SKILL.md +5 -0
- package/skills/plan-review/SKILL.md +5 -0
- package/skills/propose/SKILL.md +5 -0
- package/skills/reconcile/SKILL.md +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
* the work deadline has not passed, so one helper cannot starve its siblings
|
|
10
10
|
* and no stage can consume a whole pass.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
MAX_STAGE_ADMISSIONS,
|
|
14
|
+
PASS_STAGE_NAMES,
|
|
15
|
+
PASS_STAGE_PART_NAMES,
|
|
16
|
+
ROTATED_PASS_PARTS,
|
|
17
|
+
} from '../events/repository'
|
|
18
|
+
import type { BuildPriority } from '../ports/types'
|
|
13
19
|
|
|
14
20
|
export { PASS_STAGE_NAMES, PASS_STAGE_PART_NAMES, ROTATED_PASS_PARTS }
|
|
15
21
|
|
|
@@ -87,6 +93,16 @@ export interface PassStagePartRecord {
|
|
|
87
93
|
carried?: string[]
|
|
88
94
|
}
|
|
89
95
|
|
|
96
|
+
/** One parked admission a stage decided (#1435): `admitted` took a slot,
|
|
97
|
+
* `deferred` waited for this pass's intake to evaluate claims, `carried`
|
|
98
|
+
* left the deferral to the next pass. */
|
|
99
|
+
export interface PassAdmission {
|
|
100
|
+
slug: string
|
|
101
|
+
level: BuildPriority
|
|
102
|
+
outcome: 'admitted' | 'deferred' | 'carried'
|
|
103
|
+
part?: PassStagePart
|
|
104
|
+
}
|
|
105
|
+
|
|
90
106
|
export interface PassStageRecord {
|
|
91
107
|
stage: PassStage
|
|
92
108
|
ms: number
|
|
@@ -95,6 +111,12 @@ export interface PassStageRecord {
|
|
|
95
111
|
stopped?: PassStop
|
|
96
112
|
/** Tickets whose preparation the stage carried to the next pass (#1431). */
|
|
97
113
|
carried?: string[]
|
|
114
|
+
/** Every parked admission the stage decided, each build once with its
|
|
115
|
+
* latest outcome. Uncapped in memory; `boundStageRecords` bounds the
|
|
116
|
+
* durable copy. */
|
|
117
|
+
admissions?: PassAdmission[]
|
|
118
|
+
/** Admissions the durable record omitted beyond its bound. */
|
|
119
|
+
admissionsOmitted?: number
|
|
98
120
|
parts?: PassStagePartRecord[]
|
|
99
121
|
}
|
|
100
122
|
|
|
@@ -114,6 +136,7 @@ export function aggregateStage(
|
|
|
114
136
|
stage: PassStage,
|
|
115
137
|
ms: number,
|
|
116
138
|
parts: readonly PassStagePartRecord[],
|
|
139
|
+
admissions: readonly PassAdmission[] = [],
|
|
117
140
|
): PassStageRecord {
|
|
118
141
|
let items = 0
|
|
119
142
|
let total: number | undefined = 0
|
|
@@ -132,19 +155,53 @@ export function aggregateStage(
|
|
|
132
155
|
...(total !== undefined ? { total } : {}),
|
|
133
156
|
...(stopped !== undefined ? { stopped } : {}),
|
|
134
157
|
...(carried.size > 0 ? { carried: [...carried].slice(0, MAX_CARRIED) } : {}),
|
|
158
|
+
...(admissions.length > 0 ? { admissions: admissions.map((entry) => ({ ...entry })) } : {}),
|
|
135
159
|
...(parts.length > 1 ? { parts: parts.map((part) => ({ ...part })) } : {}),
|
|
136
160
|
}
|
|
137
161
|
}
|
|
138
162
|
|
|
163
|
+
/** The records as they become durable: each keeps its first
|
|
164
|
+
* `MAX_STAGE_ADMISSIONS` admissions and counts the rest in
|
|
165
|
+
* `admissionsOmitted`. The in-memory records keep every admission. */
|
|
166
|
+
export function boundStageRecords(records: readonly PassStageRecord[]): PassStageRecord[] {
|
|
167
|
+
return records.map((record) => {
|
|
168
|
+
const admissions = record.admissions
|
|
169
|
+
if (admissions === undefined || admissions.length <= MAX_STAGE_ADMISSIONS) return record
|
|
170
|
+
return {
|
|
171
|
+
...record,
|
|
172
|
+
admissions: admissions.slice(0, MAX_STAGE_ADMISSIONS),
|
|
173
|
+
admissionsOmitted: (record.admissionsOmitted ?? 0) + admissions.length - MAX_STAGE_ADMISSIONS,
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
139
178
|
const progress = (items: number, total: number | undefined) =>
|
|
140
179
|
total === undefined ? `${items}` : `${items}/${total}`
|
|
141
180
|
|
|
142
181
|
const carriedText = (carried: readonly string[] | undefined) =>
|
|
143
182
|
carried !== undefined && carried.length > 0 ? ` carried ${carried.join(', ')}` : ''
|
|
144
183
|
|
|
184
|
+
const ADMISSION_OUTCOMES = ['admitted', 'deferred', 'carried'] as const
|
|
185
|
+
|
|
186
|
+
/** A stage's parked admissions grouped by outcome, each `slug level`, for
|
|
187
|
+
* example ` admitted a high, b normal; deferred c normal`. */
|
|
188
|
+
function admissionsText(record: PassStageRecord): string {
|
|
189
|
+
const groups = ADMISSION_OUTCOMES.flatMap((outcome) => {
|
|
190
|
+
const named = (record.admissions ?? []).filter((entry) => entry.outcome === outcome)
|
|
191
|
+
return named.length === 0
|
|
192
|
+
? []
|
|
193
|
+
: [`${outcome} ${named.map((entry) => `${entry.slug} ${entry.level}`).join(', ')}`]
|
|
194
|
+
})
|
|
195
|
+
if (record.admissionsOmitted !== undefined && record.admissionsOmitted > 0)
|
|
196
|
+
groups.push(`and ${record.admissionsOmitted} more admissions`)
|
|
197
|
+
return groups.length === 0 ? '' : ` ${groups.join('; ')}`
|
|
198
|
+
}
|
|
199
|
+
|
|
145
200
|
/** The dispatch log's `stages:` summary, for example
|
|
146
201
|
* `settlement 3.1s 6/11 (executions 5/9, harvest 1/2, sandboxes 0/0) · janitor 131.4s 4/12 (share)`.
|
|
147
|
-
* A carried preparation reads `intake 2.4s 0/22 (tickets 0/22 carried FLINT-1490, …)`.
|
|
202
|
+
* A carried preparation reads `intake 2.4s 0/22 (tickets 0/22 carried FLINT-1490, …)`.
|
|
203
|
+
* Parked admissions follow the stage, grouped by outcome:
|
|
204
|
+
* `sweep 41.0s 12/30 (waits 0/0, sweep 12/30) (share) admitted a high; deferred b normal`. */
|
|
148
205
|
export function formatPassStages(records: readonly PassStageRecord[]): string {
|
|
149
206
|
return records
|
|
150
207
|
.map((record) => {
|
|
@@ -157,7 +214,7 @@ export function formatPassStages(records: readonly PassStageRecord[]): string {
|
|
|
157
214
|
.join(', ')})`
|
|
158
215
|
: carriedText(record.carried)
|
|
159
216
|
const stopped = record.stopped ? ` (${record.stopped})` : ''
|
|
160
|
-
return `${record.stage} ${(record.ms / 1000).toFixed(1)}s ${progress(record.items, record.total)}${parts}${stopped}`
|
|
217
|
+
return `${record.stage} ${(record.ms / 1000).toFixed(1)}s ${progress(record.items, record.total)}${parts}${stopped}${admissionsText(record)}`
|
|
161
218
|
})
|
|
162
219
|
.join(' · ')
|
|
163
220
|
}
|
|
@@ -204,6 +261,8 @@ interface RunningStage {
|
|
|
204
261
|
/** The part whose item started last: the one in flight when a helper
|
|
205
262
|
* returns after the work deadline. */
|
|
206
263
|
lastStarted?: PartState
|
|
264
|
+
/** Parked admissions decided in this stage, latest outcome per slug. */
|
|
265
|
+
admissions: Map<string, PassAdmission>
|
|
207
266
|
}
|
|
208
267
|
|
|
209
268
|
/**
|
|
@@ -219,7 +278,7 @@ export class PassStageTracker {
|
|
|
219
278
|
constructor(private readonly clock: () => number) {}
|
|
220
279
|
|
|
221
280
|
begin(stage: PassStage): void {
|
|
222
|
-
this.running = { stage, startedAt: this.clock(), parts: [] }
|
|
281
|
+
this.running = { stage, startedAt: this.clock(), parts: [], admissions: new Map() }
|
|
223
282
|
}
|
|
224
283
|
|
|
225
284
|
/** `part` of the running stage, opened if new, and made the part in flight. */
|
|
@@ -267,6 +326,36 @@ export class PassStageTracker {
|
|
|
267
326
|
state.carried.push(ticket)
|
|
268
327
|
}
|
|
269
328
|
|
|
329
|
+
/** Record a parked admission the running stage decided, against the part
|
|
330
|
+
* in flight. Each slug keeps its latest outcome. */
|
|
331
|
+
admission(outcome: PassAdmission['outcome'], slug: string, level: BuildPriority): void {
|
|
332
|
+
const running = this.running
|
|
333
|
+
if (running === undefined) return
|
|
334
|
+
const part = running.current?.part
|
|
335
|
+
running.admissions.set(slug, { slug, level, outcome, ...(part !== undefined ? { part } : {}) })
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** Record that the pass carried `slug`'s parked admission to the next
|
|
339
|
+
* pass: on the intake stage, running or closed, where the retry would have
|
|
340
|
+
* run; otherwise on the stage still running, or the last one closed. */
|
|
341
|
+
carriedAdmission(slug: string, level: BuildPriority): void {
|
|
342
|
+
const entry: PassAdmission = { slug, level, outcome: 'carried' }
|
|
343
|
+
const running = this.running
|
|
344
|
+
if (running?.stage === 'intake') {
|
|
345
|
+
running.admissions.set(slug, entry)
|
|
346
|
+
return
|
|
347
|
+
}
|
|
348
|
+
const record =
|
|
349
|
+
this.records.find((candidate) => candidate.stage === 'intake') ??
|
|
350
|
+
(running === undefined ? this.records.at(-1) : undefined)
|
|
351
|
+
if (record === undefined) {
|
|
352
|
+
running?.admissions.set(slug, entry)
|
|
353
|
+
return
|
|
354
|
+
}
|
|
355
|
+
const admissions = (record.admissions ?? []).filter((candidate) => candidate.slug !== slug)
|
|
356
|
+
record.admissions = [...admissions, entry]
|
|
357
|
+
}
|
|
358
|
+
|
|
270
359
|
stop(part: PassStagePart, stopped: PassStop): void {
|
|
271
360
|
const state = this.enter(part)
|
|
272
361
|
if (state !== undefined) state.stopped = strongest(state.stopped, stopped)
|
|
@@ -315,6 +404,7 @@ export class PassStageTracker {
|
|
|
315
404
|
...(stopped !== undefined ? { stopped } : {}),
|
|
316
405
|
...(carried !== undefined ? { carried: [...carried] } : {}),
|
|
317
406
|
})),
|
|
407
|
+
[...running.admissions.values()],
|
|
318
408
|
)
|
|
319
409
|
}
|
|
320
410
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PublicationRetryPersistenceError } from '../kernel/publication-retry'
|
|
2
2
|
import { ForgeRequestDeferred } from '../ports/forge-request-context'
|
|
3
3
|
import { isRemoteWorkspace } from '../events/workspace-remote'
|
|
4
|
+
import { isRepositoryAuthorityLapse } from '../cli/repo-lease'
|
|
4
5
|
import { isRecoveryDeferred, recoveryStepOf } from '../ports/workspace/recovery-step'
|
|
5
6
|
/**
|
|
6
7
|
* Last-chance publication settlement at the workspace-release boundary
|
|
@@ -136,3 +137,31 @@ export async function recordPublicationLossBeforeRelease(
|
|
|
136
137
|
})
|
|
137
138
|
return (await readBuildFacts(deps.store, slug)).value
|
|
138
139
|
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Whether a merged PR already contains a pending publication's commit, so its
|
|
143
|
+
* release needs no settlement (merged completion, SPEC §15.7). True when
|
|
144
|
+
* `request` equals a merged head, or a host-side ancestry proof shows it below
|
|
145
|
+
* one. `heads` names the PR's observed head first, then its landing: a squash
|
|
146
|
+
* landing never descends from the PR's commits, but the PR head does. An absent
|
|
147
|
+
* capability, an unknown object or a throwing proof is never coverage. A forge
|
|
148
|
+
* deferral or a lapsed repository lease still propagates.
|
|
149
|
+
*/
|
|
150
|
+
export async function mergedHeadCovers(
|
|
151
|
+
request: string,
|
|
152
|
+
heads: readonly (string | undefined)[],
|
|
153
|
+
isAncestor?: (ancestor: string, descendant: string) => Promise<boolean>,
|
|
154
|
+
): Promise<boolean> {
|
|
155
|
+
const known = heads.filter((head): head is string => head !== undefined && head !== '')
|
|
156
|
+
if (known.includes(request)) return true
|
|
157
|
+
if (isAncestor === undefined) return false
|
|
158
|
+
for (const head of known) {
|
|
159
|
+
try {
|
|
160
|
+
if (await isAncestor(request, head)) return true
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (error instanceof ForgeRequestDeferred || isRepositoryAuthorityLapse(error)) throw error
|
|
163
|
+
// Unknown ancestry proves nothing; try the next head.
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
@@ -103,7 +103,8 @@ export function isWorkDigest(digest: Omit<BuildDigest, 'slug'>): boolean {
|
|
|
103
103
|
digest.terminal === 'aborted' ||
|
|
104
104
|
digest.reclaimPending === true ||
|
|
105
105
|
digest.executionOpen === true ||
|
|
106
|
-
digest.rejectionsPending === true
|
|
106
|
+
digest.rejectionsPending === true ||
|
|
107
|
+
digest.releasePending === true
|
|
107
108
|
)
|
|
108
109
|
}
|
|
109
110
|
class Chain {
|
|
@@ -135,6 +136,10 @@ export class RepoViewStore implements BuildStore {
|
|
|
135
136
|
private tickSample: RepoTickObservation['finished']
|
|
136
137
|
private records: BuildRecord[] = []
|
|
137
138
|
private recordsDirty = true
|
|
139
|
+
/** Records this view's own writes changed since the last listing: the next
|
|
140
|
+
* `listBuilds` re-reads each one (`getBuild`) instead of the whole roster,
|
|
141
|
+
* so a write costs one record read, whatever the fleet's size. */
|
|
142
|
+
private readonly dirtyRecords = new Set<string>()
|
|
138
143
|
private discovery = new Map<string, BuildDigest>()
|
|
139
144
|
private readonly dirtyDigests = new Set<string>()
|
|
140
145
|
private discoveryDirty = true
|
|
@@ -185,6 +190,7 @@ export class RepoViewStore implements BuildStore {
|
|
|
185
190
|
await this.refreshJournal()
|
|
186
191
|
await this.metaChain.run(async () => {
|
|
187
192
|
this.recordsDirty = false
|
|
193
|
+
this.dirtyRecords.clear()
|
|
188
194
|
this.discoveryDirty = false
|
|
189
195
|
this.dirtyDigests.clear()
|
|
190
196
|
this.records = await this.backing.listBuilds()
|
|
@@ -334,7 +340,21 @@ export class RepoViewStore implements BuildStore {
|
|
|
334
340
|
return this.metaChain.run(async () => {
|
|
335
341
|
if (this.recordsDirty) {
|
|
336
342
|
this.recordsDirty = false
|
|
343
|
+
this.dirtyRecords.clear()
|
|
337
344
|
this.records = await this.backing.listBuilds()
|
|
345
|
+
} else {
|
|
346
|
+
// Own writes since the last listing: one record read each, never the roster.
|
|
347
|
+
for (const slug of [...this.dirtyRecords]) {
|
|
348
|
+
this.dirtyRecords.delete(slug)
|
|
349
|
+
let record: BuildRecord | null
|
|
350
|
+
try {
|
|
351
|
+
record = await this.backing.getBuild(slug)
|
|
352
|
+
} catch (error) {
|
|
353
|
+
this.dirtyRecords.add(slug)
|
|
354
|
+
throw error
|
|
355
|
+
}
|
|
356
|
+
this.placeRecord(slug, record)
|
|
357
|
+
}
|
|
338
358
|
}
|
|
339
359
|
return structuredClone(this.records)
|
|
340
360
|
})
|
|
@@ -486,13 +506,33 @@ export class RepoViewStore implements BuildStore {
|
|
|
486
506
|
window.events.push(event)
|
|
487
507
|
window.cursor = event.seq
|
|
488
508
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
509
|
+
/** Put a re-read record in place: replaced, removed when gone, or inserted
|
|
510
|
+
* in the listing's creation-then-slug order. */
|
|
511
|
+
private placeRecord(slug: string, record: BuildRecord | null): void {
|
|
512
|
+
const at = this.records.findIndex((entry) => entry.slug === slug)
|
|
513
|
+
if (record === null) {
|
|
514
|
+
if (at >= 0) this.records.splice(at, 1)
|
|
515
|
+
return
|
|
495
516
|
}
|
|
517
|
+
if (at >= 0) {
|
|
518
|
+
this.records[at] = record
|
|
519
|
+
return
|
|
520
|
+
}
|
|
521
|
+
const after = this.records.findIndex(
|
|
522
|
+
(entry) =>
|
|
523
|
+
entry.createdAt.localeCompare(record.createdAt) > 0 ||
|
|
524
|
+
(entry.createdAt === record.createdAt && entry.slug.localeCompare(record.slug) > 0),
|
|
525
|
+
)
|
|
526
|
+
this.records.splice(after < 0 ? this.records.length : after, 0, record)
|
|
527
|
+
}
|
|
528
|
+
/** A write through this view changed `slug`'s record and, unless
|
|
529
|
+
* `recordOnly` (a lease change), its log. */
|
|
530
|
+
private invalidate(slug: string, recordOnly = false): void {
|
|
531
|
+
this.openDirty = true
|
|
532
|
+
this.dirtyRecords.add(slug)
|
|
533
|
+
if (recordOnly) return
|
|
534
|
+
this.dirtyDigests.add(slug)
|
|
535
|
+
this.appends.set(slug, (this.appends.get(slug) ?? 0) + 1)
|
|
496
536
|
}
|
|
497
537
|
async createBuild(input: NewBuildInput): Promise<BuildRecord> {
|
|
498
538
|
const record = await this.backing.createBuild(input)
|
|
@@ -624,17 +664,17 @@ export class RepoViewStore implements BuildStore {
|
|
|
624
664
|
}
|
|
625
665
|
async claimLease(slug: string, holder: string, ttlMs: number): Promise<boolean> {
|
|
626
666
|
const result = await this.backing.claimLease(slug, holder, ttlMs)
|
|
627
|
-
this.invalidate()
|
|
667
|
+
this.invalidate(slug, true)
|
|
628
668
|
return result
|
|
629
669
|
}
|
|
630
670
|
async heartbeat(slug: string, holder: string): Promise<boolean> {
|
|
631
671
|
const result = await this.backing.heartbeat(slug, holder)
|
|
632
|
-
this.invalidate()
|
|
672
|
+
this.invalidate(slug, true)
|
|
633
673
|
return result
|
|
634
674
|
}
|
|
635
675
|
async releaseLease(slug: string, holder: string): Promise<void> {
|
|
636
676
|
await this.backing.releaseLease(slug, holder)
|
|
637
|
-
this.invalidate()
|
|
677
|
+
this.invalidate(slug, true)
|
|
638
678
|
}
|
|
639
679
|
getScanCadence(repo: string) {
|
|
640
680
|
return this.backing.getScanCadence(repo)
|
|
@@ -1250,6 +1250,49 @@ export function describeBuildStoreContract(name: string, factory: BuildStoreFact
|
|
|
1250
1250
|
})
|
|
1251
1251
|
})
|
|
1252
1252
|
|
|
1253
|
+
test('releasePending marks a completed merged build whose workspace is still open', async () => {
|
|
1254
|
+
await withStore(factory, undefined, async (store) => {
|
|
1255
|
+
const repo = 'acme/dg-release'
|
|
1256
|
+
const pending = async (slug: string) =>
|
|
1257
|
+
(await store.getRepoBuildDigests(repo)).get(slug)!.releasePending
|
|
1258
|
+
const seed = async (slug: string, closing: 'pr.merged' | 'pr.closed') => {
|
|
1259
|
+
await store.createBuild(sampleBuildInput(slug, { repo }))
|
|
1260
|
+
await store.append(slug, buildCreatedWrite())
|
|
1261
|
+
await store.append(slug, {
|
|
1262
|
+
actor: DISPATCHER,
|
|
1263
|
+
type: 'workspace.provisioned',
|
|
1264
|
+
payload: {
|
|
1265
|
+
provider: 'p',
|
|
1266
|
+
ref: 'w',
|
|
1267
|
+
branch: `ab/${slug}`,
|
|
1268
|
+
base: { source: 'remote', sha: 'a'.repeat(40) },
|
|
1269
|
+
},
|
|
1270
|
+
})
|
|
1271
|
+
await store.append(
|
|
1272
|
+
slug,
|
|
1273
|
+
closing === 'pr.merged'
|
|
1274
|
+
? { actor: DISPATCHER, type: 'pr.merged', payload: { sha: 'm' } }
|
|
1275
|
+
: { actor: DISPATCHER, type: 'pr.closed', payload: {} },
|
|
1276
|
+
)
|
|
1277
|
+
await store.append(slug, {
|
|
1278
|
+
actor: DISPATCHER,
|
|
1279
|
+
type: 'build.completed',
|
|
1280
|
+
payload: { outcome: closing === 'pr.merged' ? 'merged' : 'closed-unmerged' },
|
|
1281
|
+
})
|
|
1282
|
+
}
|
|
1283
|
+
await seed('dg-merged', 'pr.merged')
|
|
1284
|
+
await seed('dg-closed', 'pr.closed')
|
|
1285
|
+
expect(await pending('dg-merged')).toBe(true)
|
|
1286
|
+
expect(await pending('dg-closed')).toBeUndefined()
|
|
1287
|
+
await store.append('dg-merged', {
|
|
1288
|
+
actor: DISPATCHER,
|
|
1289
|
+
type: 'workspace.released',
|
|
1290
|
+
payload: { ref: 'w', reason: 'completion' },
|
|
1291
|
+
})
|
|
1292
|
+
expect(await pending('dg-merged')).toBeUndefined()
|
|
1293
|
+
})
|
|
1294
|
+
})
|
|
1295
|
+
|
|
1253
1296
|
test('rejectionsPending follows non-accepted attempt settlements until their ticket moves', async () => {
|
|
1254
1297
|
await withStore(factory, undefined, async (store) => {
|
|
1255
1298
|
const repo = 'acme/dg-opt'
|
|
@@ -50,6 +50,10 @@ export const DIGEST_EVENT_TYPES = [
|
|
|
50
50
|
'pr-attachment.reclaimed',
|
|
51
51
|
'execution.started',
|
|
52
52
|
'execution.ended',
|
|
53
|
+
// The open workspace a merged build's completion still has to release.
|
|
54
|
+
'workspace.provisioned',
|
|
55
|
+
'workspace.cleanup-required',
|
|
56
|
+
'workspace.released',
|
|
53
57
|
'wait.requested',
|
|
54
58
|
'wait.refused',
|
|
55
59
|
'wait.entered',
|
|
@@ -128,6 +132,9 @@ export interface DigestAcc {
|
|
|
128
132
|
executionFacts: number
|
|
129
133
|
/** Sorted unique node slugs any target or parent move has named. */
|
|
130
134
|
nodeTargets: string[]
|
|
135
|
+
/** The latest `workspace.provisioned` / `workspace.cleanup-required` has no
|
|
136
|
+
* later `workspace.released` (the `openBuildWorkspace` rule). */
|
|
137
|
+
workspaceOpen: boolean
|
|
131
138
|
/** The latest ticket-wait fact is a request without its outcome. */
|
|
132
139
|
waitPending?: true
|
|
133
140
|
/** The entered ticket wait that has not ended. */
|
|
@@ -195,6 +202,7 @@ export const buildDigestReducer: IncrementalReducer<
|
|
|
195
202
|
openInstance: null,
|
|
196
203
|
executionFacts: 0,
|
|
197
204
|
nodeTargets: [],
|
|
205
|
+
workspaceOpen: false,
|
|
198
206
|
}),
|
|
199
207
|
fold(acc, events) {
|
|
200
208
|
for (const event of events) {
|
|
@@ -266,7 +274,13 @@ export const buildDigestReducer: IncrementalReducer<
|
|
|
266
274
|
const remaining = acc.pendingRejections.filter((p) => p !== event.attemptProposal)
|
|
267
275
|
acc.pendingRejections = remaining.length > 0 ? remaining : undefined
|
|
268
276
|
}
|
|
269
|
-
} else if (
|
|
277
|
+
} else if (
|
|
278
|
+
event.type === 'workspace.provisioned' ||
|
|
279
|
+
event.type === 'workspace.cleanup-required'
|
|
280
|
+
)
|
|
281
|
+
acc.workspaceOpen = true
|
|
282
|
+
else if (event.type === 'workspace.released') acc.workspaceOpen = false
|
|
283
|
+
else if (event.type === 'execution.started') {
|
|
270
284
|
acc.executionFacts += 1
|
|
271
285
|
acc.openInstance = event.instance ?? null
|
|
272
286
|
} else if (event.type === 'execution.ended') {
|
|
@@ -299,6 +313,7 @@ export const buildDigestReducer: IncrementalReducer<
|
|
|
299
313
|
optimization,
|
|
300
314
|
proposerWakeSeq,
|
|
301
315
|
proposerDeferredSeq,
|
|
316
|
+
workspaceOpen,
|
|
302
317
|
}) => {
|
|
303
318
|
const reclaimedSet = new Set(reclaimed)
|
|
304
319
|
const reclaimPending = hosted.some((seq) => !reclaimedSet.has(seq))
|
|
@@ -322,6 +337,9 @@ export const buildDigestReducer: IncrementalReducer<
|
|
|
322
337
|
...(waitPending ? { waitPending } : {}),
|
|
323
338
|
...(ticketWait !== undefined ? { ticketWait: structuredClone(ticketWait) } : {}),
|
|
324
339
|
...(pendingRejections?.length ? { rejectionsPending: true as const } : {}),
|
|
340
|
+
...(terminal === 'done' && merged !== undefined && workspaceOpen
|
|
341
|
+
? { releasePending: true as const }
|
|
342
|
+
: {}),
|
|
325
343
|
nodeTargets: [...nodeTargets],
|
|
326
344
|
...(kind === 'node'
|
|
327
345
|
? {
|