@defrex/autobuild 1.6.0 → 1.8.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 (165) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +423 -57
  3. package/docs/agent-runtimes.md +1 -1
  4. package/docs/answering-blocked-builds.md +44 -3
  5. package/docs/architecture.md +124 -29
  6. package/docs/cli.md +1 -0
  7. package/docs/configuration-overview.md +11 -1
  8. package/docs/configuration.md +334 -14
  9. package/docs/dispatcher.md +1 -1
  10. package/docs/forges.md +1 -0
  11. package/docs/integration-overview.md +2 -2
  12. package/docs/integration-tree.md +7 -4
  13. package/docs/merge-policy.md +78 -6
  14. package/docs/migration-1.0.md +4 -2
  15. package/docs/operating.md +3 -2
  16. package/docs/operator-api.md +45 -13
  17. package/docs/operator-surfaces.md +16 -3
  18. package/docs/plugin-authoring.md +45 -7
  19. package/docs/remote-store-protocol.md +28 -7
  20. package/docs/restacking.md +35 -11
  21. package/docs/ticket-dependencies.md +9 -4
  22. package/docs/ticket-sources.md +34 -6
  23. package/docs/tickets.md +7 -1
  24. package/docs/troubleshooting.md +1 -1
  25. package/docs/workspaces.md +1 -1
  26. package/package.json +3 -3
  27. package/packages/core/src/cli/attention.ts +2 -0
  28. package/packages/core/src/cli/binary-direct.ts +1 -0
  29. package/packages/core/src/cli/build-control.ts +65 -7
  30. package/packages/core/src/cli/context.ts +55 -14
  31. package/packages/core/src/cli/dashboard/actions.ts +13 -4
  32. package/packages/core/src/cli/dashboard/landing-display.ts +32 -8
  33. package/packages/core/src/cli/dashboard/model.ts +61 -8
  34. package/packages/core/src/cli/dashboard/render.ts +28 -3
  35. package/packages/core/src/cli/dashboard/tree.ts +9 -1
  36. package/packages/core/src/cli/dispatch-frontend.ts +10 -14
  37. package/packages/core/src/cli/dispatch-preflight.ts +1 -0
  38. package/packages/core/src/cli/dispatch-repository-feed.ts +145 -109
  39. package/packages/core/src/cli/dispatch.ts +9 -3
  40. package/packages/core/src/cli/help.ts +80 -11
  41. package/packages/core/src/cli/init-validation.ts +14 -1
  42. package/packages/core/src/cli/landings.ts +1 -1
  43. package/packages/core/src/cli/main.ts +60 -9
  44. package/packages/core/src/cli/publication-settlement.ts +10 -0
  45. package/packages/core/src/cli/repository-status.ts +37 -2
  46. package/packages/core/src/cli/status.ts +186 -12
  47. package/packages/core/src/cli/terminals.ts +197 -4
  48. package/packages/core/src/cli/ticket.ts +22 -4
  49. package/packages/core/src/cli/wait.ts +1 -0
  50. package/packages/core/src/cli/watch.ts +73 -0
  51. package/packages/core/src/config/landing.ts +12 -0
  52. package/packages/core/src/config/live.ts +4 -0
  53. package/packages/core/src/config/path-selectors.ts +68 -0
  54. package/packages/core/src/config/profiles.ts +96 -0
  55. package/packages/core/src/config/ready-assignee.ts +43 -11
  56. package/packages/core/src/config/roles.ts +33 -10
  57. package/packages/core/src/config/schema.ts +205 -81
  58. package/packages/core/src/events/catalog.ts +17 -3
  59. package/packages/core/src/events/compatibility.ts +4 -1
  60. package/packages/core/src/events/forge-degradation-policy.ts +16 -2
  61. package/packages/core/src/events/head-paths-limits.ts +25 -0
  62. package/packages/core/src/events/payloads.ts +323 -20
  63. package/packages/core/src/events/policy.ts +22 -0
  64. package/packages/core/src/events/repository.ts +47 -1
  65. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +320 -130
  66. package/packages/core/src/kernel/build-creation.ts +29 -0
  67. package/packages/core/src/kernel/consent-revocation.ts +72 -0
  68. package/packages/core/src/kernel/dispatch-capacity.ts +19 -8
  69. package/packages/core/src/kernel/engine.ts +48 -8
  70. package/packages/core/src/kernel/forge-health.ts +47 -0
  71. package/packages/core/src/kernel/guarded-forge.ts +76 -18
  72. package/packages/core/src/kernel/head-paths-state.ts +63 -0
  73. package/packages/core/src/kernel/head-paths.ts +401 -0
  74. package/packages/core/src/kernel/landing-policy-identity.ts +20 -0
  75. package/packages/core/src/kernel/landing-policy.ts +55 -2
  76. package/packages/core/src/kernel/landing-readiness.ts +104 -9
  77. package/packages/core/src/kernel/landing-state.ts +44 -4
  78. package/packages/core/src/kernel/leaf-restack-state.ts +50 -2
  79. package/packages/core/src/kernel/log-index.ts +27 -1
  80. package/packages/core/src/kernel/node-parent.ts +2 -0
  81. package/packages/core/src/kernel/node-polling.ts +13 -3
  82. package/packages/core/src/kernel/node-restack-state.ts +8 -1
  83. package/packages/core/src/kernel/node-restack-transaction.ts +45 -0
  84. package/packages/core/src/kernel/read-deferrals.ts +3 -1
  85. package/packages/core/src/kernel/read-facts.ts +37 -2
  86. package/packages/core/src/kernel/reducer-registry.ts +22 -1
  87. package/packages/core/src/kernel/reducer.ts +332 -16
  88. package/packages/core/src/kernel/target-observation.ts +2 -5
  89. package/packages/core/src/kernel/terminal-guard.ts +52 -3
  90. package/packages/core/src/kernel/ticket-handbacks.ts +40 -0
  91. package/packages/core/src/kernel/ticket-preparation.ts +15 -1
  92. package/packages/core/src/kernel/ticket-wait.ts +345 -0
  93. package/packages/core/src/kernel/verify-applicability.ts +9 -19
  94. package/packages/core/src/ontology.ts +1 -0
  95. package/packages/core/src/operator/annotations.ts +6 -0
  96. package/packages/core/src/operator/index.ts +3 -0
  97. package/packages/core/src/operator/protocol.ts +25 -2
  98. package/packages/core/src/operator/query.ts +1 -1
  99. package/packages/core/src/operator/registry.ts +122 -10
  100. package/packages/core/src/operator/repository-events.ts +67 -0
  101. package/packages/core/src/operator/sandbox-host.ts +3 -0
  102. package/packages/core/src/operator/tickets.ts +15 -3
  103. package/packages/core/src/plugin-sdk/index.ts +4 -0
  104. package/packages/core/src/ports/forge/create.ts +6 -0
  105. package/packages/core/src/ports/forge/github-transport.ts +40 -3
  106. package/packages/core/src/ports/forge/github.ts +12 -1
  107. package/packages/core/src/ports/forge/workspace-ancestry.ts +60 -0
  108. package/packages/core/src/ports/forge-failure.ts +31 -2
  109. package/packages/core/src/ports/runner/routing.ts +66 -5
  110. package/packages/core/src/ports/tickets/assignees.ts +54 -0
  111. package/packages/core/src/ports/tickets/contract.ts +164 -4
  112. package/packages/core/src/ports/tickets/create.ts +17 -3
  113. package/packages/core/src/ports/tickets/fake.ts +5 -0
  114. package/packages/core/src/ports/tickets/github-fake.ts +18 -2
  115. package/packages/core/src/ports/tickets/github.ts +247 -29
  116. package/packages/core/src/ports/tickets/hosted-index.ts +1 -0
  117. package/packages/core/src/ports/tickets/operations.ts +6 -1
  118. package/packages/core/src/ports/tickets/tree.ts +12 -2
  119. package/packages/core/src/ports/tickets/update.ts +6 -2
  120. package/packages/core/src/ports/types.ts +36 -5
  121. package/packages/core/src/ports/workspace/vercel-sandbox.ts +9 -0
  122. package/packages/core/src/processes/build-child.ts +28 -7
  123. package/packages/core/src/processes/build-execution-state.ts +34 -2
  124. package/packages/core/src/processes/build-runner.ts +165 -19
  125. package/packages/core/src/processes/dispatcher.ts +837 -115
  126. package/packages/core/src/processes/execution-no-progress.ts +22 -2
  127. package/packages/core/src/processes/harvest-child.ts +4 -0
  128. package/packages/core/src/processes/harvest-runner.ts +5 -0
  129. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  130. package/packages/core/src/processes/publication-state.ts +6 -1
  131. package/packages/core/src/processes/repo-view.ts +2 -0
  132. package/packages/core/src/scenarios/harness.ts +15 -1
  133. package/packages/core/src/store/digest.ts +41 -2
  134. package/packages/core/src/store/reduced-reads.ts +4 -1
  135. package/packages/core/src/store/reducer-value-shapes.json +10310 -8441
  136. package/packages/core/src/store/remote/client.ts +49 -10
  137. package/packages/core/src/store/remote/index.ts +4 -0
  138. package/packages/core/src/store/remote/protocol.ts +18 -1
  139. package/packages/core/src/store/remote/released-clients.json +22 -0
  140. package/packages/core/src/store/remote/released-reducer-values/1.7.0.json +27366 -0
  141. package/packages/core/src/store/remote/released-reducer-values/1.8.0.json +29043 -0
  142. package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
  143. package/packages/core/src/store/repo-state-events.ts +3 -0
  144. package/packages/core/src/store/types.ts +27 -0
  145. package/packages/core/src/testing/dispatch-read-budget.ts +84 -58
  146. package/packages/core/src/testing/index.ts +2 -0
  147. package/packages/core/src/testing/reduced-read-budget.ts +419 -9
  148. package/skills/code-review/SKILL.md +8 -0
  149. package/skills/finalize/SKILL.md +4 -0
  150. package/skills/guide/SKILL.md +241 -47
  151. package/skills/guide/references/integration-tree.md +7 -4
  152. package/skills/guide/references/merge-policy.md +78 -6
  153. package/skills/guide/references/migration-1.0.md +4 -2
  154. package/skills/guide/references/operator-api.md +45 -13
  155. package/skills/guide/references/plugin-authoring.md +45 -7
  156. package/skills/guide/references/remote-store-protocol.md +28 -7
  157. package/skills/guide/references/restacking.md +35 -11
  158. package/skills/guide/references/ticket-dependencies.md +9 -4
  159. package/skills/implement/SKILL.md +15 -1
  160. package/skills/operate/SKILL.md +133 -16
  161. package/skills/plan/SKILL.md +17 -2
  162. package/skills/plan-review/SKILL.md +8 -0
  163. package/skills/reconcile/SKILL.md +21 -5
  164. package/skills/tickets/SKILL.md +23 -6
  165. package/templates/hosted-service/package.json +2 -2
