@defrex/autobuild 1.5.0 → 1.6.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 +85 -14
- package/docs/answering-blocked-builds.md +7 -4
- package/docs/architecture.md +38 -10
- package/docs/configuration.md +55 -5
- package/docs/dispatcher.md +2 -2
- package/docs/glossary.md +1 -1
- package/docs/operating.md +1 -1
- package/docs/operator-api.md +14 -2
- package/docs/plugin-authoring.md +4 -0
- package/docs/remote-store-protocol.md +14 -4
- package/docs/restacking.md +4 -0
- package/docs/tickets.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/dashboard/model.ts +14 -4
- package/packages/core/src/cli/dashboard/poll.ts +14 -0
- package/packages/core/src/cli/dashboard/render.ts +3 -0
- package/packages/core/src/cli/dispatch-preflight.ts +4 -1
- package/packages/core/src/cli/dispatch-tickets.ts +47 -0
- package/packages/core/src/cli/dispatch-upgrade-controller.ts +3 -0
- package/packages/core/src/cli/dispatch.ts +368 -98
- package/packages/core/src/cli/help.ts +4 -2
- package/packages/core/src/cli/repo-lease.ts +225 -0
- package/packages/core/src/cli/repository-status.ts +3 -1
- package/packages/core/src/cli/status.ts +13 -13
- package/packages/core/src/cli/wait.ts +4 -1
- package/packages/core/src/cli/watch.ts +15 -4
- package/packages/core/src/config/schema.ts +38 -2
- package/packages/core/src/events/catalog.ts +2 -0
- package/packages/core/src/events/payloads.ts +15 -0
- package/packages/core/src/events/policy.ts +2 -0
- package/packages/core/src/events/repository.ts +2 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +196 -230
- package/packages/core/src/kernel/dispatch-capacity.ts +134 -30
- package/packages/core/src/kernel/engine.ts +13 -6
- package/packages/core/src/kernel/generators/build-log.ts +9 -0
- package/packages/core/src/kernel/incremental-fixtures.ts +1 -0
- package/packages/core/src/kernel/janitor-failure.ts +85 -5
- package/packages/core/src/kernel/leaf-restack-state.ts +4 -2
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-landing.ts +2 -1
- package/packages/core/src/kernel/reducer-registry.ts +6 -1
- package/packages/core/src/kernel/reducer.ts +58 -4
- package/packages/core/src/kernel/ticket-preparation.ts +11 -7
- package/packages/core/src/operator/query.ts +15 -12
- package/packages/core/src/ports/tickets/create.ts +19 -5
- package/packages/core/src/ports/types.ts +4 -0
- package/packages/core/src/ports/workspace/commit-preservation.ts +28 -12
- package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
- package/packages/core/src/ports/workspace/harvest-execution.ts +4 -2
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +3 -0
- package/packages/core/src/processes/build-runner.ts +2 -1
- package/packages/core/src/processes/dispatcher.ts +231 -41
- package/packages/core/src/processes/execution-no-progress.ts +2 -0
- package/packages/core/src/processes/harvest-child.ts +4 -2
- package/packages/core/src/processes/harvest-execution-state.ts +104 -0
- package/packages/core/src/processes/harvest-runner.ts +246 -17
- package/packages/core/src/scenarios/harness.ts +145 -35
- package/packages/core/src/store/reduced-reads.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +1463 -1215
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.6.0.json +27173 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
- package/packages/core/src/testing/reduced-read-budget.ts +339 -2
- package/skills/guide/SKILL.md +53 -17
- package/skills/guide/references/operator-api.md +14 -2
- package/skills/guide/references/plugin-authoring.md +4 -0
- package/skills/guide/references/remote-store-protocol.md +14 -4
- package/skills/guide/references/restacking.md +4 -0
- package/skills/operate/SKILL.md +50 -11
- package/skills/tickets/SKILL.md +4 -2
- package/templates/hosted-service/package.json +2 -2
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
currentDeferralObservationReducer,
|
|
74
74
|
type DeferralLedger,
|
|
75
75
|
} from '../../kernel/auto-merge'
|
|
76
|
-
import { decideNextFromFacts } from '../../kernel/engine'
|
|
76
|
+
import { decideNextFromFacts, landingRestackDue } from '../../kernel/engine'
|
|
77
77
|
import { verifyPhase } from '../../ontology'
|
|
78
78
|
import { indexLog, type LogIndex } from '../../kernel/log-index'
|
|
79
79
|
import {
|
|
@@ -185,6 +185,8 @@ export interface DashboardHarvest {
|
|
|
185
185
|
|
|
186
186
|
export interface DashboardBuild {
|
|
187
187
|
draining?: boolean
|
|
188
|
+
/** A work row's standing alert, such as a parked build waiting for a slot. */
|
|
189
|
+
alert?: { tone: 'yellow' | 'red'; text: string }
|
|
188
190
|
integrationRow?: IntegrationRow
|
|
189
191
|
integrationDetail?: IntegrationDetail
|
|
190
192
|
collectionIdentity?: {
|
|
@@ -1344,15 +1346,22 @@ export interface DashboardHeader extends DashboardFrameHeader {
|
|
|
1344
1346
|
* projection here means build rows (including their phase intervals) may be
|
|
1345
1347
|
* cached without caching dispatcher settings or Harvest state.
|
|
1346
1348
|
*/
|
|
1347
|
-
/** A node waiting for a runner slot says so on its row
|
|
1348
|
-
* alert already stands. Returns copies; cached projected
|
|
1349
|
+
/** A node or parked build waiting for a runner slot says so on its row
|
|
1350
|
+
* unless a more urgent alert already stands. Returns copies; cached projected
|
|
1351
|
+
* rows stay intact. */
|
|
1349
1352
|
export function decorateSlotWaits(
|
|
1350
1353
|
rows: readonly DashboardBuild[],
|
|
1351
1354
|
capacity: DispatchCapacity | undefined,
|
|
1352
1355
|
): DashboardBuild[] {
|
|
1353
1356
|
const waiting = new Map((capacity?.waitingNodes ?? []).map((node) => [node.slug, node.request]))
|
|
1354
|
-
|
|
1357
|
+
const parked = new Map(
|
|
1358
|
+
(capacity?.waitingBuilds ?? []).map((build) => [build.slug, build.request]),
|
|
1359
|
+
)
|
|
1360
|
+
if (!waiting.size && !parked.size) return [...rows]
|
|
1355
1361
|
return rows.map((row) => {
|
|
1362
|
+
const leaf = parked.get(row.slug)
|
|
1363
|
+
if (leaf && !row.integrationRow && !row.alert)
|
|
1364
|
+
return { ...row, alert: { tone: 'yellow', text: slotWaitText(leaf) } }
|
|
1356
1365
|
const request = waiting.get(row.slug)
|
|
1357
1366
|
if (!request || !row.integrationRow || row.integrationRow.alert) return row
|
|
1358
1367
|
return {
|
|
@@ -1437,6 +1446,7 @@ export function buildDashboard(
|
|
|
1437
1446
|
state,
|
|
1438
1447
|
workspace: openBuildWorkspace(events) !== null,
|
|
1439
1448
|
provisioning: provisionMarkerReducer.reduce(events) !== undefined,
|
|
1449
|
+
restackDue: landingRestackDue(state, indexLog(events)),
|
|
1440
1450
|
})),
|
|
1441
1451
|
config.capacity,
|
|
1442
1452
|
new Date(),
|
|
@@ -9,6 +9,8 @@ import { composeBuildConfig } from '../../config/live'
|
|
|
9
9
|
import type { PipelineSourceMeta } from '../../config/pipeline-source'
|
|
10
10
|
import type { AbEvent } from '../../events/catalog'
|
|
11
11
|
import { buildReducer, type BuildAcc, type BuildState } from '../../kernel/reducer'
|
|
12
|
+
import { landingRestackDue } from '../../kernel/engine'
|
|
13
|
+
import { leafRestackReducer, type LeafRestackState } from '../../kernel/leaf-restack-state'
|
|
12
14
|
import {
|
|
13
15
|
BUILD_EFFECTIVE_CONFIG_ARTIFACT,
|
|
14
16
|
parseBuildConfigMetadata,
|
|
@@ -65,6 +67,8 @@ interface LiveEntry {
|
|
|
65
67
|
* folded into a copy of it instead of re-reducing the whole log. */
|
|
66
68
|
acc: BuildAcc
|
|
67
69
|
state: BuildState
|
|
70
|
+
/** Advanced with every delta, for `landingRestackDue`. */
|
|
71
|
+
restack: LeafRestackState
|
|
68
72
|
build: DashboardBuild | null
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -81,6 +85,7 @@ interface ReducedEntry {
|
|
|
81
85
|
state: BuildState
|
|
82
86
|
workspace: boolean
|
|
83
87
|
provisioning: boolean
|
|
88
|
+
restackDue: boolean
|
|
84
89
|
build: DashboardBuild | null
|
|
85
90
|
}
|
|
86
91
|
|
|
@@ -267,6 +272,7 @@ export class DashboardBuildPollCache {
|
|
|
267
272
|
state: value.state,
|
|
268
273
|
workspace: value.workspace !== null,
|
|
269
274
|
provisioning: value.provisionMarker !== undefined,
|
|
275
|
+
restackDue: landingRestackDue(value.state, value.log),
|
|
270
276
|
build:
|
|
271
277
|
current?.kind === 'reduced' &&
|
|
272
278
|
current.cursor === cursor &&
|
|
@@ -322,6 +328,10 @@ export class DashboardBuildPollCache {
|
|
|
322
328
|
events,
|
|
323
329
|
acc,
|
|
324
330
|
state,
|
|
331
|
+
restack: leafRestackReducer.advance(
|
|
332
|
+
current?.restack ?? leafRestackReducer.initial(),
|
|
333
|
+
delta,
|
|
334
|
+
),
|
|
325
335
|
build: await this.projectRow(record, state, events, config),
|
|
326
336
|
})
|
|
327
337
|
}
|
|
@@ -347,6 +357,10 @@ export class DashboardBuildPollCache {
|
|
|
347
357
|
workspace: entry.kind === 'reduced' ? entry.workspace : entry.workspace.open !== null,
|
|
348
358
|
provisioning:
|
|
349
359
|
entry.kind === 'reduced' ? entry.provisioning : entry.provisionMarker.marker !== null,
|
|
360
|
+
restackDue:
|
|
361
|
+
entry.kind === 'reduced'
|
|
362
|
+
? entry.restackDue
|
|
363
|
+
: landingRestackDue(entry.state, { restack: entry.restack }),
|
|
350
364
|
})
|
|
351
365
|
states.set(slug, entry.state)
|
|
352
366
|
if (entry.build !== null) builds.push(entry.build)
|
|
@@ -471,6 +471,9 @@ function renderBuild(
|
|
|
471
471
|
),
|
|
472
472
|
)
|
|
473
473
|
}
|
|
474
|
+
if (build.alert)
|
|
475
|
+
for (const line of wrappedText(build.alert.text, Math.max(1, width - 4), ''))
|
|
476
|
+
lines.push(paint(` ! ${line}`, build.alert.tone, color))
|
|
474
477
|
// Setup failures and blocker questions are dense-list previews. Their model
|
|
475
478
|
// strings remain untouched; newline-aware wrapping and capping happen only
|
|
476
479
|
// at this presentation seam.
|
|
@@ -207,6 +207,8 @@ async function runGenerationPreflight(
|
|
|
207
207
|
)
|
|
208
208
|
return false
|
|
209
209
|
prepared = true
|
|
210
|
+
// The successor claims with its own configured lease timeout.
|
|
211
|
+
let leaseTtlMs = 60_000
|
|
210
212
|
for (;;) {
|
|
211
213
|
signal.throwIfAborted()
|
|
212
214
|
const current = (await readDispatchUpgrade(opened.store, opened.repo)).value.runs[handoff.run]
|
|
@@ -228,6 +230,7 @@ async function runGenerationPreflight(
|
|
|
228
230
|
facts.stop.payload.outcome === 'normal'))
|
|
229
231
|
if (ready) {
|
|
230
232
|
const config = await loadConfig(join(launch.checkout, 'autobuild.toml'))
|
|
233
|
+
leaseTtlMs = config.policy.dispatchLeaseTimeoutSeconds * 1000
|
|
231
234
|
const accounts = selectedExecutionAccounts(config)
|
|
232
235
|
const available = inspectLocalAccountEnvironment(
|
|
233
236
|
new LocalCredentials(join(launch.checkout, '.autobuild')),
|
|
@@ -245,7 +248,7 @@ async function runGenerationPreflight(
|
|
|
245
248
|
return false
|
|
246
249
|
}
|
|
247
250
|
}
|
|
248
|
-
if (ready && (await opened.store.claimRepoLease(opened.repo, launch.run,
|
|
251
|
+
if (ready && (await opened.store.claimRepoLease(opened.repo, launch.run, leaseTtlMs))) {
|
|
249
252
|
await opened.store.appendRepo(opened.repo, {
|
|
250
253
|
actor: DISPATCHER,
|
|
251
254
|
type: 'dispatcher.takeover',
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dispatcher's ticket source (SPEC §3.2): built once per dispatcher
|
|
3
|
+
* process start, before the loop, against the repository's filesystem
|
|
4
|
+
* location rather than its identity.
|
|
5
|
+
*/
|
|
6
|
+
import type { TicketsConfig } from '../config/schema'
|
|
7
|
+
import { normalizeGitRemoteUrl } from '../kernel/origin'
|
|
8
|
+
import type { PluginRegistry } from '../plugins/registry'
|
|
9
|
+
import type { GitHubRequest } from '../ports/forge/github-transport'
|
|
10
|
+
import { createTicketSource } from '../ports/tickets/create'
|
|
11
|
+
import type { TicketSource } from '../ports/types'
|
|
12
|
+
import type { Exec } from '../ports/workspace/git-worktree'
|
|
13
|
+
import type { RepoStatePaths } from './repo-state'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Construct the dispatcher's ticket source. `state.checkout` is the checkout
|
|
17
|
+
* (or origin mode's scratch root), never the repository identity, so a
|
|
18
|
+
* `github` source resolves its coordinates from the checkout's `origin`.
|
|
19
|
+
* Origin mode supplies its repository directly: its scratch root is no Git
|
|
20
|
+
* checkout.
|
|
21
|
+
*
|
|
22
|
+
* Cost: in checkout mode the `github` and `hosted` sources spend one
|
|
23
|
+
* `git remote get-url origin` spawn; origin mode spends none. It runs once
|
|
24
|
+
* per dispatcher process start, never per tick or config reload, and makes
|
|
25
|
+
* zero store reads.
|
|
26
|
+
*/
|
|
27
|
+
export function dispatcherTicketSource(
|
|
28
|
+
config: TicketsConfig,
|
|
29
|
+
opts: {
|
|
30
|
+
env: Record<string, string | undefined>
|
|
31
|
+
exec: Exec
|
|
32
|
+
/** Origin mode's repository (`--repository` / `AB_REPOSITORY`). */
|
|
33
|
+
repository?: string
|
|
34
|
+
},
|
|
35
|
+
state: Pick<RepoStatePaths, 'checkout'>,
|
|
36
|
+
localStateRoot: string | undefined,
|
|
37
|
+
plugins: PluginRegistry,
|
|
38
|
+
seams: { transport?: GitHubRequest } = {},
|
|
39
|
+
): Promise<TicketSource> {
|
|
40
|
+
return createTicketSource(config, opts.env, state.checkout, localStateRoot, plugins, {
|
|
41
|
+
exec: opts.exec,
|
|
42
|
+
...(opts.repository !== undefined
|
|
43
|
+
? { repository: normalizeGitRemoteUrl(opts.repository) }
|
|
44
|
+
: {}),
|
|
45
|
+
...seams,
|
|
46
|
+
})
|
|
47
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from './dispatch-upgrade-target'
|
|
11
11
|
import type { CachedRuntime } from './dispatch-runtime-cache'
|
|
12
12
|
import { releasePreparedRuntime, reservePreparedRuntime } from './dispatch-runtime-use'
|
|
13
|
+
import { isRepositoryAuthorityLapse } from './repo-lease'
|
|
13
14
|
import { captureRuntimeIdentity } from '../runtime-identity'
|
|
14
15
|
import type { DispatchUpgradeState, Handoff } from '../kernel/dispatch-upgrade'
|
|
15
16
|
|
|
@@ -195,6 +196,8 @@ export class DispatchUpgradeController {
|
|
|
195
196
|
}
|
|
196
197
|
} catch (error) {
|
|
197
198
|
if (preparation.signal.aborted || this.abort.signal.aborted) return
|
|
199
|
+
// A fenced effect during a lapsed repository lease skips the check.
|
|
200
|
+
if (isRepositoryAuthorityLapse(error)) return
|
|
198
201
|
if (error instanceof TargetResolutionError) target = error.target
|
|
199
202
|
if (target && !this.failed.has(target.key)) {
|
|
200
203
|
await this.input.append({
|