@defrex/autobuild 0.13.0 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/SPEC.md +673 -99
- package/bin/ab-dispatch-kernel.ts +4 -6
- package/docs/architecture.md +322 -75
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +112 -12
- package/docs/hosted-service.md +20 -2
- package/docs/integration-tree.md +117 -0
- package/docs/landing-policy.md +150 -0
- package/docs/mcp.md +24 -0
- package/docs/migration-1.0.md +68 -0
- package/docs/operator-api.md +20 -9
- package/docs/remote-store-protocol.md +114 -9
- package/docs/remote-ticket-protocol.md +26 -5
- package/docs/restacking.md +79 -0
- package/docs/setup.md +49 -6
- package/docs/ticket-dependencies.md +69 -0
- package/docs/ticket-migration.md +8 -0
- package/package.json +4 -3
- package/packages/core/src/cli/attention.ts +40 -163
- package/packages/core/src/cli/build-control.ts +75 -55
- package/packages/core/src/cli/bulk-control.ts +3 -2
- package/packages/core/src/cli/context.ts +68 -78
- package/packages/core/src/cli/dashboard/actions.ts +6 -3
- package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
- package/packages/core/src/cli/dashboard/live.ts +5 -0
- package/packages/core/src/cli/dashboard/model.ts +178 -40
- package/packages/core/src/cli/dashboard/poll.ts +15 -9
- package/packages/core/src/cli/dashboard/refresh.ts +176 -0
- package/packages/core/src/cli/dashboard/render.ts +78 -28
- package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
- package/packages/core/src/cli/dashboard/selection.ts +7 -1
- package/packages/core/src/cli/dashboard/tree.ts +107 -0
- package/packages/core/src/cli/dispatch-frontend.ts +173 -169
- package/packages/core/src/cli/dispatch-process.ts +14 -7
- package/packages/core/src/cli/dispatch-repository-feed.ts +196 -0
- package/packages/core/src/cli/dispatch.ts +397 -214
- package/packages/core/src/cli/dispatcher-liveness.ts +41 -21
- package/packages/core/src/cli/harvest.ts +71 -39
- package/packages/core/src/cli/help.ts +49 -32
- package/packages/core/src/cli/historical-build-state.ts +27 -0
- package/packages/core/src/cli/init-validation.ts +43 -2
- package/packages/core/src/cli/keyboard.ts +6 -0
- package/packages/core/src/cli/landings.ts +18 -0
- package/packages/core/src/cli/main.ts +52 -18
- package/packages/core/src/cli/mcp.ts +9 -0
- package/packages/core/src/cli/pr-attachments.ts +10 -13
- package/packages/core/src/cli/pr-summary-publication.ts +27 -60
- package/packages/core/src/cli/pr-summary.ts +43 -13
- package/packages/core/src/cli/publication-settlement.ts +177 -21
- package/packages/core/src/cli/repository-status.ts +49 -2
- package/packages/core/src/cli/status.ts +133 -36
- package/packages/core/src/cli/terminal-restore.ts +54 -0
- package/packages/core/src/cli/terminal.ts +16 -2
- package/packages/core/src/cli/terminals.ts +121 -219
- package/packages/core/src/cli/ticket-editor.ts +10 -3
- package/packages/core/src/cli/ticket.ts +115 -20
- package/packages/core/src/cli/upgrade-commit.ts +4 -0
- package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
- package/packages/core/src/cli/upgrade-landing.ts +69 -0
- package/packages/core/src/cli/upgrade.ts +16 -0
- package/packages/core/src/cli/wait.ts +194 -91
- package/packages/core/src/cli/watch.ts +111 -109
- package/packages/core/src/config/landing.ts +22 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/pipeline-source.ts +4 -3
- package/packages/core/src/config/schema.ts +3 -0
- package/packages/core/src/events/catalog.ts +48 -3
- package/packages/core/src/events/payloads.ts +295 -6
- package/packages/core/src/events/repository.ts +38 -3
- package/packages/core/src/integration/harness.ts +11 -2
- package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +3330 -119
- package/packages/core/src/kernel/auto-merge-default.ts +1 -0
- package/packages/core/src/kernel/auto-merge.ts +29 -4
- package/packages/core/src/kernel/build-identity.ts +94 -0
- package/packages/core/src/kernel/change-presence.ts +179 -0
- package/packages/core/src/kernel/dispatch-status.ts +17 -1
- package/packages/core/src/kernel/dispatcher-liveness.ts +10 -4
- package/packages/core/src/kernel/engine.ts +89 -2
- package/packages/core/src/kernel/generators/build-log.ts +23 -0
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +25 -3
- package/packages/core/src/kernel/harvest.ts +25 -23
- package/packages/core/src/kernel/integration-completeness.ts +81 -0
- package/packages/core/src/kernel/integration-landing.ts +263 -0
- package/packages/core/src/kernel/integration-stack.ts +36 -0
- package/packages/core/src/kernel/integration-state.ts +135 -0
- package/packages/core/src/kernel/landing-policy.ts +47 -0
- package/packages/core/src/kernel/landing-publication.ts +41 -0
- package/packages/core/src/kernel/landing-readiness.ts +67 -0
- package/packages/core/src/kernel/landing-state.ts +96 -0
- package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
- package/packages/core/src/kernel/log-index-value.ts +38 -0
- package/packages/core/src/kernel/log-index.ts +35 -5
- package/packages/core/src/kernel/node-landing.ts +439 -0
- package/packages/core/src/kernel/node-parent.ts +184 -0
- package/packages/core/src/kernel/node-restack-state.ts +191 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
- package/packages/core/src/kernel/node-restack.ts +274 -0
- package/packages/core/src/kernel/read-facts.ts +704 -0
- package/packages/core/src/kernel/reconcile-head.ts +51 -0
- package/packages/core/src/kernel/reconcile-restack.ts +560 -0
- package/packages/core/src/kernel/reducer-registry.ts +153 -3
- package/packages/core/src/kernel/reducer.ts +121 -6
- package/packages/core/src/kernel/repository-attention.ts +179 -0
- package/packages/core/src/kernel/service-facts.ts +135 -0
- package/packages/core/src/kernel/snapshot-parent.ts +33 -0
- package/packages/core/src/kernel/terminal-guard.ts +133 -0
- package/packages/core/src/ontology.ts +9 -1
- package/packages/core/src/operator/annotations.ts +12 -0
- package/packages/core/src/operator/control.ts +11 -6
- package/packages/core/src/operator/index.ts +6 -0
- package/packages/core/src/operator/landings.ts +35 -0
- package/packages/core/src/operator/presentation.ts +1 -0
- package/packages/core/src/operator/protocol.ts +12 -3
- package/packages/core/src/operator/query.ts +40 -21
- package/packages/core/src/operator/read-view.ts +4 -13
- package/packages/core/src/operator/registry.ts +48 -19
- package/packages/core/src/operator/requests.ts +3 -22
- package/packages/core/src/operator/sandbox.ts +10 -9
- package/packages/core/src/operator/tickets.ts +57 -11
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/ports/forge/contract.ts +91 -3
- package/packages/core/src/ports/forge/fake.ts +142 -4
- package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
- package/packages/core/src/ports/forge/github-readiness.ts +421 -0
- package/packages/core/src/ports/forge/github.ts +631 -35
- package/packages/core/src/ports/forge/local-git.ts +119 -5
- package/packages/core/src/ports/forge/readiness.ts +99 -0
- package/packages/core/src/ports/tickets/contract.ts +41 -0
- package/packages/core/src/ports/tickets/create.ts +8 -1
- package/packages/core/src/ports/tickets/fake.ts +32 -1
- package/packages/core/src/ports/tickets/file-codec.ts +7 -0
- package/packages/core/src/ports/tickets/file.ts +18 -1
- package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
- package/packages/core/src/ports/tickets/linear.ts +124 -4
- package/packages/core/src/ports/tickets/migration.ts +25 -1
- package/packages/core/src/ports/tickets/operations.ts +7 -2
- package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
- package/packages/core/src/ports/tickets/remote.ts +10 -1
- package/packages/core/src/ports/tickets/revision.ts +3 -1
- package/packages/core/src/ports/tickets/tree.ts +148 -0
- package/packages/core/src/ports/tickets/update.ts +15 -2
- package/packages/core/src/ports/types.ts +135 -5
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
- package/packages/core/src/processes/build-child.ts +6 -6
- package/packages/core/src/processes/build-runner.ts +586 -87
- package/packages/core/src/processes/dispatch-failure-budget.ts +5 -4
- package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
- package/packages/core/src/processes/dispatcher.ts +2239 -357
- package/packages/core/src/processes/execution-no-progress.ts +46 -1
- package/packages/core/src/processes/harvest-execution-state.ts +15 -9
- package/packages/core/src/processes/harvest-runner.ts +34 -70
- package/packages/core/src/processes/harvest.ts +38 -15
- package/packages/core/src/processes/infrastructure-failure-budget.ts +13 -15
- package/packages/core/src/processes/orchestrator-tick.ts +2 -2
- package/packages/core/src/processes/publication-loss.ts +35 -21
- package/packages/core/src/processes/publication-state.ts +30 -5
- package/packages/core/src/processes/repo-view.ts +244 -1130
- package/packages/core/src/processes/tick-publication.ts +110 -0
- package/packages/core/src/store/adapter.ts +23 -0
- package/packages/core/src/store/build-scope.ts +35 -0
- package/packages/core/src/store/contract.ts +909 -0
- package/packages/core/src/store/digest.ts +52 -4
- package/packages/core/src/store/local/schema.ts +26 -13
- package/packages/core/src/store/local/store.ts +296 -55
- package/packages/core/src/store/memory.ts +181 -30
- package/packages/core/src/store/phase-session.ts +34 -0
- package/packages/core/src/store/reduced-reads.ts +240 -0
- package/packages/core/src/store/reducer-value-shapes.json +18323 -0
- package/packages/core/src/store/reducer-value-validation.ts +96 -0
- package/packages/core/src/store/reducer-values.ts +145 -0
- package/packages/core/src/store/remote/client.ts +85 -0
- package/packages/core/src/store/remote/compatibility.ts +21 -9
- package/packages/core/src/store/remote/index.ts +19 -0
- package/packages/core/src/store/remote/protocol.ts +27 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/repo-state-events.ts +3 -1
- package/packages/core/src/store/repo-tick.ts +72 -0
- package/packages/core/src/store/session-handle.ts +34 -0
- package/packages/core/src/store/snapshots.ts +10 -0
- package/packages/core/src/store/subscribe.ts +1 -1
- package/packages/core/src/store/ticket-assets.ts +4 -4
- package/packages/core/src/store/types.ts +71 -6
- package/packages/core/src/testing/dispatch-read-budget.ts +215 -0
- package/packages/core/src/testing/index.ts +10 -0
- package/packages/core/src/testing/reduced-read-budget.ts +502 -0
- package/packages/core/src/testing/refresh-scheduler.ts +32 -0
- package/skills/guide/SKILL.md +116 -62
- package/skills/guide/references/integration-tree.md +117 -0
- package/skills/guide/references/landing-policy.md +150 -0
- package/skills/guide/references/migration-1.0.md +68 -0
- package/skills/guide/references/operator-api.md +13 -6
- package/skills/guide/references/plugin-authoring.md +34 -0
- package/skills/guide/references/remote-store-protocol.md +114 -9
- package/skills/guide/references/remote-ticket-protocol.md +26 -5
- package/skills/guide/references/restacking.md +79 -0
- package/skills/guide/references/setup.md +49 -6
- package/skills/guide/references/ticket-dependencies.md +69 -0
- package/skills/guide/references/ticket-migration.md +8 -0
- package/skills/operate/SKILL.md +55 -5
- package/skills/reconcile/SKILL.md +55 -48
- package/skills/spec/SKILL.md +67 -1
- package/skills/tickets/SKILL.md +55 -2
- package/templates/autobuild.toml +3 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { validateEventWrite, type AbEvent } from '../../events/catalog'
|
|
2
|
+
import { KERNEL } from '../../events/envelope'
|
|
3
|
+
import type { EventPayload } from '../../events/payloads'
|
|
4
|
+
|
|
5
|
+
export const leafTransaction: EventPayload<'restack.prepared'> = {
|
|
6
|
+
id: 'leaf-1',
|
|
7
|
+
trigger: 'verify-entry',
|
|
8
|
+
cycle: 6,
|
|
9
|
+
observation: 7,
|
|
10
|
+
branch: 'ab/leaf',
|
|
11
|
+
oldHead: 'b'.repeat(40),
|
|
12
|
+
oldBase: 'a'.repeat(40),
|
|
13
|
+
targetBase: 'c'.repeat(40),
|
|
14
|
+
changeSha: 'd'.repeat(40),
|
|
15
|
+
workspaceHead: 'b'.repeat(40),
|
|
16
|
+
localBranchHead: 'b'.repeat(40),
|
|
17
|
+
message: 'Leaf change\n\nAutobuild-Build: leaf\n',
|
|
18
|
+
}
|
|
19
|
+
export function leafRestackLog(): AbEvent[] {
|
|
20
|
+
const writes = [
|
|
21
|
+
{
|
|
22
|
+
type: 'build.created',
|
|
23
|
+
actor: { kind: 'dispatcher' },
|
|
24
|
+
payload: { ticket: { source: 'file', id: 'leaf' }, repo: 'repo', baseBranch: 'main' },
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'spec.imported',
|
|
28
|
+
actor: { kind: 'dispatcher' },
|
|
29
|
+
payload: { artifact: { kind: 'spec', rev: 0 }, ticket: { source: 'file', id: 'leaf' } },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'plan.completed',
|
|
33
|
+
actor: { kind: 'agent', role: 'plan', session: 's1' },
|
|
34
|
+
payload: { round: 1, artifact: { kind: 'plan', rev: 0 } },
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'plan-review.verdict',
|
|
38
|
+
actor: { kind: 'agent', role: 'plan-review', session: 's2' },
|
|
39
|
+
payload: {
|
|
40
|
+
round: 1,
|
|
41
|
+
verdict: 'approve',
|
|
42
|
+
findings: [],
|
|
43
|
+
artifact: { kind: 'plan-review', rev: 0 },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'implement.completed',
|
|
48
|
+
actor: { kind: 'agent', role: 'implement', session: 's3' },
|
|
49
|
+
payload: {
|
|
50
|
+
round: 1,
|
|
51
|
+
commits: { base: leafTransaction.oldBase, head: leafTransaction.oldHead },
|
|
52
|
+
artifact: { kind: 'implement-notes', rev: 0 },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'code-review.verdict',
|
|
57
|
+
actor: { kind: 'agent', role: 'code-review', session: 's4' },
|
|
58
|
+
payload: {
|
|
59
|
+
round: 1,
|
|
60
|
+
verdict: 'approve',
|
|
61
|
+
findings: [],
|
|
62
|
+
artifact: { kind: 'code-review', rev: 0 },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: 'target.moved',
|
|
67
|
+
actor: KERNEL,
|
|
68
|
+
payload: { branch: 'main', sha: leafTransaction.targetBase },
|
|
69
|
+
},
|
|
70
|
+
{ type: 'restack.prepared', actor: KERNEL, payload: leafTransaction },
|
|
71
|
+
{
|
|
72
|
+
type: 'restack.replayed',
|
|
73
|
+
actor: KERNEL,
|
|
74
|
+
payload: { id: leafTransaction.id, conflicted: false },
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'restack.publish-intended',
|
|
78
|
+
actor: KERNEL,
|
|
79
|
+
payload: { ...leafTransaction, headSha: 'e'.repeat(40) },
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'restack.rewritten',
|
|
83
|
+
actor: KERNEL,
|
|
84
|
+
payload: {
|
|
85
|
+
...leafTransaction,
|
|
86
|
+
headSha: 'e'.repeat(40),
|
|
87
|
+
archives: [
|
|
88
|
+
{
|
|
89
|
+
ref: `refs/autobuild/archive/leaf/${leafTransaction.oldHead}`,
|
|
90
|
+
sha: leafTransaction.oldHead,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'restack.completed',
|
|
97
|
+
actor: KERNEL,
|
|
98
|
+
payload: { ...leafTransaction, headSha: 'e'.repeat(40) },
|
|
99
|
+
},
|
|
100
|
+
]
|
|
101
|
+
return writes.map(
|
|
102
|
+
(write, i) =>
|
|
103
|
+
({
|
|
104
|
+
...validateEventWrite(write),
|
|
105
|
+
build: 'leaf',
|
|
106
|
+
seq: i + 1,
|
|
107
|
+
ts: '2026-10-17T00:00:00.000Z',
|
|
108
|
+
}) as AbEvent,
|
|
109
|
+
)
|
|
110
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { validateEventWrite, type AbEvent, type EventWrite } from '../../events/catalog'
|
|
2
|
+
import { DISPATCHER, KERNEL } from '../../events/envelope'
|
|
3
|
+
|
|
4
|
+
/** A complete multi-item transaction, including a stable-identity drop and a
|
|
5
|
+
* foreign conflict, for every persisted reducer's prefix/shape coverage. */
|
|
6
|
+
export function nodeRestackLog(): AbEvent[] {
|
|
7
|
+
const parent = 'b'.repeat(40)
|
|
8
|
+
const expected = 'a'.repeat(40)
|
|
9
|
+
const head = 'c'.repeat(40)
|
|
10
|
+
const writes: EventWrite[] = [
|
|
11
|
+
{
|
|
12
|
+
actor: DISPATCHER,
|
|
13
|
+
type: 'build.created',
|
|
14
|
+
payload: {
|
|
15
|
+
repo: 'repo',
|
|
16
|
+
ticket: { source: 'file', id: 'node' },
|
|
17
|
+
baseBranch: 'main',
|
|
18
|
+
kind: 'node',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{ actor: DISPATCHER, type: 'node.opened', payload: { sha: 'd'.repeat(40) } },
|
|
22
|
+
{
|
|
23
|
+
actor: KERNEL,
|
|
24
|
+
type: 'node.writer-reserved',
|
|
25
|
+
payload: {
|
|
26
|
+
id: 'node-tx',
|
|
27
|
+
operation: 'restack',
|
|
28
|
+
expected,
|
|
29
|
+
parent,
|
|
30
|
+
oldBase: 'd'.repeat(40),
|
|
31
|
+
archive: `refs/autobuild/archive/node/${expected}`,
|
|
32
|
+
changes: [
|
|
33
|
+
{ sha: 'e'.repeat(40), build: 'source' },
|
|
34
|
+
{ sha: 'f'.repeat(40), mainline: 1 },
|
|
35
|
+
],
|
|
36
|
+
upstreamBuilds: ['source'],
|
|
37
|
+
merges: [{ sha: 'f'.repeat(40), parent, identities: ['source'], missing: [] }],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
actor: KERNEL,
|
|
42
|
+
type: 'node.item-prepared',
|
|
43
|
+
payload: { id: 'node-tx', index: 0, base: parent },
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
actor: KERNEL,
|
|
47
|
+
type: 'node.item-replayed',
|
|
48
|
+
payload: {
|
|
49
|
+
id: 'node-tx',
|
|
50
|
+
index: 0,
|
|
51
|
+
base: parent,
|
|
52
|
+
head: parent,
|
|
53
|
+
dropped: true,
|
|
54
|
+
dropReason: 'upstream-identity',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
actor: KERNEL,
|
|
59
|
+
type: 'node.item-prepared',
|
|
60
|
+
payload: { id: 'node-tx', index: 1, base: parent },
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
actor: KERNEL,
|
|
64
|
+
type: 'node.item-conflicted',
|
|
65
|
+
payload: { id: 'node-tx', index: 1, base: parent },
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
actor: KERNEL,
|
|
69
|
+
type: 'node.item-replayed',
|
|
70
|
+
payload: { id: 'node-tx', index: 1, base: parent, head, dropped: false },
|
|
71
|
+
},
|
|
72
|
+
{ actor: KERNEL, type: 'node.publish-intended', payload: { id: 'node-tx', head } },
|
|
73
|
+
{ actor: KERNEL, type: 'node.rewritten', payload: { id: 'node-tx', previous: expected, head } },
|
|
74
|
+
{
|
|
75
|
+
actor: KERNEL,
|
|
76
|
+
type: 'node.inventory',
|
|
77
|
+
payload: { head, builds: ['source'], foreign: [head] },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
actor: KERNEL,
|
|
81
|
+
type: 'node.writer-settled',
|
|
82
|
+
payload: { id: 'node-tx', outcome: 'completed' },
|
|
83
|
+
},
|
|
84
|
+
]
|
|
85
|
+
return writes.map(
|
|
86
|
+
(write, index) =>
|
|
87
|
+
({
|
|
88
|
+
...validateEventWrite(write),
|
|
89
|
+
build: 'node',
|
|
90
|
+
seq: index + 1,
|
|
91
|
+
ts: '2026-10-17T00:00:00Z',
|
|
92
|
+
}) as AbEvent,
|
|
93
|
+
)
|
|
94
|
+
}
|
|
@@ -119,13 +119,24 @@ export function randomSettingsJournal(seed: number, length: number): RepositoryE
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
const counters = {
|
|
122
|
-
claimed: 0,
|
|
123
|
-
launched: 0,
|
|
124
122
|
merged: 0,
|
|
125
123
|
closed: 0,
|
|
126
124
|
conflicted: 0,
|
|
127
|
-
|
|
125
|
+
abandoned: 0,
|
|
126
|
+
discarded: 0,
|
|
127
|
+
janitorFailed: 0,
|
|
128
|
+
recovered: 0,
|
|
129
|
+
dispatchFailed: 0,
|
|
130
|
+
resumed: 0,
|
|
131
|
+
swept: 0,
|
|
132
|
+
dispatched: 0,
|
|
133
|
+
authored: 0,
|
|
134
|
+
bounced: 0,
|
|
135
|
+
claimRaces: 0,
|
|
136
|
+
invalidTickets: 0,
|
|
137
|
+
dependencyBlocked: 0,
|
|
128
138
|
harvestStarted: 0,
|
|
139
|
+
harvestResumed: 0,
|
|
129
140
|
harvestCompleted: 0,
|
|
130
141
|
harvestEscalated: 0,
|
|
131
142
|
harvestFailed: 0,
|
|
@@ -159,6 +170,17 @@ export function randomStatusJournal(seed: number, length: number): RepositoryEve
|
|
|
159
170
|
}),
|
|
160
171
|
() => ({ type: 'dispatcher.tick-failed', payload: { run, error: 'e' } }),
|
|
161
172
|
() => ({ type: 'dispatcher.tick-started', payload: { run } }),
|
|
173
|
+
() => ({
|
|
174
|
+
type: 'dispatcher.forge-readiness-failed',
|
|
175
|
+
payload: {
|
|
176
|
+
run,
|
|
177
|
+
forge: 'github',
|
|
178
|
+
rootBranch: 'main',
|
|
179
|
+
check: 'squash',
|
|
180
|
+
detail: 'Squash merging disabled',
|
|
181
|
+
remediation: 'Enable squash merging',
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
162
184
|
() => ({ type: 'dispatcher.config-rejected', payload: { run, error: 'bad' } }),
|
|
163
185
|
() => ({
|
|
164
186
|
type: 'dispatcher.operator-reported',
|
|
@@ -741,32 +741,34 @@ export function harvestCreationsDuringReadyScan(
|
|
|
741
741
|
beforeEvents: readonly RepositoryEvent[],
|
|
742
742
|
afterEvents: readonly RepositoryEvent[],
|
|
743
743
|
): InFlightHarvestCreation[] {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
744
|
+
return harvestCreationsFromStates(reduceHarvest(beforeEvents), reduceHarvest(afterEvents))
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export function harvestCreationsFromStates(
|
|
748
|
+
before: HarvestState,
|
|
749
|
+
after: HarvestState,
|
|
750
|
+
): InFlightHarvestCreation[] {
|
|
747
751
|
const creations = new Map<string, InFlightHarvestCreation>()
|
|
748
|
-
const keyOf = (run: string, proposalKey: string)
|
|
749
|
-
const known = new Set
|
|
750
|
-
|
|
752
|
+
const keyOf = (run: string, proposalKey: string) => `${run}\0${proposalKey}`
|
|
753
|
+
const known = new Set(
|
|
754
|
+
before.runs.flatMap((run) =>
|
|
755
|
+
run.reservations.map((entry) => keyOf(run.run, entry.proposalKey)),
|
|
756
|
+
),
|
|
757
|
+
)
|
|
758
|
+
for (const creation of inFlightHarvestCreations(before))
|
|
759
|
+
creations.set(keyOf(creation.run, creation.proposalKey), creation)
|
|
760
|
+
for (const run of after.runs)
|
|
751
761
|
for (const reservation of run.reservations) {
|
|
752
|
-
|
|
762
|
+
const key = keyOf(run.run, reservation.proposalKey)
|
|
763
|
+
if (known.has(key) || reservation.seq <= before.lastSeq) continue
|
|
764
|
+
known.add(key)
|
|
765
|
+
creations.set(key, {
|
|
766
|
+
run: run.run,
|
|
767
|
+
proposalKey: reservation.proposalKey,
|
|
768
|
+
creationKey: reservation.id,
|
|
769
|
+
reservationSeq: reservation.seq,
|
|
770
|
+
})
|
|
753
771
|
}
|
|
754
|
-
}
|
|
755
|
-
for (const creation of inFlightHarvestCreations(before)) {
|
|
756
|
-
creations.set(keyOf(creation.run, creation.proposalKey), creation)
|
|
757
|
-
}
|
|
758
|
-
for (const event of afterEvents) {
|
|
759
|
-
if (event.seq <= before.lastSeq || event.type !== 'harvest.proposal.id-reserved') continue
|
|
760
|
-
const key = keyOf(event.payload.run, event.payload.proposalKey)
|
|
761
|
-
if (known.has(key)) continue
|
|
762
|
-
known.add(key)
|
|
763
|
-
creations.set(key, {
|
|
764
|
-
run: event.payload.run,
|
|
765
|
-
proposalKey: event.payload.proposalKey,
|
|
766
|
-
creationKey: event.payload.id,
|
|
767
|
-
reservationSeq: event.seq,
|
|
768
|
-
})
|
|
769
|
-
}
|
|
770
772
|
return [...creations.values()]
|
|
771
773
|
}
|
|
772
774
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { BuildState } from './reducer'
|
|
2
|
+
import type { TicketSource, TicketListing } from '../ports/types'
|
|
3
|
+
import type { BuildStore, BuildRecord } from '../store/types'
|
|
4
|
+
import { readBuildFacts } from '../store/reduced-reads'
|
|
5
|
+
import { DISPATCHER } from '../events/envelope'
|
|
6
|
+
import type { EventPayload } from '../events/payloads'
|
|
7
|
+
|
|
8
|
+
/** One exhaustive source sample shared by every node in a dispatcher pass.
|
|
9
|
+
* Scheduling may be cached; publication always requests a sample from this pass. */
|
|
10
|
+
export interface IntegrationObservationInputs {
|
|
11
|
+
listing: TicketListing
|
|
12
|
+
builds: { record: BuildRecord; state: BuildState }[]
|
|
13
|
+
}
|
|
14
|
+
export async function integrationObservationInputs(
|
|
15
|
+
store: BuildStore,
|
|
16
|
+
tickets: TicketSource,
|
|
17
|
+
repo: string,
|
|
18
|
+
): Promise<IntegrationObservationInputs> {
|
|
19
|
+
if (!tickets.integrationTree || !tickets.listAll)
|
|
20
|
+
throw new Error('ticket source cannot establish exhaustive integration completeness')
|
|
21
|
+
const listing = await tickets.listAll()
|
|
22
|
+
const builds = []
|
|
23
|
+
for (const record of await store.listBuildsForRepo(repo))
|
|
24
|
+
builds.push({ record, state: (await readBuildFacts(store, record.slug)).value.state })
|
|
25
|
+
return { listing, builds }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A failed or partial enumeration cannot authorize verification or publication. */
|
|
29
|
+
export async function observeIntegration(
|
|
30
|
+
store: BuildStore,
|
|
31
|
+
tickets: TicketSource,
|
|
32
|
+
slug: string,
|
|
33
|
+
inputs?: () => Promise<IntegrationObservationInputs>,
|
|
34
|
+
): Promise<EventPayload<'integration.observed'>> {
|
|
35
|
+
const record = await store.getBuild(slug)
|
|
36
|
+
const state = (await readBuildFacts(store, slug)).value.state
|
|
37
|
+
const observation: EventPayload<'integration.observed'> = {
|
|
38
|
+
openChildren: [],
|
|
39
|
+
diagnostics: [],
|
|
40
|
+
contributions: [...(state.integration?.observation?.contributions ?? [])],
|
|
41
|
+
}
|
|
42
|
+
const children = new Set<string>()
|
|
43
|
+
try {
|
|
44
|
+
if (!record?.ticket || !tickets.integrationTree || !tickets.listAll)
|
|
45
|
+
throw new Error('ticket source cannot establish exhaustive integration completeness')
|
|
46
|
+
if (record.ticket.source !== tickets.name)
|
|
47
|
+
throw new Error('configured ticket source differs from the frozen node source')
|
|
48
|
+
const { listing, builds } = await (inputs
|
|
49
|
+
? inputs()
|
|
50
|
+
: integrationObservationInputs(store, tickets, record.repo))
|
|
51
|
+
observation.diagnostics.push(...listing.diagnostics)
|
|
52
|
+
for (const ticket of listing.tickets)
|
|
53
|
+
if (ticket.target === record.ticket.id && !ticket.resolved) children.add(ticket.ref.id)
|
|
54
|
+
// Frozen claims survive edits to the source ticket's target.
|
|
55
|
+
for (const { record: build, state: child } of builds) {
|
|
56
|
+
if (child.target?.build === slug && child.status !== 'done' && child.status !== 'aborted')
|
|
57
|
+
children.add(build.ticket?.id ?? build.slug)
|
|
58
|
+
if (
|
|
59
|
+
[child.nodeRestack?.parentRequest, child.nodeRestack?.parentChange].some(
|
|
60
|
+
(move) => move && (move.old.target?.build === slug || move.next.target?.build === slug),
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
children.add(build.ticket?.id ?? build.slug)
|
|
64
|
+
if (child.target?.build === slug && child.prState === 'merged')
|
|
65
|
+
observation.contributions.push(build.slug)
|
|
66
|
+
}
|
|
67
|
+
observation.contributions.push(...(state.nodeRestack?.inventory?.contributions ?? []))
|
|
68
|
+
} catch (error) {
|
|
69
|
+
observation.diagnostics.push(error instanceof Error ? error.message : String(error))
|
|
70
|
+
}
|
|
71
|
+
observation.openChildren = [...children].sort()
|
|
72
|
+
observation.diagnostics.sort()
|
|
73
|
+
observation.contributions = [...new Set(observation.contributions)].sort()
|
|
74
|
+
if (JSON.stringify(observation) !== JSON.stringify(state.integration?.observation))
|
|
75
|
+
await store.append(slug, {
|
|
76
|
+
actor: DISPATCHER,
|
|
77
|
+
type: 'integration.observed',
|
|
78
|
+
payload: observation,
|
|
79
|
+
})
|
|
80
|
+
return observation
|
|
81
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { snapshotParent } from './snapshot-parent'
|
|
2
|
+
import { buildTrailers } from './build-identity'
|
|
3
|
+
import { KERNEL, DISPATCHER } from '../events/envelope'
|
|
4
|
+
import type { Forge } from '../ports/types'
|
|
5
|
+
import type { Exec } from '../ports/workspace/git-worktree'
|
|
6
|
+
import type { BuildStore } from '../store/types'
|
|
7
|
+
import { readBuildFacts } from '../store/reduced-reads'
|
|
8
|
+
import { inspectIntegrationStack } from './integration-stack'
|
|
9
|
+
import { acknowledgeNodeLanding } from './node-landing'
|
|
10
|
+
|
|
11
|
+
export interface IntegrationLandingDeps {
|
|
12
|
+
store: BuildStore
|
|
13
|
+
forge: Forge
|
|
14
|
+
exec: Exec
|
|
15
|
+
workspacePath: string
|
|
16
|
+
slug: string
|
|
17
|
+
branch: string
|
|
18
|
+
destination: string
|
|
19
|
+
pr: number
|
|
20
|
+
holder: string
|
|
21
|
+
id: string
|
|
22
|
+
commandSeq?: number
|
|
23
|
+
decisionSeq?: number
|
|
24
|
+
head: string
|
|
25
|
+
parent: string
|
|
26
|
+
cycle: string
|
|
27
|
+
eligible: () => Promise<boolean>
|
|
28
|
+
}
|
|
29
|
+
/** The source-owned reservation protects root publication across lease loss. */
|
|
30
|
+
export async function landIntegrationRoot(deps: IntegrationLandingDeps): Promise<void> {
|
|
31
|
+
const { store, forge, slug, workspacePath, exec } = deps
|
|
32
|
+
if (!forge.rewrite || !forge.inspectLandingPr) return
|
|
33
|
+
if (!(await store.claimNodeWriter(slug, deps.holder, 60_000))) return
|
|
34
|
+
const authority = async () => {
|
|
35
|
+
if (!(await store.renewNodeWriter(slug, deps.holder)))
|
|
36
|
+
throw new Error('integration writer lease lost')
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
let state = (await readBuildFacts(store, slug)).value.state
|
|
40
|
+
if (
|
|
41
|
+
state.integration?.landing ||
|
|
42
|
+
state.nodeRestack?.parentRequest ||
|
|
43
|
+
state.nodeRestack?.parentChange
|
|
44
|
+
)
|
|
45
|
+
return
|
|
46
|
+
const existing = state.integration?.intent
|
|
47
|
+
let landed: string | undefined
|
|
48
|
+
if (existing) {
|
|
49
|
+
// Readback precedes controls: a completed write must survive revocation.
|
|
50
|
+
const pr = await forge.getPrState(workspacePath, deps.pr)
|
|
51
|
+
if (pr.state === 'merged' && pr.headSha === existing.head) landed = pr.sha
|
|
52
|
+
if (forge.name === 'local-git') {
|
|
53
|
+
const actual = await snapshotParent(
|
|
54
|
+
deps,
|
|
55
|
+
deps.destination,
|
|
56
|
+
`refs/autobuild/reconcile/${slug}/readback`,
|
|
57
|
+
)
|
|
58
|
+
const contains = await exec(['git', 'merge-base', '--is-ancestor', existing.head, actual], {
|
|
59
|
+
cwd: workspacePath,
|
|
60
|
+
})
|
|
61
|
+
if (contains.exitCode === 0) landed = existing.head
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const abandon = async (reason: string) => {
|
|
65
|
+
const pending = (await readBuildFacts(store, slug)).value.state.integration?.intent
|
|
66
|
+
if (pending)
|
|
67
|
+
await store.append(slug, {
|
|
68
|
+
actor: KERNEL,
|
|
69
|
+
type: 'integration.abandoned',
|
|
70
|
+
payload: { id: pending.id, reason },
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
if (!landed) {
|
|
74
|
+
if (!(await deps.eligible())) {
|
|
75
|
+
await abandon('Eligibility changed before publication')
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
const cancelled = await forge.setAutoMerge(workspacePath, deps.pr, false)
|
|
79
|
+
if (cancelled.kind !== 'applied') return
|
|
80
|
+
const pr = await forge.inspectLandingPr(workspacePath, deps.pr)
|
|
81
|
+
if (
|
|
82
|
+
!pr.open ||
|
|
83
|
+
pr.base !== deps.destination ||
|
|
84
|
+
pr.head !== deps.branch ||
|
|
85
|
+
pr.headSha !== deps.head
|
|
86
|
+
)
|
|
87
|
+
return
|
|
88
|
+
const parent = await snapshotParent(
|
|
89
|
+
deps,
|
|
90
|
+
deps.destination,
|
|
91
|
+
`refs/autobuild/reconcile/${slug}/parent`,
|
|
92
|
+
)
|
|
93
|
+
const head = await forge.rewrite.snapshot({
|
|
94
|
+
workspacePath,
|
|
95
|
+
branch: deps.branch,
|
|
96
|
+
destinationRef: `refs/autobuild/reconcile/${slug}/head`,
|
|
97
|
+
})
|
|
98
|
+
if (parent !== deps.parent || head !== deps.head) {
|
|
99
|
+
await abandon('Parent or head moved')
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
await inspectIntegrationStack(exec, workspacePath, parent, head)
|
|
103
|
+
const local = forge.name === 'local-git'
|
|
104
|
+
if (!local && !forge.mergeLinearStack) return // Never substitute squash.
|
|
105
|
+
const gate = local ? await forge.inspectLandingGate?.(deps.destination) : undefined
|
|
106
|
+
if (local && (!forge.rewrite.fastForward || gate?.kind !== 'proved-ungated')) return
|
|
107
|
+
const freshness = local
|
|
108
|
+
? { fenced: true, evidence: ['Exact parent compare-and-swap fast-forward'] }
|
|
109
|
+
: ((await forge.inspectMergeFreshness?.(deps.destination)) ?? {
|
|
110
|
+
fenced: false,
|
|
111
|
+
evidence: ['Freshness enforcement unavailable'],
|
|
112
|
+
})
|
|
113
|
+
await authority()
|
|
114
|
+
await forge.rewrite.archive({
|
|
115
|
+
workspacePath,
|
|
116
|
+
ref: `refs/autobuild/archive/${slug}/${head}`,
|
|
117
|
+
sha: head,
|
|
118
|
+
})
|
|
119
|
+
if (!existing) {
|
|
120
|
+
await store.append(slug, {
|
|
121
|
+
actor: KERNEL,
|
|
122
|
+
type: 'integration.landing-intended',
|
|
123
|
+
payload: {
|
|
124
|
+
id: deps.id,
|
|
125
|
+
cycle: deps.cycle,
|
|
126
|
+
head,
|
|
127
|
+
parent,
|
|
128
|
+
...(deps.commandSeq === undefined ? {} : { commandSeq: deps.commandSeq }),
|
|
129
|
+
...(deps.decisionSeq === undefined ? {} : { decisionSeq: deps.decisionSeq }),
|
|
130
|
+
...freshness,
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
} else if (
|
|
134
|
+
existing.head !== head ||
|
|
135
|
+
existing.parent !== parent ||
|
|
136
|
+
existing.commandSeq !== deps.commandSeq
|
|
137
|
+
)
|
|
138
|
+
return
|
|
139
|
+
if (!(await deps.eligible())) {
|
|
140
|
+
await abandon('Eligibility changed before publication')
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
await authority()
|
|
144
|
+
// This is the final external read before the merge request. GitHub's
|
|
145
|
+
// endpoint fences the head only; its remaining race is audited below.
|
|
146
|
+
const current = await snapshotParent(
|
|
147
|
+
deps,
|
|
148
|
+
deps.destination,
|
|
149
|
+
`refs/autobuild/reconcile/${slug}/fresh`,
|
|
150
|
+
)
|
|
151
|
+
if (current !== parent) {
|
|
152
|
+
const pending = (await readBuildFacts(store, slug)).value.state.integration?.intent
|
|
153
|
+
if (pending)
|
|
154
|
+
await store.append(slug, {
|
|
155
|
+
actor: KERNEL,
|
|
156
|
+
type: 'integration.abandoned',
|
|
157
|
+
payload: { id: pending.id, reason: 'Parent moved before publication' },
|
|
158
|
+
})
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
if (local) {
|
|
162
|
+
const result = await forge.rewrite.fastForward!({
|
|
163
|
+
workspacePath,
|
|
164
|
+
branch: deps.destination,
|
|
165
|
+
expected: parent,
|
|
166
|
+
sha: head,
|
|
167
|
+
})
|
|
168
|
+
if (result.kind !== 'published') return
|
|
169
|
+
landed = head
|
|
170
|
+
} else {
|
|
171
|
+
landed = await forge.mergeLinearStack!(workspacePath, deps.pr, head)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
await authority()
|
|
175
|
+
state = (await readBuildFacts(store, slug)).value.state
|
|
176
|
+
const intent = state.integration!.intent!
|
|
177
|
+
await store.append(slug, {
|
|
178
|
+
actor: DISPATCHER,
|
|
179
|
+
type: 'integration.landed',
|
|
180
|
+
payload: {
|
|
181
|
+
operation: intent.id,
|
|
182
|
+
head: intent.head,
|
|
183
|
+
landed,
|
|
184
|
+
provenance: 'kernel',
|
|
185
|
+
verified: true,
|
|
186
|
+
fenced: intent.fenced,
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
await store.append(slug, {
|
|
190
|
+
actor: DISPATCHER,
|
|
191
|
+
type: 'pr.merged',
|
|
192
|
+
payload: { sha: landed, buildTrailerPresent: true },
|
|
193
|
+
})
|
|
194
|
+
await acknowledgeNodeLanding(forge, workspacePath, deps.pr, landed)
|
|
195
|
+
} finally {
|
|
196
|
+
await store.releaseNodeWriter(slug, deps.holder)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Audit immutable merge-result commits, including after build completion. */
|
|
201
|
+
export async function auditIntegrationLanding(
|
|
202
|
+
deps: Pick<IntegrationLandingDeps, 'store' | 'forge' | 'exec' | 'workspacePath' | 'slug' | 'id'>,
|
|
203
|
+
): Promise<void> {
|
|
204
|
+
const state = (await readBuildFacts(deps.store, deps.slug)).value.state
|
|
205
|
+
const landing = state.integration?.landing
|
|
206
|
+
if (!landing?.operation || state.integration?.audit || !deps.forge.rewrite) return
|
|
207
|
+
const trees: string[] = []
|
|
208
|
+
for (const sha of [landing.head, landing.landed]) {
|
|
209
|
+
const present = await deps.exec(['git', 'cat-file', '-e', `${sha}^{commit}`], {
|
|
210
|
+
cwd: deps.workspacePath,
|
|
211
|
+
})
|
|
212
|
+
if (present.exitCode !== 0) {
|
|
213
|
+
const fetched = await deps.exec(['git', 'fetch', '--no-tags', 'origin', sha], {
|
|
214
|
+
cwd: deps.workspacePath,
|
|
215
|
+
})
|
|
216
|
+
if (fetched.exitCode !== 0) throw new Error('integration audit commit unavailable')
|
|
217
|
+
}
|
|
218
|
+
const tree = await deps.exec(['git', 'rev-parse', `${sha}^{tree}`], { cwd: deps.workspacePath })
|
|
219
|
+
if (tree.exitCode !== 0) throw new Error('integration landing tree audit pending')
|
|
220
|
+
trees.push(tree.stdout.trim())
|
|
221
|
+
}
|
|
222
|
+
const intent = state.integration?.intent
|
|
223
|
+
const identities = intent
|
|
224
|
+
? await inspectIntegrationStack(deps.exec, deps.workspacePath, intent.parent, landing.head)
|
|
225
|
+
: []
|
|
226
|
+
const messages = intent
|
|
227
|
+
? await deps.exec(
|
|
228
|
+
['git', 'log', '--format=%B%x00', `${intent.parent}..${landing.landed}`, '--'],
|
|
229
|
+
{ cwd: deps.workspacePath },
|
|
230
|
+
)
|
|
231
|
+
: undefined
|
|
232
|
+
if (messages && messages.exitCode !== 0) throw new Error('landing identity audit pending')
|
|
233
|
+
const landedIdentities = messages
|
|
234
|
+
? messages.stdout.split('\0').flatMap((message) => buildTrailers(message))
|
|
235
|
+
: []
|
|
236
|
+
const missing = identities.filter(
|
|
237
|
+
(identity) => landedIdentities.filter((value) => value === identity).length !== 1,
|
|
238
|
+
)
|
|
239
|
+
if (trees[0] !== trees[1] || missing.length) {
|
|
240
|
+
const id = `integration-audit-${landing.operation}`
|
|
241
|
+
if (![...state.openEscalations, ...state.answeredEscalations].some((item) => item.id === id))
|
|
242
|
+
await deps.store.append(deps.slug, {
|
|
243
|
+
actor: KERNEL,
|
|
244
|
+
type: 'escalation.raised',
|
|
245
|
+
payload: {
|
|
246
|
+
id,
|
|
247
|
+
phase: 'verify:integration',
|
|
248
|
+
source: 'agent',
|
|
249
|
+
question: `Integration result requires attention: verified ${landing.head} (${trees[0]}), landed ${landing.landed} (${trees[1]}). Missing or duplicate identities: ${missing.join(', ') || 'none'}. The shared parent has not been rewritten.`,
|
|
250
|
+
},
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
await deps.store.append(deps.slug, {
|
|
254
|
+
actor: KERNEL,
|
|
255
|
+
type: 'integration.audited',
|
|
256
|
+
payload: {
|
|
257
|
+
operation: landing.operation,
|
|
258
|
+
verifiedTree: trees[0]!,
|
|
259
|
+
landedTree: trees[1]!,
|
|
260
|
+
identities,
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Exec } from '../ports/workspace/git-worktree'
|
|
2
|
+
import { buildTrailers } from './build-identity'
|
|
3
|
+
|
|
4
|
+
/** A node has no wrapper identity: every commit retains its contributing build. */
|
|
5
|
+
export async function inspectIntegrationStack(
|
|
6
|
+
exec: Exec,
|
|
7
|
+
cwd: string,
|
|
8
|
+
parent: string,
|
|
9
|
+
head: string,
|
|
10
|
+
): Promise<string[]> {
|
|
11
|
+
const ancestry = await exec(['git', 'merge-base', '--is-ancestor', parent, head], { cwd })
|
|
12
|
+
if (ancestry.exitCode !== 0)
|
|
13
|
+
throw new Error('integration stack is not a fast-forward of its verified parent')
|
|
14
|
+
const range = await exec(
|
|
15
|
+
['git', 'log', '--reverse', '--format=%H%x00%P%x00%B%x00', `${parent}..${head}`, '--'],
|
|
16
|
+
{ cwd },
|
|
17
|
+
)
|
|
18
|
+
if (range.exitCode !== 0) throw new Error('cannot inspect integration stack')
|
|
19
|
+
const fields = range.stdout.split('\0')
|
|
20
|
+
const builds: string[] = []
|
|
21
|
+
let previous = parent
|
|
22
|
+
for (let index = 0; index + 2 < fields.length; index += 3) {
|
|
23
|
+
const sha = fields[index]!.trim()
|
|
24
|
+
const parents = fields[index + 1]!.trim()
|
|
25
|
+
const identities = buildTrailers(fields[index + 2]!)
|
|
26
|
+
if (parents !== previous || identities.length !== 1 || builds.includes(identities[0]!))
|
|
27
|
+
throw new Error(
|
|
28
|
+
'integration stack requires a linear range with one unique build identity per commit',
|
|
29
|
+
)
|
|
30
|
+
builds.push(identities[0]!)
|
|
31
|
+
previous = sha
|
|
32
|
+
}
|
|
33
|
+
if (!builds.length || previous !== head)
|
|
34
|
+
throw new Error('integration stack has no complete owned range')
|
|
35
|
+
return builds
|
|
36
|
+
}
|