@defrex/autobuild 1.14.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.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +44 -5
  3. package/docs/architecture.md +43 -6
  4. package/docs/configuration.md +8 -3
  5. package/docs/dispatcher-hosting.md +13 -0
  6. package/docs/remote-store-protocol.md +1 -1
  7. package/docs/troubleshooting.md +33 -3
  8. package/docs/workspaces.md +2 -1
  9. package/package.json +3 -3
  10. package/packages/core/src/cli/dispatch.ts +171 -5
  11. package/packages/core/src/cli/repository-status.ts +15 -0
  12. package/packages/core/src/events/policy.ts +1 -0
  13. package/packages/core/src/events/repository.ts +95 -6
  14. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/23d33121de6d3325.json +107 -0
  15. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/e28c68e63cbd265f.json +108 -0
  16. package/packages/core/src/kernel/reducer-revisions.ts +3 -0
  17. package/packages/core/src/kernel/repository-read-facts.ts +9 -0
  18. package/packages/core/src/ports/types.ts +10 -4
  19. package/packages/core/src/ports/workspace/vercel-sandbox.ts +281 -75
  20. package/packages/core/src/processes/dispatcher.ts +1142 -265
  21. package/packages/core/src/processes/invocation-budget.ts +6 -0
  22. package/packages/core/src/processes/launch-cut.ts +37 -0
  23. package/packages/core/src/processes/pass-stages.ts +294 -0
  24. package/packages/core/src/store/reducer-value-shapes.json +5285 -5003
  25. package/packages/core/src/store/remote/released-clients.json +22 -0
  26. package/packages/core/src/store/remote/released-reducer-values/1.15.0.json +36354 -0
  27. package/packages/core/src/store/remote/released-reducer-values/1.16.0.json +36358 -0
  28. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  29. package/packages/core/src/store/remote/released-value-policy.ts +7 -0
  30. package/packages/core/src/store/repo-state-events.ts +1 -0
  31. package/packages/core/src/testing/reduced-read-budget.ts +285 -8
  32. package/skills/guide/SKILL.md +25 -3
  33. package/skills/guide/references/remote-store-protocol.md +1 -1
  34. package/skills/operate/SKILL.md +16 -4
  35. package/templates/hosted-service/package.json +2 -2
@@ -5,14 +5,16 @@ import release2 from './1.11.1.json'
5
5
  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
- import release6 from './1.2.0.json'
9
- import release7 from './1.3.0.json'
10
- import release8 from './1.4.0.json'
11
- import release9 from './1.5.0.json'
12
- import release10 from './1.6.0.json'
13
- import release11 from './1.7.0.json'
14
- import release12 from './1.8.0.json'
15
- import release13 from './1.9.0.json'
8
+ import release6 from './1.15.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'
16
18
  import type { ReducerValueCatalog } from '../../reducer-value-validation'
