@aviaratech/ai-delivery 0.3.35 → 0.3.37

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 (301) hide show
  1. package/CONTRIBUTING.md +12 -206
  2. package/README.md +56 -554
  3. package/dist/agent.d.ts +1 -3
  4. package/dist/agent.js +74 -16
  5. package/dist/agent.js.map +7 -1
  6. package/dist/agentReadiness.test.js +73 -67
  7. package/dist/agentReadiness.test.js.map +7 -1
  8. package/dist/boardReconcile.test.js +1651 -1590
  9. package/dist/boardReconcile.test.js.map +7 -1
  10. package/dist/build.test.js +130 -0
  11. package/dist/build.test.js.map +7 -0
  12. package/dist/callerErrors.test.js +91 -0
  13. package/dist/callerErrors.test.js.map +7 -0
  14. package/dist/cli.js +389 -517
  15. package/dist/cli.js.map +7 -1
  16. package/dist/cliResult.d.ts +2 -2
  17. package/dist/cliResult.js +42 -45
  18. package/dist/cliResult.js.map +7 -1
  19. package/dist/cliResult.test.js +424 -369
  20. package/dist/cliResult.test.js.map +7 -1
  21. package/dist/config/deliveryConfig.d.ts +288 -14
  22. package/dist/config/deliveryConfig.js +472 -390
  23. package/dist/config/deliveryConfig.js.map +7 -1
  24. package/dist/config/deliveryConfig.test.js +773 -649
  25. package/dist/config/deliveryConfig.test.js.map +7 -1
  26. package/dist/contributorChecks.test.js +1694 -916
  27. package/dist/contributorChecks.test.js.map +7 -1
  28. package/dist/currentConsumer.test.js +819 -737
  29. package/dist/currentConsumer.test.js.map +7 -1
  30. package/dist/currentTrackingScenario.test.js +499 -479
  31. package/dist/currentTrackingScenario.test.js.map +7 -1
  32. package/dist/delivery/common.js +160 -172
  33. package/dist/delivery/common.js.map +7 -1
  34. package/dist/delivery/delivery.test.js +509 -431
  35. package/dist/delivery/delivery.test.js.map +7 -1
  36. package/dist/delivery/evidence.d.ts +2 -2
  37. package/dist/delivery/evidence.js +133 -120
  38. package/dist/delivery/evidence.js.map +7 -1
  39. package/dist/delivery/index.js +7 -2
  40. package/dist/delivery/index.js.map +7 -1
  41. package/dist/delivery/legacy.js +65 -5
  42. package/dist/delivery/legacy.js.map +7 -1
  43. package/dist/delivery/policy.d.ts +10 -10
  44. package/dist/delivery/policy.js +211 -238
  45. package/dist/delivery/policy.js.map +7 -1
  46. package/dist/delivery/stage.d.ts +18 -18
  47. package/dist/delivery/stage.js +220 -235
  48. package/dist/delivery/stage.js.map +7 -1
  49. package/dist/deliveryBoard.d.ts +74 -0
  50. package/dist/deliveryBoard.js +644 -0
  51. package/dist/deliveryBoard.js.map +7 -0
  52. package/dist/deliveryBoard.test.js +649 -0
  53. package/dist/deliveryBoard.test.js.map +7 -0
  54. package/dist/deliveryHealth.test.js +179 -155
  55. package/dist/deliveryHealth.test.js.map +7 -1
  56. package/dist/dependencyCompatibility.test.js +154 -140
  57. package/dist/dependencyCompatibility.test.js.map +7 -1
  58. package/dist/directoryIndependent.test.js +417 -383
  59. package/dist/directoryIndependent.test.js.map +7 -1
  60. package/dist/dispatch.d.ts +16 -11
  61. package/dist/dispatch.js +316 -354
  62. package/dist/dispatch.js.map +7 -1
  63. package/dist/errors.d.ts +3 -3
  64. package/dist/errors.js +103 -96
  65. package/dist/errors.js.map +7 -1
  66. package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
  67. package/dist/fixtures/deliveryBoardReplay.js +617 -0
  68. package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
  69. package/dist/fixtures/discovery.d.ts +63 -23
  70. package/dist/fixtures/discovery.js +96 -90
  71. package/dist/fixtures/discovery.js.map +7 -1
  72. package/dist/fixtures/inertEntrypointChild.js +57 -56
  73. package/dist/fixtures/inertEntrypointChild.js.map +7 -1
  74. package/dist/fixtures/inertEntrypoints.d.ts +1 -1
  75. package/dist/fixtures/inertEntrypoints.js +321 -276
  76. package/dist/fixtures/inertEntrypoints.js.map +7 -1
  77. package/dist/fixtures/inertTarget.d.ts +78 -7
  78. package/dist/fixtures/inertTarget.js +769 -691
  79. package/dist/fixtures/inertTarget.js.map +7 -1
  80. package/dist/fixtures/issue63.d.ts +4 -3
  81. package/dist/fixtures/issue63.js +260 -274
  82. package/dist/fixtures/issue63.js.map +7 -1
  83. package/dist/fixtures/issueProjectItems.d.ts +20 -0
  84. package/dist/fixtures/issueProjectItems.js +15 -0
  85. package/dist/fixtures/issueProjectItems.js.map +7 -0
  86. package/dist/fixtures/readView.d.ts +120 -0
  87. package/dist/fixtures/readView.js +172 -0
  88. package/dist/fixtures/readView.js.map +7 -0
  89. package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
  90. package/dist/fixtures/recordedGitHubFlows.js +109 -0
  91. package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
  92. package/dist/genericCompatibility.test.js +64 -55
  93. package/dist/genericCompatibility.test.js.map +7 -1
  94. package/dist/git.d.ts +0 -3
  95. package/dist/git.js +59 -76
  96. package/dist/git.js.map +7 -1
  97. package/dist/gitProcess.d.ts +1 -1
  98. package/dist/gitProcess.js +58 -53
  99. package/dist/gitProcess.js.map +7 -1
  100. package/dist/github/client.d.ts +2 -2
  101. package/dist/github/client.js +484 -379
  102. package/dist/github/client.js.map +7 -1
  103. package/dist/github/commandIdentityPolicy.js +42 -52
  104. package/dist/github/commandIdentityPolicy.js.map +7 -1
  105. package/dist/github/discovery.d.ts +1 -0
  106. package/dist/github/discovery.js +197 -215
  107. package/dist/github/discovery.js.map +7 -1
  108. package/dist/github/discovery.test.js +223 -177
  109. package/dist/github/discovery.test.js.map +7 -1
  110. package/dist/github/issueHistory.d.ts +2 -2
  111. package/dist/github/issueHistory.js +117 -125
  112. package/dist/github/issueHistory.js.map +7 -1
  113. package/dist/github/machineAuth.d.ts +1 -1
  114. package/dist/github/machineAuth.js +126 -117
  115. package/dist/github/machineAuth.js.map +7 -1
  116. package/dist/github/machineAuth.test.js +755 -639
  117. package/dist/github/machineAuth.test.js.map +7 -1
  118. package/dist/github/nativeIssueMetadata.js +286 -273
  119. package/dist/github/nativeIssueMetadata.js.map +7 -1
  120. package/dist/github/projectDelivery.d.ts +18 -2
  121. package/dist/github/projectDelivery.js +615 -557
  122. package/dist/github/projectDelivery.js.map +7 -1
  123. package/dist/github/relationships.js +433 -389
  124. package/dist/github/relationships.js.map +7 -1
  125. package/dist/github/repo.d.ts +1 -0
  126. package/dist/github/repo.js +123 -96
  127. package/dist/github/repo.js.map +7 -1
  128. package/dist/index.js +3 -3
  129. package/dist/index.js.map +7 -1
  130. package/dist/issue.d.ts +40 -9
  131. package/dist/issue.js +2102 -1742
  132. package/dist/issue.js.map +7 -1
  133. package/dist/issue63History.test.js +40 -42
  134. package/dist/issue63History.test.js.map +7 -1
  135. package/dist/issue63Routes.test.js +154 -143
  136. package/dist/issue63Routes.test.js.map +7 -1
  137. package/dist/issueBatchUpdate.test.js +989 -885
  138. package/dist/issueBatchUpdate.test.js.map +7 -1
  139. package/dist/issueBlockerGuard.test.js +262 -226
  140. package/dist/issueBlockerGuard.test.js.map +7 -1
  141. package/dist/issueContract.d.ts +23 -4
  142. package/dist/issueContract.js +416 -395
  143. package/dist/issueContract.js.map +7 -1
  144. package/dist/issueContract.test.d.ts +4 -3
  145. package/dist/issueContract.test.js +358 -321
  146. package/dist/issueContract.test.js.map +7 -1
  147. package/dist/issueDates.test.js +235 -233
  148. package/dist/issueDates.test.js.map +7 -1
  149. package/dist/issueInfoReadback.test.js +304 -190
  150. package/dist/issueInfoReadback.test.js.map +7 -1
  151. package/dist/issueIntake.test.js +1938 -1732
  152. package/dist/issueIntake.test.js.map +7 -1
  153. package/dist/issueJournal.d.ts +40 -19
  154. package/dist/issueJournal.js +229 -138
  155. package/dist/issueJournal.js.map +7 -1
  156. package/dist/issueJournal.test.js +605 -422
  157. package/dist/issueJournal.test.js.map +7 -1
  158. package/dist/issueRollup.test.d.ts +1 -0
  159. package/dist/issueRollup.test.js +476 -0
  160. package/dist/issueRollup.test.js.map +7 -0
  161. package/dist/issueTracking.test.js +1059 -989
  162. package/dist/issueTracking.test.js.map +7 -1
  163. package/dist/issueWriteRecovery.test.d.ts +1 -0
  164. package/dist/issueWriteRecovery.test.js +260 -0
  165. package/dist/issueWriteRecovery.test.js.map +7 -0
  166. package/dist/lifecycle.test.js +112 -441
  167. package/dist/lifecycle.test.js.map +7 -1
  168. package/dist/logger.js +80 -74
  169. package/dist/logger.js.map +7 -1
  170. package/dist/mcp/index.js +116 -94
  171. package/dist/mcp/index.js.map +7 -1
  172. package/dist/mcp/tools.d.ts +252 -310
  173. package/dist/mcp/tools.js +235 -342
  174. package/dist/mcp/tools.js.map +7 -1
  175. package/dist/pluginAuthProbe.js +63 -52
  176. package/dist/pluginAuthProbe.js.map +7 -1
  177. package/dist/pluginAuthProbe.test.js +85 -62
  178. package/dist/pluginAuthProbe.test.js.map +7 -1
  179. package/dist/pluginCredentials.test.js +282 -259
  180. package/dist/pluginCredentials.test.js.map +7 -1
  181. package/dist/pluginDoctor.test.js +653 -588
  182. package/dist/pluginDoctor.test.js.map +7 -1
  183. package/dist/pluginInstaller.d.ts +7 -5
  184. package/dist/pluginInstaller.js +1173 -1229
  185. package/dist/pluginInstaller.js.map +7 -1
  186. package/dist/pluginInstaller.test.js +1842 -1423
  187. package/dist/pluginInstaller.test.js.map +7 -1
  188. package/dist/pluginPackaging.test.js +417 -413
  189. package/dist/pluginPackaging.test.js.map +7 -1
  190. package/dist/pr.d.ts +114 -131
  191. package/dist/pr.js +1314 -1327
  192. package/dist/pr.js.map +7 -1
  193. package/dist/pr.test.js +967 -653
  194. package/dist/pr.test.js.map +7 -1
  195. package/dist/prAssociation.test.js +2419 -1788
  196. package/dist/prAssociation.test.js.map +7 -1
  197. package/dist/prDispatch.test.js +123 -89
  198. package/dist/prDispatch.test.js.map +7 -1
  199. package/dist/readView.d.ts +184 -0
  200. package/dist/readView.js +218 -0
  201. package/dist/readView.js.map +7 -0
  202. package/dist/readView.test.d.ts +1 -0
  203. package/dist/readView.test.js +146 -0
  204. package/dist/readView.test.js.map +7 -0
  205. package/dist/releaseReconciliation.test.js +267 -288
  206. package/dist/releaseReconciliation.test.js.map +7 -1
  207. package/dist/releaseWorkflow.test.js +2493 -422
  208. package/dist/releaseWorkflow.test.js.map +7 -1
  209. package/dist/review.d.ts +738 -2
  210. package/dist/review.js +601 -348
  211. package/dist/review.js.map +7 -1
  212. package/dist/review.test.js +1218 -812
  213. package/dist/review.test.js.map +7 -1
  214. package/dist/reviewSubmit.test.d.ts +1 -0
  215. package/dist/reviewSubmit.test.js +747 -0
  216. package/dist/reviewSubmit.test.js.map +7 -0
  217. package/dist/services/agentReadinessService.js +42 -37
  218. package/dist/services/agentReadinessService.js.map +7 -1
  219. package/dist/services/blockerGuardService.js +188 -188
  220. package/dist/services/blockerGuardService.js.map +7 -1
  221. package/dist/services/boardReconcileService.d.ts +125 -125
  222. package/dist/services/boardReconcileService.js +1295 -1421
  223. package/dist/services/boardReconcileService.js.map +7 -1
  224. package/dist/services/deliveryHealthService.js +197 -199
  225. package/dist/services/deliveryHealthService.js.map +7 -1
  226. package/dist/services/legacyIssueMigration.js +263 -277
  227. package/dist/services/legacyIssueMigration.js.map +7 -1
  228. package/dist/stagedChecks.test.js +396 -194
  229. package/dist/stagedChecks.test.js.map +7 -1
  230. package/dist/start.test.js +99 -95
  231. package/dist/start.test.js.map +7 -1
  232. package/dist/stdoutRegression.test.js +321 -358
  233. package/dist/stdoutRegression.test.js.map +7 -1
  234. package/dist/targetPolicyDiscovery.test.js +141 -143
  235. package/dist/targetPolicyDiscovery.test.js.map +7 -1
  236. package/dist/targetPolicyEntrypoints.test.js +308 -269
  237. package/dist/targetPolicyEntrypoints.test.js.map +7 -1
  238. package/dist/targetPolicyLocal.test.js +580 -1051
  239. package/dist/targetPolicyLocal.test.js.map +7 -1
  240. package/dist/targetPolicyRoutes.test.js +274 -281
  241. package/dist/targetPolicyRoutes.test.js.map +7 -1
  242. package/dist/targetRepositoryExecution.test.d.ts +1 -0
  243. package/dist/targetRepositoryExecution.test.js +451 -0
  244. package/dist/targetRepositoryExecution.test.js.map +7 -0
  245. package/dist/terminalMessages.js +41 -35
  246. package/dist/terminalMessages.js.map +7 -1
  247. package/dist/toolOutput.d.ts +2 -0
  248. package/dist/toolOutput.js +36 -0
  249. package/dist/toolOutput.js.map +7 -0
  250. package/dist/toolOutput.test.d.ts +1 -0
  251. package/dist/toolOutput.test.js +240 -0
  252. package/dist/toolOutput.test.js.map +7 -0
  253. package/dist/utils/atomicJson.d.ts +0 -2
  254. package/dist/utils/atomicJson.js +81 -77
  255. package/dist/utils/atomicJson.js.map +7 -1
  256. package/dist/utils/filesystem.d.ts +0 -8
  257. package/dist/utils/filesystem.js +5 -19
  258. package/dist/utils/filesystem.js.map +7 -1
  259. package/dist/utils/lockfile.js +68 -71
  260. package/dist/utils/lockfile.js.map +7 -1
  261. package/dist/verification.d.ts +1 -54
  262. package/dist/verification.js +976 -1941
  263. package/dist/verification.js.map +7 -1
  264. package/dist/verificationGate.test.js +127 -117
  265. package/dist/verificationGate.test.js.map +7 -1
  266. package/dist/version.js +45 -24
  267. package/dist/version.js.map +7 -1
  268. package/package.json +9 -8
  269. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  270. package/plugins/ai-delivery/README.md +47 -156
  271. package/plugins/ai-delivery/plugin.json +1 -1
  272. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
  273. package/plugins/ai-delivery/runtime/dist/cli.js +351 -115
  274. package/plugins/ai-delivery/runtime/package.json +1 -1
  275. package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
  276. package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
  277. package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
  278. package/dist/investigationCompletion.test.js +0 -728
  279. package/dist/investigationCompletion.test.js.map +0 -1
  280. package/dist/services/deliveryAdmission.d.ts +0 -49
  281. package/dist/services/deliveryAdmission.js +0 -165
  282. package/dist/services/deliveryAdmission.js.map +0 -1
  283. package/dist/services/worktreeRegistry.d.ts +0 -434
  284. package/dist/services/worktreeRegistry.js +0 -1248
  285. package/dist/services/worktreeRegistry.js.map +0 -1
  286. package/dist/setup.d.ts +0 -60
  287. package/dist/setup.js +0 -585
  288. package/dist/setup.js.map +0 -1
  289. package/dist/setup.test.js +0 -3329
  290. package/dist/setup.test.js.map +0 -1
  291. package/dist/worktree.d.ts +0 -28
  292. package/dist/worktree.js +0 -188
  293. package/dist/worktree.js.map +0 -1
  294. package/dist/worktreeTransition.d.ts +0 -211
  295. package/dist/worktreeTransition.js +0 -1037
  296. package/dist/worktreeTransition.js.map +0 -1
  297. package/dist/worktreeTransition.test.js +0 -1191
  298. package/dist/worktreeTransition.test.js.map +0 -1
  299. /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
  300. /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
  301. /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
