@defrex/autobuild 1.4.1 → 1.5.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 (201) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +440 -95
  3. package/bin/ab-dispatch-kernel.ts +1 -0
  4. package/docs/accounts.md +9 -0
  5. package/docs/agent-runtimes.md +1 -0
  6. package/docs/answering-blocked-builds.md +2 -1
  7. package/docs/architecture.md +290 -130
  8. package/docs/assets/headline-wide.png +0 -0
  9. package/docs/build-store.md +33 -3
  10. package/docs/cli.md +2 -1
  11. package/docs/configuration-overview.md +9 -0
  12. package/docs/configuration.md +166 -101
  13. package/docs/dispatcher-hosting.md +19 -3
  14. package/docs/dispatcher.md +9 -4
  15. package/docs/integration-overview.md +2 -2
  16. package/docs/integration-tree.md +91 -28
  17. package/docs/merge-policy.md +28 -9
  18. package/docs/operator-api.md +43 -18
  19. package/docs/operator-surfaces.md +1 -1
  20. package/docs/plugin-authoring.md +85 -8
  21. package/docs/remote-store-protocol.md +25 -7
  22. package/docs/remote-ticket-protocol.md +126 -12
  23. package/docs/restacking.md +20 -6
  24. package/docs/seams.md +2 -2
  25. package/docs/setup.md +19 -13
  26. package/docs/spec-standard.md +2 -1
  27. package/docs/ticket-dependencies.md +26 -8
  28. package/docs/ticket-migration.md +70 -7
  29. package/docs/ticket-sources.md +82 -5
  30. package/docs/tickets.md +34 -2
  31. package/docs/troubleshooting.md +2 -2
  32. package/docs/verification.md +5 -5
  33. package/docs/website.md +8 -0
  34. package/docs/workspaces.md +1 -1
  35. package/package.json +5 -4
  36. package/packages/core/src/accounts/hosted-readiness.ts +21 -0
  37. package/packages/core/src/cli/attention.ts +1 -0
  38. package/packages/core/src/cli/build-control.ts +36 -12
  39. package/packages/core/src/cli/connect.ts +9 -18
  40. package/packages/core/src/cli/context.ts +44 -0
  41. package/packages/core/src/cli/dashboard/configuration.ts +11 -0
  42. package/packages/core/src/cli/dashboard/model.ts +40 -10
  43. package/packages/core/src/cli/dashboard/queue.ts +21 -0
  44. package/packages/core/src/cli/dashboard/render.ts +40 -22
  45. package/packages/core/src/cli/dispatch-frontend.ts +63 -30
  46. package/packages/core/src/cli/dispatch-mode.ts +35 -16
  47. package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
  48. package/packages/core/src/cli/dispatch.ts +154 -47
  49. package/packages/core/src/cli/help.ts +59 -22
  50. package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
  51. package/packages/core/src/cli/init-readiness-remote.ts +16 -3
  52. package/packages/core/src/cli/init-validation.ts +144 -42
  53. package/packages/core/src/cli/issue-links.ts +67 -0
  54. package/packages/core/src/cli/main.ts +32 -15
  55. package/packages/core/src/cli/pr-summary-publication.ts +38 -7
  56. package/packages/core/src/cli/publication-settlement.ts +36 -24
  57. package/packages/core/src/cli/repository-status.ts +201 -49
  58. package/packages/core/src/cli/status.ts +41 -3
  59. package/packages/core/src/cli/terminals.ts +37 -2
  60. package/packages/core/src/cli/ticket-editor.ts +20 -6
  61. package/packages/core/src/cli/ticket.ts +264 -46
  62. package/packages/core/src/cli/triage-count-sampler.ts +59 -0
  63. package/packages/core/src/cli/watch.ts +4 -0
  64. package/packages/core/src/config/live.ts +45 -4
  65. package/packages/core/src/config/load.ts +9 -0
  66. package/packages/core/src/config/pipeline-source.ts +6 -2
  67. package/packages/core/src/config/ready-assignee.ts +86 -0
  68. package/packages/core/src/config/schema.ts +164 -36
  69. package/packages/core/src/distribution-packaging.ts +1 -1
  70. package/packages/core/src/events/catalog.ts +5 -0
  71. package/packages/core/src/events/compatibility.ts +2 -1
  72. package/packages/core/src/events/payloads.ts +70 -0
  73. package/packages/core/src/events/policy.ts +8 -0
  74. package/packages/core/src/events/repository.ts +91 -28
  75. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +41 -0
  76. package/packages/core/src/kernel/build-identity.ts +12 -0
  77. package/packages/core/src/kernel/change-presence.ts +139 -6
  78. package/packages/core/src/kernel/dispatch-capacity.ts +80 -14
  79. package/packages/core/src/kernel/dispatch-status.ts +10 -1
  80. package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
  81. package/packages/core/src/kernel/engine.ts +4 -2
  82. package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
  83. package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
  84. package/packages/core/src/kernel/harvest.ts +4 -1
  85. package/packages/core/src/kernel/integration-completeness.ts +104 -17
  86. package/packages/core/src/kernel/integration-landing.ts +17 -0
  87. package/packages/core/src/kernel/integration-state.ts +17 -0
  88. package/packages/core/src/kernel/issue-keywords.ts +202 -0
  89. package/packages/core/src/kernel/janitor-failure.ts +11 -0
  90. package/packages/core/src/kernel/kernel-git.ts +87 -0
  91. package/packages/core/src/kernel/landing-readiness.ts +25 -17
  92. package/packages/core/src/kernel/log-index.ts +1 -1
  93. package/packages/core/src/kernel/node-issue-links.ts +142 -0
  94. package/packages/core/src/kernel/node-parent.ts +6 -0
  95. package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
  96. package/packages/core/src/kernel/pr-summary.ts +24 -0
  97. package/packages/core/src/kernel/read-deferrals.ts +75 -12
  98. package/packages/core/src/kernel/read-facts.ts +32 -1
  99. package/packages/core/src/kernel/reconcile-restack.ts +1 -1
  100. package/packages/core/src/kernel/reducer-registry.ts +31 -1
  101. package/packages/core/src/kernel/reducer.ts +90 -2
  102. package/packages/core/src/kernel/ticket-preparation.ts +12 -0
  103. package/packages/core/src/kernel/verify-budget.ts +43 -0
  104. package/packages/core/src/operator/index.ts +3 -1
  105. package/packages/core/src/operator/presentation.ts +3 -0
  106. package/packages/core/src/operator/protocol.ts +38 -2
  107. package/packages/core/src/operator/query.ts +66 -29
  108. package/packages/core/src/operator/registry.ts +47 -26
  109. package/packages/core/src/operator/tickets.ts +77 -10
  110. package/packages/core/src/plugin-sdk/index.ts +13 -0
  111. package/packages/core/src/plugins/manifest.ts +1 -1
  112. package/packages/core/src/plugins/registry.ts +1 -0
  113. package/packages/core/src/ports/forge/contract.ts +69 -0
  114. package/packages/core/src/ports/forge/create.ts +5 -0
  115. package/packages/core/src/ports/forge/fake.ts +184 -3
  116. package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
  117. package/packages/core/src/ports/forge/github.ts +175 -38
  118. package/packages/core/src/ports/forge/local-git.ts +14 -0
  119. package/packages/core/src/ports/forge/readiness.ts +10 -0
  120. package/packages/core/src/ports/forge-failure.ts +43 -0
  121. package/packages/core/src/ports/runner/claude.ts +7 -1
  122. package/packages/core/src/ports/runner/codex.ts +7 -2
  123. package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
  124. package/packages/core/src/ports/runner/pi.ts +7 -1
  125. package/packages/core/src/ports/runner/runtime.ts +3 -0
  126. package/packages/core/src/ports/runner/start-prompt.ts +37 -0
  127. package/packages/core/src/ports/tickets/contract.ts +320 -7
  128. package/packages/core/src/ports/tickets/create.ts +72 -17
  129. package/packages/core/src/ports/tickets/fake.ts +18 -0
  130. package/packages/core/src/ports/tickets/file-codec.ts +20 -0
  131. package/packages/core/src/ports/tickets/file.ts +43 -1
  132. package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
  133. package/packages/core/src/ports/tickets/github-issues.ts +431 -0
  134. package/packages/core/src/ports/tickets/github-validators.ts +194 -0
  135. package/packages/core/src/ports/tickets/github.ts +2029 -0
  136. package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
  137. package/packages/core/src/ports/tickets/issue-links.ts +86 -0
  138. package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
  139. package/packages/core/src/ports/tickets/linear.ts +66 -6
  140. package/packages/core/src/ports/tickets/migration.ts +290 -68
  141. package/packages/core/src/ports/tickets/operations.ts +98 -12
  142. package/packages/core/src/ports/tickets/priority.ts +55 -0
  143. package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
  144. package/packages/core/src/ports/tickets/remote.ts +188 -13
  145. package/packages/core/src/ports/tickets/revision.ts +22 -1
  146. package/packages/core/src/ports/tickets/states.ts +43 -0
  147. package/packages/core/src/ports/tickets/tree.ts +58 -12
  148. package/packages/core/src/ports/tickets/update.ts +12 -2
  149. package/packages/core/src/ports/types.ts +194 -11
  150. package/packages/core/src/ports/workspace/commit-preservation.ts +135 -13
  151. package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
  152. package/packages/core/src/ports/workspace/vercel-sandbox.ts +132 -27
  153. package/packages/core/src/processes/build-runner.ts +99 -21
  154. package/packages/core/src/processes/dispatcher.ts +1080 -533
  155. package/packages/core/src/processes/execution-no-progress.ts +5 -0
  156. package/packages/core/src/processes/harvest-runner.ts +17 -8
  157. package/packages/core/src/processes/harvest.ts +5 -8
  158. package/packages/core/src/processes/tick-publication.ts +12 -2
  159. package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
  160. package/packages/core/src/processes/workspace-preservation.ts +37 -2
  161. package/packages/core/src/runtime-identity.ts +10 -2
  162. package/packages/core/src/scenarios/harness.ts +4 -0
  163. package/packages/core/src/store/adapter.ts +7 -1
  164. package/packages/core/src/store/contract.ts +83 -2
  165. package/packages/core/src/store/digest.ts +32 -1
  166. package/packages/core/src/store/reducer-value-shapes.json +4187 -3391
  167. package/packages/core/src/store/remote/protocol.ts +2 -0
  168. package/packages/core/src/store/remote/released-clients.json +22 -0
  169. package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
  170. package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
  171. package/packages/core/src/store/repo-state-events.ts +2 -0
  172. package/packages/core/src/store/types.ts +5 -0
  173. package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
  174. package/packages/core/src/testing/index.ts +18 -1
  175. package/packages/core/src/testing/presence-history.ts +79 -0
  176. package/packages/core/src/testing/reduced-read-budget.ts +1197 -31
  177. package/packages/core/src/testing/upgrade-generations.ts +77 -0
  178. package/skills/code-review/SKILL.md +4 -3
  179. package/skills/finalize/SKILL.md +18 -2
  180. package/skills/guide/SKILL.md +382 -139
  181. package/skills/guide/references/accounts.md +9 -0
  182. package/skills/guide/references/integration-tree.md +91 -28
  183. package/skills/guide/references/merge-policy.md +28 -9
  184. package/skills/guide/references/operator-api.md +43 -18
  185. package/skills/guide/references/plugin-authoring.md +85 -8
  186. package/skills/guide/references/remote-store-protocol.md +25 -7
  187. package/skills/guide/references/remote-ticket-protocol.md +126 -12
  188. package/skills/guide/references/restacking.md +20 -6
  189. package/skills/guide/references/setup.md +19 -13
  190. package/skills/guide/references/spec-standard.md +2 -1
  191. package/skills/guide/references/ticket-dependencies.md +26 -8
  192. package/skills/guide/references/ticket-migration.md +70 -7
  193. package/skills/harvest-review/SKILL.md +4 -3
  194. package/skills/implement/SKILL.md +20 -1
  195. package/skills/operate/SKILL.md +103 -28
  196. package/skills/plan/SKILL.md +1 -1
  197. package/skills/reconcile/SKILL.md +5 -4
  198. package/skills/spec/SKILL.md +15 -2
  199. package/skills/tickets/SKILL.md +114 -37
  200. package/templates/autobuild.toml +5 -0
  201. package/templates/hosted-service/package.json +2 -2
