@defrex/autobuild 1.12.0 → 1.14.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 +465 -163
- package/bin/ab-build-runner.ts +8 -0
- package/docs/answering-blocked-builds.md +28 -4
- package/docs/architecture.md +136 -53
- package/docs/cli.md +1 -1
- package/docs/configuration.md +120 -17
- package/docs/dispatcher.md +19 -8
- package/docs/integration-overview.md +1 -1
- package/docs/integration-tree.md +12 -9
- package/docs/merge-policy.md +7 -2
- package/docs/operating.md +13 -3
- package/docs/operator-api.md +46 -23
- package/docs/operator-surfaces.md +7 -6
- package/docs/optimization-nodes.md +7 -6
- package/docs/plugin-authoring.md +46 -18
- package/docs/remote-store-protocol.md +52 -13
- package/docs/remote-ticket-protocol.md +85 -38
- package/docs/restacking.md +48 -3
- package/docs/setup.md +2 -1
- package/docs/ticket-migration.md +2 -2
- package/docs/ticket-sources.md +23 -8
- package/docs/tickets.md +4 -4
- package/docs/troubleshooting.md +32 -2
- package/docs/verification.md +3 -1
- package/package.json +3 -3
- package/packages/core/src/cli/build-control.ts +72 -6
- package/packages/core/src/cli/dashboard/actions.ts +4 -0
- package/packages/core/src/cli/dashboard/integration-row.ts +43 -19
- package/packages/core/src/cli/dashboard/model.ts +14 -8
- package/packages/core/src/cli/dashboard/poll.ts +218 -10
- package/packages/core/src/cli/dashboard/queue.ts +21 -10
- package/packages/core/src/cli/dashboard/row-text.ts +2 -1
- package/packages/core/src/cli/dashboard/vocabulary.ts +5 -1
- package/packages/core/src/cli/dispatch-frontend.ts +2 -1
- package/packages/core/src/cli/dispatch-tickets.ts +33 -12
- package/packages/core/src/cli/dispatch.ts +547 -145
- package/packages/core/src/cli/help.ts +38 -24
- package/packages/core/src/cli/main.ts +7 -5
- package/packages/core/src/cli/publication-settlement.ts +4 -0
- package/packages/core/src/cli/remote-poll.ts +22 -5
- package/packages/core/src/cli/repository-status.ts +19 -9
- package/packages/core/src/cli/status.ts +23 -11
- package/packages/core/src/cli/store-opening.ts +12 -0
- package/packages/core/src/cli/ticket-start.ts +3 -3
- package/packages/core/src/cli/ticket.ts +12 -11
- package/packages/core/src/cli/wait.ts +8 -28
- package/packages/core/src/cli/watch.ts +113 -50
- package/packages/core/src/config/reference-metadata.ts +7 -1
- package/packages/core/src/config/reference.ts +5 -2
- package/packages/core/src/config/schema.ts +51 -16
- package/packages/core/src/events/payloads.ts +74 -14
- package/packages/core/src/events/policy.ts +1 -0
- package/packages/core/src/events/repository.ts +33 -3
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +31 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/be211f0e31a65006.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/0a10010ee5cf2e47.json +577 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/227701361be6d1e0.json +490 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/312cc4090820a612.json +1078 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/76e5043bae7a80ab.json +86 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/87a917802870bbed.json +87 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9d85616e5b9e24c1.json +500 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a2780567b4989fb6.json +105 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c7c94fbe7f63cf07.json +84 -0
- package/packages/core/src/kernel/clean-restack-policy.ts +40 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +243 -107
- package/packages/core/src/kernel/done-escalations.ts +273 -0
- package/packages/core/src/kernel/engine.ts +28 -9
- package/packages/core/src/kernel/integration-landing.ts +24 -4
- package/packages/core/src/kernel/integration-stack.ts +39 -0
- package/packages/core/src/kernel/janitor-failure.ts +20 -1
- package/packages/core/src/kernel/log-index-value.ts +3 -0
- package/packages/core/src/kernel/log-index.ts +41 -2
- package/packages/core/src/kernel/open-pr-backpressure.ts +3 -3
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer-revisions.ts +19 -0
- package/packages/core/src/kernel/reducer.ts +42 -8
- package/packages/core/src/kernel/repository-attention.ts +14 -5
- package/packages/core/src/kernel/repository-read-facts.ts +9 -0
- package/packages/core/src/kernel/ticket-starts.ts +15 -4
- package/packages/core/src/kernel/verify-stages.ts +46 -7
- package/packages/core/src/operator/attention.ts +28 -3
- package/packages/core/src/operator/done-escalations.ts +38 -0
- package/packages/core/src/operator/presentation.ts +1 -1
- package/packages/core/src/operator/protocol.ts +8 -5
- package/packages/core/src/operator/query.ts +33 -19
- package/packages/core/src/operator/registry.ts +17 -13
- package/packages/core/src/operator/ticket-start.ts +8 -7
- package/packages/core/src/operator/tickets.ts +28 -9
- package/packages/core/src/plugin-sdk/index.ts +10 -0
- package/packages/core/src/plugins/manifest.ts +14 -1
- package/packages/core/src/ports/forge/create.ts +8 -0
- package/packages/core/src/ports/forge/github-transport.ts +5 -1
- package/packages/core/src/ports/forge/github.ts +3 -0
- package/packages/core/src/ports/tickets/contract.ts +147 -76
- package/packages/core/src/ports/tickets/create.ts +47 -7
- package/packages/core/src/ports/tickets/fake.ts +8 -4
- package/packages/core/src/ports/tickets/file-codec.ts +4 -3
- package/packages/core/src/ports/tickets/file.ts +7 -3
- package/packages/core/src/ports/tickets/github.ts +1 -0
- package/packages/core/src/ports/tickets/grants.ts +11 -3
- package/packages/core/src/ports/tickets/hosted-index.ts +5 -0
- package/packages/core/src/ports/tickets/linear.ts +28 -9
- package/packages/core/src/ports/tickets/migration.ts +4 -4
- package/packages/core/src/ports/tickets/operations.ts +4 -2
- package/packages/core/src/ports/tickets/priority-labels.ts +213 -0
- package/packages/core/src/ports/tickets/priority.ts +127 -21
- package/packages/core/src/ports/tickets/remote-protocol.ts +10 -0
- package/packages/core/src/ports/tickets/remote.ts +104 -11
- package/packages/core/src/ports/tickets/revision.ts +5 -3
- package/packages/core/src/ports/tickets/search.ts +9 -0
- package/packages/core/src/ports/tickets/tree.ts +8 -6
- package/packages/core/src/ports/types.ts +30 -15
- package/packages/core/src/ports/workspace/build-execution.ts +13 -1
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +4 -0
- package/packages/core/src/ports/workspace/create.ts +16 -3
- package/packages/core/src/ports/workspace/execution-exit-marker.ts +41 -0
- package/packages/core/src/ports/workspace/recovery-step.ts +101 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +596 -144
- package/packages/core/src/processes/build-execution-state.ts +4 -0
- package/packages/core/src/processes/build-runner.ts +14 -1
- package/packages/core/src/processes/dispatcher.ts +841 -230
- package/packages/core/src/processes/execution-settlement.ts +25 -3
- package/packages/core/src/processes/harvest-runner.ts +12 -7
- package/packages/core/src/processes/infrastructure-failure-budget.ts +7 -2
- package/packages/core/src/processes/invocation-budget.ts +176 -0
- package/packages/core/src/processes/publication-loss.ts +38 -3
- package/packages/core/src/processes/tick-publication.ts +1 -0
- package/packages/core/src/processes/workspace-preservation.ts +86 -15
- package/packages/core/src/store/contract.ts +88 -3
- package/packages/core/src/store/event-reads.ts +30 -1
- package/packages/core/src/store/reduced-reads.ts +23 -0
- package/packages/core/src/store/reducer-value-shapes.json +6759 -6490
- package/packages/core/src/store/reducer-value-validation.ts +188 -33
- package/packages/core/src/store/remote/client.ts +169 -29
- package/packages/core/src/store/remote/compatibility.ts +113 -56
- package/packages/core/src/store/remote/credentials.ts +4 -1
- package/packages/core/src/store/remote/protocol.ts +3 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.13.0.json +35966 -0
- package/packages/core/src/store/remote/released-reducer-values/1.14.0.json +36076 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
- package/packages/core/src/store/remote/released-value-policy.ts +144 -0
- package/packages/core/src/store/remote/retry.ts +406 -0
- package/packages/core/src/store/repo-state-events.ts +1 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +155 -11
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/invocation-budget.ts +42 -0
- package/packages/core/src/testing/reduced-read-budget.ts +589 -19
- package/packages/core/src/testing/released-value-coverage.ts +423 -0
- package/packages/core/src/web/overview-source.ts +19 -6
- package/skills/guide/SKILL.md +147 -67
- package/skills/guide/references/integration-tree.md +12 -9
- package/skills/guide/references/merge-policy.md +7 -2
- package/skills/guide/references/operator-api.md +46 -23
- package/skills/guide/references/optimization-nodes.md +7 -6
- package/skills/guide/references/plugin-authoring.md +46 -18
- package/skills/guide/references/remote-store-protocol.md +52 -13
- package/skills/guide/references/remote-ticket-protocol.md +85 -38
- package/skills/guide/references/restacking.md +48 -3
- package/skills/guide/references/setup.md +2 -1
- package/skills/guide/references/ticket-migration.md +2 -2
- package/skills/operate/SKILL.md +136 -55
- package/skills/plan/SKILL.md +4 -3
- package/skills/spec/SKILL.md +9 -5
- package/skills/tickets/SKILL.md +25 -17
- package/templates/hosted-service/package.json +2 -2
|
@@ -11,6 +11,8 @@ import { DISPATCHER, humanActor, KERNEL } from '../events/envelope'
|
|
|
11
11
|
import { WebModelHub } from '../web/hub'
|
|
12
12
|
import { readOnlyStore } from '../web/read-only'
|
|
13
13
|
import { OverviewFrameSource } from '../web/overview-source'
|
|
14
|
+
import { DashboardBuildPollCache, type DashboardPollSnapshot } from '../cli/dashboard/poll'
|
|
15
|
+
import { configSchema } from '../config/schema'
|
|
14
16
|
import { projectRepositoryFrame } from '../web/repository-source'
|
|
15
17
|
import { finishedOutcomeText } from '../cli/dashboard/vocabulary'
|
|
16
18
|
import { measureStoreReads } from './reduced-read-budget'
|
|
@@ -967,12 +969,16 @@ const OVERVIEW_BUDGET_CONFIG = {
|
|
|
967
969
|
|
|
968
970
|
/**
|
|
969
971
|
* `ab web`'s overview costs the same at 100 and 100,000 builds (5 live, the
|
|
970
|
-
* rest finished
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
*
|
|
975
|
-
*
|
|
972
|
+
* rest finished, one finished long ago with an open escalation): a fresh
|
|
973
|
+
* process reads the `buildRoster` and `doneEscalations` rollups and only the
|
|
974
|
+
* live and escalated builds; an idle poll reads the change position; a change
|
|
975
|
+
* to one build reads that build only, plus one roster read when the build
|
|
976
|
+
* starts or finishes, including one created and finished between two polls,
|
|
977
|
+
* or is acknowledged; and no read scans history. The terminal dashboard's
|
|
978
|
+
* poll cache then measures the same repositories: cold start, idle refresh,
|
|
979
|
+
* one live change and an acknowledgement each cost the same at both sizes and
|
|
980
|
+
* never list builds or read events (#1372). Row metrics need a memory
|
|
981
|
+
* backing, so other backings skip it.
|
|
976
982
|
*/
|
|
977
983
|
async function webOverviewReadBudget(store: BuildStore, backing: BuildStore): Promise<void> {
|
|
978
984
|
const { MemoryBuildStore } = await import('../store/memory')
|
|
@@ -1002,13 +1008,41 @@ async function webOverviewReadBudget(store: BuildStore, backing: BuildStore): Pr
|
|
|
1002
1008
|
for (let i = 0; i < n - 5; i++) {
|
|
1003
1009
|
const slug = `${prefix}done-${String(i).padStart(6, '0')}`
|
|
1004
1010
|
await create(slug)
|
|
1005
|
-
// Every fourth build aborts, then finishes its cleanup.
|
|
1011
|
+
// Every fourth build aborts, then finishes its cleanup. The first was
|
|
1012
|
+
// blocked when aborted: the abort closed its escalation (#1387).
|
|
1006
1013
|
if (i % 4 === 3) {
|
|
1014
|
+
if (i === 3)
|
|
1015
|
+
await backing.append(slug, {
|
|
1016
|
+
actor: KERNEL,
|
|
1017
|
+
type: 'escalation.raised',
|
|
1018
|
+
payload: { id: 'abort-closed', phase: 'implement', source: 'agent', question: 'q' },
|
|
1019
|
+
})
|
|
1007
1020
|
await backing.append(slug, { actor: KERNEL, type: 'build.aborted', payload: {} })
|
|
1008
1021
|
await complete(slug, 'abandoned')
|
|
1009
1022
|
} else await complete(slug)
|
|
1010
1023
|
}
|
|
1011
1024
|
for (let i = 0; i < 5; i++) await create(live(i))
|
|
1025
|
+
// A post-completion escalation on a build far older than the roster's
|
|
1026
|
+
// newest finished entries.
|
|
1027
|
+
const escalated = `${prefix}done-000000`
|
|
1028
|
+
const raise = (slug: string) =>
|
|
1029
|
+
backing.append(slug, {
|
|
1030
|
+
actor: KERNEL,
|
|
1031
|
+
type: 'escalation.raised',
|
|
1032
|
+
payload: {
|
|
1033
|
+
id: 'integration-audit-op',
|
|
1034
|
+
phase: 'verify:integration',
|
|
1035
|
+
source: 'agent',
|
|
1036
|
+
question: 'Integration result requires attention',
|
|
1037
|
+
},
|
|
1038
|
+
})
|
|
1039
|
+
const acknowledge = (slug: string) =>
|
|
1040
|
+
backing.append(slug, {
|
|
1041
|
+
actor: humanActor('op'),
|
|
1042
|
+
type: 'escalation.answered',
|
|
1043
|
+
payload: { id: 'integration-audit-op', answer: 'ack', resolution: 'retry' },
|
|
1044
|
+
})
|
|
1045
|
+
await raise(escalated)
|
|
1012
1046
|
const config = await backing.putRepoArtifact(repo, {
|
|
1013
1047
|
kind: 'config',
|
|
1014
1048
|
content: JSON.stringify(OVERVIEW_BUDGET_CONFIG),
|
|
@@ -1026,7 +1060,9 @@ async function webOverviewReadBudget(store: BuildStore, backing: BuildStore): Pr
|
|
|
1026
1060
|
// The canonical materializations happen once, before any measured read.
|
|
1027
1061
|
await readRepositoryFacts(store, repo)
|
|
1028
1062
|
await store.getReducerValue({ kind: 'rollup', repo }, { reducer: 'buildRoster' })
|
|
1063
|
+
await store.getReducerValue({ kind: 'rollup', repo }, { reducer: 'doneEscalations' })
|
|
1029
1064
|
for (let i = 0; i < 5; i++) await readBuildFacts(store, live(i))
|
|
1065
|
+
await readBuildFacts(store, escalated)
|
|
1030
1066
|
|
|
1031
1067
|
const counter = countingStore(store, { slugs: true })
|
|
1032
1068
|
// A fresh process: no state but the saved values.
|
|
@@ -1068,13 +1104,21 @@ async function webOverviewReadBudget(store: BuildStore, backing: BuildStore): Pr
|
|
|
1068
1104
|
const named = (calls: Record<string, number>, slug: string) =>
|
|
1069
1105
|
Object.keys(buildScope(calls)).every((name) => name.endsWith(`:${slug.replace(prefix, '')}`))
|
|
1070
1106
|
|
|
1071
|
-
// (a) The first read:
|
|
1107
|
+
// (a) The first read: both rollups, the five live builds and the
|
|
1108
|
+
// escalated done build, never the build whose abort closed its question.
|
|
1072
1109
|
const first = await measure('first')
|
|
1073
|
-
expect(first.calls['getReducerValue:rollup']).toBe(
|
|
1074
|
-
expect(buildScope(first.calls)).toEqual(reads(...[0, 1, 2, 3, 4].map(live)))
|
|
1110
|
+
expect(first.calls['getReducerValue:rollup']).toBe(2)
|
|
1111
|
+
expect(buildScope(first.calls)).toEqual(reads(...[0, 1, 2, 3, 4].map(live), escalated))
|
|
1112
|
+
expect(
|
|
1113
|
+
[...frame.overview!.active, ...frame.overview!.queued].map((row) => row.slug),
|
|
1114
|
+
).not.toContain(`${prefix}done-000003`)
|
|
1075
1115
|
expect(first.rows).toBe(0)
|
|
1076
1116
|
expect(first.repoRows).toBe(0)
|
|
1077
|
-
expect(frame.overview!.active.length + frame.overview!.queued.length).toBe(
|
|
1117
|
+
expect(frame.overview!.active.length + frame.overview!.queued.length).toBe(6)
|
|
1118
|
+
expect(frame.overview!.active.find((row) => row.slug === escalated)?.status).toMatchObject({
|
|
1119
|
+
word: 'BLOCKED',
|
|
1120
|
+
note: 'done',
|
|
1121
|
+
})
|
|
1078
1122
|
expect(frame.overview!.finished).toHaveLength(10)
|
|
1079
1123
|
|
|
1080
1124
|
// (b) Idle: the change position only.
|
|
@@ -1131,11 +1175,58 @@ async function webOverviewReadBudget(store: BuildStore, backing: BuildStore): Pr
|
|
|
1131
1175
|
word: finishedOutcomeText('merged').word,
|
|
1132
1176
|
})
|
|
1133
1177
|
expect(shown()).not.toContain(blinked)
|
|
1178
|
+
|
|
1179
|
+
// (g) Acknowledging the escalation: that build's reads, and it leaves.
|
|
1180
|
+
await acknowledge(escalated)
|
|
1181
|
+
const acknowledged = await measure('acknowledged')
|
|
1182
|
+
expect(named(acknowledged.calls, escalated)).toBe(true)
|
|
1183
|
+
expect(shown()).not.toContain(escalated)
|
|
1134
1184
|
expect(await measure('after')).toEqual({
|
|
1135
1185
|
calls: { getRepoChangePosition: 1 },
|
|
1136
1186
|
rows: 0,
|
|
1137
1187
|
repoRows: 0,
|
|
1138
1188
|
})
|
|
1189
|
+
|
|
1190
|
+
// The terminal dashboard over the same repository, as a fresh process.
|
|
1191
|
+
const terminalEscalated = `${prefix}done-000004`
|
|
1192
|
+
await raise(terminalEscalated)
|
|
1193
|
+
const terminalConfig = configSchema.parse(OVERVIEW_BUDGET_CONFIG)
|
|
1194
|
+
// Warm-up: an earlier process saved every value the cold start reads.
|
|
1195
|
+
await new DashboardBuildPollCache(store, repo, terminalConfig).refresh()
|
|
1196
|
+
const terminalCounter = countingStore(store, { slugs: true })
|
|
1197
|
+
const cache = new DashboardBuildPollCache(terminalCounter.proxy, repo, terminalConfig)
|
|
1198
|
+
let snapshot!: DashboardPollSnapshot
|
|
1199
|
+
const refresh = async (phase: string) => {
|
|
1200
|
+
terminalCounter.calls.length = 0
|
|
1201
|
+
const metrics = await measureStoreReads(backing, async () => {
|
|
1202
|
+
snapshot = await cache.refresh()
|
|
1203
|
+
})
|
|
1204
|
+
for (const name of terminalCounter.calls) expect(HISTORY_READS.has(name)).toBe(false)
|
|
1205
|
+
const calls = Object.fromEntries(
|
|
1206
|
+
Object.entries(terminalCounter.histogram()).map(([name, count]) => [
|
|
1207
|
+
name.replaceAll(prefix, ''),
|
|
1208
|
+
count,
|
|
1209
|
+
]),
|
|
1210
|
+
)
|
|
1211
|
+
phases[`terminal-${phase}`] = { calls, rows: metrics.rows, repoRows: metrics.repoRows }
|
|
1212
|
+
return phases[`terminal-${phase}`]!
|
|
1213
|
+
}
|
|
1214
|
+
const visible = () => snapshot.builds.map((build) => build.slug)
|
|
1215
|
+
const holding = () => (snapshot.capacityBuilds ?? []).map((build) => build.record.slug)
|
|
1216
|
+
const cold = await refresh('cold')
|
|
1217
|
+
expect(cold.rows).toBe(0)
|
|
1218
|
+
expect(visible()).toContain(terminalEscalated)
|
|
1219
|
+
expect(holding()).not.toContain(terminalEscalated)
|
|
1220
|
+
expect(await refresh('idle')).toEqual({
|
|
1221
|
+
calls: { listBuildsChangedSince: 1 },
|
|
1222
|
+
rows: 0,
|
|
1223
|
+
repoRows: 0,
|
|
1224
|
+
})
|
|
1225
|
+
await backing.append(live(2), { actor: KERNEL, type: 'plan.started', payload: { round: 1 } })
|
|
1226
|
+
expect(named((await refresh('change')).calls, live(2))).toBe(true)
|
|
1227
|
+
await acknowledge(terminalEscalated)
|
|
1228
|
+
expect(named((await refresh('acknowledged')).calls, terminalEscalated)).toBe(true)
|
|
1229
|
+
expect(visible()).not.toContain(terminalEscalated)
|
|
1139
1230
|
results[n] = phases
|
|
1140
1231
|
}
|
|
1141
1232
|
expect(results[100_000]).toEqual(results[100]!)
|
|
@@ -2410,6 +2501,59 @@ export async function githubTicketSearchRequestBudget(
|
|
|
2410
2501
|
expect(sequences[1]).toEqual(sequences[0]!)
|
|
2411
2502
|
}
|
|
2412
2503
|
|
|
2504
|
+
export interface TicketPriorityLabelFixture {
|
|
2505
|
+
/** A raw source without native priority. */
|
|
2506
|
+
source: TicketSource
|
|
2507
|
+
/** The ready criteria dispatch lists with. */
|
|
2508
|
+
criteria: import('../ports/types').TicketCriteria
|
|
2509
|
+
/** A seeded ready ticket carrying the `priority:high` label. */
|
|
2510
|
+
highId: string
|
|
2511
|
+
reset(): void
|
|
2512
|
+
/** Provider requests since the last reset, in order. */
|
|
2513
|
+
requests(): string[]
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
/** The label fallback reads priority from data a read already returned: for
|
|
2517
|
+
* every recurring read the raw source offers, at 1 and 100 tickets, the
|
|
2518
|
+
* facade issues exactly the raw source's request sequence (none when the raw
|
|
2519
|
+
* read issues none), so it adds zero requests whatever the raw read costs. A
|
|
2520
|
+
* seeded `priority:high` label reads as `high` and never appears among
|
|
2521
|
+
* `labels`. */
|
|
2522
|
+
export async function ticketPriorityLabelReadBudget(
|
|
2523
|
+
fixture: (population: number) => Promise<TicketPriorityLabelFixture>,
|
|
2524
|
+
): Promise<void> {
|
|
2525
|
+
const { compatibleTicketSource } = await import('../ports/tickets/tree')
|
|
2526
|
+
for (const population of [1, 100]) {
|
|
2527
|
+
const { source, criteria, highId, reset, requests } = await fixture(population)
|
|
2528
|
+
expect(source.priority).toBeFalsy()
|
|
2529
|
+
const facade = compatibleTicketSource(source)
|
|
2530
|
+
expect(facade.priority).toBe(true)
|
|
2531
|
+
const reads: Array<[string, (from: TicketSource) => Promise<unknown>]> = [
|
|
2532
|
+
['listReady', (from) => from.listReady(criteria)],
|
|
2533
|
+
['get', (from) => from.get(highId)],
|
|
2534
|
+
['dependencyStates', (from) => from.dependencyStates([highId])],
|
|
2535
|
+
]
|
|
2536
|
+
if (source.listAll) reads.push(['listAll', (from) => from.listAll!()])
|
|
2537
|
+
if (source.listPage) reads.push(['listPage', (from) => from.listPage!(criteria, { limit: 10 })])
|
|
2538
|
+
for (const [name, read] of reads) {
|
|
2539
|
+
await read(source)
|
|
2540
|
+
reset()
|
|
2541
|
+
await read(source)
|
|
2542
|
+
const raw = requests()
|
|
2543
|
+
reset()
|
|
2544
|
+
await read(facade)
|
|
2545
|
+
expect({ name, requests: requests() }).toEqual({ name, requests: raw })
|
|
2546
|
+
}
|
|
2547
|
+
const high = await facade.get(highId)
|
|
2548
|
+
expect(high?.priority).toBe('high')
|
|
2549
|
+
expect(high?.labels.some((label) => label.toLowerCase().startsWith('priority:'))).toBe(false)
|
|
2550
|
+
const ready = (await facade.listReady(criteria)).tickets.find(
|
|
2551
|
+
(ticket) => ticket.ref.id === highId,
|
|
2552
|
+
)
|
|
2553
|
+
expect(ready?.priority).toBe('high')
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2413
2557
|
/** Builds one dispatcher pass's observation inputs for a node build over a
|
|
2414
2558
|
* fresh memory store, reporting which listing path the source decided on
|
|
2415
2559
|
* before the pass; `observe` then observes the node with those inputs. */
|
|
@@ -74,11 +74,13 @@ export {
|
|
|
74
74
|
targetedCompletenessParity,
|
|
75
75
|
ticketListReadBudget,
|
|
76
76
|
ticketPageReadBudget,
|
|
77
|
+
ticketPriorityLabelReadBudget,
|
|
77
78
|
ticketSearchReadBudget,
|
|
78
79
|
ticketSearchRequestBudget,
|
|
79
80
|
ticketSearchRows,
|
|
80
81
|
ticketTargetingReadBudget,
|
|
81
82
|
type TicketPageFixture,
|
|
83
|
+
type TicketPriorityLabelFixture,
|
|
82
84
|
type TicketSearchFixture,
|
|
83
85
|
type TicketSearchRequestFixture,
|
|
84
86
|
type TicketSearchRow,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { PluginFactoryContext } from '../plugins/manifest'
|
|
2
|
+
import { InvocationDeadlineError, withInvocationSignal } from '../processes/invocation-budget'
|
|
3
|
+
|
|
4
|
+
/** A base fetch whose every request stalls until its signal aborts, recording
|
|
5
|
+
* the signal each request carried. No network, no timers. */
|
|
6
|
+
export function stallingFetch(): { base: typeof fetch; signals: (AbortSignal | undefined)[] } {
|
|
7
|
+
const signals: (AbortSignal | undefined)[] = []
|
|
8
|
+
const base = ((_input: unknown, init?: RequestInit) => {
|
|
9
|
+
const signal = init?.signal ?? undefined
|
|
10
|
+
signals.push(signal)
|
|
11
|
+
return new Promise<Response>((_, reject) =>
|
|
12
|
+
signal?.addEventListener('abort', () => reject(signal.reason), { once: true }),
|
|
13
|
+
)
|
|
14
|
+
}) as unknown as typeof fetch
|
|
15
|
+
return { base, signals }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Drive a cooperative plugin through the plugin API 1.12 factory context:
|
|
19
|
+
* inside a work phase it reads `invocationSignal()` and fetches through the
|
|
20
|
+
* host `fetch`; the phase then hits its deadline. Returns what the plugin
|
|
21
|
+
* observed so each port's test can assert the contract. */
|
|
22
|
+
export async function cancelCooperativePluginCall(
|
|
23
|
+
context: PluginFactoryContext,
|
|
24
|
+
signals: (AbortSignal | undefined)[],
|
|
25
|
+
): Promise<{
|
|
26
|
+
seen: AbortSignal | undefined
|
|
27
|
+
requestSignal: AbortSignal | undefined
|
|
28
|
+
error: unknown
|
|
29
|
+
}> {
|
|
30
|
+
const work = new AbortController()
|
|
31
|
+
let seen: AbortSignal | undefined
|
|
32
|
+
const call = withInvocationSignal(work.signal, async () => {
|
|
33
|
+
seen = context.invocationSignal?.()
|
|
34
|
+
return context.fetch!('https://provider.plugin.test/call')
|
|
35
|
+
})
|
|
36
|
+
work.abort(new InvocationDeadlineError('work'))
|
|
37
|
+
const error = await call.then(
|
|
38
|
+
() => undefined,
|
|
39
|
+
(rejection: unknown) => rejection,
|
|
40
|
+
)
|
|
41
|
+
return { seen, requestSignal: signals.at(-1), error }
|
|
42
|
+
}
|