@defrex/autobuild 1.7.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 +316 -47
- package/docs/answering-blocked-builds.md +44 -3
- package/docs/architecture.md +62 -7
- package/docs/cli.md +1 -0
- package/docs/configuration-overview.md +1 -1
- package/docs/configuration.md +49 -9
- package/docs/dispatcher.md +1 -1
- 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 +26 -5
- package/docs/operator-surfaces.md +10 -0
- package/docs/plugin-authoring.md +1 -1
- package/docs/remote-store-protocol.md +9 -1
- package/docs/restacking.md +23 -4
- package/docs/ticket-dependencies.md +9 -4
- package/docs/tickets.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.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/help.ts +69 -7
- 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/status.ts +178 -12
- package/packages/core/src/cli/terminals.ts +197 -4
- package/packages/core/src/cli/wait.ts +1 -0
- package/packages/core/src/cli/watch.ts +71 -0
- package/packages/core/src/config/landing.ts +12 -0
- package/packages/core/src/config/path-selectors.ts +68 -0
- package/packages/core/src/config/schema.ts +40 -58
- package/packages/core/src/events/catalog.ts +17 -3
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/head-paths-limits.ts +25 -0
- package/packages/core/src/events/payloads.ts +315 -20
- package/packages/core/src/events/policy.ts +21 -0
- package/packages/core/src/events/repository.ts +30 -1
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +247 -6
- 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/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-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 +28 -1
- package/packages/core/src/kernel/reducer-registry.ts +22 -1
- package/packages/core/src/kernel/reducer.ts +316 -17
- 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 +12 -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 +15 -2
- package/packages/core/src/operator/registry.ts +97 -5
- package/packages/core/src/operator/repository-events.ts +67 -0
- package/packages/core/src/ports/tickets/fake.ts +5 -0
- package/packages/core/src/ports/types.ts +3 -2
- package/packages/core/src/processes/build-execution-state.ts +30 -1
- package/packages/core/src/processes/build-runner.ts +150 -18
- package/packages/core/src/processes/dispatcher.ts +739 -97
- package/packages/core/src/processes/execution-no-progress.ts +22 -2
- 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/store/digest.ts +41 -2
- package/packages/core/src/store/reduced-reads.ts +4 -1
- package/packages/core/src/store/reducer-value-shapes.json +10108 -8432
- package/packages/core/src/store/remote/client.ts +28 -2
- package/packages/core/src/store/remote/protocol.ts +11 -1
- package/packages/core/src/store/remote/released-clients.json +11 -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 +2 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +16 -0
- package/packages/core/src/testing/reduced-read-budget.ts +347 -0
- package/skills/code-review/SKILL.md +8 -0
- package/skills/finalize/SKILL.md +4 -0
- package/skills/guide/SKILL.md +125 -26
- 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 +26 -5
- package/skills/guide/references/plugin-authoring.md +1 -1
- package/skills/guide/references/remote-store-protocol.md +9 -1
- package/skills/guide/references/restacking.md +23 -4
- package/skills/guide/references/ticket-dependencies.md +9 -4
- package/skills/implement/SKILL.md +15 -1
- package/skills/operate/SKILL.md +104 -13
- 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 +5 -4
- package/templates/hosted-service/package.json +2 -2
|
@@ -17,6 +17,12 @@ import { nativeSessionHandleSchema } from './native-session'
|
|
|
17
17
|
import { z } from 'zod'
|
|
18
18
|
import { landingRuleSchema } from '../config/landing'
|
|
19
19
|
import { refineUniqueIssues } from '../ports/tickets/issue-links'
|
|
20
|
+
import {
|
|
21
|
+
HEAD_PATHS_ARTIFACT,
|
|
22
|
+
HEAD_PATHS_PREVIEW,
|
|
23
|
+
HEAD_PATHS_SOURCES,
|
|
24
|
+
LANDING_MATCHED_PATHS_PREVIEW,
|
|
25
|
+
} from './head-paths-limits'
|
|
20
26
|
import {
|
|
21
27
|
artifactRefSchema,
|
|
22
28
|
buildOutcomeSchema,
|
|
@@ -40,6 +46,36 @@ import {
|
|
|
40
46
|
type VerifyOutcome,
|
|
41
47
|
} from '../ontology'
|
|
42
48
|
|
|
49
|
+
/** Most tickets one wait may name. */
|
|
50
|
+
export const WAIT_TICKET_LIMIT = 20
|
|
51
|
+
/** Ticket ids an agent declares a wait on: 1..20 trimmed, nonblank, unique. */
|
|
52
|
+
export const waitTicketIdsSchema = z
|
|
53
|
+
.array(z.string().trim().min(1))
|
|
54
|
+
.min(1)
|
|
55
|
+
.max(WAIT_TICKET_LIMIT)
|
|
56
|
+
.superRefine((ids, ctx) => {
|
|
57
|
+
const seen = new Set<string>()
|
|
58
|
+
for (const [index, id] of ids.entries()) {
|
|
59
|
+
if (seen.has(id))
|
|
60
|
+
ctx.addIssue({ code: 'custom', path: [index], message: `duplicate ticket id "${id}"` })
|
|
61
|
+
seen.add(id)
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
export const waitRefusalCauseSchema = z.enum([
|
|
65
|
+
'unknown-ticket',
|
|
66
|
+
'own-ticket',
|
|
67
|
+
'completed',
|
|
68
|
+
'no-source-ticket',
|
|
69
|
+
'publication-lost',
|
|
70
|
+
])
|
|
71
|
+
export type WaitRefusalCause = z.infer<typeof waitRefusalCauseSchema>
|
|
72
|
+
export const waitEndCauseSchema = z.enum(['operator', 'automatic'])
|
|
73
|
+
export type WaitEndCause = z.infer<typeof waitEndCauseSchema>
|
|
74
|
+
/** How a reduced ticket wait ended: a `wait.ended` cause, or `unresolvable`
|
|
75
|
+
* when the dispatcher raised `policy/wait-unresolvable` because a waited
|
|
76
|
+
* ticket was rejected or deleted. Reduced-only: no event payload carries it. */
|
|
77
|
+
export type ReducedWaitEndCause = WaitEndCause | 'unresolvable'
|
|
78
|
+
|
|
43
79
|
export const gitOid = z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/)
|
|
44
80
|
const targetLineageSchema = z
|
|
45
81
|
.array(
|
|
@@ -47,7 +83,13 @@ const targetLineageSchema = z
|
|
|
47
83
|
node: z.string().min(1),
|
|
48
84
|
from: gitOid,
|
|
49
85
|
receipts: z
|
|
50
|
-
.array(
|
|
86
|
+
.array(
|
|
87
|
+
z.strictObject({
|
|
88
|
+
id: z.string().min(1),
|
|
89
|
+
previous: gitOid,
|
|
90
|
+
head: gitOid,
|
|
91
|
+
}),
|
|
92
|
+
)
|
|
51
93
|
.min(1)
|
|
52
94
|
.max(64),
|
|
53
95
|
}),
|
|
@@ -67,7 +109,7 @@ export const reconcileTransactionSchema = z.strictObject({
|
|
|
67
109
|
localBranchHead: gitOid,
|
|
68
110
|
})
|
|
69
111
|
export const leafRestackSchema = reconcileTransactionSchema.omit({ attempt: true }).extend({
|
|
70
|
-
trigger: z.enum(['verify-entry', 'awaiting-landing']),
|
|
112
|
+
trigger: z.enum(['verify-entry', 'awaiting-landing', 'wait-resume']),
|
|
71
113
|
cycle: z.number().int().nonnegative(),
|
|
72
114
|
observation: z.number().int().positive(),
|
|
73
115
|
message: z.string().min(1),
|
|
@@ -82,6 +124,37 @@ export const landingCandidateSchema = z.strictObject({
|
|
|
82
124
|
parent: z.string().min(1),
|
|
83
125
|
cycle: z.string().min(1),
|
|
84
126
|
})
|
|
127
|
+
/** A bounded path summary: the exact count plus the sorted, unique first
|
|
128
|
+
* `max` paths. The complete set lives in the `head-paths` artifact. */
|
|
129
|
+
function pathPreview(max: number) {
|
|
130
|
+
return z
|
|
131
|
+
.strictObject({
|
|
132
|
+
total: z.number().int().nonnegative(),
|
|
133
|
+
preview: z.array(z.string().min(1)).max(max),
|
|
134
|
+
})
|
|
135
|
+
.superRefine(({ total, preview }, ctx) => {
|
|
136
|
+
if (preview.length !== Math.min(total, max))
|
|
137
|
+
ctx.addIssue({
|
|
138
|
+
code: 'custom',
|
|
139
|
+
path: ['preview'],
|
|
140
|
+
message: `preview must hold exactly min(total, ${max}) paths`,
|
|
141
|
+
})
|
|
142
|
+
for (let index = 1; index < preview.length; index++)
|
|
143
|
+
if (!(preview[index - 1]! < preview[index]!)) {
|
|
144
|
+
ctx.addIssue({
|
|
145
|
+
code: 'custom',
|
|
146
|
+
path: ['preview', index],
|
|
147
|
+
message: 'preview paths must be sorted and unique',
|
|
148
|
+
})
|
|
149
|
+
break
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const landingRuleRef = z.strictObject({
|
|
155
|
+
index: z.number().int().nonnegative(),
|
|
156
|
+
snapshot: landingRuleSchema,
|
|
157
|
+
})
|
|
85
158
|
const landingDecision = z.strictObject({
|
|
86
159
|
candidate: landingCandidateSchema,
|
|
87
160
|
from: z.enum(['leaf', 'node']),
|
|
@@ -91,10 +164,33 @@ const landingDecision = z.strictObject({
|
|
|
91
164
|
]),
|
|
92
165
|
labels: z.array(z.string()),
|
|
93
166
|
mode: z.enum(['auto', 'consent']),
|
|
94
|
-
rule: z.union([
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
167
|
+
rule: z.union([landingRuleRef, z.strictObject({ default: z.literal(true) })]),
|
|
168
|
+
/** Path-predicate rules only: the changed paths the rule's selectors
|
|
169
|
+
* matched, sorted, the first `LANDING_MATCHED_PATHS_PREVIEW` plus a total. */
|
|
170
|
+
paths: pathPreview(LANDING_MATCHED_PATHS_PREVIEW).optional(),
|
|
171
|
+
})
|
|
172
|
+
/** A landing decision the dispatcher could not make yet: evaluation reached a
|
|
173
|
+
* path-predicate rule and the candidate head's changed paths are not
|
|
174
|
+
* recorded. `policy` is the evaluated `[[merge]]` rules' identity, so an
|
|
175
|
+
* edited policy re-evaluates once. Never treated as an empty change. */
|
|
176
|
+
const landingDeferred = z.strictObject({
|
|
177
|
+
candidate: landingCandidateSchema,
|
|
178
|
+
reason: z.enum(['paths-unrecorded']),
|
|
179
|
+
rule: landingRuleRef,
|
|
180
|
+
policy: z.string().min(1),
|
|
181
|
+
})
|
|
182
|
+
/** Consent given under a path-predicate rule, revoked because a reconcile's
|
|
183
|
+
* own edits touched files those predicates match. `paths` holds the matched
|
|
184
|
+
* resolution paths: sorted, the first `LANDING_MATCHED_PATHS_PREVIEW` plus a
|
|
185
|
+
* total. */
|
|
186
|
+
const landingConsentRevoked = z.strictObject({
|
|
187
|
+
commandSeq: z.number().int().positive(),
|
|
188
|
+
source: z.enum(['reconcile', 'node-rewrite']),
|
|
189
|
+
rule: landingRuleRef,
|
|
190
|
+
previousHead: z.string().min(1),
|
|
191
|
+
head: z.string().min(1),
|
|
192
|
+
consentedHead: z.string().min(1).optional(),
|
|
193
|
+
paths: pathPreview(LANDING_MATCHED_PATHS_PREVIEW),
|
|
98
194
|
})
|
|
99
195
|
const nodeParent = z.strictObject({
|
|
100
196
|
target: z.strictObject({ ticket: ticketRefSchema, build: z.string().min(1) }).nullable(),
|
|
@@ -107,8 +203,59 @@ const parentChange = z.strictObject({
|
|
|
107
203
|
revision: z.string(),
|
|
108
204
|
})
|
|
109
205
|
|
|
206
|
+
const headPathsPreview = pathPreview(HEAD_PATHS_PREVIEW)
|
|
207
|
+
const headPathsRecorded = z
|
|
208
|
+
.strictObject({
|
|
209
|
+
source: z.enum(HEAD_PATHS_SOURCES),
|
|
210
|
+
// Plain commit names, like the node and integration heads they describe.
|
|
211
|
+
head: z.string().min(1),
|
|
212
|
+
destination: z.string().min(1),
|
|
213
|
+
mergeBase: z.string().min(1),
|
|
214
|
+
total: z.number().int().nonnegative(),
|
|
215
|
+
preview: z.array(z.string().min(1)).max(HEAD_PATHS_PREVIEW),
|
|
216
|
+
/** Reconcile-produced heads only: the paths the resolution itself edited. */
|
|
217
|
+
resolution: headPathsPreview.optional(),
|
|
218
|
+
artifact: z.strictObject({
|
|
219
|
+
kind: z.literal(HEAD_PATHS_ARTIFACT),
|
|
220
|
+
rev: z.number().int().nonnegative(),
|
|
221
|
+
}),
|
|
222
|
+
})
|
|
223
|
+
.superRefine((payload, ctx) => {
|
|
224
|
+
const summary = headPathsPreview.safeParse({
|
|
225
|
+
total: payload.total,
|
|
226
|
+
preview: payload.preview,
|
|
227
|
+
})
|
|
228
|
+
for (const issue of summary.error?.issues ?? [])
|
|
229
|
+
ctx.addIssue({
|
|
230
|
+
code: 'custom',
|
|
231
|
+
path: issue.path,
|
|
232
|
+
message: issue.message,
|
|
233
|
+
})
|
|
234
|
+
})
|
|
235
|
+
|
|
110
236
|
const empty = z.strictObject({})
|
|
111
237
|
const reasonOnly = z.strictObject({ reason: z.string().optional() })
|
|
238
|
+
/** Where an abort hands the build's ticket back. Triage is the default. */
|
|
239
|
+
export const abortDestinationSchema = z.enum(['triage', 'ready'])
|
|
240
|
+
export type AbortDestination = z.infer<typeof abortDestinationSchema>
|
|
241
|
+
/** Why a dispatcher returned a claimed or ready ticket other than as completion. */
|
|
242
|
+
export const handbackCauseSchema = z.enum([
|
|
243
|
+
'abort',
|
|
244
|
+
'spec-bounce',
|
|
245
|
+
'preparation-failed',
|
|
246
|
+
'pr-closed',
|
|
247
|
+
'discard',
|
|
248
|
+
])
|
|
249
|
+
export type HandbackCause = z.infer<typeof handbackCauseSchema>
|
|
250
|
+
/** What a hand-back report carries beyond its identity: the lifecycle role the
|
|
251
|
+
* ticket landed in, the role asked for when it differs, the operator's reason
|
|
252
|
+
* and the spec-standard parts that forced a fallback. */
|
|
253
|
+
export const handbackReport = {
|
|
254
|
+
role: abortDestinationSchema,
|
|
255
|
+
requested: abortDestinationSchema.optional(),
|
|
256
|
+
reason: z.string().min(1).max(2000).optional(),
|
|
257
|
+
missing: z.array(z.string().min(1)).min(1).optional(),
|
|
258
|
+
}
|
|
112
259
|
/** Fan-out provenance shared by the auto-merge command facts: the repository
|
|
113
260
|
* seq of the `dispatcher.auto-merge-default-set` fact that caused the command,
|
|
114
261
|
* when one did. Per-build commands omit it. `{}` stays valid, so existing
|
|
@@ -397,9 +544,15 @@ export const eventPayloadSchemas = {
|
|
|
397
544
|
}),
|
|
398
545
|
'node.parent-requested': parentChange,
|
|
399
546
|
'node.parent-accepted': parentChange,
|
|
400
|
-
'node.parent-pr-retargeted': z.strictObject({
|
|
547
|
+
'node.parent-pr-retargeted': z.strictObject({
|
|
548
|
+
id: z.string().min(1),
|
|
549
|
+
base: z.string().min(1),
|
|
550
|
+
}),
|
|
401
551
|
'node.parent-completed': z.strictObject({ id: z.string().min(1) }),
|
|
402
|
-
'node.parent-cancelled': z.strictObject({
|
|
552
|
+
'node.parent-cancelled': z.strictObject({
|
|
553
|
+
id: z.string().min(1),
|
|
554
|
+
reason: z.string(),
|
|
555
|
+
}),
|
|
403
556
|
'node.parent-rejection-cleared': z.strictObject({
|
|
404
557
|
revision: z.string(),
|
|
405
558
|
target: z.string().nullable(),
|
|
@@ -456,7 +609,10 @@ export const eventPayloadSchemas = {
|
|
|
456
609
|
index: z.number().int().nonnegative(),
|
|
457
610
|
base: z.string().min(1),
|
|
458
611
|
}),
|
|
459
|
-
'node.publish-intended': z.strictObject({
|
|
612
|
+
'node.publish-intended': z.strictObject({
|
|
613
|
+
id: z.string().min(1),
|
|
614
|
+
head: z.string().min(1),
|
|
615
|
+
}),
|
|
460
616
|
'node.rewritten': z.strictObject({
|
|
461
617
|
id: z.string().min(1),
|
|
462
618
|
previous: z.string().min(1),
|
|
@@ -496,7 +652,12 @@ export const eventPayloadSchemas = {
|
|
|
496
652
|
'node.issue-links-published': z.strictObject({
|
|
497
653
|
pr: z.number().int().positive(),
|
|
498
654
|
issueLinks: z
|
|
499
|
-
.array(
|
|
655
|
+
.array(
|
|
656
|
+
z.strictObject({
|
|
657
|
+
issue: issueNumber,
|
|
658
|
+
intent: z.enum(['closes', 'refs']),
|
|
659
|
+
}),
|
|
660
|
+
)
|
|
500
661
|
.superRefine(refineUniqueIssues),
|
|
501
662
|
}),
|
|
502
663
|
'node.inventory': z.strictObject({
|
|
@@ -506,7 +667,10 @@ export const eventPayloadSchemas = {
|
|
|
506
667
|
contributions: z.array(z.string()).optional(),
|
|
507
668
|
foreign: z.array(z.string()),
|
|
508
669
|
}),
|
|
509
|
-
'integration.abandoned': z.strictObject({
|
|
670
|
+
'integration.abandoned': z.strictObject({
|
|
671
|
+
id: z.string().min(1),
|
|
672
|
+
reason: z.string().min(1),
|
|
673
|
+
}),
|
|
510
674
|
'integration.observed': z.strictObject({
|
|
511
675
|
membershipSource: z.string().optional(),
|
|
512
676
|
openChildren: z.array(z.string()),
|
|
@@ -629,7 +793,12 @@ export const eventPayloadSchemas = {
|
|
|
629
793
|
/** Preserved branch heads not restored over the branch: already
|
|
630
794
|
* contained, or superseded by a recorded rewrite in the bounded record. */
|
|
631
795
|
restorationSkipped: z
|
|
632
|
-
.array(
|
|
796
|
+
.array(
|
|
797
|
+
z.strictObject({
|
|
798
|
+
sha: gitOid,
|
|
799
|
+
reason: z.enum(['contained', 'superseded']),
|
|
800
|
+
}),
|
|
801
|
+
)
|
|
633
802
|
.min(1)
|
|
634
803
|
.optional(),
|
|
635
804
|
}),
|
|
@@ -840,6 +1009,15 @@ export const eventPayloadSchemas = {
|
|
|
840
1009
|
sha: z.string().regex(/^[0-9a-f]{40,64}$/i),
|
|
841
1010
|
step: z.string().min(1),
|
|
842
1011
|
}),
|
|
1012
|
+
/** An implement session's commits, published before its ticket wait is
|
|
1013
|
+
* entered; `wait.published` with the same `id` completes it. */
|
|
1014
|
+
z.strictObject({
|
|
1015
|
+
operation: z.literal('wait'),
|
|
1016
|
+
id: z.string().min(1),
|
|
1017
|
+
branch: z.string().min(1),
|
|
1018
|
+
sha: gitOid,
|
|
1019
|
+
base: gitOid,
|
|
1020
|
+
}),
|
|
843
1021
|
]),
|
|
844
1022
|
/** Durable loss record: the dispatcher released (or is about to release) the
|
|
845
1023
|
* workspace while the referenced `publication.requested` (named by `request`,
|
|
@@ -860,7 +1038,7 @@ export const eventPayloadSchemas = {
|
|
|
860
1038
|
'publication.lost': z.strictObject({
|
|
861
1039
|
/** seq of the lost `publication.requested` event. */
|
|
862
1040
|
request: z.number().int().positive(),
|
|
863
|
-
operation: z.enum(['implement', 'reconcile', 'restack', 'finalize', 'finalize-step']),
|
|
1041
|
+
operation: z.enum(['implement', 'reconcile', 'restack', 'finalize', 'finalize-step', 'wait']),
|
|
864
1042
|
branch: z.string().min(1),
|
|
865
1043
|
sha: z.string().regex(/^[0-9a-f]{40,64}$/i),
|
|
866
1044
|
reason: z.string().trim().min(1),
|
|
@@ -872,6 +1050,20 @@ export const eventPayloadSchemas = {
|
|
|
872
1050
|
ticket: ticketRefSchema,
|
|
873
1051
|
state: z.string().min(1),
|
|
874
1052
|
label: z.string().min(1),
|
|
1053
|
+
// Optional so pre-destination checkpoints replay; a legacy checkpoint's
|
|
1054
|
+
// role derives from its state.
|
|
1055
|
+
role: handbackReport.role.optional(),
|
|
1056
|
+
requested: handbackReport.requested,
|
|
1057
|
+
reason: handbackReport.reason,
|
|
1058
|
+
missing: handbackReport.missing,
|
|
1059
|
+
}),
|
|
1060
|
+
/** Checkpoint for a non-abort build hand-back (closed PR, discard): the
|
|
1061
|
+
* ticket move and comment are committed and never repeated. */
|
|
1062
|
+
'build.ticket-returned': z.strictObject({
|
|
1063
|
+
ticket: ticketRefSchema,
|
|
1064
|
+
state: z.string().min(1),
|
|
1065
|
+
cause: z.enum(['pr-closed', 'discard']),
|
|
1066
|
+
role: abortDestinationSchema,
|
|
875
1067
|
}),
|
|
876
1068
|
/** A post-creation dispatch attempt stopped before runner attachment. */
|
|
877
1069
|
'dispatch.failed': z.strictObject({
|
|
@@ -885,7 +1077,10 @@ export const eventPayloadSchemas = {
|
|
|
885
1077
|
// ── Operator commands (D2: commands are events in the same log) ───────────
|
|
886
1078
|
'build.pause-requested': reasonOnly,
|
|
887
1079
|
'build.resume-requested': reasonOnly,
|
|
888
|
-
'build.abort-requested':
|
|
1080
|
+
'build.abort-requested': z.strictObject({
|
|
1081
|
+
reason: z.string().optional(),
|
|
1082
|
+
to: abortDestinationSchema.optional(),
|
|
1083
|
+
}),
|
|
889
1084
|
'build.discard-requested': empty,
|
|
890
1085
|
'build.janitor-attempt-failed': z.strictObject({
|
|
891
1086
|
firstFailureAt: z.iso.datetime(),
|
|
@@ -914,9 +1109,15 @@ export const eventPayloadSchemas = {
|
|
|
914
1109
|
after: z.iso.datetime(),
|
|
915
1110
|
}),
|
|
916
1111
|
'landing.decided': landingDecision,
|
|
1112
|
+
'landing.deferred': landingDeferred,
|
|
1113
|
+
'landing.consent-revoked': landingConsentRevoked,
|
|
917
1114
|
'build.hold-requested': empty,
|
|
918
|
-
'build.land-requested': z.strictObject({
|
|
919
|
-
|
|
1115
|
+
'build.land-requested': z.strictObject({
|
|
1116
|
+
decisionSeq: z.number().int().positive(),
|
|
1117
|
+
}),
|
|
1118
|
+
'landing.command-acknowledged': z.strictObject({
|
|
1119
|
+
commandSeq: z.number().int().positive(),
|
|
1120
|
+
}),
|
|
920
1121
|
'landing.native-enable-started': empty,
|
|
921
1122
|
'landing.forge-merged': z.strictObject({
|
|
922
1123
|
classification: z.enum(['human', 'possible-stale-enable']),
|
|
@@ -961,7 +1162,10 @@ export const eventPayloadSchemas = {
|
|
|
961
1162
|
}),
|
|
962
1163
|
z.strictObject({
|
|
963
1164
|
artifact: artifactRefSchema,
|
|
964
|
-
operator: z.strictObject({
|
|
1165
|
+
operator: z.strictObject({
|
|
1166
|
+
user: z.string().min(1),
|
|
1167
|
+
via: viaSchema.optional(),
|
|
1168
|
+
}),
|
|
965
1169
|
assets: z.array(pinnedAssetSchema).optional(),
|
|
966
1170
|
}),
|
|
967
1171
|
]),
|
|
@@ -1162,7 +1366,10 @@ export const eventPayloadSchemas = {
|
|
|
1162
1366
|
headSha: gitOid.optional(),
|
|
1163
1367
|
restackId: z.string().min(1).optional(),
|
|
1164
1368
|
failed: z.array(
|
|
1165
|
-
z.strictObject({
|
|
1369
|
+
z.strictObject({
|
|
1370
|
+
step: z.string().min(1),
|
|
1371
|
+
report: artifactRefSchema.optional(),
|
|
1372
|
+
}),
|
|
1166
1373
|
),
|
|
1167
1374
|
cancelled: z.array(
|
|
1168
1375
|
z.strictObject({
|
|
@@ -1272,6 +1479,17 @@ export const eventPayloadSchemas = {
|
|
|
1272
1479
|
actual: gitOid.nullable(),
|
|
1273
1480
|
}),
|
|
1274
1481
|
'restack.completed': leafRestackSchema.extend({ headSha: gitOid }),
|
|
1482
|
+
/** A pre-publication wait-resume fast-forward: the local branch had no
|
|
1483
|
+
* commits beyond `from` and nothing was published, so it now points at
|
|
1484
|
+
* the target snapshot `to`. No remote write happened. */
|
|
1485
|
+
'restack.advanced': z.strictObject({
|
|
1486
|
+
trigger: z.literal('wait-resume'),
|
|
1487
|
+
cycle: z.number().int().nonnegative(),
|
|
1488
|
+
observation: z.number().int().positive(),
|
|
1489
|
+
branch: z.string().min(1),
|
|
1490
|
+
from: gitOid,
|
|
1491
|
+
to: gitOid,
|
|
1492
|
+
}),
|
|
1275
1493
|
'reconcile.started': z.strictObject({
|
|
1276
1494
|
attempt,
|
|
1277
1495
|
baseSha: z.string().min(1),
|
|
@@ -1300,11 +1518,33 @@ export const eventPayloadSchemas = {
|
|
|
1300
1518
|
conflicted: z.boolean(),
|
|
1301
1519
|
archives: z.array(archiveEntry),
|
|
1302
1520
|
}),
|
|
1521
|
+
/** The kernel abandoned an open reconcile occurrence with no publish
|
|
1522
|
+
* intent because its session declared a ticket wait and the target moved
|
|
1523
|
+
* before the build resumed. The workspace operation was aborted and nothing
|
|
1524
|
+
* was published; `restackId` names the automatic restack it also closes. */
|
|
1525
|
+
'reconcile.superseded': z.strictObject({
|
|
1526
|
+
attempt,
|
|
1527
|
+
cycle: z.number().int().nonnegative(),
|
|
1528
|
+
cause: z.literal('wait-resume'),
|
|
1529
|
+
restackId: z.string().min(1).optional(),
|
|
1530
|
+
}),
|
|
1303
1531
|
'reconcile.completed': z.union([
|
|
1304
|
-
z.strictObject({
|
|
1305
|
-
|
|
1532
|
+
z.strictObject({
|
|
1533
|
+
mergeCommit: z.string().min(1),
|
|
1534
|
+
artifact: artifactRefSchema,
|
|
1535
|
+
}),
|
|
1536
|
+
z.strictObject({
|
|
1537
|
+
headSha: gitOid,
|
|
1538
|
+
rewriteId: z.string().min(1),
|
|
1539
|
+
artifact: artifactRefSchema,
|
|
1540
|
+
}),
|
|
1306
1541
|
]),
|
|
1307
1542
|
|
|
1543
|
+
/** The paths a produced candidate head changes against its merge base with
|
|
1544
|
+
* the destination, recorded once per head before the write that establishes
|
|
1545
|
+
* it. A bounded summary; the complete sets are the `head-paths` artifact. */
|
|
1546
|
+
'head.paths-recorded': headPathsRecorded,
|
|
1547
|
+
|
|
1308
1548
|
// ── Cross-cutting ──────────────────────────────────────────────────────────
|
|
1309
1549
|
/** An agent found the build only partly resolves a linked `closes` issue.
|
|
1310
1550
|
* One-way: no fact can express an upgrade. Inert once links are sealed. */
|
|
@@ -1381,6 +1621,61 @@ export const eventPayloadSchemas = {
|
|
|
1381
1621
|
question: z.string().min(1),
|
|
1382
1622
|
refs: z.array(z.string()),
|
|
1383
1623
|
}),
|
|
1624
|
+
/** An agent's terminal declaring that its build waits on other tickets
|
|
1625
|
+
* (SPEC §11 "Ticket waits"). Advisory until the dispatcher validates it:
|
|
1626
|
+
* `wait.entered` or `wait.refused` with the same `id` answers it. */
|
|
1627
|
+
'wait.requested': z.strictObject({
|
|
1628
|
+
id: z.string().min(1),
|
|
1629
|
+
phase: phaseSchema,
|
|
1630
|
+
round,
|
|
1631
|
+
tickets: waitTicketIdsSchema,
|
|
1632
|
+
reason: z.string().trim().min(1),
|
|
1633
|
+
/** An implement session's unpublished commits at declaration. `published`:
|
|
1634
|
+
* the CLI already pushed `sha` (local workspace). `requested`: a
|
|
1635
|
+
* `publication.requested {operation: 'wait'}` with this id precedes this
|
|
1636
|
+
* event, and the dispatcher enters the wait only after `wait.published`. */
|
|
1637
|
+
publication: z
|
|
1638
|
+
.strictObject({
|
|
1639
|
+
branch: z.string().min(1),
|
|
1640
|
+
base: gitOid,
|
|
1641
|
+
sha: gitOid,
|
|
1642
|
+
settlement: z.enum(['published', 'requested']),
|
|
1643
|
+
})
|
|
1644
|
+
.optional(),
|
|
1645
|
+
}),
|
|
1646
|
+
/** The dispatcher published a wait's requested commits. */
|
|
1647
|
+
'wait.published': z.strictObject({ id: z.string().min(1), sha: gitOid }),
|
|
1648
|
+
/** The dispatcher refused a ticket wait. Nothing was written to the ticket
|
|
1649
|
+
* and no wait began; the declaring phase re-runs with `message` as its
|
|
1650
|
+
* guidance. `tickets` names the offending ids. */
|
|
1651
|
+
'wait.refused': z.strictObject({
|
|
1652
|
+
id: z.string().min(1),
|
|
1653
|
+
cause: waitRefusalCauseSchema,
|
|
1654
|
+
tickets: z.array(z.string().min(1)),
|
|
1655
|
+
message: z.string().trim().min(1),
|
|
1656
|
+
}),
|
|
1657
|
+
/** Entering a ticket wait. The source ticket's `blockedBy` already lists
|
|
1658
|
+
* every ticket; `escalation` identifies the wait's escalation, which an
|
|
1659
|
+
* operator answers to end the wait early. The dispatcher ends it with
|
|
1660
|
+
* `wait.ended {cause: automatic}` once every ticket completes, or raises
|
|
1661
|
+
* `policy/wait-unresolvable` when one is rejected or deleted. A waiting
|
|
1662
|
+
* leaf holds no slot. */
|
|
1663
|
+
'wait.entered': z.strictObject({
|
|
1664
|
+
id: z.string().min(1),
|
|
1665
|
+
escalation: z.string().min(1),
|
|
1666
|
+
tickets: z.array(ticketRefSchema).min(1).max(WAIT_TICKET_LIMIT),
|
|
1667
|
+
reason: z.string().trim().min(1),
|
|
1668
|
+
question: z.string().min(1),
|
|
1669
|
+
}),
|
|
1670
|
+
/** A ticket wait ended without an operator answer: `automatic`, written by
|
|
1671
|
+
* the dispatcher on the first tick after every waited ticket completed;
|
|
1672
|
+
* `operator` from an operator surface that ends the wait without
|
|
1673
|
+
* answering. An answer to the wait's escalation also ends it. */
|
|
1674
|
+
'wait.ended': z.strictObject({
|
|
1675
|
+
id: z.string().min(1),
|
|
1676
|
+
cause: waitEndCauseSchema,
|
|
1677
|
+
message: z.string().trim().min(1),
|
|
1678
|
+
}),
|
|
1384
1679
|
'phase.failed': z.strictObject({
|
|
1385
1680
|
phase: phaseSchema,
|
|
1386
1681
|
round: round.optional(),
|
|
@@ -17,6 +17,10 @@ export const buildEventPolicy = {
|
|
|
17
17
|
'build.janitor-escalated': 'decisive',
|
|
18
18
|
'landing.application-failed': 'decisive',
|
|
19
19
|
'landing.decided': 'decisive',
|
|
20
|
+
// A reader that ignores a deferral only evaluates the candidate again.
|
|
21
|
+
'landing.deferred': 'advisory',
|
|
22
|
+
// Decisive: a reader that ignored it would merge on revoked consent.
|
|
23
|
+
'landing.consent-revoked': 'decisive',
|
|
20
24
|
'build.hold-requested': 'decisive',
|
|
21
25
|
'build.land-requested': 'decisive',
|
|
22
26
|
'landing.command-acknowledged': 'decisive',
|
|
@@ -28,12 +32,20 @@ export const buildEventPolicy = {
|
|
|
28
32
|
'target.rewritten': 'decisive',
|
|
29
33
|
'target.rewrite-cleared': 'decisive',
|
|
30
34
|
'target.moved': 'decisive',
|
|
35
|
+
// Advisory although merge-rule path predicates decide on it: a decisive
|
|
36
|
+
// unknown type would make an older runtime in a hot-upgrade fleet defer
|
|
37
|
+
// every kernel decision on the build. An older runtime cannot parse a
|
|
38
|
+
// `[[merge]]` rule carrying `paths` or `within` (rule schemas are strict), so
|
|
39
|
+
// it never decides a path rule; ignoring the fact it sees "not recorded",
|
|
40
|
+
// which every consumer treats safely.
|
|
41
|
+
'head.paths-recorded': 'advisory',
|
|
31
42
|
'restack.prepared': 'decisive',
|
|
32
43
|
'restack.replayed': 'decisive',
|
|
33
44
|
'restack.publish-intended': 'decisive',
|
|
34
45
|
'restack.rewritten': 'decisive',
|
|
35
46
|
'restack.contended': 'decisive',
|
|
36
47
|
'restack.completed': 'decisive',
|
|
48
|
+
'restack.advanced': 'decisive',
|
|
37
49
|
'integration.abandoned': 'decisive',
|
|
38
50
|
'integration.observed': 'decisive',
|
|
39
51
|
'integration.prepared': 'decisive',
|
|
@@ -100,6 +112,7 @@ export const buildEventPolicy = {
|
|
|
100
112
|
'abort.remote-branch-deleted': 'decisive',
|
|
101
113
|
'abort.local-branch-deleted': 'decisive',
|
|
102
114
|
'abort.ticket-returned': 'decisive',
|
|
115
|
+
'build.ticket-returned': 'decisive',
|
|
103
116
|
'dispatch.failed': 'decisive',
|
|
104
117
|
'dispatch.comment-posted': 'advisory',
|
|
105
118
|
'build.pause-requested': 'decisive',
|
|
@@ -156,6 +169,7 @@ export const buildEventPolicy = {
|
|
|
156
169
|
'reconcile.publish-intended': 'decisive',
|
|
157
170
|
'reconcile.rewritten': 'decisive',
|
|
158
171
|
'reconcile.completed': 'decisive',
|
|
172
|
+
'reconcile.superseded': 'decisive',
|
|
159
173
|
'issue-link.downgraded': 'decisive',
|
|
160
174
|
'issue-links.sealed': 'decisive',
|
|
161
175
|
'observation.recorded': 'advisory',
|
|
@@ -166,6 +180,11 @@ export const buildEventPolicy = {
|
|
|
166
180
|
'session.build-read-recovered': 'decisive',
|
|
167
181
|
'phase.deferred': 'decisive',
|
|
168
182
|
'phase.deferral-escalated': 'decisive',
|
|
183
|
+
'wait.requested': 'decisive',
|
|
184
|
+
'wait.refused': 'decisive',
|
|
185
|
+
'wait.entered': 'decisive',
|
|
186
|
+
'wait.ended': 'decisive',
|
|
187
|
+
'wait.published': 'decisive',
|
|
169
188
|
} satisfies Record<EventType, FactClassification>
|
|
170
189
|
export const repositoryEventPolicy = {
|
|
171
190
|
'dispatcher.placement-set': 'advisory',
|
|
@@ -178,6 +197,8 @@ export const repositoryEventPolicy = {
|
|
|
178
197
|
'ticket-preparation.recovery-failed': 'decisive',
|
|
179
198
|
'ticket-preparation.handback-selected': 'decisive',
|
|
180
199
|
'ticket-preparation.resolved': 'decisive',
|
|
200
|
+
'ticket.handed-back': 'decisive',
|
|
201
|
+
'ticket.handback-settled': 'decisive',
|
|
181
202
|
|
|
182
203
|
'tickets.migration-recorded': 'decisive',
|
|
183
204
|
'change-presence.observed': 'decisive',
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
type ActorKind,
|
|
33
33
|
} from './envelope'
|
|
34
34
|
import { EventValidationError } from './catalog'
|
|
35
|
-
import { providerAttemptSchema } from './payloads'
|
|
35
|
+
import { handbackCauseSchema, handbackReport, providerAttemptSchema } from './payloads'
|
|
36
36
|
|
|
37
37
|
const round = z.number().int().positive()
|
|
38
38
|
const attempt = z.number().int().positive()
|
|
@@ -857,6 +857,8 @@ export const ticketPreparationEventPayloadSchemas = {
|
|
|
857
857
|
'ticket-preparation.handback-selected': z.strictObject({
|
|
858
858
|
...preparationIdentity,
|
|
859
859
|
state: z.string().min(1),
|
|
860
|
+
/** Spec-standard parts a bounce found missing, for its hand-back report. */
|
|
861
|
+
missing: handbackReport.missing,
|
|
860
862
|
}),
|
|
861
863
|
'ticket-preparation.resolved': z.strictObject({
|
|
862
864
|
...preparationIdentity,
|
|
@@ -867,6 +869,30 @@ export const ticketPreparationEventPayloadSchemas = {
|
|
|
867
869
|
}),
|
|
868
870
|
}
|
|
869
871
|
|
|
872
|
+
/** Operator-visible ticket hand-backs. Each identity (`build`, or a
|
|
873
|
+
* preparation `attempt`) reports once; the dispatcher appends the report only
|
|
874
|
+
* after the ticket move is committed, so a watcher may move the ticket on it. */
|
|
875
|
+
export const ticketHandbackEventPayloadSchemas = {
|
|
876
|
+
/** A dispatcher returned a claimed or ready ticket, not as completion. */
|
|
877
|
+
'ticket.handed-back': z
|
|
878
|
+
.strictObject({
|
|
879
|
+
/** The ref actually moved (its current id after any migration). */
|
|
880
|
+
ticket: ticketRefSchema,
|
|
881
|
+
build: z.string().min(1).optional(),
|
|
882
|
+
attempt: z.string().min(1).optional(),
|
|
883
|
+
cause: handbackCauseSchema,
|
|
884
|
+
/** The backend state name the ticket was moved to. */
|
|
885
|
+
state: z.string().min(1),
|
|
886
|
+
...handbackReport,
|
|
887
|
+
})
|
|
888
|
+
.superRefine((value, ctx) => {
|
|
889
|
+
if ((value.build === undefined) === (value.attempt === undefined))
|
|
890
|
+
ctx.addIssue({ code: 'custom', message: 'exactly one of build or attempt is required' })
|
|
891
|
+
}),
|
|
892
|
+
/** Settles a build hand-back identity once the build is complete. */
|
|
893
|
+
'ticket.handback-settled': z.strictObject({ build: z.string().min(1) }),
|
|
894
|
+
}
|
|
895
|
+
|
|
870
896
|
export const dispatchPlacementFactSchema = z.discriminatedUnion('hosted', [
|
|
871
897
|
z.strictObject({
|
|
872
898
|
hosted: z.literal(true),
|
|
@@ -894,6 +920,7 @@ export type DispatchPlacementFact = z.infer<typeof dispatchPlacementFactSchema>
|
|
|
894
920
|
export const repositoryEventPayloadSchemas = {
|
|
895
921
|
'dispatcher.placement-set': dispatchPlacementFactSchema,
|
|
896
922
|
...ticketPreparationEventPayloadSchemas,
|
|
923
|
+
...ticketHandbackEventPayloadSchemas,
|
|
897
924
|
...ticketMigrationEventPayloadSchemas,
|
|
898
925
|
...forgeHealthEventPayloadSchemas,
|
|
899
926
|
...kernelGitHealthEventPayloadSchemas,
|
|
@@ -975,6 +1002,8 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
|
975
1002
|
'ticket-preparation.recovery-failed': ['dispatcher'],
|
|
976
1003
|
'ticket-preparation.handback-selected': ['dispatcher'],
|
|
977
1004
|
'ticket-preparation.resolved': ['dispatcher'],
|
|
1005
|
+
'ticket.handed-back': ['dispatcher'],
|
|
1006
|
+
'ticket.handback-settled': ['dispatcher'],
|
|
978
1007
|
|
|
979
1008
|
'tickets.migration-recorded': ['human'],
|
|
980
1009
|
'change-presence.observed': ['dispatcher', 'kernel'],
|