@@ -372,7 +372,7 @@ it to exist. An unknown build returns `404 not-found`.
372
372
 
373
373
  | BuildStore operation | HTTP route | Request | Success |
374
374
  |---|---|---|---|
375
- | `createBuild` | `POST /builds` | `{slug: string, repo: string, repoOrigin?: string, ticket?: TicketRef, branch?: string, created?: event write}`; `slug`, `repo`, and a supplied `branch` are nonempty. `created`, when present, must be a valid `build.created` write; the server appends it as seq 1 atomically with the record (both exist or neither), and an invalid one is `422` with nothing created | `201` + authoritative `BuildRecord`; project credentials receive a fresh random-suffixed slug and matching branch. Owner admin/open mode keeps exact-slug semantics with `409 conflict` for duplicates |
375
+ | `createBuild` | `POST /builds` | `{slug: string, repo: string, repoOrigin?: string, ticket?: TicketRef, branch?: string, created?: event write}`; `slug`, `repo`, and a supplied `branch` are nonempty. `created`, when present, must be a valid `build.created` write; the server appends it as seq 1 atomically with the record (both exist or neither), and an invalid one is `422` with nothing created | `201` + authoritative `BuildRecord`; project credentials receive a fresh random-suffixed slug and a branch in the build kind's namespace (`ab/<slug>`, or `ab-node/<slug>` for a node); a supplied `branch` must be `ab/<requested slug>` or `ab-node/<requested slug>` agreeing with the `build.created` kind, otherwise `400 validation`. Owner admin/open mode keeps exact-slug semantics with `409 conflict` for duplicates |
376
376
  | `listBuilds` | `GET /builds` | none | `200` + `BuildRecord[]`, filtered by the server to the credential project; owner admin may list all projects. List order is unspecified |
