@defrex/autobuild 1.0.0-beta.3 → 1.0.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 +362 -56
- package/bin/ab-dispatch-generation.ts +93 -0
- package/docs/agent-runtimes.md +157 -0
- package/docs/answering-blocked-builds.md +21 -3
- package/docs/architecture.md +166 -7
- package/docs/build-store.md +123 -0
- package/docs/builds.md +82 -0
- package/docs/cli.md +48 -0
- package/docs/configuration-overview.md +93 -0
- package/docs/configuration.md +1778 -188
- package/docs/dispatcher-hosting.md +115 -0
- package/docs/dispatcher.md +59 -0
- package/docs/forges.md +121 -0
- package/docs/getting-started.md +60 -0
- package/docs/glossary.md +60 -0
- package/docs/hosted-service.md +2 -2
- package/docs/intake.md +48 -0
- package/docs/integration-overview.md +81 -0
- package/docs/integration-tree.md +87 -2
- package/docs/integration.md +54 -0
- package/docs/operating.md +114 -0
- package/docs/operator-api.md +64 -11
- package/docs/operator-surfaces.md +90 -0
- package/docs/overview.md +49 -0
- package/docs/plugin-authoring.md +426 -0
- package/docs/remote-store-protocol.md +12 -9
- package/docs/restacking.md +4 -1
- package/docs/seams.md +66 -0
- package/docs/setup.md +28 -6
- package/docs/skills.md +119 -0
- package/docs/spec-standard.md +23 -5
- package/docs/ticket-sources.md +132 -0
- package/docs/tickets.md +69 -0
- package/docs/troubleshooting.md +111 -0
- package/docs/upgrading.md +50 -0
- package/docs/verification.md +146 -0
- package/docs/website.md +47 -5
- package/docs/workspaces.md +152 -0
- package/package.json +5 -4
- 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 +105 -2
- 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 +3 -0
- package/packages/core/src/cli/dashboard/model.ts +34 -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 +52 -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 +5 -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 +604 -60
- package/packages/core/src/cli/dispatcher-liveness.ts +1 -1
- package/packages/core/src/cli/env.ts +1 -1
- package/packages/core/src/cli/harvest.ts +28 -11
- package/packages/core/src/cli/help.ts +10 -5
- 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 +15 -45
- 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 +67 -3
- package/packages/core/src/cli/runtime-spawn.ts +16 -0
- package/packages/core/src/cli/status.ts +57 -3
- 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/landing.ts +8 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/reference-metadata.ts +31 -0
- package/packages/core/src/config/reference.ts +342 -0
- package/packages/core/src/config/roles.ts +1 -1
- package/packages/core/src/config/schema.ts +352 -10
- 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 +53 -9
- package/packages/core/src/events/policy.ts +25 -0
- package/packages/core/src/events/repository.ts +184 -4
- package/packages/core/src/events/runtime.ts +16 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +2515 -78
- 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-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-polling.ts +160 -0
- package/packages/core/src/kernel/read-facts.ts +40 -5
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer.ts +75 -14
- package/packages/core/src/kernel/service-facts.ts +11 -4
- package/packages/core/src/ontology.ts +2 -2
- package/packages/core/src/open-map.ts +3 -1
- package/packages/core/src/operator/presentation.ts +7 -0
- package/packages/core/src/operator/query.ts +6 -2
- package/packages/core/src/operator/registry.ts +1 -1
- 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/types.ts +10 -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 +254 -23
- 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 +153 -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 +5783 -3305
- package/packages/core/src/store/remote/client.ts +43 -0
- package/packages/core/src/store/repo-state-events.ts +20 -3
- package/packages/core/src/store/types.ts +7 -0
- package/skills/finalize/SKILL.md +3 -1
- package/skills/guide/SKILL.md +273 -48
- package/skills/guide/references/integration-tree.md +87 -2
- package/skills/guide/references/operator-api.md +71 -14
- package/skills/guide/references/plugin-authoring.md +231 -266
- package/skills/guide/references/remote-store-protocol.md +12 -9
- package/skills/guide/references/restacking.md +4 -1
- package/skills/guide/references/setup.md +28 -6
- package/skills/guide/references/spec-standard.md +23 -5
- package/skills/harvest/SKILL.md +4 -0
- package/skills/harvest-review/SKILL.md +4 -0
- package/skills/implement/SKILL.md +4 -2
- package/skills/operate/SKILL.md +104 -35
- package/skills/plan/SKILL.md +12 -4
- package/skills/spec/SKILL.md +20 -2
- package/skills/tickets/SKILL.md +20 -1
- package/templates/hosted-service/package.json +2 -2
|
@@ -67,6 +67,7 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
67
67
|
'integration.prepared': ['kernel', 'dispatcher'],
|
|
68
68
|
'integration.landing-intended': ['kernel', 'dispatcher'],
|
|
69
69
|
'integration.landed': ['kernel', 'dispatcher'],
|
|
70
|
+
'integration.verification-failed': ['kernel', 'dispatcher'],
|
|
70
71
|
'integration.audited': ['kernel', 'dispatcher'],
|
|
71
72
|
'node.restack-requested': ['dispatcher', 'human'],
|
|
72
73
|
'node.restack-satisfied': ['kernel', 'dispatcher'],
|
|
@@ -89,15 +90,20 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
89
90
|
'node.contribution-recorded': ['kernel', 'dispatcher'],
|
|
90
91
|
'node.inventory': ['kernel', 'dispatcher'],
|
|
91
92
|
'node.opened': ['dispatcher'],
|
|
93
|
+
'node.poll-checked': ['dispatcher'],
|
|
92
94
|
'node.compared': ['dispatcher'],
|
|
93
95
|
'pr.opened': ['dispatcher'],
|
|
94
96
|
'build.created': ['dispatcher', 'human'],
|
|
95
97
|
'build.completed': ['dispatcher'],
|
|
98
|
+
'runner.runtime-recorded': ['kernel'],
|
|
96
99
|
'runner.attached': ['kernel'],
|
|
97
100
|
'runner.setup-failed': ['kernel'],
|
|
98
101
|
'workspace.provisioned': ['dispatcher', 'kernel'],
|
|
99
102
|
'workspace.provision-started': ['dispatcher'],
|
|
100
103
|
'workspace.released': ['dispatcher', 'kernel'],
|
|
104
|
+
'execution.relaunch-requested': ['kernel'],
|
|
105
|
+
'execution.drain-authorized': ['dispatcher'],
|
|
106
|
+
'execution.drain-settled': ['dispatcher'],
|
|
101
107
|
'execution.started': ['dispatcher'],
|
|
102
108
|
'execution.ended': ['dispatcher'],
|
|
103
109
|
'infrastructure.failed': ['dispatcher'],
|
|
@@ -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
|
|
@@ -454,6 +456,16 @@ export const eventPayloadSchemas = {
|
|
|
454
456
|
)
|
|
455
457
|
.optional(),
|
|
456
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
|
+
}),
|
|
457
469
|
'integration.prepared': z.strictObject({
|
|
458
470
|
id: z.string().min(1),
|
|
459
471
|
head: z.string().min(1),
|
|
@@ -489,6 +501,12 @@ export const eventPayloadSchemas = {
|
|
|
489
501
|
landedTree: z.string().min(1),
|
|
490
502
|
identities: z.array(z.string()),
|
|
491
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
|
+
}),
|
|
492
510
|
'node.compared': z.strictObject({
|
|
493
511
|
parentSha: z.string().min(1),
|
|
494
512
|
headSha: z.string().min(1),
|
|
@@ -502,6 +520,11 @@ export const eventPayloadSchemas = {
|
|
|
502
520
|
}),
|
|
503
521
|
}),
|
|
504
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
|
+
}),
|
|
505
528
|
'runner.attached': z.strictObject({
|
|
506
529
|
instance: z.string().min(1),
|
|
507
530
|
host: z.string().min(1),
|
|
@@ -548,6 +571,23 @@ export const eventPayloadSchemas = {
|
|
|
548
571
|
}),
|
|
549
572
|
/** Dispatcher-owned identity and provider lifecycle evidence. These facts do
|
|
550
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
|
+
}),
|
|
551
591
|
'execution.started': z.strictObject({
|
|
552
592
|
provider: z.string().min(1),
|
|
553
593
|
workspaceRef: z.string().min(1),
|
|
@@ -563,7 +603,7 @@ export const eventPayloadSchemas = {
|
|
|
563
603
|
'execution.ended': z.strictObject({
|
|
564
604
|
instance: z.string().min(1),
|
|
565
605
|
workspaceRef: z.string().min(1),
|
|
566
|
-
outcome: z.enum(['completed', 'stopped', 'lost']),
|
|
606
|
+
outcome: z.enum(['completed', 'stopped', 'lost', 'relaunch']),
|
|
567
607
|
exitCode: z.number().int().nullable().optional(),
|
|
568
608
|
}),
|
|
569
609
|
'infrastructure.failed': z.strictObject({
|
|
@@ -750,14 +790,18 @@ export const eventPayloadSchemas = {
|
|
|
750
790
|
artifact: artifactRefSchema,
|
|
751
791
|
session: z.string().min(1),
|
|
752
792
|
}),
|
|
753
|
-
'spec.revised': z.
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
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
|
+
]),
|
|
761
805
|
|
|
762
806
|
// ── Sessions (every agent run is bracketed by these) ──────────────────────
|
|
763
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',
|
|
@@ -157,6 +163,11 @@ export const repositoryEventPolicy = {
|
|
|
157
163
|
'harvest.step.completed': 'decisive',
|
|
158
164
|
'harvest.session.started': 'decisive',
|
|
159
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
|
+
|
|
160
171
|
'harvest.proposals.submitted': 'decisive',
|
|
161
172
|
'harvest.review.verdict': 'decisive',
|
|
162
173
|
'harvest.proposal.id-reserved': 'decisive',
|
|
@@ -172,6 +183,20 @@ export const repositoryEventPolicy = {
|
|
|
172
183
|
'orchestrator.sandbox.reset': 'decisive',
|
|
173
184
|
'orchestrator.sandbox.published': 'decisive',
|
|
174
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',
|
|
175
200
|
'dispatcher.run-started': 'decisive',
|
|
176
201
|
'dispatcher.stop-requested': 'decisive',
|
|
177
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
|
}),
|
|
@@ -650,6 +811,11 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
|
650
811
|
'harvest.step.completed': ['kernel'],
|
|
651
812
|
'harvest.session.started': ['kernel'],
|
|
652
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
|
+
|
|
653
819
|
'harvest.proposals.submitted': ['agent'],
|
|
654
820
|
'harvest.review.verdict': ['agent'],
|
|
655
821
|
'harvest.proposal.id-reserved': ['kernel'],
|
|
@@ -669,6 +835,20 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
|
669
835
|
'orchestrator.sandbox.reset': ['human'],
|
|
670
836
|
'orchestrator.sandbox.published': ['human'],
|
|
671
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'],
|
|
672
852
|
'dispatcher.run-started': ['dispatcher'],
|
|
673
853
|
'dispatcher.stop-requested': ['dispatcher'],
|
|
674
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
|
+
}
|