@defrex/autobuild 1.0.0-beta.2 → 1.0.0-beta.3

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 (50) hide show
  1. package/SPEC.md +25 -3
  2. package/docs/architecture.md +4 -0
  3. package/docs/integration-tree.md +4 -2
  4. package/docs/remote-store-protocol.md +5 -0
  5. package/docs/remote-ticket-protocol.md +5 -0
  6. package/docs/setup.md +4 -0
  7. package/docs/spec-standard.md +71 -0
  8. package/docs/ticket-migration.md +50 -4
  9. package/package.json +3 -3
  10. package/packages/core/src/cli/build-control.ts +3 -3
  11. package/packages/core/src/cli/dashboard/integration-detail.ts +8 -6
  12. package/packages/core/src/cli/dashboard/integration-row.ts +15 -8
  13. package/packages/core/src/cli/dashboard/model.ts +7 -0
  14. package/packages/core/src/cli/dispatch-frontend.ts +5 -0
  15. package/packages/core/src/cli/dispatch-repository-feed.ts +2 -1
  16. package/packages/core/src/cli/dispatch.ts +5 -0
  17. package/packages/core/src/cli/help.ts +1 -0
  18. package/packages/core/src/cli/main.ts +11 -8
  19. package/packages/core/src/cli/repository-status.ts +7 -1
  20. package/packages/core/src/cli/ticket.ts +35 -11
  21. package/packages/core/src/events/payloads.ts +2 -0
  22. package/packages/core/src/events/policy.ts +1 -0
  23. package/packages/core/src/events/repository.ts +21 -0
  24. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +4025 -3978
  25. package/packages/core/src/kernel/change-presence.ts +7 -1
  26. package/packages/core/src/kernel/dispatch-capacity.ts +12 -4
  27. package/packages/core/src/kernel/integration-completeness.ts +54 -16
  28. package/packages/core/src/kernel/node-parent.ts +35 -10
  29. package/packages/core/src/kernel/read-facts.ts +7 -0
  30. package/packages/core/src/kernel/reducer-registry.ts +3 -0
  31. package/packages/core/src/kernel/reducer.ts +1 -1
  32. package/packages/core/src/kernel/ticket-migrations.ts +139 -0
  33. package/packages/core/src/operator/query.ts +7 -1
  34. package/packages/core/src/operator/tickets.ts +30 -26
  35. package/packages/core/src/ports/tickets/linear.ts +180 -12
  36. package/packages/core/src/ports/tickets/migration.ts +92 -9
  37. package/packages/core/src/ports/types.ts +7 -0
  38. package/packages/core/src/processes/dispatcher.ts +164 -36
  39. package/packages/core/src/store/contract.ts +30 -0
  40. package/packages/core/src/store/reducer-value-shapes.json +5735 -5642
  41. package/packages/core/src/store/repo-state-events.ts +3 -2
  42. package/packages/core/src/testing/dispatch-read-budget.ts +3 -2
  43. package/skills/guide/SKILL.md +3 -1
  44. package/skills/guide/references/integration-tree.md +4 -2
  45. package/skills/guide/references/remote-store-protocol.md +5 -0
  46. package/skills/guide/references/remote-ticket-protocol.md +5 -0
  47. package/skills/guide/references/setup.md +4 -0
  48. package/skills/guide/references/spec-standard.md +71 -0
  49. package/skills/guide/references/ticket-migration.md +50 -4
  50. package/skills/spec/SKILL.md +16 -4
package/SPEC.md CHANGED
@@ -406,7 +406,9 @@ Two things wear the name:
406
406
  ### 6.1 The spec standard
407
407
 
408
408
  A reference document defining "buildable": what/why not how, acceptance
409
- criteria, explicit out-of-scope, evidence links. It is a shared resource
409
+ criteria, explicit out-of-scope, evidence links — plus sizing guidance:
410
+ fewer, larger tickets, split only at clean seams into a wide blocker graph so
411
+ independent tickets build in parallel. It is a shared resource
410
412
  cited by **every ticket-producing surface** — `/spec`, `harvest`, every
411
413
  `ingest:*`, and `dispatch`. An ingester's proposal is a spec written to the
412
414
  same standard with weaker evidence.
@@ -1395,7 +1397,8 @@ implementer: ab context (findings.json now materialized) → …
1395
1397
 
