@defrex/autobuild 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -18
- package/SPEC.md +499 -238
- package/bin/ab-dispatch-generation.ts +11 -2
- package/docs/accounts.md +119 -0
- package/docs/agent-runtimes.md +4 -4
- package/docs/answering-blocked-builds.md +2 -2
- package/docs/architecture.md +262 -53
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +3 -41
- package/docs/builds.md +4 -4
- package/docs/cli.md +18 -4
- package/docs/configuration-overview.md +115 -4
- package/docs/configuration.md +488 -334
- package/docs/dispatcher-hosting.md +19 -34
- package/docs/dispatcher.md +1 -1
- package/docs/forges.md +5 -5
- package/docs/getting-started.md +2 -2
- package/docs/glossary.md +6 -6
- package/docs/intake.md +2 -0
- package/docs/integration-overview.md +15 -15
- package/docs/integration-tree.md +45 -38
- package/docs/integration.md +6 -6
- package/{skills/guide/references/landing-policy.md → docs/merge-policy.md} +40 -24
- package/docs/migration-1.0.md +17 -13
- package/docs/operating.md +41 -19
- package/docs/operator-api.md +180 -51
- package/docs/operator-surfaces.md +5 -18
- package/docs/overview.md +3 -3
- package/docs/plugin-authoring.md +21 -0
- package/docs/remote-store-protocol.md +242 -68
- package/docs/remote-ticket-protocol.md +30 -50
- package/docs/restacking.md +54 -15
- package/docs/seams.md +8 -8
- package/docs/setup.md +59 -119
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +6 -6
- package/docs/ticket-dependencies.md +7 -7
- package/docs/ticket-sources.md +18 -0
- package/docs/tickets.md +8 -2
- package/docs/troubleshooting.md +8 -12
- package/docs/upgrading.md +9 -4
- package/docs/verification.md +60 -14
- package/docs/workspaces.md +4 -4
- package/package.json +17 -6
- package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
- package/packages/core/src/accounts/chatgpt-state.ts +41 -0
- package/packages/core/src/accounts/local-credentials.ts +194 -0
- package/packages/core/src/accounts/local-inference.ts +106 -0
- package/packages/core/src/accounts/local-owner.ts +123 -0
- package/packages/core/src/accounts/sensitive.ts +2 -0
- package/packages/core/src/cli/accounts.ts +147 -0
- package/packages/core/src/cli/binary-direct.ts +13 -1
- package/packages/core/src/cli/binary-lifecycle.ts +65 -2
- package/packages/core/src/cli/binary.ts +3 -1
- package/packages/core/src/cli/build-control.ts +83 -28
- package/packages/core/src/cli/connect.ts +3 -3
- package/packages/core/src/cli/context.ts +81 -38
- package/packages/core/src/cli/dashboard/facts.ts +2 -1
- package/packages/core/src/cli/dashboard/integration-detail.ts +8 -8
- package/packages/core/src/cli/dashboard/integration-row.ts +40 -13
- package/packages/core/src/cli/dashboard/landing-display.ts +25 -0
- package/packages/core/src/cli/dashboard/model.ts +56 -33
- package/packages/core/src/cli/dashboard/poll.ts +9 -3
- package/packages/core/src/cli/dashboard/render.ts +59 -37
- package/packages/core/src/cli/dashboard/target-distance.ts +14 -0
- package/packages/core/src/cli/dashboard/tree.ts +3 -2
- package/packages/core/src/cli/dispatch-args.ts +1 -1
- package/packages/core/src/cli/dispatch-frontend.ts +6 -3
- package/packages/core/src/cli/dispatch-handoff.ts +125 -44
- package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
- package/packages/core/src/cli/dispatch-launcher.ts +54 -21
- package/packages/core/src/cli/dispatch-preflight.ts +6 -1
- package/packages/core/src/cli/dispatch.ts +106 -11
- package/packages/core/src/cli/env.ts +4 -0
- package/packages/core/src/cli/help.ts +46 -23
- package/packages/core/src/cli/init-readiness-remote.ts +22 -1
- package/packages/core/src/cli/init-readiness-shared.ts +5 -1
- package/packages/core/src/cli/init-validation.ts +160 -18
- package/packages/core/src/cli/main.ts +68 -8
- package/packages/core/src/cli/node-verification-provenance.ts +1 -97
- package/packages/core/src/cli/publication-settlement.ts +47 -21
- package/packages/core/src/cli/repository-status.ts +20 -9
- package/packages/core/src/cli/secrets.ts +173 -0
- package/packages/core/src/cli/status.ts +42 -5
- package/packages/core/src/cli/store-opening.ts +17 -2
- package/packages/core/src/cli/terminal.ts +22 -1
- package/packages/core/src/cli/terminals.ts +14 -10
- package/packages/core/src/cli/upgrade-agent.ts +9 -1
- package/packages/core/src/cli/upgrade-landing.ts +70 -30
- package/packages/core/src/cli/upgrade.ts +3 -1
- package/packages/core/src/cli/wait.ts +15 -7
- package/packages/core/src/cli/watch-lifetime.ts +111 -0
- package/packages/core/src/cli/watch.ts +635 -510
- package/packages/core/src/config/accounts.ts +101 -0
- package/packages/core/src/config/effective-artifact.fixture.ts +27 -0
- package/packages/core/src/config/effective-artifact.ts +13 -0
- package/packages/core/src/config/landing.ts +1 -1
- package/packages/core/src/config/live.ts +14 -1
- package/packages/core/src/config/load.ts +21 -1
- package/packages/core/src/config/pipeline-source.ts +28 -0
- package/packages/core/src/config/reference-metadata.ts +2 -0
- package/packages/core/src/config/reference.ts +22 -7
- package/packages/core/src/config/roles.ts +54 -3
- package/packages/core/src/config/schema.ts +146 -162
- package/packages/core/src/context-directory.ts +26 -0
- package/packages/core/src/distribution-packaging.ts +26 -5
- package/packages/core/src/events/catalog.ts +10 -2
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/globs.ts +1 -1
- package/packages/core/src/events/payloads.ts +73 -1
- package/packages/core/src/events/policy.ts +7 -0
- package/packages/core/src/events/repository.ts +4 -4
- package/packages/core/src/events/sessions.ts +6 -6
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +574 -0
- package/packages/core/src/kernel/auto-merge.ts +2 -2
- package/packages/core/src/kernel/engine.ts +255 -26
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +10 -0
- package/packages/core/src/kernel/integration-landing.ts +3 -3
- package/packages/core/src/kernel/integration-state.ts +27 -4
- package/packages/core/src/kernel/leaf-restack-state.ts +28 -3
- package/packages/core/src/kernel/log-index.ts +13 -1
- package/packages/core/src/kernel/node-landing.ts +8 -8
- package/packages/core/src/kernel/node-parent.ts +2 -2
- package/packages/core/src/kernel/node-restack-transaction.ts +1 -1
- package/packages/core/src/kernel/node-verification-context.ts +216 -0
- package/packages/core/src/kernel/phases.ts +1 -1
- package/packages/core/src/kernel/plan-verify-selection.ts +16 -0
- package/packages/core/src/kernel/publication-retry.ts +168 -0
- package/packages/core/src/kernel/reconcile-restack.ts +29 -1
- package/packages/core/src/kernel/reducer.ts +85 -5
- package/packages/core/src/kernel/target-distance.ts +45 -0
- package/packages/core/src/kernel/terminal-guard.ts +10 -1
- package/packages/core/src/kernel/verify-stage-state.ts +123 -0
- package/packages/core/src/kernel/verify-stages.ts +39 -0
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +1 -1
- package/packages/core/src/operator/index.ts +3 -7
- package/packages/core/src/operator/landings.ts +5 -1
- package/packages/core/src/operator/presentation.ts +6 -1
- package/packages/core/src/operator/protocol.ts +6 -0
- package/packages/core/src/operator/query.ts +14 -18
- package/packages/core/src/operator/registry.ts +39 -7
- package/packages/core/src/operator/sandbox-host.ts +64 -40
- package/packages/core/src/operator/sandbox.ts +3 -0
- package/packages/core/src/operator/ticket-source-backend.ts +3 -12
- package/packages/core/src/operator/tickets.ts +25 -4
- package/packages/core/src/plugins/manifest.ts +2 -1
- package/packages/core/src/ports/forge/contract.ts +2 -2
- package/packages/core/src/ports/forge/git-rewrite.ts +25 -2
- package/packages/core/src/ports/forge/github-readiness.ts +2 -2
- package/packages/core/src/ports/forge/github.ts +26 -7
- package/packages/core/src/ports/forge/local-git.ts +4 -4
- package/packages/core/src/ports/forge/readiness.ts +1 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/account-env.ts +88 -0
- package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
- package/packages/core/src/ports/runner/claude.ts +26 -2
- package/packages/core/src/ports/runner/codex.ts +63 -31
- package/packages/core/src/ports/runner/one-shot.ts +2 -0
- package/packages/core/src/ports/runner/provider-error.ts +5 -0
- package/packages/core/src/ports/runner/routing.ts +35 -4
- package/packages/core/src/ports/tickets/contract.ts +58 -0
- package/packages/core/src/ports/tickets/tree.ts +1 -1
- package/packages/core/src/ports/types.ts +28 -7
- package/packages/core/src/ports/workspace/account-policy.ts +72 -0
- package/packages/core/src/ports/workspace/build-execution.ts +9 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
- package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +182 -72
- package/packages/core/src/processes/build-child.ts +6 -8
- package/packages/core/src/processes/build-execution-state.ts +8 -5
- package/packages/core/src/processes/build-runner.ts +554 -99
- package/packages/core/src/processes/dispatcher.ts +209 -101
- package/packages/core/src/processes/execution-no-progress.ts +8 -1
- package/packages/core/src/processes/execution-settlement.ts +21 -3
- package/packages/core/src/processes/harvest-runner.ts +68 -8
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-loss.ts +8 -2
- package/packages/core/src/processes/publication-state.ts +42 -4
- package/packages/core/src/processes/repo-view.ts +14 -0
- package/packages/core/src/processes/verify-cycle-config.ts +96 -0
- package/packages/core/src/project-secrets.ts +105 -0
- package/packages/core/src/{integration → scenarios}/harness.ts +330 -317
- package/packages/core/src/secret-name.ts +41 -0
- package/packages/core/src/store/account-redaction.ts +156 -0
- package/packages/core/src/store/adapter.ts +1 -0
- package/packages/core/src/store/build-scope.ts +9 -0
- package/packages/core/src/store/contract.ts +116 -2
- package/packages/core/src/store/local/schema.ts +13 -0
- package/packages/core/src/store/local/store.ts +42 -0
- package/packages/core/src/store/memory.ts +47 -0
- package/packages/core/src/store/operator-presence.ts +21 -0
- package/packages/core/src/store/phase-session.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +5185 -4156
- package/packages/core/src/store/remote/client.ts +89 -48
- package/packages/core/src/store/remote/compatibility.ts +20 -0
- package/packages/core/src/store/remote/protocol.ts +4 -0
- package/packages/core/src/store/remote/version.ts +3 -1
- package/packages/core/src/store/retention.ts +2 -3
- package/packages/core/src/store/session-handle.ts +9 -0
- package/packages/core/src/store/streams/session-writer.ts +1 -1
- package/packages/core/src/store/types.ts +12 -2
- package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
- package/packages/core/src/testing/index.ts +12 -1
- package/packages/core/src/testing/reduced-read-budget.ts +47 -0
- package/packages/core/src/testing/temp-directories.ts +58 -0
- package/skills/code-review/SKILL.md +23 -9
- package/skills/finalize/SKILL.md +15 -7
- package/skills/guide/SKILL.md +373 -148
- package/skills/guide/references/accounts.md +119 -0
- package/skills/guide/references/integration-tree.md +45 -38
- package/{docs/landing-policy.md → skills/guide/references/merge-policy.md} +40 -24
- package/skills/guide/references/migration-1.0.md +17 -13
- package/skills/guide/references/operator-api.md +180 -51
- package/skills/guide/references/plugin-authoring.md +21 -0
- package/skills/guide/references/remote-store-protocol.md +242 -68
- package/skills/guide/references/remote-ticket-protocol.md +30 -50
- package/skills/guide/references/restacking.md +54 -15
- package/skills/guide/references/setup.md +59 -119
- package/skills/guide/references/spec-standard.md +6 -6
- package/skills/guide/references/ticket-dependencies.md +7 -7
- package/skills/harvest/SKILL.md +3 -1
- package/skills/harvest-review/SKILL.md +3 -1
- package/skills/implement/SKILL.md +43 -17
- package/skills/operate/SKILL.md +118 -118
- package/skills/plan/SKILL.md +39 -13
- package/skills/plan-review/SKILL.md +15 -10
- package/skills/reconcile/SKILL.md +22 -3
- package/skills/spec/SKILL.md +20 -20
- package/skills/tickets/SKILL.md +12 -9
- package/templates/autobuild.toml +1 -1
- package/templates/hosted-service/package.json +2 -2
- package/docs/hosted-dispatcher-cutover-validation.md +0 -178
- package/docs/hosted-dispatcher.md +0 -275
- package/docs/hosted-service.md +0 -293
- package/docs/mcp.md +0 -149
- package/packages/core/src/orchestrator/approvals.ts +0 -115
- package/packages/core/src/orchestrator/conversation.ts +0 -167
- package/packages/core/src/orchestrator/model.ts +0 -86
- package/packages/core/src/orchestrator/prompt.ts +0 -63
- package/packages/core/src/orchestrator/tools.ts +0 -117
- package/packages/core/src/orchestrator/turn-runner.ts +0 -457
- package/packages/core/src/processes/orchestrator-tick.ts +0 -360
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { accountSchema, selectAccount } from './accounts'
|
|
2
|
+
import { isSafeStepName } from '../context-directory'
|
|
1
3
|
/**
|
|
2
4
|
* autobuild.toml schema (SPEC §16.1, D9): the one declarative per-repo config
|
|
3
5
|
* file. Declarative, not executable — the kernel, dispatcher, CLI, and any
|
|
@@ -25,8 +27,6 @@ import {
|
|
|
25
27
|
} from '../ports/workspace/provider-capabilities'
|
|
26
28
|
import { defineEntry, openMap, ownEntries, parseEntry } from '../open-map'
|
|
27
29
|
import { forwardIssues } from '../zod-issues'
|
|
28
|
-
import { compileEventGlobs } from '../events/globs'
|
|
29
|
-
import { REPOSITORY_ATTENTION_EVENTS } from '../events/repository'
|
|
30
30
|
import { effectiveRuntimeReferences } from './roles'
|
|
31
31
|
|
|
32
32
|
// ── Open maps ────────────────────────────────────────────────────────────────
|
|
@@ -60,11 +60,11 @@ import { effectiveRuntimeReferences } from './roles'
|
|
|
60
60
|
* rather than silent, but a diagnostic that contradicts the source is its own
|
|
61
61
|
* defect: §16.1 errors are feedback to whoever edits the file.
|
|
62
62
|
*/
|
|
63
|
-
function stepSection<T, C>(
|
|
63
|
+
function stepSection<T, C, S = string[]>(
|
|
64
64
|
label: string,
|
|
65
|
-
stepsSchema: z.ZodType<
|
|
65
|
+
stepsSchema: z.ZodType<S>,
|
|
66
66
|
tableSchema: z.ZodType<T>,
|
|
67
|
-
compose: (steps:
|
|
67
|
+
compose: (steps: S, stepConfigs: Record<string, T>, afterReconcile: boolean) => C,
|
|
68
68
|
allowAfterReconcile = false,
|
|
69
69
|
) {
|
|
70
70
|
const afterReconcileSchema = z.boolean().default(true)
|
|
@@ -72,7 +72,7 @@ function stepSection<T, C>(
|
|
|
72
72
|
.unknown()
|
|
73
73
|
.transform((input, ctx): C => {
|
|
74
74
|
const stepConfigs: Record<string, T> = Object.create(null)
|
|
75
|
-
let steps
|
|
75
|
+
let steps = stepsSchema.parse(undefined)
|
|
76
76
|
let afterReconcile = afterReconcileSchema.parse(undefined)
|
|
77
77
|
for (const [key, raw] of ownEntries(input, label, ctx)) {
|
|
78
78
|
if (key === 'afterReconcile' && allowAfterReconcile) {
|
|
@@ -94,8 +94,17 @@ function stepSection<T, C>(
|
|
|
94
94
|
})
|
|
95
95
|
.prefault({})
|
|
96
96
|
documentSchema(stepsSchema, {
|
|
97
|
+
...(allowAfterReconcile
|
|
98
|
+
? {
|
|
99
|
+
constraints:
|
|
100
|
+
'Each name is nonempty; each grouped stage contains at least one nonempty name. Names must be unique within and across stages.',
|
|
101
|
+
}
|
|
102
|
+
: {}),
|
|
97
103
|
description:
|
|
98
|
-
|
|
104
|
+
(allowAfterReconcile
|
|
105
|
+
? 'Ordered verify stages: a name is a singleton stage; a nonempty array runs its members concurrently. Names must be unique within and across stages. '
|
|
106
|
+
: 'Ordered names of the configured step tables. ') +
|
|
107
|
+
'Names contain only ASCII letters, digits, ., _ and -, excluding "." and "..". Every listed step must have a table and every table must be listed.',
|
|
99
108
|
})
|
|
100
109
|
documentSchema(tableSchema, {
|
|
101
110
|
description:
|
|
@@ -478,6 +487,8 @@ documentSchema(verifyPathGlobSchema, {
|
|
|
478
487
|
})
|
|
479
488
|
|
|
480
489
|
const verifyApplicabilityShape = {
|
|
490
|
+
/** Absence preserves historical serialized configuration identity. */
|
|
491
|
+
failFast: documentSchema(z.boolean().optional(), { default: 'false (omission is preserved)' }),
|
|
481
492
|
afterReconcile: z.boolean().optional(),
|
|
482
493
|
/** Any-match positive path selectors; absent means unconditional. */
|
|
483
494
|
paths: z
|
|
@@ -503,6 +514,7 @@ documentFields(verifyCheckStepSchema, {
|
|
|
503
514
|
'Name of an existing command in [commands]; required for check steps and forbidden for agent steps.',
|
|
504
515
|
afterReconcile:
|
|
505
516
|
'Step override wins over `[verify].afterReconcile`; false skips this step after reconciliation only.',
|
|
517
|
+
failFast: 'Cancel unfinished members of this stage when this step fails. Defaults to false.',
|
|
506
518
|
paths: 'Apply only when at least one changed path matches. Available to both variants.',
|
|
507
519
|
always:
|
|
508
520
|
'`true` makes the step mandatory in plan selection and bypasses path gating. Available to both variants.',
|
|
@@ -520,6 +532,7 @@ documentFields(verifyAgentStepSchema, {
|
|
|
520
532
|
skill: 'Exact installed skill name; required for agent steps and forbidden for check steps.',
|
|
521
533
|
afterReconcile:
|
|
522
534
|
'Step override wins over `[verify].afterReconcile`; false skips this step after reconciliation only.',
|
|
535
|
+
failFast: 'Cancel unfinished members of this stage when this step fails. Defaults to false.',
|
|
523
536
|
paths: 'Apply only when at least one changed path matches. Available to both variants.',
|
|
524
537
|
always:
|
|
525
538
|
'`true` makes the step mandatory in plan selection and bypasses path gating. Available to both variants.',
|
|
@@ -535,6 +548,8 @@ export interface VerifyConfig {
|
|
|
535
548
|
afterReconcile: boolean
|
|
536
549
|
/** Step order — each entry names a `verify:<step>` phase (§15.2.1). */
|
|
537
550
|
steps: string[]
|
|
551
|
+
/** Present only when the source contains grouped entries. */
|
|
552
|
+
stages?: string[][]
|
|
538
553
|
/** The [verify.<step>] tables, keyed by step name. */
|
|
539
554
|
stepConfigs: Record<string, VerifyStepConfig>
|
|
540
555
|
}
|
|
@@ -547,12 +562,31 @@ export interface VerifyConfig {
|
|
|
547
562
|
*/
|
|
548
563
|
export const verifySectionSchema = stepSection(
|
|
549
564
|
'[verify]',
|
|
550
|
-
z
|
|
565
|
+
z
|
|
566
|
+
.array(
|
|
567
|
+
z.union([
|
|
568
|
+
z.string().min(1),
|
|
569
|
+
z.array(z.string().min(1)).min(1, 'verify stage must not be empty'),
|
|
570
|
+
]),
|
|
571
|
+
)
|
|
572
|
+
.default([]),
|
|
551
573
|
verifyStepConfigSchema,
|
|
552
|
-
(
|
|
574
|
+
(entries, stepConfigs, afterReconcile): VerifyConfig => ({
|
|
575
|
+
steps: entries.flat(),
|
|
576
|
+
stepConfigs,
|
|
577
|
+
afterReconcile,
|
|
578
|
+
...(entries.some(Array.isArray)
|
|
579
|
+
? { stages: entries.map((entry) => (typeof entry === 'string' ? [entry] : entry)) }
|
|
580
|
+
: {}),
|
|
581
|
+
}),
|
|
553
582
|
true,
|
|
554
583
|
)
|
|
555
584
|
|
|
585
|
+
/** Historical configurations have singleton stages without additional metadata. */
|
|
586
|
+
export function verifyStages(config: VerifyConfig): readonly (readonly string[])[] {
|
|
587
|
+
return config.stages ?? config.steps.map((step) => [step])
|
|
588
|
+
}
|
|
589
|
+
|
|
556
590
|
// ── [finalize.<step>] ────────────────────────────────────────────────────────
|
|
557
591
|
|
|
558
592
|
/** Finalize steps deliberately omit verify-only applicability fields. */
|
|
@@ -612,6 +646,7 @@ export const finalizeSectionSchema = stepSection(
|
|
|
612
646
|
const roleArgsSchema = z.array(z.string().min(1))
|
|
613
647
|
|
|
614
648
|
const runtimeAxesSchema = z.strictObject({
|
|
649
|
+
account: z.string().min(1).regex(/\S/).optional(),
|
|
615
650
|
runtime: z.string().min(1).optional(),
|
|
616
651
|
model: z.string().min(1).optional(),
|
|
617
652
|
args: roleArgsSchema.optional(),
|
|
@@ -620,6 +655,8 @@ const runtimeAxesSchema = z.strictObject({
|
|
|
620
655
|
})
|
|
621
656
|
|
|
622
657
|
documentFields(runtimeAxesSchema, {
|
|
658
|
+
account:
|
|
659
|
+
'Named billing account; inherits independently. Claude selects the sole subscription account when omitted.',
|
|
623
660
|
runtime: 'Select an agent adapter.',
|
|
624
661
|
model: 'Select the exact model. Codex uses unqualified `gpt-*`; Pi ids are provider-qualified.',
|
|
625
662
|
args: 'Ordered extra CLI argv tokens applied to every phase and tool-free one-shot invocation. A supplied list replaces, rather than unions with, the inherited list.',
|
|
@@ -646,6 +683,8 @@ export const roleSchema = runtimeAxesSchema.extend({
|
|
|
646
683
|
})
|
|
647
684
|
|
|
648
685
|
documentFields(roleSchema, {
|
|
686
|
+
account:
|
|
687
|
+
'Named billing account; inherits independently. Claude selects the sole subscription account when omitted.',
|
|
649
688
|
runtime: 'Select an agent adapter.',
|
|
650
689
|
model: 'Select the exact model. Codex uses unqualified `gpt-*`; Pi ids are provider-qualified.',
|
|
651
690
|
args: 'Ordered extra CLI argv tokens applied to every phase and tool-free one-shot invocation. A supplied list replaces, rather than unions with, the inherited list.',
|
|
@@ -969,131 +1008,15 @@ documentSchema(orchestratorSandboxSchema.shape.environmentVariables, {
|
|
|
969
1008
|
})
|
|
970
1009
|
export type OrchestratorSandboxConfig = z.infer<typeof orchestratorSandboxSchema>
|
|
971
1010
|
|
|
972
|
-
/** The turn runner lives inside the hosted operator route and the dispatcher
|
|
973
|
-
* tick, both of which run under a Vercel function duration limit the config's
|
|
974
|
-
* invocation budget can never exceed: a value above this is clamped (not
|
|
975
|
-
* rejected) at parse time so a mis-set budget degrades to the limit instead of
|
|
976
|
-
* failing every deploy. The operator route pins `maxDuration` to this same
|
|
977
|
-
* constant, so one number is cited by the config, the route, and the docs. */
|
|
978
|
-
export const ORCHESTRATOR_ROUTE_LIMIT_SECONDS = 300
|
|
979
|
-
|
|
980
|
-
/** Turn budget floor for the dispatcher tick's orchestrator step: when less
|
|
981
|
-
* than this many seconds of tick budget remain, the step skips the pass
|
|
982
|
-
* entirely (suspension state is durable, so skipping is always safe). */
|
|
983
|
-
export const ORCHESTRATOR_MIN_TURN_SECONDS = 30
|
|
984
|
-
|
|
985
|
-
/** The turn approval entries' shape: a registry tool name, optionally
|
|
986
|
-
* qualified by the discriminator field's accepted value (`tool:qualifier`).
|
|
987
|
-
* Validation is syntactic only — an entry naming an absent or unknown tool is
|
|
988
|
-
* inert by design (documented in docs/configuration.md), because the list
|
|
989
|
-
* is meant to stay stable while the registry grows — e.g. `sandbox.publish`
|
|
990
|
-
* was named here before its ticket landed, and stays inert in bindings
|
|
991
|
-
* where no sandbox backend is bound (the hosted default). */
|
|
992
|
-
const ORCHESTRATOR_APPROVAL_ENTRY = /^[a-z][a-z0-9_.]*(:[a-z0-9_-]+)?$/
|
|
993
|
-
|
|
994
|
-
/** The attention set a new session's wake settings inherit when the
|
|
995
|
-
* repository does not override `wake`: the build events an operator or agent
|
|
996
|
-
* must wake up for, spelled as literal globs. These legacy hosted defaults
|
|
997
|
-
* remain independent of CLI watch defaults; failed node verification belongs
|
|
998
|
-
* to both. Repository-journal attention can also wake a session. */
|
|
999
|
-
export const defaultOrchestratorWakeGlobs: readonly string[] = [
|
|
1000
|
-
'escalation.raised',
|
|
1001
|
-
'integration.verification-failed',
|
|
1002
|
-
'phase.deferral-escalated',
|
|
1003
|
-
'phase.failed',
|
|
1004
|
-
'infrastructure.failed',
|
|
1005
|
-
'runner.setup-failed',
|
|
1006
|
-
'dispatch.failed',
|
|
1007
|
-
'publication.lost',
|
|
1008
|
-
'finalize.completed',
|
|
1009
|
-
'pr.conflicted',
|
|
1010
|
-
'pr.merged',
|
|
1011
|
-
'pr.closed',
|
|
1012
|
-
'build.completed',
|
|
1013
|
-
'build.aborted',
|
|
1014
|
-
...REPOSITORY_ATTENTION_EVENTS,
|
|
1015
|
-
]
|
|
1016
|
-
|
|
1017
|
-
/** The registry tools a turn asks its operator about before executing.
|
|
1018
|
-
* The maintainer sets this to `[]` for autonomous operation. */
|
|
1019
|
-
export const defaultOrchestratorApprovals: readonly string[] = [
|
|
1020
|
-
'builds.control:abort',
|
|
1021
|
-
'builds.control:discard',
|
|
1022
|
-
'builds.answer:revise-spec',
|
|
1023
|
-
'sandbox.publish',
|
|
1024
|
-
'tickets.move:ready',
|
|
1025
|
-
]
|
|
1026
|
-
|
|
1027
|
-
/** A session's effective wake globs: the configured `wake` when declared
|
|
1028
|
-
* (an explicit `[]` means never wake), else the default attention set. Kept
|
|
1029
|
-
* as a resolver rather than a schema default so `wake`'s absence (inherit)
|
|
1030
|
-
* and emptiness (never wake) stay distinct. */
|
|
1031
|
-
export function orchestratorWakeGlobs(config: OrchestratorConfig): string[] {
|
|
1032
|
-
return [...(config.wake ?? defaultOrchestratorWakeGlobs)]
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
1011
|
export const orchestratorSchema = z.strictObject({
|
|
1036
1012
|
enabled: z.boolean().default(false),
|
|
1037
1013
|
sandbox: orchestratorSandboxSchema.prefault({}),
|
|
1038
|
-
/** Provider-qualified model string for the turn runner, in the same
|
|
1039
|
-
* vocabulary as `[roles]` model strings (nonblank; a leading
|
|
1040
|
-
* `vercel-ai-gateway/` prefix is stripped before the gateway provider).
|
|
1041
|
-
* Resolved through the deployment's gateway credential. Required when
|
|
1042
|
-
* `enabled = true` (cross-validated below); the runner never starts a turn
|
|
1043
|
-
* on a repository whose config omits it. */
|
|
1044
|
-
model: z.string().min(1).optional(),
|
|
1045
|
-
/** Wall-clock budget for one turn invocation, in seconds. Clamped — not
|
|
1046
|
-
* rejected — to ORCHESTRATOR_ROUTE_LIMIT_SECONDS, the hosted function
|
|
1047
|
-
* duration the runner runs under. */
|
|
1048
|
-
invocationBudgetSeconds: z
|
|
1049
|
-
.number()
|
|
1050
|
-
.int()
|
|
1051
|
-
.positive()
|
|
1052
|
-
.default(240)
|
|
1053
|
-
.transform((value) => Math.min(value, ORCHESTRATOR_ROUTE_LIMIT_SECONDS)),
|
|
1054
|
-
/** Registry tool names (optionally `tool:qualifier`) whose calls suspend a
|
|
1055
|
-
* turn until the operator answers. Empty means none. Entries naming an
|
|
1056
|
-
* absent or unknown tool are inert by design, which is what keeps the
|
|
1057
|
-
* default list stable while the registry grows. */
|
|
1058
|
-
approvals: z
|
|
1059
|
-
.array(
|
|
1060
|
-
z
|
|
1061
|
-
.string()
|
|
1062
|
-
.regex(
|
|
1063
|
-
ORCHESTRATOR_APPROVAL_ENTRY,
|
|
1064
|
-
'approval entries look like "tool" or "tool:qualifier"',
|
|
1065
|
-
),
|
|
1066
|
-
)
|
|
1067
|
-
.default([...defaultOrchestratorApprovals]),
|
|
1068
|
-
/** Wake-filter globs a NEW session inherits. Kept schema-optional (not
|
|
1069
|
-
* `.default()`) so absent ("inherit the default attention set") and `[]`
|
|
1070
|
-
* ("never wake") stay distinct. Each glob must match at least one build
|
|
1071
|
-
* or repository-journal event type — validated below with the shared
|
|
1072
|
-
* `ab watch` compiler. */
|
|
1073
|
-
wake: z.array(z.string().min(1)).optional(),
|
|
1074
1014
|
})
|
|
1075
1015
|
|
|
1076
1016
|
documentFields(orchestratorSchema, {
|
|
1077
1017
|
enabled:
|
|
1078
|
-
'
|
|
1018
|
+
'Enables externally driven sandbox tools, archive cleanup and dispatcher idle settlement. Operators run in external agent harnesses.',
|
|
1079
1019
|
sandbox: 'Sandbox behavior knobs.',
|
|
1080
|
-
model:
|
|
1081
|
-
"Provider-qualified model string for the turn runner, in the same vocabulary as `[roles]` model strings (a leading `vercel-ai-gateway/` prefix is accepted and stripped). Resolved through the deployment's gateway credential.",
|
|
1082
|
-
invocationBudgetSeconds:
|
|
1083
|
-
'Wall-clock budget in seconds for one turn invocation. Values above the route limit are clamped after parsing.',
|
|
1084
|
-
approvals:
|
|
1085
|
-
"Registry tool names whose calls suspend a turn until you answer. Empty (`[]`) means none \u2014 autonomous operation. An entry naming an absent or unknown tool is **inert by design**, never a config error: the list stays stable while the registry grows, and a tool's removal cannot break parsing. A `tool:qualifier` entry applies to the named discriminator value only (for example `tickets.move:ready` approves moving a ticket to `ready`); for a tool without a discriminator, only the bare form matches.",
|
|
1086
|
-
wake: 'The attention events a **new** session wakes for. Kept schema-optional so absent (inherit the legacy hosted wake set including `integration.verification-failed`, independently of CLI watch defaults) and `[]` (never wake; message-only) stay distinct. Each glob must match at least one build or repository-journal event type, validated with the same compiler `ab watch` uses. Existing sessions never retroactively inherit; an explicit `PUT .../wake` always wins.',
|
|
1087
|
-
})
|
|
1088
|
-
documentSchema(orchestratorSchema.shape.model, {
|
|
1089
|
-
required: 'Required when orchestrator.enabled = true.',
|
|
1090
|
-
})
|
|
1091
|
-
documentSchema(orchestratorSchema.shape.invocationBudgetSeconds, {
|
|
1092
|
-
constraints: `Values above ${ORCHESTRATOR_ROUTE_LIMIT_SECONDS} are clamped to that limit after parsing.`,
|
|
1093
|
-
})
|
|
1094
|
-
documentSchema(orchestratorSchema.shape.wake, {
|
|
1095
|
-
constraints:
|
|
1096
|
-
'Every glob must match a known build or repository-journal event. Omission inherits the legacy hosted wake set independently of CLI watch defaults; [] disables waking.',
|
|
1097
1020
|
})
|
|
1098
1021
|
export type OrchestratorConfig = z.infer<typeof orchestratorSchema>
|
|
1099
1022
|
|
|
@@ -1140,7 +1063,8 @@ export const configRootSchema = z.strictObject({
|
|
|
1140
1063
|
.refine((value) => value.trim().length > 0, 'plugin module specifiers must be nonblank'),
|
|
1141
1064
|
)
|
|
1142
1065
|
.default([]),
|
|
1143
|
-
|
|
1066
|
+
merge: z.array(landingRuleSchema).optional(),
|
|
1067
|
+
landing: z.array(landingRuleSchema).optional(),
|
|
1144
1068
|
pr: prSchema.optional(),
|
|
1145
1069
|
workspace: workspaceSchema.prefault({}),
|
|
1146
1070
|
commands: commandsSchema,
|
|
@@ -1151,6 +1075,7 @@ export const configRootSchema = z.strictObject({
|
|
|
1151
1075
|
// disappear ahead of both eager resolution and the unconsumed-key warning;
|
|
1152
1076
|
// the registry-aware eager resolver requires default.runtime and can
|
|
1153
1077
|
// therefore include the complete materialized runtime list in its diagnostic.
|
|
1078
|
+
accounts: openMap('[accounts]', accountSchema).default({}),
|
|
1154
1079
|
roles: openMap('[roles]', roleSchema),
|
|
1155
1080
|
policy: policySchema.prefault({}),
|
|
1156
1081
|
orchestrator: orchestratorSchema.prefault({}),
|
|
@@ -1176,12 +1101,17 @@ documentFields(configRootSchema, {
|
|
|
1176
1101
|
'Forge adapter name. Shipped values are `github` and `local-git`; configured plugins may register other names.',
|
|
1177
1102
|
plugins:
|
|
1178
1103
|
'Trusted Bun plugin modules loaded by dispatch, `ab ticket`, and scoped phase CLI processes.',
|
|
1179
|
-
|
|
1104
|
+
merge: 'Ordered merge rules; the first matching rule controls consent.',
|
|
1105
|
+
landing: 'Deprecated alias for merge. Do not declare both keys.',
|
|
1180
1106
|
pr: 'Pull request review image hosting configuration.',
|
|
1181
1107
|
workspace: 'Workspace provider selector and provider-specific configuration.',
|
|
1182
1108
|
commands: 'Named shell commands used by setup and deterministic checks.',
|
|
1183
|
-
verify:
|
|
1184
|
-
|
|
1109
|
+
verify:
|
|
1110
|
+
'Ordered verification steps and applicability rules. Step names use ASCII letters, digits, ., _ and -; exactly . and .. are forbidden.',
|
|
1111
|
+
finalize:
|
|
1112
|
+
'Ordered post-PR steps. Failures are recorded without blocking the PR. Step names use ASCII letters, digits, ., _ and -; exactly . and .. are forbidden.',
|
|
1113
|
+
accounts:
|
|
1114
|
+
'Named Claude subscription, Kimi Code, or ChatGPT subscription billing accounts. Descriptors contain credential variable names only.',
|
|
1185
1115
|
roles: 'Named agent roles. The reserved default role provides inherited runtime axes.',
|
|
1186
1116
|
policy: 'Lifecycle budgets, retries, convergence and harvest limits.',
|
|
1187
1117
|
orchestrator:
|
|
@@ -1214,7 +1144,84 @@ export const TOP_LEVEL_KEYS = Object.keys(configRootSchema.shape)
|
|
|
1214
1144
|
* because validation failures are feedback to whoever edits the file (D6
|
|
1215
1145
|
* discipline applied to config).
|
|
1216
1146
|
*/
|
|
1217
|
-
|
|
1147
|
+
const normalizedConfigSchema = configRootSchema.transform((input, ctx) => {
|
|
1148
|
+
if (input.merge !== undefined && input.landing !== undefined) {
|
|
1149
|
+
ctx.addIssue({
|
|
1150
|
+
code: 'custom',
|
|
1151
|
+
path: ['merge'],
|
|
1152
|
+
message: 'merge and deprecated landing cannot both be declared',
|
|
1153
|
+
})
|
|
1154
|
+
return z.NEVER
|
|
1155
|
+
}
|
|
1156
|
+
const { merge, landing, ...rest } = input
|
|
1157
|
+
return { ...rest, landing: merge ?? landing ?? [] }
|
|
1158
|
+
})
|
|
1159
|
+
|
|
1160
|
+
export const configSchema = normalizedConfigSchema.superRefine((config, ctx) => {
|
|
1161
|
+
for (const [name, account] of Object.entries(config.accounts)) {
|
|
1162
|
+
if (account.kind !== 'chatgpt-subscription') continue
|
|
1163
|
+
if (
|
|
1164
|
+
Object.entries(config.accounts).some(
|
|
1165
|
+
([other, a]) => other !== name && a.credentialEnv === account.credentialEnv,
|
|
1166
|
+
)
|
|
1167
|
+
)
|
|
1168
|
+
ctx.addIssue({
|
|
1169
|
+
code: 'custom',
|
|
1170
|
+
path: ['accounts', name],
|
|
1171
|
+
message: 'ChatGPT accounts require distinct credentialEnv slots',
|
|
1172
|
+
})
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
const accountVariables = new Set(
|
|
1176
|
+
Object.values(config.accounts).map((account) => account.credentialEnv),
|
|
1177
|
+
)
|
|
1178
|
+
for (const name of config.orchestrator.sandbox.environmentVariables)
|
|
1179
|
+
if (accountVariables.has(name))
|
|
1180
|
+
ctx.addIssue({
|
|
1181
|
+
code: 'custom',
|
|
1182
|
+
path: ['orchestrator', 'sandbox', 'environmentVariables'],
|
|
1183
|
+
message: `Account credential variable ${JSON.stringify(name)} cannot enter an operator sandbox`,
|
|
1184
|
+
})
|
|
1185
|
+
const defaults = config.roles.default ?? {}
|
|
1186
|
+
for (const [role, spec] of Object.entries(config.roles)) {
|
|
1187
|
+
const primary = {
|
|
1188
|
+
runtime: spec.runtime ?? defaults.runtime,
|
|
1189
|
+
account: spec.account ?? defaults.account,
|
|
1190
|
+
}
|
|
1191
|
+
const targets = [
|
|
1192
|
+
primary,
|
|
1193
|
+
...(spec.alternates ?? defaults.alternates ?? []).map((alt) => ({
|
|
1194
|
+
runtime: alt.runtime ?? primary.runtime,
|
|
1195
|
+
account: alt.account ?? primary.account,
|
|
1196
|
+
})),
|
|
1197
|
+
]
|
|
1198
|
+
targets.forEach((target, index) => {
|
|
1199
|
+
try {
|
|
1200
|
+
selectAccount(
|
|
1201
|
+
config.accounts,
|
|
1202
|
+
target.runtime,
|
|
1203
|
+
target.account,
|
|
1204
|
+
`role ${JSON.stringify(role)}${index ? ` alternate[${index - 1}]` : ''}`,
|
|
1205
|
+
)
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
ctx.addIssue({ code: 'custom', path: ['roles', role], message: (error as Error).message })
|
|
1208
|
+
}
|
|
1209
|
+
})
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
for (const kind of ['verify', 'finalize'] as const) {
|
|
1213
|
+
const section = config[kind]
|
|
1214
|
+
if (!section) continue
|
|
1215
|
+
for (const name of new Set([...section.steps, ...Object.keys(section.stepConfigs)])) {
|
|
1216
|
+
if (!isSafeStepName(name))
|
|
1217
|
+
ctx.addIssue({
|
|
1218
|
+
code: 'custom',
|
|
1219
|
+
path: [kind, name],
|
|
1220
|
+
message: `${kind} step "${name}" must contain only ASCII letters, digits, ., _ or - and cannot be . or ..`,
|
|
1221
|
+
})
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1218
1225
|
const firstPluginIndex = new Map<string, number>()
|
|
1219
1226
|
config.plugins.forEach((specifier, index) => {
|
|
1220
1227
|
const firstIndex = firstPluginIndex.get(specifier)
|
|
@@ -1274,7 +1281,15 @@ export const configSchema = configRootSchema.superRefine((config, ctx) => {
|
|
|
1274
1281
|
// while sibling issues are collected. Guard the cross-check so malformed
|
|
1275
1282
|
// tables report validation feedback instead of throwing inside validation.
|
|
1276
1283
|
if (config.verify?.stepConfigs !== undefined) {
|
|
1284
|
+
const seen = new Set<string>()
|
|
1277
1285
|
config.verify.steps.forEach((step, index) => {
|
|
1286
|
+
if (seen.has(step))
|
|
1287
|
+
ctx.addIssue({
|
|
1288
|
+
code: 'custom',
|
|
1289
|
+
path: ['verify', 'steps', index],
|
|
1290
|
+
message: `duplicate verify step ${JSON.stringify(step)} across or within stages`,
|
|
1291
|
+
})
|
|
1292
|
+
seen.add(step)
|
|
1278
1293
|
if (!Object.hasOwn(config.verify.stepConfigs, step)) {
|
|
1279
1294
|
ctx.addIssue({
|
|
1280
1295
|
code: 'custom',
|
|
@@ -1391,38 +1406,7 @@ export const configSchema = configRootSchema.superRefine((config, ctx) => {
|
|
|
1391
1406
|
// `createWorkspaceProvider` (construction) and `validateInitReadiness`
|
|
1392
1407
|
// (init validation), both of which run after plugin load; no site loads
|
|
1393
1408
|
// plugins earlier to widen parse-time coverage.
|
|
1394
|
-
// Wake globs are validated with the same compiler `ab watch` uses, over the
|
|
1395
|
-
// build AND repository-journal catalogs — the wake pass scans both — so a
|
|
1396
|
-
// typo'd glob fails at parse time instead of silently matching nothing —
|
|
1397
|
-
// regardless of `enabled`, since a later enablement would inherit the
|
|
1398
|
-
// already-broken value.
|
|
1399
|
-
if (config.orchestrator.wake !== undefined) {
|
|
1400
|
-
try {
|
|
1401
|
-
compileEventGlobs(config.orchestrator.wake, {
|
|
1402
|
-
repository: true,
|
|
1403
|
-
usage: '[orchestrator].wake',
|
|
1404
|
-
})
|
|
1405
|
-
} catch (error) {
|
|
1406
|
-
ctx.addIssue({
|
|
1407
|
-
code: 'custom',
|
|
1408
|
-
path: ['orchestrator', 'wake'],
|
|
1409
|
-
message: error instanceof Error ? error.message : String(error),
|
|
1410
|
-
})
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
1409
|
if (config.orchestrator.enabled) {
|
|
1415
|
-
// The turn runner's model is not optional when the orchestrator is on:
|
|
1416
|
-
// an enabled table without one would fail at first turn start, far from
|
|
1417
|
-
// the edit that caused it.
|
|
1418
|
-
if (config.orchestrator.model === undefined) {
|
|
1419
|
-
ctx.addIssue({
|
|
1420
|
-
code: 'custom',
|
|
1421
|
-
path: ['orchestrator', 'model'],
|
|
1422
|
-
message:
|
|
1423
|
-
'[orchestrator].enabled = true requires [orchestrator].model — name the provider-qualified model string the turn runner uses (same vocabulary as [roles], resolved through the deployment gateway credential)',
|
|
1424
|
-
})
|
|
1425
|
-
}
|
|
1426
1410
|
const providerForbidden =
|
|
1427
1411
|
BUILTIN_WORKSPACE_PROVIDER_CONFIG.get(config.workspace.provider)?.sandboxForbiddenEnv ?? []
|
|
1428
1412
|
config.orchestrator.sandbox.environmentVariables.forEach((name, index) => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Session scratch names are direct children of .ab, shared across rounds. */
|
|
2
|
+
export function isSafeStepName(name: string): boolean {
|
|
3
|
+
return /^[A-Za-z0-9._-]+$/.test(name) && name !== '.' && name !== '..'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function contextDirectory(phase: string, finalizeStep?: string): string {
|
|
7
|
+
const base = phase.split('@')[0]!
|
|
8
|
+
const step = finalizeStep ?? (base.startsWith('verify:') ? base.slice(7) : undefined)
|
|
9
|
+
if (step !== undefined && !isSafeStepName(step)) {
|
|
10
|
+
throw new Error(`Invalid context step name "${step}"`)
|
|
11
|
+
}
|
|
12
|
+
return `.ab/${finalizeStep !== undefined ? `finalize-${step}` : base.replace(':', '-')}`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function resolveContextDirectory(phase: string, explicit?: string): string {
|
|
16
|
+
const expected = contextDirectory(phase)
|
|
17
|
+
if (explicit === undefined) return expected
|
|
18
|
+
if (explicit === expected) return explicit
|
|
19
|
+
if (
|
|
20
|
+
phase.split('@')[0] === 'finalize' &&
|
|
21
|
+
explicit.startsWith('.ab/finalize-') &&
|
|
22
|
+
isSafeStepName(explicit.slice('.ab/finalize-'.length))
|
|
23
|
+
)
|
|
24
|
+
return explicit
|
|
25
|
+
throw new Error(`AB_CONTEXT_DIR "${explicit}" must name the session directory ${expected}`)
|
|
26
|
+
}
|
|
@@ -66,10 +66,16 @@ export async function packageDistribution(
|
|
|
66
66
|
root: string,
|
|
67
67
|
exec: PackagingExec = spawnExec,
|
|
68
68
|
signal?: AbortSignal,
|
|
69
|
+
filesystem: { mkdtemp(prefix: string): Promise<string>; rm: typeof rm } = { mkdtemp, rm },
|
|
69
70
|
): Promise<Uint8Array> {
|
|
70
|
-
const staging = await mkdtemp(join(tmpdir(), 'autobuild-pack-staging-'))
|
|
71
|
-
|
|
71
|
+
const staging = await filesystem.mkdtemp(join(tmpdir(), 'autobuild-pack-staging-'))
|
|
72
|
+
let destination: string | undefined
|
|
73
|
+
let failure: unknown
|
|
74
|
+
let failed = false
|
|
75
|
+
let bytes!: Uint8Array
|
|
76
|
+
let errors: unknown[] = []
|
|
72
77
|
try {
|
|
78
|
+
destination = await filesystem.mkdtemp(join(tmpdir(), 'autobuild-pack-'))
|
|
73
79
|
// Pack from a staging copy of the repo's `files` set rather than the repo
|
|
74
80
|
// root: the packed manifest must differ from the repo manifest (above), and
|
|
75
81
|
// rewriting the repo manifest in place would leave a window where tracked
|
|
@@ -108,9 +114,24 @@ export async function packageDistribution(
|
|
|
108
114
|
const archives = (await readdir(destination)).filter((name) => name.endsWith('.tgz'))
|
|
109
115
|
if (archives.length !== 1)
|
|
110
116
|
throw new Error('Autobuild packaging did not produce exactly one archive')
|
|
111
|
-
|
|
117
|
+
bytes = new Uint8Array(await readFile(join(destination, archives[0]!)))
|
|
118
|
+
} catch (error) {
|
|
119
|
+
failed = true
|
|
120
|
+
failure = error
|
|
112
121
|
} finally {
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
const results = await Promise.allSettled(
|
|
123
|
+
[staging, destination]
|
|
124
|
+
.filter((path): path is string => path !== undefined)
|
|
125
|
+
.map((path) => filesystem.rm(path, { recursive: true, force: true })),
|
|
126
|
+
)
|
|
127
|
+
errors = results.flatMap((result) => (result.status === 'rejected' ? [result.reason] : []))
|
|
115
128
|
}
|
|
129
|
+
if (errors.length)
|
|
130
|
+
throw new AggregateError(
|
|
131
|
+
failed ? [failure, ...errors] : errors,
|
|
132
|
+
'Distribution packaging cleanup failed',
|
|
133
|
+
failed ? { cause: failure } : undefined,
|
|
134
|
+
)
|
|
135
|
+
if (failed) throw failure
|
|
136
|
+
return bytes
|
|
116
137
|
}
|
|
@@ -55,6 +55,7 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
55
55
|
'landing.native-enable-started': ['dispatcher'],
|
|
56
56
|
'landing.forge-merged': ['kernel'],
|
|
57
57
|
'landing.native-applied': ['dispatcher', 'kernel'],
|
|
58
|
+
'target.distance': ['dispatcher'],
|
|
58
59
|
'target.moved': ['dispatcher', 'kernel'],
|
|
59
60
|
'restack.prepared': ['kernel', 'dispatcher'],
|
|
60
61
|
'restack.replayed': ['kernel', 'dispatcher'],
|
|
@@ -117,6 +118,8 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
117
118
|
// Only the dispatcher releases workspaces and settles publications (§15.7);
|
|
118
119
|
// the kernel never destroys one, so it never records a loss.
|
|
119
120
|
'publication.lost': ['dispatcher'],
|
|
121
|
+
'publication.retry-scheduled': ['kernel', 'dispatcher'],
|
|
122
|
+
'publication.retry-exhausted': ['kernel', 'dispatcher'],
|
|
120
123
|
'abort.remote-branch-deleted': ['dispatcher'],
|
|
121
124
|
'abort.local-branch-deleted': ['dispatcher'],
|
|
122
125
|
'abort.ticket-returned': ['dispatcher'],
|
|
@@ -155,7 +158,11 @@ export const allowedActorKinds: Record<EventType, readonly ActorKind[]> = {
|
|
|
155
158
|
'code-review.verdict': ['agent'],
|
|
156
159
|
|
|
157
160
|
'verify.reconcile-policy-captured': ['kernel'],
|
|
161
|
+
'verify.config-captured': ['kernel'],
|
|
162
|
+
'verify.config-superseded': ['kernel'],
|
|
158
163
|
'verify.started': ['kernel'],
|
|
164
|
+
'verify.cancelled': ['kernel'],
|
|
165
|
+
'verify.stage-failed': ['kernel'],
|
|
159
166
|
'verify.completed': ['kernel', 'agent'],
|
|
160
167
|
'finalize.started': ['kernel'],
|
|
161
168
|
'finalize.completed': ['kernel'],
|
|
@@ -256,10 +263,11 @@ export function validateEventWrite(input: {
|
|
|
256
263
|
(escalation.source !== 'policy' ||
|
|
257
264
|
(escalation.policyCause !== 'infrastructure-failure-limit' &&
|
|
258
265
|
escalation.policyCause !== 'dispatch-failure-limit' &&
|
|
259
|
-
escalation.policyCause !== 'execution-no-progress'
|
|
266
|
+
escalation.policyCause !== 'execution-no-progress' &&
|
|
267
|
+
escalation.policyCause !== 'publication-retry-limit'))
|
|
260
268
|
) {
|
|
261
269
|
throw new EventValidationError(
|
|
262
|
-
'invalid dispatcher escalation: only policy/infrastructure-failure-limit or policy/dispatch-failure-limit or policy/execution-no-progress may be raised outside the kernel',
|
|
270
|
+
'invalid dispatcher escalation: only policy/infrastructure-failure-limit or policy/dispatch-failure-limit or policy/execution-no-progress or policy/publication-retry-limit may be raised outside the kernel',
|
|
263
271
|
)
|
|
264
272
|
}
|
|
265
273
|
if (escalation.source === 'policy' && escalation.policyCause === undefined) {
|
|
@@ -23,7 +23,8 @@ export interface StoredEvent {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** Change this revision whenever projection semantics change without new types. */
|
|
26
|
-
|
|
26
|
+
// Revision 3 retains optional billing-account descriptors in session/attempt projections.
|
|
27
|
+
export const READ_DECODER_REVISION = 3
|
|
27
28
|
export function catalogIdentity(
|
|
28
29
|
build: Record<string, string> = buildEventPolicy,
|
|
29
30
|
repository: Record<string, string> = repositoryEventPolicy,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared event-glob compilation (§15.3, AUT-342): the anchored glob matcher
|
|
3
|
-
* `ab watch`, `ab wait`, and
|
|
3
|
+
* `ab watch`, `ab wait`, and explicit session wake writes use.
|
|
4
4
|
* `*` matches any run of characters, `?` exactly one, everything else
|
|
5
5
|
* verbatim (so the dots inside event type names are escaped). Every glob
|
|
6
6
|
* must match at least one event type in one of the given catalogs, else a
|