agent-dealer 1.2.7 → 1.2.9

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 (112) hide show
  1. package/bundle/server/dist/adapters/agent-deck-bind.js +16 -6
  2. package/bundle/server/dist/adapters/agent-deck-bind.test.js +74 -0
  3. package/bundle/server/dist/adapters/agent-health.js +14 -3
  4. package/bundle/server/dist/adapters/github.js +84 -5
  5. package/bundle/server/dist/adapters/github.test.js +83 -1
  6. package/bundle/server/dist/adapters/muse-capability.js +443 -24
  7. package/bundle/server/dist/adapters/muse-capability.test.js +469 -25
  8. package/bundle/server/dist/adapters/muse-visual-qa.js +114 -0
  9. package/bundle/server/dist/adapters/muse-visual-qa.test.js +68 -0
  10. package/bundle/server/dist/adapters/worktree-deps.js +96 -0
  11. package/bundle/server/dist/adapters/worktree-deps.test.js +144 -0
  12. package/bundle/server/dist/capacity/muse-probe.js +56 -9
  13. package/bundle/server/dist/capacity/muse-probe.test.js +188 -1
  14. package/bundle/server/dist/coordinator/admission.js +14 -1
  15. package/bundle/server/dist/coordinator/admission.test.js +197 -4
  16. package/bundle/server/dist/coordinator/auto-merge.integration.test.js +276 -0
  17. package/bundle/server/dist/coordinator/auto-merge.js +244 -4
  18. package/bundle/server/dist/coordinator/checks-wait-config.js +19 -0
  19. package/bundle/server/dist/coordinator/commands.js +284 -23
  20. package/bundle/server/dist/coordinator/commands.test.js +47 -0
  21. package/bundle/server/dist/coordinator/deck-outage.integration.test.js +4 -2
  22. package/bundle/server/dist/coordinator/developer-effect.js +224 -4
  23. package/bundle/server/dist/coordinator/developer-effect.test.js +288 -3
  24. package/bundle/server/dist/coordinator/execution-report.js +6 -0
  25. package/bundle/server/dist/coordinator/execution-report.test.js +7 -0
  26. package/bundle/server/dist/coordinator/failure-cause.js +64 -1
  27. package/bundle/server/dist/coordinator/failure-cause.test.js +92 -1
  28. package/bundle/server/dist/coordinator/failure-reason.js +7 -0
  29. package/bundle/server/dist/coordinator/failure-reason.test.js +14 -0
  30. package/bundle/server/dist/coordinator/human-resolution.js +36 -1
  31. package/bundle/server/dist/coordinator/human-resolution.test.js +33 -0
  32. package/bundle/server/dist/coordinator/merge-conflict-sync.js +647 -0
  33. package/bundle/server/dist/coordinator/merge-conflict-sync.test.js +121 -0
  34. package/bundle/server/dist/coordinator/muse-developer.integration.test.js +9 -4
  35. package/bundle/server/dist/coordinator/muse-spawn.js +122 -29
  36. package/bundle/server/dist/coordinator/muse-spawn.test.js +210 -0
  37. package/bundle/server/dist/coordinator/operator-criteria.js +168 -0
  38. package/bundle/server/dist/coordinator/operator-criteria.test.js +78 -0
  39. package/bundle/server/dist/coordinator/operator-verification.integration.test.js +347 -0
  40. package/bundle/server/dist/coordinator/playbook-feedback.js +693 -0
  41. package/bundle/server/dist/coordinator/playbook-feedback.test.js +702 -0
  42. package/bundle/server/dist/coordinator/projection.js +10 -4
  43. package/bundle/server/dist/coordinator/projection.test.js +13 -0
  44. package/bundle/server/dist/coordinator/prompts-execution-contract.test.js +107 -0
  45. package/bundle/server/dist/coordinator/prompts.js +211 -2
  46. package/bundle/server/dist/coordinator/prompts.test.js +231 -0
  47. package/bundle/server/dist/coordinator/recovery.js +57 -3
  48. package/bundle/server/dist/coordinator/recovery.test.js +67 -8
  49. package/bundle/server/dist/coordinator/reflect-trigger.js +33 -169
  50. package/bundle/server/dist/coordinator/reflect-trigger.test.js +149 -200
  51. package/bundle/server/dist/coordinator/repair-cycle.integration.test.js +1 -0
  52. package/bundle/server/dist/coordinator/reviewer-effect.js +16 -1
  53. package/bundle/server/dist/coordinator/reviewer-result.js +6 -0
  54. package/bundle/server/dist/coordinator/routing.js +45 -6
  55. package/bundle/server/dist/coordinator/routing.test.js +76 -15
  56. package/bundle/server/dist/coordinator/session-timeouts.js +30 -0
  57. package/bundle/server/dist/coordinator/usage-cap-defer.js +61 -0
  58. package/bundle/server/dist/coordinator/usage-cap.integration.test.js +1 -1
  59. package/bundle/server/dist/coordinator/worker-loop.js +18 -4
  60. package/bundle/server/dist/db/ci-attempts-migration.test.js +70 -0
  61. package/bundle/server/dist/db/index.js +18 -0
  62. package/bundle/server/dist/db/schema.sql +5 -0
  63. package/bundle/server/dist/docs-execution-analysis.test.js +1 -0
  64. package/bundle/server/dist/repository/artifacts-for-issue.js +3 -3
  65. package/bundle/server/dist/repository/human-actions.js +14 -0
  66. package/bundle/server/dist/repository/issues.js +67 -6
  67. package/bundle/server/dist/repository/work-items.js +7 -0
  68. package/bundle/server/dist/repository/worker-sessions.js +51 -2
  69. package/bundle/server/dist/routes/human-actions.js +10 -8
  70. package/bundle/server/dist/routes/issues-execution-contract.test.js +321 -0
  71. package/bundle/server/dist/routes/issues.js +19 -2
  72. package/bundle/server/dist/runners/muse-code-args.js +25 -0
  73. package/bundle/server/dist/runners/muse-code-args.test.js +30 -0
  74. package/bundle/server/dist/runners/muse-code-jsonl.js +106 -11
  75. package/bundle/server/dist/runners/muse-config-core.js +18 -1
  76. package/bundle/server/dist/runners/muse-config.test.js +37 -0
  77. package/bundle/server/dist/runners/muse-serve-session.js +5 -0
  78. package/bundle/server/dist/runners/spawn-cli.js +116 -0
  79. package/bundle/server/dist/runners/spawn-cli.test.js +124 -0
  80. package/bundle/server/package.json +2 -2
  81. package/bundle/server/static-ui/assets/index-CU6fNntg.js +64 -0
  82. package/bundle/server/static-ui/assets/{index-DyAJNyfV.css → index-K_YcYkQU.css} +1 -1
  83. package/bundle/server/static-ui/index.html +2 -2
  84. package/bundle/shared/dist/execution-analysis.d.ts +22 -22
  85. package/bundle/shared/dist/execution-contract.d.ts +117 -0
  86. package/bundle/shared/dist/execution-contract.js +307 -0
  87. package/bundle/shared/dist/execution-contract.test.d.ts +2 -0
  88. package/bundle/shared/dist/execution-contract.test.js +499 -0
  89. package/bundle/shared/dist/execution-report.d.ts +9 -9
  90. package/bundle/shared/dist/execution-report.js +2 -0
  91. package/bundle/shared/dist/failure-cause.d.ts +4 -4
  92. package/bundle/shared/dist/failure-cause.js +2 -0
  93. package/bundle/shared/dist/human-actions.d.ts +4 -4
  94. package/bundle/shared/dist/human-actions.js +17 -0
  95. package/bundle/shared/dist/index.d.ts +85 -84
  96. package/bundle/shared/dist/index.js +3 -0
  97. package/bundle/shared/dist/issues.d.ts +176 -16
  98. package/bundle/shared/dist/issues.js +22 -0
  99. package/bundle/shared/dist/issues.test.js +3 -0
  100. package/bundle/shared/dist/outbound-draft.d.ts +12 -12
  101. package/bundle/shared/dist/worker-sessions.d.ts +10 -0
  102. package/bundle/shared/dist/worker-sessions.js +8 -0
  103. package/bundle/shared/dist/worker-sessions.test.js +1 -0
  104. package/bundle/shared/dist/workflow.d.ts +4 -4
  105. package/bundle/shared/dist/workflow.js +16 -0
  106. package/bundle/shared/dist/workflow.test.js +3 -0
  107. package/bundle/shared/package.json +1 -1
  108. package/dist/action.js +4 -1
  109. package/dist/action.test.js +42 -0
  110. package/dist/index.js +1 -1
  111. package/package.json +1 -1
  112. package/bundle/server/static-ui/assets/index-yLyxRd-7.js +0 -64
