@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,3 +1,6 @@
|
|
|
1
|
+
import { suspendNativeLanding } from '../kernel/landing-publication'
|
|
2
|
+
import { validateNodeChange } from '../kernel/node-restack'
|
|
3
|
+
import { validateRestack, retainReplay } from '../kernel/reconcile-restack'
|
|
1
4
|
import { readBuildFacts, readTerminalGuard, type CurrentBuildFacts } from '../store/reduced-reads'
|
|
2
5
|
/**
|
|
3
6
|
* The three terminal commands — `ab done`, `ab verdict`, `ab escalate`
|
|
@@ -23,11 +26,6 @@ import type { EventEnvelope } from '../events/catalog'
|
|
|
23
26
|
import { agentActor, KERNEL } from '../events/envelope'
|
|
24
27
|
import { isRemoteWorkspace } from '../events/workspace-remote'
|
|
25
28
|
import type { IdSource } from '../ids'
|
|
26
|
-
import {
|
|
27
|
-
autoMergeApplicationType,
|
|
28
|
-
pendingAutoMerge,
|
|
29
|
-
recordAutoMergeDeferralObservation,
|
|
30
|
-
} from '../kernel/auto-merge'
|
|
31
29
|
import { phaseSpecFor } from '../kernel/phases'
|
|
32
30
|
import { resolvePlanVerifySteps } from '../kernel/plan-verify-selection'
|
|
33
31
|
import {
|
|
@@ -40,11 +38,7 @@ import {
|
|
|
40
38
|
type ReviewVerdictKind,
|
|
41
39
|
} from '../ontology'
|
|
42
40
|
import type { Forge } from '../ports/types'
|
|
43
|
-
import {
|
|
44
|
-
phaseScratchRejection,
|
|
45
|
-
reconcileScratchViolations,
|
|
46
|
-
scratchPathsTouchedInRange,
|
|
47
|
-
} from '../ports/workspace/phase-scratch'
|
|
41
|
+
import { phaseScratchRejection, scratchPathsTouchedInRange } from '../ports/workspace/phase-scratch'
|
|
48
42
|
import type { Exec } from '../ports/workspace/git-worktree'
|
|
49
43
|
import type { ArtifactMeta, BuildStore } from '../store/types'
|
|
50
44
|
import { textContent } from '../store/types'
|
|
@@ -136,7 +130,7 @@ async function assertCleanWorktree(deps: TerminalDeps): Promise<void> {
|
|
|
136
130
|
}
|
|
137
131
|
|
|
138
132
|
function baseBranchOf(events: CurrentBuildFacts): string {
|
|
139
|
-
if (events.
|
|
133
|
+
if (events.state.baseBranch) return events.state.baseBranch
|
|
140
134
|
throw new Error('this build has no build.created event — cannot resolve its baseBranch (§15.3)')
|
|
141
135
|
}
|
|
142
136
|
|
|
@@ -293,41 +287,18 @@ export async function completeFinalizePr(
|
|
|
293
287
|
await preparePrAttachments(deps, events, pr.url)
|
|
294
288
|
|
|
295
289
|
const latest = (await readBuildFacts(store, env.build)).value
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
290
|
+
const nodeTarget = latest.state.target !== undefined
|
|
291
|
+
if (nodeTarget) {
|
|
292
|
+
const cancellation = await deps.forge.setAutoMerge(deps.workspacePath, pr.number, false)
|
|
293
|
+
if (cancellation.kind !== 'applied')
|
|
294
|
+
throw new Error('node-target native auto-merge cancellation unconfirmed')
|
|
295
|
+
}
|
|
302
296
|
const event = await store.append(env.build, {
|
|
303
297
|
actor: KERNEL,
|
|
304
298
|
type: 'finalize.completed',
|
|
305
299
|
payload: { pr },
|
|
306
300
|
})
|
|
307
301
|
|
|
308
|
-
if (autoMerge !== undefined) {
|
|
309
|
-
try {
|
|
310
|
-
if (autoMergeResult?.kind === 'applied') {
|
|
311
|
-
await store.append(env.build, {
|
|
312
|
-
actor: KERNEL,
|
|
313
|
-
type: autoMergeApplicationType(autoMerge.enabled),
|
|
314
|
-
payload: { commandSeq: autoMerge.commandSeq },
|
|
315
|
-
})
|
|
316
|
-
} else if (autoMergeResult?.kind === 'deferred' && autoMergeResult.reason !== undefined) {
|
|
317
|
-
await recordAutoMergeDeferralObservation(
|
|
318
|
-
store,
|
|
319
|
-
env.build,
|
|
320
|
-
autoMergeResult.reason,
|
|
321
|
-
pr.number,
|
|
322
|
-
autoMerge.commandSeq,
|
|
323
|
-
deps.ids('obs'),
|
|
324
|
-
)
|
|
325
|
-
}
|
|
326
|
-
} catch {
|
|
327
|
-
// The janitor retries unmatched commands and provider diagnostics.
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
302
|
return event
|
|
332
303
|
}
|
|
333
304
|
|
|
@@ -421,6 +392,7 @@ export async function done(deps: TerminalDeps, opts: DoneOpts = {}): Promise<Eve
|
|
|
421
392
|
return event
|
|
422
393
|
}
|
|
423
394
|
// Local publication remains immediate and push-before-fact.
|
|
395
|
+
await suspendNativeLanding({ ...deps, slug: env.build }, `implement:${env.round}`)
|
|
424
396
|
await deps.forge.pushBranch(deps.workspacePath, branch)
|
|
425
397
|
const { event } = await store.appendWithArtifacts(
|
|
426
398
|
env.build,
|
|
@@ -483,55 +455,81 @@ export async function done(deps: TerminalDeps, opts: DoneOpts = {}): Promise<Eve
|
|
|
483
455
|
const notesPath = requireNotes(opts.notes, "reconcile's 'ab done' deposits reconcile-notes")
|
|
484
456
|
const notes = await readTextFile(notesPath, '--notes')
|
|
485
457
|
await assertCleanWorktree(deps)
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
`HEAD ${head} has ${parts.length - 1} parent(s); merge the base branch ` +
|
|
495
|
-
'into this branch first (§15.7, D1: never rebase)',
|
|
496
|
-
)
|
|
497
|
-
}
|
|
498
|
-
const scratchPaths = await reconcileScratchViolations(
|
|
499
|
-
deps.exec,
|
|
500
|
-
deps.workspacePath,
|
|
501
|
-
head,
|
|
502
|
-
parts.slice(1),
|
|
503
|
-
)
|
|
504
|
-
if (scratchPaths.length > 0) throw phaseScratchRejection(scratchPaths)
|
|
505
|
-
const branch = await buildBranch(deps)
|
|
506
|
-
if (remotePublication(events)) {
|
|
507
|
-
const { event } = await store.appendWithArtifacts(
|
|
458
|
+
const node = events.state.nodeRestack
|
|
459
|
+
if (node?.conflict && node.active) {
|
|
460
|
+
const conflict = node.conflict
|
|
461
|
+
const change = node.active.changes[conflict.index]!
|
|
462
|
+
const head = (await git(deps, ['rev-parse', 'HEAD'])).trim()
|
|
463
|
+
await validateNodeChange(deps, change, conflict.base, head)
|
|
464
|
+
await retainReplay({ ...deps, slug: env.build }, head, conflict.base)
|
|
465
|
+
const deposited = await store.appendWithArtifacts(
|
|
508
466
|
env.build,
|
|
509
467
|
[{ kind: 'reconcile-notes', content: notes }],
|
|
510
|
-
(
|
|
511
|
-
actor,
|
|
512
|
-
type: '
|
|
468
|
+
() => ({
|
|
469
|
+
actor: KERNEL,
|
|
470
|
+
type: 'node.item-replayed',
|
|
513
471
|
payload: {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
472
|
+
id: node.active!.id,
|
|
473
|
+
index: conflict.index,
|
|
474
|
+
base: conflict.base,
|
|
475
|
+
head,
|
|
476
|
+
dropped: false,
|
|
518
477
|
},
|
|
519
478
|
}),
|
|
520
479
|
)
|
|
521
|
-
return
|
|
480
|
+
return store.append(env.build, {
|
|
481
|
+
actor,
|
|
482
|
+
type: 'reconcile.completed',
|
|
483
|
+
payload: {
|
|
484
|
+
headSha: head,
|
|
485
|
+
rewriteId: node.active.id,
|
|
486
|
+
artifact: refOf(deposited.artifacts[0]),
|
|
487
|
+
},
|
|
488
|
+
})
|
|
522
489
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
490
|
+
const transaction = events.reconcileTransaction
|
|
491
|
+
if (transaction === undefined || transaction.attempt !== env.round)
|
|
492
|
+
throw new Error(
|
|
493
|
+
'reconcile requires a kernel-prepared single-change replay; restart this reconcile occurrence',
|
|
494
|
+
)
|
|
495
|
+
const head = (await git(deps, ['rev-parse', 'HEAD'])).trim()
|
|
496
|
+
const priorIntent = events.reconcileHistory.findLast(
|
|
497
|
+
(event) =>
|
|
498
|
+
event.type === 'reconcile.publish-intended' && event.payload.id === transaction.id,
|
|
499
|
+
)
|
|
500
|
+
if (
|
|
501
|
+
priorIntent?.type === 'reconcile.publish-intended' &&
|
|
502
|
+
priorIntent.payload.headSha !== head
|
|
503
|
+
)
|
|
504
|
+
throw new Error(
|
|
505
|
+
'the durable reconcile publication intent names another resolved head; restore that head before retrying completion',
|
|
506
|
+
)
|
|
507
|
+
const restack = { ...deps, slug: env.build }
|
|
508
|
+
await validateRestack(restack, transaction, head)
|
|
509
|
+
await retainReplay(restack, head, transaction.targetBase)
|
|
510
|
+
const conflicted =
|
|
511
|
+
events.reconcileReplay?.id === transaction.id && events.reconcileReplay.conflicted
|
|
512
|
+
const { event: intended } = await store.appendWithArtifacts(
|
|
526
513
|
env.build,
|
|
527
514
|
[{ kind: 'reconcile-notes', content: notes }],
|
|
528
515
|
(deposited) => ({
|
|
529
|
-
actor,
|
|
530
|
-
type: 'reconcile.
|
|
531
|
-
payload: {
|
|
516
|
+
actor: KERNEL,
|
|
517
|
+
type: 'reconcile.publish-intended',
|
|
518
|
+
payload: { ...transaction, headSha: head, conflicted, artifact: refOf(deposited[0]) },
|
|
532
519
|
}),
|
|
533
520
|
)
|
|
534
|
-
|
|
521
|
+
// All resolver publications wait until the agent turn has ended.
|
|
522
|
+
return store.append(env.build, {
|
|
523
|
+
actor,
|
|
524
|
+
type: 'publication.requested',
|
|
525
|
+
payload: {
|
|
526
|
+
operation: 'reconcile',
|
|
527
|
+
branch: transaction.branch,
|
|
528
|
+
sha: head,
|
|
529
|
+
artifact: intended.payload.artifact,
|
|
530
|
+
rewrite: { ...transaction, conflicted },
|
|
531
|
+
},
|
|
532
|
+
})
|
|
535
533
|
}
|
|
536
534
|
|
|
537
535
|
default:
|
|
@@ -764,6 +762,25 @@ async function agentVerifyVerdict(
|
|
|
764
762
|
}
|
|
765
763
|
const step = verifyStep(env.phase)
|
|
766
764
|
const reportKind = verifyReportKind(step)
|
|
765
|
+
const facts = (await readBuildFacts(store, env.build)).value
|
|
766
|
+
const start =
|
|
767
|
+
facts.log.restack.gates[
|
|
768
|
+
String(Math.max(facts.log.code.latestApproveSeq, facts.log.lastReconcileCompletedSeq))
|
|
769
|
+
]
|
|
770
|
+
const integrationStart =
|
|
771
|
+
facts.state.kind === 'node'
|
|
772
|
+
? facts.log.verifyStarted.findLast((record) => record.attempt === env.round)
|
|
773
|
+
: undefined
|
|
774
|
+
const evidence =
|
|
775
|
+
integrationStart !== undefined
|
|
776
|
+
? {
|
|
777
|
+
baseSha: integrationStart.baseSha,
|
|
778
|
+
headSha: integrationStart.headSha,
|
|
779
|
+
restackId: integrationStart.restackId,
|
|
780
|
+
}
|
|
781
|
+
: start === undefined
|
|
782
|
+
? {}
|
|
783
|
+
: { baseSha: start.targetBase, headSha: start.headSha, restackId: start.id }
|
|
767
784
|
|
|
768
785
|
if (opts.verdict === 'pass') {
|
|
769
786
|
// Optional --notes are deposited as the step's report kind and the event
|
|
@@ -777,6 +794,7 @@ async function agentVerifyVerdict(
|
|
|
777
794
|
actor,
|
|
778
795
|
type: 'verify.completed',
|
|
779
796
|
payload: {
|
|
797
|
+
...evidence,
|
|
780
798
|
step,
|
|
781
799
|
attempt: env.round,
|
|
782
800
|
outcome: 'pass',
|
|
@@ -790,7 +808,7 @@ async function agentVerifyVerdict(
|
|
|
790
808
|
await store.append(env.build, {
|
|
791
809
|
actor,
|
|
792
810
|
type: 'verify.completed',
|
|
793
|
-
payload: { step, attempt: env.round, outcome: 'pass' },
|
|
811
|
+
payload: { ...evidence, step, attempt: env.round, outcome: 'pass' },
|
|
794
812
|
}),
|
|
795
813
|
]
|
|
796
814
|
}
|
|
@@ -807,7 +825,7 @@ async function agentVerifyVerdict(
|
|
|
807
825
|
await store.append(env.build, {
|
|
808
826
|
actor,
|
|
809
827
|
type: 'verify.completed',
|
|
810
|
-
payload: { step, attempt: env.round, outcome: 'skipped', reason },
|
|
828
|
+
payload: { ...evidence, step, attempt: env.round, outcome: 'skipped', reason },
|
|
811
829
|
}),
|
|
812
830
|
]
|
|
813
831
|
}
|
|
@@ -827,6 +845,7 @@ async function agentVerifyVerdict(
|
|
|
827
845
|
actor,
|
|
828
846
|
type: 'verify.completed',
|
|
829
847
|
payload: {
|
|
848
|
+
...evidence,
|
|
830
849
|
step,
|
|
831
850
|
attempt: env.round,
|
|
832
851
|
outcome: 'fail',
|
|
@@ -31,14 +31,19 @@ export async function editTicket(
|
|
|
31
31
|
const ticket = await requireTicket(source, id)
|
|
32
32
|
const front = {
|
|
33
33
|
id,
|
|
34
|
+
kind: ticket.kind ?? 'work',
|
|
35
|
+
...(ticket.target !== undefined ? { target: ticket.target } : {}),
|
|
34
36
|
title: ticket.title,
|
|
35
37
|
labels: [...ticket.labels],
|
|
36
38
|
blockedBy: [...(ticket.blockedBy ?? [])],
|
|
37
39
|
...(ticket.creationKey !== undefined ? { idempotencyKey: ticket.creationKey } : {}),
|
|
38
40
|
}
|
|
39
41
|
// Reference comments remain part of the frontmatter, outside the editable keys.
|
|
40
|
-
const reference = `# Read-only reference\n# state = ${JSON.stringify(ticket.state ?? null)}\n# revision = ${JSON.stringify(ticket.revision)}\n`
|
|
41
|
-
const serialized = serializeTicketFile(front, ticket.body)
|
|
42
|
+
const reference = `# Read-only reference\n# target = ${JSON.stringify(ticket.target ?? null)} (root when null)\n# state = ${JSON.stringify(ticket.state ?? null)}\n# revision = ${JSON.stringify(ticket.revision)}\n`
|
|
43
|
+
const serialized = serializeTicketFile({ ...front, kind: 'work' }, ticket.body).replace(
|
|
44
|
+
'+++\n',
|
|
45
|
+
`+++\nkind = ${JSON.stringify(front.kind)}\n`,
|
|
46
|
+
)
|
|
42
47
|
const original = serialized.replace('+++\n', `+++\n${reference}`)
|
|
43
48
|
const directory = await mkdtemp(join(tmpdir(), 'ab-ticket-edit-'))
|
|
44
49
|
const path = join(directory, 'ticket.md')
|
|
@@ -58,11 +63,13 @@ export async function editTicket(
|
|
|
58
63
|
if (comments !== reference.trimEnd())
|
|
59
64
|
throw new Error('read-only reference comments cannot change')
|
|
60
65
|
if (
|
|
66
|
+
parsed.front.kind !== front.kind ||
|
|
67
|
+
parsed.front.target !== front.target ||
|
|
61
68
|
parsed.front.id !== id ||
|
|
62
69
|
parsed.front.idempotencyKey !== front.idempotencyKey ||
|
|
63
70
|
JSON.stringify(parsed.front.blockedBy ?? []) !== JSON.stringify(front.blockedBy)
|
|
64
71
|
)
|
|
65
|
-
throw new Error('id, idempotencyKey and blockedBy are read-only')
|
|
72
|
+
throw new Error('kind, target, id, idempotencyKey and blockedBy are read-only')
|
|
66
73
|
const patch: TicketUpdate = {}
|
|
67
74
|
if (parsed.front.title !== ticket.title) patch.title = parsed.front.title
|
|
68
75
|
if (parsed.body !== ticket.body) patch.body = parsed.body
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { readTicketTree } from '../operator/tickets'
|
|
2
|
+
import { updateTicketTarget } from '../kernel/node-parent'
|
|
3
|
+
import { createForge } from '../ports/forge/create'
|
|
4
|
+
import { compatibleTicketSource, type TicketTreeEntry } from '../ports/tickets/tree'
|
|
1
5
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
2
6
|
import { exportTickets, importTickets } from '../ports/tickets/migration'
|
|
3
7
|
import { composeTicketAssets } from '../store/ticket-assets'
|
|
@@ -71,6 +75,8 @@ export interface TicketCommandOpts {
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
export interface TicketCreateOpts extends TicketCommandOpts {
|
|
78
|
+
kind?: import('../ports/types').TicketKind
|
|
79
|
+
target?: string | null
|
|
74
80
|
title: string
|
|
75
81
|
json?: boolean
|
|
76
82
|
/** Path to the ticket body — the spec (docs/spec-standard.md). */
|
|
@@ -85,6 +91,8 @@ export interface TicketCreateOpts extends TicketCommandOpts {
|
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
export interface TicketUpdateOpts extends TicketCommandOpts {
|
|
94
|
+
kind?: import('../ports/types').TicketKind
|
|
95
|
+
target?: string | null
|
|
88
96
|
id: string
|
|
89
97
|
json?: boolean
|
|
90
98
|
title?: string
|
|
@@ -163,6 +171,7 @@ export interface TicketStateCreateOpts extends TicketCommandOpts {
|
|
|
163
171
|
}
|
|
164
172
|
|
|
165
173
|
type TicketCommandName =
|
|
174
|
+
| 'tree'
|
|
166
175
|
| 'export'
|
|
167
176
|
| 'import'
|
|
168
177
|
| 'states'
|
|
@@ -234,12 +243,16 @@ async function createTicketCommandSource(
|
|
|
234
243
|
const factory = opts.sourceFactory ?? createTicketSource
|
|
235
244
|
return {
|
|
236
245
|
config,
|
|
237
|
-
source:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
246
|
+
source: compatibleTicketSource(
|
|
247
|
+
await factory(
|
|
248
|
+
config.tickets,
|
|
249
|
+
config.tickets.source === 'hosted'
|
|
250
|
+
? { ...opts.env, AB_STORE: repoState.storeRef }
|
|
251
|
+
: opts.env,
|
|
252
|
+
targetRepo,
|
|
253
|
+
repoState.localStateRoot,
|
|
254
|
+
plugins,
|
|
255
|
+
),
|
|
243
256
|
),
|
|
244
257
|
}
|
|
245
258
|
}
|
|
@@ -284,6 +297,8 @@ function ticketDetail(ticket: Ticket, assets: TicketAssetSummary[] = []): string
|
|
|
284
297
|
const lines = [
|
|
285
298
|
`ticket ${ticket.ref.source}:${ticket.ref.id}`,
|
|
286
299
|
` title: ${ticket.title}`,
|
|
300
|
+
` kind: ${ticket.kind ?? 'work'}`,
|
|
301
|
+
` target: ${ticket.target ?? '(root)'}`,
|
|
287
302
|
` state: ${ticket.state ?? '(unknown)'}`,
|
|
288
303
|
` labels: ${ticket.labels.join(', ') || '(none)'}`,
|
|
289
304
|
]
|
|
@@ -308,6 +323,8 @@ export async function abTicketCreate(opts: TicketCreateOpts): Promise<void> {
|
|
|
308
323
|
const ticket = await createTicket(
|
|
309
324
|
source,
|
|
310
325
|
{
|
|
326
|
+
...(opts.kind !== undefined ? { kind: opts.kind } : {}),
|
|
327
|
+
...(opts.target !== undefined ? { target: opts.target } : {}),
|
|
311
328
|
title: opts.title,
|
|
312
329
|
body,
|
|
313
330
|
...(opts.labels !== undefined ? { labels: opts.labels } : {}),
|
|
@@ -334,19 +351,43 @@ export async function abTicketCreate(opts: TicketCreateOpts): Promise<void> {
|
|
|
334
351
|
|
|
335
352
|
export async function abTicketUpdate(opts: TicketUpdateOpts): Promise<void> {
|
|
336
353
|
const body = opts.bodyFile === undefined ? undefined : await readBody(opts.bodyFile)
|
|
337
|
-
const { source } = await resolveTicketCommand(opts, 'update')
|
|
354
|
+
const { source, config } = await resolveTicketCommand(opts, 'update')
|
|
338
355
|
const patch: TicketUpdate = {
|
|
356
|
+
...(opts.kind !== undefined ? { kind: opts.kind } : {}),
|
|
357
|
+
...(opts.target !== undefined ? { target: opts.target } : {}),
|
|
339
358
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
340
359
|
...(body !== undefined ? { body } : {}),
|
|
341
360
|
...(opts.labels !== undefined ? { labels: [...opts.labels] } : {}),
|
|
342
361
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
362
|
+
const updated =
|
|
363
|
+
patch.target === undefined
|
|
364
|
+
? await updateTicket(source, opts.id, patch, opts.json === true, opts.expectedRevision)
|
|
365
|
+
: await withTicketStore(opts, ({ store, repo }) =>
|
|
366
|
+
updateTicketTarget(
|
|
367
|
+
{
|
|
368
|
+
store,
|
|
369
|
+
repo,
|
|
370
|
+
source,
|
|
371
|
+
root: config.baseBranch,
|
|
372
|
+
configuredSource: config.tickets.source,
|
|
373
|
+
supportsRetarget: async () => {
|
|
374
|
+
const registry = await loadPlugins(config.plugins, opts.targetRepo)
|
|
375
|
+
const forge = await createForge({
|
|
376
|
+
name: config.forge,
|
|
377
|
+
registry,
|
|
378
|
+
env: opts.env,
|
|
379
|
+
repoRoot: opts.targetRepo,
|
|
380
|
+
})
|
|
381
|
+
return !!forge.retargetPr && !!forge.inspectLandingPr
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
opts.id,
|
|
385
|
+
patch,
|
|
386
|
+
opts.expectedRevision,
|
|
387
|
+
),
|
|
388
|
+
)
|
|
389
|
+
if (opts.json === true && updated !== null) emitTicketJson(opts, updated)
|
|
390
|
+
else opts.stdout(`ticket updated: ${source.name}:${opts.id}`)
|
|
350
391
|
}
|
|
351
392
|
|
|
352
393
|
export async function abTicketBlock(opts: TicketBlockerOpts): Promise<void> {
|
|
@@ -724,9 +765,9 @@ export async function abTicketStateCreate(opts: TicketStateCreateOpts): Promise<
|
|
|
724
765
|
}
|
|
725
766
|
|
|
726
767
|
const CREATE_USAGE =
|
|
727
|
-
'usage: ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--json] (§8.8)'
|
|
768
|
+
'usage: ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--kind work|node] [--target <id> | --no-target] [--json] (§8.8)'
|
|
728
769
|
const UPDATE_USAGE =
|
|
729
|
-
'usage: ab ticket update <id> [--title <title>] [--body <file>] [--labels a,b] [--expected-revision <opaque>] [--json] (§8.8)'
|
|
770
|
+
'usage: ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--expected-revision <opaque>] [--json] (§8.8)'
|
|
730
771
|
const BLOCK_USAGE =
|
|
731
772
|
'usage: ab ticket block <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json] (§8.8)'
|
|
732
773
|
const UNBLOCK_USAGE =
|
|
@@ -746,6 +787,7 @@ const STATE_CREATE_USAGE = 'usage: ab ticket state create <name> [--about <text>
|
|
|
746
787
|
export const TICKET_USAGE = [
|
|
747
788
|
'usage: ab ticket export <dir> [--store <ref>]',
|
|
748
789
|
'usage: ab ticket import <dir> [--store <ref>]',
|
|
790
|
+
'usage: ab ticket tree [--json]',
|
|
749
791
|
CREATE_USAGE,
|
|
750
792
|
'usage: ab ticket edit <id> (§8.8)',
|
|
751
793
|
UPDATE_USAGE,
|
|
@@ -800,7 +842,16 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
800
842
|
case 'create': {
|
|
801
843
|
const parsed = parseArgs(
|
|
802
844
|
args,
|
|
803
|
-
{
|
|
845
|
+
{
|
|
846
|
+
kind: 'value',
|
|
847
|
+
target: 'value',
|
|
848
|
+
'no-target': 'boolean',
|
|
849
|
+
body: 'value',
|
|
850
|
+
state: 'value',
|
|
851
|
+
labels: 'value',
|
|
852
|
+
'blocked-by': 'value',
|
|
853
|
+
json: 'boolean',
|
|
854
|
+
},
|
|
804
855
|
TICKET_USAGE,
|
|
805
856
|
)
|
|
806
857
|
const title = parsed.positionals.join(' ')
|
|
@@ -814,6 +865,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
814
865
|
const blockedBy = stringFlag(parsed, 'blocked-by')
|
|
815
866
|
await abTicketCreate({
|
|
816
867
|
...opts,
|
|
868
|
+
...metadataFlags(parsed),
|
|
817
869
|
title,
|
|
818
870
|
bodyFile,
|
|
819
871
|
...(state !== undefined ? { state } : {}),
|
|
@@ -835,6 +887,9 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
835
887
|
const parsed = parseArgs(
|
|
836
888
|
args,
|
|
837
889
|
{
|
|
890
|
+
kind: 'value',
|
|
891
|
+
target: 'value',
|
|
892
|
+
'no-target': 'boolean',
|
|
838
893
|
title: 'value',
|
|
839
894
|
body: 'value',
|
|
840
895
|
labels: 'value',
|
|
@@ -844,7 +899,9 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
844
899
|
TICKET_USAGE,
|
|
845
900
|
)
|
|
846
901
|
const [id, ...extra] = parsed.positionals
|
|
847
|
-
const hasUpdate = ['title', 'body', 'labels'].some((flag) =>
|
|
902
|
+
const hasUpdate = ['title', 'body', 'labels', 'kind', 'target', 'no-target'].some((flag) =>
|
|
903
|
+
parsed.flags.has(flag),
|
|
904
|
+
)
|
|
848
905
|
if (id === undefined || id.trim() === '' || extra.length > 0 || !hasUpdate) {
|
|
849
906
|
throw new Error(TICKET_USAGE)
|
|
850
907
|
}
|
|
@@ -856,6 +913,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
856
913
|
}
|
|
857
914
|
await abTicketUpdate({
|
|
858
915
|
...opts,
|
|
916
|
+
...metadataFlags(parsed),
|
|
859
917
|
id,
|
|
860
918
|
expectedRevision: stringFlag(parsed, 'expected-revision'),
|
|
861
919
|
...(title !== undefined ? { title } : {}),
|
|
@@ -916,6 +974,28 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
916
974
|
return
|
|
917
975
|
}
|
|
918
976
|
|
|
977
|
+
case 'tree': {
|
|
978
|
+
const parsed = parseArgs(args, { json: 'boolean' }, TICKET_USAGE)
|
|
979
|
+
if (parsed.positionals.length) throw new Error(TICKET_USAGE)
|
|
980
|
+
const { source, config } = await resolveTicketCommand(opts, 'tree')
|
|
981
|
+
const tree = await readTicketTree(source, config.baseBranch)
|
|
982
|
+
for (const diagnostic of tree.diagnostics) opts.stderr(diagnostic)
|
|
983
|
+
if (parsed.flags.has('json')) opts.stdout(JSON.stringify(tree, null, 2))
|
|
984
|
+
else {
|
|
985
|
+
opts.stdout(tree.root)
|
|
986
|
+
const print = (entries: TicketTreeEntry[], depth: number): void => {
|
|
987
|
+
for (const entry of entries) {
|
|
988
|
+
opts.stdout(
|
|
989
|
+
`${' '.repeat(depth)}${entry.ticket.ref.id} [${entry.ticket.kind}] (${entry.ticket.state ?? 'unknown'}) ${entry.ticket.title}`,
|
|
990
|
+
)
|
|
991
|
+
print(entry.children, depth + 1)
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
print(tree.children, 1)
|
|
995
|
+
}
|
|
996
|
+
return
|
|
997
|
+
}
|
|
998
|
+
|
|
919
999
|
case 'show': {
|
|
920
1000
|
const parsed = parseArgs(args, { json: 'boolean', store: 'value' }, TICKET_USAGE)
|
|
921
1001
|
const [id, ...extra] = parsed.positionals
|
|
@@ -1064,3 +1144,18 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1064
1144
|
throw new Error(TICKET_USAGE)
|
|
1065
1145
|
}
|
|
1066
1146
|
}
|
|
1147
|
+
|
|
1148
|
+
function metadataFlags(
|
|
1149
|
+
parsed: ReturnType<typeof parseArgs>,
|
|
1150
|
+
): Pick<TicketUpdate, 'kind' | 'target'> {
|
|
1151
|
+
const kind = stringFlag(parsed, 'kind')
|
|
1152
|
+
const target = stringFlag(parsed, 'target')
|
|
1153
|
+
if (kind !== undefined && kind !== 'work' && kind !== 'node')
|
|
1154
|
+
throw new Error('--kind must be work or node')
|
|
1155
|
+
if (target !== undefined && (!target.trim() || parsed.flags.has('no-target')))
|
|
1156
|
+
throw new Error('--target requires a nonblank id and cannot be combined with --no-target')
|
|
1157
|
+
return {
|
|
1158
|
+
...(kind !== undefined ? { kind } : {}),
|
|
1159
|
+
...(target !== undefined ? { target } : parsed.flags.has('no-target') ? { target: null } : {}),
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
@@ -241,6 +241,10 @@ function literalPathspec(path: string): string {
|
|
|
241
241
|
function managedRoots(record: UpgradeCommitRecord, report: UpgradeReport): Map<string, string[]> {
|
|
242
242
|
const roots = new Map<string, string[]>()
|
|
243
243
|
if (record.gitRoot === undefined) return roots
|
|
244
|
+
if (report.landing?.changed) {
|
|
245
|
+
const path = repositoryPath(record.gitRoot, join(record.targetRepo, 'autobuild.toml'))
|
|
246
|
+
if (path) roots.set('landing-policy', [path])
|
|
247
|
+
}
|
|
244
248
|
for (const { skill } of report.skills) {
|
|
245
249
|
const paths = [
|
|
246
250
|
join(record.targetRepo, '.agents', 'skills', skill),
|
|
@@ -4,7 +4,7 @@ import { isRemoteStoreRef, resolveRepoState } from './repo-state'
|
|
|
4
4
|
import {
|
|
5
5
|
classifyClient,
|
|
6
6
|
compatibilityAdvice,
|
|
7
|
-
|
|
7
|
+
releaseVersion,
|
|
8
8
|
supportedClientRangeSchema,
|
|
9
9
|
} from '../store/remote/compatibility'
|
|
10
10
|
|
|
@@ -58,7 +58,7 @@ export async function checkUpgradeCompatibility(options: {
|
|
|
58
58
|
})(),
|
|
59
59
|
expired,
|
|
60
60
|
]).finally(() => clearTimeout(timeout))
|
|
61
|
-
if (!response || !
|
|
61
|
+
if (!response || !releaseVersion(response.autobuildVersion)) return unknown()
|
|
62
62
|
const serviceVersion = response.autobuildVersion as string
|
|
63
63
|
if (!Object.hasOwn(response, 'supportedClientRange')) {
|
|
64
64
|
if (targetVersion !== serviceVersion)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { readRepositoryFacts } from '../store/reduced-reads'
|
|
2
|
+
import { resolveRepoState, isRemoteStoreRef } from './repo-state'
|
|
3
|
+
import { readFile, rename, writeFile, rm, access } from 'node:fs/promises'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import { randomUUID } from 'node:crypto'
|
|
6
|
+
import { parseConfig } from '../config/load'
|
|
7
|
+
import type { Exec } from '../ports/workspace/git-worktree'
|
|
8
|
+
import { openSessionlessStore, type StoreOpener } from './store-opening'
|
|
9
|
+
|
|
10
|
+
/** Upgrade samples the destination repository's journal, never ambient AB_STORE. */
|
|
11
|
+
export async function migrateLandingPolicy(opts: {
|
|
12
|
+
targetRepo: string
|
|
13
|
+
exec: Exec
|
|
14
|
+
env?: Record<string, string | undefined>
|
|
15
|
+
openStore?: StoreOpener
|
|
16
|
+
}): Promise<{ changed: boolean; legacyDefault?: boolean }> {
|
|
17
|
+
const path = join(opts.targetRepo, 'autobuild.toml')
|
|
18
|
+
let source: string
|
|
19
|
+
try {
|
|
20
|
+
source = await readFile(path, 'utf8')
|
|
21
|
+
} catch {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Landing policy migration requires readable ${path}; restore its configuration and retry ab upgrade`,
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
// Parsing proves that the explicit array is valid; retain its exact bytes.
|
|
27
|
+
parseConfig(source, path)
|
|
28
|
+
const parsed = Bun.TOML.parse(source) as Record<string, unknown>
|
|
29
|
+
if (Object.hasOwn(parsed, 'landing')) return { changed: false }
|
|
30
|
+
let enabled = false
|
|
31
|
+
try {
|
|
32
|
+
const paths = await resolveRepoState({ targetRepo: opts.targetRepo, exec: opts.exec })
|
|
33
|
+
let journalAbsent = false
|
|
34
|
+
if (!opts.openStore && !isRemoteStoreRef(paths.storeRef)) {
|
|
35
|
+
try {
|
|
36
|
+
await access(join(paths.storeRef, 'autobuild.sqlite'))
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error
|
|
39
|
+
journalAbsent = true
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!journalAbsent) {
|
|
43
|
+
const context = await openSessionlessStore({
|
|
44
|
+
...opts,
|
|
45
|
+
env: { ...(opts.env ?? process.env), AB_STORE: undefined },
|
|
46
|
+
})
|
|
47
|
+
try {
|
|
48
|
+
const facts = await readRepositoryFacts(context.store, context.repo)
|
|
49
|
+
enabled = facts.value.autoMerge.latest?.enabled ?? false
|
|
50
|
+
} finally {
|
|
51
|
+
await context.store.close()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Cannot read the target repository's legacy auto-merge journal; restore store access and retry ab upgrade, or configure explicit [[landing]] rules (landing = [] selects the new defaults): ${error instanceof Error ? error.message : String(error)}`,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
const result = `${source.replace(/\n?$/, '\n')}\n# Migrated from the durable auto-merge default. First matching rule wins.\n[[landing]]\nfrom = "leaf"\nmode = "${enabled ? 'auto' : 'consent'}"\n\n[[landing]]\nfrom = "node"\nmode = "consent"\n`
|
|
60
|
+
parseConfig(result, path)
|
|
61
|
+
const temporary = `${path}.${randomUUID()}.tmp`
|
|
62
|
+
try {
|
|
63
|
+
await writeFile(temporary, result)
|
|
64
|
+
await rename(temporary, path)
|
|
65
|
+
} finally {
|
|
66
|
+
await rm(temporary, { force: true })
|
|
67
|
+
}
|
|
68
|
+
return { changed: true, legacyDefault: enabled }
|
|
69
|
+
}
|