17
19
  export interface ReleasedReducerValues extends ReducerValueCatalog {
18
20
  versions: Record<string, number>
@@ -24,12 +26,14 @@ export const RELEASED_REDUCER_VALUES: Readonly<Record<string, ReleasedReducerVal
24
26
  '1.12.0.json': release3,
25
27
  '1.13.0.json': release4,
26
28
  '1.14.0.json': release5,
27
- '1.2.0.json': release6,
28
- '1.3.0.json': release7,
29
- '1.4.0.json': release8,
30
- '1.5.0.json': release9,
31
- '1.6.0.json': release10,
32
- '1.7.0.json': release11,
33
- '1.8.0.json': release12,
34
- '1.9.0.json': release13,
29
+ '1.15.0.json': release6,
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,
35
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: [
@@ -67,6 +67,7 @@ export const REPOSITORY_LATEST_EVENT_TYPES: readonly RepositoryEventType[] = [
67
67
  'dispatcher.ticket-scan-completed',
68
68
  'dispatcher.placement-set',
69
69
  'dispatcher.work-deferred',
70
+ 'dispatcher.pass-cursors',
70
71
  ]
71
72
  const LATEST_TYPES = new Set<string>(REPOSITORY_LATEST_EVENT_TYPES)
72
73
 
@@ -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,267 @@ 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 },
2782
+ })
2783
+ }
2784
+
2785
+ /** #1409: carrying the rotated loops' positions between bounded passes, and
2786
+ * checking mixed-version deferral only on the build acted on. Positions come
2787
+ * from the repository facts the tick's refresh already reduced, so carrying
2788
+ * one adds no read; a pass that cuts no loop writes nothing once they are
2789
+ * clear. No listing reads a build's facts for compatibility: settled builds
2790
+ * a newer writer's decisive fact defers are never read, however many there
2791
+ * are. Fresh dispatchers per tick: no per-process cache. */
2792
+ export async function passCursorsReadBudget(): Promise<void> {
2793
+ const { newerFact, seedNewerMemoryFact } = await import('./newer-writer')
2794
+ const { MemoryBuildStore } = await import('../store/memory')
2795
+ const repo = '/repos/pass-cursors'
2796
+ const sha = 'a'.repeat(40)
2797
+ const config = parseConfig('[tickets]\nsource = "file"\nreadyState = "Ready"\n')
2798
+ async function world(length: number, settled: number) {
2799
+ let now = Date.parse('2026-12-01T00:00:00.000Z')
2800
+ const clock = () => new Date(now)
2801
+ const store = new MemoryBuildStore({ clock })
2802
+ await store.ensureRepo(repo)
2803
+ const create = async (slug: string) => {
2804
+ const ticket = { source: 'fake', id: `T-${slug}`, title: slug }
2805
+ await store.createBuild({
2806
+ slug,
2807
+ repo,
2808
+ ticket,
2809
+ branch: `ab/${slug}`,
2810
+ created: {
2811
+ actor: DISPATCHER,
2812
+ type: 'build.created',
2813
+ payload: { ticket, repo, baseBranch: 'main' },
2814
+ },
2815
+ })
2816
+ return ticket
2817
+ }
2818
+ const running = async (slug: string) => {
2819
+ const ticket = await create(slug)
2820
+ for (const event of [
2821
+ {
2822
+ type: 'workspace.provisioned',
2823
+ payload: {
2824
+ provider: 'fake',
2825
+ ref: `/ws/ab/${slug}`,
2826
+ branch: `ab/${slug}`,
2827
+ base: { source: 'remote', sha },
2828
+ },
2829
+ },
2830
+ { type: 'spec.imported', payload: { artifact: { kind: 'spec', rev: 0 }, ticket } },
2831
+ { type: 'target.moved', payload: { branch: 'main', sha } },
2832
+ { type: 'slot.admitted', payload: {} },
2833
+ ])
2834
+ await store.append(slug, { actor: DISPATCHER, ...event } as never)
2835
+ await store.append(slug, { actor: KERNEL, type: 'plan.started', payload: { round: 1 } })
2836
+ }
2837
+ // The janitor's work: running leaves with live runners and long histories.
2838
+ const busy = ['busy-a', 'busy-b']
2839
+ for (const slug of busy) {
2840
+ await running(slug)
2841
+ await seedBuildFiller(store, slug, length, INERT_BUILD_FILLER)
2842
+ await store.claimLease(slug, `${slug}-runner`, 365 * 24 * 3_600_000)
2843
+ }
2844
+ // Settled builds a newer writer's decisive fact defers.
2845
+ const deferred: string[] = []
2846
+ for (let i = 1; i <= settled; i++) {
2847
+ const slug = `settled-${i}`
2848
+ await create(slug)
2849
+ await store.append(slug, {
2850
+ actor: DISPATCHER,
2851
+ type: 'build.completed',
2852
+ payload: { outcome: 'merged' },
2853
+ })
2854
+ seedNewerMemoryFact(store, newerFact(3, 'decisive', slug))
2855
+ deferred.push(slug)
2856
+ }
2857
+ // One live build it defers, which the stages reach.
2858
+ await running('live-mixed')
2859
+ seedNewerMemoryFact(
2860
+ store,
2861
+ newerFact((await store.getEvents('live-mixed')).length + 1, 'decisive', 'live-mixed'),
2862
+ )
2863
+ now += 3_600_000
2864
+ // One canonical reduction per key happens before anything is measured.
2865
+ await readRepositoryFacts(store, repo)
2866
+ await readBuildDigests(store, repo)
2867
+ for (const slug of [...busy, 'live-mixed', ...deferred]) await readBuildFacts(store, slug)
2868
+ const forge = new FakeForge()
2869
+ forge.seedBranch('main', sha)
2870
+ const tick = async () => {
2871
+ const dispatcher = new Dispatcher({
2872
+ store,
2873
+ tickets: new FakeTicketSource([]),
2874
+ workspaces: new FakeWorkspaceProvider({
2875
+ root: '/ws',
2876
+ mode: 'logical',
2877
+ base: { source: 'remote', sha },
2878
+ }),
2879
+ forge,
2880
+ config,
2881
+ repo,
2882
+ exec: async () => ({ stdout: `${sha}\trefs/heads/main\n`, stderr: '', exitCode: 0 }),
2883
+ launchRunner: async () => 'scheduled' as const,
2884
+ ids: sequentialIds(),
2885
+ clock,
2886
+ })
2887
+ const facts: Record<string, number> = {}
2888
+ const read = store.getReducerValue.bind(store)
2889
+ store.getReducerValue = async (...args: Parameters<typeof read>) => {
2890
+ const [scope, request] = args
2891
+ if (scope.kind === 'build' && request.reducer === 'buildReadFacts')
2892
+ facts[scope.slug] = (facts[scope.slug] ?? 0) + 1
2893
+ return read(...args)
2894
+ }
2895
+ const positions = async () =>
2896
+ (await store.getRepoEvents(repo)).filter((e) => e.type === 'dispatcher.pass-cursors').length
2897
+ const before = await positions()
2898
+ try {
2899
+ const metrics = await measureStoreReads(store, async () => {
2900
+ await dispatcher.tick({ acceptNewWork: false, deadlineAt: now + 250_000 })
2901
+ })
2902
+ // The store's public reads: what a remote store would serve.
2903
+ const calls = Object.fromEntries(
2904
+ Object.entries(metrics.calls).filter(([name]) =>
2905
+ [
2906
+ 'getReducerValue',
2907
+ 'getRepoBuildDigests',
2908
+ 'listBuilds',
2909
+ 'getArtifact',
2910
+ 'getRepo',
2911
+ 'getEvents',
2912
+ 'getRepoEvents',
2913
+ 'getBuild',
2914
+ ].includes(name),
2915
+ ),
2916
+ )
2917
+ return { calls, repoRows: metrics.repoRows, facts, wrote: (await positions()) - before }
2918
+ } finally {
2919
+ store.getReducerValue = read
2920
+ now += 60_000
2921
+ }
2922
+ }
2923
+ const carry = (cursors: Record<string, string>) =>
2924
+ store.appendRepo(repo, {
2925
+ actor: DISPATCHER,
2926
+ type: 'dispatcher.pass-cursors',
2927
+ payload: { cursors },
2928
+ })
2929
+ return { tick, carry, deferred }
2930
+ }
2931
+
2932
+ const measured: Record<string, unknown> = {}
2933
+ for (const length of [100, 100_000]) {
2934
+ for (const settled of [20, 200]) {
2935
+ const w = await world(length, settled)
2936
+ // Settle the first tick's own writes (deferral, observations).
2937
+ await w.tick()
2938
+ await w.tick()
2939
+ const plain = await w.tick()
2940
+ // Nothing cut and no position held: nothing written, no new row read.
2941
+ expect(plain.wrote).toBe(0)
2942
+ expect(plain.repoRows).toBe(0)
2943
+ // Settled deferred builds are never read; the live one at most once.
2944
+ for (const slug of w.deferred) expect(plain.facts[slug]).toBeUndefined()
2945
+ expect(plain.facts['live-mixed']).toBe(1)
2946
+ // A carried position reads what a pass after any other new repository
2947
+ // row reads, the refresh's tail, plus the later refresh of the one
2948
+ // append that clears it once every build was reached.
2949
+ await w.carry({})
2950
+ const baseline = await w.tick()
2951
+ expect(baseline.wrote).toBe(0)
2952
+ await w.carry({ janitor: 'busy-a', sweep: 'busy-a' })
2953
+ const carried = await w.tick()
2954
+ expect(carried.wrote).toBe(1)
2955
+ expect(carried.calls).toEqual({
2956
+ ...baseline.calls,
2957
+ getReducerValue: baseline.calls.getReducerValue! + 1,
2958
+ getRepo: baseline.calls.getRepo! + 1,
2959
+ })
2960
+ expect(carried.repoRows).toBe(baseline.repoRows + 1)
2961
+ // The clearing row is read at most once more, then nothing.
2962
+ expect((await w.tick()).repoRows).toBeLessThanOrEqual(baseline.repoRows)
2963
+ const idle = await w.tick()
2964
+ expect(idle).toMatchObject({ wrote: 0, repoRows: 0 })
2965
+ measured[`${length}:${settled}`] = { calls: plain.calls, facts: plain.facts }
2966
+ }
2967
+ }
2968
+ // The same reads at 100 and 100,000 events; the same facts reads whatever
2969
+ // the number of deferred builds (only the store's own digest batch grows
2970
+ // with the fleet).
2971
+ expect(measured['100:20']).toEqual(measured['100000:20'])
2972
+ expect(measured['100:200']).toEqual(measured['100000:200'])
2973
+ const facts = Object.values(measured).map((entry) => (entry as { facts: unknown }).facts)
2974
+ for (const other of facts) expect(other).toEqual(facts[0])
2975
+ console.log('pass cursors read budget', {
2976
+ histories: [100, 100_000],
2977
+ settledDeferred: [20, 200],
2978
+ tick: measured['100:20'],
2702
2979
  })
2703
2980
  }
