@defrex/autobuild 1.6.0 → 1.8.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 +423 -57
- package/docs/agent-runtimes.md +1 -1
- package/docs/answering-blocked-builds.md +44 -3
- package/docs/architecture.md +124 -29
- package/docs/cli.md +1 -0
- package/docs/configuration-overview.md +11 -1
- package/docs/configuration.md +334 -14
- package/docs/dispatcher.md +1 -1
- package/docs/forges.md +1 -0
- 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 +45 -13
- package/docs/operator-surfaces.md +16 -3
- package/docs/plugin-authoring.md +45 -7
- package/docs/remote-store-protocol.md +28 -7
- package/docs/restacking.md +35 -11
- package/docs/ticket-dependencies.md +9 -4
- package/docs/ticket-sources.md +34 -6
- package/docs/tickets.md +7 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/workspaces.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary-direct.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/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 +80 -11
- package/packages/core/src/cli/init-validation.ts +14 -1
- 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/repository-status.ts +37 -2
- package/packages/core/src/cli/status.ts +186 -12
- package/packages/core/src/cli/terminals.ts +197 -4
- package/packages/core/src/cli/ticket.ts +22 -4
- package/packages/core/src/cli/wait.ts +1 -0
- package/packages/core/src/cli/watch.ts +73 -0
- package/packages/core/src/config/landing.ts +12 -0
- package/packages/core/src/config/live.ts +4 -0
- package/packages/core/src/config/path-selectors.ts +68 -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 +205 -81
- package/packages/core/src/events/catalog.ts +17 -3
- package/packages/core/src/events/compatibility.ts +4 -1
- package/packages/core/src/events/forge-degradation-policy.ts +16 -2
- package/packages/core/src/events/head-paths-limits.ts +25 -0
- package/packages/core/src/events/payloads.ts +323 -20
- package/packages/core/src/events/policy.ts +22 -0
- package/packages/core/src/events/repository.ts +47 -1
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +320 -130
- package/packages/core/src/kernel/build-creation.ts +29 -0
- 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/forge-health.ts +47 -0
- package/packages/core/src/kernel/guarded-forge.ts +76 -18
- 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-state.ts +50 -2
- package/packages/core/src/kernel/log-index.ts +27 -1
- package/packages/core/src/kernel/node-parent.ts +2 -0
- 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 +37 -2
- package/packages/core/src/kernel/reducer-registry.ts +22 -1
- package/packages/core/src/kernel/reducer.ts +332 -16
- 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 +15 -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 +25 -2
- package/packages/core/src/operator/query.ts +1 -1
- package/packages/core/src/operator/registry.ts +122 -10
- package/packages/core/src/operator/repository-events.ts +67 -0
- 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/fake.ts +5 -0
- 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 +36 -5
- 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 +34 -2
- package/packages/core/src/processes/build-runner.ts +165 -19
- package/packages/core/src/processes/dispatcher.ts +837 -115
- package/packages/core/src/processes/execution-no-progress.ts +22 -2
- 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/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-state.ts +6 -1
- package/packages/core/src/processes/repo-view.ts +2 -0
- package/packages/core/src/scenarios/harness.ts +15 -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 +10310 -8441
- package/packages/core/src/store/remote/client.ts +49 -10
- package/packages/core/src/store/remote/index.ts +4 -0
- package/packages/core/src/store/remote/protocol.ts +18 -1
- package/packages/core/src/store/remote/released-clients.json +22 -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/1.8.0.json +29043 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +3 -0
- package/packages/core/src/store/types.ts +27 -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 +419 -9
- package/skills/code-review/SKILL.md +8 -0
- package/skills/finalize/SKILL.md +4 -0
- package/skills/guide/SKILL.md +241 -47
- 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 +45 -13
- package/skills/guide/references/plugin-authoring.md +45 -7
- package/skills/guide/references/remote-store-protocol.md +28 -7
- package/skills/guide/references/restacking.md +35 -11
- package/skills/guide/references/ticket-dependencies.md +9 -4
- package/skills/implement/SKILL.md +15 -1
- package/skills/operate/SKILL.md +133 -16
- 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 +23 -6
- package/templates/hosted-service/package.json +2 -2
|
@@ -4,6 +4,8 @@ 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'
|
|
8
|
+
import release6 from './1.8.0.json'
|
|
7
9
|
import type { ReducerValueCatalog } from '../../reducer-value-validation'
|
|
8
10
|
export interface ReleasedReducerValues extends ReducerValueCatalog {
|
|
9
11
|
versions: Record<string, number>
|
|
@@ -14,4 +16,6 @@ export const RELEASED_REDUCER_VALUES: Readonly<Record<string, ReleasedReducerVal
|
|
|
14
16
|
'1.4.0.json': release2,
|
|
15
17
|
'1.5.0.json': release3,
|
|
16
18
|
'1.6.0.json': release4,
|
|
19
|
+
'1.7.0.json': release5,
|
|
20
|
+
'1.8.0.json': release6,
|
|
17
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,10 +40,12 @@ 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',
|
|
45
47
|
'dispatcher.forge-recovered',
|
|
48
|
+
'forge.credential-limited',
|
|
46
49
|
'dispatcher.kernel-git-unavailable',
|
|
47
50
|
'dispatcher.kernel-git-recovered',
|
|
48
51
|
...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
|
|
@@ -109,6 +114,14 @@ export interface ArtifactMeta {
|
|
|
109
114
|
* render rows. Nothing is persisted: every adapter derives the digest from
|
|
110
115
|
* the event log on each call, so the log stays the sole authority and the
|
|
111
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
|
+
|
|
112
125
|
export interface BuildDigest {
|
|
113
126
|
compatibility?: import('../events/compatibility').CompatibilityState
|
|
114
127
|
/** A kernel landing requested an audit and no audit settlement has followed. */
|
|
@@ -128,6 +141,14 @@ export interface BuildDigest {
|
|
|
128
141
|
readinessChangeSeq?: number
|
|
129
142
|
slug: string
|
|
130
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
|
|
131
152
|
/** Ascending-seq `{seq, ts}` pairs for every `observation.recorded` in the
|
|
132
153
|
* build's log; `ts` is the event envelope timestamp (AUT-521: the harvest
|
|
133
154
|
* pressure gate measures drift from the oldest unclaimed occurrence's ts,
|
|
@@ -296,6 +317,12 @@ export interface BuildStore extends BoundedEventReads {
|
|
|
296
317
|
* The handle retains this shape so foreign/admin calls fail loudly. */
|
|
297
318
|
scopeBuild(slug: string): BuildScopedStore
|
|
298
319
|
|
|
320
|
+
/** How `createBuild` chooses the canonical slug. Absent: exactly
|
|
321
|
+
* `input.slug`. `'keyed'`: `input.slug`, or `creationBuildSlug(repo, slug,
|
|
322
|
+
* creationKey)` when a key is sent. `'allocated'`: possibly a slug the
|
|
323
|
+
* caller never learns if the response is lost, so absence at a known slug
|
|
324
|
+
* proves nothing. */
|
|
325
|
+
buildCreationIdentity?(): Promise<'keyed' | 'allocated'>
|
|
299
326
|
createBuild(input: NewBuildInput): Promise<BuildRecord>
|
|
300
327
|
getBuild(slug: string): Promise<BuildRecord | null>
|
|
301
328
|
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,
|