agl 42.2.2 → 43.0.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 (171) hide show
  1. package/changelog.md +16 -0
  2. package/dist_serve/bundle.js +6697 -5287
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_serve/bundle.js.third-party-notices.json +29 -29
  5. package/dist_serve/bundle.js.third-party-notices.txt +29 -29
  6. package/dist_serve/third-party-notices.md +597 -8
  7. package/dist_ts/00_commitinfo_data.js +1 -1
  8. package/dist_ts/aglapi/aglapisurface.document.js +114 -16
  9. package/dist_ts/aglapi/interfaces.d.ts +30 -0
  10. package/dist_ts/aglapi/interfaces.js +7 -1
  11. package/dist_ts/classes.authstore.d.ts +7 -0
  12. package/dist_ts/classes.authstore.js +12 -1
  13. package/dist_ts/classes.cli.js +10 -1
  14. package/dist_ts/classes.controller.d.ts +41 -11
  15. package/dist_ts/classes.controller.js +224 -48
  16. package/dist_ts/classes.harnessoperationmanager.d.ts +44 -0
  17. package/dist_ts/classes.harnessoperationmanager.js +15 -10
  18. package/dist_ts/classes.mcpclient.d.ts +5 -0
  19. package/dist_ts/classes.mcpclient.js +15 -3
  20. package/dist_ts/classes.mcpcontrollerhost.d.ts +3 -0
  21. package/dist_ts/classes.mcpcontrollerhost.js +14 -2
  22. package/dist_ts/classes.mcptools.d.ts +4 -3
  23. package/dist_ts/classes.mcptools.js +20 -1
  24. package/dist_ts/classes.mcpvalidation.js +4 -1
  25. package/dist_ts/classes.ticketstore.d.ts +71 -3
  26. package/dist_ts/classes.ticketstore.js +299 -12
  27. package/dist_ts/classes.validation.d.ts +2 -0
  28. package/dist_ts/classes.validation.js +27 -5
  29. package/dist_ts/driver/classes.directreports.d.ts +23 -3
  30. package/dist_ts/driver/classes.directreports.js +59 -2
  31. package/dist_ts/driver/classes.drivereventrelay.js +3 -2
  32. package/dist_ts/driver/functions.driverinstructions.d.ts +1 -1
  33. package/dist_ts/driver/functions.driverinstructions.js +12 -3
  34. package/dist_ts/driver/functions.drivertools.d.ts +4 -0
  35. package/dist_ts/driver/functions.drivertools.js +8 -2
  36. package/dist_ts/fleet/classes.boardpump.d.ts +53 -3
  37. package/dist_ts/fleet/classes.boardpump.js +237 -32
  38. package/dist_ts/fleet/classes.claudeworkers.d.ts +10 -3
  39. package/dist_ts/fleet/classes.claudeworkers.js +43 -19
  40. package/dist_ts/fleet/classes.codexworkers.d.ts +5 -3
  41. package/dist_ts/fleet/classes.codexworkers.js +26 -9
  42. package/dist_ts/fleet/classes.deploymonitor.d.ts +253 -0
  43. package/dist_ts/fleet/classes.deploymonitor.js +821 -0
  44. package/dist_ts/fleet/classes.gitfacts.d.ts +61 -0
  45. package/dist_ts/fleet/classes.gitfacts.js +125 -0
  46. package/dist_ts/fleet/classes.releasereconciler.d.ts +51 -0
  47. package/dist_ts/fleet/classes.releasereconciler.js +101 -0
  48. package/dist_ts/fleet/classes.service.d.ts +13 -1
  49. package/dist_ts/fleet/classes.service.js +76 -7
  50. package/dist_ts/fleet/classes.ticketeffects.d.ts +13 -0
  51. package/dist_ts/fleet/classes.ticketeffects.js +42 -8
  52. package/dist_ts/fleet/classes.workers.d.ts +10 -3
  53. package/dist_ts/fleet/classes.workers.js +18 -3
  54. package/dist_ts/fleet/functions.controllerbuild.d.ts +23 -0
  55. package/dist_ts/fleet/functions.controllerbuild.js +75 -0
  56. package/dist_ts/fleet/functions.deployprobes.d.ts +39 -0
  57. package/dist_ts/fleet/functions.deployprobes.js +82 -0
  58. package/dist_ts/fleet/functions.deployvalidation.d.ts +27 -0
  59. package/dist_ts/fleet/functions.deployvalidation.js +43 -0
  60. package/dist_ts/fleet/functions.release.d.ts +2 -1
  61. package/dist_ts/fleet/functions.release.js +32 -5
  62. package/dist_ts/fleet/functions.releasefacts.d.ts +45 -0
  63. package/dist_ts/fleet/functions.releasefacts.js +68 -0
  64. package/dist_ts/fleet/functions.validation.d.ts +3 -3
  65. package/dist_ts/fleet/functions.validation.js +4 -7
  66. package/dist_ts/fleet/functions.watchprobes.js +7 -9
  67. package/dist_ts/fleet/functions.workervalidation.js +4 -3
  68. package/dist_ts/fleet/interfaces.workers.d.ts +30 -3
  69. package/dist_ts/fleet/interfaces.workers.js +14 -1
  70. package/dist_ts/functions.deploycli.d.ts +33 -0
  71. package/dist_ts/functions.deploycli.js +155 -0
  72. package/dist_ts/functions.mcpdeploytools.d.ts +13 -0
  73. package/dist_ts/functions.mcpdeploytools.js +16 -0
  74. package/dist_ts/functions.mcptickettools.d.ts +54 -0
  75. package/dist_ts/functions.mcptickettools.js +8 -7
  76. package/dist_ts/functions.ticketautolabels.d.ts +2 -0
  77. package/dist_ts/functions.ticketautolabels.js +9 -3
  78. package/dist_ts/functions.ticketcli.d.ts +16 -2
  79. package/dist_ts/functions.ticketcli.js +105 -27
  80. package/dist_ts/functions.ticketvalidation.d.ts +55 -0
  81. package/dist_ts/functions.ticketvalidation.js +26 -8
  82. package/dist_ts_interfaces/deployments.d.ts +241 -0
  83. package/dist_ts_interfaces/deployments.js +5 -6
  84. package/dist_ts_interfaces/fleet.d.ts +12 -0
  85. package/dist_ts_interfaces/fleetworkers.d.ts +21 -1
  86. package/dist_ts_interfaces/interfaces.d.ts +4 -2
  87. package/dist_ts_interfaces/interfaces.js +4 -2
  88. package/dist_ts_interfaces/mcprequests.d.ts +3 -2
  89. package/dist_ts_interfaces/mcprequests.js +3 -1
  90. package/dist_ts_interfaces/requests.d.ts +3 -2
  91. package/dist_ts_interfaces/requests.directreports.d.ts +58 -6
  92. package/dist_ts_interfaces/requests.js +1 -1
  93. package/dist_ts_interfaces/requests.tickets.d.ts +25 -5
  94. package/dist_ts_interfaces/requests.tickets.js +2 -2
  95. package/dist_ts_interfaces/tickets.d.ts +71 -6
  96. package/dist_ts_interfaces/tickets.js +34 -6
  97. package/dist_ts_migration/classes.documentmigrationrunner.d.ts +7 -0
  98. package/dist_ts_migration/classes.documentmigrationrunner.js +14 -1
  99. package/dist_ts_migration/index.d.ts +2 -0
  100. package/dist_ts_migration/index.js +3 -1
  101. package/dist_ts_migration/v41_ticketclosedcolumn.d.ts +20 -0
  102. package/dist_ts_migration/v41_ticketclosedcolumn.js +118 -0
  103. package/dist_ts_migration/v41_ticketlinkrepos.d.ts +24 -0
  104. package/dist_ts_migration/v41_ticketlinkrepos.js +101 -0
  105. package/package.json +6 -2
  106. package/readme.md +306 -36
  107. package/third-party-notices.md +597 -8
  108. package/ts/00_commitinfo_data.ts +1 -1
  109. package/ts/aglapi/aglapisurface.document.ts +113 -15
  110. package/ts/aglapi/interfaces.ts +6 -0
  111. package/ts/classes.authstore.ts +13 -0
  112. package/ts/classes.cli.ts +9 -0
  113. package/ts/classes.controller.ts +238 -59
  114. package/ts/classes.harnessoperationmanager.ts +20 -14
  115. package/ts/classes.mcpclient.ts +17 -2
  116. package/ts/classes.mcpcontrollerhost.ts +15 -1
  117. package/ts/classes.mcptools.ts +21 -2
  118. package/ts/classes.mcpvalidation.ts +2 -0
  119. package/ts/classes.ticketstore.ts +312 -13
  120. package/ts/classes.validation.ts +28 -4
  121. package/ts/driver/classes.directreports.ts +58 -3
  122. package/ts/driver/classes.drivereventrelay.ts +2 -1
  123. package/ts/driver/functions.driverinstructions.ts +11 -2
  124. package/ts/driver/functions.drivertools.ts +10 -2
  125. package/ts/fleet/classes.boardpump.ts +235 -28
  126. package/ts/fleet/classes.claudeworkers.ts +36 -15
  127. package/ts/fleet/classes.codexworkers.ts +24 -7
  128. package/ts/fleet/classes.deploymonitor.ts +854 -0
  129. package/ts/fleet/classes.gitfacts.ts +135 -0
  130. package/ts/fleet/classes.releasereconciler.ts +103 -0
  131. package/ts/fleet/classes.service.ts +81 -8
  132. package/ts/fleet/classes.ticketeffects.ts +38 -6
  133. package/ts/fleet/classes.workers.ts +19 -5
  134. package/ts/fleet/functions.controllerbuild.ts +84 -0
  135. package/ts/fleet/functions.deployprobes.ts +84 -0
  136. package/ts/fleet/functions.deployvalidation.ts +50 -0
  137. package/ts/fleet/functions.release.ts +32 -3
  138. package/ts/fleet/functions.releasefacts.ts +91 -0
  139. package/ts/fleet/functions.validation.ts +3 -6
  140. package/ts/fleet/functions.watchprobes.ts +6 -8
  141. package/ts/fleet/functions.workervalidation.ts +3 -2
  142. package/ts/fleet/interfaces.workers.ts +23 -3
  143. package/ts/functions.deploycli.ts +151 -0
  144. package/ts/functions.mcpdeploytools.ts +18 -0
  145. package/ts/functions.mcptickettools.ts +7 -6
  146. package/ts/functions.ticketautolabels.ts +10 -2
  147. package/ts/functions.ticketcli.ts +100 -24
  148. package/ts/functions.ticketvalidation.ts +26 -7
  149. package/ts_interfaces/deployments.ts +194 -0
  150. package/ts_interfaces/fleet.ts +17 -2
  151. package/ts_interfaces/fleetworkers.ts +20 -0
  152. package/ts_interfaces/interfaces.ts +3 -1
  153. package/ts_interfaces/mcprequests.ts +3 -0
  154. package/ts_interfaces/requests.directreports.ts +52 -8
  155. package/ts_interfaces/requests.tickets.ts +20 -4
  156. package/ts_interfaces/requests.ts +6 -1
  157. package/ts_interfaces/tickets.ts +53 -6
  158. package/ts_migration/classes.documentmigrationrunner.ts +15 -0
  159. package/ts_migration/index.ts +2 -0
  160. package/ts_migration/v41_ticketclosedcolumn.ts +106 -0
  161. package/ts_migration/v41_ticketlinkrepos.ts +91 -0
  162. package/ts_web/00_commitinfo_data.ts +1 -1
  163. package/ts_web/elements.deployments.ts +1066 -0
  164. package/ts_web/elements.directreport.ts +2 -2
  165. package/ts_web/elements.directreportsession.ts +5 -5
  166. package/ts_web/elements.harnesscontrollerapp.ts +179 -13
  167. package/ts_web/elements.makedirectreport.ts +444 -0
  168. package/ts_web/elements.nativesession.ts +29 -1
  169. package/ts_web/elements.ticketboard.ts +74 -18
  170. package/ts_web/functions.deployments.ts +225 -0
  171. package/ts_web/functions.sessionchat.ts +2 -0
