@defrex/autobuild 1.11.1 → 1.12.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 +177 -54
- package/docs/answering-blocked-builds.md +10 -2
- package/docs/architecture.md +66 -6
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +13 -11
- package/docs/dispatcher.md +1 -1
- package/docs/integration-tree.md +28 -16
- package/docs/operator-api.md +4 -4
- package/docs/operator-surfaces.md +35 -0
- package/docs/optimization-nodes.md +3 -2
- package/docs/tickets.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/ambient-errors.ts +17 -0
- package/packages/core/src/cli/bounded-io.ts +174 -0
- package/packages/core/src/cli/dashboard/model.ts +81 -23
- package/packages/core/src/cli/dashboard/poll.ts +20 -31
- package/packages/core/src/cli/dashboard/render.ts +14 -37
- package/packages/core/src/cli/dashboard/row-text.ts +24 -7
- package/packages/core/src/cli/dashboard/tone-ansi.ts +39 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +161 -20
- package/packages/core/src/cli/dispatch-handoff.ts +41 -10
- package/packages/core/src/cli/dispatch-launch-contract.ts +5 -0
- package/packages/core/src/cli/dispatch-launcher-cadence.ts +80 -0
- package/packages/core/src/cli/dispatch-launcher.ts +9 -10
- package/packages/core/src/cli/dispatch-preflight.ts +12 -3
- package/packages/core/src/cli/dispatch-release-observer.ts +53 -0
- package/packages/core/src/cli/dispatch-runtime-cache.ts +204 -82
- package/packages/core/src/cli/dispatch-runtime-dependencies.ts +250 -43
- package/packages/core/src/cli/dispatch-upgrade-install.ts +36 -16
- package/packages/core/src/cli/dispatch-upgrade-source.ts +8 -2
- package/packages/core/src/cli/dispatch-yield-observer.ts +82 -0
- package/packages/core/src/cli/dispatch.ts +68 -5
- package/packages/core/src/cli/env.ts +2 -15
- package/packages/core/src/cli/help.ts +5 -4
- package/packages/core/src/cli/main.ts +4 -2
- package/packages/core/src/cli/production-store.ts +102 -0
- package/packages/core/src/cli/repo-state.ts +2 -3
- package/packages/core/src/cli/repository-status.ts +28 -22
- package/packages/core/src/cli/sessionless-store.ts +26 -0
- package/packages/core/src/cli/status.ts +169 -40
- package/packages/core/src/cli/store-opening.ts +15 -58
- package/packages/core/src/cli/store-ref.ts +6 -1
- package/packages/core/src/config/schema.ts +1 -1
- package/packages/core/src/distribution-packaging.ts +156 -18
- package/packages/core/src/events/catalog-identity.ts +28 -0
- package/packages/core/src/events/catalog.ts +3 -9
- package/packages/core/src/events/compatibility.ts +2 -30
- package/packages/core/src/events/payloads.ts +11 -0
- package/packages/core/src/events/policy.ts +3 -0
- package/packages/core/src/events/repository.ts +1 -1
- package/packages/core/src/events/sessions.ts +1 -1
- package/packages/core/src/events/validation-error.ts +12 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +9 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3064e337cc75f8d6.json +310 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a1e90a969d32a367.json +307 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/da3bc91c49211eab.json +310 -0
- package/packages/core/src/kernel/auto-merge-default.ts +2 -1
- package/packages/core/src/kernel/capacity-build.ts +21 -0
- package/packages/core/src/kernel/discard-in-flight.ts +13 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +354 -147
- package/packages/core/src/kernel/engine.ts +2 -8
- package/packages/core/src/kernel/measurement.ts +24 -0
- package/packages/core/src/kernel/read-facts.ts +8 -370
- package/packages/core/src/kernel/reducer-registry.ts +40 -125
- package/packages/core/src/kernel/reducer-revisions.ts +3 -0
- package/packages/core/src/kernel/reducer-value-entry.ts +98 -0
- package/packages/core/src/kernel/reducer-value-index.ts +75 -0
- package/packages/core/src/kernel/reducer.ts +57 -9
- package/packages/core/src/kernel/reopen-state.ts +10 -0
- package/packages/core/src/kernel/repository-read-facts.ts +375 -0
- package/packages/core/src/kernel/verify-stage-state.ts +145 -3
- package/packages/core/src/operator/presentation.ts +13 -0
- package/packages/core/src/operator/query.ts +40 -39
- package/packages/core/src/operator/registry.ts +3 -3
- package/packages/core/src/ports/workspace/fake.ts +15 -3
- package/packages/core/src/processes/dispatcher.ts +232 -75
- package/packages/core/src/processes/execution-no-progress.ts +1 -0
- package/packages/core/src/store/local/capabilities.ts +115 -0
- package/packages/core/src/store/local/store.ts +86 -56
- package/packages/core/src/store/reduced-reads.ts +9 -1
- package/packages/core/src/store/reducer-value-read.ts +235 -0
- package/packages/core/src/store/reducer-value-shapes.json +1437 -1349
- package/packages/core/src/store/reducer-values.ts +36 -204
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.12.0.json +35806 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
- package/packages/core/src/store/rollup-lease.ts +41 -0
- package/packages/core/src/store/rollups.ts +7 -38
- package/packages/core/src/store/snapshots.ts +1 -1
- package/packages/core/src/testing/dispatch-read-budget.ts +265 -4
- package/packages/core/src/testing/import-graph.ts +78 -0
- package/packages/core/src/testing/reduced-read-budget.ts +221 -22
- package/packages/core/src/testing/slot-agreement.ts +52 -0
- package/packages/core/src/web/assets/app.js +5 -5
- package/skills/guide/SKILL.md +115 -44
- package/skills/guide/references/integration-tree.md +28 -16
- package/skills/guide/references/operator-api.md +4 -4
- package/skills/guide/references/optimization-nodes.md +3 -2
- package/skills/operate/SKILL.md +38 -20
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,225 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { z } from 'zod'
|
|
5
|
-
import type { AbEvent } from '../events/catalog'
|
|
6
|
-
import type { RepositoryEvent } from '../events/repository'
|
|
1
|
+
/** Named JSON answers over persisted incremental state, resolved against the
|
|
2
|
+
* complete catalog. The event log remains authoritative. */
|
|
3
|
+
import { READ_CATALOG_IDENTITY } from '../events/catalog-identity'
|
|
7
4
|
import { REDUCERS } from '../kernel/reducer-registry'
|
|
8
|
-
import type {
|
|
5
|
+
import type { SnapshotScope } from './snapshots'
|
|
9
6
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
parseValueRequest,
|
|
8
|
+
readResolvedReducerValue,
|
|
9
|
+
resolveRegisteredValue,
|
|
10
|
+
type ReducerValue,
|
|
11
|
+
type ReducerValueRequest,
|
|
12
|
+
type ReducerValueStorage,
|
|
13
|
+
} from './reducer-value-read'
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
value: JsonValue
|
|
31
|
-
}
|
|
32
|
-
export const reducerValueSchema = z
|
|
33
|
-
.object({
|
|
34
|
-
version: z.number().int().positive(),
|
|
35
|
-
cursor: z.number().int().nonnegative(),
|
|
36
|
-
value: z.json(),
|
|
37
|
-
})
|
|
38
|
-
.strict()
|
|
39
|
-
|
|
40
|
-
export interface ValueCatalogEntry {
|
|
41
|
-
scope: SnapshotScope['kind']
|
|
42
|
-
args: z.ZodType
|
|
43
|
-
validate(state: unknown): boolean
|
|
44
|
-
adapt(events: readonly (AbEvent | RepositoryEvent)[]): readonly unknown[]
|
|
45
|
-
value(state: unknown): JsonValue
|
|
46
|
-
// biome-ignore lint/suspicious/noExplicitAny: heterogeneous executable catalog
|
|
47
|
-
create(args: any): IncrementalReducer<any, any, any>
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function canonical(value: unknown): string {
|
|
51
|
-
if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`
|
|
52
|
-
if (value !== null && typeof value === 'object')
|
|
53
|
-
return `{${Object.entries(value)
|
|
54
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
55
|
-
.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`)
|
|
56
|
-
.join(',')}}`
|
|
57
|
-
return JSON.stringify(value)
|
|
58
|
-
}
|
|
15
|
+
export {
|
|
16
|
+
canonical,
|
|
17
|
+
parseValueRequest,
|
|
18
|
+
readResolvedReducerValue,
|
|
19
|
+
reducerValueRequestSchema,
|
|
20
|
+
reducerValueSchema,
|
|
21
|
+
resolveRegisteredValue,
|
|
22
|
+
type JsonValue,
|
|
23
|
+
type ReducerValue,
|
|
24
|
+
type ReducerValueRequest,
|
|
25
|
+
type ReducerValueStorage,
|
|
26
|
+
type ResolvedReducerValue,
|
|
27
|
+
type ValueCacheRow,
|
|
28
|
+
type ValueCatalogEntry,
|
|
29
|
+
} from './reducer-value-read'
|
|
59
30
|
|
|
60
31
|
export function resolveReducerValue(
|
|
61
32
|
scope: SnapshotScope,
|
|
62
33
|
input: ReducerValueRequest,
|
|
63
34
|
catalogIdentity = READ_CATALOG_IDENTITY,
|
|
64
35
|
) {
|
|
65
|
-
const request =
|
|
66
|
-
if (request.read !== undefined)
|
|
67
|
-
throw new Error(`reducer "${request.reducer}" takes no read-time arguments`)
|
|
36
|
+
const request = parseValueRequest(input)
|
|
68
37
|
const registration = Object.hasOwn(REDUCERS, request.reducer)
|
|
69
38
|
? REDUCERS[request.reducer]
|
|
70
39
|
: undefined
|
|
71
|
-
|
|
72
|
-
const entry = registration.valueRead
|
|
73
|
-
if ('excluded' in entry)
|
|
74
|
-
throw new Error(`excluded reducer "${request.reducer}": ${entry.excluded}`)
|
|
75
|
-
if (entry.scope !== scope.kind) throw new Error(`wrong scope for reducer "${request.reducer}"`)
|
|
76
|
-
const args = entry.args.parse(request.args ?? {})
|
|
77
|
-
const reducer = entry.create(args)
|
|
78
|
-
const identity = canonical({
|
|
79
|
-
scope,
|
|
80
|
-
reducer: request.reducer,
|
|
81
|
-
version: reducer.version,
|
|
82
|
-
catalogIdentity,
|
|
83
|
-
args,
|
|
84
|
-
})
|
|
85
|
-
// v2 ignores checkpoints from the former client-writable key format.
|
|
86
|
-
const key = `${REDUCER_VALUE_SNAPSHOT_PREFIX}v2.${new Bun.CryptoHasher('sha256').update(identity).digest('hex').slice(0, 54)}`
|
|
87
|
-
return { name: request.reducer, reducer, identity, key, entry }
|
|
40
|
+
return resolveRegisteredValue(scope, request, registration, catalogIdentity)
|
|
88
41
|
}
|
|
89
42
|
|
|
90
|
-
|
|
91
|
-
* cannot submit a new accumulator through the value API. `token` identifies the
|
|
92
|
-
* exact row read, including malformed bytes that could not be decoded. */
|
|
93
|
-
export interface ValueCacheRow {
|
|
94
|
-
snapshot: ReducerSnapshot
|
|
95
|
-
token: string
|
|
96
|
-
}
|
|
97
|
-
export interface ReducerValueStorage {
|
|
98
|
-
checkpoints?: {
|
|
99
|
-
publish(key: string, snapshot: ReducerSnapshot, checkpoints: ReducerSnapshot[]): Promise<void>
|
|
100
|
-
coverage(key: string, cursor: number): Promise<boolean>
|
|
101
|
-
latest(key: string, through: number): Promise<ReducerSnapshot | null>
|
|
102
|
-
}
|
|
103
|
-
highWater(): Promise<number>
|
|
104
|
-
read(key: string): Promise<ValueCacheRow | null>
|
|
105
|
-
events(since: number, through: number): Promise<(AbEvent | RepositoryEvent)[]>
|
|
106
|
-
put(key: string, snapshot: ReducerSnapshot): Promise<boolean>
|
|
107
|
-
repair(key: string, observed: ValueCacheRow, snapshot: ReducerSnapshot): Promise<boolean>
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export async function readReducerValue(
|
|
43
|
+
export function readReducerValue(
|
|
111
44
|
scope: SnapshotScope,
|
|
112
45
|
request: ReducerValueRequest,
|
|
113
46
|
storage: ReducerValueStorage,
|
|
114
47
|
): Promise<ReducerValue> {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
let
|
|
48
|
+
// Not `async`: returning the inner promise directly keeps the read's
|
|
49
|
+
// microtask timing identical to the single-function body it replaced.
|
|
50
|
+
let resolved: ReturnType<typeof resolveReducerValue>
|
|
118
51
|
try {
|
|
119
|
-
|
|
120
|
-
} catch {
|
|
121
|
-
|
|
122
|
-
/* unreadable cache is a miss */
|
|
123
|
-
}
|
|
124
|
-
// A concurrent reader may have persisted beyond our first boundary. Only a
|
|
125
|
-
// fresh authoritative boundary can establish ahead-of-log poison.
|
|
126
|
-
if (row && row.snapshot.cursor > boundary) boundary = await storage.highWater()
|
|
127
|
-
let acc = reducer.initial()
|
|
128
|
-
let cursor = 0
|
|
129
|
-
let valid = false
|
|
130
|
-
if (row) {
|
|
131
|
-
const { snapshot } = row
|
|
132
|
-
const state = snapshot.state as { identity?: unknown; acc?: unknown } | null
|
|
133
|
-
try {
|
|
134
|
-
valid =
|
|
135
|
-
snapshot.version === reducer.version &&
|
|
136
|
-
Number.isSafeInteger(snapshot.cursor) &&
|
|
137
|
-
snapshot.cursor >= 0 &&
|
|
138
|
-
snapshot.cursor <= boundary &&
|
|
139
|
-
state !== null &&
|
|
140
|
-
typeof state === 'object' &&
|
|
141
|
-
state.identity === identity &&
|
|
142
|
-
entry.validate(state.acc)
|
|
143
|
-
} catch {
|
|
144
|
-
valid = false // malformed nested cache data must never prevent replay
|
|
145
|
-
}
|
|
146
|
-
if (valid) {
|
|
147
|
-
acc = structuredClone(state!.acc)
|
|
148
|
-
cursor = snapshot.cursor
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (storage.checkpoints && row && !valid)
|
|
152
|
-
throw new CheckpointIntegrityError('corrupt canonical stream seed')
|
|
153
|
-
let recovering = false
|
|
154
|
-
if (storage.checkpoints && valid && !(await storage.checkpoints.coverage(key, cursor))) {
|
|
155
|
-
// A pre-checkpoint server may advance the shared canonical row during a
|
|
156
|
-
// rolling deploy or rollback. Its accumulator cannot supply the missing
|
|
157
|
-
// intermediate seeds. Refold only the uncovered suffix under the seed lock.
|
|
158
|
-
const checkpoint = await storage.checkpoints.latest(key, cursor)
|
|
159
|
-
if (checkpoint) {
|
|
160
|
-
const state = checkpoint.state as { identity?: unknown; acc?: unknown } | null
|
|
161
|
-
if (
|
|
162
|
-
checkpoint.version !== reducer.version ||
|
|
163
|
-
!Number.isSafeInteger(checkpoint.cursor) ||
|
|
164
|
-
checkpoint.cursor < 0 ||
|
|
165
|
-
checkpoint.cursor > cursor ||
|
|
166
|
-
state?.identity !== identity ||
|
|
167
|
-
!entry.validate(state.acc)
|
|
168
|
-
)
|
|
169
|
-
throw new CheckpointIntegrityError('corrupt recovery stream-seed checkpoint')
|
|
170
|
-
acc = structuredClone(state.acc)
|
|
171
|
-
cursor = checkpoint.cursor
|
|
172
|
-
} else {
|
|
173
|
-
// Initial legacy adoption with no checkpoint to resume from.
|
|
174
|
-
acc = reducer.initial()
|
|
175
|
-
cursor = 0
|
|
176
|
-
}
|
|
177
|
-
recovering = true
|
|
178
|
-
}
|
|
179
|
-
const start = cursor
|
|
180
|
-
const delta = (await storage.events(cursor, boundary)).filter((event) => event.seq <= boundary)
|
|
181
|
-
for (const event of delta) {
|
|
182
|
-
if (event.seq !== cursor + 1) throw new Error('noncontiguous reducer log')
|
|
183
|
-
cursor = event.seq
|
|
184
|
-
}
|
|
185
|
-
if (cursor !== boundary) throw new Error('incomplete reducer log')
|
|
186
|
-
const checkpoints: ReducerSnapshot[] = []
|
|
187
|
-
if (storage.checkpoints) {
|
|
188
|
-
const oldest = Math.max(0, boundary - REPOSITORY_TAIL_WINDOW)
|
|
189
|
-
const prefix = delta.filter((event) => event.seq <= oldest)
|
|
190
|
-
acc = reducer.advance(acc, entry.adapt(projectStoredEvents(prefix)))
|
|
191
|
-
if (start <= oldest)
|
|
192
|
-
checkpoints.push({
|
|
193
|
-
version: reducer.version,
|
|
194
|
-
cursor: oldest,
|
|
195
|
-
state: { identity, acc: structuredClone(acc) },
|
|
196
|
-
})
|
|
197
|
-
for (const event of delta) {
|
|
198
|
-
if (event.seq <= oldest) continue
|
|
199
|
-
acc = reducer.advance(acc, entry.adapt(projectStoredEvents([event])))
|
|
200
|
-
checkpoints.push({
|
|
201
|
-
version: reducer.version,
|
|
202
|
-
cursor: event.seq,
|
|
203
|
-
state: { identity, acc: structuredClone(acc) },
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
} else acc = reducer.advance(acc, entry.adapt(projectStoredEvents(delta)))
|
|
207
|
-
const value = entry.value(reducer.finish(acc))
|
|
208
|
-
if (!valid || recovering || delta.length > 0) {
|
|
209
|
-
const next = { version: reducer.version, cursor, state: { identity, acc } }
|
|
210
|
-
if (storage.checkpoints) {
|
|
211
|
-
await storage.checkpoints.publish(key, next, checkpoints)
|
|
212
|
-
return { version: reducer.version, cursor, value, catalogIdentity: READ_CATALOG_IDENTITY }
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
if (row && !valid && row.snapshot.version === reducer.version)
|
|
216
|
-
await storage.repair(key, row, next)
|
|
217
|
-
else if (row && !valid && row.snapshot.version !== reducer.version) {
|
|
218
|
-
/* foreign cache is read-only */
|
|
219
|
-
} else await storage.put(key, next)
|
|
220
|
-
} catch {
|
|
221
|
-
/* best-effort cache; log and reduction errors propagate */
|
|
222
|
-
}
|
|
52
|
+
resolved = resolveReducerValue(scope, request)
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return Promise.reject(error)
|
|
223
55
|
}
|
|
224
|
-
return
|
|
56
|
+
return readResolvedReducerValue(resolved, storage)
|
|
225
57
|
}
|
|
@@ -154,5 +154,16 @@
|
|
|
154
154
|
"provenance": {
|
|
155
155
|
"tag": "v1.11.1"
|
|
156
156
|
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"version": "1.12.0",
|
|
160
|
+
"publishedAt": "2026-11-30T20:20:02.645Z",
|
|
161
|
+
"protocol": "7",
|
|
162
|
+
"contract": "1.12.0.json",
|
|
163
|
+
"projects": true,
|
|
164
|
+
"catalogIdentity": "a381f7bfe8eb04827869e5b05fb19901c2d52867081de419f44f2e00005ef306",
|
|
165
|
+
"provenance": {
|
|
166
|
+
"tag": "v1.12.0"
|
|
167
|
+
}
|
|
157
168
|
}
|
|
158
169
|
]
|