@defrex/autobuild 1.6.0 → 1.7.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 +107 -10
- package/docs/agent-runtimes.md +1 -1
- package/docs/architecture.md +62 -22
- package/docs/configuration-overview.md +10 -0
- package/docs/configuration.md +285 -5
- package/docs/forges.md +1 -0
- package/docs/operator-api.md +19 -8
- package/docs/operator-surfaces.md +6 -3
- package/docs/plugin-authoring.md +44 -6
- package/docs/remote-store-protocol.md +19 -6
- package/docs/restacking.md +12 -7
- package/docs/ticket-sources.md +34 -6
- package/docs/tickets.md +6 -0
- package/docs/workspaces.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +1 -0
- package/packages/core/src/cli/binary-direct.ts +1 -0
- package/packages/core/src/cli/dispatch-frontend.ts +10 -14
- package/packages/core/src/cli/dispatch-preflight.ts +1 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +145 -109
- package/packages/core/src/cli/dispatch.ts +9 -3
- package/packages/core/src/cli/help.ts +11 -4
- package/packages/core/src/cli/init-validation.ts +14 -1
- package/packages/core/src/cli/repository-status.ts +37 -2
- package/packages/core/src/cli/status.ts +8 -0
- package/packages/core/src/cli/ticket.ts +22 -4
- package/packages/core/src/cli/watch.ts +2 -0
- package/packages/core/src/config/live.ts +4 -0
- package/packages/core/src/config/profiles.ts +96 -0
- package/packages/core/src/config/ready-assignee.ts +43 -11
- package/packages/core/src/config/roles.ts +33 -10
- package/packages/core/src/config/schema.ts +166 -24
- package/packages/core/src/events/compatibility.ts +3 -1
- package/packages/core/src/events/forge-degradation-policy.ts +16 -2
- package/packages/core/src/events/payloads.ts +8 -0
- package/packages/core/src/events/policy.ts +1 -0
- package/packages/core/src/events/repository.ts +17 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +73 -124
- package/packages/core/src/kernel/build-creation.ts +29 -0
- package/packages/core/src/kernel/forge-health.ts +47 -0
- package/packages/core/src/kernel/guarded-forge.ts +76 -18
- package/packages/core/src/kernel/node-parent.ts +2 -0
- package/packages/core/src/kernel/read-facts.ts +9 -1
- package/packages/core/src/kernel/reducer.ts +18 -1
- package/packages/core/src/kernel/ticket-preparation.ts +4 -1
- package/packages/core/src/operator/protocol.ts +10 -0
- package/packages/core/src/operator/query.ts +1 -1
- package/packages/core/src/operator/registry.ts +25 -5
- package/packages/core/src/operator/sandbox-host.ts +3 -0
- package/packages/core/src/operator/tickets.ts +15 -3
- package/packages/core/src/plugin-sdk/index.ts +4 -0
- package/packages/core/src/ports/forge/create.ts +6 -0
- package/packages/core/src/ports/forge/github-transport.ts +40 -3
- package/packages/core/src/ports/forge/github.ts +12 -1
- package/packages/core/src/ports/forge/workspace-ancestry.ts +60 -0
- package/packages/core/src/ports/forge-failure.ts +31 -2
- package/packages/core/src/ports/runner/routing.ts +66 -5
- package/packages/core/src/ports/tickets/assignees.ts +54 -0
- package/packages/core/src/ports/tickets/contract.ts +164 -4
- package/packages/core/src/ports/tickets/create.ts +17 -3
- package/packages/core/src/ports/tickets/github-fake.ts +18 -2
- package/packages/core/src/ports/tickets/github.ts +247 -29
- package/packages/core/src/ports/tickets/hosted-index.ts +1 -0
- package/packages/core/src/ports/tickets/operations.ts +6 -1
- package/packages/core/src/ports/tickets/tree.ts +12 -2
- package/packages/core/src/ports/tickets/update.ts +6 -2
- package/packages/core/src/ports/types.ts +33 -3
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +9 -0
- package/packages/core/src/processes/build-child.ts +28 -7
- package/packages/core/src/processes/build-execution-state.ts +4 -1
- package/packages/core/src/processes/build-runner.ts +15 -1
- package/packages/core/src/processes/dispatcher.ts +98 -18
- package/packages/core/src/processes/harvest-child.ts +4 -0
- package/packages/core/src/processes/harvest-runner.ts +5 -0
- package/packages/core/src/processes/repo-view.ts +2 -0
- package/packages/core/src/scenarios/harness.ts +15 -1
- package/packages/core/src/store/reducer-value-shapes.json +3119 -2926
- package/packages/core/src/store/remote/client.ts +21 -8
- package/packages/core/src/store/remote/index.ts +4 -0
- package/packages/core/src/store/remote/protocol.ts +7 -0
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.7.0.json +27366 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
- package/packages/core/src/store/repo-state-events.ts +1 -0
- package/packages/core/src/store/types.ts +11 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +84 -58
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/reduced-read-budget.ts +72 -9
- package/skills/guide/SKILL.md +116 -21
- package/skills/guide/references/operator-api.md +19 -8
- package/skills/guide/references/plugin-authoring.md +44 -6
- package/skills/guide/references/remote-store-protocol.md +19 -6
- package/skills/guide/references/restacking.md +12 -7
- package/skills/operate/SKILL.md +29 -3
- package/skills/tickets/SKILL.md +18 -2
- package/templates/hosted-service/package.json +2 -2
|
@@ -4,6 +4,7 @@ import release1 from './1.3.0.json'
|
|
|
4
4
|
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
|
+
import release5 from './1.7.0.json'
|
|
7
8
|
import type { ReducerValueCatalog } from '../../reducer-value-validation'
|
|
8
9
|
export interface ReleasedReducerValues extends ReducerValueCatalog {
|
|
9
10
|
versions: Record<string, number>
|
|
@@ -14,4 +15,5 @@ export const RELEASED_REDUCER_VALUES: Readonly<Record<string, ReleasedReducerVal
|
|
|
14
15
|
'1.4.0.json': release2,
|
|
15
16
|
'1.5.0.json': release3,
|
|
16
17
|
'1.6.0.json': release4,
|
|
18
|
+
'1.7.0.json': release5,
|
|
17
19
|
}
|
|
@@ -43,6 +43,7 @@ export const REPOSITORY_STATE_EVENT_TYPES: readonly RepositoryEventType[] = [
|
|
|
43
43
|
...DISPATCH_HANDOFF_EVENT_TYPES,
|
|
44
44
|
'dispatcher.forge-degraded',
|
|
45
45
|
'dispatcher.forge-recovered',
|
|
46
|
+
'forge.credential-limited',
|
|
46
47
|
'dispatcher.kernel-git-unavailable',
|
|
47
48
|
'dispatcher.kernel-git-recovered',
|
|
48
49
|
...Object.keys(changePresenceEventPayloadSchemas),
|
|
@@ -79,6 +79,11 @@ export interface NewBuildInput {
|
|
|
79
79
|
repoOrigin?: string
|
|
80
80
|
ticket?: TicketRef
|
|
81
81
|
branch?: string
|
|
82
|
+
/** The creating preparation attempt, sent only when `buildCreationIdentity`
|
|
83
|
+
* answers `'keyed'`. A store that allocates the canonical slug derives it
|
|
84
|
+
* from (repo, slug, creationKey) with `creationBuildSlug` and creates at
|
|
85
|
+
* most one build per key; exact-slug adapters ignore it. */
|
|
86
|
+
creationKey?: string
|
|
82
87
|
/** The build's `build.created` fact, appended as seq 1 in the same atomic
|
|
83
88
|
* step as the record: both exist or neither does, so the claim-time facts it
|
|
84
89
|
* freezes (ticket assets, SPEC §6.3) can never be lost to a crash between
|
|
@@ -296,6 +301,12 @@ export interface BuildStore extends BoundedEventReads {
|
|
|
296
301
|
* The handle retains this shape so foreign/admin calls fail loudly. */
|
|
297
302
|
scopeBuild(slug: string): BuildScopedStore
|
|
298
303
|
|
|
304
|
+
/** How `createBuild` chooses the canonical slug. Absent: exactly
|
|
305
|
+
* `input.slug`. `'keyed'`: `input.slug`, or `creationBuildSlug(repo, slug,
|
|
306
|
+
* creationKey)` when a key is sent. `'allocated'`: possibly a slug the
|
|
307
|
+
* caller never learns if the response is lost, so absence at a known slug
|
|
308
|
+
* proves nothing. */
|
|
309
|
+
buildCreationIdentity?(): Promise<'keyed' | 'allocated'>
|
|
299
310
|
createBuild(input: NewBuildInput): Promise<BuildRecord>
|
|
300
311
|
getBuild(slug: string): Promise<BuildRecord | null>
|
|
301
312
|
listBuilds(): Promise<BuildRecord[]>
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { missingAccountCredentials, reconcileMissingAccounts } from '../accounts/availability'
|
|
2
2
|
import { readRepositoryFacts } from '../store/reduced-reads'
|
|
3
|
+
import { READ_CATALOG_IDENTITY } from '../events/compatibility'
|
|
3
4
|
import { dispatchFrontendReducer } from '../cli/dispatch-repository-feed'
|
|
4
|
-
import {
|
|
5
|
-
catalogSnapshotName,
|
|
6
|
-
loadReducerSnapshot,
|
|
7
|
-
persistReducerSnapshot,
|
|
8
|
-
} from '../store/snapshots'
|
|
5
|
+
import { catalogSnapshotName, loadReducerSnapshot } from '../store/snapshots'
|
|
9
6
|
import { expect } from 'bun:test'
|
|
10
7
|
import { DispatchFrontend } from '../cli/dispatch-frontend'
|
|
11
8
|
import type { DispatchChildResult } from '../cli/dispatch-process'
|
|
@@ -194,16 +191,7 @@ export async function dispatchReadBudget(
|
|
|
194
191
|
await refresh()
|
|
195
192
|
// Startup without a checkpoint seeds from the canonical value, not the journal.
|
|
196
193
|
expect(metrics.state).toBe(0)
|
|
197
|
-
|
|
198
|
-
(
|
|
199
|
-
await loadReducerSnapshot(
|
|
200
|
-
{ getReducerSnapshot: getSnapshot },
|
|
201
|
-
{ kind: 'repo', repo },
|
|
202
|
-
'dispatchFrontend',
|
|
203
|
-
{ version: dispatchFrontendReducer.version },
|
|
204
|
-
)
|
|
205
|
-
)?.state,
|
|
206
|
-
).length
|
|
194
|
+
let checkpointSize: number | undefined
|
|
207
195
|
let recordReads: number | undefined
|
|
208
196
|
// The execution-mode frontend renders the kernel's published triage count;
|
|
209
197
|
// it never reads the ticket source itself, on any refresh.
|
|
@@ -278,12 +266,18 @@ export async function dispatchReadBudget(
|
|
|
278
266
|
},
|
|
279
267
|
})
|
|
280
268
|
}
|
|
269
|
+
// Dashboard-class traffic is part of the bound: canonical facts present it.
|
|
270
|
+
await backing.appendRepo(repo, {
|
|
271
|
+
actor: humanActor('test'),
|
|
272
|
+
type: 'dispatcher.pause-set',
|
|
273
|
+
payload: { enabled: false },
|
|
274
|
+
})
|
|
281
275
|
})
|
|
282
276
|
const before = { ...metrics }
|
|
283
277
|
now += 6000
|
|
284
278
|
await refresh()
|
|
285
279
|
expect(metrics.puts - before.puts).toBe((batch + 1) % 5 === 0 ? 1 : 0)
|
|
286
|
-
expect(metrics.rows - before.rows).toBe(
|
|
280
|
+
expect(metrics.rows - before.rows).toBe(129)
|
|
287
281
|
expect(metrics.events - before.events).toBe(1)
|
|
288
282
|
expect(metrics.state - before.state).toBe(0)
|
|
289
283
|
expect(metrics.snapshots - before.snapshots).toBe(0)
|
|
@@ -306,8 +300,12 @@ export async function dispatchReadBudget(
|
|
|
306
300
|
)
|
|
307
301
|
)?.state,
|
|
308
302
|
).length
|
|
309
|
-
//
|
|
310
|
-
|
|
303
|
+
// The first throttled save folds the child's identity; from then on the
|
|
304
|
+
// checkpoint is fixed: neither ticks nor dashboard-class facts grow it.
|
|
305
|
+
if (batch >= 4) {
|
|
306
|
+
checkpointSize ??= size
|
|
307
|
+
expect(size).toBe(checkpointSize)
|
|
308
|
+
}
|
|
311
309
|
const rows = metrics.rows
|
|
312
310
|
await refresh()
|
|
313
311
|
expect(metrics.rows).toBe(rows)
|
|
@@ -358,7 +356,8 @@ export async function dispatchReadBudget(
|
|
|
358
356
|
expect(metrics.rows - before.rows).toBe(1)
|
|
359
357
|
expect(metrics.state - before.state).toBe(0)
|
|
360
358
|
|
|
361
|
-
// Fixed relevant events/cursor isolate growth from unrelated legacy identities
|
|
359
|
+
// Fixed relevant events/cursor isolate growth from unrelated legacy identities
|
|
360
|
+
// and from the dashboard-event history a version-4 checkpoint cached.
|
|
362
361
|
// This runs through both the local and existing real HTTP invocations.
|
|
363
362
|
const retentionRepo = '/dashboard-retention-budget'
|
|
364
363
|
await backing.ensureRepo(retentionRepo)
|
|
@@ -379,51 +378,66 @@ export async function dispatchReadBudget(
|
|
|
379
378
|
}
|
|
380
379
|
const holder = history[0]!
|
|
381
380
|
const latest = history.at(-1)!
|
|
381
|
+
const dashboard: RepositoryEvent[] = []
|
|
382
|
+
for (let i = 0; i < 10000; i++)
|
|
383
|
+
dashboard.push(
|
|
384
|
+
await backing.appendRepo(retentionRepo, {
|
|
385
|
+
actor: humanActor('test'),
|
|
386
|
+
type: i % 2 === 0 ? 'dispatcher.pause-set' : 'dispatcher.intake-set',
|
|
387
|
+
payload: { enabled: i % 4 < 2 },
|
|
388
|
+
}),
|
|
389
|
+
)
|
|
390
|
+
const cursor = dashboard.at(-1)!.seq
|
|
382
391
|
const sizes: number[] = []
|
|
383
392
|
const checkpoint = backing.getReducerSnapshot.bind(backing)
|
|
384
393
|
try {
|
|
385
394
|
for (const length of [100, 10000]) {
|
|
386
|
-
// Model a validated pre-upgrade version-4 cache
|
|
395
|
+
// Model a validated pre-upgrade version-4 cache holding `length` run
|
|
396
|
+
// starts and `length` dashboard facts; no current row exists yet.
|
|
397
|
+
let upgraded = false
|
|
387
398
|
backing.getReducerSnapshot = async (...args) => {
|
|
388
|
-
|
|
389
|
-
if (
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
+
if (args[0].kind !== 'repo' || args[0].repo !== retentionRepo) return checkpoint(...args)
|
|
400
|
+
if (args[2] === 4)
|
|
401
|
+
return {
|
|
402
|
+
version: 4,
|
|
403
|
+
cursor,
|
|
404
|
+
state: {
|
|
405
|
+
catalogIdentity: READ_CATALOG_IDENTITY,
|
|
406
|
+
acc: {
|
|
407
|
+
retained: [...history.slice(0, length - 1), latest, ...dashboard.slice(0, length)],
|
|
408
|
+
incompleteIdentities: false,
|
|
409
|
+
holder: 'old-0',
|
|
410
|
+
},
|
|
399
411
|
},
|
|
400
|
-
}
|
|
401
|
-
|
|
412
|
+
}
|
|
413
|
+
return upgraded ? checkpoint(...args) : null
|
|
402
414
|
}
|
|
403
|
-
await persistReducerSnapshot(
|
|
404
|
-
store,
|
|
405
|
-
{ kind: 'repo', repo: retentionRepo },
|
|
406
|
-
'dispatchFrontend',
|
|
407
|
-
{
|
|
408
|
-
version: 4,
|
|
409
|
-
cursor: latest.seq,
|
|
410
|
-
state: { retained: [], incompleteIdentities: true },
|
|
411
|
-
},
|
|
412
|
-
)
|
|
413
415
|
const projection = new DispatchRepositoryFeed(store, retentionRepo, () => new Date(now))
|
|
414
416
|
const rows = metrics.rows
|
|
415
417
|
const bytes = metrics.bytes
|
|
418
|
+
const puts = metrics.puts
|
|
416
419
|
await projection.warm()
|
|
420
|
+
// The legacy row normalizes without reading event rows, and is replaced once.
|
|
421
|
+
expect(metrics.rows).toBe(rows)
|
|
422
|
+
expect(metrics.puts - puts).toBe(1)
|
|
417
423
|
expect(projection.identities).toEqual([holder, latest])
|
|
418
424
|
expect(projection.incompleteIdentities).toBe(true)
|
|
419
425
|
sizes.push(metrics.bytes - bytes)
|
|
420
|
-
|
|
426
|
+
upgraded = true
|
|
421
427
|
now += 60000
|
|
422
428
|
await projection.refresh()
|
|
423
429
|
await projection.save(true)
|
|
424
|
-
expect(metrics.puts).toBe(
|
|
430
|
+
expect(metrics.puts - puts).toBe(1)
|
|
431
|
+
expect(metrics.rows).toBe(rows)
|
|
432
|
+
// A restart restores the replacement clean: no write, no rows.
|
|
433
|
+
const restarted = new DispatchRepositoryFeed(store, retentionRepo, () => new Date(now))
|
|
434
|
+
await restarted.warm()
|
|
435
|
+
await restarted.save(true)
|
|
436
|
+
expect(restarted.identities).toEqual([holder, latest])
|
|
437
|
+
expect(metrics.puts - puts).toBe(1)
|
|
425
438
|
expect(metrics.rows).toBe(rows)
|
|
426
439
|
}
|
|
440
|
+
// The replacement's size is fixed by its identities, not the legacy history.
|
|
427
441
|
expect(sizes[0]).toBe(sizes[1])
|
|
428
442
|
} finally {
|
|
429
443
|
backing.getReducerSnapshot = checkpoint
|
|
@@ -1229,7 +1243,7 @@ export async function warmRestoreReadBudget(
|
|
|
1229
1243
|
seeds: number
|
|
1230
1244
|
seedRows: number
|
|
1231
1245
|
canonical: number
|
|
1232
|
-
missing: { rows: number; slices?: number; identities: number;
|
|
1246
|
+
missing: { rows: number; slices?: number; identities: number; checkpointReads: number }
|
|
1233
1247
|
}[] = []
|
|
1234
1248
|
const slices = countJournalSlices(backing)
|
|
1235
1249
|
try {
|
|
@@ -1326,13 +1340,24 @@ export async function warmRestoreReadBudget(
|
|
|
1326
1340
|
if (request.reducer === 'repositoryReadFacts') metrics.canonical++
|
|
1327
1341
|
return value(scope, request)
|
|
1328
1342
|
}
|
|
1343
|
+
const frontendCheckpoint = (args: Parameters<BuildStore['getReducerSnapshot']>) =>
|
|
1344
|
+
args[0].kind === 'repo' &&
|
|
1345
|
+
args[0].repo === repo &&
|
|
1346
|
+
args[1] === catalogSnapshotName('dispatchFrontend')
|
|
1347
|
+
const checkpointVersions: number[] = []
|
|
1348
|
+
backing.getReducerSnapshot = async (...args) => {
|
|
1349
|
+
if (frontendCheckpoint(args)) checkpointVersions.push(args[2])
|
|
1350
|
+
return checkpoint(...args)
|
|
1351
|
+
}
|
|
1329
1352
|
try {
|
|
1330
1353
|
// A checkpoint `gap` events stale: restore within the window, else canonical seed.
|
|
1331
1354
|
const feed = new DispatchRepositoryFeed(store, repo, () => new Date(60_000))
|
|
1332
|
-
await feed.refresh()
|
|
1355
|
+
const restored = await feed.refresh()
|
|
1333
1356
|
const head = await backing.getRepoHighWater(repo)
|
|
1334
1357
|
// Within the window the delta carries the fact; presentation reads canonical facts.
|
|
1335
|
-
if (gap === 1) expect(
|
|
1358
|
+
if (gap === 1) expect(restored.at(-1)?.payload).toEqual({ enabled: true })
|
|
1359
|
+
// A present current checkpoint is the only checkpoint read, even when stale.
|
|
1360
|
+
expect(checkpointVersions).toEqual([dispatchFrontendReducer.version])
|
|
1336
1361
|
if (verify) {
|
|
1337
1362
|
expect(metrics.raw).toBe(0)
|
|
1338
1363
|
expect(metrics.seeds).toBe(0)
|
|
@@ -1348,12 +1373,12 @@ export async function warmRestoreReadBudget(
|
|
|
1348
1373
|
expect((await readRepositoryFacts(store, repo)).value.settings.paused).toBe(true)
|
|
1349
1374
|
|
|
1350
1375
|
// A missing checkpoint: a fresh process with no presentation state at all.
|
|
1351
|
-
backing.getReducerSnapshot = async (...args) =>
|
|
1352
|
-
args
|
|
1353
|
-
args[
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1376
|
+
backing.getReducerSnapshot = async (...args) => {
|
|
1377
|
+
if (!frontendCheckpoint(args)) return checkpoint(...args)
|
|
1378
|
+
checkpointVersions.push(args[2])
|
|
1379
|
+
return null
|
|
1380
|
+
}
|
|
1381
|
+
checkpointVersions.length = 0
|
|
1357
1382
|
const counted = { ...metrics }
|
|
1358
1383
|
slices?.reset()
|
|
1359
1384
|
const fresh = new DispatchRepositoryFeed(store, repo, () => new Date(120_000))
|
|
@@ -1362,8 +1387,10 @@ export async function warmRestoreReadBudget(
|
|
|
1362
1387
|
rows: metrics.rows - counted.rows,
|
|
1363
1388
|
...(slices ? { slices: slices.rows() } : {}),
|
|
1364
1389
|
identities: fresh.identities.length,
|
|
1365
|
-
|
|
1390
|
+
checkpointReads: checkpointVersions.length,
|
|
1366
1391
|
}
|
|
1392
|
+
// A current-version miss makes one legacy read, then seeds canonically.
|
|
1393
|
+
expect(checkpointVersions).toEqual([dispatchFrontendReducer.version, 4])
|
|
1367
1394
|
expect(metrics.seeds).toBe(counted.seeds)
|
|
1368
1395
|
expect(metrics.raw).toBe(counted.raw)
|
|
1369
1396
|
expect(metrics.canonical - counted.canonical).toBe(1)
|
|
@@ -1373,16 +1400,15 @@ export async function warmRestoreReadBudget(
|
|
|
1373
1400
|
fresh.identities.map((e) => e.type === 'dispatcher.run-started' && e.payload.run),
|
|
1374
1401
|
).toEqual([gap === 2 ? 'racing-anchor' : 'latest'])
|
|
1375
1402
|
if (gap !== 2) expect(fresh.identities).toEqual([latest])
|
|
1376
|
-
expect(fresh.events).toEqual([])
|
|
1377
1403
|
// Unchanged: zero event rows. One new fact: exactly one row.
|
|
1378
1404
|
slices?.reset()
|
|
1379
1405
|
expect(await fresh.refresh()).toEqual([])
|
|
1380
1406
|
expect(metrics.rows - counted.rows).toBe(0)
|
|
1381
1407
|
if (slices) expect(slices.rows()).toBe(0)
|
|
1382
1408
|
const next = await append(false)
|
|
1383
|
-
expect(
|
|
1409
|
+
expect(await fresh.refresh()).toEqual([next])
|
|
1384
1410
|
expect(metrics.rows - counted.rows).toBe(1)
|
|
1385
|
-
expect(
|
|
1411
|
+
expect(checkpointVersions).toHaveLength(2)
|
|
1386
1412
|
reports.push({
|
|
1387
1413
|
gap,
|
|
1388
1414
|
seeds: metrics.seeds,
|
|
@@ -280,6 +280,20 @@ export async function reducedReadBudget(opts: {
|
|
|
280
280
|
const factsBytes = Buffer.byteLength(JSON.stringify(stableFacts))
|
|
281
281
|
if (repositoryBytes !== undefined) expect(factsBytes).toBeLessThan(repositoryBytes + 512)
|
|
282
282
|
repositoryBytes = factsBytes
|
|
283
|
+
// A credential limit seen outside the dispatcher joins the saved
|
|
284
|
+
// repository value; it adds no read to the guarded-call health check.
|
|
285
|
+
await store.appendRepo(repo, {
|
|
286
|
+
actor: KERNEL,
|
|
287
|
+
type: 'forge.credential-limited',
|
|
288
|
+
payload: {
|
|
289
|
+
forge: 'github',
|
|
290
|
+
process: 'build-runner budget',
|
|
291
|
+
credential: 'unauthenticated',
|
|
292
|
+
missingCredential: 'GITHUB_TOKEN and GH_TOKEN are unset',
|
|
293
|
+
message: 'API rate limit exceeded',
|
|
294
|
+
resetAt: new Date(Date.parse('2026-01-01T00:00:00.000Z') + length * 1000).toISOString(),
|
|
295
|
+
},
|
|
296
|
+
})
|
|
283
297
|
// Warm persisted values independently of any consumer instance.
|
|
284
298
|
await readBuildStreamSeed(store, slug)
|
|
285
299
|
await readBuildFacts(store, slug)
|
|
@@ -344,11 +358,22 @@ export async function reducedReadBudget(opts: {
|
|
|
344
358
|
actor: KERNEL,
|
|
345
359
|
}),
|
|
346
360
|
).toBe('unchanged')
|
|
347
|
-
|
|
361
|
+
// Latest per (forge, process): repeated limits replace, never accumulate.
|
|
362
|
+
expect((await readRepositoryFacts(cold, repo)).value.forgeCredentialLimits).toHaveLength(1)
|
|
348
363
|
}
|
|
349
364
|
expect(costs.events).toBe(0)
|
|
350
365
|
expect(costs.metadata).toBeLessThan(operations * 20)
|
|
351
366
|
}
|
|
367
|
+
// The guarded-call health check stays clear and flat per call beside
|
|
368
|
+
// a saved credential limit.
|
|
369
|
+
for (const operations of [1, 8]) {
|
|
370
|
+
reset()
|
|
371
|
+
for (let n = 0; n < operations; n++) {
|
|
372
|
+
expect(await readForgeHealth(cold, repo)).toBeUndefined()
|
|
373
|
+
}
|
|
374
|
+
expect(costs.events).toBe(0)
|
|
375
|
+
expect(costs.metadata).toBeLessThan(operations * 10)
|
|
376
|
+
}
|
|
352
377
|
// Account holds survive fresh consumers and reconcile without idle journal reads or writes.
|
|
353
378
|
const missing = missingAccountCredentials(
|
|
354
379
|
{ billing: { kind: 'claude-subscription', credentialEnv: 'BILLING_TOKEN' } },
|
|
@@ -1782,7 +1807,13 @@ export async function provisionContinuationGuardReadBudget(opts: {
|
|
|
1782
1807
|
}
|
|
1783
1808
|
|
|
1784
1809
|
/** In-memory history seeding for preparation budgets; never used as a recurring read. */
|
|
1785
|
-
export async function seedPreparationHistory(
|
|
1810
|
+
export async function seedPreparationHistory(
|
|
1811
|
+
store: BuildStore,
|
|
1812
|
+
repo: string,
|
|
1813
|
+
facts: number,
|
|
1814
|
+
/** Record the pending attempt's creation identity, keyed when `creationKey` is set. */
|
|
1815
|
+
creation?: { slug: string; creationKey?: string },
|
|
1816
|
+
) {
|
|
1786
1817
|
await store.ensureRepo(repo)
|
|
1787
1818
|
for (let i = 0; i < facts / 2; i++) {
|
|
1788
1819
|
const ticket = { source: 'fake', id: `old-${i}` }
|
|
@@ -1808,6 +1839,12 @@ export async function seedPreparationHistory(store: BuildStore, repo: string, fa
|
|
|
1808
1839
|
claimedState: 'Doing',
|
|
1809
1840
|
},
|
|
1810
1841
|
})
|
|
1842
|
+
if (creation)
|
|
1843
|
+
await store.appendRepo(repo, {
|
|
1844
|
+
actor: DISPATCHER,
|
|
1845
|
+
type: 'ticket-preparation.creation-selected',
|
|
1846
|
+
payload: { attempt: 'pending', ticket: { source: 'fake', id: 'pending' }, ...creation },
|
|
1847
|
+
})
|
|
1811
1848
|
await store.appendRepo(repo, {
|
|
1812
1849
|
actor: DISPATCHER,
|
|
1813
1850
|
type: 'ticket-preparation.recovery-failed',
|
|
@@ -2784,12 +2821,22 @@ export async function ticketRoleTickBudget(
|
|
|
2784
2821
|
export async function urgentIntakeReadBudget() {
|
|
2785
2822
|
const { MemoryBuildStore } = await import('../store/memory')
|
|
2786
2823
|
const sha = 'a'.repeat(40)
|
|
2787
|
-
const
|
|
2788
|
-
'[tickets]\nsource = "hosted"\nteamKey = "ENG"\n[verify]\nsteps = []\n[finalize]\nsteps = []\n'
|
|
2789
|
-
|
|
2824
|
+
const plain =
|
|
2825
|
+
'[tickets]\nsource = "hosted"\nteamKey = "ENG"\n[verify]\nsteps = []\n[finalize]\nsteps = []\n'
|
|
2826
|
+
// Profile selection is pure label matching over the listing the scan
|
|
2827
|
+
// already holds (SPEC §9): one selected and one conflicting ticket must
|
|
2828
|
+
// cost no extra source request or store row.
|
|
2829
|
+
const profiled = `${plain}[profiles.deep]\nlabel = "deep"\n[profiles.cheap]\nlabel = "cheap"\n`
|
|
2790
2830
|
const methods = ['listReady', 'get', 'dependencyStates', 'listAll'] as const
|
|
2791
2831
|
const results = new Map<string, { calls: Record<string, number>[]; rows: number[] }>()
|
|
2792
|
-
|
|
2832
|
+
const profileResults = new Map<string, { calls: Record<string, number>[]; rows: number[] }>()
|
|
2833
|
+
for (const [urgent, profiles] of [
|
|
2834
|
+
[false, false],
|
|
2835
|
+
[true, false],
|
|
2836
|
+
[false, true],
|
|
2837
|
+
[true, true],
|
|
2838
|
+
] as const) {
|
|
2839
|
+
const config = parseConfig(profiles ? profiled : plain)
|
|
2793
2840
|
for (const length of [100, 100_000]) {
|
|
2794
2841
|
const source = new FakeTicketSource([], { createState: 'triage', doneState: 'done' })
|
|
2795
2842
|
const calls: Record<string, number> = Object.fromEntries(methods.map((name) => [name, 0]))
|
|
@@ -2810,6 +2857,9 @@ export async function urgentIntakeReadBudget() {
|
|
|
2810
2857
|
title,
|
|
2811
2858
|
body: 'Budget',
|
|
2812
2859
|
...(urgent && index === 2 ? { priority: 'urgent' as const } : {}),
|
|
2860
|
+
...(profiles
|
|
2861
|
+
? { labels: index === 0 ? ['deep'] : index === 1 ? ['deep', 'cheap'] : [] }
|
|
2862
|
+
: {}),
|
|
2813
2863
|
})
|
|
2814
2864
|
await source.addBlocker(ticket.ref.id, blocker.ref.id)
|
|
2815
2865
|
await source.transition(ticket.ref.id, 'ready')
|
|
@@ -2818,7 +2868,7 @@ export async function urgentIntakeReadBudget() {
|
|
|
2818
2868
|
let now = 1_800_000_000_000
|
|
2819
2869
|
const clock = () => new Date(now)
|
|
2820
2870
|
const store = new MemoryBuildStore({ clock })
|
|
2821
|
-
const repo = `https://github.com/budget/urgent-intake-${urgent}-${length}`
|
|
2871
|
+
const repo = `https://github.com/budget/urgent-intake-${urgent}-${profiles}-${length}`
|
|
2822
2872
|
await store.ensureRepo(repo)
|
|
2823
2873
|
for (let i = 0; i < length; i++)
|
|
2824
2874
|
await store.appendRepo(repo, {
|
|
@@ -2862,7 +2912,9 @@ export async function urgentIntakeReadBudget() {
|
|
|
2862
2912
|
)
|
|
2863
2913
|
rows.push(counter.rows)
|
|
2864
2914
|
expect(report.dispatched).toBe(0)
|
|
2865
|
-
|
|
2915
|
+
// A conflicting ticket is withheld before dependency checks.
|
|
2916
|
+
expect(report.dependencyBlocked).toBe(profiles ? 2 : 3)
|
|
2917
|
+
expect(report.invalidTickets).toBe(profiles ? 1 : 0)
|
|
2866
2918
|
expect(counter.rows).toBeLessThanOrEqual(32)
|
|
2867
2919
|
// Prepare the tick's own tail, then prove an unchanged read costs zero rows.
|
|
2868
2920
|
await readRepositoryFacts(store, repo)
|
|
@@ -2872,12 +2924,23 @@ export async function urgentIntakeReadBudget() {
|
|
|
2872
2924
|
await readBuildDigests(store, repo)
|
|
2873
2925
|
expect(counter.rows).toBe(0)
|
|
2874
2926
|
}
|
|
2875
|
-
results.set(`${urgent}:${length}`, {
|
|
2927
|
+
;(profiles ? profileResults : results).set(`${urgent}:${length}`, {
|
|
2928
|
+
calls: perTick,
|
|
2929
|
+
rows,
|
|
2930
|
+
})
|
|
2876
2931
|
await store.close()
|
|
2877
2932
|
}
|
|
2878
2933
|
}
|
|
2879
2934
|
const [baseline, ...rest] = [...results.values()]
|
|
2880
2935
|
for (const result of rest) expect(result).toEqual(baseline!)
|
|
2936
|
+
const [profileBaseline, ...profileRest] = [...profileResults.values()]
|
|
2937
|
+
for (const result of profileRest) expect(result).toEqual(profileBaseline!)
|
|
2938
|
+
// Profiles never add a request or a row; withholding a conflict can only save.
|
|
2939
|
+
profileBaseline!.calls.forEach((tick, index) => {
|
|
2940
|
+
for (const name of methods)
|
|
2941
|
+
expect(tick[name]).toBeLessThanOrEqual(baseline!.calls[index]![name]!)
|
|
2942
|
+
expect(profileBaseline!.rows[index]).toBeLessThanOrEqual(baseline!.rows[index]!)
|
|
2943
|
+
})
|
|
2881
2944
|
return baseline!.calls[0]!
|
|
2882
2945
|
}
|
|
2883
2946
|
|