@@ -4,6 +4,7 @@ import { controllerMcpJobMethods, type TControllerMcpJobTypedRequest } from './m
4
4
  import { controllerMcpTicketMethods, type TControllerMcpTicketTypedRequest } from './requests.tickets.js';
5
5
  import { controllerMcpFleetMethods, type TControllerMcpFleetTypedRequest } from './requests.fleet.js';
6
6
  import { controllerMcpSessionFeedMethods, type TControllerMcpSessionFeedTypedRequest } from './sessionfeed.js';
7
+ import { controllerMcpDeployMethods, type TControllerMcpDeployTypedRequest } from './deployments.js';
7
8
  import * as plugins from './plugins.js';
8
9
  import type { IReq_ControllerMcpWorkerEnroll, IWorkerCallerSubject } from './workercallers.js';
9
10
  import type { IReq_ControllerSettingsGet, IReq_ControllerSettingsUpdate } from './requests.js';
@@ -62,6 +63,7 @@ export const controllerMcpMethods = [
62
63
  ...controllerMcpFleetMethods,
63
64
  ...controllerMcpFleetWorkerMethods,
64
65
  ...controllerMcpSessionFeedMethods,
66
+ ...controllerMcpDeployMethods,
65
67
  'agl.mcp.worker.enroll',
66
68
  ] as const;
67
69
  export type TControllerMcpMethod = (typeof controllerMcpMethods)[number];
@@ -432,6 +434,7 @@ export type TControllerMcpTypedRequest =
432
434
  | TControllerMcpFleetTypedRequest
