@defrex/autobuild 1.8.1 → 1.9.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 +92 -11
- package/docs/architecture.md +38 -14
- package/docs/configuration.md +247 -4
- package/docs/dispatcher-hosting.md +4 -0
- package/docs/merge-policy.md +45 -5
- package/docs/operating.md +21 -0
- package/docs/operator-api.md +11 -2
- package/docs/plugin-authoring.md +4 -1
- package/docs/restacking.md +4 -0
- package/docs/setup.md +3 -1
- package/docs/verification.md +7 -6
- package/package.json +4 -3
- package/packages/core/src/cli/attention.ts +3 -0
- package/packages/core/src/cli/dashboard/landing-display.ts +9 -1
- package/packages/core/src/cli/dashboard/model.ts +25 -6
- package/packages/core/src/cli/dashboard/render.ts +2 -2
- package/packages/core/src/cli/dispatch.ts +120 -1
- package/packages/core/src/cli/help.ts +6 -2
- package/packages/core/src/cli/repository-status.ts +66 -1
- package/packages/core/src/cli/status.ts +2 -2
- package/packages/core/src/cli/watch.ts +1074 -627
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/load.ts +19 -0
- package/packages/core/src/config/schema.ts +114 -0
- package/packages/core/src/events/catalog.ts +2 -0
- package/packages/core/src/events/payloads.ts +22 -0
- package/packages/core/src/events/policy.ts +9 -0
- package/packages/core/src/events/repository.ts +43 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +31 -0
- package/packages/core/src/kernel/auto-merge.ts +33 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +18 -0
- package/packages/core/src/kernel/landing-state.ts +56 -0
- package/packages/core/src/kernel/reducer.ts +1 -1
- package/packages/core/src/plugin-sdk/index.ts +7 -1
- package/packages/core/src/ports/forge/fake.ts +128 -8
- package/packages/core/src/ports/forge/git-rewrite.ts +34 -3
- package/packages/core/src/ports/forge/github-squash-message.ts +89 -0
- package/packages/core/src/ports/forge/github-transport.ts +30 -0
- package/packages/core/src/ports/forge/github.ts +565 -164
- package/packages/core/src/ports/types.ts +47 -3
- package/packages/core/src/processes/build-execution-state.ts +4 -3
- package/packages/core/src/processes/dispatcher.ts +73 -4
- package/packages/core/src/processes/execution-no-progress.ts +2 -0
- package/packages/core/src/processes/hook-command.ts +125 -0
- package/packages/core/src/processes/hook-webhook.ts +144 -0
- package/packages/core/src/processes/hooks.ts +740 -0
- package/packages/core/src/store/contract.ts +28 -0
- package/packages/core/src/store/reducer-value-shapes.json +3729 -3297
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.9.0.json +29475 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
- package/packages/core/src/store/repo-state-events.ts +3 -0
- package/packages/core/src/store/retention.ts +16 -2
- package/packages/core/src/testing/index.ts +1 -0
- package/packages/core/src/testing/reduced-read-budget.ts +476 -1
- package/skills/guide/SKILL.md +81 -6
- package/skills/guide/references/merge-policy.md +45 -5
- package/skills/guide/references/operator-api.md +11 -2
- package/skills/guide/references/plugin-authoring.md +4 -1
- package/skills/guide/references/restacking.md +4 -0
- package/skills/guide/references/setup.md +3 -1
- package/skills/operate/SKILL.md +24 -4
- package/templates/hosted-service/package.json +2 -2
|
@@ -70,6 +70,20 @@ function describeIssue(issue: z.core.$ZodIssue): string {
|
|
|
70
70
|
return ` ${formatPath(path)}: ${message}`
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** The hook a redefinition error points at, when the offending line is a
|
|
74
|
+
* `[hooks.<name>]` header; other syntax errors keep the generic message. */
|
|
75
|
+
function duplicateHookName(text: string, error: TomlError): string | undefined {
|
|
76
|
+
if (!error.message.includes('redefine')) return undefined
|
|
77
|
+
const line = text.split(/\r?\n/)[error.line - 1]
|
|
78
|
+
const match =
|
|
79
|
+
line === undefined
|
|
80
|
+
? null
|
|
81
|
+
: /^\s*\[\s*hooks\s*\.\s*("[^"]*"|'[^']*'|[A-Za-z0-9_-]+)\s*\]/.exec(line)
|
|
82
|
+
if (match === null) return undefined
|
|
83
|
+
const name = match[1]!
|
|
84
|
+
return name.startsWith('"') || name.startsWith("'") ? name.slice(1, -1) : name
|
|
85
|
+
}
|
|
86
|
+
|
|
73
87
|
/**
|
|
74
88
|
* Parse and validate autobuild.toml text. Deprecated spellings are reported
|
|
75
89
|
* through `warn` after validation succeeds; invalid text throws first. The
|
|
@@ -89,6 +103,11 @@ export function parseConfig(
|
|
|
89
103
|
table = parseToml(tomlText)
|
|
90
104
|
} catch (error) {
|
|
91
105
|
if (error instanceof TomlError) {
|
|
106
|
+
const hook = duplicateHookName(tomlText, error)
|
|
107
|
+
if (hook !== undefined)
|
|
108
|
+
throw new ConfigError(
|
|
109
|
+
`${source}: duplicate hook name ${JSON.stringify(hook)} — declare each [hooks.<name>] table once`,
|
|
110
|
+
)
|
|
92
111
|
throw new ConfigError(`${source}: TOML syntax error: ${error.message}`)
|
|
93
112
|
}
|
|
94
113
|
throw error
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
} from '../ports/workspace/provider-capabilities'
|
|
30
30
|
import { defineEntry, openMap, ownEntries, parseEntry } from '../open-map'
|
|
31
31
|
import { forwardIssues } from '../zod-issues'
|
|
32
|
+
import { compileEventGlobs } from '../events/globs'
|
|
32
33
|
import { displayName, effectiveRuntimeReferences, RESERVED_ROLE } from './roles'
|
|
33
34
|
import { normalizeProfileLabel, profileRoles } from './profiles'
|
|
34
35
|
import {
|
|
@@ -1208,9 +1209,83 @@ documentSchema(storeSchema.shape.url, {
|
|
|
1208
1209
|
constraints:
|
|
1209
1210
|
'Absolute HTTPS service URL; loopback HTTP allowed. No credentials, query or fragment. Trailing slashes normalized.',
|
|
1210
1211
|
})
|
|
1212
|
+
// ── Hooks ────────────────────────────────────────────────────────────────────
|
|
1213
|
+
//
|
|
1214
|
+
// Observe-only consumers the lease-holding dispatcher feeds: each matching
|
|
1215
|
+
// `ab watch --json` record is delivered to the hook's command or URL, one at a
|
|
1216
|
+
// time, in order, at least once. A hook never gates anything.
|
|
1217
|
+
|
|
1218
|
+
const LOOPBACK_HOST = /^(localhost|127(\.\d{1,3}){3}|\[::1\])$/
|
|
1219
|
+
|
|
1220
|
+
/** A hook endpoint: https, or http only to a loopback host. The original
|
|
1221
|
+
* string is kept; credentials and fragments are refused so no secret can sit
|
|
1222
|
+
* in `autobuild.toml`. */
|
|
1223
|
+
const hookUrlSchema = z.string().superRefine((value, ctx) => {
|
|
1224
|
+
let url: URL
|
|
1225
|
+
try {
|
|
1226
|
+
if (value !== value.trim()) throw new Error('surrounding whitespace')
|
|
1227
|
+
url = new URL(value)
|
|
1228
|
+
} catch {
|
|
1229
|
+
ctx.addIssue({ code: 'custom', message: 'hook url must be an absolute URL' })
|
|
1230
|
+
return
|
|
1231
|
+
}
|
|
1232
|
+
if (url.username !== '' || url.password !== '' || url.hash !== '' || value.includes('#'))
|
|
1233
|
+
ctx.addIssue({ code: 'custom', message: 'hook url must not contain credentials or a fragment' })
|
|
1234
|
+
if (
|
|
1235
|
+
!(url.protocol === 'https:' || (url.protocol === 'http:' && LOOPBACK_HOST.test(url.hostname)))
|
|
1236
|
+
)
|
|
1237
|
+
ctx.addIssue({
|
|
1238
|
+
code: 'custom',
|
|
1239
|
+
message:
|
|
1240
|
+
'hook url must be https (http is allowed only to loopback: localhost, 127.0.0.0/8, [::1])',
|
|
1241
|
+
})
|
|
1242
|
+
})
|
|
1243
|
+
documentSchema(hookUrlSchema, {
|
|
1244
|
+
constraints:
|
|
1245
|
+
'Absolute HTTPS URL; HTTP allowed only to loopback (localhost, 127.0.0.0/8, [::1]). No credentials or fragment. Query strings are kept.',
|
|
1246
|
+
})
|
|
1247
|
+
|
|
1248
|
+
export const hookSchema = z.strictObject({
|
|
1249
|
+
/** Shell command run once per record with the JSON line on stdin. */
|
|
1250
|
+
command: z
|
|
1251
|
+
.string()
|
|
1252
|
+
.refine((value) => value.trim().length > 0, 'hook command must be nonblank')
|
|
1253
|
+
.optional(),
|
|
1254
|
+
/** Endpoint that receives each record as a signed JSON POST. */
|
|
1255
|
+
url: hookUrlSchema.optional(),
|
|
1256
|
+
/** Dispatcher environment variable holding the url hook's signing secret. */
|
|
1257
|
+
secretEnv: envNameSchema.optional(),
|
|
1258
|
+
/** `ab watch --event` globs; absent means `ab watch`'s default attention set. */
|
|
1259
|
+
events: z
|
|
1260
|
+
.array(z.string().refine((value) => value.trim().length > 0, 'event globs must be nonblank'))
|
|
1261
|
+
.min(1, 'list at least one event glob, or omit events for the default attention filter')
|
|
1262
|
+
.optional(),
|
|
1263
|
+
timeoutSeconds: z.number().int().positive().max(3600).default(30),
|
|
1264
|
+
})
|
|
1265
|
+
|
|
1266
|
+
documentFields(hookSchema, {
|
|
1267
|
+
command:
|
|
1268
|
+
'Shell command run from the repository checkout once per record, with the record as one JSON line on stdin. Exit status 0 within the timeout is success. Set exactly one of command or url.',
|
|
1269
|
+
url: 'HTTPS endpoint that receives each record as a signed JSON POST; http only to loopback. A 2xx response within the timeout is success; redirects are not followed.',
|
|
1270
|
+
secretEnv:
|
|
1271
|
+
'Name of the dispatcher environment variable holding the HMAC signing secret; required with url. The value never appears in config, events, status or logs.',
|
|
1272
|
+
events:
|
|
1273
|
+
'Event globs with `ab watch --event` grammar, validated against the build and repository catalogs. Absent means the default attention filter of `ab watch`.',
|
|
1274
|
+
timeoutSeconds:
|
|
1275
|
+
'Seconds one delivery may take (a command run or a request) before it is stopped and counted as a failure.',
|
|
1276
|
+
})
|
|
1277
|
+
documentSchema(hookSchema, {
|
|
1278
|
+
description: 'Named observe-only hook delivered matching watch records by the dispatcher.',
|
|
1279
|
+
constraints:
|
|
1280
|
+
'Hook names use ASCII letters, digits, ., _ and -. Exactly one of command or url. A url hook requires secretEnv naming a set, nonempty variable in the dispatcher environment. The hosted dispatcher rejects command hooks and delivers url hooks.',
|
|
1281
|
+
})
|
|
1282
|
+
export type HookConfig = z.infer<typeof hookSchema>
|
|
1283
|
+
export const hooksSchema = openMap('[hooks]', hookSchema)
|
|
1284
|
+
|
|
1211
1285
|
export const configRootSchema = z.strictObject({
|
|
1212
1286
|
store: storeSchema.optional(),
|
|
1213
1287
|
upgrade: z.strictObject({ automatic: z.boolean().default(true) }).prefault({}),
|
|
1288
|
+
hooks: hooksSchema.default({}),
|
|
1214
1289
|
/** Base branch builds cut from and target (§16.1). */
|
|
1215
1290
|
baseBranch: z.string().min(1).default('main'),
|
|
1216
1291
|
/** Concurrent builds for this repository (§16.1). */
|
|
@@ -1261,6 +1336,8 @@ export const configRootSchema = z.strictObject({
|
|
|
1261
1336
|
documentFields(configRootSchema, {
|
|
1262
1337
|
store: 'Optional remote BuildStore connection. Credentials live outside TOML.',
|
|
1263
1338
|
upgrade: 'Automatic dispatcher runtime target checks and adoption.',
|
|
1339
|
+
hooks:
|
|
1340
|
+
'Named observe-only hooks: the dispatcher delivers each matching watch record to a command or URL, in order and at least once.',
|
|
1264
1341
|
baseBranch: 'Branch used to cut builds, target PRs, and merge during reconciliation.',
|
|
1265
1342
|
capacity:
|
|
1266
1343
|
'Builds running work at once for this repository. A build that finished its pipeline holds no slot while it waits for a merge decision, nor does a build waiting on other tickets; either is admitted ahead of new claims when it must run again. Other unfinished paused and blocked work retains slots. Node reconcile and verification exclude their own blocked/paused descendants at admission; new claims use total occupancy. See [integration capacity](integration-tree.md).',
|
|
@@ -1453,6 +1530,43 @@ export const configSchema = normalizedConfigSchema.superRefine((config, ctx) =>
|
|
|
1453
1530
|
}
|
|
1454
1531
|
}
|
|
1455
1532
|
|
|
1533
|
+
for (const [name, hook] of Object.entries(config.hooks ?? {})) {
|
|
1534
|
+
if (!isSafeStepName(name)) {
|
|
1535
|
+
ctx.addIssue({
|
|
1536
|
+
code: 'custom',
|
|
1537
|
+
path: ['hooks', name],
|
|
1538
|
+
message: `[hooks.${name}] name must contain only ASCII letters, digits, ., _ or - and cannot be . or ..`,
|
|
1539
|
+
})
|
|
1540
|
+
}
|
|
1541
|
+
const target = (message: string): void =>
|
|
1542
|
+
ctx.addIssue({ code: 'custom', path: ['hooks', name], message })
|
|
1543
|
+
if (hook.command === undefined && hook.url === undefined)
|
|
1544
|
+
target(`[hooks.${name}] has no target — set command or url`)
|
|
1545
|
+
if (hook.command !== undefined && hook.url !== undefined)
|
|
1546
|
+
target(`[hooks.${name}] sets both command and url — set exactly one`)
|
|
1547
|
+
if (hook.url !== undefined && hook.secretEnv === undefined)
|
|
1548
|
+
target(
|
|
1549
|
+
`[hooks.${name}] url hooks require secretEnv naming the signing-secret environment variable`,
|
|
1550
|
+
)
|
|
1551
|
+
if (hook.command !== undefined && hook.secretEnv !== undefined)
|
|
1552
|
+
target(`[hooks.${name}].secretEnv applies only to url hooks`)
|
|
1553
|
+
for (const [index, glob] of (hook.events ?? []).entries()) {
|
|
1554
|
+
try {
|
|
1555
|
+
compileEventGlobs([glob], {
|
|
1556
|
+
repository: true,
|
|
1557
|
+
additionalCatalog: ['dispatcher.lost'],
|
|
1558
|
+
usage: 'hooks',
|
|
1559
|
+
})
|
|
1560
|
+
} catch {
|
|
1561
|
+
ctx.addIssue({
|
|
1562
|
+
code: 'custom',
|
|
1563
|
+
path: ['hooks', name, 'events', index],
|
|
1564
|
+
message: `[hooks.${name}].events: ${JSON.stringify(glob)} matches no known event type in the build or repository catalogs`,
|
|
1565
|
+
})
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1456
1570
|
const firstPluginIndex = new Map<string, number>()
|
|
1457
1571
|
config.plugins.forEach((specifier, index) => {
|
|
1458
1572
|
const firstIndex = firstPluginIndex.get(specifier)
|
|
@@ -56,6 +56,8 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
56
56
|
'build.land-requested': ['human'],
|
|
57
57
|
'landing.command-acknowledged': ['dispatcher', 'kernel'],
|
|
58
58
|
'landing.native-enable-started': ['dispatcher'],
|
|
59
|
+
'landing.polling-selected': ['dispatcher'],
|
|
60
|
+
'landing.human-merge-required': ['dispatcher'],
|
|
59
61
|
'landing.forge-merged': ['kernel'],
|
|
60
62
|
'landing.native-applied': ['dispatcher', 'kernel'],
|
|
61
63
|
'target.distance': ['dispatcher'],
|
|
@@ -1119,6 +1119,28 @@ export const eventPayloadSchemas = {
|
|
|
1119
1119
|
commandSeq: z.number().int().positive(),
|
|
1120
1120
|
}),
|
|
1121
1121
|
'landing.native-enable-started': empty,
|
|
1122
|
+
/** The landing cannot be armed natively (forge GraphQL is unavailable), so
|
|
1123
|
+
* the dispatcher lands it by polling: it squashes on a tick where the
|
|
1124
|
+
* forge reports the PR clear at the candidate head. Once per candidate,
|
|
1125
|
+
* decision and command. */
|
|
1126
|
+
'landing.polling-selected': z.strictObject({
|
|
1127
|
+
candidate: landingCandidateSchema,
|
|
1128
|
+
decisionSeq: z.number().int().positive(),
|
|
1129
|
+
commandSeq: z.number().int().positive().optional(),
|
|
1130
|
+
detail: z.string().min(1),
|
|
1131
|
+
}),
|
|
1132
|
+
/** The landing settled into awaiting a human merge: it cannot be armed
|
|
1133
|
+
* natively and the base requires a merge queue, or the forge refused the
|
|
1134
|
+
* guarded squash of a PR it had reported clear. No further landing calls
|
|
1135
|
+
* for this candidate, decision and command. */
|
|
1136
|
+
'landing.human-merge-required': z.strictObject({
|
|
1137
|
+
candidate: landingCandidateSchema,
|
|
1138
|
+
decisionSeq: z.number().int().positive(),
|
|
1139
|
+
commandSeq: z.number().int().positive().optional(),
|
|
1140
|
+
cause: z.enum(['merge-queue-rule', 'merge-queue-activity', 'merge-refused']),
|
|
1141
|
+
/** Why; for `merge-refused`, the forge's refusal message verbatim. */
|
|
1142
|
+
detail: z.string().min(1),
|
|
1143
|
+
}),
|
|
1122
1144
|
'landing.forge-merged': z.strictObject({
|
|
1123
1145
|
classification: z.enum(['human', 'possible-stale-enable']),
|
|
1124
1146
|
overrodeHold: z.boolean(),
|
|
@@ -25,6 +25,12 @@ export const buildEventPolicy = {
|
|
|
25
25
|
'build.land-requested': 'decisive',
|
|
26
26
|
'landing.command-acknowledged': 'decisive',
|
|
27
27
|
'landing.native-enable-started': 'decisive',
|
|
28
|
+
// Advisory: they record which landing route was taken and gate only
|
|
29
|
+
// further landing attempts. An older runtime that ignores them retries
|
|
30
|
+
// native application and records its existing deferral, which is safe;
|
|
31
|
+
// a decisive unknown type would defer every kernel decision on the build.
|
|
32
|
+
'landing.polling-selected': 'advisory',
|
|
33
|
+
'landing.human-merge-required': 'advisory',
|
|
28
34
|
'landing.forge-merged': 'decisive',
|
|
29
35
|
'landing.native-applied': 'decisive',
|
|
30
36
|
'target.distance': 'advisory',
|
|
@@ -267,6 +273,9 @@ export const repositoryEventPolicy = {
|
|
|
267
273
|
'forge.credential-limited': 'advisory',
|
|
268
274
|
'dispatcher.kernel-git-unavailable': 'advisory',
|
|
269
275
|
'dispatcher.kernel-git-recovered': 'advisory',
|
|
276
|
+
'hook.failing': 'advisory',
|
|
277
|
+
'hook.recovered': 'advisory',
|
|
278
|
+
'hook.skipped': 'advisory',
|
|
270
279
|
'dispatcher.ticket-source-degraded': 'decisive',
|
|
271
280
|
'dispatcher.ticket-source-recovered': 'decisive',
|
|
272
281
|
'dispatcher.tick-failed': 'decisive',
|
|
@@ -801,6 +801,42 @@ export const kernelGitHealthEventPayloadSchemas = {
|
|
|
801
801
|
}),
|
|
802
802
|
} as const
|
|
803
803
|
|
|
804
|
+
/** Configured hook delivery health (§16.1 `[hooks]`). Advisory attention only:
|
|
805
|
+
* no reducer consumes these and no decision path reads them. */
|
|
806
|
+
const hookName = z.string().regex(/^(?!\.{1,2}$)[A-Za-z0-9._-]+$/)
|
|
807
|
+
export const hookEventPayloadSchemas = {
|
|
808
|
+
/** A hook has been failing continuously for the attention threshold; once per episode. */
|
|
809
|
+
'hook.failing': z.strictObject({
|
|
810
|
+
hook: hookName,
|
|
811
|
+
since: z.iso.datetime(),
|
|
812
|
+
attempts: z.number().int().min(1),
|
|
813
|
+
error: z.string().min(1).max(1_000),
|
|
814
|
+
/** The id of the record the hook keeps failing on. */
|
|
815
|
+
record: z.string().min(1),
|
|
816
|
+
}),
|
|
817
|
+
/** The first success after a reported failure episode. */
|
|
818
|
+
'hook.recovered': z.strictObject({
|
|
819
|
+
hook: hookName,
|
|
820
|
+
since: z.iso.datetime(),
|
|
821
|
+
attempts: z.number().int().min(1),
|
|
822
|
+
}),
|
|
823
|
+
/** History the hook could no longer retrieve, or a build announcement it
|
|
824
|
+
* could not resolve; the hook resumed past it. Never silent. */
|
|
825
|
+
'hook.skipped': z.strictObject({
|
|
826
|
+
hook: hookName,
|
|
827
|
+
reason: z.string().min(1).max(1_000),
|
|
828
|
+
ranges: z
|
|
829
|
+
.array(
|
|
830
|
+
z.strictObject({
|
|
831
|
+
stream: z.string().min(1),
|
|
832
|
+
after: z.number().int().min(0),
|
|
833
|
+
through: z.number().int().min(0),
|
|
834
|
+
}),
|
|
835
|
+
)
|
|
836
|
+
.max(1_000),
|
|
837
|
+
}),
|
|
838
|
+
} as const
|
|
839
|
+
|
|
804
840
|
export const ticketMigrationEventPayloadSchemas = {
|
|
805
841
|
'tickets.migration-recorded': z
|
|
806
842
|
.strictObject({
|
|
@@ -924,6 +960,7 @@ export const repositoryEventPayloadSchemas = {
|
|
|
924
960
|
...ticketMigrationEventPayloadSchemas,
|
|
925
961
|
...forgeHealthEventPayloadSchemas,
|
|
926
962
|
...kernelGitHealthEventPayloadSchemas,
|
|
963
|
+
...hookEventPayloadSchemas,
|
|
927
964
|
...changePresenceEventPayloadSchemas,
|
|
928
965
|
...ticketSourceHealthEventPayloadSchemas,
|
|
929
966
|
...harvestEventPayloadSchemas,
|
|
@@ -949,6 +986,9 @@ export const REPOSITORY_ATTENTION_EVENTS = [
|
|
|
949
986
|
'forge.credential-limited',
|
|
950
987
|
'dispatcher.kernel-git-unavailable',
|
|
951
988
|
'dispatcher.kernel-git-recovered',
|
|
989
|
+
'hook.failing',
|
|
990
|
+
'hook.recovered',
|
|
991
|
+
'hook.skipped',
|
|
952
992
|
'dispatcher.ticket-source-degraded',
|
|
953
993
|
'dispatcher.ticket-source-recovered',
|
|
954
994
|
'dispatcher.tick-failed',
|
|
@@ -1078,6 +1118,9 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
|
1078
1118
|
'forge.credential-limited': ['dispatcher', 'kernel'],
|
|
1079
1119
|
'dispatcher.kernel-git-unavailable': ['dispatcher'],
|
|
1080
1120
|
'dispatcher.kernel-git-recovered': ['dispatcher'],
|
|
1121
|
+
'hook.failing': ['dispatcher'],
|
|
1122
|
+
'hook.recovered': ['dispatcher'],
|
|
1123
|
+
'hook.skipped': ['dispatcher'],
|
|
1081
1124
|
'dispatcher.ticket-source-degraded': ['dispatcher'],
|
|
1082
1125
|
'dispatcher.ticket-source-recovered': ['dispatcher'],
|
|
1083
1126
|
'dispatcher.tick-failed': ['dispatcher'],
|
|
@@ -2220,6 +2220,7 @@
|
|
|
2220
2220
|
"$.build.lastEvent.payload.assets[].size: number",
|
|
2221
2221
|
"$.build.lastEvent.payload.assets[]: object",
|
|
2222
2222
|
"$.build.lastEvent.payload.attempt: number",
|
|
2223
|
+
"$.build.lastEvent.payload.attempts: number",
|
|
2223
2224
|
"$.build.lastEvent.payload.base.sha: string",
|
|
2224
2225
|
"$.build.lastEvent.payload.base.source: string",
|
|
2225
2226
|
"$.build.lastEvent.payload.base: object",
|
|
@@ -2341,6 +2342,7 @@
|
|
|
2341
2342
|
"$.build.lastEvent.payload.handoff: string",
|
|
2342
2343
|
"$.build.lastEvent.payload.head: string",
|
|
2343
2344
|
"$.build.lastEvent.payload.headSha: string",
|
|
2345
|
+
"$.build.lastEvent.payload.hook: string",
|
|
2344
2346
|
"$.build.lastEvent.payload.hosted: boolean",
|
|
2345
2347
|
"$.build.lastEvent.payload.hostedSeq: number",
|
|
2346
2348
|
"$.build.lastEvent.payload.id: string",
|
|
@@ -2398,6 +2400,7 @@
|
|
|
2398
2400
|
"$.build.lastEvent.payload.question: string",
|
|
2399
2401
|
"$.build.lastEvent.payload.queued: number",
|
|
2400
2402
|
"$.build.lastEvent.payload.reason: string",
|
|
2403
|
+
"$.build.lastEvent.payload.record: string",
|
|
2401
2404
|
"$.build.lastEvent.payload.ref: string",
|
|
2402
2405
|
"$.build.lastEvent.payload.refs: array",
|
|
2403
2406
|
"$.build.lastEvent.payload.refs[]: string",
|
|
@@ -2445,6 +2448,7 @@
|
|
|
2445
2448
|
"$.build.lastEvent.payload.session: string",
|
|
2446
2449
|
"$.build.lastEvent.payload.sessionId: string",
|
|
2447
2450
|
"$.build.lastEvent.payload.sha: string",
|
|
2451
|
+
"$.build.lastEvent.payload.since: string",
|
|
2448
2452
|
"$.build.lastEvent.payload.snapshots.outcome: string",
|
|
2449
2453
|
"$.build.lastEvent.payload.snapshots: object",
|
|
2450
2454
|
"$.build.lastEvent.payload.source: string",
|
|
@@ -2782,6 +2786,9 @@
|
|
|
2782
2786
|
"$.build.pollingActivity.harvest.session.suspended: string",
|
|
2783
2787
|
"$.build.pollingActivity.harvest.started: string",
|
|
2784
2788
|
"$.build.pollingActivity.head.paths-recorded: string",
|
|
2789
|
+
"$.build.pollingActivity.hook.failing: string",
|
|
2790
|
+
"$.build.pollingActivity.hook.recovered: string",
|
|
2791
|
+
"$.build.pollingActivity.hook.skipped: string",
|
|
2785
2792
|
"$.build.pollingActivity.implement.completed: string",
|
|
2786
2793
|
"$.build.pollingActivity.implement.started: string",
|
|
2787
2794
|
"$.build.pollingActivity.infrastructure.cleanup-attempted: string",
|
|
@@ -3458,6 +3465,7 @@
|
|
|
3458
3465
|
"$.build.lastEvent.payload.assets[].size: number",
|
|
3459
3466
|
"$.build.lastEvent.payload.assets[]: object",
|
|
3460
3467
|
"$.build.lastEvent.payload.attempt: number",
|
|
3468
|
+
"$.build.lastEvent.payload.attempts: number",
|
|
3461
3469
|
"$.build.lastEvent.payload.base.sha: string",
|
|
3462
3470
|
"$.build.lastEvent.payload.base.source: string",
|
|
3463
3471
|
"$.build.lastEvent.payload.base: object",
|
|
@@ -3579,6 +3587,7 @@
|
|
|
3579
3587
|
"$.build.lastEvent.payload.handoff: string",
|
|
3580
3588
|
"$.build.lastEvent.payload.head: string",
|
|
3581
3589
|
"$.build.lastEvent.payload.headSha: string",
|
|
3590
|
+
"$.build.lastEvent.payload.hook: string",
|
|
3582
3591
|
"$.build.lastEvent.payload.hosted: boolean",
|
|
3583
3592
|
"$.build.lastEvent.payload.hostedSeq: number",
|
|
3584
3593
|
"$.build.lastEvent.payload.id: string",
|
|
@@ -3636,6 +3645,7 @@
|
|
|
3636
3645
|
"$.build.lastEvent.payload.question: string",
|
|
3637
3646
|
"$.build.lastEvent.payload.queued: number",
|
|
3638
3647
|
"$.build.lastEvent.payload.reason: string",
|
|
3648
|
+
"$.build.lastEvent.payload.record: string",
|
|
3639
3649
|
"$.build.lastEvent.payload.ref: string",
|
|
3640
3650
|
"$.build.lastEvent.payload.refs: array",
|
|
3641
3651
|
"$.build.lastEvent.payload.refs[]: string",
|
|
@@ -3683,6 +3693,7 @@
|
|
|
3683
3693
|
"$.build.lastEvent.payload.session: string",
|
|
3684
3694
|
"$.build.lastEvent.payload.sessionId: string",
|
|
3685
3695
|
"$.build.lastEvent.payload.sha: string",
|
|
3696
|
+
"$.build.lastEvent.payload.since: string",
|
|
3686
3697
|
"$.build.lastEvent.payload.snapshots.outcome: string",
|
|
3687
3698
|
"$.build.lastEvent.payload.snapshots: object",
|
|
3688
3699
|
"$.build.lastEvent.payload.source: string",
|
|
@@ -4020,6 +4031,9 @@
|
|
|
4020
4031
|
"$.build.pollingActivity.harvest.session.suspended: string",
|
|
4021
4032
|
"$.build.pollingActivity.harvest.started: string",
|
|
4022
4033
|
"$.build.pollingActivity.head.paths-recorded: string",
|
|
4034
|
+
"$.build.pollingActivity.hook.failing: string",
|
|
4035
|
+
"$.build.pollingActivity.hook.recovered: string",
|
|
4036
|
+
"$.build.pollingActivity.hook.skipped: string",
|
|
4023
4037
|
"$.build.pollingActivity.implement.completed: string",
|
|
4024
4038
|
"$.build.pollingActivity.implement.started: string",
|
|
4025
4039
|
"$.build.pollingActivity.infrastructure.cleanup-attempted: string",
|
|
@@ -6176,6 +6190,7 @@
|
|
|
6176
6190
|
"$.lastEvent.payload.assets[].size: number",
|
|
6177
6191
|
"$.lastEvent.payload.assets[]: object",
|
|
6178
6192
|
"$.lastEvent.payload.attempt: number",
|
|
6193
|
+
"$.lastEvent.payload.attempts: number",
|
|
6179
6194
|
"$.lastEvent.payload.base.sha: string",
|
|
6180
6195
|
"$.lastEvent.payload.base.source: string",
|
|
6181
6196
|
"$.lastEvent.payload.base: object",
|
|
@@ -6297,6 +6312,7 @@
|
|
|
6297
6312
|
"$.lastEvent.payload.handoff: string",
|
|
6298
6313
|
"$.lastEvent.payload.head: string",
|
|
6299
6314
|
"$.lastEvent.payload.headSha: string",
|
|
6315
|
+
"$.lastEvent.payload.hook: string",
|
|
6300
6316
|
"$.lastEvent.payload.hosted: boolean",
|
|
6301
6317
|
"$.lastEvent.payload.hostedSeq: number",
|
|
6302
6318
|
"$.lastEvent.payload.id: string",
|
|
@@ -6354,6 +6370,7 @@
|
|
|
6354
6370
|
"$.lastEvent.payload.question: string",
|
|
6355
6371
|
"$.lastEvent.payload.queued: number",
|
|
6356
6372
|
"$.lastEvent.payload.reason: string",
|
|
6373
|
+
"$.lastEvent.payload.record: string",
|
|
6357
6374
|
"$.lastEvent.payload.ref: string",
|
|
6358
6375
|
"$.lastEvent.payload.refs: array",
|
|
6359
6376
|
"$.lastEvent.payload.refs[]: string",
|
|
@@ -6401,6 +6418,7 @@
|
|
|
6401
6418
|
"$.lastEvent.payload.session: string",
|
|
6402
6419
|
"$.lastEvent.payload.sessionId: string",
|
|
6403
6420
|
"$.lastEvent.payload.sha: string",
|
|
6421
|
+
"$.lastEvent.payload.since: string",
|
|
6404
6422
|
"$.lastEvent.payload.snapshots.outcome: string",
|
|
6405
6423
|
"$.lastEvent.payload.snapshots: object",
|
|
6406
6424
|
"$.lastEvent.payload.source: string",
|
|
@@ -6738,6 +6756,9 @@
|
|
|
6738
6756
|
"$.pollingActivity.harvest.session.suspended: string",
|
|
6739
6757
|
"$.pollingActivity.harvest.started: string",
|
|
6740
6758
|
"$.pollingActivity.head.paths-recorded: string",
|
|
6759
|
+
"$.pollingActivity.hook.failing: string",
|
|
6760
|
+
"$.pollingActivity.hook.recovered: string",
|
|
6761
|
+
"$.pollingActivity.hook.skipped: string",
|
|
6741
6762
|
"$.pollingActivity.implement.completed: string",
|
|
6742
6763
|
"$.pollingActivity.implement.started: string",
|
|
6743
6764
|
"$.pollingActivity.infrastructure.cleanup-attempted: string",
|
|
@@ -7657,6 +7678,7 @@
|
|
|
7657
7678
|
"$.retained[].payload.attachedSeq: number",
|
|
7658
7679
|
"$.retained[].payload.attempt: number",
|
|
7659
7680
|
"$.retained[].payload.attempt: string",
|
|
7681
|
+
"$.retained[].payload.attempts: number",
|
|
7660
7682
|
"$.retained[].payload.available: array",
|
|
7661
7683
|
"$.retained[].payload.base.sha: string",
|
|
7662
7684
|
"$.retained[].payload.base.source: string",
|
|
@@ -7827,6 +7849,7 @@
|
|
|
7827
7849
|
"$.retained[].payload.handoff: string",
|
|
7828
7850
|
"$.retained[].payload.head: string",
|
|
7829
7851
|
"$.retained[].payload.headSha: string",
|
|
7852
|
+
"$.retained[].payload.hook: string",
|
|
7830
7853
|
"$.retained[].payload.host: string",
|
|
7831
7854
|
"$.retained[].payload.hosted: boolean",
|
|
7832
7855
|
"$.retained[].payload.hostedSeq: number",
|
|
@@ -7925,8 +7948,10 @@
|
|
|
7925
7948
|
"$.retained[].payload.publicationHead: string",
|
|
7926
7949
|
"$.retained[].payload.question: string",
|
|
7927
7950
|
"$.retained[].payload.queued: number",
|
|
7951
|
+
"$.retained[].payload.ranges: array",
|
|
7928
7952
|
"$.retained[].payload.readyState: string",
|
|
7929
7953
|
"$.retained[].payload.reason: string",
|
|
7954
|
+
"$.retained[].payload.record: string",
|
|
7930
7955
|
"$.retained[].payload.ref: string",
|
|
7931
7956
|
"$.retained[].payload.refs: array",
|
|
7932
7957
|
"$.retained[].payload.refs[]: string",
|
|
@@ -7985,6 +8010,7 @@
|
|
|
7985
8010
|
"$.retained[].payload.session: string",
|
|
7986
8011
|
"$.retained[].payload.sessionId: string",
|
|
7987
8012
|
"$.retained[].payload.sha: string",
|
|
8013
|
+
"$.retained[].payload.since: string",
|
|
7988
8014
|
"$.retained[].payload.slug: string",
|
|
7989
8015
|
"$.retained[].payload.snapshots.outcome: string",
|
|
7990
8016
|
"$.retained[].payload.snapshots: object",
|
|
@@ -8083,6 +8109,7 @@
|
|
|
8083
8109
|
"$.retained[].payload.args: array",
|
|
8084
8110
|
"$.retained[].payload.attempt: number",
|
|
8085
8111
|
"$.retained[].payload.attempt: string",
|
|
8112
|
+
"$.retained[].payload.attempts: number",
|
|
8086
8113
|
"$.retained[].payload.build: string",
|
|
8087
8114
|
"$.retained[].payload.builds: array",
|
|
8088
8115
|
"$.retained[].payload.builds[].instance: string",
|
|
@@ -8164,6 +8191,7 @@
|
|
|
8164
8191
|
"$.retained[].payload.handle.version: number",
|
|
8165
8192
|
"$.retained[].payload.handle.workspacePath: string",
|
|
8166
8193
|
"$.retained[].payload.handle: object",
|
|
8194
|
+
"$.retained[].payload.hook: string",
|
|
8167
8195
|
"$.retained[].payload.hosted: boolean",
|
|
8168
8196
|
"$.retained[].payload.identity: string",
|
|
8169
8197
|
"$.retained[].payload.instance: string",
|
|
@@ -8191,8 +8219,10 @@
|
|
|
8191
8219
|
"$.retained[].payload.predecessor: string",
|
|
8192
8220
|
"$.retained[].payload.provider: string",
|
|
8193
8221
|
"$.retained[].payload.queued: number",
|
|
8222
|
+
"$.retained[].payload.ranges: array",
|
|
8194
8223
|
"$.retained[].payload.readyState: string",
|
|
8195
8224
|
"$.retained[].payload.reason: string",
|
|
8225
|
+
"$.retained[].payload.record: string",
|
|
8196
8226
|
"$.retained[].payload.remediation: string",
|
|
8197
8227
|
"$.retained[].payload.report.kind: string",
|
|
8198
8228
|
"$.retained[].payload.report.rev: number",
|
|
@@ -8218,6 +8248,7 @@
|
|
|
8218
8248
|
"$.retained[].payload.scan: object",
|
|
8219
8249
|
"$.retained[].payload.session: string",
|
|
8220
8250
|
"$.retained[].payload.sessionId: string",
|
|
8251
|
+
"$.retained[].payload.since: string",
|
|
8221
8252
|
"$.retained[].payload.slug: string",
|
|
8222
8253
|
"$.retained[].payload.snapshots.outcome: string",
|
|
8223
8254
|
"$.retained[].payload.snapshots: object",
|
|
@@ -5,6 +5,7 @@ import { autoMergeDeferralClasses, type AutoMergeDeferralReason } from '../ports
|
|
|
5
5
|
import type { BuildStore } from '../store/types'
|
|
6
6
|
import { defineReducer } from './incremental'
|
|
7
7
|
import type { BuildState } from './reducer'
|
|
8
|
+
import { currentLandingFallback, landingAuthorized, landingFallbackReason } from './landing-state'
|
|
8
9
|
|
|
9
10
|
/** The complete GitHub `mergeStateStatus` enum. Keeping this list closed is a
|
|
10
11
|
* safety property: a future forge state cannot silently become direct-merge
|
|
@@ -21,6 +22,15 @@ export const mergeStateStatuses = [
|
|
|
21
22
|
] as const
|
|
22
23
|
|
|
23
24
|
export type MergeStateStatus = (typeof mergeStateStatuses)[number]
|
|
25
|
+
|
|
26
|
+
/** The merge states in which GitHub reports a PR clear to merge. The polling
|
|
27
|
+
* route merges only from these, never relying on GitHub refusing a premature
|
|
28
|
+
* merge: BLOCKED, BEHIND, DIRTY, UNKNOWN and DRAFT are never clear. */
|
|
29
|
+
export const MERGE_CLEAR_STATES: ReadonlySet<MergeStateStatus> = new Set([
|
|
30
|
+
'CLEAN',
|
|
31
|
+
'UNSTABLE',
|
|
32
|
+
'HAS_HOOKS',
|
|
33
|
+
])
|
|
24
34
|
export type MergeGatePresence = 'present' | 'absent'
|
|
25
35
|
|
|
26
36
|
export type AutoMergeEnableDisposition =
|
|
@@ -270,6 +280,24 @@ export function currentAutoMergeDeferralFrom(
|
|
|
270
280
|
return deferralObservationFrom(ledger, state.pr.number, pending.commandSeq)?.payload.summary
|
|
271
281
|
}
|
|
272
282
|
|
|
283
|
+
/** Why an authorized landing on an open PR is still waiting: the current
|
|
284
|
+
* fallback route (landing by polling, or awaiting a human merge) first, then
|
|
285
|
+
* the current gate deferral. Shared by `ab status` and both dashboards. */
|
|
286
|
+
export function currentLandingWaitReasonFrom(
|
|
287
|
+
ledger: DeferralLedger,
|
|
288
|
+
state: Pick<BuildState, 'autoMerge' | 'pr' | 'landing' | 'prState'>,
|
|
289
|
+
): string | undefined {
|
|
290
|
+
const fallback = currentLandingFallback(state.landing)
|
|
291
|
+
if (
|
|
292
|
+
fallback !== undefined &&
|
|
293
|
+
state.pr !== undefined &&
|
|
294
|
+
state.prState === 'open' &&
|
|
295
|
+
landingAuthorized(state.landing)
|
|
296
|
+
)
|
|
297
|
+
return landingFallbackReason(fallback, state.pr.number)
|
|
298
|
+
return currentAutoMergeDeferralFrom(ledger, state)
|
|
299
|
+
}
|
|
300
|
+
|
|
273
301
|
const DEFERRAL_SUMMARIES = {
|
|
274
302
|
'github-plan-limitation':
|
|
275
303
|
'GitHub rulesets are unavailable because of the repository account plan',
|
|
@@ -353,6 +381,11 @@ export function mergeAttentionFromFacts(state: BuildState, ledger: DeferralLedge
|
|
|
353
381
|
state.status === 'aborted'
|
|
354
382
|
)
|
|
355
383
|
return null
|
|
384
|
+
// A landing settled as awaiting a human merge needs a person to merge on
|
|
385
|
+
// the forge. Polling needs no action and is not attention.
|
|
386
|
+
const fallback = currentLandingFallback(state.landing)
|
|
387
|
+
if (fallback?.mode === 'human-merge' && landingAuthorized(state.landing))
|
|
388
|
+
return { pr: state.pr, reason: landingFallbackReason(fallback, state.pr.number) }
|
|
356
389
|
// Consent and hold attention belongs to the current readiness queue. Only
|
|
357
390
|
// gate deferrals remain here, so stale or unfinished landings cannot wake
|
|
358
391
|
// through a second, weaker consent predicate.
|
|
@@ -245,6 +245,24 @@ export function randomStatusJournal(seed: number, length: number): RepositoryEve
|
|
|
245
245
|
payload: { executable: 'git', detail: 'Executable not found in $PATH: "git"' },
|
|
246
246
|
}),
|
|
247
247
|
() => ({ type: 'dispatcher.kernel-git-recovered', payload: { executable: 'git' } }),
|
|
248
|
+
() => ({
|
|
249
|
+
type: 'hook.failing',
|
|
250
|
+
payload: {
|
|
251
|
+
hook: 'notify',
|
|
252
|
+
since: '2026-01-01T00:00:00.000Z',
|
|
253
|
+
attempts: 3,
|
|
254
|
+
error: 'exit status 1',
|
|
255
|
+
record: 'repo:1',
|
|
256
|
+
},
|
|
257
|
+
}),
|
|
258
|
+
() => ({
|
|
259
|
+
type: 'hook.recovered',
|
|
260
|
+
payload: { hook: 'notify', since: '2026-01-01T00:00:00.000Z', attempts: 3 },
|
|
261
|
+
}),
|
|
262
|
+
() => ({
|
|
263
|
+
type: 'hook.skipped',
|
|
264
|
+
payload: { hook: 'notify', reason: 'cursor too old', ranges: [] },
|
|
265
|
+
}),
|
|
248
266
|
() => ({
|
|
249
267
|
type: 'dispatcher.run-started',
|
|
250
268
|
payload: {
|