@@ -1,492 +1,512 @@
1
- import assert from 'node:assert/strict';
2
- import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { join } from 'node:path';
5
- import { Client } from '@modelcontextprotocol/sdk/client/index.js';
6
- import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
7
- import { test, vi } from 'vitest';
8
- import * as githubClients from './github/client.js';
9
- import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from './fixtures/discovery.js';
10
- import { createAiDeliveryMcpServer } from './mcp/index.js';
11
- import { canonicalIssueBody } from './issue.js';
12
- // Only the external GitHub/auth port is replaced. Reads reflect stored writes;
13
- // unexpected endpoints and foreign targets fail instead of returning canned success.
1
+ import { issueProjectItemsResponse } from "./fixtures/issueProjectItems.js";
2
+ import assert from "node:assert/strict";
3
+ import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
7
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
8
+ import { test, vi } from "vitest";
9
+ import * as githubClients from "./github/client.js";
10
+ import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from "./fixtures/discovery.js";
11
+ import { createAiDeliveryMcpServer } from "./mcp/index.js";
12
+ import { canonicalIssueBody } from "./issue.js";
14
13
  function trackingRepository() {
15
- const issues = new Map();
16
- const comments = [];
17
- const events = [];
18
- let writes = 0;
19
- const add = (number, title, body, parent) => {
20
- const value = {
21
- number,
22
- id: 100 + number,
23
- node_id: `ISSUE${String(number)}`,
24
- title,
25
- body,
26
- state: 'open',
27
- type: { name: 'Task' },
28
- labels: [],
29
- html_url: `https://github.com/example/widget/issues/${String(number)}`,
30
- updated_at: '2026-10-07T00:00:00Z',
31
- parent,
32
- status: parent === null ? null : 'Active',
33
- reason: null,
34
- ...(parent === null ? {} : { points: 2, priority: 'High' }),
35
- };
36
- issues.set(number, value);
37
- return value;
38
- };
39
- add(10, 'Original tracking parent', 'Original unsized parent', null);
40
- add(20, 'Replacement tracking parent', 'Replacement unsized parent', null);
41
- add(17, ' Legacy <tracking> & title\r\n', '\nLegacy & backlog <tag>\t \r\n', 10);
42
- add(18, 'Second tracking issue', canonicalIssueBody({
43
- title: 'Second tracking issue',
44
- issueType: 'Task',
45
- points: 2,
46
- problem: 'A second executable issue needs a new parent.',
47
- outcome: 'The issue retains its contract when reparented.',
48
- acceptanceCriteria: [
49
- {
50
- behavior: 'A parent update returns the new native parent.',
51
- verifiedBy: 'The scenario checks persisted parent membership.',
52
- },
53
- ],
54
- outOfScope: ['Changing the executable work.'],
55
- openQuestions: [],
56
- draft: false,
57
- }), 10);
58
- const get = (number) => {
59
- assert.equal(typeof number, 'number');
60
- const issue = issues.get(number);
61
- assert.ok(issue, `Unknown synthetic issue ${String(number)}`);
62
- return issue;
14
+ const issues = /* @__PURE__ */ new Map();
15
+ const comments = [];
16
+ const events = [];
17
+ let writes = 0;
18
+ const add = (number, title, body, parent) => {
19
+ const value = {
20
+ number,
21
+ id: 100 + number,
22
+ node_id: `ISSUE${String(number)}`,
23
+ title,
24
+ body,
25
+ state: "open",
26
+ type: { name: "Task" },
27
+ labels: [],
28
+ html_url: `https://github.com/example/widget/issues/${String(number)}`,
29
+ url: `https://api.github.com/repos/example/widget/issues/${String(number)}`,
30
+ repository_url: "https://api.github.com/repos/example/widget",
31
+ updated_at: "2026-10-07T00:00:00Z",
32
+ parent,
33
+ status: parent === null ? null : "Active",
34
+ reason: null,
35
+ ...parent === null ? {} : { points: 2, priority: "High" }
63
36
  };
64
- const target = (input) => {
65
- if ('owner' in input)
66
- assert.equal(input.owner, 'example');
67
- if ('repo' in input)
68
- assert.equal(input.repo, 'widget');
69
- if ('name' in input)
70
- assert.equal(input.name, 'widget');
71
- if ('org' in input)
72
- assert.equal(input.org, 'example');
73
- };
74
- const mutation = (event) => {
75
- writes += 1;
76
- events.push(event);
77
- };
78
- const values = (issue) => [
79
- ...(issue.points === undefined
80
- ? []
81
- : [
82
- {
83
- issue_field_id: 101,
84
- issue_field_name: 'Estimate',
85
- data_type: 'single_select',
86
- value: String(issue.points),
87
- single_select_option: { name: String(issue.points) },
88
- },
89
- ]),
90
- ...(issue.priority === undefined
91
- ? []
92
- : [
93
- {
94
- issue_field_id: 102,
95
- issue_field_name: 'Urgency',
96
- data_type: 'single_select',
97
- value: issue.priority,
98
- single_select_option: { name: issue.priority },
99
- },
100
- ]),
101
- ];
102
- const listSubIssues = async (input) => {
37
+ issues.set(number, value);
38
+ return value;
39
+ };
40
+ add(10, "Original tracking parent", "Original unsized parent", null);
41
+ add(20, "Replacement tracking parent", "Replacement unsized parent", null);
42
+ add(17, " Legacy <tracking> & title\r\n", "\nLegacy & backlog <tag> \r\n", 10);
43
+ add(
44
+ 18,
45
+ "Second tracking issue",
46
+ canonicalIssueBody({
47
+ title: "Second tracking issue",
48
+ issueType: "Task",
49
+ points: 2,
50
+ problem: "A second executable issue needs a new parent.",
51
+ outcome: "The issue retains its contract when reparented.",
52
+ acceptanceCriteria: [
53
+ {
54
+ behavior: "A parent update returns the new native parent.",
55
+ verifiedBy: "The scenario checks persisted parent membership."
56
+ }
57
+ ],
58
+ outOfScope: ["Changing the executable work."],
59
+ openQuestions: [],
60
+ draft: false
61
+ }),
62
+ 10
63
+ );
64
+ const get = (number) => {
65
+ assert.equal(typeof number, "number");
66
+ const issue = issues.get(number);
67
+ assert.ok(issue, `Unknown synthetic issue ${String(number)}`);
68
+ return issue;
69
+ };
70
+ const target = (input) => {
71
+ if ("owner" in input) assert.equal(input.owner, "example");
72
+ if ("repo" in input) assert.equal(input.repo, "widget");
73
+ if ("name" in input) assert.equal(input.name, "widget");
74
+ if ("org" in input) assert.equal(input.org, "example");
75
+ };
76
+ const mutation = (event) => {
77
+ writes += 1;
78
+ events.push(event);
79
+ };
80
+ const values = (issue) => [
81
+ ...issue.points === void 0 ? [] : [
82
+ {
83
+ issue_field_id: 101,
84
+ issue_field_name: "Estimate",
85
+ data_type: "single_select",
86
+ value: String(issue.points),
87
+ single_select_option: { name: String(issue.points) }
88
+ }
89
+ ],
90
+ ...issue.priority === void 0 ? [] : [
91
+ {
92
+ issue_field_id: 102,
93
+ issue_field_name: "Urgency",
94
+ data_type: "single_select",
95
+ value: issue.priority,
96
+ single_select_option: { name: issue.priority }
97
+ }
98
+ ]
99
+ ];
100
+ const listSubIssues = async (input) => {
101
+ target(input);
102
+ get(input.issue_number);
103
+ return { data: structuredClone([...issues.values()].filter((issue) => issue.parent === input.issue_number)) };
104
+ };
105
+ const rest = {
106
+ issues: {
107
+ get: async (input) => {
103
108
  target(input);
104
- get(input.issue_number);
105
- return { data: structuredClone([...issues.values()].filter((issue) => issue.parent === input.issue_number)) };
106
- };
107
- const rest = {
108
- issues: {
109
- get: async (input) => {
110
- target(input);
111
- return { data: structuredClone(get(input.issue_number)) };
112
- },
113
- listForRepo: async (input) => {
114
- target(input);
115
- assert.equal(input.page, 1);
116
- return {
117
- data: structuredClone([...issues.values()].filter((issue) => input.state === 'all' || issue.state === input.state)),
118
- };
119
- },
120
- listSubIssues,
121
- create: async (input) => {
122
- target(input);
123
- assert.equal(issues.has(31), false, 'the scenario creates exactly one child');
124
- assert.equal(input.type, 'Task');
125
- const issue = add(31, input.title, input.body, null);
126
- mutation('issue:create:31');
127
- return { data: structuredClone(issue) };
128
- },
129
- update: async (input) => {
130
- target(input);
131
- const issue = get(input.issue_number);
132
- for (const key of ['title', 'body', 'state'])
133
- if (typeof input[key] === 'string')
134
- issue[key] = input[key];
135
- if (typeof input.type === 'string')
136
- issue.type = { name: input.type };
137
- if (typeof input.state_reason === 'string')
138
- issue.reason = input.state_reason.toUpperCase();
139
- mutation(`issue:update:${String(issue.number)}`);
140
- return { data: structuredClone(issue) };
141
- },
142
- addSubIssue: async (input) => {
143
- target(input);
144
- const parent = get(input.issue_number);
145
- const child = [...issues.values()].find((issue) => issue.id === input.sub_issue_id);
146
- assert.ok(child);
147
- assert.equal(child.parent, null);
148
- child.parent = parent.number;
149
- mutation(`parent:add:${String(child.number)}:${String(parent.number)}`);
150
- return { data: structuredClone(child) };
151
- },
152
- removeSubIssue: async (input) => {
153
- target(input);
154
- const child = [...issues.values()].find((issue) => issue.id === input.sub_issue_id);
155
- assert.ok(child);
156
- assert.equal(child.parent, input.issue_number);
157
- child.parent = null;
158
- mutation(`parent:remove:${String(child.number)}`);
159
- return { data: structuredClone(child) };
160
- },
161
- listComments: async (input) => {
162
- target(input);
163
- const issue = get(input.issue_number);
164
- return {
165
- data: structuredClone(comments.filter((comment) => comment.issue_url.endsWith(`/issues/${String(issue.number)}`))),
166
- };
167
- },
168
- createComment: async (input) => {
169
- target(input);
170
- const issue = get(input.issue_number);
171
- const id = 101 + comments.length;
172
- const comment = {
173
- id,
174
- body: input.body,
175
- html_url: `${issue.html_url}#issuecomment-${String(id)}`,
176
- issue_url: `https://api.github.com/repos/example/widget/issues/${String(issue.number)}`,
177
- user: { login: 'operator' },
178
- };
179
- comments.push(comment);
180
- mutation(`comment:create:${String(id)}`);
181
- return { data: structuredClone(comment) };
182
- },
183
- getComment: async (input) => {
184
- target(input);
185
- const comment = comments.find((value) => value.id === input.comment_id);
186
- assert.ok(comment);
187
- events.push(`comment:read:${String(comment.id)}`);
188
- return { data: structuredClone(comment) };
189
- },
190
- },
191
- search: {
192
- issuesAndPullRequests: async (input) => {
193
- assert.equal(input.page, 1);
194
- assert.equal(typeof input.q, 'string');
195
- const match = /^repo:example\/widget is:issue "(Legacy|Replacement)"$/u.exec(input.q);
196
- assert.ok(match, 'search must retain repository and literal text boundaries');
197
- const items = [...issues.values()].filter((issue) => `${issue.title}\n${issue.body}`.includes(match[1]));
198
- return { data: { total_count: items.length, incomplete_results: false, items: structuredClone(items) } };
199
- },
200
- },
201
- paginate: async (method, input) => {
202
- assert.equal(method, listSubIssues);
203
- return (await method(input)).data;
204
- },
205
- request: async (route, input) => {
206
- target(input);
207
- if (route === 'GET /orgs/{org}/issue-fields')
208
- return {
209
- data: [
210
- {
211
- id: 101,
212
- name: 'Estimate',
213
- data_type: 'single_select',
214
- options: [{ name: '1' }, { name: '2' }, { name: '4' }],
215
- },
216
- { id: 102, name: 'Urgency', data_type: 'single_select', options: [{ name: 'High' }, { name: 'Low' }] },
217
- ],
218
- };
219
- const issue = get(input.issue_number);
220
- if (route === 'POST /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values') {
221
- for (const field of input.issue_field_values) {
222
- if (field.field_id === 101)
223
- issue.points = Number(field.value);
224
- else {
225
- assert.equal(field.field_id, 102);
226
- issue.priority = field.value;
227
- }
228
- }
229
- mutation(`fields:${String(issue.number)}`);
230
- }
231
- else
232
- assert.equal(route, 'GET /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values');
233
- return { data: values(issue) };
234
- },
235
- };
236
- const discovery = syntheticDiscoveryClients();
237
- const page = (nodes) => ({ nodes, pageInfo: { hasNextPage: false, endCursor: null } });
238
- const projectItem = (issue) => ({
239
- id: `ITEM${String(issue.number)}`,
240
- isArchived: false,
241
- content: { id: issue.node_id },
242
- fieldValueByName: issue.status === null
243
- ? null
244
- : {
245
- name: issue.status,
246
- optionId: `STATUS-${String(['Queued', 'Active', 'Waiting', 'Shipped'].indexOf(issue.status))}`,
247
- },
248
- });
249
- const graphql = async (query, input) => {
109
+ return { data: structuredClone(get(input.issue_number)) };
110
+ },
111
+ listForRepo: async (input) => {
250
112
  target(input);
251
- if (query.includes('blockedBy(first:')) {
252
- const issue = get(input.number);
253
- return {
254
- repository: {
255
- issue: {
256
- parent: issue.parent === null
257
- ? null
258
- : {
259
- id: get(issue.parent).node_id,
260
- number: issue.parent,
261
- repository: { nameWithOwner: 'example/widget' },
262
- },
263
- blockedBy: page([]),
264
- },
265
- },
266
- };
267
- }
268
- if (query.includes('IssueClosureReadback')) {
269
- const issue = get(input.number);
270
- return {
271
- repository: {
272
- issue: {
273
- number: issue.number,
274
- repository: { nameWithOwner: 'example/widget' },
275
- state: issue.state.toUpperCase(),
276
- stateReason: issue.reason,
277
- duplicateOf: null,
278
- },
279
- },
280
- };
281
- }
282
- if (query.includes('ProjectDeliveryItems'))
283
- return {
284
- organization: {
285
- projectV2: { items: page([...issues.values()].filter((issue) => issue.status !== null).map(projectItem)) },
286
- },
287
- };
288
- if (query.includes('AddProjectDeliveryItem')) {
289
- const issue = [...issues.values()].find((value) => value.node_id === input.contentId);
290
- assert.ok(issue);
291
- assert.equal(input.projectId, 'PROJECT-1');
292
- mutation(`project:add:${String(issue.number)}`);
293
- return { addProjectV2ItemById: { item: { id: `ITEM${String(issue.number)}` } } };
294
- }
295
- if (query.includes('UpdateProjectDeliveryStatus')) {
296
- const issue = get(Number(String(input.itemId).slice(4)));
297
- assert.equal(input.projectId, 'PROJECT-1');
298
- assert.equal(input.fieldId, 'STATUS-FIELD');
299
- const status = ['Queued', 'Active', 'Waiting', 'Shipped'][Number(String(input.optionId).slice(7))];
300
- assert.ok(status);
301
- issue.status = status;
302
- mutation(`project:status:${String(issue.number)}:${status}`);
303
- return { updateProjectV2ItemFieldValue: { projectV2Item: { id: input.itemId } } };
304
- }
305
- if (query.includes('ProjectDeliveryItemReadback')) {
306
- const issue = get(Number(String(input.itemId).slice(4)));
307
- return { node: { ...projectItem(issue), project: { id: 'PROJECT-1', number: 1 } } };
308
- }
309
- return discovery.graphql(query, input);
310
- };
311
- return {
312
- issues,
313
- comments,
314
- events,
315
- rest,
316
- graphql,
317
- snapshot: () => structuredClone({ issues: [...issues.values()], comments, writes }),
318
- writes: () => writes,
319
- };
320
- }
321
- test('composes shipped tracking through one non-Git MCP session with persisted readbacks and inert refusals', async () => {
322
- const root = mkdtempSync(join(tmpdir(), 'delivery-tracking-scenario-'));
323
- const fixture = trackingRepository();
324
- vi.stubEnv('AI_DELIVERY_CONFIG', join(root, 'operator.json'));
325
- writeFileSync(join(root, 'operator.json'), JSON.stringify({
326
- schemaVersion: 'ai-delivery.user@1',
327
- roles: {
328
- author: { authSource: 'personal', identity: 'host-author', credentialEnv: { token: 'SYNTHETIC_TOKEN' } },
329
- reviewer: {
330
- identity: 'app-reviewer',
331
- credentialEnv: { appId: 'APP_ID', installationId: 'INSTALLATION_ID', privateKeyPath: 'KEY_PATH' },
332
- },
333
- },
334
- project: 1,
335
- checkoutRoots: [],
336
- pointsField: 'Estimate',
337
- priorityField: 'Urgency',
338
- statusField: 'Flow',
339
- statuses: syntheticDiscoveryConfig.native.project.statuses,
340
- }));
341
- vi.spyOn(githubClients, 'createDeliveryGitHubClients').mockImplementation(async (input) => {
342
- assert.equal(input.role, 'author');
113
+ assert.equal(input.page, 1);
343
114
  return {
344
- role: 'author',
345
- authSource: 'personal',
346
- authenticatedAuthor: async () => ({ actorLogin: 'operator', credentialIdentity: 'user:1' }),
347
- rest: fixture.rest,
348
- graphql: fixture.graphql,
115
+ data: structuredClone(
116
+ [...issues.values()].filter((issue) => input.state === "all" || issue.state === input.state)
117
+ )
349
118
  };
350
- });
351
- const server = createAiDeliveryMcpServer({ repoRoot: root });
352
- const client = new Client({ name: 'tracking-scenario', version: '1' });
353
- const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
354
- async function call(name, args) {
355
- const result = await client.callTool({ name, arguments: { repo: 'example/widget', ...args } });
356
- assert.equal(result.isError, undefined, JSON.stringify(result));
357
- return JSON.parse(result.content[0].text);
119
+ },
120
+ listSubIssues,
121
+ create: async (input) => {
122
+ target(input);
123
+ assert.equal(issues.has(31), false, "the scenario creates exactly one child");
124
+ assert.equal(input.type, "Task");
125
+ const issue = add(31, input.title, input.body, null);
126
+ mutation("issue:create:31");
127
+ return { data: structuredClone(issue) };
128
+ },
129
+ update: async (input) => {
130
+ target(input);
131
+ const issue = get(input.issue_number);
132
+ for (const key of ["title", "body", "state"])
133
+ if (typeof input[key] === "string") issue[key] = input[key];
134
+ if (typeof input.type === "string") issue.type = { name: input.type };
135
+ if (typeof input.state_reason === "string") issue.reason = input.state_reason.toUpperCase();
136
+ mutation(`issue:update:${String(issue.number)}`);
137
+ return { data: structuredClone(issue) };
138
+ },
139
+ addSubIssue: async (input) => {
140
+ target(input);
141
+ const parent = get(input.issue_number);
142
+ const child = [...issues.values()].find((issue) => issue.id === input.sub_issue_id);
143
+ assert.ok(child);
144
+ assert.equal(child.parent, null);
145
+ child.parent = parent.number;
146
+ mutation(`parent:add:${String(child.number)}:${String(parent.number)}`);
147
+ return { data: structuredClone(child) };
148
+ },
149
+ removeSubIssue: async (input) => {
150
+ target(input);
151
+ const child = [...issues.values()].find((issue) => issue.id === input.sub_issue_id);
152
+ assert.ok(child);
153
+ assert.equal(child.parent, input.issue_number);
154
+ child.parent = null;
155
+ mutation(`parent:remove:${String(child.number)}`);
156
+ return { data: structuredClone(child) };
157
+ },
158
+ listComments: async (input) => {
159
+ target(input);
160
+ const issue = get(input.issue_number);
161
+ return {
162
+ data: structuredClone(
163
+ comments.filter((comment) => comment.issue_url.endsWith(`/issues/${String(issue.number)}`))
164
+ )
165
+ };
166
+ },
167
+ createComment: async (input) => {
168
+ target(input);
169
+ const issue = get(input.issue_number);
170
+ const id = 101 + comments.length;
171
+ const comment = {
172
+ id,
173
+ body: input.body,
174
+ html_url: `${issue.html_url}#issuecomment-${String(id)}`,
175
+ issue_url: `https://api.github.com/repos/example/widget/issues/${String(issue.number)}`,
176
+ user: { login: "operator" }
177
+ };
178
+ comments.push(comment);
179
+ mutation(`comment:create:${String(id)}`);
180
+ return { data: structuredClone(comment) };
181
+ },
182
+ getComment: async (input) => {
183
+ target(input);
184
+ const comment = comments.find((value) => value.id === input.comment_id);
185
+ assert.ok(comment);
186
+ events.push(`comment:read:${String(comment.id)}`);
187
+ return { data: structuredClone(comment) };
188
+ }
189
+ },
190
+ search: {
191
+ issuesAndPullRequests: async (input) => {
192
+ assert.equal(input.page, 1);
193
+ assert.equal(typeof input.q, "string");
194
+ const match = /^repo:example\/widget is:issue "(Legacy|Replacement)"$/u.exec(input.q);
195
+ assert.ok(match, "search must retain repository and literal text boundaries");
196
+ const items = [...issues.values()].filter((issue) => `${issue.title}
197
+ ${issue.body}`.includes(match[1]));
198
+ return { data: { total_count: items.length, incomplete_results: false, items: structuredClone(items) } };
199
+ }
200
+ },
201
+ paginate: async (method, input) => {
202
+ assert.equal(method, listSubIssues);
203
+ return (await method(input)).data;
204
+ },
205
+ request: async (route, input) => {
206
+ target(input);
207
+ if (route === "GET /orgs/{org}/issue-fields")
208
+ return {
209
+ data: [
210
+ {
211
+ id: 101,
212
+ name: "Estimate",
213
+ data_type: "single_select",
214
+ options: [{ name: "1" }, { name: "2" }, { name: "4" }]
215
+ },
216
+ { id: 102, name: "Urgency", data_type: "single_select", options: [{ name: "High" }, { name: "Low" }] }
217
+ ]
218
+ };
219
+ const issue = get(input.issue_number);
220
+ if (route === "POST /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values") {
221
+ for (const field of input.issue_field_values) {
222
+ if (field.field_id === 101) issue.points = Number(field.value);
223
+ else {
224
+ assert.equal(field.field_id, 102);
225
+ issue.priority = field.value;
226
+ }
227
+ }
228
+ mutation(`fields:${String(issue.number)}`);
229
+ } else assert.equal(route, "GET /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values");
230
+ return { data: values(issue) };
358
231
  }
359
- async function refuse(name, args) {
360
- const before = fixture.snapshot();
361
- const refused = await client.callTool({ name, arguments: { repo: 'example/widget', ...args } }).then((result) => result.isError === true, () => true);
362
- assert.equal(refused, true, name);
363
- assert.deepEqual(fixture.snapshot(), before, `${name} must not mutate stored native state or write count`);
232
+ };
233
+ const discovery = syntheticDiscoveryClients();
234
+ const page = (nodes) => ({ nodes, pageInfo: { hasNextPage: false, endCursor: null } });
235
+ const projectItem = (issue) => ({
236
+ id: `ITEM${String(issue.number)}`,
237
+ isArchived: false,
238
+ content: { id: issue.node_id },
239
+ fieldValueByName: issue.status === null ? null : {
240
+ name: issue.status,
241
+ optionId: `STATUS-${String(["Queued", "Active", "Waiting", "Shipped"].indexOf(issue.status))}`
364
242
  }
365
- const fields = {
366
- issueType: 'Task',
367
- points: 2,
368
- problem: 'Legacy tracking needs a portable replacement.',
369
- outcome: 'Replacement tracking has an explicit native readback.',
370
- acceptanceCriteria: [
371
- {
372
- behavior: 'Invalid tracking requests leave native state unchanged.',
373
- verifiedBy: 'The synthetic MCP scenario compares stored state and writes.',
243
+ });
244
+ const graphql = async (query, input) => {
245
+ target(input);
246
+ if (query.includes("blockedBy(first:")) {
247
+ const issue = get(input.number);
248
+ return {
249
+ repository: {
250
+ issue: {
251
+ parent: issue.parent === null ? null : {
252
+ id: get(issue.parent).node_id,
253
+ number: issue.parent,
254
+ repository: { nameWithOwner: "example/widget" }
374
255
  },
375
- ],
376
- outOfScope: ['Implementing batch or deferral.'],
377
- openQuestions: [],
378
- context: {
379
- files: ['src/currentTrackingScenario.test.ts'],
380
- evidence: ['https://github.com/example/widget/issues/17'],
381
- },
382
- draft: false,
383
- };
384
- try {
385
- await server.connect(serverTransport);
386
- await client.connect(clientTransport);
387
- assert.equal(existsSync(join(root, '.git')), false);
388
- const tools = (await client.listTools()).tools.map((tool) => tool.name);
389
- for (const name of ['issue_list', 'issue_search', 'issue_update', 'issue_create', 'issue_comment', 'issue_info'])
390
- assert.ok(tools.includes(name));
391
- const original = await call('issue_list', {
392
- parentIssueNumber: 10,
393
- state: 'all',
394
- });
395
- assert.deepEqual(original.issues.map((issue) => issue.number), [17, 18]);
396
- const found = await call('issue_search', { query: 'Legacy', state: 'all' });
397
- assert.deepEqual(found.issues.map((issue) => issue.number), [17]);
398
- await refuse('issue_update', { issueNumber: 17, points: 'two' });
399
- const rewritten = await call('issue_update', {
400
- ...fields,
401
- issueNumber: 17,
402
- title: 'Replacement tracking issue',
403
- preserveHistory: true,
404
- });
405
- const expectedHistory = '<details>\n<summary>Previous issue title and body</summary>\n\nTitle:\n<pre> Legacy &lt;tracking&gt; &amp; title\r\n</pre>\n\nBody:\n<pre>\nLegacy &amp; backlog &lt;tag&gt;\t \r\n</pre>\n\n</details>';
406
- assert.equal(rewritten.historyComment.body, expectedHistory);
407
- assert.equal(fixture.comments[0].body, expectedHistory);
408
- assert.equal(fixture.comments[0].user.login, 'operator');
409
- const historyRead = fixture.events.indexOf('comment:read:101');
410
- assert.ok(historyRead >= 0 && historyRead < fixture.events.indexOf('issue:update:17'));
411
- assert.equal(rewritten.title, fixture.issues.get(17).title);
412
- assert.equal(rewritten.body, fixture.issues.get(17).body);
413
- const created = await call('issue_create', {
414
- ...fields,
415
- title: 'Replacement sized child',
416
- priority: 'High',
417
- parentIssueNumber: 20,
418
- });
419
- assert.equal(created.created.number, 31);
420
- const child = await call('issue_info', { issueNumber: created.created.number });
421
- assert.equal(child.points, 2);
422
- assert.equal(child.priority, 'High');
423
- assert.equal(child.issueType, 'Task');
424
- assert.equal(child.parentIssueNumber, 20);
425
- assert.equal(child.projectStatus, 'Todo');
426
- assert.equal(fixture.issues.get(31).parent, 20);
427
- await refuse('issue_batch', { issues: [17, 18], parentIssueNumber: 20 });
428
- for (const issueNumber of [17, 18]) {
429
- const moved = await call('issue_update', { issueNumber, parentIssueNumber: 20 });
430
- assert.equal(moved.parentIssueNumber, 20);
431
- assert.equal(fixture.issues.get(issueNumber).parent, 20);
256
+ blockedBy: page([])
257
+ }
258
+ }
259
+ };
260
+ }
261
+ if (query.includes("IssueClosureReadback")) {
262
+ const issue = get(input.number);
263
+ return {
264
+ repository: {
265
+ issue: {
266
+ number: issue.number,
267
+ repository: { nameWithOwner: "example/widget" },
268
+ state: issue.state.toUpperCase(),
269
+ stateReason: issue.reason,
270
+ duplicateOf: null
271
+ }
432
272
  }
433
- assert.deepEqual((await call('issue_list', { parentIssueNumber: 10, state: 'all' })).issues, []);
434
- assert.deepEqual((await call('issue_list', { parentIssueNumber: 20, state: 'all' })).issues.map((issue) => issue.number), [17, 18, 31]);
435
- for (const number of [10, 20])
436
- assert.equal((await call('issue_info', { issueNumber: number })).points, undefined);
437
- const journal = await call('issue_comment', {
438
- issueNumber: 31,
439
- kind: 'progress',
440
- summary: 'Tracking replay is verified.',
441
- status: 'In progress',
442
- done: ['Reparented two issues individually.'],
443
- decisionNeeded: 'None',
444
- keyNumbers: [],
445
- evidence: [created.created.url],
446
- nextStep: 'Review',
447
- nextDate: '2026-10-09',
448
- });
449
- const storedJournal = fixture.comments.find((comment) => comment.id === journal.commentId);
450
- assert.equal(storedJournal.body, journal.body);
451
- assert.equal(storedJournal.html_url, journal.url);
452
- assert.equal(storedJournal.user.login, 'operator');
453
- assert.match(journal.body, /Tracking replay is verified/u);
454
- await refuse('issue_defer', { issueNumber: 17, trigger: 'After review' });
455
- const deferred = await call('issue_update', { issueNumber: 17, defer: { trigger: 'After review' } });
456
- assert.deepEqual(deferred.deferred, { trigger: 'After review' });
457
- assert.deepEqual((await call('issue_info', { issueNumber: 17 })).deferred, { trigger: 'After review' });
458
- const undeferred = await call('issue_update', { issueNumber: 17, undefer: true });
459
- assert.equal(undeferred.deferred, null);
460
- const closed = await call('issue_update', { issueNumber: 17, state: 'closed', closeReason: 'not_planned', supersededBy: 31 });
461
- assert.equal(closed.closure.state, 'closed');
462
- assert.equal(closed.closure.closeReason, 'not_planned');
463
- assert.equal(closed.closure.supersededBy, 31);
464
- assert.equal(closed.projectStatus, 'Done');
465
- assert.equal(fixture.issues.get(17).reason, 'NOT_PLANNED');
466
- assert.equal(fixture.issues.get(17).status, 'Shipped');
467
- assert.equal(fixture.comments.find((comment) => comment.id === closed.closure.comment.commentId).body, 'Requested closure reason: not_planned.\nSuperseded by example/widget#31.');
468
- const final = await call('issue_info', { issueNumber: 17 });
469
- assert.equal(final.state, 'closed');
470
- assert.equal(final.parentIssueNumber, 20);
471
- assert.equal(final.projectStatus, 'Done');
472
- const finalSearch = await call('issue_search', {
473
- query: 'Replacement',
474
- state: 'all',
475
- });
476
- assert.deepEqual(finalSearch.issues.map(({ number, state }) => ({ number, state })), [
477
- { number: 20, state: 'open' },
478
- { number: 17, state: 'closed' },
479
- { number: 31, state: 'open' },
480
- ]);
481
- assert.ok(fixture.writes() > 0);
482
- assert.equal(existsSync(join(root, '.git')), false);
273
+ };
274
+ }
275
+ if (query.includes("ProjectDeliveryIssueItems"))
276
+ return issueProjectItemsResponse(
277
+ input,
278
+ [...issues.values()].filter((issue) => issue.status !== null && issue.node_id === input.issueNodeId).map(projectItem),
279
+ { id: "PROJECT-1", number: 1 }
280
+ );
281
+ if (query.includes("AddProjectDeliveryItem")) {
282
+ const issue = [...issues.values()].find((value) => value.node_id === input.contentId);
283
+ assert.ok(issue);
284
+ assert.equal(input.projectId, "PROJECT-1");
285
+ mutation(`project:add:${String(issue.number)}`);
286
+ return { addProjectV2ItemById: { item: { id: `ITEM${String(issue.number)}` } } };
483
287
  }
484
- finally {
485
- await client.close();
486
- await server.close();
487
- vi.restoreAllMocks();
488
- vi.unstubAllEnvs();
489
- rmSync(root, { recursive: true, force: true });
288
+ if (query.includes("UpdateProjectDeliveryStatus")) {
289
+ const issue = get(Number(String(input.itemId).slice(4)));
290
+ assert.equal(input.projectId, "PROJECT-1");
291
+ assert.equal(input.fieldId, "STATUS-FIELD");
292
+ const status = ["Queued", "Active", "Waiting", "Shipped"][Number(String(input.optionId).slice(7))];
293
+ assert.ok(status);
294
+ issue.status = status;
295
+ mutation(`project:status:${String(issue.number)}:${status}`);
296
+ return { updateProjectV2ItemFieldValue: { projectV2Item: { id: input.itemId } } };
490
297
  }
298
+ if (query.includes("ProjectDeliveryItemReadback")) {
299
+ const issue = get(Number(String(input.itemId).slice(4)));
300
+ return { node: { ...projectItem(issue), project: { id: "PROJECT-1", number: 1 } } };
301
+ }
302
+ return discovery.graphql(query, input);
303
+ };
304
+ return {
305
+ issues,
306
+ comments,
307
+ events,
308
+ rest,
309
+ graphql,
310
+ snapshot: () => structuredClone({ issues: [...issues.values()], comments, writes }),
311
+ writes: () => writes
312
+ };
313
+ }
314
+ test("composes shipped tracking through one non-Git MCP session with persisted readbacks and inert refusals", async () => {
315
+ const root = mkdtempSync(join(tmpdir(), "delivery-tracking-scenario-"));
316
+ const fixture = trackingRepository();
317
+ vi.stubEnv("AI_DELIVERY_CONFIG", join(root, "operator.json"));
318
+ writeFileSync(
319
+ join(root, "operator.json"),
320
+ JSON.stringify({
321
+ schemaVersion: "ai-delivery.user@1",
322
+ roles: {
323
+ author: { authSource: "personal", identity: "host-author", credentialEnv: { token: "SYNTHETIC_TOKEN" } },
324
+ reviewer: {
325
+ identity: "app-reviewer",
326
+ credentialEnv: { appId: "APP_ID", installationId: "INSTALLATION_ID", privateKeyPath: "KEY_PATH" }
327
+ }
328
+ },
329
+ project: 1,
330
+ checkoutRoots: [],
331
+ pointsField: "Estimate",
332
+ priorityField: "Urgency",
333
+ statusField: "Flow",
334
+ statuses: syntheticDiscoveryConfig.native.project.statuses
335
+ })
336
+ );
337
+ vi.spyOn(githubClients, "createDeliveryGitHubClients").mockImplementation(async (input) => {
338
+ assert.equal(input.role, "author");
339
+ return {
340
+ role: "author",
341
+ authSource: "personal",
342
+ authenticatedAuthor: async () => ({ actorLogin: "operator", credentialIdentity: "user:1" }),
343
+ rest: fixture.rest,
344
+ graphql: fixture.graphql
345
+ };
346
+ });
347
+ const server = createAiDeliveryMcpServer({ repoRoot: root });
348
+ const client = new Client({ name: "tracking-scenario", version: "1" });
349
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
350
+ async function call(name, args) {
351
+ const result = await client.callTool({ name, arguments: { repo: "example/widget", ...args } });
352
+ assert.equal(result.isError, void 0, JSON.stringify(result));
353
+ return JSON.parse(result.content[0].text);
354
+ }
355
+ async function refuse(name, args) {
356
+ const before = fixture.snapshot();
357
+ const refused = await client.callTool({ name, arguments: { repo: "example/widget", ...args } }).then(
358
+ (result) => result.isError === true,
359
+ () => true
360
+ );
361
+ assert.equal(refused, true, name);
362
+ assert.deepEqual(fixture.snapshot(), before, `${name} must not mutate stored native state or write count`);
363
+ }
364
+ const fields = {
365
+ issueType: "Task",
366
+ points: 2,
367
+ problem: "Legacy tracking needs a portable replacement.",
368
+ outcome: "Replacement tracking has an explicit native readback.",
369
+ acceptanceCriteria: [
370
+ {
371
+ behavior: "Invalid tracking requests leave native state unchanged.",
372
+ verifiedBy: "The synthetic MCP scenario compares stored state and writes."
373
+ }
374
+ ],
375
+ outOfScope: ["Implementing batch or deferral."],
376
+ openQuestions: [],
377
+ context: {
378
+ files: ["src/currentTrackingScenario.test.ts"],
379
+ evidence: ["https://github.com/example/widget/issues/17"]
380
+ },
381
+ draft: false
382
+ };
383
+ try {
384
+ await server.connect(serverTransport);
385
+ await client.connect(clientTransport);
386
+ assert.equal(existsSync(join(root, ".git")), false);
387
+ const tools = (await client.listTools()).tools.map((tool) => tool.name);
388
+ for (const name of ["issue_list", "issue_search", "issue_update", "issue_create", "issue_comment", "issue_info"])
389
+ assert.ok(tools.includes(name));
390
+ const original = await call("issue_list", {
391
+ parentIssueNumber: 10,
392
+ state: "all"
393
+ });
394
+ assert.deepEqual(
395
+ original.issues.map((issue) => issue.number),
396
+ [17, 18]
397
+ );
398
+ const found = await call("issue_search", { query: "Legacy", state: "all" });
399
+ assert.deepEqual(
400
+ found.issues.map((issue) => issue.number),
401
+ [17]
402
+ );
403
+ await refuse("issue_update", { issueNumber: 17, points: "two" });
404
+ const rewritten = await call("issue_update", {
405
+ ...fields,
406
+ issueNumber: 17,
407
+ title: "Replacement tracking issue",
408
+ preserveHistory: true,
409
+ verbose: true
410
+ });
411
+ const expectedHistory = "<details>\n<summary>Previous issue title and body</summary>\n\nTitle:\n<pre> Legacy &lt;tracking&gt; &amp; title\r\n</pre>\n\nBody:\n<pre>\nLegacy &amp; backlog &lt;tag&gt; \r\n</pre>\n\n</details>";
412
+ assert.equal(rewritten.historyComment.body, expectedHistory);
413
+ assert.equal(fixture.comments[0].body, expectedHistory);
414
+ assert.equal(fixture.comments[0].user.login, "operator");
415
+ const historyRead = fixture.events.indexOf("comment:read:101");
416
+ assert.ok(historyRead >= 0 && historyRead < fixture.events.indexOf("issue:update:17"));
417
+ assert.equal(rewritten.title, fixture.issues.get(17).title);
418
+ assert.equal(rewritten.body, fixture.issues.get(17).body);
419
+ const created = await call("issue_create", {
420
+ ...fields,
421
+ title: "Replacement sized child",
422
+ priority: "High",
423
+ parentIssueNumber: 20
424
+ });
425
+ assert.equal(created.created.number, 31);
426
+ const child = await call("issue_info", { issueNumber: created.created.number });
427
+ assert.equal(child.points, 2);
428
+ assert.equal(child.priority, "High");
429
+ assert.equal(child.issueType, "Task");
430
+ assert.equal(child.parentIssueNumber, 20);
431
+ assert.equal(child.projectStatus, "Todo");
432
+ assert.equal(fixture.issues.get(31).parent, 20);
433
+ await refuse("issue_batch", { issues: [17, 18], parentIssueNumber: 20 });
434
+ for (const issueNumber of [17, 18]) {
435
+ const moved = await call("issue_update", { issueNumber, parentIssueNumber: 20 });
436
+ assert.equal(moved.parentIssueNumber, 20);
437
+ assert.equal(fixture.issues.get(issueNumber).parent, 20);
438
+ }
439
+ assert.deepEqual(
440
+ (await call("issue_list", { parentIssueNumber: 10, state: "all" })).issues,
441
+ []
442
+ );
443
+ assert.deepEqual(
444
+ (await call("issue_list", { parentIssueNumber: 20, state: "all" })).issues.map(
445
+ (issue) => issue.number
446
+ ),
447
+ [17, 18, 31]
448
+ );
449
+ for (const number of [10, 20])
450
+ assert.equal((await call("issue_info", { issueNumber: number })).points, void 0);
451
+ const journal = await call("issue_comment", {
452
+ verbose: true,
453
+ issueNumber: 31,
454
+ kind: "progress",
455
+ summary: "Tracking replay is verified.",
456
+ status: "In progress",
457
+ done: ["Reparented two issues individually."],
458
+ decisionNeeded: "None",
459
+ keyNumbers: [],
460
+ evidence: [created.created.url],
461
+ nextStep: "Review",
462
+ nextDate: "2026-10-09"
463
+ });
464
+ const storedJournal = fixture.comments.find((comment) => comment.id === journal.commentId);
465
+ assert.equal(storedJournal.body, journal.body);
466
+ assert.equal(storedJournal.html_url, journal.url);
467
+ assert.equal(storedJournal.user.login, "operator");
468
+ assert.match(journal.body, /Tracking replay is verified/u);
469
+ await refuse("issue_defer", { issueNumber: 17, trigger: "After review" });
470
+ const deferred = await call("issue_update", { issueNumber: 17, defer: { trigger: "After review" } });
471
+ assert.deepEqual(deferred.deferred, { trigger: "After review" });
472
+ assert.deepEqual((await call("issue_info", { issueNumber: 17 })).deferred, { trigger: "After review" });
473
+ const undeferred = await call("issue_update", { issueNumber: 17, undefer: true });
474
+ assert.equal(undeferred.deferred, null);
475
+ const closed = await call("issue_update", { issueNumber: 17, state: "closed", closeReason: "not_planned", supersededBy: 31 });
476
+ assert.equal(closed.closure.state, "closed");
477
+ assert.equal(closed.closure.closeReason, "not_planned");
478
+ assert.equal(closed.closure.supersededBy, 31);
479
+ assert.equal(closed.projectStatus, "Done");
480
+ assert.equal(fixture.issues.get(17).reason, "NOT_PLANNED");
481
+ assert.equal(fixture.issues.get(17).status, "Shipped");
482
+ assert.equal(
483
+ fixture.comments.find((comment) => comment.id === closed.closure.comment.commentId).body,
484
+ "Requested closure reason: not_planned.\nSuperseded by example/widget#31."
485
+ );
486
+ const final = await call("issue_info", { issueNumber: 17 });
487
+ assert.equal(final.state, "closed");
488
+ assert.equal(final.parentIssueNumber, 20);
489
+ assert.equal(final.projectStatus, "Done");
490
+ const finalSearch = await call("issue_search", {
491
+ query: "Replacement",
492
+ state: "all"
493
+ });
494
+ assert.deepEqual(
495
+ finalSearch.issues.map(({ number, state }) => ({ number, state })),
496
+ [
497
+ { number: 20, state: "open" },
498
+ { number: 17, state: "closed" },
499
+ { number: 31, state: "open" }
500
+ ]
501
+ );
502
+ assert.ok(fixture.writes() > 0);
503
+ assert.equal(existsSync(join(root, ".git")), false);
504
+ } finally {
505
+ await client.close();
506
+ await server.close();
507
+ vi.restoreAllMocks();
508
+ vi.unstubAllEnvs();
509
+ rmSync(root, { recursive: true, force: true });
510
+ }
491
511
  });
492
- //# sourceMappingURL=currentTrackingScenario.test.js.map
512
+ //# sourceMappingURL=currentTrackingScenario.test.js.map