@defrex/autobuild 1.0.1 → 1.1.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 +6 -6
- package/SPEC.md +360 -229
- package/docs/answering-blocked-builds.md +2 -2
- package/docs/architecture.md +155 -45
- package/docs/assets/headline-wide.png +0 -0
- package/docs/builds.md +4 -4
- package/docs/cli.md +4 -4
- package/docs/configuration-overview.md +4 -4
- package/docs/configuration.md +245 -210
- package/docs/dispatcher-hosting.md +2 -2
- 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/hosted-dispatcher.md +6 -3
- package/docs/hosted-service.md +16 -5
- package/docs/integration-overview.md +15 -15
- package/docs/integration-tree.md +45 -38
- package/docs/integration.md +6 -6
- package/docs/mcp.md +16 -15
- package/docs/{landing-policy.md → merge-policy.md} +42 -24
- package/docs/migration-1.0.md +17 -13
- package/docs/operating.md +41 -18
- package/docs/operator-api.md +91 -15
- package/docs/operator-surfaces.md +8 -4
- package/docs/overview.md +3 -3
- package/docs/remote-store-protocol.md +76 -11
- package/docs/remote-ticket-protocol.md +1 -1
- package/docs/restacking.md +54 -15
- package/docs/setup.md +41 -6
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +6 -6
- package/docs/ticket-dependencies.md +7 -7
- package/docs/tickets.md +8 -2
- package/docs/troubleshooting.md +2 -2
- package/docs/upgrading.md +8 -3
- package/docs/verification.md +60 -14
- package/package.json +7 -5
- 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/build-control.ts +83 -28
- 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.ts +35 -9
- package/packages/core/src/cli/env.ts +4 -0
- package/packages/core/src/cli/help.ts +30 -23
- package/packages/core/src/cli/main.ts +24 -8
- package/packages/core/src/cli/node-verification-provenance.ts +1 -97
- package/packages/core/src/cli/publication-settlement.ts +43 -20
- package/packages/core/src/cli/repository-status.ts +20 -9
- package/packages/core/src/cli/status.ts +42 -5
- package/packages/core/src/cli/store-opening.ts +6 -1
- package/packages/core/src/cli/terminal.ts +22 -1
- package/packages/core/src/cli/terminals.ts +14 -10
- 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 +634 -511
- 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/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/schema.ts +86 -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/globs.ts +1 -1
- package/packages/core/src/events/payloads.ts +70 -1
- package/packages/core/src/events/policy.ts +7 -0
- package/packages/core/src/events/repository.ts +2 -4
- package/packages/core/src/events/sessions.ts +6 -6
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +571 -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 +82 -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 +1 -7
- package/packages/core/src/operator/landings.ts +5 -1
- package/packages/core/src/operator/presentation.ts +6 -1
- package/packages/core/src/operator/query.ts +14 -18
- package/packages/core/src/operator/registry.ts +17 -6
- 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/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/workspace/build-execution.ts +3 -1
- package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +59 -39
- 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 +522 -98
- package/packages/core/src/processes/dispatcher.ts +186 -101
- package/packages/core/src/processes/execution-no-progress.ts +8 -1
- 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/{integration → scenarios}/harness.ts +330 -317
- 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 +113 -1
- 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 +5081 -4160
- package/packages/core/src/store/remote/client.ts +47 -1
- package/packages/core/src/store/remote/compatibility.ts +2 -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/index.ts +11 -1
- 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 +253 -118
- package/skills/guide/references/integration-tree.md +45 -38
- package/skills/guide/references/{landing-policy.md → merge-policy.md} +42 -24
- package/skills/guide/references/migration-1.0.md +17 -13
- package/skills/guide/references/operator-api.md +91 -15
- package/skills/guide/references/remote-store-protocol.md +76 -11
- package/skills/guide/references/remote-ticket-protocol.md +1 -1
- package/skills/guide/references/restacking.md +54 -15
- package/skills/guide/references/setup.md +41 -6
- package/skills/guide/references/spec-standard.md +6 -6
- package/skills/guide/references/ticket-dependencies.md +7 -7
- package/skills/implement/SKILL.md +43 -17
- package/skills/operate/SKILL.md +117 -116
- 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 +19 -19
- package/skills/tickets/SKILL.md +9 -7
- package/templates/autobuild.toml +1 -1
- package/templates/hosted-service/package.json +2 -2
- 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
|
|
|
@@ -631,11 +629,6 @@ export interface DispatcherDeps {
|
|
|
631
629
|
* supplies cancellation and treats every absence/failure/invalid result as a
|
|
632
630
|
* local deterministic fallback, so naming can never prevent build creation. */
|
|
633
631
|
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
632
|
/** Settle pending publication for `slug` after durable proof that the
|
|
640
633
|
* guest execution ended. Supplied by the DispatchLoop; the settlement stage
|
|
641
634
|
* invokes it only on a recorded completion. */
|
|
@@ -807,7 +800,16 @@ export class Dispatcher {
|
|
|
807
800
|
revision = artifact.meta.revision
|
|
808
801
|
pinned = parseEffectiveBuildConfig(artifact)
|
|
809
802
|
}
|
|
810
|
-
return decideNextFromFacts(
|
|
803
|
+
return decideNextFromFacts(
|
|
804
|
+
state,
|
|
805
|
+
log,
|
|
806
|
+
await capturedBuildConfig(
|
|
807
|
+
this.store,
|
|
808
|
+
slug,
|
|
809
|
+
state,
|
|
810
|
+
composeBuildConfig(pinned, this.deps.config),
|
|
811
|
+
),
|
|
812
|
+
)
|
|
811
813
|
} catch (error) {
|
|
812
814
|
report.blockedDiagnostics.push(
|
|
813
815
|
`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 +865,11 @@ export class Dispatcher {
|
|
|
863
865
|
if (settle === undefined) return undefined
|
|
864
866
|
return async (slug) => {
|
|
865
867
|
if (await deferMixedVersion(this.store, slug)) return
|
|
866
|
-
|
|
867
|
-
|
|
868
|
+
try {
|
|
869
|
+
await settle(slug)
|
|
870
|
+
} finally {
|
|
871
|
+
await this.store.refreshBuild(slug)
|
|
872
|
+
}
|
|
868
873
|
}
|
|
869
874
|
}
|
|
870
875
|
|
|
@@ -999,61 +1004,6 @@ export class Dispatcher {
|
|
|
999
1004
|
// launch. Pending control commands still launch the runner so the kernel
|
|
1000
1005
|
// can settle them under the repository lease.
|
|
1001
1006
|
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
1007
|
return report
|
|
1058
1008
|
}
|
|
1059
1009
|
|
|
@@ -2299,6 +2249,67 @@ export class Dispatcher {
|
|
|
2299
2249
|
}
|
|
2300
2250
|
}
|
|
2301
2251
|
}
|
|
2252
|
+
if (
|
|
2253
|
+
state.kind !== 'node' &&
|
|
2254
|
+
state.status !== 'queued' &&
|
|
2255
|
+
state.status !== 'aborted' &&
|
|
2256
|
+
state.prState !== 'merged' &&
|
|
2257
|
+
state.prState !== 'closed'
|
|
2258
|
+
) {
|
|
2259
|
+
const facts = await this.store.buildFacts(record.slug)
|
|
2260
|
+
const target = facts.log.restack.target
|
|
2261
|
+
if (target && target.branch === facts.state.baseBranch) {
|
|
2262
|
+
let sample = {
|
|
2263
|
+
branch: target.branch,
|
|
2264
|
+
sha: target.sha,
|
|
2265
|
+
head: null,
|
|
2266
|
+
count: null,
|
|
2267
|
+
} as EventPayload<'target.distance'>
|
|
2268
|
+
try {
|
|
2269
|
+
sample = await sampleTargetDistance({
|
|
2270
|
+
...target,
|
|
2271
|
+
buildBranch: record.branch ?? `ab/${record.slug}`,
|
|
2272
|
+
...(facts.workspace && !isRemoteWorkspace(facts.workspace)
|
|
2273
|
+
? { localPath: this.forgeWorkspacePathOf(facts.workspace) }
|
|
2274
|
+
: {}),
|
|
2275
|
+
exec: this.deps.exec,
|
|
2276
|
+
forge: this.deps.forge,
|
|
2277
|
+
})
|
|
2278
|
+
} catch (error) {
|
|
2279
|
+
if (
|
|
2280
|
+
error instanceof ForgeRequestDeferred ||
|
|
2281
|
+
(isForgeFailure(error) && error.details.kind === 'rate-limited')
|
|
2282
|
+
)
|
|
2283
|
+
throw error
|
|
2284
|
+
if (facts.log.restack.distance?.count != null)
|
|
2285
|
+
report.janitorDiagnostics.push(
|
|
2286
|
+
`build ${record.slug}: target distance failed — ${error instanceof Error ? error.message : String(error)}`,
|
|
2287
|
+
)
|
|
2288
|
+
}
|
|
2289
|
+
const current = await this.store.buildFacts(record.slug)
|
|
2290
|
+
if (
|
|
2291
|
+
current.state.status !== 'done' &&
|
|
2292
|
+
current.state.status !== 'aborted' &&
|
|
2293
|
+
current.state.prState !== 'merged' &&
|
|
2294
|
+
current.state.prState !== 'closed' &&
|
|
2295
|
+
current.state.baseBranch === target.branch &&
|
|
2296
|
+
current.log.restack.target?.sha === target.sha &&
|
|
2297
|
+
current.log.restack.completedAt === facts.log.restack.completedAt &&
|
|
2298
|
+
current.state.implement.commits?.head === facts.state.implement.commits?.head &&
|
|
2299
|
+
(current.log.restack.distance?.branch !== sample.branch ||
|
|
2300
|
+
current.log.restack.distance?.sha !== sample.sha ||
|
|
2301
|
+
current.log.restack.distance?.head !== sample.head ||
|
|
2302
|
+
current.log.restack.distance?.count !== sample.count)
|
|
2303
|
+
) {
|
|
2304
|
+
await this.store.append(record.slug, {
|
|
2305
|
+
actor: DISPATCHER,
|
|
2306
|
+
type: 'target.distance',
|
|
2307
|
+
payload: sample,
|
|
2308
|
+
})
|
|
2309
|
+
loaded = undefined
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2302
2313
|
if (state.pr) {
|
|
2303
2314
|
await this.checkPr(
|
|
2304
2315
|
record,
|
|
@@ -2318,7 +2329,7 @@ export class Dispatcher {
|
|
|
2318
2329
|
}
|
|
2319
2330
|
await completeNodePoll()
|
|
2320
2331
|
} catch (error) {
|
|
2321
|
-
if (error instanceof
|
|
2332
|
+
if (error instanceof ForgeRequestDeferred) {
|
|
2322
2333
|
attempted = false
|
|
2323
2334
|
return
|
|
2324
2335
|
}
|
|
@@ -3041,7 +3052,10 @@ export class Dispatcher {
|
|
|
3041
3052
|
const config = artifact
|
|
3042
3053
|
? composeBuildConfig(parseEffectiveBuildConfig(artifact), this.deps.config)
|
|
3043
3054
|
: this.deps.config
|
|
3044
|
-
return integrationVerified(
|
|
3055
|
+
return integrationVerified(
|
|
3056
|
+
candidate,
|
|
3057
|
+
await capturedBuildConfig(store, record.slug, candidate, config),
|
|
3058
|
+
)
|
|
3045
3059
|
}
|
|
3046
3060
|
const facts = await store.buildFacts(record.slug)
|
|
3047
3061
|
const decision = await this.decideBuild(record.slug, facts.state, facts.log, report)
|
|
@@ -3074,8 +3088,7 @@ export class Dispatcher {
|
|
|
3074
3088
|
nativeCancelled || prState.nativeAutoMerge === false
|
|
3075
3089
|
? { kind: 'applied' as const }
|
|
3076
3090
|
: await forge.setAutoMerge(workspacePath, pr.number, false)
|
|
3077
|
-
if (cancellation.kind !== 'applied')
|
|
3078
|
-
throw new Error('Native landing cancellation unconfirmed')
|
|
3091
|
+
if (cancellation.kind !== 'applied') throw new Error('Native merge cancellation unconfirmed')
|
|
3079
3092
|
nativeCancelled = true
|
|
3080
3093
|
}
|
|
3081
3094
|
if (isReady) {
|
|
@@ -3090,11 +3103,11 @@ export class Dispatcher {
|
|
|
3090
3103
|
state = current
|
|
3091
3104
|
break
|
|
3092
3105
|
}
|
|
3093
|
-
if (!record.ticket) throw new Error('
|
|
3106
|
+
if (!record.ticket) throw new Error('Merge policy requires a readable source ticket')
|
|
3094
3107
|
const ticket = await tickets.get(await this.currentTicketId(record))
|
|
3095
3108
|
if (!ticket)
|
|
3096
3109
|
throw new Error(
|
|
3097
|
-
`
|
|
3110
|
+
`Merge policy source ticket ${record.ticket.id} is unavailable; retrying on next poll`,
|
|
3098
3111
|
)
|
|
3099
3112
|
const input = {
|
|
3100
3113
|
from: integration ? ('node' as const) : ('leaf' as const),
|
|
@@ -3138,7 +3151,7 @@ export class Dispatcher {
|
|
|
3138
3151
|
? { kind: 'applied' as const }
|
|
3139
3152
|
: await forge.setAutoMerge(workspacePath, pr.number, false)
|
|
3140
3153
|
if (result.kind !== 'applied')
|
|
3141
|
-
throw new Error('Native
|
|
3154
|
+
throw new Error('Native merge cancellation unconfirmed; retrying')
|
|
3142
3155
|
const current = (await store.buildFacts(record.slug)).state
|
|
3143
3156
|
if (current.landing?.native?.enabled !== false)
|
|
3144
3157
|
await store.append(record.slug, {
|
|
@@ -3218,7 +3231,10 @@ export class Dispatcher {
|
|
|
3218
3231
|
candidate.status === 'aborted' ||
|
|
3219
3232
|
candidate.openEscalations.length ||
|
|
3220
3233
|
candidate.pendingCommands.length ||
|
|
3221
|
-
!integrationVerified(
|
|
3234
|
+
!integrationVerified(
|
|
3235
|
+
candidate,
|
|
3236
|
+
await capturedBuildConfig(store, record.slug, candidate, config),
|
|
3237
|
+
)
|
|
3222
3238
|
)
|
|
3223
3239
|
return false
|
|
3224
3240
|
await this.observeIntegration(record.slug, true)
|
|
@@ -3277,7 +3293,7 @@ export class Dispatcher {
|
|
|
3277
3293
|
type: 'integration.abandoned',
|
|
3278
3294
|
payload: {
|
|
3279
3295
|
id: intent.id,
|
|
3280
|
-
reason: 'Nested
|
|
3296
|
+
reason: 'Nested merge eligibility changed before reservation',
|
|
3281
3297
|
},
|
|
3282
3298
|
})
|
|
3283
3299
|
return
|
|
@@ -3341,7 +3357,7 @@ export class Dispatcher {
|
|
|
3341
3357
|
{
|
|
3342
3358
|
code: 'unproven-gate-state',
|
|
3343
3359
|
detail:
|
|
3344
|
-
'Frozen destination node generation is unavailable or disagrees with its branch. Native
|
|
3360
|
+
'Frozen destination node generation is unavailable or disagrees with its branch. Native merge is withheld; human action required.',
|
|
3345
3361
|
},
|
|
3346
3362
|
pr.number,
|
|
3347
3363
|
commandSeq,
|
|
@@ -3386,7 +3402,7 @@ export class Dispatcher {
|
|
|
3386
3402
|
if (enableSeq === undefined) return
|
|
3387
3403
|
const cancelled = await forge.setAutoMerge(workspacePath, pr.number, false)
|
|
3388
3404
|
if (cancelled.kind !== 'applied')
|
|
3389
|
-
throw new Error('Native
|
|
3405
|
+
throw new Error('Native merge cancellation unconfirmed; retrying')
|
|
3390
3406
|
const attempt = (retry?.attempt ?? 0) + 1
|
|
3391
3407
|
await store.append(record.slug, {
|
|
3392
3408
|
actor: DISPATCHER,
|
|
@@ -3604,7 +3620,7 @@ export class Dispatcher {
|
|
|
3604
3620
|
id: this.deps.ids('obs'),
|
|
3605
3621
|
kind: 'followup',
|
|
3606
3622
|
summary:
|
|
3607
|
-
'
|
|
3623
|
+
'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
3624
|
refs: ['landing-contrary-to-policy'],
|
|
3609
3625
|
},
|
|
3610
3626
|
})
|
|
@@ -4445,7 +4461,13 @@ export class Dispatcher {
|
|
|
4445
4461
|
if (record.lease) {
|
|
4446
4462
|
if (new Date(record.lease.expiresAt).getTime() > now) continue // healthy
|
|
4447
4463
|
} else if (now - new Date(record.updatedAt).getTime() < this.leaseTtlMs) {
|
|
4448
|
-
|
|
4464
|
+
const facts = await this.store.buildFacts(record.slug)
|
|
4465
|
+
const cleanup = facts.state.verifyStage.cleanupExecutionSeq
|
|
4466
|
+
if (
|
|
4467
|
+
facts.lastExecution !== 'relaunch' &&
|
|
4468
|
+
!(cleanup !== undefined && facts.state.verifyStage.executionSeq <= cleanup)
|
|
4469
|
+
)
|
|
4470
|
+
continue // absent lease within the first-claim grace (see DispatcherOpts)
|
|
4449
4471
|
}
|
|
4450
4472
|
const facts = await this.store.buildFacts(record.slug)
|
|
4451
4473
|
const state = facts.state
|
|
@@ -4465,6 +4487,27 @@ export class Dispatcher {
|
|
|
4465
4487
|
!(await this.dispatchBudget(record.slug))
|
|
4466
4488
|
)
|
|
4467
4489
|
continue
|
|
4490
|
+
const pendingRewrite = facts.publication.latestUncompletedRequest()?.payload
|
|
4491
|
+
const retryIntent =
|
|
4492
|
+
pendingRewrite?.operation === 'reconcile' && pendingRewrite.rewrite
|
|
4493
|
+
? { operation: 'reconcile' as const, id: pendingRewrite.rewrite.id }
|
|
4494
|
+
: facts.log.restack.intent
|
|
4495
|
+
? { operation: 'restack' as const, id: facts.log.restack.intent.id }
|
|
4496
|
+
: undefined
|
|
4497
|
+
// Publication waits must not prevent a replacement runner from
|
|
4498
|
+
// acknowledging controls, including abort on an exhausted episode.
|
|
4499
|
+
if (retryIntent && state.pendingCommands.length === 0) {
|
|
4500
|
+
try {
|
|
4501
|
+
await publicationRetryGate(
|
|
4502
|
+
{ store: this.store, slug: record.slug, clock: this.deps.clock, actor: DISPATCHER },
|
|
4503
|
+
retryIntent.operation,
|
|
4504
|
+
retryIntent.id,
|
|
4505
|
+
)
|
|
4506
|
+
} catch (error) {
|
|
4507
|
+
if (error instanceof ForgeRequestDeferred) continue
|
|
4508
|
+
throw error
|
|
4509
|
+
}
|
|
4510
|
+
}
|
|
4468
4511
|
const decision = await this.decideBuild(record.slug, state, facts.log, report)
|
|
4469
4512
|
if (decision === undefined) continue
|
|
4470
4513
|
if (state.status === 'done' || state.status === 'aborted') continue
|
|
@@ -5000,7 +5043,7 @@ export class Dispatcher {
|
|
|
5000
5043
|
if (state.pendingCommands.some((c) => c.command === 'abort'))
|
|
5001
5044
|
return `target node ${ticket.target} is closing`
|
|
5002
5045
|
if (state.integration?.intent && !state.integration.landing)
|
|
5003
|
-
return `target node ${ticket.target} is
|
|
5046
|
+
return `target node ${ticket.target} is merging`
|
|
5004
5047
|
if (!digest.nodeOpened || !record.branch) return `target node ${ticket.target} is not yet open`
|
|
5005
5048
|
return {
|
|
5006
5049
|
target: {
|
|
@@ -5440,9 +5483,14 @@ export class Dispatcher {
|
|
|
5440
5483
|
)
|
|
5441
5484
|
return
|
|
5442
5485
|
const artifact = await this.store.getArtifact(record.slug, BUILD_EFFECTIVE_CONFIG_ARTIFACT)
|
|
5443
|
-
const config =
|
|
5444
|
-
|
|
5445
|
-
|
|
5486
|
+
const config = await capturedBuildConfig(
|
|
5487
|
+
this.store,
|
|
5488
|
+
record.slug,
|
|
5489
|
+
state,
|
|
5490
|
+
artifact
|
|
5491
|
+
? composeBuildConfig(parseEffectiveBuildConfig(artifact), this.deps.config)
|
|
5492
|
+
: this.deps.config,
|
|
5493
|
+
)
|
|
5446
5494
|
if (
|
|
5447
5495
|
!integrationCurrent(state) ||
|
|
5448
5496
|
state.integration?.cycle?.config !== integrationConfig(config)
|
|
@@ -5463,6 +5511,12 @@ export class Dispatcher {
|
|
|
5463
5511
|
return
|
|
5464
5512
|
const exact = await forge.compareBranches(state.baseBranch!, record.branch!)
|
|
5465
5513
|
if (exact.parentSha !== comparison.parentSha || exact.headSha !== comparison.headSha) return
|
|
5514
|
+
const cycle = {
|
|
5515
|
+
id: this.deps.ids('integration-cycle'),
|
|
5516
|
+
parent: exact.parentSha,
|
|
5517
|
+
head: exact.headSha,
|
|
5518
|
+
}
|
|
5519
|
+
let context: string | undefined
|
|
5466
5520
|
await this.withKernelRepository(async (path) => {
|
|
5467
5521
|
const head = await forge.rewrite!.snapshot({
|
|
5468
5522
|
workspacePath: path,
|
|
@@ -5476,18 +5530,49 @@ export class Dispatcher {
|
|
|
5476
5530
|
ref: `refs/autobuild/archive/${record.slug}/${head}`,
|
|
5477
5531
|
sha: head,
|
|
5478
5532
|
})
|
|
5533
|
+
if (
|
|
5534
|
+
config.verify.steps.some((step) => config.verify.stepConfigs[step]?.kind === 'agent')
|
|
5535
|
+
) {
|
|
5536
|
+
const exec = forge.kernelExec ?? this.deps.exec
|
|
5537
|
+
// Snapshot fetch brings the complete head ancestry, including merge sides.
|
|
5538
|
+
// A parent may have advanced independently and need its own fetch.
|
|
5539
|
+
const parent = await exec(['git', 'cat-file', '-e', `${exact.parentSha}^{commit}`], {
|
|
5540
|
+
cwd: path,
|
|
5541
|
+
})
|
|
5542
|
+
if (parent.exitCode !== 0) {
|
|
5543
|
+
const fetched = await exec(['git', 'fetch', '--no-tags', 'origin', exact.parentSha], {
|
|
5544
|
+
cwd: path,
|
|
5545
|
+
})
|
|
5546
|
+
if (fetched.exitCode !== 0)
|
|
5547
|
+
throw new Error(`cannot fetch node verification parent: ${fetched.stderr}`)
|
|
5548
|
+
}
|
|
5549
|
+
context = await prepareNodeVerificationContext(
|
|
5550
|
+
this.store,
|
|
5551
|
+
record.repo,
|
|
5552
|
+
cycle,
|
|
5553
|
+
current,
|
|
5554
|
+
{ exec, workspacePath: path },
|
|
5555
|
+
)
|
|
5556
|
+
}
|
|
5479
5557
|
})
|
|
5480
5558
|
if (!(await this.store.renewNodeWriter(record.slug, holder))) return
|
|
5481
|
-
await this.store.
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5559
|
+
const prepared = await this.store.appendWithArtifactsIfCurrent(
|
|
5560
|
+
record.slug,
|
|
5561
|
+
current.lastSeq,
|
|
5562
|
+
context === undefined ? [] : [{ kind: NODE_VERIFICATION_CONTEXT, content: context }],
|
|
5563
|
+
(deposited) => ({
|
|
5564
|
+
actor: DISPATCHER,
|
|
5565
|
+
type: 'integration.prepared',
|
|
5566
|
+
payload: {
|
|
5567
|
+
...cycle,
|
|
5568
|
+
config: integrationConfig(config),
|
|
5569
|
+
...(deposited[0]
|
|
5570
|
+
? { context: { kind: NODE_VERIFICATION_CONTEXT, rev: deposited[0].revision } }
|
|
5571
|
+
: {}),
|
|
5572
|
+
},
|
|
5573
|
+
}),
|
|
5574
|
+
)
|
|
5575
|
+
if (!prepared) return
|
|
5491
5576
|
} finally {
|
|
5492
5577
|
await this.store.releaseNodeWriter(record.slug, holder)
|
|
5493
5578
|
}
|
|
@@ -5569,7 +5654,7 @@ export class Dispatcher {
|
|
|
5569
5654
|
head: record.branch,
|
|
5570
5655
|
base: state.baseBranch,
|
|
5571
5656
|
title: `Integration: ${record.ticket?.id ?? record.slug}`,
|
|
5572
|
-
body: `Integration build ${record.slug}. Target: ${state.target?.ticket.id ?? state.baseBranch}. Human
|
|
5657
|
+
body: `Integration build ${record.slug}. Target: ${state.target?.ticket.id ?? state.baseBranch}. Human merge required.`,
|
|
5573
5658
|
})
|
|
5574
5659
|
} catch (error) {
|
|
5575
5660
|
if (
|
|
@@ -5616,7 +5701,7 @@ export class Dispatcher {
|
|
|
5616
5701
|
if (!landing || entry.digest.nodeContribution?.landing === landing) return
|
|
5617
5702
|
const state = inputs.states.get(slug)!
|
|
5618
5703
|
if (!state.pr || !forge.inspectLandingPr)
|
|
5619
|
-
throw new Error('cannot establish
|
|
5704
|
+
throw new Error('cannot establish merged node source head')
|
|
5620
5705
|
visiting.add(slug)
|
|
5621
5706
|
const pr = await forge.inspectLandingPr(path, state.pr.number)
|
|
5622
5707
|
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) {
|
|
@@ -15,6 +15,7 @@ export const POLICY_PHASE_FAILURE_RESET_SCOPES = {
|
|
|
15
15
|
'execution-no-progress': 'none',
|
|
16
16
|
'setup-failure-limit': 'none',
|
|
17
17
|
'infrastructure-failure-limit': 'none',
|
|
18
|
+
'publication-retry-limit': 'none',
|
|
18
19
|
'phase-attempt-limit': 'matching-round',
|
|
19
20
|
'non-retryable-phase-failure': 'matching-round',
|
|
20
21
|
} as const satisfies Record<PolicyEscalationCause, PhaseFailureBudgetResetScope>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PublicationRetryPersistenceError } from '../kernel/publication-retry'
|
|
1
2
|
import { ForgeRequestDeferred } from '../ports/forge-request-context'
|
|
2
3
|
import { isRemoteWorkspace } from '../events/workspace-remote'
|
|
3
4
|
/**
|
|
@@ -63,7 +64,11 @@ export async function settlePublicationFactsBeforeRelease(
|
|
|
63
64
|
try {
|
|
64
65
|
await deps.settlePublication?.(slug)
|
|
65
66
|
} catch (error) {
|
|
66
|
-
if (
|
|
67
|
+
if (
|
|
68
|
+
error instanceof ForgeRequestDeferred ||
|
|
69
|
+
error instanceof PublicationRetryPersistenceError
|
|
70
|
+
)
|
|
71
|
+
throw error
|
|
67
72
|
/* Summary is best effort. */
|
|
68
73
|
}
|
|
69
74
|
return (await readBuildFacts(deps.store, slug)).value
|
|
@@ -73,7 +78,8 @@ export async function settlePublicationFactsBeforeRelease(
|
|
|
73
78
|
try {
|
|
74
79
|
await deps.settlePublication?.(slug)
|
|
75
80
|
} catch (error) {
|
|
76
|
-
if (error instanceof ForgeRequestDeferred
|
|
81
|
+
if (error instanceof ForgeRequestDeferred || error instanceof PublicationRetryPersistenceError)
|
|
82
|
+
throw error
|
|
77
83
|
/* Record loss before release. */
|
|
78
84
|
}
|
|
79
85
|
const refreshed = (await readBuildFacts(deps.store, slug)).value
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
publicationRetryState,
|
|
3
|
+
type PublicationOperation,
|
|
4
|
+
type PublicationRetryEvent,
|
|
5
|
+
} from '../kernel/publication-retry'
|
|
1
6
|
import { reconcileHead } from '../kernel/reconcile-head'
|
|
2
7
|
import type { AbEvent } from '../events/catalog'
|
|
3
8
|
import { defineReducer, type IncrementalReducer } from '../kernel/incremental'
|
|
@@ -28,10 +33,11 @@ type LedgerItem =
|
|
|
28
33
|
* any type) whose seq exceeds the request's. */
|
|
29
34
|
export interface PublicationLedger {
|
|
30
35
|
ledger: LedgerItem[]
|
|
36
|
+
retries: PublicationRetryEvent[]
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
/** Bump when `PublicationLedger` or its fold changes. */
|
|
34
|
-
export const PUBLICATION_STATE_REDUCER_VERSION =
|
|
40
|
+
export const PUBLICATION_STATE_REDUCER_VERSION = 6
|
|
35
41
|
|
|
36
42
|
function compact(event: AbEvent): LedgerItem | undefined {
|
|
37
43
|
switch (event.type) {
|
|
@@ -111,6 +117,7 @@ function itemCompletes(item: LedgerItem, request: PublicationRequest): boolean {
|
|
|
111
117
|
|
|
112
118
|
/** The publication selectors, derived from one ledger. */
|
|
113
119
|
export interface PublicationView {
|
|
120
|
+
retry(operation: PublicationOperation, id: string): ReturnType<typeof publicationRetryState>
|
|
114
121
|
requestCompleted(request: PublicationRequest): boolean
|
|
115
122
|
requestSettled(request: PublicationRequest): boolean
|
|
116
123
|
latestUncompletedRequest(): PublicationRequest | undefined
|
|
@@ -119,7 +126,10 @@ export interface PublicationView {
|
|
|
119
126
|
pending(): boolean
|
|
120
127
|
}
|
|
121
128
|
|
|
122
|
-
function viewOf(
|
|
129
|
+
function viewOf(
|
|
130
|
+
ledger: readonly LedgerItem[],
|
|
131
|
+
retries: readonly PublicationRetryEvent[],
|
|
132
|
+
): PublicationView {
|
|
123
133
|
const requestCompleted = (request: PublicationRequest): boolean =>
|
|
124
134
|
ledger.some((item) => itemCompletes(item, request))
|
|
125
135
|
|
|
@@ -153,6 +163,7 @@ function viewOf(ledger: readonly LedgerItem[]): PublicationView {
|
|
|
153
163
|
}
|
|
154
164
|
|
|
155
165
|
return {
|
|
166
|
+
retry: (operation, id) => publicationRetryState(retries, operation, id),
|
|
156
167
|
requestCompleted,
|
|
157
168
|
requestSettled,
|
|
158
169
|
latestUncompletedRequest,
|
|
@@ -172,9 +183,36 @@ export const publicationStateReducer: IncrementalReducer<
|
|
|
172
183
|
PublicationView
|
|
173
184
|
> = defineReducer<PublicationLedger, AbEvent, PublicationView>({
|
|
174
185
|
version: PUBLICATION_STATE_REDUCER_VERSION,
|
|
175
|
-
initial: () => ({ ledger: [] }),
|
|
186
|
+
initial: () => ({ ledger: [], retries: [] }),
|
|
176
187
|
fold(acc, events) {
|
|
177
188
|
for (const event of events) {
|
|
189
|
+
if (
|
|
190
|
+
event.type === 'publication.retry-scheduled' ||
|
|
191
|
+
event.type === 'publication.retry-exhausted' ||
|
|
192
|
+
event.type === 'escalation.answered'
|
|
193
|
+
)
|
|
194
|
+
acc.retries.push(event)
|
|
195
|
+
if (
|
|
196
|
+
event.type === 'restack.completed' ||
|
|
197
|
+
event.type === 'restack.contended' ||
|
|
198
|
+
event.type === 'reconcile.contended' ||
|
|
199
|
+
(event.type === 'reconcile.completed' && 'rewriteId' in event.payload)
|
|
200
|
+
) {
|
|
201
|
+
const id =
|
|
202
|
+
'id' in event.payload
|
|
203
|
+
? event.payload.id
|
|
204
|
+
: 'rewriteId' in event.payload
|
|
205
|
+
? event.payload.rewriteId
|
|
206
|
+
: undefined
|
|
207
|
+
const operation = event.type.startsWith('restack.') ? 'restack' : 'reconcile'
|
|
208
|
+
acc.retries = acc.retries.filter(
|
|
209
|
+
(e) =>
|
|
210
|
+
e.type === 'escalation.answered' ||
|
|
211
|
+
e.payload.operation !== operation ||
|
|
212
|
+
e.payload.rewriteId !== id,
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
if (event.type === 'workspace.released') acc.retries = []
|
|
178
216
|
const item = compact(event)
|
|
179
217
|
const last = acc.ledger[acc.ledger.length - 1]
|
|
180
218
|
if (item !== undefined) acc.ledger.push(item)
|
|
@@ -182,7 +220,7 @@ export const publicationStateReducer: IncrementalReducer<
|
|
|
182
220
|
else acc.ledger.push({ t: 'barrier', seq: event.seq })
|
|
183
221
|
}
|
|
184
222
|
},
|
|
185
|
-
finish: (acc) => viewOf(acc.ledger),
|
|
223
|
+
finish: (acc) => viewOf(acc.ledger, acc.retries),
|
|
186
224
|
})
|
|
187
225
|
|
|
188
226
|
export function publicationRequestCompleted(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OperatorIdentity, OperatorPresence } from '../store/operator-presence'
|
|
1
2
|
import { readBuildDigests } from '../store/reduced-reads'
|
|
2
3
|
/** Repository-scoped sequencing and metadata coordination. Current reductions
|
|
3
4
|
* come exclusively from persisted values; raw methods return actual event output. */
|
|
@@ -461,6 +462,19 @@ export class RepoViewStore implements BuildStore {
|
|
|
461
462
|
await this.backing.releaseLease(slug, holder)
|
|
462
463
|
this.invalidate()
|
|
463
464
|
}
|
|
465
|
+
upsertOperatorPresence(
|
|
466
|
+
repo: string,
|
|
467
|
+
identity: OperatorIdentity,
|
|
468
|
+
signal?: AbortSignal,
|
|
469
|
+
): Promise<OperatorPresence> {
|
|
470
|
+
return this.backing.upsertOperatorPresence(repo, identity, signal)
|
|
471
|
+
}
|
|
472
|
+
removeOperatorPresence(repo: string, id: string, signal?: AbortSignal): Promise<void> {
|
|
473
|
+
return this.backing.removeOperatorPresence(repo, id, signal)
|
|
474
|
+
}
|
|
475
|
+
listOperatorPresence(repo: string): Promise<OperatorPresence[]> {
|
|
476
|
+
return this.backing.listOperatorPresence(repo)
|
|
477
|
+
}
|
|
464
478
|
ensureRepo(repo: string): Promise<RepositoryRecord> {
|
|
465
479
|
return this.backing.ensureRepo(repo)
|
|
466
480
|
}
|