@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
|
@@ -66,13 +66,17 @@ export const ticketPreparationReducer = defineReducer<
|
|
|
66
66
|
})
|
|
67
67
|
|
|
68
68
|
/** The one operator line for a durably abandoned attempt. An unconfirmed
|
|
69
|
-
* claim is never reported as applied: its provider outcome is unknown.
|
|
69
|
+
* claim is never reported as applied: its provider outcome is unknown. An
|
|
70
|
+
* event written before claim certainty was recorded says so. */
|
|
70
71
|
export function abandonedPreparationDiagnostic(
|
|
71
|
-
attempt:
|
|
72
|
-
reason
|
|
72
|
+
attempt: { attempt: string; ticket: TicketRef; claimed?: boolean },
|
|
73
|
+
reason?: string,
|
|
73
74
|
): string {
|
|
74
|
-
const claim =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
const claim =
|
|
76
|
+
attempt.claimed === true
|
|
77
|
+
? 'claim confirmed'
|
|
78
|
+
: attempt.claimed === false
|
|
79
|
+
? 'claim unconfirmed (provider outcome unknown; it may have applied the claim)'
|
|
80
|
+
: 'claim certainty not recorded (provider outcome unknown)'
|
|
81
|
+
return `ticket ${attempt.ticket.id} (${attempt.ticket.source}): preparation ${attempt.attempt} abandoned; ${claim}; ticket unchanged — ${reason ?? 'no reason recorded'}`
|
|
78
82
|
}
|
|
@@ -3,6 +3,7 @@ import { migrationIdentity } from '../kernel/ticket-migrations'
|
|
|
3
3
|
import { enrichDrainingRow, projectHandoffs } from '../cli/dashboard/handoff'
|
|
4
4
|
import { enrichIntegrationRows } from '../cli/dashboard/integration-row'
|
|
5
5
|
import { dispatchCapacity, slotRequest, type CapacityBuild } from '../kernel/dispatch-capacity'
|
|
6
|
+
import { landingRestackDue } from '../kernel/engine'
|
|
6
7
|
import { forgeReadinessWarnings } from '../kernel/dispatch-status'
|
|
7
8
|
import { readBuildDigests } from '../store/reduced-reads'
|
|
8
9
|
import {
|
|
@@ -117,18 +118,19 @@ async function listFromView(
|
|
|
117
118
|
record,
|
|
118
119
|
facts.state,
|
|
119
120
|
opts.now,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
slotRequest(
|
|
122
|
+
{
|
|
123
|
+
record,
|
|
124
|
+
state: facts.state,
|
|
125
|
+
workspace: facts.workspace !== null,
|
|
126
|
+
// Leaves rely on the continuation's lease; only nodes read the marker.
|
|
127
|
+
provisioning:
|
|
128
|
+
facts.state.kind === 'node' &&
|
|
129
|
+
(await readBuildFacts(view, record.slug)).value.provisionMarker !== undefined,
|
|
130
|
+
restackDue: landingRestackDue(facts.state, facts.log),
|
|
131
|
+
},
|
|
132
|
+
opts.now,
|
|
133
|
+
),
|
|
132
134
|
)
|
|
133
135
|
if (statuses.has(projected.status)) output.push(projected)
|
|
134
136
|
}
|
|
@@ -439,6 +441,7 @@ async function dashboardFromView(
|
|
|
439
441
|
provisioning:
|
|
440
442
|
facts.state.kind === 'node' &&
|
|
441
443
|
(await readBuildFacts(view, record.slug)).value.provisionMarker !== undefined,
|
|
444
|
+
restackDue: landingRestackDue(facts.state, facts.log),
|
|
442
445
|
})
|
|
443
446
|
if (projectsNoDashboardRow(facts.state)) continue
|
|
444
447
|
const pinned = await readPinnedConfig(view, record.slug, config, facts.state.verify.configPin)
|
|
@@ -2,7 +2,7 @@ import { compatibleTicketSource } from './tree'
|
|
|
2
2
|
import { configuredStore } from '../../cli/configured-store'
|
|
3
3
|
import { projectToken } from '../../cli/project-credentials'
|
|
4
4
|
import { resolveRepoOrigin } from '../../cli/repo-state'
|
|
5
|
-
import { spawnExec } from '../workspace/git-worktree'
|
|
5
|
+
import { spawnExec, type Exec } from '../workspace/git-worktree'
|
|
6
6
|
/**
|
|
7
7
|
* TicketSource factory (SPEC §3.2, §13): construct the builtin or plugin source
|
|
8
8
|
* named by [tickets]. Plugin credentials, like LINEAR_API_KEY, come only from
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
createGitHubFetchTransport,
|
|
23
23
|
githubTokenSource,
|
|
24
24
|
resolveGitHubToken,
|
|
25
|
+
type GitHubRequest,
|
|
25
26
|
} from '../forge/github-transport'
|
|
26
27
|
import { parseRepoCoordinates } from '../forge/github'
|
|
27
28
|
import { normalizeGitRemoteUrl } from '../../kernel/origin'
|
|
@@ -37,13 +38,25 @@ function reason(error: unknown): string {
|
|
|
37
38
|
async function rawTicketSource(
|
|
38
39
|
config: TicketsConfig,
|
|
39
40
|
env: Record<string, string | undefined>,
|
|
40
|
-
/**
|
|
41
|
+
/** Filesystem location of the repository: the checkout, or origin-mode
|
|
42
|
+
* dispatch's scratch root. Never a repository identity URL. A relative
|
|
43
|
+
* [tickets].dir is relative to it, not this process's cwd. */
|
|
41
44
|
targetRepo: string,
|
|
42
45
|
/** Selected local state root. Remote stores pass the repo-local default. */
|
|
43
46
|
localStateRoot?: string,
|
|
44
47
|
/** Registry loaded from this repository's configured plugins. */
|
|
45
48
|
plugins: PluginRegistry = createPluginRegistry(),
|
|
49
|
+
options: {
|
|
50
|
+
/** Already-resolved repository origin for a caller with no checkout
|
|
51
|
+
* (origin-mode dispatch). Used instead of resolving targetRepo's origin. */
|
|
52
|
+
repository?: string
|
|
53
|
+
/** Exec seam for the origin lookup; defaults to spawnExec. */
|
|
54
|
+
exec?: Exec
|
|
55
|
+
/** GitHub API seam for the github source; defaults to the fetch transport. */
|
|
56
|
+
transport?: GitHubRequest
|
|
57
|
+
} = {},
|
|
46
58
|
): Promise<TicketSource> {
|
|
59
|
+
const exec = options.exec ?? spawnExec
|
|
47
60
|
if (config.source === 'hosted') {
|
|
48
61
|
const buildUrl = env.AB_STORE?.trim() || configuredStore(targetRepo)
|
|
49
62
|
const rawUrl = config.url ?? buildUrl
|
|
@@ -72,7 +85,7 @@ async function rawTicketSource(
|
|
|
72
85
|
? env.AB_TICKET_TOKEN
|
|
73
86
|
: projectToken(
|
|
74
87
|
rawUrl,
|
|
75
|
-
(await resolveRepoOrigin(targetRepo,
|
|
88
|
+
options.repository ?? (await resolveRepoOrigin(targetRepo, exec)) ?? targetRepo,
|
|
76
89
|
config.url &&
|
|
77
90
|
(!buildUrl ||
|
|
78
91
|
!/^https?:/.test(buildUrl) ||
|
|
@@ -130,7 +143,8 @@ async function rawTicketSource(
|
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
if (config.source === 'github') {
|
|
133
|
-
const origin =
|
|
146
|
+
const origin =
|
|
147
|
+
env.AB_REPOSITORY?.trim() || options.repository || (await resolveRepoOrigin(targetRepo, exec))
|
|
134
148
|
if (origin === undefined || origin === '')
|
|
135
149
|
throw new Error(
|
|
136
150
|
'[tickets].source = "github" needs the repository\'s origin remote on github.com; set the checkout\'s origin or export AB_REPOSITORY',
|
|
@@ -141,7 +155,7 @@ async function rawTicketSource(
|
|
|
141
155
|
`[tickets].source = "github" needs an origin on github.com; origin is ${origin}`,
|
|
142
156
|
)
|
|
143
157
|
return new GitHubTicketSource({
|
|
144
|
-
transport: createGitHubFetchTransport({ token: githubTokenSource(env) }),
|
|
158
|
+
transport: options.transport ?? createGitHubFetchTransport({ token: githubTokenSource(env) }),
|
|
145
159
|
repository: coordinates,
|
|
146
160
|
lifecycle: ticketLifecycle(config),
|
|
147
161
|
readyLabels: config.readyLabels ?? ['autobuild'],
|
|
@@ -559,6 +559,10 @@ export interface WorkspaceProvider {
|
|
|
559
559
|
* branch head it covers must not be restored over the branch; report it
|
|
560
560
|
* in `restorationSkipped`. */
|
|
561
561
|
restorationReplaced?: string[]
|
|
562
|
+
/** Where the forge keeps `restoration` archive refs: `local` (local-git)
|
|
563
|
+
* means the repository already holds them and restoration must not
|
|
564
|
+
* consult a remote; `remote` means they may exist only on origin. */
|
|
565
|
+
restorationArchives?: 'local' | 'remote'
|
|
562
566
|
/** Immutable recovery checkpoint, never a moved base branch. */
|
|
563
567
|
revision?: string
|
|
564
568
|
/** Monotonic environment generation used in provider idempotency keys. */
|
|
@@ -171,18 +171,34 @@ export async function restoreGitCommits(input: {
|
|
|
171
171
|
!head.remoteRef.endsWith(`/${head.sha}`)
|
|
172
172
|
)
|
|
173
173
|
throw new Error('invalid workspace restoration ref')
|
|
174
|
-
if (!input.local)
|
|
175
|
-
await git(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
174
|
+
if (!input.local) {
|
|
175
|
+
const fetched = await git(
|
|
176
|
+
[
|
|
177
|
+
'fetch',
|
|
178
|
+
'--no-tags',
|
|
179
|
+
'--no-write-fetch-head',
|
|
180
|
+
'--refmap=',
|
|
181
|
+
'origin',
|
|
182
|
+
`+${head.remoteRef}:${head.remoteRef}`,
|
|
183
|
+
],
|
|
184
|
+
true,
|
|
185
|
+
)
|
|
186
|
+
if (fetched.exitCode !== 0)
|
|
187
|
+
throw new Error(
|
|
188
|
+
`workspace restoration archive ref ${head.remoteRef} could not be fetched from origin: ${fetched.stderr}`,
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
const resolveArgs = ['rev-parse', '--verify', '--quiet', `${head.remoteRef}^{commit}`]
|
|
192
|
+
const resolved = await git(resolveArgs, true)
|
|
193
|
+
const actual = resolved.stdout.trim()
|
|
194
|
+
if (resolved.exitCode === 1 || (resolved.exitCode === 0 && !actual))
|
|
195
|
+
throw new Error(
|
|
196
|
+
`workspace restoration archive ref ${head.remoteRef} is missing from the ${input.local ? 'local repository' : 'repository after fetching from origin'}`,
|
|
197
|
+
)
|
|
198
|
+
if (resolved.exitCode !== 0)
|
|
199
|
+
throw new Error(
|
|
200
|
+
`workspace restoration git ${resolveArgs.join(' ')} failed: ${resolved.stderr}`,
|
|
201
|
+
)
|
|
186
202
|
if (actual !== head.sha) throw new Error(`workspace restoration ref ${head.remoteRef} changed`)
|
|
187
203
|
for (const sha of [head.sha, ...head.commits]) await git(['cat-file', '-e', `${sha}^{commit}`])
|
|
188
204
|
if (head.role !== 'branch') continue
|
|
@@ -334,7 +334,9 @@ export class GitWorktreeProvider implements WorkspaceProvider {
|
|
|
334
334
|
branch: opts.branch,
|
|
335
335
|
heads: opts.restoration,
|
|
336
336
|
replaced: opts.restorationReplaced,
|
|
337
|
-
local
|
|
337
|
+
// A remote forge's archive fetch writes no local ref, so restoration
|
|
338
|
+
// has to fetch the exact ref itself; local-git never consults origin.
|
|
339
|
+
local: opts.restorationArchives !== 'remote',
|
|
338
340
|
})
|
|
339
341
|
if (skipped.length) handle.restorationSkipped = skipped
|
|
340
342
|
handle.base = {
|
|
@@ -33,8 +33,10 @@ export interface HarvestExecutionStart {
|
|
|
33
33
|
/** Remote base branch the disposable environment is provisioned from. */
|
|
34
34
|
baseBranch: string
|
|
35
35
|
workspaceRef?: string
|
|
36
|
-
/** Repository-lease holder the
|
|
37
|
-
*
|
|
36
|
+
/** Repository-lease holder of the launching dispatch invocation, as named
|
|
37
|
+
* by the execution's `harvest.execution.authorized`. The guest matches its
|
|
38
|
+
* authorization against it and never claims, renews or releases the
|
|
39
|
+
* lease. */
|
|
38
40
|
leaseHolder?: string
|
|
39
41
|
environment?: HarvestExecutionEnvironment
|
|
40
42
|
}
|
|
@@ -1464,6 +1464,9 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1464
1464
|
generation?: number
|
|
1465
1465
|
restoration?: import('../types').WorkspacePreservationHead[]
|
|
1466
1466
|
restorationReplaced?: string[]
|
|
1467
|
+
/** Ignored: a sandbox clone never holds archive refs, so restoration here
|
|
1468
|
+
* always fetches each exact ref from origin, whatever the forge. */
|
|
1469
|
+
restorationArchives?: 'local' | 'remote'
|
|
1467
1470
|
}): Promise<WorkspaceProvisionResult> {
|
|
1468
1471
|
const scopedToken = await (this.options.delegateCredential ?? delegateCredential)(
|
|
1469
1472
|
this.options.storeRef,
|
|
@@ -1154,7 +1154,8 @@ export class BuildRunner {
|
|
|
1154
1154
|
}
|
|
1155
1155
|
const currentFailure = state.setupFailure
|
|
1156
1156
|
const openSetupEscalation = state.openEscalations.some(
|
|
1157
|
-
(escalation) =>
|
|
1157
|
+
(escalation) =>
|
|
1158
|
+
escalation.phase === 'setup' && escalation.source === 'policy' && !escalation.janitor,
|
|
1158
1159
|
)
|
|
1159
1160
|
const streak = await readBuildSelector(store, slug, 'setupStreak')
|
|
1160
1161
|
|