@defrex/autobuild 1.1.0 → 1.3.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 -13
- package/SPEC.md +249 -15
- package/bin/ab-dispatch-generation.ts +11 -2
- package/docs/accounts.md +130 -0
- package/docs/agent-runtimes.md +4 -4
- package/docs/answering-blocked-builds.md +4 -1
- package/docs/architecture.md +224 -12
- package/docs/build-store.md +3 -41
- package/docs/builds.md +2 -0
- package/docs/cli.md +14 -0
- package/docs/configuration-overview.md +117 -0
- package/docs/configuration.md +266 -141
- package/docs/dispatcher-hosting.md +18 -33
- package/docs/intake.md +2 -0
- package/docs/integration-tree.md +16 -5
- package/docs/merge-policy.md +1 -3
- package/docs/operating.md +1 -2
- package/docs/operator-api.md +144 -53
- package/docs/operator-surfaces.md +32 -20
- package/docs/overview.md +1 -1
- package/docs/plugin-authoring.md +27 -1
- package/docs/remote-store-protocol.md +259 -91
- package/docs/remote-ticket-protocol.md +29 -49
- package/docs/restacking.md +45 -0
- package/docs/seams.md +8 -8
- package/docs/setup.md +34 -129
- package/docs/spec-standard.md +4 -2
- package/docs/ticket-dependencies.md +8 -0
- package/docs/ticket-sources.md +18 -0
- package/docs/troubleshooting.md +7 -11
- package/docs/upgrading.md +1 -1
- package/docs/workspaces.md +4 -4
- package/package.json +14 -5
- 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.ts +3 -1
- package/packages/core/src/cli/connect.ts +3 -3
- package/packages/core/src/cli/dispatch-frontend.ts +1 -0
- 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-repository-feed.ts +107 -26
- package/packages/core/src/cli/dispatch.ts +135 -27
- package/packages/core/src/cli/dispatcher-liveness.ts +6 -1
- package/packages/core/src/cli/forge-clear.ts +30 -0
- package/packages/core/src/cli/help.ts +17 -0
- 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 +72 -0
- package/packages/core/src/cli/publication-settlement.ts +4 -1
- package/packages/core/src/cli/secrets.ts +173 -0
- package/packages/core/src/cli/store-opening.ts +11 -1
- package/packages/core/src/cli/upgrade-agent.ts +9 -1
- package/packages/core/src/cli/watch.ts +12 -14
- package/packages/core/src/config/accounts.ts +101 -0
- package/packages/core/src/config/live.ts +14 -1
- package/packages/core/src/config/roles.ts +54 -3
- package/packages/core/src/config/schema.ts +60 -0
- package/packages/core/src/events/catalog.ts +1 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/forge-degradation-policy.ts +11 -0
- package/packages/core/src/events/payloads.ts +13 -0
- package/packages/core/src/events/policy.ts +9 -0
- package/packages/core/src/events/repository.ts +75 -2
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +278 -0
- package/packages/core/src/kernel/change-presence.ts +74 -8
- package/packages/core/src/kernel/engine.ts +8 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +14 -0
- package/packages/core/src/kernel/node-polling.ts +40 -7
- package/packages/core/src/kernel/node-restack-demand.ts +74 -0
- package/packages/core/src/kernel/node-restack-state.ts +5 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +33 -1
- package/packages/core/src/kernel/read-facts.ts +6 -0
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer.ts +4 -1
- package/packages/core/src/kernel/ticket-preparation.ts +66 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +20 -0
- package/packages/core/src/operator/index.ts +4 -0
- package/packages/core/src/operator/protocol.ts +6 -0
- package/packages/core/src/operator/registry.ts +42 -1
- package/packages/core/src/operator/tickets.ts +25 -4
- package/packages/core/src/plugins/manifest.ts +2 -1
- package/packages/core/src/ports/runner/account-env.ts +139 -0
- package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
- package/packages/core/src/ports/runner/claude.ts +70 -42
- 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 +6 -1
- 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/provider-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +125 -35
- package/packages/core/src/processes/build-runner.ts +32 -1
- package/packages/core/src/processes/dispatcher.ts +493 -121
- package/packages/core/src/processes/execution-no-progress.ts +1 -0
- 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/harvest.ts +11 -16
- package/packages/core/src/processes/repo-view.ts +3 -0
- package/packages/core/src/project-secrets.ts +105 -0
- package/packages/core/src/secret-name.ts +41 -0
- package/packages/core/src/store/account-redaction.ts +156 -0
- package/packages/core/src/store/artifact-meta.ts +7 -0
- package/packages/core/src/store/contract.ts +60 -1
- package/packages/core/src/store/memory.ts +4 -0
- package/packages/core/src/store/reducer-value-shapes.json +7389 -6647
- package/packages/core/src/store/reducer-value-validation.ts +106 -6
- package/packages/core/src/store/remote/client.ts +85 -50
- package/packages/core/src/store/remote/compatibility.ts +57 -0
- package/packages/core/src/store/remote/index.ts +6 -0
- package/packages/core/src/store/remote/protocol.ts +8 -1
- package/packages/core/src/store/remote/released-reducer-values/1.2.0.json +8129 -0
- package/packages/core/src/store/remote/version.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +4 -2
- package/packages/core/src/store/snapshots.ts +16 -3
- package/packages/core/src/store/types.ts +2 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +266 -5
- package/packages/core/src/testing/index.ts +2 -1
- package/packages/core/src/testing/reduced-read-budget.ts +560 -5
- package/skills/guide/SKILL.md +164 -37
- package/skills/guide/references/accounts.md +130 -0
- package/skills/guide/references/integration-tree.md +16 -5
- package/skills/guide/references/merge-policy.md +1 -3
- package/skills/guide/references/operator-api.md +144 -53
- package/skills/guide/references/plugin-authoring.md +27 -1
- package/skills/guide/references/remote-store-protocol.md +259 -91
- package/skills/guide/references/remote-ticket-protocol.md +29 -49
- package/skills/guide/references/restacking.md +45 -0
- package/skills/guide/references/setup.md +34 -129
- package/skills/guide/references/spec-standard.md +4 -2
- package/skills/guide/references/ticket-dependencies.md +8 -0
- package/skills/harvest/SKILL.md +3 -1
- package/skills/harvest-review/SKILL.md +3 -1
- package/skills/operate/SKILL.md +26 -11
- package/skills/reconcile/SKILL.md +6 -0
- package/skills/spec/SKILL.md +1 -1
- package/skills/tickets/SKILL.md +10 -5
- package/templates/hosted-service/package.json +2 -2
- package/docs/hosted-dispatcher-cutover-validation.md +0 -178
- package/docs/hosted-dispatcher.md +0 -278
- package/docs/hosted-service.md +0 -304
- package/docs/mcp.md +0 -150
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { LocalCredentials } from '../accounts/local-credentials'
|
|
2
|
+
import { LocalAccountOwner, renewLocalAccounts } from '../accounts/local-owner'
|
|
3
|
+
import { accountRedactor, redactAccountStore } from '../store/account-redaction'
|
|
1
4
|
import { capturedBuildConfig } from '../processes/verify-cycle-config'
|
|
2
5
|
import { ForgeRequestDeferred } from '../ports/forge-request-context'
|
|
3
6
|
import { migrationIdentity } from '../kernel/ticket-migrations'
|
|
@@ -168,7 +171,7 @@ import {
|
|
|
168
171
|
} from '../processes/build-execution-state'
|
|
169
172
|
import { HarvestRunner, type HarvestRunnerResult } from '../processes/harvest-runner'
|
|
170
173
|
import {
|
|
171
|
-
|
|
174
|
+
unclaimedObservationCount,
|
|
172
175
|
evaluateHarvestPressureFromStore,
|
|
173
176
|
evaluateHarvestPressureFromDigests,
|
|
174
177
|
} from '../processes/harvest'
|
|
@@ -249,7 +252,10 @@ export function slugNamingPrompt(spec: string): string {
|
|
|
249
252
|
function definedEnv(env: Record<string, string | undefined>): Record<string, string> {
|
|
250
253
|
const defined: Record<string, string> = {}
|
|
251
254
|
for (const [key, value] of Object.entries(env)) {
|
|
252
|
-
if (
|
|
255
|
+
if (
|
|
256
|
+
value !== undefined &&
|
|
257
|
+
!['AB_TOKEN', 'AB_TICKET_TOKEN', 'AB_TICKET_URL', 'AB_PROJECT_SECRETS_KEY'].includes(key)
|
|
258
|
+
)
|
|
253
259
|
defined[key] = value
|
|
254
260
|
}
|
|
255
261
|
return defined
|
|
@@ -294,6 +300,9 @@ interface ResumePrompt {
|
|
|
294
300
|
/** The real adapters the loop drives — resolved by `wire` (default: the
|
|
295
301
|
* production ports; tests inject fakes). */
|
|
296
302
|
export interface DispatchWiring {
|
|
303
|
+
renewAccounts?: (authority: { repo: string; run: string }) => Promise<void>
|
|
304
|
+
releaseAccounts?: () => Promise<void>
|
|
305
|
+
|
|
297
306
|
credentialIssuer?: typeof delegateCredential
|
|
298
307
|
store: BuildStore
|
|
299
308
|
tickets: TicketSource
|
|
@@ -517,8 +526,12 @@ async function defaultWire(
|
|
|
517
526
|
remoteBranchHead: async (branch: string): Promise<string | undefined> => {
|
|
518
527
|
const remoteBranchSha = forge.remoteBranchSha
|
|
519
528
|
if (remoteBranchSha === undefined) return undefined
|
|
529
|
+
// The provider pushes through the guest, bypassing the forge's read
|
|
530
|
+
// invalidation, so each head read takes a fresh scope: a post-push
|
|
531
|
+
// readback must never replay the tick's pre-push answer.
|
|
532
|
+
const read = () => remoteBranchSha.call(forge, branch)
|
|
520
533
|
try {
|
|
521
|
-
return await
|
|
534
|
+
return await (forge.withReadScope ? forge.withReadScope(read) : read())
|
|
522
535
|
} catch (error) {
|
|
523
536
|
if (error instanceof GitHubApiError && error.status === 404) return undefined
|
|
524
537
|
throw error
|
|
@@ -536,6 +549,51 @@ async function defaultWire(
|
|
|
536
549
|
plugins,
|
|
537
550
|
)
|
|
538
551
|
const { runtimes } = createProductionRuntimes()
|
|
552
|
+
if (opts.env.AB_PROJECT_SECRETS_FAILED === '1')
|
|
553
|
+
for (const name of JSON.parse(opts.env.AB_PROJECT_SECRETS_UNAVAILABLE ?? '[]') as string[])
|
|
554
|
+
delete opts.env[name]
|
|
555
|
+
let accounts = config.accounts
|
|
556
|
+
const credentials = new LocalCredentials(join(state.checkout, '.autobuild'))
|
|
557
|
+
const owner = new LocalAccountOwner(credentials)
|
|
558
|
+
const claimed = new Set<string>()
|
|
559
|
+
let renewal: Promise<void> | undefined
|
|
560
|
+
let accountTimer: ReturnType<typeof setInterval> | undefined
|
|
561
|
+
const renewAccounts = async (authority: { repo: string; run: string }) => {
|
|
562
|
+
if (opts.repository || !Object.values(accounts).some((a) => a.kind === 'chatgpt-subscription'))
|
|
563
|
+
return
|
|
564
|
+
if (!accountTimer) {
|
|
565
|
+
accountTimer = setInterval(() => {
|
|
566
|
+
void (async () => {
|
|
567
|
+
const held = await opened.store.getRepo(authority.repo)
|
|
568
|
+
if (
|
|
569
|
+
held?.lease?.holder !== authority.run ||
|
|
570
|
+
Date.parse(held.lease.expiresAt) <= Date.now()
|
|
571
|
+
) {
|
|
572
|
+
await releaseAccounts()
|
|
573
|
+
return
|
|
574
|
+
}
|
|
575
|
+
await renewAccounts(authority)
|
|
576
|
+
})().catch(() => {})
|
|
577
|
+
}, 15000)
|
|
578
|
+
accountTimer.unref()
|
|
579
|
+
}
|
|
580
|
+
if (renewal) return renewal
|
|
581
|
+
renewal = renewLocalAccounts(owner, accounts, opts.env, claimed).finally(() => {
|
|
582
|
+
renewal = undefined
|
|
583
|
+
})
|
|
584
|
+
return renewal
|
|
585
|
+
}
|
|
586
|
+
const releaseAccounts = async () => {
|
|
587
|
+
if (accountTimer) clearInterval(accountTimer)
|
|
588
|
+
accountTimer = undefined
|
|
589
|
+
await renewal
|
|
590
|
+
for (const name of claimed) owner.release(name)
|
|
591
|
+
claimed.clear()
|
|
592
|
+
}
|
|
593
|
+
opened.store = redactAccountStore(
|
|
594
|
+
opened.store,
|
|
595
|
+
accountRedactor(() => accounts, opts.env),
|
|
596
|
+
)
|
|
539
597
|
let runtimeReferences = effectiveRuntimeReferences(config)
|
|
540
598
|
// A local override relocates the whole tree. Remote stores still need local
|
|
541
599
|
// scratch beneath the repository default. Plugin factories receive only
|
|
@@ -549,6 +607,7 @@ async function defaultWire(
|
|
|
549
607
|
env: opts.env,
|
|
550
608
|
storeRef: opened.storeRef,
|
|
551
609
|
runtimeReferences: () => runtimeReferences,
|
|
610
|
+
accounts: () => accounts,
|
|
552
611
|
sandboxSetupCommand: config.commands.setup,
|
|
553
612
|
sandboxRoot: resolve(join(opened.localStateRoot, 'orchestrator-sandboxes')),
|
|
554
613
|
sandboxEnvironmentVariables: config.orchestrator.sandbox.environmentVariables,
|
|
@@ -571,6 +630,8 @@ async function defaultWire(
|
|
|
571
630
|
|
|
572
631
|
return {
|
|
573
632
|
store: opened.store,
|
|
633
|
+
renewAccounts,
|
|
634
|
+
releaseAccounts,
|
|
574
635
|
tickets,
|
|
575
636
|
forge,
|
|
576
637
|
workspaces: workspaceRuntime.provider,
|
|
@@ -586,6 +647,7 @@ async function defaultWire(
|
|
|
586
647
|
clock: systemClock,
|
|
587
648
|
plugins,
|
|
588
649
|
updateRuntimeReferences: (effectiveConfig) => {
|
|
650
|
+
accounts = effectiveConfig.accounts
|
|
589
651
|
runtimeReferences = effectiveRuntimeReferences(effectiveConfig)
|
|
590
652
|
},
|
|
591
653
|
}
|
|
@@ -810,6 +872,7 @@ class DispatchLoop {
|
|
|
810
872
|
signal,
|
|
811
873
|
...(resolvedSlug.model !== undefined ? { model: resolvedSlug.model } : {}),
|
|
812
874
|
args: resolvedSlug.args,
|
|
875
|
+
account: resolvedSlug.account,
|
|
813
876
|
})
|
|
814
877
|
return result.text
|
|
815
878
|
}
|
|
@@ -1149,6 +1212,7 @@ class DispatchLoop {
|
|
|
1149
1212
|
return this.serialize(async () => {
|
|
1150
1213
|
// Refresh before every watch decision. The owner publishes atomically;
|
|
1151
1214
|
// everything below captures the resulting one snapshot for this tick.
|
|
1215
|
+
await this.flushPendingTickFailure()
|
|
1152
1216
|
await this.refreshConfig()
|
|
1153
1217
|
if (await this.acceptUpgradeYield()) return emptyTickReport()
|
|
1154
1218
|
// Every tick verifies local lease currency, reclaiming when necessary. Without it,
|
|
@@ -1169,31 +1233,25 @@ class DispatchLoop {
|
|
|
1169
1233
|
}
|
|
1170
1234
|
this.tickStartedAt = startedAt
|
|
1171
1235
|
|
|
1172
|
-
//
|
|
1173
|
-
//
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
// writes nothing. Any other failed sample must neither fail dispatch nor
|
|
1177
|
-
// replace the last complete measurement with a fabricated zero.
|
|
1236
|
+
// Refresh inside the serialized tick so claims and the display both see
|
|
1237
|
+
// the latest repository facts. Shared refresh failures still fail the tick.
|
|
1238
|
+
await this.repoView.refresh()
|
|
1239
|
+
const digests = await this.repoView.getRepoBuildDigests(this.repoIdentity)
|
|
1178
1240
|
if (this.dashboard) {
|
|
1179
1241
|
try {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1242
|
+
// Display-only sampling reuses the refreshed inputs without backing
|
|
1243
|
+
// reads. Publish only a complete measurement; retain it on failure.
|
|
1244
|
+
const count = unclaimedObservationCount({
|
|
1245
|
+
digests,
|
|
1246
|
+
harvestEvents: this.repoView.repositoryFacts().harvest,
|
|
1247
|
+
})
|
|
1248
|
+
this.observationCount = count
|
|
1184
1249
|
} catch {
|
|
1185
|
-
//
|
|
1186
|
-
// retry on the next tick; they are not dashboard failures.
|
|
1250
|
+
// Retry on the next tick without fabricating a zero.
|
|
1187
1251
|
}
|
|
1188
1252
|
}
|
|
1189
|
-
|
|
1190
|
-
// Sample inside the serialized tick, not at process startup. Every
|
|
1191
|
-
// dispatcher therefore gates claims from the latest repository facts.
|
|
1192
|
-
await this.repoView.refresh()
|
|
1193
1253
|
const executionSlugs = new Set(
|
|
1194
|
-
[...(
|
|
1195
|
-
.filter(([, digest]) => digest.executionOpen)
|
|
1196
|
-
.map(([slug]) => slug),
|
|
1254
|
+
[...digests].filter(([, digest]) => digest.executionOpen).map(([slug]) => slug),
|
|
1197
1255
|
)
|
|
1198
1256
|
await authorizeRemoteHandoffs(
|
|
1199
1257
|
this.wiring.store,
|
|
@@ -1206,10 +1264,12 @@ class DispatchLoop {
|
|
|
1206
1264
|
settings.intake || (!this.dashboard && this.opts.kernelRunId === undefined)
|
|
1207
1265
|
? undefined
|
|
1208
1266
|
: await this.dispatcher.observeReady({ viewRefreshed: true })
|
|
1267
|
+
await this.wiring.renewAccounts?.({ repo: this.repoIdentity, run: this.runId })
|
|
1209
1268
|
const report = await this.dispatcher.tick({
|
|
1210
1269
|
resumeCurrent,
|
|
1211
1270
|
viewRefreshed: true,
|
|
1212
1271
|
acceptNewWork: settings.intake,
|
|
1272
|
+
observationOnly: this.opts.env.AB_PROJECT_SECRETS_FAILED === '1',
|
|
1213
1273
|
defaultAutoMerge: settings.defaultAutoMerge,
|
|
1214
1274
|
autoMergeUser: buildControlUser(this.opts.env),
|
|
1215
1275
|
// Invocation bound forwarded into the tick: per-item loops inside the
|
|
@@ -3012,6 +3072,50 @@ class DispatchLoop {
|
|
|
3012
3072
|
}
|
|
3013
3073
|
}
|
|
3014
3074
|
|
|
3075
|
+
private pendingTickFailure:
|
|
3076
|
+
| { original: string; first: string; last: string; count: number }
|
|
3077
|
+
| undefined
|
|
3078
|
+
|
|
3079
|
+
/** Reporting is diagnostic: its failure must never replace the operational error. */
|
|
3080
|
+
private async reportTickFailure(error: unknown): Promise<void> {
|
|
3081
|
+
const original = formatDispatcherError(error)
|
|
3082
|
+
this.warn(`tick failed: ${original}`)
|
|
3083
|
+
try {
|
|
3084
|
+
await this.publishTickFailure(error)
|
|
3085
|
+
} catch (publicationError) {
|
|
3086
|
+
const now = this.wiring.clock().toISOString()
|
|
3087
|
+
if (this.pendingTickFailure) {
|
|
3088
|
+
this.pendingTickFailure.last = now
|
|
3089
|
+
this.pendingTickFailure.count++
|
|
3090
|
+
} else {
|
|
3091
|
+
this.pendingTickFailure = { original, first: now, last: now, count: 1 }
|
|
3092
|
+
}
|
|
3093
|
+
// Never reuse an old boundary to close a later tick (or a peer's tick).
|
|
3094
|
+
this.tickStartedAt = undefined
|
|
3095
|
+
this.warn(`tick failure unreported: ${formatDispatcherError(publicationError)}`)
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
private async flushPendingTickFailure(): Promise<void> {
|
|
3100
|
+
const pending = this.pendingTickFailure
|
|
3101
|
+
if (!pending) return
|
|
3102
|
+
try {
|
|
3103
|
+
await this.wiring.store.appendRepo(this.repoIdentity, {
|
|
3104
|
+
actor: DISPATCHER,
|
|
3105
|
+
type: 'dispatcher.tick-failed',
|
|
3106
|
+
payload: {
|
|
3107
|
+
run: this.runId,
|
|
3108
|
+
error:
|
|
3109
|
+
`Unreported tick failure window ${pending.first} through ${pending.last} ` +
|
|
3110
|
+
`(${pending.count} failures); original tick error: ${pending.original}`,
|
|
3111
|
+
},
|
|
3112
|
+
})
|
|
3113
|
+
this.pendingTickFailure = undefined
|
|
3114
|
+
} catch (error) {
|
|
3115
|
+
this.warn(`tick failure window still unreported: ${formatDispatcherError(error)}`)
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3015
3119
|
private async publishTickFailure(error: unknown): Promise<void> {
|
|
3016
3120
|
const failed = {
|
|
3017
3121
|
actor: DISPATCHER,
|
|
@@ -3080,6 +3184,7 @@ class DispatchLoop {
|
|
|
3080
3184
|
publication: this.wiring.workspaces.publication,
|
|
3081
3185
|
forge: this.wiring.forge,
|
|
3082
3186
|
workspacePath: this.opts.targetRepo,
|
|
3187
|
+
checkoutless: this.opts.repository !== undefined,
|
|
3083
3188
|
exec: this.opts.exec,
|
|
3084
3189
|
ids: this.wiring.ids,
|
|
3085
3190
|
runId: this.runId,
|
|
@@ -4184,6 +4289,7 @@ class DispatchLoop {
|
|
|
4184
4289
|
cacheId: request.cacheId,
|
|
4185
4290
|
target: request.target,
|
|
4186
4291
|
}
|
|
4292
|
+
await this.wiring.releaseAccounts?.()
|
|
4187
4293
|
let acceptanceError: unknown
|
|
4188
4294
|
try {
|
|
4189
4295
|
await this.repoView.appendRepo(this.repoIdentity, {
|
|
@@ -4364,6 +4470,7 @@ class DispatchLoop {
|
|
|
4364
4470
|
this.wiring.runtimes,
|
|
4365
4471
|
config.roles,
|
|
4366
4472
|
config.policy.sessionBudgetSeconds,
|
|
4473
|
+
config.accounts,
|
|
4367
4474
|
)
|
|
4368
4475
|
const deadline = new Date(
|
|
4369
4476
|
Date.parse(retirement.startedAt) + config.policy.upgradeDrainSeconds * 1000,
|
|
@@ -4577,7 +4684,7 @@ class DispatchLoop {
|
|
|
4577
4684
|
// invocation.
|
|
4578
4685
|
if (this.pastDeadline()) return
|
|
4579
4686
|
const initial = await this.dispatcherTick(true).catch(async (error: unknown) => {
|
|
4580
|
-
await this.
|
|
4687
|
+
await this.reportTickFailure(error)
|
|
4581
4688
|
throw error
|
|
4582
4689
|
})
|
|
4583
4690
|
const initialPrinted = this.printReport(initial, false)
|
|
@@ -4620,18 +4727,18 @@ class DispatchLoop {
|
|
|
4620
4727
|
this.startUpgradeChecks()
|
|
4621
4728
|
let startup = true
|
|
4622
4729
|
while (!this.watchStopped && !this.superseded) {
|
|
4730
|
+
let failed = false
|
|
4623
4731
|
try {
|
|
4624
4732
|
const report = await this.dispatcherTick(startup)
|
|
4625
4733
|
this.printReport(report, this.harvestInFlight === undefined)
|
|
4626
4734
|
startup = false
|
|
4627
4735
|
} catch (error) {
|
|
4628
4736
|
if (this.forgePublicationFailed) throw error
|
|
4629
|
-
|
|
4630
|
-
await this.
|
|
4631
|
-
this.warn(`tick failed: ${message}`)
|
|
4737
|
+
failed = true
|
|
4738
|
+
await this.reportTickFailure(error)
|
|
4632
4739
|
}
|
|
4633
4740
|
if (this.watchStopped || this.superseded) break
|
|
4634
|
-
await sleep(intervalMs)
|
|
4741
|
+
await sleep(failed || this.pendingTickFailure ? Math.max(intervalMs, 1000) : intervalMs)
|
|
4635
4742
|
}
|
|
4636
4743
|
if (this.superseded) {
|
|
4637
4744
|
this.warn('dispatcher superseded by another invocation — detaching')
|
|
@@ -5149,6 +5256,7 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
|
|
|
5149
5256
|
// view; leave the reduced state behind so the next cold process reads
|
|
5150
5257
|
// only what is newer than it.
|
|
5151
5258
|
|
|
5259
|
+
await wiring.releaseAccounts?.()
|
|
5152
5260
|
if (resolvedOpts.wire === undefined) await wiring.store.close()
|
|
5153
5261
|
}
|
|
5154
5262
|
}
|
|
@@ -42,6 +42,7 @@ export class StandbyIdentityResolver {
|
|
|
42
42
|
private readonly store: BuildStore,
|
|
43
43
|
private readonly repo: string,
|
|
44
44
|
private readonly history?: {
|
|
45
|
+
selectHolder?: (holder: string | undefined) => void
|
|
45
46
|
allowLookup: () => boolean
|
|
46
47
|
remember: (events: RepositoryEvent[], complete: boolean) => void
|
|
47
48
|
},
|
|
@@ -64,7 +65,7 @@ export class StandbyIdentityResolver {
|
|
|
64
65
|
const facts = (await readDispatcherRunFacts(this.store, this.repo, holder)).value
|
|
65
66
|
this.ingest(facts.start ? [facts.start] : [])
|
|
66
67
|
const complete = false // This lookup correlates one holder, not the complete journal.
|
|
67
|
-
this.history?.remember([
|
|
68
|
+
this.history?.remember(facts.start ? [facts.start] : [], complete)
|
|
68
69
|
} catch {
|
|
69
70
|
// Identity is best effort; the sampled holder id remains sufficient.
|
|
70
71
|
}
|
|
@@ -90,8 +91,12 @@ export class StandbyIdentityResolver {
|
|
|
90
91
|
return yieldedHolder
|
|
91
92
|
}
|
|
92
93
|
this.failed = false
|
|
94
|
+
const previousHolder = this.record?.lease?.holder
|
|
93
95
|
this.record = record
|
|
94
96
|
const holder = record?.lease?.holder
|
|
97
|
+
this.history?.selectHolder?.(holder)
|
|
98
|
+
const start = holder === undefined ? undefined : this.starts.get(holder)
|
|
99
|
+
if (start && previousHolder !== holder) this.history?.remember([start], false)
|
|
95
100
|
if (holder !== undefined && holder !== run) await this.correlate(holder)
|
|
96
101
|
return this.current(run, yieldedHolder, now)
|
|
97
102
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { clearForgeDegradation } from '../operator/control'
|
|
2
|
+
import { buildControlUser } from './build-control'
|
|
3
|
+
import { withSessionlessStore, type SessionlessStoreOpts } from './store-opening'
|
|
4
|
+
|
|
5
|
+
export async function abForgeClear(
|
|
6
|
+
opts: SessionlessStoreOpts & {
|
|
7
|
+
forge: string
|
|
8
|
+
reason: string
|
|
9
|
+
json?: boolean
|
|
10
|
+
stdout: (line: string) => void
|
|
11
|
+
},
|
|
12
|
+
): Promise<void> {
|
|
13
|
+
if (['AB_BUILD', 'AB_SESSION', 'AB_HARVEST'].some((name) => opts.env[name]?.trim()))
|
|
14
|
+
throw new Error(
|
|
15
|
+
'repository forge-clear requires an operator outside a build or harvest session',
|
|
16
|
+
)
|
|
17
|
+
if (!opts.forge.trim() || !opts.reason.trim()) throw new Error('forge and reason are required')
|
|
18
|
+
await withSessionlessStore(opts, async ({ store, repo }) => {
|
|
19
|
+
const result = await clearForgeDegradation({
|
|
20
|
+
store,
|
|
21
|
+
repo,
|
|
22
|
+
user: buildControlUser(opts.env),
|
|
23
|
+
forge: opts.forge,
|
|
24
|
+
reason: opts.reason,
|
|
25
|
+
})
|
|
26
|
+
opts.stdout(
|
|
27
|
+
opts.json ? JSON.stringify(result) : `Cleared forge ${opts.forge} degradation for ${repo}`,
|
|
28
|
+
)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
@@ -71,6 +71,22 @@ export const HELP_CATALOG: readonly HelpEntry[] = [
|
|
|
71
71
|
'locally. --validate cannot be combined with --force.',
|
|
72
72
|
]),
|
|
73
73
|
},
|
|
74
|
+
{
|
|
75
|
+
name: 'accounts',
|
|
76
|
+
summary: 'Sign in with ChatGPT for a Codex billing account',
|
|
77
|
+
audience: 'human',
|
|
78
|
+
detail: page([
|
|
79
|
+
'Usage: ab accounts login NAME [--local|--project]',
|
|
80
|
+
'Runs outside sessions. Local stores protected repository credentials for the dispatcher. Project transfers credentials to the connected refreshing secret and retains none locally. The browser completes OpenAI authorization; tokens are never printed.',
|
|
81
|
+
]),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'secrets',
|
|
85
|
+
summary: 'Manage write-only secrets for a connected project',
|
|
86
|
+
audience: 'human',
|
|
87
|
+
detail:
|
|
88
|
+
'Usage: ab secrets list [--json] | ab secrets set NAME | ab secrets remove NAME. Uses the saved owner credential from ab connect. Set reads hidden terminal input or redirected stdin; values are never returned. List reports owner, set time, fingerprint, status and last supply time. Runs outside sessions.',
|
|
89
|
+
},
|
|
74
90
|
{
|
|
75
91
|
name: 'connect',
|
|
76
92
|
audience: 'human',
|
|
@@ -247,6 +263,7 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
247
263
|
detail: page([
|
|
248
264
|
'Usage:',
|
|
249
265
|
' ab repository status [--json] [--store <ref>]',
|
|
266
|
+
' ab repository forge-clear --forge <name> --reason <text> [--json] [--store <ref>]',
|
|
250
267
|
'',
|
|
251
268
|
'Report the durable ticket-intake setting and repository-wide pause from',
|
|
252
269
|
'the same journal projection used by dispatch and the dashboard.',
|
|
@@ -17,6 +17,21 @@ export async function validateRemoteReadiness(
|
|
|
17
17
|
ctx: WorkspaceReadinessContext,
|
|
18
18
|
): Promise<InitValidationReport> {
|
|
19
19
|
const vercel = ctx.providerConfig as VercelSandboxConfig
|
|
20
|
+
const hostChecks = Object.entries(ctx.accounts ?? {}).map(([name, descriptor]) => ({
|
|
21
|
+
name: `host account ${JSON.stringify(name)}`,
|
|
22
|
+
status: ctx.env[descriptor.credentialEnv] ? ('pass' as const) : ('fail' as const),
|
|
23
|
+
detail: ctx.env[descriptor.credentialEnv]
|
|
24
|
+
? `${descriptor.credentialEnv} is present`
|
|
25
|
+
: `${descriptor.credentialEnv} is missing; ${descriptor.kind === 'claude-subscription' ? 'run claude setup-token and set the dispatcher variable' : 'provision the Kimi membership key'}`,
|
|
26
|
+
}))
|
|
27
|
+
if (hostChecks.some((check) => check.status === 'fail'))
|
|
28
|
+
return {
|
|
29
|
+
provider: 'vercel-sandbox',
|
|
30
|
+
context: 'Vercel Sandbox',
|
|
31
|
+
checks: hostChecks,
|
|
32
|
+
exitCode: 1,
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
const remoteLine = await gitText(
|
|
21
36
|
ctx.exec,
|
|
22
37
|
ctx.repo,
|
|
@@ -69,6 +84,7 @@ export async function validateRemoteReadiness(
|
|
|
69
84
|
exec: ctx.exec,
|
|
70
85
|
...(ctx.packageArchive !== undefined ? { packageArchive: ctx.packageArchive } : {}),
|
|
71
86
|
runtimeReferences: [...ctx.runtimeReferences],
|
|
87
|
+
accounts: ctx.accounts,
|
|
72
88
|
...(ctx.signal !== undefined ? { signal: ctx.signal } : {}),
|
|
73
89
|
onSandbox: (name) => ctx.stdout(`Disposable Vercel Sandbox: ${name} (active)`),
|
|
74
90
|
})
|
|
@@ -103,8 +119,13 @@ export async function validateRemoteReadiness(
|
|
|
103
119
|
? 'no workspace.config.provisioning steps declared'
|
|
104
120
|
: `completed: ${remote.provisioning.join(', ')}`,
|
|
105
121
|
},
|
|
122
|
+
...hostChecks,
|
|
106
123
|
...guest.checks,
|
|
107
124
|
],
|
|
108
|
-
exitCode:
|
|
125
|
+
exitCode:
|
|
126
|
+
guest.checks.some((check) => check.status === 'fail') ||
|
|
127
|
+
Object.values(ctx.accounts ?? {}).some((account) => !ctx.env[account.credentialEnv])
|
|
128
|
+
? 1
|
|
129
|
+
: 0,
|
|
109
130
|
}
|
|
110
131
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sensitiveAccountValues } from '../accounts/sensitive'
|
|
1
2
|
/**
|
|
2
3
|
* Readiness-probe helpers shared by the local-worktree and remote validation
|
|
3
4
|
* paths (AUT-516). Moved out of `cli/init-validation.ts` so the remote
|
|
@@ -39,7 +40,10 @@ export function createReadinessRedactor(
|
|
|
39
40
|
].sort((left, right) => right.length - left.length)
|
|
40
41
|
return (value) => {
|
|
41
42
|
let text = message(value)
|
|
42
|
-
for (const secret of secrets
|
|
43
|
+
for (const secret of [...sensitiveAccountValues, ...secrets].sort(
|
|
44
|
+
(a, b) => b.length - a.length,
|
|
45
|
+
))
|
|
46
|
+
text = text.split(secret).join('[REDACTED]')
|
|
43
47
|
return text
|
|
44
48
|
}
|
|
45
49
|
}
|