@defrex/autobuild 1.0.1 → 1.2.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 +10 -18
- package/SPEC.md +499 -238
- package/bin/ab-dispatch-generation.ts +11 -2
- package/docs/accounts.md +119 -0
- package/docs/agent-runtimes.md +4 -4
- package/docs/answering-blocked-builds.md +2 -2
- package/docs/architecture.md +262 -53
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +3 -41
- package/docs/builds.md +4 -4
- package/docs/cli.md +18 -4
- package/docs/configuration-overview.md +115 -4
- package/docs/configuration.md +488 -334
- package/docs/dispatcher-hosting.md +19 -34
- package/docs/dispatcher.md +1 -1
- package/docs/forges.md +5 -5
- package/docs/getting-started.md +2 -2
- package/docs/glossary.md +6 -6
- package/docs/intake.md +2 -0
- package/docs/integration-overview.md +15 -15
- package/docs/integration-tree.md +45 -38
- package/docs/integration.md +6 -6
- package/{skills/guide/references/landing-policy.md → docs/merge-policy.md} +40 -24
- package/docs/migration-1.0.md +17 -13
- package/docs/operating.md +41 -19
- package/docs/operator-api.md +180 -51
- package/docs/operator-surfaces.md +5 -18
- package/docs/overview.md +3 -3
- package/docs/plugin-authoring.md +21 -0
- package/docs/remote-store-protocol.md +242 -68
- package/docs/remote-ticket-protocol.md +30 -50
- package/docs/restacking.md +54 -15
- package/docs/seams.md +8 -8
- package/docs/setup.md +59 -119
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +6 -6
- package/docs/ticket-dependencies.md +7 -7
- package/docs/ticket-sources.md +18 -0
- package/docs/tickets.md +8 -2
- package/docs/troubleshooting.md +8 -12
- package/docs/upgrading.md +9 -4
- package/docs/verification.md +60 -14
- package/docs/workspaces.md +4 -4
- package/package.json +17 -6
- package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
- package/packages/core/src/accounts/chatgpt-state.ts +41 -0
- package/packages/core/src/accounts/local-credentials.ts +194 -0
- package/packages/core/src/accounts/local-inference.ts +106 -0
- package/packages/core/src/accounts/local-owner.ts +123 -0
- package/packages/core/src/accounts/sensitive.ts +2 -0
- package/packages/core/src/cli/accounts.ts +147 -0
- package/packages/core/src/cli/binary-direct.ts +13 -1
- package/packages/core/src/cli/binary-lifecycle.ts +65 -2
- package/packages/core/src/cli/binary.ts +3 -1
- package/packages/core/src/cli/build-control.ts +83 -28
- package/packages/core/src/cli/connect.ts +3 -3
- package/packages/core/src/cli/context.ts +81 -38
- package/packages/core/src/cli/dashboard/facts.ts +2 -1
- package/packages/core/src/cli/dashboard/integration-detail.ts +8 -8
- package/packages/core/src/cli/dashboard/integration-row.ts +40 -13
- package/packages/core/src/cli/dashboard/landing-display.ts +25 -0
- package/packages/core/src/cli/dashboard/model.ts +56 -33
- package/packages/core/src/cli/dashboard/poll.ts +9 -3
- package/packages/core/src/cli/dashboard/render.ts +59 -37
- package/packages/core/src/cli/dashboard/target-distance.ts +14 -0
- package/packages/core/src/cli/dashboard/tree.ts +3 -2
- package/packages/core/src/cli/dispatch-args.ts +1 -1
- package/packages/core/src/cli/dispatch-frontend.ts +6 -3
- package/packages/core/src/cli/dispatch-handoff.ts +125 -44
- package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
- package/packages/core/src/cli/dispatch-launcher.ts +54 -21
- package/packages/core/src/cli/dispatch-preflight.ts +6 -1
- package/packages/core/src/cli/dispatch.ts +106 -11
- package/packages/core/src/cli/env.ts +4 -0
- package/packages/core/src/cli/help.ts +46 -23
- package/packages/core/src/cli/init-readiness-remote.ts +22 -1
- package/packages/core/src/cli/init-readiness-shared.ts +5 -1
- package/packages/core/src/cli/init-validation.ts +160 -18
- package/packages/core/src/cli/main.ts +68 -8
- package/packages/core/src/cli/node-verification-provenance.ts +1 -97
- package/packages/core/src/cli/publication-settlement.ts +47 -21
- package/packages/core/src/cli/repository-status.ts +20 -9
- package/packages/core/src/cli/secrets.ts +173 -0
- package/packages/core/src/cli/status.ts +42 -5
- package/packages/core/src/cli/store-opening.ts +17 -2
- package/packages/core/src/cli/terminal.ts +22 -1
- package/packages/core/src/cli/terminals.ts +14 -10
- package/packages/core/src/cli/upgrade-agent.ts +9 -1
- package/packages/core/src/cli/upgrade-landing.ts +70 -30
- package/packages/core/src/cli/upgrade.ts +3 -1
- package/packages/core/src/cli/wait.ts +15 -7
- package/packages/core/src/cli/watch-lifetime.ts +111 -0
- package/packages/core/src/cli/watch.ts +635 -510
- package/packages/core/src/config/accounts.ts +101 -0
- package/packages/core/src/config/effective-artifact.fixture.ts +27 -0
- package/packages/core/src/config/effective-artifact.ts +13 -0
- package/packages/core/src/config/landing.ts +1 -1
- package/packages/core/src/config/live.ts +14 -1
- package/packages/core/src/config/load.ts +21 -1
- package/packages/core/src/config/pipeline-source.ts +28 -0
- package/packages/core/src/config/reference-metadata.ts +2 -0
- package/packages/core/src/config/reference.ts +22 -7
- package/packages/core/src/config/roles.ts +54 -3
- package/packages/core/src/config/schema.ts +146 -162
- package/packages/core/src/context-directory.ts +26 -0
- package/packages/core/src/distribution-packaging.ts +26 -5
- package/packages/core/src/events/catalog.ts +10 -2
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/globs.ts +1 -1
- package/packages/core/src/events/payloads.ts +73 -1
- package/packages/core/src/events/policy.ts +7 -0
- package/packages/core/src/events/repository.ts +4 -4
- package/packages/core/src/events/sessions.ts +6 -6
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +574 -0
- package/packages/core/src/kernel/auto-merge.ts +2 -2
- package/packages/core/src/kernel/engine.ts +255 -26
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +10 -0
- package/packages/core/src/kernel/integration-landing.ts +3 -3
- package/packages/core/src/kernel/integration-state.ts +27 -4
- package/packages/core/src/kernel/leaf-restack-state.ts +28 -3
- package/packages/core/src/kernel/log-index.ts +13 -1
- package/packages/core/src/kernel/node-landing.ts +8 -8
- package/packages/core/src/kernel/node-parent.ts +2 -2
- package/packages/core/src/kernel/node-restack-transaction.ts +1 -1
- package/packages/core/src/kernel/node-verification-context.ts +216 -0
- package/packages/core/src/kernel/phases.ts +1 -1
- package/packages/core/src/kernel/plan-verify-selection.ts +16 -0
- package/packages/core/src/kernel/publication-retry.ts +168 -0
- package/packages/core/src/kernel/reconcile-restack.ts +29 -1
- package/packages/core/src/kernel/reducer.ts +85 -5
- package/packages/core/src/kernel/target-distance.ts +45 -0
- package/packages/core/src/kernel/terminal-guard.ts +10 -1
- package/packages/core/src/kernel/verify-stage-state.ts +123 -0
- package/packages/core/src/kernel/verify-stages.ts +39 -0
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +1 -1
- package/packages/core/src/operator/index.ts +3 -7
- package/packages/core/src/operator/landings.ts +5 -1
- package/packages/core/src/operator/presentation.ts +6 -1
- package/packages/core/src/operator/protocol.ts +6 -0
- package/packages/core/src/operator/query.ts +14 -18
- package/packages/core/src/operator/registry.ts +39 -7
- package/packages/core/src/operator/sandbox-host.ts +64 -40
- package/packages/core/src/operator/sandbox.ts +3 -0
- package/packages/core/src/operator/ticket-source-backend.ts +3 -12
- package/packages/core/src/operator/tickets.ts +25 -4
- package/packages/core/src/plugins/manifest.ts +2 -1
- package/packages/core/src/ports/forge/contract.ts +2 -2
- package/packages/core/src/ports/forge/git-rewrite.ts +25 -2
- package/packages/core/src/ports/forge/github-readiness.ts +2 -2
- package/packages/core/src/ports/forge/github.ts +26 -7
- package/packages/core/src/ports/forge/local-git.ts +4 -4
- package/packages/core/src/ports/forge/readiness.ts +1 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/account-env.ts +88 -0
- package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
- package/packages/core/src/ports/runner/claude.ts +26 -2
- package/packages/core/src/ports/runner/codex.ts +63 -31
- package/packages/core/src/ports/runner/one-shot.ts +2 -0
- package/packages/core/src/ports/runner/provider-error.ts +5 -0
- package/packages/core/src/ports/runner/routing.ts +35 -4
- package/packages/core/src/ports/tickets/contract.ts +58 -0
- package/packages/core/src/ports/tickets/tree.ts +1 -1
- package/packages/core/src/ports/types.ts +28 -7
- package/packages/core/src/ports/workspace/account-policy.ts +72 -0
- package/packages/core/src/ports/workspace/build-execution.ts +9 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
- package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +182 -72
- package/packages/core/src/processes/build-child.ts +6 -8
- package/packages/core/src/processes/build-execution-state.ts +8 -5
- package/packages/core/src/processes/build-runner.ts +554 -99
- package/packages/core/src/processes/dispatcher.ts +209 -101
- package/packages/core/src/processes/execution-no-progress.ts +8 -1
- package/packages/core/src/processes/execution-settlement.ts +21 -3
- package/packages/core/src/processes/harvest-runner.ts +68 -8
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-loss.ts +8 -2
- package/packages/core/src/processes/publication-state.ts +42 -4
- package/packages/core/src/processes/repo-view.ts +14 -0
- package/packages/core/src/processes/verify-cycle-config.ts +96 -0
- package/packages/core/src/project-secrets.ts +105 -0
- package/packages/core/src/{integration → scenarios}/harness.ts +330 -317
- package/packages/core/src/secret-name.ts +41 -0
- package/packages/core/src/store/account-redaction.ts +156 -0
- package/packages/core/src/store/adapter.ts +1 -0
- package/packages/core/src/store/build-scope.ts +9 -0
- package/packages/core/src/store/contract.ts +116 -2
- package/packages/core/src/store/local/schema.ts +13 -0
- package/packages/core/src/store/local/store.ts +42 -0
- package/packages/core/src/store/memory.ts +47 -0
- package/packages/core/src/store/operator-presence.ts +21 -0
- package/packages/core/src/store/phase-session.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +5185 -4156
- package/packages/core/src/store/remote/client.ts +89 -48
- package/packages/core/src/store/remote/compatibility.ts +20 -0
- package/packages/core/src/store/remote/protocol.ts +4 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/retention.ts +2 -3
- package/packages/core/src/store/session-handle.ts +9 -0
- package/packages/core/src/store/streams/session-writer.ts +1 -1
- package/packages/core/src/store/types.ts +12 -2
- package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
- package/packages/core/src/testing/index.ts +12 -1
- package/packages/core/src/testing/reduced-read-budget.ts +47 -0
- package/packages/core/src/testing/temp-directories.ts +58 -0
- package/skills/code-review/SKILL.md +23 -9
- package/skills/finalize/SKILL.md +15 -7
- package/skills/guide/SKILL.md +373 -148
- package/skills/guide/references/accounts.md +119 -0
- package/skills/guide/references/integration-tree.md +45 -38
- package/{docs/landing-policy.md → skills/guide/references/merge-policy.md} +40 -24
- package/skills/guide/references/migration-1.0.md +17 -13
- package/skills/guide/references/operator-api.md +180 -51
- package/skills/guide/references/plugin-authoring.md +21 -0
- package/skills/guide/references/remote-store-protocol.md +242 -68
- package/skills/guide/references/remote-ticket-protocol.md +30 -50
- package/skills/guide/references/restacking.md +54 -15
- package/skills/guide/references/setup.md +59 -119
- package/skills/guide/references/spec-standard.md +6 -6
- package/skills/guide/references/ticket-dependencies.md +7 -7
- package/skills/harvest/SKILL.md +3 -1
- package/skills/harvest-review/SKILL.md +3 -1
- package/skills/implement/SKILL.md +43 -17
- package/skills/operate/SKILL.md +118 -118
- package/skills/plan/SKILL.md +39 -13
- package/skills/plan-review/SKILL.md +15 -10
- package/skills/reconcile/SKILL.md +22 -3
- package/skills/spec/SKILL.md +20 -20
- package/skills/tickets/SKILL.md +12 -9
- package/templates/autobuild.toml +1 -1
- package/templates/hosted-service/package.json +2 -2
- package/docs/hosted-dispatcher-cutover-validation.md +0 -178
- package/docs/hosted-dispatcher.md +0 -275
- package/docs/hosted-service.md +0 -293
- package/docs/mcp.md +0 -149
- package/packages/core/src/orchestrator/approvals.ts +0 -115
- package/packages/core/src/orchestrator/conversation.ts +0 -167
- package/packages/core/src/orchestrator/model.ts +0 -86
- package/packages/core/src/orchestrator/prompt.ts +0 -63
- package/packages/core/src/orchestrator/tools.ts +0 -117
- package/packages/core/src/orchestrator/turn-runner.ts +0 -457
- package/packages/core/src/processes/orchestrator-tick.ts +0 -360
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { accountPolicy, accountGuestEnvironment } from './account-policy'
|
|
1
2
|
import { gitRewrite, parseRemoteHead } from '../forge/git-rewrite'
|
|
2
3
|
import { delegateCredential } from '../../store/remote/credentials'
|
|
3
4
|
import type { ExecutionLaunchAuth } from './build-execution'
|
|
@@ -741,6 +742,7 @@ async function preflightBun(sandbox: VercelSandboxHandle, image: string): Promis
|
|
|
741
742
|
}
|
|
742
743
|
|
|
743
744
|
export interface VercelReadinessOptions {
|
|
745
|
+
accounts?: import('../../config/accounts').Accounts
|
|
744
746
|
config: VercelSandboxConfig
|
|
745
747
|
env: Record<string, string | undefined>
|
|
746
748
|
storeRef: string
|
|
@@ -838,6 +840,9 @@ export async function validateVercelSandbox(
|
|
|
838
840
|
if (facade.createFresh === undefined) {
|
|
839
841
|
throw new Error('the configured Vercel SDK facade does not support fresh validation sandboxes')
|
|
840
842
|
}
|
|
843
|
+
const readinessAccountPolicy = accountPolicy('allow-all', options.accounts ?? {}, options.env)
|
|
844
|
+
if (readinessAccountPolicy.missing.length)
|
|
845
|
+
throw new Error(`Missing credentials: ${readinessAccountPolicy.missing.join('; ')}`)
|
|
841
846
|
const sandbox = await facade.createFresh({
|
|
842
847
|
source: {
|
|
843
848
|
type: 'git',
|
|
@@ -853,7 +858,7 @@ export async function validateVercelSandbox(
|
|
|
853
858
|
...(config.snapshotExpirationSeconds === undefined
|
|
854
859
|
? {}
|
|
855
860
|
: { snapshotExpiration: config.snapshotExpirationSeconds * 1000 }),
|
|
856
|
-
networkPolicy:
|
|
861
|
+
networkPolicy: readinessAccountPolicy.policy,
|
|
857
862
|
keepLastSnapshots: { count: VERCEL_KEEP_LAST_SNAPSHOTS, deleteEvicted: true },
|
|
858
863
|
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
859
864
|
})
|
|
@@ -930,7 +935,11 @@ export async function validateVercelSandbox(
|
|
|
930
935
|
await bootstrapRuntimes(
|
|
931
936
|
sandbox,
|
|
932
937
|
config,
|
|
933
|
-
|
|
938
|
+
accountGuestEnvironment(
|
|
939
|
+
runtimeEnvironment(config, options.env),
|
|
940
|
+
options.accounts ?? {},
|
|
941
|
+
options.env,
|
|
942
|
+
),
|
|
934
943
|
options.runtimeReferences ?? [],
|
|
935
944
|
true,
|
|
936
945
|
options.signal,
|
|
@@ -944,13 +953,18 @@ export async function validateVercelSandbox(
|
|
|
944
953
|
`PATH=${VERCEL_BUN_BIN_PATH}:$PATH exec ${VERCEL_BUN_EXECUTABLE} ${VERCEL_AUTOBUILD_PATH}/bin/ab-init-probe.ts`,
|
|
945
954
|
],
|
|
946
955
|
cwd: VERCEL_WORKSPACE_PATH,
|
|
947
|
-
env:
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
.
|
|
952
|
-
|
|
953
|
-
|
|
956
|
+
env: {
|
|
957
|
+
...accountGuestEnvironment(
|
|
958
|
+
runtimeEnvironment(config, options.env),
|
|
959
|
+
options.accounts ?? {},
|
|
960
|
+
options.env,
|
|
961
|
+
),
|
|
962
|
+
AB_STORE: options.storeRef,
|
|
963
|
+
AB_TOKEN: options.storeToken,
|
|
964
|
+
...(options.env.AB_CHATGPT_HOSTED_READINESS
|
|
965
|
+
? { AB_CHATGPT_HOSTED_READINESS: options.env.AB_CHATGPT_HOSTED_READINESS }
|
|
966
|
+
: {}),
|
|
967
|
+
},
|
|
954
968
|
}),
|
|
955
969
|
)
|
|
956
970
|
readiness = {
|
|
@@ -1122,6 +1136,7 @@ export interface VercelSandboxProviderOptions {
|
|
|
1122
1136
|
facade?: VercelSandboxFacade
|
|
1123
1137
|
exec?: Exec
|
|
1124
1138
|
packageArchive?: () => Promise<Uint8Array>
|
|
1139
|
+
accounts?: () => import('../../config/accounts').Accounts
|
|
1125
1140
|
runtimeReferences?: RuntimeReferencesSource
|
|
1126
1141
|
/** Checkout-less seam: the repository's HTTPS GitHub origin. Default reads
|
|
1127
1142
|
* `git remote get-url origin` from `repo` on the host. */
|
|
@@ -1168,6 +1183,25 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1168
1183
|
private readonly facade: VercelSandboxFacade
|
|
1169
1184
|
private readonly exec: Exec
|
|
1170
1185
|
private readonly active = new Set<string>()
|
|
1186
|
+
private readonly policyLocks = new Map<string, Promise<void>>()
|
|
1187
|
+
|
|
1188
|
+
private async withPolicyLock<T>(ref: string, action: () => Promise<T>): Promise<T> {
|
|
1189
|
+
const previous = this.policyLocks.get(ref) ?? Promise.resolve()
|
|
1190
|
+
let release!: () => void
|
|
1191
|
+
const held = new Promise<void>((resolve) => {
|
|
1192
|
+
release = resolve
|
|
1193
|
+
})
|
|
1194
|
+
const queued = previous.then(() => held)
|
|
1195
|
+
this.policyLocks.set(ref, queued)
|
|
1196
|
+
await previous
|
|
1197
|
+
try {
|
|
1198
|
+
return await action()
|
|
1199
|
+
} finally {
|
|
1200
|
+
release()
|
|
1201
|
+
if (this.policyLocks.get(ref) === queued) this.policyLocks.delete(ref)
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1171
1205
|
/** A failed stop leaves execution state unknown until a later stop/delete succeeds. */
|
|
1172
1206
|
private readonly uncertain = new Set<string>()
|
|
1173
1207
|
private readonly origins = new Map<string, ReturnType<typeof cleanGithubOrigin>>()
|
|
@@ -1204,11 +1238,13 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1204
1238
|
this.observeWaitMs = options.observeWaitMs ?? VERCEL_OBSERVE_WAIT_MS
|
|
1205
1239
|
this.buildExecution = {
|
|
1206
1240
|
start: (input, auth) => this.start(input, auth),
|
|
1207
|
-
observe: (identity) =>
|
|
1241
|
+
observe: (identity) =>
|
|
1242
|
+
this.withPolicyLock(identity.workspaceRef, () => this.observeExecution(identity)),
|
|
1208
1243
|
}
|
|
1209
1244
|
this.harvestExecution = {
|
|
1210
1245
|
start: (input, auth) => this.startHarvestExecution(input, auth),
|
|
1211
|
-
observe: (identity) =>
|
|
1246
|
+
observe: (identity) =>
|
|
1247
|
+
this.withPolicyLock(identity.workspaceRef, () => this.observeExecution(identity)),
|
|
1212
1248
|
}
|
|
1213
1249
|
this.orchestratorSandbox = {
|
|
1214
1250
|
describe: (input) => this.describeOperatorSandbox(input),
|
|
@@ -1233,9 +1269,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1233
1269
|
}
|
|
1234
1270
|
this.publication = {
|
|
1235
1271
|
rewrite: (input: Parameters<NonNullable<WorkspacePublication['rewrite']>>[0]) =>
|
|
1236
|
-
this.publish(input),
|
|
1272
|
+
this.withPolicyLock(input.ref, () => this.publish(input)),
|
|
1237
1273
|
isPublished: (input: { sha: string; branch: string }) => this.isPublished(input),
|
|
1238
|
-
publish: (input: { ref: string; sha: string; branch: string }) =>
|
|
1274
|
+
publish: (input: { ref: string; sha: string; branch: string }) =>
|
|
1275
|
+
this.withPolicyLock(input.ref, () => this.publish(input)),
|
|
1239
1276
|
}
|
|
1240
1277
|
// The operator-sandbox publication path reuses the SAME capability: its
|
|
1241
1278
|
// publish pushes an exact sha from any sandbox ref, including an operator
|
|
@@ -1353,7 +1390,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1353
1390
|
...(this.options.config.snapshotExpirationSeconds === undefined
|
|
1354
1391
|
? {}
|
|
1355
1392
|
: { snapshotExpiration: this.options.config.snapshotExpirationSeconds * 1000 }),
|
|
1356
|
-
networkPolicy: uploadPackPolicy(origin, readAuth),
|
|
1393
|
+
networkPolicy: this.billingPolicy(uploadPackPolicy(origin, readAuth)),
|
|
1357
1394
|
keepLastSnapshots: { count: VERCEL_KEEP_LAST_SNAPSHOTS, deleteEvicted: true },
|
|
1358
1395
|
signal: this.operationSignal(),
|
|
1359
1396
|
})
|
|
@@ -1400,7 +1437,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1400
1437
|
await bootstrapRuntimes(
|
|
1401
1438
|
sandbox,
|
|
1402
1439
|
this.options.config,
|
|
1403
|
-
{ ...
|
|
1440
|
+
{ ...this.guestEnvironment(), AB_TOKEN: scopedToken },
|
|
1404
1441
|
currentRuntimeReferences(this.options.runtimeReferences),
|
|
1405
1442
|
true,
|
|
1406
1443
|
)
|
|
@@ -1519,6 +1556,21 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1519
1556
|
this.origins.delete(ref)
|
|
1520
1557
|
}
|
|
1521
1558
|
|
|
1559
|
+
private guestEnvironment(): Record<string, string> {
|
|
1560
|
+
return accountGuestEnvironment(
|
|
1561
|
+
runtimeEnvironment(this.options.config, this.options.env),
|
|
1562
|
+
this.options.accounts?.() ?? {},
|
|
1563
|
+
this.options.env,
|
|
1564
|
+
)
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
private billingPolicy(base: NetworkPolicy, ref?: string): NetworkPolicy {
|
|
1568
|
+
if (ref?.startsWith('autobuild-sandbox-')) return base
|
|
1569
|
+
const result = accountPolicy(base, this.options.accounts?.() ?? {}, this.options.env)
|
|
1570
|
+
if (result.missing.length) throw new Error(`Missing credentials: ${result.missing.join('; ')}`)
|
|
1571
|
+
return result.policy
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1522
1574
|
private async normalNetworkPolicy(ref: string): Promise<{
|
|
1523
1575
|
origin: ReturnType<typeof cleanGithubOrigin>
|
|
1524
1576
|
policy: NetworkPolicy
|
|
@@ -1527,11 +1579,14 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1527
1579
|
this.origins.set(ref, origin)
|
|
1528
1580
|
return {
|
|
1529
1581
|
origin,
|
|
1530
|
-
policy:
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1582
|
+
policy: this.billingPolicy(
|
|
1583
|
+
uploadPackPolicy(
|
|
1584
|
+
origin,
|
|
1585
|
+
this.options.config.gitPasswordEnv === undefined
|
|
1586
|
+
? undefined
|
|
1587
|
+
: `Basic ${Buffer.from(`${requireVercelEnvironmentValue(this.options.env, this.options.config.gitUsernameEnv!)}:${requireVercelEnvironmentValue(this.options.env, this.options.config.gitPasswordEnv)}`).toString('base64')}`,
|
|
1588
|
+
),
|
|
1589
|
+
ref,
|
|
1535
1590
|
),
|
|
1536
1591
|
}
|
|
1537
1592
|
}
|
|
@@ -1591,7 +1646,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1591
1646
|
await bootstrapRuntimes(
|
|
1592
1647
|
sandbox,
|
|
1593
1648
|
this.options.config,
|
|
1594
|
-
{ ...
|
|
1649
|
+
{ ...this.guestEnvironment(), AB_TOKEN: scopedToken },
|
|
1595
1650
|
currentRuntimeReferences(this.options.runtimeReferences),
|
|
1596
1651
|
false,
|
|
1597
1652
|
)
|
|
@@ -1604,9 +1659,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1604
1659
|
supervision: { kind: 'environment' },
|
|
1605
1660
|
}),
|
|
1606
1661
|
}
|
|
1607
|
-
|
|
1608
|
-
if (!['AB_TOKEN', 'AB_TICKET_URL', 'AB_TICKET_TOKEN'].includes(name))
|
|
1609
|
-
env[name] = requireVercelEnvironmentValue(this.options.env, name)
|
|
1662
|
+
Object.assign(env, this.guestEnvironment())
|
|
1610
1663
|
const command = (await sandbox.runCommand({
|
|
1611
1664
|
cmd: 'sh',
|
|
1612
1665
|
args: [
|
|
@@ -1814,7 +1867,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1814
1867
|
...(this.options.config.snapshotExpirationSeconds === undefined
|
|
1815
1868
|
? {}
|
|
1816
1869
|
: { snapshotExpiration: this.options.config.snapshotExpirationSeconds * 1000 }),
|
|
1817
|
-
networkPolicy: uploadPackPolicy(origin, readAuth),
|
|
1870
|
+
networkPolicy: this.billingPolicy(uploadPackPolicy(origin, readAuth)),
|
|
1818
1871
|
keepLastSnapshots: { count: VERCEL_KEEP_LAST_SNAPSHOTS, deleteEvicted: true },
|
|
1819
1872
|
signal: this.operationSignal(),
|
|
1820
1873
|
})
|
|
@@ -1855,7 +1908,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1855
1908
|
await bootstrapRuntimes(
|
|
1856
1909
|
sandbox,
|
|
1857
1910
|
this.options.config,
|
|
1858
|
-
{ ...
|
|
1911
|
+
{ ...this.guestEnvironment(), AB_TOKEN: scopedToken },
|
|
1859
1912
|
currentRuntimeReferences(this.options.runtimeReferences),
|
|
1860
1913
|
true,
|
|
1861
1914
|
)
|
|
@@ -1892,7 +1945,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1892
1945
|
await bootstrapRuntimes(
|
|
1893
1946
|
sandbox,
|
|
1894
1947
|
this.options.config,
|
|
1895
|
-
{ ...
|
|
1948
|
+
{ ...this.guestEnvironment(), AB_TOKEN: scopedToken },
|
|
1896
1949
|
currentRuntimeReferences(this.options.runtimeReferences),
|
|
1897
1950
|
false,
|
|
1898
1951
|
)
|
|
@@ -1915,9 +1968,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1915
1968
|
: {}),
|
|
1916
1969
|
[HARVEST_RUNNER_OPTIONS_ENV]: JSON.stringify(envelope),
|
|
1917
1970
|
}
|
|
1918
|
-
|
|
1919
|
-
if (!['AB_TOKEN', 'AB_TICKET_URL', 'AB_TICKET_TOKEN'].includes(envName))
|
|
1920
|
-
env[envName] = requireVercelEnvironmentValue(this.options.env, envName)
|
|
1971
|
+
Object.assign(env, this.guestEnvironment())
|
|
1921
1972
|
const command = (await sandbox.runCommand({
|
|
1922
1973
|
cmd: 'sh',
|
|
1923
1974
|
args: [
|
|
@@ -1932,17 +1983,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1932
1983
|
return this.environmentSupervisedHandle(name, sandbox, command)
|
|
1933
1984
|
}
|
|
1934
1985
|
|
|
1935
|
-
/**
|
|
1936
|
-
*
|
|
1937
|
-
*
|
|
1938
|
-
*
|
|
1939
|
-
* longer knows is `lost`; a non-null exit code — from the lookup or from
|
|
1940
|
-
* the bounded wait it triggered — is `ended`; an interrupted or timed-out
|
|
1941
|
-
* wait leaves the execution `running`. The lifetime bound (session expiry
|
|
1942
|
-
* plus the shared stop/snapshot margin) runs before the lookup and fails
|
|
1943
|
-
* with the environment named instead of waiting. Unknown provider errors
|
|
1944
|
-
* propagate — callers treat an unresolvable observation as running and
|
|
1945
|
-
* never reap on it. */
|
|
1986
|
+
/** Observe a recovered execution and confirm whole-environment teardown
|
|
1987
|
+
* before exposing a terminal observation. Command exit alone does not prove
|
|
1988
|
+
* descendants have stopped writing to the shared workspace. Stop failures
|
|
1989
|
+
* propagate so settlement retains the execution and lease and retries. */
|
|
1946
1990
|
private async observeExecution(identity: BuildExecutionIdentity): Promise<ExecutionObservation> {
|
|
1947
1991
|
if (identity.commandId === undefined) {
|
|
1948
1992
|
throw new Error(
|
|
@@ -1951,13 +1995,40 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1951
1995
|
}
|
|
1952
1996
|
const sandbox = await this.facade.get(identity.workspaceRef, this.operationSignal())
|
|
1953
1997
|
if (sandbox === null) return { state: 'lost' }
|
|
1954
|
-
|
|
1998
|
+
const settled = async (observation: ExecutionObservation): Promise<ExecutionObservation> => {
|
|
1999
|
+
try {
|
|
2000
|
+
await sandbox.stop({ signal: this.operationSignal() })
|
|
2001
|
+
} catch (error) {
|
|
2002
|
+
if (!isMissingVercelSandbox(error)) {
|
|
2003
|
+
this.uncertain.add(identity.workspaceRef)
|
|
2004
|
+
this.sessions.delete(identity.workspaceRef)
|
|
2005
|
+
throw error
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
this.active.delete(identity.workspaceRef)
|
|
2009
|
+
this.uncertain.delete(identity.workspaceRef)
|
|
2010
|
+
this.sessions.delete(identity.workspaceRef)
|
|
2011
|
+
return observation
|
|
2012
|
+
}
|
|
2013
|
+
const currentSession = sandbox.currentSession?.().sessionId
|
|
2014
|
+
if (
|
|
2015
|
+
identity.sessionId !== undefined &&
|
|
2016
|
+
currentSession !== undefined &&
|
|
2017
|
+
currentSession !== identity.sessionId
|
|
2018
|
+
)
|
|
2019
|
+
return { state: 'lost' }
|
|
2020
|
+
// Terminal provider status proves the recorded incarnation is stopped.
|
|
2021
|
+
// Never stop a newer resumed session or demand a second stop of one that
|
|
2022
|
+
// the provider already confirms stopped.
|
|
2023
|
+
if (
|
|
2024
|
+
sandbox.sessionStatus === 'stopped' ||
|
|
2025
|
+
sandbox.sessionStatus === 'aborted' ||
|
|
2026
|
+
sandbox.sessionStatus === 'failed'
|
|
2027
|
+
)
|
|
1955
2028
|
return { state: 'lost' }
|
|
2029
|
+
if (sandbox.sessionStatus !== undefined && sandbox.sessionStatus !== 'running') {
|
|
2030
|
+
return settled({ state: 'lost' })
|
|
1956
2031
|
}
|
|
1957
|
-
// Mirrors the command path's VM-lifetime bound: past the environment's
|
|
1958
|
-
// session expiry (plus the shared stop/snapshot margin) the execution
|
|
1959
|
-
// cannot still be running, so re-issuing the long-poll would only end in
|
|
1960
|
-
// a generic transport failure. Fail with the environment named instead.
|
|
1961
2032
|
if (sandbox.sessionExpiresAt !== undefined) {
|
|
1962
2033
|
const deadline = sandbox.sessionExpiresAt + VERCEL_LIFETIME_MARGIN_MS
|
|
1963
2034
|
if (Date.now() > deadline) {
|
|
@@ -1968,36 +2039,69 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1968
2039
|
)
|
|
1969
2040
|
}
|
|
1970
2041
|
}
|
|
2042
|
+
let attention: string | undefined
|
|
2043
|
+
const accounts = this.options.accounts?.() ?? {}
|
|
2044
|
+
// Preserve legacy observation: without accounts there is no credential
|
|
2045
|
+
// policy to refresh, and no additional provider write or failure point.
|
|
2046
|
+
if (Object.keys(accounts).length) {
|
|
2047
|
+
const origin =
|
|
2048
|
+
this.origins.get(identity.workspaceRef) ?? cleanGithubOrigin(await this.origin())
|
|
2049
|
+
const base = uploadPackPolicy(
|
|
2050
|
+
origin,
|
|
2051
|
+
this.options.config.gitPasswordEnv === undefined
|
|
2052
|
+
? undefined
|
|
2053
|
+
: `Basic ${Buffer.from(`${requireVercelEnvironmentValue(this.options.env, this.options.config.gitUsernameEnv!)}:${requireVercelEnvironmentValue(this.options.env, this.options.config.gitPasswordEnv)}`).toString('base64')}`,
|
|
2054
|
+
)
|
|
2055
|
+
const refreshed = accountPolicy(base, accounts, this.options.env)
|
|
2056
|
+
try {
|
|
2057
|
+
await sandbox.update(
|
|
2058
|
+
{ networkPolicy: refreshed.policy },
|
|
2059
|
+
{ signal: this.operationSignal() },
|
|
2060
|
+
)
|
|
2061
|
+
} catch {
|
|
2062
|
+
await sandbox.stop({ signal: this.operationSignal() })
|
|
2063
|
+
return { state: 'lost', attention: 'Account policy renewal failed; sandbox stopped' }
|
|
2064
|
+
}
|
|
2065
|
+
if (refreshed.missing.length) {
|
|
2066
|
+
attention = `Missing credentials: ${refreshed.missing.join('; ')}`
|
|
2067
|
+
// The updated policy fences the missing account by removing its bearer
|
|
2068
|
+
// transform. Its next request fails authentication through the runtime's
|
|
2069
|
+
// account-specific recovery path. Keep other routes in this guest alive:
|
|
2070
|
+
// declarations include unused accounts and do not identify active sessions.
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
const diagnosed = (observation: ExecutionObservation): ExecutionObservation =>
|
|
2074
|
+
attention === undefined ? observation : { ...observation, attention }
|
|
2075
|
+
let observation: ExecutionObservation
|
|
1971
2076
|
try {
|
|
1972
2077
|
const command = await sandbox.getCommand(identity.commandId, {
|
|
1973
2078
|
signal: this.operationSignal(),
|
|
1974
2079
|
})
|
|
1975
|
-
if (command.exitCode !== null)
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
}
|
|
1991
|
-
return { state: 'ended', exitCode: finished.exitCode }
|
|
1992
|
-
} catch (error) {
|
|
1993
|
-
if (isMissingVercelSandbox(error)) return { state: 'lost' }
|
|
1994
|
-
if (isInterruptedLongPoll(error)) return { state: 'running' }
|
|
1995
|
-
throw error
|
|
2080
|
+
if (command.exitCode !== null) {
|
|
2081
|
+
observation = { state: 'ended', exitCode: command.exitCode }
|
|
2082
|
+
} else {
|
|
2083
|
+
try {
|
|
2084
|
+
const finished = await command.wait({
|
|
2085
|
+
signal: AbortSignal.any([
|
|
2086
|
+
AbortSignal.timeout(this.observeWaitMs),
|
|
2087
|
+
this.operationSignal(),
|
|
2088
|
+
]),
|
|
2089
|
+
})
|
|
2090
|
+
observation = { state: 'ended', exitCode: finished.exitCode }
|
|
2091
|
+
} catch (error) {
|
|
2092
|
+
if (isMissingVercelSandbox(error)) observation = { state: 'lost' }
|
|
2093
|
+
else if (isInterruptedLongPoll(error)) return diagnosed({ state: 'running' })
|
|
2094
|
+
else throw error
|
|
2095
|
+
}
|
|
1996
2096
|
}
|
|
1997
2097
|
} catch (error) {
|
|
1998
|
-
if (isMissingVercelSandbox(error))
|
|
1999
|
-
throw error
|
|
2098
|
+
if (isMissingVercelSandbox(error)) observation = { state: 'lost' }
|
|
2099
|
+
else throw error
|
|
2000
2100
|
}
|
|
2101
|
+
// Deliberately outside the lookup/wait catch: an ambiguous stop must not
|
|
2102
|
+
// become proof of loss or command exit, even when its error resembles a
|
|
2103
|
+
// transport interruption.
|
|
2104
|
+
return settled(diagnosed(observation))
|
|
2001
2105
|
}
|
|
2002
2106
|
|
|
2003
2107
|
// ── Operator sandbox capability (AUT-340) ─────────────────────────
|
|
@@ -2561,7 +2665,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2561
2665
|
if (!token) {
|
|
2562
2666
|
throw new Error('vercel-sandbox publication requires GITHUB_TOKEN or GH_TOKEN')
|
|
2563
2667
|
}
|
|
2564
|
-
const { origin
|
|
2668
|
+
const { origin } = await this.normalNetworkPolicy(input.ref)
|
|
2565
2669
|
const sandbox =
|
|
2566
2670
|
this.sessions.get(input.ref) ?? (await this.facade.get(input.ref, this.operationSignal()))
|
|
2567
2671
|
if (sandbox === null) throw new Error(`unknown sandbox ${input.ref}`)
|
|
@@ -2613,7 +2717,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2613
2717
|
},
|
|
2614
2718
|
}
|
|
2615
2719
|
try {
|
|
2616
|
-
await sandbox.update(
|
|
2720
|
+
await sandbox.update(
|
|
2721
|
+
{ networkPolicy: this.billingPolicy(publicationPolicy, input.ref) },
|
|
2722
|
+
{ signal: this.operationSignal() },
|
|
2723
|
+
)
|
|
2617
2724
|
if (input.expected !== undefined) {
|
|
2618
2725
|
const capability = gitRewrite(async (cmd) => {
|
|
2619
2726
|
const result = await sandbox.runCommand({
|
|
@@ -2665,7 +2772,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2665
2772
|
await sandbox.stop({ signal: this.operationSignal() })
|
|
2666
2773
|
} finally {
|
|
2667
2774
|
try {
|
|
2668
|
-
await sandbox.update(
|
|
2775
|
+
await sandbox.update(
|
|
2776
|
+
{ networkPolicy: (await this.normalNetworkPolicy(input.ref)).policy },
|
|
2777
|
+
{ signal: this.operationSignal() },
|
|
2778
|
+
)
|
|
2669
2779
|
} finally {
|
|
2670
2780
|
await sandbox.stop({ signal: this.operationSignal() })
|
|
2671
2781
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { composeBuildConfig } from '../config/live'
|
|
2
|
+
import { readVerifyPipeline } from '../config/pipeline-source'
|
|
1
3
|
import { guardForge } from '../kernel/guarded-forge'
|
|
2
4
|
import { isRemoteWorkspace } from '../events/workspace-remote'
|
|
3
5
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
@@ -13,7 +15,6 @@ import { openProductionStore } from '../cli/store-opening'
|
|
|
13
15
|
import { BuildRunner, LeaseHeldError, SetupFailureError } from './build-runner'
|
|
14
16
|
import {
|
|
15
17
|
BUILD_EFFECTIVE_CONFIG_ARTIFACT,
|
|
16
|
-
buildOwnedSectionsDiffer,
|
|
17
18
|
diagnosticArtifact,
|
|
18
19
|
parseEffectiveBuildConfig,
|
|
19
20
|
type BuildRunnerDiagnosticOutcome,
|
|
@@ -80,13 +81,9 @@ export async function runBuildChild(
|
|
|
80
81
|
if (latest === null) return currentConfig
|
|
81
82
|
try {
|
|
82
83
|
const parsed = parseEffectiveBuildConfig(latest)
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
// by something other than a launch — keep the last valid boundary.
|
|
87
|
-
if (!buildOwnedSectionsDiffer(currentConfig, parsed)) {
|
|
88
|
-
currentConfig = parsed
|
|
89
|
-
}
|
|
84
|
+
// Deployment reloads may race a runner capture. The runner resolves
|
|
85
|
+
// build-owned sections through the capture's immutable revision.
|
|
86
|
+
currentConfig = composeBuildConfig(currentConfig, parsed)
|
|
90
87
|
} catch {
|
|
91
88
|
// The dispatcher publishes only validated snapshots. If storage is
|
|
92
89
|
// externally corrupted, preserve the child's last valid boundary.
|
|
@@ -98,6 +95,7 @@ export async function runBuildChild(
|
|
|
98
95
|
store,
|
|
99
96
|
config: currentConfig,
|
|
100
97
|
getConfig,
|
|
98
|
+
readVerifyPipeline: () => readVerifyPipeline(workspace.path ?? workspace.ref, spawnExec),
|
|
101
99
|
runtimes,
|
|
102
100
|
workspacePath: workspace.path ?? workspace.ref,
|
|
103
101
|
workspaceProvider: workspace.provider,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeEffectiveConfigArtifact } from '../config/effective-artifact'
|
|
1
2
|
import type { Config } from '../config/schema'
|
|
2
3
|
import { configSchema } from '../config/schema'
|
|
3
4
|
import { BUILD_OWNED_CONFIG_PATHS } from '../config/live'
|
|
@@ -22,7 +23,11 @@ export function effectiveBuildConfigContent(config: Config): string {
|
|
|
22
23
|
const { verify, finalize, ...root } = config
|
|
23
24
|
return JSON.stringify({
|
|
24
25
|
...root,
|
|
25
|
-
verify: {
|
|
26
|
+
verify: {
|
|
27
|
+
steps: verify.stages ?? verify.steps,
|
|
28
|
+
afterReconcile: verify.afterReconcile,
|
|
29
|
+
...verify.stepConfigs,
|
|
30
|
+
},
|
|
26
31
|
finalize: { steps: finalize.steps, ...finalize.stepConfigs },
|
|
27
32
|
})
|
|
28
33
|
}
|
|
@@ -38,7 +43,7 @@ export function parseEffectiveBuildConfig(artifact: Artifact): Config {
|
|
|
38
43
|
}`,
|
|
39
44
|
)
|
|
40
45
|
}
|
|
41
|
-
const result = configSchema.safeParse(value)
|
|
46
|
+
const result = configSchema.safeParse(normalizeEffectiveConfigArtifact(value))
|
|
42
47
|
if (!result.success) {
|
|
43
48
|
throw new Error(
|
|
44
49
|
`invalid ${BUILD_EFFECTIVE_CONFIG_ARTIFACT}: ${result.error.issues
|
|
@@ -75,9 +80,7 @@ export function parseBuildConfigMetadata(artifact: Artifact): {
|
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
/**
|
|
79
|
-
* guard against a deposit that rewrites the pinned pipeline without a recorded
|
|
80
|
-
* pipeline-source commit advance. */
|
|
83
|
+
/** Compare only build-owned sections, independently of live deployment settings. */
|
|
81
84
|
export function buildOwnedSectionsDiffer(a: Config, b: Config): boolean {
|
|
82
85
|
return BUILD_OWNED_CONFIG_PATHS.some(
|
|
83
86
|
(path) => JSON.stringify(a[path]) !== JSON.stringify(b[path]),
|