@aviaratech/ai-delivery 0.3.34 → 0.3.35

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 (75) hide show
  1. package/README.md +48 -0
  2. package/dist/boardReconcile.test.d.ts +1 -0
  3. package/dist/boardReconcile.test.js +1685 -0
  4. package/dist/boardReconcile.test.js.map +1 -0
  5. package/dist/cli.js +35 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cliResult.js +21 -1
  8. package/dist/cliResult.js.map +1 -1
  9. package/dist/cliResult.test.js +82 -0
  10. package/dist/cliResult.test.js.map +1 -1
  11. package/dist/config/deliveryConfig.d.ts +32 -0
  12. package/dist/config/deliveryConfig.js +5 -0
  13. package/dist/config/deliveryConfig.js.map +1 -1
  14. package/dist/config/deliveryConfig.test.js +67 -0
  15. package/dist/config/deliveryConfig.test.js.map +1 -1
  16. package/dist/currentTrackingScenario.test.js +6 -4
  17. package/dist/currentTrackingScenario.test.js.map +1 -1
  18. package/dist/directoryIndependent.test.js +2 -2
  19. package/dist/directoryIndependent.test.js.map +1 -1
  20. package/dist/dispatch.d.ts +1 -1
  21. package/dist/dispatch.js +33 -1
  22. package/dist/dispatch.js.map +1 -1
  23. package/dist/errors.d.ts +13 -0
  24. package/dist/errors.js +15 -0
  25. package/dist/errors.js.map +1 -1
  26. package/dist/github/commandIdentityPolicy.js +1 -0
  27. package/dist/github/commandIdentityPolicy.js.map +1 -1
  28. package/dist/github/discovery.d.ts +2 -0
  29. package/dist/github/discovery.js +17 -3
  30. package/dist/github/discovery.js.map +1 -1
  31. package/dist/github/projectDelivery.d.ts +36 -0
  32. package/dist/github/projectDelivery.js +136 -31
  33. package/dist/github/projectDelivery.js.map +1 -1
  34. package/dist/github/relationships.d.ts +5 -2
  35. package/dist/github/relationships.js +59 -2
  36. package/dist/github/relationships.js.map +1 -1
  37. package/dist/issue.d.ts +66 -1
  38. package/dist/issue.js +259 -62
  39. package/dist/issue.js.map +1 -1
  40. package/dist/issueBatchUpdate.test.js +229 -12
  41. package/dist/issueBatchUpdate.test.js.map +1 -1
  42. package/dist/issueTracking.test.js +436 -11
  43. package/dist/issueTracking.test.js.map +1 -1
  44. package/dist/mcp/index.js +4 -0
  45. package/dist/mcp/index.js.map +1 -1
  46. package/dist/mcp/tools.d.ts +592 -0
  47. package/dist/mcp/tools.js +7 -0
  48. package/dist/mcp/tools.js.map +1 -1
  49. package/dist/pluginInstaller.js +21 -23
  50. package/dist/pluginInstaller.js.map +1 -1
  51. package/dist/pluginInstaller.test.js +121 -1
  52. package/dist/pluginInstaller.test.js.map +1 -1
  53. package/dist/pluginPackaging.test.js +135 -6
  54. package/dist/pluginPackaging.test.js.map +1 -1
  55. package/dist/services/boardReconcileService.d.ts +1204 -0
  56. package/dist/services/boardReconcileService.js +1571 -0
  57. package/dist/services/boardReconcileService.js.map +1 -0
  58. package/dist/services/deliveryAdmission.d.ts +2 -0
  59. package/dist/services/deliveryAdmission.js +2 -2
  60. package/dist/services/deliveryAdmission.js.map +1 -1
  61. package/dist/setup.test.js +299 -28
  62. package/dist/setup.test.js.map +1 -1
  63. package/dist/stdoutRegression.test.js +5 -2
  64. package/dist/stdoutRegression.test.js.map +1 -1
  65. package/dist/verification.js +12 -2
  66. package/dist/verification.js.map +1 -1
  67. package/dist/version.d.ts +6 -0
  68. package/dist/version.js +16 -1
  69. package/dist/version.js.map +1 -1
  70. package/package.json +2 -1
  71. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  72. package/plugins/ai-delivery/plugin.json +1 -1
  73. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +24 -0
  74. package/plugins/ai-delivery/runtime/dist/cli.js +72 -71
  75. package/plugins/ai-delivery/runtime/package.json +1 -1
