@defrex/autobuild 1.5.0 → 1.7.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 +192 -24
- package/docs/agent-runtimes.md +1 -1
- package/docs/answering-blocked-builds.md +7 -4
- package/docs/architecture.md +100 -32
- package/docs/configuration-overview.md +10 -0
- package/docs/configuration.md +340 -10
- package/docs/dispatcher.md +2 -2
- package/docs/forges.md +1 -0
- package/docs/glossary.md +1 -1
- package/docs/operating.md +1 -1
- package/docs/operator-api.md +33 -10
- package/docs/operator-surfaces.md +6 -3
- package/docs/plugin-authoring.md +48 -6
- package/docs/remote-store-protocol.md +33 -10
- package/docs/restacking.md +16 -7
- package/docs/ticket-sources.md +34 -6
- package/docs/tickets.md +7 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/workspaces.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +3 -0
- package/packages/core/src/cli/binary-direct.ts +1 -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-frontend.ts +10 -14
- package/packages/core/src/cli/dispatch-preflight.ts +5 -1
- package/packages/core/src/cli/dispatch-repository-feed.ts +145 -109
- 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 +377 -101
- package/packages/core/src/cli/help.ts +15 -6
- package/packages/core/src/cli/init-validation.ts +14 -1
- package/packages/core/src/cli/repo-lease.ts +225 -0
- package/packages/core/src/cli/repository-status.ts +40 -3
- package/packages/core/src/cli/status.ts +21 -13
- package/packages/core/src/cli/ticket.ts +22 -4
- package/packages/core/src/cli/wait.ts +4 -1
- package/packages/core/src/cli/watch.ts +17 -4
- package/packages/core/src/config/live.ts +4 -0
- package/packages/core/src/config/profiles.ts +96 -0
- package/packages/core/src/config/ready-assignee.ts +43 -11
- package/packages/core/src/config/roles.ts +33 -10
- package/packages/core/src/config/schema.ts +204 -26
- package/packages/core/src/events/catalog.ts +2 -0
- package/packages/core/src/events/compatibility.ts +3 -1
- package/packages/core/src/events/forge-degradation-policy.ts +16 -2
- package/packages/core/src/events/payloads.ts +23 -0
- package/packages/core/src/events/policy.ts +3 -0
- package/packages/core/src/events/repository.ts +19 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +267 -352
- package/packages/core/src/kernel/build-creation.ts +29 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +134 -30
- package/packages/core/src/kernel/engine.ts +13 -6
- package/packages/core/src/kernel/forge-health.ts +47 -0
- package/packages/core/src/kernel/generators/build-log.ts +9 -0
- package/packages/core/src/kernel/guarded-forge.ts +76 -18
- 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/node-parent.ts +2 -0
- package/packages/core/src/kernel/read-facts.ts +9 -1
- package/packages/core/src/kernel/reducer-registry.ts +6 -1
- package/packages/core/src/kernel/reducer.ts +75 -4
- package/packages/core/src/kernel/ticket-preparation.ts +15 -8
- package/packages/core/src/operator/protocol.ts +10 -0
- package/packages/core/src/operator/query.ts +16 -13
- package/packages/core/src/operator/registry.ts +25 -5
- package/packages/core/src/operator/sandbox-host.ts +3 -0
- package/packages/core/src/operator/tickets.ts +15 -3
- package/packages/core/src/plugin-sdk/index.ts +4 -0
- package/packages/core/src/ports/forge/create.ts +6 -0
- package/packages/core/src/ports/forge/github-transport.ts +40 -3
- package/packages/core/src/ports/forge/github.ts +12 -1
- package/packages/core/src/ports/forge/workspace-ancestry.ts +60 -0
- package/packages/core/src/ports/forge-failure.ts +31 -2
- package/packages/core/src/ports/runner/routing.ts +66 -5
- package/packages/core/src/ports/tickets/assignees.ts +54 -0
- package/packages/core/src/ports/tickets/contract.ts +164 -4
- package/packages/core/src/ports/tickets/create.ts +35 -7
- package/packages/core/src/ports/tickets/github-fake.ts +18 -2
- package/packages/core/src/ports/tickets/github.ts +247 -29
- package/packages/core/src/ports/tickets/hosted-index.ts +1 -0
- package/packages/core/src/ports/tickets/operations.ts +6 -1
- package/packages/core/src/ports/tickets/tree.ts +12 -2
- package/packages/core/src/ports/tickets/update.ts +6 -2
- package/packages/core/src/ports/types.ts +37 -3
- 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 +12 -0
- package/packages/core/src/processes/build-child.ts +28 -7
- package/packages/core/src/processes/build-execution-state.ts +4 -1
- package/packages/core/src/processes/build-runner.ts +17 -2
- package/packages/core/src/processes/dispatcher.ts +329 -59
- package/packages/core/src/processes/execution-no-progress.ts +2 -0
- package/packages/core/src/processes/harvest-child.ts +8 -2
- package/packages/core/src/processes/harvest-execution-state.ts +104 -0
- package/packages/core/src/processes/harvest-runner.ts +251 -17
- package/packages/core/src/processes/repo-view.ts +2 -0
- package/packages/core/src/scenarios/harness.ts +160 -36
- package/packages/core/src/store/reduced-reads.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +3339 -2898
- package/packages/core/src/store/remote/client.ts +21 -8
- package/packages/core/src/store/remote/index.ts +4 -0
- package/packages/core/src/store/remote/protocol.ts +7 -0
- package/packages/core/src/store/remote/released-clients.json +22 -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/1.7.0.json +27366 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +1 -0
- package/packages/core/src/store/types.ts +11 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +84 -58
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/reduced-read-budget.ts +411 -11
- package/skills/guide/SKILL.md +166 -35
- package/skills/guide/references/operator-api.md +33 -10
- package/skills/guide/references/plugin-authoring.md +48 -6
- package/skills/guide/references/remote-store-protocol.md +33 -10
- package/skills/guide/references/restacking.md +16 -7
- package/skills/operate/SKILL.md +79 -14
- package/skills/tickets/SKILL.md +22 -4
- package/templates/hosted-service/package.json +2 -2
|
@@ -3,6 +3,7 @@ import { checkTicketRevision } from './revision'
|
|
|
3
3
|
import { validateTicketUpdate } from './update'
|
|
4
4
|
import { refuseUnsupportedIssueLinks } from './issue-links'
|
|
5
5
|
import { refuseUnsupportedPriority, withoutUnsupportedPriority } from './priority'
|
|
6
|
+
import { refuseUnsupportedAssignees } from './assignees'
|
|
6
7
|
|
|
7
8
|
/** Sources without a capability cannot present that capability's fields. */
|
|
8
9
|
export function normalizeTicket(
|
|
@@ -10,8 +11,9 @@ export function normalizeTicket(
|
|
|
10
11
|
supported = true,
|
|
11
12
|
issueLinks = true,
|
|
12
13
|
priority = true,
|
|
14
|
+
assignees = true,
|
|
13
15
|
): Ticket {
|
|
14
|
-
const { target, issueLinks: links, priority: urgency, ...rest } = ticket
|
|
16
|
+
const { target, issueLinks: links, priority: urgency, assignees: assigned, ...rest } = ticket
|
|
15
17
|
return {
|
|
16
18
|
...rest,
|
|
17
19
|
kind: supported ? (ticket.kind ?? 'work') : 'work',
|
|
@@ -19,12 +21,19 @@ export function normalizeTicket(
|
|
|
19
21
|
...(issueLinks && links !== undefined ? { issueLinks: links } : {}),
|
|
20
22
|
// Normal is the absence of the field, so strict wire schemas never see it.
|
|
21
23
|
...(priority && urgency === 'urgent' ? { priority: urgency } : {}),
|
|
24
|
+
...(assignees && assigned !== undefined ? { assignees: assigned } : {}),
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/** Apply the source's own capabilities to a ticket it returned. */
|
|
26
29
|
export function normalizeSourceTicket(source: TicketSource, ticket: Ticket): Ticket {
|
|
27
|
-
return normalizeTicket(
|
|
30
|
+
return normalizeTicket(
|
|
31
|
+
ticket,
|
|
32
|
+
!!source.integrationTree,
|
|
33
|
+
!!source.issueLinks,
|
|
34
|
+
!!source.priority,
|
|
35
|
+
!!source.assignees,
|
|
36
|
+
)
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
export function refuseUnsupportedMetadata(
|
|
@@ -37,6 +46,7 @@ export function refuseUnsupportedMetadata(
|
|
|
37
46
|
)
|
|
38
47
|
refuseUnsupportedIssueLinks(source, patch)
|
|
39
48
|
refuseUnsupportedPriority(source, patch)
|
|
49
|
+
refuseUnsupportedAssignees(source, patch)
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
/** Validate before any part of a mixed patch is written. Canonical refs close alias cycles. */
|
|
@@ -3,6 +3,7 @@ import { expandIssues } from '../../zod-issues'
|
|
|
3
3
|
import type { TicketUpdate } from '../types'
|
|
4
4
|
import { issueLinksInputSchema, normalizeIssueLinks } from './issue-links'
|
|
5
5
|
import { ticketPrioritySchema } from './priority'
|
|
6
|
+
import { ticketAssigneesSchema } from './assignees'
|
|
6
7
|
|
|
7
8
|
const ticketUpdateSchema = z
|
|
8
9
|
.strictObject({
|
|
@@ -23,6 +24,7 @@ const ticketUpdateSchema = z
|
|
|
23
24
|
labels: z.array(z.string()).optional(),
|
|
24
25
|
issueLinks: issueLinksInputSchema.optional(),
|
|
25
26
|
priority: ticketPrioritySchema.optional(),
|
|
27
|
+
assignees: ticketAssigneesSchema.optional(),
|
|
26
28
|
})
|
|
27
29
|
.refine(
|
|
28
30
|
(patch) =>
|
|
@@ -32,8 +34,9 @@ const ticketUpdateSchema = z
|
|
|
32
34
|
patch.kind !== undefined ||
|
|
33
35
|
patch.target !== undefined ||
|
|
34
36
|
patch.issueLinks !== undefined ||
|
|
35
|
-
patch.priority !== undefined
|
|
36
|
-
|
|
37
|
+
patch.priority !== undefined ||
|
|
38
|
+
patch.assignees !== undefined,
|
|
39
|
+
'update must name at least one of title, body, labels, issue links, priority, assignees, kind, or target',
|
|
37
40
|
)
|
|
38
41
|
|
|
39
42
|
/** Render ticket-update issues while retaining nested union branch detail. */
|
|
@@ -70,5 +73,6 @@ export function validateTicketUpdate(patch: TicketUpdate): TicketUpdate {
|
|
|
70
73
|
? { issueLinks: normalizeIssueLinks(result.data.issueLinks) }
|
|
71
74
|
: {}),
|
|
72
75
|
...(result.data.priority !== undefined ? { priority: result.data.priority } : {}),
|
|
76
|
+
...(result.data.assignees !== undefined ? { assignees: [...result.data.assignees] } : {}),
|
|
73
77
|
}
|
|
74
78
|
}
|
|
@@ -96,6 +96,9 @@ export interface Ticket {
|
|
|
96
96
|
/** `urgent` dispatches before normal ready work. Absent means normal, or a
|
|
97
97
|
* source that cannot store priority. Normalized tickets never carry `normal`. */
|
|
98
98
|
priority?: TicketPriority
|
|
99
|
+
/** Usernames the ticket is assigned to. Present (possibly empty) only for
|
|
100
|
+
* sources with the `assignees` capability; not part of `revision`. */
|
|
101
|
+
assignees?: string[]
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
/** Dispatch class: urgent ready work is claimed before normal ready work. */
|
|
@@ -123,6 +126,7 @@ export interface TicketCriteria {
|
|
|
123
126
|
export interface TicketPage {
|
|
124
127
|
limit: number
|
|
125
128
|
offset?: number
|
|
129
|
+
/** Dispatch order or newest filed first; see `TicketSource.listPage`. */
|
|
126
130
|
order?: 'oldest' | 'newest'
|
|
127
131
|
}
|
|
128
132
|
|
|
@@ -156,6 +160,10 @@ export interface TicketDraft {
|
|
|
156
160
|
/** Dispatch class. A source without the `priority` capability refuses
|
|
157
161
|
* `urgent`; `normal` is a no-op. */
|
|
158
162
|
priority?: TicketPriority
|
|
163
|
+
/** Exact assignees: entries are usernames or `me` (the owner of the source's
|
|
164
|
+
* credential). Callers apply any `[tickets].createAssignee` default. A source
|
|
165
|
+
* without the `assignees` capability refuses, never discards. */
|
|
166
|
+
assignees?: string[]
|
|
159
167
|
}
|
|
160
168
|
|
|
161
169
|
/** One node of the dependency graph, as this source sees it. */
|
|
@@ -216,6 +224,10 @@ export interface TicketUpdate {
|
|
|
216
224
|
/** `normal` removes urgency. A source without the `priority` capability
|
|
217
225
|
* refuses `urgent`; `normal` is a no-op. */
|
|
218
226
|
priority?: TicketPriority
|
|
227
|
+
/** A complete assignee replacement; entries are usernames or `me`. An
|
|
228
|
+
* explicit empty array clears assignees. A source without the `assignees`
|
|
229
|
+
* capability refuses, never discards. */
|
|
230
|
+
assignees?: string[]
|
|
219
231
|
}
|
|
220
232
|
|
|
221
233
|
/** One workflow state of a source that can enumerate them. */
|
|
@@ -281,6 +293,20 @@ export interface TicketSource {
|
|
|
281
293
|
* boundary, including create and guarded writes. Sources without it read
|
|
282
294
|
* every ticket as normal and refuse any write naming `urgent`. */
|
|
283
295
|
readonly priority?: boolean
|
|
296
|
+
/** Opt in only when assignees are persisted, returned on every read (an
|
|
297
|
+
* empty array when unassigned) and verified at every write boundary,
|
|
298
|
+
* including create, keyed-create adoption and guarded writes; a write that
|
|
299
|
+
* the provider accepts without the requested assignees must fail. Sources
|
|
300
|
+
* without it refuse any write naming assignees and
|
|
301
|
+
* `[tickets].createAssignee`. */
|
|
302
|
+
readonly assignees?: boolean
|
|
303
|
+
/** Synchronous and request-free: why `[tickets].createAssignee` cannot be
|
|
304
|
+
* honoured given what `prepareReadyAssignee` resolved, or undefined.
|
|
305
|
+
* Checked at dispatcher startup and on every reload. */
|
|
306
|
+
createAssigneeRefusal?(value: string): string | undefined
|
|
307
|
+
/** `ab init --validate`: a one-line summary of who `[tickets].createAssignee`
|
|
308
|
+
* names; throws an actionable error when it names nobody assignable. */
|
|
309
|
+
describeCreateAssignee?(value: string): Promise<string>
|
|
284
310
|
/** Opt in only when `listReady` (and `listPage`, if implemented) honour
|
|
285
311
|
* `criteria.assignee` and an unassigned ticket is never ready while it is
|
|
286
312
|
* set. Sources without it refuse `[tickets].readyAssignee` at startup,
|
|
@@ -331,9 +357,13 @@ export interface TicketSource {
|
|
|
331
357
|
* actionable diagnostics for individual source records excluded as invalid.
|
|
332
358
|
* Fatal source failures and invariants still reject the call. */
|
|
333
359
|
listReady(criteria: TicketCriteria): Promise<TicketListing>
|
|
334
|
-
/** Optional native window
|
|
335
|
-
*
|
|
336
|
-
*
|
|
360
|
+
/** Optional native window over the listReady matches. `oldest` (default)
|
|
361
|
+
* is dispatch order: with `priority`, urgent first, then normal, each in
|
|
362
|
+
* listReady order. `newest` is newest filed first: creation time descending,
|
|
363
|
+
* independent of urgency, with a stable tie-break; it is not the reverse of
|
|
364
|
+
* dispatch order. Offset and limit apply after ordering. Default offset 0.
|
|
365
|
+
* Arguments are nonnegative integers; zero limit returns no tickets with the
|
|
366
|
+
* full matching total. Diagnostics
|
|
337
367
|
* and failures match listReady; a failure must not trigger a full-read fallback.
|
|
338
368
|
* listReady and listAll remain exhaustive. */
|
|
339
369
|
listPage?(criteria: TicketCriteria, page: TicketPage): Promise<TicketPageListing>
|
|
@@ -559,6 +589,10 @@ export interface WorkspaceProvider {
|
|
|
559
589
|
* branch head it covers must not be restored over the branch; report it
|
|
560
590
|
* in `restorationSkipped`. */
|
|
561
591
|
restorationReplaced?: string[]
|
|
592
|
+
/** Where the forge keeps `restoration` archive refs: `local` (local-git)
|
|
593
|
+
* means the repository already holds them and restoration must not
|
|
594
|
+
* consult a remote; `remote` means they may exist only on origin. */
|
|
595
|
+
restorationArchives?: 'local' | 'remote'
|
|
562
596
|
/** Immutable recovery checkpoint, never a moved base branch. */
|
|
563
597
|
revision?: string
|
|
564
598
|
/** 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
|
}
|
|
@@ -7,6 +7,7 @@ import { inspectGitCandidate, preserveGitCommits, restoreGitCommits } from './co
|
|
|
7
7
|
import { accountPolicy, accountGuestEnvironment } from './account-policy'
|
|
8
8
|
import { HOSTED_ACCOUNT_READINESS_ENV } from '../../accounts/hosted-readiness'
|
|
9
9
|
import { gitRewrite, parseRemoteHead } from '../forge/git-rewrite'
|
|
10
|
+
import { GITHUB_REQUIRE_CREDENTIAL_ENV } from '../forge/github-transport'
|
|
10
11
|
import { delegateCredential } from '../../store/remote/credentials'
|
|
11
12
|
import type { ExecutionLaunchAuth } from './build-execution'
|
|
12
13
|
import { createHash } from 'node:crypto'
|
|
@@ -1464,6 +1465,9 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1464
1465
|
generation?: number
|
|
1465
1466
|
restoration?: import('../types').WorkspacePreservationHead[]
|
|
1466
1467
|
restorationReplaced?: string[]
|
|
1468
|
+
/** Ignored: a sandbox clone never holds archive refs, so restoration here
|
|
1469
|
+
* always fetches each exact ref from origin, whatever the forge. */
|
|
1470
|
+
restorationArchives?: 'local' | 'remote'
|
|
1467
1471
|
}): Promise<WorkspaceProvisionResult> {
|
|
1468
1472
|
const scopedToken = await (this.options.delegateCredential ?? delegateCredential)(
|
|
1469
1473
|
this.options.storeRef,
|
|
@@ -1907,6 +1911,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1907
1911
|
}),
|
|
1908
1912
|
}
|
|
1909
1913
|
Object.assign(env, this.guestEnvironment())
|
|
1914
|
+
// Guests hold no forge credential: their GitHub API requests fail typed
|
|
1915
|
+
// instead of going out anonymously. Applied last so no forwarded value
|
|
1916
|
+
// can disable it.
|
|
1917
|
+
env[GITHUB_REQUIRE_CREDENTIAL_ENV] = '1'
|
|
1910
1918
|
const command = (await sandbox.runCommand({
|
|
1911
1919
|
cmd: 'sh',
|
|
1912
1920
|
args: [
|
|
@@ -2231,6 +2239,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2231
2239
|
[HARVEST_RUNNER_OPTIONS_ENV]: JSON.stringify(envelope),
|
|
2232
2240
|
}
|
|
2233
2241
|
Object.assign(env, this.guestEnvironment())
|
|
2242
|
+
// Guests hold no forge credential: their GitHub API requests fail typed
|
|
2243
|
+
// instead of going out anonymously. Applied last so no forwarded value
|
|
2244
|
+
// can disable it.
|
|
2245
|
+
env[GITHUB_REQUIRE_CREDENTIAL_ENV] = '1'
|
|
2234
2246
|
const command = (await sandbox.runCommand({
|
|
2235
2247
|
cmd: 'sh',
|
|
2236
2248
|
args: [
|
|
@@ -5,6 +5,8 @@ import { isRemoteWorkspace } from '../events/workspace-remote'
|
|
|
5
5
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
6
6
|
import { hostname } from 'node:os'
|
|
7
7
|
import { createForge } from '../ports/forge/create'
|
|
8
|
+
import { GITHUB_REQUIRE_CREDENTIAL_ENV } from '../ports/forge/github-transport'
|
|
9
|
+
import { withWorkspaceAncestry } from '../ports/forge/workspace-ancestry'
|
|
8
10
|
import { createProductionRuntimes } from '../ports/runner/production'
|
|
9
11
|
import { spawnExec } from '../ports/workspace/git-worktree'
|
|
10
12
|
import { loadPlugins } from '../plugins/load'
|
|
@@ -67,14 +69,30 @@ export async function runBuildChild(
|
|
|
67
69
|
repoRoot: workspace.path ?? workspace.ref,
|
|
68
70
|
env,
|
|
69
71
|
})
|
|
72
|
+
const workspaceRemote = opts.guest === true || isRemoteWorkspace(workspace)
|
|
73
|
+
const created = await createForge({
|
|
74
|
+
name: currentConfig.forge,
|
|
75
|
+
registry: plugins,
|
|
76
|
+
env,
|
|
77
|
+
repoRoot: workspace.path ?? workspace.ref,
|
|
78
|
+
})
|
|
79
|
+
// A remote guest holds no forge credential: ancestry proofs run through the
|
|
80
|
+
// workspace's own Git read channel instead of an anonymous API request.
|
|
81
|
+
// The runner's limits are its own; only the dispatcher pauses the repository.
|
|
70
82
|
const forge = guardForge(
|
|
71
|
-
|
|
83
|
+
workspaceRemote
|
|
84
|
+
? withWorkspaceAncestry(created, {
|
|
85
|
+
exec: spawnExec,
|
|
86
|
+
workspacePath: workspace.path ?? workspace.ref,
|
|
87
|
+
})
|
|
88
|
+
: created,
|
|
89
|
+
{
|
|
90
|
+
store: fullStore,
|
|
91
|
+
repo: record.repo,
|
|
72
92
|
name: currentConfig.forge,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}),
|
|
77
|
-
{ store: fullStore, repo: record.repo, name: currentConfig.forge, wait: true },
|
|
93
|
+
wait: true,
|
|
94
|
+
scope: { process: `build-runner ${input.slug}` },
|
|
95
|
+
},
|
|
78
96
|
)
|
|
79
97
|
const getConfig = async () => {
|
|
80
98
|
const latest = await store.getArtifact(input.slug, BUILD_EFFECTIVE_CONFIG_ARTIFACT)
|
|
@@ -99,7 +117,7 @@ export async function runBuildChild(
|
|
|
99
117
|
runtimes,
|
|
100
118
|
workspacePath: workspace.path ?? workspace.ref,
|
|
101
119
|
workspaceProvider: workspace.provider,
|
|
102
|
-
workspaceRemote
|
|
120
|
+
workspaceRemote,
|
|
103
121
|
shutdownSignal: opts.shutdownSignal,
|
|
104
122
|
branch: workspace.branch,
|
|
105
123
|
slug: input.slug,
|
|
@@ -112,6 +130,9 @@ export async function runBuildChild(
|
|
|
112
130
|
sessionEnv: {
|
|
113
131
|
AB_STORE: input.storeRef,
|
|
114
132
|
...(env.AB_TOKEN !== undefined && env.AB_TOKEN !== '' ? { AB_TOKEN: env.AB_TOKEN } : {}),
|
|
133
|
+
...(env[GITHUB_REQUIRE_CREDENTIAL_ENV] === '1'
|
|
134
|
+
? { [GITHUB_REQUIRE_CREDENTIAL_ENV]: '1' }
|
|
135
|
+
: {}),
|
|
115
136
|
},
|
|
116
137
|
})
|
|
117
138
|
await runner.run()
|
|
@@ -20,9 +20,12 @@ export interface BuildRunnerDiagnostic {
|
|
|
20
20
|
|
|
21
21
|
/** JSON form of the normalized config's strict declarative input shape. */
|
|
22
22
|
export function effectiveBuildConfigContent(config: Config): string {
|
|
23
|
-
const { verify, finalize, ...root } = config
|
|
23
|
+
const { verify, finalize, profiles, ...root } = config
|
|
24
24
|
return JSON.stringify({
|
|
25
25
|
...root,
|
|
26
|
+
// Omitted when empty so repositories without profiles keep byte-identical
|
|
27
|
+
// artifacts that an older client's strict root parse still accepts.
|
|
28
|
+
...(profiles !== undefined && Object.keys(profiles).length > 0 ? { profiles } : {}),
|
|
26
29
|
verify: {
|
|
27
30
|
steps: verify.stages ?? verify.steps,
|
|
28
31
|
afterReconcile: verify.afterReconcile,
|
|
@@ -787,6 +787,8 @@ export class BuildRunner {
|
|
|
787
787
|
|
|
788
788
|
private async startBracket(write: EventWrite<'session.started'>) {
|
|
789
789
|
const { store, slug } = this.deps
|
|
790
|
+
if (this.boundaryProfile !== undefined)
|
|
791
|
+
write = { ...write, payload: { ...write.payload, profile: { ...this.boundaryProfile } } }
|
|
790
792
|
const old = this.recovery
|
|
791
793
|
const budgetMs = this.resolveSessionRole(write.payload.role).sessionBudgetSeconds * 1000
|
|
792
794
|
if (
|
|
@@ -941,6 +943,8 @@ export class BuildRunner {
|
|
|
941
943
|
* consults the mutable owner again. */
|
|
942
944
|
private boundaryConfig: Config
|
|
943
945
|
private boundaryResolver: RuntimeResolver
|
|
946
|
+
/** The build's profile and whether the boundary config still defines it. */
|
|
947
|
+
private boundaryProfile: { name: string; configured: boolean } | undefined
|
|
944
948
|
|
|
945
949
|
constructor(private readonly deps: BuildRunnerDeps) {
|
|
946
950
|
const redactor = accountRedactor(
|
|
@@ -979,12 +983,22 @@ export class BuildRunner {
|
|
|
979
983
|
const state = (await readBuildFacts(this.deps.store, this.deps.slug)).value.state
|
|
980
984
|
const config = await capturedBuildConfig(this.deps.store, this.deps.slug, state, deployment)
|
|
981
985
|
this.boundaryConfig = config
|
|
982
|
-
|
|
986
|
+
const base = createRuntimeResolver(
|
|
983
987
|
this.deps.runtimes,
|
|
984
988
|
config.roles,
|
|
985
989
|
config.policy.sessionBudgetSeconds,
|
|
986
990
|
config.accounts,
|
|
991
|
+
config.profiles,
|
|
987
992
|
)
|
|
993
|
+
// The build's profile was fixed at claim; its contents come from the
|
|
994
|
+
// boundary-current config. A profile a reload removed falls back to the
|
|
995
|
+
// repository roles, and the next session.started records that.
|
|
996
|
+
const profile = state.profile === undefined ? undefined : base.profile(state.profile.name)
|
|
997
|
+
this.boundaryResolver = profile ?? base
|
|
998
|
+
this.boundaryProfile =
|
|
999
|
+
state.profile === undefined
|
|
1000
|
+
? undefined
|
|
1001
|
+
: { name: state.profile.name, configured: profile !== undefined }
|
|
988
1002
|
return config
|
|
989
1003
|
}
|
|
990
1004
|
|
|
@@ -1154,7 +1168,8 @@ export class BuildRunner {
|
|
|
1154
1168
|
}
|
|
1155
1169
|
const currentFailure = state.setupFailure
|
|
1156
1170
|
const openSetupEscalation = state.openEscalations.some(
|
|
1157
|
-
(escalation) =>
|
|
1171
|
+
(escalation) =>
|
|
1172
|
+
escalation.phase === 'setup' && escalation.source === 'policy' && !escalation.janitor,
|
|
1158
1173
|
)
|
|
1159
1174
|
const streak = await readBuildSelector(store, slug, 'setupStreak')
|
|
1160
1175
|
|