433
435
  | TControllerMcpFleetWorkerTypedRequest
434
436
  | TControllerMcpSessionFeedTypedRequest
437
+ | TControllerMcpDeployTypedRequest
435
438
  | IReq_ControllerMcpSettingsGet
436
439
  | IReq_ControllerMcpSettingsUpdate
437
440
  | TControllerMcpWorkspaceTypedRequest
@@ -1,10 +1,16 @@
1
1
  import type * as plugins from './plugins.js';
2
2
  import type { IDirectReport, IDirectReportView } from './directreports.js';
3
- import type { IFleetWorkerJob, TFleetWorkerHarness } from './fleetworkers.js';
3
+ import type { IFleetRelaunchBlocker, IFleetWorkerJob, TFleetWorkerHarness } from './fleetworkers.js';
4
4
  import type { IControllerDraftAttachment, IControllerMessageBundle, IControllerRuntimeId, TControllerPromptDelivery } from './interfaces.js';
5
+ import type { IControllerNativeSession, IControllerNativeSessionRef } from './nativesessions.js';
5
6
  import type { IReq_ControllerFleetWorkerRead } from './requests.fleetworkers.js';
6
7
 
7
8
  /** The owner's direct reports, active ones unless `retired` asks for all. */
9
+ /**
10
+ * Whom a direct report reports to. Every report reports to the host's driver, the owner of the Driver view; the
11
+ * request names it so that other superiors can follow.
12
+ */
13
+ export type TDirectReportSuperior = { kind: 'driver' };
8
14
  export interface IReq_ControllerDirectReportList extends plugins.typedrequestInterfaces.implementsTR<
9
15
  plugins.typedrequestInterfaces.ITypedRequest,
10
16
  IReq_ControllerDirectReportList
@@ -22,7 +28,7 @@ export interface IReq_ControllerDirectReportAppoint extends plugins.typedrequest
22
28
  IReq_ControllerDirectReportAppoint
23
29
  > {
24
30
  method: 'controller.directreport.appoint';
25
- request: { name: string; workerName: string; projects?: string[] };
31
+ request: { name: string; workerName: string; projects?: string[]; reportsTo?: TDirectReportSuperior };
26
32
  response: { report: IDirectReportView };
27
33
  }
28
34
  /**
@@ -44,9 +50,47 @@ export interface IReq_ControllerDirectReportAdopt extends plugins.typedrequestIn
44
50
  IReq_ControllerDirectReportAdopt
45
51
  > {
46
52
  method: 'controller.directreport.adopt';
47
- request: { name: string; harness: TFleetWorkerHarness; nativeId: string; driverTicketKey: string; projects?: string[]; relaunch?: IDirectReportRelaunch };
53
+ request: { name: string; harness: TFleetWorkerHarness; nativeId: string; driverTicketKey: string; projects?: string[]; relaunch?: IDirectReportRelaunch; reportsTo?: TDirectReportSuperior };
48
54
  response: { report: IDirectReportView };
49
55
  }
56
+ /**
57
+ * Why a session cannot become a direct report now, beside the relaunch's own refusals: `notListed`, no source the
58
+ * session feed reads lists it; `alreadyReport`, an active report holds it; `workerNoTicket`, the fleet worker bound to
59
+ * it has no ticket to steer it through; `projectConversation`, an AGL project conversation records the Claude Code
60
+ * session, and that project writes to it; `directoryMissing`, its directory is gone; `noProfile`, no Claude fleet
61
+ * profile uses the Claude Code home that holds it; `profileHome`, the chosen profile uses another home.
62
+ */
63
+ export interface IDirectReportBlocker {
64
+ code: 'notListed' | 'alreadyReport' | 'workerNoTicket' | 'projectConversation' | 'directoryMissing' | 'noProfile' | 'profileHome' | IFleetRelaunchBlocker['code'];
65
+ message: string;
66
+ pid?: number;
67
+ }
68
+ /**
69
+ * How the session `session` would become a direct report, and what refuses that now, read-only. The path follows the
70
+ * session: a session a fleet worker of the owner is bound to is appointed (`appoint`, that worker's `workerName`), a
71
+ * Codex thread is adopted by reference (`reference`), and a Claude Code session is relaunched under the fleet's control
72
+ * (`relaunch`) with a Claude profile of `profiles`, those whose Claude Code home holds it: `profile` (the first by
73
+ * default) in `cwd` (the session's own by default), through the relaunch's own checks. `reportsTo` lists whom the
74
+ * report can report to. Nothing is written; an adopt or appoint checks again.
75
+ */
76
+ export interface IReq_ControllerDirectReportPreflight extends plugins.typedrequestInterfaces.implementsTR<
77
+ plugins.typedrequestInterfaces.ITypedRequest,
78
+ IReq_ControllerDirectReportPreflight
79
+ > {
80
+ method: 'controller.directreport.preflight';
81
+ request: { session: IControllerNativeSessionRef; profile?: string; cwd?: string };
82
+ response: {
83
+ path: 'appoint' | 'reference' | 'relaunch';
84
+ /** The session as the session feed lists it; absent when no source lists it. */
85
+ session?: IControllerNativeSession;
86
+ workerName?: string;
87
+ profiles: string[];
88
+ profile?: string;
89
+ cwd?: string;
90
+ reportsTo: Array<{ superior: TDirectReportSuperior; label: string }>;
91
+ blockers: IDirectReportBlocker[];
92
+ };
93
+ }
50
94
  /** Retires a direct report. Its session is left as it is, and its name stays taken. */
51
95
  export interface IReq_ControllerDirectReportRetire extends plugins.typedrequestInterfaces.implementsTR<
52
96
  plugins.typedrequestInterfaces.ITypedRequest,
@@ -57,21 +101,21 @@ export interface IReq_ControllerDirectReportRetire extends plugins.typedrequestI
57
101
  response: { report: IDirectReport };
58
102
  }
59
103
  /**
60
- * The newest turns of a direct report that is a Codex thread, read as the AGL conversation `sessionId` of the project
61
- * `projectId` whose folder the thread works in. `turnId` is the turn the thread runs now, which a message to a turn
62
- * another Codex client runs names as its `expectedTurnId`.
104
+ * The newest turns of a direct report that is a Codex thread, read through the shared Codex server that owns it,
105
+ * outside every project. `cwd` is the directory the thread works in. `turnId` is the turn the thread runs now, which a
106
+ * message to a turn another Codex client runs names as its `expectedTurnId`.
63
107
  */
64
108
  export interface IDirectReportSessionPage {
65
109
  kind: 'session';
66
110
  report: string;
67
- projectId: string;
68
111
  sessionId: IControllerRuntimeId;
112
+ cwd: string;
69
113
  bundles: IControllerMessageBundle[];
70
114
  /** The transcript holds turns before the first returned bundle. */
71
115
  earlier: boolean;
72
116
  turnId?: string;
73
117
  }
