@defrex/autobuild 0.14.0 → 1.0.0-beta.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 +4 -2
- package/SPEC.md +654 -98
- package/docs/architecture.md +226 -5
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +112 -12
- package/docs/hosted-service.md +18 -0
- package/docs/integration-tree.md +117 -0
- package/docs/landing-policy.md +150 -0
- package/docs/mcp.md +24 -0
- package/docs/migration-1.0.md +68 -0
- package/docs/operator-api.md +19 -8
- package/docs/remote-store-protocol.md +30 -7
- package/docs/remote-ticket-protocol.md +26 -5
- package/docs/restacking.md +79 -0
- package/docs/setup.md +49 -6
- package/docs/ticket-dependencies.md +69 -0
- package/docs/ticket-migration.md +8 -0
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +25 -2
- package/packages/core/src/cli/build-control.ts +65 -41
- package/packages/core/src/cli/context.ts +54 -2
- package/packages/core/src/cli/dashboard/actions.ts +6 -3
- package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
- package/packages/core/src/cli/dashboard/live.ts +5 -0
- package/packages/core/src/cli/dashboard/model.ts +142 -18
- package/packages/core/src/cli/dashboard/poll.ts +15 -9
- package/packages/core/src/cli/dashboard/refresh.ts +176 -0
- package/packages/core/src/cli/dashboard/render.ts +78 -28
- package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
- package/packages/core/src/cli/dashboard/selection.ts +7 -1
- package/packages/core/src/cli/dashboard/tree.ts +107 -0
- package/packages/core/src/cli/dispatch-frontend.ts +156 -109
- package/packages/core/src/cli/dispatch.ts +250 -136
- package/packages/core/src/cli/dispatcher-liveness.ts +15 -2
- package/packages/core/src/cli/help.ts +49 -32
- package/packages/core/src/cli/init-validation.ts +43 -2
- package/packages/core/src/cli/keyboard.ts +6 -0
- package/packages/core/src/cli/landings.ts +18 -0
- package/packages/core/src/cli/main.ts +49 -15
- package/packages/core/src/cli/mcp.ts +9 -0
- package/packages/core/src/cli/publication-settlement.ts +168 -2
- package/packages/core/src/cli/repository-status.ts +11 -0
- package/packages/core/src/cli/status.ts +72 -5
- package/packages/core/src/cli/terminal-restore.ts +54 -0
- package/packages/core/src/cli/terminal.ts +16 -2
- package/packages/core/src/cli/terminals.ts +98 -79
- package/packages/core/src/cli/ticket-editor.ts +10 -3
- package/packages/core/src/cli/ticket.ts +113 -18
- package/packages/core/src/cli/upgrade-commit.ts +4 -0
- package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
- package/packages/core/src/cli/upgrade-landing.ts +69 -0
- package/packages/core/src/cli/upgrade.ts +16 -0
- package/packages/core/src/cli/wait.ts +115 -19
- package/packages/core/src/cli/watch.ts +51 -12
- package/packages/core/src/config/landing.ts +22 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/schema.ts +3 -0
- package/packages/core/src/events/catalog.ts +48 -3
- package/packages/core/src/events/payloads.ts +295 -6
- package/packages/core/src/events/repository.ts +31 -0
- package/packages/core/src/integration/harness.ts +10 -0
- package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +1030 -239
- package/packages/core/src/kernel/auto-merge-default.ts +1 -0
- package/packages/core/src/kernel/auto-merge.ts +12 -3
- package/packages/core/src/kernel/build-identity.ts +94 -0
- package/packages/core/src/kernel/change-presence.ts +179 -0
- package/packages/core/src/kernel/dispatch-status.ts +17 -1
- package/packages/core/src/kernel/engine.ts +89 -2
- package/packages/core/src/kernel/generators/build-log.ts +23 -0
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +11 -0
- package/packages/core/src/kernel/integration-completeness.ts +81 -0
- package/packages/core/src/kernel/integration-landing.ts +263 -0
- package/packages/core/src/kernel/integration-stack.ts +36 -0
- package/packages/core/src/kernel/integration-state.ts +135 -0
- package/packages/core/src/kernel/landing-policy.ts +47 -0
- package/packages/core/src/kernel/landing-publication.ts +41 -0
- package/packages/core/src/kernel/landing-readiness.ts +67 -0
- package/packages/core/src/kernel/landing-state.ts +96 -0
- package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
- package/packages/core/src/kernel/log-index.ts +35 -5
- package/packages/core/src/kernel/node-landing.ts +439 -0
- package/packages/core/src/kernel/node-parent.ts +184 -0
- package/packages/core/src/kernel/node-restack-state.ts +191 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
- package/packages/core/src/kernel/node-restack.ts +274 -0
- package/packages/core/src/kernel/read-facts.ts +70 -3
- package/packages/core/src/kernel/reconcile-head.ts +51 -0
- package/packages/core/src/kernel/reconcile-restack.ts +560 -0
- package/packages/core/src/kernel/reducer-registry.ts +16 -0
- package/packages/core/src/kernel/reducer.ts +121 -6
- package/packages/core/src/kernel/snapshot-parent.ts +33 -0
- package/packages/core/src/ontology.ts +9 -1
- package/packages/core/src/operator/annotations.ts +12 -0
- package/packages/core/src/operator/control.ts +6 -0
- package/packages/core/src/operator/index.ts +4 -0
- package/packages/core/src/operator/landings.ts +35 -0
- package/packages/core/src/operator/presentation.ts +1 -0
- package/packages/core/src/operator/protocol.ts +12 -3
- package/packages/core/src/operator/query.ts +3 -1
- package/packages/core/src/operator/registry.ts +48 -19
- package/packages/core/src/operator/requests.ts +1 -8
- package/packages/core/src/operator/tickets.ts +55 -9
- package/packages/core/src/ports/forge/contract.ts +91 -3
- package/packages/core/src/ports/forge/fake.ts +142 -4
- package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
- package/packages/core/src/ports/forge/github-readiness.ts +421 -0
- package/packages/core/src/ports/forge/github.ts +631 -35
- package/packages/core/src/ports/forge/local-git.ts +119 -5
- package/packages/core/src/ports/forge/readiness.ts +99 -0
- package/packages/core/src/ports/tickets/contract.ts +41 -0
- package/packages/core/src/ports/tickets/create.ts +8 -1
- package/packages/core/src/ports/tickets/fake.ts +32 -1
- package/packages/core/src/ports/tickets/file-codec.ts +7 -0
- package/packages/core/src/ports/tickets/file.ts +18 -1
- package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
- package/packages/core/src/ports/tickets/linear.ts +124 -4
- package/packages/core/src/ports/tickets/migration.ts +25 -1
- package/packages/core/src/ports/tickets/operations.ts +7 -2
- package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
- package/packages/core/src/ports/tickets/remote.ts +10 -1
- package/packages/core/src/ports/tickets/revision.ts +3 -1
- package/packages/core/src/ports/tickets/tree.ts +148 -0
- package/packages/core/src/ports/tickets/update.ts +15 -2
- package/packages/core/src/ports/types.ts +135 -5
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
- package/packages/core/src/processes/build-runner.ts +530 -23
- package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
- package/packages/core/src/processes/dispatcher.ts +2145 -203
- package/packages/core/src/processes/execution-no-progress.ts +46 -1
- package/packages/core/src/processes/publication-state.ts +30 -5
- package/packages/core/src/processes/repo-view.ts +21 -2
- package/packages/core/src/store/build-scope.ts +18 -0
- package/packages/core/src/store/contract.ts +658 -0
- package/packages/core/src/store/digest.ts +52 -4
- package/packages/core/src/store/local/schema.ts +25 -13
- package/packages/core/src/store/local/store.ts +117 -1
- package/packages/core/src/store/memory.ts +62 -1
- package/packages/core/src/store/phase-session.ts +17 -0
- package/packages/core/src/store/reduced-reads.ts +2 -1
- package/packages/core/src/store/reducer-value-shapes.json +10707 -6440
- package/packages/core/src/store/remote/client.ts +44 -0
- package/packages/core/src/store/remote/compatibility.ts +19 -9
- package/packages/core/src/store/remote/protocol.ts +11 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/session-handle.ts +15 -0
- package/packages/core/src/store/subscribe.ts +1 -1
- package/packages/core/src/store/types.ts +32 -4
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/reduced-read-budget.ts +48 -8
- package/packages/core/src/testing/refresh-scheduler.ts +32 -0
- package/skills/guide/SKILL.md +110 -61
- package/skills/guide/references/integration-tree.md +117 -0
- package/skills/guide/references/landing-policy.md +150 -0
- package/skills/guide/references/migration-1.0.md +68 -0
- package/skills/guide/references/operator-api.md +12 -5
- package/skills/guide/references/plugin-authoring.md +34 -0
- package/skills/guide/references/remote-store-protocol.md +30 -7
- package/skills/guide/references/remote-ticket-protocol.md +26 -5
- package/skills/guide/references/restacking.md +79 -0
- package/skills/guide/references/setup.md +49 -6
- package/skills/guide/references/ticket-dependencies.md +69 -0
- package/skills/guide/references/ticket-migration.md +8 -0
- package/skills/operate/SKILL.md +55 -5
- package/skills/reconcile/SKILL.md +55 -48
- package/skills/spec/SKILL.md +67 -1
- package/skills/tickets/SKILL.md +55 -2
- package/templates/autobuild.toml +3 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { suspendNativeLanding } from '../kernel/landing-publication'
|
|
2
|
+
import { completeAutomaticReconcile } from '../kernel/leaf-restack-completion'
|
|
3
|
+
import { readBuildFacts, readPhaseFailures } from '../store/reduced-reads'
|
|
2
4
|
import type { IdSource } from '../ids'
|
|
3
5
|
import { DISPATCHER, KERNEL } from '../events/envelope'
|
|
4
6
|
import type { Forge, WorkspacePublication } from '../ports/types'
|
|
@@ -35,10 +37,173 @@ export async function settlePendingPublication(
|
|
|
35
37
|
): Promise<void> {
|
|
36
38
|
const publication = deps.publication
|
|
37
39
|
if (publication === undefined) return
|
|
40
|
+
await completeAutomaticReconcile(deps.store, slug)
|
|
38
41
|
let events = (await readBuildFacts(deps.store, slug)).value
|
|
39
42
|
const request = events.publication.latestUncompletedRequest()
|
|
40
43
|
if (request === undefined) return
|
|
41
44
|
|
|
45
|
+
if (request.payload.operation === 'restack') {
|
|
46
|
+
const record = await deps.store.getBuild(slug)
|
|
47
|
+
const clock = deps.clock ?? systemClock
|
|
48
|
+
if (
|
|
49
|
+
events.state.sessions.open.length > 0 ||
|
|
50
|
+
(events.open !== null &&
|
|
51
|
+
record?.lease !== undefined &&
|
|
52
|
+
new Date(record.lease.expiresAt).getTime() > clock().getTime())
|
|
53
|
+
)
|
|
54
|
+
return
|
|
55
|
+
if (publication.rewrite === undefined)
|
|
56
|
+
throw new Error('workspace provider lacks trusted restack publication')
|
|
57
|
+
const ref = events.workspace?.ref
|
|
58
|
+
if (ref === undefined) throw new Error('restack publication requires its retained workspace')
|
|
59
|
+
const transaction = request.payload.rewrite
|
|
60
|
+
const active = events.log.restack.active
|
|
61
|
+
const intended = events.log.restack.intent
|
|
62
|
+
if (
|
|
63
|
+
transaction.headSha !== request.payload.sha ||
|
|
64
|
+
active?.id !== transaction.id ||
|
|
65
|
+
intended?.id !== transaction.id ||
|
|
66
|
+
intended.headSha !== request.payload.sha ||
|
|
67
|
+
intended.targetBase !== transaction.targetBase ||
|
|
68
|
+
intended.oldHead !== transaction.oldHead ||
|
|
69
|
+
intended.branch !== request.payload.branch
|
|
70
|
+
)
|
|
71
|
+
throw new Error('restack publication request does not match its durable intent')
|
|
72
|
+
const archives = [...new Set([...events.gitTips, request.payload.sha])].map((sha) => ({
|
|
73
|
+
ref: `refs/autobuild/archive/${slug}/${sha}`,
|
|
74
|
+
sha,
|
|
75
|
+
}))
|
|
76
|
+
await suspendNativeLanding({ ...deps, slug }, `publication:${request.seq}`)
|
|
77
|
+
const result = await publication.rewrite({
|
|
78
|
+
ref,
|
|
79
|
+
sha: request.payload.sha,
|
|
80
|
+
branch: transaction.branch,
|
|
81
|
+
expected: transaction.oldHead,
|
|
82
|
+
localExpected: transaction.localBranchHead,
|
|
83
|
+
archives,
|
|
84
|
+
})
|
|
85
|
+
const latest = (await readBuildFacts(deps.store, slug)).value
|
|
86
|
+
if (
|
|
87
|
+
(result.kind === 'published' || result.rewritten === true) &&
|
|
88
|
+
!latest.restackHistory.some(
|
|
89
|
+
(e) => e.type === 'restack.rewritten' && e.payload.id === transaction.id,
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
await deps.store.append(slug, {
|
|
93
|
+
actor: DISPATCHER,
|
|
94
|
+
type: 'restack.rewritten',
|
|
95
|
+
payload: {
|
|
96
|
+
...transaction,
|
|
97
|
+
archives,
|
|
98
|
+
...(result.kind === 'lease-mismatch' ? { observedHead: result.actual } : {}),
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
if (result.kind === 'lease-mismatch') {
|
|
102
|
+
await deps.store.append(slug, {
|
|
103
|
+
actor: DISPATCHER,
|
|
104
|
+
type: 'restack.contended',
|
|
105
|
+
payload: { id: transaction.id, request: request.seq, actual: result.actual },
|
|
106
|
+
})
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
const settled = await readBuildFacts(deps.store, slug)
|
|
110
|
+
if (!settled.value.publication.requestCompleted(request))
|
|
111
|
+
await deps.store.appendIfCurrent(slug, settled.cursor, {
|
|
112
|
+
actor: DISPATCHER,
|
|
113
|
+
type: 'restack.completed',
|
|
114
|
+
payload: transaction,
|
|
115
|
+
})
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (request.payload.operation === 'reconcile' && request.payload.rewrite !== undefined) {
|
|
120
|
+
const record = await deps.store.getBuild(slug)
|
|
121
|
+
const clock = deps.clock ?? systemClock
|
|
122
|
+
if (
|
|
123
|
+
events.open !== null &&
|
|
124
|
+
record?.lease !== undefined &&
|
|
125
|
+
new Date(record.lease.expiresAt).getTime() > clock().getTime()
|
|
126
|
+
)
|
|
127
|
+
return
|
|
128
|
+
if (publication.rewrite === undefined)
|
|
129
|
+
throw new Error(
|
|
130
|
+
'workspace provider lacks trusted reconcile rewrite/archive publication; upgrade the provider before retrying',
|
|
131
|
+
)
|
|
132
|
+
const ref = events.workspace?.ref
|
|
133
|
+
if (ref === undefined) throw new Error('reconcile publication requires its retained workspace')
|
|
134
|
+
const transaction = request.payload.rewrite
|
|
135
|
+
const intended = events.reconcileHistory.findLast(
|
|
136
|
+
(event) => event.type === 'reconcile.publish-intended' && event.payload.id === transaction.id,
|
|
137
|
+
)
|
|
138
|
+
if (
|
|
139
|
+
intended?.type !== 'reconcile.publish-intended' ||
|
|
140
|
+
intended.payload.headSha !== request.payload.sha ||
|
|
141
|
+
intended.payload.oldHead !== transaction.oldHead ||
|
|
142
|
+
intended.payload.targetBase !== transaction.targetBase
|
|
143
|
+
)
|
|
144
|
+
throw new Error('reconcile request does not match its durable resolved intent')
|
|
145
|
+
if (events.reconcileBases[String(transaction.attempt)] !== transaction.targetBase)
|
|
146
|
+
throw new Error('reconcile publication target differs from the recorded start')
|
|
147
|
+
const tips = new Set([...events.gitTips, request.payload.sha])
|
|
148
|
+
const archives = [...tips].map((sha) => ({ ref: `refs/autobuild/archive/${slug}/${sha}`, sha }))
|
|
149
|
+
await suspendNativeLanding({ ...deps, slug }, `publication:${request.seq}`)
|
|
150
|
+
const result = await publication.rewrite({
|
|
151
|
+
ref,
|
|
152
|
+
sha: request.payload.sha,
|
|
153
|
+
branch: request.payload.branch,
|
|
154
|
+
expected: transaction.oldHead,
|
|
155
|
+
localExpected: transaction.localBranchHead,
|
|
156
|
+
archives,
|
|
157
|
+
})
|
|
158
|
+
const history = (await readBuildFacts(deps.store, slug)).value.reconcileHistory
|
|
159
|
+
if (
|
|
160
|
+
(result.kind === 'published' || result.rewritten === true) &&
|
|
161
|
+
!history.some((e) => e.type === 'reconcile.rewritten' && e.payload.id === transaction.id)
|
|
162
|
+
)
|
|
163
|
+
await deps.store.append(slug, {
|
|
164
|
+
actor: DISPATCHER,
|
|
165
|
+
type: 'reconcile.rewritten',
|
|
166
|
+
payload: {
|
|
167
|
+
...transaction,
|
|
168
|
+
headSha: request.payload.sha,
|
|
169
|
+
archives,
|
|
170
|
+
...(result.kind === 'lease-mismatch' ? { observedHead: result.actual } : {}),
|
|
171
|
+
},
|
|
172
|
+
})
|
|
173
|
+
if (result.kind === 'lease-mismatch') {
|
|
174
|
+
await deps.store.append(slug, {
|
|
175
|
+
actor: DISPATCHER,
|
|
176
|
+
type: 'reconcile.contended',
|
|
177
|
+
payload: { id: transaction.id, request: request.seq, actual: result.actual },
|
|
178
|
+
})
|
|
179
|
+
const failures = await readPhaseFailures(deps.store, slug, 'reconcile', transaction.attempt)
|
|
180
|
+
await deps.store.append(slug, {
|
|
181
|
+
actor: KERNEL,
|
|
182
|
+
type: 'phase.failed',
|
|
183
|
+
payload: {
|
|
184
|
+
phase: 'reconcile',
|
|
185
|
+
round: transaction.attempt,
|
|
186
|
+
attempt: failures.count + 1,
|
|
187
|
+
willRetry: true,
|
|
188
|
+
error: `reconcile publication lost its expected-head lease to ${result.actual ?? '(deleted)'}; replay again onto frozen base ${transaction.targetBase}`,
|
|
189
|
+
},
|
|
190
|
+
})
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
if (!(await readBuildFacts(deps.store, slug)).value.publication.requestCompleted(request))
|
|
194
|
+
await deps.store.append(slug, {
|
|
195
|
+
actor: DISPATCHER,
|
|
196
|
+
type: 'reconcile.completed',
|
|
197
|
+
payload: {
|
|
198
|
+
headSha: request.payload.sha,
|
|
199
|
+
rewriteId: transaction.id,
|
|
200
|
+
artifact: request.payload.artifact,
|
|
201
|
+
},
|
|
202
|
+
})
|
|
203
|
+
await completeAutomaticReconcile(deps.store, slug)
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
|
|
42
207
|
const abandoned = events.publication.requestSettled(request)
|
|
43
208
|
// Consulted for every uncompleted request, not only abandoned ones: a guest
|
|
44
209
|
// that pushed its branch before dying is owed its completion fact, not a
|
|
@@ -83,6 +248,7 @@ export async function settlePendingPublication(
|
|
|
83
248
|
const ref = events.workspace?.ref
|
|
84
249
|
if (ref === undefined)
|
|
85
250
|
throw new Error(`build ${slug} has a publication request but no open workspace`)
|
|
251
|
+
await suspendNativeLanding({ ...deps, slug }, `publication:${request.seq}`)
|
|
86
252
|
await publication.publish({ ref, sha: request.payload.sha, branch: request.payload.branch })
|
|
87
253
|
}
|
|
88
254
|
} catch (error) {
|
|
@@ -168,7 +334,7 @@ export async function settlePendingPublication(
|
|
|
168
334
|
events,
|
|
169
335
|
{
|
|
170
336
|
branch: request.payload.branch,
|
|
171
|
-
baseBranch: created.payload.baseBranch,
|
|
337
|
+
baseBranch: events.state.baseBranch ?? created.payload.baseBranch,
|
|
172
338
|
title,
|
|
173
339
|
body: newline === -1 ? '' : text.slice(newline + 1).replace(/^\n+/, ''),
|
|
174
340
|
mergeMessage: text,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { forgeReadinessWarnings, reduceDispatchStatus } from '../kernel/dispatch-status'
|
|
1
2
|
import { readRepositoryFacts, type RepositoryReadFacts } from '../store/reduced-reads'
|
|
2
3
|
import {
|
|
3
4
|
formatDispatcherIdentity,
|
|
@@ -18,6 +19,7 @@ import { withSessionlessStore, type StoreOpener } from './store-opening'
|
|
|
18
19
|
/** Script-facing projection returned by `ab repository status`. */
|
|
19
20
|
export interface RepositoryStatus extends DispatchSettings {
|
|
20
21
|
repo: string
|
|
22
|
+
warningLines?: string[]
|
|
21
23
|
dispatcher: DispatcherLiveness
|
|
22
24
|
ticketSourceDegradation?: TicketSourceDegradation
|
|
23
25
|
/** Live operator sandboxes (AUT-340); released environments are omitted. */
|
|
@@ -82,9 +84,15 @@ export function projectRepositoryStatus(
|
|
|
82
84
|
}
|
|
83
85
|
publications.reverse()
|
|
84
86
|
const active = reduceTicketSourceHealth(events)
|
|
87
|
+
const latestRun = events.findLast((event) => event.type === 'dispatcher.run-started')
|
|
88
|
+
const warningLines =
|
|
89
|
+
latestRun?.type === 'dispatcher.run-started'
|
|
90
|
+
? forgeReadinessWarnings(reduceDispatchStatus(events, latestRun.payload.run))
|
|
91
|
+
: []
|
|
85
92
|
return {
|
|
86
93
|
...(active === undefined ? {} : { ticketSourceDegradation: active }),
|
|
87
94
|
repo,
|
|
95
|
+
...(warningLines.length ? { warningLines } : {}),
|
|
88
96
|
dispatcher,
|
|
89
97
|
...reduceDispatchSettings(events),
|
|
90
98
|
sandboxes: sandboxStates(events)
|
|
@@ -105,8 +113,10 @@ export function repositoryStatusFromFacts(
|
|
|
105
113
|
facts: RepositoryReadFacts,
|
|
106
114
|
dispatcher: DispatcherLiveness,
|
|
107
115
|
): RepositoryStatus {
|
|
116
|
+
const warningLines = facts.status ? forgeReadinessWarnings(facts.status) : []
|
|
108
117
|
return {
|
|
109
118
|
repo,
|
|
119
|
+
...(warningLines.length ? { warningLines } : {}),
|
|
110
120
|
dispatcher,
|
|
111
121
|
...facts.settings,
|
|
112
122
|
...(facts.health === undefined ? {} : { ticketSourceDegradation: facts.health }),
|
|
@@ -141,6 +151,7 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
|
|
|
141
151
|
`ticket source ${active.source}: ${active.cause} (${active.operation}) — ${active.message}${'resetAt' in active ? `; reset ${active.resetAt}` : ''}`,
|
|
142
152
|
]),
|
|
143
153
|
`repository: ${status.repo}`,
|
|
154
|
+
...(status.warningLines ?? []),
|
|
144
155
|
`dispatcher: ${status.dispatcher.state}${status.dispatcher.holder ? ` — ${formatDispatcherIdentity(status.dispatcher.holder)}` : ' — no dispatcher holds the repository'}`,
|
|
145
156
|
...(status.dispatcher.expiredHolder
|
|
146
157
|
? [`expired dispatcher: ${formatDispatcherIdentity(status.dispatcher.expiredHolder)}`]
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { indexLog } from '../kernel/log-index'
|
|
2
|
+
import { projectTree, type TreeProjection } from './dashboard/tree'
|
|
3
|
+
import { buildVocabulary } from './dashboard/model'
|
|
1
4
|
import { readBuildDigests } from '../store/reduced-reads'
|
|
2
5
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
3
6
|
import type { BuildFacts } from '../processes/repo-view'
|
|
@@ -94,6 +97,11 @@ export interface LeaseInfo {
|
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
export interface BuildSummary {
|
|
100
|
+
kind?: 'integration' | 'work'
|
|
101
|
+
target?: string
|
|
102
|
+
integration?: ReturnType<typeof buildVocabulary>['integration']
|
|
103
|
+
integrationState?: BuildState['integration']
|
|
104
|
+
nodeRestack?: BuildState['nodeRestack']
|
|
97
105
|
slug: string
|
|
98
106
|
ticket?: TicketRef
|
|
99
107
|
/** The reducer's effective status (§15.5) — never mixed with lease health. */
|
|
@@ -139,6 +147,9 @@ export type BuildDecisionProjection =
|
|
|
139
147
|
| { kind: 'unavailable'; diagnostic: string }
|
|
140
148
|
|
|
141
149
|
export interface BuildDetail extends BuildSummary {
|
|
150
|
+
tree?: TreeProjection
|
|
151
|
+
/** Immutable policy provenance and durable command/native application state. */
|
|
152
|
+
landing?: BuildState['landing']
|
|
142
153
|
/** Current work-owner decision. Open PRs use the build-owned config; ended
|
|
143
154
|
* PRs project the repository completion path directly from durable state. */
|
|
144
155
|
decision?: BuildDecisionProjection
|
|
@@ -228,6 +239,9 @@ export function summarizeFrom(record: BuildRecord, state: BuildState, now: Date)
|
|
|
228
239
|
const attempt = active?.attempt
|
|
229
240
|
return {
|
|
230
241
|
slug: record.slug,
|
|
242
|
+
...buildVocabulary(state),
|
|
243
|
+
...(state.kind === 'node' ? { integrationState: state.integration } : {}),
|
|
244
|
+
...(state.kind === 'node' ? { nodeRestack: state.nodeRestack } : {}),
|
|
231
245
|
// record.ticket is a TicketRef already carrying id/title/url — no artifact
|
|
232
246
|
// read and no ticket-provider call (live ticket state is out of scope).
|
|
233
247
|
...(record.ticket !== undefined ? { ticket: record.ticket } : {}),
|
|
@@ -278,6 +292,7 @@ export function detail(
|
|
|
278
292
|
record,
|
|
279
293
|
{
|
|
280
294
|
state: reduceBuild(events),
|
|
295
|
+
log: indexLog(events),
|
|
281
296
|
observations: events
|
|
282
297
|
.filter((event) => event.type === 'observation.recorded')
|
|
283
298
|
.map((event) => event.payload),
|
|
@@ -292,7 +307,8 @@ export function detail(
|
|
|
292
307
|
|
|
293
308
|
export function detailFromFacts(
|
|
294
309
|
record: BuildRecord,
|
|
295
|
-
facts: Pick<BuildFacts, 'state' | 'open'> &
|
|
310
|
+
facts: Pick<BuildFacts, 'state' | 'open'> &
|
|
311
|
+
Partial<Pick<BuildFacts, 'log'>> & { observations: BuildState['observations'] },
|
|
296
312
|
now: Date,
|
|
297
313
|
events?: AbEvent[],
|
|
298
314
|
decision?: BuildDecisionProjection,
|
|
@@ -327,7 +343,9 @@ export function detailFromFacts(
|
|
|
327
343
|
}))
|
|
328
344
|
return {
|
|
329
345
|
...summary,
|
|
346
|
+
...(facts.log ? { tree: projectTree(record, state, facts.log.restack) } : {}),
|
|
330
347
|
autoMerge: autoMergeDisplay(state),
|
|
348
|
+
...(state.landing && Object.keys(state.landing).length ? { landing: state.landing } : {}),
|
|
331
349
|
...(decision !== undefined ? { decision } : {}),
|
|
332
350
|
openEscalations: state.openEscalations,
|
|
333
351
|
...(state.reviewRoundCeilings.plan !== undefined || state.reviewRoundCeilings.code !== undefined
|
|
@@ -501,13 +519,15 @@ export function renderSummaries(summaries: BuildSummary[], now: Date, emptyNote:
|
|
|
501
519
|
rows.push([
|
|
502
520
|
summary.slug,
|
|
503
521
|
summary.status,
|
|
504
|
-
|
|
522
|
+
summary.kind === 'integration'
|
|
523
|
+
? `integration ${summary.integration ?? ''}`
|
|
524
|
+
: phaseCell(summary),
|
|
505
525
|
healthWord(summary.lease.health),
|
|
506
526
|
summary.progress.heartbeatAt === undefined
|
|
507
527
|
? '—'
|
|
508
528
|
: relativeTime(summary.progress.heartbeatAt, now),
|
|
509
529
|
`${progressAge}${isDiverged(summary.progress, now) ? ' diverged' : ''}`,
|
|
510
|
-
ticketCell(summary)
|
|
530
|
+
`${ticketCell(summary)}${summary.target ? ` target ${summary.target}` : ''}`,
|
|
511
531
|
prCell(summary),
|
|
512
532
|
])
|
|
513
533
|
}
|
|
@@ -522,6 +542,52 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
|
|
|
522
542
|
lines.push(` ticket: ${d.ticket.id}${title}`)
|
|
523
543
|
if (d.ticket.url !== undefined) lines.push(` ticket url: ${d.ticket.url}`)
|
|
524
544
|
}
|
|
545
|
+
if (d.target)
|
|
546
|
+
lines.push(
|
|
547
|
+
` ${d.kind ?? 'work'} · target ${d.target}${d.integration ? ` · ${d.integration}` : ''}`,
|
|
548
|
+
)
|
|
549
|
+
if (d.integrationState) {
|
|
550
|
+
const integration = d.integrationState
|
|
551
|
+
lines.push(` open children: ${integration.observation?.openChildren.join(', ') || 'none'}`)
|
|
552
|
+
if (integration.observation?.diagnostics.length)
|
|
553
|
+
lines.push(` completeness unavailable: ${integration.observation.diagnostics.join('; ')}`)
|
|
554
|
+
if (integration.cycle)
|
|
555
|
+
lines.push(
|
|
556
|
+
` verification head: ${integration.cycle.head} · parent ${integration.cycle.parent}`,
|
|
557
|
+
)
|
|
558
|
+
if (d.integration === 'verification failed')
|
|
559
|
+
lines.push(' repair: file a child ticket targeting this node')
|
|
560
|
+
}
|
|
561
|
+
if (d.nodeRestack) {
|
|
562
|
+
const node = d.nodeRestack
|
|
563
|
+
const move = node.parentRequest ?? node.parentChange
|
|
564
|
+
if (move)
|
|
565
|
+
lines.push(
|
|
566
|
+
` reparenting: ${move.old.target?.ticket.id ?? move.old.branch} → ${move.next.target?.ticket.id ?? move.next.branch}`,
|
|
567
|
+
)
|
|
568
|
+
if (node.parentRejection) lines.push(` target change refused: ${node.parentRejection.reason}`)
|
|
569
|
+
if (node.inventory) {
|
|
570
|
+
lines.push(` node head: ${node.inventory.head}`)
|
|
571
|
+
lines.push(` build changes: ${node.inventory.builds.join(', ') || 'none'}`)
|
|
572
|
+
lines.push(` foreign changes (node-owned): ${node.inventory.foreign.join(', ') || 'none'}`)
|
|
573
|
+
}
|
|
574
|
+
if (!node.active && node.observedParent && node.observedParent.sha !== node.contributionBase)
|
|
575
|
+
lines.push(` node restack pending: parent ${node.observedParent.sha}`)
|
|
576
|
+
if (node.active) {
|
|
577
|
+
lines.push(
|
|
578
|
+
` node ${node.active.operation}: ${node.active.id} · ${node.items.length}/${node.active.changes.length} changes · parent ${node.active.parent}`,
|
|
579
|
+
)
|
|
580
|
+
if (node.conflict) {
|
|
581
|
+
const change = node.active.changes[node.conflict.index]!
|
|
582
|
+
lines.push(
|
|
583
|
+
` conflict item ${node.conflict.index + 1}: ${change.sha} · ${change.build ?? 'foreign'}`,
|
|
584
|
+
)
|
|
585
|
+
}
|
|
586
|
+
for (const proof of node.active.merges)
|
|
587
|
+
if (proof.missing.length || proof.build)
|
|
588
|
+
lines.push(` unsafe merge ${proof.sha}: ${proof.missing.join(', ') || proof.build}`)
|
|
589
|
+
}
|
|
590
|
+
}
|
|
525
591
|
lines.push(` status: ${d.status}${d.outcome !== undefined ? ` (${d.outcome})` : ''}`)
|
|
526
592
|
lines.push(` phase: ${phaseCell(d)}`)
|
|
527
593
|
if (d.reviewRoundCeilings !== undefined) {
|
|
@@ -727,10 +793,11 @@ export interface StatusOpts {
|
|
|
727
793
|
}
|
|
728
794
|
|
|
729
795
|
/** Statuses a bare `ab builds` shows: the ones an operator can still act on. */
|
|
730
|
-
const ACTIVE_STATUSES: BuildStatus[] = ['running', 'paused', 'blocked']
|
|
796
|
+
const ACTIVE_STATUSES: BuildStatus[] = ['running', 'collecting', 'paused', 'blocked']
|
|
731
797
|
|
|
732
798
|
export function statusFilter(all?: boolean, queued?: boolean): BuildStatus[] {
|
|
733
|
-
if (all === true)
|
|
799
|
+
if (all === true)
|
|
800
|
+
return ['queued', 'running', 'collecting', 'paused', 'blocked', 'done', 'aborted']
|
|
734
801
|
return queued === true ? [...ACTIVE_STATUSES, 'queued'] : ACTIVE_STATUSES
|
|
735
802
|
}
|
|
736
803
|
|
|
@@ -32,6 +32,13 @@ export const BRACKETED_PASTE_MODE = {
|
|
|
32
32
|
restoreOrder: 20,
|
|
33
33
|
} as const satisfies TerminalMode
|
|
34
34
|
|
|
35
|
+
export const FOCUS_REPORTING_MODE = {
|
|
36
|
+
name: 'focus-reporting',
|
|
37
|
+
enter: '\x1b[?1004h',
|
|
38
|
+
restore: '\x1b[?1004l',
|
|
39
|
+
restoreOrder: 5,
|
|
40
|
+
} as const satisfies TerminalMode
|
|
41
|
+
|
|
35
42
|
export const KITTY_KEYBOARD_FLAGS = 0b1_1101
|
|
36
43
|
|
|
37
44
|
export const KITTY_KEYBOARD_MODE = {
|
|
@@ -172,3 +179,50 @@ export function installTerminalRestoreHook(
|
|
|
172
179
|
},
|
|
173
180
|
}
|
|
174
181
|
}
|
|
182
|
+
|
|
183
|
+
/** Presentation-owned job control. The kernel is a separately supervised
|
|
184
|
+
* process and is deliberately absent from these callbacks. */
|
|
185
|
+
export function installPresentationSuspension(
|
|
186
|
+
modes: TerminalModeController,
|
|
187
|
+
suspend: () => void,
|
|
188
|
+
resume: () => void,
|
|
189
|
+
boundary: TerminalRestoreProcess = process as unknown as TerminalRestoreProcess,
|
|
190
|
+
): { close(): void; suspend(): void } {
|
|
191
|
+
let closed = false
|
|
192
|
+
let paused = false
|
|
193
|
+
let saved: readonly TerminalMode[] = []
|
|
194
|
+
const onContinue = (): void => {
|
|
195
|
+
if (closed || !paused) return
|
|
196
|
+
paused = false
|
|
197
|
+
resume()
|
|
198
|
+
for (const mode of saved) modes.enter(mode)
|
|
199
|
+
saved = []
|
|
200
|
+
}
|
|
201
|
+
const onStop = (): void => {
|
|
202
|
+
if (closed || paused) return
|
|
203
|
+
paused = true
|
|
204
|
+
saved = modes.activeModes
|
|
205
|
+
modes.restoreAll()
|
|
206
|
+
suspend()
|
|
207
|
+
boundary.removeListener('SIGTSTP', onStop)
|
|
208
|
+
// Replay with the default disposition. SIGCONT reinstalls our handler.
|
|
209
|
+
boundary.kill(boundary.pid, 'SIGTSTP')
|
|
210
|
+
}
|
|
211
|
+
const continued = (): void => {
|
|
212
|
+
if (closed) return
|
|
213
|
+
boundary.removeListener('SIGTSTP', onStop)
|
|
214
|
+
boundary.on('SIGTSTP', onStop)
|
|
215
|
+
onContinue()
|
|
216
|
+
}
|
|
217
|
+
boundary.on('SIGTSTP', onStop)
|
|
218
|
+
boundary.on('SIGCONT', continued)
|
|
219
|
+
return {
|
|
220
|
+
suspend: onStop,
|
|
221
|
+
close(): void {
|
|
222
|
+
closed = true
|
|
223
|
+
saved = []
|
|
224
|
+
boundary.removeListener('SIGTSTP', onStop)
|
|
225
|
+
boundary.removeListener('SIGCONT', continued)
|
|
226
|
+
},
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -44,6 +44,9 @@ export type TerminalInputEvent =
|
|
|
44
44
|
| { type: 'paste'; text: string }
|
|
45
45
|
|
|
46
46
|
export interface TerminalInputHooks {
|
|
47
|
+
onFocus?(focused: boolean): void
|
|
48
|
+
onInteraction?(): void
|
|
49
|
+
onSuspend?(): void
|
|
47
50
|
onListening?(): void
|
|
48
51
|
onKeyboardFlags?(flags: number): void
|
|
49
52
|
onDeviceAttributes?(): void
|
|
@@ -169,6 +172,9 @@ export function createTerminalInputDecoder(hooks: TerminalInputHooks = {}): Term
|
|
|
169
172
|
let watch: string | undefined
|
|
170
173
|
|
|
171
174
|
const reportEvent = (report: CsiReport): TerminalInputEvent | undefined => {
|
|
175
|
+
if (report.kind === 'suspend') hooks.onSuspend?.()
|
|
176
|
+
if (report.kind === 'focus') hooks.onFocus?.(report.focused)
|
|
177
|
+
if (report.kind === 'ignored') hooks.onInteraction?.()
|
|
172
178
|
if (report.kind === 'input') return report.event
|
|
173
179
|
if (report.kind === 'keyboard-flags') hooks.onKeyboardFlags?.(report.flags)
|
|
174
180
|
if (report.kind === 'device-attributes') hooks.onDeviceAttributes?.()
|
|
@@ -267,11 +273,15 @@ export function createTerminalInputDecoder(hooks: TerminalInputHooks = {}): Term
|
|
|
267
273
|
}
|
|
268
274
|
|
|
269
275
|
const restart = fragment.startsWith('\x1b[')
|
|
270
|
-
if (csi !== undefined ||
|
|
276
|
+
if (csi !== undefined || restart) {
|
|
271
277
|
const consumed = consumeCsi(fragment, restart)
|
|
272
278
|
if (consumed.consumed) return consumed.event
|
|
273
279
|
}
|
|
274
280
|
|
|
281
|
+
if (key.ctrl === true && key.name === 'z') {
|
|
282
|
+
hooks.onSuspend?.()
|
|
283
|
+
return undefined
|
|
284
|
+
}
|
|
275
285
|
if (key.name === 'up') return { type: 'up' }
|
|
276
286
|
if (key.name === 'down') return { type: 'down' }
|
|
277
287
|
if (key.name === 'left') return { type: 'left' }
|
|
@@ -287,7 +297,10 @@ export function createTerminalInputDecoder(hooks: TerminalInputHooks = {}): Term
|
|
|
287
297
|
}
|
|
288
298
|
if (key.name === 'escape' || key.sequence === '\u001b') return { type: 'escape' }
|
|
289
299
|
|
|
290
|
-
if (key.ctrl === true || key.meta === true)
|
|
300
|
+
if (key.ctrl === true || key.meta === true) {
|
|
301
|
+
hooks.onInteraction?.()
|
|
302
|
+
return undefined
|
|
303
|
+
}
|
|
291
304
|
const printable =
|
|
292
305
|
text ??
|
|
293
306
|
(key.name?.length === 1 ? key.name : key.sequence !== undefined ? key.sequence : undefined)
|
|
@@ -296,6 +309,7 @@ export function createTerminalInputDecoder(hooks: TerminalInputHooks = {}): Term
|
|
|
296
309
|
printable.length === 0 ||
|
|
297
310
|
/[\u0000-\u001f\u007f]/u.test(printable)
|
|
298
311
|
) {
|
|
312
|
+
hooks.onInteraction?.()
|
|
299
313
|
return undefined
|
|
300
314
|
}
|
|
301
315
|
return { type: 'text', text: printable }
|