@@ -201,12 +201,12 @@ export const HELP_CATALOG: readonly HelpEntry[] = [
201
201
  detail: page([
202
202
  'Usage:',
203
203
  ' ab ticket tree [--json]',
204
- ' ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|normal] [--kind work|node] [--target <id> | --no-target] [--json]',
204
+ ' 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]',
205
205
  ' ab ticket edit <id>',
206
206
  ' ab ticket export <dir> [--store <ref>]',
207
207
  ' ab ticket import <dir> [--states <state,...>] [--store <ref>]',
208
208
  ' ab ticket migration record <dir> [--store <ref>]',
209
- ' ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|normal] [--expected-revision <opaque>] [--json]',
209
+ ' 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]',
210
210
  ' ab ticket block <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
211
211
  ' ab ticket unblock <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
212
212
  ' ab ticket list [--state <state>] [--labels a,b] [--json]',
@@ -243,12 +243,18 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
243
243
  'in source order; it never preempts a running build. normal (the default)',
244
244
  'removes urgency. Sources that cannot store priority refuse urgent, name the',
245
245
  'source, and write nothing; normal is a no-op there.',
246
+ '--assignees entries are usernames or me (the owner of the source credential).',
247
+ 'On create they replace the [tickets].createAssignee default and --assignees ""',
248
+ 'creates an unassigned ticket; on update they replace the set and "" clears it.',
249
+ 'Sources that cannot store assignees refuse the write, name the source, and',
250
+ 'write nothing.',
246
251
  '',
247
252
  'With no list filters, list uses the same ready criteria as dispatch. show one ticket, including its body/spec.',
248
253
  'Human output is the default and marks urgent tickets. --json emits exactly',
249
254
  'one bare value, and every JSON ticket names its priority: Ticket[]',
250
255
  'for list, the hierarchy for tree, and the resulting Ticket for ticket mutations; show',
251
- 'adds an assets array (kind, name, revision, size, layout, fileCount).',
256
+ 'adds an assets array (kind, name, revision, size, layout, fileCount). Sources',
257
+ 'that store assignees add an assignees array of usernames.',
252
258
  '',
253
259
  'Ticket assets are files or folders (a design export, a reference screenshot, a',
254
260
  'sample payload) attached to a ticket and kept in the BuildStore, never in the',
@@ -314,7 +320,8 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
314
320
  summary: 'List ready merges awaiting consent.',
315
321
  detail: page([
316
322
  'Usage: ab merges [--json] [--store <ref>]',
317
- 'Shows ready consent and held merges with effective target, branch, verification and node children.',
323
+ 'Shows ready consent and held merges with effective target, branch, verification, node children,',
324
+ 'the current candidate head and any consented head.',
318
325
  'Use ab merge <slug> to consent or ab hold <slug> to withdraw consent. Merge rechecks readiness.',
319
326
  'Source ancestry is available separately through ab ticket tree or MCP tickets.tree.',
320
327
  ]),
@@ -332,6 +339,10 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
332
339
  'shows every status and subsumes --queued. --json emits the projection as a',
333
340
  'bare JSON value, and --store overrides the BuildStore path or URL.',
334
341
  '',
342
+ 'A build parked on a ticket wait lists as waiting, with the tickets after its',
343
+ 'phase. --json keeps the reducer status (blocked) and adds wait with its state',
344
+ 'and tickets.',
345
+ '',
335
346
  'This command is read-only and requires no session identity for operator use.',
336
347
  'Inside a phase, a complete ambient tuple retains its build scope, so the',
337
348
  'repository-wide list is denied; malformed or partial identity is rejected.',
@@ -402,18 +413,24 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
402
413
  'Default filter — actionable attention only. Builds: escalation.raised, phase.deferral-escalated, integration.landed,',
403
414
  'integration.verification-failed (failed node verification), build.janitor-failing, build.janitor-escalated,',
404
415
  'build.compatibility-deferred, node.item-conflicted, target.rewritten, conflicted restack.replayed,',
405
- 'derived build.consent-ready and',
416
+ 'landing.consent-revoked (protected merge consent revoked by a reconcile), derived build.consent-ready and',
406
417
  'build.merge-decision (a current actionable merge-gate deferral or unsafe forge outcome).',
407
418
  'Consent and held ready merges use only build.consent-ready, once per readiness episode.',
408
419
  'Unready or stale consent candidates stay silent; one merge gate decision per build/PR.',
409
420
  'Repository: harvest.escalated, harvest.recovery-exhausted, dispatcher.config-rejected, dispatcher.forge-readiness-failed,',
410
- 'dispatcher.kernel-git-unavailable, dispatcher.config-reloaded with restartRequired, abnormal dispatcher.run-stopped,',
421
+ 'dispatcher.kernel-git-unavailable, forge.credential-limited, dispatcher.config-reloaded with restartRequired,',
422
+ 'abnormal dispatcher.run-stopped,',
411
423
  'abandoned ticket-preparation.resolved (claim confirmed or unconfirmed; ticket unchanged),',
424
+ 'ticket.handed-back (a claimed or ready ticket returned other than as completion: abort,',
425
+ 'spec-bounce, preparation-failed, pr-closed or discard; emitted once after the move),',
412
426
  'and dispatcher.lost. dispatcher.ticket-source-persistent reports degradation past',
413
427
  'resetAt after a tick started at or after reset completes or fails while still degraded,',
414
428
  'or 15 minutes without a reset; dispatcher.tick-failure-persistent reports',
415
429
  'five minutes of continuous tick failure outside source grace or cooldown. Each episode',
416
430
  'reports once; recovery ends it. Cooldown failures do not start the tick-failure clock.',
431
+ 'Ticket waits are routine, not attention: wait.entered, wait.ended and the escalation.answered',
432
+ "that ends a wait stay out of the default. Follow them with --event 'wait.*' --event escalation.answered.",
433
+ 'A wait-unresolvable escalation (a waited ticket was rejected or deleted) is ordinary attention.',
417
434
  '--event replaces defaults with exactly matching catalog events (or dispatcher.lost).',
418
435
  'Routine failures, finalize and terminal outcomes require explicit --event globs.',
419
436
  'Derived records carry observation instead of event, with observedAt and PR/reason',
@@ -658,13 +675,27 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
658
675
  summary: 'Request that a non-terminal build abort and be cleaned up.',
659
676
  detail: page([
660
677
  'Usage:',
661
- ' ab abort <slug> [--store <ref>]',
678
+ ' ab abort <slug> [--to triage|ready] [--reason <text>] [--store <ref>]',
662
679
  '',
663
680
  'Durably request that a queued, running, paused, or blocked build abort. The live',
664
681
  'agent turn is cancelled promptly; dispatcher cleanup closes any unmerged PR,',
665
682
  'removes the workspace and local/remote branches, labels the ticket',
666
- 'autobuild:aborted, and returns it to triage. Cleanup is asynchronous and retry-safe.',
667
- '--store overrides the BuildStore path or URL. This command is sessionless; a phase',
683
+ 'autobuild:aborted, and hands the ticket back. Cleanup is asynchronous and retry-safe.',
684
+ '',
685
+ ' --to <role> Where the ticket goes: triage (default) or ready. ready moves it',
686
+ ' straight to the configured ready state with its blockedBy list',
687
+ ' unchanged, so it redispatches once its blockers merge; no second',
688
+ ' move is needed. A ticket that no longer conforms to the spec',
689
+ ' standard falls back to triage, and the comment lists what is missing.',
690
+ ' --reason <text> Recorded on the request (1-2000 characters) and quoted in the',
691
+ ' hand-back comment.',
692
+ ' --store <ref> Override the BuildStore path or URL.',
693
+ '',
694
+ 'The ticket moves once, inside cleanup. After the move is committed the dispatcher',
695
+ 'appends one ticket.handed-back repository event (in the default ab watch filter).',
696
+ 'Act on that event, not on build.aborted: moving the ticket after it is safe, and no',
697
+ 'later dispatcher write overrides it. Repeating the same abort is a no-op; a',
698
+ 'different destination or reason is refused. This command is sessionless; a phase',
668
699
  'may not control its own build.',
669
700
  ]),
670
701
  },
@@ -685,10 +716,20 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
685
716
  audience: 'human' as const,
686
717
  summary: name === 'hold' ? 'Hold a merge and withdraw consent.' : 'Consent to a ready merge.',
687
718
  detail: page([
688
- `Usage: ab ${name} <slug> [--store <ref>]`,
719
+ name === 'hold'
720
+ ? 'Usage: ab hold <slug> [--store <ref>]'
721
+ : 'Usage: ab merge <slug> [--head <sha>] [--store <ref>]',
689
722
  '',
690
- 'Merge consent survives restacks and verification; hold persists until merge.',
723
+ 'Merge consent survives clean restacks and verification; hold persists until merge.',
724
+ 'Consent given under a [[merge]] rule with paths or within is revoked when a reconcile',
725
+ 'edits a file the rule protects (landing.consent-revoked); the build needs fresh consent.',
691
726
  'These sessionless controls never bypass merge gates.',
727
+ ...(name === 'merge'
728
+ ? [
729
+ '--head refuses, recording nothing, unless <sha> (full or ≥7-character prefix)',
730
+ "is the build's current candidate head; consent still survives later clean restacks.",
731
+ ]
732
+ : []),
692
733
  ]),
693
734
  })),