74
- /** A direct report's newest turns: its fleet worker's transcript, or the conversation its Codex thread is. */
118
+ /** A direct report's newest turns: its fleet worker's transcript, or its Codex thread's. */
75
119
  export type TDirectReportPage = ({ kind: 'fleet-worker'; report: string } & IReq_ControllerFleetWorkerRead['response']) | IDirectReportSessionPage;
76
120
  /**
77
121
  * Reads the newest `limit` bundles (1-200; default 50) of the active direct report `name`. A Claude Code session the
@@ -8,7 +8,7 @@ import type {
8
8
  export const controllerMcpTicketMethods = [
9
9
  'agl.mcp.ticket.list', 'agl.mcp.ticket.board', 'agl.mcp.ticket.search', 'agl.mcp.ticket.get',
10
10
  'agl.mcp.ticket.comments', 'agl.mcp.ticket.create', 'agl.mcp.ticket.update',
11
- 'agl.mcp.ticket.move', 'agl.mcp.ticket.comment', 'agl.mcp.ticket.link',
11
+ 'agl.mcp.ticket.move', 'agl.mcp.ticket.comment', 'agl.mcp.ticket.link', 'agl.mcp.ticket.unlink',
12
12
  'agl.mcp.ticket.ask', 'agl.mcp.ticket.answer',
13
13
  ] as const;
14
14
  export type TControllerMcpTicketMethod = (typeof controllerMcpTicketMethods)[number];
@@ -35,7 +35,8 @@ export type TControllerMcpTicketRequest<TMethod extends TTicketOperation> = {
35
35
  /**
36
36
  * Lists the shared board's tickets across all projects, filtered by `mine`, `project`, `status`,
37
37
  * `label` or `text`. `mine` means the caller's verified session. `label` also matches AutoLabels,
38
- * which AGL computes and nobody sets: `openQuestion` marks a ticket with an unanswered question.
38
+ * which AGL computes and nobody sets: `openQuestion` marks a ticket with an unanswered question,
39
+ * `planned` a ticket with a release plan that is not yet released.
39
40
  */
40
41
  export interface IReq_ControllerMcpTicketList extends plugins.typedrequestInterfaces.implementsTR<
41
42
  TControllerMcpTicketRequest<'list'>, IReq_ControllerMcpTicketList
@@ -98,7 +99,8 @@ export interface IReq_ControllerMcpTicketCreate extends plugins.typedrequestInte
98
99
  * Changes the title, Markdown description, priority, labels, project or parent of a ticket assigned
99
100
  * to the caller, while `expectedRevision` still names the ticket's revision; a stale edit is
100
101
  * refused as `TICKET_REVISION_CONFLICT` with `currentRevision`, so read it again first. The status
101
- * changes only by a move, and only the driver or the owner assigns.
102
+ * changes only by a move, and only the driver or the owner assigns. Only the driver or the owner
103
+ * sets `releasePlan` (a fleet repository as `org/name` and an optional version; `null` clears it).
102
104
  */
103
105
  export interface IReq_ControllerMcpTicketUpdate extends plugins.typedrequestInterfaces.implementsTR<
104
106
  TControllerMcpTicketRequest<'update'>, IReq_ControllerMcpTicketUpdate
@@ -131,7 +133,8 @@ export interface IReq_ControllerMcpTicketComment extends plugins.typedrequestInt
131
133
  response: { comment: ITicketComment };
132
134
  }
133
135
  /**
134
- * Links a branch (repo, branch, full sha), a commit (repo, sha) or a release (package, version) to a
136
+ * Links a branch (repo, branch, full sha), a commit (repo, sha), a release (package, version) or the
137
+ * version a bug was found in (`affects`: repo as org/name of a fleet repository, version) to a
135
138
  * ticket assigned to the caller. Link the review branch before moving the ticket to review.
136
139
  */
137
140
  export interface IReq_ControllerMcpTicketLink extends plugins.typedrequestInterfaces.implementsTR<
@@ -141,6 +144,18 @@ export interface IReq_ControllerMcpTicketLink extends plugins.typedrequestInterf
141
144
  request: { ticketId: string; link: TTicketLink } & { ownerToken?: string };
142
145
  response: { ticket: ITicket };
143
146
  }
147
+ /**
148
+ * Removes one link from a ticket, exactly as the ticket holds it. Only the driver or the owner
149
+ * unlinks, and never the evidence the ticket's column requires (a review branch, a landed branch
150
+ * or commit, a release's release link).
151
+ */
152
+ export interface IReq_ControllerMcpTicketUnlink extends plugins.typedrequestInterfaces.implementsTR<
153
+ TControllerMcpTicketRequest<'unlink'>, IReq_ControllerMcpTicketUnlink
154
+ > {
155
+ method: 'agl.mcp.ticket.unlink';
156
+ request: { ticketId: string; link: TTicketLink } & { ownerToken?: string };
157
+ response: { ticket: ITicket };
158
+ }
144
159
  /**
145
160
  * Asks the owner a question on a ticket assigned to the caller: Markdown, with up to 20 options
146
161
  * (label, optional description); `multiSelect` allows several, `allowCustom` (default true) a free
@@ -173,5 +188,6 @@ export type TControllerMcpTicketTypedRequest =
173
188
  | IReq_ControllerMcpTicketMove
174
189
  | IReq_ControllerMcpTicketComment
175
190
  | IReq_ControllerMcpTicketLink
191
+ | IReq_ControllerMcpTicketUnlink
176
192
  | IReq_ControllerMcpTicketAsk
177
193
  | IReq_ControllerMcpTicketAnswer;
@@ -57,8 +57,9 @@ import type {
57
57
  IReq_ControllerFleetWorkerRead,
58
58
  IReq_ControllerFleetWorkerSteer,
59
59
  } from './requests.fleetworkers.js';
60
- import type { IReq_ControllerDirectReportList, IReq_ControllerDirectReportMessage, IReq_ControllerDirectReportRead } from './requests.directreports.js';
60
+ import type { IReq_ControllerDirectReportAdopt, IReq_ControllerDirectReportAppoint, IReq_ControllerDirectReportPreflight, IReq_ControllerDirectReportList, IReq_ControllerDirectReportMessage, IReq_ControllerDirectReportRead } from './requests.directreports.js';
61
61
  import type { IReq_ControllerSessionFeedAcknowledge, IReq_ControllerSessionFeedList } from './sessionfeed.js';
62
+ import type { TControllerDeployTypedRequest } from './deployments.js';
62
63
  import type {
63
64
  IReq_ControllerNativeSessionAuxiliaryGet,
64
65
  IReq_ControllerNativeSessionIntelligenceAsk,
@@ -263,8 +264,12 @@ export type TControllerRequest =
263
264
  | IReq_ControllerDirectReportList
264
265
  | IReq_ControllerDirectReportMessage
265
266
  | IReq_ControllerDirectReportRead
267
+ | IReq_ControllerDirectReportPreflight
268
+ | IReq_ControllerDirectReportAppoint
269
+ | IReq_ControllerDirectReportAdopt
266
270
  | IReq_ControllerSessionFeedList
267
271
  | IReq_ControllerSessionFeedAcknowledge
272
+ | TControllerDeployTypedRequest
268
273
  | IReq_ControllerNativeSessionRead
269
274
  | IReq_ControllerNativeSessionAuxiliaryGet
270
275
  | IReq_ControllerNativeSessionSend
@@ -40,9 +40,19 @@ export interface ITicketReleasePlan { repo: string; version?: string }
40
40
  export interface ITicketMaintenanceWindow { from: string; to: string; targets: string[]; questionId?: string }
41
41
  /**
42
42
  * A planned deploy: the deploy target should run `version`, a release of its repository, or a newer one. Setting it
43
- * asks the owner `questionId` on the ticket; the answer is the owner's go.
43
+ * asks the owner `questionId` on the ticket; the answer is the owner's go. Its ticket is a deploy ticket, which holds no
44
+ * code or release, so no release ends it before its target runs the version.
44
45
  */