377
377
  | `getBuild` | `GET /builds/{slug}` | none | `200` + `BuildRecord`; absent is `404` (the shipped client maps this to `null`) |
378
378
  | `append` | `POST /builds/{slug}/events` | event write | `201` + build event envelope |
@@ -687,7 +687,7 @@ seconds (the stream/session wait ceiling) and 25 seconds. A held request's authe
687
687
  are identical to the immediate form: a `401`, `403`, or `409` identity failure
688
688
  is answered immediately, never held.
689
689
 
690
- The parameter is purely additive in the version it merged in (protocol `2`,
690
+ The parameter is purely additive in the protocol version that introduced it (protocol `2`,
691
691
  where the event-wait rules were introduced): a server
692
692
  that ignores `wait` remains conforming — its immediate empty answers only raise
693
693
  the client's request rate — and a client that sends `wait` to such a server
@@ -748,7 +748,8 @@ from one build's log:
748
748
  "head": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
749
749
  "base": "cccccccccccccccccccccccccccccccccccccccc",
750
750
  "identities": ["build:child"]
751
- }
751
+ },
752
+ "nodeTargets": ["ab-node-auth"] // node builds the build's target or parent moves ever named, sorted; [] when none
752
753
  }
753
754
  ```
754
755
 
@@ -759,6 +760,16 @@ recording or recovering a contribution advances `readinessChangeSeq`. These
759
760
  members are additive: older peers can omit them, leaving presence unproven rather
760
761
  than substituting source completion. They do not change the protocol version.
761
762
 
763
+ `nodeTargets` lists every node build named by the build's `build.created`
764
+ target or by either side of a `node.parent-requested` or
765
+ `node.parent-accepted` move. The set only grows, so it is a superset of the
766
+ nodes the build relates to, and a dispatcher finds a node's child builds from
767
+ digests, reading full facts only for builds that name that node. Current
768
+ services always send it, possibly empty. The field is additive and keeps the
769
+ protocol version: older clients ignore it. A client that needs it and gets an
770
+ answer without it, from an older service, fails with a typed error instead of
771
+ reading each build's facts.
772
+
762
773
  The digest is derived from the event log on every call — the server persists
763
774
  nothing and there is no refresh step. Protocol version `3` reshaped the
764
775
  digest's `observations` from bare sequence numbers to `{seq, ts}` pairs and
@@ -1110,7 +1121,7 @@ by this rule (their retention belongs to the open archival thread), and open
1110
1121
  streams are never pruned. A read of a stream whose chunks were pruned returns
1111
1122
  no chunks, `status: "closed"`, and the artifact reference.
1112
1123
 
1113
- These additions were purely additive in the version they merged in (protocol
1124
+ These additions were purely additive in the protocol version that introduced them (protocol
1114
1125
  `2`, where the stream routes were introduced), and a
1115
1126
  conforming server implements the stream routes together with this document's
1116
1127
  rules exactly as it does for the event and artifact routes.
@@ -1175,7 +1186,14 @@ streams must also belong to the addressed parent.
1175
1186
 
1176
1187
  `GET /builds` is filtered by the server to the credential's project. Project
1177
1188
  `POST /builds` always allocates a fresh random-suffixed slug from the requested
1178
- base and a matching `ab/<slug>` branch, even when the base is unused. The
1189
+ base, even when the base is unused, and a matching branch in the build kind's
1190
+ namespace: `ab-node/<slug>` when the `build.created` payload has `kind: "node"`,
1191
+ otherwise `ab/<slug>`. Without `created`, a supplied `branch` prefix decides the
1192
+ kind. A supplied `branch` must be exactly `ab/<requested slug>` or
1193
+ `ab-node/<requested slug>` and agree with the `build.created` kind; only its
1194
+ namespace is used. The base (the requested slug's first 60 characters, trailing
1195
+ hyphens removed) must be a kebab build slug. A malformed or conflicting branch,
1196
+ or an invalid base, is `400 validation` with nothing created. The
1179
1197
  returned BuildRecord slug and branch are authoritative for all subsequent
1180
1198
  work. A foreign or missing base returns null on GET; it neither reveals
1181
1199
  collisions nor blocks creation. Owner admin retains exact-slug creation and
@@ -1252,8 +1270,8 @@ a guessed ID cannot bypass the boundary. Only the runner can heartbeat or re-acq
1252
1270
  adopted repository lease holder; another current holder still fences it. Recovery acknowledgements remain dispatcher-side.
1253
1271
 
1254
1272
  Hosted ticket access is gated by grant kind. Build-runner and build-phase grants
1255
- cannot call ticket routes. Harvest-phase grants may call only list-ready, get
1256
- and dependency-states; harvest-runner grants may additionally create proposals.
1273
+ cannot call ticket routes. Harvest-phase grants may call only list-ready,
1274
+ list-targeting, get and dependency-states; harvest-runner grants may additionally create proposals.
1257
1275
  Other ticket mutations require project or admin authority. A denied operation
1258
1276
  returns 403 naming the grant kind and operation before parsing or source construction.
1259
1277
  Ticket admission and repository-keyed assets use the authenticated project;
@@ -99,8 +99,9 @@ The strict request envelope is:
99
99
  loads the project's durable independent ticket policy. Project authority publishes
100
100
  version 1 policy through `POST /tickets/policy`, using the usual context/input
101
101
  envelope. The input contains only `version` and `tickets`: source, teamKey,
102
- readyState, triageState, claimedState, doneState, createState, proposalState and
103
- optional readyLabels. URL, secrets, and pipeline configuration are rejected.
102
+ readyState, triageState, claimedState, doneState, createState, proposalState,
103
+ optional readyLabels, and the optional backlogState and rejectedState roles. URL,
104
+ secrets, and pipeline configuration are rejected.
104
105
  Only project or owner authority can publish. This does not append BuildStore
105
106
  history. Registration removal invalidates policy and grants from that registration.
106
107
 
@@ -114,6 +115,28 @@ State lookup prefers an exact match, then a unique case-insensitive match;
114
115
  unknown or ambiguous names are refused. Lists order configured triage, ready,
115
116
  doing, done first (deduplicated), then other names alphabetically.
116
117
 
118
+ `backlogState` and `rejectedState` have no defaults: an unset role holds no state,
119
+ and a policy that names neither behaves exactly as before. Each must differ,
120
+ case-insensitively, from the ready, claimed, done, triage and proposal states and
121
+ from the other; a publish that overlaps is refused with `400` naming the keys.
122
+ A named role's state is created when missing. Role names match existing states
123
+ case-insensitively, so `backlogState = "icebox"` next to an existing `icebox` (or
124
+ `Icebox`) state creates nothing: that state and its tickets now hold the role.
125
+ Removing a role leaves its state in place as a custom state. Operator and MCP
126
+ ticket tools resolve role moves through these policy names.
127
+
128
+ Clients that understand the roles send `x-autobuild-ticket-policy-roles: 1`. With
129
+ it, a publish is the complete policy, and omitting a role clears it. Without it,
130
+ as from released 1.2–1.4 clients, each omitted role keeps its saved value for the
131
+ same registration, so an older client never erases a newer client's mapping. If
132
+ a kept role would then name the same state as a lifecycle name that publish
133
+ sets, the service keeps the whole saved policy unchanged, answers
134
+ `200 { "ok": true }`, and records a diagnostic naming the colliding keys. A
135
+ policy read (`input: null`) includes the roles only with the header. Every
136
+ `/tickets/*` response, including errors, carries
137
+ `x-autobuild-ticket-policy-roles: 1`; a client publishing a role that receives
138
+ `400` without it reports that the service predates policy roles.
139
+
117
140
  `[tickets] url` selects the ticket service independently of the build store;
118
141
  otherwise the selected remote build store is used. A local build store requires
119
142
  an explicit ticket URL. Credentials are resolved for that selected service.
@@ -129,10 +152,14 @@ AB_TOKEN. Revocation, expiry, parent revocation and registration changes invalid
129
152
  grants. Existing combined-service BuildStore delegation remains supported.
130
153
 
131
154
  The service never contacts Linear or relays external trackers. If the project's
132
- source is Linear, file or another non-hosted source, machine HTTP, operator and
155
+ source is Linear, GitHub, file or another non-hosted source, machine HTTP, operator and
133
156
  MCP ticket surfaces refuse with a message naming that project and source: its
134
157
  tickets live in its own source, accessed directly by its dispatcher. This is a
135
158
  409 conflict, not an empty queue. The dispatcher's direct adapters are unchanged.
159
+ Configuration refusals carry a `code`: `external-ticket-source` for a non-hosted
160
+ source, `no-dispatcher-run` when a project has neither a published ticket policy
161
+ nor any recorded dispatcher run, and `effective-config-unavailable` for other
162
+ missing or unreadable configuration.
136
163
 
137
164
  ## Operations
138
165
 
@@ -142,7 +169,9 @@ The operation names and `input` values are:
142
169
  |---|---|---|
143
170
  | `states` | `{}` | `{name, tickets, about?}[]`, including empty states |
144
171
  | `add-state` | `{name, about?: string}` | `{state: {name,tickets,about?}, created: boolean}` |
172
+ | `state-counts` | `{names: string[]}` (1–16) | `{name, tickets}[]` for the names that resolve |
145
173
  | `list-ready` | `{labels?: string[], state?: string}` | `TicketListing` |
174
+ | `list-targeting` | `{nodeId: string}` | `TicketListing` of every state |
146
175
  | `get` | `{id}` | `Ticket \| null` |
147
176
  | `claim` | `{id}` | `{claimed: boolean}` |
148
177
  | `comment` | `{id, body}` | `{ok: true}` |
@@ -207,8 +236,8 @@ current required resolution fields; domain and storage types are unchanged.
207
236
  Build and harvest runners exchange project authority for signed, project-bound
208
237
  execution and phase credentials through `/credentials/delegate` (see the remote
209
238
  store protocol). Build-runner and build-phase credentials cannot call any ticket
210
- operation. Harvest-phase credentials permit only list-ready, get and
211
- dependency-states. Harvest-runner credentials permit those reads plus create
239
+ operation. Harvest-phase credentials permit only list-ready, list-targeting, get
240
+ and dependency-states. Harvest-runner credentials permit those reads plus create
212
241
  for filing proposals. Claim, comment, transition, update, add-blocker and
213
242
  remove-blocker require project or admin authority; their access is unchanged.
214
243
  Denied delegated calls return 403 with an error naming the grant kind and
@@ -222,6 +251,10 @@ Custom state creation uses `/^[a-z][a-z0-9-]{0,39}$/`; an optional purpose must
222
251
  be one nonblank line. A duplicate in any letter case is refused without
223
252
  changing purpose. `add-state` requires project or owner machine authority;
224
253
  ticket grants and harvest delegations can read states but cannot create them.
254
+ `state-counts` returns bounded per-state totals only, never ticket rows, with
255
+ each name resolved exactly or by one case-insensitive match. It requires project
256
+ or owner authority, not ticket grants or harvest delegations. A source without
257
+ state counts answers 409 conflict, with no listing fallback.
225
258
  Request context cannot supply lifecycle policy or insert another project's
226
259
  states. These operations use the existing wire version and strict envelopes.
227
260
 
@@ -232,13 +265,15 @@ Every ticket read includes an opaque `revision`. Pass it as `expectedRevision`
232
265
  `move`, `block` and `unblock`. A stale write fails without changing anything and
233
266
  reports the current revision. Omission preserves unguarded behavior. Blocker
234
267
  checks cover the entire batch. Dispatcher moves remain unguarded and change the
235
- revision. Sources without guarded writes, including Linear, refuse supplied
236
- revisions rather than ignoring them.
268
+ revision. Sources without guarded writes, including Linear and GitHub, refuse
269
+ supplied revisions rather than ignoring them.
237
270
 
238
271
  `ab ticket edit <id>` opens `$VISUAL`, falling back to `$EDITOR`, using TOML
239
272
  frontmatter and a Markdown body. Only title, body and labels are editable;
240
273
  id, blockers, creation key and reference comments are read-only. It saves only
241
- changed fields with the opening revision. Unchanged or formatting-only edits
274
+ changed fields with the opening revision. Sources without guarded writes,
275
+ including Linear and GitHub, re-read the ticket immediately before an
276
+ unguarded write and refuse a changed revision, with the no-lock race window of file checks. Unchanged or formatting-only edits
242
277
  write nothing. On conflict, invalid input or editor failure, the error names an
243
278
  absolute file path containing the edited text. Read the current ticket and
244
279
  reapply the intended changes before retrying; conflicts are never merged.
@@ -258,7 +293,8 @@ snapshot of fields, blockers and revision.
258
293
 
259
294
  `POST /tickets/mutate-if-revision` accepts the usual authenticated context and
260
295
  `input: { id, expectedRevision, mutation }`. Mutation is one of
261
- `{ kind: "update", patch: { title?, body?, labels?, kind?, target? } }`,
296
+ `{ kind: "update", patch: { title?, body?, labels?, kind?, target?,
297
+ priority?: "urgent" | "normal" } }`,
262
298
  `{ kind: "transition", state }`, or
263
299
  `{ kind: "blockers", operation: "block" | "unblock", ids: string[] }`.
264
300
  Unknown keys and empty patches are refused. Success returns `{ ok: true }`.
@@ -280,8 +316,11 @@ BuildStore protocol version.
280
316
 
281
317
  Create options accept optional `requestedId: string` alongside `state` and
282
318
  `idempotencyKey`. Older clients omit it and responses are unchanged. Unsupported
283
- sources reject supplied ids; Linear is not an import target. File sources keep
284
- filesystem-safe ids exactly and never overwrite an occupied id.
319
+ sources reject supplied ids. Linear is not an import target. GitHub rejects
320
+ supplied ids but is an import target: it allocates every issue number itself and
321
+ import remaps each ticket to the number GitHub returns, as described in the
322
+ migration procedure's GitHub section. File sources keep filesystem-safe ids
323
+ exactly and never overwrite an occupied id.
285
324
 
286
325
  Hosted sources preserve only literal own-team `<teamKey>-<n>` ids, where `n` is a
287
326
  positive canonical decimal within PostgreSQL bigint bounds. For example,
@@ -312,11 +351,86 @@ Effective metadata changes increment the revision; equivalent aliases are no-ops
312
351
  Ticket responses include these fields only with `x-autobuild-ticket-tree: 1`.
313
352
  This capability is independent of revision and comment capabilities and of the
314
353
  client version. Without it, both fields are projected away, preserving historical
315
- strict decoders. Current hosted clients send all three capability headers and
354
+ strict decoders. Current hosted clients send every capability header and
316
355
  default absent kind to `work`. Unfiltered listing includes all ticket states and
317
356
  empty nodes for `ab ticket tree`; dispatch and merge behavior are unchanged.
318
357
 
358
+ ### Targeted listing
359
+
360
+ `list-targeting` returns every ticket in every state whose `target` is exactly
361
+ `nodeId`, equal to unfiltered `list-ready` filtered by target, read through the
362
+ project's target index so its cost follows the node's children rather than the
363
+ project's ticket count. An unknown id returns an empty listing. A backing source
364
+ without targeted listing answers `409` with `code: "targeting-unsupported"`; the
365
+ service never filters a full listing instead. Ticket grants and harvest
366
+ delegations may call it wherever they may call `list-ready`.
367
+
368
+ Every `/tickets/*` response, including errors, carries
369
+ `x-autobuild-ticket-targeting: 1`. A current client declares `listTargeting`
370
+ only after a response from the service has carried that header, and settles the
371
+ decision before use: from the policy sync, or else from one `list-targeting`
372
+ probe for the reserved id `~negotiate`, which never names a ticket. An ok
373
+ response without the header, or a `404` or `400` refusal of `list-targeting`
374
+ without it, means the service predates the operation. Against such a service
375
+ the client never declares it, and integration observation uses the exhaustive
376
+ listing by that explicit decision. An inconclusive probe (a network failure or
377
+ an unmarked gateway error) fails source construction. A targeted read the
378
+ service later refuses fails closed, with no fallback within the pass.
379
+
380
+ ## Issue links
381
+
382
+ Hosted tickets store forge issue links as `issueLinks`, an array of
383
+ `{ "issue": N, "intent": "closes" | "refs" }` with unique positive issue numbers.
384
+ Create, update and guarded update accept the field; intent is required on the
385
+ wire. Update replaces the whole set and `[]` clears it. The service stores links
386
+ sorted by issue number. Effective changes increment the revision, and rewriting
387
+ an identical set is a no-op.
388
+
389
+ Ticket responses include nonempty `issueLinks` only with
390
+ `x-autobuild-ticket-issue-links: 1`, independently of the other capabilities and
391
+ of the client version. Without it, links are projected away for historical strict
392
+ decoders, and stored links survive their writes. Every `/tickets/*` response,
393
+ including errors, carries `x-autobuild-ticket-issue-links: 1`.
394
+
395
+ `dependency-states` entries for existing tickets include `state`, the blocker's
396
+ native state name, only with `x-autobuild-ticket-dependency-state: 1`. Without
397
+ it the field is projected away for historical strict decoders. A service that
398
+ predates the capability ignores the header and omits the field, which is
399
+ optional. Clients apply the configured rejected role to it; the service never
400
+ interprets it.
401
+
402
+ A service whose backing source cannot store links refuses a write naming them,
403
+ including `[]`, with `409 { "kind": "conflict", "code": "issue-links-unsupported" }`
404
+ before anything is written. A service predating issue links refuses the unknown
405
+ field with a `400` validation error and no capability header. Clients report both
406
+ as `TicketIssueLinksUnsupported`.
407
+
319
408
  Completed ticket imports record `tickets.migration-recorded` in the selected
320
409
  BuildStore repository journal, with export identity, origin/destination adapter
321
410
  names and the actual complete ID mapping. Requested-ID preservation alone does
322
411
  not establish continuity for in-flight builds; see the migration procedure.
412
+
413
+ ## Priority
414
+
415
+ Hosted tickets store `priority`, either `"urgent"` or `"normal"`. Create,
416
+ update and guarded update accept it as an optional field. A create that omits it
417
+ files a normal ticket, and an update that omits it never changes it. Tickets that
418
+ existed before the field read as normal. A priority change increments the
419
+ revision, and rewriting the same value is a no-op.
420
+
421
+ Ticket responses include `priority` on every ticket, `normal` included, only with
422
+ `x-autobuild-ticket-priority: 1`, independently of the other capabilities and of
423
+ the client version. Without it, priority is projected away for historical strict
424
+ decoders, whose writes never name it and so never clear it. Every `/tickets/*`
425
+ response, including errors, carries `x-autobuild-ticket-priority: 1`.
426
+
427
+ `list-ready` returns urgent tickets first, then normal ones, each class in filing
428
+ order, for every client. Ordering happens within the existing listing; it adds no
429
+ per-ticket reads.
430
+
431
+ A service whose backing source cannot store priority refuses a write naming
432
+ `urgent` with `409 { "kind": "conflict", "code": "priority-unsupported" }` before
433
+ anything is written. A service predating priority refuses the unknown field with a
434
+ `400` validation error and no capability header. Clients report both as
435
+ `TicketPriorityUnsupported`. Current clients omit `normal` on create, so a plain
436
+ create still works against such a service.
@@ -84,8 +84,11 @@ pending while ancestors restack or reconcile. A durable availability observation
84
84
  allows unchanged idle ticks, including after restart, to skip repository preparation
85
85
  and native auto-merge cancellation. Exact node/parent heads, contribution base,
86
86
  request contents, accepted ancestry, foreign aliases and confirmed landing evidence
87
- invalidate that observation when they change; polling timestamps do not. Failed
88
- assessments never establish unavailability. Availability is not proof of destination
87
+ invalidate that observation when they change; polling timestamps do not. Confirmed
88
+ landing evidence comes from every repository build, including mixed-version deferred
89
+ builds whose own decisions stay withheld, so the dispatcher check and the node
90
+ transaction assess the same fingerprint. Failed assessments never establish
91
+ unavailability. Availability is not proof of destination
89
92
  coverage. Moving to another destination branch explicitly settles obsolete requests
90
93
  with `destination-changed`; losing identities on the same branch leaves them waiting.
91
94
  Native auto-merge is suspended with confirmed, reusable receipts only when replay
@@ -126,8 +129,10 @@ Before replacement the kernel publishes retained tips, displaced heads and the
126
129
  temporary change under immutable exact archive refs. Remote archives also publish
127
130
  commits present only on the remote: GitHub uses create-only Git-reference REST creation
128
131
  when the workspace lacks the commit, retaining guarded Git pushes for local objects.
129
- Exact remote readback confirms publication, then a depth-one fetch by the archive ref
130
- (without tags or configured refmap expansion) restores missing commits and verifies them
132
+ Exact remote readback confirms publication, then a non-shallow fetch of only that exact
133
+ archive ref (without tags, configured refmap expansion or a depth limit) restores
134
+ missing commits and their missing ancestry, writes no shallow boundary, leaves an
135
+ already-shallow repository's existing boundaries unchanged, and verifies the commits
131
136
  locally before returning. `restack.*` facts record
132
137
  preparation, replay, intent, archived replacement, contention and completion.
133
138
  Unpublished request/loss records alone cannot preserve objects from a released
@@ -221,7 +226,11 @@ retry allowance. Rejected pushes, lease conflicts, dirty trees and unclassified
221
226
  errors retain their existing behavior.
222
227
 
223
228
  Preserved restoration checkpoints survive repeated replacement; a published
224
- reconcile or restack rewrite retires the old checkpoint.
229
+ reconcile or restack rewrite retires the old checkpoint. Node, restack and
230
+ reconcile rewrites also supersede a branch checkpoint that the build's bounded
231
+ record of its latest 64 replaced heads covers: provisioning keeps its archived
232
+ objects but never restores it over the branch. Coverage older than that bound
233
+ falls back to refusing divergent branch work.
225
234
  Recovery context applies to the following session and its repeated hydration; later
226
235
  sessions do not inherit obsolete reconstruction instructions.
227
236
 
@@ -244,7 +253,12 @@ external ticket state, missing ticket/state, or conflicting slug ownership termi
244
253
  automatic recovery with an `abandoned` resolution and diagnostic reason. The
245
254
  ticket is left unchanged; an operator can leave it finished or cancelled, or
246
255
  inspect ownership and explicitly return it to Ready for another attempt. These
247
- cases stop provider polling and diagnostic appends. Recovery failures are
256
+ cases stop provider polling and further durable diagnostic appends. The tick
257
+ that records the abandonment reports one dispatcher diagnostic naming the
258
+ ticket and attempt, whether the claim was confirmed or its provider outcome is
259
+ unknown, and the recorded reason. If that tick fails for any reason, its
260
+ failure error carries the diagnostics instead. Later ticks do not repeat it.
261
+ Recovery failures are
248
262
  reported without preventing janitor, lease sweep, or other dispatch recovery.
249
263
  This is not general process
250
264
  crash recovery. Confirmed Ready/Triage transitions settle idempotently, so a
@@ -126,7 +126,9 @@ exits nonzero on failure. Then:
126
126
  alternate. The runtime that launched setup and the temporary fresh-skeleton
127
127
  default do not constrain the final arrangement.
128
128
  3. Choose the ticket source and workflow states. Confirm account/team facts and
129
- required environment credentials. Author a repository-owned acceptance-check skill and select it from an agent
129
+ required environment credentials. The `github` source needs no new secret:
130
+ it uses the forge's `GITHUB_TOKEN`, `GH_TOKEN` or `gh auth login`, which must
131
+ read and write the repository's issues. Author a repository-owned acceptance-check skill and select it from an agent
130
132
  verify step in every repository. An **acceptance check** is a repository-owned agent verify step that runs the built software, exercises each acceptance criterion in the spec, attaches evidence, and returns a typed verdict. Every repository must configure one. It is not a test suite and leaves no test files behind.
131
133
  Wire an existing maintained end-to-end or browser test suite into an ordinary `check` step. If none exists, do not create one during setup. The acceptance check neither substitutes for nor seeds a suite.
132
134
  4. Preserve an existing `autobuild.toml` and unrelated repository choices on a
@@ -391,14 +393,10 @@ manifest-directed artifact paths remain authoritative. Never commit scratch.
391
393
  1. Run `ab context` and read `"$AB_CONTEXT_DIR/context.json"`. The verifier receives
392
394
  `$AB_CONTEXT_DIR/spec.md`, the configured step,
393
395
  the commit range, and, after escalation is answered, `$AB_CONTEXT_DIR/guidance.json`.
394
- Node verify sessions also receive `nodeVerification` in the context manifest:
395
- contribution specs and a provenance index mapping commits to the builds that
396
- introduced them. Read those specs through the manifest's allocated paths.
397
- Also read `handPushedCommits: [{sha, originalSha, message}]` from the manifest
398
- and index. These hand-pushed node commit messages express maintainer-authorized
399
- intent; judge quality and consistency, and never fail them solely for lacking
400
- a covering spec. Other node changes are authorized when the node spec or the introducing
401
- contribution's spec covers it; use the commit index to find that spec.
396
+ Node verify sessions also receive `nodeVerification`: contribution specs,
397
+ a commit provenance index and owned `handPushedCommits`, read through the
398
+ manifest's allocated paths. Judge them as described in
399
+ [node verification context](integration-tree.md#node-verification-context).
402
400
  2. Exercise each applicable acceptance criterion through the repository's real
403
401
  application lifecycle. Prefer the narrowest honest flow that catches a
404
402
  regression.
@@ -434,7 +432,7 @@ Owner admin requests require an explicit registered context.repo; project creden
434
432
  cannot select another project. See [local builds with hosted tickets](#local-builds-with-hosted-tickets).
435
433
 
436
434
  The service never contacts Linear. Projects with external sources (including
437
- file and Linear) keep using those sources directly through their dispatcher;
435
+ file, Linear and GitHub) keep using those sources directly through their dispatcher;
438
436
  service ticket HTTP and operator surfaces refuse with project/source
439
437
  feedback rather than returning an empty queue.
440
438
 
@@ -463,6 +461,9 @@ To retain earlier names configure `triageState = "Backlog"`,
463
461
  `claimedState = "Doing"`, `doneState = "Done"`, and the desired `readyState`.
464
462
  Existing ticket rows are never renamed. Older combined-service clients continue
465
463
  using the uploaded dispatcher configuration until independent policy is published.
464
+ Also set the recommended `backlogState` and `rejectedState` so agents can defer
465
+ and decline work by role; role moves create a missing state on first use.
466
+ Published policy carries both roles, and publishes from older clients keep them.
466
467
 
467
468
  ## Forge readiness
468
469
 
@@ -522,9 +523,11 @@ with hosted ticket numbering reset to 1. See
522
523
  ## Hosted dispatch and local viewing
523
524
 
524
525
  A plain `ab dispatch` reads dispatch placement once before starting local execution.
525
- For a hosted project it opens the Store-only viewer automatically, displaying
526
+ For a hosted project it opens the viewer automatically, displaying
526
527
  `viewer · dispatched by <host>` from the placement origin (including a nondefault
527
528
  port). `--once`, `--plain`, and `--interval` retain their viewer meanings.
529
+ The viewer reads its dashboard from the Store; its one ticket-source read is
530
+ the header's triage count, through the source's optional `countStates`.
528
531
  `--takeover` explicitly dispatches locally, with a warning that it can displace
529
532
  the hosted dispatcher; it cannot be combined with `--viewer`. Startup intake
530
533
  flags require `--takeover` when placement selects viewer.
@@ -533,6 +536,9 @@ An unreadable placement fails closed with a typed error naming the cause:
533
536
  use `--viewer` to watch or `--takeover` to dispatch locally. Both explicit modes
534
537
  skip placement discovery. Older services without the capability and projects
535
538
  with unknown or nonhosted placement retain local dispatch behavior. Local stores
536
- need no placement request. Origin mode (`--repository` or `AB_REPOSITORY`) and
537
- hosted cron dispatch bypass this check. Placement is a startup snapshot, not a
539
+ need no placement request. Failing to resolve the checkout's store selection
540
+ (for example, a malformed `autobuild.toml`) is not a placement failure: default
541
+ startup reports it as a repository resolution error naming its cause, and
542
+ neither explicit mode bypasses it. Origin mode (`--repository` or
543
+ `AB_REPOSITORY`) and hosted cron dispatch bypass this check. Placement is a startup snapshot, not a
538
544
  liveness probe or a polling input.
@@ -164,7 +164,8 @@ order.
164
164
  The spec is the build's contract artifact (kind `spec`, revision 0).
165
165
  Every downstream reviewer approves conformance to its pinned revision.
166
166
  For leaves, a phase that discovers the spec itself is wrong raises an
167
- escalation (`ab escalate`); a human answers, the spec gets revision N+1,
167
+ escalation (`ab escalate`); your operator agent, within your instructions and
168
+ authority, or you answer it with a revised spec. The spec gets revision N+1,
168
169
  and the leaf restarts from `plan` after any unfinished reconcile resumes under
169
170
  the revised spec and its publication is confirmed.
170
171
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  `ab ticket create --blocked-by` validates prerequisite ids and records blocking
4
4
  relationships, but a single CLI command is **not an atomic publication guarantee**.
5
- In particular, direct Linear creates the issue first and adds
5
+ In particular, direct Linear and GitHub create the issue first and add
6
6
  its blocker relationships in separate requests. If the issue is already in the
7
7
  ready state, a dispatcher can see it before those relationships exist. A
8
8
  successful create response containing every blocker does not prove that no build
@@ -19,6 +19,8 @@ before publishing it. Use the repository's triage state when it differs from its
19
19
  ready state. This temporary staging does not require another placement approval.
20
20
  If no non-ready state can be established, resolve that before creating the
21
21
  dependent; never guess that a name such as "Backlog" is safe in every repository.
22
+ A configured backlog role is a known non-ready state: `ab ticket move <id>
23
+ --role backlog` reaches it without knowing its native name.
22
24
 
23
25
  1. Create prerequisites in dependency order and extract each new `.ref.id` from
24
26
  the complete `--json` response, never the human confirmation line.
@@ -28,7 +30,12 @@ dependent; never guess that a name such as "Backlog" is safe in every repository
28
30
  non-ready and every expected blocker is present. Repair missing relationships
29
31
  through `ab ticket block`, then read back again.
30
32
  4. Only after verification, move it to the intended final state with
31
- `ab ticket move <id> <state> --json`. Verify the final state and blockers.
33
+ `ab ticket move <id> <state> --json`, or by role with
34
+ `ab ticket move <id> --role ready --json`. Verify the final state and blockers.
35
+
36
+ A blocker in the configured rejected state never resolves: its dependents stay
37
+ unclaimed until the blocker leaves that state or is removed with
38
+ `ab ticket unblock`.
32
39
 
33
40
  For a repository whose configured triage and ready states are `Triage` and
34
41
  `Ready`, respectively, and whose human requested ready placement:
@@ -77,13 +84,24 @@ parent history. An empty completed contribution is satisfied; missing evidence,
77
84
  an open or aborted node, or ambiguous newest build generations remain queued.
78
85
  Older successful generations are never substituted for the newest build.
79
86
 
80
- Destination observations retain versioned, head-bound Git witnesses (reachable
81
- commit SHAs and direct build trailers) and a fixed-length evidence digest. Current
87
+ Destination observations record a head-bound, query-scoped probe rather than
88
+ the destination's history: only the commit SHAs and direct build trailers in the
89
+ proof closure of the identities being decided (blocker identities, plus the
90
+ landings and confirmed foreign aliases that could transport them), which of those
91
+ are reachable from the sampled head, presence answers for only those identities,
92
+ and a fixed-length evidence digest. Observation size is bounded by that closure,
93
+ independent of the destination's reachable commit count and of repository history.
94
+ While the head is unchanged and the probe covers the current questions, current
82
95
  confirmed landings and aliases from only the destination's accepted ancestry are
83
- reapplied before reuse. Unrelated merged history and ready destinations do not
84
- invalidate this proof. Head changes require a fresh Git sample; legacy observations
85
- without witnesses refresh once rather than replaying repository history. Current
86
- readiness and newest-generation checks still apply before claim.
96
+ reapplied without Git; unrelated merged history and ready-set changes neither
97
+ invalidate it nor append events. A moved head requires a fresh Git sample. A
98
+ newly relevant landing or a new question needs only a new probe: a dispatcher
99
+ still holding the full in-memory witness for that branch and head compacts one
100
+ without Git, and otherwise samples Git once. Observations without a probe,
101
+ including older full-history witnesses, are never trusted for admission: they
102
+ are re-derived once the same way, and an unavailable sample leaves the dependent
103
+ queued; neither replays repository history. Current readiness and
104
+ newest-generation checks still apply before claim.
87
105
 
88
106
  - Same node: the blocking change merges directly into the target.
89
107
  - Ancestor: the change merges into an ancestor, then presence demand restacks only the required path to the target.
@@ -2,7 +2,9 @@
2
2
 
3
3
  Export and import use the ordinary file ticket layout. They operate on tickets
4
4
  and current attachments through the ticket source; neither command contacts the
5
- forge. File and hosted sources support import. Linear supports export only.
5
+ forge, except that a GitHub source reads and writes the repository's issues.
6
+ File, hosted and GitHub sources support import. Every built-in source supports
7
+ export.
6
8
 
7
9
  1. Pause intake and quiesce build-related ticket writes and other ticket writers
8
10
  for the cutover. In-flight builds need not be aborted. Import preflight does
@@ -13,8 +15,8 @@ forge. File and hosted sources support import. Linear supports export only.
13
15
  directory only after all reads succeed. Back up the target tracker too.
14
16
  3. Configure the new `[tickets]` source, or use `ab connect --tickets URL` for a
15
17
  hosted ticket service. Keep the export directory intact.
16
- 4. Run `ab ticket import /path/to/export`. Inspect its printed ticket and state
17
- mappings and `/path/to/export/.ab-import-map.json`.
18
+ 4. Run `ab ticket import /path/to/export [--states <state,…>]`. Inspect its
19
+ printed ticket and state mappings and `/path/to/export/.ab-import-map.json`.
18
20
  5. Import records a durable source/ID mapping in the same BuildStore and repository
19
21
  that hold the existing builds, after tickets, metadata and assets finish.
20
22
  Keep that BuildStore/repository identity through the cutover.
@@ -37,13 +39,40 @@ through export when file or Linear tickets have attachments there.
37
39
  State directory names use lowercase letters, digits and hyphens, start with a
38
40
  letter and contain at most forty characters. Export maps `In Progress` to
39
41
  `in-progress`, `Backlog` to `backlog`, and `Done` to `done`. It retains each ticket's
40
- state rather than assigning lifecycle roles. Distinct names that collapse to the
42
+ state, and the manifest records which lifecycle roles each state held under the
43
+ exporting configuration: triage, ready, claimed, done, backlog, rejected, and the
44
+ create and proposal placements. Distinct names that collapse to the
41
45
  same directory fail before publication. The hidden `.ab-migration.json` records
42
46
  original display names and the state map. Import also accepts ordinary legacy
43
47
  file layouts: it reuses exact or unique case-insensitive target states before
44
48
  normalizing new names. A seeded `done` satisfies `Done`; absent `In Progress`
45
49
  creates `in-progress`. Ambiguous matches and colliding state maps fail preflight.
46
50
 
51
+ A state that held a role lands in the destination's state for the same role,
52
+ whatever either source calls it. For example, an `icebox` backlog lands in a
53
+ `later` backlog, and Linear's `Backlog` triage lands in `triage`. A state holding
54
+ several roles takes the first of done, rejected, claimed, ready, backlog, triage,
55
+ proposal and create. If the destination configures no backlog or rejected state
56
+ for such a state, import refuses and names the `[tickets]` key to set. States
57
+ without a role, and exports made before roles were recorded, map by name as above.
58
+
59
+ ## Importing selected states
60
+
61
+ `ab ticket import <dir> --states triage,ready,icebox` imports only the tickets in
62
+ the named states and creates only those states. Teams moving to a new tracker
63
+ often take their open work and leave closed history behind. A name matches an
64
+ export directory exactly, then by unique case-insensitive match, then by the
65
+ original display name the manifest recorded (`In Progress` for `in-progress`).
66
+ An unknown name is refused, and the refusal lists the export's states.
67
+
68
+ A blocker on a left-out ticket in the done role is dropped as resolved. Any other
69
+ reference to a left-out ticket is reported before any write, and nothing is
70
+ imported. That covers a blocker in another state, an integration-tree target, and
71
+ an issue link to a left-out issue in an export from GitHub. Import also refuses a
72
+ selection that leaves out a ticket an unfinished build is working on or targets.
73
+ The refusal names the build and the ticket, so in-flight work keeps its continuity.
74
+ Without `--states`, every ticket is imported.
75
+
47
76
  File targets retain source ids. Hosted targets keep canonical own-team ids:
48
77
  `AUT-706` imported into team `AUT` stays `AUT-706`. Other ids receive numbers above
49
78
  all existing and preserved incoming numbers. Known clashes with unrelated tickets
@@ -52,7 +81,8 @@ Content similarity and stale mapping files never establish identity.
52
81
 
53
82
  Creation keys establish identity. Exports retain existing keys and assign keys to
54
83
  legacy tickets. Importing an ordinary file layout first saves a hidden migration
55
- identity and keys in that input directory. Preserve this file and the input across
84
+ identity and keys in that input directory. The identity also records when it was
85
+ first saved, and that time is passed as the creation keys' reservation time. Preserve this file and the input across
56
86
  retries. After interruption, rerun the same command: committed creates are adopted
57
87
  by key even if their mapping write failed. Adopted bodies and other fields are not
58
88
  overwritten. Missing blockers and comments are replayed, and unchanged attachments
@@ -62,7 +92,7 @@ timestamps remain in the export; imported comments use the target's metadata.
62
92
 
63
93
  Portable records use TOML frontmatter between `+++` fences and an unchanged
64
94
  Markdown body. Alongside `id`, `title`, `labels`, `blockedBy` and `idempotencyKey`,
65
- optional `comments` contain `body`, `createdAt` and optional `author`. Optional
95
+ optional `issueLinks` contain `issue` and `intent` (`closes` or `refs`), optional `priority` is `"urgent"` (absent means normal), optional `comments` contain `body`, `createdAt` and optional `author`. Optional
66
96
  `attachments` contain `kind`, `name`, `layout` (`file` or `tree`) and `entries`:
67
97
  `{ type = "dir", path = "empty" }` or
68
98
  `{ type = "file", path = "image.png", base64 = "…" }`. Common asset limits and
@@ -78,12 +108,45 @@ no continuous sync, assignee migration, state history or build-history migration
78
108
 
79
109
  Integration-tree `kind` and `target` are preserved in portable frontmatter.
80
110
  Import validates the complete target graph before changing the destination and
81
- refuses a destination that cannot preserve metadata. It creates or adopts every
111
+ refuses a destination that cannot preserve metadata. Issue links and urgent
112
+ priority are preserved the same way, and a destination that cannot store them is refused before any write. It creates or adopts every
82
113
  identity, establishes node kinds, then applies targets using the durable id map,
83
114
  just like blockers. Input order does not matter. Resuming also restores edges on
84
115
  adopted tickets; normal destination validation still guards existing graphs and
85
116
  node demotion. Older work-only exports remain valid.
86
117
 
118
+ ## GitHub
119
+
120
+ GitHub chooses issue numbers, so import into a `github` source remaps every
121
+ ticket. Check the printed mapping and `.ab-import-map.json`, which list each
122
+ original id with its new issue number. Blockers are rewritten through that
123
+ mapping and become native issue dependencies. Comments become issue comments,
124
+ and attachments go to the BuildStore under the new number. States become
125
+ `autobuild:<state>` labels. The done role closes the issue as completed, the
126
+ rejected role closes it as not planned, and triage leaves it open without a state
127
+ label. Each issue carries a creation key in a hidden marker, so an interrupted
128
+ import resumes with the same command and adopts the issues it already opened.
129
+ Resuming never duplicates an issue, and it replays missing blockers, comments and
130
+ assets.
131
+
132
+ Before any write, import reports every problem together: states that cannot be
133
+ `autobuild:` labels (for example `proposal`, or names that are not lowercase),
134
+ a rejected state when `[tickets].rejectedState` is unset, and ticket labels that
135
+ would collide with a state label (`autobuild:<state>`) or an issue-link label
136
+ (`autobuild-link:…`). The `autobuild:proposal` and `autobuild:aborted` marker
137
+ labels are ordinary labels and import as-is. Node kinds become the exact `node`
138
+ label, and targets become sub-issue relationships to the remapped node issues.
139
+ Issue links are kept. They are rewritten through the mapping only when the export
140
+ came from GitHub, because only then do they name the exported tickets.
141
+
142
+ Export from a `github` source covers every issue, closed ones included. It records
143
+ comment history with authors and timestamps, kinds, targets, blockers and issue links, and skips
144
+ pull requests. An issue it cannot read as a ticket, such as one with two state
145
+ labels, fails the export. Issues closed as not planned export in the rejected
146
+ role even when `[tickets].rejectedState` is unset. Export and import read comment
147
+ history explicitly. The GitHub source still lists no comment history in
148
+ `ab ticket show`, and dispatcher ticks never read it.
149
+
87
150
  ## In-flight builds
88
151
 
89
152
  A recorded migration resolves old source-qualified ticket references through the