@defrex/autobuild 0.13.0 → 1.0.0-beta.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 +5 -3
- package/SPEC.md +673 -99
- package/bin/ab-dispatch-kernel.ts +4 -6
- package/docs/architecture.md +322 -75
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +112 -12
- package/docs/hosted-service.md +20 -2
- package/docs/integration-tree.md +117 -0
- package/docs/landing-policy.md +150 -0
- package/docs/mcp.md +24 -0
- package/docs/migration-1.0.md +68 -0
- package/docs/operator-api.md +20 -9
- package/docs/remote-store-protocol.md +114 -9
- package/docs/remote-ticket-protocol.md +26 -5
- package/docs/restacking.md +79 -0
- package/docs/setup.md +49 -6
- package/docs/ticket-dependencies.md +69 -0
- package/docs/ticket-migration.md +8 -0
- package/package.json +4 -3
- package/packages/core/src/cli/attention.ts +40 -163
- package/packages/core/src/cli/build-control.ts +75 -55
- package/packages/core/src/cli/bulk-control.ts +3 -2
- package/packages/core/src/cli/context.ts +68 -78
- package/packages/core/src/cli/dashboard/actions.ts +6 -3
- package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
- package/packages/core/src/cli/dashboard/live.ts +5 -0
- package/packages/core/src/cli/dashboard/model.ts +178 -40
- package/packages/core/src/cli/dashboard/poll.ts +15 -9
- package/packages/core/src/cli/dashboard/refresh.ts +176 -0
- package/packages/core/src/cli/dashboard/render.ts +78 -28
- package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
- package/packages/core/src/cli/dashboard/selection.ts +7 -1
- package/packages/core/src/cli/dashboard/tree.ts +107 -0
- package/packages/core/src/cli/dispatch-frontend.ts +173 -169
- package/packages/core/src/cli/dispatch-process.ts +14 -7
- package/packages/core/src/cli/dispatch-repository-feed.ts +196 -0
- package/packages/core/src/cli/dispatch.ts +397 -214
- package/packages/core/src/cli/dispatcher-liveness.ts +41 -21
- package/packages/core/src/cli/harvest.ts +71 -39
- package/packages/core/src/cli/help.ts +49 -32
- package/packages/core/src/cli/historical-build-state.ts +27 -0
- package/packages/core/src/cli/init-validation.ts +43 -2
- package/packages/core/src/cli/keyboard.ts +6 -0
- package/packages/core/src/cli/landings.ts +18 -0
- package/packages/core/src/cli/main.ts +52 -18
- package/packages/core/src/cli/mcp.ts +9 -0
- package/packages/core/src/cli/pr-attachments.ts +10 -13
- package/packages/core/src/cli/pr-summary-publication.ts +27 -60
- package/packages/core/src/cli/pr-summary.ts +43 -13
- package/packages/core/src/cli/publication-settlement.ts +177 -21
- package/packages/core/src/cli/repository-status.ts +49 -2
- package/packages/core/src/cli/status.ts +133 -36
- package/packages/core/src/cli/terminal-restore.ts +54 -0
- package/packages/core/src/cli/terminal.ts +16 -2
- package/packages/core/src/cli/terminals.ts +121 -219
- package/packages/core/src/cli/ticket-editor.ts +10 -3
- package/packages/core/src/cli/ticket.ts +115 -20
- package/packages/core/src/cli/upgrade-commit.ts +4 -0
- package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
- package/packages/core/src/cli/upgrade-landing.ts +69 -0
- package/packages/core/src/cli/upgrade.ts +16 -0
- package/packages/core/src/cli/wait.ts +194 -91
- package/packages/core/src/cli/watch.ts +111 -109
- package/packages/core/src/config/landing.ts +22 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/pipeline-source.ts +4 -3
- package/packages/core/src/config/schema.ts +3 -0
- package/packages/core/src/events/catalog.ts +48 -3
- package/packages/core/src/events/payloads.ts +295 -6
- package/packages/core/src/events/repository.ts +38 -3
- package/packages/core/src/integration/harness.ts +11 -2
- package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +3330 -119
- package/packages/core/src/kernel/auto-merge-default.ts +1 -0
- package/packages/core/src/kernel/auto-merge.ts +29 -4
- package/packages/core/src/kernel/build-identity.ts +94 -0
- package/packages/core/src/kernel/change-presence.ts +179 -0
- package/packages/core/src/kernel/dispatch-status.ts +17 -1
- package/packages/core/src/kernel/dispatcher-liveness.ts +10 -4
- package/packages/core/src/kernel/engine.ts +89 -2
- package/packages/core/src/kernel/generators/build-log.ts +23 -0
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +25 -3
- package/packages/core/src/kernel/harvest.ts +25 -23
- package/packages/core/src/kernel/integration-completeness.ts +81 -0
- package/packages/core/src/kernel/integration-landing.ts +263 -0
- package/packages/core/src/kernel/integration-stack.ts +36 -0
- package/packages/core/src/kernel/integration-state.ts +135 -0
- package/packages/core/src/kernel/landing-policy.ts +47 -0
- package/packages/core/src/kernel/landing-publication.ts +41 -0
- package/packages/core/src/kernel/landing-readiness.ts +67 -0
- package/packages/core/src/kernel/landing-state.ts +96 -0
- package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
- package/packages/core/src/kernel/log-index-value.ts +38 -0
- package/packages/core/src/kernel/log-index.ts +35 -5
- package/packages/core/src/kernel/node-landing.ts +439 -0
- package/packages/core/src/kernel/node-parent.ts +184 -0
- package/packages/core/src/kernel/node-restack-state.ts +191 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
- package/packages/core/src/kernel/node-restack.ts +274 -0
- package/packages/core/src/kernel/read-facts.ts +704 -0
- package/packages/core/src/kernel/reconcile-head.ts +51 -0
- package/packages/core/src/kernel/reconcile-restack.ts +560 -0
- package/packages/core/src/kernel/reducer-registry.ts +153 -3
- package/packages/core/src/kernel/reducer.ts +121 -6
- package/packages/core/src/kernel/repository-attention.ts +179 -0
- package/packages/core/src/kernel/service-facts.ts +135 -0
- package/packages/core/src/kernel/snapshot-parent.ts +33 -0
- package/packages/core/src/kernel/terminal-guard.ts +133 -0
- package/packages/core/src/ontology.ts +9 -1
- package/packages/core/src/operator/annotations.ts +12 -0
- package/packages/core/src/operator/control.ts +11 -6
- package/packages/core/src/operator/index.ts +6 -0
- package/packages/core/src/operator/landings.ts +35 -0
- package/packages/core/src/operator/presentation.ts +1 -0
- package/packages/core/src/operator/protocol.ts +12 -3
- package/packages/core/src/operator/query.ts +40 -21
- package/packages/core/src/operator/read-view.ts +4 -13
- package/packages/core/src/operator/registry.ts +48 -19
- package/packages/core/src/operator/requests.ts +3 -22
- package/packages/core/src/operator/sandbox.ts +10 -9
- package/packages/core/src/operator/tickets.ts +57 -11
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/ports/forge/contract.ts +91 -3
- package/packages/core/src/ports/forge/fake.ts +142 -4
- package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
- package/packages/core/src/ports/forge/github-readiness.ts +421 -0
- package/packages/core/src/ports/forge/github.ts +631 -35
- package/packages/core/src/ports/forge/local-git.ts +119 -5
- package/packages/core/src/ports/forge/readiness.ts +99 -0
- package/packages/core/src/ports/tickets/contract.ts +41 -0
- package/packages/core/src/ports/tickets/create.ts +8 -1
- package/packages/core/src/ports/tickets/fake.ts +32 -1
- package/packages/core/src/ports/tickets/file-codec.ts +7 -0
- package/packages/core/src/ports/tickets/file.ts +18 -1
- package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
- package/packages/core/src/ports/tickets/linear.ts +124 -4
- package/packages/core/src/ports/tickets/migration.ts +25 -1
- package/packages/core/src/ports/tickets/operations.ts +7 -2
- package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
- package/packages/core/src/ports/tickets/remote.ts +10 -1
- package/packages/core/src/ports/tickets/revision.ts +3 -1
- package/packages/core/src/ports/tickets/tree.ts +148 -0
- package/packages/core/src/ports/tickets/update.ts +15 -2
- package/packages/core/src/ports/types.ts +135 -5
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
- package/packages/core/src/processes/build-child.ts +6 -6
- package/packages/core/src/processes/build-runner.ts +586 -87
- package/packages/core/src/processes/dispatch-failure-budget.ts +5 -4
- package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
- package/packages/core/src/processes/dispatcher.ts +2239 -357
- package/packages/core/src/processes/execution-no-progress.ts +46 -1
- package/packages/core/src/processes/harvest-execution-state.ts +15 -9
- package/packages/core/src/processes/harvest-runner.ts +34 -70
- package/packages/core/src/processes/harvest.ts +38 -15
- package/packages/core/src/processes/infrastructure-failure-budget.ts +13 -15
- package/packages/core/src/processes/orchestrator-tick.ts +2 -2
- package/packages/core/src/processes/publication-loss.ts +35 -21
- package/packages/core/src/processes/publication-state.ts +30 -5
- package/packages/core/src/processes/repo-view.ts +244 -1130
- package/packages/core/src/processes/tick-publication.ts +110 -0
- package/packages/core/src/store/adapter.ts +23 -0
- package/packages/core/src/store/build-scope.ts +35 -0
- package/packages/core/src/store/contract.ts +909 -0
- package/packages/core/src/store/digest.ts +52 -4
- package/packages/core/src/store/local/schema.ts +26 -13
- package/packages/core/src/store/local/store.ts +296 -55
- package/packages/core/src/store/memory.ts +181 -30
- package/packages/core/src/store/phase-session.ts +34 -0
- package/packages/core/src/store/reduced-reads.ts +240 -0
- package/packages/core/src/store/reducer-value-shapes.json +18323 -0
- package/packages/core/src/store/reducer-value-validation.ts +96 -0
- package/packages/core/src/store/reducer-values.ts +145 -0
- package/packages/core/src/store/remote/client.ts +85 -0
- package/packages/core/src/store/remote/compatibility.ts +21 -9
- package/packages/core/src/store/remote/index.ts +19 -0
- package/packages/core/src/store/remote/protocol.ts +27 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/repo-state-events.ts +3 -1
- package/packages/core/src/store/repo-tick.ts +72 -0
- package/packages/core/src/store/session-handle.ts +34 -0
- package/packages/core/src/store/snapshots.ts +10 -0
- package/packages/core/src/store/subscribe.ts +1 -1
- package/packages/core/src/store/ticket-assets.ts +4 -4
- package/packages/core/src/store/types.ts +71 -6
- package/packages/core/src/testing/dispatch-read-budget.ts +215 -0
- package/packages/core/src/testing/index.ts +10 -0
- package/packages/core/src/testing/reduced-read-budget.ts +502 -0
- package/packages/core/src/testing/refresh-scheduler.ts +32 -0
- package/skills/guide/SKILL.md +116 -62
- package/skills/guide/references/integration-tree.md +117 -0
- package/skills/guide/references/landing-policy.md +150 -0
- package/skills/guide/references/migration-1.0.md +68 -0
- package/skills/guide/references/operator-api.md +13 -6
- package/skills/guide/references/plugin-authoring.md +34 -0
- package/skills/guide/references/remote-store-protocol.md +114 -9
- package/skills/guide/references/remote-ticket-protocol.md +26 -5
- package/skills/guide/references/restacking.md +79 -0
- package/skills/guide/references/setup.md +49 -6
- package/skills/guide/references/ticket-dependencies.md +69 -0
- package/skills/guide/references/ticket-migration.md +8 -0
- package/skills/operate/SKILL.md +55 -5
- package/skills/reconcile/SKILL.md +55 -48
- package/skills/spec/SKILL.md +67 -1
- package/skills/tickets/SKILL.md +55 -2
- package/templates/autobuild.toml +3 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
import { nodeRestackReducer } from './node-restack-state'
|
|
2
|
+
import { leafRestackReducer } from './leaf-restack-state'
|
|
3
|
+
import { terminalGuardReducer } from './terminal-guard'
|
|
4
|
+
import { repositoryAttentionReducer } from './repository-attention'
|
|
5
|
+
import {
|
|
6
|
+
dispatcherRunFactsReducer,
|
|
7
|
+
buildStreamSeedReducer,
|
|
8
|
+
buildReadFactsReducer,
|
|
9
|
+
repositoryReadFactsReducer,
|
|
10
|
+
optionalValue,
|
|
11
|
+
} from './read-facts'
|
|
12
|
+
import { validateAccumulator, encodeReducerValue } from '../store/reducer-value-validation'
|
|
13
|
+
import {
|
|
14
|
+
effectiveConfigReducer,
|
|
15
|
+
buildDelegationReducer,
|
|
16
|
+
harvestDelegationReducer,
|
|
17
|
+
} from './service-facts'
|
|
18
|
+
import { phaseSchema } from '../ontology'
|
|
19
|
+
import { z } from 'zod'
|
|
20
|
+
import type { ValueCatalogEntry } from '../store/reducer-values'
|
|
21
|
+
import { dispatchFrontendReducer } from '../cli/dispatch-repository-feed'
|
|
1
22
|
import { executionNoProgressReducer } from '../processes/execution-no-progress'
|
|
2
23
|
import { summaryBoundaryReducer, summaryRequestsReducer } from './pr-summary'
|
|
3
24
|
import { dispatchFailureBudgetReducer } from '../processes/dispatch-failure-budget'
|
|
@@ -52,6 +73,7 @@ import {
|
|
|
52
73
|
import { buildReducer } from './reducer'
|
|
53
74
|
|
|
54
75
|
export interface RegisteredReducer {
|
|
76
|
+
valueRead: ValueCatalogEntry | { excluded: string }
|
|
55
77
|
// biome-ignore lint/suspicious/noExplicitAny: the registry is heterogeneous
|
|
56
78
|
reducer: IncrementalReducer<any, any, any>
|
|
57
79
|
/** The whole-array functions (or private methods) this reducer backs. */
|
|
@@ -60,7 +82,26 @@ export interface RegisteredReducer {
|
|
|
60
82
|
|
|
61
83
|
/** Parameterized reducers are registered with representative arguments; the
|
|
62
84
|
* accumulator shape does not depend on them. */
|
|
63
|
-
|
|
85
|
+
const REGISTERED: Record<string, Omit<RegisteredReducer, 'valueRead'>> = {
|
|
86
|
+
nodeRestack: { reducer: nodeRestackReducer, covers: ['advanceNodeRestack'] },
|
|
87
|
+
leafRestack: { reducer: leafRestackReducer, covers: ['advanceLeafRestack'] },
|
|
88
|
+
baseBranchValue: { reducer: optionalValue(baseBranchReducer), covers: [] },
|
|
89
|
+
publishedBranchHeadValue: { reducer: optionalValue(publishedBranchHeadReducer), covers: [] },
|
|
90
|
+
verifyDiffBaseValue: { reducer: optionalValue(verifyDiffBaseReducer), covers: [] },
|
|
91
|
+
recordedBaseShaValue: { reducer: optionalValue(recordedBaseShaReducer), covers: [] },
|
|
92
|
+
terminalGuard: {
|
|
93
|
+
reducer: terminalGuardReducer({ phase: 'plan', round: 1, session: 'session' }),
|
|
94
|
+
covers: [],
|
|
95
|
+
},
|
|
96
|
+
dispatcherRunFacts: { reducer: dispatcherRunFactsReducer('run-a'), covers: [] },
|
|
97
|
+
repositoryAttention: { reducer: repositoryAttentionReducer, covers: [] },
|
|
98
|
+
repositoryReadFacts: { reducer: repositoryReadFactsReducer, covers: [] },
|
|
99
|
+
buildStreamSeed: { reducer: buildStreamSeedReducer, covers: [] },
|
|
100
|
+
buildReadFacts: { reducer: buildReadFactsReducer, covers: [] },
|
|
101
|
+
effectiveConfig: { reducer: effectiveConfigReducer, covers: [] },
|
|
102
|
+
buildDelegation: { reducer: buildDelegationReducer, covers: [] },
|
|
103
|
+
harvestDelegation: { reducer: harvestDelegationReducer, covers: [] },
|
|
104
|
+
dispatchFrontend: { reducer: dispatchFrontendReducer, covers: [] },
|
|
64
105
|
executionNoProgress: { reducer: executionNoProgressReducer, covers: [] },
|
|
65
106
|
summaryBoundary: { reducer: summaryBoundaryReducer, covers: ['summaryBoundary'] },
|
|
66
107
|
summaryRequests: { reducer: summaryRequestsReducer, covers: ['pendingSummaryRequests'] },
|
|
@@ -122,9 +163,9 @@ export const REDUCERS: Record<string, RegisteredReducer> = {
|
|
|
122
163
|
phaseFailures: { reducer: phaseFailuresReducer('plan', 1), covers: ['phaseFailures'] },
|
|
123
164
|
openBuildWorkspace: {
|
|
124
165
|
reducer: openBuildWorkspaceReducer,
|
|
125
|
-
covers: ['openBuildWorkspace'
|
|
166
|
+
covers: ['openBuildWorkspace'],
|
|
126
167
|
},
|
|
127
|
-
baseBranch: { reducer: baseBranchReducer, covers: [
|
|
168
|
+
baseBranch: { reducer: baseBranchReducer, covers: [] },
|
|
128
169
|
provisionMarker: { reducer: provisionMarkerReducer, covers: ['openProvisionMarker'] },
|
|
129
170
|
recoveryCheckpoint: { reducer: recoveryCheckpointReducer, covers: ['recoveryCheckpoint'] },
|
|
130
171
|
currentDeferralObservation: {
|
|
@@ -143,9 +184,118 @@ export const REDUCERS: Record<string, RegisteredReducer> = {
|
|
|
143
184
|
pinnedAssets: { reducer: pinnedAssetsReducer, covers: ['findPinnedRevision'] },
|
|
144
185
|
}
|
|
145
186
|
|
|
187
|
+
/** Qualification concerns the existing finished contract, including absence. */
|
|
188
|
+
const valueExclusions: Record<string, string> = {
|
|
189
|
+
dispatchFrontend: 'returns a list of raw repository journal events',
|
|
190
|
+
journalView: 'returns a list of raw repository journal events',
|
|
191
|
+
repositoryStateEvents: 'returns a list of raw repository journal events',
|
|
192
|
+
session: 'consumes operator-session logs rather than build or repository events',
|
|
193
|
+
publicationState: 'finished value contains executable selector functions',
|
|
194
|
+
logIndex: 'finished value contains Maps and Sets',
|
|
195
|
+
hostedPrAttachments: 'finished value is a Map',
|
|
196
|
+
...Object.fromEntries(
|
|
197
|
+
[
|
|
198
|
+
'summaryBoundary',
|
|
199
|
+
'ticketSourceHealth',
|
|
200
|
+
'frozenPrImageHost',
|
|
201
|
+
'publishedBranchHead',
|
|
202
|
+
'verifyDiffBase',
|
|
203
|
+
'recordedBaseSha',
|
|
204
|
+
'baseBranch',
|
|
205
|
+
'provisionMarker',
|
|
206
|
+
'recoveryCheckpoint',
|
|
207
|
+
].map((name) => [name, 'finished contract can return top-level undefined, which is not JSON']),
|
|
208
|
+
),
|
|
209
|
+
}
|
|
210
|
+
const repositoryValues = new Set([
|
|
211
|
+
'repositoryReadFacts',
|
|
212
|
+
'dispatcherRunFacts',
|
|
213
|
+
'repositoryAttention',
|
|
214
|
+
'effectiveConfig',
|
|
215
|
+
'harvestDelegation',
|
|
216
|
+
'harvest',
|
|
217
|
+
'dispatchSettings',
|
|
218
|
+
'dispatchStatus',
|
|
219
|
+
'sandboxStates',
|
|
220
|
+
'openHarvestExecutions',
|
|
221
|
+
'openTick',
|
|
222
|
+
'autoMergeDefault',
|
|
223
|
+
])
|
|
224
|
+
const noArgs = z.object({}).strict()
|
|
225
|
+
const parameterized: Record<string, Pick<ValueCatalogEntry, 'args' | 'create'>> = {
|
|
226
|
+
terminalGuard: {
|
|
227
|
+
args: z
|
|
228
|
+
.object({ phase: phaseSchema, round: z.number().int(), session: z.string().min(1) })
|
|
229
|
+
.strict(),
|
|
230
|
+
create: (args) => terminalGuardReducer(args),
|
|
231
|
+
},
|
|
232
|
+
dispatchStatus: {
|
|
233
|
+
args: z.object({ run: z.string().min(1) }).strict(),
|
|
234
|
+
create: ({ run }) => dispatchStatusReducer(run),
|
|
235
|
+
},
|
|
236
|
+
dispatcherRunFacts: {
|
|
237
|
+
args: z.object({ run: z.string().min(1) }).strict(),
|
|
238
|
+
create: ({ run }) => dispatcherRunFactsReducer(run),
|
|
239
|
+
},
|
|
240
|
+
openTick: {
|
|
241
|
+
args: z.object({ run: z.string().min(1) }).strict(),
|
|
242
|
+
create: ({ run }) => openTickReducer(run),
|
|
243
|
+
},
|
|
244
|
+
dispatchFailureBudget: {
|
|
245
|
+
args: z.object({ infrastructureOwnsWorkspace: z.boolean() }).strict(),
|
|
246
|
+
create: ({ infrastructureOwnsWorkspace }) =>
|
|
247
|
+
dispatchFailureBudgetReducer(infrastructureOwnsWorkspace),
|
|
248
|
+
},
|
|
249
|
+
phaseFailures: {
|
|
250
|
+
args: z.object({ phase: phaseSchema, round: z.number().int().nonnegative() }).strict(),
|
|
251
|
+
create: ({ phase, round }) => phaseFailuresReducer(phase, round),
|
|
252
|
+
},
|
|
253
|
+
}
|
|
254
|
+
export const REDUCERS: Record<string, RegisteredReducer> = Object.fromEntries(
|
|
255
|
+
Object.entries(REGISTERED).map(([name, entry]) => [
|
|
256
|
+
name,
|
|
257
|
+
{
|
|
258
|
+
...entry,
|
|
259
|
+
valueRead: valueExclusions[name]
|
|
260
|
+
? { excluded: valueExclusions[name] }
|
|
261
|
+
: {
|
|
262
|
+
scope: repositoryValues.has(name) ? 'repo' : 'build',
|
|
263
|
+
args: parameterized[name]?.args ?? noArgs,
|
|
264
|
+
validate: (state: unknown) => validateAccumulator(name, state),
|
|
265
|
+
value: encodeReducerValue,
|
|
266
|
+
adapt: (events: Parameters<ValueCatalogEntry['adapt']>[0]) =>
|
|
267
|
+
name === 'buildDigest'
|
|
268
|
+
? events.map((event) => ({
|
|
269
|
+
type: event.type,
|
|
270
|
+
seq: event.seq,
|
|
271
|
+
ts: event.ts,
|
|
272
|
+
...('hostedSeq' in event.payload ? { hostedSeq: event.payload.hostedSeq } : {}),
|
|
273
|
+
...(event.type === 'integration.landed'
|
|
274
|
+
? { auditRequested: !!event.payload.operation }
|
|
275
|
+
: {}),
|
|
276
|
+
...(event.type === 'pr.merged' ? { mergedSha: event.payload.sha } : {}),
|
|
277
|
+
...(event.type === 'node.contribution-recorded'
|
|
278
|
+
? { nodeContribution: event.payload }
|
|
279
|
+
: {}),
|
|
280
|
+
...(event.type === 'build.created' ? { kind: event.payload.kind } : {}),
|
|
281
|
+
...('instance' in event.payload ? { instance: event.payload.instance } : {}),
|
|
282
|
+
}))
|
|
283
|
+
: events,
|
|
284
|
+
create: parameterized[name]?.create ?? (() => entry.reducer),
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
]),
|
|
288
|
+
)
|
|
289
|
+
|
|
146
290
|
/** Event-array functions that are deliberately not reducers, each with the
|
|
147
291
|
* concrete reason. */
|
|
148
292
|
export const EXCLUDED: Record<string, string> = {
|
|
293
|
+
referencedGitTips:
|
|
294
|
+
'Pure one-event Git tip extraction used by the persisted buildReadFacts fold; not a current-state replay.',
|
|
295
|
+
continuePreparation:
|
|
296
|
+
'Async Git/store effects resuming one durable replay transaction; not an event-only projection.',
|
|
297
|
+
shouldPublishTick:
|
|
298
|
+
'Publication decision over a new report and actual start time plus the bounded recorded journal; no event-only reduction can decide whether an unrecorded tick has effects.',
|
|
149
299
|
projectDispatcherLiveness:
|
|
150
300
|
'combines mutable repository lease metadata and an explicit clock with correlated facts; cannot be restored from an event-only snapshot',
|
|
151
301
|
decideNext: 'a decision function over config; returns a Decision, not a state',
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { advanceLanding, type LandingState } from './landing-state'
|
|
2
|
+
import { advanceIntegration, type IntegrationState } from './integration-state'
|
|
3
|
+
import { advanceNodeRestack, type NodeRestackState } from './node-restack-state'
|
|
4
|
+
import { reconcileRewriteHead } from './reconcile-head'
|
|
1
5
|
/**
|
|
2
6
|
* The state reducer (SPEC §15.5, §3.4): state is a reduction of events — any
|
|
3
7
|
* snapshot is a cache, never the source of truth, and resumability falls out.
|
|
@@ -109,6 +113,9 @@ export interface OpenSession {
|
|
|
109
113
|
* the aggregate attempt high-water and cannot identify the current cycle in
|
|
110
114
|
* the window between a verify failure and the next `verify.started`. */
|
|
111
115
|
export interface VerifyResult {
|
|
116
|
+
baseSha?: string
|
|
117
|
+
headSha?: string
|
|
118
|
+
restackId?: string
|
|
112
119
|
step: string
|
|
113
120
|
attempt: number
|
|
114
121
|
outcome: VerifyOutcome
|
|
@@ -132,6 +139,7 @@ export type PrLifecycle = 'open' | 'merged' | 'closed' | 'conflicted'
|
|
|
132
139
|
* non-transactional forge/event boundary: consumers treat the command as
|
|
133
140
|
* settled only when both `enabled` and `commandSeq` match. */
|
|
134
141
|
export interface AutoMergeProjection {
|
|
142
|
+
explicitCommandSeq?: number
|
|
135
143
|
/** Latest human command. False with no commandSeq means the default: off. */
|
|
136
144
|
requested: boolean
|
|
137
145
|
commandSeq?: number
|
|
@@ -148,6 +156,16 @@ export interface AutoMergeProjection {
|
|
|
148
156
|
export type ObservationRecord = EventPayload<'observation.recorded'>
|
|
149
157
|
|
|
150
158
|
export interface BuildState {
|
|
159
|
+
kind?: 'work' | 'node'
|
|
160
|
+
target?: EventPayload<'build.created'>['target']
|
|
161
|
+
baseBranch?: string
|
|
162
|
+
mergedSha?: string
|
|
163
|
+
nodeOpening?: EventPayload<'node.opening'>
|
|
164
|
+
nodeOpened?: EventPayload<'node.opened'>
|
|
165
|
+
nodeRestack?: NodeRestackState
|
|
166
|
+
integration?: IntegrationState
|
|
167
|
+
nodeComparison?: EventPayload<'node.compared'>
|
|
168
|
+
|
|
151
169
|
/**
|
|
152
170
|
* §15.5: 'queued' until `runner.attached`, 'running' after;
|
|
153
171
|
* 'blocked' ≡ open escalation; 'paused' ≡ `build.paused` without a later
|
|
@@ -186,7 +204,9 @@ export interface BuildState {
|
|
|
186
204
|
/** From `finalize.completed` (§15.3) — the kernel opened the PR (D7). */
|
|
187
205
|
pr?: { number: number; url: string; headSha: string }
|
|
188
206
|
prState?: PrLifecycle
|
|
189
|
-
/**
|
|
207
|
+
/** Readiness provenance, landing-bound consent and native application receipts. */
|
|
208
|
+
landing?: LandingState
|
|
209
|
+
/** Historical auto-merge controls retained for replay compatibility. */
|
|
190
210
|
autoMerge: AutoMergeProjection
|
|
191
211
|
/** seq of the latest `finalize.completed`, else 0 — "has finalize run for
|
|
192
212
|
* the CURRENT spec". `prState` cannot answer that: it is the full-log PR
|
|
@@ -308,6 +328,16 @@ export function discardInFlight(state: Pick<BuildState, 'discardRequest'>): bool
|
|
|
308
328
|
* trip through `JSON.stringify` — the foundation for incremental advancement
|
|
309
329
|
* and cached state. */
|
|
310
330
|
export interface BuildAcc {
|
|
331
|
+
kind?: 'work' | 'node'
|
|
332
|
+
target?: EventPayload<'build.created'>['target']
|
|
333
|
+
baseBranch?: string
|
|
334
|
+
mergedSha?: string
|
|
335
|
+
nodeOpening?: EventPayload<'node.opening'>
|
|
336
|
+
nodeOpened?: EventPayload<'node.opened'>
|
|
337
|
+
nodeRestack?: NodeRestackState
|
|
338
|
+
integration?: IntegrationState
|
|
339
|
+
nodeComparison?: EventPayload<'node.compared'>
|
|
340
|
+
|
|
311
341
|
attached: boolean
|
|
312
342
|
pausedFlag: boolean
|
|
313
343
|
terminal?: 'done' | 'aborted'
|
|
@@ -320,6 +350,7 @@ export interface BuildAcc {
|
|
|
320
350
|
reviewRoundCeilings: BuildState['reviewRoundCeilings']
|
|
321
351
|
pr: BuildState['pr']
|
|
322
352
|
prState?: PrLifecycle
|
|
353
|
+
landing?: LandingState
|
|
323
354
|
autoMerge: AutoMergeProjection
|
|
324
355
|
specRev?: number
|
|
325
356
|
restartSince: number
|
|
@@ -350,7 +381,7 @@ export interface BuildAcc {
|
|
|
350
381
|
}
|
|
351
382
|
|
|
352
383
|
/** Bump when `BuildAcc`'s shape or the fold's semantics change. */
|
|
353
|
-
export const BUILD_REDUCER_VERSION =
|
|
384
|
+
export const BUILD_REDUCER_VERSION = 11
|
|
354
385
|
|
|
355
386
|
function initialBuildAcc(): BuildAcc {
|
|
356
387
|
return {
|
|
@@ -361,6 +392,7 @@ function initialBuildAcc(): BuildAcc {
|
|
|
361
392
|
answeredEscalations: [],
|
|
362
393
|
reviewRoundCeilings: {},
|
|
363
394
|
pr: undefined,
|
|
395
|
+
landing: {},
|
|
364
396
|
autoMerge: { requested: false },
|
|
365
397
|
restartSince: 0,
|
|
366
398
|
pinnedAssets: [],
|
|
@@ -451,10 +483,52 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
451
483
|
|
|
452
484
|
let lastEvent = acc.lastEvent
|
|
453
485
|
for (const event of events) {
|
|
486
|
+
acc.landing ??= {}
|
|
487
|
+
advanceLanding(acc.landing, event)
|
|
488
|
+
if (event.type.startsWith('integration.')) {
|
|
489
|
+
acc.integration ??= {}
|
|
490
|
+
advanceIntegration(acc.integration, event)
|
|
491
|
+
}
|
|
492
|
+
if (event.type.startsWith('node.') || (acc.kind === 'node' && event.type === 'target.moved')) {
|
|
493
|
+
acc.nodeRestack ??= { items: [] }
|
|
494
|
+
advanceNodeRestack(acc.nodeRestack, [event])
|
|
495
|
+
}
|
|
454
496
|
switch (event.type) {
|
|
455
497
|
// Facts the projection does not need (workspace liveness is the
|
|
456
498
|
// dispatcher's concern; finalize post-steps are failure-tolerant §5).
|
|
499
|
+
case 'node.parent-accepted':
|
|
500
|
+
if (acc.kind === 'node') {
|
|
501
|
+
acc.target = event.payload.next.target ?? undefined
|
|
502
|
+
acc.baseBranch = event.payload.next.branch
|
|
503
|
+
delete acc.nodeComparison
|
|
504
|
+
if (acc.integration) {
|
|
505
|
+
delete acc.integration.cycle
|
|
506
|
+
delete acc.integration.observation
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
break
|
|
510
|
+
case 'node.opening':
|
|
511
|
+
acc.nodeOpening = event.payload
|
|
512
|
+
break
|
|
513
|
+
case 'node.opened':
|
|
514
|
+
acc.nodeOpened = event.payload
|
|
515
|
+
break
|
|
516
|
+
case 'node.compared':
|
|
517
|
+
acc.nodeComparison = event.payload
|
|
518
|
+
break
|
|
519
|
+
case 'node.rewritten':
|
|
520
|
+
if (acc.nodeComparison)
|
|
521
|
+
acc.nodeComparison = { ...acc.nodeComparison, headSha: event.payload.head }
|
|
522
|
+
if (pr) pr = { ...pr, headSha: event.payload.head }
|
|
523
|
+
break
|
|
524
|
+
case 'pr.opened':
|
|
525
|
+
pr = event.payload.pr
|
|
526
|
+
prState = 'open'
|
|
527
|
+
break
|
|
457
528
|
case 'build.created':
|
|
529
|
+
acc.kind = event.payload.kind
|
|
530
|
+
acc.target = event.payload.target
|
|
531
|
+
acc.baseBranch = event.payload.baseBranch
|
|
458
532
|
pinnedAssets = event.payload.assets ?? []
|
|
459
533
|
break
|
|
460
534
|
case 'workspace.provisioned':
|
|
@@ -556,6 +630,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
556
630
|
discardRequest = { seq: event.seq, actor: event.actor }
|
|
557
631
|
break
|
|
558
632
|
case 'build.auto-merge-requested':
|
|
633
|
+
if (event.payload.integrationConsent === true) autoMerge.explicitCommandSeq = event.seq
|
|
559
634
|
autoMerge.requested = true
|
|
560
635
|
autoMerge.commandSeq = event.seq
|
|
561
636
|
// A fan-out (or seeded) command carries the default fact it answers; a
|
|
@@ -691,6 +766,9 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
691
766
|
const result = normalizeVerifyCompletion(event.payload)
|
|
692
767
|
verify.maxAttemptSeen = Math.max(verify.maxAttemptSeen, result.attempt)
|
|
693
768
|
verify.results.push({
|
|
769
|
+
...(result.baseSha === undefined ? {} : { baseSha: result.baseSha }),
|
|
770
|
+
...(result.headSha === undefined ? {} : { headSha: result.headSha }),
|
|
771
|
+
...(result.restackId === undefined ? {} : { restackId: result.restackId }),
|
|
694
772
|
step: result.step,
|
|
695
773
|
attempt: result.attempt,
|
|
696
774
|
outcome: result.outcome,
|
|
@@ -731,6 +809,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
731
809
|
autoMerge.applied = { enabled: false, commandSeq: event.payload.commandSeq }
|
|
732
810
|
break
|
|
733
811
|
case 'pr.merged':
|
|
812
|
+
acc.mergedSha = event.payload.sha
|
|
734
813
|
prState = 'merged'
|
|
735
814
|
break
|
|
736
815
|
case 'pr.closed':
|
|
@@ -747,7 +826,24 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
747
826
|
seq: event.seq,
|
|
748
827
|
})
|
|
749
828
|
break
|
|
829
|
+
case 'restack.rewritten':
|
|
830
|
+
case 'restack.completed':
|
|
831
|
+
if (event.type === 'restack.completed' && prState === 'conflicted') prState = 'open'
|
|
832
|
+
if (pr !== undefined)
|
|
833
|
+
pr = {
|
|
834
|
+
...pr,
|
|
835
|
+
headSha:
|
|
836
|
+
event.type === 'restack.rewritten'
|
|
837
|
+
? (event.payload.observedHead ?? event.payload.headSha)
|
|
838
|
+
: event.payload.headSha,
|
|
839
|
+
}
|
|
840
|
+
break
|
|
841
|
+
case 'reconcile.rewritten':
|
|
842
|
+
if (pr !== undefined) pr = { ...pr, headSha: reconcileRewriteHead(event.payload) }
|
|
843
|
+
break
|
|
750
844
|
case 'reconcile.completed': {
|
|
845
|
+
if (acc.kind !== 'node' && 'headSha' in event.payload && pr !== undefined)
|
|
846
|
+
pr = { ...pr, headSha: event.payload.headSha }
|
|
751
847
|
// The terminal payload has no attempt, so preserve it from the
|
|
752
848
|
// matching in-flight occurrence before complete() clears that context.
|
|
753
849
|
// An unmatched completion remains a bare context rather than borrowing
|
|
@@ -873,15 +969,33 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
873
969
|
terminal ??
|
|
874
970
|
(pausedFlag
|
|
875
971
|
? 'paused'
|
|
876
|
-
: acc.openEscalations.length > 0
|
|
972
|
+
: acc.openEscalations.length > 0 ||
|
|
973
|
+
(acc.integration?.cycle &&
|
|
974
|
+
acc.nodeComparison?.headSha === acc.integration.cycle.head &&
|
|
975
|
+
acc.nodeComparison?.parentSha === acc.integration.cycle.parent &&
|
|
976
|
+
acc.verify.results.some(
|
|
977
|
+
(result) =>
|
|
978
|
+
result.restackId === acc.integration!.cycle!.id && result.outcome === 'fail',
|
|
979
|
+
))
|
|
877
980
|
? 'blocked'
|
|
878
|
-
:
|
|
879
|
-
? '
|
|
880
|
-
:
|
|
981
|
+
: acc.kind === 'node' && acc.nodeOpened !== undefined
|
|
982
|
+
? 'collecting'
|
|
983
|
+
: attached
|
|
984
|
+
? 'running'
|
|
985
|
+
: 'queued')
|
|
881
986
|
|
|
882
987
|
const active = currentPhase ?? lastCompletedPhase
|
|
883
988
|
|
|
884
989
|
return {
|
|
990
|
+
kind: acc.kind,
|
|
991
|
+
target: acc.target,
|
|
992
|
+
baseBranch: acc.baseBranch,
|
|
993
|
+
nodeOpening: acc.nodeOpening,
|
|
994
|
+
mergedSha: acc.mergedSha,
|
|
995
|
+
nodeOpened: acc.nodeOpened,
|
|
996
|
+
integration: acc.integration,
|
|
997
|
+
nodeComparison: acc.nodeComparison,
|
|
998
|
+
nodeRestack: acc.nodeRestack,
|
|
885
999
|
status,
|
|
886
1000
|
outcome: acc.outcome,
|
|
887
1001
|
phase: active?.phase,
|
|
@@ -893,6 +1007,7 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
893
1007
|
reviewRoundCeilings: acc.reviewRoundCeilings,
|
|
894
1008
|
pr: acc.pr,
|
|
895
1009
|
prState: acc.prState,
|
|
1010
|
+
landing: acc.landing,
|
|
896
1011
|
autoMerge: acc.autoMerge,
|
|
897
1012
|
finalizeCompletedSeq: acc.finalizeCompletedSeq,
|
|
898
1013
|
finalizeSteps: acc.finalizeSteps,
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { RepositoryEvent } from '../events/repository'
|
|
2
|
+
import { defineReducer } from './incremental'
|
|
3
|
+
type Degraded = Extract<RepositoryEvent, { type: 'dispatcher.ticket-source-degraded' }>
|
|
4
|
+
type Failed = Extract<RepositoryEvent, { type: 'dispatcher.tick-failed' }>
|
|
5
|
+
export type PersistenceObservation =
|
|
6
|
+
| {
|
|
7
|
+
type: 'dispatcher.ticket-source-persistent'
|
|
8
|
+
source: string
|
|
9
|
+
cause: string
|
|
10
|
+
message: string
|
|
11
|
+
resetAt?: string
|
|
12
|
+
episodeSeq: number
|
|
13
|
+
observedAt: string
|
|
14
|
+
dependencyLimited: boolean
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
type: 'dispatcher.tick-failure-persistent'
|
|
18
|
+
run: string
|
|
19
|
+
firstFailure: string
|
|
20
|
+
error: string
|
|
21
|
+
episodeSeq: number
|
|
22
|
+
observedAt: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface SourceAttention {
|
|
26
|
+
event: Degraded
|
|
27
|
+
deadline: number
|
|
28
|
+
dependencyLimited: boolean
|
|
29
|
+
requiresRetry: boolean
|
|
30
|
+
retryObserved: boolean
|
|
31
|
+
}
|
|
32
|
+
export interface RepositoryAttentionState {
|
|
33
|
+
sources: [string, SourceAttention][]
|
|
34
|
+
failure?: Failed
|
|
35
|
+
tickStarts: [string, number][]
|
|
36
|
+
}
|
|
37
|
+
/** Incremental journal projection. Episode starts survive run anchors and
|
|
38
|
+
* repeated evidence can strengthen, but never postpone, an existing deadline. */
|
|
39
|
+
export class RepositoryAttention {
|
|
40
|
+
private sources: Map<string, SourceAttention>
|
|
41
|
+
private failure: Failed | undefined
|
|
42
|
+
private tickStarts: Map<string, number>
|
|
43
|
+
constructor(state?: RepositoryAttentionState) {
|
|
44
|
+
this.sources = new Map(state?.sources ?? [])
|
|
45
|
+
this.failure = state?.failure
|
|
46
|
+
this.tickStarts = new Map(state?.tickStarts ?? [])
|
|
47
|
+
}
|
|
48
|
+
snapshot(): RepositoryAttentionState {
|
|
49
|
+
return structuredClone({
|
|
50
|
+
sources: [...this.sources],
|
|
51
|
+
failure: this.failure,
|
|
52
|
+
tickStarts: [...this.tickStarts],
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private sourceDefersTick(now: number): boolean {
|
|
57
|
+
return [...this.sources.values()].some(
|
|
58
|
+
(source) => now < source.deadline || (source.requiresRetry && !source.retryObserved),
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Crossing resetAt alone does not prove persistence: the dispatcher must
|
|
63
|
+
* finish a tick that could actually retry after the provider cooldown. */
|
|
64
|
+
private observeRetry(run: string): void {
|
|
65
|
+
const startedAt = this.tickStarts.get(run)
|
|
66
|
+
this.tickStarts.delete(run)
|
|
67
|
+
if (startedAt === undefined) return
|
|
68
|
+
for (const source of this.sources.values()) {
|
|
69
|
+
if (startedAt >= source.deadline) source.retryObserved = true
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
fold(event: RepositoryEvent): void {
|
|
73
|
+
switch (event.type) {
|
|
74
|
+
case 'dispatcher.ticket-source-degraded': {
|
|
75
|
+
const existing = this.sources.get(event.payload.source)
|
|
76
|
+
const deadline =
|
|
77
|
+
'resetAt' in event.payload
|
|
78
|
+
? Date.parse(event.payload.resetAt)
|
|
79
|
+
: Date.parse(event.ts) + 15 * 60_000
|
|
80
|
+
if (existing) {
|
|
81
|
+
existing.deadline = Math.min(existing.deadline, deadline)
|
|
82
|
+
existing.requiresRetry ||= 'resetAt' in event.payload
|
|
83
|
+
} else
|
|
84
|
+
this.sources.set(event.payload.source, {
|
|
85
|
+
event,
|
|
86
|
+
deadline,
|
|
87
|
+
dependencyLimited: false,
|
|
88
|
+
requiresRetry: 'resetAt' in event.payload,
|
|
89
|
+
retryObserved: false,
|
|
90
|
+
})
|
|
91
|
+
// Cooldown-driven failures are not an independent dispatcher outage.
|
|
92
|
+
if (this.sourceDefersTick(Date.parse(event.ts))) this.failure = undefined
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
case 'dispatcher.ticket-source-dependency-limited': {
|
|
96
|
+
const source = this.sources.get(event.payload.source)
|
|
97
|
+
if (source) source.dependencyLimited = true
|
|
98
|
+
break
|
|
99
|
+
}
|
|
100
|
+
case 'dispatcher.ticket-source-recovered':
|
|
101
|
+
this.sources.delete(event.payload.source)
|
|
102
|
+
break
|
|
103
|
+
case 'dispatcher.run-started':
|
|
104
|
+
this.failure = undefined
|
|
105
|
+
this.tickStarts.clear()
|
|
106
|
+
break
|
|
107
|
+
case 'dispatcher.run-stopped':
|
|
108
|
+
this.tickStarts.delete(event.payload.run)
|
|
109
|
+
if (this.failure?.payload.run === event.payload.run) this.failure = undefined
|
|
110
|
+
break
|
|
111
|
+
case 'dispatcher.tick-started':
|
|
112
|
+
this.tickStarts.set(event.payload.run, Date.parse(event.payload.startedAt ?? event.ts))
|
|
113
|
+
break
|
|
114
|
+
case 'dispatcher.tick-completed':
|
|
115
|
+
this.observeRetry(event.payload.run)
|
|
116
|
+
if (this.failure?.payload.run === event.payload.run) this.failure = undefined
|
|
117
|
+
break
|
|
118
|
+
case 'dispatcher.tick-failed':
|
|
119
|
+
this.observeRetry(event.payload.run)
|
|
120
|
+
if (this.sourceDefersTick(Date.parse(event.ts))) this.failure = undefined
|
|
121
|
+
else if (this.failure?.payload.run !== event.payload.run) this.failure = event
|
|
122
|
+
break
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
pending(now: Date): { identity: string; observation: PersistenceObservation }[] {
|
|
126
|
+
const results: { identity: string; observation: PersistenceObservation }[] = []
|
|
127
|
+
for (const {
|
|
128
|
+
event,
|
|
129
|
+
deadline,
|
|
130
|
+
dependencyLimited,
|
|
131
|
+
requiresRetry,
|
|
132
|
+
retryObserved,
|
|
133
|
+
} of this.sources.values()) {
|
|
134
|
+
if (now.getTime() < deadline || (requiresRetry && !retryObserved)) continue
|
|
135
|
+
results.push({
|
|
136
|
+
identity: `source:${event.seq}`,
|
|
137
|
+
observation: {
|
|
138
|
+
type: 'dispatcher.ticket-source-persistent',
|
|
139
|
+
...event.payload,
|
|
140
|
+
episodeSeq: event.seq,
|
|
141
|
+
observedAt: now.toISOString(),
|
|
142
|
+
dependencyLimited,
|
|
143
|
+
},
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
const event = this.failure
|
|
147
|
+
if (
|
|
148
|
+
event &&
|
|
149
|
+
!this.sourceDefersTick(now.getTime()) &&
|
|
150
|
+
now.getTime() >= Date.parse(event.ts) + 5 * 60_000
|
|
151
|
+
)
|
|
152
|
+
results.push({
|
|
153
|
+
identity: `tick:${event.seq}`,
|
|
154
|
+
observation: {
|
|
155
|
+
type: 'dispatcher.tick-failure-persistent',
|
|
156
|
+
...event.payload,
|
|
157
|
+
firstFailure: event.ts,
|
|
158
|
+
episodeSeq: event.seq,
|
|
159
|
+
observedAt: now.toISOString(),
|
|
160
|
+
},
|
|
161
|
+
})
|
|
162
|
+
return results
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const repositoryAttentionReducer = defineReducer<
|
|
167
|
+
RepositoryAttentionState,
|
|
168
|
+
RepositoryEvent,
|
|
169
|
+
RepositoryAttentionState
|
|
170
|
+
>({
|
|
171
|
+
version: 1,
|
|
172
|
+
initial: () => ({ sources: [], tickStarts: [] }),
|
|
173
|
+
fold(acc, events) {
|
|
174
|
+
const attention = new RepositoryAttention(acc)
|
|
175
|
+
for (const event of events) attention.fold(event)
|
|
176
|
+
Object.assign(acc, attention.snapshot())
|
|
177
|
+
},
|
|
178
|
+
finish: (acc) => structuredClone(acc),
|
|
179
|
+
})
|