@defrex/autobuild 0.13.0 → 1.0.0-beta.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 +5 -3
- package/SPEC.md +673 -99
- package/bin/ab-dispatch-kernel.ts +4 -6
- package/docs/architecture.md +322 -75
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +112 -12
- package/docs/hosted-service.md +20 -2
- package/docs/integration-tree.md +117 -0
- package/docs/landing-policy.md +150 -0
- package/docs/mcp.md +24 -0
- package/docs/migration-1.0.md +68 -0
- package/docs/operator-api.md +20 -9
- package/docs/remote-store-protocol.md +114 -9
- package/docs/remote-ticket-protocol.md +26 -5
- package/docs/restacking.md +79 -0
- package/docs/setup.md +49 -6
- package/docs/ticket-dependencies.md +69 -0
- package/docs/ticket-migration.md +8 -0
- package/package.json +4 -3
- package/packages/core/src/cli/attention.ts +40 -163
- package/packages/core/src/cli/build-control.ts +75 -55
- package/packages/core/src/cli/bulk-control.ts +3 -2
- package/packages/core/src/cli/context.ts +68 -78
- package/packages/core/src/cli/dashboard/actions.ts +6 -3
- package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
- package/packages/core/src/cli/dashboard/live.ts +5 -0
- package/packages/core/src/cli/dashboard/model.ts +178 -40
- package/packages/core/src/cli/dashboard/poll.ts +15 -9
- package/packages/core/src/cli/dashboard/refresh.ts +176 -0
- package/packages/core/src/cli/dashboard/render.ts +78 -28
- package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
- package/packages/core/src/cli/dashboard/selection.ts +7 -1
- package/packages/core/src/cli/dashboard/tree.ts +107 -0
- package/packages/core/src/cli/dispatch-frontend.ts +173 -169
- package/packages/core/src/cli/dispatch-process.ts +14 -7
- package/packages/core/src/cli/dispatch-repository-feed.ts +196 -0
- package/packages/core/src/cli/dispatch.ts +397 -214
- package/packages/core/src/cli/dispatcher-liveness.ts +41 -21
- package/packages/core/src/cli/harvest.ts +71 -39
- package/packages/core/src/cli/help.ts +49 -32
- package/packages/core/src/cli/historical-build-state.ts +27 -0
- package/packages/core/src/cli/init-validation.ts +43 -2
- package/packages/core/src/cli/keyboard.ts +6 -0
- package/packages/core/src/cli/landings.ts +18 -0
- package/packages/core/src/cli/main.ts +52 -18
- package/packages/core/src/cli/mcp.ts +9 -0
- package/packages/core/src/cli/pr-attachments.ts +10 -13
- package/packages/core/src/cli/pr-summary-publication.ts +27 -60
- package/packages/core/src/cli/pr-summary.ts +43 -13
- package/packages/core/src/cli/publication-settlement.ts +177 -21
- package/packages/core/src/cli/repository-status.ts +49 -2
- package/packages/core/src/cli/status.ts +133 -36
- package/packages/core/src/cli/terminal-restore.ts +54 -0
- package/packages/core/src/cli/terminal.ts +16 -2
- package/packages/core/src/cli/terminals.ts +121 -219
- package/packages/core/src/cli/ticket-editor.ts +10 -3
- package/packages/core/src/cli/ticket.ts +115 -20
- package/packages/core/src/cli/upgrade-commit.ts +4 -0
- package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
- package/packages/core/src/cli/upgrade-landing.ts +69 -0
- package/packages/core/src/cli/upgrade.ts +16 -0
- package/packages/core/src/cli/wait.ts +194 -91
- package/packages/core/src/cli/watch.ts +111 -109
- package/packages/core/src/config/landing.ts +22 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/pipeline-source.ts +4 -3
- package/packages/core/src/config/schema.ts +3 -0
- package/packages/core/src/events/catalog.ts +48 -3
- package/packages/core/src/events/payloads.ts +295 -6
- package/packages/core/src/events/repository.ts +38 -3
- package/packages/core/src/integration/harness.ts +11 -2
- package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +3330 -119
- package/packages/core/src/kernel/auto-merge-default.ts +1 -0
- package/packages/core/src/kernel/auto-merge.ts +29 -4
- package/packages/core/src/kernel/build-identity.ts +94 -0
- package/packages/core/src/kernel/change-presence.ts +179 -0
- package/packages/core/src/kernel/dispatch-status.ts +17 -1
- package/packages/core/src/kernel/dispatcher-liveness.ts +10 -4
- package/packages/core/src/kernel/engine.ts +89 -2
- package/packages/core/src/kernel/generators/build-log.ts +23 -0
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +25 -3
- package/packages/core/src/kernel/harvest.ts +25 -23
- package/packages/core/src/kernel/integration-completeness.ts +81 -0
- package/packages/core/src/kernel/integration-landing.ts +263 -0
- package/packages/core/src/kernel/integration-stack.ts +36 -0
- package/packages/core/src/kernel/integration-state.ts +135 -0
- package/packages/core/src/kernel/landing-policy.ts +47 -0
- package/packages/core/src/kernel/landing-publication.ts +41 -0
- package/packages/core/src/kernel/landing-readiness.ts +67 -0
- package/packages/core/src/kernel/landing-state.ts +96 -0
- package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
- package/packages/core/src/kernel/log-index-value.ts +38 -0
- package/packages/core/src/kernel/log-index.ts +35 -5
- package/packages/core/src/kernel/node-landing.ts +439 -0
- package/packages/core/src/kernel/node-parent.ts +184 -0
- package/packages/core/src/kernel/node-restack-state.ts +191 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
- package/packages/core/src/kernel/node-restack.ts +274 -0
- package/packages/core/src/kernel/read-facts.ts +704 -0
- package/packages/core/src/kernel/reconcile-head.ts +51 -0
- package/packages/core/src/kernel/reconcile-restack.ts +560 -0
- package/packages/core/src/kernel/reducer-registry.ts +153 -3
- package/packages/core/src/kernel/reducer.ts +121 -6
- package/packages/core/src/kernel/repository-attention.ts +179 -0
- package/packages/core/src/kernel/service-facts.ts +135 -0
- package/packages/core/src/kernel/snapshot-parent.ts +33 -0
- package/packages/core/src/kernel/terminal-guard.ts +133 -0
- package/packages/core/src/ontology.ts +9 -1
- package/packages/core/src/operator/annotations.ts +12 -0
- package/packages/core/src/operator/control.ts +11 -6
- package/packages/core/src/operator/index.ts +6 -0
- package/packages/core/src/operator/landings.ts +35 -0
- package/packages/core/src/operator/presentation.ts +1 -0
- package/packages/core/src/operator/protocol.ts +12 -3
- package/packages/core/src/operator/query.ts +40 -21
- package/packages/core/src/operator/read-view.ts +4 -13
- package/packages/core/src/operator/registry.ts +48 -19
- package/packages/core/src/operator/requests.ts +3 -22
- package/packages/core/src/operator/sandbox.ts +10 -9
- package/packages/core/src/operator/tickets.ts +57 -11
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/ports/forge/contract.ts +91 -3
- package/packages/core/src/ports/forge/fake.ts +142 -4
- package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
- package/packages/core/src/ports/forge/github-readiness.ts +421 -0
- package/packages/core/src/ports/forge/github.ts +631 -35
- package/packages/core/src/ports/forge/local-git.ts +119 -5
- package/packages/core/src/ports/forge/readiness.ts +99 -0
- package/packages/core/src/ports/tickets/contract.ts +41 -0
- package/packages/core/src/ports/tickets/create.ts +8 -1
- package/packages/core/src/ports/tickets/fake.ts +32 -1
- package/packages/core/src/ports/tickets/file-codec.ts +7 -0
- package/packages/core/src/ports/tickets/file.ts +18 -1
- package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
- package/packages/core/src/ports/tickets/linear.ts +124 -4
- package/packages/core/src/ports/tickets/migration.ts +25 -1
- package/packages/core/src/ports/tickets/operations.ts +7 -2
- package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
- package/packages/core/src/ports/tickets/remote.ts +10 -1
- package/packages/core/src/ports/tickets/revision.ts +3 -1
- package/packages/core/src/ports/tickets/tree.ts +148 -0
- package/packages/core/src/ports/tickets/update.ts +15 -2
- package/packages/core/src/ports/types.ts +135 -5
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
- package/packages/core/src/processes/build-child.ts +6 -6
- package/packages/core/src/processes/build-runner.ts +586 -87
- package/packages/core/src/processes/dispatch-failure-budget.ts +5 -4
- package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
- package/packages/core/src/processes/dispatcher.ts +2239 -357
- package/packages/core/src/processes/execution-no-progress.ts +46 -1
- package/packages/core/src/processes/harvest-execution-state.ts +15 -9
- package/packages/core/src/processes/harvest-runner.ts +34 -70
- package/packages/core/src/processes/harvest.ts +38 -15
- package/packages/core/src/processes/infrastructure-failure-budget.ts +13 -15
- package/packages/core/src/processes/orchestrator-tick.ts +2 -2
- package/packages/core/src/processes/publication-loss.ts +35 -21
- package/packages/core/src/processes/publication-state.ts +30 -5
- package/packages/core/src/processes/repo-view.ts +244 -1130
- package/packages/core/src/processes/tick-publication.ts +110 -0
- package/packages/core/src/store/adapter.ts +23 -0
- package/packages/core/src/store/build-scope.ts +35 -0
- package/packages/core/src/store/contract.ts +909 -0
- package/packages/core/src/store/digest.ts +52 -4
- package/packages/core/src/store/local/schema.ts +26 -13
- package/packages/core/src/store/local/store.ts +296 -55
- package/packages/core/src/store/memory.ts +181 -30
- package/packages/core/src/store/phase-session.ts +34 -0
- package/packages/core/src/store/reduced-reads.ts +240 -0
- package/packages/core/src/store/reducer-value-shapes.json +18323 -0
- package/packages/core/src/store/reducer-value-validation.ts +96 -0
- package/packages/core/src/store/reducer-values.ts +145 -0
- package/packages/core/src/store/remote/client.ts +85 -0
- package/packages/core/src/store/remote/compatibility.ts +21 -9
- package/packages/core/src/store/remote/index.ts +19 -0
- package/packages/core/src/store/remote/protocol.ts +27 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/repo-state-events.ts +3 -1
- package/packages/core/src/store/repo-tick.ts +72 -0
- package/packages/core/src/store/session-handle.ts +34 -0
- package/packages/core/src/store/snapshots.ts +10 -0
- package/packages/core/src/store/subscribe.ts +1 -1
- package/packages/core/src/store/ticket-assets.ts +4 -4
- package/packages/core/src/store/types.ts +71 -6
- package/packages/core/src/testing/dispatch-read-budget.ts +215 -0
- package/packages/core/src/testing/index.ts +10 -0
- package/packages/core/src/testing/reduced-read-budget.ts +502 -0
- package/packages/core/src/testing/refresh-scheduler.ts +32 -0
- package/skills/guide/SKILL.md +116 -62
- package/skills/guide/references/integration-tree.md +117 -0
- package/skills/guide/references/landing-policy.md +150 -0
- package/skills/guide/references/migration-1.0.md +68 -0
- package/skills/guide/references/operator-api.md +13 -6
- package/skills/guide/references/plugin-authoring.md +34 -0
- package/skills/guide/references/remote-store-protocol.md +114 -9
- package/skills/guide/references/remote-ticket-protocol.md +26 -5
- package/skills/guide/references/restacking.md +79 -0
- package/skills/guide/references/setup.md +49 -6
- package/skills/guide/references/ticket-dependencies.md +69 -0
- package/skills/guide/references/ticket-migration.md +8 -0
- package/skills/operate/SKILL.md +55 -5
- package/skills/reconcile/SKILL.md +55 -48
- package/skills/spec/SKILL.md +67 -1
- package/skills/tickets/SKILL.md +55 -2
- package/templates/autobuild.toml +3 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { consentReady, consentIdentity, type ConsentReady } from './attention'
|
|
2
|
+
import { formatReadinessFailure } from '../ports/forge/readiness'
|
|
3
|
+
import { readBuildDigests } from '../store/reduced-reads'
|
|
4
|
+
import { readBuildStreamSeed, readRepositoryAttention } from '../store/reduced-reads'
|
|
5
|
+
import { buildStreamSeedReducer, type BuildStreamSeed } from '../kernel/read-facts'
|
|
6
|
+
import { historicalBuildState, historicalRepositoryAttention } from './historical-build-state'
|
|
1
7
|
import { readDispatcherLiveness } from './dispatcher-liveness'
|
|
2
8
|
import { projectDispatcherLiveness } from '../kernel/dispatcher-liveness'
|
|
3
9
|
import type { RepositoryRecord } from '../store/types'
|
|
@@ -44,7 +50,7 @@ import type { AbEvent } from '../events/catalog'
|
|
|
44
50
|
import type { EventType } from '../events/payloads'
|
|
45
51
|
import type { RepositoryEvent } from '../events/repository'
|
|
46
52
|
import {
|
|
47
|
-
|
|
53
|
+
mergeDecisionFromFacts,
|
|
48
54
|
mergeIdentity,
|
|
49
55
|
RepositoryAttention,
|
|
50
56
|
repositoryNeedsAttention,
|
|
@@ -52,7 +58,7 @@ import {
|
|
|
52
58
|
type PersistenceObservation,
|
|
53
59
|
} from './attention'
|
|
54
60
|
import type { BuildState, PrLifecycle } from '../kernel/reducer'
|
|
55
|
-
import {
|
|
61
|
+
import { buildReducer } from '../kernel/reducer'
|
|
56
62
|
import type { BuildOutcome, BuildStatus, Phase } from '../ontology'
|
|
57
63
|
import type { Exec } from '../ports/workspace/git-worktree'
|
|
58
64
|
import { PhaseSessionError } from '../store/phase-session'
|
|
@@ -81,7 +87,13 @@ const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000
|
|
|
81
87
|
const REPO_STREAM_KEY = '#repo'
|
|
82
88
|
|
|
83
89
|
/** Statuses a build can still leave; the others are terminal (§15.5). */
|
|
84
|
-
const NONTERMINAL_STATUSES: readonly BuildStatus[] = [
|
|
90
|
+
const NONTERMINAL_STATUSES: readonly BuildStatus[] = [
|
|
91
|
+
'queued',
|
|
92
|
+
'running',
|
|
93
|
+
'collecting',
|
|
94
|
+
'paused',
|
|
95
|
+
'blocked',
|
|
96
|
+
]
|
|
85
97
|
const TERMINAL_STATUSES: readonly BuildStatus[] = ['done', 'aborted']
|
|
86
98
|
|
|
87
99
|
// ── The default filter: the attention set ────────────────────────────────────
|
|
@@ -91,7 +103,11 @@ const TERMINAL_STATUSES: readonly BuildStatus[] = ['done', 'aborted']
|
|
|
91
103
|
* a watch emits exactly these — deciding what to do about a blocker or a
|
|
92
104
|
* merge stays with the caller's skill.
|
|
93
105
|
*/
|
|
94
|
-
export const BUILD_ATTENTION_EVENTS = [
|
|
106
|
+
export const BUILD_ATTENTION_EVENTS = [
|
|
107
|
+
'escalation.raised',
|
|
108
|
+
'integration.landed',
|
|
109
|
+
'node.item-conflicted',
|
|
110
|
+
] as const satisfies readonly EventType[]
|
|
95
111
|
|
|
96
112
|
// ── Glob compilation and matching ────────────────────────────────────────────
|
|
97
113
|
|
|
@@ -136,11 +152,17 @@ function validAttentionIdentity(id: unknown): boolean {
|
|
|
136
152
|
const value: unknown = JSON.parse(id)
|
|
137
153
|
return (
|
|
138
154
|
Array.isArray(value) &&
|
|
139
|
-
value.length ===
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
155
|
+
((value.length === 3 &&
|
|
156
|
+
value[0] === 'consent' &&
|
|
157
|
+
typeof value[1] === 'string' &&
|
|
158
|
+
value[1].length > 0 &&
|
|
159
|
+
Number.isSafeInteger(value[2]) &&
|
|
160
|
+
value[2] > 0) ||
|
|
161
|
+
(value.length === 2 &&
|
|
162
|
+
typeof value[0] === 'string' &&
|
|
163
|
+
value[0].length > 0 &&
|
|
164
|
+
Number.isSafeInteger(value[1]) &&
|
|
165
|
+
value[1] > 0))
|
|
144
166
|
)
|
|
145
167
|
} catch {
|
|
146
168
|
return false
|
|
@@ -295,12 +317,12 @@ export interface AttentionObservationRecord {
|
|
|
295
317
|
repo?: string
|
|
296
318
|
build: string | null
|
|
297
319
|
state: WatchRecordState | null
|
|
298
|
-
observation: MergeDecision | PersistenceObservation
|
|
320
|
+
observation: MergeDecision | PersistenceObservation | ConsentReady
|
|
299
321
|
cursor: string
|
|
300
322
|
}
|
|
301
323
|
|
|
302
324
|
export function projectAttentionRecord(
|
|
303
|
-
observation: MergeDecision | PersistenceObservation,
|
|
325
|
+
observation: MergeDecision | PersistenceObservation | ConsentReady,
|
|
304
326
|
state: BuildState | null,
|
|
305
327
|
cursor: string,
|
|
306
328
|
scope: { build: string } | { repo: string },
|
|
@@ -315,7 +337,7 @@ export function projectAttentionRecord(
|
|
|
315
337
|
}
|
|
316
338
|
|
|
317
339
|
export function renderAttentionLine(
|
|
318
|
-
observation: MergeDecision | PersistenceObservation,
|
|
340
|
+
observation: MergeDecision | PersistenceObservation | ConsentReady,
|
|
319
341
|
label: string,
|
|
320
342
|
): string {
|
|
321
343
|
return `${observation.observedAt} ${singleLine(label)} ${observation.type} ${singleLine(JSON.stringify(observation))}`
|
|
@@ -430,6 +452,8 @@ export function summarizeEvent(event: AbEvent | RepositoryEvent, state: BuildSta
|
|
|
430
452
|
return `ticket source ${event.payload.source} recovered: ${event.payload.cause} (${event.payload.operation})`
|
|
431
453
|
case 'dispatcher.tick-failed':
|
|
432
454
|
return `dispatcher tick failed: ${singleLine(event.payload.error)}`
|
|
455
|
+
case 'dispatcher.forge-readiness-failed':
|
|
456
|
+
return singleLine(formatReadinessFailure(event.payload))
|
|
433
457
|
case 'dispatcher.config-rejected':
|
|
434
458
|
return `dispatcher config rejected: ${singleLine(event.payload.error)}`
|
|
435
459
|
case 'dispatcher.harvest-runner-failed':
|
|
@@ -516,7 +540,7 @@ interface BuildStream {
|
|
|
516
540
|
slug: string
|
|
517
541
|
named: boolean
|
|
518
542
|
/** The full prefix, appended in seq order — what `reduceBuild` runs over. */
|
|
519
|
-
|
|
543
|
+
seed: BuildStreamSeed
|
|
520
544
|
lastSeq: number
|
|
521
545
|
status: BuildStatus
|
|
522
546
|
}
|
|
@@ -597,11 +621,9 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
597
621
|
? decodeCursor(opts.since, { store: storeRef, repo })
|
|
598
622
|
: undefined
|
|
599
623
|
const deliveredAttention = new Set(resumedCursor?.deliveredAttention ?? [])
|
|
600
|
-
|
|
624
|
+
let repositoryAttention = new RepositoryAttention()
|
|
601
625
|
let attentionInitialized = false
|
|
602
626
|
let livenessEvents: RepositoryEvent[] = []
|
|
603
|
-
let livenessSeq = 0
|
|
604
|
-
let livenessInitialized = false
|
|
605
627
|
const observedOwners = new Map<string, RepositoryRecord>()
|
|
606
628
|
const streams = new Map<string, Stream>()
|
|
607
629
|
// Every stream's position — matching or not, delivered or baselined —
|
|
@@ -648,7 +670,7 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
648
670
|
}
|
|
649
671
|
|
|
650
672
|
const emitObservation = (
|
|
651
|
-
observation: MergeDecision | PersistenceObservation,
|
|
673
|
+
observation: MergeDecision | PersistenceObservation | ConsentReady,
|
|
652
674
|
state: BuildState | null,
|
|
653
675
|
scope: { build: string } | { repo: string },
|
|
654
676
|
identity: string,
|
|
@@ -667,6 +689,17 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
667
689
|
requestStop()
|
|
668
690
|
}
|
|
669
691
|
}
|
|
692
|
+
const checkConsent = (stream: BuildStream): void => {
|
|
693
|
+
if (filters.length || stop) return
|
|
694
|
+
const observation = consentReady(stream.seed, now())
|
|
695
|
+
if (observation)
|
|
696
|
+
emitObservation(
|
|
697
|
+
observation,
|
|
698
|
+
buildReducer.finish(stream.seed.build),
|
|
699
|
+
{ build: stream.slug },
|
|
700
|
+
consentIdentity(stream.slug, observation.position),
|
|
701
|
+
)
|
|
702
|
+
}
|
|
670
703
|
const checkPersistence = (): void => {
|
|
671
704
|
if (filters.length || !attentionInitialized || stop) return
|
|
672
705
|
for (const { identity, observation } of repositoryAttention.pending(now())) {
|
|
@@ -674,29 +707,14 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
674
707
|
if (stop) return
|
|
675
708
|
}
|
|
676
709
|
}
|
|
677
|
-
const baselineMerge = (slug: string,
|
|
678
|
-
|
|
679
|
-
// historical prefix, even if consent was subsequently armed again.
|
|
680
|
-
const prefix: AbEvent[] = []
|
|
681
|
-
for (const event of events) {
|
|
682
|
-
prefix.push(event)
|
|
683
|
-
const observation = mergeDecision(prefix, now())
|
|
684
|
-
if (observation) deliveredAttention.add(mergeIdentity(slug, observation.pr.number))
|
|
685
|
-
}
|
|
710
|
+
const baselineMerge = (slug: string, seed: BuildStreamSeed): void => {
|
|
711
|
+
for (const pr of seed.mergeAttentionPrs) deliveredAttention.add(mergeIdentity(slug, pr))
|
|
686
712
|
}
|
|
687
713
|
|
|
688
714
|
const checkLiveness = async (): Promise<void> => {
|
|
689
715
|
if (!followRepository || stop) return
|
|
690
|
-
if (!livenessInitialized) {
|
|
691
|
-
const input = await readDispatcherLiveness(store, repo, now())
|
|
692
|
-
livenessEvents = input.events
|
|
693
|
-
livenessSeq = input.events.at(-1)?.seq ?? 0
|
|
694
|
-
livenessInitialized = true
|
|
695
|
-
}
|
|
696
716
|
if ((await store.getRepo(repo)) === null) return
|
|
697
|
-
|
|
698
|
-
livenessEvents.push(...fresh)
|
|
699
|
-
livenessSeq = fresh.at(-1)?.seq ?? livenessSeq
|
|
717
|
+
livenessEvents = (await readDispatcherLiveness(store, repo, now())).events
|
|
700
718
|
// Sample metadata after the journal. Recheck both immediately before
|
|
701
719
|
// reporting: a failed read is infrastructure, never evidence of death.
|
|
702
720
|
const record = await store.getRepo(repo)
|
|
@@ -709,9 +727,7 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
709
727
|
Date.parse(owner.lease.expiresAt) > now().getTime()
|
|
710
728
|
)
|
|
711
729
|
continue
|
|
712
|
-
|
|
713
|
-
livenessEvents.push(...delta)
|
|
714
|
-
livenessSeq = delta.at(-1)?.seq ?? livenessSeq
|
|
730
|
+
livenessEvents = (await readDispatcherLiveness(store, repo, now())).events
|
|
715
731
|
const current = await store.getRepo(repo)
|
|
716
732
|
if (current?.lease?.holder === id) {
|
|
717
733
|
observedOwners.set(id, current)
|
|
@@ -758,14 +774,21 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
758
774
|
* stream's just-extended array; the resume path replays the backlog
|
|
759
775
|
* into a scratch prefix so a resumed record never leaks state from
|
|
760
776
|
* events that landed after it. */
|
|
761
|
-
const processBuildEvent = (stream: BuildStream, event: AbEvent
|
|
777
|
+
const processBuildEvent = (stream: BuildStream, event: AbEvent): void => {
|
|
762
778
|
if (stop) return
|
|
763
779
|
stream.lastSeq = event.seq
|
|
764
780
|
positions[stream.slug] = event.seq
|
|
765
|
-
|
|
766
|
-
|
|
781
|
+
stream.seed = buildStreamSeedReducer.advance(stream.seed, [event])
|
|
782
|
+
const state = buildReducer.finish(stream.seed.build)
|
|
783
|
+
stream.status = state.status
|
|
784
|
+
if (
|
|
785
|
+
matchesBuildFilter(event.type, filters) ||
|
|
786
|
+
(!filters.length && event.type === 'restack.replayed' && event.payload.conflicted)
|
|
787
|
+
)
|
|
788
|
+
emit(event, state)
|
|
789
|
+
checkConsent(stream)
|
|
767
790
|
if (!filters.length && !stop) {
|
|
768
|
-
const observation =
|
|
791
|
+
const observation = mergeDecisionFromFacts(state, stream.seed.deferral, now())
|
|
769
792
|
if (observation)
|
|
770
793
|
emitObservation(
|
|
771
794
|
observation,
|
|
@@ -799,45 +822,30 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
799
822
|
if (streams.has(slug)) return true
|
|
800
823
|
const record = await store.getBuild(slug)
|
|
801
824
|
if (record === null) return false
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
// the baselined stream prefix. Mirrors cli/wait.ts trackBuild.
|
|
808
|
-
const events = await store.getEvents(slug)
|
|
825
|
+
const current = await readBuildStreamSeed(store, slug)
|
|
826
|
+
const seed =
|
|
827
|
+
resumeSeq === undefined
|
|
828
|
+
? current.value
|
|
829
|
+
: await historicalBuildState(store, slug, resumeSeq, current)
|
|
809
830
|
const stream: BuildStream = {
|
|
810
831
|
kind: 'build',
|
|
811
832
|
slug,
|
|
812
833
|
named: slugs.includes(slug),
|
|
813
|
-
|
|
814
|
-
lastSeq:
|
|
815
|
-
status:
|
|
834
|
+
seed,
|
|
835
|
+
lastSeq: resumeSeq ?? current.cursor,
|
|
836
|
+
status: buildReducer.finish(current.value.build).status,
|
|
816
837
|
}
|
|
817
838
|
streams.set(slug, stream)
|
|
818
839
|
positions[slug] = stream.lastSeq
|
|
819
|
-
if (resumeSeq === undefined)
|
|
820
|
-
baselineMerge(slug,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
slug,
|
|
827
|
-
events.filter((event) => event.seq <= resumeSeq),
|
|
828
|
-
)
|
|
829
|
-
stream.lastSeq = resumeSeq
|
|
830
|
-
// Replay the backlog into a scratch prefix: each record's state is
|
|
831
|
-
// the reduction of the prefix ENDING at that event, never the
|
|
832
|
-
// reduction of the full loaded prefix, which would leak state from
|
|
833
|
-
// events that landed after the one being recorded.
|
|
834
|
-
const replay: AbEvent[] = events.filter((event) => event.seq <= resumeSeq)
|
|
835
|
-
for (const event of events) {
|
|
836
|
-
if (event.seq <= resumeSeq) continue
|
|
837
|
-
replay.push(event)
|
|
838
|
-
processBuildEvent(stream, event, replay)
|
|
839
|
-
if (stop) break
|
|
840
|
+
if (resumeSeq === undefined || resumedCursor?.deliveredAttention === undefined)
|
|
841
|
+
baselineMerge(slug, seed)
|
|
842
|
+
if (resumeSeq !== undefined) {
|
|
843
|
+
for (const event of await store.getEvents(slug, resumeSeq)) {
|
|
844
|
+
processBuildEvent(stream, event)
|
|
845
|
+
if (stop) break
|
|
846
|
+
}
|
|
840
847
|
}
|
|
848
|
+
checkConsent(stream)
|
|
841
849
|
return true
|
|
842
850
|
}
|
|
843
851
|
|
|
@@ -856,26 +864,13 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
856
864
|
* the throw stay tracked, so the retry neither duplicates nor skips.
|
|
857
865
|
*/
|
|
858
866
|
const discoverBuilds = async (): Promise<void> => {
|
|
859
|
-
|
|
860
|
-
// one flat batch read replaces a full getEvents per candidate build, per
|
|
861
|
-
// discovery pass; `terminal` is reduceBuild's exact terminal rule
|
|
862
|
-
// (store/digest's reduceBuildDigest, pinned by contract). The per-build
|
|
863
|
-
// full read below remains deliberate for builds the digest cannot retire:
|
|
864
|
-
// its retained prefix is consumed at full replay depth by every later
|
|
865
|
-
// reduction (approvals, findings, answered escalations, PR facts,
|
|
866
|
-
// observations), so bounding it would need reducer-partition store
|
|
867
|
-
// machinery out of AUT-545's scope. The reduceBuild re-check stays: it is
|
|
868
|
-
// the legacy-record fallback (a record whose `repo` predates origin
|
|
869
|
-
// normalization is in `mine` via `repoOrigin` but absent from the digest
|
|
870
|
-
// map, which keys on `record.repo`) and it keeps this filter unable to
|
|
871
|
-
// diverge from reduceBuild. Mirrors cli/wait.ts discoverBuilds.
|
|
872
|
-
const digests = await store.getRepoBuildDigests(repo)
|
|
867
|
+
const digests = await readBuildDigests(store, repo)
|
|
873
868
|
for (const record of (await store.listBuilds()).filter(mine)) {
|
|
874
869
|
if (streams.has(record.slug) || retired.has(record.slug)) continue
|
|
875
870
|
const digest = digests.get(record.slug)
|
|
876
871
|
if (digest !== undefined && digest.terminal !== undefined) continue
|
|
877
|
-
const
|
|
878
|
-
const status =
|
|
872
|
+
const current = await readBuildStreamSeed(store, record.slug)
|
|
873
|
+
const status = buildReducer.finish(current.value.build).status
|
|
879
874
|
if (!NONTERMINAL_STATUSES.includes(status)) {
|
|
880
875
|
// Terminal is permanent (reduceBuild never clears it): a legacy
|
|
881
876
|
// record the digest cannot retire is read once, not every pass.
|
|
@@ -886,13 +881,15 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
886
881
|
kind: 'build',
|
|
887
882
|
slug: record.slug,
|
|
888
883
|
named: false,
|
|
889
|
-
|
|
890
|
-
lastSeq:
|
|
884
|
+
seed: current.value,
|
|
885
|
+
lastSeq: current.cursor,
|
|
891
886
|
status,
|
|
892
887
|
}
|
|
893
888
|
streams.set(record.slug, stream)
|
|
894
|
-
baselineMerge(record.slug,
|
|
889
|
+
baselineMerge(record.slug, current.value)
|
|
895
890
|
positions[record.slug] = stream.lastSeq
|
|
891
|
+
checkConsent(stream)
|
|
892
|
+
if (stop) break
|
|
896
893
|
}
|
|
897
894
|
}
|
|
898
895
|
|
|
@@ -903,18 +900,21 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
903
900
|
positions[REPO_STREAM_KEY] = stream.lastSeq
|
|
904
901
|
try {
|
|
905
902
|
if ((await store.getRepo(repo)) !== null) {
|
|
906
|
-
|
|
907
|
-
const
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
903
|
+
const current = await readRepositoryAttention(store, repo)
|
|
904
|
+
const baseline = resumeSeq ?? current.cursor
|
|
905
|
+
const seed =
|
|
906
|
+
resumeSeq === undefined
|
|
907
|
+
? current.value
|
|
908
|
+
: await historicalRepositoryAttention(store, repo, resumeSeq, current)
|
|
909
|
+
repositoryAttention = new RepositoryAttention(seed)
|
|
912
910
|
attentionInitialized = true
|
|
913
911
|
stream.lastSeq = baseline
|
|
914
912
|
positions[REPO_STREAM_KEY] = baseline
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
913
|
+
if (resumeSeq !== undefined) {
|
|
914
|
+
for (const event of await store.getRepoEvents(repo, baseline)) {
|
|
915
|
+
if (stop) break
|
|
916
|
+
processRepositoryEvent(stream, event)
|
|
917
|
+
}
|
|
918
918
|
}
|
|
919
919
|
if (!stop) checkPersistence()
|
|
920
920
|
} else attentionInitialized = true
|
|
@@ -931,12 +931,11 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
931
931
|
const fresh = await store.getEvents(stream.slug, stream.lastSeq, readOpts)
|
|
932
932
|
for (const event of fresh) {
|
|
933
933
|
if (stop) break
|
|
934
|
-
stream
|
|
935
|
-
processBuildEvent(stream, event, stream.events)
|
|
934
|
+
processBuildEvent(stream, event)
|
|
936
935
|
if (stop) break
|
|
937
936
|
}
|
|
938
937
|
if (fresh.length > 0 && !stop) {
|
|
939
|
-
stream.status =
|
|
938
|
+
stream.status = buildReducer.finish(stream.seed.build).status
|
|
940
939
|
}
|
|
941
940
|
return true
|
|
942
941
|
}
|
|
@@ -951,11 +950,14 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
951
950
|
if ((await store.getRepo(repo)) === null) return true
|
|
952
951
|
if (!attentionInitialized) {
|
|
953
952
|
repositoryInitialization ??= (async () => {
|
|
954
|
-
const
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
953
|
+
const current = await readRepositoryAttention(store, repo)
|
|
954
|
+
const resumeSeq = sinceStreams[REPO_STREAM_KEY]
|
|
955
|
+
const baseline = resumeSeq ?? current.cursor
|
|
956
|
+
const seed =
|
|
957
|
+
resumeSeq === undefined
|
|
958
|
+
? current.value
|
|
959
|
+
: await historicalRepositoryAttention(store, repo, resumeSeq, current)
|
|
960
|
+
repositoryAttention = new RepositoryAttention(seed)
|
|
959
961
|
stream.lastSeq = baseline
|
|
960
962
|
positions[REPO_STREAM_KEY] = baseline
|
|
961
963
|
attentionInitialized = true
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
/** Ordered dispatcher-owned policy; omitted predicates are wildcards. */
|
|
4
|
+
export const landingRuleSchema = z.strictObject({
|
|
5
|
+
into: z
|
|
6
|
+
.string()
|
|
7
|
+
.refine(
|
|
8
|
+
(value) => value.trim().length > 0,
|
|
9
|
+
'into must be root, node, or a nonblank node ticket id',
|
|
10
|
+
)
|
|
11
|
+
.optional(),
|
|
12
|
+
from: z.enum(['leaf', 'node']).optional(),
|
|
13
|
+
label: z
|
|
14
|
+
.string()
|
|
15
|
+
.refine(
|
|
16
|
+
(value) => value.trim().length > 0,
|
|
17
|
+
'label must be nonblank (labels match exactly, including case)',
|
|
18
|
+
)
|
|
19
|
+
.optional(),
|
|
20
|
+
mode: z.enum(['auto', 'consent']),
|
|
21
|
+
})
|
|
22
|
+
export type LandingRule = z.infer<typeof landingRuleSchema>
|
|
@@ -55,7 +55,8 @@ export interface PipelineSource {
|
|
|
55
55
|
export interface PipelineSourceInput {
|
|
56
56
|
slug: string
|
|
57
57
|
record: Pick<BuildRecord, 'branch'>
|
|
58
|
-
events
|
|
58
|
+
events?: readonly AbEvent[]
|
|
59
|
+
recordedBase?: string
|
|
59
60
|
/** 'origin' reads through the forge; 'checkout' reads through git exec in
|
|
60
61
|
* the dispatcher's checkout (build branches are refs of the shared repo). */
|
|
61
62
|
mode: 'origin' | 'checkout'
|
|
@@ -250,7 +251,7 @@ export async function resolvePipelineSource(
|
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
}
|
|
253
|
-
const baseSha = recordedBaseSha(events)
|
|
254
|
+
const baseSha = input.recordedBase ?? recordedBaseSha(events ?? [])
|
|
254
255
|
if (baseSha === undefined) {
|
|
255
256
|
onFailure({ kind: 'no-base', detail: 'no recorded base commit (legacy build)' })
|
|
256
257
|
return undefined
|
|
@@ -368,7 +369,7 @@ export async function resolvePipelineSource(
|
|
|
368
369
|
return parsed
|
|
369
370
|
}
|
|
370
371
|
}
|
|
371
|
-
const baseSha = recordedBaseSha(events)
|
|
372
|
+
const baseSha = input.recordedBase ?? recordedBaseSha(events ?? [])
|
|
372
373
|
if (baseSha === undefined) {
|
|
373
374
|
onFailure({ kind: 'no-base', detail: 'no recorded base commit (legacy build)' })
|
|
374
375
|
return undefined
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* validated.
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod'
|
|
15
|
+
import { landingRuleSchema } from './landing'
|
|
16
|
+
export { landingRuleSchema, type LandingRule } from './landing'
|
|
15
17
|
import { normalizeServiceURL } from '../connection'
|
|
16
18
|
import { prImageHostSchema } from '../ontology'
|
|
17
19
|
import { SANDBOX_FORBIDDEN_ENV } from '../ports/workspace/operator-sandbox'
|
|
@@ -825,6 +827,7 @@ const configRootSchema = z.strictObject({
|
|
|
825
827
|
.refine((value) => value.trim().length > 0, 'plugin module specifiers must be nonblank'),
|
|
826
828
|
)
|
|
827
829
|
.default([]),
|
|
830
|
+
landing: z.array(landingRuleSchema).default([]),
|
|
828
831
|
pr: prSchema.optional(),
|
|
829
832
|
workspace: workspaceSchema.prefault({}),
|
|
830
833
|
commands: commandsSchema,
|
|
@@ -40,6 +40,46 @@ export interface EventWrite<T extends EventType = EventType> {
|
|
|
40
40
|
* catalog tables in SPEC §15.3.
|
|
41
41
|
*/
|
|
42
42
|
export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
43
|
+
'landing.decided': ['dispatcher', 'kernel'],
|
|
44
|
+
'build.hold-requested': ['human'],
|
|
45
|
+
'build.land-requested': ['human'],
|
|
46
|
+
'landing.command-acknowledged': ['dispatcher', 'kernel'],
|
|
47
|
+
'landing.native-enable-started': ['dispatcher'],
|
|
48
|
+
'landing.forge-merged': ['kernel'],
|
|
49
|
+
'landing.native-applied': ['dispatcher', 'kernel'],
|
|
50
|
+
'target.moved': ['dispatcher', 'kernel'],
|
|
51
|
+
'restack.prepared': ['kernel', 'dispatcher'],
|
|
52
|
+
'restack.replayed': ['kernel', 'dispatcher'],
|
|
53
|
+
'restack.publish-intended': ['kernel', 'dispatcher'],
|
|
54
|
+
'restack.rewritten': ['kernel', 'dispatcher'],
|
|
55
|
+
'restack.contended': ['kernel', 'dispatcher'],
|
|
56
|
+
'restack.completed': ['kernel', 'dispatcher'],
|
|
57
|
+
'integration.abandoned': ['kernel', 'dispatcher'],
|
|
58
|
+
'integration.observed': ['kernel', 'dispatcher'],
|
|
59
|
+
'integration.prepared': ['kernel', 'dispatcher'],
|
|
60
|
+
'integration.landing-intended': ['kernel', 'dispatcher'],
|
|
61
|
+
'integration.landed': ['kernel', 'dispatcher'],
|
|
62
|
+
'integration.audited': ['kernel', 'dispatcher'],
|
|
63
|
+
'node.parent-requested': ['dispatcher', 'human'],
|
|
64
|
+
'node.parent-accepted': ['dispatcher', 'human'],
|
|
65
|
+
'node.parent-pr-retargeted': ['dispatcher', 'human'],
|
|
66
|
+
'node.parent-completed': ['dispatcher', 'human'],
|
|
67
|
+
'node.parent-cancelled': ['dispatcher', 'human'],
|
|
68
|
+
'node.parent-rejection-cleared': ['dispatcher', 'human'],
|
|
69
|
+
'node.parent-rejected': ['dispatcher', 'human'],
|
|
70
|
+
'node.opening': ['dispatcher'],
|
|
71
|
+
'node.writer-reserved': ['kernel', 'dispatcher'],
|
|
72
|
+
'node.item-prepared': ['kernel', 'dispatcher'],
|
|
73
|
+
'node.item-replayed': ['kernel', 'dispatcher'],
|
|
74
|
+
'node.item-conflicted': ['kernel', 'dispatcher'],
|
|
75
|
+
'node.publish-intended': ['kernel', 'dispatcher'],
|
|
76
|
+
'node.rewritten': ['kernel', 'dispatcher'],
|
|
77
|
+
'node.writer-settled': ['kernel', 'dispatcher'],
|
|
78
|
+
'node.contribution-recorded': ['kernel', 'dispatcher'],
|
|
79
|
+
'node.inventory': ['kernel', 'dispatcher'],
|
|
80
|
+
'node.opened': ['dispatcher'],
|
|
81
|
+
'node.compared': ['dispatcher'],
|
|
82
|
+
'pr.opened': ['dispatcher'],
|
|
43
83
|
'build.created': ['dispatcher', 'human'],
|
|
44
84
|
'build.completed': ['dispatcher'],
|
|
45
85
|
'runner.attached': ['kernel'],
|
|
@@ -73,8 +113,8 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
73
113
|
'build.auto-merge-requested': ['human'],
|
|
74
114
|
'build.auto-merge-cancelled': ['human'],
|
|
75
115
|
'build.auto-merge-default-observed': ['dispatcher'],
|
|
76
|
-
'build.paused': ['kernel'],
|
|
77
|
-
'build.resumed': ['kernel'],
|
|
116
|
+
'build.paused': ['kernel', 'dispatcher'],
|
|
117
|
+
'build.resumed': ['kernel', 'dispatcher'],
|
|
78
118
|
'build.aborted': ['kernel', 'dispatcher'],
|
|
79
119
|
|
|
80
120
|
'spec.imported': ['dispatcher'],
|
|
@@ -111,7 +151,12 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
111
151
|
'pr.conflicted': ['dispatcher'],
|
|
112
152
|
'reconcile.progress-checked': ['kernel'],
|
|
113
153
|
'reconcile.started': ['kernel'],
|
|
114
|
-
'reconcile.
|
|
154
|
+
'reconcile.prepared': ['kernel'],
|
|
155
|
+
'reconcile.contended': ['kernel', 'dispatcher'],
|
|
156
|
+
'reconcile.replayed': ['kernel'],
|
|
157
|
+
'reconcile.publish-intended': ['kernel'],
|
|
158
|
+
'reconcile.rewritten': ['kernel', 'dispatcher'],
|
|
159
|
+
'reconcile.completed': ['agent', 'dispatcher', 'kernel'],
|
|
115
160
|
|
|
116
161
|
'observation.recorded': ['kernel', 'agent'],
|
|
117
162
|
'escalation.raised': ['agent', 'kernel', 'dispatcher'],
|