@defrex/autobuild 1.0.0-beta.2 → 1.0.0-beta.4
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/SPEC.md +342 -23
- package/bin/ab-dispatch-generation.ts +93 -0
- package/docs/answering-blocked-builds.md +21 -3
- package/docs/architecture.md +170 -7
- package/docs/configuration.md +173 -5
- package/docs/integration-tree.md +91 -4
- package/docs/integration.md +54 -0
- package/docs/operator-api.md +58 -5
- package/docs/remote-store-protocol.md +9 -1
- package/docs/remote-ticket-protocol.md +5 -0
- package/docs/restacking.md +4 -1
- package/docs/setup.md +24 -0
- package/docs/spec-standard.md +94 -5
- package/docs/ticket-migration.md +50 -4
- package/package.json +3 -3
- package/packages/core/src/cli/artifact.ts +5 -4
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary-direct.ts +190 -0
- package/packages/core/src/cli/binary-lifecycle.ts +46 -0
- package/packages/core/src/cli/binary.ts +24 -210
- package/packages/core/src/cli/build-control.ts +108 -5
- package/packages/core/src/cli/context.ts +41 -1
- package/packages/core/src/cli/dashboard/hand-pushed.ts +24 -0
- package/packages/core/src/cli/dashboard/handoff.ts +64 -0
- package/packages/core/src/cli/dashboard/integration-detail.ts +11 -6
- package/packages/core/src/cli/dashboard/integration-row.ts +15 -8
- package/packages/core/src/cli/dashboard/model.ts +41 -10
- package/packages/core/src/cli/dashboard/render.ts +24 -2
- package/packages/core/src/cli/dashboard/rollback.ts +30 -0
- package/packages/core/src/cli/dispatch-args.ts +53 -0
- package/packages/core/src/cli/dispatch-crash-budget.ts +15 -0
- package/packages/core/src/cli/dispatch-frontend.ts +57 -5
- package/packages/core/src/cli/dispatch-handoff.ts +276 -0
- package/packages/core/src/cli/dispatch-launch-contract.ts +170 -0
- package/packages/core/src/cli/dispatch-launcher.ts +580 -0
- package/packages/core/src/cli/dispatch-parent-watch.ts +44 -0
- package/packages/core/src/cli/dispatch-preflight.ts +272 -0
- package/packages/core/src/cli/dispatch-presentation-job.ts +46 -0
- package/packages/core/src/cli/dispatch-presentation-ownership.ts +9 -0
- package/packages/core/src/cli/dispatch-process.ts +22 -90
- package/packages/core/src/cli/dispatch-readiness.ts +47 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +6 -1
- package/packages/core/src/cli/dispatch-runtime-cache.ts +522 -0
- package/packages/core/src/cli/dispatch-runtime-dependencies.ts +291 -0
- package/packages/core/src/cli/dispatch-runtime-use.ts +336 -0
- package/packages/core/src/cli/dispatch-upgrade-controller.ts +221 -0
- package/packages/core/src/cli/dispatch-upgrade-install.ts +258 -0
- package/packages/core/src/cli/dispatch-upgrade-source.ts +309 -0
- package/packages/core/src/cli/dispatch-upgrade-target.ts +190 -0
- package/packages/core/src/cli/dispatch.ts +609 -60
- package/packages/core/src/cli/dispatcher-liveness.ts +1 -1
- package/packages/core/src/cli/harvest.ts +28 -11
- package/packages/core/src/cli/help.ts +7 -3
- package/packages/core/src/cli/installation.ts +5 -3
- package/packages/core/src/cli/main-checkout.ts +59 -0
- package/packages/core/src/cli/main.ts +26 -53
- package/packages/core/src/cli/node-verification-provenance.ts +97 -0
- package/packages/core/src/cli/repo-state.ts +3 -58
- package/packages/core/src/cli/repository-status.ts +74 -4
- package/packages/core/src/cli/runtime-spawn.ts +16 -0
- package/packages/core/src/cli/status.ts +57 -3
- package/packages/core/src/cli/ticket.ts +35 -11
- package/packages/core/src/cli/upgrade-followup.ts +25 -0
- package/packages/core/src/cli/wait.ts +3 -0
- package/packages/core/src/cli/watch.ts +7 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/schema.ts +8 -4
- package/packages/core/src/distribution-packaging.ts +116 -0
- package/packages/core/src/events/catalog.ts +6 -0
- package/packages/core/src/events/payloads.ts +55 -9
- package/packages/core/src/events/policy.ts +26 -0
- package/packages/core/src/events/repository.ts +205 -4
- package/packages/core/src/events/runtime.ts +16 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +6537 -4053
- package/packages/core/src/kernel/change-presence.ts +7 -1
- package/packages/core/src/kernel/dispatch-capacity.ts +12 -4
- package/packages/core/src/kernel/dispatch-drain-recovery.ts +121 -0
- package/packages/core/src/kernel/dispatch-status.ts +4 -2
- package/packages/core/src/kernel/dispatch-upgrade.ts +171 -0
- package/packages/core/src/kernel/dispatcher-liveness.ts +7 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +82 -0
- package/packages/core/src/kernel/guarded-forge.ts +1 -1
- package/packages/core/src/kernel/harvest.ts +98 -4
- package/packages/core/src/kernel/integration-attention.ts +20 -0
- package/packages/core/src/kernel/integration-completeness.ts +54 -16
- package/packages/core/src/kernel/integration-state.ts +80 -11
- package/packages/core/src/kernel/landing-readiness.ts +6 -1
- package/packages/core/src/kernel/mixed-version.ts +34 -0
- package/packages/core/src/kernel/node-parent.ts +35 -10
- package/packages/core/src/kernel/node-polling.ts +160 -0
- package/packages/core/src/kernel/read-facts.ts +47 -5
- package/packages/core/src/kernel/reducer-registry.ts +6 -0
- package/packages/core/src/kernel/reducer.ts +75 -14
- package/packages/core/src/kernel/service-facts.ts +11 -4
- package/packages/core/src/kernel/ticket-migrations.ts +139 -0
- package/packages/core/src/operator/presentation.ts +7 -0
- package/packages/core/src/operator/query.ts +13 -3
- package/packages/core/src/operator/registry.ts +1 -1
- package/packages/core/src/operator/tickets.ts +30 -26
- package/packages/core/src/plugins/load.ts +4 -1
- package/packages/core/src/plugins/runtime-snapshot.ts +128 -0
- package/packages/core/src/ports/forge/contract.ts +29 -0
- package/packages/core/src/ports/forge/github.ts +189 -61
- package/packages/core/src/ports/forge-failure.ts +1 -0
- package/packages/core/src/ports/forge-telemetry.ts +3 -0
- package/packages/core/src/ports/runner/session-env.ts +1 -0
- package/packages/core/src/ports/tickets/linear.ts +180 -12
- package/packages/core/src/ports/tickets/migration.ts +92 -9
- package/packages/core/src/ports/types.ts +17 -0
- package/packages/core/src/ports/workspace/distribution-archive.ts +22 -149
- package/packages/core/src/ports/workspace/distribution-release.ts +56 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/local-build-execution.ts +37 -17
- package/packages/core/src/processes/build-child-exit.ts +5 -26
- package/packages/core/src/processes/build-runner.ts +81 -11
- package/packages/core/src/processes/dispatcher.ts +418 -59
- package/packages/core/src/processes/execution-no-progress.ts +6 -0
- package/packages/core/src/processes/execution-relaunch.ts +30 -0
- package/packages/core/src/processes/execution-settlement.ts +16 -7
- package/packages/core/src/processes/harvest-runner.ts +328 -292
- package/packages/core/src/processes/process-group-reaper.ts +17 -10
- package/packages/core/src/runtime-identity.ts +22 -3
- package/packages/core/src/store/contract.ts +183 -0
- package/packages/core/src/store/local/store.ts +197 -72
- package/packages/core/src/store/reduced-reads.ts +8 -0
- package/packages/core/src/store/reducer-value-shapes.json +8915 -6344
- package/packages/core/src/store/remote/client.ts +43 -0
- package/packages/core/src/store/repo-state-events.ts +21 -3
- package/packages/core/src/store/types.ts +7 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +3 -2
- package/skills/guide/SKILL.md +234 -24
- package/skills/guide/references/integration-tree.md +91 -4
- package/skills/guide/references/operator-api.md +53 -4
- package/skills/guide/references/plugin-authoring.md +45 -4
- package/skills/guide/references/remote-store-protocol.md +9 -1
- package/skills/guide/references/remote-ticket-protocol.md +5 -0
- package/skills/guide/references/restacking.md +4 -1
- package/skills/guide/references/setup.md +24 -0
- package/skills/guide/references/spec-standard.md +94 -5
- package/skills/guide/references/ticket-migration.md +50 -4
- package/skills/harvest/SKILL.md +4 -0
- package/skills/harvest-review/SKILL.md +4 -0
- package/skills/operate/SKILL.md +78 -8
- package/skills/spec/SKILL.md +35 -5
- package/skills/tickets/SKILL.md +19 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { runtimeIdentitySchema } from './runtime'
|
|
2
|
+
import { viaSchema } from './envelope'
|
|
1
3
|
import { nativeSessionHandleSchema } from './native-session'
|
|
2
4
|
/**
|
|
3
5
|
* The event vocabulary (SPEC §15.3), frozen as schemas — this closes open
|
|
@@ -438,6 +440,7 @@ export const eventPayloadSchemas = {
|
|
|
438
440
|
}),
|
|
439
441
|
'integration.abandoned': z.strictObject({ id: z.string().min(1), reason: z.string().min(1) }),
|
|
440
442
|
'integration.observed': z.strictObject({
|
|
443
|
+
membershipSource: z.string().optional(),
|
|
441
444
|
openChildren: z.array(z.string()),
|
|
442
445
|
diagnostics: z.array(z.string()),
|
|
443
446
|
contributions: z.array(z.string()),
|
|
@@ -448,10 +451,21 @@ export const eventPayloadSchemas = {
|
|
|
448
451
|
id: z.string(),
|
|
449
452
|
title: z.string().optional(),
|
|
450
453
|
builds: z.array(z.string()).optional(),
|
|
454
|
+
claims: z.array(z.string()).optional(),
|
|
451
455
|
}),
|
|
452
456
|
)
|
|
453
457
|
.optional(),
|
|
454
458
|
}),
|
|
459
|
+
'integration.verification-failed': z.strictObject({
|
|
460
|
+
id: z.string().trim().min(1),
|
|
461
|
+
head: z.string().trim().min(1),
|
|
462
|
+
parent: z.string().trim().min(1),
|
|
463
|
+
steps: z
|
|
464
|
+
.array(z.string().trim().min(1))
|
|
465
|
+
.min(1)
|
|
466
|
+
.refine((steps) => new Set(steps).size === steps.length, 'failed steps must be unique'),
|
|
467
|
+
guidance: z.string().trim().min(1),
|
|
468
|
+
}),
|
|
455
469
|
'integration.prepared': z.strictObject({
|
|
456
470
|
id: z.string().min(1),
|
|
457
471
|
head: z.string().min(1),
|
|
@@ -487,6 +501,12 @@ export const eventPayloadSchemas = {
|
|
|
487
501
|
landedTree: z.string().min(1),
|
|
488
502
|
identities: z.array(z.string()),
|
|
489
503
|
}),
|
|
504
|
+
'node.poll-checked': z.strictObject({
|
|
505
|
+
activityKey: z.string().min(1),
|
|
506
|
+
unchangedSince: z.iso.datetime(),
|
|
507
|
+
nodeIdleAfterSeconds: z.number().int().positive(),
|
|
508
|
+
nodeIdlePollSeconds: z.number().int().positive(),
|
|
509
|
+
}),
|
|
490
510
|
'node.compared': z.strictObject({
|
|
491
511
|
parentSha: z.string().min(1),
|
|
492
512
|
headSha: z.string().min(1),
|
|
@@ -500,6 +520,11 @@ export const eventPayloadSchemas = {
|
|
|
500
520
|
}),
|
|
501
521
|
}),
|
|
502
522
|
'build.completed': z.strictObject({ outcome: buildOutcomeSchema }),
|
|
523
|
+
'runner.runtime-recorded': z.strictObject({
|
|
524
|
+
instance: z.string().min(1),
|
|
525
|
+
attachedSeq: z.number().int().positive(),
|
|
526
|
+
runtime: runtimeIdentitySchema,
|
|
527
|
+
}),
|
|
503
528
|
'runner.attached': z.strictObject({
|
|
504
529
|
instance: z.string().min(1),
|
|
505
530
|
host: z.string().min(1),
|
|
@@ -546,6 +571,23 @@ export const eventPayloadSchemas = {
|
|
|
546
571
|
}),
|
|
547
572
|
/** Dispatcher-owned identity and provider lifecycle evidence. These facts do
|
|
548
573
|
* not carry pipeline progress; they make disposable execution observable. */
|
|
574
|
+
'execution.relaunch-requested': z.strictObject({
|
|
575
|
+
instance: z.string().min(1),
|
|
576
|
+
correlation: z.string().min(1),
|
|
577
|
+
from: runtimeIdentitySchema,
|
|
578
|
+
to: runtimeIdentitySchema,
|
|
579
|
+
}),
|
|
580
|
+
'execution.drain-authorized': z.strictObject({
|
|
581
|
+
targetRuntime: runtimeIdentitySchema.optional(),
|
|
582
|
+
correlation: z.string().min(1),
|
|
583
|
+
run: z.string().min(1),
|
|
584
|
+
runtime: runtimeIdentitySchema,
|
|
585
|
+
instance: z.string().min(1),
|
|
586
|
+
}),
|
|
587
|
+
'execution.drain-settled': z.strictObject({
|
|
588
|
+
correlation: z.string().min(1),
|
|
589
|
+
instance: z.string().min(1),
|
|
590
|
+
}),
|
|
549
591
|
'execution.started': z.strictObject({
|
|
550
592
|
provider: z.string().min(1),
|
|
551
593
|
workspaceRef: z.string().min(1),
|
|
@@ -561,7 +603,7 @@ export const eventPayloadSchemas = {
|
|
|
561
603
|
'execution.ended': z.strictObject({
|
|
562
604
|
instance: z.string().min(1),
|
|
563
605
|
workspaceRef: z.string().min(1),
|
|
564
|
-
outcome: z.enum(['completed', 'stopped', 'lost']),
|
|
606
|
+
outcome: z.enum(['completed', 'stopped', 'lost', 'relaunch']),
|
|
565
607
|
exitCode: z.number().int().nullable().optional(),
|
|
566
608
|
}),
|
|
567
609
|
'infrastructure.failed': z.strictObject({
|
|
@@ -748,14 +790,18 @@ export const eventPayloadSchemas = {
|
|
|
748
790
|
artifact: artifactRefSchema,
|
|
749
791
|
session: z.string().min(1),
|
|
750
792
|
}),
|
|
751
|
-
'spec.revised': z.
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
793
|
+
'spec.revised': z.union([
|
|
794
|
+
z.strictObject({
|
|
795
|
+
artifact: artifactRefSchema,
|
|
796
|
+
escalation: z.number().int().positive(),
|
|
797
|
+
assets: z.array(pinnedAssetSchema).optional(),
|
|
798
|
+
}),
|
|
799
|
+
z.strictObject({
|
|
800
|
+
artifact: artifactRefSchema,
|
|
801
|
+
operator: z.strictObject({ user: z.string().min(1), via: viaSchema.optional() }),
|
|
802
|
+
assets: z.array(pinnedAssetSchema).optional(),
|
|
803
|
+
}),
|
|
804
|
+
]),
|
|
759
805
|
|
|
760
806
|
// ── Sessions (every agent run is bracketed by these) ──────────────────────
|
|
761
807
|
'session.started': z.strictObject({
|
|
@@ -34,9 +34,11 @@ export const buildEventPolicy = {
|
|
|
34
34
|
'integration.prepared': 'decisive',
|
|
35
35
|
'integration.landing-intended': 'decisive',
|
|
36
36
|
'integration.landed': 'decisive',
|
|
37
|
+
'integration.verification-failed': 'decisive',
|
|
37
38
|
'integration.audited': 'decisive',
|
|
38
39
|
'node.restack-requested': 'decisive',
|
|
39
40
|
'node.restack-satisfied': 'decisive',
|
|
41
|
+
'node.poll-checked': 'advisory',
|
|
40
42
|
'node.parent-distance': 'advisory',
|
|
41
43
|
'node.parent-requested': 'decisive',
|
|
42
44
|
'node.parent-accepted': 'decisive',
|
|
@@ -60,11 +62,15 @@ export const buildEventPolicy = {
|
|
|
60
62
|
'pr.opened': 'decisive',
|
|
61
63
|
'build.created': 'decisive',
|
|
62
64
|
'build.completed': 'decisive',
|
|
65
|
+
'runner.runtime-recorded': 'advisory',
|
|
63
66
|
'runner.attached': 'decisive',
|
|
64
67
|
'runner.setup-failed': 'decisive',
|
|
65
68
|
'workspace.provisioned': 'decisive',
|
|
66
69
|
'workspace.provision-started': 'decisive',
|
|
67
70
|
'workspace.released': 'decisive',
|
|
71
|
+
'execution.relaunch-requested': 'decisive',
|
|
72
|
+
'execution.drain-authorized': 'decisive',
|
|
73
|
+
'execution.drain-settled': 'decisive',
|
|
68
74
|
'execution.started': 'decisive',
|
|
69
75
|
'execution.ended': 'decisive',
|
|
70
76
|
'infrastructure.failed': 'decisive',
|
|
@@ -140,6 +146,7 @@ export const buildEventPolicy = {
|
|
|
140
146
|
'phase.deferral-escalated': 'decisive',
|
|
141
147
|
} satisfies Record<EventType, FactClassification>
|
|
142
148
|
export const repositoryEventPolicy = {
|
|
149
|
+
'tickets.migration-recorded': 'decisive',
|
|
143
150
|
'change-presence.observed': 'decisive',
|
|
144
151
|
'harvest.pause-requested': 'decisive',
|
|
145
152
|
'harvest.resume-requested': 'decisive',
|
|
@@ -156,6 +163,11 @@ export const repositoryEventPolicy = {
|
|
|
156
163
|
'harvest.step.completed': 'decisive',
|
|
157
164
|
'harvest.session.started': 'decisive',
|
|
158
165
|
'harvest.session.ended': 'decisive',
|
|
166
|
+
'harvest.session.native-handle-recorded': 'decisive',
|
|
167
|
+
'harvest.session.suspended': 'decisive',
|
|
168
|
+
'harvest.session.resumed': 'decisive',
|
|
169
|
+
'harvest.session.resume-fallback': 'decisive',
|
|
170
|
+
|
|
159
171
|
'harvest.proposals.submitted': 'decisive',
|
|
160
172
|
'harvest.review.verdict': 'decisive',
|
|
161
173
|
'harvest.proposal.id-reserved': 'decisive',
|
|
@@ -171,6 +183,20 @@ export const repositoryEventPolicy = {
|
|
|
171
183
|
'orchestrator.sandbox.reset': 'decisive',
|
|
172
184
|
'orchestrator.sandbox.published': 'decisive',
|
|
173
185
|
'orchestrator.sandbox.publish-failed': 'decisive',
|
|
186
|
+
'dispatcher.upgrade-target-resolved': 'advisory',
|
|
187
|
+
'dispatcher.target-prepared': 'decisive',
|
|
188
|
+
'dispatcher.yield-requested': 'decisive',
|
|
189
|
+
'dispatcher.terminal-released': 'decisive',
|
|
190
|
+
'dispatcher.takeover': 'decisive',
|
|
191
|
+
'dispatcher.drain-settled': 'decisive',
|
|
192
|
+
'dispatcher.drain-deadline': 'decisive',
|
|
193
|
+
'dispatcher.upgrade-detected': 'advisory',
|
|
194
|
+
'dispatcher.upgrade-failed': 'decisive',
|
|
195
|
+
'dispatcher.runtime-rolled-back': 'decisive',
|
|
196
|
+
'dispatcher.rollback-hold-cleared': 'decisive',
|
|
197
|
+
'dispatcher.handoff-started': 'decisive',
|
|
198
|
+
'dispatcher.handoff-completed': 'decisive',
|
|
199
|
+
'dispatcher.runtime-recorded': 'advisory',
|
|
174
200
|
'dispatcher.run-started': 'decisive',
|
|
175
201
|
'dispatcher.stop-requested': 'decisive',
|
|
176
202
|
'dispatcher.run-stopped': 'decisive',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { nativeSessionHandleSchema } from './native-session'
|
|
2
|
+
import { runtimeIdentitySchema } from './runtime'
|
|
1
3
|
import { stampCompatibility, type CompatibilityMetadata, repositoryEventPolicy } from './policy'
|
|
2
4
|
import { hardReadinessKeys } from '../ports/forge/readiness'
|
|
3
5
|
/**
|
|
@@ -28,7 +30,7 @@ import {
|
|
|
28
30
|
type ActorKind,
|
|
29
31
|
} from './envelope'
|
|
30
32
|
import { EventValidationError } from './catalog'
|
|
31
|
-
import {
|
|
33
|
+
import { providerAttemptSchema } from './payloads'
|
|
32
34
|
|
|
33
35
|
const round = z.number().int().positive()
|
|
34
36
|
const attempt = z.number().int().positive()
|
|
@@ -117,6 +119,27 @@ const restartRequiredConfigPathsSchema = z
|
|
|
117
119
|
})
|
|
118
120
|
})
|
|
119
121
|
|
|
122
|
+
const upgradeTargetSchema = z.strictObject({
|
|
123
|
+
mode: z.enum(['pinned', 'installed', 'source']),
|
|
124
|
+
key: z.string().min(1),
|
|
125
|
+
source: z.string().min(1),
|
|
126
|
+
version: z.string().optional(),
|
|
127
|
+
base: z.string().optional(),
|
|
128
|
+
sha: z.string().optional(),
|
|
129
|
+
})
|
|
130
|
+
const upgradeIdentitySchema = z.strictObject({
|
|
131
|
+
correlation: z.string().min(1),
|
|
132
|
+
run: dispatchRun,
|
|
133
|
+
lineage: z.string().min(1),
|
|
134
|
+
from: runtimeIdentitySchema,
|
|
135
|
+
target: upgradeTargetSchema,
|
|
136
|
+
})
|
|
137
|
+
const handoffSchema = upgradeIdentitySchema.extend({
|
|
138
|
+
to: runtimeIdentitySchema,
|
|
139
|
+
root: z.string().min(1),
|
|
140
|
+
cacheId: z.string().min(1),
|
|
141
|
+
})
|
|
142
|
+
|
|
120
143
|
export const harvestEventPayloadSchemas = {
|
|
121
144
|
// Repository-wide operator control. Requests are human commands; paused /
|
|
122
145
|
// resumed are kernel acknowledgements made only at workflow boundaries.
|
|
@@ -202,7 +225,54 @@ export const harvestEventPayloadSchemas = {
|
|
|
202
225
|
artifact: artifactRefSchema.optional(),
|
|
203
226
|
detail: z.string().optional(),
|
|
204
227
|
}),
|
|
228
|
+
'harvest.session.native-handle-recorded': z.strictObject({
|
|
229
|
+
run: z.string().min(1),
|
|
230
|
+
session: z.string().min(1),
|
|
231
|
+
handle: nativeSessionHandleSchema,
|
|
232
|
+
}),
|
|
233
|
+
'harvest.session.suspended': z.strictObject({
|
|
234
|
+
run: z.string().min(1),
|
|
235
|
+
session: z.string().min(1),
|
|
236
|
+
cause: z.enum(['shutdown', 'cutover']),
|
|
237
|
+
transcript: artifactRefSchema,
|
|
238
|
+
usage: z
|
|
239
|
+
.strictObject({
|
|
240
|
+
inputTokens: z.number().int().nonnegative(),
|
|
241
|
+
outputTokens: z.number().int().nonnegative(),
|
|
242
|
+
turns: z.number().int().nonnegative(),
|
|
243
|
+
})
|
|
244
|
+
.optional(),
|
|
245
|
+
}),
|
|
246
|
+
'harvest.session.resumed': z.strictObject({
|
|
247
|
+
run: z.string().min(1),
|
|
248
|
+
session: z.string().min(1),
|
|
249
|
+
predecessor: z.string().min(1),
|
|
250
|
+
root: z.string().min(1),
|
|
251
|
+
handle: nativeSessionHandleSchema,
|
|
252
|
+
}),
|
|
253
|
+
'harvest.session.resume-fallback': z.strictObject({
|
|
254
|
+
run: z.string().min(1),
|
|
255
|
+
session: z.string().min(1),
|
|
256
|
+
reason: z.enum([
|
|
257
|
+
'missing-handle',
|
|
258
|
+
'changed-route',
|
|
259
|
+
'unsupported',
|
|
260
|
+
'wrong-runner',
|
|
261
|
+
'wrong-host',
|
|
262
|
+
'wrong-workspace',
|
|
263
|
+
'missing-state',
|
|
264
|
+
]),
|
|
265
|
+
message: z.string().min(1),
|
|
266
|
+
}),
|
|
205
267
|
'harvest.session.started': z.strictObject({
|
|
268
|
+
continuation: z
|
|
269
|
+
.strictObject({
|
|
270
|
+
predecessor: z.string().min(1),
|
|
271
|
+
root: z.string().min(1),
|
|
272
|
+
handle: nativeSessionHandleSchema.optional(),
|
|
273
|
+
cause: z.enum(['shutdown', 'cutover', 'runner-loss']),
|
|
274
|
+
})
|
|
275
|
+
.optional(),
|
|
206
276
|
run: z.string().min(1),
|
|
207
277
|
session: z.string().min(1),
|
|
208
278
|
role: z.enum(['harvest', 'harvest-review']),
|
|
@@ -215,7 +285,16 @@ export const harvestEventPayloadSchemas = {
|
|
|
215
285
|
/** Stream id this session's live view writes to (SPEC §9, session
|
|
216
286
|
* streams). Optional only so historical journals replay unchanged. */
|
|
217
287
|
stream: z.string().min(1).optional(),
|
|
218
|
-
|
|
288
|
+
// Native continuation can try a configured alternate before index zero.
|
|
289
|
+
substitution: z
|
|
290
|
+
.strictObject({
|
|
291
|
+
failed: providerAttemptSchema,
|
|
292
|
+
selectedIndex: z.number().int().nonnegative(),
|
|
293
|
+
})
|
|
294
|
+
.refine((value) => value.selectedIndex !== value.failed.index, {
|
|
295
|
+
message: 'substitution must select a different configured target',
|
|
296
|
+
})
|
|
297
|
+
.optional(),
|
|
219
298
|
}),
|
|
220
299
|
'harvest.session.ended': z.strictObject({
|
|
221
300
|
run: z.string().min(1),
|
|
@@ -275,7 +354,14 @@ export const harvestEventPayloadSchemas = {
|
|
|
275
354
|
attempt,
|
|
276
355
|
error: z.string().min(1),
|
|
277
356
|
willRetry: z.boolean(),
|
|
278
|
-
providerAttempts:
|
|
357
|
+
providerAttempts: z
|
|
358
|
+
.array(providerAttemptSchema)
|
|
359
|
+
.min(1)
|
|
360
|
+
.refine(
|
|
361
|
+
(attempts) => new Set(attempts.map((attempt) => attempt.index)).size === attempts.length,
|
|
362
|
+
{ message: 'provider attempts must name distinct configured targets' },
|
|
363
|
+
)
|
|
364
|
+
.optional(),
|
|
279
365
|
}),
|
|
280
366
|
} as const
|
|
281
367
|
|
|
@@ -386,8 +472,83 @@ export const dispatcherStatusEventPayloadSchemas = {
|
|
|
386
472
|
}),
|
|
387
473
|
/** A terminal frontend follows exactly one run. The referenced artifact is
|
|
388
474
|
* the composed Config the kernel is actually using, never an on-disk guess. */
|
|
475
|
+
'dispatcher.upgrade-target-resolved': z.strictObject({
|
|
476
|
+
run: dispatchRun,
|
|
477
|
+
lineage: z.string().min(1),
|
|
478
|
+
target: upgradeTargetSchema,
|
|
479
|
+
}),
|
|
480
|
+
'dispatcher.target-prepared': handoffSchema,
|
|
481
|
+
'dispatcher.yield-requested': handoffSchema.extend({
|
|
482
|
+
successor: dispatchRun,
|
|
483
|
+
mode: z.enum(['drain', 'cutover']),
|
|
484
|
+
evidence: z.string().min(1),
|
|
485
|
+
}),
|
|
486
|
+
'dispatcher.terminal-released': handoffSchema,
|
|
487
|
+
'dispatcher.takeover': handoffSchema.extend({ successor: dispatchRun }),
|
|
488
|
+
'dispatcher.drain-settled': handoffSchema.extend({
|
|
489
|
+
slug: z.string().min(1),
|
|
490
|
+
instance: z.string().min(1),
|
|
491
|
+
outcome: z.enum(['drained', 'suspended', 'unknown']),
|
|
492
|
+
}),
|
|
493
|
+
'dispatcher.drain-deadline': handoffSchema.extend({ deadline: z.iso.datetime() }),
|
|
494
|
+
'dispatcher.upgrade-detected': upgradeIdentitySchema,
|
|
495
|
+
'dispatcher.upgrade-failed': upgradeIdentitySchema.extend({ reason: z.string().min(1) }),
|
|
496
|
+
'dispatcher.runtime-rolled-back': z.strictObject({
|
|
497
|
+
correlation: dispatchRun,
|
|
498
|
+
run: dispatchRun,
|
|
499
|
+
lineage: dispatchRun,
|
|
500
|
+
predecessor: dispatchRun,
|
|
501
|
+
successor: dispatchRun,
|
|
502
|
+
handoff: dispatchRun,
|
|
503
|
+
takeoverAt: z.iso.datetime(),
|
|
504
|
+
failures: z.literal(3),
|
|
505
|
+
failed: runtimeIdentitySchema,
|
|
506
|
+
restored: runtimeIdentitySchema,
|
|
507
|
+
failedRoot: z.string().min(1),
|
|
508
|
+
restoredRoot: z.string().min(1),
|
|
509
|
+
target: upgradeTargetSchema,
|
|
510
|
+
reason: z.string().min(1),
|
|
511
|
+
}),
|
|
512
|
+
'dispatcher.rollback-hold-cleared': z.strictObject({
|
|
513
|
+
correlation: dispatchRun,
|
|
514
|
+
run: dispatchRun,
|
|
515
|
+
lineage: dispatchRun,
|
|
516
|
+
target: upgradeTargetSchema,
|
|
517
|
+
}),
|
|
518
|
+
'dispatcher.handoff-started': handoffSchema.extend({
|
|
519
|
+
remoteBuilds: z
|
|
520
|
+
.array(
|
|
521
|
+
z.strictObject({
|
|
522
|
+
slug: z.string().min(1),
|
|
523
|
+
instance: z.string().min(1),
|
|
524
|
+
runtime: runtimeIdentitySchema.optional(),
|
|
525
|
+
}),
|
|
526
|
+
)
|
|
527
|
+
.optional(),
|
|
528
|
+
successor: dispatchRun.optional(),
|
|
529
|
+
mode: z.enum(['drain', 'cutover']).optional(),
|
|
530
|
+
startedAt: z.iso.datetime().optional(),
|
|
531
|
+
deadline: z.iso.datetime().optional(),
|
|
532
|
+
builds: z
|
|
533
|
+
.array(z.strictObject({ slug: z.string().min(1), instance: z.string().min(1) }))
|
|
534
|
+
.optional(),
|
|
535
|
+
}),
|
|
536
|
+
'dispatcher.handoff-completed': handoffSchema.extend({
|
|
537
|
+
successor: dispatchRun,
|
|
538
|
+
mode: z.enum(['drain', 'cutover']).optional(),
|
|
539
|
+
startedAt: z.iso.datetime().optional(),
|
|
540
|
+
endedAt: z.iso.datetime().optional(),
|
|
541
|
+
drained: z.number().int().nonnegative().optional(),
|
|
542
|
+
suspended: z.number().int().nonnegative().optional(),
|
|
543
|
+
}),
|
|
544
|
+
'dispatcher.runtime-recorded': z.strictObject({
|
|
545
|
+
run: dispatchRun,
|
|
546
|
+
startedSeq: z.number().int().positive(),
|
|
547
|
+
runtime: runtimeIdentitySchema,
|
|
548
|
+
}),
|
|
389
549
|
'dispatcher.run-started': z.strictObject({
|
|
390
550
|
run: dispatchRun,
|
|
551
|
+
lineage: dispatchRun.optional(),
|
|
391
552
|
pid: z.number().int().positive(),
|
|
392
553
|
host: z.string().trim().min(1).optional(),
|
|
393
554
|
effectiveConfig: artifactRefSchema,
|
|
@@ -447,7 +608,7 @@ export const dispatcherStatusEventPayloadSchemas = {
|
|
|
447
608
|
'dispatcher.runner-settled': z.strictObject({
|
|
448
609
|
run: dispatchRun,
|
|
449
610
|
slug: z.string().min(1),
|
|
450
|
-
outcome: z.enum(['parked', 'lease-held', 'launch-failed', 'failed']),
|
|
611
|
+
outcome: z.enum(['parked', 'lease-held', 'launch-failed', 'failed', 'relaunch']),
|
|
451
612
|
status: z.string().min(1).optional(),
|
|
452
613
|
error: z.string().min(1).optional(),
|
|
453
614
|
}),
|
|
@@ -546,7 +707,27 @@ export const forgeHealthEventPayloadSchemas = {
|
|
|
546
707
|
'dispatcher.forge-recovered': z.strictObject({ forge: z.string().min(1) }),
|
|
547
708
|
} as const
|
|
548
709
|
|
|
710
|
+
export const ticketMigrationEventPayloadSchemas = {
|
|
711
|
+
'tickets.migration-recorded': z
|
|
712
|
+
.strictObject({
|
|
713
|
+
identity: z.string().min(1),
|
|
714
|
+
from: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
715
|
+
to: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
716
|
+
mapping: z.record(z.string().min(1), z.string().min(1)),
|
|
717
|
+
})
|
|
718
|
+
.superRefine((value, ctx) => {
|
|
719
|
+
if (
|
|
720
|
+
value.from === value.to &&
|
|
721
|
+
Object.entries(value.mapping).some(([id, next]) => id !== next)
|
|
722
|
+
)
|
|
723
|
+
ctx.addIssue({ code: 'custom', message: 'migration sources must differ' })
|
|
724
|
+
if (new Set(Object.values(value.mapping)).size !== Object.keys(value.mapping).length)
|
|
725
|
+
ctx.addIssue({ code: 'custom', message: 'duplicate destination ticket id' })
|
|
726
|
+
}),
|
|
727
|
+
} as const
|
|
728
|
+
|
|
549
729
|
export const repositoryEventPayloadSchemas = {
|
|
730
|
+
...ticketMigrationEventPayloadSchemas,
|
|
550
731
|
...forgeHealthEventPayloadSchemas,
|
|
551
732
|
...changePresenceEventPayloadSchemas,
|
|
552
733
|
...ticketSourceHealthEventPayloadSchemas,
|
|
@@ -613,6 +794,7 @@ export type HarvestEventWrite<T extends HarvestEventType = HarvestEventType> =
|
|
|
613
794
|
export const HARVEST_EVENT_TYPES = Object.keys(harvestEventPayloadSchemas) as HarvestEventType[]
|
|
614
795
|
|
|
615
796
|
const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
797
|
+
'tickets.migration-recorded': ['human'],
|
|
616
798
|
'change-presence.observed': ['dispatcher', 'kernel'],
|
|
617
799
|
'harvest.pause-requested': ['human'],
|
|
618
800
|
'harvest.resume-requested': ['human'],
|
|
@@ -629,6 +811,11 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
|
629
811
|
'harvest.step.completed': ['kernel'],
|
|
630
812
|
'harvest.session.started': ['kernel'],
|
|
631
813
|
'harvest.session.ended': ['kernel'],
|
|
814
|
+
'harvest.session.native-handle-recorded': ['kernel'],
|
|
815
|
+
'harvest.session.suspended': ['kernel'],
|
|
816
|
+
'harvest.session.resumed': ['kernel'],
|
|
817
|
+
'harvest.session.resume-fallback': ['kernel'],
|
|
818
|
+
|
|
632
819
|
'harvest.proposals.submitted': ['agent'],
|
|
633
820
|
'harvest.review.verdict': ['agent'],
|
|
634
821
|
'harvest.proposal.id-reserved': ['kernel'],
|
|
@@ -648,6 +835,20 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
|
648
835
|
'orchestrator.sandbox.reset': ['human'],
|
|
649
836
|
'orchestrator.sandbox.published': ['human'],
|
|
650
837
|
'orchestrator.sandbox.publish-failed': ['human'],
|
|
838
|
+
'dispatcher.upgrade-target-resolved': ['dispatcher'],
|
|
839
|
+
'dispatcher.target-prepared': ['dispatcher'],
|
|
840
|
+
'dispatcher.yield-requested': ['dispatcher'],
|
|
841
|
+
'dispatcher.terminal-released': ['dispatcher'],
|
|
842
|
+
'dispatcher.takeover': ['dispatcher'],
|
|
843
|
+
'dispatcher.drain-settled': ['dispatcher'],
|
|
844
|
+
'dispatcher.drain-deadline': ['dispatcher'],
|
|
845
|
+
'dispatcher.upgrade-detected': ['dispatcher'],
|
|
846
|
+
'dispatcher.upgrade-failed': ['dispatcher'],
|
|
847
|
+
'dispatcher.runtime-rolled-back': ['dispatcher'],
|
|
848
|
+
'dispatcher.rollback-hold-cleared': ['dispatcher'],
|
|
849
|
+
'dispatcher.handoff-started': ['dispatcher'],
|
|
850
|
+
'dispatcher.handoff-completed': ['dispatcher'],
|
|
851
|
+
'dispatcher.runtime-recorded': ['dispatcher'],
|
|
651
852
|
'dispatcher.run-started': ['dispatcher'],
|
|
652
853
|
'dispatcher.stop-requested': ['dispatcher'],
|
|
653
854
|
'dispatcher.run-stopped': ['dispatcher'],
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const runtimeIdentitySchema = z.strictObject({
|
|
4
|
+
version: z.string().trim().min(1),
|
|
5
|
+
commit: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64}|unknown)$/),
|
|
6
|
+
source: z.strictObject({
|
|
7
|
+
kind: z.enum(['source', 'package']),
|
|
8
|
+
location: z.string().trim().min(1),
|
|
9
|
+
}),
|
|
10
|
+
})
|
|
11
|
+
export type RuntimeIdentity = z.infer<typeof runtimeIdentitySchema>
|
|
12
|
+
export function formatRuntimeIdentity(runtime: RuntimeIdentity | null): string {
|
|
13
|
+
return runtime === null
|
|
14
|
+
? 'runtime unrecorded'
|
|
15
|
+
: `autobuild ${runtime.version}; commit ${runtime.commit}; ${runtime.source.kind} ${runtime.source.location}`
|
|
16
|
+
}
|