@defrex/autobuild 1.11.1 → 1.12.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 +177 -54
- package/docs/answering-blocked-builds.md +10 -2
- package/docs/architecture.md +66 -6
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +13 -11
- package/docs/dispatcher.md +1 -1
- package/docs/integration-tree.md +28 -16
- package/docs/operator-api.md +4 -4
- package/docs/operator-surfaces.md +35 -0
- package/docs/optimization-nodes.md +3 -2
- package/docs/tickets.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/ambient-errors.ts +17 -0
- package/packages/core/src/cli/bounded-io.ts +174 -0
- package/packages/core/src/cli/dashboard/model.ts +81 -23
- package/packages/core/src/cli/dashboard/poll.ts +20 -31
- package/packages/core/src/cli/dashboard/render.ts +14 -37
- package/packages/core/src/cli/dashboard/row-text.ts +24 -7
- package/packages/core/src/cli/dashboard/tone-ansi.ts +39 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +161 -20
- package/packages/core/src/cli/dispatch-handoff.ts +41 -10
- package/packages/core/src/cli/dispatch-launch-contract.ts +5 -0
- package/packages/core/src/cli/dispatch-launcher-cadence.ts +80 -0
- package/packages/core/src/cli/dispatch-launcher.ts +9 -10
- package/packages/core/src/cli/dispatch-preflight.ts +12 -3
- package/packages/core/src/cli/dispatch-release-observer.ts +53 -0
- package/packages/core/src/cli/dispatch-runtime-cache.ts +204 -82
- package/packages/core/src/cli/dispatch-runtime-dependencies.ts +250 -43
- package/packages/core/src/cli/dispatch-upgrade-install.ts +36 -16
- package/packages/core/src/cli/dispatch-upgrade-source.ts +8 -2
- package/packages/core/src/cli/dispatch-yield-observer.ts +82 -0
- package/packages/core/src/cli/dispatch.ts +68 -5
- package/packages/core/src/cli/env.ts +2 -15
- package/packages/core/src/cli/help.ts +5 -4
- package/packages/core/src/cli/main.ts +4 -2
- package/packages/core/src/cli/production-store.ts +102 -0
- package/packages/core/src/cli/repo-state.ts +2 -3
- package/packages/core/src/cli/repository-status.ts +28 -22
- package/packages/core/src/cli/sessionless-store.ts +26 -0
- package/packages/core/src/cli/status.ts +169 -40
- package/packages/core/src/cli/store-opening.ts +15 -58
- package/packages/core/src/cli/store-ref.ts +6 -1
- package/packages/core/src/config/schema.ts +1 -1
- package/packages/core/src/distribution-packaging.ts +156 -18
- package/packages/core/src/events/catalog-identity.ts +28 -0
- package/packages/core/src/events/catalog.ts +3 -9
- package/packages/core/src/events/compatibility.ts +2 -30
- package/packages/core/src/events/payloads.ts +11 -0
- package/packages/core/src/events/policy.ts +3 -0
- package/packages/core/src/events/repository.ts +1 -1
- package/packages/core/src/events/sessions.ts +1 -1
- package/packages/core/src/events/validation-error.ts +12 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +9 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3064e337cc75f8d6.json +310 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a1e90a969d32a367.json +307 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/da3bc91c49211eab.json +310 -0
- package/packages/core/src/kernel/auto-merge-default.ts +2 -1
- package/packages/core/src/kernel/capacity-build.ts +21 -0
- package/packages/core/src/kernel/discard-in-flight.ts +13 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +354 -147
- package/packages/core/src/kernel/engine.ts +2 -8
- package/packages/core/src/kernel/measurement.ts +24 -0
- package/packages/core/src/kernel/read-facts.ts +8 -370
- package/packages/core/src/kernel/reducer-registry.ts +40 -125
- package/packages/core/src/kernel/reducer-revisions.ts +3 -0
- package/packages/core/src/kernel/reducer-value-entry.ts +98 -0
- package/packages/core/src/kernel/reducer-value-index.ts +75 -0
- package/packages/core/src/kernel/reducer.ts +57 -9
- package/packages/core/src/kernel/reopen-state.ts +10 -0
- package/packages/core/src/kernel/repository-read-facts.ts +375 -0
- package/packages/core/src/kernel/verify-stage-state.ts +145 -3
- package/packages/core/src/operator/presentation.ts +13 -0
- package/packages/core/src/operator/query.ts +40 -39
- package/packages/core/src/operator/registry.ts +3 -3
- package/packages/core/src/ports/workspace/fake.ts +15 -3
- package/packages/core/src/processes/dispatcher.ts +232 -75
- package/packages/core/src/processes/execution-no-progress.ts +1 -0
- package/packages/core/src/store/local/capabilities.ts +115 -0
- package/packages/core/src/store/local/store.ts +86 -56
- package/packages/core/src/store/reduced-reads.ts +9 -1
- package/packages/core/src/store/reducer-value-read.ts +235 -0
- package/packages/core/src/store/reducer-value-shapes.json +1437 -1349
- package/packages/core/src/store/reducer-values.ts +36 -204
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.12.0.json +35806 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
- package/packages/core/src/store/rollup-lease.ts +41 -0
- package/packages/core/src/store/rollups.ts +7 -38
- package/packages/core/src/store/snapshots.ts +1 -1
- package/packages/core/src/testing/dispatch-read-budget.ts +265 -4
- package/packages/core/src/testing/import-graph.ts +78 -0
- package/packages/core/src/testing/reduced-read-budget.ts +221 -22
- package/packages/core/src/testing/slot-agreement.ts +52 -0
- package/packages/core/src/web/assets/app.js +5 -5
- package/skills/guide/SKILL.md +115 -44
- package/skills/guide/references/integration-tree.md +28 -16
- package/skills/guide/references/operator-api.md +4 -4
- package/skills/guide/references/optimization-nodes.md +3 -2
- package/skills/operate/SKILL.md +38 -20
- package/templates/hosted-service/package.json +2 -2
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value-read entry every registered reducer is served through, built
|
|
3
|
+
* without the complete catalog. `reducer-registry.ts` builds `REDUCERS` with
|
|
4
|
+
* `valueReadEntry`, and `reducer-value-index.ts` builds the selectively loaded
|
|
5
|
+
* registrations with it, so both produce identical entries.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
import { phaseSchema } from '../ontology'
|
|
9
|
+
import { validateAccumulator, encodeReducerValue } from '../store/reducer-value-validation'
|
|
10
|
+
import type { ValueCatalogEntry } from '../store/reducer-value-read'
|
|
11
|
+
import type { IncrementalReducer } from './incremental'
|
|
12
|
+
|
|
13
|
+
export interface RegisteredReducer {
|
|
14
|
+
valueRead: ValueCatalogEntry | { excluded: string }
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: the registry is heterogeneous
|
|
16
|
+
reducer: IncrementalReducer<any, any, any>
|
|
17
|
+
/** The whole-array functions (or private methods) this reducer backs. */
|
|
18
|
+
covers: readonly string[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Qualification concerns the existing finished contract, including absence. */
|
|
22
|
+
export const valueExclusions: Record<string, string> = {
|
|
23
|
+
dispatchFrontend: 'returns a list of raw repository journal events',
|
|
24
|
+
journalView: 'returns a list of raw repository journal events',
|
|
25
|
+
repositoryStateEvents: 'returns a list of raw repository journal events',
|
|
26
|
+
session: 'consumes operator-session logs rather than build or repository events',
|
|
27
|
+
publicationState: 'finished value contains executable selector functions',
|
|
28
|
+
logIndex: 'finished value contains Maps and Sets',
|
|
29
|
+
hostedPrAttachments: 'finished value is a Map',
|
|
30
|
+
...Object.fromEntries(
|
|
31
|
+
[
|
|
32
|
+
'summaryBoundary',
|
|
33
|
+
'ticketSourceHealth',
|
|
34
|
+
'frozenPrImageHost',
|
|
35
|
+
'publishedBranchHead',
|
|
36
|
+
'verifyDiffBase',
|
|
37
|
+
'recordedBaseSha',
|
|
38
|
+
'baseBranch',
|
|
39
|
+
'provisionMarker',
|
|
40
|
+
'recoveryCheckpoint',
|
|
41
|
+
].map((name) => [name, 'finished contract can return top-level undefined, which is not JSON']),
|
|
42
|
+
),
|
|
43
|
+
}
|
|
44
|
+
export const repositoryValues = new Set([
|
|
45
|
+
'dispatchPlacement',
|
|
46
|
+
'ticketPreparation',
|
|
47
|
+
'ticketHandbacks',
|
|
48
|
+
'ticketStarts',
|
|
49
|
+
'ticketMigrations',
|
|
50
|
+
'forgeHealthValue',
|
|
51
|
+
'repositoryReadFacts',
|
|
52
|
+
'dispatchUpgrade',
|
|
53
|
+
'dispatcherRunFacts',
|
|
54
|
+
'repositoryAttention',
|
|
55
|
+
'effectiveConfig',
|
|
56
|
+
'harvestDelegation',
|
|
57
|
+
'harvest',
|
|
58
|
+
'dispatchSettings',
|
|
59
|
+
'dispatchStatus',
|
|
60
|
+
'sandboxStates',
|
|
61
|
+
'openHarvestExecutions',
|
|
62
|
+
'hostedHarvestAuthority',
|
|
63
|
+
'openTick',
|
|
64
|
+
'autoMergeDefault',
|
|
65
|
+
])
|
|
66
|
+
export const noArgs = z.object({}).strict()
|
|
67
|
+
const run = z.object({ run: z.string().min(1) }).strict()
|
|
68
|
+
/** Arguments of the parameterized reducers; their `create` functions stay with
|
|
69
|
+
* the reducer modules that construct them. */
|
|
70
|
+
export const parameterizedArgs: Record<string, z.ZodType> = {
|
|
71
|
+
terminalGuard: z
|
|
72
|
+
.object({ phase: phaseSchema, round: z.number().int(), session: z.string().min(1) })
|
|
73
|
+
.strict(),
|
|
74
|
+
dispatchStatus: run,
|
|
75
|
+
dispatcherRunFacts: run,
|
|
76
|
+
openTick: run,
|
|
77
|
+
dispatchFailureBudget: z.object({ infrastructureOwnsWorkspace: z.boolean() }).strict(),
|
|
78
|
+
phaseFailures: z.object({ phase: phaseSchema, round: z.number().int().nonnegative() }).strict(),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** One registered reducer's value-read entry. */
|
|
82
|
+
export function valueReadEntry(
|
|
83
|
+
name: string,
|
|
84
|
+
// biome-ignore lint/suspicious/noExplicitAny: the registry is heterogeneous
|
|
85
|
+
reducer: IncrementalReducer<any, any, any>,
|
|
86
|
+
options: Partial<Pick<ValueCatalogEntry, 'create' | 'adapt'>> = {},
|
|
87
|
+
): RegisteredReducer['valueRead'] {
|
|
88
|
+
const excluded = valueExclusions[name]
|
|
89
|
+
if (excluded) return { excluded }
|
|
90
|
+
return {
|
|
91
|
+
scope: repositoryValues.has(name) ? 'repo' : 'build',
|
|
92
|
+
args: parameterizedArgs[name] ?? noArgs,
|
|
93
|
+
validate: (state: unknown) => validateAccumulator(name, state),
|
|
94
|
+
value: encodeReducerValue,
|
|
95
|
+
adapt: options.adapt ?? ((events) => events),
|
|
96
|
+
create: options.create ?? (() => reducer),
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selective reducer lookup for value reads. The reducers short-lived readers
|
|
3
|
+
* request load only their own modules; every other name resolves through the
|
|
4
|
+
* complete `REDUCERS` catalog, loaded on first need. Both paths build entries
|
|
5
|
+
* with `valueReadEntry`, so identities, keys and validation are identical
|
|
6
|
+
* (`reducer-value-index.test.ts` pins each selective registration to its
|
|
7
|
+
* catalog entry). This module must never import the registry statically.
|
|
8
|
+
*/
|
|
9
|
+
import { valueReadEntry, type RegisteredReducer } from './reducer-value-entry'
|
|
10
|
+
|
|
11
|
+
type Loader = () => Promise<RegisteredReducer>
|
|
12
|
+
|
|
13
|
+
/** Names whose registration is built from the reducer module alone. `covers`
|
|
14
|
+
* and representative arguments match `REGISTERED`. */
|
|
15
|
+
const SELECTIVE: Record<string, Loader> = {
|
|
16
|
+
dispatchUpgrade: async () => {
|
|
17
|
+
const { dispatchUpgradeReducer } = await import('./dispatch-upgrade')
|
|
18
|
+
return registration('dispatchUpgrade', dispatchUpgradeReducer)
|
|
19
|
+
},
|
|
20
|
+
repositoryReadFacts: async () => {
|
|
21
|
+
const { repositoryReadFactsReducer } = await import('./repository-read-facts')
|
|
22
|
+
return registration('repositoryReadFacts', repositoryReadFactsReducer)
|
|
23
|
+
},
|
|
24
|
+
dispatcherRunFacts: async () => {
|
|
25
|
+
const { dispatcherRunFactsReducer } = await import('./repository-read-facts')
|
|
26
|
+
return registration('dispatcherRunFacts', dispatcherRunFactsReducer('run-a'), {
|
|
27
|
+
create: ({ run }) => dispatcherRunFactsReducer(run),
|
|
28
|
+
})
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
export const SELECTIVE_VALUE_REGISTRATIONS: readonly string[] = Object.keys(SELECTIVE)
|
|
32
|
+
|
|
33
|
+
function registration(
|
|
34
|
+
name: string,
|
|
35
|
+
reducer: RegisteredReducer['reducer'],
|
|
36
|
+
options?: Parameters<typeof valueReadEntry>[2],
|
|
37
|
+
): RegisteredReducer {
|
|
38
|
+
return { reducer, covers: [], valueRead: valueReadEntry(name, reducer, options) }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const loaded = new Map<string, Promise<RegisteredReducer>>()
|
|
42
|
+
const settled = new Map<string, RegisteredReducer>()
|
|
43
|
+
let catalog: Record<string, RegisteredReducer> | undefined
|
|
44
|
+
|
|
45
|
+
/** The registration `name` resolves to, or `undefined` for an unknown name. */
|
|
46
|
+
export async function loadValueRegistration(name: string): Promise<RegisteredReducer | undefined> {
|
|
47
|
+
if (!Object.hasOwn(SELECTIVE, name)) {
|
|
48
|
+
catalog ??= (await import('./reducer-registry')).REDUCERS
|
|
49
|
+
return Object.hasOwn(catalog, name) ? catalog[name] : undefined
|
|
50
|
+
}
|
|
51
|
+
let pending = loaded.get(name)
|
|
52
|
+
if (!pending) {
|
|
53
|
+
pending = SELECTIVE[name]!().then(
|
|
54
|
+
(registration) => {
|
|
55
|
+
settled.set(name, registration)
|
|
56
|
+
return registration
|
|
57
|
+
},
|
|
58
|
+
(error: unknown) => {
|
|
59
|
+
loaded.delete(name)
|
|
60
|
+
throw error
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
loaded.set(name, pending)
|
|
64
|
+
}
|
|
65
|
+
return pending
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The answer `loadValueRegistration(name)` would give, synchronously, once
|
|
69
|
+
* the module it needs has loaded; `null` while it has not. A warm read then
|
|
70
|
+
* resolves with no added await, so its timing matches the static catalog. */
|
|
71
|
+
export function loadedValueRegistration(name: string): RegisteredReducer | undefined | null {
|
|
72
|
+
if (Object.hasOwn(SELECTIVE, name)) return settled.get(name) ?? null
|
|
73
|
+
if (!catalog) return null
|
|
74
|
+
return Object.hasOwn(catalog, name) ? catalog[name] : undefined
|
|
75
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { SelectedAccount } from '../config/accounts'
|
|
|
2
2
|
import { foldHeadPaths, type HeadPathsSummary } from './head-paths-state'
|
|
3
3
|
import {
|
|
4
4
|
advanceVerifyStage,
|
|
5
|
+
escalationCarried,
|
|
5
6
|
initialVerifyStageState,
|
|
6
7
|
verifyMemberKey,
|
|
7
8
|
runningVerifyMembers,
|
|
@@ -458,6 +459,23 @@ export interface BuildState {
|
|
|
458
459
|
* `wait awaiting-pr` decision (`pipeline.settled`); capacity evidence only,
|
|
459
460
|
* never a pipeline decision input. */
|
|
460
461
|
pipelineSettled?: number
|
|
462
|
+
/** seq of the latest admission into a slot: the build's `build.created` or
|
|
463
|
+
* the dispatcher's `slot.admitted` (SPEC §12 "What holds a slot"). Runner
|
|
464
|
+
* allocation never admits. Capacity evidence only. Omitted for an empty
|
|
465
|
+
* log, and by an older server. */
|
|
466
|
+
slotAdmittedSeq?: number
|
|
467
|
+
/** seq of the latest fact that released the slot or ended an outside wait
|
|
468
|
+
* whose runner must be admitted again: `pipeline.settled`, an answer that
|
|
469
|
+
* closes an open escalation while the build is not carried
|
|
470
|
+
* (`escalationCarried`), such a `wait.ended`, and `build.paused` (SPEC §12
|
|
471
|
+
* "What holds a slot"). Capacity evidence only. Omitted until one lands,
|
|
472
|
+
* and by an older server. */
|
|
473
|
+
slotReleasedSeq?: number
|
|
474
|
+
/** The node runner need the latest `slot.admitted` named (SPEC §12 "What
|
|
475
|
+
* holds a slot"): a node holds its slot while that need remains. Cleared by
|
|
476
|
+
* an admission that names none; `build.created` sets none. Capacity
|
|
477
|
+
* evidence only. */
|
|
478
|
+
slotAdmittedNeed?: string
|
|
461
479
|
/** Full-log `finalize.step-completed` facts, in event order (§5).
|
|
462
480
|
* Post-steps are failure-tolerant, so a completion counts whether `ok` is
|
|
463
481
|
* true or false. Current-spec membership is determined by
|
|
@@ -593,15 +611,7 @@ export interface BuildState {
|
|
|
593
611
|
failures: Record<string, number>
|
|
594
612
|
}
|
|
595
613
|
|
|
596
|
-
|
|
597
|
-
* while the build is non-terminal and its discard is unsettled; the reducer
|
|
598
|
-
* settles it only by terminal completion. This is the single predicate shared
|
|
599
|
-
* by the auto-merge default fan-out (`autoMergeDefaultEligible`, AUT-418) and
|
|
600
|
-
* the per-build consent guard (`controlBuild`'s `discard-pending` refusal), so
|
|
601
|
-
* the two controls' discard exclusions cannot diverge silently. */
|
|
602
|
-
export function discardInFlight(state: Pick<BuildState, 'discardRequest'>): boolean {
|
|
603
|
-
return state.discardRequest !== undefined
|
|
604
|
-
}
|
|
614
|
+
export { discardInFlight } from './discard-in-flight'
|
|
605
615
|
|
|
606
616
|
/** The reducer's carried accumulator: everything `reduceBuild` folds, before
|
|
607
617
|
* the final status derivation. Plain JSON-shaped data (the escalation and
|
|
@@ -694,6 +704,9 @@ export interface BuildAcc {
|
|
|
694
704
|
priority?: TicketPriority
|
|
695
705
|
finalizeCompletedSeq: number
|
|
696
706
|
pipelineSettled?: number
|
|
707
|
+
slotAdmittedSeq?: number
|
|
708
|
+
slotReleasedSeq?: number
|
|
709
|
+
slotAdmittedNeed?: string
|
|
697
710
|
finalizeSteps: BuildState['finalizeSteps']
|
|
698
711
|
plan: BuildState['plan']
|
|
699
712
|
implement: BuildState['implement']
|
|
@@ -773,6 +786,13 @@ function initialBuildAcc(): BuildAcc {
|
|
|
773
786
|
function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
774
787
|
advanceCompatibility(acc.compatibility, events)
|
|
775
788
|
events = projectEvents(events)
|
|
789
|
+
// The open execution as of each event, for the answer fold's carry: read
|
|
790
|
+
// before the pre-pass below marks this batch's ended instances.
|
|
791
|
+
const latestExecution = acc.executions.at(-1)
|
|
792
|
+
let liveExecution =
|
|
793
|
+
latestExecution && !acc.endedExecutionInstances[latestExecution.instance]
|
|
794
|
+
? latestExecution
|
|
795
|
+
: undefined
|
|
776
796
|
for (const event of events) {
|
|
777
797
|
if (event.type === 'build.compatibility-deferred')
|
|
778
798
|
acc.compatibilityDeferredBoundary = event.payload.boundary
|
|
@@ -853,6 +873,19 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
853
873
|
const suspended = new Map(acc.suspendedSessions.map((s) => [s.session, s]))
|
|
854
874
|
const openSessions = new Map(acc.openSessions.map((s) => [s.session, s]))
|
|
855
875
|
const failures = acc.failures
|
|
876
|
+
/** Work Autobuild started still outruns the open escalations, as of the
|
|
877
|
+
* event being folded: an answer then releases nothing (SPEC §12). */
|
|
878
|
+
const carried = () =>
|
|
879
|
+
escalationCarried({
|
|
880
|
+
openEscalations: [...openEscalations.values()],
|
|
881
|
+
verifyStage: acc.verifyStage,
|
|
882
|
+
verifyCycle: verify.cycleSince,
|
|
883
|
+
maxAttemptSeen: verify.maxAttemptSeen,
|
|
884
|
+
executions,
|
|
885
|
+
liveExecution,
|
|
886
|
+
slotAdmittedSeq: acc.slotAdmittedSeq,
|
|
887
|
+
failures: [dispatchFailures, infrastructureFailures, setupFailures],
|
|
888
|
+
})
|
|
856
889
|
|
|
857
890
|
const start = (ctx: PhaseContext): void => {
|
|
858
891
|
currentPhase = ctx
|
|
@@ -1079,6 +1112,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1079
1112
|
prState = 'open'
|
|
1080
1113
|
break
|
|
1081
1114
|
case 'build.created':
|
|
1115
|
+
acc.slotAdmittedSeq = event.seq
|
|
1082
1116
|
acc.kind = event.payload.kind
|
|
1083
1117
|
acc.target = event.payload.target
|
|
1084
1118
|
acc.baseBranch = event.payload.baseBranch
|
|
@@ -1196,9 +1230,11 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1196
1230
|
break
|
|
1197
1231
|
case 'execution.started':
|
|
1198
1232
|
executions.push({ ...event.payload, seq: event.seq })
|
|
1233
|
+
liveExecution = executions.at(-1)
|
|
1199
1234
|
infrastructureFailure = undefined
|
|
1200
1235
|
break
|
|
1201
1236
|
case 'execution.ended':
|
|
1237
|
+
if (liveExecution?.instance === event.payload.instance) liveExecution = undefined
|
|
1202
1238
|
infrastructureFailure = undefined
|
|
1203
1239
|
break
|
|
1204
1240
|
case 'infrastructure.failed': {
|
|
@@ -1276,6 +1312,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1276
1312
|
}
|
|
1277
1313
|
break
|
|
1278
1314
|
case 'build.paused':
|
|
1315
|
+
acc.slotReleasedSeq = event.seq
|
|
1279
1316
|
pausedFlag = true
|
|
1280
1317
|
pending.pause = []
|
|
1281
1318
|
break
|
|
@@ -1592,6 +1629,12 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1592
1629
|
break
|
|
1593
1630
|
case 'pipeline.settled':
|
|
1594
1631
|
acc.pipelineSettled = Math.max(acc.pipelineSettled ?? 0, event.payload.cycle)
|
|
1632
|
+
acc.slotReleasedSeq = event.seq
|
|
1633
|
+
break
|
|
1634
|
+
case 'slot.admitted':
|
|
1635
|
+
acc.slotAdmittedSeq = event.seq
|
|
1636
|
+
if (event.payload.need !== undefined) acc.slotAdmittedNeed = event.payload.need
|
|
1637
|
+
else delete acc.slotAdmittedNeed
|
|
1595
1638
|
break
|
|
1596
1639
|
case 'finalize.step-completed':
|
|
1597
1640
|
// §5: post-steps are independent and failure-tolerant — a completion
|
|
@@ -1810,6 +1853,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1810
1853
|
const wait = acc.wait
|
|
1811
1854
|
if (wait?.id !== event.payload.id || wait.ended) break
|
|
1812
1855
|
wait.ended = { cause: event.payload.cause, seq: event.seq, message: event.payload.message }
|
|
1856
|
+
if (!carried()) acc.slotReleasedSeq = event.seq
|
|
1813
1857
|
const open = openEscalations.get(wait.escalation)
|
|
1814
1858
|
if (open) {
|
|
1815
1859
|
openEscalations.delete(open.id)
|
|
@@ -1881,6 +1925,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1881
1925
|
// with no open raise is ignored (total over any prefix).
|
|
1882
1926
|
const open = openEscalations.get(event.payload.id)
|
|
1883
1927
|
if (open) {
|
|
1928
|
+
if (!carried()) acc.slotReleasedSeq = event.seq
|
|
1884
1929
|
openEscalations.delete(event.payload.id)
|
|
1885
1930
|
answeredEscalations.push({
|
|
1886
1931
|
...open,
|
|
@@ -2047,6 +2092,9 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
2047
2092
|
autoMerge: acc.autoMerge,
|
|
2048
2093
|
finalizeCompletedSeq: acc.finalizeCompletedSeq,
|
|
2049
2094
|
...(acc.pipelineSettled !== undefined ? { pipelineSettled: acc.pipelineSettled } : {}),
|
|
2095
|
+
...(acc.slotAdmittedSeq !== undefined ? { slotAdmittedSeq: acc.slotAdmittedSeq } : {}),
|
|
2096
|
+
...(acc.slotReleasedSeq !== undefined ? { slotReleasedSeq: acc.slotReleasedSeq } : {}),
|
|
2097
|
+
...(acc.slotAdmittedNeed !== undefined ? { slotAdmittedNeed: acc.slotAdmittedNeed } : {}),
|
|
2050
2098
|
finalizeSteps: acc.finalizeSteps,
|
|
2051
2099
|
lastEvent,
|
|
2052
2100
|
lastSeq: Math.max(lastEvent?.seq ?? 0, acc.compatibility.lastSeq),
|
|
@@ -42,6 +42,16 @@ export function reopenUnsettled(
|
|
|
42
42
|
)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/** An answered `revise-spec` escalation still waits for its revision: no
|
|
46
|
+
* `spec.revised` has landed since the answer (§6.3). */
|
|
47
|
+
export function reviseSpecPending(
|
|
48
|
+
state: Pick<BuildState, 'answeredEscalations' | 'restartSince'>,
|
|
49
|
+
): boolean {
|
|
50
|
+
return state.answeredEscalations.some(
|
|
51
|
+
(e) => e.resolution === 'revise-spec' && e.answeredSeq > state.restartSince,
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
/** Where a reopen sends the leaf. */
|
|
46
56
|
export function reopenRoute(reopen: NonNullable<BuildState['reopen']>): 'implement' | 'plan' {
|
|
47
57
|
return reopen.spec !== undefined ? 'plan' : 'implement'
|