@defrex/autobuild 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/SPEC.md +440 -95
- package/bin/ab-dispatch-kernel.ts +1 -0
- package/docs/accounts.md +9 -0
- package/docs/agent-runtimes.md +1 -0
- package/docs/answering-blocked-builds.md +2 -1
- package/docs/architecture.md +290 -130
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +33 -3
- package/docs/cli.md +2 -1
- package/docs/configuration-overview.md +9 -0
- package/docs/configuration.md +166 -101
- package/docs/dispatcher-hosting.md +19 -3
- package/docs/dispatcher.md +9 -4
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +91 -28
- package/docs/merge-policy.md +28 -9
- package/docs/operator-api.md +43 -18
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +85 -8
- package/docs/remote-store-protocol.md +25 -7
- package/docs/remote-ticket-protocol.md +126 -12
- package/docs/restacking.md +20 -6
- package/docs/seams.md +2 -2
- package/docs/setup.md +19 -13
- package/docs/spec-standard.md +2 -1
- package/docs/ticket-dependencies.md +26 -8
- package/docs/ticket-migration.md +70 -7
- package/docs/ticket-sources.md +82 -5
- package/docs/tickets.md +34 -2
- package/docs/troubleshooting.md +2 -2
- package/docs/verification.md +5 -5
- package/docs/website.md +8 -0
- package/docs/workspaces.md +1 -1
- package/package.json +5 -4
- package/packages/core/src/accounts/hosted-readiness.ts +21 -0
- package/packages/core/src/cli/attention.ts +1 -0
- package/packages/core/src/cli/build-control.ts +36 -12
- package/packages/core/src/cli/connect.ts +9 -18
- package/packages/core/src/cli/context.ts +44 -0
- package/packages/core/src/cli/dashboard/configuration.ts +11 -0
- package/packages/core/src/cli/dashboard/model.ts +40 -10
- package/packages/core/src/cli/dashboard/queue.ts +21 -0
- package/packages/core/src/cli/dashboard/render.ts +40 -22
- package/packages/core/src/cli/dispatch-frontend.ts +63 -30
- package/packages/core/src/cli/dispatch-mode.ts +35 -16
- package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
- package/packages/core/src/cli/dispatch.ts +154 -47
- package/packages/core/src/cli/help.ts +59 -22
- package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
- package/packages/core/src/cli/init-readiness-remote.ts +16 -3
- package/packages/core/src/cli/init-validation.ts +144 -42
- package/packages/core/src/cli/issue-links.ts +67 -0
- package/packages/core/src/cli/main.ts +32 -15
- package/packages/core/src/cli/pr-summary-publication.ts +38 -7
- package/packages/core/src/cli/publication-settlement.ts +36 -24
- package/packages/core/src/cli/repository-status.ts +201 -49
- package/packages/core/src/cli/status.ts +41 -3
- package/packages/core/src/cli/terminals.ts +37 -2
- package/packages/core/src/cli/ticket-editor.ts +20 -6
- package/packages/core/src/cli/ticket.ts +264 -46
- package/packages/core/src/cli/triage-count-sampler.ts +59 -0
- package/packages/core/src/cli/watch.ts +4 -0
- package/packages/core/src/config/live.ts +45 -4
- package/packages/core/src/config/load.ts +9 -0
- package/packages/core/src/config/pipeline-source.ts +6 -2
- package/packages/core/src/config/ready-assignee.ts +86 -0
- package/packages/core/src/config/schema.ts +164 -36
- package/packages/core/src/distribution-packaging.ts +1 -1
- package/packages/core/src/events/catalog.ts +5 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/payloads.ts +70 -0
- package/packages/core/src/events/policy.ts +8 -0
- package/packages/core/src/events/repository.ts +91 -28
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +41 -0
- package/packages/core/src/kernel/build-identity.ts +12 -0
- package/packages/core/src/kernel/change-presence.ts +139 -6
- package/packages/core/src/kernel/dispatch-capacity.ts +80 -14
- package/packages/core/src/kernel/dispatch-status.ts +10 -1
- package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
- package/packages/core/src/kernel/engine.ts +4 -2
- package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
- package/packages/core/src/kernel/harvest.ts +4 -1
- package/packages/core/src/kernel/integration-completeness.ts +104 -17
- package/packages/core/src/kernel/integration-landing.ts +17 -0
- package/packages/core/src/kernel/integration-state.ts +17 -0
- package/packages/core/src/kernel/issue-keywords.ts +202 -0
- package/packages/core/src/kernel/janitor-failure.ts +11 -0
- package/packages/core/src/kernel/kernel-git.ts +87 -0
- package/packages/core/src/kernel/landing-readiness.ts +25 -17
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-issue-links.ts +142 -0
- package/packages/core/src/kernel/node-parent.ts +6 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
- package/packages/core/src/kernel/pr-summary.ts +24 -0
- package/packages/core/src/kernel/read-deferrals.ts +75 -12
- package/packages/core/src/kernel/read-facts.ts +32 -1
- package/packages/core/src/kernel/reconcile-restack.ts +1 -1
- package/packages/core/src/kernel/reducer-registry.ts +31 -1
- package/packages/core/src/kernel/reducer.ts +90 -2
- package/packages/core/src/kernel/ticket-preparation.ts +12 -0
- package/packages/core/src/kernel/verify-budget.ts +43 -0
- package/packages/core/src/operator/index.ts +3 -1
- package/packages/core/src/operator/presentation.ts +3 -0
- package/packages/core/src/operator/protocol.ts +38 -2
- package/packages/core/src/operator/query.ts +66 -29
- package/packages/core/src/operator/registry.ts +47 -26
- package/packages/core/src/operator/tickets.ts +77 -10
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/plugins/registry.ts +1 -0
- package/packages/core/src/ports/forge/contract.ts +69 -0
- package/packages/core/src/ports/forge/create.ts +5 -0
- package/packages/core/src/ports/forge/fake.ts +184 -3
- package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
- package/packages/core/src/ports/forge/github.ts +175 -38
- package/packages/core/src/ports/forge/local-git.ts +14 -0
- package/packages/core/src/ports/forge/readiness.ts +10 -0
- package/packages/core/src/ports/forge-failure.ts +43 -0
- package/packages/core/src/ports/runner/claude.ts +7 -1
- package/packages/core/src/ports/runner/codex.ts +7 -2
- package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
- package/packages/core/src/ports/runner/pi.ts +7 -1
- package/packages/core/src/ports/runner/runtime.ts +3 -0
- package/packages/core/src/ports/runner/start-prompt.ts +37 -0
- package/packages/core/src/ports/tickets/contract.ts +320 -7
- package/packages/core/src/ports/tickets/create.ts +72 -17
- package/packages/core/src/ports/tickets/fake.ts +18 -0
- package/packages/core/src/ports/tickets/file-codec.ts +20 -0
- package/packages/core/src/ports/tickets/file.ts +43 -1
- package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
- package/packages/core/src/ports/tickets/github-issues.ts +431 -0
- package/packages/core/src/ports/tickets/github-validators.ts +194 -0
- package/packages/core/src/ports/tickets/github.ts +2029 -0
- package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
- package/packages/core/src/ports/tickets/issue-links.ts +86 -0
- package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
- package/packages/core/src/ports/tickets/linear.ts +66 -6
- package/packages/core/src/ports/tickets/migration.ts +290 -68
- package/packages/core/src/ports/tickets/operations.ts +98 -12
- package/packages/core/src/ports/tickets/priority.ts +55 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
- package/packages/core/src/ports/tickets/remote.ts +188 -13
- package/packages/core/src/ports/tickets/revision.ts +22 -1
- package/packages/core/src/ports/tickets/states.ts +43 -0
- package/packages/core/src/ports/tickets/tree.ts +58 -12
- package/packages/core/src/ports/tickets/update.ts +12 -2
- package/packages/core/src/ports/types.ts +194 -11
- package/packages/core/src/ports/workspace/commit-preservation.ts +135 -13
- package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +132 -27
- package/packages/core/src/processes/build-runner.ts +99 -21
- package/packages/core/src/processes/dispatcher.ts +1080 -533
- package/packages/core/src/processes/execution-no-progress.ts +5 -0
- package/packages/core/src/processes/harvest-runner.ts +17 -8
- package/packages/core/src/processes/harvest.ts +5 -8
- package/packages/core/src/processes/tick-publication.ts +12 -2
- package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
- package/packages/core/src/processes/workspace-preservation.ts +37 -2
- package/packages/core/src/runtime-identity.ts +10 -2
- package/packages/core/src/scenarios/harness.ts +4 -0
- package/packages/core/src/store/adapter.ts +7 -1
- package/packages/core/src/store/contract.ts +83 -2
- package/packages/core/src/store/digest.ts +32 -1
- package/packages/core/src/store/reducer-value-shapes.json +4187 -3391
- package/packages/core/src/store/remote/protocol.ts +2 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +5 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
- package/packages/core/src/testing/index.ts +18 -1
- package/packages/core/src/testing/presence-history.ts +79 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1197 -31
- package/packages/core/src/testing/upgrade-generations.ts +77 -0
- package/skills/code-review/SKILL.md +4 -3
- package/skills/finalize/SKILL.md +18 -2
- package/skills/guide/SKILL.md +382 -139
- package/skills/guide/references/accounts.md +9 -0
- package/skills/guide/references/integration-tree.md +91 -28
- package/skills/guide/references/merge-policy.md +28 -9
- package/skills/guide/references/operator-api.md +43 -18
- package/skills/guide/references/plugin-authoring.md +85 -8
- package/skills/guide/references/remote-store-protocol.md +25 -7
- package/skills/guide/references/remote-ticket-protocol.md +126 -12
- package/skills/guide/references/restacking.md +20 -6
- package/skills/guide/references/setup.md +19 -13
- package/skills/guide/references/spec-standard.md +2 -1
- package/skills/guide/references/ticket-dependencies.md +26 -8
- package/skills/guide/references/ticket-migration.md +70 -7
- package/skills/harvest-review/SKILL.md +4 -3
- package/skills/implement/SKILL.md +20 -1
- package/skills/operate/SKILL.md +103 -28
- package/skills/plan/SKILL.md +1 -1
- package/skills/reconcile/SKILL.md +5 -4
- package/skills/spec/SKILL.md +15 -2
- package/skills/tickets/SKILL.md +114 -37
- package/templates/autobuild.toml +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A node's issue-link union (SPEC "Forge issue links"). Each landed child
|
|
3
|
+
* records its contribution once as `node.issue-links-recorded` on the node;
|
|
4
|
+
* the node's reducer folds contributions with `mergeNodeIssueLinks`, so the
|
|
5
|
+
* union is never recomputed from child logs. A node's set is its own
|
|
6
|
+
* effective links merged with that union. A root node's PR into the default
|
|
7
|
+
* branch carries the set; a nested node's PR carries it as refs-only lines.
|
|
8
|
+
* Both are written through `Forge.updatePrIssueLinks` and confirmed by
|
|
9
|
+
* `node.issue-links-published`.
|
|
10
|
+
*/
|
|
11
|
+
import type { Forge, IssueLink } from '../ports/types'
|
|
12
|
+
|
|
13
|
+
/** One issue in a node union or a child contribution. `downgraded` is set
|
|
14
|
+
* when some contributing child downgraded the issue before its seal. */
|
|
15
|
+
export interface NodeIssueLink {
|
|
16
|
+
issue: number
|
|
17
|
+
intent: 'closes' | 'refs'
|
|
18
|
+
downgraded?: true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The reduced node fields this module reads. */
|
|
22
|
+
export interface NodeIssueLinkState {
|
|
23
|
+
kind?: 'work' | 'node'
|
|
24
|
+
target?: unknown
|
|
25
|
+
pr?: { number: number }
|
|
26
|
+
prState?: string
|
|
27
|
+
issueLinks: ReadonlyArray<IssueLink & { downgrade?: unknown }>
|
|
28
|
+
nodeIssueLinks?: {
|
|
29
|
+
links: readonly NodeIssueLink[]
|
|
30
|
+
published?: { pr: number; issueLinks: readonly IssueLink[] }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Merge a contribution into a union, per issue: a downgrade by any
|
|
36
|
+
* contributor wins and makes the issue `refs`; otherwise any `closes` makes
|
|
37
|
+
* it `closes`; an issue every contributor only references stays `refs`.
|
|
38
|
+
* Commutative, associative and idempotent; sorted ascending by issue.
|
|
39
|
+
*/
|
|
40
|
+
export function mergeNodeIssueLinks(
|
|
41
|
+
current: readonly NodeIssueLink[],
|
|
42
|
+
contribution: readonly NodeIssueLink[],
|
|
43
|
+
): NodeIssueLink[] {
|
|
44
|
+
const merged = new Map<number, { closes: boolean; downgraded: boolean }>()
|
|
45
|
+
for (const link of [...current, ...contribution]) {
|
|
46
|
+
const entry = merged.get(link.issue) ?? {
|
|
47
|
+
closes: false,
|
|
48
|
+
downgraded: false,
|
|
49
|
+
}
|
|
50
|
+
entry.closes ||= link.intent === 'closes'
|
|
51
|
+
entry.downgraded ||= link.downgraded === true
|
|
52
|
+
merged.set(link.issue, entry)
|
|
53
|
+
}
|
|
54
|
+
return [...merged]
|
|
55
|
+
.sort(([a], [b]) => a - b)
|
|
56
|
+
.map(([issue, { closes, downgraded }]) =>
|
|
57
|
+
downgraded
|
|
58
|
+
? { issue, intent: 'refs' as const, downgraded: true as const }
|
|
59
|
+
: { issue, intent: closes ? ('closes' as const) : ('refs' as const) },
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A build's own effective links with downgrade provenance, ascending. */
|
|
64
|
+
export function ownIssueLinks(state: NodeIssueLinkState): NodeIssueLink[] {
|
|
65
|
+
return [...state.issueLinks]
|
|
66
|
+
.sort((a, b) => a.issue - b.issue)
|
|
67
|
+
.map(({ issue, intent, downgrade }) => ({
|
|
68
|
+
issue,
|
|
69
|
+
intent,
|
|
70
|
+
...(downgrade !== undefined ? { downgraded: true as const } : {}),
|
|
71
|
+
}))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A node's set: its own effective links merged with its children's union. */
|
|
75
|
+
export function nodeIssueLinkSet(state: NodeIssueLinkState): NodeIssueLink[] {
|
|
76
|
+
return mergeNodeIssueLinks(ownIssueLinks(state), state.nodeIssueLinks?.links ?? [])
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** What a landed child records on its target node: a nested node's set (its
|
|
80
|
+
* own links merged with its union), or a leaf's effective links with
|
|
81
|
+
* downgrade provenance. */
|
|
82
|
+
export function contributedIssueLinks(state: NodeIssueLinkState): NodeIssueLink[] {
|
|
83
|
+
return state.kind === 'node' ? nodeIssueLinkSet(state) : ownIssueLinks(state)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The lines a node's PR body carries, when it should: the build is a node,
|
|
87
|
+
* the forge closes issues and can update a PR's keyword lines, and the set is
|
|
88
|
+
* nonempty. A root node's PR into the configured base carries the set as is;
|
|
89
|
+
* a nested node's PR into its parent carries every issue as `refs`, so it
|
|
90
|
+
* shows on the issue without closing anything. */
|
|
91
|
+
export function nodeIssueLinksForForge(
|
|
92
|
+
state: NodeIssueLinkState,
|
|
93
|
+
forge: Pick<Forge, 'closesIssues' | 'updatePrIssueLinks'>,
|
|
94
|
+
): IssueLink[] | undefined {
|
|
95
|
+
if (
|
|
96
|
+
state.kind !== 'node' ||
|
|
97
|
+
forge.closesIssues !== true ||
|
|
98
|
+
typeof forge.updatePrIssueLinks !== 'function'
|
|
99
|
+
)
|
|
100
|
+
return undefined
|
|
101
|
+
const links = nodeIssueLinkSet(state)
|
|
102
|
+
if (links.length === 0) return undefined
|
|
103
|
+
const nested = state.target !== undefined
|
|
104
|
+
return links.map(({ issue, intent }) => ({ issue, intent: nested ? 'refs' : intent }))
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function canonical(links: readonly IssueLink[]): string {
|
|
108
|
+
return JSON.stringify(
|
|
109
|
+
[...links].sort((a, b) => a.issue - b.issue).map(({ issue, intent }) => ({ issue, intent })),
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The links to write when the open node PR's last confirmed readback
|
|
114
|
+
* differs from its set. A pure comparison of reduced state: no forge call
|
|
115
|
+
* and no event read while nothing changes. */
|
|
116
|
+
export function nodeIssueLinksSyncPending(
|
|
117
|
+
state: NodeIssueLinkState,
|
|
118
|
+
forge: Pick<Forge, 'closesIssues' | 'updatePrIssueLinks'>,
|
|
119
|
+
): IssueLink[] | undefined {
|
|
120
|
+
const links = nodeIssueLinksForForge(state, forge)
|
|
121
|
+
if (links === undefined || state.pr === undefined || state.prState !== 'open') return undefined
|
|
122
|
+
const published = state.nodeIssueLinks?.published
|
|
123
|
+
return published === undefined ||
|
|
124
|
+
published.pr !== state.pr.number ||
|
|
125
|
+
canonical(published.issueLinks) !== canonical(links)
|
|
126
|
+
? links
|
|
127
|
+
: undefined
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** True when the last confirmed readback for `pr` already equals `links`. */
|
|
131
|
+
export function nodeIssueLinksPublished(
|
|
132
|
+
state: NodeIssueLinkState,
|
|
133
|
+
pr: number,
|
|
134
|
+
links: readonly IssueLink[],
|
|
135
|
+
): boolean {
|
|
136
|
+
const published = state.nodeIssueLinks?.published
|
|
137
|
+
return (
|
|
138
|
+
published !== undefined &&
|
|
139
|
+
published.pr === pr &&
|
|
140
|
+
canonical(published.issueLinks) === canonical(links)
|
|
141
|
+
)
|
|
142
|
+
}
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
checkTicketRevision,
|
|
11
11
|
} from '../ports/tickets/revision'
|
|
12
12
|
import { validateTicketTree } from '../ports/tickets/tree'
|
|
13
|
+
import { refuseUnsupportedIssueLinks } from '../ports/tickets/issue-links'
|
|
14
|
+
import { refuseUnsupportedPriority } from '../ports/tickets/priority'
|
|
13
15
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
14
16
|
import type { BuildRecord, BuildStore } from '../store/types'
|
|
15
17
|
import type { BuildState } from './reducer'
|
|
@@ -125,6 +127,10 @@ export async function updateTicketTarget(
|
|
|
125
127
|
patch: TicketUpdate,
|
|
126
128
|
expectedRevision?: string,
|
|
127
129
|
): Promise<Ticket | null> {
|
|
130
|
+
// Refuse before node.parent-requested is appended: the catch below only
|
|
131
|
+
// cancels that request on revision errors.
|
|
132
|
+
refuseUnsupportedIssueLinks(ctx.source, patch)
|
|
133
|
+
refuseUnsupportedPriority(ctx.source, patch)
|
|
128
134
|
if (patch.target === undefined) return updateTicket(ctx.source, id, patch, true, expectedRevision)
|
|
129
135
|
const ticket = await requireTicket(ctx.source, id)
|
|
130
136
|
if (expectedRevision !== undefined) {
|
|
@@ -58,6 +58,8 @@ export async function runNodeTransaction(
|
|
|
58
58
|
}
|
|
59
59
|
const record = await deps.store.getBuild(deps.slug)
|
|
60
60
|
if (!record) throw new Error('missing node build')
|
|
61
|
+
// Every repository build, mixed-version deferred ones included: the
|
|
62
|
+
// dispatcher's availability batch mirrors this set so both fingerprints agree.
|
|
61
63
|
const records = await deps.store.listBuildsForRepo(record.repo)
|
|
62
64
|
const digests = await readBuildDigests(deps.store, record.repo)
|
|
63
65
|
const entries = records.flatMap((record) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineReducer } from './incremental'
|
|
2
2
|
import type { AbEvent } from '../events/catalog'
|
|
3
|
+
import type { Decision } from './engine'
|
|
3
4
|
|
|
4
5
|
/** Latest completed occurrence only: never replay an obsolete publication backlog. */
|
|
5
6
|
export const summaryBoundaryReducer = defineReducer<
|
|
@@ -64,6 +65,29 @@ export function summaryBoundary(events: readonly AbEvent[]) {
|
|
|
64
65
|
return summaryBoundaryReducer.reduce(events)
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
const VERIFY_CONTINUATIONS = new Set<Decision['kind']>([
|
|
69
|
+
'run-check',
|
|
70
|
+
'run-agent-verify',
|
|
71
|
+
'evaluate-verify',
|
|
72
|
+
'skip-verify',
|
|
73
|
+
'run-verify-stage',
|
|
74
|
+
'cancel-verify-stage',
|
|
75
|
+
'record-verify-stage-failure',
|
|
76
|
+
])
|
|
77
|
+
|
|
78
|
+
/** Remote guests coalesce a verify cycle into one summary handoff: a completed
|
|
79
|
+
* verify-step occurrence whose next decision stays in the same cycle requests
|
|
80
|
+
* nothing. Local runners never consult this. */
|
|
81
|
+
export function continuesVerifyCycle(
|
|
82
|
+
boundary: { occurrence: number } | undefined,
|
|
83
|
+
verifyStarted: readonly { seq: number }[],
|
|
84
|
+
next: Decision,
|
|
85
|
+
): boolean {
|
|
86
|
+
if (boundary === undefined) return false
|
|
87
|
+
if (!verifyStarted.some((record) => record.seq === boundary.occurrence)) return false
|
|
88
|
+
return VERIFY_CONTINUATIONS.has(next.kind)
|
|
89
|
+
}
|
|
90
|
+
|
|
67
91
|
type SummaryRequest = Extract<AbEvent, { type: 'pr-summary.requested' }>
|
|
68
92
|
export const summaryRequestsReducer = defineReducer<
|
|
69
93
|
{
|
|
@@ -10,6 +10,10 @@ export interface ReadDeferral {
|
|
|
10
10
|
diagnostic: string
|
|
11
11
|
ended: boolean
|
|
12
12
|
settled: boolean
|
|
13
|
+
/** Seq of the chain's latest classified read failure. */
|
|
14
|
+
lastFailureSeq: number
|
|
15
|
+
/** A later own-build read succeeded after `lastFailureSeq`. */
|
|
16
|
+
recovered: boolean
|
|
13
17
|
}
|
|
14
18
|
export interface ReadDeferralsAcc {
|
|
15
19
|
sessions: Record<string, { phase: Phase; round: number; ended: boolean; terminal: boolean }>
|
|
@@ -20,10 +24,27 @@ export function initialReadDeferrals(): ReadDeferralsAcc {
|
|
|
20
24
|
return { sessions: {}, pending: [], raises: {} }
|
|
21
25
|
}
|
|
22
26
|
/** Session identity and the launched phase/round are all required. Diagnostic
|
|
23
|
-
* facts alone never advance a phase or reset any failure allowance.
|
|
27
|
+
* facts alone never advance a phase or reset any failure allowance. A native
|
|
28
|
+
* continuation inherits its predecessor's pending item, so a chain parks once.
|
|
29
|
+
* Recovery is only the durable `session.build-read-recovered` fact newer than
|
|
30
|
+
* the chain's latest failure; it retires a finalize post-step, which has no
|
|
31
|
+
* terminal, once the kernel records that session's step outcome. */
|
|
24
32
|
export function foldReadDeferrals(acc: ReadDeferralsAcc, events: readonly AbEvent[]): void {
|
|
25
33
|
for (const event of events) {
|
|
26
34
|
if (event.type === 'session.started') {
|
|
35
|
+
const predecessor = event.payload.continuation?.predecessor
|
|
36
|
+
if (predecessor !== undefined) {
|
|
37
|
+
for (const item of acc.pending)
|
|
38
|
+
if (
|
|
39
|
+
item.session === predecessor &&
|
|
40
|
+
!item.ended &&
|
|
41
|
+
item.phase === event.payload.phase &&
|
|
42
|
+
item.round === (event.payload.round ?? 1)
|
|
43
|
+
)
|
|
44
|
+
item.session = event.payload.session
|
|
45
|
+
if (!acc.pending.some((item) => item.session === predecessor))
|
|
46
|
+
delete acc.sessions[predecessor]
|
|
47
|
+
}
|
|
27
48
|
acc.sessions[event.payload.session] = {
|
|
28
49
|
phase: event.payload.phase,
|
|
29
50
|
round: event.payload.round ?? 1,
|
|
@@ -53,23 +74,65 @@ export function foldReadDeferrals(acc: ReadDeferralsAcc, events: readonly AbEven
|
|
|
53
74
|
if (event.type === 'session.build-read-failed') {
|
|
54
75
|
const p = event.payload
|
|
55
76
|
const session = acc.sessions[p.session]
|
|
77
|
+
const existing = acc.pending.find((item) => item.session === p.session)
|
|
56
78
|
if (
|
|
57
79
|
session &&
|
|
58
80
|
!session.terminal &&
|
|
59
81
|
!session.ended &&
|
|
60
82
|
session.phase === p.phase &&
|
|
61
|
-
session.round === p.round
|
|
62
|
-
!acc.pending.some((item) => item.session === p.session)
|
|
83
|
+
session.round === p.round
|
|
63
84
|
) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
85
|
+
if (!existing)
|
|
86
|
+
acc.pending.push({
|
|
87
|
+
session: p.session,
|
|
88
|
+
phase: p.phase,
|
|
89
|
+
round: p.round,
|
|
90
|
+
evidenceSeq: event.seq,
|
|
91
|
+
diagnostic: p.diagnostic,
|
|
92
|
+
ended: false,
|
|
93
|
+
settled: false,
|
|
94
|
+
lastFailureSeq: event.seq,
|
|
95
|
+
recovered: false,
|
|
96
|
+
})
|
|
97
|
+
else if (
|
|
98
|
+
!existing.ended &&
|
|
99
|
+
!existing.settled &&
|
|
100
|
+
existing.phase === p.phase &&
|
|
101
|
+
existing.round === p.round
|
|
102
|
+
) {
|
|
103
|
+
// A later failure invalidates earlier recovery; the chain keeps one item.
|
|
104
|
+
existing.lastFailureSeq = event.seq
|
|
105
|
+
existing.recovered = false
|
|
106
|
+
existing.diagnostic = p.diagnostic
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (event.type === 'session.build-read-recovered') {
|
|
111
|
+
const p = event.payload
|
|
112
|
+
for (const item of acc.pending)
|
|
113
|
+
if (
|
|
114
|
+
item.session === p.session &&
|
|
115
|
+
item.phase === p.phase &&
|
|
116
|
+
item.round === p.round &&
|
|
117
|
+
item.evidenceSeq === p.evidenceSeq &&
|
|
118
|
+
item.lastFailureSeq === p.failureSeq &&
|
|
119
|
+
!item.ended &&
|
|
120
|
+
!item.settled
|
|
121
|
+
)
|
|
122
|
+
item.recovered = true
|
|
123
|
+
}
|
|
124
|
+
if (
|
|
125
|
+
(event.type === 'finalize.step-completed' || event.type === 'publication.requested') &&
|
|
126
|
+
acc.pending.some((item) => item.phase === 'finalize' && item.recovered && !item.settled) &&
|
|
127
|
+
event.actor.kind === 'agent'
|
|
128
|
+
) {
|
|
129
|
+
// The kernel's step outcome for a recovered post-step session, even after its end.
|
|
130
|
+
const id = event.actor.session
|
|
131
|
+
const retired = (item: ReadDeferral) =>
|
|
132
|
+
item.session === id && item.phase === 'finalize' && item.recovered && !item.settled
|
|
133
|
+
if (acc.pending.some(retired)) {
|
|
134
|
+
acc.pending = acc.pending.filter((item) => !retired(item))
|
|
135
|
+
delete acc.sessions[id]
|
|
73
136
|
}
|
|
74
137
|
}
|
|
75
138
|
if (event.type === 'session.ended') {
|
|
@@ -116,6 +116,19 @@ const parts = {
|
|
|
116
116
|
dashboard: dashboardFactsReducer,
|
|
117
117
|
deferral: currentDeferralObservationReducer,
|
|
118
118
|
}
|
|
119
|
+
/** Capacity of `replacedHeads`; supersession beyond it falls back to refusal. */
|
|
120
|
+
export const REPLACED_HEADS_CAP = 64
|
|
121
|
+
const OID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/
|
|
122
|
+
/** The published history each recorded rewrite replaced. */
|
|
123
|
+
function replacedShas(event: AbEvent): string[] {
|
|
124
|
+
const shas =
|
|
125
|
+
event.type === 'node.rewritten'
|
|
126
|
+
? [event.payload.previous]
|
|
127
|
+
: event.type === 'restack.rewritten' || event.type === 'reconcile.rewritten'
|
|
128
|
+
? [event.payload.oldHead, event.payload.localBranchHead]
|
|
129
|
+
: []
|
|
130
|
+
return [...new Set(shas)].filter((sha) => OID.test(sha))
|
|
131
|
+
}
|
|
119
132
|
export interface RunnerAttach {
|
|
120
133
|
seq: number
|
|
121
134
|
ts: string
|
|
@@ -158,6 +171,9 @@ export interface BuildReadAcc {
|
|
|
158
171
|
finalizePublicationRequested: boolean
|
|
159
172
|
workspaceFence?: Extract<AbEvent, { type: 'workspace.fenced' }>
|
|
160
173
|
workspacePreservation?: Extract<AbEvent, { type: 'workspace.commits-preserved' }>
|
|
174
|
+
/** Bounded record of the latest distinct shas a recorded rewrite replaced,
|
|
175
|
+
* newest last. Preserved branch heads it covers are superseded. */
|
|
176
|
+
replacedHeads: string[]
|
|
161
177
|
workspaceLoss?: Extract<AbEvent, { type: 'workspace.commits-lost' }>
|
|
162
178
|
latestWorkspace?: Extract<
|
|
163
179
|
AbEvent,
|
|
@@ -217,7 +233,7 @@ export interface BuildReadAcc {
|
|
|
217
233
|
}
|
|
218
234
|
export const buildReadFactsReducer = defineReducer({
|
|
219
235
|
rawEvents: true,
|
|
220
|
-
version:
|
|
236
|
+
version: 7 + Object.values(parts).reduce((sum, reducer) => sum + reducer.version, 0),
|
|
221
237
|
initial: (): BuildReadAcc => ({
|
|
222
238
|
runnerAttaches: [],
|
|
223
239
|
summaryRequests: summaryRequestsReducer.initial(),
|
|
@@ -251,6 +267,7 @@ export const buildReadFactsReducer = defineReducer({
|
|
|
251
267
|
reconcileBases: {},
|
|
252
268
|
reconcileHistory: [],
|
|
253
269
|
restackHistory: [],
|
|
270
|
+
replacedHeads: [],
|
|
254
271
|
candidateRecoveries: {},
|
|
255
272
|
candidateRecoverySeqs: {},
|
|
256
273
|
sessionStarts: [],
|
|
@@ -333,6 +350,13 @@ export const buildReadFactsReducer = defineReducer({
|
|
|
333
350
|
// branch over a durably acknowledged rewrite of the public branch.
|
|
334
351
|
if (event.type === 'reconcile.rewritten' || event.type === 'restack.rewritten')
|
|
335
352
|
delete acc.workspacePreservation
|
|
353
|
+
for (const sha of replacedShas(event)) {
|
|
354
|
+
const index = acc.replacedHeads.indexOf(sha)
|
|
355
|
+
if (index >= 0) acc.replacedHeads.splice(index, 1)
|
|
356
|
+
acc.replacedHeads.push(sha)
|
|
357
|
+
if (acc.replacedHeads.length > REPLACED_HEADS_CAP)
|
|
358
|
+
acc.replacedHeads.splice(0, acc.replacedHeads.length - REPLACED_HEADS_CAP)
|
|
359
|
+
}
|
|
336
360
|
if (event.type === 'session.started') {
|
|
337
361
|
const last = acc.sessionStarts.at(-1)
|
|
338
362
|
if (event.payload.continuation && last?.session === event.payload.continuation.predecessor)
|
|
@@ -510,6 +534,7 @@ export const buildReadFactsReducer = defineReducer({
|
|
|
510
534
|
latestWorkspace: acc.latestWorkspace,
|
|
511
535
|
workspaceFence: acc.workspaceFence,
|
|
512
536
|
workspacePreservation: acc.workspacePreservation,
|
|
537
|
+
replacedHeads: [...acc.replacedHeads],
|
|
513
538
|
workspaceLoss: acc.workspaceLoss,
|
|
514
539
|
planFeedback: structuredClone(acc.planFeedback),
|
|
515
540
|
findings: structuredClone(acc.findings),
|
|
@@ -553,6 +578,7 @@ import { repositoryAttentionReducer } from './repository-attention'
|
|
|
553
578
|
import { dispatchSettingsReducer } from './dispatch-settings'
|
|
554
579
|
import { harvestReducer } from './harvest'
|
|
555
580
|
import { forgeHealthReducer } from './forge-health'
|
|
581
|
+
import { kernelGitHealthReducer } from './kernel-git'
|
|
556
582
|
import { ticketSourceHealthReducer } from './ticket-source-health'
|
|
557
583
|
import { autoMergeDefaultReducer } from './auto-merge-default'
|
|
558
584
|
import { effectiveConfigReducer } from './service-facts'
|
|
@@ -604,6 +630,7 @@ export interface RepositoryReadAcc {
|
|
|
604
630
|
settings: ReturnType<typeof dispatchSettingsReducer.initial>
|
|
605
631
|
harvest: ReturnType<typeof harvestReducer.initial>
|
|
606
632
|
forgeHealth: ReturnType<typeof forgeHealthReducer.initial>
|
|
633
|
+
kernelGit: ReturnType<typeof kernelGitHealthReducer.initial>
|
|
607
634
|
ticketMigrations: ReturnType<typeof ticketMigrationsReducer.initial>
|
|
608
635
|
health: ReturnType<typeof ticketSourceHealthReducer.initial>
|
|
609
636
|
autoMerge: ReturnType<typeof autoMergeDefaultReducer.initial>
|
|
@@ -628,6 +655,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
628
655
|
dispatcherRunFactsReducer('version').version +
|
|
629
656
|
openHarvestExecutionsReducer.version +
|
|
630
657
|
forgeHealthReducer.version +
|
|
658
|
+
kernelGitHealthReducer.version +
|
|
631
659
|
repositoryAttentionReducer.version +
|
|
632
660
|
dispatchSettingsReducer.version +
|
|
633
661
|
harvestReducer.version +
|
|
@@ -658,6 +686,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
658
686
|
settings: dispatchSettingsReducer.initial(),
|
|
659
687
|
harvest: harvestReducer.initial(),
|
|
660
688
|
forgeHealth: forgeHealthReducer.initial(),
|
|
689
|
+
kernelGit: kernelGitHealthReducer.initial(),
|
|
661
690
|
ticketMigrations: ticketMigrationsReducer.initial(),
|
|
662
691
|
health: ticketSourceHealthReducer.initial(),
|
|
663
692
|
autoMerge: autoMergeDefaultReducer.initial(),
|
|
@@ -675,6 +704,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
675
704
|
acc.settings = dispatchSettingsReducer.advance(acc.settings, events)
|
|
676
705
|
acc.harvest = harvestReducer.advance(acc.harvest, events)
|
|
677
706
|
acc.forgeHealth = forgeHealthReducer.advance(acc.forgeHealth, events)
|
|
707
|
+
acc.kernelGit = kernelGitHealthReducer.advance(acc.kernelGit, events)
|
|
678
708
|
acc.ticketMigrations = ticketMigrationsReducer.advance(acc.ticketMigrations, events)
|
|
679
709
|
acc.health = ticketSourceHealthReducer.advance(acc.health, events)
|
|
680
710
|
acc.autoMerge = autoMergeDefaultReducer.advance(acc.autoMerge, events)
|
|
@@ -808,6 +838,7 @@ export const repositoryReadFactsReducer = defineReducer({
|
|
|
808
838
|
settings: dispatchSettingsReducer.finish(acc.settings),
|
|
809
839
|
harvest: harvestReducer.finish(acc.harvest),
|
|
810
840
|
forgeHealth: forgeHealthReducer.finish(acc.forgeHealth),
|
|
841
|
+
kernelGit: kernelGitHealthReducer.finish(acc.kernelGit),
|
|
811
842
|
ticketMigrations: ticketMigrationsReducer.finish(acc.ticketMigrations),
|
|
812
843
|
health: ticketSourceHealthReducer.finish(acc.health),
|
|
813
844
|
autoMerge: autoMergeDefaultReducer.finish(acc.autoMerge),
|
|
@@ -115,7 +115,7 @@ export { retainReplay, restoreReplay } from './replay-retention'
|
|
|
115
115
|
import { restoreReplay } from './replay-retention'
|
|
116
116
|
|
|
117
117
|
/** Restore a sandbox-only change from durable bytes without remote write access. */
|
|
118
|
-
async function restoreChange(deps: RestackDeps, sha: string): Promise<boolean> {
|
|
118
|
+
export async function restoreChange(deps: RestackDeps, sha: string): Promise<boolean> {
|
|
119
119
|
const artifact = await deps.store.getArtifact(deps.slug, `reconcile-change-${sha}`)
|
|
120
120
|
if (artifact === null) return restoreReplay(deps, sha)
|
|
121
121
|
const content = new TextDecoder().decode(artifact.content)
|
|
@@ -31,7 +31,7 @@ import { dispatchFailureBudgetReducer } from '../processes/dispatch-failure-budg
|
|
|
31
31
|
import { ticketSourceHealthReducer } from './ticket-source-health'
|
|
32
32
|
/**
|
|
33
33
|
* Every incremental reducer, with its published version and the whole-array
|
|
34
|
-
* functions it backs. `reducer-registry.test.ts` snapshots the versions and
|
|
34
|
+
* functions it backs. `reducer-registry.integration.test.ts` snapshots the versions and
|
|
35
35
|
* the accumulator shapes, and scans `kernel/`, `store/` and `processes/` so a
|
|
36
36
|
* new event-array projection must be registered here or excluded with a reason.
|
|
37
37
|
*/
|
|
@@ -267,6 +267,35 @@ const parameterized: Record<string, Pick<ValueCatalogEntry, 'args' | 'create'>>
|
|
|
267
267
|
create: ({ phase, round }) => phaseFailuresReducer(phase, round),
|
|
268
268
|
},
|
|
269
269
|
}
|
|
270
|
+
/** The node slugs one digest row names: a `build.created` target, or either
|
|
271
|
+
* side of a node parent move. Undecodable payloads name none. */
|
|
272
|
+
function digestNodeTargetsOf(event: { type: string; payload: unknown }): {
|
|
273
|
+
nodeTargets?: string[]
|
|
274
|
+
} {
|
|
275
|
+
const build = (target: unknown) =>
|
|
276
|
+
target !== null &&
|
|
277
|
+
typeof target === 'object' &&
|
|
278
|
+
'build' in target &&
|
|
279
|
+
typeof target.build === 'string'
|
|
280
|
+
? [target.build]
|
|
281
|
+
: []
|
|
282
|
+
const targetOf = (value: unknown) =>
|
|
283
|
+
value !== null && typeof value === 'object' && 'target' in value ? build(value.target) : []
|
|
284
|
+
const payload = event.payload
|
|
285
|
+
const nodeTargets =
|
|
286
|
+
event.type === 'build.created'
|
|
287
|
+
? targetOf(payload)
|
|
288
|
+
: (event.type === 'node.parent-requested' || event.type === 'node.parent-accepted') &&
|
|
289
|
+
payload !== null &&
|
|
290
|
+
typeof payload === 'object'
|
|
291
|
+
? [
|
|
292
|
+
...('old' in payload ? targetOf(payload.old) : []),
|
|
293
|
+
...('next' in payload ? targetOf(payload.next) : []),
|
|
294
|
+
]
|
|
295
|
+
: []
|
|
296
|
+
return nodeTargets.length ? { nodeTargets } : {}
|
|
297
|
+
}
|
|
298
|
+
|
|
270
299
|
export const REDUCERS: Record<string, RegisteredReducer> = Object.fromEntries(
|
|
271
300
|
Object.entries(REGISTERED).map(([name, entry]) => [
|
|
272
301
|
name,
|
|
@@ -299,6 +328,7 @@ export const REDUCERS: Record<string, RegisteredReducer> = Object.fromEntries(
|
|
|
299
328
|
? { nodeContribution: event.payload }
|
|
300
329
|
: {}),
|
|
301
330
|
...(event.type === 'build.created' ? { kind: event.payload.kind } : {}),
|
|
331
|
+
...digestNodeTargetsOf(event),
|
|
302
332
|
...(event.payload !== null &&
|
|
303
333
|
typeof event.payload === 'object' &&
|
|
304
334
|
'instance' in event.payload
|