@defrex/autobuild 1.15.0 → 1.16.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.
@@ -6,14 +6,15 @@ import release3 from './1.12.0.json'
6
6
  import release4 from './1.13.0.json'
7
7
  import release5 from './1.14.0.json'
8
8
  import release6 from './1.15.0.json'
9
- import release7 from './1.2.0.json'
10
- import release8 from './1.3.0.json'
11
- import release9 from './1.4.0.json'
12
- import release10 from './1.5.0.json'
13
- import release11 from './1.6.0.json'
14
- import release12 from './1.7.0.json'
15
- import release13 from './1.8.0.json'
16
- import release14 from './1.9.0.json'
9
+ import release7 from './1.16.0.json'
10
+ import release8 from './1.2.0.json'
11
+ import release9 from './1.3.0.json'
12
+ import release10 from './1.4.0.json'
13
+ import release11 from './1.5.0.json'
14
+ import release12 from './1.6.0.json'
15
+ import release13 from './1.7.0.json'
16
+ import release14 from './1.8.0.json'
17
+ import release15 from './1.9.0.json'
17
18
  import type { ReducerValueCatalog } from '../../reducer-value-validation'
18
19
  export interface ReleasedReducerValues extends ReducerValueCatalog {
19
20
  versions: Record<string, number>
@@ -26,12 +27,13 @@ export const RELEASED_REDUCER_VALUES: Readonly<Record<string, ReleasedReducerVal
26
27
  '1.13.0.json': release4,
27
28
  '1.14.0.json': release5,
28
29
  '1.15.0.json': release6,
29
- '1.2.0.json': release7,
30
- '1.3.0.json': release8,
31
- '1.4.0.json': release9,
32
- '1.5.0.json': release10,
33
- '1.6.0.json': release11,
34
- '1.7.0.json': release12,
35
- '1.8.0.json': release13,
36
- '1.9.0.json': release14,
30
+ '1.16.0.json': release7,
31
+ '1.2.0.json': release8,
32
+ '1.3.0.json': release9,
33
+ '1.4.0.json': release10,
34
+ '1.5.0.json': release11,
35
+ '1.6.0.json': release12,
36
+ '1.7.0.json': release13,
37
+ '1.8.0.json': release14,
38
+ '1.9.0.json': release15,
37
39
  }
@@ -40,6 +40,13 @@ export const RELEASED_VALUE_POLICY: readonly ReleasedValuePolicy[] = [
40
40
  reason:
41
41
  'Every supported release knows released, stopped and live. A provisioning or failed sandbox has no usable live environment, which older readers spell stopped: their repository status shows it as stopped, dispatcher idle settlement acts only on live, and an operator open of a stopped environment ensures it again, which is what a failed or unfinished one needs.',
42
42
  },
