@defrex/autobuild 1.0.0-beta.3 → 1.0.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 +362 -56
- package/bin/ab-dispatch-generation.ts +93 -0
- package/docs/agent-runtimes.md +157 -0
- package/docs/answering-blocked-builds.md +21 -3
- package/docs/architecture.md +166 -7
- package/docs/build-store.md +123 -0
- package/docs/builds.md +82 -0
- package/docs/cli.md +48 -0
- package/docs/configuration-overview.md +93 -0
- package/docs/configuration.md +1778 -188
- package/docs/dispatcher-hosting.md +115 -0
- package/docs/dispatcher.md +59 -0
- package/docs/forges.md +121 -0
- package/docs/getting-started.md +60 -0
- package/docs/glossary.md +60 -0
- package/docs/hosted-service.md +2 -2
- package/docs/intake.md +48 -0
- package/docs/integration-overview.md +81 -0
- package/docs/integration-tree.md +87 -2
- package/docs/integration.md +54 -0
- package/docs/operating.md +114 -0
- package/docs/operator-api.md +64 -11
- package/docs/operator-surfaces.md +90 -0
- package/docs/overview.md +49 -0
- package/docs/plugin-authoring.md +426 -0
- package/docs/remote-store-protocol.md +12 -9
- package/docs/restacking.md +4 -1
- package/docs/seams.md +66 -0
- package/docs/setup.md +28 -6
- package/docs/skills.md +119 -0
- package/docs/spec-standard.md +23 -5
- package/docs/ticket-sources.md +132 -0
- package/docs/tickets.md +69 -0
- package/docs/troubleshooting.md +111 -0
- package/docs/upgrading.md +50 -0
- package/docs/verification.md +146 -0
- package/docs/website.md +47 -5
- package/docs/workspaces.md +152 -0
- package/package.json +5 -4
- package/packages/core/src/cli/artifact.ts +5 -4
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary-direct.ts +190 -0
- package/packages/core/src/cli/binary-lifecycle.ts +46 -0
- package/packages/core/src/cli/binary.ts +24 -210
- package/packages/core/src/cli/build-control.ts +105 -2
- package/packages/core/src/cli/context.ts +41 -1
- package/packages/core/src/cli/dashboard/hand-pushed.ts +24 -0
- package/packages/core/src/cli/dashboard/handoff.ts +64 -0
- package/packages/core/src/cli/dashboard/integration-detail.ts +3 -0
- package/packages/core/src/cli/dashboard/model.ts +34 -10
- package/packages/core/src/cli/dashboard/render.ts +24 -2
- package/packages/core/src/cli/dashboard/rollback.ts +30 -0
- package/packages/core/src/cli/dispatch-args.ts +53 -0
- package/packages/core/src/cli/dispatch-crash-budget.ts +15 -0
- package/packages/core/src/cli/dispatch-frontend.ts +52 -5
- package/packages/core/src/cli/dispatch-handoff.ts +276 -0
- package/packages/core/src/cli/dispatch-launch-contract.ts +170 -0
- package/packages/core/src/cli/dispatch-launcher.ts +580 -0
- package/packages/core/src/cli/dispatch-parent-watch.ts +44 -0
- package/packages/core/src/cli/dispatch-preflight.ts +272 -0
- package/packages/core/src/cli/dispatch-presentation-job.ts +46 -0
- package/packages/core/src/cli/dispatch-presentation-ownership.ts +9 -0
- package/packages/core/src/cli/dispatch-process.ts +22 -90
- package/packages/core/src/cli/dispatch-readiness.ts +47 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +5 -1
- package/packages/core/src/cli/dispatch-runtime-cache.ts +522 -0
- package/packages/core/src/cli/dispatch-runtime-dependencies.ts +291 -0
- package/packages/core/src/cli/dispatch-runtime-use.ts +336 -0
- package/packages/core/src/cli/dispatch-upgrade-controller.ts +221 -0
- package/packages/core/src/cli/dispatch-upgrade-install.ts +258 -0
- package/packages/core/src/cli/dispatch-upgrade-source.ts +309 -0
- package/packages/core/src/cli/dispatch-upgrade-target.ts +190 -0
- package/packages/core/src/cli/dispatch.ts +604 -60
- package/packages/core/src/cli/dispatcher-liveness.ts +1 -1
- package/packages/core/src/cli/env.ts +1 -1
- package/packages/core/src/cli/harvest.ts +28 -11
- package/packages/core/src/cli/help.ts +10 -5
- package/packages/core/src/cli/installation.ts +5 -3
- package/packages/core/src/cli/main-checkout.ts +59 -0
- package/packages/core/src/cli/main.ts +15 -45
- package/packages/core/src/cli/node-verification-provenance.ts +97 -0
- package/packages/core/src/cli/repo-state.ts +3 -58
- package/packages/core/src/cli/repository-status.ts +67 -3
- package/packages/core/src/cli/runtime-spawn.ts +16 -0
- package/packages/core/src/cli/status.ts +57 -3
- package/packages/core/src/cli/upgrade-followup.ts +25 -0
- package/packages/core/src/cli/wait.ts +3 -0
- package/packages/core/src/cli/watch.ts +7 -0
- package/packages/core/src/config/landing.ts +8 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/reference-metadata.ts +31 -0
- package/packages/core/src/config/reference.ts +342 -0
- package/packages/core/src/config/roles.ts +1 -1
- package/packages/core/src/config/schema.ts +352 -10
- package/packages/core/src/distribution-packaging.ts +116 -0
- package/packages/core/src/events/catalog.ts +6 -0
- package/packages/core/src/events/payloads.ts +53 -9
- package/packages/core/src/events/policy.ts +25 -0
- package/packages/core/src/events/repository.ts +184 -4
- package/packages/core/src/events/runtime.ts +16 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +2515 -78
- package/packages/core/src/kernel/dispatch-drain-recovery.ts +121 -0
- package/packages/core/src/kernel/dispatch-status.ts +4 -2
- package/packages/core/src/kernel/dispatch-upgrade.ts +171 -0
- package/packages/core/src/kernel/dispatcher-liveness.ts +7 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +82 -0
- package/packages/core/src/kernel/guarded-forge.ts +1 -1
- package/packages/core/src/kernel/harvest.ts +98 -4
- package/packages/core/src/kernel/integration-attention.ts +20 -0
- package/packages/core/src/kernel/integration-state.ts +80 -11
- package/packages/core/src/kernel/landing-readiness.ts +6 -1
- package/packages/core/src/kernel/mixed-version.ts +34 -0
- package/packages/core/src/kernel/node-polling.ts +160 -0
- package/packages/core/src/kernel/read-facts.ts +40 -5
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer.ts +75 -14
- package/packages/core/src/kernel/service-facts.ts +11 -4
- package/packages/core/src/ontology.ts +2 -2
- package/packages/core/src/open-map.ts +3 -1
- package/packages/core/src/operator/presentation.ts +7 -0
- package/packages/core/src/operator/query.ts +6 -2
- package/packages/core/src/operator/registry.ts +1 -1
- package/packages/core/src/plugins/load.ts +4 -1
- package/packages/core/src/plugins/runtime-snapshot.ts +128 -0
- package/packages/core/src/ports/forge/contract.ts +29 -0
- package/packages/core/src/ports/forge/github.ts +189 -61
- package/packages/core/src/ports/forge-failure.ts +1 -0
- package/packages/core/src/ports/forge-telemetry.ts +3 -0
- package/packages/core/src/ports/runner/session-env.ts +1 -0
- package/packages/core/src/ports/types.ts +10 -0
- package/packages/core/src/ports/workspace/distribution-archive.ts +22 -149
- package/packages/core/src/ports/workspace/distribution-release.ts +56 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/local-build-execution.ts +37 -17
- package/packages/core/src/processes/build-child-exit.ts +5 -26
- package/packages/core/src/processes/build-runner.ts +81 -11
- package/packages/core/src/processes/dispatcher.ts +254 -23
- package/packages/core/src/processes/execution-no-progress.ts +6 -0
- package/packages/core/src/processes/execution-relaunch.ts +30 -0
- package/packages/core/src/processes/execution-settlement.ts +16 -7
- package/packages/core/src/processes/harvest-runner.ts +328 -292
- package/packages/core/src/processes/process-group-reaper.ts +17 -10
- package/packages/core/src/runtime-identity.ts +22 -3
- package/packages/core/src/store/contract.ts +153 -0
- package/packages/core/src/store/local/store.ts +197 -72
- package/packages/core/src/store/reduced-reads.ts +8 -0
- package/packages/core/src/store/reducer-value-shapes.json +5783 -3305
- package/packages/core/src/store/remote/client.ts +43 -0
- package/packages/core/src/store/repo-state-events.ts +20 -3
- package/packages/core/src/store/types.ts +7 -0
- package/skills/finalize/SKILL.md +3 -1
- package/skills/guide/SKILL.md +273 -48
- package/skills/guide/references/integration-tree.md +87 -2
- package/skills/guide/references/operator-api.md +71 -14
- package/skills/guide/references/plugin-authoring.md +231 -266
- package/skills/guide/references/remote-store-protocol.md +12 -9
- package/skills/guide/references/restacking.md +4 -1
- package/skills/guide/references/setup.md +28 -6
- package/skills/guide/references/spec-standard.md +23 -5
- package/skills/harvest/SKILL.md +4 -0
- package/skills/harvest-review/SKILL.md +4 -0
- package/skills/implement/SKILL.md +4 -2
- package/skills/operate/SKILL.md +104 -35
- package/skills/plan/SKILL.md +12 -4
- package/skills/spec/SKILL.md +20 -2
- package/skills/tickets/SKILL.md +20 -1
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,222 +1,36 @@
|
|
|
1
|
-
import { guardForge } from '../kernel/guarded-forge'
|
|
2
|
-
import { scopeLocalStoreToPhaseSession } from '../store/phase-session'
|
|
3
|
-
import { openProductionStore } from './store-opening'
|
|
4
|
-
/**
|
|
5
|
-
* Shared wiring for the `ab` process entry points. Production calls this with
|
|
6
|
-
* argv only; the repo-local hot entry may additionally supply a per-paint
|
|
7
|
-
* dashboard renderer resolver. All command routing and resource cleanup stay
|
|
8
|
-
* identical between the two entries.
|
|
9
|
-
*/
|
|
10
1
|
import { join } from 'node:path'
|
|
11
|
-
import { isSessionlessInvocation, runCli } from './main'
|
|
12
|
-
import { createUpgradeAgentResolver } from './upgrade-agent'
|
|
13
|
-
import { loadDotEnv } from './dotenv'
|
|
14
|
-
import { MissingAmbientContextError, resolveCliEnv, resolveHarvestCliEnv } from './env'
|
|
15
|
-
import { openProductionSessionStore } from './store-opening'
|
|
16
|
-
import { processTerminal, processTerminalInput, type TerminalOut } from './terminal'
|
|
17
|
-
import { installTerminalRestoreHook, type TerminalRestoreProcess } from './terminal-restore'
|
|
18
2
|
import type { DashboardRendererResolver } from './dashboard/render'
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* progress is active. Everywhere else its process must retain Node's ordinary
|
|
29
|
-
* immediate SIGINT termination. */
|
|
30
|
-
export function usesGenericSessionlessSigintHandler(command: string | undefined): boolean {
|
|
31
|
-
return command !== 'upgrade' && command !== 'update'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface SessionlessSigintBoundary {
|
|
35
|
-
on(event: 'SIGINT', listener: () => void): unknown
|
|
36
|
-
once(event: 'SIGINT', listener: () => void): unknown
|
|
37
|
-
removeListener(event: 'SIGINT', listener: () => void): unknown
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Dispatch keeps its listener through the complete child drain; ordinary
|
|
41
|
-
* sessionless commands preserve the historical one-shot cancellation. */
|
|
42
|
-
export function installSessionlessSigintHandler(
|
|
43
|
-
command: string | undefined,
|
|
44
|
-
onSigint: () => void,
|
|
45
|
-
boundary: SessionlessSigintBoundary = process,
|
|
46
|
-
): () => void {
|
|
47
|
-
if (!usesGenericSessionlessSigintHandler(command)) return () => {}
|
|
48
|
-
if (command === 'dispatch') boundary.on('SIGINT', onSigint)
|
|
49
|
-
else boundary.once('SIGINT', onSigint)
|
|
50
|
-
return () => boundary.removeListener('SIGINT', onSigint)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Install the dispatch-only process fallback around the exact CLI lifetime. */
|
|
54
|
-
export async function withDispatchTerminalRestore<T>(
|
|
55
|
-
command: string | undefined,
|
|
56
|
-
terminal: TerminalOut,
|
|
57
|
-
run: () => Promise<T>,
|
|
58
|
-
boundary: TerminalRestoreProcess = process as unknown as TerminalRestoreProcess,
|
|
59
|
-
requestStop: (signal: NodeJS.Signals) => void = () => {},
|
|
60
|
-
): Promise<T> {
|
|
61
|
-
const hook =
|
|
62
|
-
command === 'dispatch'
|
|
63
|
-
? installTerminalRestoreHook(terminal.modes, boundary, requestStop)
|
|
64
|
-
: undefined
|
|
65
|
-
try {
|
|
66
|
-
return await run()
|
|
67
|
-
} finally {
|
|
68
|
-
hook?.close()
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
3
|
+
import { loadDotEnv } from './dotenv'
|
|
4
|
+
import { parseDispatchArgs } from './dispatch-args'
|
|
5
|
+
import { launchDispatcher } from './dispatch-launcher'
|
|
6
|
+
import { DISPATCH_GENERATION_ENV } from './dispatch-launch-contract'
|
|
7
|
+
export {
|
|
8
|
+
usesGenericSessionlessSigintHandler,
|
|
9
|
+
installSessionlessSigintHandler,
|
|
10
|
+
withDispatchTerminalRestore,
|
|
11
|
+
} from './binary-lifecycle'
|
|
72
12
|
export async function runBinary(
|
|
73
13
|
argv: string[],
|
|
74
|
-
|
|
14
|
+
resolver?: DashboardRendererResolver,
|
|
75
15
|
): Promise<number> {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
workspacePath: process.cwd(),
|
|
87
|
-
processEnv: process.env,
|
|
88
|
-
exec: spawnExec,
|
|
89
|
-
stdout: (line: string) => console.log(line),
|
|
90
|
-
stderr: (line: string) => console.error(line),
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Sessionless commands resolve their own repository/store and do not require
|
|
94
|
-
// a phase tuple; durable controls also take a target slug and inspect raw
|
|
95
|
-
// AB_SESSION/AB_BUILD only to reject self-control. The flat-name set and
|
|
96
|
-
// mixed nested-command classifier live beside the switch in main.ts.
|
|
97
|
-
if (isSessionlessInvocation(argv)) {
|
|
98
|
-
// The dispatch watch loop runs until SIGINT; abort the signal so it exits
|
|
99
|
-
// cleanly at the next tick boundary (§15.6-C: in-flight leases expire and
|
|
100
|
-
// a future dispatch re-attaches).
|
|
101
|
-
const controller = new AbortController()
|
|
102
|
-
const onSigint = (): void => controller.abort('SIGINT')
|
|
103
|
-
const ownsSigint = usesGenericSessionlessSigintHandler(command)
|
|
104
|
-
const terminal = processTerminal(process.stdout)
|
|
105
|
-
const removeSigint = installSessionlessSigintHandler(command, onSigint)
|
|
16
|
+
delete process.env.AB_DISPATCH_LAUNCH_CONTEXT
|
|
17
|
+
delete process.env[DISPATCH_GENERATION_ENV]
|
|
18
|
+
if (argv[0] !== '--version') loadDotEnv(join(process.cwd(), '.env'), process.env)
|
|
19
|
+
delete process.env.AB_DISPATCH_LAUNCH_CONTEXT
|
|
20
|
+
delete process.env[DISPATCH_GENERATION_ENV]
|
|
21
|
+
if (
|
|
22
|
+
argv[0] === 'dispatch' &&
|
|
23
|
+
!(argv.length === 2 && argv[1] === '--help') &&
|
|
24
|
+
resolver === undefined
|
|
25
|
+
) {
|
|
106
26
|
try {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
terminal,
|
|
110
|
-
() =>
|
|
111
|
-
runCli(argv, {
|
|
112
|
-
...unscopedDeps,
|
|
113
|
-
...(ownsSigint ? { signal: controller.signal } : {}),
|
|
114
|
-
// `ab dispatch`'s dashboard seam: interactive iff stdout is a real
|
|
115
|
-
// TTY, so a pipe or redirect silently gets plain output.
|
|
116
|
-
terminal,
|
|
117
|
-
input: processTerminalInput(process.stdin),
|
|
118
|
-
...(command === 'init'
|
|
119
|
-
? { initInteractive: process.stdin.isTTY === true && process.stdout.isTTY === true }
|
|
120
|
-
: {}),
|
|
121
|
-
upgradeResolverFactory: createUpgradeAgentResolver,
|
|
122
|
-
...(resolveDashboardRenderer !== undefined ? { resolveDashboardRenderer } : {}),
|
|
123
|
-
}),
|
|
124
|
-
process as unknown as TerminalRestoreProcess,
|
|
125
|
-
(signal) => controller.abort(signal),
|
|
126
|
-
)
|
|
127
|
-
} finally {
|
|
128
|
-
removeSigint()
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (command === 'harvest') {
|
|
133
|
-
let harvestEnv: ReturnType<typeof resolveHarvestCliEnv>
|
|
134
|
-
try {
|
|
135
|
-
harvestEnv = resolveHarvestCliEnv(process.env)
|
|
27
|
+
const args = parseDispatchArgs(argv.slice(1), process.env)
|
|
28
|
+
if (!args.once && !args.repository) return await launchDispatcher(argv)
|
|
136
29
|
} catch (error) {
|
|
137
|
-
if (error instanceof MissingAmbientContextError) {
|
|
138
|
-
return runCli(argv, unscopedDeps)
|
|
139
|
-
}
|
|
140
30
|
console.error(error instanceof Error ? error.message : String(error))
|
|
141
31
|
return 1
|
|
142
32
|
}
|
|
143
|
-
const store = openProductionSessionStore(harvestEnv)
|
|
144
|
-
try {
|
|
145
|
-
return await runCli(argv, {
|
|
146
|
-
...unscopedDeps,
|
|
147
|
-
store,
|
|
148
|
-
harvestEnv,
|
|
149
|
-
ids: randomIds(),
|
|
150
|
-
clock: systemClock,
|
|
151
|
-
})
|
|
152
|
-
} finally {
|
|
153
|
-
await store.close()
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
let cliEnv: ReturnType<typeof resolveCliEnv>
|
|
158
|
-
try {
|
|
159
|
-
cliEnv = resolveCliEnv(process.env)
|
|
160
|
-
} catch (error) {
|
|
161
|
-
if (error instanceof MissingAmbientContextError) {
|
|
162
|
-
return runCli(argv, unscopedDeps)
|
|
163
|
-
}
|
|
164
|
-
console.error(error instanceof Error ? error.message : String(error))
|
|
165
|
-
return 1
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// A scoped phase process is composed from the build worktree's immutable
|
|
169
|
-
// configuration just like dispatch. Load and select the forge before opening
|
|
170
|
-
// the store so plugin failures cannot partially execute terminal plumbing.
|
|
171
|
-
// Guest tolerance (AUT-517), always on here: in checkout mode `ab dispatch`
|
|
172
|
-
// already failed startup if a configured plugin did not resolve, and
|
|
173
|
-
// origin-mode phase processes only run inside guests — so an unresolvable
|
|
174
|
-
// bare specifier here can only be the provider-plugin case, which a phase
|
|
175
|
-
// process (never constructing workspace providers) may skip.
|
|
176
|
-
let forge: Awaited<ReturnType<typeof createForge>>
|
|
177
|
-
try {
|
|
178
|
-
const repoRoot = process.cwd()
|
|
179
|
-
const packageRoot = await resolveMainRepo(repoRoot, spawnExec)
|
|
180
|
-
const config = await loadConfig(join(repoRoot, 'autobuild.toml'))
|
|
181
|
-
const plugins = await loadPlugins(config.plugins, repoRoot, {
|
|
182
|
-
packageRoot,
|
|
183
|
-
guest: true,
|
|
184
|
-
})
|
|
185
|
-
forge = await createForge({
|
|
186
|
-
name: config.forge,
|
|
187
|
-
registry: plugins,
|
|
188
|
-
env: process.env,
|
|
189
|
-
repoRoot,
|
|
190
|
-
})
|
|
191
|
-
} catch (error) {
|
|
192
|
-
console.error(error instanceof Error ? error.message : String(error))
|
|
193
|
-
return 1
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const kernelStore = openProductionStore(cliEnv.store, cliEnv.token)
|
|
197
|
-
const store = scopeLocalStoreToPhaseSession(kernelStore, {
|
|
198
|
-
kind: 'build',
|
|
199
|
-
id: cliEnv.build,
|
|
200
|
-
session: cliEnv.session,
|
|
201
|
-
})
|
|
202
|
-
try {
|
|
203
|
-
const record = await store.getBuild(cliEnv.build)
|
|
204
|
-
if (record)
|
|
205
|
-
forge = guardForge(forge, {
|
|
206
|
-
store: kernelStore,
|
|
207
|
-
repo: record.repo,
|
|
208
|
-
name: forge.name,
|
|
209
|
-
wait: true,
|
|
210
|
-
})
|
|
211
|
-
return await runCli(argv, {
|
|
212
|
-
...unscopedDeps,
|
|
213
|
-
store,
|
|
214
|
-
env: cliEnv,
|
|
215
|
-
forge,
|
|
216
|
-
ids: randomIds(),
|
|
217
|
-
clock: systemClock,
|
|
218
|
-
})
|
|
219
|
-
} finally {
|
|
220
|
-
await store.close()
|
|
221
33
|
}
|
|
34
|
+
const { runDirectBinary } = await import('./binary-direct')
|
|
35
|
+
return runDirectBinary(argv, resolver)
|
|
222
36
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { integrationFailed } from '../kernel/integration-state'
|
|
1
2
|
import { landPreconditions } from '../kernel/landing-readiness'
|
|
2
3
|
import { observeIntegration } from '../kernel/integration-completeness'
|
|
3
4
|
import type { TicketSource } from '../ports/types'
|
|
@@ -92,6 +93,7 @@ export type BuildControlResult =
|
|
|
92
93
|
count: number
|
|
93
94
|
resolution: 'guidance' | 'retry' | 'dismiss-finding' | 'revise-spec'
|
|
94
95
|
resumed: boolean
|
|
96
|
+
nodeRevision?: boolean
|
|
95
97
|
specRev?: number
|
|
96
98
|
authorizedEarlier?: boolean
|
|
97
99
|
remainingOpen?: number
|
|
@@ -370,6 +372,35 @@ export function decideRevise(
|
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
|
|
375
|
+
function assertNodeRevisionEligible(slug: string, state: BuildState): void {
|
|
376
|
+
const restack = state.nodeRestack
|
|
377
|
+
if (
|
|
378
|
+
state.kind !== 'node' ||
|
|
379
|
+
!state.nodeOpened ||
|
|
380
|
+
(state.status !== 'collecting' && !(state.status === 'blocked' && integrationFailed(state))) ||
|
|
381
|
+
terminalSignal(state) ||
|
|
382
|
+
state.pendingCommands.length ||
|
|
383
|
+
state.openEscalations.length ||
|
|
384
|
+
state.currentPhase ||
|
|
385
|
+
state.sessions.open.length ||
|
|
386
|
+
state.sessions.suspended.length ||
|
|
387
|
+
restack?.active ||
|
|
388
|
+
restack?.parentRequest ||
|
|
389
|
+
restack?.parentChange ||
|
|
390
|
+
Object.keys(restack?.requests ?? {}).length ||
|
|
391
|
+
state.integration?.intent ||
|
|
392
|
+
state.landing?.nativeEnablePending ||
|
|
393
|
+
state.landing?.native?.enabled ||
|
|
394
|
+
state.landing?.forgeMerge ||
|
|
395
|
+
state.landing?.command?.kind === 'land'
|
|
396
|
+
) {
|
|
397
|
+
throw new BuildControlError(
|
|
398
|
+
'inactive',
|
|
399
|
+
`build "${slug}" cannot revise its node spec while work or controls are active; wait for idle collection or failed verification and retry`,
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
373
404
|
function throwRefusal(decision: Extract<ReviseDecision, { kind: 'refuse' }>): never {
|
|
374
405
|
throw new BuildControlError(decision.code, decision.message)
|
|
375
406
|
}
|
|
@@ -610,7 +641,17 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
610
641
|
: reviewRoundLimitEscalation(opts.slug, selectedOpen(state, captured))
|
|
611
642
|
|
|
612
643
|
if (opts.action.resolve?.kind === 'revise-spec') {
|
|
613
|
-
const
|
|
644
|
+
const nodeRevision =
|
|
645
|
+
state.kind === 'node' &&
|
|
646
|
+
captured === undefined &&
|
|
647
|
+
state.openEscalations.length === 0 &&
|
|
648
|
+
!state.answeredEscalations.some(
|
|
649
|
+
(item) => item.resolution === 'revise-spec' && item.answeredSeq > state.restartSince,
|
|
650
|
+
)
|
|
651
|
+
if (nodeRevision) assertNodeRevisionEligible(opts.slug, state)
|
|
652
|
+
const initial = nodeRevision
|
|
653
|
+
? { kind: 'node' as const }
|
|
654
|
+
: decideRevise(opts.slug, state, captured)
|
|
614
655
|
if (initial.kind === 'refuse') throwRefusal(initial)
|
|
615
656
|
|
|
616
657
|
let artifact: ArtifactRef
|
|
@@ -674,6 +715,62 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
674
715
|
artifact = { kind: 'spec', rev: deposited.revision }
|
|
675
716
|
}
|
|
676
717
|
|
|
718
|
+
if (nodeRevision) {
|
|
719
|
+
const holder = `spec-revision-${crypto.randomUUID()}`
|
|
720
|
+
if (!(await opts.store.claimNodeWriter(opts.slug, holder, 60_000))) {
|
|
721
|
+
throw new BuildControlError('inactive', 'Node writer is busy; retry the spec revision')
|
|
722
|
+
}
|
|
723
|
+
let runnerLease = false
|
|
724
|
+
try {
|
|
725
|
+
// Fence attachment as well as branch writers while publishing.
|
|
726
|
+
// Lease expiry is evaluated by the store's clock, never client time.
|
|
727
|
+
runnerLease = await opts.store.claimLease(opts.slug, holder, 60_000)
|
|
728
|
+
if (!runnerLease)
|
|
729
|
+
throw new BuildControlError(
|
|
730
|
+
'inactive',
|
|
731
|
+
'Node runner is busy; retry the spec revision',
|
|
732
|
+
)
|
|
733
|
+
const fresh = (await readBuildFacts(opts.store, opts.slug)).value.state
|
|
734
|
+
assertNodeRevisionEligible(opts.slug, fresh)
|
|
735
|
+
// Do not adopt intervening work or an unrelated escalation as authority.
|
|
736
|
+
if (fresh.lastSeq !== state.lastSeq) {
|
|
737
|
+
throw new BuildControlError(
|
|
738
|
+
'inactive',
|
|
739
|
+
'Build changed while preparing the spec; retry. Deposited artifacts remain inert.',
|
|
740
|
+
)
|
|
741
|
+
}
|
|
742
|
+
const published = await opts.store.appendIfCurrent(opts.slug, fresh.lastSeq, {
|
|
743
|
+
actor: KERNEL,
|
|
744
|
+
type: 'spec.revised',
|
|
745
|
+
payload: {
|
|
746
|
+
artifact,
|
|
747
|
+
operator: { user, ...(opts.via ? { via: opts.via } : {}) },
|
|
748
|
+
...(assets !== undefined ? { assets } : {}),
|
|
749
|
+
},
|
|
750
|
+
})
|
|
751
|
+
if (!published)
|
|
752
|
+
throw new BuildControlError(
|
|
753
|
+
'inactive',
|
|
754
|
+
'Build changed while publishing the spec; retry. Deposited artifacts remain inert.',
|
|
755
|
+
)
|
|
756
|
+
return {
|
|
757
|
+
kind: 'answered',
|
|
758
|
+
slug: opts.slug,
|
|
759
|
+
count: 0,
|
|
760
|
+
resolution: 'revise-spec',
|
|
761
|
+
resumed: false,
|
|
762
|
+
nodeRevision: true,
|
|
763
|
+
specRev: artifact.rev,
|
|
764
|
+
}
|
|
765
|
+
} finally {
|
|
766
|
+
try {
|
|
767
|
+
if (runnerLease) await opts.store.releaseLease(opts.slug, holder)
|
|
768
|
+
} finally {
|
|
769
|
+
await opts.store.releaseNodeWriter(opts.slug, holder)
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
677
774
|
// Re-read at the last durable moment. The PR janitor and abort
|
|
678
775
|
// acknowledgement may still write while a blocked build is parked.
|
|
679
776
|
const freshState = (await readBuildFacts(opts.store, opts.slug)).value.state
|
|
@@ -685,7 +782,12 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
685
782
|
assets = decision.assets
|
|
686
783
|
authorizedEarlier = true
|
|
687
784
|
}
|
|
688
|
-
const answer =
|
|
785
|
+
const answer =
|
|
786
|
+
guidance === ''
|
|
787
|
+
? state.kind === 'node'
|
|
788
|
+
? 'Operator replaced the node spec; recollect and verify'
|
|
789
|
+
: SPEC_REVISION_ANSWER
|
|
790
|
+
: guidance
|
|
689
791
|
const alsoPaused = freshState.status === 'paused'
|
|
690
792
|
|
|
691
793
|
// Answers must precede spec.revised: the engine parks an answered
|
|
@@ -727,6 +829,7 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
727
829
|
count: decision.open.length,
|
|
728
830
|
resolution: 'revise-spec',
|
|
729
831
|
resumed: alsoPaused,
|
|
832
|
+
...(state.kind === 'node' ? { nodeRevision: true } : {}),
|
|
730
833
|
...(after.specRev !== undefined ? { specRev: after.specRev } : {}),
|
|
731
834
|
...(authorizedEarlier ? { authorizedEarlier: true } : {}),
|
|
732
835
|
...(signal !== undefined ? { terminalSignal: signal } : {}),
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectNodeVerificationProvenance,
|
|
3
|
+
type NodeVerificationIndex,
|
|
4
|
+
} from './node-verification-provenance'
|
|
1
5
|
import { compatibilityDiagnostic } from '../kernel/mixed-version'
|
|
2
6
|
import { readBuildFacts, type CurrentBuildFacts } from '../store/reduced-reads'
|
|
3
7
|
/**
|
|
@@ -99,6 +103,7 @@ export interface ContextManifest {
|
|
|
99
103
|
commitRange?: CommitRange
|
|
100
104
|
/** Reconcile: `{baseSha}` freshly recorded by this attempt's phase start (§15.7). */
|
|
101
105
|
conflict?: { baseSha: string }
|
|
106
|
+
nodeVerification?: Omit<NodeVerificationIndex, 'commits'> & { indexPath: string }
|
|
102
107
|
nodeChange?: {
|
|
103
108
|
owner: string
|
|
104
109
|
transaction: string
|
|
@@ -219,12 +224,13 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
219
224
|
phase === 'implement' || phase === 'reconcile' ? locate(`${phase}-notes.md`) : undefined
|
|
220
225
|
const materialized: Record<string, MaterializedEntry> = {}
|
|
221
226
|
|
|
222
|
-
async function writeDerived(desiredPath: string, content: string): Promise<
|
|
227
|
+
async function writeDerived(desiredPath: string, content: string): Promise<string> {
|
|
223
228
|
const relPath = locate(desiredPath)
|
|
224
229
|
const target = join(abDir, relPath)
|
|
225
230
|
await mkdir(dirname(target), { recursive: true })
|
|
226
231
|
await writeFile(target, content)
|
|
227
232
|
materialized[relPath] = 'derived'
|
|
233
|
+
return `.ab/${relPath}`
|
|
228
234
|
}
|
|
229
235
|
|
|
230
236
|
/** Latest rev when `rev` omitted; silently skips absent kinds — the tree is
|
|
@@ -457,6 +463,40 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
457
463
|
manifest.commitRange = state.implement.commits
|
|
458
464
|
}
|
|
459
465
|
|
|
466
|
+
if (isVerifyPhase(phase) && state.kind === 'node' && state.integration?.cycle) {
|
|
467
|
+
if (!gitWorkspace)
|
|
468
|
+
throw new Error('node verification provenance requires a Git workspace and exec')
|
|
469
|
+
const record = await store.getBuild(build)
|
|
470
|
+
if (!record) throw new Error(`node verification build ${build} is missing`)
|
|
471
|
+
const contributionBase =
|
|
472
|
+
state.nodeRestack?.contributionBoundaries?.[manifest.commitRange!.head] ??
|
|
473
|
+
state.nodeRestack?.contributionBase ??
|
|
474
|
+
state.nodeOpened?.sha
|
|
475
|
+
if (!contributionBase)
|
|
476
|
+
throw new Error(
|
|
477
|
+
`node verification ${build} is missing its durable contribution boundary; restore node opening evidence`,
|
|
478
|
+
)
|
|
479
|
+
const { index, specs } = await collectNodeVerificationProvenance(
|
|
480
|
+
store,
|
|
481
|
+
record.repo,
|
|
482
|
+
manifest.commitRange!,
|
|
483
|
+
{ exec: deps.exec!, workspacePath },
|
|
484
|
+
{ contributionBase, foreignAliases: state.nodeRestack?.foreignAliases },
|
|
485
|
+
)
|
|
486
|
+
for (const contribution of index.contributions) {
|
|
487
|
+
contribution.specPath = await writeDerived(
|
|
488
|
+
`contributions/${contribution.build}/spec.md`,
|
|
489
|
+
specs.get(contribution.build)!,
|
|
490
|
+
)
|
|
491
|
+
}
|
|
492
|
+
const indexPath = await writeDerived(
|
|
493
|
+
'node-verification.json',
|
|
494
|
+
`${JSON.stringify(index, null, 2)}\n`,
|
|
495
|
+
)
|
|
496
|
+
const { commits: _commits, ...metadata } = index
|
|
497
|
+
manifest.nodeVerification = { ...metadata, indexPath }
|
|
498
|
+
}
|
|
499
|
+
|
|
460
500
|
if (phase === 'reconcile' && state.nodeRestack?.conflict) {
|
|
461
501
|
const node = state.nodeRestack
|
|
462
502
|
const conflict = node.conflict!
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { originalForeign } from '../../kernel/change-presence'
|
|
2
|
+
import type { NodeRestackState } from '../../kernel/node-restack-state'
|
|
3
|
+
|
|
4
|
+
export const handPushedLabel = 'Hand-pushed changes'
|
|
5
|
+
export interface HandPushedChange {
|
|
6
|
+
sha: string
|
|
7
|
+
originalSha: string
|
|
8
|
+
}
|
|
9
|
+
export function projectHandPushed(
|
|
10
|
+
node: NodeRestackState | undefined,
|
|
11
|
+
): HandPushedChange[] | undefined {
|
|
12
|
+
if (!node?.inventory) return undefined
|
|
13
|
+
const aliases = new Map(Object.entries(node.foreignAliases ?? {}))
|
|
14
|
+
return node.inventory.foreign.map((sha) => ({ sha, originalSha: originalForeign(sha, aliases) }))
|
|
15
|
+
}
|
|
16
|
+
export function handPushedText(changes: HandPushedChange[] | undefined): string {
|
|
17
|
+
return (
|
|
18
|
+
changes
|
|
19
|
+
?.map(({ sha, originalSha }) =>
|
|
20
|
+
sha === originalSha ? sha : `${sha} (original ${originalSha})`,
|
|
21
|
+
)
|
|
22
|
+
.join(', ') || (changes ? 'none' : 'unknown')
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { RuntimeIdentity } from '../../events/runtime'
|
|
2
|
+
import type { DispatchUpgradeState } from '../../kernel/dispatch-upgrade'
|
|
3
|
+
import type { DashboardBuild } from './model'
|
|
4
|
+
import { displayText } from './cells'
|
|
5
|
+
|
|
6
|
+
export interface DashboardHandoff {
|
|
7
|
+
run: string
|
|
8
|
+
successor?: string
|
|
9
|
+
correlation: string
|
|
10
|
+
from: RuntimeIdentity
|
|
11
|
+
to: RuntimeIdentity
|
|
12
|
+
mode: 'drain' | 'cutover'
|
|
13
|
+
deadline?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Only accepted durable facts determine visibility; takeover and time do not retire a run. */
|
|
17
|
+
export function projectHandoffs(state: DispatchUpgradeState): {
|
|
18
|
+
handoffs: DashboardHandoff[]
|
|
19
|
+
draining: ReadonlySet<string>
|
|
20
|
+
} {
|
|
21
|
+
const runs = Object.values(state.runs)
|
|
22
|
+
.filter((run) => run.handoff && !run.completed)
|
|
23
|
+
.sort(
|
|
24
|
+
(a, b) =>
|
|
25
|
+
a.handoff!.seq - b.handoff!.seq ||
|
|
26
|
+
a.handoff!.payload.run.localeCompare(b.handoff!.payload.run),
|
|
27
|
+
)
|
|
28
|
+
const draining = new Set<string>()
|
|
29
|
+
const handoffs = runs.map((run): DashboardHandoff => {
|
|
30
|
+
const fact = run.handoff!.payload
|
|
31
|
+
const mode = fact.mode ?? 'cutover'
|
|
32
|
+
if (mode === 'drain') for (const slug of Object.keys(run.outstanding)) draining.add(slug)
|
|
33
|
+
return {
|
|
34
|
+
run: fact.run,
|
|
35
|
+
correlation: fact.correlation,
|
|
36
|
+
from: fact.from,
|
|
37
|
+
to: fact.to,
|
|
38
|
+
mode,
|
|
39
|
+
...(fact.successor !== undefined ? { successor: fact.successor } : {}),
|
|
40
|
+
...(run.deadline !== undefined ? { deadline: run.deadline } : {}),
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
return { handoffs, draining }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function enrichDrainingRow(
|
|
47
|
+
row: DashboardBuild,
|
|
48
|
+
draining: ReadonlySet<string>,
|
|
49
|
+
): DashboardBuild {
|
|
50
|
+
if (row.draining === undefined && !draining.has(row.slug)) return row
|
|
51
|
+
const { draining: _previous, ...fresh } = row
|
|
52
|
+
return { ...fresh, ...(draining.has(row.slug) ? { draining: true } : {}) }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function handoffRuntime(runtime: RuntimeIdentity): string {
|
|
56
|
+
const version = runtime.version && runtime.version !== 'unknown' ? runtime.version : undefined
|
|
57
|
+
const commit =
|
|
58
|
+
runtime.commit && runtime.commit !== 'unknown' ? runtime.commit.slice(0, 12) : undefined
|
|
59
|
+
return displayText([version, commit].filter(Boolean).join(' ') || 'unknown')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function formatHandoff(handoff: DashboardHandoff): string {
|
|
63
|
+
return `handoff ${handoffRuntime(handoff.from)} to ${handoffRuntime(handoff.to)}; mode ${handoff.mode}; drain deadline ${handoff.deadline ?? 'unknown'}`
|
|
64
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { projectHandPushed, type HandPushedChange } from './hand-pushed'
|
|
1
2
|
import type { Config } from '../../config/schema'
|
|
2
3
|
import type { BuildRecord } from '../../store/types'
|
|
3
4
|
import type { BuildState } from '../../kernel/reducer'
|
|
@@ -21,6 +22,7 @@ export interface IntegrationChild {
|
|
|
21
22
|
landed: boolean
|
|
22
23
|
}
|
|
23
24
|
export interface IntegrationDetail {
|
|
25
|
+
handPushedCommits?: HandPushedChange[]
|
|
24
26
|
parentDistance?: string
|
|
25
27
|
destination: string
|
|
26
28
|
branch: string
|
|
@@ -117,6 +119,7 @@ export function projectIntegrationDetail(
|
|
|
117
119
|
(restack.active && restack.replay?.conflicted ? restack.replay : undefined)
|
|
118
120
|
const mode = nodeLandingPolicyDisplay(state, config.landing)
|
|
119
121
|
return {
|
|
122
|
+
handPushedCommits: projectHandPushed(state.nodeRestack),
|
|
120
123
|
parentDistance: row.parentDistance,
|
|
121
124
|
destination: `${row.destination}${state.target ? '' : ' (the configured base branch)'}`,
|
|
122
125
|
branch: record.branch ?? state.nodeOpening?.branch ?? 'unknown branch',
|