45
46
  export interface ITicketDeployPlan { target: string; version: string; questionId: string }
47
+ /** What a caller plans: the deploy target and the release it should run; AGL asks the owner and records the question. */
48
+ export interface ITicketDeployPlanInput { target: string; version: string }
49
+ /**
50
+ * The owner's question a deploy plan asks, by option id: `1` deploy now, `2` in the next maintenance window (for the
51
+ * AGL controller: when no session is busy), `3` hold.
52
+ */
53
+ export const ticketDeployPlanOptions = { now: '1', later: '2', hold: '3' } as const;
54
+ /** The owner's question a maintenance window the driver proposed asks, by option id: `1` approve it, `2` decline it. */
55
+ export const ticketWindowOptions = { approve: '1', decline: '2' } as const;
46
56
  export interface ITicketAttachment { name: string; url: string; }
47
57
  export interface ITicketSource {
48
58
  kind: 'owner_words' | 'driver' | 'worker';
@@ -78,8 +88,13 @@ export interface ITicket {
78
88
  autoLabels?: TTicketAutoLabel[];
79
89
  }
80
90
  export type TTicketData = Omit<ITicket, 'revision' | 'permissions' | 'autoLabels'> & { revision?: number };
81
- /** Labels AGL computes from a ticket's state. Hand labels may not use these names. */
82
- export const ticketAutoLabels = ['openQuestion'] as const;
91
+ /**
92
+ * Labels AGL computes from a ticket's state. Hand labels may not use these names. `openQuestion`: an unanswered
93
+ * question on a ticket that is not done; `planned`: a release plan, a deploy plan or a maintenance window on a ticket
94
+ * that is not done; `undeployed`: released in a version that some deploy target of one of its repositories does not run
95
+ * yet, which holds for a target that never answered its probe, until every target is seen running it.
96
+ */
97
+ export const ticketAutoLabels = ['openQuestion', 'planned', 'undeployed'] as const;
83
98
  export type TTicketAutoLabel = (typeof ticketAutoLabels)[number];
84
99
  export const isTicketAutoLabel = (valueArg: string): valueArg is TTicketAutoLabel => (
85
100
  (ticketAutoLabels as readonly string[]).includes(valueArg)
@@ -214,6 +229,17 @@ export interface ITicketChanges {
214
229
  parentId?: string | null;
215
230
  project?: string;
216
231
  labels?: string[];
232
+ /** `null` clears the plan. Only the driver or owner plans releases. */
233
+ releasePlan?: ITicketReleasePlan | null;
234
+ /** `null` cancels the window. Only the driver or owner plans windows. */
235
+ maintenanceWindow?: ITicketMaintenanceWindow | null;
236
+ /**
237
+ * A deploy plan asks the owner when it is set. Once asked it keeps its target and version: the same plan set again
238
+ * asks anew once the owner answered, and closing the ticket drops it. A deploy ticket holds no code or release: a
239
+ * ticket that does, or that is done, plans none, and one with a plan takes no branch, commit or release link. Only the
240
+ * driver or owner plans deploys.
241
+ */
242
+ deployPlan?: ITicketDeployPlanInput;
217
243
  }
218
244
  export interface ITicketCreate {
219
245
  project: string;
@@ -225,6 +251,9 @@ export interface ITicketCreate {
225
251
  priority?: TTicketPriority;
226
252
  assignee?: ITicketPerson;
227
253
  labels?: string[];
254
+ releasePlan?: ITicketReleasePlan;
255
+ maintenanceWindow?: ITicketMaintenanceWindow;
256
+ deployPlan?: ITicketDeployPlanInput;
228
257
  sourceText?: string;
229
258
  attachments?: ITicketAttachment[];
230
259
  }
@@ -277,6 +306,8 @@ export interface ITicketOperations {
277
306
  move: { request: ITicketMove; response: { tickets: ITicket[] } };
278
307
  comment: { request: { ticketId: string; body: string | TTicketReferenceContent }; response: { comment: ITicketComment } };
279
308
  link: { request: { ticketId: string; link: TTicketLink }; response: { ticket: ITicket } };
309
+ /** Removes one link exactly as it is held. Only the driver or owner unlinks, and never the evidence a ticket's column requires. */
310
+ unlink: { request: { ticketId: string; link: TTicketLink }; response: { ticket: ITicket } };
280
311
  ask: { request: ITicketAsk; response: { question: ITicketQuestion; ticket: ITicket } };
281
312
  answer: { request: ITicketAnswer; response: { question: ITicketQuestion; ticket: ITicket } };
282
313
  }
@@ -307,17 +338,33 @@ export const ticketErrorMessages = {
307
338
  ticket_identity_required: 'A verified MCP caller is required for this ticket operation. Unidentified callers may only list or get tickets.',
308
339
  ticket_not_found: 'The requested ticket does not exist.',
309
340
  ticket_not_assigned: 'Workers may update or move only tickets assigned to their verified session.',
310
- ticket_worker_column: 'Workers may update or move only within ready, in_progress, needs_input and review; only driver or owner may land or release.',
341
+ ticket_worker_column: 'Workers may update or move only within ready, in_progress, needs_input and review; only driver or owner may land, release or close.',
311
342
  ticket_worker_create_backlog: 'Worker-created tickets must start in backlog.',
312
343
  ticket_assignment_forbidden: 'Only the driver or owner may assign tickets.',
313
344
  ticket_review_branch_required: 'Review requires a linked branch with its full commit sha.',
345
+ ticket_landed_evidence_required: 'Landed requires a linked branch or commit with its full sha; fleet land links it. Work that ships no code goes to closed.',
346
+ ticket_released_evidence_required: 'Released requires a release link; fleet release links it. Work that ships no code goes to closed.',
347
+ ticket_closed_landed: 'A landed ticket is released by the tag that ships its code, not closed: closing it would drop the landed code from release and deploy tracking. Move it back first if the code is not to ship.',
314
348
  ticket_parent_required: 'A subtask requires a task parent.',
315
349
  ticket_parent_invalid: 'Parents must be an epic for a task or a task for a subtask, in the same project.',
316
350
  ticket_move_anchor_invalid: 'The before-ticket must be another ticket in the destination column.',
317
- ticket_label_reserved: 'AutoLabels such as openQuestion are computed by AGL and cannot be set by hand.',
351
+ ticket_label_reserved: 'AutoLabels such as openQuestion, planned and undeployed are computed by AGL and cannot be set by hand.',
352
+ ticket_release_plan_forbidden: 'Only the driver or owner may plan a release.',
353
+ ticket_unlink_forbidden: 'The driver may remove an affects link; code and release links only the owner may remove, and workers none.',
354
+ ticket_release_link_forbidden: 'A release is the remote\'s tag: fleet links it to the tickets the tag ships, and only the owner links a release by hand.',
355
+ ticket_link_not_found: 'The ticket holds no such link.',
356
+ ticket_affects_invalid: 'An affects link names a repository fleet discovery knows (org/name) and the version a bug was found in, such as 0.5.0.',
357
+ ticket_release_plan_invalid: 'A release plan names a repository fleet discovery knows (org/name) and optionally a version such as 41.0.0.',
358
+ ticket_window_forbidden: 'Only the driver or owner may plan a maintenance window.',
359
+ ticket_window_invalid: 'A maintenance window runs from one time to a later one that has not passed, at most 7 days, for deploy targets the Configuration master names; the AGL controller needs none.',
360
+ ticket_deploy_plan_forbidden: 'Only the driver or owner may plan a deploy.',
361
+ ticket_deploy_plan_invalid: 'A deploy plan names a deploy target and a release version such as 3.1.0.',
362
+ ticket_deploy_plan_link_forbidden: 'A deploy ticket holds no code or release: link it to the code ticket. A deploy ticket ends when its target runs the release, or by closing it.',
363
+ ticket_deploy_plan_fixed: 'A deploy plan keeps the target and version it asked the owner about: set the same plan again to ask anew once the owner answered, or close the ticket to drop it; another target or version is a ticket of its own.',
364
+ ticket_window_waiting: 'The maintenance window waits for the owner\'s answer to its question; it changes once the owner has answered.',
365
+ ticket_go_owner_only: 'Only the owner answers the question of a deploy plan or a maintenance window: the answer is the owner\'s go.',
318
366
  ticket_ask_forbidden: 'Workers may ask questions only on tickets assigned to their verified session.',
319
367
  ticket_answer_forbidden: 'Only the owner or the driver may answer ticket questions.',
320
- ticket_go_owner_only: 'Only the owner answers the question of a deploy plan or a maintenance window: the answer is the owner\'s go.',
321
368
  ticket_question_not_found: 'The requested question does not exist on this ticket.',
322
369
  ticket_comment_not_found: 'The requested comment does not exist on this ticket.',
323
370
  ticket_question_answered: 'The question already has a different answer; a second answer is refused. Ask a new question instead.',
@@ -12,6 +12,8 @@ import { ControllerLayoutV32Migration } from './v32_controllerlayoutmigration.js
12
12
  import { InferenceCollectionsV37Migration } from './v37_inferencecollections.js';
13
13
  import { ClaudeGatewayRetirementV38Migration } from './v38_claudegatewayretirement.js';
14
14
  import { TicketOwnerPrincipalV38Migration } from './v38_ticketownerprincipal.js';
15
+ import { TicketClosedColumnV41Migration } from './v41_ticketclosedcolumn.js';
16
+ import { TicketLinkReposV41Migration } from './v41_ticketlinkrepos.js';
15
17
  import type { IControllerIssuerIdentity } from '../ts/interfaces.identity.js';
16
18
 
17
19
  interface IDocumentMigration {
@@ -56,6 +58,19 @@ export class PostDatabaseDocumentMigrationRunner {
56
58
  await new TicketOwnerPrincipalV38Migration(this.database, principalIdArg).run();
57
59
  }
58
60
 
61
+ /** AGL-916: tickets released by hand without a release link move to closed; answers the keys it moved. */
62
+ public async runTicketClosedColumn(): Promise<string[]> {
63
+ return await new TicketClosedColumnV41Migration(this.database).run();
64
+ }
65
+
66
+ /**
67
+ * AGL-909: once, links and release plans name each repository `resolveArg` resolves as `org/name`; answers the keys it
68
+ * changed. With no repository discovered (`discoveredArg` 0) it waits for a later start.
69
+ */
70
+ public async runTicketLinkRepos(resolveArg: (nameArg: string) => string | undefined, discoveredArg: number): Promise<string[]> {
71
+ return await new TicketLinkReposV41Migration(this.database, resolveArg, discoveredArg).run();
72
+ }
73
+
59
74
  public async runControllerIssuerIdentity(
60
75
  dataRootDirectoryArg: string,
61
76
  ): Promise<IControllerIssuerIdentity> {
@@ -28,3 +28,5 @@ export * from './v39_fleetrepositorydiscovery.js';
28
28
  export * from './v39_flexcompaction.js';
29
29
  export * from './v39_flexpublicheadpointers.js';
30
30
  export * from './v41_ticketmigrationmarkers.js';
31
+ export * from './v41_ticketclosedcolumn.js';
32
+ export * from './v41_ticketlinkrepos.js';
@@ -0,0 +1,106 @@
1
+ import * as plugins from './plugins.js';
2
+ import { TicketActivityModel, TicketBoardModel, TicketCommentModel, TicketModel } from '../ts/classes.ticketmodels.js';
3
+ import { AuthError } from '../ts/interfaces.auth.js';
4
+ import type { ITicketActivity, ITicketActor, ITicketComment } from '../ts_interfaces/tickets.js';
5
+ import { TicketMigrationMarkerModel } from './v41_ticketmigrationmarkers.js';
6
+
7
+ export const ticketClosedColumnMigrationId = 'v41_ticketclosedcolumn';
8
+ /** What the migration says on each ticket it moves. */
9
+ export const ticketClosedColumnMigrationNote = 'Moved from Released to Closed by the AGL-916 migration: this ticket was released by hand '
10
+ + 'without a release link and links no code, so it shipped no release AGL knows of. Closed holds work that ships no code. '
11
+ + 'Move it back once it has a release link.';
12
+
13
+ /** Who the migration's history entries name. */
14
+ export const ticketClosedColumnMigrationActor: ITicketActor = { id: 'agl:migration', name: 'AGL migration (AGL-916)', role: 'driver' };
15
+
16
+ /**
17
+ * AGL-916: released requires a release link now. A ticket released by hand without one and without any code link
18
+ * shipped no release AGL knows of: it moves to `closed`, the column for work that ships no code, after the tickets
19
+ * already there, in its released order, with a `moved` entry in its history and a comment saying why. A ticket that
20
+ * links code stays: the release reconciler links it from the remote tag that holds its landing. It runs once: its
21
+ * marker is written in the same transaction, and a later start does nothing whatever the board holds.
22
+ */
23
+ export class TicketClosedColumnV41Migration {
24
+ constructor(private readonly database: plugins.nosqldb.SmartdataDb | undefined) {}
25
+
26
+ public async run(): Promise<string[]> {
27
+ if (!this.database) throw new AuthError('not_initialized', 'The authentication store database is unavailable.');
28
+ if (await TicketMigrationMarkerModel.exact.findStoredOne({ id: ticketClosedColumnMigrationId })) return [];
29
+ const session = this.database.createSession();
30
+ try {
31
+ return (await session.withTransaction(async (transactionArg) => {
32
+ if (await TicketMigrationMarkerModel.exact.findStoredOne({ id: ticketClosedColumnMigrationId }, { session: transactionArg })) return [];
33
+ const now = new Date().toISOString();
34
+ const marker = async (ticketsArg: string[]) => {
35
+ const inserted = await TicketMigrationMarkerModel.exact.insert({ id: ticketClosedColumnMigrationId, completedAt: now, tickets: ticketsArg },
36
+ { session: transactionArg });
37
+ if (inserted.status !== 'inserted') throw new AuthError('concurrent_change', 'The closed-column migration ran twice.');
38
+ };
39
+ const released = await this.page({ 'ticket.columnId': 'released' }, transactionArg);
40
+ const moving = released.filter((recordArg) => !recordArg.ticket.links.some((linkArg) => (
41
+ linkArg.kind === 'release' || linkArg.kind === 'branch' || linkArg.kind === 'commit')))
42
+ .sort((leftArg, rightArg) => leftArg.ticket.order - rightArg.ticket.order);
43
+ if (!moving.length) { await marker([]); return []; }
44
+ const board = await TicketBoardModel.exact.findStoredOne({ id: 'global' }, { session: transactionArg });
45
+ if (!board) throw new AuthError('not_initialized', 'The ticket board is unavailable.');
46
+ const fenced = await TicketBoardModel.exact.transition({ current: board, change: (modelArg) => { modelArg.revision += 1; } },
47
+ { session: transactionArg });
48
+ if (fenced.status !== 'transitioned') throw new AuthError('concurrent_change', 'The ticket board changed during the closed-column migration.');
49
+ const revision = board.revision + 1;
50
+ let order = (await this.page({ 'ticket.columnId': 'closed' }, transactionArg)).length;
51
+ for (const current of moving) {
52
+ const before = { columnId: current.ticket.columnId, order: current.ticket.order };
53
+ const after = { columnId: 'closed' as const, order: order++ };
54
+ const moved = await TicketModel.exact.transition({ current, change: (modelArg) => {
55
+ modelArg.ticket = { ...modelArg.ticket, ...after, revision: (modelArg.ticket.revision ?? 0) + 1,
56
+ updatedBy: ticketClosedColumnMigrationActor, updatedAt: now };
57
+ } }, { session: transactionArg });
58
+ if (moved.status !== 'transitioned') throw new AuthError('concurrent_change', 'A ticket changed during the closed-column migration.');
59
+ // The history lists one revision's entries by id: the move sorts before the comment that says why.
60
+ const [id, noteId] = [plugins.crypto.randomUUID(), plugins.crypto.randomUUID()].sort()
61
+ .map((uuidArg) => `${String(revision).padStart(16, '0')}:${uuidArg}`) as [string, string];
62
+ const activity: ITicketActivity = { id, ticketId: current.id, actor: ticketClosedColumnMigrationActor, createdAt: now, action: 'moved',
63
+ changes: { columnId: { before: before.columnId, after: after.columnId }, order: { before: before.order, after: after.order } } };
64
+ const inserted = await TicketActivityModel.exact.insert({ id, ticketId: current.id, activity }, { session: transactionArg });
65
+ if (inserted.status !== 'inserted') throw new AuthError('concurrent_change', 'Ticket activity identity conflict during the closed-column migration.');
66
+ const commentId = `${String(revision).padStart(16, '0')}:${plugins.crypto.randomUUID()}`;
67
+ const comment: ITicketComment = { id: commentId, ticketId: current.id, author: ticketClosedColumnMigrationActor, createdAt: now,
68
+ body: [{ type: 'text', text: ticketClosedColumnMigrationNote }] };
69
+ const commented = await TicketCommentModel.exact.insert({ id: commentId, ticketId: current.id, comment }, { session: transactionArg });
70
+ if (commented.status !== 'inserted') throw new AuthError('concurrent_change', 'Ticket comment identity conflict during the closed-column migration.');
71
+ const note: ITicketActivity = { id: noteId, ticketId: current.id, actor: ticketClosedColumnMigrationActor, createdAt: now, action: 'commented',
72
+ changes: { comment: { after: comment } } };
73
+ const noted = await TicketActivityModel.exact.insert({ id: noteId, ticketId: current.id, activity: note }, { session: transactionArg });
74
+ if (noted.status !== 'inserted') throw new AuthError('concurrent_change', 'Ticket activity identity conflict during the closed-column migration.');
75
+ }
76
+ // The released column keeps its order without gaps.
77
+ let releasedOrder = 0;
78
+ for (const current of released.filter((recordArg) => !moving.includes(recordArg)).sort((leftArg, rightArg) => leftArg.ticket.order - rightArg.ticket.order)) {
79
+ const next = releasedOrder++;
80
+ if (current.ticket.order === next) continue;
81
+ const reordered = await TicketModel.exact.transition({ current, change: (modelArg) => {
82
+ modelArg.ticket = { ...modelArg.ticket, order: next, revision: (modelArg.ticket.revision ?? 0) + 1 };
83
+ } }, { session: transactionArg });
84
+ if (reordered.status !== 'transitioned') throw new AuthError('concurrent_change', 'A ticket changed during the closed-column migration.');
85
+ }
86
+ const moved = moving.map((recordArg) => recordArg.id);
87
+ await marker(moved);
88
+ return moved;
89
+ }, { timeoutMS: 60_000 })) ?? [];
90
+ } finally {
91
+ await session.close();
92
+ }
93
+ }
94
+
95
+ private async page(filterArg: Record<string, unknown>, sessionArg: plugins.nosqldb.SmartdataSession) {
96
+ const records = [] as Awaited<ReturnType<typeof TicketModel.exact.findStored>>;
97
+ let after: string | undefined;
98
+ while (true) {
99
+ const page = await TicketModel.exact.findStored({ filter: { ...filterArg, ...(after ? { id: { $gt: after } } : {}) },
100
+ sort: { id: 1 }, limit: 500, session: sessionArg });
101
+ records.push(...page);
102
+ if (page.length < 500) return records;
103
+ after = page.at(-1)!.id;
104
+ }
105
+ }
106
+ }
@@ -0,0 +1,91 @@
1
+ import * as plugins from './plugins.js';
2
+ import { TicketActivityModel, TicketBoardModel, TicketModel } from '../ts/classes.ticketmodels.js';
3
+ import { AuthError } from '../ts/interfaces.auth.js';
4
+ import type { ITicketActivity, ITicketActor, TTicketData, TTicketLink } from '../ts_interfaces/tickets.js';
5
+ import { TicketMigrationMarkerModel } from './v41_ticketmigrationmarkers.js';
6
+
7
+ export const ticketLinkReposMigrationId = 'v41_ticketlinkrepos';
8
+ /** Who the migration's history entries name. */
9
+ export const ticketLinkReposMigrationActor: ITicketActor = { id: 'agl:migration', name: 'AGL migration (AGL-909)', role: 'driver' };
10
+
11
+ /**
12
+ * AGL-909: a repository is named one way, `org/name`. Links and release plans written by hand or by an earlier fleet
13
+ * name it by its fleet id (the bare directory name, which another checkout may later share) or by its checkout path.
14
+ * Once, every name `resolveArg` resolves to exactly one discovered repository is rewritten to its `org/name`, with an
15
+ * `updated` entry in the ticket's history; a name it cannot resolve (another host's path, a name several checkouts
16
+ * share) stays as it is, and every reader still resolves it. The marker is written in the same transaction. A start whose
17
+ * discovery found no repository (the workspace roots unreadable, say) runs nothing and writes no marker: a later start
18
+ * runs it again.
19
+ */
20
+ export class TicketLinkReposV41Migration {
21
+ constructor(private readonly database: plugins.nosqldb.SmartdataDb | undefined,
22
+ private readonly resolve: (nameArg: string) => string | undefined, private readonly discovered: number) {}
23
+
24
+ public async run(): Promise<string[]> {
25
+ if (!this.database) throw new AuthError('not_initialized', 'The authentication store database is unavailable.');
26
+ if (this.discovered === 0) return [];
27
+ if (await TicketMigrationMarkerModel.exact.findStoredOne({ id: ticketLinkReposMigrationId })) return [];
28
+ const session = this.database.createSession();
29
+ try {
30
+ return (await session.withTransaction(async (transactionArg) => {
31
+ if (await TicketMigrationMarkerModel.exact.findStoredOne({ id: ticketLinkReposMigrationId }, { session: transactionArg })) return [];
32
+ const board = await TicketBoardModel.exact.findStoredOne({ id: 'global' }, { session: transactionArg });
33
+ if (!board) throw new AuthError('not_initialized', 'The ticket board is unavailable.');
34
+ const fenced = await TicketBoardModel.exact.transition({ current: board, change: (modelArg) => { modelArg.revision += 1; } },
35
+ { session: transactionArg });
36
+ if (fenced.status !== 'transitioned') throw new AuthError('concurrent_change', 'The ticket board changed during the link migration.');
37
+ const revision = board.revision + 1;
38
+ const now = new Date().toISOString();
39
+ const changed: string[] = [];
40
+ for (const current of await this.page(transactionArg)) {
41
+ const next = this.normalized(current.ticket);
42
+ if (!next) continue;
43
+ const moved = await TicketModel.exact.transition({ current, change: (modelArg) => {
44
+ modelArg.ticket = { ...next, revision: (modelArg.ticket.revision ?? 0) + 1, updatedBy: ticketLinkReposMigrationActor, updatedAt: now };
45
+ } }, { session: transactionArg });
46
+ if (moved.status !== 'transitioned') throw new AuthError('concurrent_change', 'A ticket changed during the link migration.');
47
+ const changes: ITicketActivity['changes'] = {};
48
+ if (JSON.stringify(next.links) !== JSON.stringify(current.ticket.links)) changes.links = { before: current.ticket.links, after: next.links };
49
+ if (JSON.stringify(next.releasePlan) !== JSON.stringify(current.ticket.releasePlan)) {
50
+ changes.releasePlan = { before: current.ticket.releasePlan, after: next.releasePlan };
51
+ }
52
+ const id = `${String(revision).padStart(16, '0')}:${plugins.crypto.randomUUID()}`;
53
+ const activity: ITicketActivity = { id, ticketId: current.id, actor: ticketLinkReposMigrationActor, createdAt: now, action: 'updated', changes };
54
+ const inserted = await TicketActivityModel.exact.insert({ id, ticketId: current.id, activity }, { session: transactionArg });
55
+ if (inserted.status !== 'inserted') throw new AuthError('concurrent_change', 'Ticket activity identity conflict during the link migration.');
56
+ changed.push(current.ticket.key);
57
+ }
58
+ const marker = await TicketMigrationMarkerModel.exact.insert({ id: ticketLinkReposMigrationId, completedAt: now, tickets: changed },
59
+ { session: transactionArg });
60
+ if (marker.status !== 'inserted') throw new AuthError('concurrent_change', 'The link migration ran twice.');
61
+ return changed;
62
+ }, { timeoutMS: 60_000 })) ?? [];
63
+ } finally {
64
+ await session.close();
65
+ }
66
+ }
67
+
68
+ /** The ticket with every repository it names as `org/name` where that resolves; undefined when nothing changes. */
69
+ private normalized(ticketArg: TTicketData): TTicketData | undefined {
70
+ const name = (valueArg: string) => this.resolve(valueArg) ?? valueArg;
71
+ const links = ticketArg.links.map((linkArg): TTicketLink => (
72
+ linkArg.kind === 'release' ? (linkArg.repo === undefined ? linkArg : { ...linkArg, repo: name(linkArg.repo) }) : { ...linkArg, repo: name(linkArg.repo) }
73
+ ));
74
+ // Two links that now name one repository the same way are one link.
75
+ const unique = links.filter((linkArg, indexArg) => links.findIndex((otherArg) => JSON.stringify(otherArg) === JSON.stringify(linkArg)) === indexArg);
76
+ const next: TTicketData = { ...ticketArg, links: unique,
77
+ ...(ticketArg.releasePlan ? { releasePlan: { ...ticketArg.releasePlan, repo: name(ticketArg.releasePlan.repo) } } : {}) };
78
+ return JSON.stringify(next) === JSON.stringify(ticketArg) ? undefined : next;
79
+ }
80
+
81
+ private async page(sessionArg: plugins.nosqldb.SmartdataSession) {
82
+ const records = [] as Awaited<ReturnType<typeof TicketModel.exact.findStored>>;
83
+ let after: string | undefined;
84
+ while (true) {
85
+ const page = await TicketModel.exact.findStored({ filter: after ? { id: { $gt: after } } : {}, sort: { id: 1 }, limit: 500, session: sessionArg });
86
+ records.push(...page);
87
+ if (page.length < 500) return records;
88
+ after = page.at(-1)!.id;
89
+ }
90
+ }
91
+ }
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '42.2.2',
6
+ version: '43.0.0',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }