@defrex/autobuild 1.12.0 → 1.13.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.
Files changed (159) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +435 -160
  3. package/bin/ab-build-runner.ts +8 -0
  4. package/docs/answering-blocked-builds.md +25 -3
  5. package/docs/architecture.md +124 -53
  6. package/docs/cli.md +1 -1
  7. package/docs/configuration.md +110 -15
  8. package/docs/dispatcher.md +19 -8
  9. package/docs/integration-overview.md +1 -1
  10. package/docs/integration-tree.md +12 -9
  11. package/docs/merge-policy.md +7 -2
  12. package/docs/operating.md +5 -3
  13. package/docs/operator-api.md +46 -23
  14. package/docs/operator-surfaces.md +7 -6
  15. package/docs/optimization-nodes.md +7 -6
  16. package/docs/plugin-authoring.md +46 -18
  17. package/docs/remote-store-protocol.md +51 -12
  18. package/docs/remote-ticket-protocol.md +85 -38
  19. package/docs/restacking.md +48 -3
  20. package/docs/setup.md +2 -1
  21. package/docs/ticket-migration.md +2 -2
  22. package/docs/ticket-sources.md +23 -8
  23. package/docs/tickets.md +4 -4
  24. package/docs/troubleshooting.md +17 -2
  25. package/docs/verification.md +3 -1
  26. package/package.json +3 -3
  27. package/packages/core/src/cli/build-control.ts +72 -6
  28. package/packages/core/src/cli/dashboard/actions.ts +4 -0
  29. package/packages/core/src/cli/dashboard/integration-row.ts +43 -19
  30. package/packages/core/src/cli/dashboard/model.ts +14 -8
  31. package/packages/core/src/cli/dashboard/poll.ts +218 -10
  32. package/packages/core/src/cli/dashboard/queue.ts +21 -10
  33. package/packages/core/src/cli/dashboard/row-text.ts +2 -1
  34. package/packages/core/src/cli/dashboard/vocabulary.ts +5 -1
  35. package/packages/core/src/cli/dispatch-frontend.ts +2 -1
  36. package/packages/core/src/cli/dispatch-tickets.ts +33 -12
  37. package/packages/core/src/cli/dispatch.ts +527 -144
  38. package/packages/core/src/cli/help.ts +38 -24
  39. package/packages/core/src/cli/main.ts +7 -5
  40. package/packages/core/src/cli/publication-settlement.ts +4 -0
  41. package/packages/core/src/cli/remote-poll.ts +22 -5
  42. package/packages/core/src/cli/repository-status.ts +19 -9
  43. package/packages/core/src/cli/status.ts +23 -11
  44. package/packages/core/src/cli/store-opening.ts +12 -0
  45. package/packages/core/src/cli/ticket-start.ts +3 -3
  46. package/packages/core/src/cli/ticket.ts +12 -11
  47. package/packages/core/src/cli/wait.ts +8 -28
  48. package/packages/core/src/cli/watch.ts +113 -50
  49. package/packages/core/src/config/reference-metadata.ts +7 -1
  50. package/packages/core/src/config/reference.ts +5 -2
  51. package/packages/core/src/config/schema.ts +51 -16
  52. package/packages/core/src/events/payloads.ts +74 -14
  53. package/packages/core/src/events/repository.ts +14 -3
  54. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +27 -0
  55. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/0a10010ee5cf2e47.json +577 -0
  56. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/227701361be6d1e0.json +490 -0
  57. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/76e5043bae7a80ab.json +86 -0
  58. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/87a917802870bbed.json +87 -0
  59. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9d85616e5b9e24c1.json +500 -0
  60. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c7c94fbe7f63cf07.json +84 -0
  61. package/packages/core/src/kernel/clean-restack-policy.ts +40 -0
  62. package/packages/core/src/kernel/dispatch-capacity.ts +243 -107
  63. package/packages/core/src/kernel/done-escalations.ts +269 -0
  64. package/packages/core/src/kernel/engine.ts +28 -9
  65. package/packages/core/src/kernel/integration-landing.ts +24 -4
  66. package/packages/core/src/kernel/integration-stack.ts +39 -0
  67. package/packages/core/src/kernel/janitor-failure.ts +20 -1
  68. package/packages/core/src/kernel/log-index-value.ts +3 -0
  69. package/packages/core/src/kernel/log-index.ts +41 -2
  70. package/packages/core/src/kernel/open-pr-backpressure.ts +3 -3
  71. package/packages/core/src/kernel/reducer-registry.ts +3 -0
  72. package/packages/core/src/kernel/reducer-revisions.ts +15 -0
  73. package/packages/core/src/kernel/reducer.ts +27 -7
  74. package/packages/core/src/kernel/repository-attention.ts +14 -5
  75. package/packages/core/src/kernel/ticket-starts.ts +15 -4
  76. package/packages/core/src/kernel/verify-stages.ts +46 -7
  77. package/packages/core/src/operator/attention.ts +28 -3
  78. package/packages/core/src/operator/done-escalations.ts +38 -0
  79. package/packages/core/src/operator/presentation.ts +1 -1
  80. package/packages/core/src/operator/protocol.ts +8 -5
  81. package/packages/core/src/operator/query.ts +33 -19
  82. package/packages/core/src/operator/registry.ts +17 -13
  83. package/packages/core/src/operator/ticket-start.ts +8 -7
  84. package/packages/core/src/operator/tickets.ts +28 -9
  85. package/packages/core/src/plugin-sdk/index.ts +10 -0
  86. package/packages/core/src/plugins/manifest.ts +14 -1
  87. package/packages/core/src/ports/forge/create.ts +8 -0
  88. package/packages/core/src/ports/forge/github-transport.ts +5 -1
  89. package/packages/core/src/ports/forge/github.ts +3 -0
  90. package/packages/core/src/ports/tickets/contract.ts +147 -76
  91. package/packages/core/src/ports/tickets/create.ts +47 -7
  92. package/packages/core/src/ports/tickets/fake.ts +8 -4
  93. package/packages/core/src/ports/tickets/file-codec.ts +4 -3
  94. package/packages/core/src/ports/tickets/file.ts +7 -3
  95. package/packages/core/src/ports/tickets/github.ts +1 -0
  96. package/packages/core/src/ports/tickets/grants.ts +11 -3
  97. package/packages/core/src/ports/tickets/hosted-index.ts +5 -0
  98. package/packages/core/src/ports/tickets/linear.ts +28 -9
  99. package/packages/core/src/ports/tickets/migration.ts +4 -4
  100. package/packages/core/src/ports/tickets/operations.ts +4 -2
  101. package/packages/core/src/ports/tickets/priority-labels.ts +213 -0
  102. package/packages/core/src/ports/tickets/priority.ts +127 -21
  103. package/packages/core/src/ports/tickets/remote-protocol.ts +10 -0
  104. package/packages/core/src/ports/tickets/remote.ts +104 -11
  105. package/packages/core/src/ports/tickets/revision.ts +5 -3
  106. package/packages/core/src/ports/tickets/search.ts +9 -0
  107. package/packages/core/src/ports/tickets/tree.ts +8 -6
  108. package/packages/core/src/ports/types.ts +30 -15
  109. package/packages/core/src/ports/workspace/build-execution.ts +4 -0
  110. package/packages/core/src/ports/workspace/builtin-capabilities.ts +4 -0
  111. package/packages/core/src/ports/workspace/create.ts +16 -3
  112. package/packages/core/src/ports/workspace/execution-exit-marker.ts +41 -0
  113. package/packages/core/src/ports/workspace/recovery-step.ts +101 -0
  114. package/packages/core/src/ports/workspace/vercel-sandbox.ts +510 -145
  115. package/packages/core/src/processes/build-execution-state.ts +4 -0
  116. package/packages/core/src/processes/build-runner.ts +14 -1
  117. package/packages/core/src/processes/dispatcher.ts +544 -212
  118. package/packages/core/src/processes/execution-settlement.ts +1 -0
  119. package/packages/core/src/processes/harvest-runner.ts +12 -7
  120. package/packages/core/src/processes/infrastructure-failure-budget.ts +7 -2
  121. package/packages/core/src/processes/invocation-budget.ts +176 -0
  122. package/packages/core/src/processes/publication-loss.ts +38 -3
  123. package/packages/core/src/processes/workspace-preservation.ts +86 -15
  124. package/packages/core/src/store/contract.ts +81 -3
  125. package/packages/core/src/store/event-reads.ts +30 -1
  126. package/packages/core/src/store/reduced-reads.ts +23 -0
  127. package/packages/core/src/store/reducer-value-shapes.json +6628 -6469
  128. package/packages/core/src/store/reducer-value-validation.ts +181 -33
  129. package/packages/core/src/store/remote/client.ts +169 -29
  130. package/packages/core/src/store/remote/compatibility.ts +113 -56
  131. package/packages/core/src/store/remote/credentials.ts +4 -1
  132. package/packages/core/src/store/remote/protocol.ts +3 -0
  133. package/packages/core/src/store/remote/released-clients.json +11 -0
  134. package/packages/core/src/store/remote/released-reducer-values/1.13.0.json +35966 -0
  135. package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
  136. package/packages/core/src/store/remote/released-value-policy.ts +144 -0
  137. package/packages/core/src/store/remote/retry.ts +406 -0
  138. package/packages/core/src/testing/dispatch-read-budget.ts +144 -10
  139. package/packages/core/src/testing/index.ts +2 -0
  140. package/packages/core/src/testing/invocation-budget.ts +42 -0
  141. package/packages/core/src/testing/reduced-read-budget.ts +381 -18
  142. package/packages/core/src/testing/released-value-coverage.ts +423 -0
  143. package/packages/core/src/web/overview-source.ts +19 -6
  144. package/skills/guide/SKILL.md +138 -67
  145. package/skills/guide/references/integration-tree.md +12 -9
  146. package/skills/guide/references/merge-policy.md +7 -2
  147. package/skills/guide/references/operator-api.md +46 -23
  148. package/skills/guide/references/optimization-nodes.md +7 -6
  149. package/skills/guide/references/plugin-authoring.md +46 -18
  150. package/skills/guide/references/remote-store-protocol.md +51 -12
  151. package/skills/guide/references/remote-ticket-protocol.md +85 -38
  152. package/skills/guide/references/restacking.md +48 -3
  153. package/skills/guide/references/setup.md +2 -1
  154. package/skills/guide/references/ticket-migration.md +2 -2
  155. package/skills/operate/SKILL.md +82 -51
  156. package/skills/plan/SKILL.md +4 -3
  157. package/skills/spec/SKILL.md +9 -5
  158. package/skills/tickets/SKILL.md +25 -17
  159. package/templates/hosted-service/package.json +2 -2