2704
2981
 
@@ -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
@@ -1269,7 +1270,28 @@ cut short is stopped or left uncertain for a later fence. The tick counts the
1269
1270
  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
- the next invocation runs that build first.
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.
1284
+ No stage consumes a bounded invocation: each starts items only within its share
1285
+ of the time left when it begins (half for deferred work, the janitor and the
1286
+ lease sweep, a quarter for the others; intake runs to the work deadline), and
1287
+ each helper still gets its first item. Loops whose items stay listed (execution
1288
+ and harvest settlement, the janitor, hand-backs, dispatch recovery, resume, the
1289
+ lease sweep) continue next invocation after the last item they started,
1290
+ through the latest-only `dispatcher.pass-cursors` fact, so every build is
1291
+ visited within a bounded number of passes. Each pass logs `stages:` with time
1292
+ and items per stage; a pass the work deadline cuts short logs `tick: work
1293
+ deadline reached during <stage>` naming the part in flight, and `ab repository
1294
+ status` shows the latest as `last pass stages:`.
1273
1295
  Fencing is revalidated after restart; a saved receipt alone never authorizes
1274
1296
  cleanup of a newer execution. Current recovery notes are linked by the session
1275
1297
  manifest's `workspaceRecovery` field. Recovery notes apply to the next session
