@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,13 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
operatorPresenceBodySchema,
|
|
3
|
+
operatorPresenceWireSchema,
|
|
4
|
+
operatorPresenceListSchema,
|
|
5
|
+
} from './protocol'
|
|
6
|
+
import {
|
|
7
|
+
operatorIdentitySchema,
|
|
8
|
+
type OperatorIdentity,
|
|
9
|
+
type OperatorPresence,
|
|
10
|
+
} from '../operator-presence'
|
|
11
|
+
import {
|
|
12
|
+
ReducerValueIncompatibilityError,
|
|
2
13
|
clientIdentityError,
|
|
3
14
|
classifyClient,
|
|
4
15
|
releaseVersion,
|
|
5
16
|
supportedClientRangeSchema,
|
|
6
17
|
} from './compatibility'
|
|
7
18
|
import { stampCompatibility, buildEventPolicy, repositoryEventPolicy } from '../../events/policy'
|
|
8
|
-
import { READ_CATALOG_IDENTITY
|
|
19
|
+
import { READ_CATALOG_IDENTITY } from '../../events/compatibility'
|
|
9
20
|
import { CATALOG_IDENTITY_HEADER } from './version'
|
|
10
|
-
import {
|
|
21
|
+
import { diagnoseReducerValue } from '../reducer-value-validation'
|
|
11
22
|
import { prepareEventWrite as validateEventWrite } from '../../events/catalog'
|
|
12
23
|
import { prepareRepositoryEventWrite as validateRepositoryEventWrite } from '../../events/repository'
|
|
13
24
|
import {
|
|
@@ -185,9 +196,6 @@ export interface RemoteBuildStoreOptions {
|
|
|
185
196
|
export class RemoteBuildStore implements BuildStore {
|
|
186
197
|
readonly catalogIdentity = READ_CATALOG_IDENTITY
|
|
187
198
|
readonly networkReads = true
|
|
188
|
-
// Reader-local accumulators for this client instance. Never publish these into the service's
|
|
189
|
-
// cache: its catalog may interpret the same journal differently.
|
|
190
|
-
private readonly replayStates = new Map<string, { cursor: number; acc: unknown }>()
|
|
191
199
|
private readonly base: string
|
|
192
200
|
private readonly token: string | undefined
|
|
193
201
|
private readonly fetchFn: typeof fetch
|
|
@@ -261,7 +269,7 @@ export class RemoteBuildStore implements BuildStore {
|
|
|
261
269
|
}
|
|
262
270
|
|
|
263
271
|
private async raw(
|
|
264
|
-
method: 'GET' | 'POST' | 'PUT',
|
|
272
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE',
|
|
265
273
|
path: string,
|
|
266
274
|
body?: unknown,
|
|
267
275
|
signal?: AbortSignal,
|
|
@@ -355,10 +363,7 @@ export class RemoteBuildStore implements BuildStore {
|
|
|
355
363
|
const response = await this.raw('GET', `${this.repoPath(repo)}/build-digests`)
|
|
356
364
|
if (!response.ok) throw await this.toError(response)
|
|
357
365
|
const digests = buildDigestListSchema.parse(await response.json())
|
|
358
|
-
|
|
359
|
-
return new Map(digests.map((digest) => [digest.slug, digest]))
|
|
360
|
-
const { readPersistedBuildDigests } = await import('../reduced-reads')
|
|
361
|
-
return readPersistedBuildDigests(this, repo)
|
|
366
|
+
return new Map(digests.map((digest) => [digest.slug, digest]))
|
|
362
367
|
}
|
|
363
368
|
|
|
364
369
|
async append<T extends EventType>(slug: string, event: EventWrite<T>): Promise<EventEnvelope<T>> {
|
|
@@ -619,6 +624,42 @@ export class RemoteBuildStore implements BuildStore {
|
|
|
619
624
|
})
|
|
620
625
|
}
|
|
621
626
|
|
|
627
|
+
async upsertOperatorPresence(
|
|
628
|
+
repo: string,
|
|
629
|
+
identity: OperatorIdentity,
|
|
630
|
+
signal?: AbortSignal,
|
|
631
|
+
): Promise<OperatorPresence> {
|
|
632
|
+
return this.requestJson(
|
|
633
|
+
'POST',
|
|
634
|
+
`${this.repoPath(repo)}/operator-presence`,
|
|
635
|
+
operatorPresenceWireSchema,
|
|
636
|
+
operatorPresenceBodySchema.parse(identity),
|
|
637
|
+
signal ? AbortSignal.any([signal, AbortSignal.timeout(10_000)]) : AbortSignal.timeout(10_000),
|
|
638
|
+
)
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
async removeOperatorPresence(repo: string, id: string, signal?: AbortSignal): Promise<void> {
|
|
642
|
+
id = operatorIdentitySchema.shape.id.parse(id)
|
|
643
|
+
const response = await this.raw(
|
|
644
|
+
'DELETE',
|
|
645
|
+
`${this.repoPath(repo)}/operator-presence/${encodeURIComponent(id)}`,
|
|
646
|
+
undefined,
|
|
647
|
+
signal,
|
|
648
|
+
)
|
|
649
|
+
if (response.status === 404 || response.status === 405) return
|
|
650
|
+
if (!response.ok) throw await this.toError(response)
|
|
651
|
+
const result = okResponseSchema.strict().parse(await response.json())
|
|
652
|
+
if (!result.ok) throw new Error('operator withdrawal was not acknowledged')
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
async listOperatorPresence(repo: string): Promise<OperatorPresence[]> {
|
|
656
|
+
return this.requestJson(
|
|
657
|
+
'GET',
|
|
658
|
+
`${this.repoPath(repo)}/operator-presence`,
|
|
659
|
+
operatorPresenceListSchema,
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
|
|
622
663
|
async ensureRepo(repo: string): Promise<RepositoryRecord> {
|
|
623
664
|
return this.requestJson('POST', '/repos', repositoryRecordWireSchema, { repo })
|
|
624
665
|
}
|
|
@@ -714,49 +755,49 @@ export class RemoteBuildStore implements BuildStore {
|
|
|
714
755
|
}
|
|
715
756
|
|
|
716
757
|
async getReducerValue(scope: SnapshotScope, request: ReducerValueRequest): Promise<ReducerValue> {
|
|
717
|
-
const { reducer
|
|
758
|
+
const { reducer } = resolveReducerValue(scope, request)
|
|
718
759
|
const root = scope.kind === 'build' ? this.buildPath(scope.slug) : this.repoPath(scope.repo)
|
|
719
760
|
const response = await this.raw('POST', `${root}/reducer-values`, request)
|
|
720
761
|
if (!response.ok) throw await this.toError(response)
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
}
|
|
734
|
-
// Freeze at this response's cursor, including when concurrent reads finish
|
|
735
|
-
// out of order. Clone before folding: reducers may mutate their accumulator.
|
|
736
|
-
const cached = this.replayStates.get(replayIdentity)
|
|
737
|
-
const reusable = cached !== undefined && cached.cursor <= result.cursor ? cached : undefined
|
|
738
|
-
let cursor = reusable?.cursor ?? 0
|
|
739
|
-
let acc = reusable === undefined ? reducer.initial() : structuredClone(reusable.acc)
|
|
740
|
-
if (cursor < result.cursor) {
|
|
741
|
-
const events =
|
|
742
|
-
scope.kind === 'build'
|
|
743
|
-
? await this.getEvents(scope.slug, cursor)
|
|
744
|
-
: await this.getRepoEvents(scope.repo, cursor)
|
|
745
|
-
const bounded = events.filter((event) => event.seq <= result.cursor)
|
|
746
|
-
for (const event of bounded) {
|
|
747
|
-
if (event.seq !== cursor + 1) throw new Error('noncontiguous reducer log')
|
|
748
|
-
cursor = event.seq
|
|
749
|
-
}
|
|
750
|
-
if (cursor !== result.cursor) throw new Error('incomplete reducer log')
|
|
751
|
-
acc = reducer.advance(acc, entry.adapt(projectStoredEvents(bounded)))
|
|
762
|
+
let body: unknown
|
|
763
|
+
try {
|
|
764
|
+
body = await response.json()
|
|
765
|
+
} catch (error) {
|
|
766
|
+
if (!(error instanceof SyntaxError)) throw error
|
|
767
|
+
throw new ReducerValueIncompatibilityError(
|
|
768
|
+
request.reducer,
|
|
769
|
+
scope,
|
|
770
|
+
reducer.version,
|
|
771
|
+
undefined,
|
|
772
|
+
'invalid reducer envelope: expected JSON',
|
|
773
|
+
)
|
|
752
774
|
}
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
775
|
+
const parsed = reducerValueSchema.safeParse(body)
|
|
776
|
+
const serverVersion =
|
|
777
|
+
body && typeof body === 'object' && 'version' in body && typeof body.version === 'number'
|
|
778
|
+
? body.version
|
|
779
|
+
: undefined
|
|
780
|
+
const fail = (reason: string): never => {
|
|
781
|
+
throw new ReducerValueIncompatibilityError(
|
|
782
|
+
request.reducer,
|
|
783
|
+
scope,
|
|
784
|
+
reducer.version,
|
|
785
|
+
serverVersion,
|
|
786
|
+
reason,
|
|
787
|
+
)
|
|
788
|
+
}
|
|
789
|
+
if (!parsed.success) fail(`invalid reducer envelope: ${parsed.error.message}`)
|
|
790
|
+
const result = parsed.data!
|
|
791
|
+
if (result.version !== reducer.version) fail('reducer version mismatch')
|
|
792
|
+
const failure = diagnoseReducerValue(request.reducer, result.value)
|
|
793
|
+
if (failure) fail(`invalid finished value at ${failure.path}: expected ${failure.expected}`)
|
|
794
|
+
const identity = response.headers.get(CATALOG_IDENTITY_HEADER)
|
|
795
|
+
return {
|
|
796
|
+
version: result.version,
|
|
797
|
+
cursor: result.cursor,
|
|
798
|
+
value: result.value as ReducerValue['value'],
|
|
799
|
+
...(identity === null ? {} : { catalogIdentity: identity }),
|
|
758
800
|
}
|
|
759
|
-
return { version: reducer.version, cursor, value, catalogIdentity: READ_CATALOG_IDENTITY }
|
|
760
801
|
}
|
|
761
802
|
|
|
762
803
|
private snapshotPath(scope: SnapshotScope, reducer: string): string {
|
|
@@ -78,6 +78,10 @@ export function compatibilityAdvice(
|
|
|
78
78
|
* Historical lines require explicit entries; the service's own line uses its
|
|
79
79
|
* current protocol identity. Unknown historical protocols fail closed. */
|
|
80
80
|
export const RELEASE_LINE_PROTOCOLS: Readonly<Record<string, string>> = {
|
|
81
|
+
// v1.0.x shipped protocol 4; protocol 5+ requires the next minor line.
|
|
82
|
+
'1.0': '4',
|
|
83
|
+
// v1.1.x shipped protocol 6; retain it when this line becomes historical.
|
|
84
|
+
'1.1': '6',
|
|
81
85
|
'0.9': '3',
|
|
82
86
|
'0.10': '3',
|
|
83
87
|
'0.11': '3',
|
|
@@ -106,3 +110,19 @@ export function clientIdentityError(
|
|
|
106
110
|
if (!advice && expected !== undefined && protocol === expected) return undefined
|
|
107
111
|
return `remote store version mismatch: client Autobuild ${client ?? '(missing)'} protocol ${protocol ?? '(missing)'}; server Autobuild ${serviceVersion} protocol ${serviceProtocol}; ${advice ?? `supported clients ${formatClientRange(range)}; unsupported protocol identity`}`
|
|
108
112
|
}
|
|
113
|
+
|
|
114
|
+
/** A successful server answer cannot be represented by this client's reducer. */
|
|
115
|
+
export class ReducerValueIncompatibilityError extends Error {
|
|
116
|
+
override readonly name = 'ReducerValueIncompatibilityError'
|
|
117
|
+
constructor(
|
|
118
|
+
readonly reducer: string,
|
|
119
|
+
readonly scope: import('../snapshots').SnapshotScope,
|
|
120
|
+
readonly clientVersion: number,
|
|
121
|
+
readonly serverVersion: number | undefined,
|
|
122
|
+
readonly reason: string,
|
|
123
|
+
) {
|
|
124
|
+
super(
|
|
125
|
+
`incompatible reducer ${reducer}: client version ${clientVersion}, server version ${serverVersion ?? '(unavailable)'}; ${reason}`,
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { operatorIdentitySchema, operatorPresenceSchema } from '../operator-presence'
|
|
2
|
+
export const operatorPresenceBodySchema = operatorIdentitySchema
|
|
3
|
+
export const operatorPresenceWireSchema = operatorPresenceSchema
|
|
4
|
+
export const operatorPresenceListSchema = operatorPresenceSchema.array()
|
|
1
5
|
import { compatibilityMetadataSchema } from '../../events/policy'
|
|
2
6
|
/**
|
|
3
7
|
* The wire protocol of the remote BuildStore (SPEC §7.2 adapter 2): JSON
|
|
@@ -4,13 +4,15 @@ import manifest from '../../../../../package.json'
|
|
|
4
4
|
export const AUTOBUILD_VERSION = manifest.version
|
|
5
5
|
|
|
6
6
|
/** Wire compatibility version for the remote BuildStore protocol.
|
|
7
|
+
* Version 6: adds operator presence withdrawal (next minor line).
|
|
8
|
+
* Version 5: adds mutable advisory operator presence operations.
|
|
7
9
|
* Version 4: adds required fenced begin/finish tick operations and bounded
|
|
8
10
|
* repository tick telemetry.
|
|
9
11
|
* Version 3 (AUT-521): the build-digest wire shape gains per-occurrence
|
|
10
12
|
* observation timestamps and the `merged` fact — a breaking shape change,
|
|
11
13
|
* so stale peers are rejected at handshake instead of failing mid-request
|
|
12
14
|
* at schema parse. */
|
|
13
|
-
export const REMOTE_STORE_PROTOCOL_VERSION = '
|
|
15
|
+
export const REMOTE_STORE_PROTOCOL_VERSION = '6'
|
|
14
16
|
|
|
15
17
|
export const AUTOBUILD_VERSION_HEADER = 'x-autobuild-version'
|
|
16
18
|
export const REMOTE_STORE_PROTOCOL_VERSION_HEADER = 'x-autobuild-protocol-version'
|
|
@@ -39,9 +39,8 @@
|
|
|
39
39
|
export const OPERATOR_NOTES_REPO_KIND = 'operator-notes'
|
|
40
40
|
|
|
41
41
|
/** The repository artifact carrying the schema-validated composed Config one
|
|
42
|
-
* dispatch run used.
|
|
43
|
-
*
|
|
44
|
-
* (AUT-342). Defined here — the store must not import from the CLI — and
|
|
42
|
+
* dispatch run used. Hosted external operator tools and archive cleanup resolve
|
|
43
|
+
* their sandbox gate from the latest revision of this kind. Defined here — the store must not import from the CLI — and
|
|
45
44
|
* re-exported by `cli/dispatch.ts`, which deposits it. */
|
|
46
45
|
export const DISPATCHER_EFFECTIVE_CONFIG_ARTIFACT = 'dispatcher-effective-config'
|
|
47
46
|
|
|
@@ -103,6 +103,15 @@ export function createSessionScopedStore(store: BuildStore, scope: string): Sess
|
|
|
103
103
|
listBuildsForRepo(repo: string): Promise<BuildRecord[]> {
|
|
104
104
|
return Promise.reject(new SessionScopeError(scope, 'listBuildsForRepo', repo))
|
|
105
105
|
},
|
|
106
|
+
async upsertOperatorPresence(): Promise<never> {
|
|
107
|
+
throw new SessionScopeError(scope, 'upsertOperatorPresence')
|
|
108
|
+
},
|
|
109
|
+
async removeOperatorPresence(): Promise<never> {
|
|
110
|
+
throw new SessionScopeError(scope, 'removeOperatorPresence')
|
|
111
|
+
},
|
|
112
|
+
async listOperatorPresence(): Promise<never> {
|
|
113
|
+
throw new SessionScopeError(scope, 'listOperatorPresence')
|
|
114
|
+
},
|
|
106
115
|
getRepoChangePosition(repo: string): Promise<string> {
|
|
107
116
|
return Promise.reject(new SessionScopeError(scope, 'getRepoChangePosition', repo))
|
|
108
117
|
},
|
|
@@ -54,7 +54,7 @@ export interface SessionStreamSinkOptions {
|
|
|
54
54
|
/** The sink's concrete surface. Structurally a superset of the
|
|
55
55
|
* `SessionStreamSink` port (ports/types.ts): `open` keeps its port-declared
|
|
56
56
|
* shape for the build-runner's `openSessionStreamLabel` caller, while the
|
|
57
|
-
*
|
|
57
|
+
* historical turn persistence additionally supported `resume` (bind to an
|
|
58
58
|
* already-open stream — a resumed invocation must append to the turn's
|
|
59
59
|
* existing stream, never create a second one) and `flush` (await the drain,
|
|
60
60
|
* so a step-boundary checkpoint is durable before the next step starts). */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { OperatorIdentity, OperatorPresence } from './operator-presence'
|
|
2
|
+
export type { OperatorIdentity, OperatorPresence } from './operator-presence'
|
|
1
3
|
import type { ReducerValueRequest, ReducerValue } from './reducer-values'
|
|
2
4
|
/**
|
|
3
5
|
* The BuildStore seam (SPEC §7): the durable home of everything a build
|
|
@@ -421,6 +423,14 @@ export interface BuildStore {
|
|
|
421
423
|
// Kept alongside, not inside, build streams: repository state is not a build.
|
|
422
424
|
ensureRepo(repo: string): Promise<RepositoryRecord>
|
|
423
425
|
getRepo(repo: string): Promise<RepositoryRecord | null>
|
|
426
|
+
/** Mutable advisory liveness. No event, lease or repository creation. */
|
|
427
|
+
upsertOperatorPresence(
|
|
428
|
+
repo: string,
|
|
429
|
+
identity: OperatorIdentity,
|
|
430
|
+
signal?: AbortSignal,
|
|
431
|
+
): Promise<OperatorPresence>
|
|
432
|
+
removeOperatorPresence(repo: string, id: string, signal?: AbortSignal): Promise<void>
|
|
433
|
+
listOperatorPresence(repo: string): Promise<OperatorPresence[]>
|
|
424
434
|
appendRepo<T extends RepositoryEventType>(
|
|
425
435
|
repo: string,
|
|
426
436
|
event: RepositoryEventWrite<T>,
|
|
@@ -691,8 +701,8 @@ export interface BuildScopedStore extends BuildStore {
|
|
|
691
701
|
/** A BuildStore constrained to one operator session. `sessionScope` is
|
|
692
702
|
* immutable; the handle may touch only its own session's events, artifacts,
|
|
693
703
|
* and session-scoped streams, and rejects session create/list and every
|
|
694
|
-
* build/repository operation.
|
|
695
|
-
*
|
|
704
|
+
* build/repository operation. The handle confines access to exactly one
|
|
705
|
+
* historical session, mirroring `BuildScopedStore`. */
|
|
696
706
|
export interface SessionScopedStore extends BuildStore {
|
|
697
707
|
readonly sessionScope: string
|
|
698
708
|
scopeSession(id: string): SessionScopedStore
|
|
@@ -229,3 +229,125 @@ export async function dispatchReadBudget(store: BuildStore, backing: BuildStore)
|
|
|
229
229
|
expect(metrics.rows - before.rows).toBe(1)
|
|
230
230
|
expect(metrics.state - before.state).toBe(0)
|
|
231
231
|
}
|
|
232
|
+
|
|
233
|
+
/** Script a minute at both launcher cadences using the real runtime reader and
|
|
234
|
+
* launcher cache. Each helper gets a fresh facade; private reads use that same
|
|
235
|
+
* instrumented receiver rather than escaping into an uncounted reducer. */
|
|
236
|
+
export async function upgradeReadBudget(store: BuildStore): Promise<void> {
|
|
237
|
+
const { readUpgradeProjection } = await import('../cli/dispatch-handoff')
|
|
238
|
+
const { conditionalUpgradeClient } = await import('../cli/dispatch-launch-contract')
|
|
239
|
+
for (const length of [100, 10_000]) {
|
|
240
|
+
const repo = `/upgrade-budget-${length}`
|
|
241
|
+
await store.ensureRepo(repo)
|
|
242
|
+
for (let i = 0; i < length; i++)
|
|
243
|
+
await store.appendRepo(repo, {
|
|
244
|
+
actor: humanActor('budget'),
|
|
245
|
+
type: 'dispatcher.intake-set',
|
|
246
|
+
payload: { enabled: false },
|
|
247
|
+
})
|
|
248
|
+
const metrics = { position: 0, metadata: 0, reducer: 0, events: 0, rows: 0 }
|
|
249
|
+
const launch = {
|
|
250
|
+
version: 1 as const,
|
|
251
|
+
runtimeRoot: '/runtime',
|
|
252
|
+
checkout: repo,
|
|
253
|
+
journal: { repo, storeRef: '/memory' },
|
|
254
|
+
run: 'budget',
|
|
255
|
+
lineage: 'budget',
|
|
256
|
+
}
|
|
257
|
+
const client = conditionalUpgradeClient()
|
|
258
|
+
const check = () =>
|
|
259
|
+
client(repo, (condition) =>
|
|
260
|
+
readUpgradeProjection(
|
|
261
|
+
launch,
|
|
262
|
+
['dispatch'],
|
|
263
|
+
{},
|
|
264
|
+
{
|
|
265
|
+
condition,
|
|
266
|
+
openStore: () =>
|
|
267
|
+
new Proxy(store, {
|
|
268
|
+
get(target, key, receiver) {
|
|
269
|
+
if (key === 'close') return async () => {}
|
|
270
|
+
// Memory reducer storage reads bypass public getRepoEvents. Count
|
|
271
|
+
// the actual sliced rows at that private boundary as well.
|
|
272
|
+
if (key === 'repoState')
|
|
273
|
+
return (...args: unknown[]) => {
|
|
274
|
+
const state = Reflect.get(target, key).apply(receiver, args)
|
|
275
|
+
return new Proxy(state, {
|
|
276
|
+
get(state, field) {
|
|
277
|
+
const value = Reflect.get(state, field)
|
|
278
|
+
if (field !== 'events') return value
|
|
279
|
+
return new Proxy(value, {
|
|
280
|
+
get(events, method) {
|
|
281
|
+
if (method === 'slice')
|
|
282
|
+
return (since: number, through: number) => {
|
|
283
|
+
const rows = events.slice(since, through)
|
|
284
|
+
metrics.events++
|
|
285
|
+
metrics.rows += rows.length
|
|
286
|
+
return rows
|
|
287
|
+
}
|
|
288
|
+
return Reflect.get(events, method)
|
|
289
|
+
},
|
|
290
|
+
})
|
|
291
|
+
},
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
const value = Reflect.get(target, key, receiver)
|
|
295
|
+
if (typeof value !== 'function') return value
|
|
296
|
+
if (typeof key !== 'string' || !key.startsWith('get')) return value.bind(receiver)
|
|
297
|
+
return async (...args: unknown[]) => {
|
|
298
|
+
// The queried run has not started. No candidate means no
|
|
299
|
+
// historical per-run reconstruction, even at bootstrap.
|
|
300
|
+
if (key === 'getReducerValue')
|
|
301
|
+
expect((args[1] as { reducer: string }).reducer).not.toBe(
|
|
302
|
+
'dispatcherRunFacts',
|
|
303
|
+
)
|
|
304
|
+
if (key === 'getRepoChangePosition') metrics.position++
|
|
305
|
+
else if (key === 'getReducerValue' || key === 'getReducerSnapshot')
|
|
306
|
+
metrics.reducer++
|
|
307
|
+
else if (key === 'getRepoEvents' || key === 'getRepoStateEvents')
|
|
308
|
+
metrics.events++
|
|
309
|
+
else if (typeof key === 'string' && key.startsWith('get')) metrics.metadata++
|
|
310
|
+
const result = await value.apply(receiver, args)
|
|
311
|
+
if (
|
|
312
|
+
(key === 'getRepoEvents' || key === 'getRepoStateEvents') &&
|
|
313
|
+
Array.isArray(result)
|
|
314
|
+
)
|
|
315
|
+
metrics.rows += result.length
|
|
316
|
+
return result
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
}),
|
|
320
|
+
},
|
|
321
|
+
),
|
|
322
|
+
)
|
|
323
|
+
// Bootstrap is explicitly measured separately from the idle bound.
|
|
324
|
+
await check()
|
|
325
|
+
expect(metrics.position).toBe(1)
|
|
326
|
+
expect(metrics.metadata).toBeGreaterThan(0)
|
|
327
|
+
expect(metrics.reducer).toBeGreaterThan(0)
|
|
328
|
+
expect(metrics.rows).toBeGreaterThanOrEqual(length)
|
|
329
|
+
for (const interval of [1_000, 250]) {
|
|
330
|
+
for (const key of Object.keys(metrics) as (keyof typeof metrics)[]) metrics[key] = 0
|
|
331
|
+
let now = 0
|
|
332
|
+
while (now < 60_000) {
|
|
333
|
+
await check()
|
|
334
|
+
now += interval
|
|
335
|
+
}
|
|
336
|
+
expect(metrics).toEqual({
|
|
337
|
+
position: 60_000 / interval,
|
|
338
|
+
metadata: 0,
|
|
339
|
+
reducer: 0,
|
|
340
|
+
events: 0,
|
|
341
|
+
rows: 0,
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
await store.appendRepo(repo, {
|
|
345
|
+
actor: humanActor('budget'),
|
|
346
|
+
type: 'dispatcher.intake-set',
|
|
347
|
+
payload: { enabled: true },
|
|
348
|
+
})
|
|
349
|
+
metrics.reducer = 0
|
|
350
|
+
await check()
|
|
351
|
+
expect(metrics.reducer).toBeGreaterThan(0)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
@@ -56,7 +56,7 @@ export {
|
|
|
56
56
|
type Cli,
|
|
57
57
|
type E2eHarness,
|
|
58
58
|
type SkillHandlers,
|
|
59
|
-
} from '../
|
|
59
|
+
} from '../scenarios/harness'
|
|
60
60
|
|
|
61
61
|
// Harvest lifecycle and CLI seams for delegated-credential integration tests.
|
|
62
62
|
export { HarvestRunner } from '../processes/harvest-runner'
|
|
@@ -68,6 +68,7 @@ export { ProjectCredentials } from '../cli/project-credentials'
|
|
|
68
68
|
export { dispatchReadBudget } from './dispatch-read-budget'
|
|
69
69
|
|
|
70
70
|
export {
|
|
71
|
+
catalogSkewReadBudget,
|
|
71
72
|
reducedReadBudget,
|
|
72
73
|
countHistoricalRows,
|
|
73
74
|
type ReducedReadCosts,
|
|
@@ -81,3 +82,13 @@ export { readBuildFacts, readBuildStreamSeed, readRepositoryFacts } from '../sto
|
|
|
81
82
|
export { deferMixedVersion } from '../kernel/mixed-version'
|
|
82
83
|
|
|
83
84
|
export { guardForge } from '../kernel/guarded-forge'
|
|
85
|
+
|
|
86
|
+
// Node verification delivery seam exercised by the hosted authorization suite.
|
|
87
|
+
export { buildContext } from '../cli/context'
|
|
88
|
+
export { scopeLocalStoreToPhaseSession } from '../store/phase-session'
|
|
89
|
+
export {
|
|
90
|
+
prepareNodeVerificationContext,
|
|
91
|
+
NODE_VERIFICATION_CONTEXT,
|
|
92
|
+
} from '../kernel/node-verification-context'
|
|
93
|
+
|
|
94
|
+
export { temporaryDirectories, temporaryOriginScratch } from './temp-directories'
|
|
@@ -180,6 +180,17 @@ export async function reducedReadBudget(opts: {
|
|
|
180
180
|
return typeof value === 'function' ? value.bind(target) : value
|
|
181
181
|
},
|
|
182
182
|
})
|
|
183
|
+
// Explicit operation multiplication on fresh handles at both history sizes.
|
|
184
|
+
// Unchanged reduced reads never acquire historical event rows.
|
|
185
|
+
for (const operations of [1, 8]) {
|
|
186
|
+
reset()
|
|
187
|
+
for (let n = 0; n < operations; n++) {
|
|
188
|
+
await readBuildFacts(cold, slug)
|
|
189
|
+
await readRepositoryFacts(cold, repo)
|
|
190
|
+
}
|
|
191
|
+
expect(costs.events).toBe(0)
|
|
192
|
+
expect(costs.metadata).toBeLessThan(operations * 20)
|
|
193
|
+
}
|
|
183
194
|
await coldDispatchOnceBudget(store, cold, length, costs)
|
|
184
195
|
reset()
|
|
185
196
|
const view = new RepoViewStore(cold, { repo })
|
|
@@ -503,3 +514,39 @@ export function countHistoricalRows(costs: ReducedReadCosts, rows: unknown): num
|
|
|
503
514
|
return repo === costs.history!.repo && seq <= costs.history!.through
|
|
504
515
|
}).length
|
|
505
516
|
}
|
|
517
|
+
|
|
518
|
+
/** Fresh remote processes must never turn catalog skew into history reads.
|
|
519
|
+
* Callers instrument backing storage (including private checkpoint reads). */
|
|
520
|
+
export async function catalogSkewReadBudget(opts: {
|
|
521
|
+
backing: BuildStore
|
|
522
|
+
fresh: () => BuildStore
|
|
523
|
+
repo: string
|
|
524
|
+
slug: string
|
|
525
|
+
reset: () => void
|
|
526
|
+
eventRows: () => number
|
|
527
|
+
}) {
|
|
528
|
+
const reads = [
|
|
529
|
+
[{ kind: 'repo', repo: opts.repo }, { reducer: 'dispatchUpgrade' }],
|
|
530
|
+
[{ kind: 'build', slug: opts.slug }, { reducer: 'buildReadFacts' }],
|
|
531
|
+
[
|
|
532
|
+
{ kind: 'build', slug: opts.slug },
|
|
533
|
+
{ reducer: 'phaseFailures', args: { phase: 'plan', round: 1 } },
|
|
534
|
+
],
|
|
535
|
+
] as const
|
|
536
|
+
const expected = []
|
|
537
|
+
for (const [scope, request] of reads)
|
|
538
|
+
expected.push(await opts.backing.getReducerValue(scope, request))
|
|
539
|
+
const batch = await opts.backing.getRepoBuildDigests(opts.repo)
|
|
540
|
+
opts.reset()
|
|
541
|
+
for (let i = 0; i < 3; i++) {
|
|
542
|
+
const client = opts.fresh()
|
|
543
|
+
for (const [index, [scope, request]] of reads.entries()) {
|
|
544
|
+
const { catalogIdentity: _, ...answer } = await client.getReducerValue(scope, request)
|
|
545
|
+
const { catalogIdentity: __, ...canonical } = expected[index]!
|
|
546
|
+
expect(answer).toEqual(canonical)
|
|
547
|
+
}
|
|
548
|
+
expect(await client.getRepoBuildDigests(opts.repo)).toEqual(batch)
|
|
549
|
+
await client.close()
|
|
550
|
+
}
|
|
551
|
+
expect(opts.eventRows()).toBe(0)
|
|
552
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import { createHash } from 'node:crypto'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import { normalizeGitRemoteUrl } from '../kernel/origin'
|
|
6
|
+
import { mkdtemp, rm, rmdir } from 'node:fs/promises'
|
|
7
|
+
|
|
8
|
+
/** Register ownership before fixture setup can throw. Create one allocator per
|
|
9
|
+
* test file/suite, passing its afterEach hook. Existing earlier cleanup is safe. */
|
|
10
|
+
export function temporaryDirectories(afterEach: (cleanup: () => Promise<void>) => unknown) {
|
|
11
|
+
const paths = new Set<string>()
|
|
12
|
+
afterEach(async () => {
|
|
13
|
+
const owned = [...paths]
|
|
14
|
+
paths.clear()
|
|
15
|
+
const results = await Promise.allSettled(
|
|
16
|
+
owned.map((path) => rm(path, { recursive: true, force: true })),
|
|
17
|
+
)
|
|
18
|
+
const errors = results.flatMap((result) =>
|
|
19
|
+
result.status === 'rejected' ? [result.reason] : [],
|
|
20
|
+
)
|
|
21
|
+
if (errors.length) throw new AggregateError(errors, 'Test temporary directory cleanup failed')
|
|
22
|
+
})
|
|
23
|
+
return async (prefix: string): Promise<string> => {
|
|
24
|
+
const path = await mkdtemp(prefix)
|
|
25
|
+
paths.add(path)
|
|
26
|
+
return path
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Origin-mode dispatch creates a deterministic scratch path without mkdtemp.
|
|
31
|
+
* Tests own only the repository identities they exercise, never the shared parent. */
|
|
32
|
+
export function temporaryOriginScratch(afterEach: (cleanup: () => Promise<void>) => unknown) {
|
|
33
|
+
const paths = new Set<string>()
|
|
34
|
+
let ownsParent = false
|
|
35
|
+
afterEach(async () => {
|
|
36
|
+
await Promise.all([...paths].map((path) => rm(path, { recursive: true, force: true })))
|
|
37
|
+
paths.clear()
|
|
38
|
+
if (ownsParent) {
|
|
39
|
+
try {
|
|
40
|
+
await rmdir(join(tmpdir(), 'autobuild'))
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (!['ENOENT', 'ENOTEMPTY'].includes((error as NodeJS.ErrnoException).code ?? ''))
|
|
43
|
+
throw error
|
|
44
|
+
}
|
|
45
|
+
ownsParent = false
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
return (repository: string) => {
|
|
49
|
+
const parent = join(tmpdir(), 'autobuild')
|
|
50
|
+
ownsParent ||= !existsSync(parent)
|
|
51
|
+
paths.add(
|
|
52
|
+
join(
|
|
53
|
+
parent,
|
|
54
|
+
createHash('sha256').update(normalizeGitRemoteUrl(repository)).digest('hex').slice(0, 16),
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -9,12 +9,21 @@ You are a fresh skeptic reviewing the diff. You have no memory of prior
|
|
|
9
9
|
rounds by design. Your verdict travels the typed channel; prose you print
|
|
10
10
|
goes nowhere.
|
|
11
11
|
|
|
12
|
+
Large scratch belongs under the session's `.ab/` directory (prefer `$AB_CONTEXT_DIR`),
|
|
13
|
+
not `/tmp`: this includes ad-hoc PostgreSQL data/cluster directories, Cargo target
|
|
14
|
+
directories, browser profiles, and database copies. Configure `PGDATA`,
|
|
15
|
+
`CARGO_TARGET_DIR`, and explicit browser profile paths for those resources.
|
|
16
|
+
Keep `TMPDIR` outside the worktree for test suites and commands that discover
|
|
17
|
+
repositories or configuration through parent directories, including focused tests
|
|
18
|
+
and Git probes. Do not relocate required installed tooling or retained evidence;
|
|
19
|
+
manifest-directed artifact paths remain authoritative. Never commit scratch.
|
|
20
|
+
|
|
12
21
|
## Session shape
|
|
13
22
|
|
|
14
|
-
1. Run `ab context`. You get
|
|
15
|
-
(`base`/`head` in
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
1. Run `ab context`. You get `$AB_CONTEXT_DIR/spec.md`, `$AB_CONTEXT_DIR/plan.md`, the commit range
|
|
24
|
+
(`base`/`head` in `$AB_CONTEXT_DIR/context.json`), `$AB_CONTEXT_DIR/implement-notes.md`, and
|
|
25
|
+
`$AB_CONTEXT_DIR/history/` with prior rounds' findings. When present,
|
|
26
|
+
`$AB_CONTEXT_DIR/dismissed-findings.json` lists finding ids a human explicitly dismissed.
|
|
18
27
|
2. Read the actual diff (`git diff <base>..<head>`), then the surrounding
|
|
19
28
|
code. Review what changed *and* what the change touches.
|
|
20
29
|
3. Judge on exactly these axes, in this order:
|
|
@@ -28,19 +37,19 @@ goes nowhere.
|
|
|
28
37
|
author's assumption.
|
|
29
38
|
- **Spec conformance** — every acceptance criterion met; nothing beyond
|
|
30
39
|
the spec's scope smuggled in. A pinned `design` asset (listed under
|
|
31
|
-
`assets` in
|
|
40
|
+
`assets` in `$AB_CONTEXT_DIR/context.json`, files under `$AB_CONTEXT_DIR/assets/<kind>/<name>/`)
|
|
32
41
|
is a contract on observable visual and reference outcomes, not on implementation: judge the rendered output against it wherever the code lets you
|
|
33
42
|
check, and treat a divergence as a finding. A gap in the asset is not a
|
|
34
43
|
reason to invent requirements.
|
|
35
44
|
- **Tests** — do the new tests exercise the seams this change created or
|
|
36
45
|
moved? Would they fail if the change were wrong?
|
|
37
46
|
- **Fit** — matches the codebase's idioms; no needless indirection.
|
|
38
|
-
4. Write
|
|
47
|
+
4. Write `$AB_CONTEXT_DIR/code-review.md`, then exactly one verdict:
|
|
39
48
|
|
|
40
49
|
```
|
|
41
|
-
ab verdict approve --notes
|
|
42
|
-
ab verdict revise --findings
|
|
43
|
-
ab verdict escalate --reason "…" --notes
|
|
50
|
+
ab verdict approve --notes "$AB_CONTEXT_DIR/code-review.md"
|
|
51
|
+
ab verdict revise --findings "$AB_CONTEXT_DIR/findings.json" --notes "$AB_CONTEXT_DIR/code-review.md"
|
|
52
|
+
ab verdict escalate --reason "…" --notes "$AB_CONTEXT_DIR/code-review.md"
|
|
44
53
|
```
|
|
45
54
|
|
|
46
55
|
## Writing findings
|
|
@@ -102,3 +111,8 @@ reason to withhold approval — record them with `ab observe` and approve.
|
|
|
102
111
|
Escalate only genuine judgment calls a human must make (the spec itself is
|
|
103
112
|
wrong, a security tradeoff outside your authority). Out-of-scope discoveries
|
|
104
113
|
are `ab observe`, never findings.
|
|
114
|
+
|
|
115
|
+
Read the manifest path printed by `ab context`. Its `materialized` keys are
|
|
116
|
+
relative to `contextDir`: join them to locate collision-adjusted inputs.
|
|
117
|
+
Manifest path fields are workspace-relative; use `notesPath` for producer notes.
|
|
118
|
+
Run commands from the workspace root.
|