@@ -231,12 +231,12 @@ export const HELP_CATALOG: readonly HelpEntry[] = [
231
231
  detail: page([
232
232
  'Usage:',
233
233
  ' ab ticket tree [--json]',
234
- ' ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--kind work|node] [--target <id> | --no-target] [--json]',
234
+ ' ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|high|normal|low] [--assignees a,b] [--kind work|node] [--target <id> | --no-target] [--json]',
235
235
  ' ab ticket edit <id>',
236
236
  ' ab ticket export <dir> [--store <ref>]',
237
237
  ' ab ticket import <dir> [--states <state,...>] [--store <ref>]',
238
238
  ' ab ticket migration record <dir> [--store <ref>]',
239
- ' ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--expected-revision <opaque>] [--json]',
239
+ ' ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|high|normal|low] [--assignees a,b] [--expected-revision <opaque>] [--json]',
240
240
  ' ab ticket block <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
241
241
  ' ab ticket unblock <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
242
242
  ' ab ticket list [--state <state>] [--labels a,b] [--json]',
@@ -272,10 +272,12 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
272
272
  'or N:refs for partial work, comma-separated. On update it replaces the set',
273
273
  'and --issues "" clears it. Sources that cannot store issue links refuse the',
274
274
  'write, name the source, and write nothing.',
275
- '--priority urgent dispatches the ticket before normal ready work, each class',
276
- 'in source order; it never preempts a running build. normal (the default)',
277
- 'removes urgency. Sources that cannot store priority refuse urgent, name the',
278
- 'source, and write nothing; normal is a no-op there.',
275
+ '--priority sets the level: urgent, high, normal (the default) or low. Ready',
276
+ 'tickets are claimed by level, urgent first and low last, each level in source',
277
+ 'order; a running build is never preempted. On update, normal clears the level. A',
278
+ 'source without native priority stores the level as exactly one label,',
279
+ 'priority:urgent, priority:high or priority:low; those labels report as the',
280
+ 'priority, never in labels, and --labels may not name them.',
279
281
  '--assignees entries are usernames or me (the owner of the source credential).',
280
282
  'On create they replace the [tickets].createAssignee default and --assignees ""',
281
283
  'creates an unassigned ticket; on update they replace the set and "" clears it.',
@@ -283,7 +285,7 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
283
285
  'write nothing.',
284
286
  '',
285
287
  'With no list filters, list uses the same ready criteria as dispatch. show one ticket, including its body/spec.',
286
- 'Human output is the default and marks urgent tickets. --json emits exactly',
288
+ 'Human output is the default and marks every level but normal. --json emits exactly',
287
289
  'one bare value, and every JSON ticket names its priority: Ticket[]',
288
290
  'for list, the hierarchy for tree, and the resulting Ticket for ticket mutations; show',
289
291
  'adds an assets array (kind, name, revision, size, layout, fileCount). Sources',
@@ -452,12 +454,13 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
452
454
  '',
453
455
  'Default filter — actionable attention only. Builds: escalation.raised, phase.deferral-escalated, integration.landed,',
454
456
  'integration.verification-failed (failed node verification), build.janitor-failing, build.janitor-escalated,',
455
- 'build.compatibility-deferred, node.item-conflicted, target.rewritten (a node, once per rejected baseline),',
456
- 'conflicted restack.replayed,',
457
+ 'build.compatibility-deferred, target.rewritten (a node, once per rejected baseline),',
457
458
  'landing.consent-revoked (protected merge consent revoked by a reconcile),',
458
459
  "pr.checks-failed (failing forge CI on a finished leaf's live PR head),",
459
460
  "optimization.noise-exceeded (an optimization node's ε is below its measured noise), derived build.consent-ready and",
460
461
  'build.merge-decision (a current actionable merge-gate deferral, a landing awaiting a human merge, or an unsafe forge outcome).',
462
+ 'Restack conflicts (conflicted restack.replayed, node.item-conflicted) are routine: reconcile resolves them.',
463
+ 'Follow them with --event; an unresolvable conflict arrives as escalation.raised or landing.consent-revoked.',
461
464
  'Consent and held ready merges use only build.consent-ready, once per readiness episode.',
462
465
  'Unready or stale consent candidates stay silent; one merge gate decision per build/PR.',
463
466
  'Repository: harvest.escalated, harvest.recovery-exhausted, dispatcher.config-rejected, dispatcher.forge-readiness-failed,',
@@ -578,8 +581,9 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
578
581
  'Conditions (--for, repeatable): blocked, paused, running, done, aborted, terminal (done',
579
582
  'or aborted), pr=open, pr=merged, pr=closed, consent, node-merged, restack-conflicted, pr=conflicted, phase=<phase> (a core phase —',
580
583
  'plan, plan-review, implement, code-review, finalize, reconcile, propose — or verify:<step>), and',
581
- "attention (an open escalation other than a ticket wait's own, failed node verification, consent readiness, a node merge or restack conflict,",
582
- 'failing forge CI on a finished leaf, or a build waiting for a merge decision). Merge attention',
584
+ "attention (an open escalation other than a ticket wait's own, failed node verification, consent readiness, a node merge,",
585
+ 'failing forge CI on a finished leaf, or a build waiting for a merge decision). Routine restack conflicts are',
586
+ 'not attention: reconcile resolves them, and --for restack-conflicted waits for them. Merge attention',
583
587
  'requires a current actionable gate deferral or an unsafe forge outcome;',
584
588
  'armed pending consent, routine outcomes and self-healing failures stay silent.',
585
589
  'An unknown condition value is rejected before',
@@ -758,6 +762,10 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
758
762
  "the build's own commits onto the current target before any further verification.",
759
763
  'Other answer forms skip that escalation; ab abort is the other way out.',
760
764
  '',
765
+ 'On a completed build, guidance or a bare answer only acknowledges open escalations,',
766
+ 'such as a post-landing integration audit; the build stays done and every other',
767
+ 'form is refused.',
768
+ '',
761
769
  'If paused and every blocker clears, resume is requested last. --store overrides the',
762
770
  'BuildStore path or URL. This command is sessionless; a phase may not answer its',
763
771
  'own build.',
@@ -769,7 +777,7 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
769
777
  summary: 'Ask the running dispatcher to start one ticket, even while intake is off.',
770
778
  detail: page([
771
779
  'Usage:',
772
- ' ab start <ticket-id> [--priority manual|urgent|normal] [--cancel] [--json] [--store <ref>]',
780
+ ' ab start <ticket-id> [--priority manual|urgent|high|normal|low] [--cancel] [--json] [--store <ref>]',
773
781
  '',
774
782
  'Record a durable start request for one ticket. The running dispatcher, local or',
775
783
  "hosted, claims it on its next tick with a free slot in the request's priority",
@@ -783,11 +791,15 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
783
791
  'Priority tiers (free slots go to them in this order, among parked work and claims):',
784
792
  ' manual (default) Ahead of every waiting build and ticket claim, urgent ones included.',
785
793
  ' urgent After urgent parked work; ahead of urgent ready tickets and all',
786
- ' normal work.',
787
- ' normal After normal parked work and urgent claims; ahead of normal ready',
794
+ ' high, normal and low work.',
795
+ ' high After high parked work and urgent claims; ahead of high ready',
796
+ ' tickets and all normal and low work.',
797
+ ' normal After normal parked work and high claims; ahead of normal ready',
798
+ ' tickets and all low work.',
799
+ ' low After low parked work and normal claims; ahead of low ready',
788
800
  ' tickets.',
789
- 'manual is admission-only: the claimed build is urgent when the request was urgent,',
790
- "and otherwise keeps its ticket's priority.",
801
+ "manual is admission-only: the claimed build takes its ticket's level. Any other",
802
+ "tier sets the claimed build's level to the request's.",
791
803
  '',
792
804
  'Every ordinary gate still applies: the ticket must be in the configured ready',
793
805
  'state, conform to the spec standard (a nonconforming one is bounced to triage),',
@@ -798,7 +810,8 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
798
810
  'blocked, invalid, missing, not-ready, terminal or claim-refused. Pending and',
799
811
  'recently settled requests appear, with their priority, in ab repository status.',
800
812
  '',
801
- ' --priority <tier> manual (default), urgent or normal; not allowed with --cancel.',
813
+ ' --priority <tier> manual (default), urgent, high, normal or low; not allowed with',
814
+ ' --cancel.',
802
815
  ' --cancel Cancel the pending request instead; a no-op when none is pending.',
803
816
  ' --json Print the result object.',
804
817
  ' --store <ref> Override the BuildStore path or URL.',
@@ -961,13 +974,14 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
961
974
  audience: 'human',
962
975
  summary: "Set an active build's slot-admission priority.",
963
976
  detail: page([
964
- 'Usage: ab priority <slug> urgent|normal [--store <ref>]',
965
- '',
966
- 'Records build.priority-set. A build starts with its ticket priority at claim;',
967
- 'this changes only the build, never the ticket. Free slots go, in order, to urgent',
968
- 'parked work (re-verification, reconcile, resume, propose), urgent ticket claims,',
969
- 'normal parked work, then normal ticket claims. Running work is never preempted.',
970
- 'Use it to expedite a waiting build that became a blocker, or return it to normal.',
977
+ 'Usage: ab priority <slug> urgent|high|normal|low [--store <ref>]',
978
+ '',
979
+ "Records build.priority-set. A build starts at its ticket's level; this changes",
980
+ 'only the build, never the ticket. Free slots go, in order, to manual start',
981
+ "requests, then for each level, urgent, high, normal and low: that level's parked",
982
+ 'work (re-verification, reconcile, resume, reopen, propose), then its ticket',
983
+ 'claims. Running work is never preempted. Use it to expedite a waiting build',
984
+ 'that became a blocker, defer one with low, or return it to normal.',
971
985
  'Requires a running, paused or blocked build. This command is sessionless; a phase',
972
986
  'may not control its own build.',
973
987
  ]),
@@ -243,11 +243,13 @@ export function buildControlConfirmation(result: BuildControlResult): string {
243
243
  if (result.event.type === 'build.hold-requested' && result.event.payload.reason !== undefined)
244
244
  return `build ${result.slug}: merge hold requested (reason: ${result.event.payload.reason})`
245
245
  if (result.event.type === 'build.priority-set')
246
- return `build ${result.slug}: priority set to ${result.event.payload.priority}`
246
+ return `build ${result.slug}: priority set to ${result.event.payload.level ?? result.event.payload.priority}`
247
247
  return `build ${result.slug}: ${outcome[result.command]}`
248
248
  }
249
249
  case 'answered': {
250
250
  const plural = result.count === 1 ? '' : 's'
251
+ if (result.acknowledged)
252
+ return `build ${result.slug}: acknowledged ${result.count} escalation${plural} on the completed build; status stays done`
251
253
  const terminal = result.terminalSignal
252
254
  if (terminal !== undefined) {
253
255
  const ending =
@@ -1379,7 +1381,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
1379
1381
  const { abTicketStart } = await import('./ticket-start')
1380
1382
  const { parseStartPriorityFlag } = await import('../ports/tickets/priority')
1381
1383
  const usage =
1382
- 'usage: ab start <ticket-id> [--priority manual|urgent|normal] [--cancel] [--json] [--store <ref>]'
1384
+ 'usage: ab start <ticket-id> [--priority manual|urgent|high|normal|low] [--cancel] [--json] [--store <ref>]'
1383
1385
  const parsed = parseArgs(
1384
1386
  rest,
1385
1387
  { cancel: 'boolean', json: 'boolean', priority: 'value', store: 'value' },
@@ -1448,11 +1450,11 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
1448
1450
  }
1449
1451
 
1450
1452
  case 'priority': {
1451
- const { parsePriorityFlag } = await import('../ports/tickets/priority')
1452
- const usage = 'usage: ab priority <slug> urgent|normal [--store <ref>]'
1453
+ const { parseBuildPriorityFlag } = await import('../ports/tickets/priority')
1454
+ const usage = 'usage: ab priority <slug> urgent|high|normal|low [--store <ref>]'
1453
1455
  const parsed = parseArgs(rest, { store: 'value' }, usage)
1454
1456
  if (parsed.positionals.length !== 2) throw new Error(usage)
1455
- const priority = parsePriorityFlag(parsed.positionals[1]!, 'priority')
1457
+ const priority = parseBuildPriorityFlag(parsed.positionals[1]!, 'priority')
1456
1458
  await runBuildControl(
1457
1459
  deps,
1458
1460
  parsed.positionals[0]!,
@@ -1,6 +1,7 @@
1
1
  import { recoverLostCandidate } from '../kernel/reconcile-restack'
2
2
  import { publicationRetryGate, retryPublicationEffect } from '../kernel/publication-retry'
3
3
  import { ForgeRequestDeferred } from '../ports/forge-request-context'
4
+ import { isRecoveryDeferred } from '../ports/workspace/recovery-step'
4
5
  import { stat } from 'node:fs/promises'
5
6
  import { deferMixedVersion, MixedVersionDeferral } from '../kernel/mixed-version'
6
7
  import { suspendNativeLanding } from '../kernel/landing-publication'
@@ -427,6 +428,9 @@ export async function settlePendingPublication(
427
428
  }
428
429
  } catch (error) {
429
430
  if (error instanceof ForgeRequestDeferred) throw error
431
+ // The invocation deadline cut recovery short: the request stays pending
432
+ // and a later invocation settles it. Never a failed finalize step.
433
+ if (isRecoveryDeferred(error)) throw error
430
434
  if (error instanceof MixedVersionDeferral) return
431
435
  if (request.payload.operation !== 'finalize-step') throw error
432
436
  const detail = error instanceof Error ? error.message : String(error)
@@ -21,6 +21,13 @@ import { isTerminalEventReadError } from '../store/event-reads'
21
21
  */
22
22
  import { REMOTE_EVENT_WAIT_SECONDS } from '../store/remote/client'
23
23
 
24
+ /**
25
+ * A stream poll resolves this when its stream has left tracking: the task
26
+ * ends quietly — no `requestStop`, no `endCheck` — and its siblings keep
27
+ * polling. Only `ab watch` returns it (a settled build retiring).
28
+ */
29
+ export const STREAM_RETIRED: unique symbol = Symbol('stream-retired')
30
+
24
31
  /** The read options one held long-poll request carries. */
25
32
  export interface RemotePollReadOpts {
26
33
  waitSeconds?: number
@@ -116,8 +123,10 @@ export interface RemotePollRunner {
116
123
  readonly stopped: boolean
117
124
  /** Abort every in-flight held read, wake the gap sleeps, mark stopped. */
118
125
  requestStop(): void
119
- /** Launch one per-stream long-poll task; idempotent per key. `endCheck`
120
- * runs after each successful poll; true ⇒ requestStop + return. */
126
+ /** Launch one per-stream long-poll task; idempotent per key while the task
127
+ * runs. `endCheck` runs after each successful poll; true ⇒ requestStop +
128
+ * return. A poll resolving `STREAM_RETIRED` ends only its own task and
129
+ * frees the key. */
121
130
  launch(
122
131
  key: string,
123
132
  poll: (readOpts: RemotePollReadOpts) => Promise<unknown>,
@@ -185,7 +194,9 @@ export function createRemotePollRunner(opts: RemotePollRunnerOpts): RemotePollRu
185
194
  )
186
195
  }
187
196
 
197
+ const launched = new Set<string>()
188
198
  const runStreamTask = async (
199
+ key: string,
189
200
  poll: (readOpts: RemotePollReadOpts) => Promise<unknown>,
190
201
  endCheck?: () => boolean,
191
202
  ): Promise<void> => {
@@ -195,8 +206,15 @@ export function createRemotePollRunner(opts: RemotePollRunnerOpts): RemotePollRu
195
206
  const controller = new AbortController()
196
207
  inFlightReads.add(controller)
197
208
  try {
198
- await poll({ waitSeconds: readWaitSeconds(started), signal: controller.signal })
209
+ const result = await poll({
210
+ waitSeconds: readWaitSeconds(started),
211
+ signal: controller.signal,
212
+ })
199
213
  streak.onSuccess()
214
+ if (result === STREAM_RETIRED) {
215
+ launched.delete(key)
216
+ return
217
+ }
200
218
  if (endCheck?.()) {
201
219
  requestStop()
202
220
  return
@@ -219,7 +237,6 @@ export function createRemotePollRunner(opts: RemotePollRunnerOpts): RemotePollRu
219
237
  }
220
238
  }
221
239
 
222
- const launched = new Set<string>()
223
240
  const launch = (
224
241
  key: string,
225
242
  poll: (readOpts: RemotePollReadOpts) => Promise<unknown>,
@@ -227,7 +244,7 @@ export function createRemotePollRunner(opts: RemotePollRunnerOpts): RemotePollRu
227
244
  ): void => {
228
245
  if (launched.has(key)) return
229
246
  launched.add(key)
230
- track(runStreamTask(poll, endCheck))
247
+ track(runStreamTask(key, poll, endCheck))
231
248
  }
232
249
 
233
250
  const runDiscovery = (discovery: {
@@ -1,4 +1,4 @@
1
- import type { TicketStartPriority } from '../events/repository'
1
+ import { startTierOf, type StartTier } from '../ports/tickets/priority'
2
2
  import { repositoryReadFactsReducer } from '../kernel/read-facts'
3
3
  import {
4
4
  ticketStartsReducer,
@@ -18,7 +18,7 @@ import { capacityBuildFromFacts } from '../kernel/capacity-build'
18
18
  import {
19
19
  dispatchCapacity,
20
20
  startClaimDemand,
21
- urgentClaimDemand,
21
+ claimDemand,
22
22
  waitingExplanation,
23
23
  type DispatchCapacity,
24
24
  type CapacityBuild,
@@ -266,11 +266,13 @@ export interface RepositoryTicketStarts {
266
266
  pending: Array<{
267
267
  ticket: { source: string; id: string }
268
268
  request: number
269
- priority: TicketStartPriority
269
+ /** The request's admission tier (`startTierOf`). */
270
+ priority: StartTier
270
271
  requestedAt: string
271
272
  by?: string
272
273
  }>
273
- recent: SettledTicketStart[]
274
+ /** Settled or cancelled requests, newest last, each naming its tier. */
275
+ recent: Array<Omit<SettledTicketStart, 'priority' | 'level'> & { priority: StartTier }>
274
276
  }
275
277
 
276
278
  function projectTicketStarts(starts: TicketStarts): { ticketStarts?: RepositoryTicketStarts } {
@@ -279,12 +281,20 @@ function projectTicketStarts(starts: TicketStarts): { ticketStarts?: RepositoryT
279
281
  .map((entry) => ({
280
282
  ticket: entry.ticket,
281
283
  request: entry.seq,
282
- priority: entry.priority,
284
+ priority: startTierOf(entry),
283
285
  requestedAt: entry.ts,
284
286
  ...(entry.by !== undefined ? { by: entry.by } : {}),
285
287
  }))
286
288
  return pending.length || starts.recent.length
287
- ? { ticketStarts: { pending, recent: [...starts.recent] } }
289
+ ? {
290
+ ticketStarts: {
291
+ pending,
292
+ recent: starts.recent.map(({ level: _level, ...entry }) => ({
293
+ ...entry,
294
+ priority: startTierOf({ priority: entry.priority, level: _level }),
295
+ })),
296
+ },
297
+ }
288
298
  : {}
289
299
  }
290
300
 
@@ -574,7 +584,7 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
574
584
  `repository: ${status.repo}`,
575
585
  ...(status.capacity
576
586
  ? [
577
- `capacity: ${status.capacity.occupied}/${status.capacity.configured}${status.capacity.waitingNodes?.length || status.capacity.waitingBuilds?.length || status.capacity.urgentClaims || status.capacity.startRequests ? `; ${waitingExplanation(status.capacity, { requests: true })}` : ''}`,
587
+ `capacity: ${status.capacity.occupied}/${status.capacity.configured}${status.capacity.waitingNodes?.length || status.capacity.waitingBuilds?.length || status.capacity.urgentClaims || status.capacity.highClaims || status.capacity.normalClaims || status.capacity.startRequests ? `; ${waitingExplanation(status.capacity, { requests: true })}` : ''}`,
578
588
  ]
579
589
  : []),
580
590
  ...(status.capacity?.slots ? [slotsStatusLine(status.capacity.slots)] : []),
@@ -731,7 +741,7 @@ function slotsStatusLine(slots: Record<string, SlotState>): string {
731
741
  const entries = Object.entries(slots).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
732
742
  const label = (slug: string, slot: SlotState) =>
733
743
  slot.state === 'requested'
734
- ? `${slug} (${slot.request}${slot.priority === 'urgent' ? ', urgent' : ''})`
744
+ ? `${slug} (${slot.request}${slot.priority !== undefined ? `, ${slot.priority}` : ''})`
735
745
  : slug
736
746
  const clauses = (['held', 'requested', 'none'] as const).flatMap((state) => {
737
747
  const members = entries.filter(([, slot]) => slot.state === state)
@@ -761,7 +771,7 @@ export async function readRepositoryCapacity(
761
771
  builds.push(capacityBuildFromFacts(record, (await readBuildFacts(store, record.slug)).value))
762
772
  }
763
773
  return dispatchCapacity(builds, config.capacity, now, {
764
- urgentClaims: urgentClaimDemand(facts),
774
+ claims: claimDemand(facts),
765
775
  startRequests: startClaimDemand(facts),
766
776
  openPrs: { policy: config.policy, engaged: facts.openPrBackpressure !== undefined },
767
777
  })
@@ -28,16 +28,18 @@ import {
28
28
  import { readBuildFacts } from '../store/reduced-reads'
29
29
  import {
30
30
  buildPriority,
31
+ markedPriority,
31
32
  slotRequest,
32
33
  slotState,
33
34
  slotWaitText,
34
35
  type CapacityBuild,
36
+ type MarkedPriority,
35
37
  type SlotRequest,
36
38
  type SlotState,
37
39
  } from '../kernel/dispatch-capacity'
38
40
  import { capacityBuildFromFacts } from '../kernel/capacity-build'
39
41
  import { openBuildWorkspace, provisionMarkerReducer } from '../processes/dispatcher-selectors'
40
- import { URGENT_MARK } from './dashboard/queue'
42
+ import { PRIORITY_MARKS } from './dashboard/queue'
41
43
  import {
42
44
  ticketWaitStatus,
43
45
  ticketWaitText,
@@ -196,16 +198,17 @@ export interface BuildSummary {
196
198
  lease: LeaseInfo
197
199
  /** Durable-event progress, separate from mutable lease renewal. */
198
200
  progress: BuildProgress
199
- /** A node's or parked build's runner request, admitted ahead of normal
200
- * ticket claims (urgent work first: SPEC §12 "Slot admission order"). */
201
+ /** A node's or parked build's runner request, admitted ahead of its own
202
+ * level's ticket claims (higher levels first: SPEC §12 "Slot admission
203
+ * order"). */
201
204
  slotWait?: SlotRequest
202
205
  /** The build's slot state by the rules the dispatcher admits work by
203
206
  * (SPEC §12 "What holds a slot"). Absent for a `done` build, and unknown
204
207
  * (never `none`) when absent on any other: a value from an older server,
205
208
  * or a caller without the build's capacity facts. */
206
209
  slot?: SlotState
207
- /** The build's slot-admission priority when urgent; omitted means normal. */
208
- priority?: 'urgent'
210
+ /** The build's slot-admission level; omitted means normal. */
211
+ priority?: MarkedPriority
209
212
  /** The build's ticket wait while it is requested, open, or ended and not
210
213
  * yet resumed (SPEC §11 "Ticket waits"); omitted otherwise. */
211
214
  wait?: TicketWaitStatus
@@ -551,7 +554,9 @@ export function summarizeFrom(
551
554
  progress: buildProgress(record, state),
552
555
  ...(slotWait ? { slotWait } : {}),
553
556
  ...(slot ? { slot } : {}),
554
- ...(buildPriority(state) === 'urgent' ? { priority: 'urgent' as const } : {}),
557
+ ...(markedPriority(buildPriority(state)) !== undefined
558
+ ? { priority: markedPriority(buildPriority(state))! }
559
+ : {}),
555
560
  ...(wait !== undefined ? { wait } : {}),
556
561
  ...(effectiveStatus(state) === 'waiting' ? { waitOnly: true as const } : {}),
557
562
  ...(word !== undefined ? { statusWord: word } : {}),
@@ -980,7 +985,11 @@ export function renderSummaries(
980
985
  : ''
981
986
  rows.push([
982
987
  summary.slug,
983
- statusCell(summary, summary.priority === 'urgent' ? ` ${URGENT_MARK}` : '', opts.color),
988
+ statusCell(
989
+ summary,
990
+ summary.priority !== undefined ? ` ${PRIORITY_MARKS[summary.priority]}` : '',
991
+ opts.color,
992
+ ),
984
993
  slotText(summary) ?? '—',
985
994
  summary.kind === 'integration'
986
995
  ? `${summary.optimization ? treeVocabulary.optimizationKind : treeVocabulary.integrationKind} ${summary.integration ?? ''}${slotWait}`
@@ -1019,13 +1028,16 @@ export function renderSummaries(
1019
1028
 
1020
1029
  /** A summary's slot state in neutral raw terms, or undefined for a `done`
1021
1030
  * build. An absent value on any other build is `unknown`, never `none`. */
1022
- function slotText(summary: BuildSummary, urgent = (text: string) => `${text} urgent`) {
1031
+ function slotText(
1032
+ summary: BuildSummary,
1033
+ marked = (text: string, level: MarkedPriority) => `${text} ${level}`,
1034
+ ) {
1023
1035
  if (summary.status === 'done') return undefined
1024
1036
  const slot = summary.slot
1025
1037
  if (slot === undefined) return 'unknown'
1026
1038
  if (slot.state !== 'requested') return slot.state
1027
1039
  const text = `requested ${slot.request}`
1028
- return slot.priority === 'urgent' ? urgent(text) : text
1040
+ return slot.priority !== undefined ? marked(text, slot.priority) : text
1029
1041
  }
1030
1042
 
1031
1043
  /** The status word text renderers print with its note (SPEC §14 "Status
@@ -1163,14 +1175,14 @@ export function renderDetail(d: BuildDetail, now: Date, opts: { color?: boolean
1163
1175
  }
1164
1176
  const status = statusCell(d, d.outcome !== undefined ? ` (${d.outcome})` : '', opts.color)
1165
1177
  lines.push(` status: ${typeof status === 'string' ? status : status.painted}`)
1166
- const slot = slotText(d, (text) => `${text} (urgent)`)
1178
+ const slot = slotText(d, (text, level) => `${text} (${level})`)
1167
1179
  if (slot !== undefined) lines.push(` slot: ${slot}`)
1168
1180
  lines.push(` phase: ${phaseCell(d)}`)
1169
1181
  if (d.reopened !== undefined)
1170
1182
  lines.push(
1171
1183
  ` reopened: ${safeStatusText(reopenedText(d.reopened).replace(/^reopened /, ''))} (${d.reopened.at})`,
1172
1184
  )
1173
- if (d.priority === 'urgent') lines.push(' priority: urgent')
1185
+ if (d.priority !== undefined) lines.push(` priority: ${d.priority}`)
1174
1186
  if (d.reviewRoundCeilings !== undefined) {
1175
1187
  const ceilings = [
1176
1188
  ...(d.reviewRoundCeilings.plan !== undefined ? [`plan ${d.reviewRoundCeilings.plan}`] : []),
@@ -37,6 +37,18 @@ export const openProductionStore: StoreOpener = (ref, token) =>
37
37
  (url, remoteToken) => new RemoteBuildStore({ url, token: remoteToken }),
38
38
  )
39
39
 
40
+ /** Production composition for a bounded invocation: every remote Store
41
+ * request goes through `fetchFn` (normally `budgetedFetch()`), so it is
42
+ * cancelled at the current invocation phase's deadline. */
43
+ export function budgetedProductionStore(fetchFn: typeof fetch): StoreOpener {
44
+ return (ref, token) =>
45
+ composeProductionStore(
46
+ ref,
47
+ token,
48
+ (url, remoteToken) => new RemoteBuildStore({ url, token: remoteToken, fetchFn }),
49
+ )
50
+ }
51
+
40
52
  /** Apply validated ambient authority to a selected Store handle. Remote
41
53
  * handles retain server-side project authorization; every handle receives
42
54
  * the same in-process build/session scope. Keeping this primitive shared prevents
@@ -1,17 +1,17 @@
1
- import type { TicketStartPriority } from '../events/repository'
1
+ import type { StartTier } from '../ports/tickets/priority'
2
2
  import { cancelTicketStart, requestTicketStart } from '../operator/ticket-start'
3
3
  import type { TicketSource } from '../ports/types'
4
4
  import { buildControlUser } from './build-control'
5
5
  import { withSessionlessStore, type SessionlessStoreOpts } from './store-opening'
6
6
 
7
- /** `ab start <ticket-id> [--priority manual|urgent|normal] [--cancel]`: record
7
+ /** `ab start <ticket-id> [--priority manual|urgent|high|normal|low] [--cancel]`: record
8
8
  * or cancel a durable request that the running dispatcher start one ticket,
9
9
  * even while intake is off. */
10
10
  export async function abTicketStart(
11
11
  opts: SessionlessStoreOpts & {
12
12
  id: string
13
13
  cancel?: boolean
14
- priority?: TicketStartPriority
14
+ priority?: StartTier
15
15
  json?: boolean
16
16
  stdout: (line: string) => void
17
17
  ticketSource: () => Promise<TicketSource>
@@ -9,7 +9,7 @@ import { updateTicketTarget } from '../kernel/node-parent'
9
9
  import { createForge } from '../ports/forge/create'
10
10
  import { compatibleTicketSource, type TicketTreeEntry } from '../ports/tickets/tree'
11
11
  import { formatIssueLinks, parseIssueLinkList } from '../ports/tickets/issue-links'
12
- import { parsePriorityFlag, ticketPriority } from '../ports/tickets/priority'
12
+ import { namedPriority, parsePriorityFlag, ticketPriority } from '../ports/tickets/priority'
13
13
  import { creationAssignees, parseAssigneesFlag } from '../ports/tickets/assignees'
14
14
  import { creationLabels } from '../ports/tickets/labels'
15
15
  import { searchTickets, TICKET_SEARCH_MAX_LIMIT } from '../ports/tickets/search'
@@ -119,7 +119,7 @@ export interface TicketCreateOpts extends TicketCommandOpts {
119
119
  blockedBy?: string[]
120
120
  /** Forge issues the ticket addresses; sources without support refuse. */
121
121
  issueLinks?: import('../ports/types').IssueLink[]
122
- /** Dispatch class; a source without priority support refuses `urgent`. */
122
+ /** Priority level; omitted files the ticket at `normal`. */
123
123
  priority?: import('../ports/types').TicketPriority
124
124
  /** Usernames or `me`; replaces the `[tickets].createAssignee` default, and
125
125
  * an explicit [] creates an unassigned ticket. Sources without support refuse. */
@@ -138,7 +138,7 @@ export interface TicketUpdateOpts extends TicketCommandOpts {
138
138
  labels?: string[]
139
139
  /** Complete issue-link replacement. An explicit [] clears links. */
140
140
  issueLinks?: import('../ports/types').IssueLink[]
141
- /** `normal` removes urgency; a source without priority support refuses `urgent`. */
141
+ /** Replaces the priority level; `normal` clears it, omitted leaves it. */
142
142
  priority?: import('../ports/types').TicketPriority
143
143
  /** Complete assignee replacement (usernames or `me`). An explicit [] clears. */
144
144
  assignees?: string[]
@@ -368,7 +368,7 @@ function ticketSummary(ticket: Ticket): string {
368
368
  const fields = [
369
369
  `${ticket.ref.source}:${ticket.ref.id}`,
370
370
  `(${ticket.state ?? 'state unknown'})`,
371
- ...(ticket.priority === 'urgent' ? ['— urgent'] : []),
371
+ ...(ticketPriority(ticket) !== 'normal' ? [`— ${ticketPriority(ticket)}`] : []),
372
372
  `— ${ticket.title}`,
373
373
  ]
374
374
  if (ticket.labels.length > 0) fields.push(`— labels: ${ticket.labels.join(', ')}`)
@@ -411,8 +411,8 @@ function ticketDetail(
411
411
  }
412
412
 
413
413
  /** CLI JSON always names priority; normalized tickets omit the normal default. */
414
- function ticketJson(ticket: Ticket): Ticket & { priority: 'urgent' | 'normal' } {
415
- return { ...ticket, priority: ticketPriority(ticket) }
414
+ function ticketJson(ticket: Ticket) {
415
+ return namedPriority(ticket)
416
416
  }
417
417
 
418
418
  function emitTicketJson(opts: TicketCommandOpts, ticket: Ticket): void {
@@ -456,10 +456,10 @@ export async function abTicketCreate(opts: TicketCreateOpts): Promise<void> {
456
456
  ? ` — blocked by ${ticket.blockedBy.join(', ')}`
457
457
  : ''
458
458
  const issues = ticket.issueLinks?.length ? ` — ${formatIssueLinks(ticket.issueLinks)}` : ''
459
- const urgent = ticket.priority === 'urgent' ? ' — urgent' : ''
459
+ const level = ticketPriority(ticket) !== 'normal' ? ` — ${ticketPriority(ticket)}` : ''
460
460
  const assigned = ticket.assignees?.length ? ` — assigned to ${ticket.assignees.join(', ')}` : ''
461
461
  opts.stdout(
462
- `ticket created: ${ticket.ref.source}:${ticket.ref.id} (${state})${urgent}${assigned}${blockers}${issues}${url}`,
462
+ `ticket created: ${ticket.ref.source}:${ticket.ref.id} (${state})${level}${assigned}${blockers}${issues}${url}`,
463
463
  )
464
464
  }
465
465
 
@@ -570,7 +570,7 @@ export async function abTicketSearch(opts: TicketSearchOpts): Promise<void> {
570
570
  ...(opts.cursor !== undefined ? { cursor: opts.cursor } : {}),
571
571
  })
572
572
  if (opts.json === true) {
573
- opts.stdout(JSON.stringify(page, null, 2))
573
+ opts.stdout(JSON.stringify({ ...page, tickets: page.tickets.map(namedPriority) }, null, 2))
574
574
  return
575
575
  }
576
576
  for (const diagnostic of page.diagnostics) opts.stderr(diagnostic)
@@ -583,6 +583,7 @@ export async function abTicketSearch(opts: TicketSearchOpts): Promise<void> {
583
583
  `${source.name}:${hit.id}`,
584
584
  `(${hit.state ?? 'state unknown'})`,
585
585
  `[${hit.kind}]`,
586
+ ...(ticketPriority(hit) !== 'normal' ? [`— ${ticketPriority(hit)}`] : []),
586
587
  `— ${hit.title}`,
587
588
  ]
588
589
  if (hit.labels.length > 0) fields.push(`— labels: ${hit.labels.join(', ')}`)
@@ -1032,9 +1033,9 @@ export async function abTicketStateCreate(opts: TicketStateCreateOpts): Promise<
1032
1033
  }
1033
1034
 
1034
1035
  const CREATE_USAGE =
1035
- 'usage: ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--kind work|node] [--target <id> | --no-target] [--json] (§8.8)'
1036
+ 'usage: ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|high|normal|low] [--assignees a,b] [--kind work|node] [--target <id> | --no-target] [--json] (§8.8)'
1036
1037
  const UPDATE_USAGE =
1037
- 'usage: ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--expected-revision <opaque>] [--json] (§8.8)'
1038
+ 'usage: ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|high|normal|low] [--assignees a,b] [--expected-revision <opaque>] [--json] (§8.8)'
1038
1039
  const BLOCK_USAGE =
1039
1040
  'usage: ab ticket block <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json] (§8.8)'
1040
1041
  const UNBLOCK_USAGE =