@defrex/autobuild 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/SPEC.md +118 -14
- package/docs/accounts.md +12 -1
- package/docs/answering-blocked-builds.md +4 -1
- package/docs/architecture.md +120 -7
- package/docs/builds.md +2 -0
- package/docs/configuration-overview.md +6 -0
- package/docs/configuration.md +6 -0
- package/docs/integration-tree.md +16 -5
- package/docs/operator-api.md +44 -6
- package/docs/operator-surfaces.md +29 -0
- package/docs/plugin-authoring.md +6 -1
- package/docs/remote-store-protocol.md +69 -10
- package/docs/restacking.md +45 -0
- package/docs/spec-standard.md +4 -2
- package/docs/ticket-dependencies.md +8 -0
- package/package.json +3 -3
- package/packages/core/src/cli/dispatch-frontend.ts +1 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +107 -26
- package/packages/core/src/cli/dispatch.ts +64 -25
- package/packages/core/src/cli/dispatcher-liveness.ts +6 -1
- package/packages/core/src/cli/forge-clear.ts +30 -0
- package/packages/core/src/cli/help.ts +1 -0
- package/packages/core/src/cli/main.ts +28 -0
- package/packages/core/src/cli/watch.ts +9 -13
- package/packages/core/src/events/catalog.ts +1 -0
- package/packages/core/src/events/forge-degradation-policy.ts +11 -0
- package/packages/core/src/events/payloads.ts +10 -0
- package/packages/core/src/events/policy.ts +9 -0
- package/packages/core/src/events/repository.ts +73 -2
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +275 -0
- package/packages/core/src/kernel/change-presence.ts +74 -8
- package/packages/core/src/kernel/engine.ts +8 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +14 -0
- package/packages/core/src/kernel/node-polling.ts +40 -7
- package/packages/core/src/kernel/node-restack-demand.ts +74 -0
- package/packages/core/src/kernel/node-restack-state.ts +5 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +33 -1
- package/packages/core/src/kernel/read-facts.ts +6 -0
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer.ts +1 -1
- package/packages/core/src/kernel/ticket-preparation.ts +66 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +20 -0
- package/packages/core/src/operator/index.ts +2 -0
- package/packages/core/src/operator/registry.ts +20 -0
- package/packages/core/src/ports/runner/account-env.ts +60 -9
- package/packages/core/src/ports/runner/claude.ts +49 -45
- package/packages/core/src/processes/dispatcher.ts +470 -121
- package/packages/core/src/processes/execution-no-progress.ts +1 -0
- package/packages/core/src/processes/harvest.ts +11 -16
- package/packages/core/src/processes/repo-view.ts +3 -0
- package/packages/core/src/store/artifact-meta.ts +7 -0
- package/packages/core/src/store/contract.ts +57 -0
- package/packages/core/src/store/memory.ts +4 -0
- package/packages/core/src/store/reducer-value-shapes.json +7302 -6668
- package/packages/core/src/store/reducer-value-validation.ts +106 -6
- package/packages/core/src/store/remote/client.ts +48 -8
- package/packages/core/src/store/remote/compatibility.ts +39 -0
- package/packages/core/src/store/remote/index.ts +6 -0
- package/packages/core/src/store/remote/protocol.ts +8 -1
- package/packages/core/src/store/remote/released-reducer-values/1.2.0.json +8129 -0
- package/packages/core/src/store/remote/version.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +4 -2
- package/packages/core/src/store/snapshots.ts +16 -3
- package/packages/core/src/store/types.ts +2 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +144 -5
- package/packages/core/src/testing/index.ts +1 -1
- package/packages/core/src/testing/reduced-read-budget.ts +513 -5
- package/skills/guide/SKILL.md +44 -7
- package/skills/guide/references/accounts.md +12 -1
- package/skills/guide/references/integration-tree.md +16 -5
- package/skills/guide/references/operator-api.md +44 -6
- package/skills/guide/references/plugin-authoring.md +6 -1
- package/skills/guide/references/remote-store-protocol.md +69 -10
- package/skills/guide/references/restacking.md +45 -0
- package/skills/guide/references/spec-standard.md +4 -2
- package/skills/guide/references/ticket-dependencies.md +8 -0
- package/skills/operate/SKILL.md +21 -5
- package/skills/reconcile/SKILL.md +6 -0
- package/skills/tickets/SKILL.md +7 -3
- package/templates/hosted-service/package.json +2 -2
|
@@ -171,7 +171,7 @@ import {
|
|
|
171
171
|
} from '../processes/build-execution-state'
|
|
172
172
|
import { HarvestRunner, type HarvestRunnerResult } from '../processes/harvest-runner'
|
|
173
173
|
import {
|
|
174
|
-
|
|
174
|
+
unclaimedObservationCount,
|
|
175
175
|
evaluateHarvestPressureFromStore,
|
|
176
176
|
evaluateHarvestPressureFromDigests,
|
|
177
177
|
} from '../processes/harvest'
|
|
@@ -1212,6 +1212,7 @@ class DispatchLoop {
|
|
|
1212
1212
|
return this.serialize(async () => {
|
|
1213
1213
|
// Refresh before every watch decision. The owner publishes atomically;
|
|
1214
1214
|
// everything below captures the resulting one snapshot for this tick.
|
|
1215
|
+
await this.flushPendingTickFailure()
|
|
1215
1216
|
await this.refreshConfig()
|
|
1216
1217
|
if (await this.acceptUpgradeYield()) return emptyTickReport()
|
|
1217
1218
|
// Every tick verifies local lease currency, reclaiming when necessary. Without it,
|
|
@@ -1232,31 +1233,25 @@ class DispatchLoop {
|
|
|
1232
1233
|
}
|
|
1233
1234
|
this.tickStartedAt = startedAt
|
|
1234
1235
|
|
|
1235
|
-
//
|
|
1236
|
-
//
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
// writes nothing. Any other failed sample must neither fail dispatch nor
|
|
1240
|
-
// replace the last complete measurement with a fabricated zero.
|
|
1236
|
+
// Refresh inside the serialized tick so claims and the display both see
|
|
1237
|
+
// the latest repository facts. Shared refresh failures still fail the tick.
|
|
1238
|
+
await this.repoView.refresh()
|
|
1239
|
+
const digests = await this.repoView.getRepoBuildDigests(this.repoIdentity)
|
|
1241
1240
|
if (this.dashboard) {
|
|
1242
1241
|
try {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1242
|
+
// Display-only sampling reuses the refreshed inputs without backing
|
|
1243
|
+
// reads. Publish only a complete measurement; retain it on failure.
|
|
1244
|
+
const count = unclaimedObservationCount({
|
|
1245
|
+
digests,
|
|
1246
|
+
harvestEvents: this.repoView.repositoryFacts().harvest,
|
|
1247
|
+
})
|
|
1248
|
+
this.observationCount = count
|
|
1247
1249
|
} catch {
|
|
1248
|
-
//
|
|
1249
|
-
// retry on the next tick; they are not dashboard failures.
|
|
1250
|
+
// Retry on the next tick without fabricating a zero.
|
|
1250
1251
|
}
|
|
1251
1252
|
}
|
|
1252
|
-
|
|
1253
|
-
// Sample inside the serialized tick, not at process startup. Every
|
|
1254
|
-
// dispatcher therefore gates claims from the latest repository facts.
|
|
1255
|
-
await this.repoView.refresh()
|
|
1256
1253
|
const executionSlugs = new Set(
|
|
1257
|
-
[...(
|
|
1258
|
-
.filter(([, digest]) => digest.executionOpen)
|
|
1259
|
-
.map(([slug]) => slug),
|
|
1254
|
+
[...digests].filter(([, digest]) => digest.executionOpen).map(([slug]) => slug),
|
|
1260
1255
|
)
|
|
1261
1256
|
await authorizeRemoteHandoffs(
|
|
1262
1257
|
this.wiring.store,
|
|
@@ -3077,6 +3072,50 @@ class DispatchLoop {
|
|
|
3077
3072
|
}
|
|
3078
3073
|
}
|
|
3079
3074
|
|
|
3075
|
+
private pendingTickFailure:
|
|
3076
|
+
| { original: string; first: string; last: string; count: number }
|
|
3077
|
+
| undefined
|
|
3078
|
+
|
|
3079
|
+
/** Reporting is diagnostic: its failure must never replace the operational error. */
|
|
3080
|
+
private async reportTickFailure(error: unknown): Promise<void> {
|
|
3081
|
+
const original = formatDispatcherError(error)
|
|
3082
|
+
this.warn(`tick failed: ${original}`)
|
|
3083
|
+
try {
|
|
3084
|
+
await this.publishTickFailure(error)
|
|
3085
|
+
} catch (publicationError) {
|
|
3086
|
+
const now = this.wiring.clock().toISOString()
|
|
3087
|
+
if (this.pendingTickFailure) {
|
|
3088
|
+
this.pendingTickFailure.last = now
|
|
3089
|
+
this.pendingTickFailure.count++
|
|
3090
|
+
} else {
|
|
3091
|
+
this.pendingTickFailure = { original, first: now, last: now, count: 1 }
|
|
3092
|
+
}
|
|
3093
|
+
// Never reuse an old boundary to close a later tick (or a peer's tick).
|
|
3094
|
+
this.tickStartedAt = undefined
|
|
3095
|
+
this.warn(`tick failure unreported: ${formatDispatcherError(publicationError)}`)
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
private async flushPendingTickFailure(): Promise<void> {
|
|
3100
|
+
const pending = this.pendingTickFailure
|
|
3101
|
+
if (!pending) return
|
|
3102
|
+
try {
|
|
3103
|
+
await this.wiring.store.appendRepo(this.repoIdentity, {
|
|
3104
|
+
actor: DISPATCHER,
|
|
3105
|
+
type: 'dispatcher.tick-failed',
|
|
3106
|
+
payload: {
|
|
3107
|
+
run: this.runId,
|
|
3108
|
+
error:
|
|
3109
|
+
`Unreported tick failure window ${pending.first} through ${pending.last} ` +
|
|
3110
|
+
`(${pending.count} failures); original tick error: ${pending.original}`,
|
|
3111
|
+
},
|
|
3112
|
+
})
|
|
3113
|
+
this.pendingTickFailure = undefined
|
|
3114
|
+
} catch (error) {
|
|
3115
|
+
this.warn(`tick failure window still unreported: ${formatDispatcherError(error)}`)
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3080
3119
|
private async publishTickFailure(error: unknown): Promise<void> {
|
|
3081
3120
|
const failed = {
|
|
3082
3121
|
actor: DISPATCHER,
|
|
@@ -4645,7 +4684,7 @@ class DispatchLoop {
|
|
|
4645
4684
|
// invocation.
|
|
4646
4685
|
if (this.pastDeadline()) return
|
|
4647
4686
|
const initial = await this.dispatcherTick(true).catch(async (error: unknown) => {
|
|
4648
|
-
await this.
|
|
4687
|
+
await this.reportTickFailure(error)
|
|
4649
4688
|
throw error
|
|
4650
4689
|
})
|
|
4651
4690
|
const initialPrinted = this.printReport(initial, false)
|
|
@@ -4688,18 +4727,18 @@ class DispatchLoop {
|
|
|
4688
4727
|
this.startUpgradeChecks()
|
|
4689
4728
|
let startup = true
|
|
4690
4729
|
while (!this.watchStopped && !this.superseded) {
|
|
4730
|
+
let failed = false
|
|
4691
4731
|
try {
|
|
4692
4732
|
const report = await this.dispatcherTick(startup)
|
|
4693
4733
|
this.printReport(report, this.harvestInFlight === undefined)
|
|
4694
4734
|
startup = false
|
|
4695
4735
|
} catch (error) {
|
|
4696
4736
|
if (this.forgePublicationFailed) throw error
|
|
4697
|
-
|
|
4698
|
-
await this.
|
|
4699
|
-
this.warn(`tick failed: ${message}`)
|
|
4737
|
+
failed = true
|
|
4738
|
+
await this.reportTickFailure(error)
|
|
4700
4739
|
}
|
|
4701
4740
|
if (this.watchStopped || this.superseded) break
|
|
4702
|
-
await sleep(intervalMs)
|
|
4741
|
+
await sleep(failed || this.pendingTickFailure ? Math.max(intervalMs, 1000) : intervalMs)
|
|
4703
4742
|
}
|
|
4704
4743
|
if (this.superseded) {
|
|
4705
4744
|
this.warn('dispatcher superseded by another invocation — detaching')
|
|
@@ -42,6 +42,7 @@ export class StandbyIdentityResolver {
|
|
|
42
42
|
private readonly store: BuildStore,
|
|
43
43
|
private readonly repo: string,
|
|
44
44
|
private readonly history?: {
|
|
45
|
+
selectHolder?: (holder: string | undefined) => void
|
|
45
46
|
allowLookup: () => boolean
|
|
46
47
|
remember: (events: RepositoryEvent[], complete: boolean) => void
|
|
47
48
|
},
|
|
@@ -64,7 +65,7 @@ export class StandbyIdentityResolver {
|
|
|
64
65
|
const facts = (await readDispatcherRunFacts(this.store, this.repo, holder)).value
|
|
65
66
|
this.ingest(facts.start ? [facts.start] : [])
|
|
66
67
|
const complete = false // This lookup correlates one holder, not the complete journal.
|
|
67
|
-
this.history?.remember([
|
|
68
|
+
this.history?.remember(facts.start ? [facts.start] : [], complete)
|
|
68
69
|
} catch {
|
|
69
70
|
// Identity is best effort; the sampled holder id remains sufficient.
|
|
70
71
|
}
|
|
@@ -90,8 +91,12 @@ export class StandbyIdentityResolver {
|
|
|
90
91
|
return yieldedHolder
|
|
91
92
|
}
|
|
92
93
|
this.failed = false
|
|
94
|
+
const previousHolder = this.record?.lease?.holder
|
|
93
95
|
this.record = record
|
|
94
96
|
const holder = record?.lease?.holder
|
|
97
|
+
this.history?.selectHolder?.(holder)
|
|
98
|
+
const start = holder === undefined ? undefined : this.starts.get(holder)
|
|
99
|
+
if (start && previousHolder !== holder) this.history?.remember([start], false)
|
|
95
100
|
if (holder !== undefined && holder !== run) await this.correlate(holder)
|
|
96
101
|
return this.current(run, yieldedHolder, now)
|
|
97
102
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { clearForgeDegradation } from '../operator/control'
|
|
2
|
+
import { buildControlUser } from './build-control'
|
|
3
|
+
import { withSessionlessStore, type SessionlessStoreOpts } from './store-opening'
|
|
4
|
+
|
|
5
|
+
export async function abForgeClear(
|
|
6
|
+
opts: SessionlessStoreOpts & {
|
|
7
|
+
forge: string
|
|
8
|
+
reason: string
|
|
9
|
+
json?: boolean
|
|
10
|
+
stdout: (line: string) => void
|
|
11
|
+
},
|
|
12
|
+
): Promise<void> {
|
|
13
|
+
if (['AB_BUILD', 'AB_SESSION', 'AB_HARVEST'].some((name) => opts.env[name]?.trim()))
|
|
14
|
+
throw new Error(
|
|
15
|
+
'repository forge-clear requires an operator outside a build or harvest session',
|
|
16
|
+
)
|
|
17
|
+
if (!opts.forge.trim() || !opts.reason.trim()) throw new Error('forge and reason are required')
|
|
18
|
+
await withSessionlessStore(opts, async ({ store, repo }) => {
|
|
19
|
+
const result = await clearForgeDegradation({
|
|
20
|
+
store,
|
|
21
|
+
repo,
|
|
22
|
+
user: buildControlUser(opts.env),
|
|
23
|
+
forge: opts.forge,
|
|
24
|
+
reason: opts.reason,
|
|
25
|
+
})
|
|
26
|
+
opts.stdout(
|
|
27
|
+
opts.json ? JSON.stringify(result) : `Cleared forge ${opts.forge} degradation for ${repo}`,
|
|
28
|
+
)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
@@ -263,6 +263,7 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
263
263
|
detail: page([
|
|
264
264
|
'Usage:',
|
|
265
265
|
' ab repository status [--json] [--store <ref>]',
|
|
266
|
+
' ab repository forge-clear --forge <name> --reason <text> [--json] [--store <ref>]',
|
|
266
267
|
'',
|
|
267
268
|
'Report the durable ticket-intake setting and repository-wide pause from',
|
|
268
269
|
'the same journal projection used by dispatch and the dashboard.',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { abForgeClear } from './forge-clear'
|
|
1
2
|
import { abAccountsLogin } from './accounts'
|
|
2
3
|
import { abSecrets } from './secrets'
|
|
3
4
|
import { currentTicketRef } from '../kernel/ticket-migrations'
|
|
@@ -812,6 +813,33 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
812
813
|
case 'repository': {
|
|
813
814
|
const usage = 'usage: ab repository status [--json] [--store <ref>] (§8.2)'
|
|
814
815
|
const [sub, ...more] = rest
|
|
816
|
+
if (sub === 'forge-clear') {
|
|
817
|
+
const clearUsage =
|
|
818
|
+
'usage: ab repository forge-clear --forge <name> --reason <text> [--json] [--store <ref>]'
|
|
819
|
+
const parsed = parseArgs(
|
|
820
|
+
more,
|
|
821
|
+
{ forge: 'value', reason: 'value', json: 'boolean', store: 'value' },
|
|
822
|
+
clearUsage,
|
|
823
|
+
)
|
|
824
|
+
const forge = stringFlag(parsed, 'forge')
|
|
825
|
+
const reason = stringFlag(parsed, 'reason')
|
|
826
|
+
if (parsed.positionals.length || !forge?.trim() || !reason?.trim())
|
|
827
|
+
throw new Error(clearUsage)
|
|
828
|
+
if (!deps.exec) throw new Error('repository forge-clear requires an exec seam')
|
|
829
|
+
const storeRef = stringFlag(parsed, 'store')
|
|
830
|
+
await abForgeClear({
|
|
831
|
+
targetRepo: deps.workspacePath,
|
|
832
|
+
env: deps.processEnv ?? {},
|
|
833
|
+
exec: deps.exec,
|
|
834
|
+
stdout,
|
|
835
|
+
forge,
|
|
836
|
+
reason,
|
|
837
|
+
json: parsed.flags.has('json'),
|
|
838
|
+
...(storeRef !== undefined ? { storeRef } : {}),
|
|
839
|
+
...(deps.openStore !== undefined ? { openStore: deps.openStore } : {}),
|
|
840
|
+
})
|
|
841
|
+
return 0
|
|
842
|
+
}
|
|
815
843
|
if (sub !== 'status') throw new Error(usage)
|
|
816
844
|
const parsed = parseArgs(more, { json: 'boolean', store: 'value' }, usage)
|
|
817
845
|
if (parsed.positionals.length > 0) throw new Error(usage)
|
|
@@ -9,7 +9,7 @@ import { readDispatchUpgrade, readBuildDigests } from '../store/reduced-reads'
|
|
|
9
9
|
import { readBuildStreamSeed, readRepositoryAttention } from '../store/reduced-reads'
|
|
10
10
|
import { buildStreamSeedReducer, type BuildStreamSeed } from '../kernel/read-facts'
|
|
11
11
|
import { historicalBuildState, historicalRepositoryAttention } from './historical-build-state'
|
|
12
|
-
import {
|
|
12
|
+
import { readDispatcherRunFacts } from '../store/reduced-reads'
|
|
13
13
|
import { projectDispatcherLiveness } from '../kernel/dispatcher-liveness'
|
|
14
14
|
import type { RepositoryRecord } from '../store/types'
|
|
15
15
|
/**
|
|
@@ -732,7 +732,6 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
732
732
|
const deliveredAttention = new Set(resumedCursor?.deliveredAttention ?? [])
|
|
733
733
|
let repositoryAttention = new RepositoryAttention()
|
|
734
734
|
let attentionInitialized = false
|
|
735
|
-
let livenessEvents: RepositoryEvent[] = []
|
|
736
735
|
const observedOwners = new Map<string, RepositoryRecord>()
|
|
737
736
|
const streams = new Map<string, Stream>()
|
|
738
737
|
// Every stream's position — matching or not, delivered or baselined —
|
|
@@ -824,7 +823,6 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
824
823
|
const checkLiveness = async (): Promise<void> => {
|
|
825
824
|
if (!followRepository || stop) return
|
|
826
825
|
if ((await store.getRepo(repo)) === null) return
|
|
827
|
-
livenessEvents = (await readDispatcherLiveness(store, repo, now())).events
|
|
828
826
|
// Sample metadata after the journal. Recheck both immediately before
|
|
829
827
|
// reporting: a failed read is infrastructure, never evidence of death.
|
|
830
828
|
const record = await store.getRepo(repo)
|
|
@@ -838,25 +836,23 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
838
836
|
Date.parse(owner.lease.expiresAt) > now().getTime()
|
|
839
837
|
)
|
|
840
838
|
continue
|
|
841
|
-
livenessEvents = (await readDispatcherLiveness(store, repo, now())).events
|
|
842
839
|
const current = await store.getRepo(repo)
|
|
843
840
|
if (current?.lease?.holder === id) {
|
|
844
841
|
observedOwners.set(id, current)
|
|
845
842
|
if (Date.parse(current.lease.expiresAt) > now().getTime()) continue
|
|
846
843
|
}
|
|
844
|
+
const facts = (await readDispatcherRunFacts(store, repo, id)).value
|
|
845
|
+
if (facts.stop) {
|
|
846
|
+
observedOwners.delete(id)
|
|
847
|
+
continue
|
|
848
|
+
}
|
|
847
849
|
const evidence = projectDispatcherLiveness(
|
|
848
850
|
current?.lease?.holder === id ? current : owner,
|
|
849
|
-
|
|
851
|
+
[facts.start, facts.latestStart, facts.stop, facts.tick, facts.runtime].filter(
|
|
852
|
+
(event): event is RepositoryEvent => event !== undefined,
|
|
853
|
+
),
|
|
850
854
|
now(),
|
|
851
855
|
)
|
|
852
|
-
if (
|
|
853
|
-
livenessEvents.some(
|
|
854
|
-
(e) => e.type === 'dispatcher.run-stopped' && e.payload.run === id,
|
|
855
|
-
)
|
|
856
|
-
) {
|
|
857
|
-
observedOwners.delete(id)
|
|
858
|
-
continue
|
|
859
|
-
}
|
|
860
856
|
// Only a validated takeover proves transfer; intent or release alone
|
|
861
857
|
// must still report a predecessor whose successor never arrives.
|
|
862
858
|
upgrade ??= await readDispatchUpgrade(store, repo)
|
|
@@ -72,6 +72,7 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
72
72
|
'integration.audited': ['kernel', 'dispatcher'],
|
|
73
73
|
'node.restack-requested': ['dispatcher', 'human'],
|
|
74
74
|
'node.restack-satisfied': ['kernel', 'dispatcher'],
|
|
75
|
+
'node.restack-availability-observed': ['kernel', 'dispatcher'],
|
|
75
76
|
'node.parent-distance': ['kernel', 'dispatcher'],
|
|
76
77
|
'node.parent-requested': ['dispatcher', 'human'],
|
|
77
78
|
'node.parent-accepted': ['dispatcher', 'human'],
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { forgeHealthEventPayloadSchemas } from './repository'
|
|
2
|
+
|
|
3
|
+
/** Hosted admission horizon; never applied to historical event decoding. */
|
|
4
|
+
export const MAX_FORGE_DEGRADATION_MS = 24 * 60 * 60 * 1000
|
|
5
|
+
|
|
6
|
+
export function validateForgeDegradation(payload: unknown, now: Date): void {
|
|
7
|
+
const parsed = forgeHealthEventPayloadSchemas['dispatcher.forge-degraded'].parse(payload)
|
|
8
|
+
const deadline = Date.parse(parsed.resetAt)
|
|
9
|
+
if (!Number.isFinite(deadline) || deadline > now.getTime() + MAX_FORGE_DEGRADATION_MS)
|
|
10
|
+
throw new Error('forge resetAt must be a finite ISO deadline within 24 hours of server time')
|
|
11
|
+
}
|
|
@@ -347,6 +347,16 @@ export const eventPayloadSchemas = {
|
|
|
347
347
|
parent: z.string().min(1),
|
|
348
348
|
outcome: z.enum(['covered', 'destination-changed']),
|
|
349
349
|
}),
|
|
350
|
+
'node.restack-availability-observed': z.strictObject({
|
|
351
|
+
version: z.literal(1),
|
|
352
|
+
fingerprint: z.string().min(1),
|
|
353
|
+
branch: z.string().min(1),
|
|
354
|
+
parentBranch: z.string().min(1),
|
|
355
|
+
head: z.string().min(1),
|
|
356
|
+
parent: z.string().min(1),
|
|
357
|
+
base: z.string().min(1),
|
|
358
|
+
available: z.array(z.string()),
|
|
359
|
+
}),
|
|
350
360
|
'node.parent-distance': z.strictObject({
|
|
351
361
|
base: z.string().min(1),
|
|
352
362
|
parent: z.string().min(1),
|
|
@@ -40,6 +40,7 @@ export const buildEventPolicy = {
|
|
|
40
40
|
'node.restack-requested': 'decisive',
|
|
41
41
|
'node.restack-satisfied': 'decisive',
|
|
42
42
|
'node.poll-checked': 'advisory',
|
|
43
|
+
'node.restack-availability-observed': 'advisory',
|
|
43
44
|
'node.parent-distance': 'advisory',
|
|
44
45
|
'node.parent-requested': 'decisive',
|
|
45
46
|
'node.parent-accepted': 'decisive',
|
|
@@ -153,6 +154,14 @@ export const buildEventPolicy = {
|
|
|
153
154
|
'phase.deferral-escalated': 'decisive',
|
|
154
155
|
} satisfies Record<EventType, FactClassification>
|
|
155
156
|
export const repositoryEventPolicy = {
|
|
157
|
+
'ticket-preparation.intended': 'decisive',
|
|
158
|
+
'ticket-preparation.claimed': 'decisive',
|
|
159
|
+
'ticket-preparation.creation-selected': 'decisive',
|
|
160
|
+
'ticket-preparation.failed': 'decisive',
|
|
161
|
+
'ticket-preparation.recovery-failed': 'decisive',
|
|
162
|
+
'ticket-preparation.handback-selected': 'decisive',
|
|
163
|
+
'ticket-preparation.resolved': 'decisive',
|
|
164
|
+
|
|
156
165
|
'tickets.migration-recorded': 'decisive',
|
|
157
166
|
'change-presence.observed': 'decisive',
|
|
158
167
|
'harvest.pause-requested': 'decisive',
|
|
@@ -679,9 +679,26 @@ export const ticketSourceHealthEventPayloadSchemas = {
|
|
|
679
679
|
}),
|
|
680
680
|
} as const
|
|
681
681
|
|
|
682
|
+
const presenceWitnessSchema = z.strictObject({
|
|
683
|
+
version: z.literal(1),
|
|
684
|
+
commits: z
|
|
685
|
+
.array(z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/))
|
|
686
|
+
.refine(
|
|
687
|
+
(ids) => ids.every((id, index) => index === 0 || ids[index - 1]! < id),
|
|
688
|
+
'commits must be sorted and unique',
|
|
689
|
+
),
|
|
690
|
+
identities: z
|
|
691
|
+
.array(z.templateLiteral(['build:', z.string().regex(/^[a-z0-9][a-z0-9-]*$/)]))
|
|
692
|
+
.refine(
|
|
693
|
+
(ids) => ids.every((id, index) => index === 0 || ids[index - 1]! < id),
|
|
694
|
+
'identities must be sorted and unique',
|
|
695
|
+
),
|
|
696
|
+
})
|
|
697
|
+
|
|
682
698
|
/** Head-bound admission evidence. Historical observations remain append-only. */
|
|
683
699
|
export const changePresenceEventPayloadSchemas = {
|
|
684
700
|
'change-presence.observed': z.strictObject({
|
|
701
|
+
witness: presenceWitnessSchema.optional(),
|
|
685
702
|
branch: z.string().min(1),
|
|
686
703
|
destination: z.string().min(1),
|
|
687
704
|
head: z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),
|
|
@@ -704,7 +721,10 @@ export const forgeHealthEventPayloadSchemas = {
|
|
|
704
721
|
resetAt: z.iso.datetime(),
|
|
705
722
|
firstFailureAt: z.iso.datetime(),
|
|
706
723
|
}),
|
|
707
|
-
'dispatcher.forge-recovered': z.strictObject({
|
|
724
|
+
'dispatcher.forge-recovered': z.strictObject({
|
|
725
|
+
forge: z.string().min(1),
|
|
726
|
+
reason: z.string().trim().min(1).optional(),
|
|
727
|
+
}),
|
|
708
728
|
} as const
|
|
709
729
|
|
|
710
730
|
export const ticketMigrationEventPayloadSchemas = {
|
|
@@ -726,7 +746,50 @@ export const ticketMigrationEventPayloadSchemas = {
|
|
|
726
746
|
}),
|
|
727
747
|
} as const
|
|
728
748
|
|
|
749
|
+
/** Durable claim-to-build preparation boundaries, independent of build streams. */
|
|
750
|
+
const preparationIdentity = {
|
|
751
|
+
attempt: z.string().min(1),
|
|
752
|
+
ticket: ticketRefSchema,
|
|
753
|
+
}
|
|
754
|
+
export const ticketPreparationEventPayloadSchemas = {
|
|
755
|
+
'ticket-preparation.intended': z.strictObject({
|
|
756
|
+
...preparationIdentity,
|
|
757
|
+
readyState: z.string().min(1),
|
|
758
|
+
claimedState: z.string().min(1),
|
|
759
|
+
}),
|
|
760
|
+
'ticket-preparation.claimed': z.strictObject(preparationIdentity),
|
|
761
|
+
'ticket-preparation.creation-selected': z.strictObject({
|
|
762
|
+
...preparationIdentity,
|
|
763
|
+
slug: z.string().min(1),
|
|
764
|
+
}),
|
|
765
|
+
'ticket-preparation.failed': z.strictObject({
|
|
766
|
+
...preparationIdentity,
|
|
767
|
+
stage: z.string().min(1),
|
|
768
|
+
claimed: z.boolean(),
|
|
769
|
+
handback: z.string().min(1),
|
|
770
|
+
error: z.string().min(1).max(4000),
|
|
771
|
+
}),
|
|
772
|
+
'ticket-preparation.recovery-failed': z.strictObject({
|
|
773
|
+
...preparationIdentity,
|
|
774
|
+
claimed: z.boolean().optional(),
|
|
775
|
+
preparationError: z.string().min(1).max(4000).optional(),
|
|
776
|
+
handback: z.string().min(1).optional(),
|
|
777
|
+
error: z.string().min(1).max(4000),
|
|
778
|
+
retryAt: z.string().datetime(),
|
|
779
|
+
}),
|
|
780
|
+
'ticket-preparation.handback-selected': z.strictObject({
|
|
781
|
+
...preparationIdentity,
|
|
782
|
+
state: z.string().min(1),
|
|
783
|
+
}),
|
|
784
|
+
'ticket-preparation.resolved': z.strictObject({
|
|
785
|
+
...preparationIdentity,
|
|
786
|
+
outcome: z.enum(['lost-claim', 'handed-back', 'bounced', 'owned', 'abandoned']),
|
|
787
|
+
reason: z.string().min(1).max(4000).optional(),
|
|
788
|
+
}),
|
|
789
|
+
}
|
|
790
|
+
|
|
729
791
|
export const repositoryEventPayloadSchemas = {
|
|
792
|
+
...ticketPreparationEventPayloadSchemas,
|
|
730
793
|
...ticketMigrationEventPayloadSchemas,
|
|
731
794
|
...forgeHealthEventPayloadSchemas,
|
|
732
795
|
...changePresenceEventPayloadSchemas,
|
|
@@ -794,6 +857,14 @@ export type HarvestEventWrite<T extends HarvestEventType = HarvestEventType> =
|
|
|
794
857
|
export const HARVEST_EVENT_TYPES = Object.keys(harvestEventPayloadSchemas) as HarvestEventType[]
|
|
795
858
|
|
|
796
859
|
const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
860
|
+
'ticket-preparation.intended': ['dispatcher'],
|
|
861
|
+
'ticket-preparation.claimed': ['dispatcher'],
|
|
862
|
+
'ticket-preparation.creation-selected': ['dispatcher'],
|
|
863
|
+
'ticket-preparation.failed': ['dispatcher'],
|
|
864
|
+
'ticket-preparation.recovery-failed': ['dispatcher'],
|
|
865
|
+
'ticket-preparation.handback-selected': ['dispatcher'],
|
|
866
|
+
'ticket-preparation.resolved': ['dispatcher'],
|
|
867
|
+
|
|
797
868
|
'tickets.migration-recorded': ['human'],
|
|
798
869
|
'change-presence.observed': ['dispatcher', 'kernel'],
|
|
799
870
|
'harvest.pause-requested': ['human'],
|
|
@@ -861,7 +932,7 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
|
861
932
|
'dispatcher.ticket-scan-completed': ['dispatcher'],
|
|
862
933
|
'dispatcher.ticket-source-dependency-limited': ['dispatcher'],
|
|
863
934
|
'dispatcher.forge-degraded': ['dispatcher', 'kernel'],
|
|
864
|
-
'dispatcher.forge-recovered': ['dispatcher', 'kernel'],
|
|
935
|
+
'dispatcher.forge-recovered': ['dispatcher', 'kernel', 'human'],
|
|
865
936
|
'dispatcher.ticket-source-degraded': ['dispatcher'],
|
|
866
937
|
'dispatcher.ticket-source-recovered': ['dispatcher'],
|
|
867
938
|
'dispatcher.tick-failed': ['dispatcher'],
|