@defrex/autobuild 1.13.0 → 1.15.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 +61 -11
- package/docs/answering-blocked-builds.md +5 -3
- package/docs/architecture.md +29 -0
- package/docs/configuration.md +16 -8
- package/docs/dispatcher-hosting.md +10 -0
- package/docs/operating.md +8 -0
- package/docs/operator-api.md +1 -1
- package/docs/operator-surfaces.md +1 -1
- package/docs/remote-store-protocol.md +1 -1
- package/docs/troubleshooting.md +35 -1
- package/package.json +3 -3
- package/packages/core/src/cli/dispatch.ts +105 -5
- package/packages/core/src/cli/repository-status.ts +15 -0
- package/packages/core/src/config/schema.ts +2 -2
- package/packages/core/src/events/policy.ts +2 -0
- package/packages/core/src/events/repository.ts +102 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +4 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/be211f0e31a65006.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/23d33121de6d3325.json +107 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/312cc4090820a612.json +1078 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a2780567b4989fb6.json +105 -0
- package/packages/core/src/kernel/done-escalations.ts +8 -4
- package/packages/core/src/kernel/reducer-revisions.ts +6 -0
- package/packages/core/src/kernel/reducer.ts +15 -1
- package/packages/core/src/kernel/repository-read-facts.ts +18 -0
- package/packages/core/src/ports/workspace/build-execution.ts +9 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +99 -12
- package/packages/core/src/processes/dispatcher.ts +957 -185
- package/packages/core/src/processes/execution-settlement.ts +24 -3
- package/packages/core/src/processes/pass-stages.ts +294 -0
- package/packages/core/src/processes/tick-publication.ts +1 -0
- package/packages/core/src/store/contract.ts +7 -0
- package/packages/core/src/store/reducer-value-shapes.json +5733 -5345
- package/packages/core/src/store/reducer-value-validation.ts +7 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.14.0.json +36076 -0
- package/packages/core/src/store/remote/released-reducer-values/1.15.0.json +36354 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +12 -2
- package/packages/core/src/testing/reduced-read-budget.ts +405 -1
- package/skills/guide/SKILL.md +29 -9
- package/skills/guide/references/operator-api.md +1 -1
- package/skills/guide/references/remote-store-protocol.md +1 -1
- package/skills/operate/SKILL.md +64 -5
- package/templates/hosted-service/package.json +2 -2
|
@@ -4,14 +4,16 @@ import release1 from './1.11.0.json'
|
|
|
4
4
|
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
|
-
import release5 from './1.
|
|
8
|
-
import release6 from './1.
|
|
9
|
-
import release7 from './1.
|
|
10
|
-
import release8 from './1.
|
|
11
|
-
import release9 from './1.
|
|
12
|
-
import release10 from './1.
|
|
13
|
-
import release11 from './1.
|
|
14
|
-
import release12 from './1.
|
|
7
|
+
import release5 from './1.14.0.json'
|
|
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'
|
|
15
17
|
import type { ReducerValueCatalog } from '../../reducer-value-validation'
|
|
16
18
|
export interface ReleasedReducerValues extends ReducerValueCatalog {
|
|
17
19
|
versions: Record<string, number>
|
|
@@ -22,12 +24,14 @@ export const RELEASED_REDUCER_VALUES: Readonly<Record<string, ReleasedReducerVal
|
|
|
22
24
|
'1.11.1.json': release2,
|
|
23
25
|
'1.12.0.json': release3,
|
|
24
26
|
'1.13.0.json': release4,
|
|
25
|
-
'1.
|
|
26
|
-
'1.
|
|
27
|
-
'1.
|
|
28
|
-
'1.
|
|
29
|
-
'1.
|
|
30
|
-
'1.
|
|
31
|
-
'1.
|
|
32
|
-
'1.
|
|
27
|
+
'1.14.0.json': release5,
|
|
28
|
+
'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,
|
|
33
37
|
}
|
|
@@ -66,6 +66,8 @@ export const REPOSITORY_STATE_EVENT_TYPES: readonly RepositoryEventType[] = [
|
|
|
66
66
|
export const REPOSITORY_LATEST_EVENT_TYPES: readonly RepositoryEventType[] = [
|
|
67
67
|
'dispatcher.ticket-scan-completed',
|
|
68
68
|
'dispatcher.placement-set',
|
|
69
|
+
'dispatcher.work-deferred',
|
|
70
|
+
'dispatcher.pass-cursors',
|
|
69
71
|
]
|
|
70
72
|
const LATEST_TYPES = new Set<string>(REPOSITORY_LATEST_EVENT_TYPES)
|
|
71
73
|
|
|
@@ -1008,8 +1008,15 @@ async function webOverviewReadBudget(store: BuildStore, backing: BuildStore): Pr
|
|
|
1008
1008
|
for (let i = 0; i < n - 5; i++) {
|
|
1009
1009
|
const slug = `${prefix}done-${String(i).padStart(6, '0')}`
|
|
1010
1010
|
await create(slug)
|
|
1011
|
-
// Every fourth build aborts, then finishes its cleanup.
|
|
1011
|
+
// Every fourth build aborts, then finishes its cleanup. The first was
|
|
1012
|
+
// blocked when aborted: the abort closed its escalation (#1387).
|
|
1012
1013
|
if (i % 4 === 3) {
|
|
1014
|
+
if (i === 3)
|
|
1015
|
+
await backing.append(slug, {
|
|
1016
|
+
actor: KERNEL,
|
|
1017
|
+
type: 'escalation.raised',
|
|
1018
|
+
payload: { id: 'abort-closed', phase: 'implement', source: 'agent', question: 'q' },
|
|
1019
|
+
})
|
|
1013
1020
|
await backing.append(slug, { actor: KERNEL, type: 'build.aborted', payload: {} })
|
|
1014
1021
|
await complete(slug, 'abandoned')
|
|
1015
1022
|
} else await complete(slug)
|
|
@@ -1098,10 +1105,13 @@ async function webOverviewReadBudget(store: BuildStore, backing: BuildStore): Pr
|
|
|
1098
1105
|
Object.keys(buildScope(calls)).every((name) => name.endsWith(`:${slug.replace(prefix, '')}`))
|
|
1099
1106
|
|
|
1100
1107
|
// (a) The first read: both rollups, the five live builds and the
|
|
1101
|
-
// escalated done build.
|
|
1108
|
+
// escalated done build, never the build whose abort closed its question.
|
|
1102
1109
|
const first = await measure('first')
|
|
1103
1110
|
expect(first.calls['getReducerValue:rollup']).toBe(2)
|
|
1104
1111
|
expect(buildScope(first.calls)).toEqual(reads(...[0, 1, 2, 3, 4].map(live), escalated))
|
|
1112
|
+
expect(
|
|
1113
|
+
[...frame.overview!.active, ...frame.overview!.queued].map((row) => row.slug),
|
|
1114
|
+
).not.toContain(`${prefix}done-000003`)
|
|
1105
1115
|
expect(first.rows).toBe(0)
|
|
1106
1116
|
expect(first.repoRows).toBe(0)
|
|
1107
1117
|
expect(frame.overview!.active.length + frame.overview!.queued.length).toBe(6)
|
|
@@ -2517,6 +2517,388 @@ export async function flaggedWorkspaceSweepReadBudget(opts: {
|
|
|
2517
2517
|
})
|
|
2518
2518
|
}
|
|
2519
2519
|
|
|
2520
|
+
/** #1406: the early stage that serves `dispatcher.work-deferred` first. It
|
|
2521
|
+
* runs on every tick, so with no carried entry it makes no store request at
|
|
2522
|
+
* all, and with one it reads only the carried builds: the same reads at 100
|
|
2523
|
+
* and 100,000 events, whatever number of unrelated builds (here ones a newer
|
|
2524
|
+
* writer's decisive fact defers) the repository holds. Each carried build is
|
|
2525
|
+
* swept once per tick, so carrying it adds no reads to the tick. A carried
|
|
2526
|
+
* build its own mixed-version check defers stays carried. Fresh dispatchers
|
|
2527
|
+
* per tick: no per-process cache. */
|
|
2528
|
+
export async function deferredWorkReadBudget(): Promise<void> {
|
|
2529
|
+
const { newerFact, seedNewerMemoryFact } = await import('./newer-writer')
|
|
2530
|
+
const { MemoryBuildStore } = await import('../store/memory')
|
|
2531
|
+
const repo = '/repos/deferred-work'
|
|
2532
|
+
const sha = 'a'.repeat(40)
|
|
2533
|
+
const config = parseConfig('[tickets]\nsource = "file"\nreadyState = "Ready"\n')
|
|
2534
|
+
async function world(length: number, unrelated: number) {
|
|
2535
|
+
let now = Date.parse('2026-12-01T00:00:00.000Z')
|
|
2536
|
+
const clock = () => new Date(now)
|
|
2537
|
+
const store = new MemoryBuildStore({ clock })
|
|
2538
|
+
await store.ensureRepo(repo)
|
|
2539
|
+
const created = (slug: string) => ({
|
|
2540
|
+
slug,
|
|
2541
|
+
repo,
|
|
2542
|
+
ticket: { source: 'fake', id: `T-${slug}` },
|
|
2543
|
+
branch: slug,
|
|
2544
|
+
created: {
|
|
2545
|
+
actor: DISPATCHER,
|
|
2546
|
+
type: 'build.created' as const,
|
|
2547
|
+
payload: { ticket: { source: 'fake', id: `T-${slug}` }, repo, baseBranch: 'main' },
|
|
2548
|
+
},
|
|
2549
|
+
})
|
|
2550
|
+
for (let i = 1; i <= unrelated; i++) {
|
|
2551
|
+
await store.createBuild(created(`deferred-${i}`))
|
|
2552
|
+
seedNewerMemoryFact(store, newerFact(2, 'decisive', `deferred-${i}`))
|
|
2553
|
+
}
|
|
2554
|
+
// The carried leaf: its execution ended on a sandbox that has since
|
|
2555
|
+
// stopped, and it holds its slot.
|
|
2556
|
+
const slug = 'carried'
|
|
2557
|
+
await store.createBuild(created(slug))
|
|
2558
|
+
await seedBuildFiller(store, slug, length, INERT_BUILD_FILLER)
|
|
2559
|
+
const ticket = { source: 'fake', id: `T-${slug}`, title: slug }
|
|
2560
|
+
for (const event of [
|
|
2561
|
+
{
|
|
2562
|
+
type: 'workspace.provisioned',
|
|
2563
|
+
payload: {
|
|
2564
|
+
provider: 'remote-test',
|
|
2565
|
+
ref: 'carried-g0',
|
|
2566
|
+
path: '/remote/workspace',
|
|
2567
|
+
branch: slug,
|
|
2568
|
+
base: { source: 'existing', sha },
|
|
2569
|
+
},
|
|
2570
|
+
},
|
|
2571
|
+
{ type: 'spec.imported', payload: { artifact: { kind: 'spec', rev: 0 }, ticket } },
|
|
2572
|
+
{ type: 'target.moved', payload: { branch: 'main', sha } },
|
|
2573
|
+
{ type: 'slot.admitted', payload: {} },
|
|
2574
|
+
{
|
|
2575
|
+
type: 'execution.started',
|
|
2576
|
+
payload: { provider: 'remote-test', workspaceRef: 'carried-g0', instance: 'i-1' },
|
|
2577
|
+
},
|
|
2578
|
+
{
|
|
2579
|
+
type: 'execution.ended',
|
|
2580
|
+
payload: { instance: 'i-1', workspaceRef: 'carried-g0', outcome: 'completed', exitCode: 0 },
|
|
2581
|
+
},
|
|
2582
|
+
])
|
|
2583
|
+
await store.append(slug, { actor: DISPATCHER, ...event } as never)
|
|
2584
|
+
await store.append(slug, { actor: KERNEL, type: 'plan.started', payload: { round: 1 } })
|
|
2585
|
+
now += 3_600_000
|
|
2586
|
+
const launches: string[] = []
|
|
2587
|
+
const dispatcher = () =>
|
|
2588
|
+
new Dispatcher({
|
|
2589
|
+
store,
|
|
2590
|
+
tickets: new FakeTicketSource([]),
|
|
2591
|
+
workspaces: {
|
|
2592
|
+
name: 'remote-test',
|
|
2593
|
+
preservation: async () => ({ outcome: 'preserved', heads: [] }),
|
|
2594
|
+
recovery: {
|
|
2595
|
+
fence: async () => ({ outcome: 'confirmed' }),
|
|
2596
|
+
reap: async () => ({
|
|
2597
|
+
outcome: 'confirmed',
|
|
2598
|
+
snapshots: { outcome: 'confirmed', deleted: 0 },
|
|
2599
|
+
}),
|
|
2600
|
+
},
|
|
2601
|
+
provision: async () => {
|
|
2602
|
+
throw new Error('not used')
|
|
2603
|
+
},
|
|
2604
|
+
release: async () => {},
|
|
2605
|
+
},
|
|
2606
|
+
forge: (() => {
|
|
2607
|
+
const forge = new FakeForge()
|
|
2608
|
+
forge.seedBranch('main', sha)
|
|
2609
|
+
return forge
|
|
2610
|
+
})(),
|
|
2611
|
+
config,
|
|
2612
|
+
repo,
|
|
2613
|
+
exec: async () => ({ stdout: `${sha}\trefs/heads/main\n`, stderr: '', exitCode: 0 }),
|
|
2614
|
+
launchRunner: async (launched: string) => {
|
|
2615
|
+
launches.push(launched)
|
|
2616
|
+
return 'scheduled' as const
|
|
2617
|
+
},
|
|
2618
|
+
ids: sequentialIds(),
|
|
2619
|
+
clock,
|
|
2620
|
+
})
|
|
2621
|
+
// One canonical reduction per key happens before anything is measured.
|
|
2622
|
+
await readRepositoryFacts(store, repo)
|
|
2623
|
+
await readBuildDigests(store, repo)
|
|
2624
|
+
await readBuildFacts(store, slug)
|
|
2625
|
+
for (let i = 1; i <= unrelated; i++) await readBuildFacts(store, `deferred-${i}`)
|
|
2626
|
+
const carry = (builds: { slug: string; step: 'resume' }[]) =>
|
|
2627
|
+
store.appendRepo(repo, {
|
|
2628
|
+
actor: DISPATCHER,
|
|
2629
|
+
type: 'dispatcher.work-deferred',
|
|
2630
|
+
payload: { builds },
|
|
2631
|
+
})
|
|
2632
|
+
/** One tick on a fresh dispatcher: the early stage's own store traffic
|
|
2633
|
+
* and the whole tick's requests naming the carried build. */
|
|
2634
|
+
const tick = async () => {
|
|
2635
|
+
const ticking = dispatcher()
|
|
2636
|
+
const stage = Reflect.get(ticking, 'serviceDeferredWork') as (
|
|
2637
|
+
...args: unknown[]
|
|
2638
|
+
) => Promise<void>
|
|
2639
|
+
let early: StoreReadMetrics | undefined
|
|
2640
|
+
Reflect.set(ticking, 'serviceDeferredWork', async (...args: unknown[]) => {
|
|
2641
|
+
early = await measureStoreReads(store, () => stage.apply(ticking, args))
|
|
2642
|
+
})
|
|
2643
|
+
const whole = await measureStoreReads(store, async () => {
|
|
2644
|
+
await ticking.tick({ acceptNewWork: false })
|
|
2645
|
+
})
|
|
2646
|
+
return { early: early!, carriedCalls: whole.slugs[slug] ?? 0 }
|
|
2647
|
+
}
|
|
2648
|
+
return { store, slug, launches, carry, tick }
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
const stages: Record<
|
|
2652
|
+
string,
|
|
2653
|
+
{ calls: Record<string, number>; slugs: Record<string, number>; rows: number }
|
|
2654
|
+
> = {}
|
|
2655
|
+
for (const length of [100, 100_000]) {
|
|
2656
|
+
for (const unrelated of [20, 200]) {
|
|
2657
|
+
const w = await world(length, unrelated)
|
|
2658
|
+
// No carried entry: the stage makes no store request at all.
|
|
2659
|
+
await w.carry([])
|
|
2660
|
+
const idle = await w.tick()
|
|
2661
|
+
expect(idle.early.calls).toEqual({})
|
|
2662
|
+
expect(w.launches).toEqual([w.slug]) // the lease sweep launched it
|
|
2663
|
+
// Carried, with one carried build its mixed-version check defers.
|
|
2664
|
+
w.launches.length = 0
|
|
2665
|
+
await w.carry([
|
|
2666
|
+
{ slug: w.slug, step: 'resume' },
|
|
2667
|
+
{ slug: 'deferred-1', step: 'resume' },
|
|
2668
|
+
])
|
|
2669
|
+
const { early } = await w.tick()
|
|
2670
|
+
expect(w.launches).toEqual([w.slug])
|
|
2671
|
+
expect(Object.keys(early.slugs).sort()).toEqual([w.slug, 'deferred-1'].sort())
|
|
2672
|
+
// Only the tail the previous tick appended, never the seeded history.
|
|
2673
|
+
expect(early.read.every((row) => row.slug !== w.slug || row.seq > length)).toBe(true)
|
|
2674
|
+
const latest = (await w.store.getRepoEvents(repo)).findLast(
|
|
2675
|
+
(event) => event.type === 'dispatcher.work-deferred',
|
|
2676
|
+
)
|
|
2677
|
+
expect(latest?.payload).toEqual({ builds: [{ slug: 'deferred-1', step: 'resume' }] })
|
|
2678
|
+
stages[`${length}:${unrelated}`] = {
|
|
2679
|
+
calls: early.calls,
|
|
2680
|
+
slugs: early.slugs,
|
|
2681
|
+
rows: early.rows,
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
const [first, ...rest] = Object.values(stages)
|
|
2686
|
+
for (const other of rest) expect(other).toEqual(first!)
|
|
2687
|
+
|
|
2688
|
+
// Carrying a build adds no reads of it to the tick: the early stage's
|
|
2689
|
+
// sweep replaces the lease sweep's (and the settlement stage skips it).
|
|
2690
|
+
const carried = await world(100, 0)
|
|
2691
|
+
await carried.carry([{ slug: carried.slug, step: 'resume' }])
|
|
2692
|
+
const swept = await world(100, 0)
|
|
2693
|
+
const withHint = (await carried.tick()).carriedCalls
|
|
2694
|
+
const withoutHint = (await swept.tick()).carriedCalls
|
|
2695
|
+
expect(carried.launches).toEqual(swept.launches)
|
|
2696
|
+
expect(withHint).toBeLessThanOrEqual(withoutHint)
|
|
2697
|
+
console.log('deferred work read budget', {
|
|
2698
|
+
histories: [100, 100_000],
|
|
2699
|
+
unrelated: [20, 200],
|
|
2700
|
+
earlyStageCalls: first!.calls,
|
|
2701
|
+
carriedCallsPerTick: { withHint, withoutHint },
|
|
2702
|
+
})
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
/** #1409: carrying the rotated loops' positions between bounded passes, and
|
|
2706
|
+
* checking mixed-version deferral only on the build acted on. Positions come
|
|
2707
|
+
* from the repository facts the tick's refresh already reduced, so carrying
|
|
2708
|
+
* one adds no read; a pass that cuts no loop writes nothing once they are
|
|
2709
|
+
* clear. No listing reads a build's facts for compatibility: settled builds
|
|
2710
|
+
* a newer writer's decisive fact defers are never read, however many there
|
|
2711
|
+
* are. Fresh dispatchers per tick: no per-process cache. */
|
|
2712
|
+
export async function passCursorsReadBudget(): Promise<void> {
|
|
2713
|
+
const { newerFact, seedNewerMemoryFact } = await import('./newer-writer')
|
|
2714
|
+
const { MemoryBuildStore } = await import('../store/memory')
|
|
2715
|
+
const repo = '/repos/pass-cursors'
|
|
2716
|
+
const sha = 'a'.repeat(40)
|
|
2717
|
+
const config = parseConfig('[tickets]\nsource = "file"\nreadyState = "Ready"\n')
|
|
2718
|
+
async function world(length: number, settled: number) {
|
|
2719
|
+
let now = Date.parse('2026-12-01T00:00:00.000Z')
|
|
2720
|
+
const clock = () => new Date(now)
|
|
2721
|
+
const store = new MemoryBuildStore({ clock })
|
|
2722
|
+
await store.ensureRepo(repo)
|
|
2723
|
+
const create = async (slug: string) => {
|
|
2724
|
+
const ticket = { source: 'fake', id: `T-${slug}`, title: slug }
|
|
2725
|
+
await store.createBuild({
|
|
2726
|
+
slug,
|
|
2727
|
+
repo,
|
|
2728
|
+
ticket,
|
|
2729
|
+
branch: `ab/${slug}`,
|
|
2730
|
+
created: {
|
|
2731
|
+
actor: DISPATCHER,
|
|
2732
|
+
type: 'build.created',
|
|
2733
|
+
payload: { ticket, repo, baseBranch: 'main' },
|
|
2734
|
+
},
|
|
2735
|
+
})
|
|
2736
|
+
return ticket
|
|
2737
|
+
}
|
|
2738
|
+
const running = async (slug: string) => {
|
|
2739
|
+
const ticket = await create(slug)
|
|
2740
|
+
for (const event of [
|
|
2741
|
+
{
|
|
2742
|
+
type: 'workspace.provisioned',
|
|
2743
|
+
payload: {
|
|
2744
|
+
provider: 'fake',
|
|
2745
|
+
ref: `/ws/ab/${slug}`,
|
|
2746
|
+
branch: `ab/${slug}`,
|
|
2747
|
+
base: { source: 'remote', sha },
|
|
2748
|
+
},
|
|
2749
|
+
},
|
|
2750
|
+
{ type: 'spec.imported', payload: { artifact: { kind: 'spec', rev: 0 }, ticket } },
|
|
2751
|
+
{ type: 'target.moved', payload: { branch: 'main', sha } },
|
|
2752
|
+
{ type: 'slot.admitted', payload: {} },
|
|
2753
|
+
])
|
|
2754
|
+
await store.append(slug, { actor: DISPATCHER, ...event } as never)
|
|
2755
|
+
await store.append(slug, { actor: KERNEL, type: 'plan.started', payload: { round: 1 } })
|
|
2756
|
+
}
|
|
2757
|
+
// The janitor's work: running leaves with live runners and long histories.
|
|
2758
|
+
const busy = ['busy-a', 'busy-b']
|
|
2759
|
+
for (const slug of busy) {
|
|
2760
|
+
await running(slug)
|
|
2761
|
+
await seedBuildFiller(store, slug, length, INERT_BUILD_FILLER)
|
|
2762
|
+
await store.claimLease(slug, `${slug}-runner`, 365 * 24 * 3_600_000)
|
|
2763
|
+
}
|
|
2764
|
+
// Settled builds a newer writer's decisive fact defers.
|
|
2765
|
+
const deferred: string[] = []
|
|
2766
|
+
for (let i = 1; i <= settled; i++) {
|
|
2767
|
+
const slug = `settled-${i}`
|
|
2768
|
+
await create(slug)
|
|
2769
|
+
await store.append(slug, {
|
|
2770
|
+
actor: DISPATCHER,
|
|
2771
|
+
type: 'build.completed',
|
|
2772
|
+
payload: { outcome: 'merged' },
|
|
2773
|
+
})
|
|
2774
|
+
seedNewerMemoryFact(store, newerFact(3, 'decisive', slug))
|
|
2775
|
+
deferred.push(slug)
|
|
2776
|
+
}
|
|
2777
|
+
// One live build it defers, which the stages reach.
|
|
2778
|
+
await running('live-mixed')
|
|
2779
|
+
seedNewerMemoryFact(
|
|
2780
|
+
store,
|
|
2781
|
+
newerFact((await store.getEvents('live-mixed')).length + 1, 'decisive', 'live-mixed'),
|
|
2782
|
+
)
|
|
2783
|
+
now += 3_600_000
|
|
2784
|
+
// One canonical reduction per key happens before anything is measured.
|
|
2785
|
+
await readRepositoryFacts(store, repo)
|
|
2786
|
+
await readBuildDigests(store, repo)
|
|
2787
|
+
for (const slug of [...busy, 'live-mixed', ...deferred]) await readBuildFacts(store, slug)
|
|
2788
|
+
const forge = new FakeForge()
|
|
2789
|
+
forge.seedBranch('main', sha)
|
|
2790
|
+
const tick = async () => {
|
|
2791
|
+
const dispatcher = new Dispatcher({
|
|
2792
|
+
store,
|
|
2793
|
+
tickets: new FakeTicketSource([]),
|
|
2794
|
+
workspaces: new FakeWorkspaceProvider({
|
|
2795
|
+
root: '/ws',
|
|
2796
|
+
mode: 'logical',
|
|
2797
|
+
base: { source: 'remote', sha },
|
|
2798
|
+
}),
|
|
2799
|
+
forge,
|
|
2800
|
+
config,
|
|
2801
|
+
repo,
|
|
2802
|
+
exec: async () => ({ stdout: `${sha}\trefs/heads/main\n`, stderr: '', exitCode: 0 }),
|
|
2803
|
+
launchRunner: async () => 'scheduled' as const,
|
|
2804
|
+
ids: sequentialIds(),
|
|
2805
|
+
clock,
|
|
2806
|
+
})
|
|
2807
|
+
const facts: Record<string, number> = {}
|
|
2808
|
+
const read = store.getReducerValue.bind(store)
|
|
2809
|
+
store.getReducerValue = async (...args: Parameters<typeof read>) => {
|
|
2810
|
+
const [scope, request] = args
|
|
2811
|
+
if (scope.kind === 'build' && request.reducer === 'buildReadFacts')
|
|
2812
|
+
facts[scope.slug] = (facts[scope.slug] ?? 0) + 1
|
|
2813
|
+
return read(...args)
|
|
2814
|
+
}
|
|
2815
|
+
const positions = async () =>
|
|
2816
|
+
(await store.getRepoEvents(repo)).filter((e) => e.type === 'dispatcher.pass-cursors').length
|
|
2817
|
+
const before = await positions()
|
|
2818
|
+
try {
|
|
2819
|
+
const metrics = await measureStoreReads(store, async () => {
|
|
2820
|
+
await dispatcher.tick({ acceptNewWork: false, deadlineAt: now + 250_000 })
|
|
2821
|
+
})
|
|
2822
|
+
// The store's public reads: what a remote store would serve.
|
|
2823
|
+
const calls = Object.fromEntries(
|
|
2824
|
+
Object.entries(metrics.calls).filter(([name]) =>
|
|
2825
|
+
[
|
|
2826
|
+
'getReducerValue',
|
|
2827
|
+
'getRepoBuildDigests',
|
|
2828
|
+
'listBuilds',
|
|
2829
|
+
'getArtifact',
|
|
2830
|
+
'getRepo',
|
|
2831
|
+
'getEvents',
|
|
2832
|
+
'getRepoEvents',
|
|
2833
|
+
'getBuild',
|
|
2834
|
+
].includes(name),
|
|
2835
|
+
),
|
|
2836
|
+
)
|
|
2837
|
+
return { calls, repoRows: metrics.repoRows, facts, wrote: (await positions()) - before }
|
|
2838
|
+
} finally {
|
|
2839
|
+
store.getReducerValue = read
|
|
2840
|
+
now += 60_000
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
const carry = (cursors: Record<string, string>) =>
|
|
2844
|
+
store.appendRepo(repo, {
|
|
2845
|
+
actor: DISPATCHER,
|
|
2846
|
+
type: 'dispatcher.pass-cursors',
|
|
2847
|
+
payload: { cursors },
|
|
2848
|
+
})
|
|
2849
|
+
return { tick, carry, deferred }
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
const measured: Record<string, unknown> = {}
|
|
2853
|
+
for (const length of [100, 100_000]) {
|
|
2854
|
+
for (const settled of [20, 200]) {
|
|
2855
|
+
const w = await world(length, settled)
|
|
2856
|
+
// Settle the first tick's own writes (deferral, observations).
|
|
2857
|
+
await w.tick()
|
|
2858
|
+
await w.tick()
|
|
2859
|
+
const plain = await w.tick()
|
|
2860
|
+
// Nothing cut and no position held: nothing written, no new row read.
|
|
2861
|
+
expect(plain.wrote).toBe(0)
|
|
2862
|
+
expect(plain.repoRows).toBe(0)
|
|
2863
|
+
// Settled deferred builds are never read; the live one at most once.
|
|
2864
|
+
for (const slug of w.deferred) expect(plain.facts[slug]).toBeUndefined()
|
|
2865
|
+
expect(plain.facts['live-mixed']).toBe(1)
|
|
2866
|
+
// A carried position reads what a pass after any other new repository
|
|
2867
|
+
// row reads, the refresh's tail, plus the later refresh of the one
|
|
2868
|
+
// append that clears it once every build was reached.
|
|
2869
|
+
await w.carry({})
|
|
2870
|
+
const baseline = await w.tick()
|
|
2871
|
+
expect(baseline.wrote).toBe(0)
|
|
2872
|
+
await w.carry({ janitor: 'busy-a', sweep: 'busy-a' })
|
|
2873
|
+
const carried = await w.tick()
|
|
2874
|
+
expect(carried.wrote).toBe(1)
|
|
2875
|
+
expect(carried.calls).toEqual({
|
|
2876
|
+
...baseline.calls,
|
|
2877
|
+
getReducerValue: baseline.calls.getReducerValue! + 1,
|
|
2878
|
+
getRepo: baseline.calls.getRepo! + 1,
|
|
2879
|
+
})
|
|
2880
|
+
expect(carried.repoRows).toBe(baseline.repoRows + 1)
|
|
2881
|
+
// The clearing row is read at most once more, then nothing.
|
|
2882
|
+
expect((await w.tick()).repoRows).toBeLessThanOrEqual(baseline.repoRows)
|
|
2883
|
+
const idle = await w.tick()
|
|
2884
|
+
expect(idle).toMatchObject({ wrote: 0, repoRows: 0 })
|
|
2885
|
+
measured[`${length}:${settled}`] = { calls: plain.calls, facts: plain.facts }
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2888
|
+
// The same reads at 100 and 100,000 events; the same facts reads whatever
|
|
2889
|
+
// the number of deferred builds (only the store's own digest batch grows
|
|
2890
|
+
// with the fleet).
|
|
2891
|
+
expect(measured['100:20']).toEqual(measured['100000:20'])
|
|
2892
|
+
expect(measured['100:200']).toEqual(measured['100000:200'])
|
|
2893
|
+
const facts = Object.values(measured).map((entry) => (entry as { facts: unknown }).facts)
|
|
2894
|
+
for (const other of facts) expect(other).toEqual(facts[0])
|
|
2895
|
+
console.log('pass cursors read budget', {
|
|
2896
|
+
histories: [100, 100_000],
|
|
2897
|
+
settledDeferred: [20, 200],
|
|
2898
|
+
tick: measured['100:20'],
|
|
2899
|
+
})
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2520
2902
|
/** A provision continuation that reaches its launch for a build at the
|
|
2521
2903
|
* no-progress limit applies the guard instead of starting a runner. Each
|
|
2522
2904
|
* continuation is a recurring invocation (every re-provision, every remote
|
|
@@ -8717,6 +9099,28 @@ export async function openBuildListingReadBudget(opts: { commands?: boolean } =
|
|
|
8717
9099
|
type: 'escalation.answered',
|
|
8718
9100
|
payload: { id: 'integration-audit-op', answer: 'ack', resolution: 'retry' },
|
|
8719
9101
|
})
|
|
9102
|
+
// Aborted while blocked: the abort closed its escalation (#1387), so it
|
|
9103
|
+
// is listed nowhere and adds no read.
|
|
9104
|
+
await store.createBuild({
|
|
9105
|
+
slug: 'done-abort-closed',
|
|
9106
|
+
repo,
|
|
9107
|
+
created: created('done-abort-closed'),
|
|
9108
|
+
})
|
|
9109
|
+
await store.append('done-abort-closed', {
|
|
9110
|
+
actor: KERNEL,
|
|
9111
|
+
type: 'escalation.raised',
|
|
9112
|
+
payload: { id: 'abort-closed', phase: 'implement', source: 'agent', question: 'q' },
|
|
9113
|
+
})
|
|
9114
|
+
await store.append('done-abort-closed', {
|
|
9115
|
+
actor: DISPATCHER,
|
|
9116
|
+
type: 'build.aborted',
|
|
9117
|
+
payload: {},
|
|
9118
|
+
})
|
|
9119
|
+
await store.append('done-abort-closed', {
|
|
9120
|
+
actor: DISPATCHER,
|
|
9121
|
+
type: 'build.completed',
|
|
9122
|
+
payload: { outcome: 'abandoned' },
|
|
9123
|
+
})
|
|
8720
9124
|
for (let i = 0; i < settled; i++) {
|
|
8721
9125
|
const slug = `settled-${i}`
|
|
8722
9126
|
await store.createBuild({ slug, repo, created: created(slug) })
|
|
@@ -8837,7 +9241,7 @@ export async function openBuildListingReadBudget(opts: { commands?: boolean } =
|
|
|
8837
9241
|
expect(digest.escalations.map(({ slug, status }) => ({ slug, status }))).toEqual([
|
|
8838
9242
|
{ slug: 'done-escalated', status: 'done' },
|
|
8839
9243
|
])
|
|
8840
|
-
expect(JSON.stringify(digest)).not.toMatch(/open-aborted|settled-/)
|
|
9244
|
+
expect(JSON.stringify(digest)).not.toMatch(/open-aborted|done-abort-closed|settled-/)
|
|
8841
9245
|
const rows = memoryRepositoryReadCounter(store, repo)
|
|
8842
9246
|
const entries = memoryListingEntryCounter(store)
|
|
8843
9247
|
const calls = memoryStoreRequestCounter(store)
|
package/skills/guide/SKILL.md
CHANGED
|
@@ -893,10 +893,11 @@ publishes the exact SHA/branch through a temporary narrow firewall transform,
|
|
|
893
893
|
verifies it, and performs PR work locally. Ordinary completion deletes the VM.
|
|
894
894
|
The guest runner records its exit on the sandbox filesystem, so a session that
|
|
895
895
|
finished before its VM stopped still settles and publishes: recovery resumes a
|
|
896
|
-
stopped sandbox explicitly
|
|
897
|
-
resume plus guest git and push)
|
|
898
|
-
|
|
899
|
-
|
|
896
|
+
stopped sandbox explicitly, with `recoveryTimeoutMs` (default 120000, the cold
|
|
897
|
+
resume plus guest git and push) as its ceiling. A hosted invocation starts it
|
|
898
|
+
only while a realistic resume (about 45 s) plus the cleanup reserve fits, never
|
|
899
|
+
runs it past the deadline, and never stops a sandbox the provider already
|
|
900
|
+
reports stopped. `operationTimeoutMs` bounds each metadata acknowledgement.
|
|
900
901
|
Branch config, installed skills, relative/package plugins, setup, and phase CLI
|
|
901
902
|
commands resolve from the guest checkout, never dispatcher paths.
|
|
902
903
|
|
|
@@ -1262,8 +1263,24 @@ replacement consumes no infrastructure attempt. A preservation or release
|
|
|
1262
1263
|
failure is recorded against its build, as an infrastructure failure or janitor
|
|
1263
1264
|
attention, and never stops the dispatcher from advancing other builds. The
|
|
1264
1265
|
recorded error and the infrastructure-limit escalation name the failed recovery
|
|
1265
|
-
step: `resume`, `fence`, `preserve` or `cleanup`. Work
|
|
1266
|
-
|
|
1266
|
+
step: `resume`, `fence`, `preserve` or `cleanup`. Work a hosted invocation's
|
|
1267
|
+
deadline cuts short or cannot fit charges no infrastructure attempt: a resume it
|
|
1268
|
+
cut short is stopped or left uncertain for a later fence. The tick counts the
|
|
1269
|
+
build as `recoveryDeferred` (or `provisioningDeferred` for a provision that
|
|
1270
|
+
needs about 150 s), logs `build <slug>: <step> deferred by the invocation
|
|
1271
|
+
budget`, never reports idle, and records it in `dispatcher.work-deferred`, so
|
|
1272
|
+
the next invocation runs that build first, within half of its window.
|
|
1273
|
+
No stage consumes a bounded invocation: each starts items only within its share
|
|
1274
|
+
of the time left when it begins (half for deferred work, the janitor and the
|
|
1275
|
+
lease sweep, a quarter for the others; intake runs to the work deadline), and
|
|
1276
|
+
each helper still gets its first item. Loops whose items stay listed (execution
|
|
1277
|
+
and harvest settlement, the janitor, hand-backs, dispatch recovery, resume, the
|
|
1278
|
+
lease sweep) continue next invocation after the last item they started,
|
|
1279
|
+
through the latest-only `dispatcher.pass-cursors` fact, so every build is
|
|
1280
|
+
visited within a bounded number of passes. Each pass logs `stages:` with time
|
|
1281
|
+
and items per stage; a pass the work deadline cuts short logs `tick: work
|
|
1282
|
+
deadline reached during <stage>` naming the part in flight, and `ab repository
|
|
1283
|
+
status` shows the latest as `last pass stages:`.
|
|
1267
1284
|
Fencing is revalidated after restart; a saved receipt alone never authorizes
|
|
1268
1285
|
cleanup of a newer execution. Current recovery notes are linked by the session
|
|
1269
1286
|
manifest's `workspaceRecovery` field. Recovery notes apply to the next session
|
|
@@ -2864,8 +2881,8 @@ suppressed; `--plain` and non-TTY output remain line-oriented and unchanged. A
|
|
|
2864
2881
|
satisfied verify skip carries the literal `skipped` qualifier, so it remains
|
|
2865
2882
|
distinct from a pass without color. Every nonterminal build has a row,
|
|
2866
2883
|
including `queued` builds that have not attached a runner. A done build with an
|
|
2867
|
-
open escalation (a post-landing integration audit, or
|
|
2868
|
-
|
|
2884
|
+
open escalation (a post-landing integration audit, or an escalation raised
|
|
2885
|
+
during abort cleanup) also has a row, red `BLOCKED` with the note
|
|
2869
2886
|
`done` and its question, holding no slot, until `ab answer` acknowledges it. A newly claimed
|
|
2870
2887
|
build holds its slot from the claim, so its row shows its ticket, slug, green
|
|
2871
2888
|
`STARTING` status, and either the pending dispatch boundary or the latest
|
|
@@ -3125,7 +3142,10 @@ and exit, then reaps remaining descendants with bounded TERM-then-KILL cleanup.
|
|
|
3125
3142
|
Only then does it release the lease. Graceful dispatcher shutdown likewise waits
|
|
3126
3143
|
for runner suspension without a wall-clock force-exit deadline. A queued, paused
|
|
3127
3144
|
or blocked build with no live execution is acknowledged by the dispatcher
|
|
3128
|
-
directly, without provisioning a workspace or starting a runner.
|
|
3145
|
+
directly, without provisioning a workspace or starting a runner. Acknowledging
|
|
3146
|
+
the abort (`build.aborted`) closes every escalation then open, unanswered, so
|
|
3147
|
+
nothing needs acknowledging afterwards unless cleanup or a later audit raises a
|
|
3148
|
+
new one.
|
|
3129
3149
|
The dispatcher defers cleanup while that lease is live, then performs the
|
|
3130
3150
|
checkpointed, retry-safe cleanup: close an open unmerged PR, release the workspace,
|
|
3131
3151
|
delete the exact remote and local build branches, preserve existing ticket labels
|
|
@@ -85,7 +85,7 @@ raw session-event append. External operator harnesses own agent execution.
|
|
|
85
85
|
| Method and path | Result |
|
|
86
86
|
|---|---|
|
|
87
87
|
| `GET …/builds?scope=active\|queued\|all` | Build summaries, newest update first. `queued` means active plus queued, matching `ab builds --queued`. Each nonterminal summary's `slot` is `{state: "held"}`, `{state: "requested", request, priority?: "urgent" \| "high" \| "low"}` or `{state: "none"}`; absent means unknown (an older server), never `none`. Its `statusWord` is `{word, tone, note?}`, the status word every surface shows; `status` stays the reducer's lifecycle status. |
|
|
88
|
-
| `GET …/builds/{slug}` | `{detail, dashboardRow}`; `detail.slot` and `dashboardRow.slot` carry the build's slot state, shaped as in `GET …/builds`; `detail.runnerAttaches` records chronological attach boundaries and their runtime identity (version, commit, source kind/location), with null runtime for unrecorded historical attaches; `dashboardRow` remains a `CLEANING` row after `build.aborted` and becomes `null` only when the dashboard stops listing it: at `build.completed` when no escalation is open. A completed build with an open escalation keeps, or regains, a `BLOCKED` row (note `done`), including
|
|
88
|
+
| `GET …/builds/{slug}` | `{detail, dashboardRow}`; `detail.slot` and `dashboardRow.slot` carry the build's slot state, shaped as in `GET …/builds`; `detail.runnerAttaches` records chronological attach boundaries and their runtime identity (version, commit, source kind/location), with null runtime for unrecorded historical attaches; `dashboardRow` remains a `CLEANING` row after `build.aborted` and becomes `null` only when the dashboard stops listing it: at `build.completed` when no escalation is open. A completed build with an open escalation keeps, or regains, a `BLOCKED` row (note `done`), including one raised during abort cleanup; abort itself closes the escalations open when it is accepted. The row becomes `null` once the escalation is acknowledged; neither step reopens its lifecycle state. |
|
|
89
89
|
| `GET …/dashboard` | `{generatedAt, model, settingsHeader}`. `model` is the dashboard's rows, steps, elapsed timing inputs, harvest row, triage (when the dispatcher published one)/queue/capacity and settings projection. `model.capacity.slots` maps each build to its slot state, and each `model.builds[].slot` repeats it; absent means unknown. `model.configuration` is `"no-dispatcher-run"` when the repository records no dispatcher run, and absent otherwise. Optional `rollback` contains `correlation`, `lineage`, full `failed` and `restored` runtime identities and rollback event `ts` for the authoritative dispatcher lineage’s unresolved hold. Both dashboards name failed, restored and held runtime plus timestamp. Matching durable different-target hold clearance removes it; a fresh operator lineage hides it only after a committed operational tick or accepted takeover. Run-started and yielded ticks alone cannot replace authority; same-lineage generations retain the notice. Historical rollback records are not fallback notices. Optional `handoffs` lists all accepted unfinished handoffs with predecessor `run`, optional `successor`, `correlation`, full `from`/`to` runtimes, `mode` and optional `deadline`. Outstanding drain-mode builds carry `draining: true`, also on build-detail `dashboardRow`; matching settlement removes it. Accepted completion removes the handoff; neither takeover nor the clock does. Missing historical mode means cutover and missing deadline displays unknown. |
|
|
90
90
|
| `GET …/status` | Repository intake, pause, and default-auto-merge projection, plus `ticketStarts` (`{pending, recent}`, each entry with its `priority`) when single-ticket start requests are pending or recently settled. `capacity.slots`, when the held configuration is readable, maps each nonterminal build to its slot state; `capacity.occupied` counts its `held` entries. Its `operator` is `{presence: "unavailable", reason}`: this route does not load presence registrations, so it is not evidence that no operator is present. |
|
|
91
91
|
| `GET …/harvest/status` | Harvest gate, runs, steps, recovery, and attention projection. |
|
|
@@ -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` and `dispatcher.
|
|
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 |
|