@@ -3,6 +3,12 @@ export declare const IssueStatus: z.ZodEnum<["ready", "developing", "reviewing",
3
3
  export type IssueStatus = z.infer<typeof IssueStatus>;
4
4
  export declare const IssueOwner: z.ZodEnum<["human", "developer", "reviewer", "system"]>;
5
5
  export type IssueOwner = z.infer<typeof IssueOwner>;
6
+ /**
7
+ * NOT-313: default CI-repair budget — a failing CI check is the expected feedback
8
+ * loop, not an infrastructure failure, so it spends `ci_attempts` (bounded by this),
9
+ * never `infra_attempts`. Mirrors the infra default (3) deliberately.
10
+ */
11
+ export declare const DEFAULT_MAX_CI_ATTEMPTS = 3;
6
12
  /** "agent" covers an issue a coding agent created via the API/CLI (PRD §5). */
7
13
  export declare const IssueSource: z.ZodEnum<["manual", "linear", "agent"]>;
8
14
  export type IssueSource = z.infer<typeof IssueSource>;
@@ -15,6 +21,49 @@ export declare const Issue: z.ZodObject<{
15
21
  title: z.ZodString;
16
22
  description: z.ZodNullable<z.ZodString>;
17
23
  acceptanceCriteria: z.ZodNullable<z.ZodString>;
24
+ /**
25
+ * NOT-306: compiled execution contract derived from the ticket description
26
+ * (canonical `##` headings). Derived data — the description stays the source
27
+ * of truth — null for legacy/contract-free issues. Optional so previously
28
+ * stored rows and existing fixtures parse unchanged.
29
+ */
30
+ executionContract: z.ZodOptional<z.ZodNullable<z.ZodObject<{
31
+ version: z.ZodLiteral<"v1">;
32
+ executionMode: z.ZodEnum<["feature", "bug fix", "refactor", "investigation", "split child"]>;
33
+ nonGoals: z.ZodArray<z.ZodString, "many">;
34
+ exitPredicate: z.ZodString;
35
+ onePrStoppingPoint: z.ZodString;
36
+ acceptanceCriteria: z.ZodArray<z.ZodObject<{
37
+ text: z.ZodString;
38
+ evidence: z.ZodNullable<z.ZodString>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ text: string;
41
+ evidence: string | null;
42
+ }, {
43
+ text: string;
44
+ evidence: string | null;
45
+ }>, "many">;
46
+ }, "strip", z.ZodTypeAny, {
47
+ version: "v1";
48
+ executionMode: "feature" | "bug fix" | "refactor" | "investigation" | "split child";
49
+ nonGoals: string[];
50
+ exitPredicate: string;
51
+ onePrStoppingPoint: string;
52
+ acceptanceCriteria: {
53
+ text: string;
54
+ evidence: string | null;
55
+ }[];
56
+ }, {
57
+ version: "v1";
58
+ executionMode: "feature" | "bug fix" | "refactor" | "investigation" | "split child";
59
+ nonGoals: string[];
60
+ exitPredicate: string;
61
+ onePrStoppingPoint: string;
62
+ acceptanceCriteria: {
63
+ text: string;
64
+ evidence: string | null;
65
+ }[];
66
+ }>>>;
18
67
  /**
19
68
  * Portable GitHub identity (`github.com/owner/repo`) for new issues (NOT-149).
20
69
  * Legacy rows may still hold a local filesystem path until explicitly migrated —
@@ -32,6 +81,14 @@ export declare const Issue: z.ZodObject<{
32
81
  /** 0 is a valid policy: no automatic infra retry, escalate to a human immediately. */
33
82
  maxInfraAttempts: z.ZodNumber;
34
83
  infraAttempts: z.ZodNumber;
84
+ /**
85
+ * NOT-313: separate CI-repair budget. `checks_failed` spends `ciAttempts`
86
+ * (bounded by `maxCiAttempts`), every other retryable failure spends
87
+ * `infraAttempts`. 0 means no automatic CI repair — escalate immediately.
88
+ * Deliberately absent from CreateIssueInput/UpdateIssueInput (no per-ticket config).
89
+ */
90
+ maxCiAttempts: z.ZodNumber;
91
+ ciAttempts: z.ZodNumber;
35
92
  branch: z.ZodNullable<z.ZodString>;
36
93
  baseSha: z.ZodNullable<z.ZodString>;
37
94
  headSha: z.ZodNullable<z.ZodString>;
@@ -52,13 +109,13 @@ export declare const Issue: z.ZodObject<{
52
109
  createdAt: string;
53
110
  updatedAt: string;
54
111
  repo: string;
112
+ acceptanceCriteria: string | null;
113
+ description: string | null;
55
114
  title: string;
56
115
  source: "manual" | "linear" | "agent";
57
116
  externalId: string | null;
58
117
  externalLabel: string | null;
59
118
  externalUrl: string | null;
60
- description: string | null;
61
- acceptanceCriteria: string | null;
62
119
  baseBranch: string;
63
120
  currentOwner: "reviewer" | "developer" | "human" | "system";
64
121
  currentIntent: string | null;
@@ -68,11 +125,24 @@ export declare const Issue: z.ZodObject<{
68
125
  currentRound: number;
69
126
  maxInfraAttempts: number;
70
127
  infraAttempts: number;
128
+ maxCiAttempts: number;
129
+ ciAttempts: number;
71
130
  baseSha: string | null;
72
131
  headSha: string | null;
73
132
  prNumber: number | null;
74
133
  prUrl: string | null;
75
134
  autoMerge: boolean;
135
+ executionContract?: {
136
+ version: "v1";
137
+ executionMode: "feature" | "bug fix" | "refactor" | "investigation" | "split child";
138
+ nonGoals: string[];
139
+ exitPredicate: string;
140
+ onePrStoppingPoint: string;
141
+ acceptanceCriteria: {
142
+ text: string;
143
+ evidence: string | null;
144
+ }[];
145
+ } | null | undefined;
76
146
  }, {
77
147
  branch: string | null;
78
148
  status: "final_review" | "done" | "ready" | "developing" | "reviewing" | "repairing" | "needs_human" | "closed";
@@ -80,13 +150,13 @@ export declare const Issue: z.ZodObject<{
80
150
  createdAt: string;
81
151
  updatedAt: string;
82
152
  repo: string;
153
+ acceptanceCriteria: string | null;
154
+ description: string | null;
83
155
  title: string;
84
156
  source: "manual" | "linear" | "agent";
85
157
  externalId: string | null;
86
158
  externalLabel: string | null;
87
159
  externalUrl: string | null;
88
- description: string | null;
89
- acceptanceCriteria: string | null;
90
160
  baseBranch: string;
91
161
  currentOwner: "reviewer" | "developer" | "human" | "system";
92
162
  currentIntent: string | null;
@@ -96,11 +166,24 @@ export declare const Issue: z.ZodObject<{
96
166
  currentRound: number;
97
167
  maxInfraAttempts: number;
98
168
  infraAttempts: number;
169
+ maxCiAttempts: number;
170
+ ciAttempts: number;
99
171
  baseSha: string | null;
100
172
  headSha: string | null;
101
173
  prNumber: number | null;
102
174
  prUrl: string | null;
103
175
  autoMerge: boolean;
176
+ executionContract?: {
177
+ version: "v1";
178
+ executionMode: "feature" | "bug fix" | "refactor" | "investigation" | "split child";
179
+ nonGoals: string[];
180
+ exitPredicate: string;
181
+ onePrStoppingPoint: string;
182
+ acceptanceCriteria: {
183
+ text: string;
184
+ evidence: string | null;
185
+ }[];
186
+ } | null | undefined;
104
187
  }>;
105
188
  export type Issue = z.infer<typeof Issue>;
106
189
  export declare const CreateIssueInput: z.ZodObject<{
@@ -137,22 +220,22 @@ export declare const CreateIssueInput: z.ZodObject<{
137
220
  maxInfraAttempts: number;
138
221
  autoMerge: boolean;
139
222
  enqueue: boolean;
223
+ acceptanceCriteria?: string | undefined;
224
+ description?: string | undefined;
140
225
  externalId?: string | undefined;
141
226
  externalLabel?: string | undefined;
142
227
  externalUrl?: string | undefined;
143
- description?: string | undefined;
144
- acceptanceCriteria?: string | undefined;
145
228
  }, {
146
229
  repo: string;
147
230
  title: string;
148
231
  developerAgentId: string;
149
232
  reviewerAgentId: string;
233
+ acceptanceCriteria?: string | undefined;
234
+ description?: string | undefined;
150
235
  source?: "manual" | "linear" | "agent" | undefined;
151
236
  externalId?: string | undefined;
152
237
  externalLabel?: string | undefined;
153
238
  externalUrl?: string | undefined;
154
- description?: string | undefined;
155
- acceptanceCriteria?: string | undefined;
156
239
  baseBranch?: string | undefined;
157
240
  maxReviewRounds?: number | undefined;
158
241
  maxInfraAttempts?: number | undefined;
@@ -176,9 +259,9 @@ export declare const UpdateIssueInput: z.ZodObject<{
176
259
  autoMerge: z.ZodOptional<z.ZodBoolean>;
177
260
  }, "strip", z.ZodTypeAny, {
178
261
  repo?: string | undefined;
179
- title?: string | undefined;
180
- description?: string | null | undefined;
181
262
  acceptanceCriteria?: string | null | undefined;
263
+ description?: string | null | undefined;
264
+ title?: string | undefined;
182
265
  baseBranch?: string | undefined;
183
266
  developerAgentId?: string | undefined;
184
267
  reviewerAgentId?: string | undefined;
@@ -187,9 +270,9 @@ export declare const UpdateIssueInput: z.ZodObject<{
187
270
  autoMerge?: boolean | undefined;
188
271
  }, {
189
272
  repo?: string | undefined;
190
- title?: string | undefined;
191
- description?: string | null | undefined;
192
273
  acceptanceCriteria?: string | null | undefined;
274
+ description?: string | null | undefined;
275
+ title?: string | undefined;
193
276
  baseBranch?: string | undefined;
194
277
  developerAgentId?: string | undefined;
195
278
  reviewerAgentId?: string | undefined;
@@ -239,6 +322,49 @@ export declare const CreateIssueResult: z.ZodObject<{
239
322
  title: z.ZodString;
240
323
  description: z.ZodNullable<z.ZodString>;
241
324
  acceptanceCriteria: z.ZodNullable<z.ZodString>;
325
+ /**
326
+ * NOT-306: compiled execution contract derived from the ticket description
327
+ * (canonical `##` headings). Derived data — the description stays the source
328
+ * of truth — null for legacy/contract-free issues. Optional so previously
329
+ * stored rows and existing fixtures parse unchanged.
330
+ */
331
+ executionContract: z.ZodOptional<z.ZodNullable<z.ZodObject<{
332
+ version: z.ZodLiteral<"v1">;
333
+ executionMode: z.ZodEnum<["feature", "bug fix", "refactor", "investigation", "split child"]>;
334
+ nonGoals: z.ZodArray<z.ZodString, "many">;
335
+ exitPredicate: z.ZodString;
336
+ onePrStoppingPoint: z.ZodString;
337
+ acceptanceCriteria: z.ZodArray<z.ZodObject<{
338
+ text: z.ZodString;
339
+ evidence: z.ZodNullable<z.ZodString>;
340
+ }, "strip", z.ZodTypeAny, {
341
+ text: string;
342
+ evidence: string | null;
343
+ }, {
344
+ text: string;
345
+ evidence: string | null;
346
+ }>, "many">;
347
+ }, "strip", z.ZodTypeAny, {
348
+ version: "v1";
349
+ executionMode: "feature" | "bug fix" | "refactor" | "investigation" | "split child";
350
+ nonGoals: string[];
351
+ exitPredicate: string;
352
+ onePrStoppingPoint: string;
353
+ acceptanceCriteria: {
354
+ text: string;
355
+ evidence: string | null;
356
+ }[];
357
+ }, {
358
+ version: "v1";
359
+ executionMode: "feature" | "bug fix" | "refactor" | "investigation" | "split child";
360
+ nonGoals: string[];
361
+ exitPredicate: string;
362
+ onePrStoppingPoint: string;
363
+ acceptanceCriteria: {
364
+ text: string;
365
+ evidence: string | null;
366
+ }[];
367
+ }>>>;
242
368
  /**
243
369
  * Portable GitHub identity (`github.com/owner/repo`) for new issues (NOT-149).
244
370
  * Legacy rows may still hold a local filesystem path until explicitly migrated —
@@ -256,6 +382,14 @@ export declare const CreateIssueResult: z.ZodObject<{
256
382
  /** 0 is a valid policy: no automatic infra retry, escalate to a human immediately. */
257
383
  maxInfraAttempts: z.ZodNumber;
258
384
  infraAttempts: z.ZodNumber;
385
+ /**
386
+ * NOT-313: separate CI-repair budget. `checks_failed` spends `ciAttempts`
387
+ * (bounded by `maxCiAttempts`), every other retryable failure spends
388
+ * `infraAttempts`. 0 means no automatic CI repair — escalate immediately.
389
+ * Deliberately absent from CreateIssueInput/UpdateIssueInput (no per-ticket config).
390
+ */
391
+ maxCiAttempts: z.ZodNumber;
392
+ ciAttempts: z.ZodNumber;
259
393
  branch: z.ZodNullable<z.ZodString>;
260
394
  baseSha: z.ZodNullable<z.ZodString>;
261
395
  headSha: z.ZodNullable<z.ZodString>;
@@ -286,13 +420,13 @@ export declare const CreateIssueResult: z.ZodObject<{
286
420
  createdAt: string;
287
421
  updatedAt: string;
288
422
  repo: string;
423
+ acceptanceCriteria: string | null;
424
+ description: string | null;
289
425
  title: string;
290
426
  source: "manual" | "linear" | "agent";
291
427
  externalId: string | null;
292
428
  externalLabel: string | null;
293
429
  externalUrl: string | null;
294
- description: string | null;
295
- acceptanceCriteria: string | null;
296
430
  baseBranch: string;
297
431
  currentOwner: "reviewer" | "developer" | "human" | "system";
298
432
  currentIntent: string | null;
@@ -302,6 +436,8 @@ export declare const CreateIssueResult: z.ZodObject<{
302
436
  currentRound: number;
303
437
  maxInfraAttempts: number;
304
438
  infraAttempts: number;
439
+ maxCiAttempts: number;
440
+ ciAttempts: number;
305
441
  baseSha: string | null;
306
442
  headSha: string | null;
307
443
  prNumber: number | null;
@@ -310,6 +446,17 @@ export declare const CreateIssueResult: z.ZodObject<{
310
446
  created: boolean;
311
447
  queue: "enqueued" | "already_queued" | "not_queued";
312
448
  priorPasses: number;
449
+ executionContract?: {
450
+ version: "v1";
451
+ executionMode: "feature" | "bug fix" | "refactor" | "investigation" | "split child";
452
+ nonGoals: string[];
453
+ exitPredicate: string;
454
+ onePrStoppingPoint: string;
455
+ acceptanceCriteria: {
456
+ text: string;
457
+ evidence: string | null;
458
+ }[];
459
+ } | null | undefined;
313
460
  }, {
314
461
  branch: string | null;
315
462
  status: "final_review" | "done" | "ready" | "developing" | "reviewing" | "repairing" | "needs_human" | "closed";
@@ -317,13 +464,13 @@ export declare const CreateIssueResult: z.ZodObject<{
317
464
  createdAt: string;
318
465
  updatedAt: string;
319
466
  repo: string;
467
+ acceptanceCriteria: string | null;
468
+ description: string | null;
320
469
  title: string;
321
470
  source: "manual" | "linear" | "agent";
322
471
  externalId: string | null;
323
472
  externalLabel: string | null;
324
473
  externalUrl: string | null;
325
- description: string | null;
326
- acceptanceCriteria: string | null;
327
474
  baseBranch: string;
328
475
  currentOwner: "reviewer" | "developer" | "human" | "system";
329
476
  currentIntent: string | null;
@@ -333,6 +480,8 @@ export declare const CreateIssueResult: z.ZodObject<{
333
480
  currentRound: number;
334
481
  maxInfraAttempts: number;
335
482
  infraAttempts: number;
483
+ maxCiAttempts: number;
484
+ ciAttempts: number;
336
485
  baseSha: string | null;
337
486
  headSha: string | null;
338
487
  prNumber: number | null;
@@ -341,6 +490,17 @@ export declare const CreateIssueResult: z.ZodObject<{
341
490
  created: boolean;
342
491
  queue: "enqueued" | "already_queued" | "not_queued";
343
492
  priorPasses: number;
493
+ executionContract?: {
494
+ version: "v1";
495
+ executionMode: "feature" | "bug fix" | "refactor" | "investigation" | "split child";
496
+ nonGoals: string[];
497
+ exitPredicate: string;
498
+ onePrStoppingPoint: string;
499
+ acceptanceCriteria: {
500
+ text: string;
501
+ evidence: string | null;
502
+ }[];
503
+ } | null | undefined;
344
504
  }>;
345
505
  export type CreateIssueResult = z.infer<typeof CreateIssueResult>;
346
506
  /** 409 body when a re-import collides with a live issue — mirrors the runs promote path. */
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { GitHubRepoInput } from "./github-repo.js";
3
+ import { ExecutionContractV1 } from "./execution-contract.js";
3
4
  export const IssueStatus = z.enum([
4
5
  "ready",
5
6
  "developing",
@@ -11,6 +12,12 @@ export const IssueStatus = z.enum([
11
12
  "closed",
12
13
  ]);
13
14
  export const IssueOwner = z.enum(["human", "developer", "reviewer", "system"]);
15
+ /**
16
+ * NOT-313: default CI-repair budget — a failing CI check is the expected feedback
17
+ * loop, not an infrastructure failure, so it spends `ci_attempts` (bounded by this),
18
+ * never `infra_attempts`. Mirrors the infra default (3) deliberately.
19
+ */
20
+ export const DEFAULT_MAX_CI_ATTEMPTS = 3;
14
21
  /** "agent" covers an issue a coding agent created via the API/CLI (PRD §5). */
15
22
  export const IssueSource = z.enum(["manual", "linear", "agent"]);
16
23
  export const Issue = z.object({
@@ -22,6 +29,13 @@ export const Issue = z.object({
22
29
  title: z.string(),
23
30
  description: z.string().nullable(),
24
31
  acceptanceCriteria: z.string().nullable(),
32
+ /**
33
+ * NOT-306: compiled execution contract derived from the ticket description
34
+ * (canonical `##` headings). Derived data — the description stays the source
35
+ * of truth — null for legacy/contract-free issues. Optional so previously
36
+ * stored rows and existing fixtures parse unchanged.
37
+ */
38
+ executionContract: ExecutionContractV1.nullable().optional(),
25
39
  /**
26
40
  * Portable GitHub identity (`github.com/owner/repo`) for new issues (NOT-149).
27
41
  * Legacy rows may still hold a local filesystem path until explicitly migrated —
@@ -39,6 +53,14 @@ export const Issue = z.object({
39
53
  /** 0 is a valid policy: no automatic infra retry, escalate to a human immediately. */
40
54
  maxInfraAttempts: z.number().int().min(0),
41
55
  infraAttempts: z.number().int().min(0),
56
+ /**
57
+ * NOT-313: separate CI-repair budget. `checks_failed` spends `ciAttempts`
58
+ * (bounded by `maxCiAttempts`), every other retryable failure spends
59
+ * `infraAttempts`. 0 means no automatic CI repair — escalate immediately.
60
+ * Deliberately absent from CreateIssueInput/UpdateIssueInput (no per-ticket config).
61
+ */
62
+ maxCiAttempts: z.number().int().min(0),
63
+ ciAttempts: z.number().int().min(0),
42
64
  branch: z.string().nullable(),
43
65
  baseSha: z.string().nullable(),
44
66
  headSha: z.string().nullable(),
@@ -27,6 +27,7 @@ test("Issue schema parses a well-formed issue", () => {
27
27
  title: "Fix login bug",
28
28
  description: null,
29
29
  acceptanceCriteria: null,
30
+ executionContract: null,
30
31
  repo: "acme/app",
31
32
  baseBranch: "main",
32
33
  status: "ready",
@@ -38,6 +39,8 @@ test("Issue schema parses a well-formed issue", () => {
38
39
  currentRound: 1,
39
40
  maxInfraAttempts: 3,
40
41
  infraAttempts: 0,
42
+ maxCiAttempts: 3,
43
+ ciAttempts: 0,
41
44
  branch: null,
42
45
  baseSha: null,
43
46
  headSha: null,
@@ -5,11 +5,11 @@ export declare const OutboundDraftSummary: z.ZodObject<{
5
5
  target: z.ZodString;
6
6
  body: z.ZodString;
7
7
  }, "strip", z.ZodTypeAny, {
8
- target: string;
9
8
  body: string;
10
- }, {
11
9
  target: string;
10
+ }, {
12
11
  body: string;
12
+ target: string;
13
13
  }>;
14
14
  export type OutboundDraftSummary = z.infer<typeof OutboundDraftSummary>;
15
15
  export declare const OutboundToolCall: z.ZodObject<{
@@ -33,11 +33,11 @@ export declare const OutboundDraftBlock: z.ZodObject<{
33
33
  target: z.ZodString;
34
34
  body: z.ZodString;
35
35
  }, "strip", z.ZodTypeAny, {
36
- target: string;
37
36
  body: string;
38
- }, {
39
37
  target: string;
38
+ }, {
40
39
  body: string;
40
+ target: string;
41
41
  }>;
42
42
  toolCall: z.ZodObject<{
43
43
  serviceName: z.ZodString;
@@ -55,8 +55,8 @@ export declare const OutboundDraftBlock: z.ZodObject<{
55
55
  }, "strip", z.ZodTypeAny, {
56
56
  actionType: "slack_message" | "email" | "service_tool_call";
57
57
  summary: {
58
- target: string;
59
58
  body: string;
59
+ target: string;
60
60
  };
61
61
  toolCall: {
62
62
  serviceName: string;
@@ -66,8 +66,8 @@ export declare const OutboundDraftBlock: z.ZodObject<{
66
66
  }, {
67
67
  actionType: "slack_message" | "email" | "service_tool_call";
68
68
  summary: {
69
- target: string;
70
69
  body: string;
70
+ target: string;
71
71
  };
72
72
  toolCall: {
73
73
  serviceName: string;
@@ -86,11 +86,11 @@ export declare const OutboundDraftContent: z.ZodObject<{
86
86
  target: z.ZodString;
87
87
  body: z.ZodString;
88
88
  }, "strip", z.ZodTypeAny, {
89
- target: string;
90
89
  body: string;
91
- }, {
92
90
  target: string;
91
+ }, {
93
92
  body: string;
93
+ target: string;
94
94
  }>;
95
95
  toolCall: z.ZodObject<{
96
96
  serviceName: z.ZodString;
@@ -108,8 +108,8 @@ export declare const OutboundDraftContent: z.ZodObject<{
108
108
  }, "strip", z.ZodTypeAny, {
109
109
  actionType: "slack_message" | "email" | "service_tool_call";
110
110
  summary: {
111
- target: string;
112
111
  body: string;
112
+ target: string;
113
113
  };
114
114
  toolCall: {
115
115
  serviceName: string;
@@ -119,8 +119,8 @@ export declare const OutboundDraftContent: z.ZodObject<{
119
119
  }, {
120
120
  actionType: "slack_message" | "email" | "service_tool_call";
121
121
  summary: {
122
- target: string;
123
122
  body: string;
123
+ target: string;
124
124
  };
125
125
  toolCall: {
126
126
  serviceName: string;
@@ -141,8 +141,8 @@ export declare const OutboundDraftContent: z.ZodObject<{
141
141
  draft: {
142
142
  actionType: "slack_message" | "email" | "service_tool_call";
143
143
  summary: {
144
- target: string;
145
144
  body: string;
145
+ target: string;
146
146
  };
147
147
  toolCall: {
148
148
  serviceName: string;
@@ -159,8 +159,8 @@ export declare const OutboundDraftContent: z.ZodObject<{
159
159
  draft: {
160
160
  actionType: "slack_message" | "email" | "service_tool_call";
161
161
  summary: {
162
- target: string;
163
162
  body: string;
163
+ target: string;
164
164
  };
165
165
  toolCall: {
166
166
  serviceName: string;
@@ -44,6 +44,14 @@ export declare const WorkerSession: z.ZodObject<{
44
44
  processPid: z.ZodNullable<z.ZodNumber>;
45
45
  processOwner: z.ZodNullable<z.ZodString>;
46
46
  processStartedAt: z.ZodNullable<z.ZodString>;
47
+ /**
48
+ * Opaque Agent Deck correlation UUID for this session (NOT-305). Generated once at
49
+ * session creation, before spawn, and passed as observability metadata in every
50
+ * runtime's Agent Deck launch configuration. Lets Deck correlate its normalized
51
+ * playbook-fetch stream back to this durable Dealer session without granting any
52
+ * authority. Null only for rows written before NOT-305.
53
+ */
54
+ deckCorrelationId: z.ZodNullable<z.ZodString>;
47
55
  createdAt: z.ZodString;
48
56
  startedAt: z.ZodNullable<z.ZodString>;
49
57
  heartbeatAt: z.ZodNullable<z.ZodString>;
@@ -70,6 +78,7 @@ export declare const WorkerSession: z.ZodObject<{
70
78
  processPid: number | null;
71
79
  processOwner: string | null;
72
80
  processStartedAt: string | null;
81
+ deckCorrelationId: string | null;
73
82
  createdAt: string;
74
83
  startedAt: string | null;
75
84
  heartbeatAt: string | null;
@@ -96,6 +105,7 @@ export declare const WorkerSession: z.ZodObject<{
96
105
  processPid: number | null;
97
106
  processOwner: string | null;
98
107
  processStartedAt: string | null;
108
+ deckCorrelationId: string | null;
99
109
  createdAt: string;
100
110
  startedAt: string | null;
101
111
  heartbeatAt: string | null;
@@ -50,6 +50,14 @@ export const WorkerSession = z.object({
50
50
  processPid: z.number().int().nullable(),
51
51
  processOwner: z.string().nullable(),
52
52
  processStartedAt: z.string().nullable(),
53
+ /**
54
+ * Opaque Agent Deck correlation UUID for this session (NOT-305). Generated once at
55
+ * session creation, before spawn, and passed as observability metadata in every
56
+ * runtime's Agent Deck launch configuration. Lets Deck correlate its normalized
57
+ * playbook-fetch stream back to this durable Dealer session without granting any
58
+ * authority. Null only for rows written before NOT-305.
59
+ */
60
+ deckCorrelationId: z.string().uuid().nullable(),
53
61
  createdAt: z.string(),
54
62
  startedAt: z.string().nullable(),
55
63
  heartbeatAt: z.string().nullable(),
@@ -23,6 +23,7 @@ test("WorkerSession schema parses a queued developer session", () => {
23
23
  processPid: null,
24
24
  processOwner: null,
25
25
  processStartedAt: null,
26
+ deckCorrelationId: null,
26
27
  createdAt: new Date().toISOString(),
27
28
  startedAt: null,
28
29
  heartbeatAt: null,
@@ -24,7 +24,7 @@ export declare const WorkflowInstance: z.ZodObject<{
24
24
  outcome: "done" | "closed" | "migrated" | null;
25
25
  }>;
26
26
  export type WorkflowInstance = z.infer<typeof WorkflowInstance>;
27
- export declare const WorkflowEventType: z.ZodEnum<["issue.created", "issue.reassigned", "workflow.started", "worker.started", "worker.completed", "worker.failed", "worker.deferred", "worktree.ready", "deck.connected", "brief.resolved", "branch.pushed", "checks.started", "pull_request.opened", "pull_request.updated", "checks.completed", "review.submitted", "repair.started", "guidance.added", "task_snapshot.refreshed", "human_action.requested", "human_action.resolved", "final_review.requested", "issue.completed", "issue.closed", "queue.enqueued", "queue.wait_reason_changed", "queue.admitted", "queue.removed", "agent.started", "agent.completed", "host.suspended", "checkpoint.observed", "retry.reused", "legacy.imported"]>;
27
+ export declare const WorkflowEventType: z.ZodEnum<["issue.created", "issue.reassigned", "workflow.started", "worker.started", "worker.completed", "worker.failed", "worker.deferred", "worktree.ready", "worktree.deps_ready", "deck.connected", "brief.resolved", "branch.pushed", "checks.started", "pull_request.opened", "pull_request.updated", "checks.completed", "review.submitted", "repair.started", "guidance.added", "task_snapshot.refreshed", "human_action.requested", "human_action.resolved", "final_review.requested", "issue.completed", "issue.closed", "queue.enqueued", "queue.wait_reason_changed", "queue.admitted", "queue.removed", "agent.started", "agent.completed", "host.suspended", "checkpoint.observed", "retry.reused", "auto_merge.conflict_sync", "auto_merge.conflict_repair_queued", "operator_verification.waived", "legacy.imported"]>;
28
28
  export type WorkflowEventType = z.infer<typeof WorkflowEventType>;
29
29
  export declare const WorkflowEvent: z.ZodObject<{
30
30
  id: z.ZodString;
@@ -32,7 +32,7 @@ export declare const WorkflowEvent: z.ZodObject<{
32
32
  /** Nullable only for issue creation/guidance emitted before any workflow starts. */
33
33
  workflowInstanceId: z.ZodNullable<z.ZodString>;
34
34
  workerSessionId: z.ZodNullable<z.ZodString>;
35
- type: z.ZodEnum<["issue.created", "issue.reassigned", "workflow.started", "worker.started", "worker.completed", "worker.failed", "worker.deferred", "worktree.ready", "deck.connected", "brief.resolved", "branch.pushed", "checks.started", "pull_request.opened", "pull_request.updated", "checks.completed", "review.submitted", "repair.started", "guidance.added", "task_snapshot.refreshed", "human_action.requested", "human_action.resolved", "final_review.requested", "issue.completed", "issue.closed", "queue.enqueued", "queue.wait_reason_changed", "queue.admitted", "queue.removed", "agent.started", "agent.completed", "host.suspended", "checkpoint.observed", "retry.reused", "legacy.imported"]>;
35
+ type: z.ZodEnum<["issue.created", "issue.reassigned", "workflow.started", "worker.started", "worker.completed", "worker.failed", "worker.deferred", "worktree.ready", "worktree.deps_ready", "deck.connected", "brief.resolved", "branch.pushed", "checks.started", "pull_request.opened", "pull_request.updated", "checks.completed", "review.submitted", "repair.started", "guidance.added", "task_snapshot.refreshed", "human_action.requested", "human_action.resolved", "final_review.requested", "issue.completed", "issue.closed", "queue.enqueued", "queue.wait_reason_changed", "queue.admitted", "queue.removed", "agent.started", "agent.completed", "host.suspended", "checkpoint.observed", "retry.reused", "auto_merge.conflict_sync", "auto_merge.conflict_repair_queued", "operator_verification.waived", "legacy.imported"]>;
36
36
  actorType: z.ZodEnum<["human", "developer", "reviewer", "system"]>;
37
37
  actorRef: z.ZodNullable<z.ZodString>;
38
38
  /** Issue status at emit time — lets the timeline render without re-deriving state. */
@@ -45,7 +45,7 @@ export declare const WorkflowEvent: z.ZodObject<{
45
45
  causationEventId: z.ZodNullable<z.ZodString>;
46
46
  ts: z.ZodString;
47
47
  }, "strip", z.ZodTypeAny, {
48
- type: "issue.created" | "issue.reassigned" | "workflow.started" | "worker.started" | "worker.completed" | "worker.failed" | "worker.deferred" | "worktree.ready" | "deck.connected" | "brief.resolved" | "branch.pushed" | "checks.started" | "pull_request.opened" | "pull_request.updated" | "checks.completed" | "review.submitted" | "repair.started" | "guidance.added" | "task_snapshot.refreshed" | "human_action.requested" | "human_action.resolved" | "final_review.requested" | "issue.completed" | "issue.closed" | "queue.enqueued" | "queue.wait_reason_changed" | "queue.admitted" | "queue.removed" | "agent.started" | "agent.completed" | "host.suspended" | "checkpoint.observed" | "retry.reused" | "legacy.imported";
48
+ type: "issue.created" | "issue.reassigned" | "workflow.started" | "worker.started" | "worker.completed" | "worker.failed" | "worker.deferred" | "worktree.ready" | "worktree.deps_ready" | "deck.connected" | "brief.resolved" | "branch.pushed" | "checks.started" | "pull_request.opened" | "pull_request.updated" | "checks.completed" | "review.submitted" | "repair.started" | "guidance.added" | "task_snapshot.refreshed" | "human_action.requested" | "human_action.resolved" | "final_review.requested" | "issue.completed" | "issue.closed" | "queue.enqueued" | "queue.wait_reason_changed" | "queue.admitted" | "queue.removed" | "agent.started" | "agent.completed" | "host.suspended" | "checkpoint.observed" | "retry.reused" | "auto_merge.conflict_sync" | "auto_merge.conflict_repair_queued" | "operator_verification.waived" | "legacy.imported";
49
49
  id: string;
50
50
  issueId: string;
51
51
  round: number | null;
@@ -60,7 +60,7 @@ export declare const WorkflowEvent: z.ZodObject<{
60
60
  causationEventId: string | null;
61
61
  ts: string;
62
62
  }, {
63
- type: "issue.created" | "issue.reassigned" | "workflow.started" | "worker.started" | "worker.completed" | "worker.failed" | "worker.deferred" | "worktree.ready" | "deck.connected" | "brief.resolved" | "branch.pushed" | "checks.started" | "pull_request.opened" | "pull_request.updated" | "checks.completed" | "review.submitted" | "repair.started" | "guidance.added" | "task_snapshot.refreshed" | "human_action.requested" | "human_action.resolved" | "final_review.requested" | "issue.completed" | "issue.closed" | "queue.enqueued" | "queue.wait_reason_changed" | "queue.admitted" | "queue.removed" | "agent.started" | "agent.completed" | "host.suspended" | "checkpoint.observed" | "retry.reused" | "legacy.imported";
63
+ type: "issue.created" | "issue.reassigned" | "workflow.started" | "worker.started" | "worker.completed" | "worker.failed" | "worker.deferred" | "worktree.ready" | "worktree.deps_ready" | "deck.connected" | "brief.resolved" | "branch.pushed" | "checks.started" | "pull_request.opened" | "pull_request.updated" | "checks.completed" | "review.submitted" | "repair.started" | "guidance.added" | "task_snapshot.refreshed" | "human_action.requested" | "human_action.resolved" | "final_review.requested" | "issue.completed" | "issue.closed" | "queue.enqueued" | "queue.wait_reason_changed" | "queue.admitted" | "queue.removed" | "agent.started" | "agent.completed" | "host.suspended" | "checkpoint.observed" | "retry.reused" | "auto_merge.conflict_sync" | "auto_merge.conflict_repair_queued" | "operator_verification.waived" | "legacy.imported";
64
64
  id: string;
65
65
  issueId: string;
66
66
  round: number | null;
@@ -21,6 +21,8 @@ export const WorkflowEventType = z.enum([
21
21
  "worker.deferred",
22
22
  /** Mid-session milestones (NOT-109) — low volume, not per-tool-call. */
23
23
  "worktree.ready",
24
+ /** NOT-315: pre-spawn dependency provisioning settled (ran or skipped). */
25
+ "worktree.deps_ready",
24
26
  "deck.connected",
25
27
  "brief.resolved",
26
28
  "branch.pushed",
@@ -59,6 +61,20 @@ export const WorkflowEventType = z.enum([
59
61
  * per session via idempotency keys and never drive retry/routing decisions. */
60
62
  "checkpoint.observed",
61
63
  "retry.reused",
64
+ /** NOT-310: merge-time base-sync attempt after a not-mergeable failure. Payload
65
+ * carries `outcome` (skipped | merged | repair_queued | conflict_spent |
66
+ * failed) plus the branch, base, and (for conflicts) the conflicting files.
67
+ * Audit only — never re-read. */
68
+ "auto_merge.conflict_sync",
69
+ /** NOT-310: conflict-repair developer round queued after the sync hit a textual
70
+ * conflict (payload: baseBranch, branch, files, round, workItemId). Append-only
71
+ * bound key: a later not-mergeable failure with no `human_action.resolved` after
72
+ * this event escalates with the file list instead of syncing again. */
73
+ "auto_merge.conflict_repair_queued",
74
+ /** NOT-314: the operator explicitly waived an `[operator]` criterion instead of
75
+ * running its probe (payload: headSha the waiver covers, waivedBy, note).
76
+ * The gate re-blocks when the head moves past the waived SHA. */
77
+ "operator_verification.waived",
62
78
  /** Migration-only — the NOT-66 cutover repoints a legacy `events` row under this type,
63
79
  * preserving the original type/payload inside `payloadJson` (see `role: "legacy"` on
64
80
  * `WorkerSessionRole` and `outcome: "migrated"` on `WorkflowInstanceOutcome` for the same
@@ -20,6 +20,7 @@ test("WorkflowEventType accepts every PRD §9.2 event type", () => {
20
20
  "worker.completed",
21
21
  "worker.failed",
22
22
  "worktree.ready",
23
+ "worktree.deps_ready",
23
24
  "deck.connected",
24
25
  "brief.resolved",
25
26
  "branch.pushed",
@@ -41,6 +42,8 @@ test("WorkflowEventType accepts every PRD §9.2 event type", () => {
41
42
  "queue.removed",
42
43
  "checkpoint.observed",
43
44
  "retry.reused",
45
+ "auto_merge.conflict_sync",
46
+ "auto_merge.conflict_repair_queued",
44
47
  ];
45
48
  for (const t of types) {
46
49
  assert.equal(WorkflowEventType.parse(t), t);