43
+ {
44
+ kind: 'map',
45
+ sites: ['repositoryReadFacts:$.deferredWork.builds[].step'],
46
+ map: { launch: 'resume' },
47
+ reason:
48
+ 'A launch the work deadline cut (#1415) is carried like any other deferred start. Released readers serve every carried entry through the lease sweep, re-deriving the decision from build state, and use the step only to name it; a resume entry takes exactly that path. They drop the optional cut instance, so they never release a cut holder: its lease expires and their ordinary sweep fences it.',
49
+ },
43
50
  {
44
51
  kind: 'refuse',
45
52
  sites: [
@@ -2531,7 +2531,9 @@ export async function deferredWorkReadBudget(): Promise<void> {
2531
2531
  const repo = '/repos/deferred-work'
2532
2532
  const sha = 'a'.repeat(40)
2533
2533
  const config = parseConfig('[tickets]\nsource = "file"\nreadyState = "Ready"\n')
2534
- async function world(length: number, unrelated: number) {
2534
+ /** `queued`: the carried build was claimed and admitted but never
2535
+ * provisioned (#1415). */
2536
+ async function world(length: number, unrelated: number, carried: 'leaf' | 'queued' = 'leaf') {
2535
2537
  let now = Date.parse('2026-12-01T00:00:00.000Z')
2536
2538
  const clock = () => new Date(now)
2537
2539
  const store = new MemoryBuildStore({ clock })
@@ -2557,7 +2559,7 @@ export async function deferredWorkReadBudget(): Promise<void> {
2557
2559
  await store.createBuild(created(slug))
2558
2560
  await seedBuildFiller(store, slug, length, INERT_BUILD_FILLER)
2559
2561
  const ticket = { source: 'fake', id: `T-${slug}`, title: slug }
2560
- for (const event of [
2562
+ const seeded = [
2561
2563
  {
2562
2564
  type: 'workspace.provisioned',
2563
2565
  payload: {
@@ -2579,9 +2581,11 @@ export async function deferredWorkReadBudget(): Promise<void> {
2579
2581
  type: 'execution.ended',
2580
2582
  payload: { instance: 'i-1', workspaceRef: 'carried-g0', outcome: 'completed', exitCode: 0 },
2581
2583
  },
2582
- ])
2584
+ ]
2585
+ for (const event of carried === 'queued' ? seeded.slice(1, 3) : seeded)
2583
2586
  await store.append(slug, { actor: DISPATCHER, ...event } as never)
2584
- await store.append(slug, { actor: KERNEL, type: 'plan.started', payload: { round: 1 } })
2587
+ if (carried === 'leaf')
2588
+ await store.append(slug, { actor: KERNEL, type: 'plan.started', payload: { round: 1 } })
2585
2589
  now += 3_600_000
2586
2590
  const launches: string[] = []
2587
2591
  const dispatcher = () =>
@@ -2598,9 +2602,13 @@ export async function deferredWorkReadBudget(): Promise<void> {
2598
2602
  snapshots: { outcome: 'confirmed', deleted: 0 },
2599
2603
  }),
2600
2604
  },
2601
- provision: async () => {
2602
- throw new Error('not used')
2603
- },
2605
+ provision: async (input) => ({
2606
+ provider: 'remote-test',
2607
+ ref: `${input.branch}-g${input.generation ?? 0}`,
2608
+ path: '/remote/workspace',
2609
+ branch: input.branch,
2610
+ base: { source: 'existing' as const, sha },
2611
+ }),
2604
2612
  release: async () => {},
2605
2613
  },
2606
2614
  forge: (() => {
@@ -2623,7 +2631,19 @@ export async function deferredWorkReadBudget(): Promise<void> {
2623
2631
  await readBuildDigests(store, repo)
2624
2632
  await readBuildFacts(store, slug)
2625
2633
  for (let i = 1; i <= unrelated; i++) await readBuildFacts(store, `deferred-${i}`)
2626
- const carry = (builds: { slug: string; step: 'resume' }[]) =>
2634
+ // The dispatch budget the carried build's dispatch completion reads.
2635
+ if (carried === 'queued')
2636
+ await store.getReducerValue(
2637
+ { kind: 'build', slug },
2638
+ { reducer: 'dispatchFailureBudget', args: { infrastructureOwnsWorkspace: true } },
2639
+ )
2640
+ const carry = (
2641
+ builds: {
2642
+ slug: string
2643
+ step: 'resume' | 'provision' | 'launch' | 'fence'
2644
+ instance?: string
2645
+ }[],
2646
+ ) =>
2627
2647
  store.appendRepo(repo, {
2628
2648
  actor: DISPATCHER,
2629
2649
  type: 'dispatcher.work-deferred',
@@ -2642,6 +2662,7 @@ export async function deferredWorkReadBudget(): Promise<void> {
2642
2662
  })
2643
2663
  const whole = await measureStoreReads(store, async () => {
2644
2664
  await ticking.tick({ acceptNewWork: false })
2665
+ await ticking.drainProvisioning()
2645
2666
  })
2646
2667
  return { early: early!, carriedCalls: whole.slugs[slug] ?? 0 }
2647
2668
  }
@@ -2694,11 +2715,70 @@ export async function deferredWorkReadBudget(): Promise<void> {
2694
2715
  const withoutHint = (await swept.tick()).carriedCalls
2695
2716
  expect(carried.launches).toEqual(swept.launches)
2696
2717
  expect(withHint).toBeLessThanOrEqual(withoutHint)
2718
+
2719
+ // #1415: carried starts. A first provision on a claimed, never-provisioned
2720
+ // build; a launch the work deadline cut; and a cut launch whose fence is
2721
+ // still owed while its instance holds the lease. Each costs the same at
2722
+ // every history length and fleet size, reads only the carried build's
2723
+ // tail, and finishes its start in the early stage.
2724
+ const starts: Record<string, unknown[]> = {}
2725
+ const carriedStarts = [
2726
+ { kind: 'provision', world: 'queued', entry: { step: 'provision' } },
2727
+ { kind: 'launch', world: 'leaf', entry: { step: 'launch' } },
2728
+ { kind: 'fence', world: 'leaf', entry: { step: 'fence', instance: 'cut' } },
2729
+ ] as const
2730
+ // Both the history length and the fleet size differ between the two.
2731
+ for (const [length, unrelated] of [
2732
+ [100, 20],
2733
+ [100_000, 200],
2734
+ ] as const)
2735
+ for (const { kind, world: shape, entry } of carriedStarts) {
2736
+ const w = await world(length, unrelated, shape)
2737
+ if (shape === 'leaf') {
2738
+ // Warm the leaf's launch values once, as the resume case does.
2739
+ await w.carry([])
2740
+ await w.tick()
2741
+ w.launches.length = 0
2742
+ }
2743
+ if (kind === 'fence') expect(await w.store.claimLease(w.slug, 'cut', 86_400_000)).toBe(true)
2744
+ await w.carry([{ slug: w.slug, ...entry }])
2745
+ const { early, carriedCalls } = await w.tick()
2746
+ expect(w.launches).toEqual([w.slug])
2747
+ expect((await w.store.getBuild(w.slug))?.lease).toBeUndefined()
2748
+ // Only the tail the setup appended, never the seeded history.
2749
+ expect({
2750
+ kind,
2751
+ history: early.read.filter((row) => row.slug === w.slug && row.seq <= length).length,
2752
+ }).toEqual({ kind, history: 0 })
2753
+ const latest = (await w.store.getRepoEvents(repo)).findLast(
2754
+ (event) => event.type === 'dispatcher.work-deferred',
2755
+ )
2756
+ expect(latest?.payload).toEqual({ builds: [] })
2757
+ const runs = starts[kind] ?? []
2758
+ runs.push({ calls: early.calls, slugs: early.slugs, carriedCalls })
2759
+ starts[kind] = runs
2760
+ }
2761
+ for (const runs of Object.values(starts))
2762
+ for (const other of runs.slice(1)) expect(other).toEqual(runs[0])
2763
+
2764
+ // The carried first provision replaces the recovery stage's dispatch
2765
+ // completion, which then skips the build: no extra reads of it.
2766
+ const queuedCarried = await world(100, 0, 'queued')
2767
+ await queuedCarried.carry([{ slug: queuedCarried.slug, step: 'provision' }])
2768
+ const queuedRecovered = await world(100, 0, 'queued')
2769
+ const queuedWithHint = (await queuedCarried.tick()).carriedCalls
2770
+ const queuedWithoutHint = (await queuedRecovered.tick()).carriedCalls
2771
+ expect(queuedCarried.launches).toEqual(queuedRecovered.launches)
2772
+ expect(queuedWithHint).toBeLessThanOrEqual(queuedWithoutHint)
2697
2773
  console.log('deferred work read budget', {
2698
2774
  histories: [100, 100_000],
2699
2775
  unrelated: [20, 200],
2700
2776
  earlyStageCalls: first!.calls,
2701
2777
  carriedCallsPerTick: { withHint, withoutHint },
2778
+ carriedStartCalls: Object.fromEntries(
2779
+ Object.entries(starts).map(([kind, runs]) => [kind, runs[0]]),
2780
+ ),
2781
+ queuedCallsPerTick: { withHint: queuedWithHint, withoutHint: queuedWithoutHint },
2702
2782
  })
2703
2783
  }
2704
2784
 
@@ -1258,8 +1258,9 @@ down. A workspace
1258
1258
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
1259
1259
  releases it and provisions the next generation. Provisioning cut off by a
1260
1260
  recorded dispatcher teardown is the exception: the next invocation asks the
1261
- provider to verify and finish the same generation, and if it cannot, the
1262
- replacement consumes no infrastructure attempt. A preservation or release
1261
+ provider to verify and finish the same generation (the Vercel provider resumes
1262
+ after its last completed stage, at the commit it cloned), and if it cannot,
1263
+ the replacement consumes no infrastructure attempt. A preservation or release
1263
1264
  failure is recorded against its build, as an infrastructure failure or janitor
1264
1265
  attention, and never stops the dispatcher from advancing other builds. The
1265
1266
  recorded error and the infrastructure-limit escalation name the failed recovery
@@ -1270,6 +1271,16 @@ build as `recoveryDeferred` (or `provisioningDeferred` for a provision that
1270
1271
  needs about 150 s), logs `build <slug>: <step> deferred by the invocation
1271
1272
  budget`, never reports idle, and records it in `dispatcher.work-deferred`, so
1272
1273
  the next invocation runs that build first, within half of its window.
1274
+ Every start a bounded invocation admits but does not finish is carried this
1275
+ way. That includes the first provision of a build intake just claimed, which
1276
+ the next invocation runs by completing the build's dispatch. It also includes a
1277
+ launch the work deadline cuts after its execution lease was claimed, logged as
1278
+ step `launch`. Teardown releases that lease, after fencing the sandbox when the
1279
+ provider start was already requested. When teardown cannot confirm the fence or
1280
+ the release, the entry keeps the cut execution's instance, and the next
1281
+ invocation fences or releases it before anything else. A carried build keeps
1282
+ its slot. Its entry retires without launching anything when the build is
1283
+ aborted, discarded, paused or no longer needs the start.
1273
1284
  No stage consumes a bounded invocation: each starts items only within its share
1274
1285
  of the time left when it begins (half for deferred work, the janitor and the
1275
1286
  lease sweep, a quarter for the others; intake runs to the work deadline), and
@@ -1131,10 +1131,13 @@ slow cold resume of a stopped sandbox: retry, or suggest raising
1131
1131
  `at step cleanup` points at sandbox or provider state worth checking before a
1132
1132
  retry; `at step preserve` at the checkout, forge credentials or branch.
1133
1133
  A dispatch log line `build X: resume deferred by the invocation budget` (or
1134
- `provision deferred`), counted as `recoveryDeferred` or `provisioningDeferred`,
1135
- is normal: nothing is charged and the next invocation runs that build first.
1136
- The same build deferring across several invocations means the hosted budget
1137
- cannot fit that work: report it, and do not retry it.
1134
+ `provision deferred`, or `launch deferred` for a launch the work deadline cut),
1135
+ counted as `recoveryDeferred` or `provisioningDeferred`, is normal: nothing is
1136
+ charged, the build keeps its slot, and the next invocation runs that build
1137
+ first. The same build deferring across several invocations means the hosted
1138
+ budget cannot fit that work: report it, and do not retry it. A `fence` line that
1139
+ repeats with an infrastructure failure at step `fence` means the provider
1140
+ cannot confirm the sandbox stopped: check the sandbox.
1138
1141
  Each hosted invocation logs `stages:` with time and items per stage, and `ab
1139
1142
  repository status` shows the latest as `last pass stages:`. `(share)` on a
1140
1143
  stage is normal under load. Settlement, janitor, hand-back, recovery, resume
@@ -4,8 +4,8 @@
4
4
  "build": "ab-hosted-service-build"
5
5
  },
6
6
  "dependencies": {
7
- "@defrex/autobuild-hosted-store-service": "1.15.0",
8
- "@defrex/autobuild": "1.15.0",
7
+ "@defrex/autobuild-hosted-store-service": "1.16.0",
8
+ "@defrex/autobuild": "1.16.0",
9
9
  "next": "16.1.6",
10
10
  "react": "19.2.4",
11
11
  "react-dom": "19.2.4"