@defrex/autobuild 1.10.0 → 1.11.1
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 +745 -69
- 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 +165 -29
- 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 +64 -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 +111 -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 +179 -76
- package/packages/core/src/cli/dashboard/render.ts +159 -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 +40 -40
- 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 +202 -38
- 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 +105 -49
- 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 +381 -30
- 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/46196d8f0076496a.json +97 -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/dispatch-status.ts +139 -0
- 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/read-facts.ts +15 -13
- package/packages/core/src/kernel/reducer-registry.ts +27 -8
- package/packages/core/src/kernel/reducer-revisions.ts +27 -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 +129 -74
- 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 +7027 -5751
- 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 +22 -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/1.11.1.json +35718 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -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-journals.ts +117 -0
- 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 +39 -0
- package/packages/core/src/web/server.ts +97 -0
- package/skills/code-review/SKILL.md +10 -2
- package/skills/guide/SKILL.md +376 -54
- 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
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Branch-owned worktree config and supplied immutable text are parsed as
|
|
5
5
|
* one-shot inputs: `parseConfig(text)` is the primary API, while
|
|
6
|
-
* `loadConfig(path)`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* `loadConfig(path)` reads a checkout for scoped CLI and local tooling, layering
|
|
7
|
+
* the checkout's uncommitted `.autobuild/local.toml` over `autobuild.toml`
|
|
8
|
+
* (see `./local`). The running dispatcher has a separate live-reload context:
|
|
9
|
+
* `LiveConfig` reads the main checkout's two files as one candidate, retains its
|
|
10
|
+
* last valid snapshot across rejected candidates, and lets each action capture
|
|
11
|
+
* the current snapshot at its boundary.
|
|
10
12
|
*/
|
|
13
|
+
import { dirname } from 'node:path'
|
|
11
14
|
import { parse as parseToml, TomlError } from 'smol-toml'
|
|
12
15
|
import type { z } from 'zod'
|
|
13
16
|
import { expandIssues } from '../zod-issues'
|
|
17
|
+
import { parseLayeredConfig, readLocalConfig } from './local'
|
|
14
18
|
import { configSchema, TOP_LEVEL_SCALARS, TOP_LEVEL_TABLES, type Config } from './schema'
|
|
15
19
|
|
|
16
20
|
/**
|
|
@@ -84,23 +88,15 @@ function duplicateHookName(text: string, error: TomlError): string | undefined {
|
|
|
84
88
|
return name.startsWith('"') || name.startsWith("'") ? name.slice(1, -1) : name
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
* `ab init`, `ab upgrade`). Recurring or internal callers — the dispatcher and
|
|
92
|
-
* pipeline-source resolution — pass their own sink, a collector or a no-op, so
|
|
93
|
-
* a deprecation is reported once per startup or changed file instead of per
|
|
94
|
-
* phase launch.
|
|
95
|
-
*/
|
|
96
|
-
export function parseConfig(
|
|
91
|
+
/** Parse TOML text into a raw table, naming `source` in every syntax error.
|
|
92
|
+
* No schema validation happens here: layered readers merge raw tables first
|
|
93
|
+
* (see `./local`) so defaults and cross-validation see the merged input. */
|
|
94
|
+
export function parseConfigTable(
|
|
97
95
|
tomlText: string,
|
|
98
96
|
source = 'autobuild.toml',
|
|
99
|
-
|
|
100
|
-
): Config {
|
|
101
|
-
let table: unknown
|
|
97
|
+
): Record<string, unknown> {
|
|
102
98
|
try {
|
|
103
|
-
|
|
99
|
+
return parseToml(tomlText) as Record<string, unknown>
|
|
104
100
|
} catch (error) {
|
|
105
101
|
if (error instanceof TomlError) {
|
|
106
102
|
const hook = duplicateHookName(tomlText, error)
|
|
@@ -112,7 +108,21 @@ export function parseConfig(
|
|
|
112
108
|
}
|
|
113
109
|
throw error
|
|
114
110
|
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Admission for committed input, separate from effective/artifact validation. */
|
|
114
|
+
export function admitCommittedConfig(table: Record<string, unknown>, source: string): void {
|
|
115
|
+
if (Object.hasOwn(table, 'operator'))
|
|
116
|
+
throw new ConfigError(`${source}: [operator] is local-only; set it in .autobuild/local.toml`)
|
|
117
|
+
}
|
|
115
118
|
|
|
119
|
+
/** Validate a raw configuration table; every error names `source`. Deprecated
|
|
120
|
+
* spellings are reported through `warn` after validation succeeds. */
|
|
121
|
+
export function validateConfigTable(
|
|
122
|
+
table: Record<string, unknown>,
|
|
123
|
+
source = 'autobuild.toml',
|
|
124
|
+
warn: (message: string) => void = console.error,
|
|
125
|
+
): Config {
|
|
116
126
|
if (table && typeof table === 'object' && 'orchestrator' in table) {
|
|
117
127
|
const orchestrator = table.orchestrator
|
|
118
128
|
if (orchestrator && typeof orchestrator === 'object') {
|
|
@@ -140,7 +150,38 @@ export function parseConfig(
|
|
|
140
150
|
return result.data
|
|
141
151
|
}
|
|
142
152
|
|
|
143
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Parse and validate autobuild.toml text. Deprecated spellings are reported
|
|
155
|
+
* through `warn` after validation succeeds; invalid text throws first. The
|
|
156
|
+
* `console.error` default suits explicit one-shot reads (scoped CLI commands,
|
|
157
|
+
* `ab init`, `ab upgrade`). Recurring or internal callers — the dispatcher and
|
|
158
|
+
* pipeline-source resolution — pass their own sink, a collector or a no-op, so
|
|
159
|
+
* a deprecation is reported once per startup or changed file instead of per
|
|
160
|
+
* phase launch.
|
|
161
|
+
*
|
|
162
|
+
* This reads committed text only. Readers of a checkout use `loadConfig`,
|
|
163
|
+
* which layers the checkout's `.autobuild/local.toml` over it.
|
|
164
|
+
*/
|
|
165
|
+
export function parseConfig(
|
|
166
|
+
tomlText: string,
|
|
167
|
+
source = 'autobuild.toml',
|
|
168
|
+
warn: (message: string) => void = console.error,
|
|
169
|
+
): Config {
|
|
170
|
+
const table = parseConfigTable(tomlText, source)
|
|
171
|
+
admitCommittedConfig(table, source)
|
|
172
|
+
return validateConfigTable(table, source, warn)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Read a checkout's configuration: `path` (its `autobuild.toml`) layered with
|
|
177
|
+
* the sibling `.autobuild/local.toml` when that file exists. Without a local
|
|
178
|
+
* file the result is exactly `parseConfig` of `path`.
|
|
179
|
+
*/
|
|
180
|
+
export async function loadConfig(
|
|
181
|
+
path: string,
|
|
182
|
+
warn: (message: string) => void = console.error,
|
|
183
|
+
): Promise<Config> {
|
|
144
184
|
const text = await Bun.file(path).text()
|
|
145
|
-
|
|
185
|
+
const local = await readLocalConfig(dirname(path))
|
|
186
|
+
return parseLayeredConfig({ committed: { text, source: path }, local }, warn).config
|
|
146
187
|
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local configuration overrides (SPEC §16.1): an uncommitted
|
|
3
|
+
* `.autobuild/local.toml` beside a checkout's `autobuild.toml`, layered over
|
|
4
|
+
* it for every process that reads configuration from that checkout.
|
|
5
|
+
*
|
|
6
|
+
* Only an allowlist of top-level sections may be overridden. Every root key
|
|
7
|
+
* declares its classification below, so a section added later is a type error
|
|
8
|
+
* until someone decides whether it is personal or shared. The layer merges raw
|
|
9
|
+
* TOML tables before schema validation: defaults, open-map handling and every
|
|
10
|
+
* cross-field rule run on the merged input exactly as they do for
|
|
11
|
+
* `autobuild.toml`, and an invalid local value gets the message the setting
|
|
12
|
+
* gets in `autobuild.toml`, naming the local file.
|
|
13
|
+
*/
|
|
14
|
+
import { join } from 'node:path'
|
|
15
|
+
import { admitCommittedConfig, ConfigError, parseConfigTable, validateConfigTable } from './load'
|
|
16
|
+
import type { Config, configRootSchema } from './schema'
|
|
17
|
+
|
|
18
|
+
/** Location of the local override file, relative to the checkout root. */
|
|
19
|
+
export const LOCAL_CONFIG_RELATIVE_PATH = '.autobuild/local.toml'
|
|
20
|
+
|
|
21
|
+
export function localConfigPath(repoRoot: string): string {
|
|
22
|
+
return join(repoRoot, '.autobuild', 'local.toml')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type LocalOverrideClass = 'local' | 'committed'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether each raw root key may be set in `.autobuild/local.toml`. Keyed by the
|
|
29
|
+
* raw root schema (which carries both `merge` and the deprecated `landing`), so
|
|
30
|
+
* adding a root key without a classification fails to compile.
|
|
31
|
+
*/
|
|
32
|
+
export const LOCAL_OVERRIDE_CLASSIFICATION = {
|
|
33
|
+
// The local machine and process: how much work it runs, how often it scans,
|
|
34
|
+
// whether it adopts runtime upgrades.
|
|
35
|
+
capacity: 'local',
|
|
36
|
+
ticketScanIntervalSeconds: 'local',
|
|
37
|
+
upgrade: 'local',
|
|
38
|
+
operator: 'local',
|
|
39
|
+
// Personal notifications.
|
|
40
|
+
hooks: 'local',
|
|
41
|
+
// Which model subscriptions a person holds.
|
|
42
|
+
roles: 'local',
|
|
43
|
+
accounts: 'local',
|
|
44
|
+
// Must agree across everyone sharing the store, ticket source and forge.
|
|
45
|
+
store: 'committed',
|
|
46
|
+
baseBranch: 'committed',
|
|
47
|
+
forge: 'committed',
|
|
48
|
+
plugins: 'committed',
|
|
49
|
+
merge: 'committed',
|
|
50
|
+
landing: 'committed',
|
|
51
|
+
pr: 'committed',
|
|
52
|
+
generated: 'committed',
|
|
53
|
+
profiles: 'committed',
|
|
54
|
+
policy: 'committed',
|
|
55
|
+
orchestrator: 'committed',
|
|
56
|
+
tickets: 'committed',
|
|
57
|
+
// Build-owned: a build's pipeline comes from its own branch on every machine.
|
|
58
|
+
workspace: 'committed',
|
|
59
|
+
commands: 'committed',
|
|
60
|
+
verify: 'committed',
|
|
61
|
+
finalize: 'committed',
|
|
62
|
+
} as const satisfies { [K in keyof typeof configRootSchema.shape]: LocalOverrideClass }
|
|
63
|
+
|
|
64
|
+
export type ConfigRootKey = keyof typeof LOCAL_OVERRIDE_CLASSIFICATION
|
|
65
|
+
|
|
66
|
+
/** The sections a local file may set, in declaration order. */
|
|
67
|
+
export const LOCAL_OVERRIDE_KEYS = (
|
|
68
|
+
Object.keys(LOCAL_OVERRIDE_CLASSIFICATION) as ConfigRootKey[]
|
|
69
|
+
).filter((key) => LOCAL_OVERRIDE_CLASSIFICATION[key] === 'local')
|
|
70
|
+
|
|
71
|
+
/** Which settings a dispatcher's effective configuration took from a local file. */
|
|
72
|
+
export interface LocalOverrideRecord {
|
|
73
|
+
/** Path of the local file as the reading process named it. */
|
|
74
|
+
file: string
|
|
75
|
+
/** Sorted dotted leaf paths the file sets; an array is one leaf. */
|
|
76
|
+
settings: string[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ConfigText {
|
|
80
|
+
text: string
|
|
81
|
+
source: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface LayeredConfig {
|
|
85
|
+
config: Config
|
|
86
|
+
localOverrides?: LocalOverrideRecord
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function isTable(value: unknown): value is Record<string, unknown> {
|
|
90
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) return false
|
|
91
|
+
const prototype = Object.getPrototypeOf(value)
|
|
92
|
+
return prototype === null || prototype === Object.prototype
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Merge two raw TOML tables key by key: tables merge recursively; scalars,
|
|
97
|
+
* arrays (including arrays of tables) and a type mismatch replace whole. Inputs
|
|
98
|
+
* are never mutated. Keys are defined, never assigned, so an open-map entry
|
|
99
|
+
* named `__proto__` survives as an own key.
|
|
100
|
+
*/
|
|
101
|
+
export function mergeConfigTables(
|
|
102
|
+
base: Record<string, unknown>,
|
|
103
|
+
local: Record<string, unknown>,
|
|
104
|
+
): Record<string, unknown> {
|
|
105
|
+
const merged: Record<string, unknown> = Object.create(null)
|
|
106
|
+
const define = (key: string, value: unknown) =>
|
|
107
|
+
Object.defineProperty(merged, key, {
|
|
108
|
+
value,
|
|
109
|
+
enumerable: true,
|
|
110
|
+
writable: true,
|
|
111
|
+
configurable: true,
|
|
112
|
+
})
|
|
113
|
+
for (const key of Object.keys(base)) define(key, base[key])
|
|
114
|
+
for (const key of Object.keys(local)) {
|
|
115
|
+
const over = local[key]
|
|
116
|
+
const under = Object.hasOwn(base, key) ? base[key] : undefined
|
|
117
|
+
define(key, isTable(under) && isTable(over) ? mergeConfigTables(under, over) : over)
|
|
118
|
+
}
|
|
119
|
+
return merged
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function pathSegment(key: string): string {
|
|
123
|
+
return /^[A-Za-z0-9_-]+$/.test(key) ? key : JSON.stringify(key)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Sorted dotted leaf paths a local table sets. An array is a leaf; an empty
|
|
127
|
+
* table contributes its own path. */
|
|
128
|
+
export function localOverrideSettings(table: Record<string, unknown>): string[] {
|
|
129
|
+
const settings: string[] = []
|
|
130
|
+
const walk = (value: Record<string, unknown>, prefix: string) => {
|
|
131
|
+
for (const key of Object.keys(value)) {
|
|
132
|
+
const path = prefix === '' ? pathSegment(key) : `${prefix}.${pathSegment(key)}`
|
|
133
|
+
const child = value[key]
|
|
134
|
+
if (isTable(child) && Object.keys(child).length > 0) walk(child, path)
|
|
135
|
+
else settings.push(path)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
walk(table, '')
|
|
139
|
+
return settings.sort()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function rejectedKeys(local: ConfigText, table: Record<string, unknown>): string[] {
|
|
143
|
+
const allowed = `local overrides accept ${LOCAL_OVERRIDE_KEYS.join(', ')}`
|
|
144
|
+
const committed: string[] = []
|
|
145
|
+
const unknown: string[] = []
|
|
146
|
+
for (const key of Object.keys(table)) {
|
|
147
|
+
const classification = Object.hasOwn(LOCAL_OVERRIDE_CLASSIFICATION, key)
|
|
148
|
+
? LOCAL_OVERRIDE_CLASSIFICATION[key as ConfigRootKey]
|
|
149
|
+
: undefined
|
|
150
|
+
if (classification === 'local') continue
|
|
151
|
+
if (classification === 'committed')
|
|
152
|
+
committed.push(`${local.source}: ${key} can only be set in autobuild.toml — ${allowed}`)
|
|
153
|
+
else
|
|
154
|
+
unknown.push(
|
|
155
|
+
`${local.source}: ${JSON.stringify(key)} is not a configuration setting — ${allowed}`,
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
return [...committed, ...unknown]
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Parse `autobuild.toml` text layered with an optional local override file.
|
|
163
|
+
*
|
|
164
|
+
* The committed file is validated alone first, so its errors name it exactly
|
|
165
|
+
* as `parseConfig` would. The local file is then checked against the
|
|
166
|
+
* allowlist and merged; any failure after that point was introduced by the
|
|
167
|
+
* local layer and names the local file.
|
|
168
|
+
*/
|
|
169
|
+
export function parseLayeredConfig(
|
|
170
|
+
input: { committed: ConfigText; local?: ConfigText },
|
|
171
|
+
warn: (message: string) => void = console.error,
|
|
172
|
+
): LayeredConfig {
|
|
173
|
+
const { committed, local } = input
|
|
174
|
+
const committedTable = parseConfigTable(committed.text, committed.source)
|
|
175
|
+
admitCommittedConfig(committedTable, committed.source)
|
|
176
|
+
const committedConfig = validateConfigTable(committedTable, committed.source, warn)
|
|
177
|
+
if (local === undefined) return { config: committedConfig }
|
|
178
|
+
|
|
179
|
+
const localTable = parseConfigTable(local.text, local.source)
|
|
180
|
+
const rejected = rejectedKeys(local, localTable)
|
|
181
|
+
if (rejected.length > 0) throw new ConfigError(rejected.join('\n'))
|
|
182
|
+
|
|
183
|
+
// Deprecations were already reported for the committed file, and the local
|
|
184
|
+
// file cannot set the deprecated spelling.
|
|
185
|
+
const config = validateConfigTable(
|
|
186
|
+
mergeConfigTables(committedTable, localTable),
|
|
187
|
+
local.source,
|
|
188
|
+
() => {},
|
|
189
|
+
)
|
|
190
|
+
const settings = localOverrideSettings(localTable)
|
|
191
|
+
return settings.length > 0
|
|
192
|
+
? { config, localOverrides: { file: local.source, settings } }
|
|
193
|
+
: { config }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function missing(error: unknown): boolean {
|
|
197
|
+
const code = (error as NodeJS.ErrnoException | undefined)?.code
|
|
198
|
+
return code === 'ENOENT' || code === 'ENOTDIR'
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Read a checkout's local override file; `undefined` when it does not exist. */
|
|
202
|
+
export async function readLocalConfig(repoRoot: string): Promise<ConfigText | undefined> {
|
|
203
|
+
const source = localConfigPath(repoRoot)
|
|
204
|
+
try {
|
|
205
|
+
return { text: await Bun.file(source).text(), source }
|
|
206
|
+
} catch (error) {
|
|
207
|
+
if (missing(error)) return undefined
|
|
208
|
+
throw new ConfigError(
|
|
209
|
+
`${source} could not be read: ${error instanceof Error ? error.message : String(error)}`,
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -171,6 +171,7 @@ function parsePipeline(
|
|
|
171
171
|
// Merge policy is dispatcher-owned (composeBuildConfig), so a branch's
|
|
172
172
|
// deprecated spelling is not reported per launch; the dispatcher reports
|
|
173
173
|
// its own config's deprecations at startup and reload.
|
|
174
|
+
// Committed text only: a build's pipeline never sees a local override file.
|
|
174
175
|
config: parseConfig(content, `autobuild.toml@${label}`, () => {}),
|
|
175
176
|
}
|
|
176
177
|
} catch (error) {
|
|
@@ -414,6 +415,7 @@ export async function readVerifyPipeline(
|
|
|
414
415
|
? { ref: 'branch-head', commit: head }
|
|
415
416
|
: { ref: 'worktree-dirty' },
|
|
416
417
|
// Dispatcher-owned keys are not read from here; see parsePipeline.
|
|
418
|
+
// Committed text only: a build's pipeline never sees a local override file.
|
|
417
419
|
config: parseConfig(content, `autobuild.toml@${head}`, () => {}),
|
|
418
420
|
}
|
|
419
421
|
}
|
|
@@ -2,6 +2,7 @@ import type { z } from 'zod'
|
|
|
2
2
|
import { referenceMetadata, type ReferenceMetadata } from './reference-metadata'
|
|
3
3
|
import { BUILTIN_WORKSPACE_PROVIDER_CONFIG, configRootSchema } from './schema'
|
|
4
4
|
import { BUILD_OWNED_CONFIG_PATHS, CONFIG_RELOAD_CLASSIFICATION } from './live'
|
|
5
|
+
import { LOCAL_OVERRIDE_CLASSIFICATION } from './local'
|
|
5
6
|
|
|
6
7
|
/** Zod 4 input adapter. Unsupported nodes/checks fail closed at their TOML path. */
|
|
7
8
|
interface Definition {
|
|
@@ -202,6 +203,7 @@ export interface ReferenceField {
|
|
|
202
203
|
default: string
|
|
203
204
|
required: string
|
|
204
205
|
reload: string
|
|
206
|
+
localOverride: string
|
|
205
207
|
description: string
|
|
206
208
|
constraints: string[]
|
|
207
209
|
examples: string[]
|
|
@@ -239,10 +241,24 @@ export function reloadBehavior(path: string): string {
|
|
|
239
241
|
const owned = BUILD_OWNED_CONFIG_PATHS.some((prefix) => parts[0] === prefix)
|
|
240
242
|
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.`
|
|
241
243
|
}
|
|
244
|
+
/** Whether a field may be set in `.autobuild/local.toml`, from its root key. */
|
|
245
|
+
export function localOverrideBehavior(path: string): string {
|
|
246
|
+
const root = path.split(/[.[]/, 1)[0]!
|
|
247
|
+
if (root === 'operator')
|
|
248
|
+
return 'Local only: set in .autobuild/local.toml; rejected in autobuild.toml.'
|
|
249
|
+
const classification = Object.hasOwn(LOCAL_OVERRIDE_CLASSIFICATION, root)
|
|
250
|
+
? LOCAL_OVERRIDE_CLASSIFICATION[root as keyof typeof LOCAL_OVERRIDE_CLASSIFICATION]
|
|
251
|
+
: undefined
|
|
252
|
+
if (classification === undefined) fail(path, 'missing local-override classification')
|
|
253
|
+
return classification === 'local'
|
|
254
|
+
? 'Allowed in .autobuild/local.toml.'
|
|
255
|
+
: 'Committed only: set in autobuild.toml.'
|
|
256
|
+
}
|
|
242
257
|
export function schemaFields(
|
|
243
258
|
schema: z.ZodType,
|
|
244
259
|
path: string,
|
|
245
260
|
reload: (path: string) => string = reloadBehavior,
|
|
261
|
+
localOverride: (path: string) => string = localOverrideBehavior,
|
|
246
262
|
): ReferenceField[] {
|
|
247
263
|
const fields: ReferenceField[] = []
|
|
248
264
|
function visit(schema: z.ZodType, path: string, variant?: string): void {
|
|
@@ -266,6 +282,7 @@ export function schemaFields(
|
|
|
266
282
|
value.metadata.required ??
|
|
267
283
|
(value.optional ? 'Optional' : 'Required') + (variant ? ` when ${variant}` : ''),
|
|
268
284
|
reload: reload(path),
|
|
285
|
+
localOverride: localOverride(path),
|
|
269
286
|
description,
|
|
270
287
|
constraints: [...new Set(constraints)],
|
|
271
288
|
examples: value.metadata.examples ?? [],
|
|
@@ -345,6 +362,7 @@ export function renderFields(fields: readonly ReferenceField[]): string {
|
|
|
345
362
|
`- **Default:** \`${field.default}\``,
|
|
346
363
|
`- **Required:** ${field.required}`,
|
|
347
364
|
`- **Reload:** ${field.reload}`,
|
|
365
|
+
`- **Local override:** ${field.localOverride}`,
|
|
348
366
|
'',
|
|
349
367
|
`**Description:** ${field.description}`,
|
|
350
368
|
'',
|
|
@@ -1218,13 +1218,17 @@ export type TicketsConfig = z.infer<typeof ticketsSchema>
|
|
|
1218
1218
|
|
|
1219
1219
|
// ── [orchestrator] ──────────────────────────────────────────────────────────
|
|
1220
1220
|
//
|
|
1221
|
-
// The operator-agent gate (AUT-340).
|
|
1222
|
-
//
|
|
1223
|
-
//
|
|
1221
|
+
// The operator-agent gate (AUT-340). `enabled` has no schema default: an
|
|
1222
|
+
// unset value resolves per host through `orchestratorEnabled` (enabled when a
|
|
1223
|
+
// hosted deployment serves the project, disabled for local hosts). When the
|
|
1224
|
+
// resolved gate is off, the sandbox registry tools are absent from the binding
|
|
1225
|
+
// and no environment is ever provisioned.
|
|
1224
1226
|
|
|
1225
1227
|
export const orchestratorSandboxSchema = z.strictObject({
|
|
1226
|
-
/** Idle minutes without a sandbox tool call before the
|
|
1227
|
-
*
|
|
1228
|
+
/** Idle minutes without a sandbox tool call before the environment stops,
|
|
1229
|
+
* keeping its snapshot for the next resume: the provider timer on
|
|
1230
|
+
* vercel-sandbox (extended by every tool call), and the dispatcher tick's
|
|
1231
|
+
* janitor from journal evidence. */
|
|
1228
1232
|
idleMinutes: z.number().int().positive().default(30),
|
|
1229
1233
|
/** Names of non-secret host environment variables forwarded into the
|
|
1230
1234
|
* sandbox (during provisioning/setup and tool exec/start alike). These are
|
|
@@ -1236,28 +1240,44 @@ export const orchestratorSandboxSchema = z.strictObject({
|
|
|
1236
1240
|
|
|
1237
1241
|
documentFields(orchestratorSandboxSchema, {
|
|
1238
1242
|
idleMinutes:
|
|
1239
|
-
"Minutes without a sandbox tool call after which the dispatcher tick's janitor stops
|
|
1243
|
+
"Minutes without a sandbox tool call after which the operator sandbox stops, keeping its snapshot; a later sandbox.open resumes it. On vercel-sandbox the provider's own timer stops it, and every tool call extends that timer, so no dispatcher tick is needed; the dispatcher tick's janitor also stops an environment whose journal evidence is older, so it is no longer the only idle stop.",
|
|
1240
1244
|
environmentVariables:
|
|
1241
1245
|
'Names of non-secret host variables forwarded into the sandbox \u2014 the only non-toolchain environment it ever sees, during provisioning/setup and tool exec/start alike. Unset means none.',
|
|
1242
1246
|
})
|
|
1243
1247
|
documentSchema(orchestratorSandboxSchema.shape.environmentVariables, {
|
|
1244
1248
|
constraints:
|
|
1245
|
-
'
|
|
1249
|
+
'Unless `enabled = false`, forwarding store, forge, ticket-provider, model or Vercel credentials, or builtin-provider forbidden names, is rejected.',
|
|
1246
1250
|
})
|
|
1247
1251
|
export type OrchestratorSandboxConfig = z.infer<typeof orchestratorSandboxSchema>
|
|
1248
1252
|
|
|
1249
1253
|
export const orchestratorSchema = z.strictObject({
|
|
1250
|
-
|
|
1254
|
+
/** Unset resolves per host through `orchestratorEnabled`. Kept `undefined`
|
|
1255
|
+
* (no default) so a deposited effective config can tell "absent" from an
|
|
1256
|
+
* explicit `false`. */
|
|
1257
|
+
enabled: z.boolean().optional(),
|
|
1251
1258
|
sandbox: orchestratorSandboxSchema.prefault({}),
|
|
1252
1259
|
})
|
|
1253
1260
|
|
|
1254
1261
|
documentFields(orchestratorSchema, {
|
|
1255
1262
|
enabled:
|
|
1256
|
-
'Enables externally driven sandbox tools, archive cleanup and dispatcher idle settlement. Operators run in external agent harnesses.',
|
|
1263
|
+
'Enables externally driven sandbox tools, archive cleanup and dispatcher idle settlement. Operators run in external agent harnesses. Unset: enabled when served by a hosted deployment, disabled for local `ab mcp`, dispatch and init; an explicit value wins on every host.',
|
|
1257
1264
|
sandbox: 'Sandbox behavior knobs.',
|
|
1258
1265
|
})
|
|
1259
1266
|
export type OrchestratorConfig = z.infer<typeof orchestratorSchema>
|
|
1260
1267
|
|
|
1268
|
+
/** Where `[orchestrator]` is being resolved: a hosted deployment serving the
|
|
1269
|
+
* project, or a local host (`ab mcp`, local dispatch, init validation). */
|
|
1270
|
+
export type OrchestratorHost = 'hosted' | 'local'
|
|
1271
|
+
|
|
1272
|
+
/** The one place `[orchestrator].enabled` is resolved: an explicit value wins;
|
|
1273
|
+
* an absent value is enabled on a hosted deployment, disabled on local hosts. */
|
|
1274
|
+
export function orchestratorEnabled(
|
|
1275
|
+
config: { readonly orchestrator: Pick<OrchestratorConfig, 'enabled'> },
|
|
1276
|
+
host: OrchestratorHost,
|
|
1277
|
+
): boolean {
|
|
1278
|
+
return config.orchestrator.enabled ?? host === 'hosted'
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1261
1281
|
// ── Whole file ───────────────────────────────────────────────────────────────
|
|
1262
1282
|
|
|
1263
1283
|
export const storeSchema = z.strictObject({
|
|
@@ -1353,6 +1373,15 @@ export const hooksSchema = openMap('[hooks]', hookSchema)
|
|
|
1353
1373
|
|
|
1354
1374
|
export const configRootSchema = z.strictObject({
|
|
1355
1375
|
store: storeSchema.optional(),
|
|
1376
|
+
operator: z
|
|
1377
|
+
.strictObject({
|
|
1378
|
+
dispatcher: documentSchema(z.enum(['human', 'agent']).optional(), {
|
|
1379
|
+
description:
|
|
1380
|
+
'Who runs the dispatcher when none is running. Repository instructions take precedence.',
|
|
1381
|
+
default: 'Unset; ask who should run it.',
|
|
1382
|
+
}),
|
|
1383
|
+
})
|
|
1384
|
+
.optional(),
|
|
1356
1385
|
upgrade: z.strictObject({ automatic: z.boolean().default(true) }).prefault({}),
|
|
1357
1386
|
hooks: hooksSchema.default({}),
|
|
1358
1387
|
/** Base branch builds cut from and target (§16.1). */
|
|
@@ -1405,6 +1434,7 @@ export const configRootSchema = z.strictObject({
|
|
|
1405
1434
|
|
|
1406
1435
|
documentFields(configRootSchema, {
|
|
1407
1436
|
store: 'Optional remote BuildStore connection. Credentials live outside TOML.',
|
|
1437
|
+
operator: 'Local-only dispatcher ownership preference; set in .autobuild/local.toml.',
|
|
1408
1438
|
upgrade: 'Automatic dispatcher runtime target checks and adoption.',
|
|
1409
1439
|
hooks:
|
|
1410
1440
|
'Named observe-only hooks: the dispatcher delivers each matching watch record to a command or URL, in order and at least once.',
|
|
@@ -1911,7 +1941,12 @@ export const configSchema = normalizedConfigSchema.superRefine((config, ctx) =>
|
|
|
1911
1941
|
// `createWorkspaceProvider` (construction) and `validateInitReadiness`
|
|
1912
1942
|
// (init validation), both of which run after plugin load; no site loads
|
|
1913
1943
|
// plugins earlier to widen parse-time coverage.
|
|
1914
|
-
|
|
1944
|
+
//
|
|
1945
|
+
// No host is known at parse time, so the check resolves the gate for the
|
|
1946
|
+
// most permissive host, `hosted`: it runs unless `enabled = false`. A config
|
|
1947
|
+
// that never names `enabled` is enabled once a hosted deployment serves it,
|
|
1948
|
+
// so its forwarded names must already be valid here.
|
|
1949
|
+
if (orchestratorEnabled(config, 'hosted')) {
|
|
1915
1950
|
const providerForbidden =
|
|
1916
1951
|
BUILTIN_WORKSPACE_PROVIDER_CONFIG.get(config.workspace.provider)?.sandboxForbiddenEnv ?? []
|
|
1917
1952
|
config.orchestrator.sandbox.environmentVariables.forEach((name, index) => {
|
|
@@ -67,6 +67,8 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
67
67
|
'target.rewritten': ['dispatcher', 'kernel'],
|
|
68
68
|
'target.rewrite-cleared': ['dispatcher', 'kernel'],
|
|
69
69
|
'target.moved': ['dispatcher', 'kernel'],
|
|
70
|
+
'target.rewrite-reprovision-prepared': ['kernel'],
|
|
71
|
+
'target.rewrite-recovered': ['kernel'],
|
|
70
72
|
'head.paths-recorded': ['kernel', 'dispatcher'],
|
|
71
73
|
'restack.prepared': ['kernel', 'dispatcher'],
|
|
72
74
|
'restack.replayed': ['kernel', 'dispatcher'],
|
|
@@ -123,6 +125,7 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
123
125
|
'attempt.settled': ['dispatcher', 'kernel', 'human'],
|
|
124
126
|
'attempt.merged-unmeasured': ['dispatcher', 'kernel'],
|
|
125
127
|
'optimization.stopped': ['dispatcher', 'kernel', 'human'],
|
|
128
|
+
'optimization.activity-recorded': ['dispatcher'],
|
|
126
129
|
'attempt.ticket-rejected': ['dispatcher'],
|
|
127
130
|
'attempt.branch-deleted': ['dispatcher'],
|
|
128
131
|
'attempt.branch-cleanup-failed': ['dispatcher'],
|
|
@@ -152,6 +155,7 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
152
155
|
'execution.drain-settled': ['dispatcher'],
|
|
153
156
|
'execution.started': ['dispatcher'],
|
|
154
157
|
'execution.ended': ['dispatcher'],
|
|
158
|
+
'execution.accounted': ['dispatcher'],
|
|
155
159
|
'infrastructure.failed': ['dispatcher'],
|
|
156
160
|
'infrastructure.cleanup-attempted': ['dispatcher'],
|
|
157
161
|
'pr-summary.requested': ['kernel'],
|
|
@@ -770,6 +770,48 @@ const optimizationPayloadSchemas = {
|
|
|
770
770
|
cause: optimizationStopCauseSchema,
|
|
771
771
|
mode: optimizationStopModeSchema,
|
|
772
772
|
}),
|
|
773
|
+
/** The dispatcher accounted attempt execution facts into the node's
|
|
774
|
+
* active-hours clock (SPEC §13.1.1). `facts` are copied from attempt builds'
|
|
775
|
+
* `executionIntervals` values, sorted by `at`; `accounted` is each build's
|
|
776
|
+
* highest fact number the node has now seen; `watermark` bounds every later
|
|
777
|
+
* fact from below. `settles` closes the clock of a stopped node for good. */
|
|
778
|
+
'optimization.activity-recorded': z
|
|
779
|
+
.strictObject({
|
|
780
|
+
facts: z
|
|
781
|
+
.array(
|
|
782
|
+
z.strictObject({
|
|
783
|
+
build: z.string().min(1),
|
|
784
|
+
n: z.number().int().min(1),
|
|
785
|
+
instance: z.string().min(1),
|
|
786
|
+
kind: z.enum(['started', 'ended']),
|
|
787
|
+
at: z.iso.datetime(),
|
|
788
|
+
}),
|
|
789
|
+
)
|
|
790
|
+
.max(200),
|
|
791
|
+
accounted: z.record(z.string().min(1), z.number().int().nonnegative()),
|
|
792
|
+
released: z.array(z.string().min(1)).optional(),
|
|
793
|
+
watermark: z.iso.datetime(),
|
|
794
|
+
/** The dispatcher's first batch for this node: its clock tracks the
|
|
795
|
+
* builds of attempts that settle from here on. */
|
|
796
|
+
starts: z.literal(true).optional(),
|
|
797
|
+
settles: z.literal(true).optional(),
|
|
798
|
+
})
|
|
799
|
+
// `watermark` bounds compaction: every attempt fact stamped before it is
|
|
800
|
+
// in this batch or an earlier one. Facts may follow it.
|
|
801
|
+
.refine(
|
|
802
|
+
(batch) =>
|
|
803
|
+
batch.facts.every((fact, index) => index === 0 || batch.facts[index - 1]!.at <= fact.at),
|
|
804
|
+
'facts are sorted by at',
|
|
805
|
+
)
|
|
806
|
+
.refine(
|
|
807
|
+
(batch) =>
|
|
808
|
+
batch.facts.length > 0 ||
|
|
809
|
+
Object.keys(batch.accounted).length > 0 ||
|
|
810
|
+
(batch.released?.length ?? 0) > 0 ||
|
|
811
|
+
batch.starts === true ||
|
|
812
|
+
batch.settles === true,
|
|
813
|
+
'an activity batch records facts, accounted counts, releases, a start or a settlement',
|
|
814
|
+
),
|
|
773
815
|
/** A settled, non-accepted attempt's ticket was moved to the rejected role
|
|
774
816
|
* (SPEC §13). Removes the node digest's pending rejection. */
|
|
775
817
|
'attempt.ticket-rejected': z.strictObject({
|
|
@@ -1361,6 +1403,9 @@ export const eventPayloadSchemas = {
|
|
|
1361
1403
|
outcome: z.enum(['completed', 'stopped', 'lost', 'relaunch']),
|
|
1362
1404
|
exitCode: z.number().int().nullable().optional(),
|
|
1363
1405
|
}),
|
|
1406
|
+
/** Advisory: an optimization node has accounted this build's first `count`
|
|
1407
|
+
* execution facts, so its `executionIntervals` value may drop them. */
|
|
1408
|
+
'execution.accounted': z.strictObject({ count: z.number().int().min(1) }),
|
|
1364
1409
|
'infrastructure.failed': z.strictObject({
|
|
1365
1410
|
provider: z.string().min(1),
|
|
1366
1411
|
workspaceRef: z.string().min(1),
|
|
@@ -2057,6 +2102,58 @@ export const eventPayloadSchemas = {
|
|
|
2057
2102
|
sha: gitOid,
|
|
2058
2103
|
lineage: targetLineageSchema.optional(),
|
|
2059
2104
|
}),
|
|
2105
|
+
/** The kernel proved a leaf parked on a rewritten target had no work of
|
|
2106
|
+
* its own at local head `from` and is about to reset its branch to the
|
|
2107
|
+
* target snapshot `sha`. A later `target.rewrite-recovered` completes it; a
|
|
2108
|
+
* resuming runner completes the reset forward and never re-classifies. */
|
|
2109
|
+
'target.rewrite-reprovision-prepared': z.strictObject({
|
|
2110
|
+
branch: z.string().min(1),
|
|
2111
|
+
previousSha: gitOid,
|
|
2112
|
+
base: gitOid,
|
|
2113
|
+
from: gitOid,
|
|
2114
|
+
sha: gitOid,
|
|
2115
|
+
}),
|
|
2116
|
+
/** Closes a leaf's rewritten-target episode. `reprovisioned`: the build had
|
|
2117
|
+
* no work, so its branch was reset to the target `sha`, which becomes its
|
|
2118
|
+
* base in use. `accepted`: an operator answered the episode's
|
|
2119
|
+
* `policy/target-rewritten` escalation with `accept-target`; the rejected
|
|
2120
|
+
* base in use `base` is waived and the build's own commits restack onto
|
|
2121
|
+
* the target at the next replay boundary. `pendingLocal` names unpublished
|
|
2122
|
+
* local commits and the open occurrence whose completion publishes them. */
|
|
2123
|
+
'target.rewrite-recovered': z
|
|
2124
|
+
.strictObject({
|
|
2125
|
+
branch: z.string().min(1),
|
|
2126
|
+
previousSha: gitOid,
|
|
2127
|
+
sha: gitOid,
|
|
2128
|
+
base: gitOid,
|
|
2129
|
+
recovery: z.enum(['reprovisioned', 'accepted']),
|
|
2130
|
+
escalation: z.string().min(1).optional(),
|
|
2131
|
+
pendingLocal: z
|
|
2132
|
+
.strictObject({
|
|
2133
|
+
head: gitOid,
|
|
2134
|
+
owner: z.discriminatedUnion('kind', [
|
|
2135
|
+
z.strictObject({
|
|
2136
|
+
kind: z.literal('phase'),
|
|
2137
|
+
phase: z.enum(['implement', 'finalize', 'reconcile']),
|
|
2138
|
+
}),
|
|
2139
|
+
z.strictObject({
|
|
2140
|
+
kind: z.literal('finalize-step'),
|
|
2141
|
+
step: z.string().min(1),
|
|
2142
|
+
startedSeq: z.number().int().positive(),
|
|
2143
|
+
}),
|
|
2144
|
+
]),
|
|
2145
|
+
})
|
|
2146
|
+
.optional(),
|
|
2147
|
+
})
|
|
2148
|
+
.superRefine((value, ctx) => {
|
|
2149
|
+
if ((value.recovery === 'accepted') !== (value.escalation !== undefined))
|
|
2150
|
+
ctx.addIssue({
|
|
2151
|
+
code: 'custom',
|
|
2152
|
+
message: 'escalation is required exactly when recovery is accepted',
|
|
2153
|
+
})
|
|
2154
|
+
if (value.pendingLocal !== undefined && value.recovery !== 'accepted')
|
|
2155
|
+
ctx.addIssue({ code: 'custom', message: 'pendingLocal is allowed only when accepted' })
|
|
2156
|
+
}),
|
|
2060
2157
|
'restack.prepared': leafRestackSchema,
|
|
2061
2158
|
'restack.replayed': z.strictObject({
|
|
2062
2159
|
id: z.string().min(1),
|