@defrex/autobuild 1.4.1 → 1.5.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 +440 -95
- package/bin/ab-dispatch-kernel.ts +1 -0
- package/docs/accounts.md +9 -0
- package/docs/agent-runtimes.md +1 -0
- package/docs/answering-blocked-builds.md +2 -1
- package/docs/architecture.md +290 -130
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +33 -3
- package/docs/cli.md +2 -1
- package/docs/configuration-overview.md +9 -0
- package/docs/configuration.md +166 -101
- package/docs/dispatcher-hosting.md +19 -3
- package/docs/dispatcher.md +9 -4
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +91 -28
- package/docs/merge-policy.md +28 -9
- package/docs/operator-api.md +43 -18
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +85 -8
- package/docs/remote-store-protocol.md +25 -7
- package/docs/remote-ticket-protocol.md +126 -12
- package/docs/restacking.md +20 -6
- package/docs/seams.md +2 -2
- package/docs/setup.md +19 -13
- package/docs/spec-standard.md +2 -1
- package/docs/ticket-dependencies.md +26 -8
- package/docs/ticket-migration.md +70 -7
- package/docs/ticket-sources.md +82 -5
- package/docs/tickets.md +34 -2
- package/docs/troubleshooting.md +2 -2
- package/docs/verification.md +5 -5
- package/docs/website.md +8 -0
- package/docs/workspaces.md +1 -1
- package/package.json +5 -4
- package/packages/core/src/accounts/hosted-readiness.ts +21 -0
- package/packages/core/src/cli/attention.ts +1 -0
- package/packages/core/src/cli/build-control.ts +36 -12
- package/packages/core/src/cli/connect.ts +9 -18
- package/packages/core/src/cli/context.ts +44 -0
- package/packages/core/src/cli/dashboard/configuration.ts +11 -0
- package/packages/core/src/cli/dashboard/model.ts +40 -10
- package/packages/core/src/cli/dashboard/queue.ts +21 -0
- package/packages/core/src/cli/dashboard/render.ts +40 -22
- package/packages/core/src/cli/dispatch-frontend.ts +63 -30
- package/packages/core/src/cli/dispatch-mode.ts +35 -16
- package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
- package/packages/core/src/cli/dispatch.ts +154 -47
- package/packages/core/src/cli/help.ts +59 -22
- package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
- package/packages/core/src/cli/init-readiness-remote.ts +16 -3
- package/packages/core/src/cli/init-validation.ts +144 -42
- package/packages/core/src/cli/issue-links.ts +67 -0
- package/packages/core/src/cli/main.ts +32 -15
- package/packages/core/src/cli/pr-summary-publication.ts +38 -7
- package/packages/core/src/cli/publication-settlement.ts +36 -24
- package/packages/core/src/cli/repository-status.ts +201 -49
- package/packages/core/src/cli/status.ts +41 -3
- package/packages/core/src/cli/terminals.ts +37 -2
- package/packages/core/src/cli/ticket-editor.ts +20 -6
- package/packages/core/src/cli/ticket.ts +264 -46
- package/packages/core/src/cli/triage-count-sampler.ts +59 -0
- package/packages/core/src/cli/watch.ts +4 -0
- package/packages/core/src/config/live.ts +45 -4
- package/packages/core/src/config/load.ts +9 -0
- package/packages/core/src/config/pipeline-source.ts +6 -2
- package/packages/core/src/config/ready-assignee.ts +86 -0
- package/packages/core/src/config/schema.ts +164 -36
- package/packages/core/src/distribution-packaging.ts +1 -1
- package/packages/core/src/events/catalog.ts +5 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/payloads.ts +70 -0
- package/packages/core/src/events/policy.ts +8 -0
- package/packages/core/src/events/repository.ts +91 -28
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +41 -0
- package/packages/core/src/kernel/build-identity.ts +12 -0
- package/packages/core/src/kernel/change-presence.ts +139 -6
- package/packages/core/src/kernel/dispatch-capacity.ts +80 -14
- package/packages/core/src/kernel/dispatch-status.ts +10 -1
- package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
- package/packages/core/src/kernel/engine.ts +4 -2
- package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
- package/packages/core/src/kernel/harvest.ts +4 -1
- package/packages/core/src/kernel/integration-completeness.ts +104 -17
- package/packages/core/src/kernel/integration-landing.ts +17 -0
- package/packages/core/src/kernel/integration-state.ts +17 -0
- package/packages/core/src/kernel/issue-keywords.ts +202 -0
- package/packages/core/src/kernel/janitor-failure.ts +11 -0
- package/packages/core/src/kernel/kernel-git.ts +87 -0
- package/packages/core/src/kernel/landing-readiness.ts +25 -17
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-issue-links.ts +142 -0
- package/packages/core/src/kernel/node-parent.ts +6 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
- package/packages/core/src/kernel/pr-summary.ts +24 -0
- package/packages/core/src/kernel/read-deferrals.ts +75 -12
- package/packages/core/src/kernel/read-facts.ts +32 -1
- package/packages/core/src/kernel/reconcile-restack.ts +1 -1
- package/packages/core/src/kernel/reducer-registry.ts +31 -1
- package/packages/core/src/kernel/reducer.ts +90 -2
- package/packages/core/src/kernel/ticket-preparation.ts +12 -0
- package/packages/core/src/kernel/verify-budget.ts +43 -0
- package/packages/core/src/operator/index.ts +3 -1
- package/packages/core/src/operator/presentation.ts +3 -0
- package/packages/core/src/operator/protocol.ts +38 -2
- package/packages/core/src/operator/query.ts +66 -29
- package/packages/core/src/operator/registry.ts +47 -26
- package/packages/core/src/operator/tickets.ts +77 -10
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/plugins/registry.ts +1 -0
- package/packages/core/src/ports/forge/contract.ts +69 -0
- package/packages/core/src/ports/forge/create.ts +5 -0
- package/packages/core/src/ports/forge/fake.ts +184 -3
- package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
- package/packages/core/src/ports/forge/github.ts +175 -38
- package/packages/core/src/ports/forge/local-git.ts +14 -0
- package/packages/core/src/ports/forge/readiness.ts +10 -0
- package/packages/core/src/ports/forge-failure.ts +43 -0
- package/packages/core/src/ports/runner/claude.ts +7 -1
- package/packages/core/src/ports/runner/codex.ts +7 -2
- package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
- package/packages/core/src/ports/runner/pi.ts +7 -1
- package/packages/core/src/ports/runner/runtime.ts +3 -0
- package/packages/core/src/ports/runner/start-prompt.ts +37 -0
- package/packages/core/src/ports/tickets/contract.ts +320 -7
- package/packages/core/src/ports/tickets/create.ts +72 -17
- package/packages/core/src/ports/tickets/fake.ts +18 -0
- package/packages/core/src/ports/tickets/file-codec.ts +20 -0
- package/packages/core/src/ports/tickets/file.ts +43 -1
- package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
- package/packages/core/src/ports/tickets/github-issues.ts +431 -0
- package/packages/core/src/ports/tickets/github-validators.ts +194 -0
- package/packages/core/src/ports/tickets/github.ts +2029 -0
- package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
- package/packages/core/src/ports/tickets/issue-links.ts +86 -0
- package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
- package/packages/core/src/ports/tickets/linear.ts +66 -6
- package/packages/core/src/ports/tickets/migration.ts +290 -68
- package/packages/core/src/ports/tickets/operations.ts +98 -12
- package/packages/core/src/ports/tickets/priority.ts +55 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
- package/packages/core/src/ports/tickets/remote.ts +188 -13
- package/packages/core/src/ports/tickets/revision.ts +22 -1
- package/packages/core/src/ports/tickets/states.ts +43 -0
- package/packages/core/src/ports/tickets/tree.ts +58 -12
- package/packages/core/src/ports/tickets/update.ts +12 -2
- package/packages/core/src/ports/types.ts +194 -11
- package/packages/core/src/ports/workspace/commit-preservation.ts +135 -13
- package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +132 -27
- package/packages/core/src/processes/build-runner.ts +99 -21
- package/packages/core/src/processes/dispatcher.ts +1080 -533
- package/packages/core/src/processes/execution-no-progress.ts +5 -0
- package/packages/core/src/processes/harvest-runner.ts +17 -8
- package/packages/core/src/processes/harvest.ts +5 -8
- package/packages/core/src/processes/tick-publication.ts +12 -2
- package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
- package/packages/core/src/processes/workspace-preservation.ts +37 -2
- package/packages/core/src/runtime-identity.ts +10 -2
- package/packages/core/src/scenarios/harness.ts +4 -0
- package/packages/core/src/store/adapter.ts +7 -1
- package/packages/core/src/store/contract.ts +83 -2
- package/packages/core/src/store/digest.ts +32 -1
- package/packages/core/src/store/reducer-value-shapes.json +4187 -3391
- package/packages/core/src/store/remote/protocol.ts +2 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +5 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
- package/packages/core/src/testing/index.ts +18 -1
- package/packages/core/src/testing/presence-history.ts +79 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1197 -31
- package/packages/core/src/testing/upgrade-generations.ts +77 -0
- package/skills/code-review/SKILL.md +4 -3
- package/skills/finalize/SKILL.md +18 -2
- package/skills/guide/SKILL.md +382 -139
- package/skills/guide/references/accounts.md +9 -0
- package/skills/guide/references/integration-tree.md +91 -28
- package/skills/guide/references/merge-policy.md +28 -9
- package/skills/guide/references/operator-api.md +43 -18
- package/skills/guide/references/plugin-authoring.md +85 -8
- package/skills/guide/references/remote-store-protocol.md +25 -7
- package/skills/guide/references/remote-ticket-protocol.md +126 -12
- package/skills/guide/references/restacking.md +20 -6
- package/skills/guide/references/setup.md +19 -13
- package/skills/guide/references/spec-standard.md +2 -1
- package/skills/guide/references/ticket-dependencies.md +26 -8
- package/skills/guide/references/ticket-migration.md +70 -7
- package/skills/harvest-review/SKILL.md +4 -3
- package/skills/implement/SKILL.md +20 -1
- package/skills/operate/SKILL.md +103 -28
- package/skills/plan/SKILL.md +1 -1
- package/skills/reconcile/SKILL.md +5 -4
- package/skills/spec/SKILL.md +15 -2
- package/skills/tickets/SKILL.md +114 -37
- package/templates/autobuild.toml +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure readiness checks for hosted Claude and Kimi accounts whose credential
|
|
3
|
+
* is a static project secret (`ab secrets set NAME`). Only write-only
|
|
4
|
+
* metadata is read; a project secret's value is never downloaded or printed.
|
|
5
|
+
*/
|
|
6
|
+
import type { Account } from '../config/accounts'
|
|
7
|
+
import type { ProjectSecretMetadata } from '../project-secrets'
|
|
8
|
+
import type { ReadinessCheck } from '../ports/workspace/provider-capabilities'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A Claude or Kimi account is checked by metadata only on a connected project
|
|
12
|
+
* validated by a provider with remote readiness (the Vercel egress transform
|
|
13
|
+
* is what supplies project secrets), and only when no local variable is set.
|
|
14
|
+
*/
|
|
15
|
+
export function staticSecretEligible(
|
|
16
|
+
descriptor: Account,
|
|
17
|
+
env: Readonly<Record<string, string | undefined>>,
|
|
18
|
+
opts: { connected: boolean; remoteReadiness: boolean },
|
|
19
|
+
): boolean {
|
|
20
|
+
return (
|
|
21
|
+
(descriptor.kind === 'claude-subscription' || descriptor.kind === 'kimi-code') &&
|
|
22
|
+
opts.connected &&
|
|
23
|
+
opts.remoteReadiness &&
|
|
24
|
+
!env[descriptor.credentialEnv]
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function staticSecretRemedy(descriptor: Account): string {
|
|
29
|
+
const local =
|
|
30
|
+
descriptor.kind === 'kimi-code'
|
|
31
|
+
? 'provide the Kimi Code membership key in the local variable'
|
|
32
|
+
: 'run claude setup-token and provide the local variable'
|
|
33
|
+
return `set the project secret with bun ab secrets set ${descriptor.credentialEnv}, or ${local}`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function staticSecretReadiness(
|
|
37
|
+
name: string,
|
|
38
|
+
descriptor: Account,
|
|
39
|
+
metadata: readonly ProjectSecretMetadata[] | undefined,
|
|
40
|
+
): ReadinessCheck & { ready: boolean } {
|
|
41
|
+
const entry = metadata?.find((s) => s.name === descriptor.credentialEnv && s.kind === 'static')
|
|
42
|
+
const ready = entry?.status === 'ready' && entry.failureCode === null
|
|
43
|
+
const facts = entry ? `owner ${entry.owner}; set ${entry.setAt}` : ''
|
|
44
|
+
return {
|
|
45
|
+
name: `account ${JSON.stringify(name)}`,
|
|
46
|
+
status: ready ? 'pass' : 'fail',
|
|
47
|
+
ready,
|
|
48
|
+
detail: ready
|
|
49
|
+
? `Hosted credential ready; ${facts}. Hosted Claude and Kimi accounts are checked by metadata; the first hosted build is the live check.`
|
|
50
|
+
: entry
|
|
51
|
+
? `Hosted credential ${entry.status}${entry.failureCode === null ? '' : ` (${entry.failureCode})`}; ${facts}; ${staticSecretRemedy(descriptor)}`
|
|
52
|
+
: `${descriptor.credentialEnv} is missing; ${staticSecretRemedy(descriptor)}`,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -12,17 +12,30 @@ import type {
|
|
|
12
12
|
} from '../ports/workspace/provider-capabilities'
|
|
13
13
|
import { validateVercelSandbox, type VercelSandboxFacade } from '../ports/workspace/vercel-sandbox'
|
|
14
14
|
import { gitText, parseGuestOutput } from './init-readiness-shared'
|
|
15
|
+
import { hostedReadinessNames } from '../accounts/hosted-readiness'
|
|
16
|
+
import { staticSecretRemedy } from './init-hosted-accounts'
|
|
17
|
+
import { isRemoteStoreRef } from './repo-state'
|
|
15
18
|
|
|
16
19
|
export async function validateRemoteReadiness(
|
|
17
20
|
ctx: WorkspaceReadinessContext,
|
|
18
21
|
): Promise<InitValidationReport> {
|
|
19
22
|
const vercel = ctx.providerConfig as VercelSandboxConfig
|
|
23
|
+
const hosted = hostedReadinessNames(ctx.env)
|
|
24
|
+
const connected = isRemoteStoreRef(ctx.storeRef)
|
|
20
25
|
const hostChecks = Object.entries(ctx.accounts ?? {}).map(([name, descriptor]) => ({
|
|
21
26
|
name: `host account ${JSON.stringify(name)}`,
|
|
22
27
|
status: ctx.env[descriptor.credentialEnv] ? ('pass' as const) : ('fail' as const),
|
|
23
|
-
detail:
|
|
24
|
-
? `${descriptor.credentialEnv} is
|
|
25
|
-
:
|
|
28
|
+
detail: hosted.includes(name)
|
|
29
|
+
? `${descriptor.credentialEnv} is a ready hosted project secret (metadata only)`
|
|
30
|
+
: ctx.env[descriptor.credentialEnv]
|
|
31
|
+
? `${descriptor.credentialEnv} is present`
|
|
32
|
+
: `${descriptor.credentialEnv} is missing; ${
|
|
33
|
+
connected && descriptor.kind !== 'chatgpt-subscription'
|
|
34
|
+
? staticSecretRemedy(descriptor)
|
|
35
|
+
: descriptor.kind === 'claude-subscription'
|
|
36
|
+
? 'run claude setup-token and set the dispatcher variable'
|
|
37
|
+
: 'provision the Kimi membership key'
|
|
38
|
+
}`,
|
|
26
39
|
}))
|
|
27
40
|
if (hostChecks.some((check) => check.status === 'fail'))
|
|
28
41
|
return {
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { LocalCredentials } from '../accounts/local-credentials'
|
|
2
2
|
import { LocalAccountOwner } from '../accounts/local-owner'
|
|
3
3
|
import { abSecrets } from './secrets'
|
|
4
|
+
import {
|
|
5
|
+
HOSTED_ACCOUNT_READINESS_ENV,
|
|
6
|
+
HOSTED_METADATA_PLACEHOLDER,
|
|
7
|
+
hostedReadinessNames,
|
|
8
|
+
withHostedReadiness,
|
|
9
|
+
} from '../accounts/hosted-readiness'
|
|
10
|
+
import { staticSecretEligible, staticSecretReadiness } from './init-hosted-accounts'
|
|
4
11
|
import type { ProjectSecretMetadata } from '../project-secrets'
|
|
5
12
|
import { accountRemedy } from '../config/accounts'
|
|
6
13
|
import { createForge } from '../ports/forge/create'
|
|
@@ -16,7 +23,7 @@ import { mkdtemp, readFile, rm } from 'node:fs/promises'
|
|
|
16
23
|
import { tmpdir } from 'node:os'
|
|
17
24
|
import { join, resolve } from 'node:path'
|
|
18
25
|
import { effectiveRuntimeReferences } from '../config/roles'
|
|
19
|
-
import type { Config } from '../config/schema'
|
|
26
|
+
import type { Config, TicketsConfig } from '../config/schema'
|
|
20
27
|
import { loadConfig } from '../config/load'
|
|
21
28
|
import { createProductionRuntimes } from '../ports/runner/production'
|
|
22
29
|
import { createRuntimeResolver } from '../ports/runner/routing'
|
|
@@ -37,6 +44,11 @@ import { diagnosePlugins, loadPlugins } from '../plugins/load'
|
|
|
37
44
|
import { materializePluginRuntimes } from '../plugins/runtimes'
|
|
38
45
|
import { createTicketSource } from '../ports/tickets/create'
|
|
39
46
|
import { LinearTicketSource } from '../ports/tickets/linear'
|
|
47
|
+
import { GitHubTicketSource } from '../ports/tickets/github'
|
|
48
|
+
import { representableState } from '../ports/tickets/github-issues'
|
|
49
|
+
import { STATE_NAME_RULE } from '../ports/tickets/states'
|
|
50
|
+
import { holdsState } from '../ports/tickets/lifecycle'
|
|
51
|
+
import type { TicketSource } from '../ports/types'
|
|
40
52
|
import { inspectLocalStoreSnapshot } from '../store/local/store'
|
|
41
53
|
import type { StoreOpener } from './store-opening'
|
|
42
54
|
import { openProductionStore } from './store-opening'
|
|
@@ -55,6 +67,74 @@ export type {
|
|
|
55
67
|
ReadinessCheck,
|
|
56
68
|
} from '../ports/workspace/provider-capabilities'
|
|
57
69
|
|
|
70
|
+
const OPTIONAL_ROLES = [
|
|
71
|
+
{ role: 'backlog', key: 'backlogState', recommended: 'backlog' },
|
|
72
|
+
{ role: 'rejected', key: 'rejectedState', recommended: 'rejected' },
|
|
73
|
+
] as const
|
|
74
|
+
|
|
75
|
+
/** GitHub holds every open state as an `autobuild:<state>` label, so each
|
|
76
|
+
* configured state other than done and rejected (closing reasons) must follow
|
|
77
|
+
* the label rule. Throws naming the first offending key. */
|
|
78
|
+
export function assertGitHubStateLabels(tickets: TicketsConfig): void {
|
|
79
|
+
const keys = [
|
|
80
|
+
'readyState',
|
|
81
|
+
'claimedState',
|
|
82
|
+
'createState',
|
|
83
|
+
'triageState',
|
|
84
|
+
'proposalState',
|
|
85
|
+
'backlogState',
|
|
86
|
+
] as const
|
|
87
|
+
for (const key of keys) {
|
|
88
|
+
const name = tickets[key]
|
|
89
|
+
if (name !== undefined && !representableState(name))
|
|
90
|
+
throw new Error(
|
|
91
|
+
`[tickets].${key} "${name}" cannot be a GitHub state label (autobuild:<state>) — ${STATE_NAME_RULE}`,
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Advisory findings for the optional backlog and rejected roles. An unset role
|
|
98
|
+
* is an informational note, never a failure. A configured role naming no state
|
|
99
|
+
* is a warning, unless the source creates states on first use. Costs one state
|
|
100
|
+
* listing, and only when a role is configured.
|
|
101
|
+
*/
|
|
102
|
+
export async function ticketRoleReadiness(
|
|
103
|
+
tickets: TicketsConfig,
|
|
104
|
+
source: () => Promise<TicketSource>,
|
|
105
|
+
): Promise<{ notes: string[]; checks: ReadinessCheck[] }> {
|
|
106
|
+
const notes: string[] = []
|
|
107
|
+
const checks: ReadinessCheck[] = []
|
|
108
|
+
const configured = OPTIONAL_ROLES.filter(({ key }) => tickets[key] !== undefined)
|
|
109
|
+
for (const { role, key, recommended } of OPTIONAL_ROLES)
|
|
110
|
+
if (tickets[key] === undefined)
|
|
111
|
+
notes.push(
|
|
112
|
+
`Note: [tickets].${key} is not set; the ${role} role is unavailable (recommended: ${key} = "${recommended}")`,
|
|
113
|
+
)
|
|
114
|
+
if (configured.length === 0) return { notes, checks }
|
|
115
|
+
const ticketSource = await source()
|
|
116
|
+
const names =
|
|
117
|
+
ticketSource instanceof LinearTicketSource
|
|
118
|
+
? await ticketSource.workflowStateNames()
|
|
119
|
+
: ticketSource.listStates
|
|
120
|
+
? (await ticketSource.listStates()).map((info) => info.name)
|
|
121
|
+
: undefined
|
|
122
|
+
if (names === undefined) return { notes, checks }
|
|
123
|
+
for (const { role, key } of configured) {
|
|
124
|
+
const name = tickets[key]!
|
|
125
|
+
if (names.some((state) => holdsState(state, name))) continue
|
|
126
|
+
if (ticketSource.addState)
|
|
127
|
+
notes.push(`Note: ${role} role state "${name}" is created on first use`)
|
|
128
|
+
else
|
|
129
|
+
checks.push({
|
|
130
|
+
name: `ticket-role-${role}`,
|
|
131
|
+
status: 'warning',
|
|
132
|
+
detail: `[tickets].${key} "${name}" names no state in the ${ticketSource.name} source (known: ${names.join(', ') || 'none'})`,
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
return { notes, checks }
|
|
136
|
+
}
|
|
137
|
+
|
|
58
138
|
async function shell(
|
|
59
139
|
exec: Exec,
|
|
60
140
|
cwd: string,
|
|
@@ -229,17 +309,17 @@ export async function runGuestReadinessProbe(opts: {
|
|
|
229
309
|
|
|
230
310
|
try {
|
|
231
311
|
for (const [name, descriptor] of Object.entries(config.accounts)) {
|
|
312
|
+
const hosted = hostedReadinessNames(opts.env).includes(name)
|
|
232
313
|
checks.push({
|
|
233
314
|
name: `credential ${JSON.stringify(name)}`,
|
|
234
315
|
status: opts.env[descriptor.credentialEnv] ? 'pass' : 'warning',
|
|
235
|
-
detail:
|
|
316
|
+
detail: hosted
|
|
317
|
+
? `${descriptor.credentialEnv} is a hosted project secret (metadata only)`
|
|
318
|
+
: `${descriptor.credentialEnv} is ${opts.env[descriptor.credentialEnv] ? 'present' : 'absent'}${!opts.env[descriptor.credentialEnv] && descriptor.kind === 'claude-subscription' ? '; run claude setup-token for remote use' : ''}`,
|
|
236
319
|
})
|
|
237
320
|
const account = { name, descriptor }
|
|
238
321
|
const runtime = descriptor.kind === 'chatgpt-subscription' ? 'codex' : 'claude'
|
|
239
|
-
if (
|
|
240
|
-
descriptor.kind === 'chatgpt-subscription' &&
|
|
241
|
-
(JSON.parse(opts.env.AB_CHATGPT_HOSTED_READINESS ?? '[]') as string[]).includes(name)
|
|
242
|
-
) {
|
|
322
|
+
if (hosted) {
|
|
243
323
|
checks.push({
|
|
244
324
|
name: `account ${JSON.stringify(name)}`,
|
|
245
325
|
status: 'pass',
|
|
@@ -497,6 +577,7 @@ async function validateInitReadinessInner(opts: {
|
|
|
497
577
|
])
|
|
498
578
|
let caps: WorkspaceProviderCapabilities | undefined
|
|
499
579
|
let assigneeLine: string | undefined
|
|
580
|
+
let roles: Awaited<ReturnType<typeof ticketRoleReadiness>> = { notes: [], checks: [] }
|
|
500
581
|
let forgeChecks: ForgeReadinessCheck[] = readinessChecks(
|
|
501
582
|
'unknown',
|
|
502
583
|
'Host forge construction unavailable; check adapter configuration and access.',
|
|
@@ -560,14 +641,24 @@ async function validateInitReadinessInner(opts: {
|
|
|
560
641
|
}
|
|
561
642
|
}
|
|
562
643
|
}
|
|
563
|
-
|
|
564
|
-
|
|
644
|
+
let ticketSource: TicketSource | undefined
|
|
645
|
+
const openTicketSource = async () =>
|
|
646
|
+
(ticketSource ??= await createTicketSource(
|
|
565
647
|
config.tickets,
|
|
566
648
|
{ ...opts.env, AB_STORE: state.storeRef },
|
|
567
649
|
repo,
|
|
568
650
|
state.localStateRoot,
|
|
569
651
|
hostPlugins,
|
|
570
|
-
)
|
|
652
|
+
))
|
|
653
|
+
if (config.tickets.source === 'github') assertGitHubStateLabels(config.tickets)
|
|
654
|
+
if (config.tickets.source !== 'file') {
|
|
655
|
+
const ticketSource = await openTicketSource()
|
|
656
|
+
if (ticketSource instanceof GitHubTicketSource) await ticketSource.validateAccess()
|
|
657
|
+
// Who the assignee gate names, before the read it narrows, so an
|
|
658
|
+
// unresolvable value fails with the source's own remediation.
|
|
659
|
+
const assignee = config.tickets.readyAssignee
|
|
660
|
+
if (assignee !== undefined && ticketSource.describeReadyAssignee !== undefined)
|
|
661
|
+
assigneeLine = `Ticket assignee gate: ${await ticketSource.describeReadyAssignee(assignee)}`
|
|
571
662
|
await ticketSource.listReady({
|
|
572
663
|
...(config.tickets.readyLabels !== undefined ? { labels: config.tickets.readyLabels } : {}),
|
|
573
664
|
state: config.tickets.readyState,
|
|
@@ -575,19 +666,8 @@ async function validateInitReadinessInner(opts: {
|
|
|
575
666
|
? { assignee: config.tickets.readyAssignee }
|
|
576
667
|
: {}),
|
|
577
668
|
})
|
|
578
|
-
const assignee = config.tickets.readyAssignee
|
|
579
|
-
if (assignee !== undefined && ticketSource instanceof LinearTicketSource) {
|
|
580
|
-
const user = await ticketSource.resolveAssignee(assignee)
|
|
581
|
-
if (user === null) {
|
|
582
|
-
throw new Error(
|
|
583
|
-
assignee === 'me'
|
|
584
|
-
? '[tickets].readyAssignee = "me" but LINEAR_API_KEY did not resolve to a Linear user — check the key'
|
|
585
|
-
: `[tickets].readyAssignee "${assignee}" matches no user in the Linear workspace — check the address or use "me"`,
|
|
586
|
-
)
|
|
587
|
-
}
|
|
588
|
-
assigneeLine = `Ticket assignee gate: ${assignee} → ${user.name} <${user.email}>`
|
|
589
|
-
}
|
|
590
669
|
}
|
|
670
|
+
roles = await ticketRoleReadiness(config.tickets, openTicketSource)
|
|
591
671
|
} catch (error) {
|
|
592
672
|
throw new Error(redact(error))
|
|
593
673
|
}
|
|
@@ -709,6 +789,7 @@ async function validateInitReadinessInner(opts: {
|
|
|
709
789
|
}
|
|
710
790
|
|
|
711
791
|
if (report === undefined) throw new Error('readiness validation produced no report')
|
|
792
|
+
report.checks.push(...roles.checks)
|
|
712
793
|
report.checks.push(
|
|
713
794
|
...forgeChecks.map(
|
|
714
795
|
(check): ReadinessCheck => ({
|
|
@@ -728,6 +809,7 @@ async function validateInitReadinessInner(opts: {
|
|
|
728
809
|
stdout(`Store: ${state.storeRef}`)
|
|
729
810
|
stdout(`Forge: ${config.forge}`)
|
|
730
811
|
if (assigneeLine !== undefined) stdout(assigneeLine)
|
|
812
|
+
for (const note of roles.notes) stdout(note)
|
|
731
813
|
// Same raw `[workspace.config]` fallback guestEnvNames gets (f_55ba7591): a
|
|
732
814
|
// provider that declares describeEnvironment without a configSchema still
|
|
733
815
|
// receives a defined argument — the raw table — never undefined.
|
|
@@ -754,35 +836,58 @@ async function validateInitReadinessInner(opts: {
|
|
|
754
836
|
}
|
|
755
837
|
}
|
|
756
838
|
|
|
757
|
-
/**
|
|
839
|
+
/**
|
|
840
|
+
* Validation consumes the current owner's access value, never its refresh
|
|
841
|
+
* token. On a connected project, ChatGPT accounts without a local login and
|
|
842
|
+
* Claude or Kimi accounts eligible for a static project secret are reported
|
|
843
|
+
* from one write-only metadata listing; their values are never downloaded, a
|
|
844
|
+
* placeholder satisfies downstream presence checks, and the guest skips their
|
|
845
|
+
* live model probe.
|
|
846
|
+
*/
|
|
758
847
|
export async function validateInitReadiness(
|
|
759
|
-
opts: Parameters<typeof validateInitReadinessInner>[0]
|
|
848
|
+
opts: Parameters<typeof validateInitReadinessInner>[0] & {
|
|
849
|
+
fetch?: (input: string, init?: RequestInit) => Promise<Response>
|
|
850
|
+
},
|
|
760
851
|
): Promise<InitValidationReport> {
|
|
852
|
+
const { fetch: fetchImpl, ...innerOpts } = opts
|
|
761
853
|
const exec = opts.exec ?? spawnExec
|
|
762
854
|
const repo = await resolveMainRepo(opts.targetRepo, exec)
|
|
763
855
|
const config = await loadConfig(join(repo, 'autobuild.toml'))
|
|
856
|
+
const service = opts.env.AB_STORE?.trim() || config.store?.url
|
|
857
|
+
const connected = Boolean(service && isRemoteStoreRef(service))
|
|
858
|
+
const remoteReadiness =
|
|
859
|
+
builtinWorkspaceProviderCapabilities(config.workspace.provider)?.validateReadiness !== undefined
|
|
764
860
|
const accounts = Object.entries(config.accounts).filter(
|
|
765
861
|
([, a]) => a.kind === 'chatgpt-subscription',
|
|
766
862
|
)
|
|
767
|
-
|
|
863
|
+
const staticAccounts = Object.entries(config.accounts).filter(([, a]) =>
|
|
864
|
+
staticSecretEligible(a, opts.env, { connected, remoteReadiness }),
|
|
865
|
+
)
|
|
866
|
+
if (!accounts.length && !staticAccounts.length)
|
|
867
|
+
return validateInitReadinessInner({ ...innerOpts, resolvedRepo: repo })
|
|
768
868
|
const credentials = new LocalCredentials(join(repo, '.autobuild'))
|
|
769
869
|
const owner = new LocalAccountOwner(credentials)
|
|
770
870
|
const claimed: string[] = []
|
|
771
871
|
const env = { ...opts.env }
|
|
772
872
|
const checks: InitValidationReport['checks'] = []
|
|
873
|
+
const failed = (): InitValidationReport => ({
|
|
874
|
+
provider: config.workspace.provider,
|
|
875
|
+
context: config.workspace.provider === 'git-worktree' ? 'local worktree' : 'Vercel Sandbox',
|
|
876
|
+
checks,
|
|
877
|
+
exitCode: 1,
|
|
878
|
+
})
|
|
773
879
|
try {
|
|
774
|
-
const service = opts.env.AB_STORE?.trim() || config.store?.url
|
|
775
880
|
let metadata: ProjectSecretMetadata[] | undefined
|
|
776
881
|
if (
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
accounts.some(([name]) => !credentials.load(name))
|
|
882
|
+
connected &&
|
|
883
|
+
(staticAccounts.length > 0 || accounts.some(([name]) => !credentials.load(name)))
|
|
780
884
|
) {
|
|
781
885
|
await abSecrets('list', undefined, {
|
|
782
886
|
cwd: repo,
|
|
783
887
|
env: opts.env,
|
|
784
888
|
exec,
|
|
785
889
|
json: true,
|
|
890
|
+
...(fetchImpl === undefined ? {} : { fetch: fetchImpl }),
|
|
786
891
|
print: (text) => {
|
|
787
892
|
metadata = JSON.parse(text).secrets
|
|
788
893
|
},
|
|
@@ -812,22 +917,19 @@ export async function validateInitReadiness(
|
|
|
812
917
|
? `Hosted credential ${entry.status}; owner ${entry.owner}; set ${entry.setAt}; ${entry.warnings?.join(', ') || 'no refresh-window warning'}. The first hosted build is the live check.`
|
|
813
918
|
: `Credential absent; run ab accounts login ${JSON.stringify(name)} ${service && isRemoteStoreRef(service) ? '--project' : '--local'}`,
|
|
814
919
|
})
|
|
815
|
-
if (!ready)
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
context:
|
|
819
|
-
config.workspace.provider === 'git-worktree' ? 'local worktree' : 'Vercel Sandbox',
|
|
820
|
-
checks,
|
|
821
|
-
exitCode: 1,
|
|
822
|
-
}
|
|
823
|
-
env.AB_CHATGPT_HOSTED_READINESS = JSON.stringify([
|
|
824
|
-
...(JSON.parse(env.AB_CHATGPT_HOSTED_READINESS ?? '[]') as string[]),
|
|
825
|
-
name,
|
|
826
|
-
])
|
|
827
|
-
env[descriptor.credentialEnv] = 'autobuild-hosted-metadata-only'
|
|
920
|
+
if (!ready) return failed()
|
|
921
|
+
env[HOSTED_ACCOUNT_READINESS_ENV] = withHostedReadiness(env, name)
|
|
922
|
+
env[descriptor.credentialEnv] = HOSTED_METADATA_PLACEHOLDER
|
|
828
923
|
}
|
|
829
924
|
}
|
|
830
|
-
|
|
925
|
+
for (const [name, descriptor] of staticAccounts) {
|
|
926
|
+
const { ready, ...check } = staticSecretReadiness(name, descriptor, metadata)
|
|
927
|
+
checks.push(check)
|
|
928
|
+
if (!ready) return failed()
|
|
929
|
+
env[HOSTED_ACCOUNT_READINESS_ENV] = withHostedReadiness(env, name)
|
|
930
|
+
env[descriptor.credentialEnv] = HOSTED_METADATA_PLACEHOLDER
|
|
931
|
+
}
|
|
932
|
+
const report = await validateInitReadinessInner({ ...innerOpts, env, resolvedRepo: repo })
|
|
831
933
|
return { ...report, checks: [...checks, ...report.checks] }
|
|
832
934
|
} finally {
|
|
833
935
|
for (const name of claimed) owner.release(name)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ab issue downgrade <N> --reason <text>` (SPEC "Forge issue links"): an
|
|
3
|
+
* agent found the build only partly resolves a linked `closes` issue. The
|
|
4
|
+
* downgrade is one-way and must land before the kernel seals the links for
|
|
5
|
+
* the PR; a downgrade the reducer would treat as inert is refused, or, when
|
|
6
|
+
* a seal overtakes it, reported as a failure rather than a success.
|
|
7
|
+
*
|
|
8
|
+
* NOT a terminal: usable in any phase until the seal.
|
|
9
|
+
*/
|
|
10
|
+
import type { EventEnvelope } from '../events/catalog'
|
|
11
|
+
import { agentActor } from '../events/envelope'
|
|
12
|
+
import { formatIssueLinks } from '../ports/tickets/issue-links'
|
|
13
|
+
import { readBuildFacts } from '../store/reduced-reads'
|
|
14
|
+
import type { BuildStore } from '../store/types'
|
|
15
|
+
import type { CliEnv } from './env'
|
|
16
|
+
|
|
17
|
+
export interface IssueDowngradeDeps {
|
|
18
|
+
store: BuildStore
|
|
19
|
+
env: CliEnv
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IssueDowngradeOpts {
|
|
23
|
+
issue: string
|
|
24
|
+
reason: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function downgradeIssueLink(
|
|
28
|
+
deps: IssueDowngradeDeps,
|
|
29
|
+
opts: IssueDowngradeOpts,
|
|
30
|
+
): Promise<EventEnvelope<'issue-link.downgraded'>> {
|
|
31
|
+
const match = /^#?(\d+)$/.exec(opts.issue.trim())
|
|
32
|
+
const issue = match === null ? Number.NaN : Number(match[1])
|
|
33
|
+
if (!Number.isSafeInteger(issue) || issue <= 0)
|
|
34
|
+
throw new Error(`'ab issue downgrade' expects an issue number such as 824, not "${opts.issue}"`)
|
|
35
|
+
const reason = opts.reason.trim()
|
|
36
|
+
if (reason === '') throw new Error("'ab issue downgrade' requires a non-empty --reason")
|
|
37
|
+
|
|
38
|
+
const { env, store } = deps
|
|
39
|
+
const before = (await readBuildFacts(store, env.build)).value.state
|
|
40
|
+
if (before.issueLinksSealedSeq !== undefined)
|
|
41
|
+
throw new Error(
|
|
42
|
+
`issue links were sealed when the PR was prepared at seq ${before.issueLinksSealedSeq}; ` +
|
|
43
|
+
"use 'ab escalate' instead",
|
|
44
|
+
)
|
|
45
|
+
const link = before.issueLinks.find((entry) => entry.issue === issue)
|
|
46
|
+
if (link === undefined)
|
|
47
|
+
throw new Error(
|
|
48
|
+
before.issueLinks.length === 0
|
|
49
|
+
? `issue #${issue} is not linked: this build has no issue links`
|
|
50
|
+
: `issue #${issue} is not linked; linked: ${formatIssueLinks(before.issueLinks)}`,
|
|
51
|
+
)
|
|
52
|
+
if (link.intent === 'refs')
|
|
53
|
+
throw new Error(`issue #${issue} is already refs; nothing to downgrade`)
|
|
54
|
+
|
|
55
|
+
const appended = await store.append(env.build, {
|
|
56
|
+
actor: agentActor(env.phase, env.session),
|
|
57
|
+
type: 'issue-link.downgraded',
|
|
58
|
+
payload: { issue, reason },
|
|
59
|
+
})
|
|
60
|
+
const after = (await readBuildFacts(store, env.build)).value.state
|
|
61
|
+
if (after.issueLinks.find((entry) => entry.issue === issue)?.downgrade?.seq !== appended.seq)
|
|
62
|
+
throw new Error(
|
|
63
|
+
`downgrade recorded at seq ${appended.seq} but inert: links were sealed at seq ` +
|
|
64
|
+
`${after.issueLinksSealedSeq ?? '?'}; use 'ab escalate' instead`,
|
|
65
|
+
)
|
|
66
|
+
return appended
|
|
67
|
+
}
|
|
@@ -54,6 +54,7 @@ import type { SetupAgentLauncher } from './init-agent'
|
|
|
54
54
|
import { abModels } from './models'
|
|
55
55
|
import { recognizeHelpRequest, renderCommandHelp, renderTopLevelHelp } from './help'
|
|
56
56
|
import { observe } from './observe'
|
|
57
|
+
import { downgradeIssueLink } from './issue-links'
|
|
57
58
|
import { abPlugin, type PluginContractSubprocess } from './plugin'
|
|
58
59
|
import { preparePrAttachments } from './pr-attachments'
|
|
59
60
|
import { abBuildAssetGet, abBuilds, abBuildStatus } from './status'
|
|
@@ -63,7 +64,7 @@ import { abWait, WAIT_USAGE } from './wait'
|
|
|
63
64
|
import { abMcp, AB_MCP_USAGE } from './mcp'
|
|
64
65
|
import type { StoreOpener } from './store-opening'
|
|
65
66
|
import { done, escalate, verdict } from './terminals'
|
|
66
|
-
import { abTicket, openTicketSource } from './ticket'
|
|
67
|
+
import { abTicket, lazyTicketSource, openTicketSource } from './ticket'
|
|
67
68
|
import { checkUpgradeCompatibility, type CompatibilityFetch } from './upgrade-compatibility'
|
|
68
69
|
import { abUpgrade, type ResolveConflict } from './upgrade'
|
|
69
70
|
import { withUpgradeProgress } from './upgrade-progress'
|
|
@@ -341,19 +342,18 @@ async function runBuildControl(
|
|
|
341
342
|
)
|
|
342
343
|
}
|
|
343
344
|
const result = await abBuildControl({
|
|
344
|
-
|
|
345
|
-
(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
).source,
|
|
345
|
+
...lazyTicketSource(() =>
|
|
346
|
+
openTicketSource(
|
|
347
|
+
{
|
|
348
|
+
targetRepo: deps.workspacePath,
|
|
349
|
+
env: deps.processEnv ?? {},
|
|
350
|
+
exec: deps.exec!,
|
|
351
|
+
stdout: deps.stdout,
|
|
352
|
+
...(storeRef !== undefined ? { storeRef } : {}),
|
|
353
|
+
},
|
|
354
|
+
`ab ${action.kind}`,
|
|
355
|
+
),
|
|
356
|
+
),
|
|
357
357
|
targetRepo: deps.workspacePath,
|
|
358
358
|
env: deps.processEnv ?? {},
|
|
359
359
|
exec: deps.exec,
|
|
@@ -1573,6 +1573,21 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1573
1573
|
return 0
|
|
1574
1574
|
}
|
|
1575
1575
|
|
|
1576
|
+
case 'issue': {
|
|
1577
|
+
const usage = 'usage: ab issue downgrade <N> --reason <text>'
|
|
1578
|
+
const [sub, ...more] = rest
|
|
1579
|
+
if (sub !== 'downgrade') throw new Error(usage)
|
|
1580
|
+
const parsed = parseArgs(more, { reason: 'value' }, usage)
|
|
1581
|
+
const [issue] = parsed.positionals
|
|
1582
|
+
if (issue === undefined || parsed.positionals.length !== 1) throw new Error(usage)
|
|
1583
|
+
const reason = stringFlag(parsed, 'reason')
|
|
1584
|
+
if (reason === undefined) throw new Error("'ab issue downgrade' requires --reason <text>")
|
|
1585
|
+
const session = requireSession(command, deps)
|
|
1586
|
+
const event = await downgradeIssueLink(session, { issue, reason })
|
|
1587
|
+
stdout(`issue #${event.payload.issue} downgraded to refs (seq ${event.seq})`)
|
|
1588
|
+
return 0
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1576
1591
|
case 'done': {
|
|
1577
1592
|
const session = requireSession(command, deps)
|
|
1578
1593
|
const usage = 'usage: ab done [--notes <file>] (§8.2)'
|
|
@@ -1583,7 +1598,9 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1583
1598
|
stdout(
|
|
1584
1599
|
event.type === 'publication.requested'
|
|
1585
1600
|
? `${event.type} recorded (seq ${event.seq}); publication is pending — do not run ab done again`
|
|
1586
|
-
:
|
|
1601
|
+
: event.type === 'escalation.raised'
|
|
1602
|
+
? `implement produced no commits over its base — escalation ${(event.payload as { id: string }).id} recorded (seq ${event.seq}); this session is complete, do not run another terminal`
|
|
1603
|
+
: `${event.type} recorded (seq ${event.seq})`,
|
|
1587
1604
|
)
|
|
1588
1605
|
return 0
|
|
1589
1606
|
}
|
|
@@ -102,15 +102,39 @@ export async function publishSummary(
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
function remoteWorkspace(facts: CurrentBuildFacts): boolean {
|
|
106
|
+
const workspace = facts.latestWorkspace
|
|
107
|
+
return workspace?.type === 'workspace.provisioned' && isRemoteWorkspace(workspace.payload)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The launch fence: no guest request of the next execution can be at or
|
|
111
|
+
* below it. Read after pre-launch settlement and before execution.start. */
|
|
112
|
+
export async function readLaunchFence(store: BuildStore, slug: string): Promise<number> {
|
|
113
|
+
return (await readBuildFacts(store, slug)).value.state.lastSeq
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** True iff this execution wrote a still-unsettled summary request, which a
|
|
117
|
+
* remote guest does only immediately before yielding for it. */
|
|
118
|
+
export function summaryHandoffPending(facts: CurrentBuildFacts, launchFenceSeq: number): boolean {
|
|
119
|
+
return (
|
|
120
|
+
remoteWorkspace(facts) && facts.summaryRequests.some((request) => request.seq > launchFenceSeq)
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
105
124
|
/** Local boundary or durable guest handoff. Optional refresh failures never
|
|
106
|
-
* prevent pipeline progress, including a failed request deposit.
|
|
107
|
-
|
|
125
|
+
* prevent pipeline progress, including a failed request deposit. A remote
|
|
126
|
+
* guest coalesces a verify cycle (`continuesVerifyCycle`) into one request at
|
|
127
|
+
* its end, and re-asserts (`reassert`) an eligible outstanding request so the
|
|
128
|
+
* dispatcher can tell its exit is a summary handoff. */
|
|
129
|
+
export async function refreshSummaryBoundary(
|
|
130
|
+
deps: SummaryDeps,
|
|
131
|
+
options: { continuesVerifyCycle?: boolean; reassert?: boolean } = {},
|
|
132
|
+
): Promise<boolean> {
|
|
108
133
|
try {
|
|
109
134
|
const events = (await readBuildFacts(deps.store, deps.slug)).value
|
|
110
135
|
const boundary = events.summaryBoundary
|
|
111
136
|
if (boundary === undefined) return false
|
|
112
|
-
|
|
113
|
-
if (workspace?.type === 'workspace.provisioned' && isRemoteWorkspace(workspace.payload)) {
|
|
137
|
+
if (remoteWorkspace(events)) {
|
|
114
138
|
const request = events.summaryRequested[String(boundary.occurrence)]
|
|
115
139
|
if (request !== undefined) {
|
|
116
140
|
// A lost result/disposition append must not repeatedly park a guest.
|
|
@@ -120,9 +144,17 @@ export async function refreshSummaryBoundary(deps: SummaryDeps): Promise<boolean
|
|
|
120
144
|
Date.parse(events.summaryEligibleAfter) > deps.clock().getTime()
|
|
121
145
|
)
|
|
122
146
|
return false
|
|
123
|
-
|
|
147
|
+
if (!events.summaryRequests.some((event) => event.seq === request.seq)) return false
|
|
148
|
+
if (!options.reassert) return true
|
|
149
|
+
const reasserted = await deps.store.appendIfCurrent(deps.slug, events.state.lastSeq, {
|
|
150
|
+
actor: KERNEL,
|
|
151
|
+
type: 'pr-summary.requested',
|
|
152
|
+
payload: request.payload,
|
|
153
|
+
})
|
|
154
|
+
return reasserted !== null
|
|
124
155
|
}
|
|
125
156
|
if (events.state.pr === undefined && !events.finalizePublicationRequested) return false
|
|
157
|
+
if (options.continuesVerifyCycle) return false
|
|
126
158
|
const written = await deps.store.appendIfCurrent(deps.slug, events.state.lastSeq, {
|
|
127
159
|
actor: KERNEL,
|
|
128
160
|
type: 'pr-summary.requested',
|
|
@@ -148,8 +180,7 @@ export async function settleSummaryRequests(
|
|
|
148
180
|
let events = (await readBuildFacts(deps.store, deps.slug)).value
|
|
149
181
|
if (events.open !== null) return
|
|
150
182
|
// Repair a crash after terminal/session completion but before guest handoff.
|
|
151
|
-
|
|
152
|
-
if (workspace?.type !== 'workspace.provisioned' || !isRemoteWorkspace(workspace.payload)) return
|
|
183
|
+
if (!remoteWorkspace(events)) return
|
|
153
184
|
const holder = deps.reservation ?? deps.holder
|
|
154
185
|
acquired = await deps.store.claimLease(deps.slug, holder, 60_000)
|
|
155
186
|
if (!acquired) return
|