@defrex/autobuild 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/SPEC.md +432 -92
- package/bin/ab-dispatch-kernel.ts +1 -0
- package/docs/accounts.md +9 -0
- package/docs/agent-runtimes.md +1 -0
- package/docs/answering-blocked-builds.md +2 -1
- package/docs/architecture.md +282 -127
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +33 -3
- package/docs/cli.md +2 -1
- package/docs/configuration-overview.md +9 -0
- package/docs/configuration.md +163 -102
- package/docs/dispatcher-hosting.md +19 -3
- package/docs/dispatcher.md +9 -4
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +91 -28
- package/docs/merge-policy.md +28 -9
- package/docs/operator-api.md +43 -18
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +85 -8
- package/docs/remote-store-protocol.md +25 -7
- package/docs/remote-ticket-protocol.md +126 -12
- package/docs/restacking.md +20 -6
- package/docs/seams.md +2 -2
- package/docs/setup.md +19 -13
- package/docs/spec-standard.md +2 -1
- package/docs/ticket-dependencies.md +26 -8
- package/docs/ticket-migration.md +70 -7
- package/docs/ticket-sources.md +82 -5
- package/docs/tickets.md +34 -2
- package/docs/troubleshooting.md +2 -2
- package/docs/verification.md +5 -5
- package/docs/website.md +8 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/hosted-readiness.ts +21 -0
- package/packages/core/src/cli/attention.ts +1 -0
- package/packages/core/src/cli/build-control.ts +36 -12
- package/packages/core/src/cli/connect.ts +9 -18
- package/packages/core/src/cli/context.ts +44 -0
- package/packages/core/src/cli/dashboard/configuration.ts +11 -0
- package/packages/core/src/cli/dashboard/model.ts +40 -10
- package/packages/core/src/cli/dashboard/queue.ts +21 -0
- package/packages/core/src/cli/dashboard/render.ts +40 -22
- package/packages/core/src/cli/dispatch-frontend.ts +63 -30
- package/packages/core/src/cli/dispatch-mode.ts +35 -16
- package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
- package/packages/core/src/cli/dispatch.ts +154 -47
- package/packages/core/src/cli/help.ts +59 -22
- package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
- package/packages/core/src/cli/init-readiness-remote.ts +16 -3
- package/packages/core/src/cli/init-validation.ts +144 -42
- package/packages/core/src/cli/issue-links.ts +67 -0
- package/packages/core/src/cli/main.ts +32 -15
- package/packages/core/src/cli/pr-summary-publication.ts +38 -7
- package/packages/core/src/cli/publication-settlement.ts +36 -24
- package/packages/core/src/cli/repository-status.ts +201 -49
- package/packages/core/src/cli/status.ts +41 -3
- package/packages/core/src/cli/terminals.ts +37 -2
- package/packages/core/src/cli/ticket-editor.ts +20 -6
- package/packages/core/src/cli/ticket.ts +264 -46
- package/packages/core/src/cli/triage-count-sampler.ts +59 -0
- package/packages/core/src/cli/watch.ts +4 -0
- package/packages/core/src/config/live.ts +45 -4
- package/packages/core/src/config/load.ts +9 -0
- package/packages/core/src/config/pipeline-source.ts +6 -2
- package/packages/core/src/config/ready-assignee.ts +86 -0
- package/packages/core/src/config/schema.ts +164 -36
- package/packages/core/src/distribution-packaging.ts +1 -1
- package/packages/core/src/events/catalog.ts +5 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/payloads.ts +70 -0
- package/packages/core/src/events/policy.ts +8 -0
- package/packages/core/src/events/repository.ts +91 -28
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +41 -0
- package/packages/core/src/kernel/build-identity.ts +12 -0
- package/packages/core/src/kernel/change-presence.ts +139 -6
- package/packages/core/src/kernel/dispatch-capacity.ts +80 -14
- package/packages/core/src/kernel/dispatch-status.ts +10 -1
- package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
- package/packages/core/src/kernel/engine.ts +4 -2
- package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
- package/packages/core/src/kernel/harvest.ts +4 -1
- package/packages/core/src/kernel/integration-completeness.ts +104 -17
- package/packages/core/src/kernel/integration-landing.ts +17 -0
- package/packages/core/src/kernel/integration-state.ts +17 -0
- package/packages/core/src/kernel/issue-keywords.ts +202 -0
- package/packages/core/src/kernel/janitor-failure.ts +11 -0
- package/packages/core/src/kernel/kernel-git.ts +87 -0
- package/packages/core/src/kernel/landing-readiness.ts +25 -17
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-issue-links.ts +142 -0
- package/packages/core/src/kernel/node-parent.ts +6 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
- package/packages/core/src/kernel/pr-summary.ts +24 -0
- package/packages/core/src/kernel/read-deferrals.ts +75 -12
- package/packages/core/src/kernel/read-facts.ts +32 -1
- package/packages/core/src/kernel/reconcile-restack.ts +1 -1
- package/packages/core/src/kernel/reducer-registry.ts +31 -1
- package/packages/core/src/kernel/reducer.ts +90 -2
- package/packages/core/src/kernel/ticket-preparation.ts +12 -0
- package/packages/core/src/kernel/verify-budget.ts +43 -0
- package/packages/core/src/operator/index.ts +3 -1
- package/packages/core/src/operator/presentation.ts +3 -0
- package/packages/core/src/operator/protocol.ts +38 -2
- package/packages/core/src/operator/query.ts +66 -29
- package/packages/core/src/operator/registry.ts +47 -26
- package/packages/core/src/operator/tickets.ts +77 -10
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/plugins/registry.ts +1 -0
- package/packages/core/src/ports/forge/contract.ts +69 -0
- package/packages/core/src/ports/forge/create.ts +5 -0
- package/packages/core/src/ports/forge/fake.ts +184 -3
- package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
- package/packages/core/src/ports/forge/github.ts +175 -38
- package/packages/core/src/ports/forge/local-git.ts +14 -0
- package/packages/core/src/ports/forge/readiness.ts +10 -0
- package/packages/core/src/ports/forge-failure.ts +43 -0
- package/packages/core/src/ports/runner/claude.ts +7 -1
- package/packages/core/src/ports/runner/codex.ts +7 -2
- package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
- package/packages/core/src/ports/runner/pi.ts +7 -1
- package/packages/core/src/ports/runner/runtime.ts +3 -0
- package/packages/core/src/ports/runner/start-prompt.ts +37 -0
- package/packages/core/src/ports/tickets/contract.ts +320 -7
- package/packages/core/src/ports/tickets/create.ts +72 -17
- package/packages/core/src/ports/tickets/fake.ts +18 -0
- package/packages/core/src/ports/tickets/file-codec.ts +20 -0
- package/packages/core/src/ports/tickets/file.ts +43 -1
- package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
- package/packages/core/src/ports/tickets/github-issues.ts +431 -0
- package/packages/core/src/ports/tickets/github-validators.ts +194 -0
- package/packages/core/src/ports/tickets/github.ts +2029 -0
- package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
- package/packages/core/src/ports/tickets/issue-links.ts +86 -0
- package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
- package/packages/core/src/ports/tickets/linear.ts +66 -6
- package/packages/core/src/ports/tickets/migration.ts +290 -68
- package/packages/core/src/ports/tickets/operations.ts +98 -12
- package/packages/core/src/ports/tickets/priority.ts +55 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
- package/packages/core/src/ports/tickets/remote.ts +188 -13
- package/packages/core/src/ports/tickets/revision.ts +22 -1
- package/packages/core/src/ports/tickets/states.ts +43 -0
- package/packages/core/src/ports/tickets/tree.ts +58 -12
- package/packages/core/src/ports/tickets/update.ts +12 -2
- package/packages/core/src/ports/types.ts +190 -9
- package/packages/core/src/ports/workspace/commit-preservation.ts +135 -13
- package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +118 -27
- package/packages/core/src/processes/build-runner.ts +99 -21
- package/packages/core/src/processes/dispatcher.ts +822 -338
- package/packages/core/src/processes/execution-no-progress.ts +5 -0
- package/packages/core/src/processes/harvest-runner.ts +17 -8
- package/packages/core/src/processes/harvest.ts +5 -8
- package/packages/core/src/processes/tick-publication.ts +12 -2
- package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
- package/packages/core/src/processes/workspace-preservation.ts +36 -1
- package/packages/core/src/runtime-identity.ts +10 -2
- package/packages/core/src/scenarios/harness.ts +4 -0
- package/packages/core/src/store/adapter.ts +7 -1
- package/packages/core/src/store/contract.ts +83 -2
- package/packages/core/src/store/digest.ts +32 -1
- package/packages/core/src/store/reducer-value-shapes.json +4187 -3391
- package/packages/core/src/store/remote/protocol.ts +2 -0
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +5 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
- package/packages/core/src/testing/index.ts +18 -1
- package/packages/core/src/testing/presence-history.ts +79 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1085 -31
- package/packages/core/src/testing/upgrade-generations.ts +77 -0
- package/skills/code-review/SKILL.md +4 -3
- package/skills/finalize/SKILL.md +18 -2
- package/skills/guide/SKILL.md +374 -136
- package/skills/guide/references/accounts.md +9 -0
- package/skills/guide/references/integration-tree.md +91 -28
- package/skills/guide/references/merge-policy.md +28 -9
- package/skills/guide/references/operator-api.md +43 -18
- package/skills/guide/references/plugin-authoring.md +85 -8
- package/skills/guide/references/remote-store-protocol.md +25 -7
- package/skills/guide/references/remote-ticket-protocol.md +126 -12
- package/skills/guide/references/restacking.md +20 -6
- package/skills/guide/references/setup.md +19 -13
- package/skills/guide/references/spec-standard.md +2 -1
- package/skills/guide/references/ticket-dependencies.md +26 -8
- package/skills/guide/references/ticket-migration.md +70 -7
- package/skills/harvest-review/SKILL.md +4 -3
- package/skills/implement/SKILL.md +20 -1
- package/skills/operate/SKILL.md +103 -28
- package/skills/plan/SKILL.md +1 -1
- package/skills/reconcile/SKILL.md +5 -4
- package/skills/spec/SKILL.md +15 -2
- package/skills/tickets/SKILL.md +114 -37
- package/templates/autobuild.toml +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -2,6 +2,7 @@ import type { SelectedAccount } from '../config/accounts'
|
|
|
2
2
|
export type { ForgeReadinessCheck, ForgeReadinessInput } from './forge/readiness'
|
|
3
3
|
import type { ForgeReadinessCheck, ForgeReadinessInput } from './forge/readiness'
|
|
4
4
|
import type { BuildStore } from '../store/types'
|
|
5
|
+
import { ForgeRejection } from './forge-failure'
|
|
5
6
|
/**
|
|
6
7
|
* Ports (SPEC §3.2): interfaces to the world, each with swappable adapters.
|
|
7
8
|
* The kernel and processes depend only on these types; adapters live in
|
|
@@ -89,13 +90,33 @@ export interface Ticket {
|
|
|
89
90
|
blockersResolved?: boolean
|
|
90
91
|
/** Source-local ids of tickets declared as blockers. Absent ≡ none. */
|
|
91
92
|
blockedBy?: string[]
|
|
93
|
+
/** Forge issues this ticket addresses, sorted by issue number. Absent ≡ none
|
|
94
|
+
* or unsupported by the source. */
|
|
95
|
+
issueLinks?: IssueLink[]
|
|
96
|
+
/** `urgent` dispatches before normal ready work. Absent means normal, or a
|
|
97
|
+
* source that cannot store priority. Normalized tickets never carry `normal`. */
|
|
98
|
+
priority?: TicketPriority
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Dispatch class: urgent ready work is claimed before normal ready work. */
|
|
102
|
+
export type TicketPriority = 'urgent' | 'normal'
|
|
103
|
+
|
|
104
|
+
export type IssueLinkIntent = 'closes' | 'refs'
|
|
105
|
+
|
|
106
|
+
/** One forge issue a ticket addresses: `closes` fully resolves it, `refs`
|
|
107
|
+
* only partly addresses it. */
|
|
108
|
+
export interface IssueLink {
|
|
109
|
+
issue: number
|
|
110
|
+
intent: IssueLinkIntent
|
|
92
111
|
}
|
|
93
112
|
|
|
94
113
|
export interface TicketCriteria {
|
|
95
114
|
labels?: string[]
|
|
96
115
|
state?: string
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
116
|
+
/** Only the ready tickets assigned to this user. The value's forms are
|
|
117
|
+
* source-defined; `me` is the owner of the source's credential. Only sources
|
|
118
|
+
* declaring `readyAssignee` receive it — the rest refuse
|
|
119
|
+
* `[tickets].readyAssignee` before any listing. */
|
|
99
120
|
assignee?: string
|
|
100
121
|
}
|
|
101
122
|
|
|
@@ -129,6 +150,12 @@ export interface TicketDraft {
|
|
|
129
150
|
/** Source-local blocker ids, recorded natively at creation (§13). An
|
|
130
151
|
* adapter must record every one or throw — never discard silently. */
|
|
131
152
|
blockedBy?: string[]
|
|
153
|
+
/** Forge issues this ticket addresses. An adapter without the `issueLinks`
|
|
154
|
+
* capability must refuse, never discard. */
|
|
155
|
+
issueLinks?: IssueLink[]
|
|
156
|
+
/** Dispatch class. A source without the `priority` capability refuses
|
|
157
|
+
* `urgent`; `normal` is a no-op. */
|
|
158
|
+
priority?: TicketPriority
|
|
132
159
|
}
|
|
133
160
|
|
|
134
161
|
/** One node of the dependency graph, as this source sees it. */
|
|
@@ -141,9 +168,14 @@ export interface DependencyState {
|
|
|
141
168
|
* Complete per this source's NATIVE lifecycle semantics — the adapter owns
|
|
142
169
|
* this meaning and callers must not re-derive it from `state` (§13: the
|
|
143
170
|
* provider's taxonomy never leaks above the port). Linear: `state.type` in
|
|
144
|
-
* `completed | canceled`. File: state equals the source's done state.
|
|
171
|
+
* `completed | canceled`. File: state equals the source's done state. The
|
|
172
|
+
* dispatcher applies the configured rejected role on top: a blocker whose
|
|
173
|
+
* `state` holds that role never resolves.
|
|
145
174
|
*/
|
|
146
175
|
resolved: boolean
|
|
176
|
+
/** The blocker's native state name when the source knows it; absent when
|
|
177
|
+
* unsupported or when the ticket does not exist. */
|
|
178
|
+
state?: string
|
|
147
179
|
/** This node's own declared blockers, so callers can close the graph. */
|
|
148
180
|
blockedBy: string[]
|
|
149
181
|
}
|
|
@@ -155,8 +187,15 @@ export interface TicketCreateOptions {
|
|
|
155
187
|
state?: string
|
|
156
188
|
/** Source-level adoption key for crash-safe external creation. File and fake
|
|
157
189
|
* sources treat it as opaque; Linear requires a durably reserved UUID v4,
|
|
158
|
-
* sends it verbatim as the issue id, and queries that id when adopting
|
|
190
|
+
* sends it verbatim as the issue id, and queries that id when adopting;
|
|
191
|
+
* GitHub writes it as a hidden marker in the issue body by the same request
|
|
192
|
+
* that opens the issue. */
|
|
159
193
|
idempotencyKey?: string
|
|
194
|
+
/** ISO-8601. The earliest time this creation key could first have been
|
|
195
|
+
* used. A source whose key lookup is time-bounded (github) requires it with
|
|
196
|
+
* a key. Other sources ignore it. Callers must pass the same value on every
|
|
197
|
+
* retry. */
|
|
198
|
+
idempotencyKeyReservedAt?: string
|
|
160
199
|
}
|
|
161
200
|
|
|
162
201
|
/** Editable ticket fields. Omitted fields are preserved; state is deliberately
|
|
@@ -172,6 +211,11 @@ export interface TicketUpdate {
|
|
|
172
211
|
* Names need not already exist in the source; adapters own any
|
|
173
212
|
* provider-side label-registry reconciliation. */
|
|
174
213
|
labels?: string[]
|
|
214
|
+
/** A complete issue-link replacement. An explicit empty array clears links. */
|
|
215
|
+
issueLinks?: IssueLink[]
|
|
216
|
+
/** `normal` removes urgency. A source without the `priority` capability
|
|
217
|
+
* refuses `urgent`; `normal` is a no-op. */
|
|
218
|
+
priority?: TicketPriority
|
|
175
219
|
}
|
|
176
220
|
|
|
177
221
|
/** One workflow state of a source that can enumerate them. */
|
|
@@ -183,6 +227,12 @@ export interface TicketStateInfo {
|
|
|
183
227
|
about?: string
|
|
184
228
|
}
|
|
185
229
|
|
|
230
|
+
/** One state's ticket total from a bounded count read; `name` is canonical. */
|
|
231
|
+
export interface TicketStateCount {
|
|
232
|
+
name: string
|
|
233
|
+
tickets: number
|
|
234
|
+
}
|
|
235
|
+
|
|
186
236
|
/** Source methods may reject with this failure; it is not a dependency verdict. */
|
|
187
237
|
export class TicketSourceRateLimitError extends Error {
|
|
188
238
|
constructor(
|
|
@@ -223,10 +273,56 @@ export interface TicketSource {
|
|
|
223
273
|
/** Opt in only when kind/target persistence, graph validation and complete
|
|
224
274
|
* enumeration are supported at every write boundary, including guarded writes. */
|
|
225
275
|
readonly integrationTree?: boolean
|
|
276
|
+
/** Opt in only when issue links are persisted and returned at every write
|
|
277
|
+
* boundary, including create and guarded writes. Sources without it refuse
|
|
278
|
+
* any write naming issue links. */
|
|
279
|
+
readonly issueLinks?: boolean
|
|
280
|
+
/** Opt in only when urgent priority is persisted and returned at every write
|
|
281
|
+
* boundary, including create and guarded writes. Sources without it read
|
|
282
|
+
* every ticket as normal and refuse any write naming `urgent`. */
|
|
283
|
+
readonly priority?: boolean
|
|
284
|
+
/** Opt in only when `listReady` (and `listPage`, if implemented) honour
|
|
285
|
+
* `criteria.assignee` and an unassigned ticket is never ready while it is
|
|
286
|
+
* set. Sources without it refuse `[tickets].readyAssignee` at startup,
|
|
287
|
+
* `ab init --validate` and on reload, naming the source. */
|
|
288
|
+
readonly readyAssignee?: boolean
|
|
289
|
+
/** Resolve, outside any dispatcher tick, what a value like `me` needs (for
|
|
290
|
+
* example the credential's owner). Dispatch calls it once at startup whether
|
|
291
|
+
* or not `readyAssignee` is set. Memoize the result; record a credential
|
|
292
|
+
* with no user instead of throwing, and throw only for infrastructure
|
|
293
|
+
* failures. */
|
|
294
|
+
prepareReadyAssignee?(): Promise<void>
|
|
295
|
+
/** Synchronous and request-free: why this value cannot be honoured given
|
|
296
|
+
* what `prepareReadyAssignee` resolved, or undefined. Checked at dispatcher
|
|
297
|
+
* startup and on every reload. */
|
|
298
|
+
readyAssigneeRefusal?(value: string): string | undefined
|
|
299
|
+
/** `ab init --validate`: a one-line summary of who the value names (for
|
|
300
|
+
* example `me → @octocat`); throws an actionable error when it names nobody. */
|
|
301
|
+
describeReadyAssignee?(value: string): Promise<string>
|
|
226
302
|
/** Every lifecycle state, including archived/completed tickets; no ready gate. */
|
|
227
303
|
listAll?(): Promise<TicketListing>
|
|
304
|
+
/** Optional bounded integration read: every ticket in every lifecycle state
|
|
305
|
+
* whose target is `nodeId`, exhausting pagination — exactly
|
|
306
|
+
* `listAll().tickets.filter(t => t.target === nodeId)`. Diagnostics name only
|
|
307
|
+
* excluded records it read. Infrastructure failures reject; a failure never
|
|
308
|
+
* falls back to `listAll`. Sources declaring it must declare integrationTree. */
|
|
309
|
+
listTargeting?(nodeId: string): Promise<TicketListing>
|
|
228
310
|
/** Import support: the same pure id policy used by create, for mutation-free preflight. */
|
|
229
311
|
readonly requestedIds?: import('./tickets/requested-id').RequestedIdPolicy
|
|
312
|
+
/** Import support: the source chooses every created id, so import remaps
|
|
313
|
+
* every ticket and adopts committed creates through the creation key inside
|
|
314
|
+
* `create`. */
|
|
315
|
+
readonly allocatesIds?: boolean
|
|
316
|
+
/** Explicit comment history, oldest first, for export and import only;
|
|
317
|
+
* `null` for an unknown ticket. Never called on a recurring path. */
|
|
318
|
+
readComments?(id: string): Promise<TicketComment[] | null>
|
|
319
|
+
/** Every planned import input this source would refuse, reported together
|
|
320
|
+
* before any import write. */
|
|
321
|
+
importProblems?(input: {
|
|
322
|
+
states: string[]
|
|
323
|
+
labels: string[]
|
|
324
|
+
creationKeys: string[]
|
|
325
|
+
}): Promise<string[]>
|
|
230
326
|
readonly assets?: TicketAssetStore
|
|
231
327
|
/** Check and mutate at the source boundary; absent means checks are unsupported. */
|
|
232
328
|
mutateIfRevision?(id: string, expectedRevision: string, mutation: TicketMutation): Promise<void>
|
|
@@ -273,6 +369,14 @@ export interface TicketSource {
|
|
|
273
369
|
* Sources that cannot enumerate their states omit it.
|
|
274
370
|
*/
|
|
275
371
|
listStates?(): Promise<TicketStateInfo[]>
|
|
372
|
+
/**
|
|
373
|
+
* Optional bounded per-state counts for the named states (display only).
|
|
374
|
+
* Each name resolves like `resolveState` (exact, else one case-insensitive
|
|
375
|
+
* match); unmatched or ambiguous names are omitted. Never returns or parses
|
|
376
|
+
* ticket rows. A store-backed source answers from maintained totals, so its
|
|
377
|
+
* cost does not grow with the number of tickets.
|
|
378
|
+
*/
|
|
379
|
+
countStates?(names: readonly string[]): Promise<TicketStateCount[]>
|
|
276
380
|
/**
|
|
277
381
|
* Optional state creation (`ab ticket state create`). Duplicate policy is
|
|
278
382
|
* adapter-specific: file creation is idempotent and can replace purpose;
|
|
@@ -302,6 +406,15 @@ export interface WorkspaceHandle {
|
|
|
302
406
|
export interface WorkspaceProvisionResult extends WorkspaceHandle {
|
|
303
407
|
/** Durable evidence for the commit this provision selected or reused. */
|
|
304
408
|
base: WorkspaceBase
|
|
409
|
+
/** Preserved branch heads not restored over the branch. Omitted when empty. */
|
|
410
|
+
restorationSkipped?: RestorationSkip[]
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** A preserved branch head the branch already contains, or that a recorded
|
|
414
|
+
* rewrite in the build's bounded replaced-head record superseded. */
|
|
415
|
+
export interface RestorationSkip {
|
|
416
|
+
sha: string
|
|
417
|
+
reason: 'contained' | 'superseded'
|
|
305
418
|
}
|
|
306
419
|
|
|
307
420
|
/** A provider refused to destroy a checkout during provision/start. The
|
|
@@ -348,6 +461,14 @@ export interface WorkspacePublication {
|
|
|
348
461
|
branch: string
|
|
349
462
|
base: string
|
|
350
463
|
candidates: string[]
|
|
464
|
+
/** Shas a recorded rewrite replaced (bounded, newest last). A local
|
|
465
|
+
* branch they cover is archived only as a producer, never as `branch`. */
|
|
466
|
+
replaced?: string[]
|
|
467
|
+
/** True only when the dispatcher's log shows no execution ever started in
|
|
468
|
+
* this environment. Such a checkout holds no unpublished work, so objects
|
|
469
|
+
* it lacks mean nothing to preserve rather than an error. Absent keeps
|
|
470
|
+
* every object probe strict. */
|
|
471
|
+
neverExecuted?: boolean
|
|
351
472
|
}): Promise<{ outcome: 'preserved'; heads: WorkspacePreservationHead[] } | { outcome: 'absent' }>
|
|
352
473
|
|
|
353
474
|
/** Trusted after-teardown path; never route a restack through plain publish. */
|
|
@@ -434,6 +555,10 @@ export interface WorkspaceProvider {
|
|
|
434
555
|
* Providers must preserve unknown unpublished work during ordinary resume. */
|
|
435
556
|
publication?: { sha: string; cacheHeads: string[] }
|
|
436
557
|
restoration?: WorkspacePreservationHead[]
|
|
558
|
+
/** The build's bounded replaced-head record, newest last. A preserved
|
|
559
|
+
* branch head it covers must not be restored over the branch; report it
|
|
560
|
+
* in `restorationSkipped`. */
|
|
561
|
+
restorationReplaced?: string[]
|
|
437
562
|
/** Immutable recovery checkpoint, never a moved base branch. */
|
|
438
563
|
revision?: string
|
|
439
564
|
/** Monotonic environment generation used in provider idempotency keys. */
|
|
@@ -545,11 +670,24 @@ export interface BuildLandingOptions {
|
|
|
545
670
|
baseBranch?: string
|
|
546
671
|
/** Refresh durable consent and pipeline eligibility before native mutation. */
|
|
547
672
|
canApply?: () => Promise<boolean>
|
|
673
|
+
/** The build's sealed issue links, passed only to a `closesIssues` forge
|
|
674
|
+
* for a leaf aimed at the default branch. The adapter composes them into
|
|
675
|
+
* the landed headline and message with `kernel/issue-keywords`. */
|
|
676
|
+
issueLinks?: readonly IssueLink[]
|
|
548
677
|
}
|
|
549
678
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
679
|
+
/** GitHub's "No commits between" 422: a forge rejection the empty-node path
|
|
680
|
+
* recognizes by class. */
|
|
681
|
+
export class NoCommitsBetweenBranchesError extends ForgeRejection {
|
|
682
|
+
constructor(
|
|
683
|
+
message: string,
|
|
684
|
+
rejection: { forge?: string; status?: number; forgeMessage?: string } = {},
|
|
685
|
+
) {
|
|
686
|
+
super(message, {
|
|
687
|
+
forge: rejection.forge ?? 'GitHub',
|
|
688
|
+
status: rejection.status ?? 422,
|
|
689
|
+
forgeMessage: rejection.forgeMessage || message,
|
|
690
|
+
})
|
|
553
691
|
this.name = 'NoCommitsBetweenBranchesError'
|
|
554
692
|
}
|
|
555
693
|
}
|
|
@@ -592,9 +730,10 @@ export type LandingGateInspection =
|
|
|
592
730
|
| { kind: 'gated'; reason: string }
|
|
593
731
|
| { kind: 'unproven'; reason: string }
|
|
594
732
|
|
|
595
|
-
export { ForgeFailure, isForgeFailure } from './forge-failure'
|
|
733
|
+
export { ForgeFailure, ForgeRejection, isForgeFailure, isForgeRejection } from './forge-failure'
|
|
596
734
|
export type {
|
|
597
735
|
ForgeFailureDetails,
|
|
736
|
+
ForgeRejectionDetails,
|
|
598
737
|
ForgeRequestContext,
|
|
599
738
|
ForgeRequestObserver,
|
|
600
739
|
} from './forge-failure'
|
|
@@ -645,6 +784,22 @@ export interface Forge {
|
|
|
645
784
|
}>
|
|
646
785
|
|
|
647
786
|
readonly name: string
|
|
787
|
+
/** Closing keywords that reach the default branch close issues. A forge
|
|
788
|
+
* declaring it composes `issueLinks` into the PR title and body and into
|
|
789
|
+
* landing messages; without it links are recorded but never emitted. */
|
|
790
|
+
readonly closesIssues?: boolean
|
|
791
|
+
/** Rewrite an open PR's keyword paragraph so the body ends with one line
|
|
792
|
+
* per link (composed with `kernel/issue-keywords`, `trailers: false`) and
|
|
793
|
+
* neutralize closing references to `refs` issues in its title, writing
|
|
794
|
+
* only on change, then confirm both by readback. Called only with
|
|
795
|
+
* `closesIssues`, for a node's PR. Throws when the PR is not open or the
|
|
796
|
+
* readback disagrees. Without it a node's set is recorded but never
|
|
797
|
+
* written. */
|
|
798
|
+
updatePrIssueLinks?(
|
|
799
|
+
workspacePath: string,
|
|
800
|
+
number: number,
|
|
801
|
+
issueLinks: readonly IssueLink[],
|
|
802
|
+
): Promise<void>
|
|
648
803
|
/** Optional because another forge may support PRs but not public image assets. */
|
|
649
804
|
readonly prAttachments?: PrAttachmentHosting
|
|
650
805
|
/** Publish this exact SHA (HEAD for legacy callers); success requires authoritative readback. */
|
|
@@ -661,6 +816,16 @@ export interface Forge {
|
|
|
661
816
|
/** Untouched deposited pr-description. Providers may use it as the
|
|
662
817
|
* landing message; title/body remain the portable review projection. */
|
|
663
818
|
mergeMessage?: string
|
|
819
|
+
/** Issue links, passed only to a `closesIssues` forge: a leaf aimed at
|
|
820
|
+
* the default branch gets its sealed links; a leaf aimed at a node gets
|
|
821
|
+
* them refs-only; a root node gets its own links merged with its landed
|
|
822
|
+
* children's union; a nested node gets that set refs-only. An adapter
|
|
823
|
+
* that adopts an existing open PR for the head must converge it
|
|
824
|
+
* idempotently when links are present: neutralize the existing title,
|
|
825
|
+
* canonicalize the body's keyword lines, write only on change and
|
|
826
|
+
* confirm by readback, without replacing the title, prose or merge
|
|
827
|
+
* message. */
|
|
828
|
+
issueLinks?: readonly IssueLink[]
|
|
664
829
|
}): Promise<PrRef>
|
|
665
830
|
/** Optional authoritative base resolver. Capability-less adapters retain
|
|
666
831
|
* the legacy origin fetch performed by the caller. The destination is a
|
|
@@ -682,6 +847,9 @@ export interface Forge {
|
|
|
682
847
|
* gate. Transient merge states defer quietly; non-transient inability to
|
|
683
848
|
* inspect or apply consent returns a reason-bearing deferral. The operation
|
|
684
849
|
* is idempotent and safe to retry across the forge-call/event-append crash window.
|
|
850
|
+
* With options it is also called on every eligible poll while a request is
|
|
851
|
+
* armed: a matching request returns `applied` without mutation, and any
|
|
852
|
+
* repair calls `options.canApply` first.
|
|
685
853
|
*/
|
|
686
854
|
setAutoMerge(
|
|
687
855
|
workspacePath: string,
|
|
@@ -711,6 +879,12 @@ export interface Forge {
|
|
|
711
879
|
/** Authoritative forge branch tip. Absence or failure must defer target
|
|
712
880
|
* observation; callers must never substitute dispatcher-host refs. */
|
|
713
881
|
remoteBranchSha?(branch: string): Promise<string>
|
|
882
|
+
/** Whether `branch` exists on the authoritative forge remote. False is proven
|
|
883
|
+
* absence; transport, auth or malformed responses throw. Dispatch uses it at
|
|
884
|
+
* claim time so a new build never takes a branch another store owns, and to
|
|
885
|
+
* recognize a target node branch another store opened. Absent capability keeps
|
|
886
|
+
* store-only slug deduplication and reports one startup warning. */
|
|
887
|
+
remoteBranchExists?(branch: string): Promise<boolean>
|
|
714
888
|
/** Prove ancestry of immutable commit OIDs in the authoritative repository.
|
|
715
889
|
* False means a proven non-descendant; absent capability or unknown objects
|
|
716
890
|
* must fail closed, never authorize replay. */
|
|
@@ -835,12 +1009,15 @@ export interface AgentStartOpts {
|
|
|
835
1009
|
stream?: SessionStreamEmitter
|
|
836
1010
|
}
|
|
837
1011
|
|
|
1012
|
+
/** The inputs a runtime's start prompt depends on; no env, workspace or signal. */
|
|
1013
|
+
export type StartPromptOpts = Pick<AgentStartOpts, 'skill' | 'invocation' | 'buildSlug'>
|
|
1014
|
+
|
|
838
1015
|
/** Per-turn refresh for a continued session (§10): each continue turn is a
|
|
839
1016
|
* NEW session bracket (next round, fresh session id), so the runner
|
|
840
1017
|
* re-issues ambient auth for the turn (D8) — merged over the start env. A
|
|
841
1018
|
* turn left on round 1's env would have the CLI resolve the stale round and
|
|
842
1019
|
* reject the continued round's terminal as a D5 second call (§8.4). */
|
|
843
|
-
export function agentInvocation(opts:
|
|
1020
|
+
export function agentInvocation(opts: StartPromptOpts): string {
|
|
844
1021
|
const invocation = opts.invocation ?? opts.buildSlug
|
|
845
1022
|
if (invocation === undefined || invocation === '') {
|
|
846
1023
|
throw new Error('AgentStartOpts requires a non-empty invocation')
|
|
@@ -868,6 +1045,10 @@ export interface AgentRunner {
|
|
|
868
1045
|
opts: AgentResumeOpts,
|
|
869
1046
|
): Promise<AgentResumeResult>
|
|
870
1047
|
start(opts: AgentStartOpts): Promise<{ session: AgentSessionHandle; result: AgentTurnResult }>
|
|
1048
|
+
/** The exact first message `start(opts)` sends for these inputs. The kernel
|
|
1049
|
+
* records it on `session.started` before launch. Omit it when unknown;
|
|
1050
|
+
* the fact then records no prompt. */
|
|
1051
|
+
startPrompt?(opts: StartPromptOpts): string
|
|
871
1052
|
/** Review-loop rounds (§10), continuing the live native conversation. */
|
|
872
1053
|
continue(
|
|
873
1054
|
session: AgentSessionHandle,
|
|
@@ -1,8 +1,73 @@
|
|
|
1
1
|
import type { Exec } from './git-worktree'
|
|
2
|
-
import type { ForgeRewrite, WorkspacePreservationHead } from '../types'
|
|
2
|
+
import type { ForgeRewrite, RestorationSkip, WorkspacePreservationHead } from '../types'
|
|
3
|
+
|
|
4
|
+
const OID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/
|
|
5
|
+
|
|
6
|
+
/** The replaced sha in the bounded record that equals or contains `sha`.
|
|
7
|
+
* Replaced commits were published once and stay archived under
|
|
8
|
+
* `<archivePrefix><sha>`; a remote workspace fetches only those it lacks.
|
|
9
|
+
* Missing objects or unreadable archives mean "not covered", never an error. */
|
|
10
|
+
export async function supersedingReplacedHead(input: {
|
|
11
|
+
exec: Exec
|
|
12
|
+
workspacePath: string
|
|
13
|
+
sha: string
|
|
14
|
+
replaced: string[]
|
|
15
|
+
archivePrefix: string
|
|
16
|
+
local?: boolean
|
|
17
|
+
}): Promise<string | undefined> {
|
|
18
|
+
if (!OID.test(input.sha) || !input.replaced.every((sha) => OID.test(sha)))
|
|
19
|
+
throw new Error('invalid replaced head')
|
|
20
|
+
if (!/^refs\/autobuild\/archive\/[a-z0-9-]+\/$/.test(input.archivePrefix))
|
|
21
|
+
throw new Error('invalid replaced head archive prefix')
|
|
22
|
+
if (input.replaced.includes(input.sha)) return input.sha
|
|
23
|
+
const run = (args: string[]) => input.exec(['git', ...args], { cwd: input.workspacePath })
|
|
24
|
+
const newestFirst = [...input.replaced].reverse()
|
|
25
|
+
const contain = async (candidates: string[]) => {
|
|
26
|
+
const missing: string[] = []
|
|
27
|
+
for (const replaced of candidates) {
|
|
28
|
+
const result = await run(['merge-base', '--is-ancestor', input.sha, replaced])
|
|
29
|
+
if (result.exitCode === 0) return { covering: replaced, missing }
|
|
30
|
+
if (result.exitCode !== 1) missing.push(replaced)
|
|
31
|
+
}
|
|
32
|
+
return { covering: undefined, missing }
|
|
33
|
+
}
|
|
34
|
+
const first = await contain(newestFirst)
|
|
35
|
+
if (first.covering || input.local || first.missing.length === 0) return first.covering
|
|
36
|
+
const refs = first.missing.map((sha) => `${input.archivePrefix}${sha}`)
|
|
37
|
+
const listed = await run(['ls-remote', '--refs', 'origin', ...refs])
|
|
38
|
+
if (listed.exitCode !== 0) return undefined
|
|
39
|
+
const advertised = new Set(
|
|
40
|
+
listed.stdout
|
|
41
|
+
.split('\n')
|
|
42
|
+
.map((line) => line.trim().split(/\s+/))
|
|
43
|
+
.filter(([sha, ref]) => ref === `${input.archivePrefix}${sha}`)
|
|
44
|
+
.map(([, ref]) => ref!),
|
|
45
|
+
)
|
|
46
|
+
const fetchable = refs.filter((ref) => advertised.has(ref))
|
|
47
|
+
if (fetchable.length === 0) return undefined
|
|
48
|
+
const fetched = await run([
|
|
49
|
+
'fetch',
|
|
50
|
+
'--no-tags',
|
|
51
|
+
'--no-write-fetch-head',
|
|
52
|
+
'--refmap=',
|
|
53
|
+
'origin',
|
|
54
|
+
...fetchable.map((ref) => `+${ref}:${ref}`),
|
|
55
|
+
])
|
|
56
|
+
if (fetched.exitCode !== 0) return undefined
|
|
57
|
+
const verified: string[] = []
|
|
58
|
+
for (const ref of fetchable) {
|
|
59
|
+
const sha = ref.slice(input.archivePrefix.length)
|
|
60
|
+
const actual = await run(['rev-parse', '--verify', `${ref}^{commit}`])
|
|
61
|
+
if (actual.exitCode === 0 && actual.stdout.trim() === sha) verified.push(sha)
|
|
62
|
+
}
|
|
63
|
+
return (await contain(verified)).covering
|
|
64
|
+
}
|
|
3
65
|
|
|
4
66
|
/** Boundary-only Git inspection. Inventory traverses the unpublished change,
|
|
5
|
-
* while immutable archive acknowledgement proves the tip and its ancestry.
|
|
67
|
+
* while immutable archive acknowledgement proves the tip and its ancestry.
|
|
68
|
+
* With `neverExecuted`, a non-zero object probe means the checkout lacks that
|
|
69
|
+
* object: a missing base preserves nothing, and a missing `HEAD`, branch or
|
|
70
|
+
* candidate is skipped. Traversal and archive failures stay strict. */
|
|
6
71
|
export async function preserveGitCommits(input: {
|
|
7
72
|
exec: Exec
|
|
8
73
|
workspacePath: string
|
|
@@ -11,6 +76,13 @@ export async function preserveGitCommits(input: {
|
|
|
11
76
|
base: string
|
|
12
77
|
candidates: string[]
|
|
13
78
|
archive: ForgeRewrite['archive']
|
|
79
|
+
/** Shas a recorded rewrite replaced; a local branch they cover is
|
|
80
|
+
* archived as a producer so restoration never moves the branch to it. */
|
|
81
|
+
replaced?: string[]
|
|
82
|
+
local?: boolean
|
|
83
|
+
/** No execution ever started in this environment, so it holds no
|
|
84
|
+
* unpublished work and absent objects are not an error. */
|
|
85
|
+
neverExecuted?: boolean
|
|
14
86
|
}): Promise<WorkspacePreservationHead[]> {
|
|
15
87
|
const git = async (args: string[], optional = false) => {
|
|
16
88
|
const result = await input.exec(['git', ...args], { cwd: input.workspacePath })
|
|
@@ -18,23 +90,33 @@ export async function preserveGitCommits(input: {
|
|
|
18
90
|
throw new Error(`workspace preservation git ${args.join(' ')} failed: ${result.stderr}`)
|
|
19
91
|
return result
|
|
20
92
|
}
|
|
21
|
-
|
|
93
|
+
// An object probe: present, or (only for a never-executed checkout) absent.
|
|
94
|
+
const probe = (args: string[], optional = false) =>
|
|
95
|
+
input.neverExecuted
|
|
96
|
+
? input.exec(['git', ...args], { cwd: input.workspacePath })
|
|
97
|
+
: git(args, optional)
|
|
98
|
+
const branch = await probe(
|
|
22
99
|
['rev-parse', '--verify', '--quiet', `refs/heads/${input.branch}^{commit}`],
|
|
23
100
|
true,
|
|
24
101
|
)
|
|
25
|
-
const head = await
|
|
102
|
+
const head = await probe(['rev-parse', '--verify', 'HEAD^{commit}'])
|
|
26
103
|
const heads: WorkspacePreservationHead[] = []
|
|
27
104
|
const branchSha = branch.exitCode === 0 ? branch.stdout.trim() : undefined
|
|
105
|
+
const headSha = head.exitCode === 0 ? head.stdout.trim() : undefined
|
|
28
106
|
const candidates = [
|
|
29
|
-
...new Set([
|
|
107
|
+
...new Set([
|
|
108
|
+
...(branchSha ? [branchSha] : []),
|
|
109
|
+
...(headSha ? [headSha] : []),
|
|
110
|
+
...input.candidates,
|
|
111
|
+
]),
|
|
30
112
|
]
|
|
31
113
|
// The base is the authoritative branch (or recorded immutable initial base),
|
|
32
114
|
// never an arbitrary local remote-tracking cache.
|
|
33
|
-
await
|
|
115
|
+
if ((await probe(['cat-file', '-e', `${input.base}^{commit}`])).exitCode !== 0) return []
|
|
34
116
|
for (const sha of candidates) {
|
|
35
117
|
if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(sha))
|
|
36
118
|
throw new Error('invalid preservation candidate')
|
|
37
|
-
await
|
|
119
|
+
if ((await probe(['cat-file', '-e', `${sha}^{commit}`])).exitCode !== 0) continue
|
|
38
120
|
const commits = (await git(['rev-list', sha, `^${input.base}`])).stdout
|
|
39
121
|
.trim()
|
|
40
122
|
.split('\n')
|
|
@@ -42,20 +124,41 @@ export async function preserveGitCommits(input: {
|
|
|
42
124
|
if (commits.length === 0) continue
|
|
43
125
|
const remoteRef = `refs/autobuild/archive/${input.slug}/${sha}`
|
|
44
126
|
await input.archive({ workspacePath: input.workspacePath, ref: remoteRef, sha })
|
|
45
|
-
|
|
127
|
+
const superseded =
|
|
128
|
+
sha === branchSha &&
|
|
129
|
+
!!input.replaced?.length &&
|
|
130
|
+
(await supersedingReplacedHead({
|
|
131
|
+
exec: input.exec,
|
|
132
|
+
workspacePath: input.workspacePath,
|
|
133
|
+
sha,
|
|
134
|
+
replaced: input.replaced,
|
|
135
|
+
archivePrefix: `refs/autobuild/archive/${input.slug}/`,
|
|
136
|
+
local: input.local,
|
|
137
|
+
})) !== undefined
|
|
138
|
+
heads.push({
|
|
139
|
+
sha,
|
|
140
|
+
remoteRef,
|
|
141
|
+
role: sha === branchSha && !superseded ? 'branch' : 'producer',
|
|
142
|
+
commits,
|
|
143
|
+
})
|
|
46
144
|
}
|
|
47
145
|
return heads
|
|
48
146
|
}
|
|
49
147
|
|
|
50
148
|
/** Fetch only recorded immutable refs. Attaching an unpublished branch is safe
|
|
51
|
-
* only over an ancestor; detached producer objects never move the branch.
|
|
149
|
+
* only over an ancestor; detached producer objects never move the branch.
|
|
150
|
+
* Branch heads the branch contains, or that a replaced head in the bounded
|
|
151
|
+
* record covers, are classified before any mutation and skipped. */
|
|
52
152
|
export async function restoreGitCommits(input: {
|
|
53
153
|
exec: Exec
|
|
54
154
|
workspacePath: string
|
|
55
155
|
branch: string
|
|
56
156
|
heads: WorkspacePreservationHead[]
|
|
157
|
+
/** The build's bounded replaced-head record, newest last. */
|
|
158
|
+
replaced?: string[]
|
|
57
159
|
local?: boolean
|
|
58
|
-
}): Promise<
|
|
160
|
+
}): Promise<{ skipped: RestorationSkip[] }> {
|
|
161
|
+
const skipped: RestorationSkip[] = []
|
|
59
162
|
const git = async (args: string[], optional = false) => {
|
|
60
163
|
const result = await input.exec(['git', ...args], { cwd: input.workspacePath })
|
|
61
164
|
if (result.exitCode !== 0 && !optional)
|
|
@@ -85,9 +188,27 @@ export async function restoreGitCommits(input: {
|
|
|
85
188
|
if (head.role !== 'branch') continue
|
|
86
189
|
const ref = `refs/heads/${input.branch}`
|
|
87
190
|
const current = (await git(['rev-parse', '--verify', ref])).stdout.trim()
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
191
|
+
const preservedAncestor =
|
|
192
|
+
current === head.sha ||
|
|
193
|
+
(await git(['merge-base', '--is-ancestor', head.sha, current], true)).exitCode === 0
|
|
194
|
+
if (preservedAncestor) {
|
|
195
|
+
skipped.push({ sha: head.sha, reason: 'contained' })
|
|
196
|
+
continue
|
|
197
|
+
}
|
|
198
|
+
if (
|
|
199
|
+
input.replaced?.length &&
|
|
200
|
+
(await supersedingReplacedHead({
|
|
201
|
+
exec: input.exec,
|
|
202
|
+
workspacePath: input.workspacePath,
|
|
203
|
+
sha: head.sha,
|
|
204
|
+
replaced: input.replaced,
|
|
205
|
+
archivePrefix: head.remoteRef.slice(0, -head.sha.length),
|
|
206
|
+
local: input.local,
|
|
207
|
+
})) !== undefined
|
|
208
|
+
) {
|
|
209
|
+
skipped.push({ sha: head.sha, reason: 'superseded' })
|
|
210
|
+
continue
|
|
211
|
+
}
|
|
91
212
|
const currentAncestor = await git(['merge-base', '--is-ancestor', current, head.sha], true)
|
|
92
213
|
if (currentAncestor.exitCode !== 0)
|
|
93
214
|
throw new Error('workspace restoration would overwrite divergent branch work')
|
|
@@ -97,6 +218,7 @@ export async function restoreGitCommits(input: {
|
|
|
97
218
|
const attached = (await git(['symbolic-ref', '--quiet', 'HEAD'], true)).stdout.trim()
|
|
98
219
|
if (attached === ref) await git(['reset', '--hard', head.sha])
|
|
99
220
|
}
|
|
221
|
+
return { skipped }
|
|
100
222
|
}
|
|
101
223
|
|
|
102
224
|
/** Trusted exact-resource probe shared by hosted and local recovery. */
|
|
@@ -328,13 +328,15 @@ export class GitWorktreeProvider implements WorkspaceProvider {
|
|
|
328
328
|
): Promise<WorkspaceProvisionResult> {
|
|
329
329
|
const handle = await this.provisionCore(opts)
|
|
330
330
|
if (opts.restoration?.length) {
|
|
331
|
-
await restoreGitCommits({
|
|
331
|
+
const { skipped } = await restoreGitCommits({
|
|
332
332
|
exec: this.exec,
|
|
333
333
|
workspacePath: handle.path,
|
|
334
334
|
branch: opts.branch,
|
|
335
335
|
heads: opts.restoration,
|
|
336
|
+
replaced: opts.restorationReplaced,
|
|
336
337
|
local: true,
|
|
337
338
|
})
|
|
339
|
+
if (skipped.length) handle.restorationSkipped = skipped
|
|
338
340
|
handle.base = {
|
|
339
341
|
source: 'existing',
|
|
340
342
|
sha: await this.resolveCommit(handle.path, `refs/heads/${opts.branch}`),
|