@defrex/autobuild 1.11.0 → 1.11.1
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 +9 -3
- package/docs/architecture.md +10 -4
- package/docs/cli.md +1 -1
- package/docs/dispatcher.md +4 -3
- package/docs/operator-surfaces.md +3 -3
- package/package.json +3 -3
- package/packages/core/src/cli/dashboard/header.ts +10 -0
- package/packages/core/src/cli/dashboard/poll.ts +4 -3
- package/packages/core/src/cli/dashboard/render.ts +30 -0
- package/packages/core/src/cli/dispatch-frontend.ts +12 -3
- package/packages/core/src/cli/dispatch.ts +2 -4
- package/packages/core/src/cli/repository-status.ts +8 -6
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +65 -30
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/46196d8f0076496a.json +97 -0
- package/packages/core/src/kernel/dispatch-status.ts +139 -0
- package/packages/core/src/kernel/read-facts.ts +15 -13
- package/packages/core/src/kernel/reducer-revisions.ts +2 -0
- package/packages/core/src/operator/query.ts +7 -2
- package/packages/core/src/store/reducer-value-shapes.json +3566 -3528
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.11.1.json +35718 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
- package/packages/core/src/testing/dispatch-journals.ts +117 -0
- package/packages/core/src/web/repository-source.ts +6 -2
- package/skills/guide/SKILL.md +12 -4
- package/templates/hosted-service/package.json +2 -2
|
@@ -192,6 +192,145 @@ export function dispatchStatusReducer(
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/** Shared current reads retain a fixed recent window of dispatcher runs. It
|
|
196
|
+
* bounds `recentRuns` in repository read facts and the pending runs the
|
|
197
|
+
* reported dispatch status tracks. Historical holder correlations outside it
|
|
198
|
+
* use the explicitly parameterized cache. */
|
|
199
|
+
export const RECENT_DISPATCH_RUN_LIMIT = 16
|
|
200
|
+
|
|
201
|
+
/** A started, unstopped run other than the reported one, folded from its own
|
|
202
|
+
* `dispatcher.run-started` onward. `started` is that start's seq. */
|
|
203
|
+
export interface PendingDispatchRun {
|
|
204
|
+
started: number
|
|
205
|
+
status: DispatchStatus
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Which dispatcher run the repository's reduced status describes. */
|
|
209
|
+
export interface ReportedDispatch {
|
|
210
|
+
run?: string
|
|
211
|
+
status: DispatchStatus
|
|
212
|
+
/** Whether the reported run has recorded a tick boundary. */
|
|
213
|
+
ticked: boolean
|
|
214
|
+
/** Seq of the reported run's latest retained start; 0 when never seen. */
|
|
215
|
+
started: number
|
|
216
|
+
/** Sorted ascending by `started`, at most `RECENT_DISPATCH_RUN_LIMIT`. */
|
|
217
|
+
pending: PendingDispatchRun[]
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function initialReportedDispatch(): ReportedDispatch {
|
|
221
|
+
return {
|
|
222
|
+
status: dispatchStatusReducer('initial').initial(),
|
|
223
|
+
ticked: false,
|
|
224
|
+
started: 0,
|
|
225
|
+
pending: [],
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function stopped(status: Readonly<DispatchStatus>): boolean {
|
|
230
|
+
return status.health === 'stopped' || status.health === 'failed'
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function tickBoundary(event: RepositoryEvent): boolean {
|
|
234
|
+
return (
|
|
235
|
+
event.type === 'dispatcher.tick-started' ||
|
|
236
|
+
event.type === 'dispatcher.tick-completed' ||
|
|
237
|
+
event.type === 'dispatcher.tick-failed'
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Insert in start order, then evict the oldest starts beyond the bound. */
|
|
242
|
+
function retain(state: ReportedDispatch, entry: PendingDispatchRun): void {
|
|
243
|
+
let index = state.pending.length
|
|
244
|
+
while (index > 0 && state.pending[index - 1]!.started > entry.started) index--
|
|
245
|
+
state.pending.splice(index, 0, entry)
|
|
246
|
+
while (state.pending.length > RECENT_DISPATCH_RUN_LIMIT) state.pending.shift()
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Move the reported run aside (while it is live) and report `status`. */
|
|
250
|
+
function report(
|
|
251
|
+
state: ReportedDispatch,
|
|
252
|
+
status: DispatchStatus,
|
|
253
|
+
started: number,
|
|
254
|
+
ticked: boolean,
|
|
255
|
+
): void {
|
|
256
|
+
if (state.run !== undefined && !stopped(state.status))
|
|
257
|
+
retain(state, { started: state.started, status: state.status })
|
|
258
|
+
state.run = status.run
|
|
259
|
+
state.status = status
|
|
260
|
+
state.started = started
|
|
261
|
+
state.ticked = ticked
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Fold one repository event into the reported dispatcher run, in place.
|
|
265
|
+
*
|
|
266
|
+
* The reported run is the one that holds repository authority, or held it
|
|
267
|
+
* most recently, as far as the journal shows: a run that has recorded a tick
|
|
268
|
+
* boundary (`tick-started`, `tick-completed`, `tick-failed`). A run that
|
|
269
|
+
* starts while a ticked, live run is reported waits in `pending` and only
|
|
270
|
+
* displaces it by recording its own tick boundary, so a newcomer that yields
|
|
271
|
+
* and stops never touches the holder's status. When the reported run has
|
|
272
|
+
* stopped or has not ticked yet, a new start is reported at once, as is any
|
|
273
|
+
* start when no run is reported. A tick boundary from a run whose start is
|
|
274
|
+
* no longer retained promotes it too, carrying the last known effective
|
|
275
|
+
* config until the run records its own. Other events from unknown runs are
|
|
276
|
+
* ignored; a run's stop is its last event, so a stopped pending run is
|
|
277
|
+
* dropped rather than remembered.
|
|
278
|
+
*
|
|
279
|
+
* Pending holds at most `RECENT_DISPATCH_RUN_LIMIT` runs, the most recently
|
|
280
|
+
* started, so the state is bounded independent of journal length.
|
|
281
|
+
*
|
|
282
|
+
* `repositoryReadFacts` persists this state: changing this fold or its shape
|
|
283
|
+
* requires a `repositoryReadFacts` reducer revision. */
|
|
284
|
+
export function foldReportedDispatch(state: ReportedDispatch, event: RepositoryEvent): void {
|
|
285
|
+
const run = (event.payload as { run?: unknown }).run
|
|
286
|
+
if (typeof run !== 'string') return
|
|
287
|
+
if (event.type === 'dispatcher.run-started') {
|
|
288
|
+
const fresh = reduceDispatchStatus([event], run)
|
|
289
|
+
if (state.run === run) {
|
|
290
|
+
state.status = fresh
|
|
291
|
+
state.started = event.seq
|
|
292
|
+
state.ticked = false
|
|
293
|
+
return
|
|
294
|
+
}
|
|
295
|
+
const index = state.pending.findIndex((entry) => entry.status.run === run)
|
|
296
|
+
if (index !== -1) state.pending.splice(index, 1)
|
|
297
|
+
if (state.run === undefined || stopped(state.status) || !state.ticked)
|
|
298
|
+
report(state, fresh, event.seq, false)
|
|
299
|
+
else retain(state, { started: event.seq, status: fresh })
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
if (state.run === run) {
|
|
303
|
+
state.status = reduceDispatchStatus([event], run, state.status)
|
|
304
|
+
if (tickBoundary(event)) state.ticked = true
|
|
305
|
+
return
|
|
306
|
+
}
|
|
307
|
+
const index = state.pending.findIndex((entry) => entry.status.run === run)
|
|
308
|
+
if (index !== -1) {
|
|
309
|
+
const entry = state.pending[index]!
|
|
310
|
+
if (tickBoundary(event)) {
|
|
311
|
+
state.pending.splice(index, 1)
|
|
312
|
+
report(state, reduceDispatchStatus([event], run, entry.status), entry.started, true)
|
|
313
|
+
} else if (event.type === 'dispatcher.run-stopped') {
|
|
314
|
+
state.pending.splice(index, 1)
|
|
315
|
+
} else {
|
|
316
|
+
entry.status = reduceDispatchStatus([event], run, entry.status)
|
|
317
|
+
}
|
|
318
|
+
return
|
|
319
|
+
}
|
|
320
|
+
if (!tickBoundary(event)) return
|
|
321
|
+
const seed: DispatchStatus = {
|
|
322
|
+
run,
|
|
323
|
+
health: 'running',
|
|
324
|
+
...(state.status.effectiveConfig !== undefined
|
|
325
|
+
? { effectiveConfig: state.status.effectiveConfig }
|
|
326
|
+
: {}),
|
|
327
|
+
roleWarnings: [],
|
|
328
|
+
diagnostics: [],
|
|
329
|
+
lastSeq: 0,
|
|
330
|
+
}
|
|
331
|
+
report(state, reduceDispatchStatus([event], run, seed), 0, true)
|
|
332
|
+
}
|
|
333
|
+
|
|
195
334
|
export function forgeReadinessWarnings(status: Readonly<DispatchStatus>): string[] {
|
|
196
335
|
return (status.forgeReadinessFailures ?? []).map(formatReadinessFailure)
|
|
197
336
|
}
|
|
@@ -633,11 +633,15 @@ import { autoMergeDefaultReducer } from './auto-merge-default'
|
|
|
633
633
|
import { effectiveConfigReducer } from './service-facts'
|
|
634
634
|
import { sandboxStatesReducer } from '../processes/sandbox-state'
|
|
635
635
|
import { openHarvestExecutionsReducer } from '../processes/harvest-execution-state'
|
|
636
|
-
import {
|
|
636
|
+
import {
|
|
637
|
+
dispatchStatusReducer,
|
|
638
|
+
foldReportedDispatch,
|
|
639
|
+
initialReportedDispatch,
|
|
640
|
+
RECENT_DISPATCH_RUN_LIMIT,
|
|
641
|
+
type ReportedDispatch,
|
|
642
|
+
} from './dispatch-status'
|
|
637
643
|
|
|
638
|
-
|
|
639
|
-
* correlations outside it use the explicitly parameterized cache. */
|
|
640
|
-
export const RECENT_DISPATCH_RUN_LIMIT = 16
|
|
644
|
+
export { RECENT_DISPATCH_RUN_LIMIT } from './dispatch-status'
|
|
641
645
|
export interface RepositoryReadAcc {
|
|
642
646
|
missingAccounts: Record<string, import('../accounts/availability').MissingAccountCredential>
|
|
643
647
|
preparation: ReturnType<typeof ticketPreparationReducer.initial>
|
|
@@ -689,8 +693,8 @@ export interface RepositoryReadAcc {
|
|
|
689
693
|
autoMerge: ReturnType<typeof autoMergeDefaultReducer.initial>
|
|
690
694
|
config: ReturnType<typeof effectiveConfigReducer.initial>
|
|
691
695
|
sandboxes: ReturnType<typeof sandboxStatesReducer.initial>
|
|
692
|
-
status
|
|
693
|
-
|
|
696
|
+
/** The dispatcher run the reduced status describes; see `foldReportedDispatch`. */
|
|
697
|
+
dispatch: ReportedDispatch
|
|
694
698
|
scanSeq?: number
|
|
695
699
|
scan?: Extract<RepositoryEvent, { type: 'dispatcher.ticket-scan-completed' }>['payload']
|
|
696
700
|
recentRuns: [string, DispatcherRunFacts][]
|
|
@@ -754,7 +758,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
754
758
|
autoMerge: autoMergeDefaultReducer.initial(),
|
|
755
759
|
config: effectiveConfigReducer.initial(),
|
|
756
760
|
sandboxes: sandboxStatesReducer.initial(),
|
|
757
|
-
|
|
761
|
+
dispatch: initialReportedDispatch(),
|
|
758
762
|
publications: [],
|
|
759
763
|
}),
|
|
760
764
|
fold(acc: RepositoryReadAcc, events: readonly RepositoryEvent[]) {
|
|
@@ -846,11 +850,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
846
850
|
acc.dismissedThrough = Math.max(acc.dismissedThrough, acc.pendingHumanResume)
|
|
847
851
|
if (event.type === 'harvest.failed' && !event.payload.willRetry)
|
|
848
852
|
acc.failedAt[JSON.stringify(event.payload.run)] = event.ts
|
|
849
|
-
|
|
850
|
-
acc.run = event.payload.run
|
|
851
|
-
acc.status = dispatchStatusReducer(acc.run).initial()
|
|
852
|
-
}
|
|
853
|
-
if (acc.run) acc.status = dispatchStatusReducer(acc.run).advance(acc.status, [event])
|
|
853
|
+
foldReportedDispatch(acc.dispatch, event)
|
|
854
854
|
if (event.type === 'dispatcher.ticket-scan-completed') {
|
|
855
855
|
acc.scan = event.payload
|
|
856
856
|
acc.scanSeq = event.seq
|
|
@@ -917,7 +917,9 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
917
917
|
autoMerge: autoMergeDefaultReducer.finish(acc.autoMerge),
|
|
918
918
|
config: effectiveConfigReducer.finish(acc.config),
|
|
919
919
|
sandboxes: sandboxStatesReducer.finish(acc.sandboxes),
|
|
920
|
-
status: acc.
|
|
920
|
+
status: acc.dispatch.run
|
|
921
|
+
? dispatchStatusReducer(acc.dispatch.run).finish(acc.dispatch.status)
|
|
922
|
+
: undefined,
|
|
921
923
|
scan: acc.scan,
|
|
922
924
|
scanSeq: acc.scanSeq,
|
|
923
925
|
recentRuns: structuredClone(acc.recentRuns),
|
|
@@ -72,4 +72,6 @@ export const REDUCER_REVISIONS: Readonly<Record<string, string>> = {
|
|
|
72
72
|
'leafRestack/fold/5zq9n2zlit': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
73
73
|
'logIndex/fold/bwl7r7gjae': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
74
74
|
'verifyDiffBase/fold/p2si2x55v7': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
75
|
+
'repositoryReadFacts/shape/mggr8x6l5z': '#1279 reported dispatcher run tracks pending runs',
|
|
76
|
+
'repositoryReadFacts/fold/vvcfmd23zp': '#1279 status describes the authority run',
|
|
75
77
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { normalizeEffectiveConfigArtifact } from '../config/effective-artifact'
|
|
2
2
|
import { migrationIdentity } from '../kernel/ticket-migrations'
|
|
3
3
|
import { enrichDrainingRow, projectHandoffs } from '../cli/dashboard/handoff'
|
|
4
|
+
import { repositoryQueueDepth } from '../cli/dashboard/header'
|
|
4
5
|
import { enrichIntegrationRows } from '../cli/dashboard/integration-row'
|
|
5
6
|
import {
|
|
6
7
|
dispatchCapacity,
|
|
@@ -476,7 +477,7 @@ async function dashboardFromView(
|
|
|
476
477
|
enrichIntegrationRows(projected, await integrationRecords(view, opts.repo, projected, records)),
|
|
477
478
|
{
|
|
478
479
|
repo: opts.repo,
|
|
479
|
-
queued:
|
|
480
|
+
queued: repositoryQueueDepth(repositoryEvents),
|
|
480
481
|
activeCount: capacityProjection.occupied,
|
|
481
482
|
capacityProjection,
|
|
482
483
|
capacity: config.capacity,
|
|
@@ -525,7 +526,11 @@ function noDispatcherRunSnapshot(
|
|
|
525
526
|
clock: Clock,
|
|
526
527
|
): OperatorDashboardSnapshot {
|
|
527
528
|
const model: DashboardModel = {
|
|
528
|
-
...buildDashboardFromProjected(
|
|
529
|
+
...buildDashboardFromProjected(
|
|
530
|
+
[],
|
|
531
|
+
{ repo, queued: repositoryQueueDepth(facts), activeCount: 0, capacity: 0 },
|
|
532
|
+
facts,
|
|
533
|
+
),
|
|
529
534
|
configuration: 'no-dispatcher-run',
|
|
530
535
|
}
|
|
531
536
|
return dashboardSnapshot(model, clock)
|