1396
1398
  Human/pre-build ticket grooming uses one configured-source namespace
1397
1399
  (`ab ticket create|update|block|unblock|list|show|move`, plus the ticket-asset
1398
- forms below). Migration adds `ab ticket export <dir>` and `ab ticket import <dir>`
1400
+ forms below). Migration adds `ab ticket export <dir>` and `ab ticket import <dir>`,
1401
+ plus `ab ticket migration record <dir>`
1399
1402
  (see [Ticket source migration](#ticket-source-migration)). These commands are
1400
1403
  sessionless, source-agnostic, and never available as a mid-build spec
1401
1404
  mutation path. The CRUD subcommands accept `--json` and then writes exactly one
@@ -2532,7 +2535,7 @@ live, the janitor defers the saga so it cannot race process-tree teardown. Once
2532
2535
  that supervisor releases the lease, or an abruptly orphaned lease expires, cleanup
2533
2536
  closes an open unmerged PR without overriding a racing merge, releases the workspace,
2534
2537
  deletes the exact published remote branch and exact local branch, unions the
2535
- `autobuild:aborted` label into the current ticket labels, returns the ticket to
2538
+ `autobuild:aborted` label into the current ticket labels, posts an abort notice, and returns the ticket to
2536
2539
  configured Triage, and only then completes as `abandoned`. External effects are
2537
2540
  idempotent and the three `abort.*` facts checkpoint projections across crashes;
2538
2541
  missing Forge capabilities or outages leave the remainder due on the next tick.
@@ -3637,6 +3640,25 @@ the installed guide. Export keeps lifecycle membership without inferring roles;
3637
3640
  import reuses unique case-insensitive states and creates normalized missing ones.
3638
3641
 
3639
3642
 
3643
+ Completed `ab ticket import <dir> [--store <ref>]` records a durable repository
3644
+ `tickets.migration-recorded` fact after all ticket and asset work succeeds. The
3645
+ fact carries the stable export identity, source/destination adapter names and
3646
+ complete actual ID mapping. `ab ticket migration record <dir> [--store <ref>]`
3647
+ verifies a manifest-backed export used directly as a file source, checking every
3648
+ ID and creation key, and records the same continuity without importing. Tickets
3649
+ filed afterward in the exported tracker are allowed; only original manifest IDs
3650
+ enter that mapping.
3651
+
3652
+ Current operations resolve historical ticket references forward through recorded
3653
+ mappings. Completeness, targeting, admission, ancestry and lifecycle writes
3654
+ retain their gates. Missing routes, uncovered IDs and inconsistent evidence fail
3655
+ closed at current-ticket and frozen-membership operation boundaries; unrelated
3656
+ uncovered history does not block intake or alias current-source tickets. History
3657
+ is never rewritten. Preserve the BuildStore and repository,
3658
+ quiesce ticket writers during cutover, and resume in-flight builds after recording
3659
+ and destination validation. See [the migration procedure](docs/ticket-migration.md).
3660
+
3661
+
3640
3662
  ### Tree and consent operator reads
3641
3663
 
3642
3664
  The shared dashboard projection supplies root, node, target, integration build,
@@ -1395,3 +1395,7 @@ unavailable for uninstrumented adapters. Attribution retains at most ten builds
1395
1395
  ordered by descending count then build name; repository requests are unattributed.
1396
1396
  Repository status names a hotspot only when one build makes at least two requests
1397
1397
  and more than half of attributed requests. Telemetry never controls workflow.
1398
+
1399
+ Ticket-source continuity is reduced by `kernel/ticket-migrations.ts` from durable
1400
+ repository `tickets.migration-recorded` facts. Import publishes only complete
1401
+ mappings; current-operation resolvers leave build records and old events intact.
@@ -19,8 +19,10 @@ ancestor and demand the minimal restack path; same-node landings satisfy presenc
19
19
 
20
20
  ## Choosing a destination
21
21
 
22
- Whenever grooming produces more than one ticket for a feature, explicitly choose
23
- root or a node before filing. Use a node when the set should reach the base branch
22
+ First decide whether the feature should be more than one ticket at all; the
23
+ [spec standard](spec-standard.md#sizing-and-splitting) prefers fewer, larger
24
+ tickets cut at seams. Whenever grooming produces more than one ticket for a
25
+ feature, explicitly choose root or a node before filing. Use a node when the set should reach the base branch
24
26
  as one integrated change, or intermediate states should not ship independently.
25
27
  Use root when every ticket is independently valuable and safe to land alone.
26
28
  Nested nodes can collect a subfeature before contributing it to a larger feature.
@@ -1329,3 +1329,8 @@ The optional `integrationAuditPending` digest fact is introduced on the 0.14
1329
1329
  release line without changing protocol identity 4. It survives build completion
1330
1330
  and is cleared by audit settlement. Services omit it for historical 0.12/0.13
1331
1331
  clients, retaining their decoders and the supported three-line window.
1332
+
1333
+ `tickets.migration-recorded` is a durable, decisive human-authored repository
1334
+ fact: `{ identity, from, to, mapping }`, where mapping contains source ticket IDs
1335
+ and destination IDs. All migration facts survive dispatcher-run turnover.
1336
+ Conflicting identity reuse or source-qualified mappings fail replay closed.
@@ -333,3 +333,8 @@ client version. Without it, both fields are projected away, preserving historica
333
333
  strict decoders. Current hosted clients send all three capability headers and
334
334
  default absent kind to `work`. Unfiltered listing includes all ticket states and
335
335
  empty nodes for `ab ticket tree`; dispatch and landing behavior are unchanged.
336
+
337
+ Completed ticket imports record `tickets.migration-recorded` in the selected
338
+ BuildStore repository journal, with export identity, origin/destination adapter
339
+ names and the actual complete ID mapping. Requested-ID preservation alone does
340
+ not establish continuity for in-flight builds; see the migration procedure.
package/docs/setup.md CHANGED
@@ -541,3 +541,7 @@ gate. External orchestrators follow these through `ab watch` with no slugs or an
541
541
  explicit repository watch; `ab wait` remains build-only. The dashboard and operator
542
542
  repository query retain all failures for that run. After correcting settings or
543
543
  access, revalidate and restart dispatch to refresh its startup diagnostics.
544
+
545
+ Changing the connected ticket source does not itself migrate in-flight builds.
546
+ Follow [ticket migration](ticket-migration.md), keeping the existing BuildStore
547
+ and recording continuity before resuming build-related ticket writes.
@@ -54,6 +54,77 @@ evidence is not.
54
54
 
55
55
  ---
56
56
 
57
+ ## Sizing and splitting
58
+
59
+ Every build pays a fixed cost no matter how small its diff: spec, plan and
60
+ plan review, code review, the repository's full verify suite, finalize,
61
+ landing, and a restack for everything queued behind it. Ten small tickets pay
62
+ that cost ten times, and a blocker chain pays it in series. Prefer fewer,
63
+ larger tickets: one ticket per coherent change, as large as one plan and one
64
+ review pass can hold without the quality bar slipping.
65
+
66
+ A ticket is the right size when its acceptance criteria describe one feature
67
+ or fix a reviewer can judge in a single pass, one plan can cover it without
68
+ deferring a design decision to a later build, and its out-of-scope list is
69
+ short and obvious. It is too big when its criteria fall into groups that share
70
+ no behavior, when part of it waits on a decision nobody has made, or when its
71
+ parts need different landing — one can ship now while another needs consent
72
+ or must wait.
73
+
74
+ Do not split:
75
+
76
+ - by layer (schema, then API, then UI) when the layers make one behavior
77
+ change;
78
+ - into "refactor, then feature" unless the refactor is valuable and safe on
79
+ its own;
80
+ - to make progress visible, or because the spec got long. A long spec with
81
+ clear criteria is fine.
82
+
83
+ ### Cut along seams
84
+
85
+ A seam decides where to cut once a split is justified; it is not a reason to
86
+ split. A full-stack change that crosses an API boundary stays one ticket
87
+ unless its size says otherwise.
88
+
89
+ When a feature does need several tickets, find the seams before deciding the
90
+ cut: places where the code already has a narrow, stable contract between
91
+ parts — a port or adapter interface, a schema or event type, a wire protocol,
92
+ a CLI command's output, a module's public API. Read the code to find them;
93
+ don't guess. Put each ticket on one side of a seam.
94
+
95
+ A cut at a seam pays twice:
96
+
97
+ - **Fewer conflicts.** Tickets on opposite sides of a contract touch
98
+ different code, so they build in parallel and restack cleanly. Two tickets
99
+ that would edit the same functions are one ticket, or a blocker chain.
100
+ - **Testability.** The contract is the test boundary. Each side is verified
101
+ against it — the provider by contract tests, the consumer against a fake or
102
+ fixture — so neither build needs the other to prove it works.
103
+
104
+ If no seam exists where the work divides, keep it as one ticket, or make the
105
+ first ticket establish the contract with tests at the boundary and block the
106
+ tickets on either side of it until it lands. After that, they can build
107
+ concurrently.
108
+
109
+ State the seam in each ticket as behavior, not structure: what the contract
110
+ promises observably (the event, the command output, the protocol response) is
111
+ a fair acceptance criterion on both sides; file names and signatures still
112
+ belong to the planner. Record in Evidence why the cut falls where it does, so
113
+ a planner reading one ticket knows what its siblings own.
114
+
115
+ ### Keep the blocker graph wide
116
+
117
+ A split feature takes as long as its longest blocker chain, not as long as
118
+ its ticket count. A wave of independent tickets finishes in about one build's
119
+ time; the same tickets in a chain take one build per link. Prefer cuts that
120
+ let tickets start together. When one ticket must land first — usually the one
121
+ that establishes a shared contract — keep it to that contract and its tests,
122
+ so the wave behind it starts sooner, and fold nothing unrelated into it.
123
+ Add a blocker only for a real prerequisite, never to express a preferred
124
+ order.
125
+
126
+ ---
127
+
57
128
  ## Immutability during a build
58
129
 
59
130
  The spec is the build's contract artifact (kind `spec`, revision 0). It
@@ -4,8 +4,9 @@ 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
5
  forge. File and hosted sources support import. Linear supports export only.
6
6
 
7
- 1. Pause intake and stop other ticket writers for the cutover. Import preflight
8
- does not reserve numbers against concurrent writers.
7
+ 1. Pause intake and quiesce build-related ticket writes and other ticket writers
8
+ for the cutover. In-flight builds need not be aborted. Import preflight does
9
+ not reserve numbers against concurrent writers.
9
10
  2. With the old `[tickets]` configuration, run `ab ticket export /path/to/export`.
10
11
  The destination must be absent or empty. Export reads every state, including
11
12
  archived Linear tickets and empty discoverable states, and publishes the
@@ -14,8 +15,20 @@ forge. File and hosted sources support import. Linear supports export only.
14
15
  hosted ticket service. Keep the export directory intact.
15
16
  4. Run `ab ticket import /path/to/export`. Inspect its printed ticket and state
16
17
  mappings and `/path/to/export/.ab-import-map.json`.
17
- 5. Inspect ticket bodies, labels, blockers, comments and attachments in the new
18
- source. Confirm lifecycle configuration and the ready gate, then resume intake.
18
+ 5. Import records a durable source/ID mapping in the same BuildStore and repository
19
+ that hold the existing builds, after tickets, metadata and assets finish.
20
+ Keep that BuildStore/repository identity through the cutover.
21
+ 6. Inspect ticket bodies, labels, blockers, comments and attachments in the new
22
+ source. Confirm lifecycle configuration and the ready gate, then resume builds and intake.
23
+
24
+ Linear export reads full ticket details in batches and prints `read X/Y tickets`.
25
+ The total is shown as pending until inventory discovery finishes. If Linear reports
26
+ a rate limit with a usable future reset time, export prints the wait time, waits
27
+ until that reset, and retries the failed read while retaining completed pages.
28
+ Without a usable reset time, export fails immediately. A running dispatcher and
29
+ other clients authenticated as the same API user share the API budget, so they
30
+ can cause additional waits. Interrupting export with Ctrl-C publishes nothing;
31
+ the destination stays absent or empty until all ticket and attachment reads succeed.
19
32
 
20
33
  Both commands also accept
21
34
  `--store <ref>` to reach legacy BuildStore attachments. Keep the old store available
@@ -70,3 +83,36 @@ identity, establishes node kinds, then applies targets using the durable id map,
70
83
  just like blockers. Input order does not matter. Resuming also restores edges on
71
84
  adopted tickets; normal destination validation still guards existing graphs and
72
85
  node demotion. Older work-only exports remain valid.
86
+
87
+ ## In-flight builds
88
+
89
+ A recorded migration resolves old source-qualified ticket references through the
90
+ new source, including remapped IDs. Completeness, child targeting, capacity
91
+ ancestry, claimed target checks, lifecycle transitions and notices use that
92
+ mapping. Historical build events and ticket references remain unchanged. Moves
93
+ can chain across sources; mappings are never applied backward. A source switch
94
+ alone establishes no continuity. Missing migration evidence or an uncovered ID
95
+ fails closed and names the build and original ticket when operating on that
96
+ build or its frozen membership. Uncovered historical builds stay in their
97
+ original namespace during history searches; they cannot alias current tickets
98
+ or block unrelated intake. Separate trackers with the
99
+ same adapter name cannot be distinguished by historical references; this does
100
+ not establish continuity between them.
101
+
102
+ When using the export directory directly as the configured file tracker, run
103
+ `ab ticket migration record /path/to/export [--store <ref>]`. This verifies the
104
+ manifest inventory and creation keys against the destination and records identity
105
+ mappings for the original manifest IDs, without importing tickets. Additional
106
+ tickets filed in the directory after export are allowed and are not included in
107
+ the mapping. Every original ID must still exist with its recorded creation key.
108
+ Preserve `.ab-migration.json` for this step;
109
+ the tracker itself can operate without it. `.ab-import-map.json` is progress
110
+ information, never proof of continuity. Repeating an identical recording is safe;
111
+ conflicting evidence is refused.
112
+
113
+ Import is not transactional across ticket and build services. A partial import
114
+ records no continuity; rerun with the same directory to adopt by creation key.
115
+ If tickets finish but journal recording fails, the command reports that boundary:
116
+ rerun the same command to finish recording before resuming builds. The migration
117
+ journal belongs to the selected BuildStore even when ticket assets live on an
118
+ independent hosted service. Validate the destination configuration before resume.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defrex/autobuild",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Agent-driven software delivery from groomed ticket to merged PR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -144,8 +144,8 @@
144
144
  },
145
145
  "devDependencies": {
146
146
  "@biomejs/biome": "2.5.5",
147
- "@defrex/autobuild-postgres-store": "1.0.0-beta.2",
148
- "@defrex/autobuild-vercel-sandbox": "1.0.0-beta.2",
147
+ "@defrex/autobuild-postgres-store": "1.0.0-beta.3",
148
+ "@defrex/autobuild-vercel-sandbox": "1.0.0-beta.3",
149
149
  "@resvg/resvg-js": "2.6.2",
150
150
  "@types/bun": "^1.3.14",
151
151
  "@types/node": "^24.0.0",
@@ -435,7 +435,7 @@ export interface ControlBuildOpts {
435
435
  ticketSource?: () => Promise<TicketSource>
436
436
  /** Injected only for --revise-spec-from-ticket. */
437
437
  prepareTicketAssets?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<PinnedAsset[]>
438
- readTicketBody?: (ref: TicketRef) => Promise<string>
438
+ readTicketBody?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<string>
439
439
  }
440
440
 
441
441
  /** Apply one control against a freshly reduced build log. */
@@ -642,7 +642,7 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
642
642
  'ticket body reader is unavailable for --revise-spec-from-ticket',
643
643
  )
644
644
  }
645
- body = await opts.readTicketBody(record.ticket)
645
+ body = await opts.readTicketBody(record.ticket, opts.store, record.repo)
646
646
  if (record.ticket.source === 'hosted' && !opts.prepareTicketAssets) {
647
647
  throw new BuildControlError(
648
648
  'ticket-unavailable',
@@ -891,7 +891,7 @@ export interface AbBuildControlOpts {
891
891
  storeRef?: string
892
892
  /** Injected only for --revise-spec-from-ticket. */
893
893
  prepareTicketAssets?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<PinnedAsset[]>
894
- readTicketBody?: (ref: TicketRef) => Promise<string>
894
+ readTicketBody?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<string>
895
895
  /** Injectable adapter seam for unit tests. */
896
896
  openStore?: StoreOpener
897
897
  }
@@ -16,6 +16,7 @@ export interface IntegrationChild {
16
16
  id: string
17
17
  title: string
18
18
  builds?: string[]
19
+ claims?: string[]
19
20
  state: string
20
21
  landed: boolean
21
22
  }
@@ -43,13 +44,14 @@ export function projectIntegrationDetail(
43
44
  const row = projectIntegrationRow(record, state, restack, config)
44
45
  if (!row) return undefined
45
46
  const observation = state.integration?.observation
47
+ const membershipSource = observation?.membershipSource ?? record.ticket?.source
46
48
  const open = new Set(observation?.openChildren ?? [])
47
49
  const contributions = new Set(observation?.contributions ?? [])
48
50
  const children: IntegrationChild[] = (observation?.children ?? [])
49
51
  .filter(
50
52
  (c) =>
51
53
  observation!.diagnostics.length ||
52
- (c.source === record.ticket?.source && open.has(c.id)) ||
54
+ (c.source === membershipSource && open.has(c.id)) ||
53
55
  c.builds?.some((b) => contributions.has(b)),
54
56
  )
55
57
  .map((c) => ({
@@ -57,17 +59,17 @@ export function projectIntegrationDetail(
57
59
  title: c.title ?? 'title unavailable',
58
60
  landed:
59
61
  !!c.builds?.some((b) => contributions.has(b)) &&
60
- !(c.source === record.ticket?.source && open.has(c.id)),
62
+ !(c.source === membershipSource && open.has(c.id)),
61
63
  state:
62
64
  c.builds?.some((b) => contributions.has(b)) &&
63
- !(c.source === record.ticket?.source && open.has(c.id))
65
+ !(c.source === membershipSource && open.has(c.id))
64
66
  ? 'landed'
65
67
  : 'queued',
66
68
  }))
67
69
  for (const id of open)
68
- if (!children.some((c) => c.id === id && c.source === record.ticket?.source))
70
+ if (!children.some((c) => c.id === id && c.source === membershipSource))
69
71
  children.push({
70
- source: record.ticket?.source ?? '',
72
+ source: membershipSource ?? '',
71
73
  id,
72
74
  title: 'title unavailable',
73
75
  state: 'queued',
@@ -76,7 +78,7 @@ export function projectIntegrationDetail(
76
78
  for (const contribution of contributions)
77
79
  if (!children.some((c) => c.builds?.includes(contribution)))
78
80
  children.push({
79
- source: record.ticket?.source ?? '',
81
+ source: membershipSource ?? '',
80
82
  id: contribution,
81
83
  builds: [contribution],
82
84
  title: 'title unavailable',
@@ -130,7 +130,7 @@ export function enrichIntegrationRows(
130
130
  const list = row.integrationRow
131
131
  const identity = row.collectionIdentity
132
132
  if (!list || !identity) return row
133
- const live = (id: string, source: string) =>
133
+ const live = (id: string, source: string, claims?: string[]) =>
134
134
  rows
135
135
  .filter((child) => {
136
136
  const match = child.collectionIdentity
@@ -138,9 +138,10 @@ export function enrichIntegrationRows(
138
138
  match &&
139
139
  match.repo === identity.repo &&
140
140
  match.targetBuild === row.slug &&
141
- match.targetSource === identity.source &&
142
- match.targetId === identity.id &&
143
- (match.id ? match.source === source && match.id === id : child.slug === id) &&
141
+ (claims?.includes(child.slug) ||
142
+ (match.targetSource === identity.source &&
143
+ match.targetId === identity.id &&
144
+ (match.id ? match.source === source && match.id === id : child.slug === id))) &&
144
145
  match.status !== 'queued' &&
145
146
  match.status !== 'done' &&
146
147
  match.status !== 'aborted'
@@ -152,17 +153,23 @@ export function enrichIntegrationRows(
152
153
  a.collectionIdentity?.createdAt ?? '',
153
154
  ) || b.slug.localeCompare(a.slug),
154
155
  )[0]
155
- const building = list.openChildren.filter((id) => live(id, identity.source ?? '')).length
156
156
  const detail = row.integrationDetail
157
+ const building = list.openChildren.filter((id) => {
158
+ const child = detail?.children.find((entry) => entry.id === id && !entry.landed)
159
+ return live(id, child?.source ?? identity.source ?? '', child?.claims)
160
+ }).length
157
161
  const projected = detail?.children.map((child) => {
158
- const active = child.landed ? undefined : live(child.id, child.source)
162
+ const active = child.landed ? undefined : live(child.id, child.source, child.claims)
159
163
  const historical = child.builds?.length
160
164
  ? records.find((r) => r.repo === identity.repo && child.builds?.includes(r.slug))
161
165
  : undefined
162
166
  return {
163
167
  ...child,
164
- id: historical?.ticket?.id ?? child.id,
165
- source: historical?.ticket?.source ?? child.source,
168
+ id: child.id === historical?.slug ? (historical.ticket?.id ?? child.id) : child.id,
169
+ source:
170
+ child.id === historical?.slug
171
+ ? (historical.ticket?.source ?? child.source)
172
+ : child.source,
166
173
  title:
167
174
  child.title === 'title unavailable'
168
175
  ? (active?.collectionIdentity?.title ?? historical?.ticket?.title ?? child.title)
@@ -1,3 +1,4 @@
1
+ import { migrationIdentity, ticketMigrationsReducer } from '../../kernel/ticket-migrations'
1
2
  import { projectIntegrationDetail, type IntegrationDetail } from './integration-detail'
2
3
  import {
3
4
  projectIntegrationRow,
@@ -1352,6 +1353,12 @@ export function buildDashboard(
1352
1353
  })),
1353
1354
  config.capacity,
1354
1355
  new Date(),
1356
+ migrationIdentity(
1357
+ Array.isArray(repositoryEvents)
1358
+ ? ticketMigrationsReducer.reduce(repositoryEvents)
1359
+ : repositoryEvents.ticketMigrations,
1360
+ config.tickets.source,
1361
+ ),
1355
1362
  )
1356
1363
  const activeCount = capacityProjection.occupied
1357
1364
  return buildDashboardFromProjected(
@@ -1,3 +1,4 @@
1
+ import { migrationIdentity, ticketMigrationsReducer } from '../kernel/ticket-migrations'
1
2
  import { dispatchCapacity } from '../kernel/dispatch-capacity'
2
3
  import { forgeReadinessWarnings } from '../kernel/dispatch-status'
3
4
  import { RepositoryPollCache } from './dashboard/repository-poll'
@@ -395,6 +396,10 @@ export class DispatchFrontend {
395
396
  snapshot.capacityBuilds ?? [],
396
397
  config.capacity,
397
398
  this.clock(),
399
+ migrationIdentity(
400
+ ticketMigrationsReducer.reduce(repositoryEvents),
401
+ config.tickets.source,
402
+ ),
398
403
  ),
399
404
  observationCount: this.observationCount,
400
405
  observationLimit: config.policy.harvestThreshold,
@@ -6,6 +6,7 @@ import type { BuildStore, Clock } from '../store/types'
6
6
  export function isDashboardRepositoryEvent(event: RepositoryEvent): boolean {
7
7
  return (
8
8
  event.type.startsWith('harvest.') ||
9
+ event.type === 'tickets.migration-recorded' ||
9
10
  event.type === 'dispatcher.intake-set' ||
10
11
  event.type === 'dispatcher.pause-set' ||
11
12
  event.type === 'dispatcher.auto-merge-default-set'
@@ -13,7 +14,7 @@ export function isDashboardRepositoryEvent(event: RepositoryEvent): boolean {
13
14
  }
14
15
 
15
16
  export const dispatchFrontendReducer = defineReducer({
16
- version: 2,
17
+ version: 3,
17
18
  initial: (): { retained: RepositoryEvent[]; incompleteIdentities: boolean } => ({
18
19
  retained: [],
19
20
  incompleteIdentities: true,
@@ -1,3 +1,4 @@
1
+ import { migrationIdentity } from '../kernel/ticket-migrations'
1
2
  import { formatDispatcherError } from '../runtime-identity'
2
3
 
3
4
  import { isDeepStrictEqual } from 'node:util'
@@ -3667,6 +3668,10 @@ class DispatchLoop {
3667
3668
  buildSnapshot.capacityBuilds ?? [],
3668
3669
  configSnapshot.config.capacity,
3669
3670
  this.wiring.clock(),
3671
+ migrationIdentity(
3672
+ repositoryEvents.ticketMigrations,
3673
+ configSnapshot.config.tickets.source,
3674
+ ),
3670
3675
  ),
3671
3676
  observationCount: this.observationCount,
3672
3677
  observationLimit: configSnapshot.config.policy.harvestThreshold,
@@ -174,6 +174,7 @@ export const HELP_CATALOG: readonly HelpEntry[] = [
174
174
  ' ab ticket edit <id>',
175
175
  ' ab ticket export <dir> [--store <ref>]',
176
176
  ' ab ticket import <dir> [--store <ref>]',
177
+ ' ab ticket migration record <dir> [--store <ref>]',
177
178
  ' ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--expected-revision <opaque>] [--json]',
178
179
  ' ab ticket block <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
179
180
  ' ab ticket unblock <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
@@ -1,3 +1,4 @@
1
+ import { currentTicketRef } from '../kernel/ticket-migrations'
1
2
  import { requestNodeRestack } from '../operator/restack'
2
3
  import { withSessionlessStore } from './store-opening'
3
4
  import { abLandings } from './landings'
@@ -318,7 +319,7 @@ async function runBuildControl(
318
319
  slug: string,
319
320
  action: BuildControlAction,
320
321
  storeRef?: string,
321
- readTicketBody?: (ref: TicketRef) => Promise<string>,
322
+ readTicketBody?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<string>,
322
323
  prepareTicketAssets?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<PinnedAsset[]>,
323
324
  ): Promise<void> {
324
325
  if (deps.exec === undefined) {
@@ -670,6 +671,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
670
671
  throw new Error("'ab ticket' needs an exec seam — this is a wiring bug in the ab binary")
671
672
  }
672
673
  await abTicket(rest, {
674
+ signal: deps.signal,
673
675
  targetRepo: deps.workspacePath,
674
676
  env: deps.processEnv ?? {},
675
677
  exec: deps.exec,
@@ -1207,7 +1209,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
1207
1209
  let revisionTicketSource: import('../ports/types').TicketSource | undefined
1208
1210
  const readTicketBody =
1209
1211
  resolve?.kind === 'revise-spec' && resolve.body.kind === 'ticket'
1210
- ? async (ref: TicketRef): Promise<string> => {
1212
+ ? async (original: TicketRef, store: BuildStore, repo: string): Promise<string> => {
1211
1213
  const { source } = await openTicketSource(
1212
1214
  {
1213
1215
  targetRepo: deps.workspacePath,
@@ -1219,11 +1221,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
1219
1221
  'ab answer --revise-spec-from-ticket',
1220
1222
  )
1221
1223
  revisionTicketSource = source
1222
- if (source.name !== ref.source) {
1223
- throw new Error(
1224
- `build ticket source is "${ref.source}", but this repository is configured for "${source.name}"; refusing to read a same-id ticket from a different source`,
1225
- )
1226
- }
1224
+ const ref = await currentTicketRef(store, repo, source.name, original, slug)
1227
1225
  const ticket = await source.get(ref.id)
1228
1226
  if (ticket === null) {
1229
1227
  throw new Error(
@@ -1256,7 +1254,12 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
1256
1254
  ? async (ref, store, repo) => {
1257
1255
  if (!revisionTicketSource)
1258
1256
  throw new Error('ticket body must be read before preparing assets')
1259
- return preparePinnedAssets(revisionTicketSource, store, repo, ref.id)
1257
+ return preparePinnedAssets(
1258
+ revisionTicketSource,
1259
+ store,
1260
+ repo,
1261
+ (await currentTicketRef(store, repo, revisionTicketSource.name, ref, slug)).id,
1262
+ )
1260
1263
  }
1261
1264
  : undefined,
1262
1265
  )
@@ -1,3 +1,4 @@
1
+ import { migrationIdentity } from '../kernel/ticket-migrations'
1
2
  import {
2
3
  dispatchCapacity,
3
4
  type DispatchCapacity,
@@ -266,7 +267,12 @@ export async function readRepositoryCapacity(
266
267
  provisioning: build.provisionMarker !== undefined,
267
268
  })
268
269
  }
269
- return dispatchCapacity(builds, config.capacity, now)
270
+ return dispatchCapacity(
271
+ builds,
272
+ config.capacity,
273
+ now,
274
+ migrationIdentity(facts.ticketMigrations, config.tickets.source),
275
+ )
270
276
  }
271
277
  }
272
278
  return undefined