@defrex/autobuild 1.0.1 → 1.2.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 +10 -18
- package/SPEC.md +499 -238
- package/bin/ab-dispatch-generation.ts +11 -2
- package/docs/accounts.md +119 -0
- package/docs/agent-runtimes.md +4 -4
- package/docs/answering-blocked-builds.md +2 -2
- package/docs/architecture.md +262 -53
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +3 -41
- package/docs/builds.md +4 -4
- package/docs/cli.md +18 -4
- package/docs/configuration-overview.md +115 -4
- package/docs/configuration.md +488 -334
- package/docs/dispatcher-hosting.md +19 -34
- package/docs/dispatcher.md +1 -1
- package/docs/forges.md +5 -5
- package/docs/getting-started.md +2 -2
- package/docs/glossary.md +6 -6
- package/docs/intake.md +2 -0
- package/docs/integration-overview.md +15 -15
- package/docs/integration-tree.md +45 -38
- package/docs/integration.md +6 -6
- package/{skills/guide/references/landing-policy.md → docs/merge-policy.md} +40 -24
- package/docs/migration-1.0.md +17 -13
- package/docs/operating.md +41 -19
- package/docs/operator-api.md +180 -51
- package/docs/operator-surfaces.md +5 -18
- package/docs/overview.md +3 -3
- package/docs/plugin-authoring.md +21 -0
- package/docs/remote-store-protocol.md +242 -68
- package/docs/remote-ticket-protocol.md +30 -50
- package/docs/restacking.md +54 -15
- package/docs/seams.md +8 -8
- package/docs/setup.md +59 -119
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +6 -6
- package/docs/ticket-dependencies.md +7 -7
- package/docs/ticket-sources.md +18 -0
- package/docs/tickets.md +8 -2
- package/docs/troubleshooting.md +8 -12
- package/docs/upgrading.md +9 -4
- package/docs/verification.md +60 -14
- package/docs/workspaces.md +4 -4
- package/package.json +17 -6
- package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
- package/packages/core/src/accounts/chatgpt-state.ts +41 -0
- package/packages/core/src/accounts/local-credentials.ts +194 -0
- package/packages/core/src/accounts/local-inference.ts +106 -0
- package/packages/core/src/accounts/local-owner.ts +123 -0
- package/packages/core/src/accounts/sensitive.ts +2 -0
- package/packages/core/src/cli/accounts.ts +147 -0
- package/packages/core/src/cli/binary-direct.ts +13 -1
- package/packages/core/src/cli/binary-lifecycle.ts +65 -2
- package/packages/core/src/cli/binary.ts +3 -1
- package/packages/core/src/cli/build-control.ts +83 -28
- package/packages/core/src/cli/connect.ts +3 -3
- package/packages/core/src/cli/context.ts +81 -38
- package/packages/core/src/cli/dashboard/facts.ts +2 -1
- package/packages/core/src/cli/dashboard/integration-detail.ts +8 -8
- package/packages/core/src/cli/dashboard/integration-row.ts +40 -13
- package/packages/core/src/cli/dashboard/landing-display.ts +25 -0
- package/packages/core/src/cli/dashboard/model.ts +56 -33
- package/packages/core/src/cli/dashboard/poll.ts +9 -3
- package/packages/core/src/cli/dashboard/render.ts +59 -37
- package/packages/core/src/cli/dashboard/target-distance.ts +14 -0
- package/packages/core/src/cli/dashboard/tree.ts +3 -2
- package/packages/core/src/cli/dispatch-args.ts +1 -1
- package/packages/core/src/cli/dispatch-frontend.ts +6 -3
- package/packages/core/src/cli/dispatch-handoff.ts +125 -44
- package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
- package/packages/core/src/cli/dispatch-launcher.ts +54 -21
- package/packages/core/src/cli/dispatch-preflight.ts +6 -1
- package/packages/core/src/cli/dispatch.ts +106 -11
- package/packages/core/src/cli/env.ts +4 -0
- package/packages/core/src/cli/help.ts +46 -23
- package/packages/core/src/cli/init-readiness-remote.ts +22 -1
- package/packages/core/src/cli/init-readiness-shared.ts +5 -1
- package/packages/core/src/cli/init-validation.ts +160 -18
- package/packages/core/src/cli/main.ts +68 -8
- package/packages/core/src/cli/node-verification-provenance.ts +1 -97
- package/packages/core/src/cli/publication-settlement.ts +47 -21
- package/packages/core/src/cli/repository-status.ts +20 -9
- package/packages/core/src/cli/secrets.ts +173 -0
- package/packages/core/src/cli/status.ts +42 -5
- package/packages/core/src/cli/store-opening.ts +17 -2
- package/packages/core/src/cli/terminal.ts +22 -1
- package/packages/core/src/cli/terminals.ts +14 -10
- package/packages/core/src/cli/upgrade-agent.ts +9 -1
- package/packages/core/src/cli/upgrade-landing.ts +70 -30
- package/packages/core/src/cli/upgrade.ts +3 -1
- package/packages/core/src/cli/wait.ts +15 -7
- package/packages/core/src/cli/watch-lifetime.ts +111 -0
- package/packages/core/src/cli/watch.ts +635 -510
- package/packages/core/src/config/accounts.ts +101 -0
- package/packages/core/src/config/effective-artifact.fixture.ts +27 -0
- package/packages/core/src/config/effective-artifact.ts +13 -0
- package/packages/core/src/config/landing.ts +1 -1
- package/packages/core/src/config/live.ts +14 -1
- package/packages/core/src/config/load.ts +21 -1
- package/packages/core/src/config/pipeline-source.ts +28 -0
- package/packages/core/src/config/reference-metadata.ts +2 -0
- package/packages/core/src/config/reference.ts +22 -7
- package/packages/core/src/config/roles.ts +54 -3
- package/packages/core/src/config/schema.ts +146 -162
- package/packages/core/src/context-directory.ts +26 -0
- package/packages/core/src/distribution-packaging.ts +26 -5
- package/packages/core/src/events/catalog.ts +10 -2
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/globs.ts +1 -1
- package/packages/core/src/events/payloads.ts +73 -1
- package/packages/core/src/events/policy.ts +7 -0
- package/packages/core/src/events/repository.ts +4 -4
- package/packages/core/src/events/sessions.ts +6 -6
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +574 -0
- package/packages/core/src/kernel/auto-merge.ts +2 -2
- package/packages/core/src/kernel/engine.ts +255 -26
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +10 -0
- package/packages/core/src/kernel/integration-landing.ts +3 -3
- package/packages/core/src/kernel/integration-state.ts +27 -4
- package/packages/core/src/kernel/leaf-restack-state.ts +28 -3
- package/packages/core/src/kernel/log-index.ts +13 -1
- package/packages/core/src/kernel/node-landing.ts +8 -8
- package/packages/core/src/kernel/node-parent.ts +2 -2
- package/packages/core/src/kernel/node-restack-transaction.ts +1 -1
- package/packages/core/src/kernel/node-verification-context.ts +216 -0
- package/packages/core/src/kernel/phases.ts +1 -1
- package/packages/core/src/kernel/plan-verify-selection.ts +16 -0
- package/packages/core/src/kernel/publication-retry.ts +168 -0
- package/packages/core/src/kernel/reconcile-restack.ts +29 -1
- package/packages/core/src/kernel/reducer.ts +85 -5
- package/packages/core/src/kernel/target-distance.ts +45 -0
- package/packages/core/src/kernel/terminal-guard.ts +10 -1
- package/packages/core/src/kernel/verify-stage-state.ts +123 -0
- package/packages/core/src/kernel/verify-stages.ts +39 -0
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +1 -1
- package/packages/core/src/operator/index.ts +3 -7
- package/packages/core/src/operator/landings.ts +5 -1
- package/packages/core/src/operator/presentation.ts +6 -1
- package/packages/core/src/operator/protocol.ts +6 -0
- package/packages/core/src/operator/query.ts +14 -18
- package/packages/core/src/operator/registry.ts +39 -7
- package/packages/core/src/operator/sandbox-host.ts +64 -40
- package/packages/core/src/operator/sandbox.ts +3 -0
- package/packages/core/src/operator/ticket-source-backend.ts +3 -12
- package/packages/core/src/operator/tickets.ts +25 -4
- package/packages/core/src/plugins/manifest.ts +2 -1
- package/packages/core/src/ports/forge/contract.ts +2 -2
- package/packages/core/src/ports/forge/git-rewrite.ts +25 -2
- package/packages/core/src/ports/forge/github-readiness.ts +2 -2
- package/packages/core/src/ports/forge/github.ts +26 -7
- package/packages/core/src/ports/forge/local-git.ts +4 -4
- package/packages/core/src/ports/forge/readiness.ts +1 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/account-env.ts +88 -0
- package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
- package/packages/core/src/ports/runner/claude.ts +26 -2
- package/packages/core/src/ports/runner/codex.ts +63 -31
- package/packages/core/src/ports/runner/one-shot.ts +2 -0
- package/packages/core/src/ports/runner/provider-error.ts +5 -0
- package/packages/core/src/ports/runner/routing.ts +35 -4
- package/packages/core/src/ports/tickets/contract.ts +58 -0
- package/packages/core/src/ports/tickets/tree.ts +1 -1
- package/packages/core/src/ports/types.ts +28 -7
- package/packages/core/src/ports/workspace/account-policy.ts +72 -0
- package/packages/core/src/ports/workspace/build-execution.ts +9 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
- package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +182 -72
- package/packages/core/src/processes/build-child.ts +6 -8
- package/packages/core/src/processes/build-execution-state.ts +8 -5
- package/packages/core/src/processes/build-runner.ts +554 -99
- package/packages/core/src/processes/dispatcher.ts +209 -101
- package/packages/core/src/processes/execution-no-progress.ts +8 -1
- package/packages/core/src/processes/execution-settlement.ts +21 -3
- package/packages/core/src/processes/harvest-runner.ts +68 -8
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-loss.ts +8 -2
- package/packages/core/src/processes/publication-state.ts +42 -4
- package/packages/core/src/processes/repo-view.ts +14 -0
- package/packages/core/src/processes/verify-cycle-config.ts +96 -0
- package/packages/core/src/project-secrets.ts +105 -0
- package/packages/core/src/{integration → scenarios}/harness.ts +330 -317
- package/packages/core/src/secret-name.ts +41 -0
- package/packages/core/src/store/account-redaction.ts +156 -0
- package/packages/core/src/store/adapter.ts +1 -0
- package/packages/core/src/store/build-scope.ts +9 -0
- package/packages/core/src/store/contract.ts +116 -2
- package/packages/core/src/store/local/schema.ts +13 -0
- package/packages/core/src/store/local/store.ts +42 -0
- package/packages/core/src/store/memory.ts +47 -0
- package/packages/core/src/store/operator-presence.ts +21 -0
- package/packages/core/src/store/phase-session.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +5185 -4156
- package/packages/core/src/store/remote/client.ts +89 -48
- package/packages/core/src/store/remote/compatibility.ts +20 -0
- package/packages/core/src/store/remote/protocol.ts +4 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/retention.ts +2 -3
- package/packages/core/src/store/session-handle.ts +9 -0
- package/packages/core/src/store/streams/session-writer.ts +1 -1
- package/packages/core/src/store/types.ts +12 -2
- package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
- package/packages/core/src/testing/index.ts +12 -1
- package/packages/core/src/testing/reduced-read-budget.ts +47 -0
- package/packages/core/src/testing/temp-directories.ts +58 -0
- package/skills/code-review/SKILL.md +23 -9
- package/skills/finalize/SKILL.md +15 -7
- package/skills/guide/SKILL.md +373 -148
- package/skills/guide/references/accounts.md +119 -0
- package/skills/guide/references/integration-tree.md +45 -38
- package/{docs/landing-policy.md → skills/guide/references/merge-policy.md} +40 -24
- package/skills/guide/references/migration-1.0.md +17 -13
- package/skills/guide/references/operator-api.md +180 -51
- package/skills/guide/references/plugin-authoring.md +21 -0
- package/skills/guide/references/remote-store-protocol.md +242 -68
- package/skills/guide/references/remote-ticket-protocol.md +30 -50
- package/skills/guide/references/restacking.md +54 -15
- package/skills/guide/references/setup.md +59 -119
- package/skills/guide/references/spec-standard.md +6 -6
- package/skills/guide/references/ticket-dependencies.md +7 -7
- package/skills/harvest/SKILL.md +3 -1
- package/skills/harvest-review/SKILL.md +3 -1
- package/skills/implement/SKILL.md +43 -17
- package/skills/operate/SKILL.md +118 -118
- package/skills/plan/SKILL.md +39 -13
- package/skills/plan-review/SKILL.md +15 -10
- package/skills/reconcile/SKILL.md +22 -3
- package/skills/spec/SKILL.md +20 -20
- package/skills/tickets/SKILL.md +12 -9
- package/templates/autobuild.toml +1 -1
- package/templates/hosted-service/package.json +2 -2
- package/docs/hosted-dispatcher-cutover-validation.md +0 -178
- package/docs/hosted-dispatcher.md +0 -275
- package/docs/hosted-service.md +0 -293
- package/docs/mcp.md +0 -149
- package/packages/core/src/orchestrator/approvals.ts +0 -115
- package/packages/core/src/orchestrator/conversation.ts +0 -167
- package/packages/core/src/orchestrator/model.ts +0 -86
- package/packages/core/src/orchestrator/prompt.ts +0 -63
- package/packages/core/src/orchestrator/tools.ts +0 -117
- package/packages/core/src/orchestrator/turn-runner.ts +0 -457
- package/packages/core/src/processes/orchestrator-tick.ts +0 -360
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { sampleTargetDistance } from '../kernel/target-distance'
|
|
2
|
+
import { capturedBuildConfig } from './verify-cycle-config'
|
|
3
|
+
import { publicationRetryGate } from '../kernel/publication-retry'
|
|
4
|
+
import {
|
|
5
|
+
NODE_VERIFICATION_CONTEXT,
|
|
6
|
+
prepareNodeVerificationContext,
|
|
7
|
+
} from '../kernel/node-verification-context'
|
|
1
8
|
import {
|
|
2
9
|
nodeActivityKey,
|
|
3
10
|
nodePollingSchedule,
|
|
@@ -110,8 +117,6 @@ import type { TicketSourceDegradation } from '../kernel/ticket-source-health'
|
|
|
110
117
|
*/
|
|
111
118
|
import { createHash } from 'node:crypto'
|
|
112
119
|
import type { Config } from '../config/schema'
|
|
113
|
-
import type { LanguageModel } from 'ai'
|
|
114
|
-
import { runOrchestratorTickStep } from './orchestrator-tick'
|
|
115
120
|
import { DISPATCHER, KERNEL, agentActor } from '../events/envelope'
|
|
116
121
|
import { isRemoteWorkspace } from '../events/workspace-remote'
|
|
117
122
|
import type { AbEvent, EventWrite } from '../events/catalog'
|
|
@@ -128,7 +133,6 @@ import {
|
|
|
128
133
|
harvestCreationsFromStates,
|
|
129
134
|
} from '../kernel/harvest'
|
|
130
135
|
import type { BuildState } from '../kernel/reducer'
|
|
131
|
-
import { createOperatorSandboxService, type OperatorSandboxService } from '../operator/sandbox'
|
|
132
136
|
import type { ArtifactRef, TicketRef } from '../ontology'
|
|
133
137
|
import { BUILD_EXECUTION_LEASE_TTL_MS } from '../ports/workspace/build-execution'
|
|
134
138
|
import type {
|
|
@@ -433,11 +437,6 @@ export interface TickReport {
|
|
|
433
437
|
sandboxIdleStops: number
|
|
434
438
|
/** Contained idle-settlement failures this tick; retried next tick. */
|
|
435
439
|
sandboxSettleFailures: number
|
|
436
|
-
/** Contained sandbox-backend construction failures this tick (AUT-584):
|
|
437
|
-
* deterministic and config-shaped, so it re-reports every tick until the
|
|
438
|
-
* config is repaired. The affected tick runs with sandbox tools filtered
|
|
439
|
-
* exactly as when no backend exists. */
|
|
440
|
-
orchestratorSandboxFailures: number
|
|
441
440
|
}
|
|
442
441
|
|
|
443
442
|
export function emptyTickReport(): TickReport {
|
|
@@ -475,7 +474,6 @@ export function emptyTickReport(): TickReport {
|
|
|
475
474
|
harvestFailed: 0,
|
|
476
475
|
sandboxIdleStops: 0,
|
|
477
476
|
sandboxSettleFailures: 0,
|
|
478
|
-
orchestratorSandboxFailures: 0,
|
|
479
477
|
}
|
|
480
478
|
}
|
|
481
479
|
|
|
@@ -553,6 +551,8 @@ export interface TickOpts {
|
|
|
553
551
|
* resume, lease sweep, and in-flight runners continue. Absent defaults true.
|
|
554
552
|
*/
|
|
555
553
|
acceptNewWork?: boolean
|
|
554
|
+
/** Repair/settle active execution policies only; suppress all intake and launches. */
|
|
555
|
+
observationOnly?: boolean
|
|
556
556
|
/**
|
|
557
557
|
* Repository-derived claim-time default supplied by the CLI for this tick.
|
|
558
558
|
* True records the existing durable auto-merge request only on builds
|
|
@@ -631,11 +631,6 @@ export interface DispatcherDeps {
|
|
|
631
631
|
* supplies cancellation and treats every absence/failure/invalid result as a
|
|
632
632
|
* local deterministic fallback, so naming can never prevent build creation. */
|
|
633
633
|
nameSlug?: (spec: string, signal: AbortSignal) => Promise<string | null>
|
|
634
|
-
/** The orchestrator turn runner's language model, injected for tests. When
|
|
635
|
-
* absent the configured gateway model is resolved in process (AUT-342);
|
|
636
|
-
* the step itself only ever constructs in origin mode with the orchestrator
|
|
637
|
-
* enabled, so a local dispatcher never resolves a model. */
|
|
638
|
-
orchestratorModel?: LanguageModel
|
|
639
634
|
/** Settle pending publication for `slug` after durable proof that the
|
|
640
635
|
* guest execution ended. Supplied by the DispatchLoop; the settlement stage
|
|
641
636
|
* invokes it only on a recorded completion. */
|
|
@@ -807,7 +802,16 @@ export class Dispatcher {
|
|
|
807
802
|
revision = artifact.meta.revision
|
|
808
803
|
pinned = parseEffectiveBuildConfig(artifact)
|
|
809
804
|
}
|
|
810
|
-
return decideNextFromFacts(
|
|
805
|
+
return decideNextFromFacts(
|
|
806
|
+
state,
|
|
807
|
+
log,
|
|
808
|
+
await capturedBuildConfig(
|
|
809
|
+
this.store,
|
|
810
|
+
slug,
|
|
811
|
+
state,
|
|
812
|
+
composeBuildConfig(pinned, this.deps.config),
|
|
813
|
+
),
|
|
814
|
+
)
|
|
811
815
|
} catch (error) {
|
|
812
816
|
report.blockedDiagnostics.push(
|
|
813
817
|
`build ${slug} pipeline${revision === undefined ? '' : ` revision ${revision}`} unavailable: pipeline decisions withheld; next tick retries. Restore readable build-branch configuration or use a compatible dispatcher version. ${error instanceof Error || isForgeFailure(error) ? error.message : String(error)}`,
|
|
@@ -863,8 +867,11 @@ export class Dispatcher {
|
|
|
863
867
|
if (settle === undefined) return undefined
|
|
864
868
|
return async (slug) => {
|
|
865
869
|
if (await deferMixedVersion(this.store, slug)) return
|
|
866
|
-
|
|
867
|
-
|
|
870
|
+
try {
|
|
871
|
+
await settle(slug)
|
|
872
|
+
} finally {
|
|
873
|
+
await this.store.refreshBuild(slug)
|
|
874
|
+
}
|
|
868
875
|
}
|
|
869
876
|
}
|
|
870
877
|
|
|
@@ -975,6 +982,7 @@ export class Dispatcher {
|
|
|
975
982
|
await this.settleHarvestExecutions(opts)
|
|
976
983
|
if (this.outOfBudget(opts)) return report
|
|
977
984
|
await this.settleOrchestratorSandboxes(report, opts)
|
|
985
|
+
if (opts.observationOnly) return report
|
|
978
986
|
if (this.outOfBudget(opts)) return report
|
|
979
987
|
// The default fan-out runs before the janitor so one tick both records the
|
|
980
988
|
// consent and lets the janitor act on it (the janitor reduces a fresh read
|
|
@@ -999,61 +1007,6 @@ export class Dispatcher {
|
|
|
999
1007
|
// launch. Pending control commands still launch the runner so the kernel
|
|
1000
1008
|
// can settle them under the repository lease.
|
|
1001
1009
|
await this.triggerHarvest()
|
|
1002
|
-
// The orchestrator step (AUT-342) — LAST, after every build stage, so it
|
|
1003
|
-
// can only consume slack: resumes, crash reaping, and wake turns run
|
|
1004
|
-
// against min(configured, remaining tick budget) with a 30 s floor, and
|
|
1005
|
-
// a busy repository simply defers its sessions to later ticks (durable
|
|
1006
|
-
// state makes that safe). Two independent gates keep it inert where it
|
|
1007
|
-
// does not belong: the step is constructed ONLY in origin mode (a local
|
|
1008
|
-
// `ab dispatch` never constructs it — enabled = true in a local
|
|
1009
|
-
// repository's autobuild.toml lists no sessions, builds no registry, and
|
|
1010
|
-
// calls no model), and in origin mode only when the effective config
|
|
1011
|
-
// enables the orchestrator.
|
|
1012
|
-
if (this.deps.repoOrigin !== undefined && this.deps.config.orchestrator.enabled) {
|
|
1013
|
-
if (!this.outOfBudget(opts)) {
|
|
1014
|
-
const remainingSeconds =
|
|
1015
|
-
opts.deadlineAt === undefined
|
|
1016
|
-
? undefined
|
|
1017
|
-
: Math.max(0, Math.floor((opts.deadlineAt - this.deps.clock().getTime()) / 1000))
|
|
1018
|
-
// The origin-mode tick's sandbox backend (AUT-584), built from the
|
|
1019
|
-
// dispatcher's own deps — the same wired provider and forge the
|
|
1020
|
-
// settlement stage already consumes. Construction is cheap and
|
|
1021
|
-
// network-free (one idempotent ensureRepo), and building per tick
|
|
1022
|
-
// picks up hot config reloads the way the rest of the tick does.
|
|
1023
|
-
// A construction failure is contained: the step runs with sandbox
|
|
1024
|
-
// tools filtered exactly as today, and the standing counter names
|
|
1025
|
-
// the condition (the same discipline as sandboxSettleFailures).
|
|
1026
|
-
let sandbox: OperatorSandboxService | undefined
|
|
1027
|
-
try {
|
|
1028
|
-
sandbox = await createOperatorSandboxService({
|
|
1029
|
-
store: this.store,
|
|
1030
|
-
repo: this.deps.repo,
|
|
1031
|
-
provider: this.deps.workspaces,
|
|
1032
|
-
sandbox: this.deps.config.orchestrator.sandbox,
|
|
1033
|
-
baseBranch: this.deps.config.baseBranch,
|
|
1034
|
-
forge: this.deps.forge,
|
|
1035
|
-
clock: this.deps.clock,
|
|
1036
|
-
})
|
|
1037
|
-
} catch {
|
|
1038
|
-
report.orchestratorSandboxFailures += 1
|
|
1039
|
-
sandbox = undefined
|
|
1040
|
-
}
|
|
1041
|
-
await runOrchestratorTickStep({
|
|
1042
|
-
store: this.store,
|
|
1043
|
-
view: this.store,
|
|
1044
|
-
repo: this.deps.repo,
|
|
1045
|
-
config: this.deps.config,
|
|
1046
|
-
clock: this.deps.clock,
|
|
1047
|
-
ids: this.deps.ids,
|
|
1048
|
-
tickets: this.deps.tickets,
|
|
1049
|
-
...(sandbox !== undefined ? { sandbox } : {}),
|
|
1050
|
-
...(this.deps.orchestratorModel !== undefined
|
|
1051
|
-
? { model: this.deps.orchestratorModel }
|
|
1052
|
-
: {}),
|
|
1053
|
-
...(remainingSeconds !== undefined ? { remainingBudgetSeconds: remainingSeconds } : {}),
|
|
1054
|
-
})
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
1010
|
return report
|
|
1058
1011
|
}
|
|
1059
1012
|
|
|
@@ -1437,6 +1390,7 @@ export class Dispatcher {
|
|
|
1437
1390
|
{
|
|
1438
1391
|
store: this.store,
|
|
1439
1392
|
execution,
|
|
1393
|
+
ids: this.deps.ids,
|
|
1440
1394
|
...(this.settlePublication !== undefined
|
|
1441
1395
|
? { settlePublication: this.settlePublication }
|
|
1442
1396
|
: {}),
|
|
@@ -1487,6 +1441,25 @@ export class Dispatcher {
|
|
|
1487
1441
|
...(execution.sessionId !== undefined ? { sessionId: execution.sessionId } : {}),
|
|
1488
1442
|
commandId: execution.commandId,
|
|
1489
1443
|
})
|
|
1444
|
+
if (observation.attention) {
|
|
1445
|
+
const current = this.store.repositoryFacts()
|
|
1446
|
+
const authorization = current.harvestAuthorizations[JSON.stringify(execution.execution)]
|
|
1447
|
+
const run = current.harvest.runs.find((run) => run.run === authorization?.payload.run)
|
|
1448
|
+
// A model session has a durable run authorization. Escalation is
|
|
1449
|
+
// terminal and deduplicates across ticks and dispatcher restarts;
|
|
1450
|
+
// the execution itself remains observable until its command exits.
|
|
1451
|
+
if (run?.status === 'running')
|
|
1452
|
+
await this.store.appendRepo(this.deps.repo, {
|
|
1453
|
+
actor: KERNEL,
|
|
1454
|
+
type: 'harvest.escalated',
|
|
1455
|
+
payload: {
|
|
1456
|
+
run: run.run,
|
|
1457
|
+
source: 'policy',
|
|
1458
|
+
reason: observation.attention,
|
|
1459
|
+
observations: run.observations,
|
|
1460
|
+
},
|
|
1461
|
+
})
|
|
1462
|
+
}
|
|
1490
1463
|
// Conservatism: an unresolvable observation (provider error) throws
|
|
1491
1464
|
// and is contained below — it never reaps.
|
|
1492
1465
|
if (observation.state === 'running') continue
|
|
@@ -2299,6 +2272,67 @@ export class Dispatcher {
|
|
|
2299
2272
|
}
|
|
2300
2273
|
}
|
|
2301
2274
|
}
|
|
2275
|
+
if (
|
|
2276
|
+
state.kind !== 'node' &&
|
|
2277
|
+
state.status !== 'queued' &&
|
|
2278
|
+
state.status !== 'aborted' &&
|
|
2279
|
+
state.prState !== 'merged' &&
|
|
2280
|
+
state.prState !== 'closed'
|
|
2281
|
+
) {
|
|
2282
|
+
const facts = await this.store.buildFacts(record.slug)
|
|
2283
|
+
const target = facts.log.restack.target
|
|
2284
|
+
if (target && target.branch === facts.state.baseBranch) {
|
|
2285
|
+
let sample = {
|
|
2286
|
+
branch: target.branch,
|
|
2287
|
+
sha: target.sha,
|
|
2288
|
+
head: null,
|
|
2289
|
+
count: null,
|
|
2290
|
+
} as EventPayload<'target.distance'>
|
|
2291
|
+
try {
|
|
2292
|
+
sample = await sampleTargetDistance({
|
|
2293
|
+
...target,
|
|
2294
|
+
buildBranch: record.branch ?? `ab/${record.slug}`,
|
|
2295
|
+
...(facts.workspace && !isRemoteWorkspace(facts.workspace)
|
|
2296
|
+
? { localPath: this.forgeWorkspacePathOf(facts.workspace) }
|
|
2297
|
+
: {}),
|
|
2298
|
+
exec: this.deps.exec,
|
|
2299
|
+
forge: this.deps.forge,
|
|
2300
|
+
})
|
|
2301
|
+
} catch (error) {
|
|
2302
|
+
if (
|
|
2303
|
+
error instanceof ForgeRequestDeferred ||
|
|
2304
|
+
(isForgeFailure(error) && error.details.kind === 'rate-limited')
|
|
2305
|
+
)
|
|
2306
|
+
throw error
|
|
2307
|
+
if (facts.log.restack.distance?.count != null)
|
|
2308
|
+
report.janitorDiagnostics.push(
|
|
2309
|
+
`build ${record.slug}: target distance failed — ${error instanceof Error ? error.message : String(error)}`,
|
|
2310
|
+
)
|
|
2311
|
+
}
|
|
2312
|
+
const current = await this.store.buildFacts(record.slug)
|
|
2313
|
+
if (
|
|
2314
|
+
current.state.status !== 'done' &&
|
|
2315
|
+
current.state.status !== 'aborted' &&
|
|
2316
|
+
current.state.prState !== 'merged' &&
|
|
2317
|
+
current.state.prState !== 'closed' &&
|
|
2318
|
+
current.state.baseBranch === target.branch &&
|
|
2319
|
+
current.log.restack.target?.sha === target.sha &&
|
|
2320
|
+
current.log.restack.completedAt === facts.log.restack.completedAt &&
|
|
2321
|
+
current.state.implement.commits?.head === facts.state.implement.commits?.head &&
|
|
2322
|
+
(current.log.restack.distance?.branch !== sample.branch ||
|
|
2323
|
+
current.log.restack.distance?.sha !== sample.sha ||
|
|
2324
|
+
current.log.restack.distance?.head !== sample.head ||
|
|
2325
|
+
current.log.restack.distance?.count !== sample.count)
|
|
2326
|
+
) {
|
|
2327
|
+
await this.store.append(record.slug, {
|
|
2328
|
+
actor: DISPATCHER,
|
|
2329
|
+
type: 'target.distance',
|
|
2330
|
+
payload: sample,
|
|
2331
|
+
})
|
|
2332
|
+
loaded = undefined
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2302
2336
|
if (state.pr) {
|
|
2303
2337
|
await this.checkPr(
|
|
2304
2338
|
record,
|
|
@@ -2318,7 +2352,7 @@ export class Dispatcher {
|
|
|
2318
2352
|
}
|
|
2319
2353
|
await completeNodePoll()
|
|
2320
2354
|
} catch (error) {
|
|
2321
|
-
if (error instanceof
|
|
2355
|
+
if (error instanceof ForgeRequestDeferred) {
|
|
2322
2356
|
attempted = false
|
|
2323
2357
|
return
|
|
2324
2358
|
}
|
|
@@ -3041,7 +3075,10 @@ export class Dispatcher {
|
|
|
3041
3075
|
const config = artifact
|
|
3042
3076
|
? composeBuildConfig(parseEffectiveBuildConfig(artifact), this.deps.config)
|
|
3043
3077
|
: this.deps.config
|
|
3044
|
-
return integrationVerified(
|
|
3078
|
+
return integrationVerified(
|
|
3079
|
+
candidate,
|
|
3080
|
+
await capturedBuildConfig(store, record.slug, candidate, config),
|
|
3081
|
+
)
|
|
3045
3082
|
}
|
|
3046
3083
|
const facts = await store.buildFacts(record.slug)
|
|
3047
3084
|
const decision = await this.decideBuild(record.slug, facts.state, facts.log, report)
|
|
@@ -3074,8 +3111,7 @@ export class Dispatcher {
|
|
|
3074
3111
|
nativeCancelled || prState.nativeAutoMerge === false
|
|
3075
3112
|
? { kind: 'applied' as const }
|
|
3076
3113
|
: await forge.setAutoMerge(workspacePath, pr.number, false)
|
|
3077
|
-
if (cancellation.kind !== 'applied')
|
|
3078
|
-
throw new Error('Native landing cancellation unconfirmed')
|
|
3114
|
+
if (cancellation.kind !== 'applied') throw new Error('Native merge cancellation unconfirmed')
|
|
3079
3115
|
nativeCancelled = true
|
|
3080
3116
|
}
|
|
3081
3117
|
if (isReady) {
|
|
@@ -3090,11 +3126,11 @@ export class Dispatcher {
|
|
|
3090
3126
|
state = current
|
|
3091
3127
|
break
|
|
3092
3128
|
}
|
|
3093
|
-
if (!record.ticket) throw new Error('
|
|
3129
|
+
if (!record.ticket) throw new Error('Merge policy requires a readable source ticket')
|
|
3094
3130
|
const ticket = await tickets.get(await this.currentTicketId(record))
|
|
3095
3131
|
if (!ticket)
|
|
3096
3132
|
throw new Error(
|
|
3097
|
-
`
|
|
3133
|
+
`Merge policy source ticket ${record.ticket.id} is unavailable; retrying on next poll`,
|
|
3098
3134
|
)
|
|
3099
3135
|
const input = {
|
|
3100
3136
|
from: integration ? ('node' as const) : ('leaf' as const),
|
|
@@ -3138,7 +3174,7 @@ export class Dispatcher {
|
|
|
3138
3174
|
? { kind: 'applied' as const }
|
|
3139
3175
|
: await forge.setAutoMerge(workspacePath, pr.number, false)
|
|
3140
3176
|
if (result.kind !== 'applied')
|
|
3141
|
-
throw new Error('Native
|
|
3177
|
+
throw new Error('Native merge cancellation unconfirmed; retrying')
|
|
3142
3178
|
const current = (await store.buildFacts(record.slug)).state
|
|
3143
3179
|
if (current.landing?.native?.enabled !== false)
|
|
3144
3180
|
await store.append(record.slug, {
|
|
@@ -3218,7 +3254,10 @@ export class Dispatcher {
|
|
|
3218
3254
|
candidate.status === 'aborted' ||
|
|
3219
3255
|
candidate.openEscalations.length ||
|
|
3220
3256
|
candidate.pendingCommands.length ||
|
|
3221
|
-
!integrationVerified(
|
|
3257
|
+
!integrationVerified(
|
|
3258
|
+
candidate,
|
|
3259
|
+
await capturedBuildConfig(store, record.slug, candidate, config),
|
|
3260
|
+
)
|
|
3222
3261
|
)
|
|
3223
3262
|
return false
|
|
3224
3263
|
await this.observeIntegration(record.slug, true)
|
|
@@ -3277,7 +3316,7 @@ export class Dispatcher {
|
|
|
3277
3316
|
type: 'integration.abandoned',
|
|
3278
3317
|
payload: {
|
|
3279
3318
|
id: intent.id,
|
|
3280
|
-
reason: 'Nested
|
|
3319
|
+
reason: 'Nested merge eligibility changed before reservation',
|
|
3281
3320
|
},
|
|
3282
3321
|
})
|
|
3283
3322
|
return
|
|
@@ -3341,7 +3380,7 @@ export class Dispatcher {
|
|
|
3341
3380
|
{
|
|
3342
3381
|
code: 'unproven-gate-state',
|
|
3343
3382
|
detail:
|
|
3344
|
-
'Frozen destination node generation is unavailable or disagrees with its branch. Native
|
|
3383
|
+
'Frozen destination node generation is unavailable or disagrees with its branch. Native merge is withheld; human action required.',
|
|
3345
3384
|
},
|
|
3346
3385
|
pr.number,
|
|
3347
3386
|
commandSeq,
|
|
@@ -3386,7 +3425,7 @@ export class Dispatcher {
|
|
|
3386
3425
|
if (enableSeq === undefined) return
|
|
3387
3426
|
const cancelled = await forge.setAutoMerge(workspacePath, pr.number, false)
|
|
3388
3427
|
if (cancelled.kind !== 'applied')
|
|
3389
|
-
throw new Error('Native
|
|
3428
|
+
throw new Error('Native merge cancellation unconfirmed; retrying')
|
|
3390
3429
|
const attempt = (retry?.attempt ?? 0) + 1
|
|
3391
3430
|
await store.append(record.slug, {
|
|
3392
3431
|
actor: DISPATCHER,
|
|
@@ -3604,7 +3643,7 @@ export class Dispatcher {
|
|
|
3604
3643
|
id: this.deps.ids('obs'),
|
|
3605
3644
|
kind: 'followup',
|
|
3606
3645
|
summary:
|
|
3607
|
-
'
|
|
3646
|
+
'Merge contrary to policy: native auto-merge was armed or indeterminate when the forge merged without merge authorization. Operator attention required; the target has not been rewritten.',
|
|
3608
3647
|
refs: ['landing-contrary-to-policy'],
|
|
3609
3648
|
},
|
|
3610
3649
|
})
|
|
@@ -4445,7 +4484,13 @@ export class Dispatcher {
|
|
|
4445
4484
|
if (record.lease) {
|
|
4446
4485
|
if (new Date(record.lease.expiresAt).getTime() > now) continue // healthy
|
|
4447
4486
|
} else if (now - new Date(record.updatedAt).getTime() < this.leaseTtlMs) {
|
|
4448
|
-
|
|
4487
|
+
const facts = await this.store.buildFacts(record.slug)
|
|
4488
|
+
const cleanup = facts.state.verifyStage.cleanupExecutionSeq
|
|
4489
|
+
if (
|
|
4490
|
+
facts.lastExecution !== 'relaunch' &&
|
|
4491
|
+
!(cleanup !== undefined && facts.state.verifyStage.executionSeq <= cleanup)
|
|
4492
|
+
)
|
|
4493
|
+
continue // absent lease within the first-claim grace (see DispatcherOpts)
|
|
4449
4494
|
}
|
|
4450
4495
|
const facts = await this.store.buildFacts(record.slug)
|
|
4451
4496
|
const state = facts.state
|
|
@@ -4465,6 +4510,27 @@ export class Dispatcher {
|
|
|
4465
4510
|
!(await this.dispatchBudget(record.slug))
|
|
4466
4511
|
)
|
|
4467
4512
|
continue
|
|
4513
|
+
const pendingRewrite = facts.publication.latestUncompletedRequest()?.payload
|
|
4514
|
+
const retryIntent =
|
|
4515
|
+
pendingRewrite?.operation === 'reconcile' && pendingRewrite.rewrite
|
|
4516
|
+
? { operation: 'reconcile' as const, id: pendingRewrite.rewrite.id }
|
|
4517
|
+
: facts.log.restack.intent
|
|
4518
|
+
? { operation: 'restack' as const, id: facts.log.restack.intent.id }
|
|
4519
|
+
: undefined
|
|
4520
|
+
// Publication waits must not prevent a replacement runner from
|
|
4521
|
+
// acknowledging controls, including abort on an exhausted episode.
|
|
4522
|
+
if (retryIntent && state.pendingCommands.length === 0) {
|
|
4523
|
+
try {
|
|
4524
|
+
await publicationRetryGate(
|
|
4525
|
+
{ store: this.store, slug: record.slug, clock: this.deps.clock, actor: DISPATCHER },
|
|
4526
|
+
retryIntent.operation,
|
|
4527
|
+
retryIntent.id,
|
|
4528
|
+
)
|
|
4529
|
+
} catch (error) {
|
|
4530
|
+
if (error instanceof ForgeRequestDeferred) continue
|
|
4531
|
+
throw error
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4468
4534
|
const decision = await this.decideBuild(record.slug, state, facts.log, report)
|
|
4469
4535
|
if (decision === undefined) continue
|
|
4470
4536
|
if (state.status === 'done' || state.status === 'aborted') continue
|
|
@@ -5000,7 +5066,7 @@ export class Dispatcher {
|
|
|
5000
5066
|
if (state.pendingCommands.some((c) => c.command === 'abort'))
|
|
5001
5067
|
return `target node ${ticket.target} is closing`
|
|
5002
5068
|
if (state.integration?.intent && !state.integration.landing)
|
|
5003
|
-
return `target node ${ticket.target} is
|
|
5069
|
+
return `target node ${ticket.target} is merging`
|
|
5004
5070
|
if (!digest.nodeOpened || !record.branch) return `target node ${ticket.target} is not yet open`
|
|
5005
5071
|
return {
|
|
5006
5072
|
target: {
|
|
@@ -5440,9 +5506,14 @@ export class Dispatcher {
|
|
|
5440
5506
|
)
|
|
5441
5507
|
return
|
|
5442
5508
|
const artifact = await this.store.getArtifact(record.slug, BUILD_EFFECTIVE_CONFIG_ARTIFACT)
|
|
5443
|
-
const config =
|
|
5444
|
-
|
|
5445
|
-
|
|
5509
|
+
const config = await capturedBuildConfig(
|
|
5510
|
+
this.store,
|
|
5511
|
+
record.slug,
|
|
5512
|
+
state,
|
|
5513
|
+
artifact
|
|
5514
|
+
? composeBuildConfig(parseEffectiveBuildConfig(artifact), this.deps.config)
|
|
5515
|
+
: this.deps.config,
|
|
5516
|
+
)
|
|
5446
5517
|
if (
|
|
5447
5518
|
!integrationCurrent(state) ||
|
|
5448
5519
|
state.integration?.cycle?.config !== integrationConfig(config)
|
|
@@ -5463,6 +5534,12 @@ export class Dispatcher {
|
|
|
5463
5534
|
return
|
|
5464
5535
|
const exact = await forge.compareBranches(state.baseBranch!, record.branch!)
|
|
5465
5536
|
if (exact.parentSha !== comparison.parentSha || exact.headSha !== comparison.headSha) return
|
|
5537
|
+
const cycle = {
|
|
5538
|
+
id: this.deps.ids('integration-cycle'),
|
|
5539
|
+
parent: exact.parentSha,
|
|
5540
|
+
head: exact.headSha,
|
|
5541
|
+
}
|
|
5542
|
+
let context: string | undefined
|
|
5466
5543
|
await this.withKernelRepository(async (path) => {
|
|
5467
5544
|
const head = await forge.rewrite!.snapshot({
|
|
5468
5545
|
workspacePath: path,
|
|
@@ -5476,18 +5553,49 @@ export class Dispatcher {
|
|
|
5476
5553
|
ref: `refs/autobuild/archive/${record.slug}/${head}`,
|
|
5477
5554
|
sha: head,
|
|
5478
5555
|
})
|
|
5556
|
+
if (
|
|
5557
|
+
config.verify.steps.some((step) => config.verify.stepConfigs[step]?.kind === 'agent')
|
|
5558
|
+
) {
|
|
5559
|
+
const exec = forge.kernelExec ?? this.deps.exec
|
|
5560
|
+
// Snapshot fetch brings the complete head ancestry, including merge sides.
|
|
5561
|
+
// A parent may have advanced independently and need its own fetch.
|
|
5562
|
+
const parent = await exec(['git', 'cat-file', '-e', `${exact.parentSha}^{commit}`], {
|
|
5563
|
+
cwd: path,
|
|
5564
|
+
})
|
|
5565
|
+
if (parent.exitCode !== 0) {
|
|
5566
|
+
const fetched = await exec(['git', 'fetch', '--no-tags', 'origin', exact.parentSha], {
|
|
5567
|
+
cwd: path,
|
|
5568
|
+
})
|
|
5569
|
+
if (fetched.exitCode !== 0)
|
|
5570
|
+
throw new Error(`cannot fetch node verification parent: ${fetched.stderr}`)
|
|
5571
|
+
}
|
|
5572
|
+
context = await prepareNodeVerificationContext(
|
|
5573
|
+
this.store,
|
|
5574
|
+
record.repo,
|
|
5575
|
+
cycle,
|
|
5576
|
+
current,
|
|
5577
|
+
{ exec, workspacePath: path },
|
|
5578
|
+
)
|
|
5579
|
+
}
|
|
5479
5580
|
})
|
|
5480
5581
|
if (!(await this.store.renewNodeWriter(record.slug, holder))) return
|
|
5481
|
-
await this.store.
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5582
|
+
const prepared = await this.store.appendWithArtifactsIfCurrent(
|
|
5583
|
+
record.slug,
|
|
5584
|
+
current.lastSeq,
|
|
5585
|
+
context === undefined ? [] : [{ kind: NODE_VERIFICATION_CONTEXT, content: context }],
|
|
5586
|
+
(deposited) => ({
|
|
5587
|
+
actor: DISPATCHER,
|
|
5588
|
+
type: 'integration.prepared',
|
|
5589
|
+
payload: {
|
|
5590
|
+
...cycle,
|
|
5591
|
+
config: integrationConfig(config),
|
|
5592
|
+
...(deposited[0]
|
|
5593
|
+
? { context: { kind: NODE_VERIFICATION_CONTEXT, rev: deposited[0].revision } }
|
|
5594
|
+
: {}),
|
|
5595
|
+
},
|
|
5596
|
+
}),
|
|
5597
|
+
)
|
|
5598
|
+
if (!prepared) return
|
|
5491
5599
|
} finally {
|
|
5492
5600
|
await this.store.releaseNodeWriter(record.slug, holder)
|
|
5493
5601
|
}
|
|
@@ -5569,7 +5677,7 @@ export class Dispatcher {
|
|
|
5569
5677
|
head: record.branch,
|
|
5570
5678
|
base: state.baseBranch,
|
|
5571
5679
|
title: `Integration: ${record.ticket?.id ?? record.slug}`,
|
|
5572
|
-
body: `Integration build ${record.slug}. Target: ${state.target?.ticket.id ?? state.baseBranch}. Human
|
|
5680
|
+
body: `Integration build ${record.slug}. Target: ${state.target?.ticket.id ?? state.baseBranch}. Human merge required.`,
|
|
5573
5681
|
})
|
|
5574
5682
|
} catch (error) {
|
|
5575
5683
|
if (
|
|
@@ -5616,7 +5724,7 @@ export class Dispatcher {
|
|
|
5616
5724
|
if (!landing || entry.digest.nodeContribution?.landing === landing) return
|
|
5617
5725
|
const state = inputs.states.get(slug)!
|
|
5618
5726
|
if (!state.pr || !forge.inspectLandingPr)
|
|
5619
|
-
throw new Error('cannot establish
|
|
5727
|
+
throw new Error('cannot establish merged node source head')
|
|
5620
5728
|
visiting.add(slug)
|
|
5621
5729
|
const pr = await forge.inspectLandingPr(path, state.pr.number)
|
|
5622
5730
|
const head = pr.headSha
|
|
@@ -24,6 +24,7 @@ export const executionProgress = {
|
|
|
24
24
|
'landing.native-enable-started': 'bookkeeping',
|
|
25
25
|
'landing.forge-merged': 'progress',
|
|
26
26
|
'landing.native-applied': 'bookkeeping',
|
|
27
|
+
'target.distance': 'bookkeeping',
|
|
27
28
|
'target.moved': 'bookkeeping',
|
|
28
29
|
'restack.prepared': 'progress',
|
|
29
30
|
'restack.replayed': 'progress',
|
|
@@ -81,6 +82,8 @@ export const executionProgress = {
|
|
|
81
82
|
'finalize.step-started': 'progress',
|
|
82
83
|
'publication.requested': 'progress',
|
|
83
84
|
'publication.lost': 'progress',
|
|
85
|
+
'publication.retry-scheduled': 'failure',
|
|
86
|
+
'publication.retry-exhausted': 'failure',
|
|
84
87
|
'abort.remote-branch-deleted': 'progress',
|
|
85
88
|
'abort.local-branch-deleted': 'progress',
|
|
86
89
|
'abort.ticket-returned': 'progress',
|
|
@@ -114,7 +117,11 @@ export const executionProgress = {
|
|
|
114
117
|
'code-review.started': 'progress',
|
|
115
118
|
'code-review.verdict': 'progress',
|
|
116
119
|
'verify.reconcile-policy-captured': 'progress',
|
|
120
|
+
'verify.config-captured': 'progress',
|
|
121
|
+
'verify.config-superseded': 'progress',
|
|
117
122
|
'verify.started': 'progress',
|
|
123
|
+
'verify.cancelled': 'progress',
|
|
124
|
+
'verify.stage-failed': 'progress',
|
|
118
125
|
'verify.completed': 'progress',
|
|
119
126
|
'finalize.started': 'progress',
|
|
120
127
|
'finalize.completed': 'progress',
|
|
@@ -153,7 +160,7 @@ interface Accumulator {
|
|
|
153
160
|
}
|
|
154
161
|
|
|
155
162
|
export const executionNoProgressReducer = defineReducer({
|
|
156
|
-
version:
|
|
163
|
+
version: 6,
|
|
157
164
|
initial: (): Accumulator => ({ active: null, count: 0, open: [], latest: null }),
|
|
158
165
|
fold(acc, events: readonly AbEvent[]) {
|
|
159
166
|
for (const event of events) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomIds, type IdSource } from '../ids'
|
|
1
2
|
/**
|
|
2
3
|
* Settlement of foreign build executions from durable facts plus provider
|
|
3
4
|
* liveness (AUT-301). Today's completion handling hangs off the in-memory
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
* is treated as `running`. Supervision decisions reap or settle only on
|
|
12
13
|
* provider proof, never on an unknown.
|
|
13
14
|
*/
|
|
14
|
-
import { DISPATCHER } from '../events/envelope'
|
|
15
|
+
import { DISPATCHER, KERNEL } from '../events/envelope'
|
|
15
16
|
import type { AbEvent, EventWrite } from '../events/catalog'
|
|
16
17
|
import type {
|
|
17
18
|
BuildExecution,
|
|
@@ -121,11 +122,12 @@ function observationIdentity(open: {
|
|
|
121
122
|
* a recorded completion was written and publication was settled; `lost` means
|
|
122
123
|
* the provider proved the execution gone without an exit code (publication is
|
|
123
124
|
* deliberately left to the existing abandonment flow); `running` means the
|
|
124
|
-
* guest is alive or unknowable
|
|
125
|
+
* guest is alive or unknowable. Independent host attention may still be recorded. */
|
|
125
126
|
export type ExecutionSettlement = 'running' | 'settled' | 'lost'
|
|
126
127
|
|
|
127
128
|
export interface ExecutionSettlementDeps {
|
|
128
129
|
store: BuildStore
|
|
130
|
+
ids?: IdSource
|
|
129
131
|
/** The observing provider's executor. Settlement requires the `observe`
|
|
130
132
|
* capability; without it the caller supervises as before. */
|
|
131
133
|
execution: BuildExecution
|
|
@@ -163,7 +165,7 @@ export function settleExecution(
|
|
|
163
165
|
/** `settleExecution` over an already-derived open execution, for callers that
|
|
164
166
|
* hold the projection (a reducer snapshot advanced to the log tail) and so
|
|
165
167
|
* never need the event array. A `running` result or an observation error
|
|
166
|
-
* touches no event rows. */
|
|
168
|
+
* touches no event rows unless the provider also reports actionable attention. */
|
|
167
169
|
export async function settleOpenExecution(
|
|
168
170
|
deps: ExecutionSettlementDeps,
|
|
169
171
|
slug: string,
|
|
@@ -177,6 +179,22 @@ export async function settleOpenExecution(
|
|
|
177
179
|
} catch {
|
|
178
180
|
return 'running'
|
|
179
181
|
}
|
|
182
|
+
if (observation.attention) {
|
|
183
|
+
const state = (await readBuildFacts(deps.store, slug)).value.state
|
|
184
|
+
if (!state.openEscalations.some((entry) => entry.question === observation.attention))
|
|
185
|
+
await deps.store.append(slug, {
|
|
186
|
+
actor: KERNEL,
|
|
187
|
+
type: 'escalation.raised',
|
|
188
|
+
payload: {
|
|
189
|
+
id: (deps.ids ?? randomIds())('esc'),
|
|
190
|
+
phase: state.phase ?? 'setup',
|
|
191
|
+
...(state.round > 0 ? { round: state.round } : {}),
|
|
192
|
+
source: 'policy',
|
|
193
|
+
policyCause: 'non-retryable-phase-failure',
|
|
194
|
+
question: observation.attention,
|
|
195
|
+
},
|
|
196
|
+
})
|
|
197
|
+
}
|
|
180
198
|
if (observation.state === 'running') return 'running'
|
|
181
199
|
|
|
182
200
|
const request = (await readBuildFacts(deps.store, slug)).value.state.drainingExecutions?.[
|