@@ -776,7 +776,7 @@ builds.
776
776
  | `appendRepo` | `POST /repos/{repo}/events` | event write | `201` + repository event envelope |
777
777
  | `appendRepoIfCurrent` | `POST /repos/{repo}/events/conditional` | `{"expectedSeq": nonnegative integer, "event": event write}` | appended: `201` + repository event envelope; journal advanced: `200 null` (mirroring section 3's build compare-and-append). A server without the route answers `404`; callers report it and never fall back to an unconditional append |
778
778
  | `getRepoEvents` / `getRepositoryTail` | `GET /repos/{repo}/events?since={n}&through={n}&wait={s}` | optional `since` query value, parsed as in section 3; absence defaults to `0`. Optional `wait` in whole seconds, per the event-wait rules of section 3 | `200` + envelopes with `seq > since`, up to the frozen head; optional `through` caps the response at `seq <= through`; `409 cursor-too-old` below `max(0, head - 1000)` |
779
- | `getRepoStateEvents` | `GET /repos/{repo}/state-events` | none | `200` + the bounded repository-journal subset (AUT-489): every durable event type (`ticket-preparation.*`, `harvest.*`, `orchestrator.sandbox.*`, the three dispatcher setting types, and cross-generation handoff correlation facts: target-prepared, yield-requested, upgrade-failed, handoff-started, terminal-released, takeover, drain-deadline, drain-settled and handoff-completed) plus the latest-only `dispatcher.ticket-scan-completed`, `dispatcher.placement-set` and `dispatcher.work-deferred` facts and, when the journal has one, the tail from the latest `dispatcher.run-started`, in increasing sequence order; served inside the repository-existence gate like `GET events`, so an unknown repository is `404` |
779
+ | `getRepoStateEvents` | `GET /repos/{repo}/state-events` | none | `200` + the bounded repository-journal subset (AUT-489): every durable event type (`ticket-preparation.*`, `harvest.*`, `orchestrator.sandbox.*`, the three dispatcher setting types, and cross-generation handoff correlation facts: target-prepared, yield-requested, upgrade-failed, handoff-started, terminal-released, takeover, drain-deadline, drain-settled and handoff-completed) plus the latest-only `dispatcher.ticket-scan-completed`, `dispatcher.placement-set`, `dispatcher.work-deferred` and `dispatcher.pass-cursors` facts and, when the journal has one, the tail from the latest `dispatcher.run-started`, in increasing sequence order; served inside the repository-existence gate like `GET events`, so an unknown repository is `404` |
780
780
  | `getReducerSnapshot` (repo scope) | `GET /repos/{repo}/snapshots/{reducer}?version={n}` | required `version` query value, a positive integer; `reducer` is a registry name (`^[A-Za-z][A-Za-z0-9._-]{0,63}$`) | `200` + `{"version", "cursor", "state"}` or `200 null` when absent, written by another reducer version, ahead of the journal's tail, or the repository has no journal record; an unknown repository is `404`, which the shipped client also maps to `null` |
781
781
  | `putReducerSnapshot` (repo scope) | `PUT /repos/{repo}/snapshots/{reducer}` | `{"version": int >= 1, "cursor": int >= 0, "state": JSON}`, at most 16 MiB (`413` above) | `200 {"written": boolean}`; the stored cursor never decreases, so a write at an equal or lower cursor (or an equal cursor at an equal or lower version) and one past the journal's tail answer `written: false` |
782
782
  | `appendRepoWithArtifacts` | `POST /repos/{repo}/deposits` | atomic deposit request | `201` + `{event, artifacts}` using repository shapes |
@@ -1131,10 +1131,22 @@ 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.
1141
+ Each hosted invocation logs `stages:` with time and items per stage, and `ab
1142
+ repository status` shows the latest as `last pass stages:`. `(share)` on a
1143
+ stage is normal under load. Settlement, janitor, hand-back, recovery, resume
1144
+ and lease-sweep loops continue next invocation after the last item they
1145
+ started; priority-ordered admission and intake loops keep their order.
1146
+ `tick: work deadline reached during <stage>` names the stage and part the
1147
+ deadline stopped. The same stage or part stopping at the deadline on
1148
+ invocation after invocation means one visit there outlasts the window: report
1149
+ it with those lines.
1138
1150
 
1139
1151
  Leaf restack and reconcile publication retry classified transient forge or transport
1140
1152
  failures six times after the initial attempt, waiting 30, 60, 120, 240, 300 and
@@ -4,8 +4,8 @@
4
4
  "build": "ab-hosted-service-build"
5
5
  },
6
6
  "dependencies": {
7
- "@defrex/autobuild-hosted-store-service": "1.14.0",
8
- "@defrex/autobuild": "1.14.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"