@defrex/autobuild 1.10.0 → 1.11.1
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 +745 -69
- package/bin/ab-dispatch-generation.ts +3 -1
- package/docs/accounts.md +2 -1
- package/docs/answering-blocked-builds.md +20 -0
- package/docs/architecture.md +165 -29
- package/docs/build-store.md +10 -7
- package/docs/cli.md +33 -1
- package/docs/configuration-overview.md +4 -1
- package/docs/configuration.md +381 -29
- package/docs/dispatcher.md +64 -4
- package/docs/forges.md +7 -0
- package/docs/integration-tree.md +2 -2
- package/docs/operating.md +4 -2
- package/docs/operator-api.md +134 -6
- package/docs/operator-surfaces.md +85 -0
- package/docs/optimization-nodes.md +69 -11
- package/docs/plugin-authoring.md +37 -1
- package/docs/remote-store-protocol.md +94 -13
- package/docs/remote-ticket-protocol.md +40 -0
- package/docs/restacking.md +20 -4
- package/docs/setup.md +14 -2
- package/docs/ticket-dependencies.md +10 -3
- package/docs/ticket-sources.md +24 -2
- package/docs/tickets.md +7 -1
- package/docs/troubleshooting.md +8 -0
- package/docs/verification.md +4 -3
- package/docs/workspaces.md +3 -0
- package/package.json +9 -5
- package/packages/core/src/cli/accounts.ts +7 -2
- package/packages/core/src/cli/attention.ts +3 -1
- package/packages/core/src/cli/binary-direct.ts +2 -0
- package/packages/core/src/cli/binary-lifecycle.ts +2 -1
- package/packages/core/src/cli/build-control.ts +79 -1
- package/packages/core/src/cli/context.ts +4 -0
- package/packages/core/src/cli/dashboard/facts.ts +49 -53
- package/packages/core/src/cli/dashboard/header.ts +111 -0
- package/packages/core/src/cli/dashboard/model.ts +31 -39
- package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
- package/packages/core/src/cli/dashboard/poll.ts +179 -76
- package/packages/core/src/cli/dashboard/render.ts +159 -230
- package/packages/core/src/cli/dashboard/row-text.ts +538 -0
- package/packages/core/src/cli/dashboard/timeline.ts +288 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
- package/packages/core/src/cli/dispatch-args.ts +44 -1
- package/packages/core/src/cli/dispatch-frontend.ts +40 -40
- package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
- package/packages/core/src/cli/dispatch-launcher.ts +20 -7
- package/packages/core/src/cli/dispatch-web.ts +155 -0
- package/packages/core/src/cli/dispatch.ts +202 -38
- package/packages/core/src/cli/help.ts +87 -3
- package/packages/core/src/cli/init-validation.ts +3 -3
- package/packages/core/src/cli/main.ts +70 -6
- package/packages/core/src/cli/mcp.ts +35 -3
- package/packages/core/src/cli/objective.ts +1 -1
- package/packages/core/src/cli/operator-preference.ts +57 -0
- package/packages/core/src/cli/repo-lease.ts +2 -0
- package/packages/core/src/cli/repo-state.ts +56 -6
- package/packages/core/src/cli/repository-status.ts +105 -49
- package/packages/core/src/cli/status.ts +82 -1
- package/packages/core/src/cli/terminal-restore.ts +32 -7
- package/packages/core/src/cli/ticket.ts +98 -36
- package/packages/core/src/cli/wait.ts +14 -6
- package/packages/core/src/cli/watch.ts +20 -4
- package/packages/core/src/cli/web.ts +139 -0
- package/packages/core/src/config/live.ts +99 -14
- package/packages/core/src/config/load.ts +61 -20
- package/packages/core/src/config/local.ts +212 -0
- package/packages/core/src/config/pipeline-source.ts +2 -0
- package/packages/core/src/config/reference.ts +18 -0
- package/packages/core/src/config/schema.ts +45 -10
- package/packages/core/src/events/catalog.ts +4 -0
- package/packages/core/src/events/payloads.ts +97 -0
- package/packages/core/src/events/policy.ts +10 -0
- package/packages/core/src/events/repository.ts +46 -3
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +381 -30
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/46196d8f0076496a.json +97 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
- package/packages/core/src/kernel/build-roster.ts +230 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
- package/packages/core/src/kernel/dispatch-status.ts +139 -0
- package/packages/core/src/kernel/engine.ts +43 -5
- package/packages/core/src/kernel/execution-intervals.ts +61 -0
- package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
- package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
- package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
- package/packages/core/src/kernel/log-index.ts +19 -0
- package/packages/core/src/kernel/optimization-admission.ts +244 -3
- package/packages/core/src/kernel/optimization.ts +183 -4
- package/packages/core/src/kernel/phase-failures.ts +121 -0
- package/packages/core/src/kernel/published-branch-head.ts +60 -0
- package/packages/core/src/kernel/read-facts.ts +15 -13
- package/packages/core/src/kernel/reducer-registry.ts +27 -8
- package/packages/core/src/kernel/reducer-revisions.ts +27 -0
- package/packages/core/src/kernel/reducer.ts +63 -4
- package/packages/core/src/kernel/rollup.ts +61 -0
- package/packages/core/src/kernel/setup-streak.ts +38 -0
- package/packages/core/src/kernel/step-durations.ts +257 -0
- package/packages/core/src/kernel/target-observation.ts +6 -1
- package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
- package/packages/core/src/kernel/verify-diff-base.ts +5 -0
- package/packages/core/src/kernel/verify-stages.ts +13 -3
- package/packages/core/src/ontology.ts +5 -0
- package/packages/core/src/operator/agent-context-serve.ts +631 -0
- package/packages/core/src/operator/annotations.ts +75 -5
- package/packages/core/src/operator/attention.ts +470 -0
- package/packages/core/src/operator/canonical-skills.ts +35 -0
- package/packages/core/src/operator/cli-equivalents.ts +270 -0
- package/packages/core/src/operator/context-prompts.ts +61 -0
- package/packages/core/src/operator/index.ts +49 -1
- package/packages/core/src/operator/landings.ts +28 -19
- package/packages/core/src/operator/optimization.ts +7 -0
- package/packages/core/src/operator/protocol.ts +3 -0
- package/packages/core/src/operator/query.ts +129 -74
- package/packages/core/src/operator/read-view.ts +5 -2
- package/packages/core/src/operator/registry.ts +406 -46
- package/packages/core/src/operator/requests.ts +20 -18
- package/packages/core/src/operator/sandbox-host.ts +107 -11
- package/packages/core/src/operator/sandbox-resolver.ts +253 -0
- package/packages/core/src/operator/sandbox.ts +778 -82
- package/packages/core/src/operator/ticket-asset-list.ts +77 -0
- package/packages/core/src/operator/ticket-assets.ts +167 -0
- package/packages/core/src/operator/tickets.ts +33 -2
- package/packages/core/src/plugin-sdk/index.ts +22 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/ports/forge/fake.ts +92 -1
- package/packages/core/src/ports/forge/git-blob.ts +15 -0
- package/packages/core/src/ports/forge/github.ts +82 -0
- package/packages/core/src/ports/forge/local-git.ts +61 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
- package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
- package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
- package/packages/core/src/ports/tickets/contract.ts +71 -0
- package/packages/core/src/ports/tickets/fake.ts +11 -0
- package/packages/core/src/ports/tickets/file.ts +18 -0
- package/packages/core/src/ports/tickets/github-fake.ts +136 -4
- package/packages/core/src/ports/tickets/github.ts +387 -30
- package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
- package/packages/core/src/ports/tickets/linear.ts +130 -0
- package/packages/core/src/ports/tickets/priority.ts +9 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
- package/packages/core/src/ports/tickets/remote.ts +70 -6
- package/packages/core/src/ports/tickets/search.ts +139 -0
- package/packages/core/src/ports/types.ts +104 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
- package/packages/core/src/ports/workspace/create.ts +15 -1
- package/packages/core/src/ports/workspace/fake.ts +340 -12
- package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
- package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
- package/packages/core/src/ports/workspace/process-group.ts +48 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
- package/packages/core/src/processes/agent-context-assemble.ts +576 -0
- package/packages/core/src/processes/agent-context.ts +469 -0
- package/packages/core/src/processes/build-runner.ts +387 -236
- package/packages/core/src/processes/dispatcher.ts +211 -55
- package/packages/core/src/processes/execution-no-progress.ts +4 -0
- package/packages/core/src/processes/optimization-activity.ts +120 -0
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/repo-view.ts +78 -2
- package/packages/core/src/processes/sandbox-state.ts +53 -6
- package/packages/core/src/processes/tick-publication.ts +2 -0
- package/packages/core/src/processes/workspace-preparation.ts +76 -0
- package/packages/core/src/scenarios/harness.ts +0 -5
- package/packages/core/src/store/account-redaction.ts +1 -0
- package/packages/core/src/store/adapter.ts +52 -1
- package/packages/core/src/store/agent-context.ts +432 -0
- package/packages/core/src/store/build-feed.ts +291 -0
- package/packages/core/src/store/build-scope.ts +19 -1
- package/packages/core/src/store/contract.ts +911 -14
- package/packages/core/src/store/digest.ts +19 -6
- package/packages/core/src/store/histogram.ts +113 -0
- package/packages/core/src/store/local/schema.ts +62 -0
- package/packages/core/src/store/local/store.ts +628 -22
- package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
- package/packages/core/src/store/memory.ts +461 -69
- package/packages/core/src/store/open-builds.ts +19 -0
- package/packages/core/src/store/phase-session.ts +32 -4
- package/packages/core/src/store/reduced-reads.ts +14 -4
- package/packages/core/src/store/reducer-value-shapes.json +7027 -5751
- package/packages/core/src/store/reducer-values.ts +6 -1
- package/packages/core/src/store/remote/client.ts +208 -2
- package/packages/core/src/store/remote/compatibility.ts +1 -1
- package/packages/core/src/store/remote/index.ts +33 -0
- package/packages/core/src/store/remote/protocol.ts +69 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
- package/packages/core/src/store/remote/released-reducer-values/1.11.1.json +35718 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
- package/packages/core/src/store/retention.ts +23 -1
- package/packages/core/src/store/rollups.ts +337 -0
- package/packages/core/src/store/session-handle.ts +20 -2
- package/packages/core/src/store/snapshots.ts +10 -0
- package/packages/core/src/store/types.ts +108 -9
- package/packages/core/src/testing/dispatch-journals.ts +117 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
- package/packages/core/src/testing/git-config-isolation.ts +7 -5
- package/packages/core/src/testing/index.ts +27 -0
- package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
- package/packages/core/src/web/analytics-source.ts +303 -0
- package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
- package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
- package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
- package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
- package/packages/core/src/web/assets/app.css +1 -0
- package/packages/core/src/web/assets/app.js +9 -0
- package/packages/core/src/web/assets/manifest.json +31 -0
- package/packages/core/src/web/assets/theme.js +1 -0
- package/packages/core/src/web/bounded.ts +31 -0
- package/packages/core/src/web/http.ts +315 -0
- package/packages/core/src/web/hub.ts +160 -0
- package/packages/core/src/web/options.ts +38 -0
- package/packages/core/src/web/overview-source.ts +322 -0
- package/packages/core/src/web/page.ts +56 -0
- package/packages/core/src/web/protocol.ts +151 -0
- package/packages/core/src/web/read-only.ts +23 -0
- package/packages/core/src/web/repository-source.ts +39 -0
- package/packages/core/src/web/server.ts +97 -0
- package/skills/code-review/SKILL.md +10 -2
- package/skills/guide/SKILL.md +376 -54
- package/skills/guide/references/accounts.md +2 -1
- package/skills/guide/references/integration-tree.md +2 -2
- package/skills/guide/references/operator-api.md +134 -6
- package/skills/guide/references/optimization-nodes.md +69 -11
- package/skills/guide/references/plugin-authoring.md +37 -1
- package/skills/guide/references/remote-store-protocol.md +94 -13
- package/skills/guide/references/remote-ticket-protocol.md +40 -0
- package/skills/guide/references/restacking.md +20 -4
- package/skills/guide/references/setup.md +14 -2
- package/skills/guide/references/ticket-dependencies.md +10 -3
- package/skills/implement/SKILL.md +23 -4
- package/skills/operate/SKILL.md +134 -32
- package/skills/plan/SKILL.md +10 -4
- package/skills/plan-review/SKILL.md +9 -2
- package/skills/spec/SKILL.md +34 -8
- package/skills/tickets/SKILL.md +51 -5
- package/templates/hosted-service/package.json +2 -2
|
@@ -19,7 +19,7 @@ import type { IssueLink, NativeSessionHandle, TicketPriority } from '../ports/ty
|
|
|
19
19
|
import { advanceLanding, type LandingState } from './landing-state'
|
|
20
20
|
import { advanceIntegration, type IntegrationState } from './integration-state'
|
|
21
21
|
import { advanceNodeRestack, type NodeRestackState } from './node-restack-state'
|
|
22
|
-
import { advanceOptimization,
|
|
22
|
+
import { advanceOptimization, foldsIntoOptimization, type OptimizationState } from './optimization'
|
|
23
23
|
import { advanceLandingMeasurement, type LandingMeasurementState } from './landing-measurement'
|
|
24
24
|
import { advancePanel, isPanelEvent, type PanelRunState } from './panel'
|
|
25
25
|
import { mergeNodeIssueLinks, type NodeIssueLink } from './node-issue-links'
|
|
@@ -430,6 +430,9 @@ export interface BuildState {
|
|
|
430
430
|
ciFailure?: CiFailureRecord
|
|
431
431
|
/** Readiness provenance, landing-bound consent and native application receipts. */
|
|
432
432
|
targetRewrite?: Extract<AbEvent, { type: 'target.rewritten' }>
|
|
433
|
+
/** seq of the first `target.rewritten` of the open episode: the run of
|
|
434
|
+
* rewrites with the same branch and rejected baseline. */
|
|
435
|
+
targetRewriteSince?: number
|
|
433
436
|
janitor?: {
|
|
434
437
|
firstFailureAt: string
|
|
435
438
|
attempt: number
|
|
@@ -655,12 +658,20 @@ export interface BuildAcc {
|
|
|
655
658
|
/** seq of the latest `reconcile.completed`: a wait-resume
|
|
656
659
|
* `restack.completed` citing another cycle replayed cleanly. */
|
|
657
660
|
lastReconcileCompletedSeq?: number
|
|
661
|
+
/** An accepted rewritten target whose unpublished local commits await
|
|
662
|
+
* their owner's publishing completion, which opens the verify cycle. */
|
|
663
|
+
acceptedRewriteOwner?: NonNullable<
|
|
664
|
+
import('../events/payloads').EventPayload<'target.rewrite-recovered'>['pendingLocal']
|
|
665
|
+
>['owner'] & { acceptedSeq: number }
|
|
658
666
|
reviewRoundCeilings: BuildState['reviewRoundCeilings']
|
|
659
667
|
reopen?: ReopenState
|
|
660
668
|
pr: BuildState['pr']
|
|
661
669
|
prState?: PrLifecycle
|
|
662
670
|
ciFailure?: CiFailureRecord
|
|
663
671
|
targetRewrite?: Extract<AbEvent, { type: 'target.rewritten' }>
|
|
672
|
+
/** seq of the first `target.rewritten` of the open episode: the run of
|
|
673
|
+
* rewrites with the same branch and rejected baseline. */
|
|
674
|
+
targetRewriteSince?: number
|
|
664
675
|
janitor?: {
|
|
665
676
|
firstFailureAt: string
|
|
666
677
|
attempt: number
|
|
@@ -881,13 +892,55 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
881
892
|
for (const escalation of [...openEscalations.values()])
|
|
882
893
|
if (escalation.janitor) openEscalations.delete(escalation.id)
|
|
883
894
|
}
|
|
884
|
-
if (event.type === 'target.rewritten')
|
|
895
|
+
if (event.type === 'target.rewritten') {
|
|
896
|
+
// An episode is a run of rewrites with the same branch and rejected
|
|
897
|
+
// baseline: its first fact's seq identifies it for attention.
|
|
898
|
+
const open = acc.targetRewrite?.payload
|
|
899
|
+
if (
|
|
900
|
+
open === undefined ||
|
|
901
|
+
acc.targetRewriteSince === undefined ||
|
|
902
|
+
open.branch !== event.payload.branch ||
|
|
903
|
+
open.previousSha !== event.payload.previousSha
|
|
904
|
+
)
|
|
905
|
+
acc.targetRewriteSince = event.seq
|
|
906
|
+
acc.targetRewrite = event
|
|
907
|
+
}
|
|
885
908
|
if (
|
|
886
909
|
event.type === 'target.moved' ||
|
|
887
910
|
event.type === 'target.rewrite-cleared' ||
|
|
911
|
+
event.type === 'target.rewrite-recovered' ||
|
|
888
912
|
event.type === 'node.parent-accepted'
|
|
889
|
-
)
|
|
913
|
+
) {
|
|
890
914
|
delete acc.targetRewrite
|
|
915
|
+
delete acc.targetRewriteSince
|
|
916
|
+
}
|
|
917
|
+
// An accepted rewritten target opens a leaf verify cycle, like a completed
|
|
918
|
+
// reconcile, at the engine's `acceptedRewriteBoundary`: the accept itself,
|
|
919
|
+
// or its pending local owner's first completion after it.
|
|
920
|
+
if (
|
|
921
|
+
acc.kind !== 'node' &&
|
|
922
|
+
event.type === 'target.rewrite-recovered' &&
|
|
923
|
+
event.payload.recovery === 'accepted'
|
|
924
|
+
) {
|
|
925
|
+
delete acc.acceptedRewriteOwner
|
|
926
|
+
if (event.payload.pendingLocal === undefined)
|
|
927
|
+
verify.cycleSince = Math.max(verify.cycleSince, event.seq)
|
|
928
|
+
else
|
|
929
|
+
acc.acceptedRewriteOwner = { ...event.payload.pendingLocal.owner, acceptedSeq: event.seq }
|
|
930
|
+
}
|
|
931
|
+
const owner = acc.acceptedRewriteOwner
|
|
932
|
+
if (
|
|
933
|
+
owner !== undefined &&
|
|
934
|
+
event.seq > owner.acceptedSeq &&
|
|
935
|
+
(owner.kind === 'phase'
|
|
936
|
+
? (event.type === 'implement.completed' && owner.phase === 'implement') ||
|
|
937
|
+
(event.type === 'finalize.completed' && owner.phase === 'finalize') ||
|
|
938
|
+
(event.type === 'reconcile.completed' && owner.phase === 'reconcile')
|
|
939
|
+
: event.type === 'finalize.step-completed' && event.payload.step === owner.step)
|
|
940
|
+
) {
|
|
941
|
+
verify.cycleSince = Math.max(verify.cycleSince, event.seq)
|
|
942
|
+
delete acc.acceptedRewriteOwner
|
|
943
|
+
}
|
|
891
944
|
advanceLanding(acc.landing, event)
|
|
892
945
|
if (event.type.startsWith('integration.')) {
|
|
893
946
|
acc.integration ??= {}
|
|
@@ -900,7 +953,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
900
953
|
acc.nodeRestack ??= { items: [] }
|
|
901
954
|
advanceNodeRestack(acc.nodeRestack, [event])
|
|
902
955
|
}
|
|
903
|
-
if (
|
|
956
|
+
if (foldsIntoOptimization(event))
|
|
904
957
|
acc.optimization = advanceOptimization(acc.optimization, [event])
|
|
905
958
|
if (event.type === 'attempt.measurement-requested') {
|
|
906
959
|
const { observedHead: _observedHead, ...measurement } = acc.attemptMeasurement ?? {}
|
|
@@ -1621,6 +1674,11 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
|
|
|
1621
1674
|
: event.payload.headSha,
|
|
1622
1675
|
}
|
|
1623
1676
|
break
|
|
1677
|
+
case 'target.rewrite-recovered':
|
|
1678
|
+
// A no-work reprovision reset the branch onto the target snapshot.
|
|
1679
|
+
if (acc.kind !== 'node' && event.payload.recovery === 'reprovisioned')
|
|
1680
|
+
implement.contributionBase = event.payload.sha
|
|
1681
|
+
break
|
|
1624
1682
|
case 'restack.advanced':
|
|
1625
1683
|
if (acc.kind !== 'node') implement.contributionBase = event.payload.to
|
|
1626
1684
|
if (acc.wait?.ended && acc.wait.resumedSeq === undefined) acc.wait.resumedSeq = event.seq
|
|
@@ -1983,6 +2041,7 @@ function finishBuild(acc: BuildAcc): BuildState {
|
|
|
1983
2041
|
prState: acc.prState,
|
|
1984
2042
|
...(acc.ciFailure !== undefined ? { ciFailure: structuredClone(acc.ciFailure) } : {}),
|
|
1985
2043
|
targetRewrite: acc.targetRewrite,
|
|
2044
|
+
...(acc.targetRewriteSince !== undefined ? { targetRewriteSince: acc.targetRewriteSince } : {}),
|
|
1986
2045
|
janitor: acc.janitor,
|
|
1987
2046
|
landing: acc.landing,
|
|
1988
2047
|
autoMerge: acc.autoMerge,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived reducers (RFC 0007 §8, SPEC §7.7): a repository rollup over every
|
|
3
|
+
* build's saved value of one registered build reducer.
|
|
4
|
+
*
|
|
5
|
+
* A rollup is three parts: the build reducer (`buildReducer`, a registered
|
|
6
|
+
* build-scope named value), a pure contribution function from that build's
|
|
7
|
+
* slug and finished value to its share of the rollup, and a repository accumulator
|
|
8
|
+
* with `add` and `subtract`. Contributions must be invertible, so a build that
|
|
9
|
+
* changes again (a new closed segment, a reopen) has its previously absorbed
|
|
10
|
+
* contribution subtracted before its new one is added.
|
|
11
|
+
*
|
|
12
|
+
* The store's engine (`store/rollups.ts`) advances a rollup by the builds that
|
|
13
|
+
* changed since its saved change position. Definitions here are pure and
|
|
14
|
+
* browser-safe; they never read the store.
|
|
15
|
+
*/
|
|
16
|
+
import type { z } from 'zod'
|
|
17
|
+
|
|
18
|
+
export interface RollupDefinition<
|
|
19
|
+
Args = unknown,
|
|
20
|
+
Read = unknown,
|
|
21
|
+
Acc = unknown,
|
|
22
|
+
C = unknown,
|
|
23
|
+
Value = unknown,
|
|
24
|
+
> {
|
|
25
|
+
/** The ledger name; revisions go through `bun tools/reducer-revision.ts`. */
|
|
26
|
+
readonly identity: string
|
|
27
|
+
/** Derived from the identity and the build reducer's version, never edited. */
|
|
28
|
+
readonly version: number
|
|
29
|
+
/** The registered build-scope reducer whose finished value is contributed. */
|
|
30
|
+
readonly buildReducer: string
|
|
31
|
+
/** Key arguments, parsed with defaults before hashing: each combination is
|
|
32
|
+
* its own rollup with its own accumulator. */
|
|
33
|
+
readonly args: z.ZodType<Args>
|
|
34
|
+
/** Read-time arguments, parsed with defaults: they shape `finish` only and
|
|
35
|
+
* never create a key. */
|
|
36
|
+
readonly read: z.ZodType<Read>
|
|
37
|
+
readonly accSchema: z.ZodType<Acc>
|
|
38
|
+
readonly contributionSchema: z.ZodType<C>
|
|
39
|
+
/** The finished value a reader can represent; a remote client rejects any
|
|
40
|
+
* answer outside it. */
|
|
41
|
+
readonly valueSchema: z.ZodType
|
|
42
|
+
initial(): Acc
|
|
43
|
+
/** One build's share, or `null` for none. Pure. `slug` is the build's, for
|
|
44
|
+
* contributions that must name their build. */
|
|
45
|
+
contribute(buildValue: unknown, args: Args, now: Date, slug: string): C | null
|
|
46
|
+
/** Fold a contribution into `acc` in place. */
|
|
47
|
+
add(acc: Acc, contribution: C): void
|
|
48
|
+
/** Remove a previously added contribution from `acc` in place. */
|
|
49
|
+
subtract(acc: Acc, contribution: C): void
|
|
50
|
+
/** Whether `acc` holds anything retention drops at `now`. Constant work in
|
|
51
|
+
* builds and events. */
|
|
52
|
+
expired(acc: Acc, now: Date): boolean
|
|
53
|
+
/** Drop what retention no longer keeps; returns whether anything changed. */
|
|
54
|
+
prune(acc: Acc, now: Date): boolean
|
|
55
|
+
/** The answer. Applies retention on its own, so an unpruned accumulator
|
|
56
|
+
* never reports an expired entry. */
|
|
57
|
+
finish(acc: Acc, read: Read, now: Date, position: string): Value
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// biome-ignore lint/suspicious/noExplicitAny: the rollup table is heterogeneous
|
|
61
|
+
export type AnyRollupDefinition = RollupDefinition<any, any, any, any, any>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The consecutive setup-failure streak. Pure so the reducer registry can
|
|
3
|
+
* register it without importing process code.
|
|
4
|
+
*/
|
|
5
|
+
import type { AbEvent } from '../events/catalog'
|
|
6
|
+
import { defineReducer } from './incremental'
|
|
7
|
+
|
|
8
|
+
/** Consecutive durable setup failures since the latest successful attachment
|
|
9
|
+
* or explicit human answer. The accumulator keeps the boundary seq and the
|
|
10
|
+
* failure seqs, so it is exact for any array order. */
|
|
11
|
+
export const setupStreakReducer = defineReducer<
|
|
12
|
+
{ escalations: string[]; boundary: number; failures: number[] },
|
|
13
|
+
AbEvent,
|
|
14
|
+
number
|
|
15
|
+
>({
|
|
16
|
+
identity: 'setupStreak',
|
|
17
|
+
initial: () => ({ escalations: [], boundary: 0, failures: [] }),
|
|
18
|
+
fold(acc, events) {
|
|
19
|
+
for (const event of events) {
|
|
20
|
+
if (event.type === 'runner.attached') acc.boundary = event.seq
|
|
21
|
+
else if (
|
|
22
|
+
event.type === 'escalation.raised' &&
|
|
23
|
+
event.payload.phase === 'setup' &&
|
|
24
|
+
event.payload.source === 'policy'
|
|
25
|
+
) {
|
|
26
|
+
if (!acc.escalations.includes(event.payload.id)) acc.escalations.push(event.payload.id)
|
|
27
|
+
} else if (
|
|
28
|
+
event.type === 'escalation.answered' &&
|
|
29
|
+
acc.escalations.includes(event.payload.id)
|
|
30
|
+
) {
|
|
31
|
+
acc.boundary = event.seq
|
|
32
|
+
} else if (event.type === 'runner.setup-failed') {
|
|
33
|
+
acc.failures.push(event.seq)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
finish: (acc) => acc.failures.filter((seq) => seq > acc.boundary).length,
|
|
38
|
+
})
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `stepDurations`, the first rollup (RFC 0007 §8.6, SPEC §7.7): per step and
|
|
3
|
+
* UTC day, a log-scale histogram of closed segment durations from every
|
|
4
|
+
* build's `buildTimeline`.
|
|
5
|
+
*
|
|
6
|
+
* - Key arguments: `outcome` (`merged`, default, or `all`) and `kind` (`leaf`,
|
|
7
|
+
* default, `node` or `all`). `leaf` means any build whose kind is not
|
|
8
|
+
* `node`, so optimization attempts count as leaves.
|
|
9
|
+
* - Read-time argument: `window` (`24h`, `7d`, default, `30d` or `all`). A
|
|
10
|
+
* window selects every UTC day it overlaps.
|
|
11
|
+
* - Retention: days before `utcDay(now) − 400 days` are dropped.
|
|
12
|
+
*
|
|
13
|
+
* Pure and browser-safe.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod'
|
|
16
|
+
import {
|
|
17
|
+
TIMELINE_LATE_PHASE_STEPS,
|
|
18
|
+
TIMELINE_PHASE_STEPS,
|
|
19
|
+
TIMELINE_WAIT_STEPS,
|
|
20
|
+
buildTimelineReducer,
|
|
21
|
+
type BuildTimeline,
|
|
22
|
+
} from '../cli/dashboard/timeline'
|
|
23
|
+
import {
|
|
24
|
+
addCell,
|
|
25
|
+
bucketOf,
|
|
26
|
+
histogramSchema,
|
|
27
|
+
mergeInto,
|
|
28
|
+
percentile,
|
|
29
|
+
subtractFrom,
|
|
30
|
+
totals,
|
|
31
|
+
type Histogram,
|
|
32
|
+
} from '../store/histogram'
|
|
33
|
+
import { reducerVersion } from './reducer-identity'
|
|
34
|
+
import type { RollupDefinition } from './rollup'
|
|
35
|
+
|
|
36
|
+
export const STEP_DURATIONS_RETENTION_DAYS = 400
|
|
37
|
+
const DAY_MS = 86_400_000
|
|
38
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/
|
|
39
|
+
|
|
40
|
+
export const STEP_DURATION_WINDOWS = ['24h', '7d', '30d', 'all'] as const
|
|
41
|
+
export type StepDurationWindow = (typeof STEP_DURATION_WINDOWS)[number]
|
|
42
|
+
const WINDOW_MS: Record<Exclude<StepDurationWindow, 'all'>, number> = {
|
|
43
|
+
'24h': DAY_MS,
|
|
44
|
+
'7d': 7 * DAY_MS,
|
|
45
|
+
'30d': 30 * DAY_MS,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const argsSchema = z
|
|
49
|
+
.object({
|
|
50
|
+
outcome: z.enum(['merged', 'all']).default('merged'),
|
|
51
|
+
kind: z.enum(['leaf', 'node', 'all']).default('leaf'),
|
|
52
|
+
})
|
|
53
|
+
.strict()
|
|
54
|
+
export type StepDurationArgs = z.infer<typeof argsSchema>
|
|
55
|
+
const readSchema = z.object({ window: z.enum(STEP_DURATION_WINDOWS).default('7d') }).strict()
|
|
56
|
+
export type StepDurationRead = z.infer<typeof readSchema>
|
|
57
|
+
|
|
58
|
+
/** UTC day → step → histogram. */
|
|
59
|
+
export type DayHistograms = Record<string, Record<string, Histogram>>
|
|
60
|
+
const dayHistogramsSchema = z.record(
|
|
61
|
+
z.string().regex(DAY),
|
|
62
|
+
z.record(z.string().min(1), histogramSchema),
|
|
63
|
+
)
|
|
64
|
+
export interface StepDurationsAcc {
|
|
65
|
+
days: DayHistograms
|
|
66
|
+
}
|
|
67
|
+
const accSchema = z.object({ days: dayHistogramsSchema }).strict()
|
|
68
|
+
|
|
69
|
+
export interface StepDurationStat {
|
|
70
|
+
step: string
|
|
71
|
+
count: number
|
|
72
|
+
meanMs: number
|
|
73
|
+
p50Ms: number
|
|
74
|
+
p90Ms: number
|
|
75
|
+
p99Ms: number
|
|
76
|
+
totalMs: number
|
|
77
|
+
}
|
|
78
|
+
export interface StepDurationsValue {
|
|
79
|
+
/** The repository change position the answer reflects. */
|
|
80
|
+
position: string
|
|
81
|
+
window: StepDurationWindow
|
|
82
|
+
steps: StepDurationStat[]
|
|
83
|
+
}
|
|
84
|
+
const statSchema = z
|
|
85
|
+
.object({
|
|
86
|
+
step: z.string().min(1),
|
|
87
|
+
count: z.number().int().positive(),
|
|
88
|
+
meanMs: z.number().nonnegative(),
|
|
89
|
+
p50Ms: z.number().nonnegative(),
|
|
90
|
+
p90Ms: z.number().nonnegative(),
|
|
91
|
+
p99Ms: z.number().nonnegative(),
|
|
92
|
+
totalMs: z.number().nonnegative(),
|
|
93
|
+
})
|
|
94
|
+
.strict()
|
|
95
|
+
const valueSchema = z
|
|
96
|
+
.object({
|
|
97
|
+
position: z.string().regex(/^(0|[1-9][0-9]*)$/),
|
|
98
|
+
window: z.enum(STEP_DURATION_WINDOWS),
|
|
99
|
+
steps: z.array(statSchema),
|
|
100
|
+
})
|
|
101
|
+
.strict()
|
|
102
|
+
|
|
103
|
+
export function utcDay(at: Date | number | string): string {
|
|
104
|
+
return new Date(at).toISOString().slice(0, 10)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The oldest UTC day retention keeps at `now`. */
|
|
108
|
+
export function retentionCutoff(now: Date): string {
|
|
109
|
+
return utcDay(now.getTime() - STEP_DURATIONS_RETENTION_DAYS * DAY_MS)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Pipeline order: phases, `verify:*` by name, finalize, reconcile, then waits
|
|
113
|
+
* in table order. Unknown steps sort last by name. */
|
|
114
|
+
export function stepOrder(steps: Iterable<string>): string[] {
|
|
115
|
+
const rank = (step: string): number => {
|
|
116
|
+
const phase = (TIMELINE_PHASE_STEPS as readonly string[]).indexOf(step)
|
|
117
|
+
if (phase >= 0) return phase
|
|
118
|
+
if (step.startsWith('verify:')) return 10
|
|
119
|
+
const late = (TIMELINE_LATE_PHASE_STEPS as readonly string[]).indexOf(step)
|
|
120
|
+
if (late >= 0) return 20 + late
|
|
121
|
+
const wait = (TIMELINE_WAIT_STEPS as readonly string[]).indexOf(step)
|
|
122
|
+
if (wait >= 0) return 30 + wait
|
|
123
|
+
return 100
|
|
124
|
+
}
|
|
125
|
+
return [...steps].sort((a, b) => rank(a) - rank(b) || (a < b ? -1 : a > b ? 1 : 0))
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The record at `key`, created empty when absent. */
|
|
129
|
+
function slot<T extends object>(record: Record<string, T>, key: string): T {
|
|
130
|
+
let value = record[key]
|
|
131
|
+
if (value === undefined) {
|
|
132
|
+
value = {} as T
|
|
133
|
+
record[key] = value
|
|
134
|
+
}
|
|
135
|
+
return value
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function passes(timeline: BuildTimeline, args: StepDurationArgs): boolean {
|
|
139
|
+
if (args.outcome === 'merged' && timeline.outcome !== 'merged') return false
|
|
140
|
+
if (args.kind === 'leaf' && timeline.kind === 'node') return false
|
|
141
|
+
if (args.kind === 'node' && timeline.kind !== 'node') return false
|
|
142
|
+
return true
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function contribute(value: unknown, args: StepDurationArgs, now: Date): DayHistograms | null {
|
|
146
|
+
const timeline = value as BuildTimeline
|
|
147
|
+
if (!passes(timeline, args)) return null
|
|
148
|
+
const cutoff = retentionCutoff(now)
|
|
149
|
+
const days: DayHistograms = {}
|
|
150
|
+
for (const segment of timeline.segments) {
|
|
151
|
+
// Open and abandoned segments contribute nothing.
|
|
152
|
+
if (segment.state !== 'closed' || segment.end === undefined) continue
|
|
153
|
+
const day = utcDay(segment.end)
|
|
154
|
+
if (day < cutoff) continue
|
|
155
|
+
const count = segment.merged ?? 1
|
|
156
|
+
const hist = slot(slot(days, day), segment.category)
|
|
157
|
+
// A merged segment records its occurrences at their mean's bucket, so
|
|
158
|
+
// count and total stay exact.
|
|
159
|
+
addCell(hist, bucketOf(segment.durationMs / count), count, segment.durationMs)
|
|
160
|
+
}
|
|
161
|
+
return Object.keys(days).length ? days : null
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function add(acc: StepDurationsAcc, contribution: DayHistograms): void {
|
|
165
|
+
for (const [day, steps] of Object.entries(contribution)) {
|
|
166
|
+
const into = slot(acc.days, day)
|
|
167
|
+
for (const [step, hist] of Object.entries(steps)) mergeInto(slot(into, step), hist)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function subtract(acc: StepDurationsAcc, contribution: DayHistograms): void {
|
|
172
|
+
for (const [day, steps] of Object.entries(contribution)) {
|
|
173
|
+
// A day retention already dropped has nothing left to subtract.
|
|
174
|
+
const from = acc.days[day]
|
|
175
|
+
if (from === undefined) continue
|
|
176
|
+
for (const [step, hist] of Object.entries(steps)) {
|
|
177
|
+
const target = from[step]
|
|
178
|
+
if (target === undefined) continue
|
|
179
|
+
subtractFrom(target, hist)
|
|
180
|
+
if (Object.keys(target).length === 0) delete from[step]
|
|
181
|
+
}
|
|
182
|
+
if (Object.keys(from).length === 0) delete acc.days[day]
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function expired(acc: StepDurationsAcc, now: Date): boolean {
|
|
187
|
+
const cutoff = retentionCutoff(now)
|
|
188
|
+
for (const day of Object.keys(acc.days)) if (day < cutoff) return true
|
|
189
|
+
return false
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function prune(acc: StepDurationsAcc, now: Date): boolean {
|
|
193
|
+
const cutoff = retentionCutoff(now)
|
|
194
|
+
let changed = false
|
|
195
|
+
for (const day of Object.keys(acc.days))
|
|
196
|
+
if (day < cutoff) {
|
|
197
|
+
delete acc.days[day]
|
|
198
|
+
changed = true
|
|
199
|
+
}
|
|
200
|
+
return changed
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function finish(
|
|
204
|
+
acc: StepDurationsAcc,
|
|
205
|
+
read: StepDurationRead,
|
|
206
|
+
now: Date,
|
|
207
|
+
position: string,
|
|
208
|
+
): StepDurationsValue {
|
|
209
|
+
const retained = retentionCutoff(now)
|
|
210
|
+
const since = read.window === 'all' ? retained : utcDay(now.getTime() - WINDOW_MS[read.window])
|
|
211
|
+
const from = since > retained ? since : retained
|
|
212
|
+
const merged: Record<string, Histogram> = {}
|
|
213
|
+
for (const [day, steps] of Object.entries(acc.days)) {
|
|
214
|
+
if (day < from) continue
|
|
215
|
+
for (const [step, hist] of Object.entries(steps)) mergeInto(slot(merged, step), hist)
|
|
216
|
+
}
|
|
217
|
+
const steps: StepDurationStat[] = []
|
|
218
|
+
for (const step of stepOrder(Object.keys(merged))) {
|
|
219
|
+
const hist = merged[step]!
|
|
220
|
+
const { count, totalMs } = totals(hist)
|
|
221
|
+
if (count === 0) continue
|
|
222
|
+
steps.push({
|
|
223
|
+
step,
|
|
224
|
+
count,
|
|
225
|
+
meanMs: Math.round(totalMs / count),
|
|
226
|
+
p50Ms: Math.round(percentile(hist, 0.5)),
|
|
227
|
+
p90Ms: Math.round(percentile(hist, 0.9)),
|
|
228
|
+
p99Ms: Math.round(percentile(hist, 0.99)),
|
|
229
|
+
totalMs,
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
return { position, window: read.window, steps }
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export const stepDurationsRollup: RollupDefinition<
|
|
236
|
+
StepDurationArgs,
|
|
237
|
+
StepDurationRead,
|
|
238
|
+
StepDurationsAcc,
|
|
239
|
+
DayHistograms,
|
|
240
|
+
StepDurationsValue
|
|
241
|
+
> = {
|
|
242
|
+
identity: 'stepDurations',
|
|
243
|
+
version: reducerVersion('stepDurations', [buildTimelineReducer]),
|
|
244
|
+
buildReducer: 'buildTimeline',
|
|
245
|
+
args: argsSchema,
|
|
246
|
+
read: readSchema,
|
|
247
|
+
accSchema,
|
|
248
|
+
contributionSchema: dayHistogramsSchema,
|
|
249
|
+
valueSchema,
|
|
250
|
+
initial: () => ({ days: {} }),
|
|
251
|
+
contribute,
|
|
252
|
+
add,
|
|
253
|
+
subtract,
|
|
254
|
+
expired,
|
|
255
|
+
prune,
|
|
256
|
+
finish,
|
|
257
|
+
}
|
|
@@ -12,7 +12,10 @@ export function assertTargetOid(sha: string): void {
|
|
|
12
12
|
|
|
13
13
|
/** Admit only immutable forward destinations. CAS loss requires reclassification
|
|
14
14
|
* against the winning accepted observation, never a blind append. Reads consume
|
|
15
|
-
* reduced values only; idle polls read no event rows.
|
|
15
|
+
* reduced values only; idle polls read no event rows. A leaf's base in use that
|
|
16
|
+
* an operator's accept-target waived (`target.rewrite-recovered` with
|
|
17
|
+
* `accepted`) is not a baseline for that branch: its own commits restack onto
|
|
18
|
+
* the target at the next replay boundary. No other baseline is waived. */
|
|
16
19
|
export async function observeTarget(input: {
|
|
17
20
|
store: BuildStore
|
|
18
21
|
forge: Forge
|
|
@@ -54,9 +57,11 @@ export async function observeTarget(input: {
|
|
|
54
57
|
return 'rejected'
|
|
55
58
|
let previousSha: string | undefined
|
|
56
59
|
const lineage: TargetLineage[] = []
|
|
60
|
+
const waiver = state.kind === 'node' ? undefined : restack.rewriteWaiver
|
|
57
61
|
for (const baseline of baselines) {
|
|
58
62
|
assertTargetOid(baseline)
|
|
59
63
|
if (baseline === sha) continue
|
|
64
|
+
if (waiver?.branch === branch && waiver.base === baseline) continue
|
|
60
65
|
if (!forge.isCommitAncestor) throw new Error('forge ancestry proof capability unavailable')
|
|
61
66
|
if (!(await forge.isCommitAncestor(baseline, sha))) {
|
|
62
67
|
// Scoped runners trust only the dispatcher-deposited proof for this
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure decisions for a leaf leaving the `target-rewritten` wait (SPEC §7.4).
|
|
3
|
+
* The runner reads Git and the store; these helpers decide from what it read,
|
|
4
|
+
* so the protocol is unit-testable without a workspace.
|
|
5
|
+
*/
|
|
6
|
+
import type { EventPayload } from '../events/payloads'
|
|
7
|
+
import type { LogIndex } from './log-index'
|
|
8
|
+
import type { BuildState } from './reducer'
|
|
9
|
+
|
|
10
|
+
export type PendingLocal = NonNullable<EventPayload<'target.rewrite-recovered'>['pendingLocal']>
|
|
11
|
+
export type PublishingOwner = PendingLocal['owner']
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* How a resuming runner completes an open no-work reset. It never
|
|
15
|
+
* re-classifies: `complete` when the branch already sits at the prepared
|
|
16
|
+
* target, `redo` when it still sits at the proven head with a clean tracked
|
|
17
|
+
* tree, else `unknown`, which escalates rather than resetting over commits
|
|
18
|
+
* nobody proved disposable.
|
|
19
|
+
*/
|
|
20
|
+
export function reprovisionResume(
|
|
21
|
+
prepared: Pick<EventPayload<'target.rewrite-reprovision-prepared'>, 'from' | 'sha'>,
|
|
22
|
+
local: string | undefined,
|
|
23
|
+
clean: boolean,
|
|
24
|
+
): 'complete' | 'redo' | 'unknown' {
|
|
25
|
+
if (local === prepared.sha) return 'complete'
|
|
26
|
+
if (local === prepared.from && clean) return 'redo'
|
|
27
|
+
return 'unknown'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The open occurrence whose own completion publishes local commits made
|
|
32
|
+
* inside it: a started, uncompleted implement, finalize or reconcile phase,
|
|
33
|
+
* else the finalize post-step started after finalize and not completed.
|
|
34
|
+
*/
|
|
35
|
+
export function openPublishingOwner(
|
|
36
|
+
state: Pick<BuildState, 'currentPhase'>,
|
|
37
|
+
log: Pick<LogIndex, 'openFinalizeStep'>,
|
|
38
|
+
): PublishingOwner | undefined {
|
|
39
|
+
const phase = state.currentPhase?.phase
|
|
40
|
+
if (phase === 'implement' || phase === 'finalize' || phase === 'reconcile')
|
|
41
|
+
return { kind: 'phase', phase }
|
|
42
|
+
const step = log.openFinalizeStep
|
|
43
|
+
if (step !== undefined) return { kind: 'finalize-step', step: step.step, startedSeq: step.seq }
|
|
44
|
+
return undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Where an accept finds the build's local commits. `none`: everything local
|
|
49
|
+
* is already published (or nothing exists beyond the base). `pending`: local
|
|
50
|
+
* commits extend the published head (or the base) inside an open publishing
|
|
51
|
+
* occurrence, whose completion publishes them before the restack replays
|
|
52
|
+
* them. `refuse`: local commits no open occurrence owns, which the restack
|
|
53
|
+
* could never replay; the accept is refused rather than discarding them.
|
|
54
|
+
*/
|
|
55
|
+
export function classifyAcceptedLocal(input: {
|
|
56
|
+
local: string
|
|
57
|
+
published: string | undefined
|
|
58
|
+
base: string
|
|
59
|
+
/** `local` is an ancestor of (or equal to) `published`. */
|
|
60
|
+
localInPublished: boolean
|
|
61
|
+
/** `published ?? base` is an ancestor of (or equal to) `local`. */
|
|
62
|
+
localDescends: boolean
|
|
63
|
+
owner: PublishingOwner | undefined
|
|
64
|
+
}):
|
|
65
|
+
| { kind: 'none' }
|
|
66
|
+
| { kind: 'pending'; pendingLocal: PendingLocal }
|
|
67
|
+
| { kind: 'refuse'; from: string } {
|
|
68
|
+
const { local, published, base, owner } = input
|
|
69
|
+
if (published !== undefined ? input.localInPublished : local === base) return { kind: 'none' }
|
|
70
|
+
if (input.localDescends && owner !== undefined)
|
|
71
|
+
return { kind: 'pending', pendingLocal: { head: local, owner } }
|
|
72
|
+
return { kind: 'refuse', from: published ?? base }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const LISTED_COMMITS = 20
|
|
76
|
+
|
|
77
|
+
/** The one operator question of a rewritten-target episode with work at
|
|
78
|
+
* stake, or of a refused accept whose local commits no phase owns. */
|
|
79
|
+
export function targetRewriteQuestion(input: {
|
|
80
|
+
slug: string
|
|
81
|
+
branch: string
|
|
82
|
+
previousSha: string
|
|
83
|
+
sha: string
|
|
84
|
+
/** `sha subject` lines, oldest first. */
|
|
85
|
+
commits: { sha: string; subject: string }[]
|
|
86
|
+
published?: string
|
|
87
|
+
pr?: number
|
|
88
|
+
unowned?: boolean
|
|
89
|
+
}): string {
|
|
90
|
+
const short = (sha: string) => sha.slice(0, 7)
|
|
91
|
+
const listed = input.commits
|
|
92
|
+
.slice(0, LISTED_COMMITS)
|
|
93
|
+
.map((commit) => ` ${short(commit.sha)} ${commit.subject}`)
|
|
94
|
+
if (input.commits.length > LISTED_COMMITS)
|
|
95
|
+
listed.push(` and ${input.commits.length - LISTED_COMMITS} more`)
|
|
96
|
+
const lines = [
|
|
97
|
+
`target ${input.branch} was rewritten: its head ${short(input.sha)} does not descend from ` +
|
|
98
|
+
`this build's base ${short(input.previousSha)}.`,
|
|
99
|
+
]
|
|
100
|
+
if (input.unowned)
|
|
101
|
+
lines.push(
|
|
102
|
+
'The accept was refused: these local commits are unpublished and no open phase owns them, ' +
|
|
103
|
+
'so a restack could not replay them. Remove or publish them, then answer ' +
|
|
104
|
+
`\`ab answer ${input.slug} --accept-target\` again, or \`ab abort ${input.slug}\`.`,
|
|
105
|
+
)
|
|
106
|
+
else
|
|
107
|
+
lines.push(
|
|
108
|
+
`The build has its own work, so it was not reprovisioned. Answer \`ab answer ${input.slug} ` +
|
|
109
|
+
`--accept-target\` to restack its own commits onto the current ${input.branch} head, ` +
|
|
110
|
+
`or \`ab abort ${input.slug}\`.`,
|
|
111
|
+
)
|
|
112
|
+
if (input.published !== undefined) lines.push(`Published head: ${short(input.published)}.`)
|
|
113
|
+
if (input.pr !== undefined) lines.push(`Pull request: #${input.pr}.`)
|
|
114
|
+
if (listed.length > 0) lines.push('Own commits:', ...listed)
|
|
115
|
+
return lines.join('\n')
|
|
116
|
+
}
|
|
@@ -31,6 +31,11 @@ export const verifyDiffBaseReducer = defineReducer<
|
|
|
31
31
|
acc.promoted = event.payload.targetBase
|
|
32
32
|
} else if (event.type === 'restack.advanced') {
|
|
33
33
|
acc.promoted = event.payload.to
|
|
34
|
+
} else if (
|
|
35
|
+
event.type === 'target.rewrite-recovered' &&
|
|
36
|
+
event.payload.recovery === 'reprovisioned'
|
|
37
|
+
) {
|
|
38
|
+
acc.promoted = event.payload.sha
|
|
34
39
|
} else if (event.type === 'reconcile.superseded') {
|
|
35
40
|
// An abandoned occurrence's base never promotes.
|
|
36
41
|
delete acc.pendingReconcileBase
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { verifyStages, type VerifyConfig } from '../config/schema'
|
|
2
2
|
import type { LogIndex, VerifyRecord } from './log-index'
|
|
3
3
|
import type { VerifyStageState } from './verify-stage-state'
|
|
4
|
+
import { acceptedRewriteBoundary } from './leaf-restack-base'
|
|
4
5
|
|
|
5
6
|
/** Pure barrier selection shared by leaf and integration verification. */
|
|
6
7
|
export function activeVerifyStage(
|
|
@@ -41,13 +42,17 @@ export function activeVerifyStage(
|
|
|
41
42
|
/** A leaf's verify cycle boundary inputs (§15.6-A): the latest code-review
|
|
42
43
|
* approval, reconcile completion, configuration boundary, or clean
|
|
43
44
|
* wait-resume restack after a verify:* or finalize wait (SPEC §11 "Ticket
|
|
44
|
-
* waits"). Results at or before it describe an older change or base. The
|
|
45
|
+
* waits"), or an accepted rewritten target's replay boundary. Results at or before it describe an older change or base. The
|
|
45
46
|
* engine's stage selection and its `cycleBoundary` both read it; a node's
|
|
46
47
|
* wait-resume input is always 0, since nodes declare no waits. */
|
|
47
48
|
export function leafVerifyCycleInputs(
|
|
48
49
|
log: Pick<
|
|
49
50
|
LogIndex,
|
|
50
|
-
|
|
51
|
+
| 'code'
|
|
52
|
+
| 'lastReconcileCompletedSeq'
|
|
53
|
+
| 'verifyConfigBoundary'
|
|
54
|
+
| 'waitResumeVerifyBoundary'
|
|
55
|
+
| 'restack'
|
|
51
56
|
>,
|
|
52
57
|
): number {
|
|
53
58
|
return Math.max(
|
|
@@ -55,6 +60,7 @@ export function leafVerifyCycleInputs(
|
|
|
55
60
|
log.lastReconcileCompletedSeq,
|
|
56
61
|
log.verifyConfigBoundary,
|
|
57
62
|
log.waitResumeVerifyBoundary,
|
|
63
|
+
acceptedRewriteBoundary(log) ?? 0,
|
|
58
64
|
)
|
|
59
65
|
}
|
|
60
66
|
|
|
@@ -72,7 +78,11 @@ export function leafVerifiedRestack(
|
|
|
72
78
|
| 'restack'
|
|
73
79
|
>,
|
|
74
80
|
) {
|
|
75
|
-
const replay = Math.max(
|
|
81
|
+
const replay = Math.max(
|
|
82
|
+
log.code.latestApproveSeq,
|
|
83
|
+
log.lastReconcileCompletedSeq,
|
|
84
|
+
acceptedRewriteBoundary(log) ?? 0,
|
|
85
|
+
)
|
|
76
86
|
return log.waitResumeVerifyBoundary > replay
|
|
77
87
|
? log.restack.gates[String(log.waitResumeVerifyCycle)]
|
|
78
88
|
: log.restack.gates[String(replay)]
|