@defrex/autobuild 1.0.1 → 1.2.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 +10 -18
- package/SPEC.md +499 -238
- package/bin/ab-dispatch-generation.ts +11 -2
- package/docs/accounts.md +119 -0
- package/docs/agent-runtimes.md +4 -4
- package/docs/answering-blocked-builds.md +2 -2
- package/docs/architecture.md +262 -53
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +3 -41
- package/docs/builds.md +4 -4
- package/docs/cli.md +18 -4
- package/docs/configuration-overview.md +115 -4
- package/docs/configuration.md +488 -334
- package/docs/dispatcher-hosting.md +19 -34
- package/docs/dispatcher.md +1 -1
- package/docs/forges.md +5 -5
- package/docs/getting-started.md +2 -2
- package/docs/glossary.md +6 -6
- package/docs/intake.md +2 -0
- package/docs/integration-overview.md +15 -15
- package/docs/integration-tree.md +45 -38
- package/docs/integration.md +6 -6
- package/{skills/guide/references/landing-policy.md → docs/merge-policy.md} +40 -24
- package/docs/migration-1.0.md +17 -13
- package/docs/operating.md +41 -19
- package/docs/operator-api.md +180 -51
- package/docs/operator-surfaces.md +5 -18
- package/docs/overview.md +3 -3
- package/docs/plugin-authoring.md +21 -0
- package/docs/remote-store-protocol.md +242 -68
- package/docs/remote-ticket-protocol.md +30 -50
- package/docs/restacking.md +54 -15
- package/docs/seams.md +8 -8
- package/docs/setup.md +59 -119
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +6 -6
- package/docs/ticket-dependencies.md +7 -7
- package/docs/ticket-sources.md +18 -0
- package/docs/tickets.md +8 -2
- package/docs/troubleshooting.md +8 -12
- package/docs/upgrading.md +9 -4
- package/docs/verification.md +60 -14
- package/docs/workspaces.md +4 -4
- package/package.json +17 -6
- package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
- package/packages/core/src/accounts/chatgpt-state.ts +41 -0
- package/packages/core/src/accounts/local-credentials.ts +194 -0
- package/packages/core/src/accounts/local-inference.ts +106 -0
- package/packages/core/src/accounts/local-owner.ts +123 -0
- package/packages/core/src/accounts/sensitive.ts +2 -0
- package/packages/core/src/cli/accounts.ts +147 -0
- package/packages/core/src/cli/binary-direct.ts +13 -1
- package/packages/core/src/cli/binary-lifecycle.ts +65 -2
- package/packages/core/src/cli/binary.ts +3 -1
- package/packages/core/src/cli/build-control.ts +83 -28
- package/packages/core/src/cli/connect.ts +3 -3
- package/packages/core/src/cli/context.ts +81 -38
- package/packages/core/src/cli/dashboard/facts.ts +2 -1
- package/packages/core/src/cli/dashboard/integration-detail.ts +8 -8
- package/packages/core/src/cli/dashboard/integration-row.ts +40 -13
- package/packages/core/src/cli/dashboard/landing-display.ts +25 -0
- package/packages/core/src/cli/dashboard/model.ts +56 -33
- package/packages/core/src/cli/dashboard/poll.ts +9 -3
- package/packages/core/src/cli/dashboard/render.ts +59 -37
- package/packages/core/src/cli/dashboard/target-distance.ts +14 -0
- package/packages/core/src/cli/dashboard/tree.ts +3 -2
- package/packages/core/src/cli/dispatch-args.ts +1 -1
- package/packages/core/src/cli/dispatch-frontend.ts +6 -3
- package/packages/core/src/cli/dispatch-handoff.ts +125 -44
- package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
- package/packages/core/src/cli/dispatch-launcher.ts +54 -21
- package/packages/core/src/cli/dispatch-preflight.ts +6 -1
- package/packages/core/src/cli/dispatch.ts +106 -11
- package/packages/core/src/cli/env.ts +4 -0
- package/packages/core/src/cli/help.ts +46 -23
- package/packages/core/src/cli/init-readiness-remote.ts +22 -1
- package/packages/core/src/cli/init-readiness-shared.ts +5 -1
- package/packages/core/src/cli/init-validation.ts +160 -18
- package/packages/core/src/cli/main.ts +68 -8
- package/packages/core/src/cli/node-verification-provenance.ts +1 -97
- package/packages/core/src/cli/publication-settlement.ts +47 -21
- package/packages/core/src/cli/repository-status.ts +20 -9
- package/packages/core/src/cli/secrets.ts +173 -0
- package/packages/core/src/cli/status.ts +42 -5
- package/packages/core/src/cli/store-opening.ts +17 -2
- package/packages/core/src/cli/terminal.ts +22 -1
- package/packages/core/src/cli/terminals.ts +14 -10
- package/packages/core/src/cli/upgrade-agent.ts +9 -1
- package/packages/core/src/cli/upgrade-landing.ts +70 -30
- package/packages/core/src/cli/upgrade.ts +3 -1
- package/packages/core/src/cli/wait.ts +15 -7
- package/packages/core/src/cli/watch-lifetime.ts +111 -0
- package/packages/core/src/cli/watch.ts +635 -510
- package/packages/core/src/config/accounts.ts +101 -0
- package/packages/core/src/config/effective-artifact.fixture.ts +27 -0
- package/packages/core/src/config/effective-artifact.ts +13 -0
- package/packages/core/src/config/landing.ts +1 -1
- package/packages/core/src/config/live.ts +14 -1
- package/packages/core/src/config/load.ts +21 -1
- package/packages/core/src/config/pipeline-source.ts +28 -0
- package/packages/core/src/config/reference-metadata.ts +2 -0
- package/packages/core/src/config/reference.ts +22 -7
- package/packages/core/src/config/roles.ts +54 -3
- package/packages/core/src/config/schema.ts +146 -162
- package/packages/core/src/context-directory.ts +26 -0
- package/packages/core/src/distribution-packaging.ts +26 -5
- package/packages/core/src/events/catalog.ts +10 -2
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/globs.ts +1 -1
- package/packages/core/src/events/payloads.ts +73 -1
- package/packages/core/src/events/policy.ts +7 -0
- package/packages/core/src/events/repository.ts +4 -4
- package/packages/core/src/events/sessions.ts +6 -6
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +574 -0
- package/packages/core/src/kernel/auto-merge.ts +2 -2
- package/packages/core/src/kernel/engine.ts +255 -26
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +10 -0
- package/packages/core/src/kernel/integration-landing.ts +3 -3
- package/packages/core/src/kernel/integration-state.ts +27 -4
- package/packages/core/src/kernel/leaf-restack-state.ts +28 -3
- package/packages/core/src/kernel/log-index.ts +13 -1
- package/packages/core/src/kernel/node-landing.ts +8 -8
- package/packages/core/src/kernel/node-parent.ts +2 -2
- package/packages/core/src/kernel/node-restack-transaction.ts +1 -1
- package/packages/core/src/kernel/node-verification-context.ts +216 -0
- package/packages/core/src/kernel/phases.ts +1 -1
- package/packages/core/src/kernel/plan-verify-selection.ts +16 -0
- package/packages/core/src/kernel/publication-retry.ts +168 -0
- package/packages/core/src/kernel/reconcile-restack.ts +29 -1
- package/packages/core/src/kernel/reducer.ts +85 -5
- package/packages/core/src/kernel/target-distance.ts +45 -0
- package/packages/core/src/kernel/terminal-guard.ts +10 -1
- package/packages/core/src/kernel/verify-stage-state.ts +123 -0
- package/packages/core/src/kernel/verify-stages.ts +39 -0
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +1 -1
- package/packages/core/src/operator/index.ts +3 -7
- package/packages/core/src/operator/landings.ts +5 -1
- package/packages/core/src/operator/presentation.ts +6 -1
- package/packages/core/src/operator/protocol.ts +6 -0
- package/packages/core/src/operator/query.ts +14 -18
- package/packages/core/src/operator/registry.ts +39 -7
- package/packages/core/src/operator/sandbox-host.ts +64 -40
- package/packages/core/src/operator/sandbox.ts +3 -0
- package/packages/core/src/operator/ticket-source-backend.ts +3 -12
- package/packages/core/src/operator/tickets.ts +25 -4
- package/packages/core/src/plugins/manifest.ts +2 -1
- package/packages/core/src/ports/forge/contract.ts +2 -2
- package/packages/core/src/ports/forge/git-rewrite.ts +25 -2
- package/packages/core/src/ports/forge/github-readiness.ts +2 -2
- package/packages/core/src/ports/forge/github.ts +26 -7
- package/packages/core/src/ports/forge/local-git.ts +4 -4
- package/packages/core/src/ports/forge/readiness.ts +1 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/account-env.ts +88 -0
- package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
- package/packages/core/src/ports/runner/claude.ts +26 -2
- package/packages/core/src/ports/runner/codex.ts +63 -31
- package/packages/core/src/ports/runner/one-shot.ts +2 -0
- package/packages/core/src/ports/runner/provider-error.ts +5 -0
- package/packages/core/src/ports/runner/routing.ts +35 -4
- package/packages/core/src/ports/tickets/contract.ts +58 -0
- package/packages/core/src/ports/tickets/tree.ts +1 -1
- package/packages/core/src/ports/types.ts +28 -7
- package/packages/core/src/ports/workspace/account-policy.ts +72 -0
- package/packages/core/src/ports/workspace/build-execution.ts +9 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
- package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +182 -72
- package/packages/core/src/processes/build-child.ts +6 -8
- package/packages/core/src/processes/build-execution-state.ts +8 -5
- package/packages/core/src/processes/build-runner.ts +554 -99
- package/packages/core/src/processes/dispatcher.ts +209 -101
- package/packages/core/src/processes/execution-no-progress.ts +8 -1
- package/packages/core/src/processes/execution-settlement.ts +21 -3
- package/packages/core/src/processes/harvest-runner.ts +68 -8
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-loss.ts +8 -2
- package/packages/core/src/processes/publication-state.ts +42 -4
- package/packages/core/src/processes/repo-view.ts +14 -0
- package/packages/core/src/processes/verify-cycle-config.ts +96 -0
- package/packages/core/src/project-secrets.ts +105 -0
- package/packages/core/src/{integration → scenarios}/harness.ts +330 -317
- package/packages/core/src/secret-name.ts +41 -0
- package/packages/core/src/store/account-redaction.ts +156 -0
- package/packages/core/src/store/adapter.ts +1 -0
- package/packages/core/src/store/build-scope.ts +9 -0
- package/packages/core/src/store/contract.ts +116 -2
- package/packages/core/src/store/local/schema.ts +13 -0
- package/packages/core/src/store/local/store.ts +42 -0
- package/packages/core/src/store/memory.ts +47 -0
- package/packages/core/src/store/operator-presence.ts +21 -0
- package/packages/core/src/store/phase-session.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +5185 -4156
- package/packages/core/src/store/remote/client.ts +89 -48
- package/packages/core/src/store/remote/compatibility.ts +20 -0
- package/packages/core/src/store/remote/protocol.ts +4 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/retention.ts +2 -3
- package/packages/core/src/store/session-handle.ts +9 -0
- package/packages/core/src/store/streams/session-writer.ts +1 -1
- package/packages/core/src/store/types.ts +12 -2
- package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
- package/packages/core/src/testing/index.ts +12 -1
- package/packages/core/src/testing/reduced-read-budget.ts +47 -0
- package/packages/core/src/testing/temp-directories.ts +58 -0
- package/skills/code-review/SKILL.md +23 -9
- package/skills/finalize/SKILL.md +15 -7
- package/skills/guide/SKILL.md +373 -148
- package/skills/guide/references/accounts.md +119 -0
- package/skills/guide/references/integration-tree.md +45 -38
- package/{docs/landing-policy.md → skills/guide/references/merge-policy.md} +40 -24
- package/skills/guide/references/migration-1.0.md +17 -13
- package/skills/guide/references/operator-api.md +180 -51
- package/skills/guide/references/plugin-authoring.md +21 -0
- package/skills/guide/references/remote-store-protocol.md +242 -68
- package/skills/guide/references/remote-ticket-protocol.md +30 -50
- package/skills/guide/references/restacking.md +54 -15
- package/skills/guide/references/setup.md +59 -119
- package/skills/guide/references/spec-standard.md +6 -6
- package/skills/guide/references/ticket-dependencies.md +7 -7
- package/skills/harvest/SKILL.md +3 -1
- package/skills/harvest-review/SKILL.md +3 -1
- package/skills/implement/SKILL.md +43 -17
- package/skills/operate/SKILL.md +118 -118
- package/skills/plan/SKILL.md +39 -13
- package/skills/plan-review/SKILL.md +15 -10
- package/skills/reconcile/SKILL.md +22 -3
- package/skills/spec/SKILL.md +20 -20
- package/skills/tickets/SKILL.md +12 -9
- package/templates/autobuild.toml +1 -1
- package/templates/hosted-service/package.json +2 -2
- package/docs/hosted-dispatcher-cutover-validation.md +0 -178
- package/docs/hosted-dispatcher.md +0 -275
- package/docs/hosted-service.md +0 -293
- package/docs/mcp.md +0 -149
- package/packages/core/src/orchestrator/approvals.ts +0 -115
- package/packages/core/src/orchestrator/conversation.ts +0 -167
- package/packages/core/src/orchestrator/model.ts +0 -86
- package/packages/core/src/orchestrator/prompt.ts +0 -63
- package/packages/core/src/orchestrator/tools.ts +0 -117
- package/packages/core/src/orchestrator/turn-runner.ts +0 -457
- package/packages/core/src/processes/orchestrator-tick.ts +0 -360
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { documentSchema, documentFields } from './reference-metadata'
|
|
3
|
+
|
|
4
|
+
const accountCredentialEnvSchema = z
|
|
5
|
+
.string()
|
|
6
|
+
.regex(/^[A-Za-z_][A-Za-z0-9_]*$/)
|
|
7
|
+
.refine(
|
|
8
|
+
(name) => !name.startsWith('AB_'),
|
|
9
|
+
'Autobuild control variables cannot hold account credentials',
|
|
10
|
+
)
|
|
11
|
+
export const accountSchema = z.discriminatedUnion('kind', [
|
|
12
|
+
z.strictObject({
|
|
13
|
+
kind: z.literal('chatgpt-subscription'),
|
|
14
|
+
credentialEnv: accountCredentialEnvSchema,
|
|
15
|
+
}),
|
|
16
|
+
z.strictObject({
|
|
17
|
+
kind: z.literal('claude-subscription'),
|
|
18
|
+
credentialEnv: accountCredentialEnvSchema,
|
|
19
|
+
}),
|
|
20
|
+
z.strictObject({
|
|
21
|
+
kind: z.literal('kimi-code'),
|
|
22
|
+
credentialEnv: accountCredentialEnvSchema,
|
|
23
|
+
region: z.enum(['overseas', 'china']).default('overseas'),
|
|
24
|
+
}),
|
|
25
|
+
])
|
|
26
|
+
|
|
27
|
+
documentSchema(accountSchema, { description: 'Named nonsecret billing account descriptor.' })
|
|
28
|
+
documentSchema(accountCredentialEnvSchema, {
|
|
29
|
+
constraints: 'Portable environment variable identifier; AB_ control variables are reserved.',
|
|
30
|
+
})
|
|
31
|
+
for (const branch of accountSchema.options)
|
|
32
|
+
documentFields(branch, {
|
|
33
|
+
kind: 'Claude subscription, Kimi Code membership, or ChatGPT subscription (Codex only).',
|
|
34
|
+
credentialEnv:
|
|
35
|
+
'Host credential variable name; ChatGPT names a host-resolved access-token slot, never a credential value.',
|
|
36
|
+
...(branch.shape.kind.value === 'kimi-code'
|
|
37
|
+
? {
|
|
38
|
+
region:
|
|
39
|
+
'Membership region: overseas (default) or china. Selects the base URL and exact egress host together.',
|
|
40
|
+
}
|
|
41
|
+
: {}),
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
/** Nonsecret billing descriptors. Credential values are resolved only at execution boundaries. */
|
|
45
|
+
export type Account =
|
|
46
|
+
| { kind: 'claude-subscription'; credentialEnv: string }
|
|
47
|
+
| { kind: 'chatgpt-subscription'; credentialEnv: string }
|
|
48
|
+
| { kind: 'kimi-code'; credentialEnv: string; region: 'overseas' | 'china' }
|
|
49
|
+
export type Accounts = Readonly<Record<string, Account>>
|
|
50
|
+
export const selectedAccountSchema = z.strictObject({
|
|
51
|
+
name: z.string().min(1),
|
|
52
|
+
descriptor: accountSchema,
|
|
53
|
+
})
|
|
54
|
+
export type SelectedAccount = z.infer<typeof selectedAccountSchema>
|
|
55
|
+
|
|
56
|
+
export function kimiEndpoint(region: 'overseas' | 'china'): { baseUrl: string; host: string } {
|
|
57
|
+
return region === 'china'
|
|
58
|
+
? { baseUrl: 'https://api.kimi.com/coding/', host: 'api.kimi.com' }
|
|
59
|
+
: { baseUrl: 'https://api.kimi.ai/coding/', host: 'api.kimi.ai' }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function selectAccount(
|
|
63
|
+
accounts: Accounts,
|
|
64
|
+
runtime: string | undefined,
|
|
65
|
+
name: string | undefined,
|
|
66
|
+
label: string,
|
|
67
|
+
): SelectedAccount | undefined {
|
|
68
|
+
if (name === undefined && runtime === 'claude') {
|
|
69
|
+
const defaults = Object.entries(accounts).filter(
|
|
70
|
+
([, account]) => account.kind === 'claude-subscription',
|
|
71
|
+
)
|
|
72
|
+
if (defaults.length > 1)
|
|
73
|
+
throw new Error(`${label}: ambiguous Claude subscription account; select account explicitly`)
|
|
74
|
+
name = defaults[0]?.[0]
|
|
75
|
+
}
|
|
76
|
+
if (name === undefined) return undefined
|
|
77
|
+
if (!Object.hasOwn(accounts, name))
|
|
78
|
+
throw new Error(`${label}: unknown account ${JSON.stringify(name)}`)
|
|
79
|
+
const requiredRuntime = accounts[name]!.kind === 'chatgpt-subscription' ? 'codex' : 'claude'
|
|
80
|
+
if (runtime !== requiredRuntime)
|
|
81
|
+
throw new Error(
|
|
82
|
+
`${label}: account ${JSON.stringify(name)} requires runtime "${requiredRuntime}"`,
|
|
83
|
+
)
|
|
84
|
+
return { name, descriptor: accounts[name]! }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function accountRemedy(account: SelectedAccount): string {
|
|
88
|
+
return (
|
|
89
|
+
`account ${JSON.stringify(account.name)} (${account.descriptor.credentialEnv}): ` +
|
|
90
|
+
(account.descriptor.kind === 'chatgpt-subscription'
|
|
91
|
+
? `sign in again with ab accounts login ${JSON.stringify(account.name)} (--local for the local dispatcher or --project for the connected project)`
|
|
92
|
+
: account.descriptor.kind === 'claude-subscription'
|
|
93
|
+
? 'renew with claude setup-token and set the dispatcher credential variable'
|
|
94
|
+
: 'replace the Kimi Code membership key in the dispatcher credential variable')
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Encodes arbitrary names injectively; never a credential. */
|
|
99
|
+
export function accountPlaceholder(name: string): string {
|
|
100
|
+
return `autobuild-account-${Buffer.from(name).toString('hex')}`
|
|
101
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { parseConfig } from './load'
|
|
2
|
+
import { effectiveBuildConfigContent } from '../processes/build-execution-state'
|
|
3
|
+
|
|
4
|
+
/** Pre-removal normalized snapshot, including defaults written while disabled. */
|
|
5
|
+
export function historicalEffectiveConfig(enabled = false): Record<string, unknown> {
|
|
6
|
+
const config = JSON.parse(
|
|
7
|
+
effectiveBuildConfigContent(
|
|
8
|
+
parseConfig(`
|
|
9
|
+
[tickets]
|
|
10
|
+
source = "file"
|
|
11
|
+
readyState = "ready"
|
|
12
|
+
[orchestrator]
|
|
13
|
+
enabled = ${enabled}
|
|
14
|
+
[orchestrator.sandbox]
|
|
15
|
+
idleMinutes = 7
|
|
16
|
+
environmentVariables = ["CUSTOM_TOOL"]
|
|
17
|
+
`),
|
|
18
|
+
),
|
|
19
|
+
)
|
|
20
|
+
config.orchestrator = {
|
|
21
|
+
...config.orchestrator,
|
|
22
|
+
invocationBudgetSeconds: 240,
|
|
23
|
+
approvals: ['sandbox.publish'],
|
|
24
|
+
...(enabled ? { model: 'test/historical', wake: ['escalation.*'] } : {}),
|
|
25
|
+
}
|
|
26
|
+
return config
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Read compatibility for immutable pre-removal effective-config artifacts only.
|
|
2
|
+
* New TOML must pass the current strict schema without this conversion. */
|
|
3
|
+
export function normalizeEffectiveConfigArtifact(value: unknown): unknown {
|
|
4
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) return value
|
|
5
|
+
const config = value as Record<string, unknown>
|
|
6
|
+
const previous = config.orchestrator
|
|
7
|
+
if (previous === null || typeof previous !== 'object' || Array.isArray(previous)) return value
|
|
8
|
+
const orchestrator = { ...previous } as Record<string, unknown>
|
|
9
|
+
for (const key of ['model', 'invocationBudgetSeconds', 'approvals', 'wake']) {
|
|
10
|
+
delete orchestrator[key]
|
|
11
|
+
}
|
|
12
|
+
return { ...config, orchestrator }
|
|
13
|
+
}
|
|
@@ -26,5 +26,5 @@ documentFields(landingRuleSchema, {
|
|
|
26
26
|
into: 'Optional destination: `root`, any `node`, or an exact frozen destination node ticket id.',
|
|
27
27
|
from: 'Restrict this rule to one source build kind; omission matches all kinds.',
|
|
28
28
|
label: 'Optional exact, case-sensitive label on the source ticket. Blank labels are invalid.',
|
|
29
|
-
mode: 'Choose automatic
|
|
29
|
+
mode: 'Choose automatic merge or require recorded consent.',
|
|
30
30
|
})
|
|
@@ -29,6 +29,7 @@ export const CONFIG_RELOAD_CLASSIFICATION = {
|
|
|
29
29
|
verify: 'hot',
|
|
30
30
|
finalize: 'hot',
|
|
31
31
|
roles: 'hot',
|
|
32
|
+
accounts: 'hot',
|
|
32
33
|
policy: 'hot',
|
|
33
34
|
orchestrator: 'restart',
|
|
34
35
|
tickets: {
|
|
@@ -184,7 +185,12 @@ export class LiveConfig {
|
|
|
184
185
|
this.acceptedContent = startupContent
|
|
185
186
|
this.snapshot = {
|
|
186
187
|
config: startup,
|
|
187
|
-
resolver: createRuntimeResolver(
|
|
188
|
+
resolver: createRuntimeResolver(
|
|
189
|
+
runtimes,
|
|
190
|
+
startup.roles,
|
|
191
|
+
startup.policy.sessionBudgetSeconds,
|
|
192
|
+
startup.accounts,
|
|
193
|
+
),
|
|
188
194
|
revision: 0,
|
|
189
195
|
}
|
|
190
196
|
}
|
|
@@ -244,10 +250,17 @@ export class LiveConfig {
|
|
|
244
250
|
const config = composeReloadedConfig(this.startup, candidate)
|
|
245
251
|
let resolver: RuntimeResolver
|
|
246
252
|
try {
|
|
253
|
+
for (const [name, account] of Object.entries(this.snapshot.config.accounts)) {
|
|
254
|
+
if (account.kind === 'chatgpt-subscription' && !same(account, config.accounts[name]))
|
|
255
|
+
throw new Error(
|
|
256
|
+
`ChatGPT account ${JSON.stringify(name)} cannot change while dispatch is active; stop dispatch before replacing its descriptor`,
|
|
257
|
+
)
|
|
258
|
+
}
|
|
247
259
|
resolver = createRuntimeResolver(
|
|
248
260
|
this.runtimes,
|
|
249
261
|
config.roles,
|
|
250
262
|
config.policy.sessionBudgetSeconds,
|
|
263
|
+
config.accounts,
|
|
251
264
|
)
|
|
252
265
|
} catch (error) {
|
|
253
266
|
const message = error instanceof Error ? error.message : String(error)
|
|
@@ -70,7 +70,11 @@ function describeIssue(issue: z.core.$ZodIssue): string {
|
|
|
70
70
|
return ` ${formatPath(path)}: ${message}`
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export function parseConfig(
|
|
73
|
+
export function parseConfig(
|
|
74
|
+
tomlText: string,
|
|
75
|
+
source = 'autobuild.toml',
|
|
76
|
+
warn: (message: string) => void = console.error,
|
|
77
|
+
): Config {
|
|
74
78
|
let table: unknown
|
|
75
79
|
try {
|
|
76
80
|
table = parseToml(tomlText)
|
|
@@ -81,6 +85,19 @@ export function parseConfig(tomlText: string, source = 'autobuild.toml'): Config
|
|
|
81
85
|
throw error
|
|
82
86
|
}
|
|
83
87
|
|
|
88
|
+
if (table && typeof table === 'object' && 'orchestrator' in table) {
|
|
89
|
+
const orchestrator = table.orchestrator
|
|
90
|
+
if (orchestrator && typeof orchestrator === 'object') {
|
|
91
|
+
const removed = ['model', 'invocationBudgetSeconds', 'approvals', 'wake'].filter((key) =>
|
|
92
|
+
Object.hasOwn(orchestrator, key),
|
|
93
|
+
)
|
|
94
|
+
if (removed.length > 0) {
|
|
95
|
+
throw new ConfigError(
|
|
96
|
+
`${source}: [orchestrator].${removed.join(', [orchestrator].')} removed: the embedded runner was removed; operators run externally. Keep only enabled and sandbox settings.`,
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
84
101
|
const result = configSchema.safeParse(table)
|
|
85
102
|
if (!result.success) {
|
|
86
103
|
// Expanded for the operator, raw for the payload: the expanded copies carry
|
|
@@ -89,6 +106,9 @@ export function parseConfig(tomlText: string, source = 'autobuild.toml'): Config
|
|
|
89
106
|
const details = expandIssues(result.error.issues).map(describeIssue).join('\n')
|
|
90
107
|
throw new ConfigError(`${source}: invalid config\n${details}`, result.error.issues)
|
|
91
108
|
}
|
|
109
|
+
if (table && typeof table === 'object' && Object.hasOwn(table, 'landing')) {
|
|
110
|
+
warn(`${source}: [[landing]] is deprecated; use [[merge]] instead`)
|
|
111
|
+
}
|
|
92
112
|
return result.data
|
|
93
113
|
}
|
|
94
114
|
|
|
@@ -387,3 +387,31 @@ export async function resolvePipelineSource(
|
|
|
387
387
|
}
|
|
388
388
|
return parsePipeline(baseSha, 'base', baseContent, onFailure)
|
|
389
389
|
}
|
|
390
|
+
|
|
391
|
+
/** Strict execution-side read. Failures block verification rather than falling back. */
|
|
392
|
+
export async function readVerifyPipeline(
|
|
393
|
+
workspacePath: string,
|
|
394
|
+
exec: Exec,
|
|
395
|
+
): Promise<PipelineSource & { head: string }> {
|
|
396
|
+
const run = async (args: string[]) => {
|
|
397
|
+
const result = await git(args, workspacePath, exec)
|
|
398
|
+
if (result.exitCode !== 0)
|
|
399
|
+
throw new Error(`verify config: git ${args.join(' ')}: ${result.stderr}`)
|
|
400
|
+
return result.stdout.trim()
|
|
401
|
+
}
|
|
402
|
+
const head = await run(['rev-parse', '--verify', 'HEAD'])
|
|
403
|
+
if (!/^[a-f0-9]{40,64}$/.test(head)) throw new Error('verify config: invalid checkout HEAD')
|
|
404
|
+
const content = await readFile(join(workspacePath, 'autobuild.toml'), 'utf8')
|
|
405
|
+
const [committed, working] = await Promise.all([
|
|
406
|
+
run(['ls-tree', head, '--', 'autobuild.toml']),
|
|
407
|
+
run(['hash-object', '--', 'autobuild.toml']),
|
|
408
|
+
])
|
|
409
|
+
return {
|
|
410
|
+
head,
|
|
411
|
+
meta:
|
|
412
|
+
committed.split(/\s+/)[2] === working
|
|
413
|
+
? { ref: 'branch-head', commit: head }
|
|
414
|
+
: { ref: 'worktree-dirty' },
|
|
415
|
+
config: parseConfig(content, `autobuild.toml@${head}`),
|
|
416
|
+
}
|
|
417
|
+
}
|
|
@@ -2,6 +2,8 @@ import type { z } from 'zod'
|
|
|
2
2
|
|
|
3
3
|
/** Documentation describes input semantics; it never participates in validation. */
|
|
4
4
|
export interface ReferenceMetadata {
|
|
5
|
+
/** Semantic default when omission is intentionally preserved in serialized config. */
|
|
6
|
+
default?: string
|
|
5
7
|
description?: string
|
|
6
8
|
constraints?: string
|
|
7
9
|
required?: string
|
|
@@ -37,10 +37,12 @@ function fail(path: string, message: string): never {
|
|
|
37
37
|
function metadata(schema: z.ZodType, path: string): ReferenceMetadata {
|
|
38
38
|
const result = referenceMetadata(schema) ?? {}
|
|
39
39
|
for (const [key, value] of Object.entries(result)) {
|
|
40
|
-
if (
|
|
40
|
+
if (
|
|
41
|
+
!['description', 'constraints', 'required', 'examples', 'structure', 'default'].includes(key)
|
|
42
|
+
)
|
|
41
43
|
fail(path, `unknown metadata ${key}`)
|
|
42
44
|
if (
|
|
43
|
-
['description', 'constraints', 'required'].includes(key) &&
|
|
45
|
+
['description', 'constraints', 'required', 'default'].includes(key) &&
|
|
44
46
|
(typeof value !== 'string' || !value.trim())
|
|
45
47
|
)
|
|
46
48
|
fail(path, `blank or malformed ${key}`)
|
|
@@ -155,7 +157,13 @@ function input(schema: z.ZodType, path: string): Input {
|
|
|
155
157
|
optional = true
|
|
156
158
|
fallback = `${JSON.stringify(definition(current).defaultValue)} (input supplied on omission)`
|
|
157
159
|
}
|
|
158
|
-
return {
|
|
160
|
+
return {
|
|
161
|
+
schema: current,
|
|
162
|
+
metadata: meta,
|
|
163
|
+
optional,
|
|
164
|
+
default: meta.default ?? fallback,
|
|
165
|
+
constraints,
|
|
166
|
+
}
|
|
159
167
|
}
|
|
160
168
|
function typeOf(value: Input, path: string): string {
|
|
161
169
|
if (value.metadata.structure) return 'table'
|
|
@@ -177,8 +185,11 @@ function typeOf(value: Input, path: string): string {
|
|
|
177
185
|
return Object.values(def.entries!)
|
|
178
186
|
.map((v) => JSON.stringify(v))
|
|
179
187
|
.join(' | ')
|
|
180
|
-
case 'array':
|
|
181
|
-
|
|
188
|
+
case 'array': {
|
|
189
|
+
const elementInput = input(def.element!, `${path}[]`)
|
|
190
|
+
const element = typeOf(elementInput, `${path}[]`)
|
|
191
|
+
return `array of ${definition(elementInput.schema).type === 'union' ? `(${element})` : element}`
|
|
192
|
+
}
|
|
182
193
|
case 'union':
|
|
183
194
|
return def.options!.map((v) => typeOf(input(v, path), path)).join(' | ')
|
|
184
195
|
default:
|
|
@@ -202,7 +213,10 @@ export const DOCUMENTATION_RELOAD_FALLBACK = {
|
|
|
202
213
|
'tickets.doneState': 'hot',
|
|
203
214
|
} as const
|
|
204
215
|
export function reloadBehavior(path: string): string {
|
|
205
|
-
const parts = path
|
|
216
|
+
const parts = path
|
|
217
|
+
.replace(/^merge(?=\[|\.|$)/, 'landing')
|
|
218
|
+
.replaceAll('[]', '')
|
|
219
|
+
.split('.')
|
|
206
220
|
let classification: unknown = CONFIG_RELOAD_CLASSIFICATION
|
|
207
221
|
for (const part of parts) {
|
|
208
222
|
if (typeof classification === 'string') break
|
|
@@ -223,7 +237,7 @@ export function reloadBehavior(path: string): string {
|
|
|
223
237
|
? 'Dispatcher restart required; startup adapters retain their configuration.'
|
|
224
238
|
: 'Mixed: see individual fields for dispatcher reload behavior.'
|
|
225
239
|
const owned = BUILD_OWNED_CONFIG_PATHS.some((prefix) => parts[0] === prefix)
|
|
226
|
-
return `${dispatcher}${owned ? ' Build-owned pipeline: captured from the
|
|
240
|
+
return `${dispatcher}${owned ? ' Build-owned pipeline: captured from the execution checkout each verify cycle; later base-branch edits do not replace it. Workspace provisioning applies at the next build launch.' : ''} A running invocation keeps its captured values.`
|
|
227
241
|
}
|
|
228
242
|
export function schemaFields(
|
|
229
243
|
schema: z.ZodType,
|
|
@@ -298,6 +312,7 @@ export function schemaFields(
|
|
|
298
312
|
export function configurationReference(): Record<string, ReferenceField[]> {
|
|
299
313
|
const regions: Record<string, ReferenceField[]> = { root: [] }
|
|
300
314
|
for (const [key, schema] of Object.entries(configRootSchema.shape)) {
|
|
315
|
+
if (key === 'landing') continue // Deprecated spelling is documented with the canonical merge rules.
|
|
301
316
|
const fields = schemaFields(schema, key)
|
|
302
317
|
const type = fields[0]!.type
|
|
303
318
|
if (!type.includes('table')) regions.root!.push(...fields)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { selectAccount, type SelectedAccount } from './accounts'
|
|
1
2
|
/**
|
|
2
3
|
* Role-key consumability diagnostics (SPEC §9).
|
|
3
4
|
*
|
|
@@ -79,6 +80,9 @@ export interface RoleKeyDiagnostics {
|
|
|
79
80
|
type StepTable = { kind: 'check' } | { kind: 'agent'; skill: string }
|
|
80
81
|
|
|
81
82
|
export interface RuntimeReferenceGroup {
|
|
83
|
+
/** Account-free routes, retained separately when accounts are declared. */
|
|
84
|
+
legacyAuthentication?: { models: string[]; usesRuntimeDefaultModel: boolean }
|
|
85
|
+
accountTargets?: Array<{ account: SelectedAccount; model?: string; references: string[] }>
|
|
82
86
|
runtime: string
|
|
83
87
|
/** Human-readable routes selecting this runtime, including alternates. */
|
|
84
88
|
references: string[]
|
|
@@ -95,7 +99,7 @@ export interface RuntimeReferenceGroup {
|
|
|
95
99
|
* bootstrap share one source of truth.
|
|
96
100
|
*/
|
|
97
101
|
export function effectiveRuntimeReferences(
|
|
98
|
-
config: Pick<Config, 'roles' | 'verify' | 'finalize'
|
|
102
|
+
config: Pick<Config, 'roles' | 'verify' | 'finalize'> & Partial<Pick<Config, 'accounts'>>,
|
|
99
103
|
): RuntimeReferenceGroup[] {
|
|
100
104
|
const defaultSpec = config.roles.default ?? {}
|
|
101
105
|
const routes: Array<{ role: string; aliases?: string[]; label: string }> = [
|
|
@@ -112,6 +116,14 @@ export function effectiveRuntimeReferences(
|
|
|
112
116
|
})),
|
|
113
117
|
]
|
|
114
118
|
|
|
119
|
+
const legacyAuthentication = new Map<
|
|
120
|
+
string,
|
|
121
|
+
{ models: Set<string>; usesRuntimeDefaultModel: boolean }
|
|
122
|
+
>()
|
|
123
|
+
const accountTargets = new Map<
|
|
124
|
+
string,
|
|
125
|
+
Array<{ account: SelectedAccount; model?: string; references: string[] }>
|
|
126
|
+
>()
|
|
115
127
|
const grouped = new Map<
|
|
116
128
|
string,
|
|
117
129
|
{ references: Set<string>; models: Set<string>; usesRuntimeDefaultModel: boolean }
|
|
@@ -123,8 +135,28 @@ export function effectiveRuntimeReferences(
|
|
|
123
135
|
}
|
|
124
136
|
return defaultSpec
|
|
125
137
|
}
|
|
126
|
-
const add = (
|
|
138
|
+
const add = (
|
|
139
|
+
runtime: string | undefined,
|
|
140
|
+
model: string | undefined,
|
|
141
|
+
reference: string,
|
|
142
|
+
accountName?: string,
|
|
143
|
+
) => {
|
|
144
|
+
const account = selectAccount(config.accounts ?? {}, runtime, accountName, reference)
|
|
145
|
+
if (account && runtime) {
|
|
146
|
+
const targets = accountTargets.get(runtime) ?? []
|
|
147
|
+
targets.push({ account, ...(model === undefined ? {} : { model }), references: [reference] })
|
|
148
|
+
accountTargets.set(runtime, targets)
|
|
149
|
+
}
|
|
127
150
|
if (runtime === undefined || runtime.trim() === '') return
|
|
151
|
+
if (!account) {
|
|
152
|
+
const legacy = legacyAuthentication.get(runtime) ?? {
|
|
153
|
+
models: new Set<string>(),
|
|
154
|
+
usesRuntimeDefaultModel: false,
|
|
155
|
+
}
|
|
156
|
+
if (model === undefined) legacy.usesRuntimeDefaultModel = true
|
|
157
|
+
else legacy.models.add(model)
|
|
158
|
+
legacyAuthentication.set(runtime, legacy)
|
|
159
|
+
}
|
|
128
160
|
const group = grouped.get(runtime) ?? {
|
|
129
161
|
references: new Set(),
|
|
130
162
|
models: new Set(),
|
|
@@ -140,21 +172,40 @@ export function effectiveRuntimeReferences(
|
|
|
140
172
|
const spec = declaredSpec(route.role, route.aliases)
|
|
141
173
|
const runtime = spec.runtime ?? defaultSpec.runtime
|
|
142
174
|
const model = spec.model ?? defaultSpec.model
|
|
143
|
-
add(runtime, model, `${route.label} primary
|
|
175
|
+
add(runtime, model, `${route.label} primary`, spec.account ?? defaultSpec.account)
|
|
144
176
|
const alternates = spec.alternates ?? defaultSpec.alternates ?? []
|
|
145
177
|
alternates.forEach((alternate, index) => {
|
|
146
178
|
add(
|
|
147
179
|
alternate.runtime ?? runtime,
|
|
148
180
|
alternate.model ?? model,
|
|
149
181
|
`${route.label} alternate[${index}]`,
|
|
182
|
+
alternate.account ?? spec.account ?? defaultSpec.account,
|
|
150
183
|
)
|
|
151
184
|
})
|
|
152
185
|
}
|
|
153
186
|
|
|
187
|
+
// Unused accounts still require their actual runtime for readiness.
|
|
188
|
+
for (const [name, descriptor] of Object.entries(config.accounts ?? {}))
|
|
189
|
+
add(
|
|
190
|
+
descriptor.kind === 'chatgpt-subscription' ? 'codex' : 'claude',
|
|
191
|
+
descriptor.kind === 'kimi-code' ? 'kimi-for-coding' : undefined,
|
|
192
|
+
`account ${displayName(name)} readiness`,
|
|
193
|
+
name,
|
|
194
|
+
)
|
|
195
|
+
|
|
154
196
|
return [...grouped.entries()]
|
|
155
197
|
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
|
|
156
198
|
.map(([runtime, group]) => ({
|
|
157
199
|
runtime,
|
|
200
|
+
...(Object.keys(config.accounts ?? {}).length && legacyAuthentication.has(runtime)
|
|
201
|
+
? {
|
|
202
|
+
legacyAuthentication: {
|
|
203
|
+
models: [...legacyAuthentication.get(runtime)!.models].sort(),
|
|
204
|
+
usesRuntimeDefaultModel: legacyAuthentication.get(runtime)!.usesRuntimeDefaultModel,
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
: {}),
|
|
208
|
+
...(accountTargets.has(runtime) ? { accountTargets: accountTargets.get(runtime)! } : {}),
|
|
158
209
|
references: [...group.references].sort(),
|
|
159
210
|
models: [...group.models].sort(),
|
|
160
211
|
usesRuntimeDefaultModel: group.usesRuntimeDefaultModel,
|