@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,6 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { constants } from 'node:fs'
|
|
2
|
+
import {
|
|
3
|
+
chmod,
|
|
4
|
+
copyFile,
|
|
5
|
+
cp,
|
|
6
|
+
lstat,
|
|
7
|
+
mkdir,
|
|
8
|
+
mkdtemp,
|
|
9
|
+
readdir,
|
|
10
|
+
readFile,
|
|
11
|
+
rm,
|
|
12
|
+
writeFile,
|
|
13
|
+
} from 'node:fs/promises'
|
|
2
14
|
import { tmpdir } from 'node:os'
|
|
3
|
-
import { dirname, join } from 'node:path'
|
|
15
|
+
import { dirname, isAbsolute, join, relative, sep } from 'node:path'
|
|
16
|
+
import { drainStack, forEachBounded, TREE_IO_CONCURRENCY } from './cli/bounded-io'
|
|
4
17
|
|
|
5
18
|
async function spawnExec(cmd: string[], options: { cwd: string; signal?: AbortSignal }) {
|
|
6
19
|
const child = Bun.spawn(cmd, {
|
|
@@ -62,12 +75,134 @@ async function execOrThrow(
|
|
|
62
75
|
* while the repo manifest keeps it for workspace installs. */
|
|
63
76
|
const packedManifestOmittedFields = ['patchedDependencies', 'devDependencies'] as const
|
|
64
77
|
|
|
78
|
+
/** Gzip level for an archive that is extracted at once and discarded, never
|
|
79
|
+
* stored or sent anywhere (the packaged source fingerprint). Its compressed
|
|
80
|
+
* bytes are pure overhead: level 0 keeps valid gzip framing for `tar -xzf`
|
|
81
|
+
* while spending no CPU on deflate, which at Bun's default level 9 dominates
|
|
82
|
+
* the pack. */
|
|
83
|
+
export const SCRATCH_ARCHIVE_GZIP_LEVEL = 0
|
|
84
|
+
|
|
85
|
+
/** Gzip level for a locally prepared runtime archive, kept under `.autobuild`
|
|
86
|
+
* and possibly uploaded to a guest. Level 2 packs in well under half the time
|
|
87
|
+
* of the default level 9 for an archive only slightly larger, so dispatcher
|
|
88
|
+
* starts and upgrade handoffs stop paying maximum deflate effort. Its own
|
|
89
|
+
* digest is taken from the bytes it produces. */
|
|
90
|
+
export const RUNTIME_ARCHIVE_GZIP_LEVEL = 2
|
|
91
|
+
|
|
92
|
+
/** The filesystem operations {@link stageDistributionFiles} uses, with the
|
|
93
|
+
* `node:fs/promises` signatures it calls them with. */
|
|
94
|
+
export interface StagingFilesystem {
|
|
95
|
+
lstat(path: string): Promise<{
|
|
96
|
+
mode: number
|
|
97
|
+
isDirectory(): boolean
|
|
98
|
+
isFile(): boolean
|
|
99
|
+
}>
|
|
100
|
+
readdir(path: string): Promise<string[]>
|
|
101
|
+
mkdir(path: string, options?: { recursive?: boolean }): Promise<unknown>
|
|
102
|
+
copyFile(source: string, target: string, mode: number): Promise<void>
|
|
103
|
+
chmod(path: string, mode: number): Promise<void>
|
|
104
|
+
cp(source: string, target: string, options: typeof stagingCopyOptions): Promise<void>
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const nodeStagingFilesystem: StagingFilesystem = {
|
|
108
|
+
lstat,
|
|
109
|
+
readdir: (path) => readdir(path),
|
|
110
|
+
mkdir,
|
|
111
|
+
copyFile,
|
|
112
|
+
chmod,
|
|
113
|
+
cp,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const stagingCopyOptions = { recursive: true, errorOnExist: true, force: false } as const
|
|
117
|
+
|
|
118
|
+
function entriesOverlap(staging: string, entries: readonly string[]): boolean {
|
|
119
|
+
const normalized = entries.map((entry) => relative(staging, join(staging, entry)))
|
|
120
|
+
if (normalized.some((path) => path === '' || path.startsWith('..') || isAbsolute(path)))
|
|
121
|
+
return true
|
|
122
|
+
for (const a of normalized)
|
|
123
|
+
for (const b of normalized)
|
|
124
|
+
if (a !== b ? b.startsWith(a + sep) : normalized.indexOf(a) !== normalized.lastIndexOf(a))
|
|
125
|
+
return true
|
|
126
|
+
return false
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Copies each positive `files` entry of `root` to the same relative path under
|
|
130
|
+
* a fresh `staging` directory, with the result `cp(source, target, { recursive:
|
|
131
|
+
* true, errorOnExist: true, force: false })` per entry produces.
|
|
132
|
+
*
|
|
133
|
+
* Disjoint entries are walked by one bounded pool: directory children are
|
|
134
|
+
* queued as plain items, so at most `limit` filesystem operations are in flight
|
|
135
|
+
* across and within entries however many files they hold. The walker creates
|
|
136
|
+
* directories and copies regular files itself, giving each file its source
|
|
137
|
+
* mode (`& 0o7777`) and, after every copy has finished, each directory its
|
|
138
|
+
* source mode deepest level first so a read-only directory is restricted only
|
|
139
|
+
* once its descendants exist. Every other entry kind (symlinks, FIFOs,
|
|
140
|
+
* sockets, devices) is handed to `cp` with the same options, keeping its
|
|
141
|
+
* semantics exactly. Overlapping, duplicate, empty or escaping entries keep
|
|
142
|
+
* the serial per-entry `cp` loop in manifest order, so merges and overlap
|
|
143
|
+
* errors behave as before.
|
|
144
|
+
*
|
|
145
|
+
* After the first failure no operation starts, and the promise settles only
|
|
146
|
+
* once every started operation has settled, so the caller can remove staging
|
|
147
|
+
* without racing an outstanding write. */
|
|
148
|
+
export async function stageDistributionFiles(
|
|
149
|
+
root: string,
|
|
150
|
+
staging: string,
|
|
151
|
+
entries: readonly string[],
|
|
152
|
+
fs: StagingFilesystem = nodeStagingFilesystem,
|
|
153
|
+
limit = TREE_IO_CONCURRENCY,
|
|
154
|
+
): Promise<void> {
|
|
155
|
+
if (entriesOverlap(staging, entries)) {
|
|
156
|
+
for (const entry of entries) {
|
|
157
|
+
const target = join(staging, entry)
|
|
158
|
+
await fs.mkdir(dirname(target), { recursive: true })
|
|
159
|
+
await fs.cp(join(root, entry), target, stagingCopyOptions)
|
|
160
|
+
}
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
type Item = { source: string; target: string; depth: number }
|
|
164
|
+
const directories: Array<Array<{ target: string; mode: number }>> = []
|
|
165
|
+
await drainStack<Item>(
|
|
166
|
+
entries.map((entry) => ({ source: join(root, entry), target: join(staging, entry), depth: 0 })),
|
|
167
|
+
limit,
|
|
168
|
+
async ({ source, target, depth }, push) => {
|
|
169
|
+
const status = await fs.lstat(source)
|
|
170
|
+
if (depth === 0) await fs.mkdir(dirname(target), { recursive: true })
|
|
171
|
+
if (status.isDirectory()) {
|
|
172
|
+
await fs.mkdir(target)
|
|
173
|
+
const level = directories[depth] ?? []
|
|
174
|
+
directories[depth] = level
|
|
175
|
+
level.push({ target, mode: status.mode & 0o7777 })
|
|
176
|
+
for (const name of await fs.readdir(source))
|
|
177
|
+
push({ source: join(source, name), target: join(target, name), depth: depth + 1 })
|
|
178
|
+
} else if (status.isFile()) {
|
|
179
|
+
await fs.copyFile(source, target, constants.COPYFILE_EXCL)
|
|
180
|
+
await fs.chmod(target, status.mode & 0o7777)
|
|
181
|
+
} else {
|
|
182
|
+
await fs.cp(source, target, stagingCopyOptions)
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
)
|
|
186
|
+
for (let depth = directories.length - 1; depth >= 0; depth--)
|
|
187
|
+
await forEachBounded(directories[depth] ?? [], limit, ({ target, mode }) =>
|
|
188
|
+
fs.chmod(target, mode),
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Packs `root`'s `files` set with `bun pm pack`. `options.gzipLevel` (an
|
|
193
|
+
* integer 0–9) sets the archive's deflate effort; omitted, Bun's default
|
|
194
|
+
* applies and the command is unchanged. The level changes compressed bytes
|
|
195
|
+
* only, never the extracted contents. */
|
|
65
196
|
export async function packageDistribution(
|
|
66
197
|
root: string,
|
|
67
198
|
exec: PackagingExec = spawnExec,
|
|
68
199
|
signal?: AbortSignal,
|
|
69
200
|
filesystem: { mkdtemp(prefix: string): Promise<string>; rm: typeof rm } = { mkdtemp, rm },
|
|
201
|
+
options: { gzipLevel?: number } = {},
|
|
70
202
|
): Promise<Uint8Array> {
|
|
203
|
+
const { gzipLevel } = options
|
|
204
|
+
if (gzipLevel !== undefined && (!Number.isInteger(gzipLevel) || gzipLevel < 0 || gzipLevel > 9))
|
|
205
|
+
throw new Error('gzip level must be an integer from 0 to 9')
|
|
71
206
|
const staging = await filesystem.mkdtemp(join(tmpdir(), 'autobuild-pack-staging-'))
|
|
72
207
|
let destination: string | undefined
|
|
73
208
|
let failure: unknown
|
|
@@ -88,25 +223,28 @@ export async function packageDistribution(
|
|
|
88
223
|
'Autobuild packaging requires the root package.json to list its files as an array of paths',
|
|
89
224
|
)
|
|
90
225
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
recursive: true,
|
|
102
|
-
errorOnExist: true,
|
|
103
|
-
force: false,
|
|
104
|
-
})
|
|
105
|
-
}
|
|
226
|
+
// npm `files` entries may be negated globs (for example
|
|
227
|
+
// `!packages/core/src/**/*.test.ts`, which keeps test files out of the
|
|
228
|
+
// published package). Only positive entries name a path to stage: the
|
|
229
|
+
// negations stay in the staged manifest and `bun pm pack` applies them,
|
|
230
|
+
// so the packed set still excludes those paths.
|
|
231
|
+
await stageDistributionFiles(
|
|
232
|
+
root,
|
|
233
|
+
staging,
|
|
234
|
+
(files as string[]).filter((entry) => !entry.startsWith('!')),
|
|
235
|
+
)
|
|
106
236
|
for (const field of packedManifestOmittedFields) delete manifest[field]
|
|
107
237
|
await writeFile(join(staging, 'package.json'), `${JSON.stringify(manifest, null, 2)}\n`)
|
|
108
238
|
await execOrThrow(
|
|
109
|
-
[
|
|
239
|
+
[
|
|
240
|
+
'bun',
|
|
241
|
+
'pm',
|
|
242
|
+
'pack',
|
|
243
|
+
'--ignore-scripts',
|
|
244
|
+
...(gzipLevel === undefined ? [] : ['--gzip-level', String(gzipLevel)]),
|
|
245
|
+
'--destination',
|
|
246
|
+
destination,
|
|
247
|
+
],
|
|
110
248
|
staging,
|
|
111
249
|
exec,
|
|
112
250
|
signal,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The read catalog identity, kept free of payload schemas so stores can name
|
|
2
|
+
* it without initializing the decoders. `./compatibility` re-exports it. */
|
|
3
|
+
import { buildEventPolicy, repositoryEventPolicy } from './policy'
|
|
4
|
+
|
|
5
|
+
/** Change this revision whenever projection semantics change without new types. */
|
|
6
|
+
// Revision 3 retains optional billing-account descriptors in session/attempt projections.
|
|
7
|
+
// Revision 4 retains the optional effective prompt in session projections.
|
|
8
|
+
// Revision 5 retains the optional preparation creation key.
|
|
9
|
+
// Revision 6 retains the optional role profile on build creation and session starts.
|
|
10
|
+
// Revision 7 retains the optional abort destination and hand-back report fields.
|
|
11
|
+
// Revision 8 retains the optional landed head on accepted attempt settlements.
|
|
12
|
+
// Revision 9 retains the optional stream and provider substitution on judge session starts.
|
|
13
|
+
// Revision 10 retains the optional hold reason.
|
|
14
|
+
// Revision 11 retains optional forge rate-limit snapshots on tick telemetry
|
|
15
|
+
// and the optional continued marker on forge degradation.
|
|
16
|
+
// Revision 12 retains the optional build priority and urgent scan demand.
|
|
17
|
+
export const READ_DECODER_REVISION = 12
|
|
18
|
+
export function catalogIdentity(
|
|
19
|
+
build: Record<string, string> = buildEventPolicy,
|
|
20
|
+
repository: Record<string, string> = repositoryEventPolicy,
|
|
21
|
+
): string {
|
|
22
|
+
const sorted = (catalog: Record<string, string>) =>
|
|
23
|
+
Object.entries(catalog).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
24
|
+
return new Bun.CryptoHasher('sha256')
|
|
25
|
+
.update(JSON.stringify([READ_DECODER_REVISION, sorted(build), sorted(repository)]))
|
|
26
|
+
.digest('hex')
|
|
27
|
+
}
|
|
28
|
+
export const READ_CATALOG_IDENTITY = catalogIdentity()
|
|
@@ -64,6 +64,7 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
64
64
|
'landing.native-applied': ['dispatcher', 'kernel'],
|
|
65
65
|
'target.distance': ['dispatcher'],
|
|
66
66
|
'pipeline.settled': ['dispatcher'],
|
|
67
|
+
'slot.admitted': ['dispatcher'],
|
|
67
68
|
'target.rewritten': ['dispatcher', 'kernel'],
|
|
68
69
|
'target.rewrite-cleared': ['dispatcher', 'kernel'],
|
|
69
70
|
'target.moved': ['dispatcher', 'kernel'],
|
|
@@ -270,15 +271,8 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
270
271
|
* wrong and what would be accepted, so the in-session correction loop is
|
|
271
272
|
* immediate and cheap.
|
|
272
273
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
message: string,
|
|
276
|
-
readonly issues?: unknown,
|
|
277
|
-
) {
|
|
278
|
-
super(message)
|
|
279
|
-
this.name = 'EventValidationError'
|
|
280
|
-
}
|
|
281
|
-
}
|
|
274
|
+
import { EventValidationError } from './validation-error'
|
|
275
|
+
export { EventValidationError }
|
|
282
276
|
|
|
283
277
|
/**
|
|
284
278
|
* The single validation gate. Every store adapter MUST pass writes through
|
|
@@ -4,12 +4,7 @@ import type { Actor } from './envelope'
|
|
|
4
4
|
import type { AbEvent } from './catalog'
|
|
5
5
|
import { eventPayloadSchemas } from './payloads'
|
|
6
6
|
import { repositoryEventPayloadSchemas, type RepositoryEvent } from './repository'
|
|
7
|
-
import {
|
|
8
|
-
buildEventPolicy,
|
|
9
|
-
repositoryEventPolicy,
|
|
10
|
-
compatibilityMetadataSchema,
|
|
11
|
-
type CompatibilityMetadata,
|
|
12
|
-
} from './policy'
|
|
7
|
+
import { compatibilityMetadataSchema, type CompatibilityMetadata } from './policy'
|
|
13
8
|
|
|
14
9
|
export interface StoredEvent {
|
|
15
10
|
build?: string
|
|
@@ -22,30 +17,7 @@ export interface StoredEvent {
|
|
|
22
17
|
compatibility?: CompatibilityMetadata
|
|
23
18
|
}
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
// Revision 3 retains optional billing-account descriptors in session/attempt projections.
|
|
27
|
-
// Revision 4 retains the optional effective prompt in session projections.
|
|
28
|
-
// Revision 5 retains the optional preparation creation key.
|
|
29
|
-
// Revision 6 retains the optional role profile on build creation and session starts.
|
|
30
|
-
// Revision 7 retains the optional abort destination and hand-back report fields.
|
|
31
|
-
// Revision 8 retains the optional landed head on accepted attempt settlements.
|
|
32
|
-
// Revision 9 retains the optional stream and provider substitution on judge session starts.
|
|
33
|
-
// Revision 10 retains the optional hold reason.
|
|
34
|
-
// Revision 11 retains optional forge rate-limit snapshots on tick telemetry
|
|
35
|
-
// and the optional continued marker on forge degradation.
|
|
36
|
-
// Revision 12 retains the optional build priority and urgent scan demand.
|
|
37
|
-
export const READ_DECODER_REVISION = 12
|
|
38
|
-
export function catalogIdentity(
|
|
39
|
-
build: Record<string, string> = buildEventPolicy,
|
|
40
|
-
repository: Record<string, string> = repositoryEventPolicy,
|
|
41
|
-
): string {
|
|
42
|
-
const sorted = (catalog: Record<string, string>) =>
|
|
43
|
-
Object.entries(catalog).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
44
|
-
return new Bun.CryptoHasher('sha256')
|
|
45
|
-
.update(JSON.stringify([READ_DECODER_REVISION, sorted(build), sorted(repository)]))
|
|
46
|
-
.digest('hex')
|
|
47
|
-
}
|
|
48
|
-
export const READ_CATALOG_IDENTITY = catalogIdentity()
|
|
20
|
+
export { READ_DECODER_REVISION, catalogIdentity, READ_CATALOG_IDENTITY } from './catalog-identity'
|
|
49
21
|
|
|
50
22
|
/** Remove only keys reported as unknown by the original schema, then run that
|
|
51
23
|
* schema again. Its required fields, enums and refinements remain authoritative. */
|
|
@@ -2087,6 +2087,17 @@ export const eventPayloadSchemas = {
|
|
|
2087
2087
|
* (max of the verify cycle start and finalize completion seqs). Capacity
|
|
2088
2088
|
* evidence only; no pipeline decision reads it. */
|
|
2089
2089
|
'pipeline.settled': z.strictObject({ cycle: z.number().int().positive() }),
|
|
2090
|
+
/** The dispatcher's slot gate admitted a build that held no slot
|
|
2091
|
+
* (SPEC §12 "What holds a slot"), recorded before any lease claim,
|
|
2092
|
+
* provisioning or launch. `request` names the slot request admitted;
|
|
2093
|
+
* omitted for an admission without one. `need` names the node runner need
|
|
2094
|
+
* admitted (a verification cycle, a measurement, a proposal or an active
|
|
2095
|
+
* restack); a node holds its slot while that need remains. Omitted for work
|
|
2096
|
+
* builds. Capacity evidence only; no pipeline decision reads it. */
|
|
2097
|
+
'slot.admitted': z.strictObject({
|
|
2098
|
+
request: z.enum(['verification', 'reconcile', 'resume', 'reopen', 'propose']).optional(),
|
|
2099
|
+
need: z.string().min(1).optional(),
|
|
2100
|
+
}),
|
|
2090
2101
|
'target.rewritten': z.strictObject({
|
|
2091
2102
|
branch: z.string().min(1),
|
|
2092
2103
|
previousSha: gitOid,
|
|
@@ -39,6 +39,9 @@ export const buildEventPolicy = {
|
|
|
39
39
|
'landing.native-applied': 'decisive',
|
|
40
40
|
'target.distance': 'advisory',
|
|
41
41
|
'pipeline.settled': 'advisory',
|
|
42
|
+
// A reader that ignores it only counts capacity by its own older rules; no
|
|
43
|
+
// pipeline decision reads it.
|
|
44
|
+
'slot.admitted': 'advisory',
|
|
42
45
|
'target.rewritten': 'decisive',
|
|
43
46
|
'target.rewrite-cleared': 'decisive',
|
|
44
47
|
'target.moved': 'decisive',
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
type Actor,
|
|
32
32
|
type ActorKind,
|
|
33
33
|
} from './envelope'
|
|
34
|
-
import { EventValidationError } from './
|
|
34
|
+
import { EventValidationError } from './validation-error'
|
|
35
35
|
import { handbackCauseSchema, handbackReport, providerAttemptSchema } from './payloads'
|
|
36
36
|
|
|
37
37
|
const round = z.number().int().positive()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** A rejected event write. Kept apart from the build-event catalog so other
|
|
2
|
+
* event vocabularies can throw it without initializing that catalog;
|
|
3
|
+
* `./catalog` re-exports it. */
|
|
4
|
+
export class EventValidationError extends Error {
|
|
5
|
+
constructor(
|
|
6
|
+
message: string,
|
|
7
|
+
readonly issues?: unknown,
|
|
8
|
+
) {
|
|
9
|
+
super(message)
|
|
10
|
+
this.name = 'EventValidationError'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -3500,6 +3500,9 @@
|
|
|
3500
3500
|
"$.build.setupFailures[].output: string",
|
|
3501
3501
|
"$.build.setupFailures[].seq: number",
|
|
3502
3502
|
"$.build.setupFailures[]: object",
|
|
3503
|
+
"$.build.slotAdmittedSeq: number",
|
|
3504
|
+
"$.build.slotAdmittedSeq: undefined",
|
|
3505
|
+
"$.build.slotReleasedSeq: number",
|
|
3503
3506
|
"$.build.specRev: number",
|
|
3504
3507
|
"$.build.specRev: undefined",
|
|
3505
3508
|
"$.build.suspendedSessions: array",
|
|
@@ -5045,6 +5048,9 @@
|
|
|
5045
5048
|
"$.build.setupFailures[].output: string",
|
|
5046
5049
|
"$.build.setupFailures[].seq: number",
|
|
5047
5050
|
"$.build.setupFailures[]: object",
|
|
5051
|
+
"$.build.slotAdmittedSeq: number",
|
|
5052
|
+
"$.build.slotAdmittedSeq: undefined",
|
|
5053
|
+
"$.build.slotReleasedSeq: number",
|
|
5048
5054
|
"$.build.specRev: number",
|
|
5049
5055
|
"$.build.specRev: undefined",
|
|
5050
5056
|
"$.build.suspendedSessions: array",
|
|
@@ -8158,6 +8164,9 @@
|
|
|
8158
8164
|
"$.setupFailures[].output: string",
|
|
8159
8165
|
"$.setupFailures[].seq: number",
|
|
8160
8166
|
"$.setupFailures[]: object",
|
|
8167
|
+
"$.slotAdmittedSeq: number",
|
|
8168
|
+
"$.slotAdmittedSeq: undefined",
|
|
8169
|
+
"$.slotReleasedSeq: number",
|
|
8161
8170
|
"$.specRev: number",
|
|
8162
8171
|
"$.specRev: undefined",
|
|
8163
8172
|
"$.suspendedSessions: array",
|