@@ -7,6 +7,8 @@ import { test } from 'vitest';
7
7
  import * as issue from './issue.js';
8
8
  import { getAiDeliveryMcpTool } from './mcp/tools.js';
9
9
  import { syntheticDiscoveryConfig } from './fixtures/discovery.js';
10
+ import { getNativeBlockerRelationships } from './github/relationships.js';
11
+ import * as projectDelivery from './github/projectDelivery.js';
10
12
  function updateFixture() {
11
13
  const root = mkdtempSync(join(tmpdir(), 'ai-delivery-history-'));
12
14
  execFileSync('git', ['init', '-q', '-b', 'main'], { cwd: root });
@@ -28,6 +30,15 @@ function updateFixture() {
28
30
  targetPr: false,
29
31
  reason: null,
30
32
  duplicate: null,
33
+ archived: false,
34
+ archiveAfterUpdate: false,
35
+ projectUnavailableAfterUpdate: false,
36
+ nativeUnavailableAfterUpdate: false,
37
+ foreignAfterUpdate: false,
38
+ wrongNodeAfterUpdate: false,
39
+ driftAfterUpdate: false,
40
+ projectFailure: '',
41
+ nativeReadsAfterUpdate: 0,
31
42
  };
32
43
  const comments = [];
33
44
  const updates = [];
@@ -45,16 +56,29 @@ function updateFixture() {
45
56
  },
46
57
  rest: {
47
58
  issues: {
48
- get: async (input) => ({
49
- data: input.issue_number === 17
50
- ? { ...live }
51
- : {
52
- number: input.issue_number,
53
- id: 118,
54
- html_url: `https://github.com/example/widget/issues/${String(input.issue_number)}`,
55
- ...(controls.targetPr ? { pull_request: {} } : {}),
56
- },
57
- }),
59
+ get: async (input) => {
60
+ if (updates.length)
61
+ controls.nativeReadsAfterUpdate++;
62
+ if (updates.length && controls.nativeUnavailableAfterUpdate)
63
+ throw new Error('Native unavailable');
64
+ return {
65
+ data: input.issue_number === 17
66
+ ? {
67
+ ...live,
68
+ ...(updates.length && controls.wrongNodeAfterUpdate ? { node_id: 'FOREIGN_ISSUE' } : {}),
69
+ ...(updates.length && controls.foreignAfterUpdate
70
+ ? { html_url: 'https://github.com/other/widget/issues/17' }
71
+ : {}),
72
+ ...(updates.length && controls.driftAfterUpdate ? { body: 'Concurrent later edit' } : {}),
73
+ }
74
+ : {
75
+ number: input.issue_number,
76
+ id: 118,
77
+ html_url: `https://github.com/example/widget/issues/${String(input.issue_number)}`,
78
+ ...(controls.targetPr ? { pull_request: {} } : {}),
79
+ },
80
+ };
81
+ },
58
82
  listComments: async () => ({ data: comments }),
59
83
  createComment: async (input) => {
60
84
  events.push('comment');
@@ -85,6 +109,8 @@ function updateFixture() {
85
109
  updates.push(input);
86
110
  if (controls.failUpdate)
87
111
  throw new Error('Update unavailable');
112
+ if (controls.archiveAfterUpdate)
113
+ controls.archived = true;
88
114
  if (typeof input.title === 'string')
89
115
  live.title = input.title;
90
116
  if (typeof input.body === 'string')
@@ -104,6 +130,16 @@ function updateFixture() {
104
130
  request: async () => ({ data: [] }),
105
131
  },
106
132
  graphql: async (query, variables) => {
133
+ if (query.includes('ProjectDelivery') && updates.length && controls.projectFailure) {
134
+ if (controls.projectFailure === 'cancel')
135
+ throw new DOMException('Cancelled', 'AbortError');
136
+ throw Object.assign(new Error('PRIVATE_RATE_CONTENT'), {
137
+ status: 429,
138
+ response: { headers: { 'retry-after': '60' } },
139
+ });
140
+ }
141
+ if (query.includes('ProjectDelivery') && updates.length && controls.projectUnavailableAfterUpdate)
142
+ throw new Error('PRIVATE_REMOTE_CONTENT');
107
143
  if (query.includes('IssueClosureReadback'))
108
144
  return {
109
145
  repository: {
@@ -132,7 +168,7 @@ function updateFixture() {
132
168
  nodes: [
133
169
  {
134
170
  id: 'ITEM17',
135
- isArchived: false,
171
+ isArchived: controls.archived,
136
172
  content: { id: 'ISSUE17' },
137
173
  fieldValueByName: {
138
174
  name: projectStatus,
@@ -146,6 +182,7 @@ function updateFixture() {
146
182
  },
147
183
  };
148
184
  if (query.includes('UpdateProjectDeliveryStatus')) {
185
+ events.push('project-update');
149
186
  projectStatus =
150
187
  variables.optionId === 'DONE' ? 'Shipped' : variables.optionId === 'TODO' ? 'Queued' : 'Active';
151
188
  return { updateProjectV2ItemFieldValue: { projectV2Item: { id: 'ITEM17' } } };
@@ -203,6 +240,100 @@ test('history preserves exact prior content before a rewrite and retries a faile
203
240
  fixture.cleanup();
204
241
  }
205
242
  });
243
+ test('initially archived issue update refuses before history, closure or native writes', async () => {
244
+ const f = updateFixture();
245
+ try {
246
+ f.controls.archived = true;
247
+ await assert.rejects(issue.updateIssue(f.context, {
248
+ issueNumber: 17,
249
+ body: 'Replacement',
250
+ draft: true,
251
+ preserveHistory: true,
252
+ state: 'closed',
253
+ closeReason: 'not_planned',
254
+ }), /archived/u);
255
+ assert.deepEqual(f.updates, []);
256
+ assert.deepEqual(f.comments, []);
257
+ assert.equal(f.events.includes('project-update'), false);
258
+ assert.equal(f.live.state, 'open');
259
+ }
260
+ finally {
261
+ f.cleanup();
262
+ }
263
+ });
264
+ test.each(['archive', 'unavailable'])('post-commit %s reports confirmed native content and closure separately from pending Project work', async (failure) => {
265
+ const f = updateFixture();
266
+ try {
267
+ f.controls.archiveAfterUpdate = failure === 'archive';
268
+ f.controls.projectUnavailableAfterUpdate = failure === 'unavailable';
269
+ await assert.rejects(issue.updateIssue(f.context, {
270
+ issueNumber: 17,
271
+ body: 'Replacement',
272
+ draft: true,
273
+ preserveHistory: true,
274
+ state: 'closed',
275
+ closeReason: 'not_planned',
276
+ }), (error) => {
277
+ const result = error.result;
278
+ assert.equal(result.status, 'update-incomplete');
279
+ assert.equal(result.native.status, 'confirmed');
280
+ assert.equal(result.native.repository, 'example/widget');
281
+ assert.equal(result.native.readback.state, 'closed');
282
+ assert.match(result.native.readback.body, /Replacement/u);
283
+ assert.equal(result.native.closure.closeReason, 'not_planned');
284
+ assert.equal(result.native.historyComment.commentId, 91);
285
+ assert.equal(result.project.status, failure === 'archive' ? 'pending' : 'unknown');
286
+ assert.equal(result.project.desiredStatus, 'Done');
287
+ assert.equal(result.recovery.tool, 'issue_batch_update');
288
+ assert.equal(JSON.stringify(result).includes('PRIVATE_'), false);
289
+ return true;
290
+ });
291
+ assert.equal(f.updates.length, 1);
292
+ assert.equal(f.comments.length, 2);
293
+ }
294
+ finally {
295
+ f.cleanup();
296
+ }
297
+ });
298
+ test.each(['unavailable', 'foreign', 'drift', 'node'])('post-commit native %s evidence remains unknown', async (failure) => {
299
+ const f = updateFixture();
300
+ try {
301
+ f.controls.archiveAfterUpdate = true;
302
+ f.controls.nativeUnavailableAfterUpdate = failure === 'unavailable';
303
+ f.controls.foreignAfterUpdate = failure === 'foreign';
304
+ f.controls.wrongNodeAfterUpdate = failure === 'node';
305
+ f.controls.driftAfterUpdate = failure === 'drift';
306
+ await assert.rejects(issue.updateIssue(f.context, { issueNumber: 17, body: 'Replacement', draft: true }), (error) => {
307
+ const result = error.result;
308
+ assert.equal(result.native.status, 'unknown');
309
+ assert.equal(result.native.readback, null);
310
+ return true;
311
+ });
312
+ assert.equal(f.updates.length, 1);
313
+ }
314
+ finally {
315
+ f.cleanup();
316
+ }
317
+ });
318
+ test.each(['rate-limit', 'cancel'])('post-commit %s defers native readback without another request', async (failure) => {
319
+ const f = updateFixture();
320
+ try {
321
+ f.controls.projectFailure = failure;
322
+ await assert.rejects(issue.updateIssue(f.context, { issueNumber: 17, body: 'Replacement', draft: true }), (error) => {
323
+ const partial = issue.getIncompleteIssueUpdate(error);
324
+ assert.equal(partial?.native.status, 'unknown');
325
+ assert.equal(partial?.native.readback, null);
326
+ if (failure === 'rate-limit')
327
+ assert.equal(partial?.rateLimit?.retryAfterSeconds, 60);
328
+ assert.equal(JSON.stringify(partial).includes('PRIVATE_'), false);
329
+ return true;
330
+ });
331
+ assert.equal(f.controls.nativeReadsAfterUpdate, 1);
332
+ }
333
+ finally {
334
+ f.cleanup();
335
+ }
336
+ });
206
337
  test('history overflow, invalid metadata, failed comment readback and concurrent edits prevent rewrites', async () => {
207
338
  for (const failure of ['overflow', 'labels', 'readback', 'drift']) {
208
339
  const fixture = updateFixture();
@@ -605,6 +736,300 @@ test('native field pagination fails closed on a repeated nonadvancing page', asy
605
736
  }));
606
737
  await assert.rejects(issue.listIssues(context, {}), /repeated a pagination page/u);
607
738
  });
739
+ test.each([
740
+ ['catalog', 'list'],
741
+ ['values', 'list'],
742
+ ['catalog', 'ready'],
743
+ ['values', 'ready'],
744
+ ['catalog', 'capacity'],
745
+ ['values', 'capacity'],
746
+ ])('reconciliation bounds native %s through %s reads', async (collection, entry) => {
747
+ const { context } = listingFixture();
748
+ Object.assign(context, { readPageLimit: 20 });
749
+ context.clients.rest.issues.get = (async () => ({
750
+ data: {
751
+ number: 17,
752
+ node_id: 'ISSUE17',
753
+ state: 'open',
754
+ body: '',
755
+ title: 'Repair widget',
756
+ html_url: 'https://github.com/example/widget/issues/17',
757
+ },
758
+ }));
759
+ if (entry === 'capacity')
760
+ context.config = {
761
+ ...context.config,
762
+ wipLimits: [{ repository: 'example/widget', name: 'Native', match: { field: 'Estimate', value: '4' }, limit: 2 }],
763
+ };
764
+ const originalGraphql = context.clients.graphql;
765
+ context.clients.graphql = (async (query) => {
766
+ const response = await originalGraphql(query);
767
+ if (query.includes('ProjectDeliveryItems')) {
768
+ const parsed = response;
769
+ Object.assign(parsed.organization.projectV2, { id: 'PROJECT', number: 1 });
770
+ }
771
+ if (!query.includes('blockedBy(first:'))
772
+ return response;
773
+ const parsed = response;
774
+ Object.assign(parsed.repository.issue, {
775
+ id: 'ISSUE17',
776
+ number: 17,
777
+ repository: { nameWithOwner: 'example/widget' },
778
+ });
779
+ return parsed;
780
+ });
781
+ const original = context.clients.rest.request;
782
+ let requests = 0;
783
+ context.clients.rest.request = (async (route, params) => {
784
+ if (route.includes('/orgs/') !== (collection === 'catalog'))
785
+ return original(route);
786
+ requests++;
787
+ return {
788
+ data: params.page > 20
789
+ ? []
790
+ : Array.from({ length: 100 }, (_, index) => {
791
+ const id = 1000 + params.page * 100 + index;
792
+ return collection === 'catalog'
793
+ ? { id, name: `Extra ${String(id)}`, data_type: 'text' }
794
+ : { issue_field_id: id, issue_field_name: `Extra ${String(id)}`, data_type: 'text', value: 'value' };
795
+ }),
796
+ };
797
+ });
798
+ const operation = entry === 'list'
799
+ ? issue.listIssues(context, {})
800
+ : entry === 'ready'
801
+ ? issue.readyCheck(context, 17)
802
+ : issue.assertIssueStartCapacity(context, 17);
803
+ await assert.rejects(operation, (error) => {
804
+ assert.ok(error instanceof Error);
805
+ assert.equal(error.name, 'CollectionLimitError');
806
+ assert.equal(Reflect.get(error, 'pagesRequested'), 20);
807
+ return true;
808
+ });
809
+ assert.equal(requests, 20);
810
+ });
811
+ test('reconciliation bounds blocker pages and binds their source issue', async () => {
812
+ const { context } = listingFixture();
813
+ let requests = 0;
814
+ context.clients.graphql = (async () => {
815
+ requests++;
816
+ return {
817
+ repository: {
818
+ issue: {
819
+ id: 'ISSUE17',
820
+ number: 17,
821
+ repository: { nameWithOwner: 'example/widget' },
822
+ parent: null,
823
+ blockedBy: { nodes: [], pageInfo: { hasNextPage: requests < 21, endCursor: `page-${String(requests)}` } },
824
+ },
825
+ },
826
+ };
827
+ });
828
+ const input = { graphql: context.clients.graphql, repo: context.repo, issueNumber: 17, maxPages: 20 };
829
+ await assert.rejects(getNativeBlockerRelationships(input), (error) => {
830
+ assert.ok(error instanceof Error);
831
+ assert.equal(error.name, 'CollectionLimitError');
832
+ assert.equal(Reflect.get(error, 'pagesRequested'), 20);
833
+ return true;
834
+ });
835
+ assert.equal(requests, 20);
836
+ });
837
+ test('reconciliation WIP guards bound their label catalog', async () => {
838
+ const { context } = listingFixture();
839
+ Object.assign(context, { readPageLimit: 20 });
840
+ context.config = {
841
+ ...context.config,
842
+ wipLimits: [{ repository: 'example/widget', name: 'Urgent', match: { label: 'urgent' }, limit: 2 }],
843
+ };
844
+ let requests = 0;
845
+ context.clients.rest.issues.listLabelsForRepo = (async () => {
846
+ requests++;
847
+ return {
848
+ data: requests > 20
849
+ ? []
850
+ : Array.from({ length: 100 }, (_, index) => ({
851
+ name: index === 0 && requests === 1 ? 'urgent' : `label-${String(requests)}-${String(index)}`,
852
+ })),
853
+ };
854
+ });
855
+ await assert.rejects(issue.assertIssueStartCapacity(context, 17), (error) => {
856
+ assert.ok(error instanceof Error);
857
+ assert.equal(error.name, 'CollectionLimitError');
858
+ return true;
859
+ });
860
+ assert.equal(requests, 20);
861
+ });
862
+ function membershipFixture() {
863
+ const configuration = { ...listingFixture().context.projectConfiguration, writable: true };
864
+ const events = [];
865
+ const controls = { corrupt: '', archived: false, duplicate: false, unreadable: false };
866
+ let member = false;
867
+ let status = null;
868
+ const item = (readback = false) => ({
869
+ id: readback && controls.corrupt === 'item' ? 'WRONG' : 'ITEM17',
870
+ isArchived: controls.archived,
871
+ project: { id: readback && controls.corrupt === 'project' ? 'WRONG' : 'PROJECT', number: 1 },
872
+ content: controls.unreadable
873
+ ? null
874
+ : {
875
+ __typename: 'Issue',
876
+ id: readback && controls.corrupt === 'issue' ? 'WRONG' : 'ISSUE17',
877
+ number: 17,
878
+ repository: { nameWithOwner: 'example/widget' },
879
+ },
880
+ fieldValueByName: status === null ? null : { name: 'Active', optionId: controls.corrupt === 'option' ? 'WRONG' : 'ACTIVE' },
881
+ });
882
+ const graphql = (async (query) => {
883
+ if (query.includes('mutation AddProjectDeliveryItem')) {
884
+ events.push('add');
885
+ member = true;
886
+ return { addProjectV2ItemById: { item: { id: 'ITEM17' } } };
887
+ }
888
+ if (query.includes('mutation UpdateProjectDeliveryStatus')) {
889
+ events.push('status');
890
+ status = 'In Progress';
891
+ return { updateProjectV2ItemFieldValue: { projectV2Item: { id: 'ITEM17' } } };
892
+ }
893
+ if (query.includes('query ProjectDeliveryItemReadback')) {
894
+ events.push('readback');
895
+ return { node: item(true) };
896
+ }
897
+ if (query.includes('query ProjectDeliveryItems'))
898
+ return {
899
+ organization: {
900
+ projectV2: {
901
+ id: 'PROJECT',
902
+ number: 1,
903
+ items: {
904
+ nodes: member ? (controls.duplicate ? [item(), { ...item(), id: 'SECOND' }] : [item()]) : [],
905
+ pageInfo: { hasNextPage: false, endCursor: null },
906
+ },
907
+ },
908
+ },
909
+ };
910
+ throw new Error('Unexpected membership fixture query.');
911
+ });
912
+ return {
913
+ input: { graphql, configuration, org: 'example', issueNodeId: 'ISSUE17' },
914
+ events,
915
+ controls,
916
+ setMember: () => {
917
+ member = true;
918
+ },
919
+ };
920
+ }
921
+ test('membership-only add verifies the exact unarchived item and reuse writes nothing', async () => {
922
+ const f = membershipFixture();
923
+ const ensure = Reflect.get(projectDelivery, 'ensureIssueProjectMembership');
924
+ assert.equal(typeof ensure, 'function');
925
+ const result = await ensure({
926
+ ...f.input,
927
+ beforeAdd: async () => {
928
+ f.events.push('before-add');
929
+ },
930
+ });
931
+ assert.deepEqual(result, { itemId: 'ITEM17', archived: false });
932
+ assert.deepEqual(f.events, ['before-add', 'add', 'readback']);
933
+ f.events.length = 0;
934
+ await ensure(f.input);
935
+ assert.deepEqual(f.events, ['readback']);
936
+ });
937
+ test.each(['project', 'issue', 'item', 'archive', 'duplicate', 'unreadable'])('membership refuses %s evidence without a repair write', async (failure) => {
938
+ const f = membershipFixture();
939
+ f.setMember();
940
+ if (failure === 'archive')
941
+ f.controls.archived = true;
942
+ else if (failure === 'duplicate')
943
+ f.controls.duplicate = true;
944
+ else if (failure === 'unreadable')
945
+ f.controls.unreadable = true;
946
+ else
947
+ f.controls.corrupt = failure;
948
+ const ensure = Reflect.get(projectDelivery, 'ensureIssueProjectMembership');
949
+ assert.equal(typeof ensure, 'function');
950
+ await assert.rejects(ensure(f.input));
951
+ assert.deepEqual(f.events.filter((e) => e === 'add' || e === 'status'), []);
952
+ });
953
+ test('guards run immediately before both Project mutation boundaries', async () => {
954
+ const f = membershipFixture();
955
+ const input = {
956
+ ...f.input,
957
+ status: 'In Progress',
958
+ beforeAdd: async () => {
959
+ f.events.push('before-add');
960
+ },
961
+ beforeAdvance: async () => {
962
+ f.events.push('before-advance');
963
+ },
964
+ };
965
+ await projectDelivery.syncIssueProjectStatus(input);
966
+ assert.deepEqual(f.events.filter((e) => e !== 'readback'), ['before-add', 'add', 'before-advance', 'status']);
967
+ const refused = membershipFixture();
968
+ const fail = {
969
+ ...refused.input,
970
+ status: 'In Progress',
971
+ beforeAdd: async () => {
972
+ throw new Error('native drift');
973
+ },
974
+ };
975
+ await assert.rejects(projectDelivery.syncIssueProjectStatus(fail), /native drift/u);
976
+ assert.deepEqual(refused.events, []);
977
+ });
978
+ test('strict Project observation refuses hidden content instead of proving absence', async () => {
979
+ const f = membershipFixture();
980
+ f.setMember();
981
+ f.controls.unreadable = true;
982
+ const read = Reflect.get(projectDelivery, 'readProjectDeliveryItems');
983
+ assert.equal(typeof read, 'function');
984
+ await assert.rejects(read({ ...f.input, maxPages: 20 }));
985
+ assert.deepEqual(f.events, []);
986
+ });
987
+ test('strict Project observation retains exact identities and verified non-issue kinds', async () => {
988
+ const f = membershipFixture();
989
+ f.setMember();
990
+ const base = f.input.graphql;
991
+ const graphql = (async (query) => {
992
+ const response = await base(query);
993
+ const data = response;
994
+ data.organization.projectV2.items.nodes.push({
995
+ id: 'DRAFT',
996
+ isArchived: false,
997
+ content: { __typename: 'DraftIssue', id: 'DRAFT-CONTENT' },
998
+ fieldValueByName: null,
999
+ }, { id: 'PR', isArchived: true, content: { __typename: 'PullRequest', id: 'PR-CONTENT' }, fieldValueByName: null });
1000
+ return data;
1001
+ });
1002
+ const result = await projectDelivery.readProjectDeliveryItems({ ...f.input, graphql, maxPages: 20 });
1003
+ assert.deepEqual(result[0], {
1004
+ id: 'ITEM17',
1005
+ archived: false,
1006
+ contentId: 'ISSUE17',
1007
+ status: null,
1008
+ statusOptionId: null,
1009
+ projectId: 'PROJECT',
1010
+ projectNumber: 1,
1011
+ contentKind: 'issue',
1012
+ statusRead: 'unset',
1013
+ statusName: null,
1014
+ repository: 'example/widget',
1015
+ issueNumber: 17,
1016
+ });
1017
+ assert.deepEqual(result.map((item) => item.contentKind), ['issue', 'draft', 'pull-request']);
1018
+ assert.deepEqual(f.events, []);
1019
+ });
1020
+ test.each(['project', 'option'])('Project %s readback failure preserves an attempted write without retry', async (failure) => {
1021
+ const f = membershipFixture();
1022
+ f.controls.corrupt = failure;
1023
+ if (failure === 'project') {
1024
+ await assert.rejects(projectDelivery.ensureIssueProjectMembership(f.input), /exact issue item/u);
1025
+ assert.deepEqual(f.events, ['add', 'readback']);
1026
+ }
1027
+ else {
1028
+ f.setMember();
1029
+ await assert.rejects(projectDelivery.syncIssueProjectStatus({ ...f.input, status: 'In Progress' }), /unsupported Project Status/u);
1030
+ assert.deepEqual(f.events, ['status', 'readback']);
1031
+ }
1032
+ });
608
1033
  test('search applies the same case-insensitive label filter to authoritative result rows', async () => {
609
1034
  const { context } = listingFixture();
610
1035
  context.clients.rest.search.issuesAndPullRequests = (async () => ({