@defrex/autobuild 1.2.0 → 1.4.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 +416 -36
- package/docs/accounts.md +50 -1
- package/docs/answering-blocked-builds.md +4 -1
- package/docs/architecture.md +298 -17
- package/docs/build-store.md +18 -0
- package/docs/builds.md +7 -1
- package/docs/cli.md +1 -1
- package/docs/configuration-overview.md +6 -0
- package/docs/configuration.md +44 -19
- package/docs/dispatcher-hosting.md +42 -0
- package/docs/dispatcher.md +41 -0
- package/docs/forges.md +5 -0
- package/docs/integration-tree.md +24 -5
- package/docs/operating.md +11 -3
- package/docs/operator-api.md +81 -10
- package/docs/operator-surfaces.md +29 -0
- package/docs/plugin-authoring.md +51 -2
- package/docs/remote-store-protocol.md +321 -46
- package/docs/remote-ticket-protocol.md +12 -10
- package/docs/restacking.md +105 -3
- package/docs/setup.md +37 -8
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +41 -5
- package/docs/ticket-dependencies.md +8 -0
- package/docs/troubleshooting.md +9 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/availability.ts +96 -0
- package/packages/core/src/accounts/local-owner.ts +49 -2
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary.ts +17 -1
- package/packages/core/src/cli/context.ts +62 -0
- package/packages/core/src/cli/dashboard/model.ts +12 -3
- package/packages/core/src/cli/dashboard/poll.ts +65 -8
- package/packages/core/src/cli/dashboard/refresh.ts +2 -0
- package/packages/core/src/cli/dashboard/render.ts +46 -5
- package/packages/core/src/cli/dispatch-args.ts +27 -3
- package/packages/core/src/cli/dispatch-frontend.ts +179 -52
- package/packages/core/src/cli/dispatch-mode.ts +94 -0
- package/packages/core/src/cli/dispatch-preflight.ts +43 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +150 -33
- package/packages/core/src/cli/dispatch.ts +209 -36
- package/packages/core/src/cli/dispatcher-liveness.ts +6 -1
- package/packages/core/src/cli/forge-clear.ts +30 -0
- package/packages/core/src/cli/harvest.ts +2 -1
- package/packages/core/src/cli/help.ts +17 -3
- package/packages/core/src/cli/historical-build-state.ts +6 -0
- package/packages/core/src/cli/main.ts +43 -2
- package/packages/core/src/cli/publication-settlement.ts +17 -0
- package/packages/core/src/cli/remote-poll.ts +11 -1
- package/packages/core/src/cli/repository-status.ts +11 -0
- package/packages/core/src/cli/status.ts +7 -1
- package/packages/core/src/cli/wait.ts +9 -2
- package/packages/core/src/cli/watch.ts +47 -16
- package/packages/core/src/config/roles.ts +16 -1
- package/packages/core/src/events/catalog.ts +8 -0
- package/packages/core/src/events/forge-degradation-policy.ts +11 -0
- package/packages/core/src/events/payloads.ts +95 -2
- package/packages/core/src/events/policy.ts +19 -0
- package/packages/core/src/events/repository.ts +108 -2
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +464 -0
- package/packages/core/src/kernel/change-presence.ts +74 -8
- package/packages/core/src/kernel/dispatch-placement.ts +30 -0
- package/packages/core/src/kernel/engine.ts +27 -12
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +17 -1
- package/packages/core/src/kernel/generators/node-restack-log.ts +14 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +24 -2
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-landing.ts +27 -10
- package/packages/core/src/kernel/node-polling.ts +40 -7
- package/packages/core/src/kernel/node-restack-demand.ts +75 -0
- package/packages/core/src/kernel/node-restack-state.ts +20 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +47 -1
- package/packages/core/src/kernel/read-facts.ts +120 -9
- package/packages/core/src/kernel/reconcile-head.ts +34 -11
- package/packages/core/src/kernel/reconcile-restack.ts +106 -72
- package/packages/core/src/kernel/reducer-registry.ts +6 -0
- package/packages/core/src/kernel/reducer.ts +20 -2
- package/packages/core/src/kernel/replay-retention.ts +176 -0
- package/packages/core/src/kernel/target-lineage.ts +65 -0
- package/packages/core/src/kernel/target-observation.ts +117 -0
- package/packages/core/src/kernel/ticket-preparation.ts +66 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +20 -0
- package/packages/core/src/operator/index.ts +2 -0
- package/packages/core/src/operator/registry.ts +25 -13
- package/packages/core/src/operator/tickets.ts +8 -2
- package/packages/core/src/plugin-sdk/index.ts +1 -0
- package/packages/core/src/ports/forge/fake.ts +22 -0
- package/packages/core/src/ports/forge/git-rewrite.ts +49 -12
- package/packages/core/src/ports/forge/github.ts +42 -10
- package/packages/core/src/ports/forge/local-git.ts +16 -1
- package/packages/core/src/ports/runner/account-env.ts +60 -9
- package/packages/core/src/ports/runner/claude.ts +49 -45
- package/packages/core/src/ports/types.ts +58 -4
- package/packages/core/src/ports/workspace/account-policy.ts +2 -1
- package/packages/core/src/ports/workspace/commit-preservation.ts +175 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/fake.ts +4 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +22 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +304 -56
- package/packages/core/src/processes/build-runner.ts +240 -111
- package/packages/core/src/processes/dispatcher-selectors.ts +3 -2
- package/packages/core/src/processes/dispatcher.ts +732 -201
- package/packages/core/src/processes/execution-no-progress.ts +8 -0
- package/packages/core/src/processes/harvest-runner.ts +6 -7
- package/packages/core/src/processes/harvest.ts +11 -16
- package/packages/core/src/processes/publication-state.ts +2 -1
- package/packages/core/src/processes/repo-view.ts +25 -0
- package/packages/core/src/processes/workspace-preservation.ts +164 -0
- package/packages/core/src/scenarios/harness.ts +7 -0
- package/packages/core/src/store/adapter.ts +9 -0
- package/packages/core/src/store/artifact-meta.ts +7 -0
- package/packages/core/src/store/build-scope.ts +28 -0
- package/packages/core/src/store/contract.ts +182 -0
- package/packages/core/src/store/event-reads.ts +156 -0
- package/packages/core/src/store/local/schema.ts +11 -0
- package/packages/core/src/store/local/store.ts +117 -2
- package/packages/core/src/store/memory.ts +241 -0
- package/packages/core/src/store/phase-session.ts +47 -0
- package/packages/core/src/store/reduced-reads.ts +8 -0
- package/packages/core/src/store/reducer-value-shapes.json +10546 -8877
- package/packages/core/src/store/reducer-value-validation.ts +109 -6
- package/packages/core/src/store/reducer-values.ts +62 -2
- package/packages/core/src/store/remote/client.ts +208 -23
- package/packages/core/src/store/remote/compatibility.ts +195 -25
- package/packages/core/src/store/remote/errors.ts +16 -0
- package/packages/core/src/store/remote/index.ts +17 -0
- package/packages/core/src/store/remote/protocol.ts +30 -1
- package/packages/core/src/store/remote/released-clients.json +37 -0
- package/packages/core/src/store/remote/released-clients.ts +88 -0
- package/packages/core/src/store/remote/released-reducer-values/1.2.0.json +8129 -0
- package/packages/core/src/store/remote/released-reducer-values/1.3.0.json +25093 -0
- package/packages/core/src/store/remote/released-reducer-values/1.4.0.json +26128 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +13 -0
- package/packages/core/src/store/remote/version.ts +8 -1
- package/packages/core/src/store/repo-state-events.ts +6 -3
- package/packages/core/src/store/scan-cadence.ts +15 -0
- package/packages/core/src/store/session-handle.ts +18 -0
- package/packages/core/src/store/snapshots.ts +16 -3
- package/packages/core/src/store/types.ts +29 -6
- package/packages/core/src/testing/dispatch-read-budget.ts +457 -7
- package/packages/core/src/testing/index.ts +6 -1
- package/packages/core/src/testing/reduced-read-budget.ts +1240 -9
- package/skills/guide/SKILL.md +220 -22
- package/skills/guide/references/accounts.md +50 -1
- package/skills/guide/references/integration-tree.md +24 -5
- package/skills/guide/references/operator-api.md +81 -10
- package/skills/guide/references/plugin-authoring.md +51 -2
- package/skills/guide/references/remote-store-protocol.md +321 -46
- package/skills/guide/references/remote-ticket-protocol.md +12 -10
- package/skills/guide/references/restacking.md +105 -3
- package/skills/guide/references/setup.md +37 -8
- package/skills/guide/references/spec-standard.md +41 -5
- package/skills/guide/references/ticket-dependencies.md +8 -0
- package/skills/implement/SKILL.md +12 -3
- package/skills/operate/SKILL.md +85 -12
- package/skills/plan/SKILL.md +27 -4
- package/skills/plan-review/SKILL.md +22 -2
- package/skills/reconcile/SKILL.md +16 -1
- package/skills/spec/SKILL.md +7 -4
- package/skills/tickets/SKILL.md +7 -3
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import semver from 'semver'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import { AUTOBUILD_VERSION, REMOTE_STORE_PROTOCOL_VERSION } from './version'
|
|
4
|
+
import { projectReducerValue, type ReducerValueCatalog } from '../reducer-value-validation'
|
|
5
|
+
import {
|
|
6
|
+
RELEASED_CLIENTS,
|
|
7
|
+
releaseLine,
|
|
8
|
+
supportedPublishedLines,
|
|
9
|
+
CLIENT_POLICY_FLOOR,
|
|
10
|
+
CLIENT_SUPPORT_POLICY,
|
|
11
|
+
type ReleasedClient,
|
|
12
|
+
} from './released-clients'
|
|
13
|
+
import { RELEASED_REDUCER_VALUES } from './released-reducer-values'
|
|
4
14
|
|
|
5
15
|
/** Stable releases only: prefixes, whitespace, prereleases and build suffixes are not identities. */
|
|
6
16
|
export function stableVersion(value: unknown): semver.SemVer | undefined {
|
|
@@ -32,12 +42,21 @@ export const supportedClientRangeSchema = z
|
|
|
32
42
|
.refine((range) => semver.lt(range.minVersion, range.maxVersionExclusive))
|
|
33
43
|
export type SupportedClientRange = z.infer<typeof supportedClientRangeSchema>
|
|
34
44
|
|
|
35
|
-
/**
|
|
36
|
-
export function supportedClientRange(
|
|
45
|
+
/** Capture time per decision, so retirement takes effect without a redeploy. */
|
|
46
|
+
export function supportedClientRange(
|
|
47
|
+
serviceVersion = AUTOBUILD_VERSION,
|
|
48
|
+
now = Date.now(),
|
|
49
|
+
releases: readonly ReleasedClient[] = RELEASED_CLIENTS,
|
|
50
|
+
): SupportedClientRange {
|
|
37
51
|
const version = releaseVersion(serviceVersion)
|
|
38
52
|
if (!version) throw new Error('service must have a canonical release version')
|
|
53
|
+
const lines = supportedPublishedLines(serviceVersion, now, releases)
|
|
39
54
|
return {
|
|
40
|
-
minVersion:
|
|
55
|
+
minVersion:
|
|
56
|
+
lines[0] ??
|
|
57
|
+
(semver.lt(releaseLine(serviceVersion), CLIENT_POLICY_FLOOR)
|
|
58
|
+
? CLIENT_POLICY_FLOOR
|
|
59
|
+
: releaseLine(serviceVersion)),
|
|
41
60
|
maxVersionExclusive: `${version.major}.${version.minor + 1}.0`,
|
|
42
61
|
}
|
|
43
62
|
}
|
|
@@ -76,39 +95,61 @@ export function compatibilityAdvice(
|
|
|
76
95
|
|
|
77
96
|
/** Retain these wire identities and handlers until their lines leave the window.
|
|
78
97
|
* Historical lines require explicit entries; the service's own line uses its
|
|
79
|
-
*
|
|
80
|
-
export const RELEASE_LINE_PROTOCOLS: Readonly<Record<string, string>> =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'0.9': '3',
|
|
86
|
-
'0.10': '3',
|
|
87
|
-
'0.11': '3',
|
|
88
|
-
'0.12': '3',
|
|
89
|
-
// v0.13.0 shipped protocol 3. Protocol 4 requires the next minor line.
|
|
90
|
-
'0.13': '3',
|
|
91
|
-
// v0.14.0 introduced protocol 4; retain it when this line becomes historical.
|
|
92
|
-
'0.14': '4',
|
|
93
|
-
}
|
|
98
|
+
* runtime and published protocol identities. Unknown historical protocols fail closed. */
|
|
99
|
+
export const RELEASE_LINE_PROTOCOLS: Readonly<Record<string, string>> = Object.fromEntries(
|
|
100
|
+
RELEASED_CLIENTS.filter(
|
|
101
|
+
(entry) => entry.protocol && semver.gte(releaseLine(entry.version), CLIENT_POLICY_FLOOR),
|
|
102
|
+
).map((entry) => [releaseLine(entry.version).split('.').slice(0, 2).join('.'), entry.protocol!]),
|
|
103
|
+
)
|
|
94
104
|
|
|
95
105
|
export function clientIdentityError(
|
|
96
106
|
client: string | null,
|
|
97
107
|
protocol: string | null,
|
|
98
108
|
serviceVersion = AUTOBUILD_VERSION,
|
|
99
109
|
serviceProtocol = REMOTE_STORE_PROTOCOL_VERSION,
|
|
110
|
+
now = Date.now(),
|
|
111
|
+
releases: readonly ReleasedClient[] = RELEASED_CLIENTS,
|
|
100
112
|
): string | undefined {
|
|
101
|
-
const range = supportedClientRange(serviceVersion)
|
|
113
|
+
const range = supportedClientRange(serviceVersion, now, releases)
|
|
102
114
|
const service = releaseVersion(serviceVersion)!
|
|
103
115
|
const advice = compatibilityAdvice(client, serviceVersion, range)
|
|
104
116
|
const parsed = releaseVersion(client)
|
|
105
|
-
const
|
|
117
|
+
const publishedProtocol =
|
|
118
|
+
parsed &&
|
|
119
|
+
releases.find((entry) => releaseLine(entry.version) === releaseLine(parsed.version))?.protocol
|
|
120
|
+
const sameLine = parsed && parsed.major === service.major && parsed.minor === service.minor
|
|
121
|
+
const admittedProtocol =
|
|
122
|
+
protocol !== null &&
|
|
123
|
+
(protocol === publishedProtocol || (sameLine && protocol === serviceProtocol))
|
|
124
|
+
if (
|
|
106
125
|
parsed &&
|
|
107
|
-
(parsed.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
126
|
+
semver.gte(releaseLine(parsed.version), CLIENT_POLICY_FLOOR) &&
|
|
127
|
+
!advice &&
|
|
128
|
+
admittedProtocol
|
|
129
|
+
)
|
|
130
|
+
return undefined
|
|
131
|
+
return `remote store version mismatch: client Autobuild ${client ?? '(missing)'} protocol ${protocol ?? '(missing)'}; server Autobuild ${serviceVersion} protocol ${serviceProtocol}; ${advice ?? `supported clients ${formatClientRange(range)}; unsupported protocol identity`}; ${CLIENT_SUPPORT_POLICY}`
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Public health never echoes an identity that admission would reject. */
|
|
135
|
+
export function healthIdentity(
|
|
136
|
+
client: string | null,
|
|
137
|
+
protocol: string | null,
|
|
138
|
+
serviceVersion = AUTOBUILD_VERSION,
|
|
139
|
+
serviceProtocol = REMOTE_STORE_PROTOCOL_VERSION,
|
|
140
|
+
) {
|
|
141
|
+
const sameLine = releaseVersion(client) && releaseLine(client!) === releaseLine(serviceVersion)
|
|
142
|
+
const published = RELEASED_CLIENTS.find(
|
|
143
|
+
(entry) => releaseLine(entry.version) === releaseLine(serviceVersion),
|
|
144
|
+
)?.protocol
|
|
145
|
+
return {
|
|
146
|
+
autobuildVersion: serviceVersion,
|
|
147
|
+
protocolVersion:
|
|
148
|
+
sameLine && !clientIdentityError(client, protocol, serviceVersion, serviceProtocol)
|
|
149
|
+
? protocol!
|
|
150
|
+
: (published ?? serviceProtocol),
|
|
151
|
+
supportedClientRange: supportedClientRange(serviceVersion),
|
|
152
|
+
}
|
|
112
153
|
}
|
|
113
154
|
|
|
114
155
|
/** A successful server answer cannot be represented by this client's reducer. */
|
|
@@ -126,3 +167,132 @@ export class ReducerValueIncompatibilityError extends Error {
|
|
|
126
167
|
)
|
|
127
168
|
}
|
|
128
169
|
}
|
|
170
|
+
|
|
171
|
+
/** Answer a published client as its release can read: project the canonical
|
|
172
|
+
* value onto the release's frozen shape and stamp the version it expects. A value
|
|
173
|
+
* the release cannot represent is returned unchanged, so the client raises its
|
|
174
|
+
* typed incompatibility error rather than misreading it. */
|
|
175
|
+
export function reducerValueForClient<T extends { version: number; value: unknown }>(
|
|
176
|
+
client: {
|
|
177
|
+
version: string | null
|
|
178
|
+
projects: boolean
|
|
179
|
+
catalogIdentity?: string | null
|
|
180
|
+
},
|
|
181
|
+
reducer: string,
|
|
182
|
+
answer: T,
|
|
183
|
+
releases = RELEASED_CLIENTS,
|
|
184
|
+
): T {
|
|
185
|
+
// Source clients retain the package version between releases. Their catalog
|
|
186
|
+
// can require fields absent from that version's published contract.
|
|
187
|
+
if (
|
|
188
|
+
client.projects &&
|
|
189
|
+
client.catalogIdentity &&
|
|
190
|
+
!releases.some((entry) => entry.catalogIdentity === client.catalogIdentity)
|
|
191
|
+
)
|
|
192
|
+
return answer
|
|
193
|
+
const { version: release } = client
|
|
194
|
+
if (release === null) return answer
|
|
195
|
+
const published = releases.find((entry) =>
|
|
196
|
+
client.catalogIdentity
|
|
197
|
+
? entry.catalogIdentity === client.catalogIdentity
|
|
198
|
+
: entry.version === release,
|
|
199
|
+
)
|
|
200
|
+
if (!published?.contract) return answer
|
|
201
|
+
const catalog = RELEASED_REDUCER_VALUES[published.contract]
|
|
202
|
+
if (!catalog) return answer
|
|
203
|
+
if (!Object.hasOwn(catalog.versions, reducer)) return answer
|
|
204
|
+
const projected = projectReleasedValue(reducer, answer.value, catalog)
|
|
205
|
+
if ('path' in projected) return answer
|
|
206
|
+
return {
|
|
207
|
+
...answer,
|
|
208
|
+
version: catalog.versions[reducer]!,
|
|
209
|
+
value: (projected as { value: unknown }).value,
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Only the optional display event may be omitted when a release predates its
|
|
214
|
+
* discriminant. Progress, sequence and required compatibility facts stay intact.
|
|
215
|
+
* The catalog-directed walk covers nested build state without reading history. */
|
|
216
|
+
function projectReleasedValue(name: string, value: unknown, catalog: ReducerValueCatalog) {
|
|
217
|
+
const root = catalog.roots[name]
|
|
218
|
+
if (!root) return { path: '$', expected: 'known reducer' }
|
|
219
|
+
function adapt(id: string, input: unknown): unknown {
|
|
220
|
+
const shape = catalog.schemas[id]!
|
|
221
|
+
if (shape.kind === 'union') {
|
|
222
|
+
for (const member of shape.items as string[]) {
|
|
223
|
+
const candidate = adapt(member, input)
|
|
224
|
+
const result = projectReducerValue('candidate', candidate, {
|
|
225
|
+
...catalog,
|
|
226
|
+
roots: { candidate: { value: member } },
|
|
227
|
+
})
|
|
228
|
+
if (!('path' in result)) return candidate
|
|
229
|
+
}
|
|
230
|
+
return input
|
|
231
|
+
}
|
|
232
|
+
if (shape.kind === 'array' && Array.isArray(input))
|
|
233
|
+
return input.map((item) => adapt(shape.items as string, item))
|
|
234
|
+
if (shape.kind !== 'object' || !input || typeof input !== 'object' || Array.isArray(input))
|
|
235
|
+
return input
|
|
236
|
+
const out = { ...input } as Record<string, unknown>
|
|
237
|
+
for (const [key, prop] of Object.entries(shape.props ?? {})) {
|
|
238
|
+
if (!(key in out)) continue
|
|
239
|
+
if (key === 'lastEvent' && prop.optional) {
|
|
240
|
+
const result = projectReducerValue('event', out[key], {
|
|
241
|
+
...catalog,
|
|
242
|
+
roots: { event: { value: prop.type } },
|
|
243
|
+
})
|
|
244
|
+
const event = out[key]
|
|
245
|
+
function knowsType(id: string): boolean {
|
|
246
|
+
const variant = catalog.schemas[id]!
|
|
247
|
+
if (variant.kind === 'union') return (variant.items as string[]).some(knowsType)
|
|
248
|
+
const type = variant.props?.type
|
|
249
|
+
if (!type || !event || typeof event !== 'object' || !('type' in event)) return false
|
|
250
|
+
return !(
|
|
251
|
+
'path' in
|
|
252
|
+
projectReducerValue('type', event.type, {
|
|
253
|
+
...catalog,
|
|
254
|
+
roots: { type: { value: type.type } },
|
|
255
|
+
})
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
if (
|
|
259
|
+
'path' in result &&
|
|
260
|
+
event &&
|
|
261
|
+
typeof event === 'object' &&
|
|
262
|
+
'type' in event &&
|
|
263
|
+
typeof event.type === 'string' &&
|
|
264
|
+
!knowsType(prop.type)
|
|
265
|
+
) {
|
|
266
|
+
delete out[key]
|
|
267
|
+
continue
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// seenTypes is the set of event types this reader can act on, rather
|
|
271
|
+
// than an event history. Retain its known members; compatibility facts
|
|
272
|
+
// and sequence/progress remain the server's canonical answer.
|
|
273
|
+
if (key === 'seenTypes' && Array.isArray(out[key])) {
|
|
274
|
+
const array = catalog.schemas[prop.type]!
|
|
275
|
+
if (array.kind === 'array') {
|
|
276
|
+
out[key] = (out[key] as unknown[]).filter(
|
|
277
|
+
(type) =>
|
|
278
|
+
typeof type !== 'string' ||
|
|
279
|
+
!(
|
|
280
|
+
'path' in
|
|
281
|
+
projectReducerValue('type', type, {
|
|
282
|
+
...catalog,
|
|
283
|
+
roots: { type: { value: array.items as string } },
|
|
284
|
+
})
|
|
285
|
+
),
|
|
286
|
+
)
|
|
287
|
+
continue
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
out[key] = adapt(prop.type, out[key])
|
|
291
|
+
}
|
|
292
|
+
if (shape.index)
|
|
293
|
+
for (const key of Object.keys(out))
|
|
294
|
+
if (!Object.hasOwn(shape.props ?? {}, key)) out[key] = adapt(shape.index, out[key])
|
|
295
|
+
return out
|
|
296
|
+
}
|
|
297
|
+
return projectReducerValue(name, adapt(root.value, value), catalog)
|
|
298
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A permanent rejection of an outgoing store write's request size. */
|
|
2
|
+
export class StoreWriteTooLargeError extends Error {
|
|
3
|
+
override readonly name = 'StoreWriteTooLargeError'
|
|
4
|
+
|
|
5
|
+
constructor(
|
|
6
|
+
readonly method: string,
|
|
7
|
+
readonly route: string,
|
|
8
|
+
readonly requestBytes: number,
|
|
9
|
+
serverMessage?: string,
|
|
10
|
+
) {
|
|
11
|
+
super(
|
|
12
|
+
`oversized store write: ${method} ${route} (${requestBytes} request bytes)` +
|
|
13
|
+
(serverMessage === undefined ? '' : `: ${serverMessage}`),
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -14,6 +14,7 @@ export type {
|
|
|
14
14
|
} from './token'
|
|
15
15
|
export {
|
|
16
16
|
CATALOG_IDENTITY_HEADER,
|
|
17
|
+
REDUCER_VALUE_PROJECTION_HEADER,
|
|
17
18
|
AUTOBUILD_VERSION,
|
|
18
19
|
AUTOBUILD_VERSION_HEADER,
|
|
19
20
|
REMOTE_STORE_PROTOCOL_VERSION,
|
|
@@ -56,3 +57,19 @@ export type { BuildDelegationFacts, HarvestDelegationFacts } from '../../kernel/
|
|
|
56
57
|
export { delegationFactKey } from '../../kernel/service-facts'
|
|
57
58
|
|
|
58
59
|
export { assertPublicSnapshotReducer } from '../snapshots'
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
validateForgeDegradation,
|
|
63
|
+
MAX_FORGE_DEGRADATION_MS,
|
|
64
|
+
} from '../../events/forge-degradation-policy'
|
|
65
|
+
|
|
66
|
+
export * from './released-clients'
|
|
67
|
+
|
|
68
|
+
export { StoreWriteTooLargeError } from './errors'
|
|
69
|
+
export { dispatchPlacementSchema, dispatchPlacementReducer } from '../../kernel/dispatch-placement'
|
|
70
|
+
export type { DispatchPlacement } from '../../kernel/dispatch-placement'
|
|
71
|
+
export { dispatchPlacementFactSchema } from '../../events/repository'
|
|
72
|
+
export type { DispatchPlacementFact } from '../../events/repository'
|
|
73
|
+
|
|
74
|
+
export { readDispatchPlacement } from '../reduced-reads'
|
|
75
|
+
export * from '../event-reads'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { scanCadenceSchema, scanCadenceWriteSchema } from '../scan-cadence'
|
|
1
2
|
import { operatorIdentitySchema, operatorPresenceSchema } from '../operator-presence'
|
|
2
3
|
export const operatorPresenceBodySchema = operatorIdentitySchema
|
|
3
4
|
export const operatorPresenceWireSchema = operatorPresenceSchema
|
|
@@ -39,12 +40,31 @@ import type { ArtifactMeta, RepositoryArtifactMeta, SessionArtifactMeta } from '
|
|
|
39
40
|
|
|
40
41
|
// ── Errors (D6: errors as feedback over the wire) ────────────────────────────
|
|
41
42
|
|
|
42
|
-
export const errorKindSchema = z.enum([
|
|
43
|
+
export const errorKindSchema = z.enum([
|
|
44
|
+
'validation',
|
|
45
|
+
'not-found',
|
|
46
|
+
'auth',
|
|
47
|
+
'conflict',
|
|
48
|
+
'internal',
|
|
49
|
+
'unsupported-operation',
|
|
50
|
+
'cursor-too-old',
|
|
51
|
+
'checkpoint-integrity',
|
|
52
|
+
'retired-seed-generation',
|
|
53
|
+
])
|
|
43
54
|
export type ErrorKind = z.infer<typeof errorKindSchema>
|
|
44
55
|
|
|
45
56
|
export const errorBodySchema = z.object({
|
|
46
57
|
error: z.string(),
|
|
47
58
|
kind: errorKindSchema,
|
|
59
|
+
scope: z
|
|
60
|
+
.union([
|
|
61
|
+
z.object({ kind: z.literal('build'), slug: z.string() }),
|
|
62
|
+
z.object({ kind: z.literal('repo'), repo: z.string() }),
|
|
63
|
+
])
|
|
64
|
+
.optional(),
|
|
65
|
+
requestedCursor: z.number().int().nonnegative().safe().optional(),
|
|
66
|
+
head: z.number().int().nonnegative().safe().optional(),
|
|
67
|
+
oldestCursor: z.number().int().nonnegative().safe().optional(),
|
|
48
68
|
})
|
|
49
69
|
export type ErrorBody = z.infer<typeof errorBodySchema>
|
|
50
70
|
|
|
@@ -525,3 +545,12 @@ export const finishRepoTickResponseSchema = z
|
|
|
525
545
|
events: z.array(repositoryEventEnvelopeWireSchema),
|
|
526
546
|
})
|
|
527
547
|
.nullable()
|
|
548
|
+
|
|
549
|
+
export const nodeRewriteWireSchema = eventPayloadSchemas['node.rewritten'].nullable()
|
|
550
|
+
|
|
551
|
+
/** Optional and independently negotiated; no change to released value contracts. */
|
|
552
|
+
export const DISPATCH_PLACEMENT_CAPABILITY = 'dispatch-placement-v1'
|
|
553
|
+
export const placementCapabilitiesSchema = z.object({
|
|
554
|
+
capabilities: z.array(z.string()).optional(),
|
|
555
|
+
})
|
|
556
|
+
export { dispatchPlacementSchema } from '../../kernel/dispatch-placement'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"publishedAt": "2026-10-28T20:17:06.230Z",
|
|
5
|
+
"protocol": "6",
|
|
6
|
+
"contract": "1.2.0.json",
|
|
7
|
+
"projects": false,
|
|
8
|
+
"provenance": {
|
|
9
|
+
"registry": "https://registry.npmjs.org/@defrex%2fautobuild",
|
|
10
|
+
"tarball": "https://registry.npmjs.org/@defrex/autobuild/-/autobuild-1.2.0.tgz",
|
|
11
|
+
"integrity": "sha512-7Cy/PpVFdAo22+EeMBIjoq6sTKRZsVoU8adou4GTlWg5RKdFBJ3sf93QoGkTXXrsrtfw0CnuX7x0FXnqBfowGw=="
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"version": "1.3.0",
|
|
16
|
+
"publishedAt": "2026-10-29T15:44:57.934Z",
|
|
17
|
+
"protocol": "6",
|
|
18
|
+
"contract": "1.3.0.json",
|
|
19
|
+
"projects": true,
|
|
20
|
+
"provenance": {
|
|
21
|
+
"registry": "https://registry.npmjs.org/@defrex%2fautobuild",
|
|
22
|
+
"tarball": "https://registry.npmjs.org/@defrex/autobuild/-/autobuild-1.3.0.tgz",
|
|
23
|
+
"integrity": "sha512-TXc39kNb8EgM80f3+MhxzBVzFjMLhgYtWBGL40oJqJSekyHZiiuZhLOtQK8rQoWTvZB1k6XcwqBEOgl2JJgy3g=="
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"version": "1.4.0",
|
|
28
|
+
"publishedAt": "2026-11-02T16:33:21.961Z",
|
|
29
|
+
"protocol": "7",
|
|
30
|
+
"contract": "1.4.0.json",
|
|
31
|
+
"projects": true,
|
|
32
|
+
"catalogIdentity": "f9289449e0df64c1de972d7456cd4d50f179f06b36a20bed05ba91411573b194",
|
|
33
|
+
"provenance": {
|
|
34
|
+
"tag": "v1.4.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import semver from 'semver'
|
|
2
|
+
import publications from './released-clients.json'
|
|
3
|
+
|
|
4
|
+
export interface ReleasedClient {
|
|
5
|
+
version: string
|
|
6
|
+
publishedAt: string
|
|
7
|
+
protocol?: string
|
|
8
|
+
contract?: string
|
|
9
|
+
/** Header sent by the published client; absent for pre-header releases. */
|
|
10
|
+
catalogIdentity?: string
|
|
11
|
+
projects?: boolean
|
|
12
|
+
provenance: {
|
|
13
|
+
registry?: string
|
|
14
|
+
tarball?: string
|
|
15
|
+
integrity?: string
|
|
16
|
+
commit?: string
|
|
17
|
+
tag?: string
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export const RELEASED_CLIENTS: readonly ReleasedClient[] = publications
|
|
21
|
+
export const CLIENT_POLICY_FLOOR = '1.2.0'
|
|
22
|
+
export const CLIENT_SUPPORT_DAYS = 90
|
|
23
|
+
export const CLIENT_SUPPORT_POLICY =
|
|
24
|
+
'policy floor 1.2; support ends only after two newer minor lines and 90 days since the successor line was first published (across majors; service first)'
|
|
25
|
+
export const releaseLine = (version: string) => {
|
|
26
|
+
const parsed = semver.parse(version)
|
|
27
|
+
if (!parsed) throw new Error(`invalid release identity: ${version}`)
|
|
28
|
+
return `${parsed.major}.${parsed.minor}.0`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Publication facts survive retirement of identities, catalogs and handlers.
|
|
32
|
+
* Stable patch publications never reset the first publication of their line. */
|
|
33
|
+
export function publishedLines(serviceVersion: string, releases = RELEASED_CLIENTS) {
|
|
34
|
+
const service = releaseLine(serviceVersion)
|
|
35
|
+
const lines = new Map<string, number>()
|
|
36
|
+
for (const release of releases) {
|
|
37
|
+
const parsed = semver.parse(release.version)
|
|
38
|
+
if (!parsed || parsed.prerelease.length) continue
|
|
39
|
+
const line = releaseLine(release.version)
|
|
40
|
+
if (semver.lt(line, CLIENT_POLICY_FLOOR) || semver.gt(line, service)) continue
|
|
41
|
+
const time = Date.parse(release.publishedAt)
|
|
42
|
+
if (!Number.isFinite(time)) throw new Error(`invalid publication timestamp: ${release.version}`)
|
|
43
|
+
lines.set(line, Math.min(lines.get(line) ?? Infinity, time))
|
|
44
|
+
}
|
|
45
|
+
return [...lines].sort(([a], [b]) => semver.compare(a, b))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Pure, local policy computation; no store access and no process-lifetime cache. */
|
|
49
|
+
export function supportedPublishedLines(
|
|
50
|
+
serviceVersion: string,
|
|
51
|
+
now: number,
|
|
52
|
+
releases = RELEASED_CLIENTS,
|
|
53
|
+
) {
|
|
54
|
+
const lines = publishedLines(serviceVersion, releases)
|
|
55
|
+
return lines
|
|
56
|
+
.filter((_, index) => {
|
|
57
|
+
const successor = lines[index + 1]
|
|
58
|
+
return (
|
|
59
|
+
lines.length - index - 1 < 2 ||
|
|
60
|
+
!successor ||
|
|
61
|
+
now < successor[1] + CLIENT_SUPPORT_DAYS * 86400000
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
.map(([line]) => line)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function validatePublications(releases: readonly ReleasedClient[]): void {
|
|
68
|
+
let previous: string | undefined
|
|
69
|
+
for (const release of releases) {
|
|
70
|
+
const parsed = semver.parse(release.version)
|
|
71
|
+
if (!parsed || parsed.version !== release.version || parsed.build.length)
|
|
72
|
+
throw new Error(`invalid published version: ${release.version}`)
|
|
73
|
+
if (previous && semver.gte(previous, release.version))
|
|
74
|
+
throw new Error('publications must be unique and ordered')
|
|
75
|
+
if (
|
|
76
|
+
!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(release.publishedAt) ||
|
|
77
|
+
!Number.isFinite(Date.parse(release.publishedAt))
|
|
78
|
+
)
|
|
79
|
+
throw new Error(`invalid publication timestamp: ${release.version}`)
|
|
80
|
+
const normalized = release.publishedAt.includes('.')
|
|
81
|
+
? release.publishedAt
|
|
82
|
+
: release.publishedAt.replace('Z', '.000Z')
|
|
83
|
+
if (new Date(release.publishedAt).toISOString() !== normalized)
|
|
84
|
+
throw new Error(`invalid publication timestamp: ${release.version}`)
|
|
85
|
+
previous = release.version
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
validatePublications(RELEASED_CLIENTS)
|