@defrex/autobuild 1.10.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 +745 -69
- package/bin/ab-dispatch-generation.ts +3 -1
- package/docs/accounts.md +2 -1
- package/docs/answering-blocked-builds.md +20 -0
- package/docs/architecture.md +165 -29
- package/docs/build-store.md +10 -7
- package/docs/cli.md +33 -1
- package/docs/configuration-overview.md +4 -1
- package/docs/configuration.md +381 -29
- package/docs/dispatcher.md +64 -4
- package/docs/forges.md +7 -0
- package/docs/integration-tree.md +2 -2
- package/docs/operating.md +4 -2
- package/docs/operator-api.md +134 -6
- package/docs/operator-surfaces.md +85 -0
- package/docs/optimization-nodes.md +69 -11
- package/docs/plugin-authoring.md +37 -1
- package/docs/remote-store-protocol.md +94 -13
- package/docs/remote-ticket-protocol.md +40 -0
- package/docs/restacking.md +20 -4
- package/docs/setup.md +14 -2
- package/docs/ticket-dependencies.md +10 -3
- package/docs/ticket-sources.md +24 -2
- package/docs/tickets.md +7 -1
- package/docs/troubleshooting.md +8 -0
- package/docs/verification.md +4 -3
- package/docs/workspaces.md +3 -0
- package/package.json +9 -5
- package/packages/core/src/cli/accounts.ts +7 -2
- package/packages/core/src/cli/attention.ts +3 -1
- package/packages/core/src/cli/binary-direct.ts +2 -0
- package/packages/core/src/cli/binary-lifecycle.ts +2 -1
- package/packages/core/src/cli/build-control.ts +79 -1
- package/packages/core/src/cli/context.ts +4 -0
- package/packages/core/src/cli/dashboard/facts.ts +49 -53
- package/packages/core/src/cli/dashboard/header.ts +111 -0
- package/packages/core/src/cli/dashboard/model.ts +31 -39
- package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
- package/packages/core/src/cli/dashboard/poll.ts +179 -76
- package/packages/core/src/cli/dashboard/render.ts +159 -230
- package/packages/core/src/cli/dashboard/row-text.ts +538 -0
- package/packages/core/src/cli/dashboard/timeline.ts +288 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
- package/packages/core/src/cli/dispatch-args.ts +44 -1
- package/packages/core/src/cli/dispatch-frontend.ts +40 -40
- package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
- package/packages/core/src/cli/dispatch-launcher.ts +20 -7
- package/packages/core/src/cli/dispatch-web.ts +155 -0
- package/packages/core/src/cli/dispatch.ts +202 -38
- package/packages/core/src/cli/help.ts +87 -3
- package/packages/core/src/cli/init-validation.ts +3 -3
- package/packages/core/src/cli/main.ts +70 -6
- package/packages/core/src/cli/mcp.ts +35 -3
- package/packages/core/src/cli/objective.ts +1 -1
- package/packages/core/src/cli/operator-preference.ts +57 -0
- package/packages/core/src/cli/repo-lease.ts +2 -0
- package/packages/core/src/cli/repo-state.ts +56 -6
- package/packages/core/src/cli/repository-status.ts +105 -49
- package/packages/core/src/cli/status.ts +82 -1
- package/packages/core/src/cli/terminal-restore.ts +32 -7
- package/packages/core/src/cli/ticket.ts +98 -36
- package/packages/core/src/cli/wait.ts +14 -6
- package/packages/core/src/cli/watch.ts +20 -4
- package/packages/core/src/cli/web.ts +139 -0
- package/packages/core/src/config/live.ts +99 -14
- package/packages/core/src/config/load.ts +61 -20
- package/packages/core/src/config/local.ts +212 -0
- package/packages/core/src/config/pipeline-source.ts +2 -0
- package/packages/core/src/config/reference.ts +18 -0
- package/packages/core/src/config/schema.ts +45 -10
- package/packages/core/src/events/catalog.ts +4 -0
- package/packages/core/src/events/payloads.ts +97 -0
- package/packages/core/src/events/policy.ts +10 -0
- package/packages/core/src/events/repository.ts +46 -3
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +381 -30
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/46196d8f0076496a.json +97 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
- package/packages/core/src/kernel/build-roster.ts +230 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
- package/packages/core/src/kernel/dispatch-status.ts +139 -0
- package/packages/core/src/kernel/engine.ts +43 -5
- package/packages/core/src/kernel/execution-intervals.ts +61 -0
- package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
- package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
- package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
- package/packages/core/src/kernel/log-index.ts +19 -0
- package/packages/core/src/kernel/optimization-admission.ts +244 -3
- package/packages/core/src/kernel/optimization.ts +183 -4
- package/packages/core/src/kernel/phase-failures.ts +121 -0
- package/packages/core/src/kernel/published-branch-head.ts +60 -0
- package/packages/core/src/kernel/read-facts.ts +15 -13
- package/packages/core/src/kernel/reducer-registry.ts +27 -8
- package/packages/core/src/kernel/reducer-revisions.ts +27 -0
- package/packages/core/src/kernel/reducer.ts +63 -4
- package/packages/core/src/kernel/rollup.ts +61 -0
- package/packages/core/src/kernel/setup-streak.ts +38 -0
- package/packages/core/src/kernel/step-durations.ts +257 -0
- package/packages/core/src/kernel/target-observation.ts +6 -1
- package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
- package/packages/core/src/kernel/verify-diff-base.ts +5 -0
- package/packages/core/src/kernel/verify-stages.ts +13 -3
- package/packages/core/src/ontology.ts +5 -0
- package/packages/core/src/operator/agent-context-serve.ts +631 -0
- package/packages/core/src/operator/annotations.ts +75 -5
- package/packages/core/src/operator/attention.ts +470 -0
- package/packages/core/src/operator/canonical-skills.ts +35 -0
- package/packages/core/src/operator/cli-equivalents.ts +270 -0
- package/packages/core/src/operator/context-prompts.ts +61 -0
- package/packages/core/src/operator/index.ts +49 -1
- package/packages/core/src/operator/landings.ts +28 -19
- package/packages/core/src/operator/optimization.ts +7 -0
- package/packages/core/src/operator/protocol.ts +3 -0
- package/packages/core/src/operator/query.ts +129 -74
- package/packages/core/src/operator/read-view.ts +5 -2
- package/packages/core/src/operator/registry.ts +406 -46
- package/packages/core/src/operator/requests.ts +20 -18
- package/packages/core/src/operator/sandbox-host.ts +107 -11
- package/packages/core/src/operator/sandbox-resolver.ts +253 -0
- package/packages/core/src/operator/sandbox.ts +778 -82
- package/packages/core/src/operator/ticket-asset-list.ts +77 -0
- package/packages/core/src/operator/ticket-assets.ts +167 -0
- package/packages/core/src/operator/tickets.ts +33 -2
- package/packages/core/src/plugin-sdk/index.ts +22 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/ports/forge/fake.ts +92 -1
- package/packages/core/src/ports/forge/git-blob.ts +15 -0
- package/packages/core/src/ports/forge/github.ts +82 -0
- package/packages/core/src/ports/forge/local-git.ts +61 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
- package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
- package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
- package/packages/core/src/ports/tickets/contract.ts +71 -0
- package/packages/core/src/ports/tickets/fake.ts +11 -0
- package/packages/core/src/ports/tickets/file.ts +18 -0
- package/packages/core/src/ports/tickets/github-fake.ts +136 -4
- package/packages/core/src/ports/tickets/github.ts +387 -30
- package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
- package/packages/core/src/ports/tickets/linear.ts +130 -0
- package/packages/core/src/ports/tickets/priority.ts +9 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
- package/packages/core/src/ports/tickets/remote.ts +70 -6
- package/packages/core/src/ports/tickets/search.ts +139 -0
- package/packages/core/src/ports/types.ts +104 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
- package/packages/core/src/ports/workspace/create.ts +15 -1
- package/packages/core/src/ports/workspace/fake.ts +340 -12
- package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
- package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
- package/packages/core/src/ports/workspace/process-group.ts +48 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
- package/packages/core/src/processes/agent-context-assemble.ts +576 -0
- package/packages/core/src/processes/agent-context.ts +469 -0
- package/packages/core/src/processes/build-runner.ts +387 -236
- package/packages/core/src/processes/dispatcher.ts +211 -55
- package/packages/core/src/processes/execution-no-progress.ts +4 -0
- package/packages/core/src/processes/optimization-activity.ts +120 -0
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/repo-view.ts +78 -2
- package/packages/core/src/processes/sandbox-state.ts +53 -6
- package/packages/core/src/processes/tick-publication.ts +2 -0
- package/packages/core/src/processes/workspace-preparation.ts +76 -0
- package/packages/core/src/scenarios/harness.ts +0 -5
- package/packages/core/src/store/account-redaction.ts +1 -0
- package/packages/core/src/store/adapter.ts +52 -1
- package/packages/core/src/store/agent-context.ts +432 -0
- package/packages/core/src/store/build-feed.ts +291 -0
- package/packages/core/src/store/build-scope.ts +19 -1
- package/packages/core/src/store/contract.ts +911 -14
- package/packages/core/src/store/digest.ts +19 -6
- package/packages/core/src/store/histogram.ts +113 -0
- package/packages/core/src/store/local/schema.ts +62 -0
- package/packages/core/src/store/local/store.ts +628 -22
- package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
- package/packages/core/src/store/memory.ts +461 -69
- package/packages/core/src/store/open-builds.ts +19 -0
- package/packages/core/src/store/phase-session.ts +32 -4
- package/packages/core/src/store/reduced-reads.ts +14 -4
- package/packages/core/src/store/reducer-value-shapes.json +7027 -5751
- package/packages/core/src/store/reducer-values.ts +6 -1
- package/packages/core/src/store/remote/client.ts +208 -2
- package/packages/core/src/store/remote/compatibility.ts +1 -1
- package/packages/core/src/store/remote/index.ts +33 -0
- package/packages/core/src/store/remote/protocol.ts +69 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -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 +20 -16
- package/packages/core/src/store/retention.ts +23 -1
- package/packages/core/src/store/rollups.ts +337 -0
- package/packages/core/src/store/session-handle.ts +20 -2
- package/packages/core/src/store/snapshots.ts +10 -0
- package/packages/core/src/store/types.ts +108 -9
- package/packages/core/src/testing/dispatch-journals.ts +117 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
- package/packages/core/src/testing/git-config-isolation.ts +7 -5
- package/packages/core/src/testing/index.ts +27 -0
- package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
- package/packages/core/src/web/analytics-source.ts +303 -0
- package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
- package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
- package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
- package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
- package/packages/core/src/web/assets/app.css +1 -0
- package/packages/core/src/web/assets/app.js +9 -0
- package/packages/core/src/web/assets/manifest.json +31 -0
- package/packages/core/src/web/assets/theme.js +1 -0
- package/packages/core/src/web/bounded.ts +31 -0
- package/packages/core/src/web/http.ts +315 -0
- package/packages/core/src/web/hub.ts +160 -0
- package/packages/core/src/web/options.ts +38 -0
- package/packages/core/src/web/overview-source.ts +322 -0
- package/packages/core/src/web/page.ts +56 -0
- package/packages/core/src/web/protocol.ts +151 -0
- package/packages/core/src/web/read-only.ts +23 -0
- package/packages/core/src/web/repository-source.ts +39 -0
- package/packages/core/src/web/server.ts +97 -0
- package/skills/code-review/SKILL.md +10 -2
- package/skills/guide/SKILL.md +376 -54
- package/skills/guide/references/accounts.md +2 -1
- package/skills/guide/references/integration-tree.md +2 -2
- package/skills/guide/references/operator-api.md +134 -6
- package/skills/guide/references/optimization-nodes.md +69 -11
- package/skills/guide/references/plugin-authoring.md +37 -1
- package/skills/guide/references/remote-store-protocol.md +94 -13
- package/skills/guide/references/remote-ticket-protocol.md +40 -0
- package/skills/guide/references/restacking.md +20 -4
- package/skills/guide/references/setup.md +14 -2
- package/skills/guide/references/ticket-dependencies.md +10 -3
- package/skills/implement/SKILL.md +23 -4
- package/skills/operate/SKILL.md +134 -32
- package/skills/plan/SKILL.md +10 -4
- package/skills/plan-review/SKILL.md +9 -2
- package/skills/spec/SKILL.md +34 -8
- package/skills/tickets/SKILL.md +51 -5
- package/templates/hosted-service/package.json +2 -2
|
@@ -26,7 +26,17 @@ import type { TicketRef } from '../ontology'
|
|
|
26
26
|
import { defineReducer } from './incremental'
|
|
27
27
|
export { optimizationCompletionBlocker } from './integration-state'
|
|
28
28
|
import type { BuildState } from './reducer'
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
activeHours,
|
|
31
|
+
clipSpans,
|
|
32
|
+
clockView,
|
|
33
|
+
direction,
|
|
34
|
+
optimizationAdmission,
|
|
35
|
+
unionLength,
|
|
36
|
+
unionSpans,
|
|
37
|
+
type ClockSpan,
|
|
38
|
+
type OptimizationClockView,
|
|
39
|
+
} from './optimization-admission'
|
|
30
40
|
|
|
31
41
|
// The admission selectors live in a module with no reducer machinery, so the
|
|
32
42
|
// browser dashboards can import them through dispatch capacity.
|
|
@@ -78,13 +88,48 @@ export interface OptimizationValue {
|
|
|
78
88
|
head: string
|
|
79
89
|
}
|
|
80
90
|
|
|
91
|
+
/**
|
|
92
|
+
* The node's active-hours clock (SPEC §13.1.1): the exact union of the
|
|
93
|
+
* execution intervals the budget counts, the node's own proposer and
|
|
94
|
+
* measurement runs and its attempts' runs. The node's own facts fold from its
|
|
95
|
+
* log; attempt facts arrive in dispatcher batches. Activity before
|
|
96
|
+
* `watermark` is compacted into `activeMs`, so the clock stays bounded. The
|
|
97
|
+
* watermark never passes an open interval's start, so a delayed end still
|
|
98
|
+
* reconciles exactly against the spans after it.
|
|
99
|
+
*/
|
|
100
|
+
export interface OptimizationClock {
|
|
101
|
+
/** The union of active time before `watermark`, in milliseconds. */
|
|
102
|
+
activeMs: number
|
|
103
|
+
/** Every later fact is at or after it; absent before the first batch. */
|
|
104
|
+
watermark?: string
|
|
105
|
+
/** When the node recorded its latest activity batch, in store time. Every
|
|
106
|
+
* attempt fact stamped before it was visible to the next pass, so that
|
|
107
|
+
* pass compacts at most through it. */
|
|
108
|
+
recordedAt?: string
|
|
109
|
+
/** Closed active spans at or after `watermark`: sorted and disjoint. */
|
|
110
|
+
spans: ClockSpan[]
|
|
111
|
+
/** Running executions: `''` is the node itself, any other key an attempt
|
|
112
|
+
* build. At most the attempts' concurrency plus one. */
|
|
113
|
+
open: Record<string, { instance: string; start: string }>
|
|
114
|
+
/** Tracked attempt builds: the execution facts accounted of each. */
|
|
115
|
+
builds: Record<string, number>
|
|
116
|
+
/** When the node stopped: every active interval ends there. */
|
|
117
|
+
stoppedAt?: string
|
|
118
|
+
/** The stop's settlement accounted every pre-stop fact; the clock never
|
|
119
|
+
* changes again. */
|
|
120
|
+
settled?: true
|
|
121
|
+
}
|
|
122
|
+
|
|
81
123
|
/** The bounded per-node digest. Plain JSON; its size never grows with the
|
|
82
124
|
* number of settled attempts. */
|
|
83
125
|
export interface OptimizationState {
|
|
84
126
|
/** The latest `optimization.objective-accepted`. */
|
|
85
127
|
accepted: EventPayload<'optimization.objective-accepted'> & { acceptedAt: string }
|
|
86
|
-
/** When the objective was first accepted
|
|
128
|
+
/** When the objective was first accepted. The hours budget counts active
|
|
129
|
+
* hours on `clock`, not time since opening. */
|
|
87
130
|
openedAt: string
|
|
131
|
+
/** The active-hours clock the hours budget reads. */
|
|
132
|
+
clock: OptimizationClock
|
|
88
133
|
/** The accepted objective with every later quick revision applied. */
|
|
89
134
|
objective: Objective
|
|
90
135
|
/** The latest objective revision, across acceptances and quick revisions. */
|
|
@@ -160,7 +205,17 @@ function better(objective: Objective, a: number | undefined, b: number): number
|
|
|
160
205
|
return direction(objective) === 'minimize' ? Math.min(a, b) : Math.max(a, b)
|
|
161
206
|
}
|
|
162
207
|
|
|
163
|
-
/** Whether `event` is a
|
|
208
|
+
/** Whether `event` is a fact the optimization fold reads: an optimization
|
|
209
|
+
* fact, or one of the node's own execution facts its clock counts. */
|
|
210
|
+
export function foldsIntoOptimization(event: { type: string }): boolean {
|
|
211
|
+
return (
|
|
212
|
+
isOptimizationEvent(event) ||
|
|
213
|
+
event.type === 'execution.started' ||
|
|
214
|
+
event.type === 'execution.ended'
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Whether `event` is a node-log optimization fact. */
|
|
164
219
|
export function isOptimizationEvent(event: { type: string }): boolean {
|
|
165
220
|
return (
|
|
166
221
|
event.type.startsWith('optimization.') ||
|
|
@@ -185,6 +240,87 @@ function startRuler(state: OptimizationState, revision: number) {
|
|
|
185
240
|
}
|
|
186
241
|
}
|
|
187
242
|
|
|
243
|
+
/** The node runs optimization work: an undeposited proposal, a starting
|
|
244
|
+
* measurement due, or a landed panel head awaiting its progress panel. */
|
|
245
|
+
function nodeWorkDue(state: OptimizationState): boolean {
|
|
246
|
+
return (
|
|
247
|
+
(state.proposal !== undefined && state.proposal.deposited === undefined) ||
|
|
248
|
+
state.starting === undefined ||
|
|
249
|
+
(state.progressQueue?.length ?? 0) > 0
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** A fact's time, never below the clock's watermark (a store-skew guard). */
|
|
254
|
+
function clockTime(clock: OptimizationClock, at: string): string {
|
|
255
|
+
return clock.watermark !== undefined && at < clock.watermark ? clock.watermark : at
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function addSpan(clock: OptimizationClock, start: string, end: string) {
|
|
259
|
+
if (start < end) clock.spans = unionSpans([...clock.spans, [start, end]])
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Start an interval under `key`; a start without the previous one's end
|
|
263
|
+
* closes it there. */
|
|
264
|
+
function openInterval(clock: OptimizationClock, key: string, instance: string, at: string) {
|
|
265
|
+
const previous = clock.open[key]
|
|
266
|
+
if (previous !== undefined) addSpan(clock, previous.start, at)
|
|
267
|
+
clock.open[key] = { instance, start: at }
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function closeInterval(clock: OptimizationClock, key: string, instance: string, at: string) {
|
|
271
|
+
const open = clock.open[key]
|
|
272
|
+
if (open === undefined || open.instance !== instance) return
|
|
273
|
+
addSpan(clock, open.start, at)
|
|
274
|
+
delete clock.open[key]
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Fold every closed span before `through` into `activeMs`, never past the
|
|
278
|
+
* start of an open interval: its end may arrive in a later batch with a time
|
|
279
|
+
* before facts this one carried, and must still union with the spans it
|
|
280
|
+
* overlaps. */
|
|
281
|
+
function compactClock(clock: OptimizationClock, through: string) {
|
|
282
|
+
let watermark = through
|
|
283
|
+
for (const { start } of Object.values(clock.open)) if (start < watermark) watermark = start
|
|
284
|
+
if (clock.watermark !== undefined && watermark <= clock.watermark) return
|
|
285
|
+
clock.activeMs += unionLength(clipSpans(clock.spans, undefined, watermark))
|
|
286
|
+
clock.spans = clipSpans(clock.spans, watermark)
|
|
287
|
+
clock.watermark = watermark
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function recordActivity(
|
|
291
|
+
clock: OptimizationClock,
|
|
292
|
+
batch: EventPayload<'optimization.activity-recorded'>,
|
|
293
|
+
recordedAt: string,
|
|
294
|
+
) {
|
|
295
|
+
if (clock.settled) return
|
|
296
|
+
clock.recordedAt = recordedAt
|
|
297
|
+
// After a stop a batch adds only pre-stop facts; a settlement chunked over
|
|
298
|
+
// several events freezes the clock with its last, `settles`, chunk.
|
|
299
|
+
const stop = clock.stoppedAt
|
|
300
|
+
for (const fact of batch.facts) {
|
|
301
|
+
if (stop !== undefined && fact.at > stop) continue
|
|
302
|
+
if (fact.n <= (clock.builds[fact.build] ?? 0)) continue
|
|
303
|
+
const at = clockTime(clock, fact.at)
|
|
304
|
+
if (fact.kind === 'started') openInterval(clock, fact.build, fact.instance, at)
|
|
305
|
+
else closeInterval(clock, fact.build, fact.instance, at)
|
|
306
|
+
}
|
|
307
|
+
for (const [build, count] of Object.entries(batch.accounted))
|
|
308
|
+
clock.builds[build] = Math.max(clock.builds[build] ?? 0, count)
|
|
309
|
+
for (const build of batch.released ?? [])
|
|
310
|
+
if (clock.open[build] === undefined) delete clock.builds[build]
|
|
311
|
+
if (stop === undefined || !batch.settles) {
|
|
312
|
+
compactClock(clock, stop !== undefined && stop < batch.watermark ? stop : batch.watermark)
|
|
313
|
+
return
|
|
314
|
+
}
|
|
315
|
+
for (const interval of Object.values(clock.open)) addSpan(clock, interval.start, stop)
|
|
316
|
+
clock.open = {}
|
|
317
|
+
compactClock(clock, stop)
|
|
318
|
+
clock.spans = []
|
|
319
|
+
clock.builds = {}
|
|
320
|
+
delete clock.recordedAt
|
|
321
|
+
clock.settled = true
|
|
322
|
+
}
|
|
323
|
+
|
|
188
324
|
/** Fold node-log events into the digest. Returns the advanced value; the
|
|
189
325
|
* previous one is mutated in place when it exists. */
|
|
190
326
|
export function advanceOptimization(acc: OptimizationAcc, events: readonly AbEvent[]) {
|
|
@@ -196,6 +332,7 @@ export function advanceOptimization(acc: OptimizationAcc, events: readonly AbEve
|
|
|
196
332
|
state = {
|
|
197
333
|
accepted,
|
|
198
334
|
openedAt: event.ts,
|
|
335
|
+
clock: { activeMs: 0, spans: [], open: {}, builds: {} },
|
|
199
336
|
objective: structuredClone(event.payload.objective),
|
|
200
337
|
revision: event.payload.revision,
|
|
201
338
|
revisedFields: [],
|
|
@@ -219,7 +356,26 @@ export function advanceOptimization(acc: OptimizationAcc, events: readonly AbEve
|
|
|
219
356
|
continue
|
|
220
357
|
}
|
|
221
358
|
if (state === undefined) continue
|
|
359
|
+
const clock = state.clock
|
|
222
360
|
switch (event.type) {
|
|
361
|
+
case 'execution.started': {
|
|
362
|
+
// The node's own runs count only while they serve the objective.
|
|
363
|
+
if (clock.stoppedAt !== undefined) break
|
|
364
|
+
const at = clockTime(clock, event.ts)
|
|
365
|
+
if (nodeWorkDue(state)) openInterval(clock, '', event.payload.instance, at)
|
|
366
|
+
else if (clock.open[''] !== undefined) {
|
|
367
|
+
addSpan(clock, clock.open['']!.start, at)
|
|
368
|
+
delete clock.open['']
|
|
369
|
+
}
|
|
370
|
+
break
|
|
371
|
+
}
|
|
372
|
+
case 'execution.ended':
|
|
373
|
+
if (clock.stoppedAt !== undefined) break
|
|
374
|
+
closeInterval(clock, '', event.payload.instance, clockTime(clock, event.ts))
|
|
375
|
+
break
|
|
376
|
+
case 'optimization.activity-recorded':
|
|
377
|
+
recordActivity(clock, event.payload, event.ts)
|
|
378
|
+
break
|
|
223
379
|
case 'optimization.objective-revised': {
|
|
224
380
|
state.objective = applyObjectiveRevisions(state.objective, [event.payload.changes])
|
|
225
381
|
state.revision = event.payload.revision
|
|
@@ -285,6 +441,17 @@ export function advanceOptimization(acc: OptimizationAcc, events: readonly AbEve
|
|
|
285
441
|
break
|
|
286
442
|
case 'attempt.settled': {
|
|
287
443
|
const { attempt, outcome, measurement } = event.payload
|
|
444
|
+
// A build the dispatcher has not accounted is still read once it
|
|
445
|
+
// settles. Only a started clock tracks: the dispatcher starts every
|
|
446
|
+
// node's clock on its first pass, before the node can file an
|
|
447
|
+
// attempt, so only a legacy node's history is not charged.
|
|
448
|
+
if (
|
|
449
|
+
!clock.settled &&
|
|
450
|
+
clock.watermark !== undefined &&
|
|
451
|
+
attempt.build !== undefined &&
|
|
452
|
+
clock.builds[attempt.build] === undefined
|
|
453
|
+
)
|
|
454
|
+
clock.builds[attempt.build] = 0
|
|
288
455
|
const wasInFlight = state.inFlight.some((entry) => entry.proposal === attempt.proposal)
|
|
289
456
|
state.inFlight = state.inFlight.filter((entry) => entry.proposal !== attempt.proposal)
|
|
290
457
|
if (outcome === 'merged-unmeasured') {
|
|
@@ -340,6 +507,14 @@ export function advanceOptimization(acc: OptimizationAcc, events: readonly AbEve
|
|
|
340
507
|
}
|
|
341
508
|
case 'optimization.stopped':
|
|
342
509
|
state.stopped ??= { ...event.payload, at: event.ts }
|
|
510
|
+
if (clock.stoppedAt === undefined) {
|
|
511
|
+
clock.stoppedAt = event.ts
|
|
512
|
+
const node = clock.open['']
|
|
513
|
+
if (node !== undefined) {
|
|
514
|
+
addSpan(clock, node.start, event.ts)
|
|
515
|
+
delete clock.open['']
|
|
516
|
+
}
|
|
517
|
+
}
|
|
343
518
|
break
|
|
344
519
|
case 'attempt.ticket-rejected':
|
|
345
520
|
state.rejections = state.rejections.filter(
|
|
@@ -705,6 +880,8 @@ export interface OptimizationSignal {
|
|
|
705
880
|
emptyProposals: number
|
|
706
881
|
openedAt: string
|
|
707
882
|
maxHours?: number
|
|
883
|
+
/** The active-hours clock's view; absent only from an older service. */
|
|
884
|
+
clock?: OptimizationClockView
|
|
708
885
|
proposal?: { request: string; deposited?: { ids: string[]; at: string } }
|
|
709
886
|
/** seq of the latest fact that can clear a proposer blocker. */
|
|
710
887
|
wakeSeq?: number
|
|
@@ -728,6 +905,7 @@ export function optimizationSignal(
|
|
|
728
905
|
emptyProposals: state.emptyProposals,
|
|
729
906
|
openedAt: state.openedAt,
|
|
730
907
|
...(maxHours !== undefined ? { maxHours } : {}),
|
|
908
|
+
clock: clockView(state.clock),
|
|
731
909
|
...(proposal !== undefined
|
|
732
910
|
? {
|
|
733
911
|
proposal: {
|
|
@@ -766,7 +944,8 @@ export function signalDue(
|
|
|
766
944
|
signal.attemptRoom !== 0 &&
|
|
767
945
|
signal.emptyProposals < 2 &&
|
|
768
946
|
(signal.maxHours === undefined ||
|
|
769
|
-
|
|
947
|
+
signal.clock === undefined ||
|
|
948
|
+
activeHours(signal.clock, now) < signal.maxHours) &&
|
|
770
949
|
!compatibilityDeferred
|
|
771
950
|
)
|
|
772
951
|
return 'request'
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The phase.failed tally that guards phase retries. Pure so the reducer
|
|
3
|
+
* registry can register it without importing process code.
|
|
4
|
+
*/
|
|
5
|
+
import type { AbEvent } from '../events/catalog'
|
|
6
|
+
import type { EventPayload } from '../events/payloads'
|
|
7
|
+
import type { Phase } from '../ontology'
|
|
8
|
+
import {
|
|
9
|
+
resetsPhaseFailureBudget,
|
|
10
|
+
type PhaseFailureResetEscalation,
|
|
11
|
+
} from '../processes/phase-failure-budget'
|
|
12
|
+
import { defineReducer } from './incremental'
|
|
13
|
+
import { verifyMemberKey } from './verify-stage-state'
|
|
14
|
+
|
|
15
|
+
type ProviderAttempt = NonNullable<EventPayload<'phase.failed'>['providerAttempts']>[number]
|
|
16
|
+
|
|
17
|
+
export interface PhaseFailureTally {
|
|
18
|
+
count: number
|
|
19
|
+
lastError?: string
|
|
20
|
+
lastWillRetry?: boolean
|
|
21
|
+
lastProviderAttempts?: readonly ProviderAttempt[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* phase.failed tally for one phase+round — D5's retry-guard input. A factory
|
|
26
|
+
* because phase and round are parameters of the projection.
|
|
27
|
+
*
|
|
28
|
+
* An answered escalation re-arms this budget only when its semantic class
|
|
29
|
+
* acknowledges phase-runner failures (§15.6-B). Runner-failure causes reset
|
|
30
|
+
* their matching round, the phase-level verify cause resets all rounds, and
|
|
31
|
+
* unrelated policy causes reset nothing. Cause-less historical and
|
|
32
|
+
* non-policy raises retain the legacy round-shaped behavior. Failures after
|
|
33
|
+
* an applicable answer count again, so a still-failing phase re-escalates on
|
|
34
|
+
* new evidence instead of deadlocking before its recovery session starts.
|
|
35
|
+
*/
|
|
36
|
+
export function phaseFailuresReducer(phase: Phase, round: number) {
|
|
37
|
+
return defineReducer<
|
|
38
|
+
{
|
|
39
|
+
/** id → the raise's reset semantics — answers are matched by id (§15.3). */
|
|
40
|
+
raised: Record<string, PhaseFailureResetEscalation & { session?: string }>
|
|
41
|
+
owners: Record<string, string>
|
|
42
|
+
cancelled: Record<string, boolean>
|
|
43
|
+
count: number
|
|
44
|
+
lastError?: string
|
|
45
|
+
lastWillRetry?: boolean
|
|
46
|
+
lastProviderAttempts?: readonly ProviderAttempt[]
|
|
47
|
+
},
|
|
48
|
+
AbEvent,
|
|
49
|
+
PhaseFailureTally
|
|
50
|
+
>({
|
|
51
|
+
identity: 'phaseFailures',
|
|
52
|
+
initial: () => ({ raised: {}, owners: {}, cancelled: {}, count: 0 }),
|
|
53
|
+
fold(acc, events) {
|
|
54
|
+
for (const event of events) {
|
|
55
|
+
switch (event.type) {
|
|
56
|
+
case 'session.started':
|
|
57
|
+
if (event.payload.phase?.startsWith('verify:') && event.payload.round !== undefined)
|
|
58
|
+
acc.owners[event.payload.session] = verifyMemberKey(
|
|
59
|
+
event.payload.phase.slice(7),
|
|
60
|
+
event.payload.round,
|
|
61
|
+
)
|
|
62
|
+
break
|
|
63
|
+
case 'verify.cancelled':
|
|
64
|
+
acc.cancelled[verifyMemberKey(event.payload.step, event.payload.attempt)] = true
|
|
65
|
+
break
|
|
66
|
+
case 'phase.deferral-escalated':
|
|
67
|
+
acc.raised[event.payload.id] = {
|
|
68
|
+
phase: event.payload.phase,
|
|
69
|
+
round: event.payload.round,
|
|
70
|
+
source: 'policy',
|
|
71
|
+
deferral: 'own-build-read',
|
|
72
|
+
}
|
|
73
|
+
break
|
|
74
|
+
// A ticket wait's escalation (`wait.entered`) is deliberately not
|
|
75
|
+
// registered: ending a wait is not a failure retry, so its answer
|
|
76
|
+
// re-arms no budget.
|
|
77
|
+
case 'escalation.raised':
|
|
78
|
+
acc.raised[event.payload.id] = {
|
|
79
|
+
phase: event.payload.phase,
|
|
80
|
+
source: event.payload.source,
|
|
81
|
+
...(event.actor.kind === 'agent' ? { session: event.actor.session } : {}),
|
|
82
|
+
...(event.payload.policyCause !== undefined
|
|
83
|
+
? { policyCause: event.payload.policyCause }
|
|
84
|
+
: {}),
|
|
85
|
+
...(event.payload.round !== undefined ? { round: event.payload.round } : {}),
|
|
86
|
+
}
|
|
87
|
+
break
|
|
88
|
+
case 'escalation.answered': {
|
|
89
|
+
const raise = acc.raised[event.payload.id]
|
|
90
|
+
if (raise?.session && acc.cancelled[acc.owners[raise.session] ?? '']) break
|
|
91
|
+
if (raise !== undefined && resetsPhaseFailureBudget(raise, phase, round)) {
|
|
92
|
+
acc.count = 0
|
|
93
|
+
delete acc.lastError
|
|
94
|
+
delete acc.lastWillRetry
|
|
95
|
+
delete acc.lastProviderAttempts
|
|
96
|
+
}
|
|
97
|
+
break
|
|
98
|
+
}
|
|
99
|
+
case 'phase.failed':
|
|
100
|
+
if (event.payload.phase === phase && event.payload.round === round) {
|
|
101
|
+
acc.count += 1
|
|
102
|
+
acc.lastError = event.payload.error
|
|
103
|
+
acc.lastWillRetry = event.payload.willRetry
|
|
104
|
+
acc.lastProviderAttempts = event.payload.providerAttempts
|
|
105
|
+
}
|
|
106
|
+
break
|
|
107
|
+
default:
|
|
108
|
+
break
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
finish: (acc) => ({
|
|
113
|
+
count: acc.count,
|
|
114
|
+
...(acc.lastError !== undefined ? { lastError: acc.lastError } : {}),
|
|
115
|
+
...(acc.lastWillRetry !== undefined ? { lastWillRetry: acc.lastWillRetry } : {}),
|
|
116
|
+
...(acc.lastProviderAttempts !== undefined
|
|
117
|
+
? { lastProviderAttempts: acc.lastProviderAttempts }
|
|
118
|
+
: {}),
|
|
119
|
+
}),
|
|
120
|
+
})
|
|
121
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The branch head kernel plumbing last published. Pure so the reducer
|
|
3
|
+
* registry can register it without importing process code.
|
|
4
|
+
*/
|
|
5
|
+
import type { AbEvent } from '../events/catalog'
|
|
6
|
+
import { defineReducer } from './incremental'
|
|
7
|
+
import { reconcileHead, reconcileRewriteHead } from './reconcile-head'
|
|
8
|
+
|
|
9
|
+
/** Latest event-checkpointed branch head that kernel plumbing published;
|
|
10
|
+
* undefined while the build has none. */
|
|
11
|
+
export const publishedBranchHeadReducer = defineReducer<
|
|
12
|
+
{ head?: string },
|
|
13
|
+
AbEvent,
|
|
14
|
+
string | undefined
|
|
15
|
+
>({
|
|
16
|
+
identity: 'publishedBranchHead',
|
|
17
|
+
initial: () => ({}),
|
|
18
|
+
fold(acc, events) {
|
|
19
|
+
for (const event of events) {
|
|
20
|
+
if (event.type === 'implement.completed') {
|
|
21
|
+
acc.head = event.payload.commits.head
|
|
22
|
+
} else if (event.type === 'restack.rewritten' || event.type === 'restack.completed') {
|
|
23
|
+
acc.head =
|
|
24
|
+
event.type === 'restack.rewritten'
|
|
25
|
+
? (event.payload.observedHead ?? event.payload.headSha)
|
|
26
|
+
: event.payload.headSha
|
|
27
|
+
} else if (event.type === 'reconcile.rewritten') {
|
|
28
|
+
acc.head = reconcileRewriteHead(event.payload)
|
|
29
|
+
} else if (event.type === 'reconcile.completed') {
|
|
30
|
+
acc.head = reconcileHead(event.payload)
|
|
31
|
+
} else if (
|
|
32
|
+
event.type === 'wait.requested' &&
|
|
33
|
+
event.payload.publication?.settlement === 'published'
|
|
34
|
+
) {
|
|
35
|
+
acc.head = event.payload.publication.sha
|
|
36
|
+
} else if (event.type === 'wait.published') {
|
|
37
|
+
acc.head = event.payload.sha
|
|
38
|
+
} else if (
|
|
39
|
+
event.type === 'finalize.step-completed' &&
|
|
40
|
+
event.payload.ok &&
|
|
41
|
+
event.payload.headSha !== undefined
|
|
42
|
+
) {
|
|
43
|
+
acc.head = event.payload.headSha
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
finish: (acc) => acc.head,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
/** Latest event-checkpointed branch head that kernel plumbing published. */
|
|
51
|
+
export function selectPublishedBranchHead(events: readonly AbEvent[]): string {
|
|
52
|
+
const head = publishedBranchHeadReducer.reduce(events)
|
|
53
|
+
if (head === undefined) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
'finalize publication requires a prior implement.completed, reconcile.completed, ' +
|
|
56
|
+
'or successful finalize publication head, but this build has none',
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
return head
|
|
60
|
+
}
|
|
@@ -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),
|
|
@@ -6,8 +6,13 @@ import { dispatchUpgradeReducer } from './dispatch-upgrade'
|
|
|
6
6
|
import { forgeHealthReducer } from './forge-health'
|
|
7
7
|
import { decodeStoredEvent } from '../events/compatibility'
|
|
8
8
|
import { nodeRestackReducer } from './node-restack-state'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
foldsIntoOptimization,
|
|
11
|
+
optimizationLedgerReducer,
|
|
12
|
+
optimizationReducer,
|
|
13
|
+
} from './optimization'
|
|
10
14
|
import { leafRestackReducer } from './leaf-restack-state'
|
|
15
|
+
import { executionIntervalsReducer } from './execution-intervals'
|
|
11
16
|
import { terminalGuardReducer } from './terminal-guard'
|
|
12
17
|
import { repositoryAttentionReducer } from './repository-attention'
|
|
13
18
|
import {
|
|
@@ -40,12 +45,10 @@ import { ticketSourceHealthReducer } from './ticket-source-health'
|
|
|
40
45
|
*/
|
|
41
46
|
import { recordedBaseShaReducer } from '../config/pipeline-source'
|
|
42
47
|
import { openWorkspaceReducer } from '../processes/build-execution-state'
|
|
43
|
-
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
verifyDiffBaseReducer,
|
|
48
|
-
} from '../processes/build-runner'
|
|
48
|
+
import { phaseFailuresReducer } from './phase-failures'
|
|
49
|
+
import { publishedBranchHeadReducer } from './published-branch-head'
|
|
50
|
+
import { setupStreakReducer } from './setup-streak'
|
|
51
|
+
import { verifyDiffBaseReducer } from './verify-diff-base'
|
|
49
52
|
import {
|
|
50
53
|
baseBranchReducer,
|
|
51
54
|
openBuildWorkspaceReducer,
|
|
@@ -65,11 +68,13 @@ import { publicationStateReducer } from '../processes/publication-state'
|
|
|
65
68
|
import { sandboxStatesReducer } from '../processes/sandbox-state'
|
|
66
69
|
import { openTickReducer } from '../processes/tick-state'
|
|
67
70
|
import { dashboardFactsReducer } from '../cli/dashboard/facts'
|
|
71
|
+
import { buildTimelineReducer } from '../cli/dashboard/timeline'
|
|
68
72
|
import { buildDigestReducer, type DigestEventRow } from '../store/digest'
|
|
69
73
|
import { journalViewReducer, repositoryStateEventsReducer } from '../store/repo-state-events'
|
|
70
74
|
import { sessionReducer } from '../store/session-reducer'
|
|
71
75
|
import { pinnedAssetsReducer } from '../store/ticket-assets'
|
|
72
76
|
import { autoMergeDefaultReducer } from './auto-merge-default'
|
|
77
|
+
import { buildRosterEntryReducer, buildRosterRollup } from './build-roster'
|
|
73
78
|
import { currentDeferralObservationReducer } from './auto-merge'
|
|
74
79
|
import { dispatchSettingsReducer } from './dispatch-settings'
|
|
75
80
|
import { dispatchStatusReducer } from './dispatch-status'
|
|
@@ -83,6 +88,8 @@ import {
|
|
|
83
88
|
pendingPrAttachmentReclaimsReducer,
|
|
84
89
|
} from './pr-attachments'
|
|
85
90
|
import { buildReducer } from './reducer'
|
|
91
|
+
import type { AnyRollupDefinition } from './rollup'
|
|
92
|
+
import { stepDurationsRollup } from './step-durations'
|
|
86
93
|
|
|
87
94
|
export interface RegisteredReducer {
|
|
88
95
|
valueRead: ValueCatalogEntry | { excluded: string }
|
|
@@ -103,6 +110,7 @@ const REGISTERED: Record<string, Omit<RegisteredReducer, 'valueRead'>> = {
|
|
|
103
110
|
leafRestack: { reducer: leafRestackReducer, covers: ['advanceLeafRestack'] },
|
|
104
111
|
optimization: { reducer: optimizationReducer, covers: ['advanceOptimization'] },
|
|
105
112
|
optimizationLedger: { reducer: optimizationLedgerReducer, covers: [] },
|
|
113
|
+
executionIntervals: { reducer: executionIntervalsReducer, covers: [] },
|
|
106
114
|
baseBranchValue: { reducer: optionalValue(baseBranchReducer), covers: [] },
|
|
107
115
|
publishedBranchHeadValue: { reducer: optionalValue(publishedBranchHeadReducer), covers: [] },
|
|
108
116
|
verifyDiffBaseValue: { reducer: optionalValue(verifyDiffBaseReducer), covers: [] },
|
|
@@ -200,6 +208,8 @@ const REGISTERED: Record<string, Omit<RegisteredReducer, 'valueRead'>> = {
|
|
|
200
208
|
reducer: dashboardFactsReducer,
|
|
201
209
|
covers: ['phaseIntervals', 'projectSessions'],
|
|
202
210
|
},
|
|
211
|
+
buildTimeline: { reducer: buildTimelineReducer, covers: [] },
|
|
212
|
+
buildRosterEntry: { reducer: buildRosterEntryReducer, covers: [] },
|
|
203
213
|
autoMergeDefault: { reducer: autoMergeDefaultReducer, covers: ['latestAutoMergeDefault'] },
|
|
204
214
|
pinnedAssets: { reducer: pinnedAssetsReducer, covers: ['findPinnedRevision'] },
|
|
205
215
|
forgeHealthValue: { reducer: optionalValue(forgeHealthReducer), covers: [] },
|
|
@@ -327,7 +337,7 @@ function digestAttemptOf(
|
|
|
327
337
|
function digestOptimizationOf(
|
|
328
338
|
event: Parameters<ValueCatalogEntry['adapt']>[0][number],
|
|
329
339
|
): Pick<DigestEventRow, 'optimizationEvent'> {
|
|
330
|
-
if (!
|
|
340
|
+
if (!foldsIntoOptimization(event)) return {}
|
|
331
341
|
const decoded = decodeStoredEvent(event)
|
|
332
342
|
return decoded === null
|
|
333
343
|
? {}
|
|
@@ -400,6 +410,15 @@ export const REDUCERS: Record<string, RegisteredReducer> = Object.fromEntries(
|
|
|
400
410
|
]),
|
|
401
411
|
)
|
|
402
412
|
|
|
413
|
+
/** Derived reducers (SPEC §7.7): repository rollups over a registered build
|
|
414
|
+
* reducer's saved values, answered for a `{kind: 'rollup', repo}` scope. They
|
|
415
|
+
* fold no events, so they sit beside `REDUCERS` rather than in it; their
|
|
416
|
+
* versions still derive from the revision ledger and their build reducer's. */
|
|
417
|
+
export const ROLLUPS: Record<string, AnyRollupDefinition> = {
|
|
418
|
+
stepDurations: stepDurationsRollup,
|
|
419
|
+
buildRoster: buildRosterRollup,
|
|
420
|
+
}
|
|
421
|
+
|
|
403
422
|
/** Event-array functions that are deliberately not reducers, each with the
|
|
404
423
|
* concrete reason. */
|
|
405
424
|
export const EXCLUDED: Record<string, string> = {
|
|
@@ -47,4 +47,31 @@ export const REDUCER_REVISIONS: Readonly<Record<string, string>> = {
|
|
|
47
47
|
'repositoryReadFacts/fold/fk3ka9gb3z': 'AUT-1293 re-request updates pending start priority',
|
|
48
48
|
'buildReadFacts/shape/grk476irlr': 'history.retained fold for best-effort leaf history retention',
|
|
49
49
|
'buildReadFacts/fold/iub07xo6kf': '#1051 commits-retained and node.history-retained folds',
|
|
50
|
+
'optimization/shape/wy6151hb4q': '#1069 active-hours clock and execution fact counts',
|
|
51
|
+
'build/shape/d3jt2tcoj6': '#1069 active-hours clock and execution fact counts',
|
|
52
|
+
'buildDigest/shape/7dw02b53nl': '#1069 active-hours clock and execution fact counts',
|
|
53
|
+
'optimization/fold/px86golc8e': '#1069 active-hours clock and execution fact counts',
|
|
54
|
+
'build/fold/qt6bkt4ezw': '#1069 active-hours clock and execution fact counts',
|
|
55
|
+
'buildDigest/fold/2lfn4ripe4': '#1069 active-hours clock and execution fact counts',
|
|
56
|
+
'optimization/fold/n2q2dksb1t': '#1069 settlement chunks and the dispatcher-started clock',
|
|
57
|
+
'build/fold/xfau4h85gn': '#1069 settlement chunks and the dispatcher-started clock',
|
|
58
|
+
'buildDigest/fold/r14f4ydbcd': '#1069 settlement chunks and the dispatcher-started clock',
|
|
59
|
+
'optimization/shape/dlths9d2kt': '#1069 clock compacts below open runs and last batch',
|
|
60
|
+
'build/shape/qggqu27a51': '#1069 clock compacts below open runs and last batch',
|
|
61
|
+
'buildDigest/shape/qr2vs0xtvj': '#1069 clock compacts below open runs and last batch',
|
|
62
|
+
'optimization/fold/mpmd7m1p0r': '#1069 clock compacts below open runs and last batch',
|
|
63
|
+
'build/fold/sgmw4zxzmb': '#1069 clock compacts below open runs and last batch',
|
|
64
|
+
'buildDigest/fold/8fy0afqcn5': '#1069 clock compacts below open runs and last batch',
|
|
65
|
+
'sandboxStates/shape/gbrf8k4qxq': '#1223 sandbox provisioning/failed states',
|
|
66
|
+
'repositoryReadFacts/shape/o7791nz2gt': '#1223 sandbox provisioning/failed states',
|
|
67
|
+
'sandboxStates/fold/hjdgop7xoh': '#1223 fold sandbox lifecycle facts',
|
|
68
|
+
'build/shape/o79t0vefkb': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
69
|
+
'leafRestack/shape/4ju65uzvg9': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
70
|
+
'logIndex/shape/n7i96wfovf': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
71
|
+
'build/fold/1do6v52s3p': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
72
|
+
'leafRestack/fold/5zq9n2zlit': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
73
|
+
'logIndex/fold/bwl7r7gjae': '#1274 rewritten-target reprovision, accept waiver, episodes',
|
|
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',
|
|
50
77
|
}
|