@defrex/autobuild 1.4.2 → 1.5.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 +432 -92
- package/bin/ab-dispatch-kernel.ts +1 -0
- package/docs/accounts.md +9 -0
- package/docs/agent-runtimes.md +1 -0
- package/docs/answering-blocked-builds.md +2 -1
- package/docs/architecture.md +282 -127
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +33 -3
- package/docs/cli.md +2 -1
- package/docs/configuration-overview.md +9 -0
- package/docs/configuration.md +163 -102
- package/docs/dispatcher-hosting.md +19 -3
- package/docs/dispatcher.md +9 -4
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +91 -28
- package/docs/merge-policy.md +28 -9
- package/docs/operator-api.md +43 -18
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +85 -8
- package/docs/remote-store-protocol.md +25 -7
- package/docs/remote-ticket-protocol.md +126 -12
- package/docs/restacking.md +20 -6
- package/docs/seams.md +2 -2
- package/docs/setup.md +19 -13
- package/docs/spec-standard.md +2 -1
- package/docs/ticket-dependencies.md +26 -8
- package/docs/ticket-migration.md +70 -7
- package/docs/ticket-sources.md +82 -5
- package/docs/tickets.md +34 -2
- package/docs/troubleshooting.md +2 -2
- package/docs/verification.md +5 -5
- package/docs/website.md +8 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/hosted-readiness.ts +21 -0
- package/packages/core/src/cli/attention.ts +1 -0
- package/packages/core/src/cli/build-control.ts +36 -12
- package/packages/core/src/cli/connect.ts +9 -18
- package/packages/core/src/cli/context.ts +44 -0
- package/packages/core/src/cli/dashboard/configuration.ts +11 -0
- package/packages/core/src/cli/dashboard/model.ts +40 -10
- package/packages/core/src/cli/dashboard/queue.ts +21 -0
- package/packages/core/src/cli/dashboard/render.ts +40 -22
- package/packages/core/src/cli/dispatch-frontend.ts +63 -30
- package/packages/core/src/cli/dispatch-mode.ts +35 -16
- package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
- package/packages/core/src/cli/dispatch.ts +154 -47
- package/packages/core/src/cli/help.ts +59 -22
- package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
- package/packages/core/src/cli/init-readiness-remote.ts +16 -3
- package/packages/core/src/cli/init-validation.ts +144 -42
- package/packages/core/src/cli/issue-links.ts +67 -0
- package/packages/core/src/cli/main.ts +32 -15
- package/packages/core/src/cli/pr-summary-publication.ts +38 -7
- package/packages/core/src/cli/publication-settlement.ts +36 -24
- package/packages/core/src/cli/repository-status.ts +201 -49
- package/packages/core/src/cli/status.ts +41 -3
- package/packages/core/src/cli/terminals.ts +37 -2
- package/packages/core/src/cli/ticket-editor.ts +20 -6
- package/packages/core/src/cli/ticket.ts +264 -46
- package/packages/core/src/cli/triage-count-sampler.ts +59 -0
- package/packages/core/src/cli/watch.ts +4 -0
- package/packages/core/src/config/live.ts +45 -4
- package/packages/core/src/config/load.ts +9 -0
- package/packages/core/src/config/pipeline-source.ts +6 -2
- package/packages/core/src/config/ready-assignee.ts +86 -0
- package/packages/core/src/config/schema.ts +164 -36
- package/packages/core/src/distribution-packaging.ts +1 -1
- package/packages/core/src/events/catalog.ts +5 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/payloads.ts +70 -0
- package/packages/core/src/events/policy.ts +8 -0
- package/packages/core/src/events/repository.ts +91 -28
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +41 -0
- package/packages/core/src/kernel/build-identity.ts +12 -0
- package/packages/core/src/kernel/change-presence.ts +139 -6
- package/packages/core/src/kernel/dispatch-capacity.ts +80 -14
- package/packages/core/src/kernel/dispatch-status.ts +10 -1
- package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
- package/packages/core/src/kernel/engine.ts +4 -2
- package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
- package/packages/core/src/kernel/harvest.ts +4 -1
- package/packages/core/src/kernel/integration-completeness.ts +104 -17
- package/packages/core/src/kernel/integration-landing.ts +17 -0
- package/packages/core/src/kernel/integration-state.ts +17 -0
- package/packages/core/src/kernel/issue-keywords.ts +202 -0
- package/packages/core/src/kernel/janitor-failure.ts +11 -0
- package/packages/core/src/kernel/kernel-git.ts +87 -0
- package/packages/core/src/kernel/landing-readiness.ts +25 -17
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-issue-links.ts +142 -0
- package/packages/core/src/kernel/node-parent.ts +6 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
- package/packages/core/src/kernel/pr-summary.ts +24 -0
- package/packages/core/src/kernel/read-deferrals.ts +75 -12
- package/packages/core/src/kernel/read-facts.ts +32 -1
- package/packages/core/src/kernel/reconcile-restack.ts +1 -1
- package/packages/core/src/kernel/reducer-registry.ts +31 -1
- package/packages/core/src/kernel/reducer.ts +90 -2
- package/packages/core/src/kernel/ticket-preparation.ts +12 -0
- package/packages/core/src/kernel/verify-budget.ts +43 -0
- package/packages/core/src/operator/index.ts +3 -1
- package/packages/core/src/operator/presentation.ts +3 -0
- package/packages/core/src/operator/protocol.ts +38 -2
- package/packages/core/src/operator/query.ts +66 -29
- package/packages/core/src/operator/registry.ts +47 -26
- package/packages/core/src/operator/tickets.ts +77 -10
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/plugins/registry.ts +1 -0
- package/packages/core/src/ports/forge/contract.ts +69 -0
- package/packages/core/src/ports/forge/create.ts +5 -0
- package/packages/core/src/ports/forge/fake.ts +184 -3
- package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
- package/packages/core/src/ports/forge/github.ts +175 -38
- package/packages/core/src/ports/forge/local-git.ts +14 -0
- package/packages/core/src/ports/forge/readiness.ts +10 -0
- package/packages/core/src/ports/forge-failure.ts +43 -0
- package/packages/core/src/ports/runner/claude.ts +7 -1
- package/packages/core/src/ports/runner/codex.ts +7 -2
- package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
- package/packages/core/src/ports/runner/pi.ts +7 -1
- package/packages/core/src/ports/runner/runtime.ts +3 -0
- package/packages/core/src/ports/runner/start-prompt.ts +37 -0
- package/packages/core/src/ports/tickets/contract.ts +320 -7
- package/packages/core/src/ports/tickets/create.ts +72 -17
- package/packages/core/src/ports/tickets/fake.ts +18 -0
- package/packages/core/src/ports/tickets/file-codec.ts +20 -0
- package/packages/core/src/ports/tickets/file.ts +43 -1
- package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
- package/packages/core/src/ports/tickets/github-issues.ts +431 -0
- package/packages/core/src/ports/tickets/github-validators.ts +194 -0
- package/packages/core/src/ports/tickets/github.ts +2029 -0
- package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
- package/packages/core/src/ports/tickets/issue-links.ts +86 -0
- package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
- package/packages/core/src/ports/tickets/linear.ts +66 -6
- package/packages/core/src/ports/tickets/migration.ts +290 -68
- package/packages/core/src/ports/tickets/operations.ts +98 -12
- package/packages/core/src/ports/tickets/priority.ts +55 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
- package/packages/core/src/ports/tickets/remote.ts +188 -13
- package/packages/core/src/ports/tickets/revision.ts +22 -1
- package/packages/core/src/ports/tickets/states.ts +43 -0
- package/packages/core/src/ports/tickets/tree.ts +58 -12
- package/packages/core/src/ports/tickets/update.ts +12 -2
- package/packages/core/src/ports/types.ts +190 -9
- package/packages/core/src/ports/workspace/commit-preservation.ts +135 -13
- package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +118 -27
- package/packages/core/src/processes/build-runner.ts +99 -21
- package/packages/core/src/processes/dispatcher.ts +822 -338
- package/packages/core/src/processes/execution-no-progress.ts +5 -0
- package/packages/core/src/processes/harvest-runner.ts +17 -8
- package/packages/core/src/processes/harvest.ts +5 -8
- package/packages/core/src/processes/tick-publication.ts +12 -2
- package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
- package/packages/core/src/processes/workspace-preservation.ts +36 -1
- package/packages/core/src/runtime-identity.ts +10 -2
- package/packages/core/src/scenarios/harness.ts +4 -0
- package/packages/core/src/store/adapter.ts +7 -1
- package/packages/core/src/store/contract.ts +83 -2
- package/packages/core/src/store/digest.ts +32 -1
- package/packages/core/src/store/reducer-value-shapes.json +4187 -3391
- package/packages/core/src/store/remote/protocol.ts +2 -0
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +5 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
- package/packages/core/src/testing/index.ts +18 -1
- package/packages/core/src/testing/presence-history.ts +79 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1085 -31
- package/packages/core/src/testing/upgrade-generations.ts +77 -0
- package/skills/code-review/SKILL.md +4 -3
- package/skills/finalize/SKILL.md +18 -2
- package/skills/guide/SKILL.md +374 -136
- package/skills/guide/references/accounts.md +9 -0
- package/skills/guide/references/integration-tree.md +91 -28
- package/skills/guide/references/merge-policy.md +28 -9
- package/skills/guide/references/operator-api.md +43 -18
- package/skills/guide/references/plugin-authoring.md +85 -8
- package/skills/guide/references/remote-store-protocol.md +25 -7
- package/skills/guide/references/remote-ticket-protocol.md +126 -12
- package/skills/guide/references/restacking.md +20 -6
- package/skills/guide/references/setup.md +19 -13
- package/skills/guide/references/spec-standard.md +2 -1
- package/skills/guide/references/ticket-dependencies.md +26 -8
- package/skills/guide/references/ticket-migration.md +70 -7
- package/skills/harvest-review/SKILL.md +4 -3
- package/skills/implement/SKILL.md +20 -1
- package/skills/operate/SKILL.md +103 -28
- package/skills/plan/SKILL.md +1 -1
- package/skills/reconcile/SKILL.md +5 -4
- package/skills/spec/SKILL.md +15 -2
- package/skills/tickets/SKILL.md +114 -37
- package/templates/autobuild.toml +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import { WorkspaceCleanupRequired } from '../types'
|
|
6
6
|
import { inspectGitCandidate, preserveGitCommits, restoreGitCommits } from './commit-preservation'
|
|
7
7
|
import { accountPolicy, accountGuestEnvironment } from './account-policy'
|
|
8
|
+
import { HOSTED_ACCOUNT_READINESS_ENV } from '../../accounts/hosted-readiness'
|
|
8
9
|
import { gitRewrite, parseRemoteHead } from '../forge/git-rewrite'
|
|
9
10
|
import { delegateCredential } from '../../store/remote/credentials'
|
|
10
11
|
import type { ExecutionLaunchAuth } from './build-execution'
|
|
@@ -67,7 +68,7 @@ export const VERCEL_PROVISIONED_MARKER = `${VERCEL_AUTOBUILD_PATH}/.provisioned`
|
|
|
67
68
|
* instead of resuming a stale distribution that the hosted store would
|
|
68
69
|
* reject. */
|
|
69
70
|
export const VERCEL_DISTRIBUTION_VERSION_MARKER = `${VERCEL_AUTOBUILD_PATH}/.distribution-version`
|
|
70
|
-
export const VERCEL_BUN_VERSION = '1.4.
|
|
71
|
+
export const VERCEL_BUN_VERSION = '1.4.4'
|
|
71
72
|
export const VERCEL_BUN_PREFIX = '/opt/autobuild-runtime'
|
|
72
73
|
export const VERCEL_BUN_BIN_PATH = `${VERCEL_BUN_PREFIX}/node_modules/.bin`
|
|
73
74
|
export const VERCEL_BUN_EXECUTABLE = `${VERCEL_BUN_BIN_PATH}/bun`
|
|
@@ -650,6 +651,31 @@ function bunProvisioningError(image: string, operation: string, error: unknown):
|
|
|
650
651
|
)
|
|
651
652
|
}
|
|
652
653
|
|
|
654
|
+
/** The trimmed `bun --version` output of the provisioned executable, or
|
|
655
|
+
* undefined when it cannot run or prints nothing. */
|
|
656
|
+
async function reportedBunVersion(
|
|
657
|
+
sandbox: VercelSandboxHandle,
|
|
658
|
+
signal?: AbortSignal,
|
|
659
|
+
): Promise<string | undefined> {
|
|
660
|
+
try {
|
|
661
|
+
const version = (
|
|
662
|
+
await readableCommand(sandbox, {
|
|
663
|
+
cmd: VERCEL_BUN_EXECUTABLE,
|
|
664
|
+
args: ['--version'],
|
|
665
|
+
...(signal === undefined ? {} : { signal }),
|
|
666
|
+
})
|
|
667
|
+
).trim()
|
|
668
|
+
return version === '' ? undefined : version
|
|
669
|
+
} catch (error) {
|
|
670
|
+
if (signal?.aborted) throw error
|
|
671
|
+
return undefined
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function describeBunVersion(version: string | undefined): string {
|
|
676
|
+
return version === undefined ? 'no version' : version
|
|
677
|
+
}
|
|
678
|
+
|
|
653
679
|
async function provisionBun(
|
|
654
680
|
sandbox: VercelSandboxHandle,
|
|
655
681
|
image: string,
|
|
@@ -664,14 +690,15 @@ async function provisionBun(
|
|
|
664
690
|
} catch (error) {
|
|
665
691
|
throw bunProvisioningError(image, 'provision', error)
|
|
666
692
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
693
|
+
const reported = await reportedBunVersion(sandbox, signal)
|
|
694
|
+
if (reported !== VERCEL_BUN_VERSION) {
|
|
695
|
+
throw bunProvisioningError(
|
|
696
|
+
image,
|
|
697
|
+
'verify provisioned',
|
|
698
|
+
new Error(
|
|
699
|
+
`vercel-sandbox provisioned Bun reports ${describeBunVersion(reported)} but the pin is ${VERCEL_BUN_VERSION} on image ${JSON.stringify(image)}`,
|
|
700
|
+
),
|
|
701
|
+
)
|
|
675
702
|
}
|
|
676
703
|
}
|
|
677
704
|
|
|
@@ -768,12 +795,26 @@ async function runSystemProvisioning(
|
|
|
768
795
|
return completed
|
|
769
796
|
}
|
|
770
797
|
|
|
771
|
-
|
|
798
|
+
/** Bring a reused sandbox's Bun to exactly the pin before any guest command
|
|
799
|
+
* runs with it. A matching `bun --version` costs one command; any other
|
|
800
|
+
* report (a stale pin, a missing or unrunnable executable) is reinstalled at
|
|
801
|
+
* the pin with the provisioning recipe. The comparison is exact, so a partly
|
|
802
|
+
* applied upgrade is never accepted by this or any later preflight. */
|
|
803
|
+
async function ensurePinnedBun(
|
|
804
|
+
sandbox: VercelSandboxHandle,
|
|
805
|
+
image: string,
|
|
806
|
+
signal?: AbortSignal,
|
|
807
|
+
): Promise<void> {
|
|
808
|
+
const reported = await reportedBunVersion(sandbox, signal)
|
|
809
|
+
if (reported === VERCEL_BUN_VERSION) return
|
|
772
810
|
try {
|
|
773
|
-
await
|
|
811
|
+
await provisionBun(sandbox, image, signal)
|
|
774
812
|
} catch (error) {
|
|
813
|
+
const cause = error instanceof Error && error.cause instanceof Error ? error.cause : error
|
|
775
814
|
throw new Error(
|
|
776
|
-
`vercel-sandbox Bun
|
|
815
|
+
`vercel-sandbox Bun preflight on image ${JSON.stringify(image)} found ${describeBunVersion(reported)} (pin ${VERCEL_BUN_VERSION}) and could not bring it to the pin: ${
|
|
816
|
+
cause instanceof Error ? cause.message : String(cause)
|
|
817
|
+
}; release and reprovision this sandbox before retrying the build`,
|
|
777
818
|
{ cause: error },
|
|
778
819
|
)
|
|
779
820
|
}
|
|
@@ -999,8 +1040,8 @@ export async function validateVercelSandbox(
|
|
|
999
1040
|
),
|
|
1000
1041
|
AB_STORE: options.storeRef,
|
|
1001
1042
|
AB_TOKEN: options.storeToken,
|
|
1002
|
-
...(options.env
|
|
1003
|
-
? {
|
|
1043
|
+
...(options.env[HOSTED_ACCOUNT_READINESS_ENV]
|
|
1044
|
+
? { [HOSTED_ACCOUNT_READINESS_ENV]: options.env[HOSTED_ACCOUNT_READINESS_ENV] }
|
|
1004
1045
|
: {}),
|
|
1005
1046
|
},
|
|
1006
1047
|
}),
|
|
@@ -1422,6 +1463,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1422
1463
|
revision?: string
|
|
1423
1464
|
generation?: number
|
|
1424
1465
|
restoration?: import('../types').WorkspacePreservationHead[]
|
|
1466
|
+
restorationReplaced?: string[]
|
|
1425
1467
|
}): Promise<WorkspaceProvisionResult> {
|
|
1426
1468
|
const scopedToken = await (this.options.delegateCredential ?? delegateCredential)(
|
|
1427
1469
|
this.options.storeRef,
|
|
@@ -1477,6 +1519,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1477
1519
|
// without a marker — is refreshed in place. Any refresh failure
|
|
1478
1520
|
// deletes the sandbox so the next pass rematerializes cleanly.
|
|
1479
1521
|
try {
|
|
1522
|
+
await ensurePinnedBun(sandbox, this.options.config.image, this.operationSignal())
|
|
1480
1523
|
const archive = await this.archiveBytes()
|
|
1481
1524
|
await installDistribution(
|
|
1482
1525
|
sandbox,
|
|
@@ -1616,14 +1659,18 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1616
1659
|
}
|
|
1617
1660
|
}
|
|
1618
1661
|
let provisionHead = base
|
|
1662
|
+
let restorationSkipped: import('../types').RestorationSkip[] = []
|
|
1619
1663
|
if (opts.restoration?.length) {
|
|
1620
1664
|
provisionHead = await this.withTrustedGit(sandbox, name, async (exec) => {
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1665
|
+
restorationSkipped = (
|
|
1666
|
+
await restoreGitCommits({
|
|
1667
|
+
exec,
|
|
1668
|
+
workspacePath: VERCEL_WORKSPACE_PATH,
|
|
1669
|
+
branch: opts.branch,
|
|
1670
|
+
heads: opts.restoration!,
|
|
1671
|
+
replaced: opts.restorationReplaced,
|
|
1672
|
+
})
|
|
1673
|
+
).skipped
|
|
1627
1674
|
const result = await exec(
|
|
1628
1675
|
['git', 'rev-parse', '--verify', `refs/heads/${opts.branch}^{commit}`],
|
|
1629
1676
|
{ cwd: VERCEL_WORKSPACE_PATH },
|
|
@@ -1643,6 +1690,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1643
1690
|
source: opts.restoration?.length || existing !== null ? 'existing' : 'remote',
|
|
1644
1691
|
sha: provisionHead,
|
|
1645
1692
|
},
|
|
1693
|
+
...(restorationSkipped.length ? { restorationSkipped } : {}),
|
|
1646
1694
|
}
|
|
1647
1695
|
}
|
|
1648
1696
|
|
|
@@ -1819,7 +1867,16 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1819
1867
|
// stranded by a protocol-only bump or a missing/unreadable marker — is
|
|
1820
1868
|
// refreshed before the runner starts, or the hosted store would 409 its
|
|
1821
1869
|
// heartbeat and the build would strand. Refresh failure retains the
|
|
1822
|
-
// sandbox for dispatcher-owned preservation and cleanup.
|
|
1870
|
+
// sandbox for dispatcher-owned preservation and cleanup. Bun is brought
|
|
1871
|
+
// to the pin first, because the refresh and the runner both run with it.
|
|
1872
|
+
try {
|
|
1873
|
+
await ensurePinnedBun(sandbox, this.options.config.image, this.operationSignal())
|
|
1874
|
+
} catch (error) {
|
|
1875
|
+
throw new WorkspaceCleanupRequired(
|
|
1876
|
+
{ provider: this.name, ref, path: VERCEL_WORKSPACE_PATH, branch: `ab/${input.slug}` },
|
|
1877
|
+
error,
|
|
1878
|
+
)
|
|
1879
|
+
}
|
|
1823
1880
|
const distributionIdentity = await this.identityStamp()
|
|
1824
1881
|
const installed = await readDistributionVersionMarker(sandbox, this.operationSignal())
|
|
1825
1882
|
if (installed !== distributionIdentity) {
|
|
@@ -1833,7 +1890,6 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1833
1890
|
)
|
|
1834
1891
|
}
|
|
1835
1892
|
}
|
|
1836
|
-
await preflightBun(sandbox, this.options.config.image)
|
|
1837
1893
|
await bootstrapRuntimes(
|
|
1838
1894
|
sandbox,
|
|
1839
1895
|
this.options.config,
|
|
@@ -1999,6 +2055,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1999
2055
|
const installed = await readDistributionVersionMarker(sandbox, this.operationSignal())
|
|
2000
2056
|
if (installed !== distributionIdentity) {
|
|
2001
2057
|
try {
|
|
2058
|
+
await ensurePinnedBun(sandbox, this.options.config.image, this.operationSignal())
|
|
2002
2059
|
const archive = await this.archiveBytes()
|
|
2003
2060
|
await installDistribution(
|
|
2004
2061
|
sandbox,
|
|
@@ -2122,8 +2179,9 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2122
2179
|
}
|
|
2123
2180
|
}
|
|
2124
2181
|
this.origins.set(name, origin)
|
|
2125
|
-
// Launch: reassert the normal network policy
|
|
2126
|
-
// build start path does, then one detached guest
|
|
2182
|
+
// Launch: reassert the normal network policy, bring Bun to the pin and
|
|
2183
|
+
// preflight exactly as the build start path does, then one detached guest
|
|
2184
|
+
// runner command. A sandbox that cannot reach the pin is reaped.
|
|
2127
2185
|
const { policy } = await this.normalNetworkPolicy(name)
|
|
2128
2186
|
await sandbox.update({ networkPolicy: policy }, { signal: this.operationSignal() })
|
|
2129
2187
|
if (this.uncertain.has(name)) {
|
|
@@ -2132,7 +2190,20 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2132
2190
|
await sandbox.stop({ signal: this.operationSignal() })
|
|
2133
2191
|
this.uncertain.delete(name)
|
|
2134
2192
|
}
|
|
2135
|
-
|
|
2193
|
+
try {
|
|
2194
|
+
await ensurePinnedBun(sandbox, this.options.config.image, this.operationSignal())
|
|
2195
|
+
} catch (error) {
|
|
2196
|
+
try {
|
|
2197
|
+
this.sessions.set(name, sandbox)
|
|
2198
|
+
await this.reap(name)
|
|
2199
|
+
} catch (deleteError) {
|
|
2200
|
+
throw new AggregateError(
|
|
2201
|
+
[error, deleteError],
|
|
2202
|
+
`harvest sandbox ${name} Bun pin refresh failed and its environment could not be confirmed deleted`,
|
|
2203
|
+
)
|
|
2204
|
+
}
|
|
2205
|
+
throw error
|
|
2206
|
+
}
|
|
2136
2207
|
await bootstrapRuntimes(
|
|
2137
2208
|
sandbox,
|
|
2138
2209
|
this.options.config,
|
|
@@ -2352,8 +2423,8 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2352
2423
|
}
|
|
2353
2424
|
|
|
2354
2425
|
/** Provision-or-resume. A persistent sandbox auto-resumes on the first SDK
|
|
2355
|
-
* call that needs a running session, so the reuse path
|
|
2356
|
-
* distribution marker
|
|
2426
|
+
* call that needs a running session, so the reuse path brings Bun to the
|
|
2427
|
+
* pin and re-checks the distribution marker as the build paths do, then leaves
|
|
2357
2428
|
* the session running for the tool call. A fresh provision runs the same
|
|
2358
2429
|
* chain as a build workspace and ends by running the repository's setup
|
|
2359
2430
|
* command; it leaves the environment running too (the tool call follows
|
|
@@ -2378,6 +2449,26 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2378
2449
|
await sandbox.delete({ signal: this.operationSignal() })
|
|
2379
2450
|
sandbox = null
|
|
2380
2451
|
} else {
|
|
2452
|
+
// Bun is brought to the pin before anything runs with it; a reused
|
|
2453
|
+
// environment that cannot reach the pin is deleted.
|
|
2454
|
+
try {
|
|
2455
|
+
await ensurePinnedBun(sandbox, this.options.config.image, this.operationSignal())
|
|
2456
|
+
} catch (error) {
|
|
2457
|
+
try {
|
|
2458
|
+
this.sessions.set(name, sandbox)
|
|
2459
|
+
await this.reap(name)
|
|
2460
|
+
} catch (deleteError) {
|
|
2461
|
+
throw new AggregateError(
|
|
2462
|
+
[error, deleteError],
|
|
2463
|
+
`operator sandbox ${name} Bun pin refresh failed and its environment could not be confirmed deleted`,
|
|
2464
|
+
)
|
|
2465
|
+
}
|
|
2466
|
+
throw new SandboxOperationError(
|
|
2467
|
+
'provision',
|
|
2468
|
+
error instanceof Error ? error.message : String(error),
|
|
2469
|
+
{ cause: error },
|
|
2470
|
+
)
|
|
2471
|
+
}
|
|
2381
2472
|
const installed = await readDistributionVersionMarker(sandbox, this.operationSignal())
|
|
2382
2473
|
if (installed !== distributionIdentity) {
|
|
2383
2474
|
// A reused environment whose installed distribution disagrees with
|
|
@@ -18,7 +18,7 @@ import { contextDirectory } from '../context-directory'
|
|
|
18
18
|
import { reportIntegrationFailures } from '../kernel/integration-attention'
|
|
19
19
|
import type { RuntimeIdentity } from '../events/runtime'
|
|
20
20
|
import { relaunchTarget } from './execution-relaunch'
|
|
21
|
-
import {
|
|
21
|
+
import { runtimeIdentity } from '../runtime-identity'
|
|
22
22
|
import { publishExact } from '../kernel/publication'
|
|
23
23
|
import {
|
|
24
24
|
deferMixedVersion,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from '../kernel/mixed-version'
|
|
28
28
|
import { hostname } from 'node:os'
|
|
29
29
|
import { resumeAgent } from '../ports/runner/native-session'
|
|
30
|
-
import type { AgentStartOpts } from '../ports/types'
|
|
30
|
+
import type { AgentStartOpts, StartPromptOpts } from '../ports/types'
|
|
31
31
|
import { readTerminalGuardBoundary } from '../store/reduced-reads'
|
|
32
32
|
import type { OpenSession } from '../kernel/reducer'
|
|
33
33
|
import { nativeSessionHandleSchema } from '../ports/runner/native-session'
|
|
@@ -47,7 +47,12 @@ import {
|
|
|
47
47
|
requireRewrite,
|
|
48
48
|
} from '../kernel/reconcile-restack'
|
|
49
49
|
import { reconcileHead, reconcileRewriteHead } from '../kernel/reconcile-head'
|
|
50
|
-
import {
|
|
50
|
+
import {
|
|
51
|
+
readBuildFacts,
|
|
52
|
+
readBuildSelector,
|
|
53
|
+
readPhaseFailures,
|
|
54
|
+
type CurrentBuildFacts,
|
|
55
|
+
} from '../store/reduced-reads'
|
|
51
56
|
import { delegateCredential } from '../store/remote/credentials'
|
|
52
57
|
import { refreshSummaryBoundary } from '../cli/pr-summary-publication'
|
|
53
58
|
/**
|
|
@@ -103,6 +108,7 @@ import { KERNEL, agentActor, type Actor } from '../events/envelope'
|
|
|
103
108
|
import type { IdSource } from '../ids'
|
|
104
109
|
import { decideNextFromFacts, type Decision } from '../kernel/engine'
|
|
105
110
|
import { defineReducer } from '../kernel/incremental'
|
|
111
|
+
import { continuesVerifyCycle } from '../kernel/pr-summary'
|
|
106
112
|
import { PHASE_SPECS } from '../kernel/phases'
|
|
107
113
|
import type { BuildState } from '../kernel/reducer'
|
|
108
114
|
import { evaluateVerifyApplicability } from '../kernel/verify-applicability'
|
|
@@ -343,6 +349,20 @@ function capDiffOutput(output: string): string {
|
|
|
343
349
|
return `${output.slice(0, FINALIZE_DIFF_CAPTURE_CAP)}\n... (truncated at ${FINALIZE_DIFF_CAPTURE_CAP} characters)`
|
|
344
350
|
}
|
|
345
351
|
|
|
352
|
+
/** The runtime's own first message for a fresh start, spread onto
|
|
353
|
+
* `session.started`; empty when the runtime cannot report it. */
|
|
354
|
+
function recordedStartPrompt(runner: AgentRunner, opts: StartPromptOpts): { prompt?: string } {
|
|
355
|
+
const prompt = runner.startPrompt?.(opts)
|
|
356
|
+
return typeof prompt === 'string' && prompt !== '' ? { prompt } : {}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** The message a native resume sends after an interruption. */
|
|
360
|
+
function interruptionMessage(
|
|
361
|
+
cause: NonNullable<EventPayload<'session.started'>['continuation']>['cause'],
|
|
362
|
+
): string {
|
|
363
|
+
return `This session was interrupted (${cause}). Re-check the worktree and re-run anything that was in flight. Continue the current phase and round; run ab context for its durable inputs.`
|
|
364
|
+
}
|
|
365
|
+
|
|
346
366
|
function sessionBudgetError(seconds: number): string {
|
|
347
367
|
return `phase session budget expired after ${seconds} seconds`
|
|
348
368
|
}
|
|
@@ -829,6 +849,15 @@ export class BuildRunner {
|
|
|
829
849
|
},
|
|
830
850
|
},
|
|
831
851
|
}
|
|
852
|
+
// A continuation resumes the native session with the interruption
|
|
853
|
+
// notice, never the caller's start prompt.
|
|
854
|
+
write = {
|
|
855
|
+
...write,
|
|
856
|
+
payload: {
|
|
857
|
+
...write.payload,
|
|
858
|
+
prompt: interruptionMessage(write.payload.continuation!.cause),
|
|
859
|
+
},
|
|
860
|
+
}
|
|
832
861
|
started = await store.appendIfCurrent(slug, facts.cursor, write)
|
|
833
862
|
if (started) break
|
|
834
863
|
}
|
|
@@ -844,7 +873,7 @@ export class BuildRunner {
|
|
|
844
873
|
const continuation = this.continuationIntents.get(opts.env.AB_SESSION!)
|
|
845
874
|
this.continuationIntents.delete(opts.env.AB_SESSION!)
|
|
846
875
|
if (!continuation) return runner.start(opts)
|
|
847
|
-
const message =
|
|
876
|
+
const message = interruptionMessage(continuation.cause)
|
|
848
877
|
this.interruptionPrompts.set(opts.env.AB_SESSION!, message)
|
|
849
878
|
if (opts.stream)
|
|
850
879
|
opts.stream.append([
|
|
@@ -928,7 +957,7 @@ export class BuildRunner {
|
|
|
928
957
|
store: withDrainingExecution(
|
|
929
958
|
deps.store,
|
|
930
959
|
deps.instance,
|
|
931
|
-
deps.runtimeIdentity ??
|
|
960
|
+
deps.runtimeIdentity ?? runtimeIdentity(),
|
|
932
961
|
),
|
|
933
962
|
}
|
|
934
963
|
this.maxPhaseAttempts = deps.opts?.maxPhaseAttempts ?? 2
|
|
@@ -1070,7 +1099,7 @@ export class BuildRunner {
|
|
|
1070
1099
|
payload: {
|
|
1071
1100
|
instance,
|
|
1072
1101
|
attachedSeq: attached.seq,
|
|
1073
|
-
runtime: this.deps.runtimeIdentity ??
|
|
1102
|
+
runtime: this.deps.runtimeIdentity ?? runtimeIdentity(),
|
|
1074
1103
|
},
|
|
1075
1104
|
})
|
|
1076
1105
|
}
|
|
@@ -1400,7 +1429,7 @@ export class BuildRunner {
|
|
|
1400
1429
|
const request = relaunchTarget(
|
|
1401
1430
|
facts.state,
|
|
1402
1431
|
this.deps.instance,
|
|
1403
|
-
this.deps.runtimeIdentity ??
|
|
1432
|
+
this.deps.runtimeIdentity ?? runtimeIdentity(),
|
|
1404
1433
|
)
|
|
1405
1434
|
if (!request) return false
|
|
1406
1435
|
if (
|
|
@@ -1461,7 +1490,7 @@ export class BuildRunner {
|
|
|
1461
1490
|
const facts = (await readBuildFacts(this.deps.store, this.deps.slug)).value
|
|
1462
1491
|
if (await this.requestRelaunch(facts)) break
|
|
1463
1492
|
if (await deferMixedVersion(this.deps.store, this.deps.slug, KERNEL)) break
|
|
1464
|
-
if (await this.refreshSummary()) break
|
|
1493
|
+
if (await this.refreshSummary(facts)) break
|
|
1465
1494
|
if (facts.publication.pending()) {
|
|
1466
1495
|
const next = decideNextFromFacts(facts.state, facts.log, await this.captureConfig())
|
|
1467
1496
|
// Inert controls cannot start more work under unsettled publication.
|
|
@@ -1527,21 +1556,38 @@ export class BuildRunner {
|
|
|
1527
1556
|
}
|
|
1528
1557
|
}
|
|
1529
1558
|
|
|
1530
|
-
private async refreshSummary(): Promise<boolean> {
|
|
1559
|
+
private async refreshSummary(facts: CurrentBuildFacts): Promise<boolean> {
|
|
1531
1560
|
if (await deferMixedVersion(this.deps.store, this.deps.slug, KERNEL)) return false
|
|
1532
1561
|
try {
|
|
1533
1562
|
await this.ensureLease()
|
|
1534
1563
|
} catch {
|
|
1535
1564
|
return false
|
|
1536
1565
|
}
|
|
1537
|
-
return refreshSummaryBoundary(
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1566
|
+
return refreshSummaryBoundary(
|
|
1567
|
+
{
|
|
1568
|
+
store: this.deps.store,
|
|
1569
|
+
forge: this.deps.forge,
|
|
1570
|
+
slug: this.deps.slug,
|
|
1571
|
+
workspacePath: this.deps.workspacePath,
|
|
1572
|
+
storeRef: this.deps.sessionEnv?.AB_STORE ?? 'local',
|
|
1573
|
+
clock: this.deps.clock,
|
|
1574
|
+
},
|
|
1575
|
+
{ continuesVerifyCycle: this.summaryContinuesVerifyCycle(facts), reassert: true },
|
|
1576
|
+
)
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
/** Pure over the loop's facts and the config that decided the last step;
|
|
1580
|
+
* any doubt publishes as before. */
|
|
1581
|
+
private summaryContinuesVerifyCycle(facts: CurrentBuildFacts): boolean {
|
|
1582
|
+
try {
|
|
1583
|
+
return continuesVerifyCycle(
|
|
1584
|
+
facts.summaryBoundary,
|
|
1585
|
+
facts.log.verifyStarted,
|
|
1586
|
+
decideNextFromFacts(facts.state, facts.log, this.boundaryConfig),
|
|
1587
|
+
)
|
|
1588
|
+
} catch {
|
|
1589
|
+
return false
|
|
1590
|
+
}
|
|
1545
1591
|
}
|
|
1546
1592
|
|
|
1547
1593
|
/**
|
|
@@ -2836,6 +2882,7 @@ export class BuildRunner {
|
|
|
2836
2882
|
phase: 'finalize',
|
|
2837
2883
|
round: 1,
|
|
2838
2884
|
...(streamBracket !== undefined ? { stream: streamBracket.streamId } : {}),
|
|
2885
|
+
...recordedStartPrompt(target.runner, { skill, invocation: slug, buildSlug: slug }),
|
|
2839
2886
|
...(substitution !== undefined
|
|
2840
2887
|
? { substitution: { failed: substitution, selectedIndex: index } }
|
|
2841
2888
|
: {}),
|
|
@@ -2906,7 +2953,12 @@ export class BuildRunner {
|
|
|
2906
2953
|
// The failure-tolerant post-step still records its outcome below.
|
|
2907
2954
|
}
|
|
2908
2955
|
}
|
|
2909
|
-
if (
|
|
2956
|
+
if (
|
|
2957
|
+
await this.settleReadDeferral(session, {
|
|
2958
|
+
completed:
|
|
2959
|
+
turn.abortCause === undefined && turnError === undefined && result?.kind !== 'failed',
|
|
2960
|
+
})
|
|
2961
|
+
) {
|
|
2910
2962
|
this.closeBracketStream(streamBracket, 'aborted')
|
|
2911
2963
|
return { actor: agentActor(step, session), failureNote: undefined, cancelled: true }
|
|
2912
2964
|
}
|
|
@@ -2991,6 +3043,7 @@ export class BuildRunner {
|
|
|
2991
3043
|
phase: 'finalize',
|
|
2992
3044
|
round: 1,
|
|
2993
3045
|
...(streamBracket !== undefined ? { stream: streamBracket.streamId } : {}),
|
|
3046
|
+
...recordedStartPrompt(runner, { skill, invocation: slug, buildSlug: slug }),
|
|
2994
3047
|
},
|
|
2995
3048
|
} satisfies EventWrite<'session.started'>)
|
|
2996
3049
|
|
|
@@ -3062,7 +3115,9 @@ export class BuildRunner {
|
|
|
3062
3115
|
failureNote === undefined && turn.abortCause !== 'operator' ? 'completed' : 'aborted',
|
|
3063
3116
|
)
|
|
3064
3117
|
|
|
3065
|
-
const deferred = await this.settleReadDeferral(session
|
|
3118
|
+
const deferred = await this.settleReadDeferral(session, {
|
|
3119
|
+
completed: failureNote === undefined && turn.abortCause === undefined,
|
|
3120
|
+
})
|
|
3066
3121
|
return {
|
|
3067
3122
|
actor: agentActor(step, session),
|
|
3068
3123
|
failureNote,
|
|
@@ -3616,6 +3671,7 @@ export class BuildRunner {
|
|
|
3616
3671
|
round: spec.round,
|
|
3617
3672
|
})
|
|
3618
3673
|
const stream = streamBracket?.sink
|
|
3674
|
+
const live = index === 0 ? primaryLive : undefined
|
|
3619
3675
|
const startedEnvelope = await this.startBracket({
|
|
3620
3676
|
actor: KERNEL,
|
|
3621
3677
|
type: 'session.started',
|
|
@@ -3632,10 +3688,16 @@ export class BuildRunner {
|
|
|
3632
3688
|
...(substitution !== undefined
|
|
3633
3689
|
? { substitution: { failed: substitution, selectedIndex: index } }
|
|
3634
3690
|
: {}),
|
|
3691
|
+
...(live !== undefined
|
|
3692
|
+
? { prompt: continueMessage(spec) }
|
|
3693
|
+
: recordedStartPrompt(target.runner, {
|
|
3694
|
+
skill: spec.skill,
|
|
3695
|
+
invocation: slug,
|
|
3696
|
+
buildSlug: slug,
|
|
3697
|
+
})),
|
|
3635
3698
|
},
|
|
3636
3699
|
} satisfies EventWrite<'session.started'>)
|
|
3637
3700
|
const preSeq = startedEnvelope.seq
|
|
3638
|
-
const live = index === 0 ? primaryLive : undefined
|
|
3639
3701
|
|
|
3640
3702
|
let handle: AgentSessionHandle | undefined = live?.handle
|
|
3641
3703
|
let result: AgentTurnResult | undefined
|
|
@@ -3940,6 +4002,9 @@ export class BuildRunner {
|
|
|
3940
4002
|
phase: spec.phase,
|
|
3941
4003
|
round: spec.round,
|
|
3942
4004
|
...(streamBracket !== undefined ? { stream: streamBracket.streamId } : {}),
|
|
4005
|
+
...(live !== undefined
|
|
4006
|
+
? { prompt: continueMessage(spec) }
|
|
4007
|
+
: recordedStartPrompt(runner, { skill: spec.skill, invocation: slug, buildSlug: slug })),
|
|
3943
4008
|
},
|
|
3944
4009
|
} satisfies EventWrite<'session.started'>)
|
|
3945
4010
|
const preSeq = startedEnvelope.seq
|
|
@@ -4384,12 +4449,24 @@ export class BuildRunner {
|
|
|
4384
4449
|
* new evidence instead of deadlocking before its recovery session starts.
|
|
4385
4450
|
*/
|
|
4386
4451
|
|
|
4387
|
-
|
|
4452
|
+
/**
|
|
4453
|
+
* Settle the session's pending own-build read deferral. Returns true when it
|
|
4454
|
+
* parked the build. A finalize post-step never calls a terminal, so only
|
|
4455
|
+
* durable recovery evidence (`session.build-read-recovered`, newer than the
|
|
4456
|
+
* chain's latest failure) plus a `completed` turn retires its deferral; the
|
|
4457
|
+
* caller's `finalize.step-completed` then clears it.
|
|
4458
|
+
*/
|
|
4459
|
+
private async settleReadDeferral(
|
|
4460
|
+
session: string,
|
|
4461
|
+
opts?: { completed?: boolean },
|
|
4462
|
+
): Promise<boolean> {
|
|
4388
4463
|
const { store, slug } = this.deps
|
|
4389
4464
|
const item = (await readBuildFacts(store, slug)).value.log.readDeferrals.find(
|
|
4390
4465
|
(item) => item.session === session,
|
|
4391
4466
|
)
|
|
4392
4467
|
if (!item) return false
|
|
4468
|
+
const recovered =
|
|
4469
|
+
opts?.completed === true && item.phase === 'finalize' && item.recovered && !item.settled
|
|
4393
4470
|
if (!item.ended) {
|
|
4394
4471
|
await store.append(slug, {
|
|
4395
4472
|
actor: KERNEL,
|
|
@@ -4404,6 +4481,7 @@ export class BuildRunner {
|
|
|
4404
4481
|
},
|
|
4405
4482
|
})
|
|
4406
4483
|
}
|
|
4484
|
+
if (recovered) return false
|
|
4407
4485
|
await this.raiseReadDeferral(item)
|
|
4408
4486
|
return true
|
|
4409
4487
|
}
|