@defrex/autobuild 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/SPEC.md +416 -36
- package/docs/accounts.md +50 -1
- package/docs/answering-blocked-builds.md +4 -1
- package/docs/architecture.md +298 -17
- package/docs/build-store.md +18 -0
- package/docs/builds.md +7 -1
- package/docs/cli.md +1 -1
- package/docs/configuration-overview.md +6 -0
- package/docs/configuration.md +44 -19
- package/docs/dispatcher-hosting.md +42 -0
- package/docs/dispatcher.md +41 -0
- package/docs/forges.md +5 -0
- package/docs/integration-tree.md +24 -5
- package/docs/operating.md +11 -3
- package/docs/operator-api.md +81 -10
- package/docs/operator-surfaces.md +29 -0
- package/docs/plugin-authoring.md +51 -2
- package/docs/remote-store-protocol.md +321 -46
- package/docs/remote-ticket-protocol.md +12 -10
- package/docs/restacking.md +105 -3
- package/docs/setup.md +37 -8
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +41 -5
- package/docs/ticket-dependencies.md +8 -0
- package/docs/troubleshooting.md +9 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/availability.ts +96 -0
- package/packages/core/src/accounts/local-owner.ts +49 -2
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary.ts +17 -1
- package/packages/core/src/cli/context.ts +62 -0
- package/packages/core/src/cli/dashboard/model.ts +12 -3
- package/packages/core/src/cli/dashboard/poll.ts +65 -8
- package/packages/core/src/cli/dashboard/refresh.ts +2 -0
- package/packages/core/src/cli/dashboard/render.ts +46 -5
- package/packages/core/src/cli/dispatch-args.ts +27 -3
- package/packages/core/src/cli/dispatch-frontend.ts +179 -52
- package/packages/core/src/cli/dispatch-mode.ts +94 -0
- package/packages/core/src/cli/dispatch-preflight.ts +43 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +150 -33
- package/packages/core/src/cli/dispatch.ts +209 -36
- 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/harvest.ts +2 -1
- package/packages/core/src/cli/help.ts +17 -3
- package/packages/core/src/cli/historical-build-state.ts +6 -0
- package/packages/core/src/cli/main.ts +43 -2
- package/packages/core/src/cli/publication-settlement.ts +17 -0
- package/packages/core/src/cli/remote-poll.ts +11 -1
- package/packages/core/src/cli/repository-status.ts +11 -0
- package/packages/core/src/cli/status.ts +7 -1
- package/packages/core/src/cli/wait.ts +9 -2
- package/packages/core/src/cli/watch.ts +47 -16
- package/packages/core/src/config/roles.ts +16 -1
- package/packages/core/src/events/catalog.ts +8 -0
- package/packages/core/src/events/forge-degradation-policy.ts +11 -0
- package/packages/core/src/events/payloads.ts +95 -2
- package/packages/core/src/events/policy.ts +19 -0
- package/packages/core/src/events/repository.ts +108 -2
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +464 -0
- package/packages/core/src/kernel/change-presence.ts +74 -8
- package/packages/core/src/kernel/dispatch-placement.ts +30 -0
- package/packages/core/src/kernel/engine.ts +27 -12
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +17 -1
- package/packages/core/src/kernel/generators/node-restack-log.ts +14 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +24 -2
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-landing.ts +27 -10
- package/packages/core/src/kernel/node-polling.ts +40 -7
- package/packages/core/src/kernel/node-restack-demand.ts +75 -0
- package/packages/core/src/kernel/node-restack-state.ts +20 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +47 -1
- package/packages/core/src/kernel/read-facts.ts +120 -9
- package/packages/core/src/kernel/reconcile-head.ts +34 -11
- package/packages/core/src/kernel/reconcile-restack.ts +106 -72
- package/packages/core/src/kernel/reducer-registry.ts +6 -0
- package/packages/core/src/kernel/reducer.ts +20 -2
- package/packages/core/src/kernel/replay-retention.ts +176 -0
- package/packages/core/src/kernel/target-lineage.ts +65 -0
- package/packages/core/src/kernel/target-observation.ts +117 -0
- 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 +2 -0
- package/packages/core/src/operator/registry.ts +25 -13
- package/packages/core/src/operator/tickets.ts +8 -2
- package/packages/core/src/plugin-sdk/index.ts +1 -0
- package/packages/core/src/ports/forge/fake.ts +22 -0
- package/packages/core/src/ports/forge/git-rewrite.ts +49 -12
- package/packages/core/src/ports/forge/github.ts +42 -10
- package/packages/core/src/ports/forge/local-git.ts +16 -1
- package/packages/core/src/ports/runner/account-env.ts +60 -9
- package/packages/core/src/ports/runner/claude.ts +49 -45
- package/packages/core/src/ports/types.ts +58 -4
- package/packages/core/src/ports/workspace/account-policy.ts +2 -1
- package/packages/core/src/ports/workspace/commit-preservation.ts +175 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/fake.ts +4 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +22 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +304 -56
- package/packages/core/src/processes/build-runner.ts +240 -111
- package/packages/core/src/processes/dispatcher-selectors.ts +3 -2
- package/packages/core/src/processes/dispatcher.ts +732 -201
- package/packages/core/src/processes/execution-no-progress.ts +8 -0
- package/packages/core/src/processes/harvest-runner.ts +6 -7
- package/packages/core/src/processes/harvest.ts +11 -16
- package/packages/core/src/processes/publication-state.ts +2 -1
- package/packages/core/src/processes/repo-view.ts +25 -0
- package/packages/core/src/processes/workspace-preservation.ts +164 -0
- package/packages/core/src/scenarios/harness.ts +7 -0
- package/packages/core/src/store/adapter.ts +9 -0
- package/packages/core/src/store/artifact-meta.ts +7 -0
- package/packages/core/src/store/build-scope.ts +28 -0
- package/packages/core/src/store/contract.ts +182 -0
- package/packages/core/src/store/event-reads.ts +156 -0
- package/packages/core/src/store/local/schema.ts +11 -0
- package/packages/core/src/store/local/store.ts +117 -2
- package/packages/core/src/store/memory.ts +241 -0
- package/packages/core/src/store/phase-session.ts +47 -0
- package/packages/core/src/store/reduced-reads.ts +8 -0
- package/packages/core/src/store/reducer-value-shapes.json +10546 -8877
- package/packages/core/src/store/reducer-value-validation.ts +109 -6
- package/packages/core/src/store/reducer-values.ts +62 -2
- package/packages/core/src/store/remote/client.ts +208 -23
- package/packages/core/src/store/remote/compatibility.ts +195 -25
- package/packages/core/src/store/remote/errors.ts +16 -0
- package/packages/core/src/store/remote/index.ts +17 -0
- package/packages/core/src/store/remote/protocol.ts +30 -1
- package/packages/core/src/store/remote/released-clients.json +37 -0
- package/packages/core/src/store/remote/released-clients.ts +88 -0
- package/packages/core/src/store/remote/released-reducer-values/1.2.0.json +8129 -0
- package/packages/core/src/store/remote/released-reducer-values/1.3.0.json +25093 -0
- package/packages/core/src/store/remote/released-reducer-values/1.4.0.json +26128 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +13 -0
- package/packages/core/src/store/remote/version.ts +8 -1
- package/packages/core/src/store/repo-state-events.ts +6 -3
- package/packages/core/src/store/scan-cadence.ts +15 -0
- package/packages/core/src/store/session-handle.ts +18 -0
- package/packages/core/src/store/snapshots.ts +16 -3
- package/packages/core/src/store/types.ts +29 -6
- package/packages/core/src/testing/dispatch-read-budget.ts +457 -7
- package/packages/core/src/testing/index.ts +6 -1
- package/packages/core/src/testing/reduced-read-budget.ts +1240 -9
- package/skills/guide/SKILL.md +220 -22
- package/skills/guide/references/accounts.md +50 -1
- package/skills/guide/references/integration-tree.md +24 -5
- package/skills/guide/references/operator-api.md +81 -10
- package/skills/guide/references/plugin-authoring.md +51 -2
- package/skills/guide/references/remote-store-protocol.md +321 -46
- package/skills/guide/references/remote-ticket-protocol.md +12 -10
- package/skills/guide/references/restacking.md +105 -3
- package/skills/guide/references/setup.md +37 -8
- package/skills/guide/references/spec-standard.md +41 -5
- package/skills/guide/references/ticket-dependencies.md +8 -0
- package/skills/implement/SKILL.md +12 -3
- package/skills/operate/SKILL.md +85 -12
- package/skills/plan/SKILL.md +27 -4
- package/skills/plan-review/SKILL.md +22 -2
- package/skills/reconcile/SKILL.md +16 -1
- package/skills/spec/SKILL.md +7 -4
- package/skills/tickets/SKILL.md +7 -3
- package/templates/hosted-service/package.json +2 -2
|
@@ -25,6 +25,8 @@ export const executionProgress = {
|
|
|
25
25
|
'landing.forge-merged': 'progress',
|
|
26
26
|
'landing.native-applied': 'bookkeeping',
|
|
27
27
|
'target.distance': 'bookkeeping',
|
|
28
|
+
'target.rewritten': 'bookkeeping',
|
|
29
|
+
'target.rewrite-cleared': 'bookkeeping',
|
|
28
30
|
'target.moved': 'bookkeeping',
|
|
29
31
|
'restack.prepared': 'progress',
|
|
30
32
|
'restack.replayed': 'progress',
|
|
@@ -52,6 +54,7 @@ export const executionProgress = {
|
|
|
52
54
|
'node.inventory': 'bookkeeping',
|
|
53
55
|
'node.restack-requested': 'bookkeeping',
|
|
54
56
|
'node.restack-satisfied': 'progress',
|
|
57
|
+
'node.restack-availability-observed': 'bookkeeping',
|
|
55
58
|
'node.parent-distance': 'bookkeeping',
|
|
56
59
|
'node.parent-requested': 'bookkeeping',
|
|
57
60
|
'node.parent-accepted': 'progress',
|
|
@@ -70,6 +73,10 @@ export const executionProgress = {
|
|
|
70
73
|
'runner.setup-failed': 'failure',
|
|
71
74
|
'workspace.provisioned': 'bookkeeping',
|
|
72
75
|
'workspace.provision-started': 'bookkeeping',
|
|
76
|
+
'workspace.cleanup-required': 'bookkeeping',
|
|
77
|
+
'workspace.fenced': 'bookkeeping',
|
|
78
|
+
'workspace.commits-preserved': 'bookkeeping',
|
|
79
|
+
'workspace.commits-lost': 'bookkeeping',
|
|
73
80
|
'workspace.released': 'bookkeeping',
|
|
74
81
|
'execution.started': 'bookkeeping',
|
|
75
82
|
'execution.ended': 'bookkeeping',
|
|
@@ -81,6 +88,7 @@ export const executionProgress = {
|
|
|
81
88
|
'pr-summary.settled': 'progress',
|
|
82
89
|
'finalize.step-started': 'progress',
|
|
83
90
|
'publication.requested': 'progress',
|
|
91
|
+
'publication.candidate-retired': 'progress',
|
|
84
92
|
'publication.lost': 'progress',
|
|
85
93
|
'publication.retry-scheduled': 'failure',
|
|
86
94
|
'publication.retry-exhausted': 'failure',
|
|
@@ -915,8 +915,11 @@ export class HarvestRunner {
|
|
|
915
915
|
throw error
|
|
916
916
|
}
|
|
917
917
|
|
|
918
|
-
const
|
|
919
|
-
|
|
918
|
+
const hasTerminal = async () => {
|
|
919
|
+
const event = (await readRepositoryFacts(store, repo)).value.harvestTerminals[session]
|
|
920
|
+
return event !== undefined && event.seq > started.seq && spec.terminal(event, session)
|
|
921
|
+
}
|
|
922
|
+
const terminal = await hasTerminal()
|
|
920
923
|
const owner = live?.runner ?? target.runner
|
|
921
924
|
const close =
|
|
922
925
|
streamBracket !== undefined
|
|
@@ -942,11 +945,7 @@ export class HarvestRunner {
|
|
|
942
945
|
if (spec.producer) this.producer = undefined
|
|
943
946
|
// Cleanup can finish a typed deposit already in flight. Its terminal
|
|
944
947
|
// wins even when cancellation initially observed no result.
|
|
945
|
-
const completed =
|
|
946
|
-
terminal ||
|
|
947
|
-
(await store.getRepoEvents(repo, started.seq)).some((event) =>
|
|
948
|
-
spec.terminal(event, session),
|
|
949
|
-
)
|
|
948
|
+
const completed = terminal || (await hasTerminal())
|
|
950
949
|
if (completed) {
|
|
951
950
|
await this.depositTranscript(spec, session, content, usage, target.model, close)
|
|
952
951
|
return
|
|
@@ -229,16 +229,12 @@ export function collectUnclaimedObservations(input: {
|
|
|
229
229
|
return { observations, merges, state }
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
* runner's packet scan — the only source of observation payloads — and its
|
|
239
|
-
* gate re-confirmation; the dispatcher's harvest-launch gate itself evaluates
|
|
240
|
-
* from digests, AUT-521). Occurrences are keyed `{build, seq}`; payload ids
|
|
241
|
-
* are not assumed globally unique. */
|
|
232
|
+
/** Count unclaimed occurrences from already reduced build digests and harvest
|
|
233
|
+
* facts, without backing reads. The operator query and interactive dispatcher
|
|
234
|
+
* tick consume this directly; the tick reuses its shared refreshed view.
|
|
235
|
+
* The Store-only terminal frontend owns a separate refresh.
|
|
236
|
+
* Occurrences are keyed by {build, seq}, never by payload id.
|
|
237
|
+
* The harvest runner's scan still supplies full observation payloads. */
|
|
242
238
|
export function unclaimedObservationCount(input: {
|
|
243
239
|
digests: Map<string, BuildDigest>
|
|
244
240
|
harvestEvents: RepositoryEvent[] | HarvestState
|
|
@@ -275,12 +271,11 @@ export async function readRepoEventsIfRecorded(
|
|
|
275
271
|
return (await store.getRepo(repo)) === null ? [] : store.getRepoStateEvents(repo)
|
|
276
272
|
}
|
|
277
273
|
|
|
278
|
-
/**
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* shared helper's, above. */
|
|
274
|
+
/** Store-reading count helper: one repository-record probe, one canonical
|
|
275
|
+
* repository-facts request when recorded, and one repository-scoped digest
|
|
276
|
+
* request. No journal replay or writes. An absent record supplies empty harvest
|
|
277
|
+
* facts. Dispatcher ticks use unclaimedObservationCount with their shared view
|
|
278
|
+
* instead, avoiding these additional acquisitions. */
|
|
284
279
|
export async function sampleUnclaimedObservationCount(
|
|
285
280
|
store: BuildStore,
|
|
286
281
|
repo: string,
|
|
@@ -37,7 +37,7 @@ export interface PublicationLedger {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** Bump when `PublicationLedger` or its fold changes. */
|
|
40
|
-
export const PUBLICATION_STATE_REDUCER_VERSION =
|
|
40
|
+
export const PUBLICATION_STATE_REDUCER_VERSION = 7
|
|
41
41
|
|
|
42
42
|
function compact(event: AbEvent): LedgerItem | undefined {
|
|
43
43
|
switch (event.type) {
|
|
@@ -45,6 +45,7 @@ function compact(event: AbEvent): LedgerItem | undefined {
|
|
|
45
45
|
return { t: 'request', seq: event.seq, event }
|
|
46
46
|
case 'restack.completed':
|
|
47
47
|
return { t: 'restack', seq: event.seq, id: event.payload.id, head: event.payload.headSha }
|
|
48
|
+
case 'publication.candidate-retired':
|
|
48
49
|
case 'restack.contended':
|
|
49
50
|
case 'reconcile.contended':
|
|
50
51
|
return { t: 'cancelled', seq: event.seq, request: event.payload.request }
|
|
@@ -126,6 +126,10 @@ export class RepoViewStore implements BuildStore {
|
|
|
126
126
|
private readonly backing: BuildStore,
|
|
127
127
|
opts: RepoViewOptions,
|
|
128
128
|
) {
|
|
129
|
+
this.getBuildEventPage = backing.getBuildEventPage?.bind(backing)
|
|
130
|
+
this.getRepositoryTail = backing.getRepositoryTail?.bind(backing)
|
|
131
|
+
this.getStreamSeed = backing.getStreamSeed?.bind(backing)
|
|
132
|
+
this.getHarvestHistoryPage = backing.getHarvestHistoryPage?.bind(backing)
|
|
129
133
|
this.repo = opts.repo
|
|
130
134
|
}
|
|
131
135
|
private build<T>(slug: string, task: () => Promise<T>): Promise<T> {
|
|
@@ -290,6 +294,10 @@ export class RepoViewStore implements BuildStore {
|
|
|
290
294
|
getRepoStateEvents(repo: string): Promise<RepositoryEvent[]> {
|
|
291
295
|
return this.backing.getRepoStateEvents(repo)
|
|
292
296
|
}
|
|
297
|
+
getBuildEventPage: BuildStore['getBuildEventPage']
|
|
298
|
+
getRepositoryTail: BuildStore['getRepositoryTail']
|
|
299
|
+
getStreamSeed: BuildStore['getStreamSeed']
|
|
300
|
+
getHarvestHistoryPage: BuildStore['getHarvestHistoryPage']
|
|
293
301
|
getReducerValue(scope: SnapshotScope, request: ReducerValueRequest): Promise<ReducerValue> {
|
|
294
302
|
return this.backing.getReducerValue(scope, request)
|
|
295
303
|
}
|
|
@@ -462,6 +470,16 @@ export class RepoViewStore implements BuildStore {
|
|
|
462
470
|
await this.backing.releaseLease(slug, holder)
|
|
463
471
|
this.invalidate()
|
|
464
472
|
}
|
|
473
|
+
getScanCadence(repo: string) {
|
|
474
|
+
return this.backing.getScanCadence(repo)
|
|
475
|
+
}
|
|
476
|
+
putScanCadence(
|
|
477
|
+
repo: string,
|
|
478
|
+
cadence: import('../store/scan-cadence').ScanCadence,
|
|
479
|
+
allowClockRollback = false,
|
|
480
|
+
) {
|
|
481
|
+
return this.backing.putScanCadence(repo, cadence, allowClockRollback)
|
|
482
|
+
}
|
|
465
483
|
upsertOperatorPresence(
|
|
466
484
|
repo: string,
|
|
467
485
|
identity: OperatorIdentity,
|
|
@@ -495,6 +513,13 @@ export class RepoViewStore implements BuildStore {
|
|
|
495
513
|
getArtifact(slug: string, kind: string, rev?: number): Promise<Artifact | null> {
|
|
496
514
|
return this.backing.getArtifact(slug, kind, rev)
|
|
497
515
|
}
|
|
516
|
+
get getNodeRewrite(): BuildStore['getNodeRewrite'] {
|
|
517
|
+
return this.backing.getNodeRewrite?.bind(this.backing)
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
get getLatestArtifactMeta(): BuildStore['getLatestArtifactMeta'] {
|
|
521
|
+
return this.backing.getLatestArtifactMeta?.bind(this.backing)
|
|
522
|
+
}
|
|
498
523
|
listArtifacts(slug: string, kind?: string): Promise<ArtifactMeta[]> {
|
|
499
524
|
return this.backing.listArtifacts(slug, kind)
|
|
500
525
|
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { DISPATCHER } from '../events/envelope'
|
|
2
|
+
import { remoteBranchHead } from '../ports/forge/git-rewrite'
|
|
3
|
+
import type { Forge, WorkspaceProvider } from '../ports/types'
|
|
4
|
+
import type { Exec } from '../ports/workspace/git-worktree'
|
|
5
|
+
import { preserveGitCommits } from '../ports/workspace/commit-preservation'
|
|
6
|
+
import { readBuildFacts } from '../store/reduced-reads'
|
|
7
|
+
import type { BuildStore } from '../store/types'
|
|
8
|
+
|
|
9
|
+
export class WorkspaceFenceUnknown extends Error {}
|
|
10
|
+
|
|
11
|
+
/** Every caller holds the build's cleanup boundary. A fence is revalidated on
|
|
12
|
+
* every invocation, including restart: durable receipts cannot stop new code. */
|
|
13
|
+
export async function preserveWorkspaceBeforeRelease(deps: {
|
|
14
|
+
store: BuildStore
|
|
15
|
+
slug: string
|
|
16
|
+
owner: WorkspaceProvider
|
|
17
|
+
forge: Forge
|
|
18
|
+
exec: Exec
|
|
19
|
+
reason: string
|
|
20
|
+
now?: Date
|
|
21
|
+
}): Promise<void> {
|
|
22
|
+
let current = await readBuildFacts(deps.store, deps.slug)
|
|
23
|
+
const source = current.value.latestWorkspace
|
|
24
|
+
if (!source || current.value.workspace === null) return
|
|
25
|
+
const handle = { ...source.payload, path: source.payload.path ?? source.payload.ref }
|
|
26
|
+
const execution = current.value.state.executions.at(-1)
|
|
27
|
+
const executionSeq = execution?.workspaceRef === source.payload.ref ? execution.seq : 0
|
|
28
|
+
const record = await deps.store.getBuild(deps.slug)
|
|
29
|
+
if (
|
|
30
|
+
current.value.open !== null &&
|
|
31
|
+
record?.lease &&
|
|
32
|
+
new Date(record.lease.expiresAt).getTime() > (deps.now ?? new Date()).getTime()
|
|
33
|
+
)
|
|
34
|
+
throw new Error('workspace preservation refused while execution lease is live')
|
|
35
|
+
if (!deps.owner.recovery && current.value.open !== null)
|
|
36
|
+
throw new WorkspaceFenceUnknown('local execution teardown has not been recorded')
|
|
37
|
+
const outcome = deps.owner.recovery
|
|
38
|
+
? await deps.owner.recovery.fence?.(handle)
|
|
39
|
+
: { outcome: 'confirmed' as const }
|
|
40
|
+
if (!outcome || outcome.outcome === 'unknown')
|
|
41
|
+
throw new WorkspaceFenceUnknown(
|
|
42
|
+
`workspace fence is unknown: ${outcome && 'error' in outcome ? outcome.error : 'provider lacks non-destructive fencing'}`,
|
|
43
|
+
)
|
|
44
|
+
const fence = current.value.workspaceFence?.payload
|
|
45
|
+
if (
|
|
46
|
+
fence?.workspace !== source.seq ||
|
|
47
|
+
fence.execution !== executionSeq ||
|
|
48
|
+
fence.outcome !== outcome.outcome
|
|
49
|
+
) {
|
|
50
|
+
if (
|
|
51
|
+
!(await deps.store.appendIfCurrent(deps.slug, current.cursor, {
|
|
52
|
+
actor: DISPATCHER,
|
|
53
|
+
type: 'workspace.fenced',
|
|
54
|
+
payload: {
|
|
55
|
+
workspace: source.seq,
|
|
56
|
+
execution: executionSeq,
|
|
57
|
+
ref: handle.ref,
|
|
58
|
+
outcome: outcome.outcome,
|
|
59
|
+
},
|
|
60
|
+
}))
|
|
61
|
+
)
|
|
62
|
+
throw new Error('workspace changed during fencing; retry cleanup')
|
|
63
|
+
current = await readBuildFacts(deps.store, deps.slug)
|
|
64
|
+
}
|
|
65
|
+
const prior = current.value.workspacePreservation?.payload
|
|
66
|
+
const loss = current.value.workspaceLoss?.payload
|
|
67
|
+
if (
|
|
68
|
+
outcome.outcome === 'absent' &&
|
|
69
|
+
loss?.workspace === source.seq &&
|
|
70
|
+
loss.execution === executionSeq
|
|
71
|
+
)
|
|
72
|
+
return
|
|
73
|
+
const request = current.value.publication.latestUncompletedRequest()
|
|
74
|
+
const candidates = [
|
|
75
|
+
...new Set([
|
|
76
|
+
...(request && !current.value.publication.lostRecorded(request) ? [request.payload.sha] : []),
|
|
77
|
+
...(prior?.heads.map((head) => head.sha) ?? []),
|
|
78
|
+
]),
|
|
79
|
+
]
|
|
80
|
+
const metadata = {
|
|
81
|
+
workspace: source.seq,
|
|
82
|
+
execution: executionSeq,
|
|
83
|
+
ref: handle.ref,
|
|
84
|
+
branch: handle.branch,
|
|
85
|
+
phase: current.value.state.phase ?? 'implement',
|
|
86
|
+
round: current.value.state.round ?? 1,
|
|
87
|
+
}
|
|
88
|
+
let preserved:
|
|
89
|
+
| { outcome: 'preserved'; heads: import('../ports/types').WorkspacePreservationHead[] }
|
|
90
|
+
| { outcome: 'absent' }
|
|
91
|
+
if (outcome.outcome === 'absent') preserved = { outcome: 'absent' }
|
|
92
|
+
else if (deps.owner.preservation || deps.owner.publication) {
|
|
93
|
+
const preserve = deps.owner.preservation ?? deps.owner.publication?.preserve
|
|
94
|
+
if (!preserve) throw new Error('remote provider lacks trusted commit preservation')
|
|
95
|
+
preserved = await preserve({
|
|
96
|
+
ref: handle.ref,
|
|
97
|
+
slug: deps.slug,
|
|
98
|
+
branch: handle.branch,
|
|
99
|
+
base: source.payload.base.sha,
|
|
100
|
+
candidates,
|
|
101
|
+
})
|
|
102
|
+
} else {
|
|
103
|
+
const rewrite = deps.forge.kernelRewrite ?? deps.forge.rewrite
|
|
104
|
+
if (!rewrite) throw new Error('forge lacks immutable workspace commit archives')
|
|
105
|
+
let base: string
|
|
106
|
+
try {
|
|
107
|
+
base = await rewrite.snapshot({
|
|
108
|
+
workspacePath: handle.path,
|
|
109
|
+
branch: handle.branch,
|
|
110
|
+
destinationRef: `refs/autobuild/reconcile/${deps.slug}/preservation`,
|
|
111
|
+
})
|
|
112
|
+
} catch (error) {
|
|
113
|
+
// A never-published branch compares against its recorded base; any other
|
|
114
|
+
// snapshot failure, or an unreadable remote, keeps the workspace intact.
|
|
115
|
+
const remote = await remoteBranchHead(
|
|
116
|
+
deps.forge.kernelExec ?? deps.exec,
|
|
117
|
+
handle.path,
|
|
118
|
+
handle.branch,
|
|
119
|
+
).catch(() => undefined)
|
|
120
|
+
if (remote !== null) throw error
|
|
121
|
+
base = source.payload.base.sha
|
|
122
|
+
}
|
|
123
|
+
preserved = {
|
|
124
|
+
outcome: 'preserved',
|
|
125
|
+
heads: await preserveGitCommits({
|
|
126
|
+
exec: deps.forge.kernelExec ?? deps.exec,
|
|
127
|
+
workspacePath: handle.path,
|
|
128
|
+
branch: handle.branch,
|
|
129
|
+
slug: deps.slug,
|
|
130
|
+
base,
|
|
131
|
+
candidates,
|
|
132
|
+
archive: rewrite.archive,
|
|
133
|
+
}),
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (
|
|
137
|
+
preserved.outcome === 'preserved' &&
|
|
138
|
+
prior?.workspace === source.seq &&
|
|
139
|
+
prior.execution === executionSeq &&
|
|
140
|
+
JSON.stringify(prior.heads) === JSON.stringify(preserved.heads)
|
|
141
|
+
)
|
|
142
|
+
return
|
|
143
|
+
const write =
|
|
144
|
+
preserved.outcome === 'preserved'
|
|
145
|
+
? {
|
|
146
|
+
actor: DISPATCHER,
|
|
147
|
+
type: 'workspace.commits-preserved' as const,
|
|
148
|
+
payload: { ...metadata, heads: preserved.heads },
|
|
149
|
+
}
|
|
150
|
+
: {
|
|
151
|
+
actor: DISPATCHER,
|
|
152
|
+
type: 'workspace.commits-lost' as const,
|
|
153
|
+
payload: {
|
|
154
|
+
...metadata,
|
|
155
|
+
shas: [...new Set([...candidates, ...(request ? [request.payload.sha] : [])])].filter(
|
|
156
|
+
(sha) => !prior?.heads.some((head) => head.sha === sha),
|
|
157
|
+
),
|
|
158
|
+
inventory: 'additional-shas-unavailable' as const,
|
|
159
|
+
reason: `${deps.reason}: source environment is absent; additional unpublished SHAs could not be inspected`,
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
if (!(await deps.store.appendIfCurrent(deps.slug, current.cursor, write)))
|
|
163
|
+
throw new Error('workspace changed during commit preservation; retry cleanup')
|
|
164
|
+
}
|
|
@@ -476,6 +476,13 @@ export async function makeHarness(opts: {
|
|
|
476
476
|
gatePresence: opts.gatePresence ?? 'present',
|
|
477
477
|
...(opts.pluginForge?.prAttachments === true ? { prAttachments: true } : {}),
|
|
478
478
|
})
|
|
479
|
+
// This fixture's served bare repository is the authoritative forge, even
|
|
480
|
+
// when FakeForge supplies the scripted PR surface.
|
|
481
|
+
const served = new LocalGitForge({ repoRoot: opts.localGitForge === true ? origin : remote })
|
|
482
|
+
const scriptedBranch = forge.remoteBranchSha.bind(forge)
|
|
483
|
+
forge.remoteBranchSha = async (branch) =>
|
|
484
|
+
forge.remoteBranches.has(branch) ? scriptedBranch(branch) : served.remoteBranchSha(branch)
|
|
485
|
+
forge.isCommitAncestor = (ancestor, descendant) => served.isCommitAncestor(ancestor, descendant)
|
|
479
486
|
const recordPush = forge.pushBranch.bind(forge)
|
|
480
487
|
forge.pushBranch = async (cwd, branch, sha) => {
|
|
481
488
|
await recordPush(cwd, branch, sha)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './scan-cadence'
|
|
1
2
|
export * from './operator-presence'
|
|
2
3
|
export type { StoredEvent } from '../events/compatibility'
|
|
3
4
|
export { READ_CATALOG_IDENTITY } from '../events/compatibility'
|
|
@@ -146,3 +147,11 @@ export type {
|
|
|
146
147
|
export { assertPublicSnapshotReducer } from './snapshots'
|
|
147
148
|
|
|
148
149
|
export { readPersistedBuildDigests } from './reduced-reads'
|
|
150
|
+
|
|
151
|
+
export { dispatchPlacementSchema, dispatchPlacementReducer } from '../kernel/dispatch-placement'
|
|
152
|
+
export type { DispatchPlacement } from '../kernel/dispatch-placement'
|
|
153
|
+
export { dispatchPlacementFactSchema } from '../events/repository'
|
|
154
|
+
export type { DispatchPlacementFact } from '../events/repository'
|
|
155
|
+
|
|
156
|
+
export { readDispatchPlacement } from './reduced-reads'
|
|
157
|
+
export * from './event-reads'
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** An optional metadata capability is unavailable; callers may use ordinary artifact reads. */
|
|
2
|
+
export class ArtifactMetaUnsupportedError extends Error {
|
|
3
|
+
constructor() {
|
|
4
|
+
super('latest artifact metadata is unsupported')
|
|
5
|
+
this.name = 'ArtifactMetaUnsupportedError'
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -104,6 +104,12 @@ export function createBuildScopedStore(store: BuildStore, scope: string): BuildS
|
|
|
104
104
|
listBuildsForRepo(repo: string): Promise<BuildRecord[]> {
|
|
105
105
|
return Promise.reject(new BuildScopeError(scope, 'listBuildsForRepo', repo))
|
|
106
106
|
},
|
|
107
|
+
async getScanCadence(): Promise<never> {
|
|
108
|
+
throw new BuildScopeError(scope, 'getScanCadence')
|
|
109
|
+
},
|
|
110
|
+
async putScanCadence(): Promise<never> {
|
|
111
|
+
throw new BuildScopeError(scope, 'putScanCadence')
|
|
112
|
+
},
|
|
107
113
|
async upsertOperatorPresence(): Promise<never> {
|
|
108
114
|
throw new BuildScopeError(scope, 'upsertOperatorPresence')
|
|
109
115
|
},
|
|
@@ -151,6 +157,28 @@ export function createBuildScopedStore(store: BuildStore, scope: string): BuildS
|
|
|
151
157
|
own('appendWithArtifactsIfCurrent', slug)
|
|
152
158
|
return store.appendWithArtifactsIfCurrent(slug, expectedSeq, artifacts, makeEvent)
|
|
153
159
|
},
|
|
160
|
+
...(store.getBuildEventPage
|
|
161
|
+
? {
|
|
162
|
+
async getBuildEventPage(
|
|
163
|
+
slug: string,
|
|
164
|
+
since?: number,
|
|
165
|
+
opts?: import('./event-reads').EventReadOptions,
|
|
166
|
+
) {
|
|
167
|
+
own('getBuildEventPage', slug)
|
|
168
|
+
return store.getBuildEventPage!(slug, since, opts)
|
|
169
|
+
},
|
|
170
|
+
}
|
|
171
|
+
: {}),
|
|
172
|
+
...(store.getStreamSeed
|
|
173
|
+
? {
|
|
174
|
+
async getStreamSeed(target: SnapshotScope, cursor: number) {
|
|
175
|
+
if (target.kind !== 'build')
|
|
176
|
+
throw new BuildScopeError(scope, 'getStreamSeed', target.repo)
|
|
177
|
+
own('getStreamSeed', target.slug)
|
|
178
|
+
return store.getStreamSeed!(target, cursor)
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
: {}),
|
|
154
182
|
async getEvents(
|
|
155
183
|
slug: string,
|
|
156
184
|
sinceSeq?: number,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IncompleteEventReadError, BUILD_EVENT_PAGE_SIZE } from './event-reads'
|
|
1
2
|
import { repositoryReadFactsReducer } from '../kernel/read-facts'
|
|
2
3
|
import { validateReducerValue } from './reducer-value-validation'
|
|
3
4
|
import { READ_CATALOG_IDENTITY } from '../events/compatibility'
|
|
@@ -291,6 +292,34 @@ function atT0(offsetMs: number): string {
|
|
|
291
292
|
|
|
292
293
|
export function describeBuildStoreContract(name: string, factory: BuildStoreFactory): void {
|
|
293
294
|
describe(`BuildStore contract: ${name}`, () => {
|
|
295
|
+
test('scan cadence is keyed disposable metadata with atomic replacement and clock rollback', async () => {
|
|
296
|
+
await withStore(factory, undefined, async (store) => {
|
|
297
|
+
expect(await store.getScanCadence('cadence')).toBeNull()
|
|
298
|
+
expect(await store.getRepo('cadence')).toBeNull()
|
|
299
|
+
await store.ensureRepo('cadence')
|
|
300
|
+
const first = {
|
|
301
|
+
scanSeq: 1,
|
|
302
|
+
startedAt: CONTRACT_T0,
|
|
303
|
+
mode: 'admission' as const,
|
|
304
|
+
readinessFingerprint: 'ready',
|
|
305
|
+
criteriaFingerprint: 'criteria',
|
|
306
|
+
}
|
|
307
|
+
await store.putScanCadence('cadence', first)
|
|
308
|
+
expect(await store.getScanCadence('cadence')).toEqual(first)
|
|
309
|
+
expect(await store.getScanCadence('other')).toBeNull()
|
|
310
|
+
const later = { ...first, startedAt: atT0(60_000) }
|
|
311
|
+
await store.putScanCadence('cadence', later)
|
|
312
|
+
await store.putScanCadence('cadence', first)
|
|
313
|
+
expect(await store.getScanCadence('cadence')).toEqual(later)
|
|
314
|
+
await store.putScanCadence('cadence', first, true)
|
|
315
|
+
expect(await store.getScanCadence('cadence')).toEqual(first)
|
|
316
|
+
const next = { ...first, scanSeq: 2, mode: 'observation' as const }
|
|
317
|
+
await store.putScanCadence('cadence', next)
|
|
318
|
+
expect(await store.getScanCadence('cadence')).toEqual(next)
|
|
319
|
+
expect(await store.getRepoEvents('cadence')).toEqual([])
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
|
|
294
323
|
test('operator presence is concurrent, renewable advisory liveness without journal writes', async () => {
|
|
295
324
|
const clock = manualClock()
|
|
296
325
|
await withStore(factory, { clock }, async (store) => {
|
|
@@ -1120,6 +1149,11 @@ export function describeBuildStoreContract(name: string, factory: BuildStoreFact
|
|
|
1120
1149
|
const later = {
|
|
1121
1150
|
...payload,
|
|
1122
1151
|
evidence: 'landing-revision-2',
|
|
1152
|
+
witness: {
|
|
1153
|
+
version: 1 as const,
|
|
1154
|
+
commits: ['a'.repeat(40)],
|
|
1155
|
+
identities: ['build:blocker' as const],
|
|
1156
|
+
},
|
|
1123
1157
|
identities: ['build:blocker', 'build:second'],
|
|
1124
1158
|
}
|
|
1125
1159
|
await store.appendRepo(repo, {
|
|
@@ -2251,6 +2285,34 @@ export function describeBuildStoreContract(name: string, factory: BuildStoreFact
|
|
|
2251
2285
|
]
|
|
2252
2286
|
}
|
|
2253
2287
|
|
|
2288
|
+
test('unfinished preparation survives run turnover in canonical reduced state and resolution removes it', async () => {
|
|
2289
|
+
await withStore(factory, undefined, async (store) => {
|
|
2290
|
+
const repo = 'acme/preparation'
|
|
2291
|
+
await store.ensureRepo(repo)
|
|
2292
|
+
const ticket = { source: 'fake', id: 'T-1' }
|
|
2293
|
+
await store.appendRepo(repo, {
|
|
2294
|
+
actor: DISPATCHER,
|
|
2295
|
+
type: 'ticket-preparation.intended',
|
|
2296
|
+
payload: { attempt: 'prep', ticket, readyState: 'Ready', claimedState: 'Doing' },
|
|
2297
|
+
})
|
|
2298
|
+
await store.appendRepo(repo, {
|
|
2299
|
+
actor: DISPATCHER,
|
|
2300
|
+
type: 'ticket-preparation.claimed',
|
|
2301
|
+
payload: { attempt: 'prep', ticket },
|
|
2302
|
+
})
|
|
2303
|
+
for (const write of noopInvocation('next-run')) await store.appendRepo(repo, write)
|
|
2304
|
+
expect((await readRepositoryFacts(store, repo)).value.preparation.prep?.claimed).toBe(
|
|
2305
|
+
true,
|
|
2306
|
+
)
|
|
2307
|
+
await store.appendRepo(repo, {
|
|
2308
|
+
actor: DISPATCHER,
|
|
2309
|
+
type: 'ticket-preparation.resolved',
|
|
2310
|
+
payload: { attempt: 'prep', ticket, outcome: 'handed-back' },
|
|
2311
|
+
})
|
|
2312
|
+
expect((await readRepositoryFacts(store, repo)).value.preparation).toEqual({})
|
|
2313
|
+
})
|
|
2314
|
+
})
|
|
2315
|
+
|
|
2254
2316
|
test('ticket migrations survive run turnover and stay repository scoped', async () => {
|
|
2255
2317
|
await withStore(factory, undefined, async (store) => {
|
|
2256
2318
|
const repo = 'acme/migration'
|
|
@@ -2619,6 +2681,78 @@ export function describeBuildStoreContract(name: string, factory: BuildStoreFact
|
|
|
2619
2681
|
})
|
|
2620
2682
|
|
|
2621
2683
|
describe('append', () => {
|
|
2684
|
+
test('cleared targets retain bounded lineage in persisted reduced values', async () => {
|
|
2685
|
+
await withStore(factory, undefined, async (store) => {
|
|
2686
|
+
const slug = 'target-proof'
|
|
2687
|
+
await store.createBuild(sampleBuildInput(slug))
|
|
2688
|
+
const sha = 'c'.repeat(40),
|
|
2689
|
+
from = 'b'.repeat(40)
|
|
2690
|
+
const lineage = [
|
|
2691
|
+
{ node: 'parent', from, receipts: [{ id: 'tx', previous: from, head: sha }] },
|
|
2692
|
+
]
|
|
2693
|
+
await store.append(slug, {
|
|
2694
|
+
actor: KERNEL,
|
|
2695
|
+
type: 'target.moved',
|
|
2696
|
+
payload: { branch: 'main', sha },
|
|
2697
|
+
})
|
|
2698
|
+
await store.append(slug, {
|
|
2699
|
+
actor: KERNEL,
|
|
2700
|
+
type: 'target.rewritten',
|
|
2701
|
+
payload: { branch: 'main', sha, previousSha: from },
|
|
2702
|
+
})
|
|
2703
|
+
await store.append(slug, {
|
|
2704
|
+
actor: KERNEL,
|
|
2705
|
+
type: 'target.rewrite-cleared',
|
|
2706
|
+
payload: { branch: 'main', sha, lineage },
|
|
2707
|
+
})
|
|
2708
|
+
const facts = (await readBuildFacts(store, slug)).value
|
|
2709
|
+
expect(facts.log.restack.target?.lineage).toEqual(lineage)
|
|
2710
|
+
expect(facts.state.targetRewrite).toBeUndefined()
|
|
2711
|
+
})
|
|
2712
|
+
})
|
|
2713
|
+
|
|
2714
|
+
test('rewrite receipt point lookup covers every atomic append path', async () => {
|
|
2715
|
+
await withStore(factory, undefined, async (store) => {
|
|
2716
|
+
if (!store.getNodeRewrite) return
|
|
2717
|
+
const slug = 'rewrite-index'
|
|
2718
|
+
await store.createBuild(sampleBuildInput(slug))
|
|
2719
|
+
const previous = 'a'.repeat(40)
|
|
2720
|
+
const receipt = { id: 'tx', previous, head: 'b'.repeat(40) }
|
|
2721
|
+
const write = { actor: KERNEL, type: 'node.rewritten', payload: receipt } as const
|
|
2722
|
+
expect(await store.getNodeRewrite(slug, previous)).toBeNull()
|
|
2723
|
+
await store.append(slug, write)
|
|
2724
|
+
expect(await store.getNodeRewrite(slug, previous)).toEqual(receipt)
|
|
2725
|
+
const next = { ...write, payload: { ...receipt, id: 'tx-2' } }
|
|
2726
|
+
expect(await store.appendIfCurrent(slug, 0, next)).toBeNull()
|
|
2727
|
+
expect(await store.getNodeRewrite(slug, previous)).toEqual(receipt)
|
|
2728
|
+
await store.appendIfCurrent(slug, 1, next)
|
|
2729
|
+
expect((await store.getNodeRewrite(slug, previous))?.id).toBe('tx-2')
|
|
2730
|
+
await store.appendWithArtifacts(slug, [], () => ({
|
|
2731
|
+
...write,
|
|
2732
|
+
payload: { ...receipt, id: 'tx-3' },
|
|
2733
|
+
}))
|
|
2734
|
+
expect((await store.getNodeRewrite(slug, previous))?.id).toBe('tx-3')
|
|
2735
|
+
await store.appendWithArtifactsIfCurrent(slug, 3, [], () => ({
|
|
2736
|
+
...write,
|
|
2737
|
+
payload: { ...receipt, id: 'tx-4' },
|
|
2738
|
+
}))
|
|
2739
|
+
const copy = await store.getNodeRewrite(slug, previous)
|
|
2740
|
+
expect(copy?.id).toBe('tx-4')
|
|
2741
|
+
expect(await store.getNodeRewrite(slug)).toEqual(copy)
|
|
2742
|
+
copy!.id = 'mutated'
|
|
2743
|
+
expect((await store.getNodeRewrite(slug, previous))?.id).toBe('tx-4')
|
|
2744
|
+
expect((await store.getNodeRewrite(slug, undefined, previous))?.id).toBe('tx-3')
|
|
2745
|
+
const later = { id: 'tx-5', previous: 'c'.repeat(40), head: 'd'.repeat(40) }
|
|
2746
|
+
await store.append(slug, { ...write, payload: later })
|
|
2747
|
+
expect(await store.getNodeRewrite(slug, undefined, later.previous)).toEqual({
|
|
2748
|
+
...receipt,
|
|
2749
|
+
id: 'tx-4',
|
|
2750
|
+
})
|
|
2751
|
+
expect(await store.getNodeRewrite(slug, undefined, 'e'.repeat(40))).toBeNull()
|
|
2752
|
+
await expect(store.getNodeRewrite('unknown', previous)).rejects.toThrow()
|
|
2753
|
+
})
|
|
2754
|
+
})
|
|
2755
|
+
|
|
2622
2756
|
test('assigns seq 1..n per build, independently across builds (§15.1)', async () => {
|
|
2623
2757
|
await withStore(factory, undefined, async (store) => {
|
|
2624
2758
|
await store.createBuild(sampleBuildInput('seq-a'))
|
|
@@ -2867,6 +3001,30 @@ export function describeBuildStoreContract(name: string, factory: BuildStoreFact
|
|
|
2867
3001
|
})
|
|
2868
3002
|
|
|
2869
3003
|
describe('getEvents', () => {
|
|
3004
|
+
test('bounded page traversal is complete and array reads never return partial history', async () => {
|
|
3005
|
+
await withStore(factory, undefined, async (store) => {
|
|
3006
|
+
await store.createBuild(sampleBuildInput('paged-history'))
|
|
3007
|
+
for (let i = 0; i < BUILD_EVENT_PAGE_SIZE + 3; i++)
|
|
3008
|
+
await store.append('paged-history', sampleEventWrite(`page-${i}`))
|
|
3009
|
+
try {
|
|
3010
|
+
expect(await store.getEvents('paged-history')).toHaveLength(BUILD_EVENT_PAGE_SIZE + 3)
|
|
3011
|
+
} catch (error) {
|
|
3012
|
+
expect(error).toBeInstanceOf(IncompleteEventReadError)
|
|
3013
|
+
}
|
|
3014
|
+
if (!store.getBuildEventPage) return
|
|
3015
|
+
const seen: number[] = []
|
|
3016
|
+
let cursor = 0
|
|
3017
|
+
for (;;) {
|
|
3018
|
+
const page = await store.getBuildEventPage('paged-history', cursor)
|
|
3019
|
+
expect(page.events.length).toBeLessThanOrEqual(BUILD_EVENT_PAGE_SIZE)
|
|
3020
|
+
seen.push(...page.events.map((event) => event.seq))
|
|
3021
|
+
cursor = page.cursor
|
|
3022
|
+
if (!page.hasMore) break
|
|
3023
|
+
}
|
|
3024
|
+
expect(seen).toEqual(Array.from({ length: BUILD_EVENT_PAGE_SIZE + 3 }, (_, i) => i + 1))
|
|
3025
|
+
})
|
|
3026
|
+
})
|
|
3027
|
+
|
|
2870
3028
|
test('since is strictly greater-than, in seq order; default 0 = all (§7.2)', async () => {
|
|
2871
3029
|
await withStore(factory, undefined, async (store) => {
|
|
2872
3030
|
await store.createBuild(sampleBuildInput('since'))
|
|
@@ -3022,6 +3180,30 @@ export function describeBuildStoreContract(name: string, factory: BuildStoreFact
|
|
|
3022
3180
|
})
|
|
3023
3181
|
|
|
3024
3182
|
describe('artifacts', () => {
|
|
3183
|
+
test('optional latest metadata follows artifact-only revisions without mutation', async () => {
|
|
3184
|
+
await withStore(factory, undefined, async (store) => {
|
|
3185
|
+
if (!store.getLatestArtifactMeta) return
|
|
3186
|
+
await store.createBuild(sampleBuildInput('latest-meta'))
|
|
3187
|
+
expect(await store.getLatestArtifactMeta('latest-meta', 'pin')).toBeNull()
|
|
3188
|
+
for (let revision = 0; revision < 3; revision++) {
|
|
3189
|
+
const meta = await store.putArtifact('latest-meta', {
|
|
3190
|
+
kind: 'pin',
|
|
3191
|
+
content: `revision ${revision}`,
|
|
3192
|
+
metadata: { nested: { revision } },
|
|
3193
|
+
})
|
|
3194
|
+
expect(await store.getLatestArtifactMeta('latest-meta', 'pin')).toEqual(meta)
|
|
3195
|
+
expect((await store.getArtifact('latest-meta', 'pin'))?.meta).toEqual(meta)
|
|
3196
|
+
const copy = (await store.getLatestArtifactMeta('latest-meta', 'pin'))!
|
|
3197
|
+
copy.metadata.nested = 'changed'
|
|
3198
|
+
expect(await store.getLatestArtifactMeta('latest-meta', 'pin')).toEqual(meta)
|
|
3199
|
+
}
|
|
3200
|
+
expect(await store.getEvents('latest-meta')).toEqual([])
|
|
3201
|
+
await expect(store.getLatestArtifactMeta('unknown', 'pin')).rejects.toThrow(
|
|
3202
|
+
'unknown build',
|
|
3203
|
+
)
|
|
3204
|
+
})
|
|
3205
|
+
})
|
|
3206
|
+
|
|
3025
3207
|
test('revisions are 0-based per kind (§6.3): first deposit rev 0, next rev 1', async () => {
|
|
3026
3208
|
await withStore(factory, undefined, async (store) => {
|
|
3027
3209
|
await store.createBuild(sampleBuildInput('revs'))
|