694
735
  {
@@ -837,6 +878,34 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
837
878
  'terminal command. Every phase ends with exactly one terminal command (D5).',
838
879
  ]),
839
880
  },
881
+ {
882
+ name: 'wait-on',
883
+ audience: 'ai',
884
+ summary: 'Park the build on other tickets without holding a slot.',
885
+ detail: page([
886
+ 'Usage:',
887
+ ' ab wait-on <ticket-id>... --reason <text>',
888
+ '',
889
+ 'Declare that this build cannot proceed until the named tickets complete.',
890
+ 'This is a terminal command: it records the request and ends the session.',
891
+ 'The dispatcher checks the ids against the ticket source. Accepted, they are',
892
+ "added to the build's ticket as blockers and the build waits without holding",
893
+ 'a capacity slot, keeping its branch and workspace. Refused (an unknown id,',
894
+ "the build's own ticket, or an already completed ticket), nothing is written",
895
+ 'and this phase re-runs with the reason as guidance. The dispatcher ends an',
896
+ 'accepted wait on its first tick after every named ticket completes; a',
897
+ 'rejected or deleted ticket raises an ordinary escalation instead, and an',
898
+ "operator may end the wait early with 'ab answer'.",
899
+ "When the wait ends the build first restacks onto its target's current head",
900
+ 'if the target moved, so the resumed phase sees the merged blockers (a',
901
+ 'conflicting restack is reconciled first); the phase then resumes with',
902
+ 'guidance naming what it waited on. In implement the command requires a',
903
+ "clean worktree and first publishes the build's commits; a failed push",
904
+ 'writes nothing. A build holds one wait at a time: while another',
905
+ "session's wait is pending or open, this command is refused and writes",
906
+ 'nothing. Every phase ends with exactly one terminal command (D5).',
907
+ ]),
908
+ },
840
909
  {
841
910
  name: 'harvest',
842
911
  audience: 'ai',
@@ -158,7 +158,13 @@ function effectiveTargets(
158
158
  ): Array<{ runtime: string; models: string[] }> {
159
159
  // Preserve eager registry/model/argument validation, but probe only routes
160
160
  // the pipeline can consume rather than every declared role table.
161
- createRuntimeResolver(runtimes, config.roles, config.policy.sessionBudgetSeconds, config.accounts)
161
+ createRuntimeResolver(
162
+ runtimes,
163
+ config.roles,
164
+ config.policy.sessionBudgetSeconds,
165
+ config.accounts,
166
+ config.profiles,
167
+ )
162
168
  return effectiveRuntimeReferences(config).flatMap((group) => {
163
169
  const selected = Object.keys(config.accounts).length ? group.legacyAuthentication : group
164
170
  if (selected === undefined) return []
@@ -577,6 +583,7 @@ async function validateInitReadinessInner(opts: {
577
583
  ])
578
584
  let caps: WorkspaceProviderCapabilities | undefined
579
585
  let assigneeLine: string | undefined
586
+ let createAssigneeLine: string | undefined
580
587
  let roles: Awaited<ReturnType<typeof ticketRoleReadiness>> = { notes: [], checks: [] }
581
588
  let forgeChecks: ForgeReadinessCheck[] = readinessChecks(
582
589
  'unknown',
@@ -659,6 +666,11 @@ async function validateInitReadinessInner(opts: {
659
666
  const assignee = config.tickets.readyAssignee
660
667
  if (assignee !== undefined && ticketSource.describeReadyAssignee !== undefined)
661
668
  assigneeLine = `Ticket assignee gate: ${await ticketSource.describeReadyAssignee(assignee)}`
669
+ // Who every created ticket would be assigned to, so a create never
670
+ // finds out first.
671
+ const createAssignee = config.tickets.createAssignee
672
+ if (createAssignee !== undefined && ticketSource.describeCreateAssignee !== undefined)
673
+ createAssigneeLine = `Ticket create assignee: ${await ticketSource.describeCreateAssignee(createAssignee)}`
662
674
  await ticketSource.listReady({
663
675
  ...(config.tickets.readyLabels !== undefined ? { labels: config.tickets.readyLabels } : {}),
664
676
  state: config.tickets.readyState,
@@ -809,6 +821,7 @@ async function validateInitReadinessInner(opts: {
809
821
  stdout(`Store: ${state.storeRef}`)
810
822
  stdout(`Forge: ${config.forge}`)
811
823
  if (assigneeLine !== undefined) stdout(assigneeLine)
824
+ if (createAssigneeLine !== undefined) stdout(createAssigneeLine)
812
825
  for (const note of roles.notes) stdout(note)
813
826
  // Same raw `[workspace.config]` fallback guestEnvNames gets (f_55ba7591): a
814
827
  // provider that declares describeEnvironment without a configSchema still
@@ -12,7 +12,7 @@ export async function abLandings(opts: StatusOpts): Promise<void> {
12
12
  else
13
13
  for (const entry of entries)
14
14
  opts.stdout(
15
- `${entry.slug} → ${entry.target.ticket?.id ?? entry.target.branch ?? treeVocabulary.root} · ${entry.branch ?? 'unknown branch'} · ${entry.reason} · ${treeVocabulary.verify} ${entry.verification.results.map((r) => `${r.step}:${r.outcome}`).join(', ') || 'no steps'}${entry.kind === 'node' ? ` · ${treeVocabulary.children} ${entry.children?.length ?? 'unknown'} (${entry.completeness})` : ''}`,
15
+ `${entry.slug} → ${entry.target.ticket?.id ?? entry.target.branch ?? treeVocabulary.root} · ${entry.branch ?? 'unknown branch'} · ${entry.reason} · ${treeVocabulary.verify} ${entry.verification.results.map((r) => `${r.step}:${r.outcome}`).join(', ') || 'no steps'}${entry.kind === 'node' ? ` · ${treeVocabulary.children} ${entry.children?.length ?? 'unknown'} (${entry.completeness})` : ''} · ${treeVocabulary.head} ${entry.currentHead ?? 'unknown'}${entry.consentedHead ? ` · ${treeVocabulary.consentedAt} ${entry.consentedHead}` : ''}`,
16
16
  )
17
17
  })
18
18
  }
@@ -9,7 +9,7 @@ import { withSessionlessStore } from './store-opening'
9
9
  import { abLandings } from './landings'
10
10
  import { readBuildFacts } from '../store/reduced-reads'
11
11
  import { preparePinnedAssets } from '../store/ticket-assets'
12
- import type { PinnedAsset } from '../events/payloads'
12
+ import { abortDestinationSchema, type PinnedAsset } from '../events/payloads'
13
13
  import { abConnect, abDisconnect } from './connect'
14
14
  /**
15
15
  * `ab` — the only channel between agents and the store, and the enforcement
@@ -33,7 +33,12 @@ import { spawnExec, type Exec } from '../ports/workspace/git-worktree'
33
33
  import type { IdSource } from '../ids'
34
34
  import { artifactDownload, artifactDownloadStream, artifactGet, artifactPut } from './artifact'
35
35
  import { multiFlag, parseArgs, stringFlag, type ParsedArgs } from './args'
36
- import { abBuildControl, type BuildControlAction, type BuildControlResult } from './build-control'
36
+ import {
37
+ abBuildControl,
38
+ parseConsentHead,
39
+ type BuildControlAction,
40
+ type BuildControlResult,
41
+ } from './build-control'
37
42
  import {
38
43
  abBulkControl,
39
44
  bulkControlLines,
@@ -63,7 +68,7 @@ import { abWatch, WATCH_USAGE } from './watch'
63
68
  import { abWait, WAIT_USAGE } from './wait'
64
69
  import { abMcp, AB_MCP_USAGE } from './mcp'
65
70
  import type { StoreOpener } from './store-opening'
66
- import { done, escalate, verdict } from './terminals'
71
+ import { done, escalate, verdict, waitOn } from './terminals'
67
72
  import { abTicket, lazyTicketSource, openTicketSource } from './ticket'
68
73
  import { checkUpgradeCompatibility, type CompatibilityFetch } from './upgrade-compatibility'
69
74
  import { abUpgrade, type ResolveConflict } from './upgrade'
@@ -278,6 +283,8 @@ export function buildControlConfirmation(result: BuildControlResult): string {
278
283
  'auto-merge-on': 'auto-merge requested',
279
284
  'auto-merge-off': 'auto-merge cancelled',
280
285
  }
286
+ if (result.event.type === 'build.abort-requested')
287
+ return `build ${result.slug}: abort requested; ticket returns to ${result.event.payload.to ?? 'triage'}`
281
288
  return `build ${result.slug}: ${outcome[result.command]}`
282
289
  }
283
290
  case 'answered': {
@@ -1154,13 +1161,24 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
1154
1161
  }
1155
1162
 
1156
1163
  case 'abort': {
1157
- const usage = 'usage: ab abort <slug> [--store <ref>]'
1158
- const parsed = parseArgs(rest, { store: 'value' }, usage)
1164
+ const usage = 'usage: ab abort <slug> [--to triage|ready] [--reason <text>] [--store <ref>]'
1165
+ const parsed = parseArgs(rest, { store: 'value', to: 'value', reason: 'value' }, usage)
1159
1166
  if (parsed.positionals.length !== 1) throw new Error(usage)
1167
+ const to = stringFlag(parsed, 'to')
1168
+ const destination = abortDestinationSchema.safeParse(to)
1169
+ if (to !== undefined && !destination.success)
1170
+ throw new Error(
1171
+ `--to must be one of: ${abortDestinationSchema.options.join(', ')} — ${usage}`,
1172
+ )
1173
+ const reason = stringFlag(parsed, 'reason')
1160
1174
  await runBuildControl(
1161
1175
  deps,
1162
1176
  parsed.positionals[0]!,
1163
- { kind: 'abort' },
1177
+ {
1178
+ kind: 'abort',
1179
+ ...(destination.success ? { to: destination.data } : {}),
1180
+ ...(reason !== undefined ? { reason } : {}),
1181
+ },
1164
1182
  stringFlag(parsed, 'store'),
1165
1183
  )
1166
1184
  return 0
@@ -1192,13 +1210,29 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
1192
1210
  case 'merge':
1193
1211
  case 'land': {
1194
1212
  if (command === 'land') stderr('ab land is deprecated; use ab merge')
1195
- const usage = `usage: ab ${command} <slug> [--store <ref>]`
1196
- const parsed = parseArgs(rest, { store: 'value' }, usage)
1213
+ if (command === 'hold') {
1214
+ const usage = 'usage: ab hold <slug> [--store <ref>]'
1215
+ const parsed = parseArgs(rest, { store: 'value' }, usage)
1216
+ if (parsed.positionals.length !== 1) throw new Error(usage)
1217
+ await runBuildControl(
1218
+ deps,
1219
+ parsed.positionals[0]!,
1220
+ { kind: 'hold' },
1221
+ stringFlag(parsed, 'store'),
1222
+ )
1223
+ return 0
1224
+ }
1225
+ const usage = `usage: ab ${command} <slug> [--head <sha>] [--store <ref>]`
1226
+ const parsed = parseArgs(rest, { store: 'value', head: 'value' }, usage)
1197
1227
  if (parsed.positionals.length !== 1) throw new Error(usage)
1228
+ const headFlag = stringFlag(parsed, 'head')
1229
+ const head = headFlag === undefined ? undefined : parseConsentHead(headFlag)
1230
+ if (headFlag !== undefined && head === undefined)
1231
+ throw new Error(`--head must be a nonblank commit SHA — ${usage}`)
1198
1232
  await runBuildControl(
1199
1233
  deps,
1200
1234
  parsed.positionals[0]!,
1201
- { kind: command === 'merge' ? 'land' : command },
1235
+ head === undefined ? { kind: 'land' } : { kind: 'land', head },
1202
1236
  stringFlag(parsed, 'store'),
1203
1237
  )
1204
1238
  return 0
@@ -1656,6 +1690,23 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
1656
1690
  return 0
1657
1691
  }
1658
1692
 
1693
+ case 'wait-on': {
1694
+ const usage = 'usage: ab wait-on <ticket-id>... --reason <text>'
1695
+ const parsed = parseArgs(rest, { reason: 'value' }, usage)
1696
+ if (parsed.positionals.length === 0) throw new Error(usage)
1697
+ const reason = stringFlag(parsed, 'reason')
1698
+ if (reason === undefined) throw new Error("'ab wait-on' requires --reason <text>")
1699
+ const session = requireSession(command, deps)
1700
+ const event = await waitOn(session, { tickets: parsed.positionals, reason })
1701
+ stdout(
1702
+ `wait requested on ${event.payload.tickets.join(', ')} (${event.payload.id}); ` +
1703
+ 'this session is complete. The dispatcher checks the tickets: if it accepts, the ' +
1704
+ 'build waits without a slot; if it refuses, this phase re-runs with the reason in ' +
1705
+ 'its guidance.',
1706
+ )
1707
+ return 0
1708
+ }
1709
+
1659
1710
  default: {
1660
1711
  stderr(`unknown command "${command}"\n\n${renderTopLevelHelp()}`)
1661
1712
  return 1
@@ -395,6 +395,16 @@ export async function settlePendingPublication(
395
395
  })
396
396
  return
397
397
  }
398
+ if (request.payload.operation === 'wait') {
399
+ // The wait's declaration follows its request; the dispatcher enters the
400
+ // wait only after this completion fact.
401
+ await deps.store.append(slug, {
402
+ actor: DISPATCHER,
403
+ type: 'wait.published',
404
+ payload: { id: request.payload.id, sha: request.payload.sha },
405
+ })
406
+ return
407
+ }
398
408
 
399
409
  const description = await deps.store.getArtifact(
400
410
  slug,
@@ -16,7 +16,13 @@ import {
16
16
  type DispatchCapacity,
17
17
  type CapacityBuild,
18
18
  } from '../kernel/dispatch-capacity'
19
- import { forgeHealthReducer, type ForgeDegradation } from '../kernel/forge-health'
19
+ import {
20
+ activeForgeCredentialLimits,
21
+ forgeCredentialLimitsReducer,
22
+ forgeHealthReducer,
23
+ type ForgeCredentialLimit,
24
+ type ForgeDegradation,
25
+ } from '../kernel/forge-health'
20
26
  import { forgeHotspot, type ForgeRequestCounts } from '../ports/forge-telemetry'
21
27
  import { configSchema } from '../config/schema'
22
28
  import type { BuildStore } from '../store/types'
@@ -167,6 +173,10 @@ export interface RepositoryStatus extends DispatchSettings {
167
173
  capacity?: DispatchCapacity
168
174
  /** Dispatcher startup warnings, then forge readiness warnings. */
169
175
  warningLines?: string[]
176
+ /** Standing ticket diagnostics from the latest completed ticket scan — for
177
+ * example an invalid ticket, or a ready ticket whose labels select more than
178
+ * one role profile and is therefore not claimed. */
179
+ ticketDiagnostics?: string[]
170
180
  /** Standing dependency/target diagnostics from the latest completed ticket
171
181
  * scan — for example a ticket held because its target node is being built
172
182
  * by another store. */
@@ -176,6 +186,10 @@ export interface RepositoryStatus extends DispatchSettings {
176
186
  forgeRequests?: ForgeRequestCounts
177
187
  forgeRequestHotspot?: string
178
188
  forgeDegradation?: ForgeDegradation
189
+ /** Active rate limits outside the dispatcher's credential (unauthenticated
190
+ * requests, build runners, phase sessions). They never pause dispatcher
191
+ * forge work; each names the limited process. */
192
+ forgeCredentialLimits?: ForgeCredentialLimit[]
179
193
  ticketSourceDegradation?: TicketSourceDegradation
180
194
  /** Live operator sandboxes (AUT-340); released environments are omitted. */
181
195
  sandboxes: Array<{
@@ -216,7 +230,12 @@ export function projectRepositoryStatus(
216
230
  repo: string,
217
231
  events: RepositoryEvent[],
218
232
  dispatcher = projectDispatcherLiveness(null, [], new Date()),
233
+ now: Date = new Date(),
219
234
  ): RepositoryStatus {
235
+ const credentialLimits = activeForgeCredentialLimits(
236
+ forgeCredentialLimitsReducer.reduce(events),
237
+ now,
238
+ )
220
239
  const publications: RepositoryStatus['publications'] = []
221
240
  for (const event of events) {
222
241
  if (event.type !== 'orchestrator.sandbox.published') continue
@@ -252,10 +271,15 @@ export function projectRepositoryStatus(
252
271
  latestScan?.type === 'dispatcher.ticket-scan-completed'
253
272
  ? latestScan.payload.dependencyDiagnostics
254
273
  : []
274
+ const ticketDiagnostics =
275
+ latestScan?.type === 'dispatcher.ticket-scan-completed'
276
+ ? latestScan.payload.ticketDiagnostics
277
+ : []
255
278
  return {
256
279
  ...(forgeHealthReducer.reduce(events)
257
280
  ? { forgeDegradation: forgeHealthReducer.reduce(events) }
258
281
  : {}),
282
+ ...(credentialLimits.length ? { forgeCredentialLimits: credentialLimits } : {}),
259
283
  ...(active === undefined ? {} : { ticketSourceDegradation: active }),
260
284
  ...(Object.keys(repositoryReadFactsReducer.reduce(events).missingAccounts).length
261
285
  ? { missingAccounts: repositoryReadFactsReducer.reduce(events).missingAccounts }
@@ -266,6 +290,7 @@ export function projectRepositoryStatus(
266
290
  upgradeStatus: projectUpgradeStatus(dispatchUpgradeReducer.reduce(events), dispatcher),
267
291
  rollbackHold: effectiveRollbackHold(dispatchUpgradeReducer.reduce(events), dispatcher),
268
292
  ...(warningLines.length ? { warningLines } : {}),
293
+ ...(ticketDiagnostics.length ? { ticketDiagnostics: [...ticketDiagnostics] } : {}),
269
294
  ...(dependencyDiagnostics.length ? { dependencyDiagnostics: [...dependencyDiagnostics] } : {}),
270
295
  dispatcher,
271
296
  ...(() => {
@@ -294,11 +319,14 @@ export function repositoryStatusFromFacts(
294
319
  repo: string,
295
320
  facts: RepositoryReadFacts,
296
321
  dispatcher: DispatcherLiveness,
322
+ now: Date = new Date(),
297
323
  ): RepositoryStatus {
324
+ const credentialLimits = activeForgeCredentialLimits(facts.forgeCredentialLimits, now)
298
325
  const warningLines = facts.status
299
326
  ? [...facts.status.roleWarnings, ...forgeReadinessWarnings(facts.status)]
300
327
  : []
301
328
  const dependencyDiagnostics = facts.scan?.dependencyDiagnostics ?? []
329
+ const ticketDiagnostics = facts.scan?.ticketDiagnostics ?? []
302
330
  return {
303
331
  ...(Object.keys(facts.missingAccounts).length
304
332
  ? { missingAccounts: facts.missingAccounts }
@@ -309,6 +337,7 @@ export function repositoryStatusFromFacts(
309
337
  upgradeStatus: projectUpgradeStatus(facts.upgrades, dispatcher),
310
338
  rollbackHold: effectiveRollbackHold(facts.upgrades, dispatcher),
311
339
  ...(warningLines.length ? { warningLines } : {}),
340
+ ...(ticketDiagnostics.length ? { ticketDiagnostics: [...ticketDiagnostics] } : {}),
312
341
  ...(dependencyDiagnostics.length ? { dependencyDiagnostics: [...dependencyDiagnostics] } : {}),
313
342
  dispatcher,
314
343
  ...(() => {
@@ -321,6 +350,7 @@ export function repositoryStatusFromFacts(
321
350
  })(),
322
351
  ...facts.settings,
323
352
  ...(facts.forgeHealth ? { forgeDegradation: facts.forgeHealth } : {}),
353
+ ...(credentialLimits.length ? { forgeCredentialLimits: credentialLimits } : {}),
324
354
  ...(facts.health === undefined ? {} : { ticketSourceDegradation: facts.health }),
325
355
  sandboxes: facts.sandboxes
326
356
  .filter((state) => state.state !== 'released')
@@ -425,6 +455,10 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
425
455
  `forge ${status.forgeDegradation.forge}: degraded — ${status.forgeDegradation.message}; reset ${status.forgeDegradation.resetAt}`,
426
456
  ]
427
457
  : []),
458
+ ...(status.forgeCredentialLimits ?? []).map(
459
+ (limit) =>
460
+ `forge ${limit.forge}: ${limit.process} rate-limited (${limit.credential}${limit.missingCredential ? `: ${limit.missingCredential}` : ''}) until ${limit.resetAt}; dispatcher forge work is not paused`,
461
+ ),
428
462
  ...(active === undefined
429
463
  ? []
430
464
  : [
@@ -458,6 +492,7 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
458
492
  `intake: ${setting(status.intake)}`,
459
493
  `repository pause: ${setting(status.paused)}`,
460
494
  `default auto-merge: ${setting(status.defaultAutoMerge)}`,
495
+ ...(status.ticketDiagnostics ?? []).map((line) => `queue: ${line}`),
461
496
  ...(status.dependencyDiagnostics ?? []).map((line) => `queue: ${line}`),
462
497
  ...status.sandboxes.map(
463
498
  (sandbox) =>
@@ -525,7 +560,7 @@ export async function abRepositoryStatus(opts: RepositoryStatusOpts): Promise<vo
525
560
  const observedAt = opts.now?.() ?? new Date()
526
561
  const { dispatcher } = await readDispatcherLiveness(store, repo, observedAt)
527
562
  const facts = (await readRepositoryFacts(store, repo)).value
528
- const status = repositoryStatusFromFacts(repo, facts, dispatcher)
563
+ const status = repositoryStatusFromFacts(repo, facts, dispatcher, observedAt)
529
564
  status.operator = {
530
565
  presence: 'loaded',
531
566
  registrations: (await store.listOperatorPresence(repo))