@defrex/autobuild 1.7.0 → 1.8.1
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 +316 -47
- package/docs/answering-blocked-builds.md +44 -3
- package/docs/architecture.md +62 -7
- package/docs/cli.md +1 -0
- package/docs/configuration-overview.md +1 -1
- package/docs/configuration.md +49 -9
- package/docs/dispatcher.md +1 -1
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +7 -4
- package/docs/merge-policy.md +78 -6
- package/docs/migration-1.0.md +4 -2
- package/docs/operating.md +3 -2
- package/docs/operator-api.md +26 -5
- package/docs/operator-surfaces.md +10 -0
- package/docs/plugin-authoring.md +1 -1
- package/docs/remote-store-protocol.md +9 -1
- package/docs/restacking.md +23 -4
- package/docs/ticket-dependencies.md +9 -4
- package/docs/tickets.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +1 -0
- package/packages/core/src/cli/build-control.ts +65 -7
- package/packages/core/src/cli/context.ts +55 -14
- package/packages/core/src/cli/dashboard/actions.ts +13 -4
- package/packages/core/src/cli/dashboard/landing-display.ts +32 -8
- package/packages/core/src/cli/dashboard/model.ts +61 -8
- package/packages/core/src/cli/dashboard/render.ts +28 -3
- package/packages/core/src/cli/dashboard/tree.ts +9 -1
- package/packages/core/src/cli/help.ts +69 -7
- package/packages/core/src/cli/landings.ts +1 -1
- package/packages/core/src/cli/main.ts +60 -9
- package/packages/core/src/cli/publication-settlement.ts +10 -0
- package/packages/core/src/cli/status.ts +178 -12
- package/packages/core/src/cli/terminals.ts +197 -4
- package/packages/core/src/cli/wait.ts +1 -0
- package/packages/core/src/cli/watch.ts +71 -0
- package/packages/core/src/config/landing.ts +12 -0
- package/packages/core/src/config/path-selectors.ts +68 -0
- package/packages/core/src/config/schema.ts +40 -58
- package/packages/core/src/events/catalog.ts +17 -3
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/head-paths-limits.ts +25 -0
- package/packages/core/src/events/payloads.ts +315 -20
- package/packages/core/src/events/policy.ts +21 -0
- package/packages/core/src/events/repository.ts +30 -1
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +247 -6
- package/packages/core/src/kernel/consent-revocation.ts +72 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +19 -8
- package/packages/core/src/kernel/engine.ts +48 -8
- package/packages/core/src/kernel/head-paths-state.ts +63 -0
- package/packages/core/src/kernel/head-paths.ts +401 -0
- package/packages/core/src/kernel/landing-policy-identity.ts +20 -0
- package/packages/core/src/kernel/landing-policy.ts +55 -2
- package/packages/core/src/kernel/landing-readiness.ts +104 -9
- package/packages/core/src/kernel/landing-state.ts +44 -4
- package/packages/core/src/kernel/leaf-restack-base.ts +34 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +22 -2
- package/packages/core/src/kernel/log-index.ts +27 -1
- package/packages/core/src/kernel/node-polling.ts +13 -3
- package/packages/core/src/kernel/node-restack-state.ts +8 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +45 -0
- package/packages/core/src/kernel/read-deferrals.ts +3 -1
- package/packages/core/src/kernel/read-facts.ts +28 -1
- package/packages/core/src/kernel/reducer-registry.ts +22 -1
- package/packages/core/src/kernel/reducer.ts +316 -17
- package/packages/core/src/kernel/target-observation.ts +2 -5
- package/packages/core/src/kernel/terminal-guard.ts +52 -3
- package/packages/core/src/kernel/ticket-handbacks.ts +40 -0
- package/packages/core/src/kernel/ticket-preparation.ts +12 -1
- package/packages/core/src/kernel/ticket-wait.ts +345 -0
- package/packages/core/src/kernel/verify-applicability.ts +9 -19
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/index.ts +3 -0
- package/packages/core/src/operator/protocol.ts +15 -2
- package/packages/core/src/operator/registry.ts +97 -5
- package/packages/core/src/operator/repository-events.ts +67 -0
- package/packages/core/src/ports/tickets/fake.ts +5 -0
- package/packages/core/src/ports/types.ts +3 -2
- package/packages/core/src/processes/build-execution-state.ts +30 -1
- package/packages/core/src/processes/build-runner.ts +150 -18
- package/packages/core/src/processes/dispatcher.ts +739 -97
- package/packages/core/src/processes/execution-no-progress.ts +22 -2
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-state.ts +6 -1
- package/packages/core/src/store/digest.ts +41 -2
- package/packages/core/src/store/reduced-reads.ts +4 -1
- package/packages/core/src/store/reducer-value-shapes.json +10108 -8432
- package/packages/core/src/store/remote/client.ts +28 -2
- package/packages/core/src/store/remote/protocol.ts +11 -1
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.8.0.json +29043 -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 +16 -0
- package/packages/core/src/testing/reduced-read-budget.ts +347 -0
- package/skills/code-review/SKILL.md +8 -0
- package/skills/finalize/SKILL.md +4 -0
- package/skills/guide/SKILL.md +125 -26
- package/skills/guide/references/integration-tree.md +7 -4
- package/skills/guide/references/merge-policy.md +78 -6
- package/skills/guide/references/migration-1.0.md +4 -2
- package/skills/guide/references/operator-api.md +26 -5
- package/skills/guide/references/plugin-authoring.md +1 -1
- package/skills/guide/references/remote-store-protocol.md +9 -1
- package/skills/guide/references/restacking.md +23 -4
- package/skills/guide/references/ticket-dependencies.md +9 -4
- package/skills/implement/SKILL.md +15 -1
- package/skills/operate/SKILL.md +104 -13
- package/skills/plan/SKILL.md +17 -2
- package/skills/plan-review/SKILL.md +8 -0
- package/skills/reconcile/SKILL.md +21 -5
- package/skills/tickets/SKILL.md +5 -4
- package/templates/hosted-service/package.json +2 -2
|
@@ -5,6 +5,7 @@ import release2 from './1.4.0.json'
|
|
|
5
5
|
import release3 from './1.5.0.json'
|
|
6
6
|
import release4 from './1.6.0.json'
|
|
7
7
|
import release5 from './1.7.0.json'
|
|
8
|
+
import release6 from './1.8.0.json'
|
|
8
9
|
import type { ReducerValueCatalog } from '../../reducer-value-validation'
|
|
9
10
|
export interface ReleasedReducerValues extends ReducerValueCatalog {
|
|
10
11
|
versions: Record<string, number>
|
|
@@ -16,4 +17,5 @@ export const RELEASED_REDUCER_VALUES: Readonly<Record<string, ReleasedReducerVal
|
|
|
16
17
|
'1.5.0.json': release3,
|
|
17
18
|
'1.6.0.json': release4,
|
|
18
19
|
'1.7.0.json': release5,
|
|
20
|
+
'1.8.0.json': release6,
|
|
19
21
|
}
|
|
@@ -7,6 +7,7 @@ import type { RepositoryEvent, RepositoryEventType } from '../events/repository'
|
|
|
7
7
|
import { defineReducer, type IncrementalReducer } from '../kernel/incremental'
|
|
8
8
|
import {
|
|
9
9
|
ticketPreparationEventPayloadSchemas,
|
|
10
|
+
ticketHandbackEventPayloadSchemas,
|
|
10
11
|
changePresenceEventPayloadSchemas,
|
|
11
12
|
ticketSourceHealthEventPayloadSchemas,
|
|
12
13
|
dispatcherSettingEventPayloadSchemas,
|
|
@@ -39,6 +40,7 @@ export const DISPATCH_HANDOFF_EVENT_TYPES = [
|
|
|
39
40
|
* run-correlated `dispatcher.config-reloaded`. */
|
|
40
41
|
export const REPOSITORY_STATE_EVENT_TYPES: readonly RepositoryEventType[] = [
|
|
41
42
|
...Object.keys(ticketPreparationEventPayloadSchemas),
|
|
43
|
+
...Object.keys(ticketHandbackEventPayloadSchemas),
|
|
42
44
|
'tickets.migration-recorded',
|
|
43
45
|
...DISPATCH_HANDOFF_EVENT_TYPES,
|
|
44
46
|
'dispatcher.forge-degraded',
|
|
@@ -114,6 +114,14 @@ export interface ArtifactMeta {
|
|
|
114
114
|
* render rows. Nothing is persisted: every adapter derives the digest from
|
|
115
115
|
* the event log on each call, so the log stays the sole authority and the
|
|
116
116
|
* digest can always be discarded and rebuilt. */
|
|
117
|
+
/** The open ticket wait a build digest carries: the wait id, its
|
|
118
|
+
* escalation, and the tickets it waits on. */
|
|
119
|
+
export interface BuildDigestTicketWait {
|
|
120
|
+
id: string
|
|
121
|
+
escalation: string
|
|
122
|
+
tickets: TicketRef[]
|
|
123
|
+
}
|
|
124
|
+
|
|
117
125
|
export interface BuildDigest {
|
|
118
126
|
compatibility?: import('../events/compatibility').CompatibilityState
|
|
119
127
|
/** A kernel landing requested an audit and no audit settlement has followed. */
|
|
@@ -133,6 +141,14 @@ export interface BuildDigest {
|
|
|
133
141
|
readinessChangeSeq?: number
|
|
134
142
|
slug: string
|
|
135
143
|
terminal?: 'done' | 'aborted'
|
|
144
|
+
/** A ticket wait was requested and the dispatcher has not yet accepted or
|
|
145
|
+
* refused it — the one signal that makes its wait stage read the build. */
|
|
146
|
+
waitPending?: true
|
|
147
|
+
/** An entered ticket wait that has not ended (by `wait.ended`, an answer
|
|
148
|
+
* to its escalation, or the dispatcher's `policy/wait-unresolvable`
|
|
149
|
+
* raise) — the one signal that makes the dispatcher's release stage
|
|
150
|
+
* consider the build. */
|
|
151
|
+
ticketWait?: BuildDigestTicketWait
|
|
136
152
|
/** Ascending-seq `{seq, ts}` pairs for every `observation.recorded` in the
|
|
137
153
|
* build's log; `ts` is the event envelope timestamp (AUT-521: the harvest
|
|
138
154
|
* pressure gate measures drift from the oldest unclaimed occurrence's ts,
|
|
@@ -1537,6 +1537,68 @@ export async function parkedSweepReadBudget(opts: {
|
|
|
1537
1537
|
}
|
|
1538
1538
|
}
|
|
1539
1539
|
|
|
1540
|
+
/** Ticket waits (SPEC §11 "Ticket waits"): idle dispatcher ticks over leaves
|
|
1541
|
+
* parked by a ticket wait — one open, one ended and waiting for a resume slot
|
|
1542
|
+
* behind an occupied slot — read zero historical rows, append nothing and
|
|
1543
|
+
* make no wait ticket-source call, at 100 and 100,000 events. `waitCalls`
|
|
1544
|
+
* counts ticket-source calls the wait stage could make (blocker reads,
|
|
1545
|
+
* completion checks and blocker writes). `surfaces` runs the status reads an
|
|
1546
|
+
* operator polls (`ab builds`, dashboard rows) inside the same measured window,
|
|
1547
|
+
* so showing a wait is held to the same bound. */
|
|
1548
|
+
export async function ticketWaitIdleReadBudget(opts: {
|
|
1549
|
+
store: import('../store/memory').MemoryBuildStore
|
|
1550
|
+
slugs: string[]
|
|
1551
|
+
dispatcher: () => Dispatcher
|
|
1552
|
+
/** Per-request wait calls (`get`, `addBlocker`): none on idle ticks. */
|
|
1553
|
+
waitCalls: () => number
|
|
1554
|
+
/** Batched `dependencyStates` calls naming waited tickets: exactly one per
|
|
1555
|
+
* tick while some wait is open. */
|
|
1556
|
+
releaseBatches: () => number
|
|
1557
|
+
advance: () => void
|
|
1558
|
+
surfaces?: () => Promise<void>
|
|
1559
|
+
}): Promise<void> {
|
|
1560
|
+
const { store, slugs } = opts
|
|
1561
|
+
let historicalRows = 0
|
|
1562
|
+
for (const length of [100, 100_000]) {
|
|
1563
|
+
for (const slug of slugs) await seedBuildFiller(store, slug, length)
|
|
1564
|
+
const restore: (() => void)[] = []
|
|
1565
|
+
for (const slug of slugs) {
|
|
1566
|
+
const events = buildEventRows(store, slug)
|
|
1567
|
+
const boundary = events.at(-1)!.seq
|
|
1568
|
+
const slice = Array.prototype.slice
|
|
1569
|
+
events.slice = function (start?: number, end?: number) {
|
|
1570
|
+
const result = slice.call(this, start, end) as typeof events
|
|
1571
|
+
historicalRows += result.filter((event) => event.seq <= boundary).length
|
|
1572
|
+
return result
|
|
1573
|
+
}
|
|
1574
|
+
restore.push(() => Reflect.deleteProperty(events, 'slice'))
|
|
1575
|
+
}
|
|
1576
|
+
const dispatcher = opts.dispatcher()
|
|
1577
|
+
// Warm durable projections over the new tail once.
|
|
1578
|
+
opts.advance()
|
|
1579
|
+
await dispatcher.tick()
|
|
1580
|
+
await opts.surfaces?.()
|
|
1581
|
+
const calls = opts.waitCalls()
|
|
1582
|
+
historicalRows = 0
|
|
1583
|
+
for (const _ of [0, 1]) {
|
|
1584
|
+
opts.advance()
|
|
1585
|
+
const batches = opts.releaseBatches()
|
|
1586
|
+
const requests = await countStoreRequests(store, async () => {
|
|
1587
|
+
await dispatcher.tick()
|
|
1588
|
+
await opts.surfaces?.()
|
|
1589
|
+
})
|
|
1590
|
+
expect(requests.append ?? 0).toBe(0)
|
|
1591
|
+
expect(requests.appendIfCurrent ?? 0).toBe(0)
|
|
1592
|
+
expect(requests.appendWithArtifactsIfCurrent ?? 0).toBe(0)
|
|
1593
|
+
expect(opts.releaseBatches() - batches).toBe(1)
|
|
1594
|
+
}
|
|
1595
|
+
expect(historicalRows).toBe(0)
|
|
1596
|
+
expect(opts.waitCalls()).toBe(calls)
|
|
1597
|
+
for (const undo of restore) undo()
|
|
1598
|
+
console.log('ticket wait idle read budget', { history: length, builds: slugs.length })
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1540
1602
|
/** Count every MemoryBuildStore method call made while `run` executes. */
|
|
1541
1603
|
async function countStoreRequests(
|
|
1542
1604
|
store: import('../store/memory').MemoryBuildStore,
|
|
@@ -3347,3 +3409,288 @@ export async function hostedHarvestAuthorityReadBudget() {
|
|
|
3347
3409
|
expect(large.appended.size).toBe(small.appended.size)
|
|
3348
3410
|
return { small, large }
|
|
3349
3411
|
}
|
|
3412
|
+
|
|
3413
|
+
/** Head path facts are recorded by producers, never derived on the landing
|
|
3414
|
+
* poll: an awaiting-PR leaf costs fresh-dispatcher ticks no path-deriving git
|
|
3415
|
+
* command, zero `head-paths` artifact reads and zero event rows once warm, and the
|
|
3416
|
+
* same store requests at 100 and 100,000 events. Returns the measured vector
|
|
3417
|
+
* so a caller can compare a recorded build against a pre-change one. */
|
|
3418
|
+
export async function headPathsLandingReadBudget(opts: {
|
|
3419
|
+
store: import('../store/memory').MemoryBuildStore
|
|
3420
|
+
repo: string
|
|
3421
|
+
slug: string
|
|
3422
|
+
/** Whether the PR head carries a recorded fact. */
|
|
3423
|
+
recorded: boolean
|
|
3424
|
+
/** Path-predicate merge rules: warm-up must have appended exactly one of
|
|
3425
|
+
* these, reading a decided head's complete paths exactly once. */
|
|
3426
|
+
warm?: 'landing.decided' | 'landing.deferred'
|
|
3427
|
+
/** After a decided warm-up: consent to that decision, then a reconcile's
|
|
3428
|
+
* revocation of it, re-warmed once. Revoked consent adds no poll cost. */
|
|
3429
|
+
revokedConsent?: true
|
|
3430
|
+
/** One tick on a fresh dispatcher. */
|
|
3431
|
+
tick: () => Promise<unknown>
|
|
3432
|
+
advance: (ms: number) => void
|
|
3433
|
+
/** Git commands attempted so far. */
|
|
3434
|
+
git: () => readonly string[][]
|
|
3435
|
+
}) {
|
|
3436
|
+
const { store, repo, slug } = opts
|
|
3437
|
+
/** The commands that derive a head's path facts. */
|
|
3438
|
+
const pathFact = /^(merge-base|diff|merge-tree|worktree|cherry-pick|write-tree)$/
|
|
3439
|
+
const { candidateHeadPaths, HEAD_PATHS_ARTIFACT, HEAD_PATHS_PREVIEW } = await import(
|
|
3440
|
+
'../kernel/head-paths'
|
|
3441
|
+
)
|
|
3442
|
+
let artifactReads = 0
|
|
3443
|
+
let totalArtifactReads = 0
|
|
3444
|
+
const getArtifact = store.getArtifact.bind(store)
|
|
3445
|
+
store.getArtifact = async (s, kind, rev) => {
|
|
3446
|
+
if (kind === HEAD_PATHS_ARTIFACT) {
|
|
3447
|
+
artifactReads++
|
|
3448
|
+
totalArtifactReads++
|
|
3449
|
+
}
|
|
3450
|
+
return getArtifact(s, kind, rev)
|
|
3451
|
+
}
|
|
3452
|
+
await store.ensureRepo(repo)
|
|
3453
|
+
let seeded = 0
|
|
3454
|
+
const vectors: Record<string, number>[] = []
|
|
3455
|
+
try {
|
|
3456
|
+
for (const length of [100, 100_000]) {
|
|
3457
|
+
for (; seeded < length; seeded++) {
|
|
3458
|
+
await store.appendRepo(repo, {
|
|
3459
|
+
actor: humanActor('budget'),
|
|
3460
|
+
type: 'dispatcher.intake-set',
|
|
3461
|
+
payload: { enabled: true },
|
|
3462
|
+
})
|
|
3463
|
+
if (seeded % 10 === 0)
|
|
3464
|
+
await store.append(slug, {
|
|
3465
|
+
actor: KERNEL,
|
|
3466
|
+
type: 'observation.recorded',
|
|
3467
|
+
payload: { id: `obs-${seeded}`, kind: 'followup', summary: `budget padding ${seeded}` },
|
|
3468
|
+
})
|
|
3469
|
+
}
|
|
3470
|
+
for (let n = 0; n < 2; n++) {
|
|
3471
|
+
opts.advance(120_000)
|
|
3472
|
+
await opts.tick()
|
|
3473
|
+
}
|
|
3474
|
+
if (opts.warm) {
|
|
3475
|
+
const landing = (await store.getEvents(slug)).filter(
|
|
3476
|
+
(event) => event.type === 'landing.decided' || event.type === 'landing.deferred',
|
|
3477
|
+
)
|
|
3478
|
+
expect(landing.map((event) => event.type)).toEqual([opts.warm])
|
|
3479
|
+
expect(totalArtifactReads).toBe(opts.warm === 'landing.decided' ? 1 : 0)
|
|
3480
|
+
}
|
|
3481
|
+
if (opts.revokedConsent && length === 100) {
|
|
3482
|
+
const decided = (await store.getEvents(slug)).findLast(
|
|
3483
|
+
(event) => event.type === 'landing.decided',
|
|
3484
|
+
)
|
|
3485
|
+
if (decided?.type !== 'landing.decided') throw new Error('revokedConsent needs a decision')
|
|
3486
|
+
const consent = await store.append(slug, {
|
|
3487
|
+
actor: humanActor('budget'),
|
|
3488
|
+
type: 'build.land-requested',
|
|
3489
|
+
payload: { decisionSeq: decided.seq },
|
|
3490
|
+
})
|
|
3491
|
+
expect((await readBuildFacts(store, slug)).value.state.landing?.command?.rule).toBeDefined()
|
|
3492
|
+
const rule = 'index' in decided.payload.rule ? decided.payload.rule : undefined
|
|
3493
|
+
if (rule?.snapshot.paths === undefined && rule?.snapshot.within === undefined)
|
|
3494
|
+
throw new Error('revokedConsent needs a decision under a path-predicate rule')
|
|
3495
|
+
await store.append(slug, {
|
|
3496
|
+
actor: KERNEL,
|
|
3497
|
+
type: 'landing.consent-revoked',
|
|
3498
|
+
payload: {
|
|
3499
|
+
commandSeq: consent.seq,
|
|
3500
|
+
source: 'reconcile',
|
|
3501
|
+
rule,
|
|
3502
|
+
previousHead: decided.payload.candidate.head,
|
|
3503
|
+
head: decided.payload.candidate.head,
|
|
3504
|
+
paths: { total: 1, preview: ['autobuild.toml'] },
|
|
3505
|
+
},
|
|
3506
|
+
})
|
|
3507
|
+
expect((await readBuildFacts(store, slug)).value.state.landing?.command).toBeUndefined()
|
|
3508
|
+
for (let n = 0; n < 2; n++) {
|
|
3509
|
+
opts.advance(120_000)
|
|
3510
|
+
await opts.tick()
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
const rows = memoryRepositoryReadCounter(store, repo)
|
|
3514
|
+
const requests = memoryStoreRequestCounter(store)
|
|
3515
|
+
try {
|
|
3516
|
+
let vector: Record<string, number> | undefined
|
|
3517
|
+
for (let n = 0; n < 3; n++) {
|
|
3518
|
+
opts.advance(120_000)
|
|
3519
|
+
rows.reset()
|
|
3520
|
+
requests.reset()
|
|
3521
|
+
artifactReads = 0
|
|
3522
|
+
const before = opts.git().length
|
|
3523
|
+
await opts.tick()
|
|
3524
|
+
const spawned = opts.git().slice(before)
|
|
3525
|
+
expect(spawned.filter((cmd) => pathFact.test(cmd[1] ?? ''))).toEqual([])
|
|
3526
|
+
expect(artifactReads).toBe(0)
|
|
3527
|
+
expect(rows.rows).toBe(0)
|
|
3528
|
+
expect(rows.buildRows).toBe(0)
|
|
3529
|
+
const measured: Record<string, number> = {
|
|
3530
|
+
...requests.vector(),
|
|
3531
|
+
gitSpawns: spawned.length,
|
|
3532
|
+
}
|
|
3533
|
+
if (vector) expect(measured).toEqual(vector)
|
|
3534
|
+
vector = measured
|
|
3535
|
+
}
|
|
3536
|
+
vectors.push(vector!)
|
|
3537
|
+
} finally {
|
|
3538
|
+
requests.restore()
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
} finally {
|
|
3542
|
+
store.getArtifact = getArtifact
|
|
3543
|
+
}
|
|
3544
|
+
expect(vectors[1]).toEqual(vectors[0])
|
|
3545
|
+
const answer = candidateHeadPaths((await readBuildFacts(store, slug)).value.state)
|
|
3546
|
+
expect(answer.recorded).toBe(opts.recorded)
|
|
3547
|
+
if (answer.recorded) {
|
|
3548
|
+
expect(answer.record.total).toBeGreaterThan(HEAD_PATHS_PREVIEW)
|
|
3549
|
+
expect(answer.record.preview).toHaveLength(HEAD_PATHS_PREVIEW)
|
|
3550
|
+
}
|
|
3551
|
+
return vectors[0]!
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
/** Build state carries bounded head path summaries: past the record capacity,
|
|
3555
|
+
* with every complete set far beyond the preview, a fresh reader's warm build
|
|
3556
|
+
* facts read zero events and serve the same size at 1,000 and 10,000 events. */
|
|
3557
|
+
export async function headPathsStateReadBudget(opts: {
|
|
3558
|
+
store: BuildStore
|
|
3559
|
+
costs: ReducedReadCosts
|
|
3560
|
+
fresh: () => Promise<BuildStore>
|
|
3561
|
+
}) {
|
|
3562
|
+
const { store, costs } = opts
|
|
3563
|
+
const { headPathsWrite, readHeadPaths, HEAD_PATHS_RECORDS } = await import('../kernel/head-paths')
|
|
3564
|
+
const slug = 'head-paths-budget'
|
|
3565
|
+
const oid = (n: number) => n.toString(16).padStart(40, '0')
|
|
3566
|
+
const paths = Array.from({ length: 1_001 }, (_, i) => `src/f${String(i).padStart(5, '0')}.ts`)
|
|
3567
|
+
await store.createBuild({ slug, repo, branch: `ab/${slug}` })
|
|
3568
|
+
let appended = 0
|
|
3569
|
+
let facts = 0
|
|
3570
|
+
let size: number | undefined
|
|
3571
|
+
for (const length of [1_000, 10_000]) {
|
|
3572
|
+
while (appended < length) {
|
|
3573
|
+
if (appended % 100 === 0) {
|
|
3574
|
+
const { artifacts, makeEvent } = headPathsWrite(
|
|
3575
|
+
{
|
|
3576
|
+
version: 1,
|
|
3577
|
+
head: oid(++facts),
|
|
3578
|
+
destination: oid(0x10_0000 + facts),
|
|
3579
|
+
mergeBase: oid(0x20_0000 + facts),
|
|
3580
|
+
paths,
|
|
3581
|
+
},
|
|
3582
|
+
'finalize',
|
|
3583
|
+
KERNEL,
|
|
3584
|
+
)
|
|
3585
|
+
await store.appendWithArtifacts(slug, artifacts, makeEvent)
|
|
3586
|
+
} else
|
|
3587
|
+
await store.append(slug, {
|
|
3588
|
+
actor: KERNEL,
|
|
3589
|
+
type: 'observation.recorded',
|
|
3590
|
+
payload: { id: `obs-${appended}`, kind: 'followup', summary: `padding ${appended}` },
|
|
3591
|
+
})
|
|
3592
|
+
appended++
|
|
3593
|
+
}
|
|
3594
|
+
expect(facts).toBeGreaterThan(HEAD_PATHS_RECORDS)
|
|
3595
|
+
for (const reader of [store, await opts.fresh()]) {
|
|
3596
|
+
await readBuildFacts(reader, slug)
|
|
3597
|
+
costs.events = costs.metadata = costs.bytes = 0
|
|
3598
|
+
const { state } = (await readBuildFacts(reader, slug)).value
|
|
3599
|
+
expect(costs.events).toBe(0)
|
|
3600
|
+
const records = state.headPaths ?? []
|
|
3601
|
+
expect(records.map((record) => record.head)).toEqual(
|
|
3602
|
+
Array.from({ length: HEAD_PATHS_RECORDS }, (_, i) =>
|
|
3603
|
+
oid(facts - HEAD_PATHS_RECORDS + 1 + i),
|
|
3604
|
+
),
|
|
3605
|
+
)
|
|
3606
|
+
// Seqs and revisions grow by a digit; the served summaries do not.
|
|
3607
|
+
const served = JSON.stringify(
|
|
3608
|
+
records.map(({ seq: _seq, artifact: _artifact, ...summary }) => summary),
|
|
3609
|
+
).length
|
|
3610
|
+
if (size === undefined) size = served
|
|
3611
|
+
else expect(served).toBe(size)
|
|
3612
|
+
expect((await readHeadPaths(reader, slug, records.at(-1)!)).paths).toEqual(paths)
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
/** MCP `repository.events` pages a large backlog through the bounded tail
|
|
3618
|
+
* port: every call scans at most one page of disjoint, contiguous rows, the
|
|
3619
|
+
* whole backlog costs exactly its length, an unchanged cursor reads zero
|
|
3620
|
+
* rows, and nothing falls back to the unbounded journal read. */
|
|
3621
|
+
export async function repositoryEventsReadBudget() {
|
|
3622
|
+
const { MemoryBuildStore } = await import('../store/memory')
|
|
3623
|
+
const { repositoryNeedsAttention } = await import('../cli/attention')
|
|
3624
|
+
const { REPOSITORY_EVENTS_PAGE } = await import('../operator/repository-events')
|
|
3625
|
+
const store = new MemoryBuildStore()
|
|
3626
|
+
const repo = 'repository-events-budget'
|
|
3627
|
+
await store.ensureRepo(repo)
|
|
3628
|
+
const total = 900
|
|
3629
|
+
for (let i = 1; i <= total; i++) {
|
|
3630
|
+
if (i % 200 === 0)
|
|
3631
|
+
await store.appendRepo(repo, {
|
|
3632
|
+
actor: DISPATCHER,
|
|
3633
|
+
type: 'ticket.handed-back',
|
|
3634
|
+
payload: {
|
|
3635
|
+
ticket: { source: 'fake', id: `T-${i}` },
|
|
3636
|
+
build: `b-${i}`,
|
|
3637
|
+
cause: 'abort',
|
|
3638
|
+
state: 'Ready',
|
|
3639
|
+
role: 'ready',
|
|
3640
|
+
},
|
|
3641
|
+
})
|
|
3642
|
+
else
|
|
3643
|
+
await store.appendRepo(repo, {
|
|
3644
|
+
actor: humanActor('budget'),
|
|
3645
|
+
type: 'dispatcher.intake-set',
|
|
3646
|
+
payload: { enabled: true },
|
|
3647
|
+
})
|
|
3648
|
+
}
|
|
3649
|
+
const counter = memoryRepositoryReadCounter(store, repo)
|
|
3650
|
+
const ranges: { since: number; through: number | undefined; rows: number }[] = []
|
|
3651
|
+
const tail = store.getRepositoryTail.bind(store)
|
|
3652
|
+
store.getRepositoryTail = async (r, since, opts) => {
|
|
3653
|
+
const before = counter.rows
|
|
3654
|
+
const events = await tail(r, since, opts)
|
|
3655
|
+
ranges.push({ since: since ?? 0, through: opts?.through, rows: counter.rows - before })
|
|
3656
|
+
return events
|
|
3657
|
+
}
|
|
3658
|
+
store.getRepoEvents = async () => {
|
|
3659
|
+
throw new Error('repository.events must never read the unbounded journal')
|
|
3660
|
+
}
|
|
3661
|
+
const registry = buildRegistry({ store })
|
|
3662
|
+
const delivered: unknown[] = []
|
|
3663
|
+
let cursor = 0
|
|
3664
|
+
for (;;) {
|
|
3665
|
+
const page = (await registry.call('repository.events', { repo, cursor })) as {
|
|
3666
|
+
events: { seq: number }[]
|
|
3667
|
+
cursor: number
|
|
3668
|
+
hasMore: boolean
|
|
3669
|
+
}
|
|
3670
|
+
delivered.push(...page.events)
|
|
3671
|
+
cursor = page.cursor
|
|
3672
|
+
if (!page.hasMore) break
|
|
3673
|
+
}
|
|
3674
|
+
const pages = ranges.length
|
|
3675
|
+
expect(cursor).toBe(total)
|
|
3676
|
+
expect(ranges.every((range) => range.rows <= REPOSITORY_EVENTS_PAGE)).toBe(true)
|
|
3677
|
+
expect(ranges.every((range) => range.through === range.since + REPOSITORY_EVENTS_PAGE)).toBe(true)
|
|
3678
|
+
ranges.forEach((range, index) => {
|
|
3679
|
+
if (index > 0) expect(range.since).toBe(ranges[index - 1]!.since + ranges[index - 1]!.rows)
|
|
3680
|
+
})
|
|
3681
|
+
expect(ranges.reduce((sum, range) => sum + range.rows, 0)).toBe(total)
|
|
3682
|
+
const all = (await tail(repo, 0)).filter(repositoryNeedsAttention)
|
|
3683
|
+
expect(delivered).toEqual(all)
|
|
3684
|
+
expect(all).toHaveLength(Math.floor(total / 200))
|
|
3685
|
+
// Idle polls at the head read zero event rows; a baseline reads none either.
|
|
3686
|
+
counter.reset()
|
|
3687
|
+
const idle = await registry.call('repository.events', { repo, cursor })
|
|
3688
|
+
expect(idle).toEqual({ events: [], cursor, hasMore: false })
|
|
3689
|
+
expect(await registry.call('repository.events', { repo })).toEqual({
|
|
3690
|
+
events: [],
|
|
3691
|
+
cursor: total,
|
|
3692
|
+
hasMore: false,
|
|
3693
|
+
})
|
|
3694
|
+
expect(counter.rows).toBe(0)
|
|
3695
|
+
return pages
|
|
3696
|
+
}
|
|
@@ -52,6 +52,14 @@ manifest-directed artifact paths remain authoritative. Never commit scratch.
|
|
|
52
52
|
ab verdict escalate --reason "…" --notes "$AB_CONTEXT_DIR/code-review.md"
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
If you cannot judge the change until another ticket merges — it depends on
|
|
56
|
+
code that ticket owns and has not landed — end the session with
|
|
57
|
+
`ab wait-on <ticket-id>... --reason "…"` instead of a verdict or an
|
|
58
|
+
escalation. The build parks without a slot; when every named ticket
|
|
59
|
+
completes, this same review round resumes on the target's current head,
|
|
60
|
+
with a `wait` block in `$AB_CONTEXT_DIR/guidance.json`. Escalate as before for
|
|
61
|
+
anything else.
|
|
62
|
+
|
|
55
63
|
## Writing findings
|
|
56
64
|
|
|
57
65
|
Same schema as every review (the CLI validates and stamps ids): `severity`
|
package/skills/finalize/SKILL.md
CHANGED
|
@@ -63,6 +63,10 @@ is authoritative feedback for this attempt and the PR description must act on
|
|
|
63
63
|
it, while the spec remains the contract this phase is measured against — if the
|
|
64
64
|
two cannot both be satisfied, escalate instead of guessing. Finalize has no
|
|
65
65
|
review round of its own, so guidance is the only feedback it ever receives.
|
|
66
|
+
If finalize cannot proceed until another ticket merges, end the session with
|
|
67
|
+
`ab wait-on <ticket-id>... --reason "…"` instead of escalating: the build parks
|
|
68
|
+
without a slot and finalize resumes when every named ticket completes. Escalate
|
|
69
|
+
as before for anything else.
|
|
66
70
|
|
|
67
71
|
Read the manifest path printed by `ab context`. Its `materialized` keys are
|
|
68
72
|
relative to `contextDir`: join them to locate collision-adjusted inputs.
|