@defrex/autobuild 1.0.1 → 1.2.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 +10 -18
- package/SPEC.md +499 -238
- package/bin/ab-dispatch-generation.ts +11 -2
- package/docs/accounts.md +119 -0
- package/docs/agent-runtimes.md +4 -4
- package/docs/answering-blocked-builds.md +2 -2
- package/docs/architecture.md +262 -53
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +3 -41
- package/docs/builds.md +4 -4
- package/docs/cli.md +18 -4
- package/docs/configuration-overview.md +115 -4
- package/docs/configuration.md +488 -334
- package/docs/dispatcher-hosting.md +19 -34
- package/docs/dispatcher.md +1 -1
- package/docs/forges.md +5 -5
- package/docs/getting-started.md +2 -2
- package/docs/glossary.md +6 -6
- package/docs/intake.md +2 -0
- package/docs/integration-overview.md +15 -15
- package/docs/integration-tree.md +45 -38
- package/docs/integration.md +6 -6
- package/{skills/guide/references/landing-policy.md → docs/merge-policy.md} +40 -24
- package/docs/migration-1.0.md +17 -13
- package/docs/operating.md +41 -19
- package/docs/operator-api.md +180 -51
- package/docs/operator-surfaces.md +5 -18
- package/docs/overview.md +3 -3
- package/docs/plugin-authoring.md +21 -0
- package/docs/remote-store-protocol.md +242 -68
- package/docs/remote-ticket-protocol.md +30 -50
- package/docs/restacking.md +54 -15
- package/docs/seams.md +8 -8
- package/docs/setup.md +59 -119
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +6 -6
- package/docs/ticket-dependencies.md +7 -7
- package/docs/ticket-sources.md +18 -0
- package/docs/tickets.md +8 -2
- package/docs/troubleshooting.md +8 -12
- package/docs/upgrading.md +9 -4
- package/docs/verification.md +60 -14
- package/docs/workspaces.md +4 -4
- package/package.json +17 -6
- package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
- package/packages/core/src/accounts/chatgpt-state.ts +41 -0
- package/packages/core/src/accounts/local-credentials.ts +194 -0
- package/packages/core/src/accounts/local-inference.ts +106 -0
- package/packages/core/src/accounts/local-owner.ts +123 -0
- package/packages/core/src/accounts/sensitive.ts +2 -0
- package/packages/core/src/cli/accounts.ts +147 -0
- package/packages/core/src/cli/binary-direct.ts +13 -1
- package/packages/core/src/cli/binary-lifecycle.ts +65 -2
- package/packages/core/src/cli/binary.ts +3 -1
- package/packages/core/src/cli/build-control.ts +83 -28
- package/packages/core/src/cli/connect.ts +3 -3
- package/packages/core/src/cli/context.ts +81 -38
- package/packages/core/src/cli/dashboard/facts.ts +2 -1
- package/packages/core/src/cli/dashboard/integration-detail.ts +8 -8
- package/packages/core/src/cli/dashboard/integration-row.ts +40 -13
- package/packages/core/src/cli/dashboard/landing-display.ts +25 -0
- package/packages/core/src/cli/dashboard/model.ts +56 -33
- package/packages/core/src/cli/dashboard/poll.ts +9 -3
- package/packages/core/src/cli/dashboard/render.ts +59 -37
- package/packages/core/src/cli/dashboard/target-distance.ts +14 -0
- package/packages/core/src/cli/dashboard/tree.ts +3 -2
- package/packages/core/src/cli/dispatch-args.ts +1 -1
- package/packages/core/src/cli/dispatch-frontend.ts +6 -3
- package/packages/core/src/cli/dispatch-handoff.ts +125 -44
- package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
- package/packages/core/src/cli/dispatch-launcher.ts +54 -21
- package/packages/core/src/cli/dispatch-preflight.ts +6 -1
- package/packages/core/src/cli/dispatch.ts +106 -11
- package/packages/core/src/cli/env.ts +4 -0
- package/packages/core/src/cli/help.ts +46 -23
- package/packages/core/src/cli/init-readiness-remote.ts +22 -1
- package/packages/core/src/cli/init-readiness-shared.ts +5 -1
- package/packages/core/src/cli/init-validation.ts +160 -18
- package/packages/core/src/cli/main.ts +68 -8
- package/packages/core/src/cli/node-verification-provenance.ts +1 -97
- package/packages/core/src/cli/publication-settlement.ts +47 -21
- package/packages/core/src/cli/repository-status.ts +20 -9
- package/packages/core/src/cli/secrets.ts +173 -0
- package/packages/core/src/cli/status.ts +42 -5
- package/packages/core/src/cli/store-opening.ts +17 -2
- package/packages/core/src/cli/terminal.ts +22 -1
- package/packages/core/src/cli/terminals.ts +14 -10
- package/packages/core/src/cli/upgrade-agent.ts +9 -1
- package/packages/core/src/cli/upgrade-landing.ts +70 -30
- package/packages/core/src/cli/upgrade.ts +3 -1
- package/packages/core/src/cli/wait.ts +15 -7
- package/packages/core/src/cli/watch-lifetime.ts +111 -0
- package/packages/core/src/cli/watch.ts +635 -510
- package/packages/core/src/config/accounts.ts +101 -0
- package/packages/core/src/config/effective-artifact.fixture.ts +27 -0
- package/packages/core/src/config/effective-artifact.ts +13 -0
- package/packages/core/src/config/landing.ts +1 -1
- package/packages/core/src/config/live.ts +14 -1
- package/packages/core/src/config/load.ts +21 -1
- package/packages/core/src/config/pipeline-source.ts +28 -0
- package/packages/core/src/config/reference-metadata.ts +2 -0
- package/packages/core/src/config/reference.ts +22 -7
- package/packages/core/src/config/roles.ts +54 -3
- package/packages/core/src/config/schema.ts +146 -162
- package/packages/core/src/context-directory.ts +26 -0
- package/packages/core/src/distribution-packaging.ts +26 -5
- package/packages/core/src/events/catalog.ts +10 -2
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/globs.ts +1 -1
- package/packages/core/src/events/payloads.ts +73 -1
- package/packages/core/src/events/policy.ts +7 -0
- package/packages/core/src/events/repository.ts +4 -4
- package/packages/core/src/events/sessions.ts +6 -6
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +574 -0
- package/packages/core/src/kernel/auto-merge.ts +2 -2
- package/packages/core/src/kernel/engine.ts +255 -26
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +10 -0
- package/packages/core/src/kernel/integration-landing.ts +3 -3
- package/packages/core/src/kernel/integration-state.ts +27 -4
- package/packages/core/src/kernel/leaf-restack-state.ts +28 -3
- package/packages/core/src/kernel/log-index.ts +13 -1
- package/packages/core/src/kernel/node-landing.ts +8 -8
- package/packages/core/src/kernel/node-parent.ts +2 -2
- package/packages/core/src/kernel/node-restack-transaction.ts +1 -1
- package/packages/core/src/kernel/node-verification-context.ts +216 -0
- package/packages/core/src/kernel/phases.ts +1 -1
- package/packages/core/src/kernel/plan-verify-selection.ts +16 -0
- package/packages/core/src/kernel/publication-retry.ts +168 -0
- package/packages/core/src/kernel/reconcile-restack.ts +29 -1
- package/packages/core/src/kernel/reducer.ts +85 -5
- package/packages/core/src/kernel/target-distance.ts +45 -0
- package/packages/core/src/kernel/terminal-guard.ts +10 -1
- package/packages/core/src/kernel/verify-stage-state.ts +123 -0
- package/packages/core/src/kernel/verify-stages.ts +39 -0
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +1 -1
- package/packages/core/src/operator/index.ts +3 -7
- package/packages/core/src/operator/landings.ts +5 -1
- package/packages/core/src/operator/presentation.ts +6 -1
- package/packages/core/src/operator/protocol.ts +6 -0
- package/packages/core/src/operator/query.ts +14 -18
- package/packages/core/src/operator/registry.ts +39 -7
- package/packages/core/src/operator/sandbox-host.ts +64 -40
- package/packages/core/src/operator/sandbox.ts +3 -0
- package/packages/core/src/operator/ticket-source-backend.ts +3 -12
- package/packages/core/src/operator/tickets.ts +25 -4
- package/packages/core/src/plugins/manifest.ts +2 -1
- package/packages/core/src/ports/forge/contract.ts +2 -2
- package/packages/core/src/ports/forge/git-rewrite.ts +25 -2
- package/packages/core/src/ports/forge/github-readiness.ts +2 -2
- package/packages/core/src/ports/forge/github.ts +26 -7
- package/packages/core/src/ports/forge/local-git.ts +4 -4
- package/packages/core/src/ports/forge/readiness.ts +1 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/account-env.ts +88 -0
- package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
- package/packages/core/src/ports/runner/claude.ts +26 -2
- package/packages/core/src/ports/runner/codex.ts +63 -31
- package/packages/core/src/ports/runner/one-shot.ts +2 -0
- package/packages/core/src/ports/runner/provider-error.ts +5 -0
- package/packages/core/src/ports/runner/routing.ts +35 -4
- package/packages/core/src/ports/tickets/contract.ts +58 -0
- package/packages/core/src/ports/tickets/tree.ts +1 -1
- package/packages/core/src/ports/types.ts +28 -7
- package/packages/core/src/ports/workspace/account-policy.ts +72 -0
- package/packages/core/src/ports/workspace/build-execution.ts +9 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
- package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +182 -72
- package/packages/core/src/processes/build-child.ts +6 -8
- package/packages/core/src/processes/build-execution-state.ts +8 -5
- package/packages/core/src/processes/build-runner.ts +554 -99
- package/packages/core/src/processes/dispatcher.ts +209 -101
- package/packages/core/src/processes/execution-no-progress.ts +8 -1
- package/packages/core/src/processes/execution-settlement.ts +21 -3
- package/packages/core/src/processes/harvest-runner.ts +68 -8
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-loss.ts +8 -2
- package/packages/core/src/processes/publication-state.ts +42 -4
- package/packages/core/src/processes/repo-view.ts +14 -0
- package/packages/core/src/processes/verify-cycle-config.ts +96 -0
- package/packages/core/src/project-secrets.ts +105 -0
- package/packages/core/src/{integration → scenarios}/harness.ts +330 -317
- package/packages/core/src/secret-name.ts +41 -0
- package/packages/core/src/store/account-redaction.ts +156 -0
- package/packages/core/src/store/adapter.ts +1 -0
- package/packages/core/src/store/build-scope.ts +9 -0
- package/packages/core/src/store/contract.ts +116 -2
- package/packages/core/src/store/local/schema.ts +13 -0
- package/packages/core/src/store/local/store.ts +42 -0
- package/packages/core/src/store/memory.ts +47 -0
- package/packages/core/src/store/operator-presence.ts +21 -0
- package/packages/core/src/store/phase-session.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +5185 -4156
- package/packages/core/src/store/remote/client.ts +89 -48
- package/packages/core/src/store/remote/compatibility.ts +20 -0
- package/packages/core/src/store/remote/protocol.ts +4 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/retention.ts +2 -3
- package/packages/core/src/store/session-handle.ts +9 -0
- package/packages/core/src/store/streams/session-writer.ts +1 -1
- package/packages/core/src/store/types.ts +12 -2
- package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
- package/packages/core/src/testing/index.ts +12 -1
- package/packages/core/src/testing/reduced-read-budget.ts +47 -0
- package/packages/core/src/testing/temp-directories.ts +58 -0
- package/skills/code-review/SKILL.md +23 -9
- package/skills/finalize/SKILL.md +15 -7
- package/skills/guide/SKILL.md +373 -148
- package/skills/guide/references/accounts.md +119 -0
- package/skills/guide/references/integration-tree.md +45 -38
- package/{docs/landing-policy.md → skills/guide/references/merge-policy.md} +40 -24
- package/skills/guide/references/migration-1.0.md +17 -13
- package/skills/guide/references/operator-api.md +180 -51
- package/skills/guide/references/plugin-authoring.md +21 -0
- package/skills/guide/references/remote-store-protocol.md +242 -68
- package/skills/guide/references/remote-ticket-protocol.md +30 -50
- package/skills/guide/references/restacking.md +54 -15
- package/skills/guide/references/setup.md +59 -119
- package/skills/guide/references/spec-standard.md +6 -6
- package/skills/guide/references/ticket-dependencies.md +7 -7
- package/skills/harvest/SKILL.md +3 -1
- package/skills/harvest-review/SKILL.md +3 -1
- package/skills/implement/SKILL.md +43 -17
- package/skills/operate/SKILL.md +118 -118
- package/skills/plan/SKILL.md +39 -13
- package/skills/plan-review/SKILL.md +15 -10
- package/skills/reconcile/SKILL.md +22 -3
- package/skills/spec/SKILL.md +20 -20
- package/skills/tickets/SKILL.md +12 -9
- package/templates/autobuild.toml +1 -1
- package/templates/hosted-service/package.json +2 -2
- package/docs/hosted-dispatcher-cutover-validation.md +0 -178
- package/docs/hosted-dispatcher.md +0 -275
- package/docs/hosted-service.md +0 -293
- package/docs/mcp.md +0 -149
- package/packages/core/src/orchestrator/approvals.ts +0 -115
- package/packages/core/src/orchestrator/conversation.ts +0 -167
- package/packages/core/src/orchestrator/model.ts +0 -86
- package/packages/core/src/orchestrator/prompt.ts +0 -63
- package/packages/core/src/orchestrator/tools.ts +0 -117
- package/packages/core/src/orchestrator/turn-runner.ts +0 -457
- package/packages/core/src/processes/orchestrator-tick.ts +0 -360
|
@@ -165,7 +165,7 @@ async function appendCommand(
|
|
|
165
165
|
switch (command) {
|
|
166
166
|
case 'hold':
|
|
167
167
|
case 'land':
|
|
168
|
-
throw new Error('
|
|
168
|
+
throw new Error('Merge commands require compare-and-append authorization')
|
|
169
169
|
case 'pause':
|
|
170
170
|
event = await store.append(slug, {
|
|
171
171
|
actor,
|
|
@@ -212,6 +212,18 @@ async function appendCommand(
|
|
|
212
212
|
return { kind: 'command', slug, command, event }
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
function rejectCancelledAnswer(state: BuildState, captured?: Set<string>): void {
|
|
216
|
+
if (
|
|
217
|
+
state.verifyStage.superseded.some((item) =>
|
|
218
|
+
captured ? captured.has(item.escalation.id) : state.openEscalations.length === 0,
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
throw new BuildControlError(
|
|
222
|
+
'no-open-escalations',
|
|
223
|
+
'Cannot answer a stale escalation: its verifier occurrence was cancelled by fail-fast',
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
215
227
|
function selectedOpen(state: BuildState, captured?: Set<string>): OpenEscalation[] {
|
|
216
228
|
return captured === undefined
|
|
217
229
|
? state.openEscalations
|
|
@@ -354,7 +366,7 @@ export function decideRevise(
|
|
|
354
366
|
if (open.length === 0) {
|
|
355
367
|
const paused =
|
|
356
368
|
state.status === 'paused'
|
|
357
|
-
? ` If a revision already
|
|
369
|
+
? ` If a revision already merged, the build remains paused; run ab resume ${slug}.`
|
|
358
370
|
: ''
|
|
359
371
|
return {
|
|
360
372
|
kind: 'refuse',
|
|
@@ -529,7 +541,7 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
529
541
|
if (opts.action.kind === 'land') {
|
|
530
542
|
if (!landPreconditions(current, facts.log.restack))
|
|
531
543
|
throw new Error(
|
|
532
|
-
'
|
|
544
|
+
'Merge is not ready; wait for current-base verification and finalize before running ab merge',
|
|
533
545
|
)
|
|
534
546
|
if (current.kind === 'node') {
|
|
535
547
|
if (!opts.ticketSource)
|
|
@@ -545,7 +557,7 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
545
557
|
!observed.contributions.length
|
|
546
558
|
)
|
|
547
559
|
throw new Error(
|
|
548
|
-
'Node is incomplete; wait for its children and verification before running ab
|
|
560
|
+
'Node is incomplete; wait for its children and verification before running ab merge',
|
|
549
561
|
)
|
|
550
562
|
}
|
|
551
563
|
}
|
|
@@ -564,13 +576,13 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
564
576
|
})
|
|
565
577
|
if (event) return { kind: 'command', slug: opts.slug, command: opts.action.kind, event }
|
|
566
578
|
}
|
|
567
|
-
throw new Error('
|
|
579
|
+
throw new Error('Merge command was not recorded')
|
|
568
580
|
}
|
|
569
581
|
case 'auto-merge-on':
|
|
570
582
|
case 'auto-merge-off':
|
|
571
583
|
case 'toggle-auto-merge':
|
|
572
584
|
throw new Error(
|
|
573
|
-
'Auto-merge controls are retired; use ab hold or ab
|
|
585
|
+
'Auto-merge controls are retired; use ab hold or ab merge and [[merge]] policy',
|
|
574
586
|
)
|
|
575
587
|
|
|
576
588
|
case 'dashboard-pause': {
|
|
@@ -611,6 +623,10 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
611
623
|
case 'answer': {
|
|
612
624
|
const captured =
|
|
613
625
|
opts.action.escalationIds === undefined ? undefined : new Set(opts.action.escalationIds)
|
|
626
|
+
// An unblocked node revision is an independent repair operation, not
|
|
627
|
+
// an answer to a historical verifier question.
|
|
628
|
+
if (captured || state.kind !== 'node' || opts.action.resolve?.kind !== 'revise-spec')
|
|
629
|
+
rejectCancelledAnswer(state, captured)
|
|
614
630
|
const guidance = (opts.action.text ?? '').trim()
|
|
615
631
|
const actor = humanActor(user, opts.via)
|
|
616
632
|
const requestedCeiling = opts.action.reviewRoundCeiling
|
|
@@ -805,15 +821,43 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
805
821
|
},
|
|
806
822
|
})
|
|
807
823
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
824
|
+
if (freshState.verifyStage.concurrent) {
|
|
825
|
+
// Cancellation can supersede the verifier while body preparation or
|
|
826
|
+
// answer writes are in flight. Revalidate effective authorization at
|
|
827
|
+
// the atomic revision boundary, rather than trusting that old read.
|
|
828
|
+
for (;;) {
|
|
829
|
+
const current = (await readBuildFacts(opts.store, opts.slug)).value.state
|
|
830
|
+
const authorization = decideRevise(opts.slug, current, captured)
|
|
831
|
+
if (authorization.kind === 'refuse') throwRefusal(authorization)
|
|
832
|
+
if (authorization.kind !== 'complete')
|
|
833
|
+
throw new BuildControlError(
|
|
834
|
+
'missing-authorization',
|
|
835
|
+
'Spec revision authorization is no longer effective',
|
|
836
|
+
)
|
|
837
|
+
if (
|
|
838
|
+
await opts.store.appendIfCurrent(opts.slug, current.lastSeq, {
|
|
839
|
+
actor: KERNEL,
|
|
840
|
+
type: 'spec.revised',
|
|
841
|
+
payload: {
|
|
842
|
+
artifact: authorization.artifact,
|
|
843
|
+
escalation: authorization.escalationSeq,
|
|
844
|
+
...(authorization.assets === undefined ? {} : { assets: authorization.assets }),
|
|
845
|
+
},
|
|
846
|
+
})
|
|
847
|
+
)
|
|
848
|
+
break
|
|
849
|
+
}
|
|
850
|
+
} else {
|
|
851
|
+
await opts.store.append(opts.slug, {
|
|
852
|
+
actor: KERNEL,
|
|
853
|
+
type: 'spec.revised',
|
|
854
|
+
payload: {
|
|
855
|
+
artifact,
|
|
856
|
+
escalation: decision.escalationSeq,
|
|
857
|
+
...(assets !== undefined ? { assets } : {}),
|
|
858
|
+
},
|
|
859
|
+
})
|
|
860
|
+
}
|
|
817
861
|
if (alsoPaused) {
|
|
818
862
|
await opts.store.append(opts.slug, {
|
|
819
863
|
actor,
|
|
@@ -905,19 +949,30 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
905
949
|
const alsoPaused = state.status === 'paused'
|
|
906
950
|
// Appends are intentionally one-at-a-time. If an append fails midway, a
|
|
907
951
|
// retry re-reduces the log and filters already answered ids out.
|
|
952
|
+
let answeredCount = 0
|
|
908
953
|
for (const escalation of open) {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
954
|
+
for (;;) {
|
|
955
|
+
const fresh = (await readBuildFacts(opts.store, opts.slug)).value.state
|
|
956
|
+
rejectCancelledAnswer(fresh, new Set([escalation.id]))
|
|
957
|
+
if (!fresh.openEscalations.some((item) => item.id === escalation.id)) break
|
|
958
|
+
if (
|
|
959
|
+
await opts.store.appendIfCurrent(opts.slug, fresh.lastSeq, {
|
|
960
|
+
actor,
|
|
961
|
+
type: 'escalation.answered',
|
|
962
|
+
payload: {
|
|
963
|
+
id: escalation.id,
|
|
964
|
+
answer,
|
|
965
|
+
resolution,
|
|
966
|
+
...(ceilingEscalation?.id === escalation.id
|
|
967
|
+
? { reviewRoundCeiling: requestedCeiling }
|
|
968
|
+
: {}),
|
|
969
|
+
},
|
|
970
|
+
})
|
|
971
|
+
) {
|
|
972
|
+
answeredCount += 1
|
|
973
|
+
break
|
|
974
|
+
}
|
|
975
|
+
}
|
|
921
976
|
}
|
|
922
977
|
if (alsoPaused) {
|
|
923
978
|
await opts.store.append(opts.slug, {
|
|
@@ -929,7 +984,7 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
|
|
|
929
984
|
return {
|
|
930
985
|
kind: 'answered',
|
|
931
986
|
slug: opts.slug,
|
|
932
|
-
count:
|
|
987
|
+
count: answeredCount,
|
|
933
988
|
resolution,
|
|
934
989
|
resumed: alsoPaused,
|
|
935
990
|
...(ceilingEscalation !== undefined && requestedCeiling !== undefined
|
|
@@ -37,7 +37,7 @@ function requireOperator(env: ConnectOptions['env']) {
|
|
|
37
37
|
)
|
|
38
38
|
throw new Error('connect and disconnect are unavailable inside build or harvest sessions')
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
40
|
+
export async function connectedProject(opts: ConnectOptions) {
|
|
41
41
|
requireOperator(opts.env)
|
|
42
42
|
const checkout = await resolveMainRepo(opts.cwd, opts.exec)
|
|
43
43
|
const remote = await opts.exec(['git', 'remote', 'get-url', 'origin'], { cwd: checkout })
|
|
@@ -97,7 +97,7 @@ async function atomicConfig(path: string, before: string, after: string) {
|
|
|
97
97
|
}
|
|
98
98
|
export async function abConnect(raw: string | undefined, opts: ConnectOptions): Promise<void> {
|
|
99
99
|
if (opts.tickets && opts.builds) throw new Error('Choose --tickets or --builds')
|
|
100
|
-
const p = await
|
|
100
|
+
const p = await connectedProject(opts)
|
|
101
101
|
if (opts.tickets && (p.table.tickets as { source?: string } | undefined)?.source !== 'hosted')
|
|
102
102
|
throw new Error('ab connect --tickets requires [tickets] source = "hosted"')
|
|
103
103
|
const credentials = new ProjectCredentials(opts.env)
|
|
@@ -309,7 +309,7 @@ export async function abConnect(raw: string | undefined, opts: ConnectOptions):
|
|
|
309
309
|
}
|
|
310
310
|
export async function abDisconnect(opts: ConnectOptions): Promise<void> {
|
|
311
311
|
if (opts.tickets && opts.builds) throw new Error('Choose --tickets or --builds')
|
|
312
|
-
const p = await
|
|
312
|
+
const p = await connectedProject(opts)
|
|
313
313
|
if (
|
|
314
314
|
!opts.tickets &&
|
|
315
315
|
!opts.builds &&
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { resolveContextDirectory } from '../context-directory'
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
+
parseNodeVerificationContext,
|
|
3
4
|
type NodeVerificationIndex,
|
|
4
|
-
} from '
|
|
5
|
+
} from '../kernel/node-verification-context'
|
|
5
6
|
import { compatibilityDiagnostic } from '../kernel/mixed-version'
|
|
6
7
|
import { readBuildFacts, type CurrentBuildFacts } from '../store/reduced-reads'
|
|
7
8
|
/**
|
|
@@ -9,11 +10,10 @@ import { readBuildFacts, type CurrentBuildFacts } from '../store/reduced-reads'
|
|
|
9
10
|
* gitignored `.ab/` scratch dir. Everything derives from
|
|
10
11
|
* `PHASE_SPECS[phase].inputs` — the table drives, so the CLI, the manifest,
|
|
11
12
|
* and the engine all validate against the same data (no per-phase switch
|
|
12
|
-
* sprawl).
|
|
13
|
-
*
|
|
14
|
-
* findings but not the producer's session).
|
|
13
|
+
* sprawl). Each manifest selects the current phase's inputs. Sibling phase
|
|
14
|
+
* directories remain readable; scratch separation is not filesystem isolation.
|
|
15
15
|
*
|
|
16
|
-
* Disposable
|
|
16
|
+
* Disposable session-directory content is wiped and recreated on every run — stale
|
|
17
17
|
* context is worse than no context — while legacy tracked entries are restored
|
|
18
18
|
* byte-for-byte from the index. Git's local exclude keeps generated scratch
|
|
19
19
|
* ignored without mutating the repository's own `.gitignore`.
|
|
@@ -62,7 +62,7 @@ export interface ContextDeps {
|
|
|
62
62
|
ids?: IdSource
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/** Paths are relative to
|
|
65
|
+
/** Paths are relative to the session directory, forward-slash separated. */
|
|
66
66
|
export type MaterializedEntry = ArtifactRef | 'derived'
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -83,11 +83,13 @@ export interface ContextManifest {
|
|
|
83
83
|
*/
|
|
84
84
|
required: string[]
|
|
85
85
|
allowedTerminals: TerminalCommand[]
|
|
86
|
+
/** Workspace-relative directory for this session. */
|
|
87
|
+
contextDir: string
|
|
86
88
|
/** Workspace-relative path where this manifest was written. */
|
|
87
89
|
manifestPath: string
|
|
88
90
|
/** Safe workspace-relative producer notes path (implement/reconcile only). */
|
|
89
91
|
notesPath?: string
|
|
90
|
-
/** relPath (under
|
|
92
|
+
/** relPath (under the session directory) → source artifact ref, or 'derived'. */
|
|
91
93
|
materialized: Record<string, MaterializedEntry>
|
|
92
94
|
/** The ticket assets this build froze (SPEC §6.3), each written to `path`
|
|
93
95
|
* (relative to the workspace). Omitted when the build pinned none. */
|
|
@@ -119,6 +121,9 @@ export interface ContextManifest {
|
|
|
119
121
|
/** Agent-verify: the step's config from the workspace's autobuild.toml (§16.1). */
|
|
120
122
|
step?: { name: string; config: VerifyStepConfig }
|
|
121
123
|
/** The feedback this phase occurrence was started with (§15.3, §10). */
|
|
124
|
+
verifyStageFailure?: import('../kernel/verify-stage-state').VerifyStageFailure
|
|
125
|
+
verifyReports?: { step: string; report: import('../ontology').ArtifactRef; path: string }[]
|
|
126
|
+
cancelledVerify?: { step: string; attempt: number; cause: { step: string }; status: 'not-run' }[]
|
|
122
127
|
feedback?: Feedback
|
|
123
128
|
/** Chains a human resolved via dismiss-finding — the reviewer is told so (§15.6-B). */
|
|
124
129
|
dismissedFindingIds?: string[]
|
|
@@ -141,7 +146,7 @@ function currentFeedback(events: CurrentBuildFacts, phase: Phase, round: number)
|
|
|
141
146
|
return explicit ?? (phase === 'plan' ? (events.planFeedback[String(round)] ?? null) : null)
|
|
142
147
|
}
|
|
143
148
|
|
|
144
|
-
/** Empty and recreate
|
|
149
|
+
/** Empty and recreate the session directory; callers restore any tracked legacy entries. */
|
|
145
150
|
async function wipeAbDir(abDir: string): Promise<void> {
|
|
146
151
|
await rm(abDir, { recursive: true, force: true })
|
|
147
152
|
await mkdir(abDir, { recursive: true })
|
|
@@ -161,7 +166,7 @@ function dismissedIds(state: BuildState, events: CurrentBuildFacts): string[] {
|
|
|
161
166
|
|
|
162
167
|
/**
|
|
163
168
|
* Materialize the phase's `.ab/` tree and return the manifest (also written
|
|
164
|
-
* as
|
|
169
|
+
* as `$AB_CONTEXT_DIR/context.json`).
|
|
165
170
|
*/
|
|
166
171
|
export async function buildContext(deps: ContextDeps): Promise<ContextManifest> {
|
|
167
172
|
const { store, env, workspacePath } = deps
|
|
@@ -196,18 +201,29 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
196
201
|
// Preserve legacy tracked scratch exactly while replacing disposable files.
|
|
197
202
|
// Some adapter contract fixtures intentionally use a non-Git workspace;
|
|
198
203
|
// context hydration still works there, while publication remains Git-only.
|
|
199
|
-
const
|
|
204
|
+
const contextDir = resolveContextDirectory(phase, env.contextDir)
|
|
205
|
+
const abDir = join(workspacePath, contextDir)
|
|
200
206
|
const gitWorkspace =
|
|
201
207
|
deps.exec !== undefined &&
|
|
202
208
|
(await deps.exec(['git', 'rev-parse', '--is-inside-work-tree'], { cwd: workspacePath }))
|
|
203
209
|
.exitCode === 0
|
|
204
210
|
const tracked = gitWorkspace ? await trackedScratchPaths(deps.exec!, workspacePath) : []
|
|
211
|
+
if (tracked.some((path) => contextDir === path || contextDir.startsWith(`${path}/`))) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
`Tracked content blocks context directory ${contextDir}; move that content before retrying`,
|
|
214
|
+
)
|
|
215
|
+
}
|
|
205
216
|
await wipeAbDir(abDir)
|
|
206
217
|
if (gitWorkspace) {
|
|
207
|
-
await restoreTrackedScratch(
|
|
218
|
+
await restoreTrackedScratch(
|
|
219
|
+
deps.exec!,
|
|
220
|
+
workspacePath,
|
|
221
|
+
tracked.filter((path) => path.startsWith(`${contextDir}/`)),
|
|
222
|
+
)
|
|
208
223
|
await ensureScratchExcluded(deps.exec!, workspacePath)
|
|
209
224
|
}
|
|
210
|
-
if (!tracked.includes('.ab/.gitignore'))
|
|
225
|
+
if (!tracked.includes('.ab/.gitignore'))
|
|
226
|
+
await writeFile(join(workspacePath, '.ab', '.gitignore'), '*\n')
|
|
211
227
|
|
|
212
228
|
const trackedSet = new Set(tracked)
|
|
213
229
|
const allocated = new Set<string>()
|
|
@@ -215,13 +231,15 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
215
231
|
const locate = (desired: string): string => {
|
|
216
232
|
const prior = locations.get(desired)
|
|
217
233
|
if (prior !== undefined) return prior
|
|
218
|
-
const path = allocateScratchPath(desired, trackedSet, allocated)
|
|
234
|
+
const path = allocateScratchPath(desired, trackedSet, allocated, `${contextDir}/`)
|
|
219
235
|
locations.set(desired, path)
|
|
220
236
|
return path
|
|
221
237
|
}
|
|
222
238
|
const manifestRelPath = locate('context.json')
|
|
223
239
|
const notesRelPath =
|
|
224
240
|
phase === 'implement' || phase === 'reconcile' ? locate(`${phase}-notes.md`) : undefined
|
|
241
|
+
if (notesRelPath !== undefined)
|
|
242
|
+
await mkdir(dirname(join(abDir, notesRelPath)), { recursive: true })
|
|
225
243
|
const materialized: Record<string, MaterializedEntry> = {}
|
|
226
244
|
|
|
227
245
|
async function writeDerived(desiredPath: string, content: string): Promise<string> {
|
|
@@ -230,12 +248,16 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
230
248
|
await mkdir(dirname(target), { recursive: true })
|
|
231
249
|
await writeFile(target, content)
|
|
232
250
|
materialized[relPath] = 'derived'
|
|
233
|
-
return
|
|
251
|
+
return `${contextDir}/${relPath}`
|
|
234
252
|
}
|
|
235
253
|
|
|
236
254
|
/** Latest rev when `rev` omitted; silently skips absent kinds — the tree is
|
|
237
255
|
* a projection of what exists, and the manifest shows what materialized. */
|
|
238
|
-
async function writeArtifact(
|
|
256
|
+
async function writeArtifact(
|
|
257
|
+
desiredPath: string,
|
|
258
|
+
kind: string,
|
|
259
|
+
rev?: number,
|
|
260
|
+
): Promise<string | undefined> {
|
|
239
261
|
const node = state.nodeRestack
|
|
240
262
|
const sourceKind =
|
|
241
263
|
phase === 'reconcile' && node?.conflict && ['spec', 'plan', 'implement-notes'].includes(kind)
|
|
@@ -252,6 +274,7 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
252
274
|
await mkdir(dirname(target), { recursive: true })
|
|
253
275
|
await writeFile(target, artifact.content)
|
|
254
276
|
materialized[relPath] = { kind: artifact.meta.kind, rev: artifact.meta.revision }
|
|
277
|
+
return `${contextDir}/${relPath}`
|
|
255
278
|
}
|
|
256
279
|
|
|
257
280
|
const manifest: ContextManifest = {
|
|
@@ -266,8 +289,9 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
266
289
|
round,
|
|
267
290
|
required: requiredKinds(spec, phase),
|
|
268
291
|
allowedTerminals: allowedTerminals(phase),
|
|
269
|
-
|
|
270
|
-
|
|
292
|
+
contextDir,
|
|
293
|
+
manifestPath: `${contextDir}/${manifestRelPath}`,
|
|
294
|
+
...(notesRelPath !== undefined ? { notesPath: `${contextDir}/${notesRelPath}` } : {}),
|
|
271
295
|
materialized,
|
|
272
296
|
}
|
|
273
297
|
|
|
@@ -324,7 +348,7 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
324
348
|
revision: pinned.revision,
|
|
325
349
|
layout: pinned.layout,
|
|
326
350
|
size: pinned.size,
|
|
327
|
-
path:
|
|
351
|
+
path: `${contextDir}/${relPath}`,
|
|
328
352
|
})
|
|
329
353
|
}
|
|
330
354
|
}
|
|
@@ -374,6 +398,32 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
374
398
|
}
|
|
375
399
|
|
|
376
400
|
if (inputs.findings === 'current' || inputs.currentFeedback === true) {
|
|
401
|
+
if (phase === 'implement') {
|
|
402
|
+
const receiptSeq = state.verifyStage.implementations[String(round)]
|
|
403
|
+
const receipt = state.verifyStage.failures.find((f) => f.seq === receiptSeq)
|
|
404
|
+
if (receipt) {
|
|
405
|
+
manifest.verifyStageFailure = receipt
|
|
406
|
+
manifest.verifyReports = []
|
|
407
|
+
for (const failed of receipt.failed) {
|
|
408
|
+
if (!failed.report) continue
|
|
409
|
+
const path = await writeArtifact(
|
|
410
|
+
`verify/${failed.step}.md`,
|
|
411
|
+
failed.report.kind,
|
|
412
|
+
failed.report.rev,
|
|
413
|
+
)
|
|
414
|
+
if (path === undefined)
|
|
415
|
+
throw new Error(
|
|
416
|
+
`Missing routed verify report ${failed.report.kind}@${failed.report.rev}`,
|
|
417
|
+
)
|
|
418
|
+
manifest.verifyReports.push({ step: failed.step, report: failed.report, path })
|
|
419
|
+
}
|
|
420
|
+
manifest.cancelledVerify = receipt.cancelled.map((c) => ({
|
|
421
|
+
...c,
|
|
422
|
+
attempt: receipt.attempt,
|
|
423
|
+
status: 'not-run' as const,
|
|
424
|
+
}))
|
|
425
|
+
}
|
|
426
|
+
}
|
|
377
427
|
const feedback = currentFeedback(events, phase, round)
|
|
378
428
|
if (feedback !== null) {
|
|
379
429
|
manifest.feedback = feedback
|
|
@@ -384,7 +434,7 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
384
434
|
.map((id) => byId.get(id))
|
|
385
435
|
.filter((finding): finding is Finding => finding !== undefined)
|
|
386
436
|
await writeDerived('findings.json', `${JSON.stringify(resolved, null, 2)}\n`)
|
|
387
|
-
} else if ('verify' in feedback) {
|
|
437
|
+
} else if ('verify' in feedback && manifest.verifyReports === undefined) {
|
|
388
438
|
// The verify failure report routed back into the code loop (§5) — the
|
|
389
439
|
// exact rev the feedback cites, not just the latest.
|
|
390
440
|
await writeArtifact(
|
|
@@ -392,7 +442,7 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
392
442
|
feedback.verify.report.kind,
|
|
393
443
|
feedback.verify.report.rev,
|
|
394
444
|
)
|
|
395
|
-
} else {
|
|
445
|
+
} else if ('guidance' in feedback) {
|
|
396
446
|
// A human escalation answer fed in as authoritative feedback (§15.6-B).
|
|
397
447
|
await writeDerived('guidance.json', `${JSON.stringify(feedback.guidance, null, 2)}\n`)
|
|
398
448
|
}
|
|
@@ -464,29 +514,21 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
464
514
|
}
|
|
465
515
|
|
|
466
516
|
if (isVerifyPhase(phase) && state.kind === 'node' && state.integration?.cycle) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const record = await store.getBuild(build)
|
|
470
|
-
if (!record) throw new Error(`node verification build ${build} is missing`)
|
|
471
|
-
const contributionBase =
|
|
472
|
-
state.nodeRestack?.contributionBoundaries?.[manifest.commitRange!.head] ??
|
|
473
|
-
state.nodeRestack?.contributionBase ??
|
|
474
|
-
state.nodeOpened?.sha
|
|
475
|
-
if (!contributionBase)
|
|
517
|
+
const cycle = state.integration.cycle
|
|
518
|
+
if (!cycle.context)
|
|
476
519
|
throw new Error(
|
|
477
|
-
|
|
520
|
+
'node verification is missing prepared context input; prepare a new integration cycle',
|
|
478
521
|
)
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
{ contributionBase, foreignAliases: state.nodeRestack?.foreignAliases },
|
|
522
|
+
const artifact = await store.getArtifact(build, cycle.context.kind, cycle.context.rev)
|
|
523
|
+
if (!artifact) throw new Error('node verification prepared context artifact is missing')
|
|
524
|
+
const { index, specs } = parseNodeVerificationContext(
|
|
525
|
+
new TextDecoder().decode(artifact.content),
|
|
526
|
+
cycle,
|
|
485
527
|
)
|
|
486
528
|
for (const contribution of index.contributions) {
|
|
487
529
|
contribution.specPath = await writeDerived(
|
|
488
530
|
`contributions/${contribution.build}/spec.md`,
|
|
489
|
-
specs
|
|
531
|
+
specs[contribution.build]!,
|
|
490
532
|
)
|
|
491
533
|
}
|
|
492
534
|
const indexPath = await writeDerived(
|
|
@@ -565,6 +607,7 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
565
607
|
// table in §16.1, so there is nothing to materialize yet — the input stays
|
|
566
608
|
// in the table for when config grows one.
|
|
567
609
|
|
|
610
|
+
await mkdir(dirname(join(abDir, manifestRelPath)), { recursive: true })
|
|
568
611
|
await writeFile(join(abDir, manifestRelPath), `${JSON.stringify(manifest, null, 2)}\n`)
|
|
569
612
|
|
|
570
613
|
// Legacy tracked scratch is repository debt, not content Autobuild rewrites.
|
|
@@ -14,7 +14,7 @@ import type { AbEvent } from '../../events/catalog'
|
|
|
14
14
|
import { defineReducer } from '../../kernel/incremental'
|
|
15
15
|
import { verifyPhase } from '../../ontology'
|
|
16
16
|
|
|
17
|
-
export const DASHBOARD_FACTS_REDUCER_VERSION =
|
|
17
|
+
export const DASHBOARD_FACTS_REDUCER_VERSION = 3
|
|
18
18
|
|
|
19
19
|
/** One phase occurrence's wall-clock span, keyed by phase. `startSeq` is the
|
|
20
20
|
* seq of the `*.started` event, so callers can scope by the same seq
|
|
@@ -130,6 +130,7 @@ function foldInterval(intervals: Record<string, PhaseTiming>, ev: AbEvent): void
|
|
|
130
130
|
case 'verify.started':
|
|
131
131
|
open(verifyPhase(ev.payload.step))
|
|
132
132
|
break
|
|
133
|
+
case 'verify.cancelled':
|
|
133
134
|
case 'verify.completed':
|
|
134
135
|
close(verifyPhase(ev.payload.step))
|
|
135
136
|
break
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
integrationCycleVerified,
|
|
10
10
|
} from '../../kernel/integration-state'
|
|
11
11
|
import { landingReady } from '../../kernel/landing-readiness'
|
|
12
|
-
import { projectIntegrationRow } from './integration-row'
|
|
12
|
+
import { projectIntegrationRow, integrationRepairSteps } from './integration-row'
|
|
13
13
|
import { nodeLandingPolicyDisplay, nodeLandingRuleDisplay } from './landing-display'
|
|
14
14
|
|
|
15
15
|
export interface IntegrationChild {
|
|
@@ -65,7 +65,7 @@ export function projectIntegrationDetail(
|
|
|
65
65
|
state:
|
|
66
66
|
c.builds?.some((b) => contributions.has(b)) &&
|
|
67
67
|
!(c.source === membershipSource && open.has(c.id))
|
|
68
|
-
? '
|
|
68
|
+
? 'merged'
|
|
69
69
|
: 'queued',
|
|
70
70
|
}))
|
|
71
71
|
for (const id of open)
|
|
@@ -84,7 +84,7 @@ export function projectIntegrationDetail(
|
|
|
84
84
|
id: contribution,
|
|
85
85
|
builds: [contribution],
|
|
86
86
|
title: 'title unavailable',
|
|
87
|
-
state: '
|
|
87
|
+
state: 'merged',
|
|
88
88
|
landed: true,
|
|
89
89
|
})
|
|
90
90
|
children.sort(
|
|
@@ -113,7 +113,7 @@ export function projectIntegrationDetail(
|
|
|
113
113
|
results.findLast((r) => r.step === step)?.outcome ??
|
|
114
114
|
'pending',
|
|
115
115
|
}))
|
|
116
|
-
const failed =
|
|
116
|
+
const failed = integrationRepairSteps(state)
|
|
117
117
|
const conflict =
|
|
118
118
|
state.nodeRestack?.conflict ??
|
|
119
119
|
(restack.active && restack.replay?.conflicted ? restack.replay : undefined)
|
|
@@ -134,14 +134,14 @@ export function projectIntegrationDetail(
|
|
|
134
134
|
children,
|
|
135
135
|
membershipKnown: !!observation && !observation.diagnostics.length,
|
|
136
136
|
diagnostics: observation?.diagnostics ?? ['child membership unknown'],
|
|
137
|
-
verification: failed
|
|
138
|
-
? `${failed.
|
|
137
|
+
verification: failed.length
|
|
138
|
+
? `${failed.join(', ')} failed — file a repair child targeting ${record.ticket?.id ?? record.slug}`
|
|
139
139
|
: !integrationComplete(state)
|
|
140
|
-
? `pending — runs on the node head against ${row.destination} once every child has
|
|
140
|
+
? `pending — runs on the node head against ${row.destination} once every child has merged`
|
|
141
141
|
: current && integrationCycleVerified(state)
|
|
142
142
|
? 'verified on the current node head and destination'
|
|
143
143
|
: 'pending on the current node head and destination',
|
|
144
144
|
verifySteps,
|
|
145
|
-
landing: `${mode} — ${nodeLandingRuleDisplay(state, config.landing)}${landingReady(state, restack) && mode === 'consent' && state.landing?.command?.kind !== 'land' ? ` — press l, or ab
|
|
145
|
+
landing: `${mode} — ${nodeLandingRuleDisplay(state, config.landing)}${landingReady(state, restack) && mode === 'consent' && state.landing?.command?.kind !== 'land' ? ` — press l, or ab merge ${record.slug}` : ''}`,
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { distanceSuffix } from './target-distance'
|
|
1
2
|
import type { Config } from '../../config/schema'
|
|
2
3
|
import type { BuildState } from '../../kernel/reducer'
|
|
3
4
|
import type { LeafRestackState } from '../../kernel/leaf-restack-state'
|
|
@@ -11,6 +12,32 @@ import type { BuildRecord } from '../../store/types'
|
|
|
11
12
|
import type { DashboardBuild, PipelineStep } from './model'
|
|
12
13
|
import { nodeLandingPolicyDisplay } from './landing-display'
|
|
13
14
|
|
|
15
|
+
/** Repair prompts share the engine's settled-stage barrier and exact cycle evidence. */
|
|
16
|
+
export function integrationRepairSteps(state: BuildState): string[] {
|
|
17
|
+
const cycle = state.integration?.cycle
|
|
18
|
+
if (!cycle || !integrationCurrent(state)) return []
|
|
19
|
+
const pinned = JSON.parse(cycle.config).verify
|
|
20
|
+
if (Array.isArray(pinned.stages)) {
|
|
21
|
+
const receipt = state.verifyStage.failures.find(
|
|
22
|
+
(failure) =>
|
|
23
|
+
failure.cycle === cycle.seq &&
|
|
24
|
+
failure.restackId === cycle.id &&
|
|
25
|
+
failure.headSha === cycle.head &&
|
|
26
|
+
failure.baseSha === cycle.parent,
|
|
27
|
+
)
|
|
28
|
+
return receipt?.failed.map((failure) => failure.step) ?? []
|
|
29
|
+
}
|
|
30
|
+
const first = state.verify.results.find(
|
|
31
|
+
(result) =>
|
|
32
|
+
result.seq > cycle.seq &&
|
|
33
|
+
result.restackId === cycle.id &&
|
|
34
|
+
result.headSha === cycle.head &&
|
|
35
|
+
result.baseSha === cycle.parent &&
|
|
36
|
+
result.outcome === 'fail',
|
|
37
|
+
)
|
|
38
|
+
return first ? [first.step] : []
|
|
39
|
+
}
|
|
40
|
+
|
|
14
41
|
/** Shared list progress and five integration steps. */
|
|
15
42
|
export interface IntegrationRow {
|
|
16
43
|
parentDistance?: string
|
|
@@ -32,7 +59,7 @@ export function projectIntegrationRow(
|
|
|
32
59
|
): IntegrationRow | undefined {
|
|
33
60
|
if (state.kind !== 'node') return undefined
|
|
34
61
|
const destination = state.target
|
|
35
|
-
?
|
|
62
|
+
? state.target.ticket.id
|
|
36
63
|
: (state.baseBranch ?? 'unknown destination')
|
|
37
64
|
const observation = state.integration?.observation
|
|
38
65
|
const openChildren = [...new Set(observation?.openChildren ?? [])]
|
|
@@ -55,7 +82,7 @@ export function projectIntegrationRow(
|
|
|
55
82
|
expected.includes(r.step),
|
|
56
83
|
)
|
|
57
84
|
: []
|
|
58
|
-
const
|
|
85
|
+
const failed = integrationRepairSteps(state)
|
|
59
86
|
const passed = new Set(
|
|
60
87
|
receipts.filter((r) => r.outcome === 'pass' || r.outcome === 'skipped').map((r) => r.step),
|
|
61
88
|
).size
|
|
@@ -79,15 +106,15 @@ export function projectIntegrationRow(
|
|
|
79
106
|
tone: 'red',
|
|
80
107
|
text: `restack onto ${destination} conflicted — open the detail view for files`,
|
|
81
108
|
}
|
|
82
|
-
:
|
|
109
|
+
: failed.length
|
|
83
110
|
? {
|
|
84
111
|
tone: 'red',
|
|
85
|
-
text: `${
|
|
112
|
+
text: `${failed.join(', ')} failed — file a repair child targeting ${record.ticket?.id ?? record.slug}`,
|
|
86
113
|
}
|
|
87
114
|
: ready && mode === 'consent' && state.landing?.command?.kind !== 'land'
|
|
88
115
|
? {
|
|
89
116
|
tone: 'yellow',
|
|
90
|
-
text: `ready to
|
|
117
|
+
text: `ready to merge into ${destination} — press l, or ab merge ${record.slug}`,
|
|
91
118
|
}
|
|
92
119
|
: undefined
|
|
93
120
|
return {
|
|
@@ -112,9 +139,13 @@ export function projectIntegrationRow(
|
|
|
112
139
|
'verify',
|
|
113
140
|
verified,
|
|
114
141
|
current && !verified,
|
|
115
|
-
|
|
142
|
+
failed.length
|
|
143
|
+
? 'failed'
|
|
144
|
+
: current && !verified
|
|
145
|
+
? `${passed}/${expected.length}`
|
|
146
|
+
: undefined,
|
|
116
147
|
),
|
|
117
|
-
step('
|
|
148
|
+
step('merge', !!state.integration?.landing, ready, mode),
|
|
118
149
|
],
|
|
119
150
|
...(alert ? { alert } : {}),
|
|
120
151
|
}
|
|
@@ -174,7 +205,7 @@ export function enrichIntegrationRows(
|
|
|
174
205
|
child.title === 'title unavailable'
|
|
175
206
|
? (active?.collectionIdentity?.title ?? historical?.ticket?.title ?? child.title)
|
|
176
207
|
: child.title,
|
|
177
|
-
state: child.landed ? '
|
|
208
|
+
state: child.landed ? 'merged' : (active?.collectionIdentity?.phase ?? 'queued'),
|
|
178
209
|
}
|
|
179
210
|
})
|
|
180
211
|
// Historical contribution records can resolve several build slugs to the
|
|
@@ -247,9 +278,5 @@ export function nodeParentDistance(state: BuildState): string {
|
|
|
247
278
|
distance.parent === (node?.observedParent?.sha ?? state.nodeComparison?.parentSha)
|
|
248
279
|
? distance.count
|
|
249
280
|
: null
|
|
250
|
-
return count
|
|
251
|
-
? 'parent distance unknown'
|
|
252
|
-
: count === 0
|
|
253
|
-
? 'parent current'
|
|
254
|
-
: `parent ${count} commit${count === 1 ? '' : 's'} ahead`
|
|
281
|
+
return distanceSuffix(count, state.prState)
|
|
255
282
|
}
|