@defrex/autobuild 1.10.0 → 1.11.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 +738 -68
- package/bin/ab-dispatch-generation.ts +3 -1
- package/docs/accounts.md +2 -1
- package/docs/answering-blocked-builds.md +20 -0
- package/docs/architecture.md +155 -25
- package/docs/build-store.md +10 -7
- package/docs/cli.md +33 -1
- package/docs/configuration-overview.md +4 -1
- package/docs/configuration.md +381 -29
- package/docs/dispatcher.md +63 -4
- package/docs/forges.md +7 -0
- package/docs/integration-tree.md +2 -2
- package/docs/operating.md +4 -2
- package/docs/operator-api.md +134 -6
- package/docs/operator-surfaces.md +85 -0
- package/docs/optimization-nodes.md +69 -11
- package/docs/plugin-authoring.md +37 -1
- package/docs/remote-store-protocol.md +94 -13
- package/docs/remote-ticket-protocol.md +40 -0
- package/docs/restacking.md +20 -4
- package/docs/setup.md +14 -2
- package/docs/ticket-dependencies.md +10 -3
- package/docs/ticket-sources.md +24 -2
- package/docs/tickets.md +7 -1
- package/docs/troubleshooting.md +8 -0
- package/docs/verification.md +4 -3
- package/docs/workspaces.md +3 -0
- package/package.json +9 -5
- package/packages/core/src/cli/accounts.ts +7 -2
- package/packages/core/src/cli/attention.ts +3 -1
- package/packages/core/src/cli/binary-direct.ts +2 -0
- package/packages/core/src/cli/binary-lifecycle.ts +2 -1
- package/packages/core/src/cli/build-control.ts +79 -1
- package/packages/core/src/cli/context.ts +4 -0
- package/packages/core/src/cli/dashboard/facts.ts +49 -53
- package/packages/core/src/cli/dashboard/header.ts +101 -0
- package/packages/core/src/cli/dashboard/model.ts +31 -39
- package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
- package/packages/core/src/cli/dashboard/poll.ts +178 -76
- package/packages/core/src/cli/dashboard/render.ts +129 -230
- package/packages/core/src/cli/dashboard/row-text.ts +538 -0
- package/packages/core/src/cli/dashboard/timeline.ts +288 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
- package/packages/core/src/cli/dispatch-args.ts +44 -1
- package/packages/core/src/cli/dispatch-frontend.ts +29 -38
- package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
- package/packages/core/src/cli/dispatch-launcher.ts +20 -7
- package/packages/core/src/cli/dispatch-web.ts +155 -0
- package/packages/core/src/cli/dispatch.ts +200 -34
- package/packages/core/src/cli/help.ts +87 -3
- package/packages/core/src/cli/init-validation.ts +3 -3
- package/packages/core/src/cli/main.ts +70 -6
- package/packages/core/src/cli/mcp.ts +35 -3
- package/packages/core/src/cli/objective.ts +1 -1
- package/packages/core/src/cli/operator-preference.ts +57 -0
- package/packages/core/src/cli/repo-lease.ts +2 -0
- package/packages/core/src/cli/repo-state.ts +56 -6
- package/packages/core/src/cli/repository-status.ts +97 -43
- package/packages/core/src/cli/status.ts +82 -1
- package/packages/core/src/cli/terminal-restore.ts +32 -7
- package/packages/core/src/cli/ticket.ts +98 -36
- package/packages/core/src/cli/wait.ts +14 -6
- package/packages/core/src/cli/watch.ts +20 -4
- package/packages/core/src/cli/web.ts +139 -0
- package/packages/core/src/config/live.ts +99 -14
- package/packages/core/src/config/load.ts +61 -20
- package/packages/core/src/config/local.ts +212 -0
- package/packages/core/src/config/pipeline-source.ts +2 -0
- package/packages/core/src/config/reference.ts +18 -0
- package/packages/core/src/config/schema.ts +45 -10
- package/packages/core/src/events/catalog.ts +4 -0
- package/packages/core/src/events/payloads.ts +97 -0
- package/packages/core/src/events/policy.ts +10 -0
- package/packages/core/src/events/repository.ts +46 -3
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +316 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
- package/packages/core/src/kernel/build-roster.ts +230 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
- package/packages/core/src/kernel/engine.ts +43 -5
- package/packages/core/src/kernel/execution-intervals.ts +61 -0
- package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
- package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
- package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
- package/packages/core/src/kernel/log-index.ts +19 -0
- package/packages/core/src/kernel/optimization-admission.ts +244 -3
- package/packages/core/src/kernel/optimization.ts +183 -4
- package/packages/core/src/kernel/phase-failures.ts +121 -0
- package/packages/core/src/kernel/published-branch-head.ts +60 -0
- package/packages/core/src/kernel/reducer-registry.ts +27 -8
- package/packages/core/src/kernel/reducer-revisions.ts +25 -0
- package/packages/core/src/kernel/reducer.ts +63 -4
- package/packages/core/src/kernel/rollup.ts +61 -0
- package/packages/core/src/kernel/setup-streak.ts +38 -0
- package/packages/core/src/kernel/step-durations.ts +257 -0
- package/packages/core/src/kernel/target-observation.ts +6 -1
- package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
- package/packages/core/src/kernel/verify-diff-base.ts +5 -0
- package/packages/core/src/kernel/verify-stages.ts +13 -3
- package/packages/core/src/ontology.ts +5 -0
- package/packages/core/src/operator/agent-context-serve.ts +631 -0
- package/packages/core/src/operator/annotations.ts +75 -5
- package/packages/core/src/operator/attention.ts +470 -0
- package/packages/core/src/operator/canonical-skills.ts +35 -0
- package/packages/core/src/operator/cli-equivalents.ts +270 -0
- package/packages/core/src/operator/context-prompts.ts +61 -0
- package/packages/core/src/operator/index.ts +49 -1
- package/packages/core/src/operator/landings.ts +28 -19
- package/packages/core/src/operator/optimization.ts +7 -0
- package/packages/core/src/operator/protocol.ts +3 -0
- package/packages/core/src/operator/query.ts +122 -72
- package/packages/core/src/operator/read-view.ts +5 -2
- package/packages/core/src/operator/registry.ts +406 -46
- package/packages/core/src/operator/requests.ts +20 -18
- package/packages/core/src/operator/sandbox-host.ts +107 -11
- package/packages/core/src/operator/sandbox-resolver.ts +253 -0
- package/packages/core/src/operator/sandbox.ts +778 -82
- package/packages/core/src/operator/ticket-asset-list.ts +77 -0
- package/packages/core/src/operator/ticket-assets.ts +167 -0
- package/packages/core/src/operator/tickets.ts +33 -2
- package/packages/core/src/plugin-sdk/index.ts +22 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/ports/forge/fake.ts +92 -1
- package/packages/core/src/ports/forge/git-blob.ts +15 -0
- package/packages/core/src/ports/forge/github.ts +82 -0
- package/packages/core/src/ports/forge/local-git.ts +61 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
- package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
- package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
- package/packages/core/src/ports/tickets/contract.ts +71 -0
- package/packages/core/src/ports/tickets/fake.ts +11 -0
- package/packages/core/src/ports/tickets/file.ts +18 -0
- package/packages/core/src/ports/tickets/github-fake.ts +136 -4
- package/packages/core/src/ports/tickets/github.ts +387 -30
- package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
- package/packages/core/src/ports/tickets/linear.ts +130 -0
- package/packages/core/src/ports/tickets/priority.ts +9 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
- package/packages/core/src/ports/tickets/remote.ts +70 -6
- package/packages/core/src/ports/tickets/search.ts +139 -0
- package/packages/core/src/ports/types.ts +104 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
- package/packages/core/src/ports/workspace/create.ts +15 -1
- package/packages/core/src/ports/workspace/fake.ts +340 -12
- package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
- package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
- package/packages/core/src/ports/workspace/process-group.ts +48 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
- package/packages/core/src/processes/agent-context-assemble.ts +576 -0
- package/packages/core/src/processes/agent-context.ts +469 -0
- package/packages/core/src/processes/build-runner.ts +387 -236
- package/packages/core/src/processes/dispatcher.ts +211 -55
- package/packages/core/src/processes/execution-no-progress.ts +4 -0
- package/packages/core/src/processes/optimization-activity.ts +120 -0
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/repo-view.ts +78 -2
- package/packages/core/src/processes/sandbox-state.ts +53 -6
- package/packages/core/src/processes/tick-publication.ts +2 -0
- package/packages/core/src/processes/workspace-preparation.ts +76 -0
- package/packages/core/src/scenarios/harness.ts +0 -5
- package/packages/core/src/store/account-redaction.ts +1 -0
- package/packages/core/src/store/adapter.ts +52 -1
- package/packages/core/src/store/agent-context.ts +432 -0
- package/packages/core/src/store/build-feed.ts +291 -0
- package/packages/core/src/store/build-scope.ts +19 -1
- package/packages/core/src/store/contract.ts +911 -14
- package/packages/core/src/store/digest.ts +19 -6
- package/packages/core/src/store/histogram.ts +113 -0
- package/packages/core/src/store/local/schema.ts +62 -0
- package/packages/core/src/store/local/store.ts +628 -22
- package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
- package/packages/core/src/store/memory.ts +461 -69
- package/packages/core/src/store/open-builds.ts +19 -0
- package/packages/core/src/store/phase-session.ts +32 -4
- package/packages/core/src/store/reduced-reads.ts +14 -4
- package/packages/core/src/store/reducer-value-shapes.json +6987 -5749
- package/packages/core/src/store/reducer-values.ts +6 -1
- package/packages/core/src/store/remote/client.ts +208 -2
- package/packages/core/src/store/remote/compatibility.ts +1 -1
- package/packages/core/src/store/remote/index.ts +33 -0
- package/packages/core/src/store/remote/protocol.ts +69 -0
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
- package/packages/core/src/store/retention.ts +23 -1
- package/packages/core/src/store/rollups.ts +337 -0
- package/packages/core/src/store/session-handle.ts +20 -2
- package/packages/core/src/store/snapshots.ts +10 -0
- package/packages/core/src/store/types.ts +108 -9
- package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
- package/packages/core/src/testing/git-config-isolation.ts +7 -5
- package/packages/core/src/testing/index.ts +27 -0
- package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
- package/packages/core/src/web/analytics-source.ts +303 -0
- package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
- package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
- package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
- package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
- package/packages/core/src/web/assets/app.css +1 -0
- package/packages/core/src/web/assets/app.js +9 -0
- package/packages/core/src/web/assets/manifest.json +31 -0
- package/packages/core/src/web/assets/theme.js +1 -0
- package/packages/core/src/web/bounded.ts +31 -0
- package/packages/core/src/web/http.ts +315 -0
- package/packages/core/src/web/hub.ts +160 -0
- package/packages/core/src/web/options.ts +38 -0
- package/packages/core/src/web/overview-source.ts +322 -0
- package/packages/core/src/web/page.ts +56 -0
- package/packages/core/src/web/protocol.ts +151 -0
- package/packages/core/src/web/read-only.ts +23 -0
- package/packages/core/src/web/repository-source.ts +35 -0
- package/packages/core/src/web/server.ts +97 -0
- package/skills/code-review/SKILL.md +10 -2
- package/skills/guide/SKILL.md +366 -52
- package/skills/guide/references/accounts.md +2 -1
- package/skills/guide/references/integration-tree.md +2 -2
- package/skills/guide/references/operator-api.md +134 -6
- package/skills/guide/references/optimization-nodes.md +69 -11
- package/skills/guide/references/plugin-authoring.md +37 -1
- package/skills/guide/references/remote-store-protocol.md +94 -13
- package/skills/guide/references/remote-ticket-protocol.md +40 -0
- package/skills/guide/references/restacking.md +20 -4
- package/skills/guide/references/setup.md +14 -2
- package/skills/guide/references/ticket-dependencies.md +10 -3
- package/skills/implement/SKILL.md +23 -4
- package/skills/operate/SKILL.md +134 -32
- package/skills/plan/SKILL.md +10 -4
- package/skills/plan-review/SKILL.md +9 -2
- package/skills/spec/SKILL.md +34 -8
- package/skills/tickets/SKILL.md +51 -5
- package/templates/hosted-service/package.json +2 -2
|
@@ -39,7 +39,8 @@ import {
|
|
|
39
39
|
} from '../ports/forge-telemetry'
|
|
40
40
|
import { configSchema, hooksSchema } from '../config/schema'
|
|
41
41
|
import { readHookProgress } from '../processes/hooks'
|
|
42
|
-
import type { BuildStore } from '../store/types'
|
|
42
|
+
import type { BuildStore, RepositoryArtifact } from '../store/types'
|
|
43
|
+
import type { LocalOverrideRecord } from '../config/local'
|
|
43
44
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
44
45
|
import { forgeReadinessWarnings, reduceDispatchStatus } from '../kernel/dispatch-status'
|
|
45
46
|
import { readRepositoryFacts, type RepositoryReadFacts } from '../store/reduced-reads'
|
|
@@ -102,6 +103,14 @@ export interface RepositoryUpgradeStatus {
|
|
|
102
103
|
previous?: UpgradeStatusEntry
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
/** Conservative running evidence: only durable retirement clears an expired run. */
|
|
107
|
+
export function dispatcherRunning(
|
|
108
|
+
dispatcher: DispatcherLiveness,
|
|
109
|
+
upgrades: RepositoryUpgradeStatus,
|
|
110
|
+
): boolean {
|
|
111
|
+
return Boolean(dispatcher.holder || dispatcher.expiredHolder || upgrades.handoff)
|
|
112
|
+
}
|
|
113
|
+
|
|
105
114
|
export function projectUpgradeStatus(
|
|
106
115
|
upgrades: DispatchUpgradeState,
|
|
107
116
|
dispatcher: DispatcherLiveness,
|
|
@@ -178,6 +187,7 @@ export function projectUpgradeStatus(
|
|
|
178
187
|
|
|
179
188
|
/** Script-facing projection returned by `ab repository status`. */
|
|
180
189
|
export interface RepositoryStatus extends DispatchSettings {
|
|
190
|
+
dispatcherRunning: boolean
|
|
181
191
|
operator: RepositoryOperatorStatus
|
|
182
192
|
repo: string
|
|
183
193
|
/** Bounded retention window; full history stays in the repository journal. */
|
|
@@ -185,6 +195,10 @@ export interface RepositoryStatus extends DispatchSettings {
|
|
|
185
195
|
upgradeStatus: RepositoryUpgradeStatus
|
|
186
196
|
rollbackHold?: DispatchUpgradeState['lastRollback']
|
|
187
197
|
capacity?: DispatchCapacity
|
|
198
|
+
/** Settings the held dispatcher's effective configuration took from its
|
|
199
|
+
* checkout's local override file (`.autobuild/local.toml`). Absent when the
|
|
200
|
+
* held dispatcher runs without local overrides. */
|
|
201
|
+
localOverrides?: LocalOverrideRecord
|
|
188
202
|
/** Configured hooks of the latest dispatcher run and their delivery
|
|
189
203
|
* progress; set only by `ab repository status`. */
|
|
190
204
|
hooks?: HookStatus[]
|
|
@@ -226,8 +240,10 @@ export interface RepositoryStatus extends DispatchSettings {
|
|
|
226
240
|
operator: string
|
|
227
241
|
environmentId: string
|
|
228
242
|
provider: string
|
|
229
|
-
state: 'live' | 'stopped'
|
|
243
|
+
state: 'provisioning' | 'live' | 'stopped' | 'failed'
|
|
230
244
|
lastEvidenceAt: string
|
|
245
|
+
/** The failed background attempt's stage and redacted message. */
|
|
246
|
+
failure?: { stage: string; message: string }
|
|
231
247
|
}>
|
|
232
248
|
/** PR-only publications from operator sandboxes (AUT-343), newest first,
|
|
233
249
|
* latest per (operator, branch). */
|
|
@@ -361,6 +377,7 @@ export function projectRepositoryStatus(
|
|
|
361
377
|
latestScan?.type === 'dispatcher.ticket-scan-completed'
|
|
362
378
|
? latestScan.payload.ticketDiagnostics
|
|
363
379
|
: []
|
|
380
|
+
const upgradeStatus = projectUpgradeStatus(dispatchUpgradeReducer.reduce(events), dispatcher)
|
|
364
381
|
return {
|
|
365
382
|
...(forgeHealthReducer.reduce(events)
|
|
366
383
|
? { forgeDegradation: forgeHealthReducer.reduce(events) }
|
|
@@ -374,7 +391,8 @@ export function projectRepositoryStatus(
|
|
|
374
391
|
repo,
|
|
375
392
|
operator: { presence: 'unavailable', reason: OPERATOR_PRESENCE_UNAVAILABLE },
|
|
376
393
|
upgrades: dispatchUpgradeReducer.reduce(events),
|
|
377
|
-
upgradeStatus
|
|
394
|
+
upgradeStatus,
|
|
395
|
+
dispatcherRunning: dispatcherRunning(dispatcher, upgradeStatus),
|
|
378
396
|
rollbackHold: effectiveRollbackHold(dispatchUpgradeReducer.reduce(events), dispatcher),
|
|
379
397
|
...(warningLines.length ? { warningLines } : {}),
|
|
380
398
|
...(ticketDiagnostics.length ? { ticketDiagnostics: [...ticketDiagnostics] } : {}),
|
|
@@ -388,8 +406,9 @@ export function projectRepositoryStatus(
|
|
|
388
406
|
operator: state.operator,
|
|
389
407
|
environmentId: state.environmentId,
|
|
390
408
|
provider: state.provider,
|
|
391
|
-
state: state.state === '
|
|
409
|
+
state: state.state === 'released' ? ('stopped' as const) : state.state,
|
|
392
410
|
lastEvidenceAt: state.lastEvidenceTs,
|
|
411
|
+
...(state.failure !== undefined ? { failure: { ...state.failure } } : {}),
|
|
393
412
|
})),
|
|
394
413
|
publications,
|
|
395
414
|
}
|
|
@@ -401,6 +420,7 @@ export function repositoryStatusFromFacts(
|
|
|
401
420
|
dispatcher: DispatcherLiveness,
|
|
402
421
|
now: Date = new Date(),
|
|
403
422
|
): RepositoryStatus {
|
|
423
|
+
const upgradeStatus = projectUpgradeStatus(facts.upgrades, dispatcher)
|
|
404
424
|
const credentialLimits = activeForgeCredentialLimits(facts.forgeCredentialLimits, now)
|
|
405
425
|
const warningLines = facts.status
|
|
406
426
|
? [...facts.status.roleWarnings, ...forgeReadinessWarnings(facts.status)]
|
|
@@ -415,7 +435,8 @@ export function repositoryStatusFromFacts(
|
|
|
415
435
|
repo,
|
|
416
436
|
operator: { presence: 'unavailable', reason: OPERATOR_PRESENCE_UNAVAILABLE },
|
|
417
437
|
upgrades: facts.upgrades,
|
|
418
|
-
upgradeStatus
|
|
438
|
+
upgradeStatus,
|
|
439
|
+
dispatcherRunning: dispatcherRunning(dispatcher, upgradeStatus),
|
|
419
440
|
rollbackHold: effectiveRollbackHold(facts.upgrades, dispatcher),
|
|
420
441
|
...(warningLines.length ? { warningLines } : {}),
|
|
421
442
|
...(ticketDiagnostics.length ? { ticketDiagnostics: [...ticketDiagnostics] } : {}),
|
|
@@ -432,8 +453,9 @@ export function repositoryStatusFromFacts(
|
|
|
432
453
|
operator: state.operator,
|
|
433
454
|
environmentId: state.environmentId,
|
|
434
455
|
provider: state.provider,
|
|
435
|
-
state: state.state === '
|
|
456
|
+
state: state.state === 'released' ? ('stopped' as const) : state.state,
|
|
436
457
|
lastEvidenceAt: state.lastEvidenceTs,
|
|
458
|
+
...(state.failure !== undefined ? { failure: { ...state.failure } } : {}),
|
|
437
459
|
})),
|
|
438
460
|
publications: [...facts.publications].reverse().map((event) => ({
|
|
439
461
|
operator: event.payload.operator,
|
|
@@ -559,6 +581,11 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
|
|
|
559
581
|
...(status.warningLines ?? []),
|
|
560
582
|
...(status.hooks ?? []).map(renderHookStatus),
|
|
561
583
|
`dispatcher: ${status.dispatcher.state}${status.dispatcher.holder ? ` — ${formatRepositoryDispatcherIdentity(status.dispatcher.holder)}` : ' — no dispatcher holds the repository'}`,
|
|
584
|
+
...(status.localOverrides
|
|
585
|
+
? [
|
|
586
|
+
`dispatcher local overrides (${status.localOverrides.file}): ${status.localOverrides.settings.join(', ')}`,
|
|
587
|
+
]
|
|
588
|
+
: []),
|
|
562
589
|
...(status.dispatcher.expiredHolder
|
|
563
590
|
? [
|
|
564
591
|
`expired dispatcher: ${formatRepositoryDispatcherIdentity(status.dispatcher.expiredHolder)}`,
|
|
@@ -591,7 +618,7 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
|
|
|
591
618
|
...(status.dependencyDiagnostics ?? []).map((line) => `queue: ${line}`),
|
|
592
619
|
...status.sandboxes.map(
|
|
593
620
|
(sandbox) =>
|
|
594
|
-
`operator sandbox ${sandbox.environmentId} (${sandbox.provider}) — ${sandbox.state}, idle since ${sandbox.lastEvidenceAt}`,
|
|
621
|
+
`operator sandbox ${sandbox.environmentId} (${sandbox.provider}) — ${sandbox.state}${sandbox.failure !== undefined ? ` (${sandbox.failure.stage}: ${sandbox.failure.message.replace(/\s+/g, ' ')})` : ''}, idle since ${sandbox.lastEvidenceAt}`,
|
|
595
622
|
),
|
|
596
623
|
...status.publications.map(
|
|
597
624
|
(publication) =>
|
|
@@ -659,55 +686,79 @@ export function renderHookStatus(hook: HookStatus): string {
|
|
|
659
686
|
}${hook.failing ? ` — failing since ${hook.failing.since}: ${hook.failing.error}` : ''}`
|
|
660
687
|
}
|
|
661
688
|
|
|
662
|
-
/**
|
|
663
|
-
|
|
689
|
+
/** The held dispatcher's effective-config artifact: one artifact read when a
|
|
690
|
+
* dispatcher holds the repository and recorded its configuration, else none. */
|
|
691
|
+
export async function readHeldEffectiveConfig(
|
|
664
692
|
store: BuildStore,
|
|
665
693
|
repo: string,
|
|
666
694
|
facts: RepositoryReadFacts,
|
|
667
695
|
dispatcher: DispatcherLiveness,
|
|
668
|
-
|
|
669
|
-
): Promise<DispatchCapacity | undefined> {
|
|
696
|
+
): Promise<RepositoryArtifact | undefined> {
|
|
670
697
|
if (
|
|
671
698
|
dispatcher.state === 'held' &&
|
|
672
699
|
facts.status?.effectiveConfig &&
|
|
673
700
|
facts.status.run === dispatcher.holder?.run
|
|
674
701
|
) {
|
|
675
702
|
const ref = facts.status.effectiveConfig
|
|
676
|
-
|
|
677
|
-
if (artifact) {
|
|
678
|
-
const config = configSchema.parse(
|
|
679
|
-
normalizeEffectiveConfigArtifact(JSON.parse(new TextDecoder().decode(artifact.content))),
|
|
680
|
-
)
|
|
681
|
-
const builds: CapacityBuild[] = []
|
|
682
|
-
const records = await store.listBuildsForRepo(repo)
|
|
683
|
-
const digests = await store.getRepoBuildDigests(repo)
|
|
684
|
-
for (const record of records) {
|
|
685
|
-
if (digests.get(record.slug)?.terminal) continue
|
|
686
|
-
const build = (await readBuildFacts(store, record.slug)).value
|
|
687
|
-
builds.push({
|
|
688
|
-
record,
|
|
689
|
-
state: build.state,
|
|
690
|
-
workspace: build.workspace !== null,
|
|
691
|
-
provisioning: build.provisionMarker !== undefined,
|
|
692
|
-
restackDue: landingRestackDue(build.state, build.log),
|
|
693
|
-
})
|
|
694
|
-
}
|
|
695
|
-
return dispatchCapacity(
|
|
696
|
-
builds,
|
|
697
|
-
config.capacity,
|
|
698
|
-
now,
|
|
699
|
-
migrationIdentity(facts.ticketMigrations, config.tickets.source),
|
|
700
|
-
{
|
|
701
|
-
urgentClaims: urgentClaimDemand(facts),
|
|
702
|
-
startRequests: startClaimDemand(facts),
|
|
703
|
-
openPrs: { policy: config.policy, engaged: facts.openPrBackpressure !== undefined },
|
|
704
|
-
},
|
|
705
|
-
)
|
|
706
|
-
}
|
|
703
|
+
return (await store.getRepoArtifact(repo, ref.kind, ref.rev)) ?? undefined
|
|
707
704
|
}
|
|
708
705
|
return undefined
|
|
709
706
|
}
|
|
710
707
|
|
|
708
|
+
/** The local-override record an effective-config artifact's metadata carries;
|
|
709
|
+
* anything malformed reads as none. */
|
|
710
|
+
export function localOverridesFromArtifact(
|
|
711
|
+
artifact: Pick<RepositoryArtifact, 'meta'> | undefined,
|
|
712
|
+
): LocalOverrideRecord | undefined {
|
|
713
|
+
const raw = artifact?.meta.metadata.localOverrides
|
|
714
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return undefined
|
|
715
|
+
const { file, settings } = raw as { file?: unknown; settings?: unknown }
|
|
716
|
+
if (typeof file !== 'string') return undefined
|
|
717
|
+
if (!Array.isArray(settings) || !settings.every((entry) => typeof entry === 'string'))
|
|
718
|
+
return undefined
|
|
719
|
+
return { file, settings: [...settings] }
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/** Capacity is optional when no held dispatcher has a retrievable configuration
|
|
723
|
+
* (`artifact` comes from `readHeldEffectiveConfig`). */
|
|
724
|
+
export async function readRepositoryCapacity(
|
|
725
|
+
store: BuildStore,
|
|
726
|
+
repo: string,
|
|
727
|
+
facts: RepositoryReadFacts,
|
|
728
|
+
artifact: RepositoryArtifact | undefined,
|
|
729
|
+
now: Date,
|
|
730
|
+
): Promise<DispatchCapacity | undefined> {
|
|
731
|
+
if (!artifact) return undefined
|
|
732
|
+
const config = configSchema.parse(
|
|
733
|
+
normalizeEffectiveConfigArtifact(JSON.parse(new TextDecoder().decode(artifact.content))),
|
|
734
|
+
)
|
|
735
|
+
const builds: CapacityBuild[] = []
|
|
736
|
+
// Only nonterminal builds hold capacity; the open listing never reads a
|
|
737
|
+
// settled build, so this read stays flat as history accumulates.
|
|
738
|
+
for (const { record, digest } of await store.listOpenBuilds(repo)) {
|
|
739
|
+
if (digest.terminal) continue
|
|
740
|
+
const build = (await readBuildFacts(store, record.slug)).value
|
|
741
|
+
builds.push({
|
|
742
|
+
record,
|
|
743
|
+
state: build.state,
|
|
744
|
+
workspace: build.workspace !== null,
|
|
745
|
+
provisioning: build.provisionMarker !== undefined,
|
|
746
|
+
restackDue: landingRestackDue(build.state, build.log),
|
|
747
|
+
})
|
|
748
|
+
}
|
|
749
|
+
return dispatchCapacity(
|
|
750
|
+
builds,
|
|
751
|
+
config.capacity,
|
|
752
|
+
now,
|
|
753
|
+
migrationIdentity(facts.ticketMigrations, config.tickets.source),
|
|
754
|
+
{
|
|
755
|
+
urgentClaims: urgentClaimDemand(facts),
|
|
756
|
+
startRequests: startClaimDemand(facts),
|
|
757
|
+
openPrs: { policy: config.policy, engaged: facts.openPrBackpressure !== undefined },
|
|
758
|
+
},
|
|
759
|
+
)
|
|
760
|
+
}
|
|
761
|
+
|
|
711
762
|
/**
|
|
712
763
|
* `ab repository status` — read the durable dispatcher controls without
|
|
713
764
|
* creating a repository stream or starting any dispatcher work.
|
|
@@ -729,8 +780,11 @@ export async function abRepositoryStatus(opts: RepositoryStatusOpts): Promise<vo
|
|
|
729
780
|
}))
|
|
730
781
|
.filter((row) => row.heartbeatAgeMs < OPERATOR_PRESENCE_TTL_MS),
|
|
731
782
|
}
|
|
732
|
-
const
|
|
783
|
+
const held = await readHeldEffectiveConfig(store, repo, facts, dispatcher)
|
|
784
|
+
const capacity = await readRepositoryCapacity(store, repo, facts, held, observedAt)
|
|
733
785
|
if (capacity) status.capacity = capacity
|
|
786
|
+
const localOverrides = localOverridesFromArtifact(held)
|
|
787
|
+
if (localOverrides) status.localOverrides = localOverrides
|
|
734
788
|
status.hooks = await readRepositoryHooks(store, repo, facts)
|
|
735
789
|
if (opts.json === true) {
|
|
736
790
|
opts.stdout(JSON.stringify(status, null, 2))
|
|
@@ -324,6 +324,22 @@ export interface BuildDetail extends BuildSummary {
|
|
|
324
324
|
/** A work build's open or latest restack: why it ran (its trigger), the
|
|
325
325
|
* target base it moves onto, and where it stands. */
|
|
326
326
|
restack?: LeafRestackStatus
|
|
327
|
+
/** The open `target.rewritten` wait. `adoptedBase` is set when the
|
|
328
|
+
* rewritten-from commit is a base the build's first local provision adopted
|
|
329
|
+
* from a pre-existing branch (#1261). A leaf's `recovery` says how it leaves
|
|
330
|
+
* the wait: `pending` until its next runner reprovisions it (no work) or
|
|
331
|
+
* escalates (work), `escalated` while its target-rewritten escalation is
|
|
332
|
+
* open. Nodes carry none. */
|
|
333
|
+
targetRewrite?: {
|
|
334
|
+
branch: string
|
|
335
|
+
previousSha: string
|
|
336
|
+
sha: string
|
|
337
|
+
adoptedBase?: { branch: string; sha: string }
|
|
338
|
+
recovery?: 'pending' | 'escalated'
|
|
339
|
+
}
|
|
340
|
+
/** An open no-work reset of a rewritten-target episode whose rewrite has
|
|
341
|
+
* since cleared: the next runner start completes it. */
|
|
342
|
+
targetReprovision?: { branch: string; sha: string }
|
|
327
343
|
/** Per-loop review overrides for the current spec; omitted when none are set. */
|
|
328
344
|
reviewRoundCeilings?: { plan?: number; code?: number }
|
|
329
345
|
/** Frozen forge issue links with effective intent; omitted when none. */
|
|
@@ -545,6 +561,10 @@ export function detail(
|
|
|
545
561
|
.filter((event) => event.type === 'observation.recorded')
|
|
546
562
|
.map((event) => event.payload),
|
|
547
563
|
open: openExecution(events),
|
|
564
|
+
firstWorkspace: events.find(
|
|
565
|
+
(event): event is Extract<AbEvent, { type: 'workspace.provisioned' }> =>
|
|
566
|
+
event.type === 'workspace.provisioned',
|
|
567
|
+
),
|
|
548
568
|
},
|
|
549
569
|
now,
|
|
550
570
|
eventCount === undefined ? undefined : events.slice(-eventCount),
|
|
@@ -563,6 +583,45 @@ function nodeLandingDeferred(state: BuildState): { landingDeferred?: string } {
|
|
|
563
583
|
return reason === undefined ? {} : { landingDeferred: reason }
|
|
564
584
|
}
|
|
565
585
|
|
|
586
|
+
/** The open target rewrite, naming a base adopted from a pre-existing branch
|
|
587
|
+
* at the build's first local provision. */
|
|
588
|
+
function targetRewriteDetail(
|
|
589
|
+
state: BuildState,
|
|
590
|
+
firstWorkspace: BuildFacts['firstWorkspace'],
|
|
591
|
+
restack: BuildFacts['log']['restack'] | undefined,
|
|
592
|
+
): Pick<BuildDetail, 'targetRewrite' | 'targetReprovision'> {
|
|
593
|
+
const rewrite = state.targetRewrite?.payload
|
|
594
|
+
const prepared = state.kind === 'node' ? undefined : restack?.reprovision
|
|
595
|
+
if (rewrite === undefined)
|
|
596
|
+
return prepared === undefined
|
|
597
|
+
? {}
|
|
598
|
+
: { targetReprovision: { branch: prepared.branch, sha: prepared.sha } }
|
|
599
|
+
const first = firstWorkspace?.payload
|
|
600
|
+
const adopted =
|
|
601
|
+
state.kind !== 'node' &&
|
|
602
|
+
first !== undefined &&
|
|
603
|
+
first.base.source === 'existing' &&
|
|
604
|
+
first.remote !== true &&
|
|
605
|
+
first.base.sha === rewrite.previousSha
|
|
606
|
+
return {
|
|
607
|
+
targetRewrite: {
|
|
608
|
+
branch: rewrite.branch,
|
|
609
|
+
previousSha: rewrite.previousSha,
|
|
610
|
+
sha: rewrite.sha,
|
|
611
|
+
...(adopted ? { adoptedBase: { branch: first.branch, sha: first.base.sha } } : {}),
|
|
612
|
+
...(state.kind === 'node'
|
|
613
|
+
? {}
|
|
614
|
+
: {
|
|
615
|
+
recovery: state.openEscalations.some(
|
|
616
|
+
(e) => e.source === 'policy' && e.policyCause === 'target-rewritten',
|
|
617
|
+
)
|
|
618
|
+
? ('escalated' as const)
|
|
619
|
+
: ('pending' as const),
|
|
620
|
+
}),
|
|
621
|
+
},
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
566
625
|
/** An optimization node's slot-holding conditions, from its reduced digest. */
|
|
567
626
|
function optimizationDetail(
|
|
568
627
|
state: BuildState,
|
|
@@ -579,7 +638,7 @@ function optimizationDetail(
|
|
|
579
638
|
export function detailFromFacts(
|
|
580
639
|
record: BuildRecord,
|
|
581
640
|
facts: Pick<BuildFacts, 'state' | 'open'> &
|
|
582
|
-
Partial<Pick<BuildFacts, 'log' | 'runnerAttaches'>> & {
|
|
641
|
+
Partial<Pick<BuildFacts, 'log' | 'runnerAttaches' | 'firstWorkspace'>> & {
|
|
583
642
|
observations: BuildState['observations']
|
|
584
643
|
},
|
|
585
644
|
now: Date,
|
|
@@ -656,6 +715,7 @@ export function detailFromFacts(
|
|
|
656
715
|
}
|
|
657
716
|
: {}),
|
|
658
717
|
...(state.profile !== undefined ? { profile: { ...state.profile } } : {}),
|
|
718
|
+
...targetRewriteDetail(state, facts.firstWorkspace, facts.log?.restack),
|
|
659
719
|
...(state.reviewRoundCeilings.plan !== undefined || state.reviewRoundCeilings.code !== undefined
|
|
660
720
|
? { reviewRoundCeilings: { ...state.reviewRoundCeilings } }
|
|
661
721
|
: {}),
|
|
@@ -1078,6 +1138,27 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
1078
1138
|
? ` waiting on: ${safeStatusText(ticketWaitText(d.wait, d.slug))}`
|
|
1079
1139
|
: ` waiting: ${safeStatusText(ticketWaitText(d.wait, d.slug))}`,
|
|
1080
1140
|
)
|
|
1141
|
+
if (d.targetRewrite !== undefined) {
|
|
1142
|
+
const rewrite = d.targetRewrite
|
|
1143
|
+
const target = safeStatusText(rewrite.branch)
|
|
1144
|
+
const previous = rewrite.previousSha.slice(0, 7)
|
|
1145
|
+
const current = rewrite.sha.slice(0, 7)
|
|
1146
|
+
const cause =
|
|
1147
|
+
rewrite.adoptedBase !== undefined
|
|
1148
|
+
? ` waiting: target-rewritten — base ${previous} was adopted from pre-existing branch ${safeStatusText(rewrite.adoptedBase.branch)} at first provision, not cut from ${target}; ${target} at ${current} does not descend from it`
|
|
1149
|
+
: ` waiting: target ${target} rewritten ${previous} → ${current}`
|
|
1150
|
+
lines.push(
|
|
1151
|
+
rewrite.recovery === 'pending'
|
|
1152
|
+
? `${cause}; the next runner start reprovisions the build from ${target} if it has no work of its own, else escalates`
|
|
1153
|
+
: rewrite.recovery === 'escalated'
|
|
1154
|
+
? `${cause}; the build has its own work; answer ab answer ${safeStatusText(d.slug)} --accept-target to restack it onto ${target}, or abort`
|
|
1155
|
+
: `${cause}; automatic adoption withheld until the target returns or the build is aborted`,
|
|
1156
|
+
)
|
|
1157
|
+
}
|
|
1158
|
+
if (d.targetReprovision !== undefined)
|
|
1159
|
+
lines.push(
|
|
1160
|
+
` recovering: reset to ${safeStatusText(d.targetReprovision.branch)} at ${d.targetReprovision.sha.slice(0, 7)} prepared; the next runner start completes it`,
|
|
1161
|
+
)
|
|
1081
1162
|
if (d.restack !== undefined)
|
|
1082
1163
|
lines.push(
|
|
1083
1164
|
` restack: ${d.restack.trigger} onto ${d.restack.onto.slice(0, 7)} — ${d.restack.state}${d.restack.regenerated ? ` (regenerated: ${d.restack.regenerated.join(', ')})` : ''}`,
|
|
@@ -113,15 +113,27 @@ export const TERMINATING_SIGNALS = [
|
|
|
113
113
|
'SIGTERM',
|
|
114
114
|
] as const satisfies readonly NodeJS.Signals[]
|
|
115
115
|
|
|
116
|
+
export type TerminatingSignal = (typeof TERMINATING_SIGNALS)[number]
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 128 + SIGQUIT's number. A drained SIGQUIT stop reports through this exit
|
|
120
|
+
* status instead of re-signalling, because SIGQUIT's default action dumps core
|
|
121
|
+
* and nothing crashed.
|
|
122
|
+
*/
|
|
123
|
+
export const DRAINED_QUIT_EXIT = 131
|
|
124
|
+
|
|
116
125
|
export interface TerminalRestoreProcess {
|
|
117
126
|
readonly pid: number
|
|
118
127
|
on(event: string, listener: (...args: unknown[]) => void): unknown
|
|
119
128
|
removeListener(event: string, listener: (...args: unknown[]) => void): unknown
|
|
120
129
|
kill(pid: number, signal: NodeJS.Signals): unknown
|
|
130
|
+
exit(code: number): unknown
|
|
121
131
|
}
|
|
122
132
|
|
|
123
133
|
export interface TerminalRestoreHook {
|
|
124
|
-
/** Restore active modes, remove this hook's listeners, then replay a captured
|
|
134
|
+
/** Restore active modes, remove this hook's listeners, then replay a captured
|
|
135
|
+
* SIGHUP or SIGTERM. A captured SIGQUIT exits {@link DRAINED_QUIT_EXIT}
|
|
136
|
+
* instead, or returns normally when supervised. */
|
|
125
137
|
close(): void
|
|
126
138
|
}
|
|
127
139
|
|
|
@@ -129,15 +141,19 @@ export interface TerminalRestoreHook {
|
|
|
129
141
|
* Install the synchronous process-boundary fallback used only by `ab dispatch`.
|
|
130
142
|
* SIGINT is deliberately absent: raw Ctrl-C and the binary's AbortController
|
|
131
143
|
* retain the dashboard's normal final-frame teardown. Other terminating signals
|
|
132
|
-
* restore immediately
|
|
144
|
+
* restore immediately and take effect only after the async dispatch drain:
|
|
145
|
+
* SIGHUP and SIGTERM are replayed, while SIGQUIT exits 131 rather than dumping
|
|
146
|
+
* core. A `supervised` generation does not act on SIGQUIT at all; its entry
|
|
147
|
+
* reports the stop through the launcher contract's stopped exit.
|
|
133
148
|
*/
|
|
134
149
|
export function installTerminalRestoreHook(
|
|
135
150
|
modes: TerminalModeController,
|
|
136
151
|
boundary: TerminalRestoreProcess = process as unknown as TerminalRestoreProcess,
|
|
137
|
-
requestStop: (signal:
|
|
152
|
+
requestStop: (signal: TerminatingSignal) => void = () => {},
|
|
153
|
+
options: { supervised?: boolean } = {},
|
|
138
154
|
): TerminalRestoreHook {
|
|
139
155
|
let closed = false
|
|
140
|
-
let pendingSignal:
|
|
156
|
+
let pendingSignal: TerminatingSignal | undefined
|
|
141
157
|
const registrations: Array<[string, (...args: unknown[]) => void]> = []
|
|
142
158
|
|
|
143
159
|
const restore = (): void => {
|
|
@@ -173,9 +189,18 @@ export function installTerminalRestoreHook(
|
|
|
173
189
|
// without depending on another promise turn or stream drain.
|
|
174
190
|
restore()
|
|
175
191
|
remove()
|
|
176
|
-
//
|
|
177
|
-
// gone
|
|
178
|
-
|
|
192
|
+
// Act only after the supervised child has drained and the handlers are
|
|
193
|
+
// gone. SIGHUP and SIGTERM replay to keep the operating system's
|
|
194
|
+
// terminating-signal semantics; SIGQUIT's default action dumps core, so
|
|
195
|
+
// a drained quit exits 131 instead.
|
|
196
|
+
if (pendingSignal === undefined) return
|
|
197
|
+
if (pendingSignal === 'SIGQUIT') {
|
|
198
|
+
// A supervised generation returns the drain's result: its entry exits
|
|
199
|
+
// GENERATION_EXITS.stopped and the launcher owns the public 131.
|
|
200
|
+
if (!options.supervised) boundary.exit(DRAINED_QUIT_EXIT)
|
|
201
|
+
return
|
|
202
|
+
}
|
|
203
|
+
boundary.kill(boundary.pid, pendingSignal)
|
|
179
204
|
},
|
|
180
205
|
}
|
|
181
206
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { recordTicketMigration, readTicketMigrations } from '../kernel/ticket-migrations'
|
|
2
2
|
import { readTicketTree } from '../operator/tickets'
|
|
3
|
+
import {
|
|
4
|
+
activeTicketBuilds,
|
|
5
|
+
assetTicketId,
|
|
6
|
+
projectTicketAssets,
|
|
7
|
+
} from '../operator/ticket-asset-list'
|
|
3
8
|
import { updateTicketTarget } from '../kernel/node-parent'
|
|
4
9
|
import { createForge } from '../ports/forge/create'
|
|
5
10
|
import { compatibleTicketSource, type TicketTreeEntry } from '../ports/tickets/tree'
|
|
@@ -7,7 +12,8 @@ import { formatIssueLinks, parseIssueLinkList } from '../ports/tickets/issue-lin
|
|
|
7
12
|
import { parsePriorityFlag, ticketPriority } from '../ports/tickets/priority'
|
|
8
13
|
import { creationAssignees, parseAssigneesFlag } from '../ports/tickets/assignees'
|
|
9
14
|
import { creationLabels } from '../ports/tickets/labels'
|
|
10
|
-
import {
|
|
15
|
+
import { searchTickets, TICKET_SEARCH_MAX_LIMIT } from '../ports/tickets/search'
|
|
16
|
+
import { rejectedStateOf } from '../ports/tickets/github-issues'
|
|
11
17
|
import { readBuildDigests, readBuildFacts } from '../store/reduced-reads'
|
|
12
18
|
import {
|
|
13
19
|
formatObjective,
|
|
@@ -154,6 +160,20 @@ export interface TicketListOpts extends TicketCommandOpts {
|
|
|
154
160
|
json?: boolean
|
|
155
161
|
}
|
|
156
162
|
|
|
163
|
+
export interface TicketSearchOpts extends TicketCommandOpts {
|
|
164
|
+
/** Separate diagnostic sink so `--json` stdout remains one bare value. */
|
|
165
|
+
stderr: (line: string) => void
|
|
166
|
+
/** Words every match contains in its title or body. */
|
|
167
|
+
query: string
|
|
168
|
+
/** Only this state; omitted searches every state. */
|
|
169
|
+
state?: string
|
|
170
|
+
/** Every requested label must match. */
|
|
171
|
+
labels?: string[]
|
|
172
|
+
limit?: number
|
|
173
|
+
cursor?: string
|
|
174
|
+
json?: boolean
|
|
175
|
+
}
|
|
176
|
+
|
|
157
177
|
export interface TicketShowOpts extends TicketCommandOpts {
|
|
158
178
|
id: string
|
|
159
179
|
json?: boolean
|
|
@@ -228,6 +248,7 @@ type TicketCommandName =
|
|
|
228
248
|
| 'block'
|
|
229
249
|
| 'unblock'
|
|
230
250
|
| 'list'
|
|
251
|
+
| 'search'
|
|
231
252
|
| 'show'
|
|
232
253
|
| 'move'
|
|
233
254
|
| 'attach'
|
|
@@ -538,6 +559,39 @@ export async function abTicketList(opts: TicketListOpts): Promise<void> {
|
|
|
538
559
|
for (const ticket of listing.tickets) opts.stdout(ticketSummary(ticket))
|
|
539
560
|
}
|
|
540
561
|
|
|
562
|
+
/** `ab ticket search <query>` — the same page `tickets.search` returns. */
|
|
563
|
+
export async function abTicketSearch(opts: TicketSearchOpts): Promise<void> {
|
|
564
|
+
const { source } = await resolveTicketCommand(opts, 'search')
|
|
565
|
+
const page = await searchTickets(source, {
|
|
566
|
+
text: opts.query,
|
|
567
|
+
...(opts.state !== undefined ? { state: opts.state } : {}),
|
|
568
|
+
...(opts.labels !== undefined ? { labels: opts.labels } : {}),
|
|
569
|
+
...(opts.limit !== undefined ? { limit: opts.limit } : {}),
|
|
570
|
+
...(opts.cursor !== undefined ? { cursor: opts.cursor } : {}),
|
|
571
|
+
})
|
|
572
|
+
if (opts.json === true) {
|
|
573
|
+
opts.stdout(JSON.stringify(page, null, 2))
|
|
574
|
+
return
|
|
575
|
+
}
|
|
576
|
+
for (const diagnostic of page.diagnostics) opts.stderr(diagnostic)
|
|
577
|
+
if (page.tickets.length === 0) {
|
|
578
|
+
opts.stdout(`no tickets matched "${opts.query}" in the configured ${source.name} ticket source`)
|
|
579
|
+
return
|
|
580
|
+
}
|
|
581
|
+
for (const hit of page.tickets) {
|
|
582
|
+
const fields = [
|
|
583
|
+
`${source.name}:${hit.id}`,
|
|
584
|
+
`(${hit.state ?? 'state unknown'})`,
|
|
585
|
+
`[${hit.kind}]`,
|
|
586
|
+
`— ${hit.title}`,
|
|
587
|
+
]
|
|
588
|
+
if (hit.labels.length > 0) fields.push(`— labels: ${hit.labels.join(', ')}`)
|
|
589
|
+
if (hit.target !== undefined) fields.push(`— target: ${hit.target}`)
|
|
590
|
+
opts.stdout(fields.join(' '))
|
|
591
|
+
}
|
|
592
|
+
if (page.cursor !== undefined) opts.stdout(`more matches: rerun with --cursor ${page.cursor}`)
|
|
593
|
+
}
|
|
594
|
+
|
|
541
595
|
/** `ab ticket show <id>` — complete metadata plus the body/spec. */
|
|
542
596
|
export async function abTicketShow(opts: TicketShowOpts): Promise<void> {
|
|
543
597
|
const { config, source } = await resolveTicketCommand(opts, 'show')
|
|
@@ -573,14 +627,7 @@ export async function abTicketShow(opts: TicketShowOpts): Promise<void> {
|
|
|
573
627
|
},
|
|
574
628
|
}
|
|
575
629
|
: {}),
|
|
576
|
-
assets: assets
|
|
577
|
-
kind,
|
|
578
|
-
name,
|
|
579
|
-
revision,
|
|
580
|
-
size,
|
|
581
|
-
layout,
|
|
582
|
-
fileCount,
|
|
583
|
-
})),
|
|
630
|
+
assets: projectTicketAssets(assets),
|
|
584
631
|
},
|
|
585
632
|
null,
|
|
586
633
|
2,
|
|
@@ -664,14 +711,8 @@ function withTicketStore<T>(
|
|
|
664
711
|
)
|
|
665
712
|
}
|
|
666
713
|
|
|
667
|
-
/** The id ticket assets are keyed by
|
|
668
|
-
|
|
669
|
-
* the issue number. Other sources key by the id as given. */
|
|
670
|
-
export function assetTicketId(source: string, id: string): string {
|
|
671
|
-
if (source !== 'github') return id
|
|
672
|
-
const number = parseIssueId(id)
|
|
673
|
-
return number === null ? id : String(number)
|
|
674
|
-
}
|
|
714
|
+
/** The id ticket assets are keyed by; shared with the operator tools. */
|
|
715
|
+
export { assetTicketId }
|
|
675
716
|
|
|
676
717
|
function withTicketAssets<T>(
|
|
677
718
|
opts: TicketCommandOpts,
|
|
@@ -718,23 +759,6 @@ export async function unfinishedBuildTickets(
|
|
|
718
759
|
return refs
|
|
719
760
|
}
|
|
720
761
|
|
|
721
|
-
/** Slugs of this repo's non-terminal builds for the ticket. A build freezes its
|
|
722
|
-
* ticket assets at the claim (SPEC §6.3), so a change to them does not reach
|
|
723
|
-
* it. The notice is advisory: a failed lookup yields none and never blocks. */
|
|
724
|
-
async function activeBuildsFor(store: BuildStore, repo: string, id: string): Promise<string[]> {
|
|
725
|
-
try {
|
|
726
|
-
const active: string[] = []
|
|
727
|
-
for (const record of await store.listBuilds()) {
|
|
728
|
-
if (record.repo !== repo || record.ticket?.id !== id) continue
|
|
729
|
-
const { status } = (await readBuildFacts(store, record.slug)).value.state
|
|
730
|
-
if (status !== 'done' && status !== 'aborted') active.push(record.slug)
|
|
731
|
-
}
|
|
732
|
-
return active
|
|
733
|
-
} catch {
|
|
734
|
-
return []
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
|
|
738
762
|
function warnActiveBuilds(
|
|
739
763
|
opts: { stderr?: (line: string) => void; id: string },
|
|
740
764
|
slugs: string[],
|
|
@@ -763,7 +787,7 @@ export async function abTicketAttach(given: TicketAttachOpts): Promise<void> {
|
|
|
763
787
|
const live = await store.listTicketAssets(repo, opts.id)
|
|
764
788
|
const replacing = live.some((asset) => asset.kind === opts.kind && asset.name === name)
|
|
765
789
|
const meta = await store.putTicketAsset(repo, opts.id, input)
|
|
766
|
-
return { meta, replacing, active: await
|
|
790
|
+
return { meta, replacing, active: await activeTicketBuilds(buildStore, repo, opts.id) }
|
|
767
791
|
})
|
|
768
792
|
const { meta } = stored
|
|
769
793
|
warnActiveBuilds(opts, stored.active)
|
|
@@ -836,7 +860,7 @@ export async function abTicketAssetRm(given: TicketAssetRmOpts): Promise<void> {
|
|
|
836
860
|
source,
|
|
837
861
|
async ({ store, buildStore, repo }) => ({
|
|
838
862
|
removed: await store.removeTicketAsset(repo, opts.id, opts.kind, opts.name),
|
|
839
|
-
active: await
|
|
863
|
+
active: await activeTicketBuilds(buildStore, repo, opts.id),
|
|
840
864
|
}),
|
|
841
865
|
)
|
|
842
866
|
if (removed === null) {
|
|
@@ -1016,6 +1040,8 @@ const BLOCK_USAGE =
|
|
|
1016
1040
|
const UNBLOCK_USAGE =
|
|
1017
1041
|
'usage: ab ticket unblock <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json] (§8.8)'
|
|
1018
1042
|
const LIST_USAGE = 'usage: ab ticket list [--state <state>] [--labels a,b] [--json] (§8.8)'
|
|
1043
|
+
const SEARCH_USAGE =
|
|
1044
|
+
'usage: ab ticket search <query> [--state <state>] [--labels a,b] [--limit <n>] [--cursor <cursor>] [--json] (§8.8)'
|
|
1019
1045
|
const SHOW_USAGE = 'usage: ab ticket show <id> [--store <ref>] [--json] (§8.8)'
|
|
1020
1046
|
const ATTACH_USAGE =
|
|
1021
1047
|
'usage: ab ticket attach <id> <kind> <path> [--name <name>] [--store <ref>] [--json] (§8.8)'
|
|
@@ -1038,6 +1064,7 @@ export const TICKET_USAGE = [
|
|
|
1038
1064
|
BLOCK_USAGE,
|
|
1039
1065
|
UNBLOCK_USAGE,
|
|
1040
1066
|
LIST_USAGE,
|
|
1067
|
+
SEARCH_USAGE,
|
|
1041
1068
|
SHOW_USAGE,
|
|
1042
1069
|
MOVE_USAGE,
|
|
1043
1070
|
STATES_USAGE,
|
|
@@ -1290,6 +1317,41 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1290
1317
|
return
|
|
1291
1318
|
}
|
|
1292
1319
|
|
|
1320
|
+
case 'search': {
|
|
1321
|
+
const parsed = parseArgs(
|
|
1322
|
+
args,
|
|
1323
|
+
{ state: 'value', labels: 'value', limit: 'value', cursor: 'value', json: 'boolean' },
|
|
1324
|
+
SEARCH_USAGE,
|
|
1325
|
+
)
|
|
1326
|
+
const query = parsed.positionals.join(' ')
|
|
1327
|
+
if (query.trim() === '') throw new Error(SEARCH_USAGE)
|
|
1328
|
+
const state = stringFlag(parsed, 'state')
|
|
1329
|
+
if (state !== undefined && state.trim() === '') throw new Error(SEARCH_USAGE)
|
|
1330
|
+
const cursor = stringFlag(parsed, 'cursor')
|
|
1331
|
+
if (cursor !== undefined && cursor.trim() === '') throw new Error(SEARCH_USAGE)
|
|
1332
|
+
const labels = stringFlag(parsed, 'labels')
|
|
1333
|
+
const limitText = stringFlag(parsed, 'limit')
|
|
1334
|
+
let limit: number | undefined
|
|
1335
|
+
if (limitText !== undefined) {
|
|
1336
|
+
limit = /^\d+$/.test(limitText) ? Number(limitText) : Number.NaN
|
|
1337
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > TICKET_SEARCH_MAX_LIMIT) {
|
|
1338
|
+
throw new Error(
|
|
1339
|
+
`--limit must be an integer from 1 to ${TICKET_SEARCH_MAX_LIMIT}, got "${limitText}"\n${SEARCH_USAGE}`,
|
|
1340
|
+
)
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
await abTicketSearch({
|
|
1344
|
+
...opts,
|
|
1345
|
+
query,
|
|
1346
|
+
...(state !== undefined ? { state } : {}),
|
|
1347
|
+
...(labels !== undefined ? { labels: commaList(labels) } : {}),
|
|
1348
|
+
...(limit !== undefined ? { limit } : {}),
|
|
1349
|
+
...(cursor !== undefined ? { cursor } : {}),
|
|
1350
|
+
json: parsed.flags.has('json'),
|
|
1351
|
+
})
|
|
1352
|
+
return
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1293
1355
|
case 'tree': {
|
|
1294
1356
|
const parsed = parseArgs(args, { json: 'boolean' }, TICKET_USAGE)
|
|
1295
1357
|
if (parsed.positionals.length) throw new Error(TICKET_USAGE)
|