@aviaratech/ai-delivery 0.3.43 → 0.3.44

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 (51) hide show
  1. package/README.md +1 -1
  2. package/dist/agentReadiness.test.js +12 -0
  3. package/dist/agentReadiness.test.js.map +2 -2
  4. package/dist/cli.js +2 -1
  5. package/dist/cli.js.map +2 -2
  6. package/dist/directoryIndependent.test.js +22 -3
  7. package/dist/directoryIndependent.test.js.map +3 -3
  8. package/dist/dispatch.js.map +2 -2
  9. package/dist/fixtures/builderReady.d.ts +2 -0
  10. package/dist/fixtures/builderReady.js +2 -0
  11. package/dist/fixtures/builderReady.js.map +2 -2
  12. package/dist/fixtures/inertTarget.d.ts +7 -0
  13. package/dist/fixtures/inertTarget.js +5 -0
  14. package/dist/fixtures/inertTarget.js.map +2 -2
  15. package/dist/fixtures/issue63.d.ts +3 -0
  16. package/dist/issue.d.ts +21 -1
  17. package/dist/issue.js +100 -12
  18. package/dist/issue.js.map +2 -2
  19. package/dist/issueBlockerGuard.test.js +11 -0
  20. package/dist/issueBlockerGuard.test.js.map +2 -2
  21. package/dist/issueContract.d.ts +7 -0
  22. package/dist/issueContract.js +56 -9
  23. package/dist/issueContract.js.map +2 -2
  24. package/dist/issueContract.test.d.ts +1 -0
  25. package/dist/issueContract.test.js +66 -4
  26. package/dist/issueContract.test.js.map +2 -2
  27. package/dist/issueIntake.test.js +17 -0
  28. package/dist/issueIntake.test.js.map +2 -2
  29. package/dist/issueJournal.d.ts +13 -9
  30. package/dist/issueJournal.js +14 -10
  31. package/dist/issueJournal.js.map +2 -2
  32. package/dist/issueJournal.test.js +11 -8
  33. package/dist/issueJournal.test.js.map +2 -2
  34. package/dist/issueTracking.test.js +135 -2
  35. package/dist/issueTracking.test.js.map +3 -3
  36. package/dist/mcp/index.js +10 -3
  37. package/dist/mcp/index.js.map +2 -2
  38. package/dist/mcp/tools.d.ts +39 -25
  39. package/dist/mcp/tools.js +23 -5
  40. package/dist/mcp/tools.js.map +2 -2
  41. package/dist/readView.d.ts +2 -0
  42. package/dist/readView.js +1 -1
  43. package/dist/readView.js.map +2 -2
  44. package/dist/releaseReconciliation.test.js +20 -6
  45. package/dist/releaseReconciliation.test.js.map +2 -2
  46. package/package.json +1 -1
  47. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  48. package/plugins/ai-delivery/plugin.json +1 -1
  49. package/plugins/ai-delivery/runtime/dist/cli.js +138 -112
  50. package/plugins/ai-delivery/runtime/package.json +1 -1
  51. package/plugins/ai-delivery/skills/ticket-design/SKILL.md +11 -10
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
+ export declare const NEXT_DATE_REFUSAL = "nextDate must be a YYYY-MM-DD date, or null when none is scheduled.";
3
+ export declare const PLAIN_COMMENT_REFUSAL = "Send body alone for a plain comment, or kind with its journal fields.";
2
4
  declare const JournalVariants: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
5
  issueNumber: z.ZodNumber;
4
6
  summary: z.ZodString;
5
7
  status: z.ZodString;
6
8
  nextStep: z.ZodString;
7
- nextDate: z.ZodNullable<z.ZodISODate>;
9
+ nextDate: z.ZodUnion<readonly [z.ZodISODate, z.ZodNull, z.ZodPipe<z.ZodLiteral<"null">, z.ZodTransform<null, "null">>]>;
8
10
  keyNumbers: z.ZodArray<z.ZodString>;
9
11
  evidence: z.ZodArray<z.ZodURL>;
10
12
  details: z.ZodOptional<z.ZodString>;
@@ -16,7 +18,7 @@ declare const JournalVariants: z.ZodDiscriminatedUnion<[z.ZodObject<{
16
18
  summary: z.ZodString;
17
19
  status: z.ZodString;
18
20
  nextStep: z.ZodString;
19
- nextDate: z.ZodNullable<z.ZodISODate>;
21
+ nextDate: z.ZodUnion<readonly [z.ZodISODate, z.ZodNull, z.ZodPipe<z.ZodLiteral<"null">, z.ZodTransform<null, "null">>]>;
20
22
  keyNumbers: z.ZodArray<z.ZodString>;
21
23
  details: z.ZodOptional<z.ZodString>;
22
24
  lengthCap: z.ZodOptional<z.ZodNumber>;
@@ -29,7 +31,7 @@ declare const JournalVariants: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
31
  summary: z.ZodString;
30
32
  status: z.ZodString;
31
33
  nextStep: z.ZodString;
32
- nextDate: z.ZodNullable<z.ZodISODate>;
34
+ nextDate: z.ZodUnion<readonly [z.ZodISODate, z.ZodNull, z.ZodPipe<z.ZodLiteral<"null">, z.ZodTransform<null, "null">>]>;
33
35
  keyNumbers: z.ZodArray<z.ZodString>;
34
36
  evidence: z.ZodArray<z.ZodURL>;
35
37
  details: z.ZodOptional<z.ZodString>;
@@ -42,7 +44,7 @@ declare const JournalVariants: z.ZodDiscriminatedUnion<[z.ZodObject<{
42
44
  summary: z.ZodString;
43
45
  status: z.ZodString;
44
46
  nextStep: z.ZodString;
45
- nextDate: z.ZodNullable<z.ZodISODate>;
47
+ nextDate: z.ZodUnion<readonly [z.ZodISODate, z.ZodNull, z.ZodPipe<z.ZodLiteral<"null">, z.ZodTransform<null, "null">>]>;
46
48
  keyNumbers: z.ZodArray<z.ZodString>;
47
49
  evidence: z.ZodArray<z.ZodURL>;
48
50
  details: z.ZodOptional<z.ZodString>;
@@ -55,7 +57,7 @@ declare const JournalVariants: z.ZodDiscriminatedUnion<[z.ZodObject<{
55
57
  summary: z.ZodString;
56
58
  status: z.ZodString;
57
59
  nextStep: z.ZodString;
58
- nextDate: z.ZodNullable<z.ZodISODate>;
60
+ nextDate: z.ZodUnion<readonly [z.ZodISODate, z.ZodNull, z.ZodPipe<z.ZodLiteral<"null">, z.ZodTransform<null, "null">>]>;
59
61
  keyNumbers: z.ZodArray<z.ZodString>;
60
62
  evidence: z.ZodArray<z.ZodURL>;
61
63
  details: z.ZodOptional<z.ZodString>;
@@ -68,17 +70,19 @@ declare const JournalVariants: z.ZodDiscriminatedUnion<[z.ZodObject<{
68
70
  followUps: z.ZodArray<z.ZodString>;
69
71
  }, z.core.$strict>], "kind">;
70
72
  export type JournalInput = z.infer<typeof JournalVariants>;
71
- /** Publish the same kind requirements enforced by the canonical variant schemas. */
73
+ /** Publish a plain `body` or each journal kind with the fields its canonical variant requires. */
72
74
  export declare const JOURNAL_SCHEMA_METADATA: {
73
75
  required: string[];
74
- anyOf: {
76
+ anyOf: ({
77
+ required: string[];
78
+ } | {
75
79
  properties: {
76
80
  kind: {
77
81
  const: "blocker" | "closeout" | "decision" | "progress" | "start";
78
82
  };
79
83
  };
80
84
  required: string[];
81
- }[];
85
+ })[];
82
86
  };
83
87
  export declare function missingJournalFields(input: Record<string, unknown>): string[];
84
88
  export declare const JournalInputSchema: z.ZodObject<{
@@ -86,7 +90,7 @@ export declare const JournalInputSchema: z.ZodObject<{
86
90
  summary: z.ZodString;
87
91
  status: z.ZodString;
88
92
  nextStep: z.ZodString;
89
- nextDate: z.ZodNullable<z.ZodISODate>;
93
+ nextDate: z.ZodUnion<readonly [z.ZodISODate, z.ZodNull, z.ZodPipe<z.ZodLiteral<"null">, z.ZodTransform<null, "null">>]>;
90
94
  keyNumbers: z.ZodArray<z.ZodString>;
91
95
  evidence: z.ZodArray<z.ZodURL>;
92
96
  details: z.ZodOptional<z.ZodString>;
@@ -2,7 +2,9 @@ import { isIP } from "node:net";
2
2
  import { z } from "zod";
3
3
  const Text = z.string().trim().min(1).max(1e4);
4
4
  const Summary = Text.max(500).refine((value) => !/[\r\n]/u.test(value), "Summary must be one plain-language line.");
5
- const Date = z.iso.date();
5
+ const NEXT_DATE_REFUSAL = "nextDate must be a YYYY-MM-DD date, or null when none is scheduled.";
6
+ const Date = z.iso.date({ error: NEXT_DATE_REFUSAL });
7
+ const PLAIN_COMMENT_REFUSAL = "Send body alone for a plain comment, or kind with its journal fields.";
6
8
  const EvidenceUrl = z.url({ protocol: /^https$/u }).refine((value) => {
7
9
  let url;
8
10
  try {
@@ -21,7 +23,7 @@ const Common = {
21
23
  summary: Summary,
22
24
  status: Text,
23
25
  nextStep: Text,
24
- nextDate: Date.nullable(),
26
+ nextDate: z.union([Date, z.null(), z.literal("null").transform(() => null)], { error: NEXT_DATE_REFUSAL }),
25
27
  keyNumbers: z.array(Text),
26
28
  evidence: z.array(Evidence),
27
29
  details: Text.optional(),
@@ -46,14 +48,14 @@ const JournalVariants = z.discriminatedUnion("kind", [
46
48
  })
47
49
  ]);
48
50
  const JOURNAL_SCHEMA_METADATA = {
49
- required: [
50
- ...Object.entries(Common).filter(([, schema]) => !schema.isOptional()).map(([key]) => key),
51
- "kind"
52
- ],
53
- anyOf: JournalVariants.options.map((variant) => ({
54
- properties: { kind: { const: variant.shape.kind.value } },
55
- required: Object.entries(variant.shape).filter(([key, schema]) => !(key in Common) && key !== "kind" && !schema.isOptional()).map(([key]) => key)
56
- }))
51
+ required: ["issueNumber"],
52
+ anyOf: [
53
+ { required: ["body"] },
54
+ ...JournalVariants.options.map((variant) => ({
55
+ properties: { kind: { const: variant.shape.kind.value } },
56
+ required: Object.entries(variant.shape).filter(([key, schema]) => key !== "issueNumber" && !schema.isOptional()).map(([key]) => key)
57
+ }))
58
+ ]
57
59
  };
58
60
  function missingJournalFields(input) {
59
61
  const variant = JournalVariants.options.find((option) => option.shape.kind.value === input.kind);
@@ -169,6 +171,8 @@ function journalSection(body, headings) {
169
171
  export {
170
172
  JOURNAL_SCHEMA_METADATA,
171
173
  JournalInputSchema,
174
+ NEXT_DATE_REFUSAL,
175
+ PLAIN_COMMENT_REFUSAL,
172
176
  acceptanceCriteria,
173
177
  missingJournalFields,
174
178
  renderJournal
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/issueJournal.ts"],
4
- "sourcesContent": ["import { isIP } from 'node:net';\nimport { z } from 'zod';\n\nconst Text = z.string().trim().min(1).max(10000);\nconst Summary = Text.max(500).refine((value) => !/[\\r\\n]/u.test(value), 'Summary must be one plain-language line.');\nconst Date = z.iso.date();\nconst EvidenceUrl = z.url({ protocol: /^https$/u }).refine((value) => {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return false;\n }\n const hostname = url.hostname.replace(/^\\[|\\]$/gu, '').replace(/\\.$/u, '');\n return (\n !url.username &&\n !url.password &&\n isIP(hostname) === 0 &&\n hostname.includes('.') &&\n hostname !== 'localhost' &&\n !hostname.endsWith('.localhost') &&\n !hostname.endsWith('.local')\n );\n}, 'Evidence must be an HTTPS link with a public DNS hostname and no credentials or IP literal.');\nconst Evidence = EvidenceUrl.describe(\n 'HTTPS link with a public DNS hostname, such as a GitHub URL; no IP, localhost or credentials.',\n);\nconst Common = {\n issueNumber: z.number().int().positive(),\n summary: Summary,\n status: Text,\n nextStep: Text,\n nextDate: Date.nullable(),\n keyNumbers: z.array(Text),\n evidence: z.array(Evidence),\n details: Text.optional(),\n lengthCap: z.number().int().min(600).max(10000).optional(),\n};\n\nconst JournalVariants = z.discriminatedUnion('kind', [\n z.strictObject({ ...Common, kind: z.literal('start'), outcome: Text }),\n z.strictObject({\n ...Common,\n kind: z.literal('progress'),\n evidence: z.array(Evidence).min(1),\n done: z.array(Text).min(1),\n decisionNeeded: Text,\n }),\n z.strictObject({ ...Common, kind: z.literal('decision'), decision: Text, rationale: Text }),\n z.strictObject({ ...Common, kind: z.literal('blocker'), blocker: Text, resolution: Text }),\n z.strictObject({\n ...Common,\n kind: z.literal('closeout'),\n acceptance: z.array(z.strictObject({ criterion: Text, evidence: Evidence })).min(1),\n followUps: z.array(Text),\n }),\n]);\nexport type JournalInput = z.infer<typeof JournalVariants>;\n/** Publish the same kind requirements enforced by the canonical variant schemas. */\nexport const JOURNAL_SCHEMA_METADATA = {\n required: [\n ...Object.entries(Common)\n .filter(([, schema]) => !schema.isOptional())\n .map(([key]) => key),\n 'kind',\n ],\n anyOf: JournalVariants.options.map((variant) => ({\n properties: { kind: { const: variant.shape.kind.value } },\n required: Object.entries(variant.shape as Record<string, z.ZodType>)\n .filter(([key, schema]) => !(key in Common) && key !== 'kind' && !schema.isOptional())\n .map(([key]) => key),\n })),\n};\nexport function missingJournalFields(input: Record<string, unknown>): string[] {\n const variant = JournalVariants.options.find((option) => option.shape.kind.value === input.kind);\n const shape = variant?.shape ?? { ...Common, kind: z.string() };\n return Object.entries(shape as Record<string, z.ZodType>)\n .filter(([key, schema]) => !schema.isOptional() && input[key] === undefined)\n .map(([key]) => key);\n}\n\nconst onlyFor = (kind: string, what = 'non-empty text') =>\n `Required ${what} when kind is ${kind}; omit for every other kind.`;\n\n// MCP requires an object schema; the same variant validator enforces kind-specific fields.\nexport const JournalInputSchema = z\n .strictObject({\n ...Common,\n kind: z\n .enum(['start', 'progress', 'decision', 'blocker', 'closeout'])\n .describe(\n 'Select a journal kind and provide its required fields: start: outcome; progress: done, decisionNeeded and non-empty evidence; decision: decision and rationale; blocker: blocker and resolution; closeout: acceptance and followUps.',\n ),\n outcome: Text.optional().describe(onlyFor('start')),\n done: z.array(Text).min(1).optional().describe(onlyFor('progress', 'non-empty list')),\n decisionNeeded: Text.optional().describe(onlyFor('progress')),\n decision: Text.optional().describe(onlyFor('decision')),\n rationale: Text.optional().describe(onlyFor('decision')),\n blocker: Text.optional().describe(onlyFor('blocker')),\n resolution: Text.optional().describe(onlyFor('blocker')),\n acceptance: z\n .array(\n z.strictObject(\n { criterion: Text, evidence: Evidence },\n { error: 'Invalid acceptance entry. Provide only criterion and evidence.' },\n ),\n )\n .min(1)\n .optional()\n .describe(onlyFor('closeout', 'non-empty list of criterion and evidence')),\n followUps: z.array(Text).optional().describe(onlyFor('closeout', 'list, empty when none')),\n })\n .superRefine((input, ctx) => {\n const parsed = JournalVariants.safeParse(input);\n if (!parsed.success)\n for (const issue of parsed.error.issues)\n ctx.addIssue({ code: 'custom', path: issue.path, message: issue.message });\n });\n\nexport function renderJournal(raw: JournalInput, marker?: string): string {\n const input = JournalVariants.parse(raw);\n const plainPreview = (value: string): string => {\n const plain = value\n .replace(/!?\\[([^\\]]+)\\]\\([^)]*\\)/gu, '$1')\n .replace(/^\\s{0,3}(?:#{1,6}\\s+|>\\s?|[-+*]\\s+|\\d+[.)]\\s+)/gmu, '')\n .replace(/[*_~`<>[\\]\\\\]/gu, '')\n .replace(/\\s+/gu, ' ')\n .trim();\n if (plain.length <= 32) return plain;\n // Keep whole words so the cut never reads as a different statement; one word longer than the bound is cut hard.\n const space = plain.lastIndexOf(' ', 31);\n const preview = plain.slice(0, space > 0 ? space : 31);\n const last = preview.charCodeAt(preview.length - 1);\n return `${last >= 0xd800 && last <= 0xdbff ? preview.slice(0, -1) : preview}\u2026`;\n };\n const field = (label: string, value: string): string =>\n `**${label}:**${/\\n|^(?:[-*+]\\s|\\d+[.)]\\s)/u.test(value) ? '\\n' : ' '}${value}`;\n const list = (values: string[]): string => values.map((value) => '- ' + value.replace(/\\n/gu, '\\n ')).join('\\n');\n const sections = [`**Kind:** ${input.kind}. **Status:** ${input.status}`];\n switch (input.kind) {\n case 'start':\n sections.push(field('Outcome', input.outcome));\n break;\n case 'progress':\n sections.push(`**Done since last:**\\n${list(input.done)}`, field('Decision needed', input.decisionNeeded));\n break;\n case 'decision':\n sections.push(field('Decision', input.decision), field('Rationale', input.rationale));\n break;\n case 'blocker':\n sections.push(field('Blocker', input.blocker), field('Resolution needed', input.resolution));\n break;\n case 'closeout':\n sections.push(\n `**Acceptance evidence:**\\n${input.acceptance.map((item) => `- ${item.criterion} \u2014 ${item.evidence}`).join('\\n')}`,\n `**Follow-ups:** ${input.followUps.length ? input.followUps.join('; ') : 'None.'}`,\n );\n break;\n }\n sections.push(\n `**Key numbers:** ${input.keyNumbers.length ? input.keyNumbers.join('; ') : 'None reported.'}`,\n `**Next:** ${input.nextStep} (${input.nextDate ?? 'date not scheduled'}).`,\n `**Evidence:** ${input.evidence.length ? input.evidence.join(' \u00B7 ') : 'None yet.'}`,\n );\n if (input.details) sections.push(input.details);\n let body = `Status: ${plainPreview(input.status)}. Next: ${plainPreview(input.nextStep)}.\\n\\n${input.summary}`;\n let overflow = '';\n for (const section of sections) {\n if (overflow || body.length + section.length + 2 > (input.lengthCap ?? 1800)) overflow += `\\n\\n${section}`;\n else body += `\\n\\n${section}`;\n }\n if (overflow) body += `\\n\\n<details>\\n<summary>Additional journal detail</summary>${overflow}\\n\\n</details>`;\n return marker === undefined ? body : `${body}\\n\\n${marker}`;\n}\n\nexport function acceptanceCriteria(body: string): string[] {\n return journalSection(body, ['acceptance criteria'])\n .map(\n (line) =>\n line\n .trimStart()\n .match(/^[-*+]\\s*\\[[ xX]\\][ \\t](.*)$/u)?.[1]\n ?.trim() ?? '',\n )\n .filter(Boolean);\n}\n\n// Match readiness's ATX heading boundaries without changing its separate contract owner.\nfunction journalSection(body: string, headings: string[]): string[] {\n const heading = (line: string) =>\n line\n .match(/^ {0,3}#{1,6}[ \\t](.*)$/u)?.[1]\n ?.trim()\n .toLowerCase();\n const lines = body.split(/\\r?\\n/u);\n const start = lines.findIndex((line) => headings.includes(heading(line) ?? ''));\n if (start === -1) return [];\n const section: string[] = [];\n for (const line of lines.slice(start + 1)) {\n if (heading(line) !== undefined) break;\n section.push(line);\n }\n return section;\n}\n"],
5
- "mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,SAAS;AAElB,MAAM,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAK;AAC/C,MAAM,UAAU,KAAK,IAAI,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,KAAK,KAAK,GAAG,0CAA0C;AAClH,MAAM,OAAO,EAAE,IAAI,KAAK;AACxB,MAAM,cAAc,EAAE,IAAI,EAAE,UAAU,WAAW,CAAC,EAAE,OAAO,CAAC,UAAU;AACpE,MAAI;AACJ,MAAI;AACF,UAAM,IAAI,IAAI,KAAK;AAAA,EACrB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,QAAM,WAAW,IAAI,SAAS,QAAQ,aAAa,EAAE,EAAE,QAAQ,QAAQ,EAAE;AACzE,SACE,CAAC,IAAI,YACL,CAAC,IAAI,YACL,KAAK,QAAQ,MAAM,KACnB,SAAS,SAAS,GAAG,KACrB,aAAa,eACb,CAAC,SAA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,QAAQ,CAAC,GAAG;AACzC,QAAI,QAAQ,IAAI,MAAM,OAAW;AACjC,YAAQ,KAAK,IAAI;AAAA,EACnB;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isIP } from 'node:net';\nimport { z } from 'zod';\n\nconst Text = z.string().trim().min(1).max(10000);\nconst Summary = Text.max(500).refine((value) => !/[\\r\\n]/u.test(value), 'Summary must be one plain-language line.');\nexport const NEXT_DATE_REFUSAL = 'nextDate must be a YYYY-MM-DD date, or null when none is scheduled.';\nconst Date = z.iso.date({ error: NEXT_DATE_REFUSAL });\nexport const PLAIN_COMMENT_REFUSAL = 'Send body alone for a plain comment, or kind with its journal fields.';\nconst EvidenceUrl = z.url({ protocol: /^https$/u }).refine((value) => {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return false;\n }\n const hostname = url.hostname.replace(/^\\[|\\]$/gu, '').replace(/\\.$/u, '');\n return (\n !url.username &&\n !url.password &&\n isIP(hostname) === 0 &&\n hostname.includes('.') &&\n hostname !== 'localhost' &&\n !hostname.endsWith('.localhost') &&\n !hostname.endsWith('.local')\n );\n}, 'Evidence must be an HTTPS link with a public DNS hostname and no credentials or IP literal.');\nconst Evidence = EvidenceUrl.describe(\n 'HTTPS link with a public DNS hostname, such as a GitHub URL; no IP, localhost or credentials.',\n);\nconst Common = {\n issueNumber: z.number().int().positive(),\n summary: Summary,\n status: Text,\n nextStep: Text,\n nextDate: z.union([Date, z.null(), z.literal('null').transform(() => null)], { error: NEXT_DATE_REFUSAL }),\n keyNumbers: z.array(Text),\n evidence: z.array(Evidence),\n details: Text.optional(),\n lengthCap: z.number().int().min(600).max(10000).optional(),\n};\n\nconst JournalVariants = z.discriminatedUnion('kind', [\n z.strictObject({ ...Common, kind: z.literal('start'), outcome: Text }),\n z.strictObject({\n ...Common,\n kind: z.literal('progress'),\n evidence: z.array(Evidence).min(1),\n done: z.array(Text).min(1),\n decisionNeeded: Text,\n }),\n z.strictObject({ ...Common, kind: z.literal('decision'), decision: Text, rationale: Text }),\n z.strictObject({ ...Common, kind: z.literal('blocker'), blocker: Text, resolution: Text }),\n z.strictObject({\n ...Common,\n kind: z.literal('closeout'),\n acceptance: z.array(z.strictObject({ criterion: Text, evidence: Evidence })).min(1),\n followUps: z.array(Text),\n }),\n]);\nexport type JournalInput = z.infer<typeof JournalVariants>;\n/** Publish a plain `body` or each journal kind with the fields its canonical variant requires. */\nexport const JOURNAL_SCHEMA_METADATA = {\n required: ['issueNumber'],\n anyOf: [\n { required: ['body'] },\n ...JournalVariants.options.map((variant) => ({\n properties: { kind: { const: variant.shape.kind.value } },\n required: Object.entries(variant.shape as Record<string, z.ZodType>)\n .filter(([key, schema]) => key !== 'issueNumber' && !schema.isOptional())\n .map(([key]) => key),\n })),\n ],\n};\nexport function missingJournalFields(input: Record<string, unknown>): string[] {\n const variant = JournalVariants.options.find((option) => option.shape.kind.value === input.kind);\n const shape = variant?.shape ?? { ...Common, kind: z.string() };\n return Object.entries(shape as Record<string, z.ZodType>)\n .filter(([key, schema]) => !schema.isOptional() && input[key] === undefined)\n .map(([key]) => key);\n}\n\nconst onlyFor = (kind: string, what = 'non-empty text') =>\n `Required ${what} when kind is ${kind}; omit for every other kind.`;\n\n// MCP requires an object schema; the same variant validator enforces kind-specific fields.\nexport const JournalInputSchema = z\n .strictObject({\n ...Common,\n kind: z\n .enum(['start', 'progress', 'decision', 'blocker', 'closeout'])\n .describe(\n 'Select a journal kind and provide its required fields: start: outcome; progress: done, decisionNeeded and non-empty evidence; decision: decision and rationale; blocker: blocker and resolution; closeout: acceptance and followUps.',\n ),\n outcome: Text.optional().describe(onlyFor('start')),\n done: z.array(Text).min(1).optional().describe(onlyFor('progress', 'non-empty list')),\n decisionNeeded: Text.optional().describe(onlyFor('progress')),\n decision: Text.optional().describe(onlyFor('decision')),\n rationale: Text.optional().describe(onlyFor('decision')),\n blocker: Text.optional().describe(onlyFor('blocker')),\n resolution: Text.optional().describe(onlyFor('blocker')),\n acceptance: z\n .array(\n z.strictObject(\n { criterion: Text, evidence: Evidence },\n { error: 'Invalid acceptance entry. Provide only criterion and evidence.' },\n ),\n )\n .min(1)\n .optional()\n .describe(onlyFor('closeout', 'non-empty list of criterion and evidence')),\n followUps: z.array(Text).optional().describe(onlyFor('closeout', 'list, empty when none')),\n })\n .superRefine((input, ctx) => {\n const parsed = JournalVariants.safeParse(input);\n if (!parsed.success)\n for (const issue of parsed.error.issues)\n ctx.addIssue({ code: 'custom', path: issue.path, message: issue.message });\n });\n\nexport function renderJournal(raw: JournalInput, marker?: string): string {\n const input = JournalVariants.parse(raw);\n const plainPreview = (value: string): string => {\n const plain = value\n .replace(/!?\\[([^\\]]+)\\]\\([^)]*\\)/gu, '$1')\n .replace(/^\\s{0,3}(?:#{1,6}\\s+|>\\s?|[-+*]\\s+|\\d+[.)]\\s+)/gmu, '')\n .replace(/[*_~`<>[\\]\\\\]/gu, '')\n .replace(/\\s+/gu, ' ')\n .trim();\n if (plain.length <= 32) return plain;\n // Keep whole words so the cut never reads as a different statement; one word longer than the bound is cut hard.\n const space = plain.lastIndexOf(' ', 31);\n const preview = plain.slice(0, space > 0 ? space : 31);\n const last = preview.charCodeAt(preview.length - 1);\n return `${last >= 0xd800 && last <= 0xdbff ? preview.slice(0, -1) : preview}\u2026`;\n };\n const field = (label: string, value: string): string =>\n `**${label}:**${/\\n|^(?:[-*+]\\s|\\d+[.)]\\s)/u.test(value) ? '\\n' : ' '}${value}`;\n const list = (values: string[]): string => values.map((value) => '- ' + value.replace(/\\n/gu, '\\n ')).join('\\n');\n const sections = [`**Kind:** ${input.kind}. **Status:** ${input.status}`];\n switch (input.kind) {\n case 'start':\n sections.push(field('Outcome', input.outcome));\n break;\n case 'progress':\n sections.push(`**Done since last:**\\n${list(input.done)}`, field('Decision needed', input.decisionNeeded));\n break;\n case 'decision':\n sections.push(field('Decision', input.decision), field('Rationale', input.rationale));\n break;\n case 'blocker':\n sections.push(field('Blocker', input.blocker), field('Resolution needed', input.resolution));\n break;\n case 'closeout':\n sections.push(\n `**Acceptance evidence:**\\n${input.acceptance.map((item) => `- ${item.criterion} \u2014 ${item.evidence}`).join('\\n')}`,\n `**Follow-ups:** ${input.followUps.length ? input.followUps.join('; ') : 'None.'}`,\n );\n break;\n }\n sections.push(\n `**Key numbers:** ${input.keyNumbers.length ? input.keyNumbers.join('; ') : 'None reported.'}`,\n `**Next:** ${input.nextStep} (${input.nextDate ?? 'date not scheduled'}).`,\n `**Evidence:** ${input.evidence.length ? input.evidence.join(' \u00B7 ') : 'None yet.'}`,\n );\n if (input.details) sections.push(input.details);\n let body = `Status: ${plainPreview(input.status)}. Next: ${plainPreview(input.nextStep)}.\\n\\n${input.summary}`;\n let overflow = '';\n for (const section of sections) {\n if (overflow || body.length + section.length + 2 > (input.lengthCap ?? 1800)) overflow += `\\n\\n${section}`;\n else body += `\\n\\n${section}`;\n }\n if (overflow) body += `\\n\\n<details>\\n<summary>Additional journal detail</summary>${overflow}\\n\\n</details>`;\n return marker === undefined ? body : `${body}\\n\\n${marker}`;\n}\n\nexport function acceptanceCriteria(body: string): string[] {\n return journalSection(body, ['acceptance criteria'])\n .map(\n (line) =>\n line\n .trimStart()\n .match(/^[-*+]\\s*\\[[ xX]\\][ \\t](.*)$/u)?.[1]\n ?.trim() ?? '',\n )\n .filter(Boolean);\n}\n\n// Match readiness's ATX heading boundaries without changing its separate contract owner.\nfunction journalSection(body: string, headings: string[]): string[] {\n const heading = (line: string) =>\n line\n .match(/^ {0,3}#{1,6}[ \\t](.*)$/u)?.[1]\n ?.trim()\n .toLowerCase();\n const lines = body.split(/\\r?\\n/u);\n const start = lines.findIndex((line) => headings.includes(heading(line) ?? ''));\n if (start === -1) return [];\n const section: string[] = [];\n for (const line of lines.slice(start + 1)) {\n if (heading(line) !== undefined) break;\n section.push(line);\n }\n return section;\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,SAAS;AAElB,MAAM,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC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SAAO,WAAW,SAAY,OAAO,GAAG,IAAI;AAAA;AAAA,EAAO,MAAM;AAC3D;AAEO,SAAS,mBAAmB,MAAwB;AACzD,SAAO,eAAe,MAAM,CAAC,qBAAqB,CAAC,EAChD;AAAA,IACC,CAAC,SACC,KACG,UAAU,EACV,MAAM,+BAA+B,IAAI,CAAC,GACzC,KAAK,KAAK;AAAA,EAClB,EACC,OAAO,OAAO;AACnB;AAGA,SAAS,eAAe,MAAc,UAA8B;AAClE,QAAM,UAAU,CAAC,SACf,KACG,MAAM,0BAA0B,IAAI,CAAC,GACpC,KAAK,EACN,YAAY;AACjB,QAAM,QAAQ,KAAK,MAAM,QAAQ;AACjC,QAAM,QAAQ,MAAM,UAAU,CAAC,SAAS,SAAS,SAAS,QAAQ,IAAI,KAAK,EAAE,CAAC;AAC9E,MAAI,UAAU,GAAI,QAAO,CAAC;AAC1B,QAAM,UAAoB,CAAC;AAC3B,aAAW,QAAQ,MAAM,MAAM,QAAQ,CAAC,GAAG;AACzC,QAAI,QAAQ,IAAI,MAAM,OAAW;AACjC,YAAQ,KAAK,IAAI;AAAA,EACnB;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -55,14 +55,17 @@ test("a cut status or next-step preview ends on a whole word and an ellipsis (ai
55
55
  );
56
56
  assert.equal(first("\u{1F642}".repeat(40), "Run checks"), `Status: ${"\u{1F642}".repeat(15)}\u2026. Next: Run checks.`);
57
57
  });
58
- test("published comment schema lists required fields for every journal kind", () => {
59
- const schema = z.toJSONSchema(getAiDeliveryMcpTool("issue_comment").inputSchema);
58
+ test("published comment schema lists a plain body or the required fields for every journal kind", () => {
59
+ const schema = z.toJSONSchema(getAiDeliveryMcpTool("issue_comment").inputSchema, { io: "input" });
60
+ const common = ["summary", "status", "nextStep", "nextDate", "keyNumbers", "evidence", "kind"];
61
+ assert.deepEqual(schema.required, ["issueNumber"]);
60
62
  assert.deepEqual(schema.anyOf, [
61
- { properties: { kind: { const: "start" } }, required: ["outcome"] },
62
- { properties: { kind: { const: "progress" } }, required: ["done", "decisionNeeded"] },
63
- { properties: { kind: { const: "decision" } }, required: ["decision", "rationale"] },
64
- { properties: { kind: { const: "blocker" } }, required: ["blocker", "resolution"] },
65
- { properties: { kind: { const: "closeout" } }, required: ["acceptance", "followUps"] }
63
+ { required: ["body"] },
64
+ { properties: { kind: { const: "start" } }, required: [...common, "outcome"] },
65
+ { properties: { kind: { const: "progress" } }, required: [...common, "done", "decisionNeeded"] },
66
+ { properties: { kind: { const: "decision" } }, required: [...common, "decision", "rationale"] },
67
+ { properties: { kind: { const: "blocker" } }, required: [...common, "blocker", "resolution"] },
68
+ { properties: { kind: { const: "closeout" } }, required: [...common, "acceptance", "followUps"] }
66
69
  ]);
67
70
  });
68
71
  test("all typed journals validate and lead with plain status and next-step previews", () => {
@@ -452,7 +455,7 @@ test("registered journal tool returns actionable decision refusals before native
452
455
  const published = (await client.listTools()).tools.find((t) => t.name === "issue_comment");
453
456
  assert.deepEqual(
454
457
  published?.inputSchema.anyOf,
455
- z.toJSONSchema(getAiDeliveryMcpTool("issue_comment").inputSchema).anyOf
458
+ z.toJSONSchema(getAiDeliveryMcpTool("issue_comment").inputSchema, { io: "input" }).anyOf
456
459
  );
457
460
  assert.match(text, /[Pp]rovide/u, "the refusal explains the correction");
458
461
  const listed = (await client.listTools()).tools.find((tool) => tool.name === "issue_comment");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/issueJournal.test.ts"],
4
- "sourcesContent": ["import assert from 'node:assert/strict';\nimport { z } from 'zod';\nimport { test, vi } from 'vitest';\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';\nimport { createAiDeliveryMcpServer } from './mcp/index.js';\nimport { inertTarget } from './fixtures/inertTarget.js';\n\nimport { getAiDeliveryMcpTool } from './mcp/tools.js';\nimport * as issue from './issue.js';\nimport type { DeliveryContext } from './issue.js';\nimport type { JournalInput } from './issueJournal.js';\nimport { JournalInputSchema, renderJournal, acceptanceCriteria } from './issueJournal.js';\nimport { executeTool } from './dispatch.js';\nimport * as configuration from './config/deliveryConfig.js';\nimport * as githubClients from './github/client.js';\nimport { execFileSync } from 'node:child_process';\nimport { mkdtempSync, rmSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\ntest('decision journal list fields start below their label and preserve nested structure', () => {\n const result = renderJournal({\n issueNumber: 17,\n kind: 'decision',\n summary: 'A decision was made.',\n status: 'Ready',\n decision: '- First\\n - Nested\\n- Second',\n rationale: 'The existing owner is sufficient.',\n nextStep: 'Run checks',\n nextDate: null,\n keyNumbers: [],\n evidence: [],\n });\n assert.equal(\n result,\n 'Status: Ready. Next: Run checks.\\n\\nA decision was made.\\n\\n**Kind:** decision. **Status:** Ready\\n\\n**Decision:**\\n- First\\n - Nested\\n- Second\\n\\n**Rationale:** The existing owner is sufficient.\\n\\n**Key numbers:** None reported.\\n\\n**Next:** Run checks (date not scheduled).\\n\\n**Evidence:** None yet.',\n );\n});\n\ntest('a cut status or next-step preview ends on a whole word and an ellipsis (ai#3550 comment 6596479566)', () => {\n const first = (status: string, nextStep: string) =>\n renderJournal({\n issueNumber: 3550,\n kind: 'progress',\n summary: 'Weekly screen finished.',\n status,\n done: ['Screened 4,694 cells'],\n decisionNeeded: 'None',\n nextStep,\n nextDate: '2026-11-09',\n keyNumbers: [],\n evidence: ['https://github.com/aviaratech/ai/issues/3550#issuecomment-6502461445'],\n }).split('\\n')[0];\n assert.equal(\n first(\n 'Finished 9:43 pm PT. Nothing is left running; the guard exits at its next 10-minute check.',\n 'Next weekly run Monday Nov 9: `scripts/weekly.sh 2026-11-09`.',\n ),\n 'Status: Finished 9:43 pm PT. Nothing is\u2026. Next: Next weekly run Monday Nov 9:\u2026.',\n );\n assert.equal(first('\uD83D\uDE42'.repeat(40), 'Run checks'), `Status: ${'\uD83D\uDE42'.repeat(15)}\u2026. Next: Run checks.`);\n});\n\ntest('published comment schema lists required fields for every journal kind', () => {\n const schema = z.toJSONSchema(getAiDeliveryMcpTool('issue_comment')!.inputSchema);\n assert.deepEqual(schema.anyOf, [\n { properties: { kind: { const: 'start' } }, required: ['outcome'] },\n { properties: { kind: { const: 'progress' } }, required: ['done', 'decisionNeeded'] },\n { properties: { kind: { const: 'decision' } }, required: ['decision', 'rationale'] },\n { properties: { kind: { const: 'blocker' } }, required: ['blocker', 'resolution'] },\n { properties: { kind: { const: 'closeout' } }, required: ['acceptance', 'followUps'] },\n ]);\n});\n\ntest('all typed journals validate and lead with plain status and next-step previews', () => {\n const tool = getAiDeliveryMcpTool('issue_comment');\n assert.ok(tool, 'issue_comment must be exposed');\n const common = {\n issueNumber: 17,\n summary: 'Parser work is underway.',\n status: 'In progress',\n nextStep: 'Run checks',\n nextDate: '2026-10-09',\n keyNumbers: ['3 checks'],\n evidence: ['https://github.com/example/widget/pull/23'],\n };\n const valid: JournalInput[] = [\n { ...common, kind: 'start', outcome: 'Deliver a safe parser' },\n { ...common, kind: 'progress', done: ['Added validation'], decisionNeeded: 'None' },\n { ...common, kind: 'decision', decision: 'Use the existing parser', rationale: 'Preserves the contract' },\n { ...common, kind: 'blocker', blocker: 'Review pending', resolution: 'Independent acceptance' },\n {\n ...common,\n kind: 'closeout',\n acceptance: [{ criterion: 'Reject malformed input', evidence: 'https://github.com/example/widget/pull/23' }],\n followUps: [],\n },\n ];\n for (const input of valid) {\n for (const repo of [undefined, 'example/widget']) {\n for (const nextDate of [null, '2026-10-09', '2028-02-29']) {\n const selected = { ...input, nextDate, ...(repo === undefined ? {} : { repo }) };\n const parsed: ReturnType<typeof tool.inputSchema.safeParse> = tool.inputSchema.safeParse(selected);\n assert.equal(parsed.success, true, JSON.stringify(selected));\n if (parsed.success) assert.deepEqual(parsed.data, selected);\n }\n }\n assert.equal(JournalInputSchema.safeParse(input).success, true);\n assert.equal(JournalInputSchema.safeParse({ ...input, repo: 'example/widget' }).success, false);\n for (const summary of [input.summary, 'S'.repeat(500)]) {\n const marker = `<!-- ai-delivery:journal@1:sha256:${'a'.repeat(64)} -->`;\n const body = renderJournal(\n {\n ...input,\n summary,\n status: '**In progress**',\n nextStep: 'Run\\nchecks',\n lengthCap: 600,\n details: 'D'.repeat(900),\n },\n marker,\n );\n assert.equal(body.startsWith(`Status: In progress. Next: Run checks.\\n\\n${summary}\\n\\n`), true);\n assert.match(body, /<details>/u);\n assert.ok(body.endsWith(marker));\n }\n }\n for (const input of [\n { ...common, kind: 'progress' },\n { ...common, kind: 'start', outcome: '' },\n { ...common, kind: 'closeout', acceptance: [], followUps: [] },\n {\n ...common,\n kind: 'decision',\n decision: 'Use parser',\n rationale: 'Works',\n evidence: ['/Users/operator/checks.log'],\n },\n { ...common, kind: 'start', outcome: 'Deliver', nextDate: 'tomorrow' },\n { ...common, kind: 'start', outcome: 'Deliver', done: ['Wrong variant'] },\n { ...common, kind: 'progress', done: ['Deliver'], decisionNeeded: 'None', rationale: 'Wrong variant' },\n { ...common, kind: 'decision', decision: 'Use parser', rationale: 'Works', blocker: 'Wrong variant' },\n { ...common, kind: 'blocker', blocker: 'Review', resolution: 'Accept', outcome: 'Wrong variant' },\n { ...valid[4], done: ['Wrong variant'] },\n { ...valid[0], unknown: true },\n { ...valid[0], kind: 'unsupported' },\n { ...valid[0], nextDate: '2026-02-30' },\n { ...valid[0], nextDate: 20261009 },\n { ...valid[0], keyNumbers: '3 checks' },\n { ...valid[0], issueNumber: '17' },\n { ...valid[4], acceptance: [{ criterion: 'Deliver', evidence: common.evidence[0], unknown: true }] },\n ])\n for (const repo of [undefined, 'example/widget'])\n assert.equal(tool.inputSchema.safeParse({ ...input, ...(repo === undefined ? {} : { repo }) }).success, false);\n for (const repo of [\n '',\n 'example',\n 'example/widget/extra',\n 'https://github.com/example/widget',\n 'example/\\nwidget',\n 17,\n null,\n [],\n ])\n assert.equal(tool.inputSchema.safeParse({ ...valid[0], repo }).success, false);\n});\n\ntest('journal dispatch refuses invalid fields and repository conflicts before configuration or authentication', async () => {\n const settings = vi.spyOn(configuration, 'loadDeliverySettings').mockImplementation(async () => {\n throw new Error('Configuration must not load for an invalid journal');\n });\n const clients = vi.spyOn(githubClients, 'createDeliveryGitHubClients');\n const valid = {\n repo: 'example/widget',\n issueNumber: 17,\n kind: 'progress',\n summary: 'Parser work is underway.',\n status: 'In progress',\n done: ['Added validation'],\n decisionNeeded: 'None',\n keyNumbers: [],\n evidence: ['https://github.com/example/widget/pull/23'],\n nextStep: 'Run checks',\n nextDate: null,\n };\n try {\n for (const input of [\n { ...valid, kind: 'unsupported' },\n { ...valid, outcome: 'Wrong variant' },\n { ...valid, unknown: true },\n { ...valid, done: [] },\n { ...valid, evidence: [] },\n { ...valid, repo: 'invalid' },\n { ...valid, repo: 17 },\n { ...valid, nextDate: '2026-02-30' },\n ])\n await assert.rejects(executeTool('issue_comment', input, { repoRoot: '/non-git-fixture' }));\n await assert.rejects(\n executeTool('issue_comment', valid, { repoRoot: '/non-git-fixture', repo: 'example/other' }),\n /selectors disagree/u,\n );\n assert.equal(settings.mock.calls.length, 0);\n assert.equal(clients.mock.calls.length, 0, 'no authenticated client or comment writer is reached');\n } finally {\n settings.mockRestore();\n clients.mockRestore();\n }\n});\n\ntest('canonical comment writes read back and recover a lost response without duplicates', async () => {\n const comment = (\n issue as unknown as {\n commentIssue?: (\n context: DeliveryContext,\n input: JournalInput | { issueNumber: number; body: string },\n lifecycleKey?: string,\n ) => Promise<{ commentId: number; url: string; body: string; reused: boolean }>;\n }\n ).commentIssue;\n assert.ok(comment, 'canonical comment writer must exist');\n const agent = await import('./agent.js');\n assert.equal(agent.commentIssue, comment);\n assert.equal(agent.ISSUE_COMMENT_BODY_LIMIT, 65536);\n const root = mkdtempSync(join(tmpdir(), 'ai-delivery-journal-'));\n execFileSync('git', ['init', '-q', '-b', 'main'], { cwd: root });\n const stored: { id: number; body: string; html_url: string; user: { login: string }; issue_url: string }[] = [];\n let loseResponse = true;\n let corruptReadback = false;\n let authorCalls = 0;\n const context = {\n root,\n repo: { owner: 'example', repo: 'widget' },\n clients: {\n role: 'author',\n authenticatedAuthor: async () => {\n authorCalls += 1;\n return { actorLogin: 'operator', credentialIdentity: 'user:1' };\n },\n rest: {\n issues: {\n get: async () => ({ data: { number: 17, state: 'open' } }),\n listComments: async () => ({ data: stored }),\n createComment: async (input: { body: string }) => {\n const id = 91 + stored.length;\n const data = {\n id,\n body: input.body,\n html_url: `https://github.com/example/widget/issues/17#issuecomment-${String(id)}`,\n issue_url: 'https://api.github.com/repos/example/widget/issues/17',\n user: { login: 'operator' },\n };\n stored.push(data);\n if (loseResponse) {\n loseResponse = false;\n throw new Error('response lost');\n }\n return { data };\n },\n getComment: async (input: { comment_id: number }) => ({\n data: {\n ...stored.find((item) => item.id === input.comment_id),\n ...(corruptReadback ? { body: 'changed' } : {}),\n },\n }),\n },\n },\n },\n } as unknown as DeliveryContext;\n const input: JournalInput = {\n issueNumber: 17,\n kind: 'start',\n summary: 'Implementation started.',\n status: 'In progress',\n outcome: 'Deliver validation',\n keyNumbers: [],\n evidence: [],\n nextStep: 'Run checks',\n nextDate: '2026-10-09',\n };\n try {\n await assert.rejects(comment(context, input), /response lost/u);\n const recovered = await comment(context, input);\n assert.equal(recovered.commentId, 91);\n assert.equal(recovered.reused, true);\n assert.equal(stored.length, 1);\n assert.match(recovered.body, /^Status: In progress\\. Next: Run checks\\.\\n\\nImplementation started\\./u);\n corruptReadback = true;\n await assert.rejects(comment(context, input), /readback/u);\n corruptReadback = false;\n\n stored.push({ ...stored[0]!, id: 99, html_url: 'https://github.com/example/widget/issues/17#issuecomment-99' });\n await assert.rejects(comment(context, input), /duplicate authored retry matches/u);\n assert.equal(stored.length, 2, 'ambiguous retries must not write another comment');\n stored.pop();\n\n const rawBody = `\\r\\n <details>\\n<summary>Prior content</summary>\\n<pre>${'\uD83D\uDE42 &amp; prior title/body\\r\\n'.repeat(600)}</pre>\\n</details> \\t\\n`;\n assert.ok(rawBody.length > 10000);\n loseResponse = true;\n await assert.rejects(comment(context, { issueNumber: 17, body: rawBody }), /response lost/u);\n const rawRecovered = await comment(context, { issueNumber: 17, body: rawBody });\n assert.equal(rawRecovered.body, rawBody, 'raw history content must remain exact and unwrapped');\n assert.equal(rawRecovered.commentId, 92);\n assert.equal(rawRecovered.reused, true);\n assert.equal(stored.length, 2);\n assert.equal(stored[1]!.body, rawBody, 'no journal marker or unrequested content is appended');\n\n const maximumBody = '\uD83D\uDE42'.repeat(32768);\n assert.equal(maximumBody.length, 65536);\n assert.equal((await comment(context, { issueNumber: 17, body: maximumBody })).body, maximumBody);\n assert.equal(stored.length, 3);\n const beforeInvalid = authorCalls;\n for (const body of ['', ' \\r\\n\\t ', 'x'.repeat(65537), `${maximumBody}\uD83D\uDE42`])\n await assert.rejects(comment(context, { issueNumber: 17, body }), /comment body/u);\n await assert.rejects(\n comment(context, {\n ...input,\n status: 'x'.repeat(9000),\n outcome: 'x'.repeat(9000),\n nextStep: 'x'.repeat(9000),\n details: 'x'.repeat(9000),\n keyNumbers: Array.from({ length: 4 }, () => 'x'.repeat(9000)),\n }),\n /comment body/u,\n );\n await assert.rejects(\n comment(context, { issueNumber: 17, body: rawBody }, 'start:legacy'),\n /lifecycle journal key/u,\n );\n assert.equal(authorCalls, beforeInvalid, 'unsupported payloads fail before authentication or mutation');\n assert.equal(stored.length, 3);\n corruptReadback = true;\n await assert.rejects(comment(context, { issueNumber: 17, body: rawBody }), /readback/u);\n } finally {\n rmSync(root, { recursive: true, force: true });\n }\n});\n\ntest('length cap keeps the summary visible and moves every excess field into collapsed detail', () => {\n const summary = 'S'.repeat(500);\n const rendered = renderJournal({\n issueNumber: 17,\n kind: 'progress',\n summary,\n status: 'In progress '.repeat(500),\n done: ['A'.repeat(900)],\n decisionNeeded: 'None',\n keyNumbers: ['7 tests'],\n evidence: ['https://github.com/example/widget/pull/23'],\n nextStep: 'Review '.repeat(1000),\n nextDate: '2026-10-09',\n lengthCap: 600,\n });\n const first = rendered.split('\\n')[0]!;\n assert.ok(first.startsWith('Status: In progress'));\n assert.ok(first.length <= 100 && rendered.split('\\n')[2] === summary);\n assert.ok(rendered.indexOf('Next: Review') < rendered.indexOf(summary));\n assert.match(rendered, /<details>/u);\n assert.match(rendered, /A{900}/u);\n assert.match(rendered, /7 tests/u);\n assert.match(rendered, /https:\\/\\/github.com\\/example\\/widget\\/pull\\/23/u);\n});\n\ntest('automatic closeout selects acceptance checkboxes and declared follow-ups without swallowing other sections', () => {\n const body =\n '## Outcome\\nShip.\\n\\n## Acceptance Criteria\\n- [ ] Validation works\\n- [x] Recovery works\\n\\n## Follow-ups\\n- Track post-release adoption: https://github.com/example/widget/issues/24\\n\\n## Non-goals\\n- [ ] Not an acceptance criterion';\n assert.deepEqual(acceptanceCriteria(body), ['Validation works', 'Recovery works']);\n});\n\ntest('closeout accepts every readiness heading level and stops at the next heading', () => {\n for (let level = 1; level <= 6; level += 1) {\n for (let indent = 0; indent <= 3; indent += 1) {\n const heading = `${' '.repeat(indent)}${'#'.repeat(level)}`;\n const body = `${heading}\\tAcceptance Criteria\\n-[ ] Compact bullet\\n*\\t[X]\\tTabbed bullet\\n+ [x] Checked bullet\\n###### Other section\\n- [ ] Excluded\\n${heading} Follow-ups\\n- [ ] Deferred work\\n# Other section\\n- Excluded`;\n assert.deepEqual(acceptanceCriteria(body), ['Compact bullet', 'Tabbed bullet', 'Checked bullet']);\n }\n }\n});\n\ntest('journal evidence rejects local hosts and IP literals while accepting public DNS names', () => {\n const tool = getAiDeliveryMcpTool('issue_comment')!;\n const input = {\n issueNumber: 17,\n kind: 'start',\n summary: 'Work started.',\n status: 'Started',\n outcome: 'Deliver validation',\n keyNumbers: [],\n nextStep: 'Run checks',\n nextDate: null,\n };\n for (const host of [\n 'localhost',\n 'localhost.',\n 'api.localhost',\n 'runner.local',\n '127.0.0.1',\n '10.1.2.3',\n '172.16.0.1',\n '192.168.1.1',\n '169.254.1.1',\n '[::1]',\n '[fd00::1]',\n '[fe80::1]',\n '8.8.8.8',\n ])\n assert.equal(tool.inputSchema.safeParse({ ...input, evidence: [`https://${host}/evidence`] }).success, false, host);\n for (const host of ['github.com', '10.docs.example.com'])\n assert.equal(tool.inputSchema.safeParse({ ...input, evidence: [`https://${host}/evidence`] }).success, true, host);\n});\n\ntest('registered journal tool returns actionable decision refusals before native writes', async ({ signal }) => {\n const f = inertTarget(signal);\n const server = createAiDeliveryMcpServer({ repoRoot: f.root, signal });\n const client = new Client({ name: 'journal-contract-fixture', version: '1' });\n const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();\n const common = {\n repo: 'example/widget',\n issueNumber: 17,\n summary: 'Parser validation is ready.',\n status: 'In progress',\n nextStep: 'Review the parser',\n nextDate: null,\n keyNumbers: [],\n evidence: ['https://github.com/example/widget/pull/23'],\n };\n const decision = {\n ...common,\n kind: 'decision',\n decision: 'Use the existing parser',\n rationale: 'Preserves compatibility',\n };\n try {\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n // A successful call first proves the synthetic external ports and real dispatch are wired correctly.\n const valid = await client.callTool({ name: 'issue_comment', arguments: decision });\n assert.notEqual(valid.isError, true, JSON.stringify(valid));\n assert.equal(f.comments.length, 1);\n const before = f.calls.length;\n const { rationale: _rationale, ...missingRationale } = decision;\n const refused = await client.callTool({ name: 'issue_comment', arguments: missingRationale });\n assert.equal(refused.isError, true);\n assert.equal(f.comments.length, 1, 'the invalid call makes zero additional native writes');\n assert.equal(f.calls.length, before, 'refusal precedes external authentication and reads');\n const text = JSON.stringify(refused);\n assert.doesNotMatch(text, /-32602|Input validation error/u, 'a normal contract refusal must reach the handler');\n assert.match(text, /rationale/u);\n const missingBoth = await client.callTool({ name: 'issue_comment', arguments: { ...common, kind: 'progress' } });\n assert.equal(missingBoth.isError, true);\n assert.match(JSON.stringify(missingBoth), /Missing required fields: done, decisionNeeded/u);\n const missingCommon = await client.callTool({\n name: 'issue_comment',\n arguments: { repo: 'example/widget', issueNumber: 17, kind: 'decision' },\n });\n assert.equal(missingCommon.isError, true);\n assert.match(\n JSON.stringify(missingCommon),\n /Missing required fields: summary, status, nextStep, nextDate, keyNumbers, evidence, decision, rationale/u,\n );\n assert.doesNotMatch(JSON.stringify(missingCommon), /-32602|Input validation error/u);\n\n const published = (await client.listTools()).tools.find((t) => t.name === 'issue_comment');\n assert.deepEqual(\n published?.inputSchema.anyOf,\n z.toJSONSchema(getAiDeliveryMcpTool('issue_comment')!.inputSchema).anyOf,\n );\n assert.match(text, /[Pp]rovide/u, 'the refusal explains the correction');\n const listed = (await client.listTools()).tools.find((tool) => tool.name === 'issue_comment');\n assert.ok(listed);\n assert.match(listed.description ?? '', /decision: non-empty decision and rationale/u);\n const properties = listed.inputSchema.properties as Record<string, { description?: string }>;\n for (const field of ['decision', 'rationale'])\n assert.match(properties[field]?.description ?? '', /Required non-empty text when kind is decision/u);\n assert.match(properties.kind?.description ?? '', /progress: done, decisionNeeded and non-empty evidence/u);\n assert.equal(listed.inputSchema.additionalProperties, false);\n\n const { decision: _decision, ...missingDecision } = decision;\n for (const invalid of [\n missingDecision,\n { ...missingRationale, decision: 'PRIVATE_INPUT_SENTINEL' },\n { ...decision, rationale: '' },\n { ...decision, rationale: 17 },\n { ...decision, kind: 'PRIVATE_INPUT_SENTINEL' },\n { ...decision, unknown: 'PRIVATE_INPUT_SENTINEL' },\n { ...decision, PRIVATE_INPUT_SENTINEL: 'private value' },\n {\n ...common,\n kind: 'closeout',\n acceptance: [{ criterion: 'Validated', evidence: common.evidence[0], PRIVATE_INPUT_SENTINEL: 'private value' }],\n followUps: [],\n },\n { ...decision, outcome: 'PRIVATE_INPUT_SENTINEL' },\n { ...common, kind: 'start' },\n { ...common, kind: 'progress', done: ['Validated'], decisionNeeded: 'None', evidence: [] },\n { ...common, kind: 'blocker', blocker: 'Review pending' },\n { ...common, kind: 'closeout', acceptance: [], followUps: [] },\n ]) {\n const invalidResult = await client.callTool({ name: 'issue_comment', arguments: invalid });\n assert.equal(invalidResult.isError, true);\n assert.doesNotMatch(JSON.stringify(invalidResult), /PRIVATE_INPUT_SENTINEL/u);\n assert.equal(f.comments.length, 1, 'invalid journals never create a native comment');\n assert.equal(f.calls.length, before, 'invalid journals stop before external ports');\n }\n\n const renderedDecision = f.comments[0]!.body;\n assert.match(\n renderedDecision,\n /^Status: In progress\\. Next: Review the parser\\.\\n\\nParser validation is ready\\.\\n\\n\\*\\*Kind:\\*\\* decision\\. \\*\\*Status:\\*\\* In progress\\n\\n\\*\\*Decision:\\*\\* Use the existing parser\\n\\n\\*\\*Rationale:\\*\\* Preserves compatibility/u,\n );\n assert.match(renderedDecision, /<!-- ai-delivery:journal@1:sha256:[a-f0-9]{64} -->$/u);\n const retry = await client.callTool({ name: 'issue_comment', arguments: { ...decision, verbose: true } });\n assert.notEqual(retry.isError, true);\n const retried = JSON.parse((retry.content as { text: string }[])[0]!.text) as {\n body: string;\n reused: boolean;\n commentId: number;\n url: string;\n };\n assert.equal(retried.reused, true);\n assert.equal(retried.body, renderedDecision);\n assert.equal(retried.commentId, 101);\n assert.equal(retried.url, 'https://github.com/example/widget/issues/17#issuecomment-101');\n assert.equal(f.comments.length, 1);\n for (const [variant, section] of [\n [{ ...common, kind: 'start', outcome: 'Deliver validation' }, '**Outcome:** Deliver validation'],\n [\n { ...common, kind: 'progress', done: ['Validated'], decisionNeeded: 'None' },\n '**Done since last:**\\n- Validated',\n ],\n [\n { ...common, kind: 'blocker', blocker: 'Review pending', resolution: 'Independent acceptance' },\n '**Resolution needed:** Independent acceptance',\n ],\n [\n {\n ...common,\n kind: 'closeout',\n acceptance: [{ criterion: 'Validation works', evidence: common.evidence[0] }],\n followUps: [],\n },\n '**Follow-ups:** None.',\n ],\n ] as const) {\n const accepted = await client.callTool({ name: 'issue_comment', arguments: { ...variant, verbose: true } });\n assert.notEqual(accepted.isError, true, JSON.stringify(accepted));\n const value = JSON.parse((accepted.content as { text: string }[])[0]!.text) as { body: string; reused: boolean };\n assert.equal(value.reused, false);\n assert.ok(value.body.includes(section));\n assert.equal(value.body, f.comments.at(-1)!.body, 'response retains authoritative native readback');\n }\n assert.equal(f.comments.length, 5, 'all five valid journal kinds remain usable');\n } finally {\n await client.close();\n await server.close();\n await f.dispose(undefined);\n }\n});\n"],
5
- "mappings": "AAAA,OAAO,YAAY;AACnB,SAAS,SAAS;AAClB,SAAS,MAAM,UAAU;AACzB,SAAS,cAAc;AACvB,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAC1C,SAAS,mBAAmB;AAE5B,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAGvB,SAAS,oBAAoB,eAAe,0BAA0B;AACtE,SAAS,mBAAmB;AAC5B,YAAY,mBAAmB;AAC/B,YAAY,mBAAmB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,aAAa,cAAc;AACpC,SAAS,cAAc;AACvB,SAAS,YAAY;AAErB,KAAK,sFAAsF,MAAM;AAC/F,QAAM,SAAS,cAAc;AAAA,IAC3B,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,UAAU;AAAA,IACV,YAAY,CAAC;AAAA,IACb,UAAU,CAAC;AAAA,EACb,CAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF,CAAC;AAED,KAAK,uGAAuG,MAAM;AAChH,QAAM,QAAQ,CAAC,QAAgB,aAC7B,cAAc;AAAA,IACZ,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA,MAAM,CAAC,sBAAsB;AAAA,IAC7B,gBAAgB;AAAA,IAChB;AAAA,IACA,UAAU;AAAA,IACV,YAAY,CAAC;AAAA,IACb,UAAU,CAAC,sEAAsE;AAAA,EACnF,CAAC,EAAE,MAAM,IAAI,EAAE,CAAC;AAClB,SAAO;AAAA,IACL;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACA,SAAO,MAAM,MAAM,YAAK,OA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,4CAA4C;AAAA,EACjF,UAAE;AACA,UAAM,OAAO,MAAM;AACnB,UAAM,OAAO,MAAM;AACnB,UAAM,EAAE,QAAQ,MAAS;AAAA,EAC3B;AACF,CAAC;",
4
+ "sourcesContent": ["import assert from 'node:assert/strict';\nimport { z } from 'zod';\nimport { test, vi } from 'vitest';\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';\nimport { createAiDeliveryMcpServer } from './mcp/index.js';\nimport { inertTarget } from './fixtures/inertTarget.js';\n\nimport { getAiDeliveryMcpTool } from './mcp/tools.js';\nimport * as issue from './issue.js';\nimport type { DeliveryContext } from './issue.js';\nimport type { JournalInput } from './issueJournal.js';\nimport { JournalInputSchema, renderJournal, acceptanceCriteria } from './issueJournal.js';\nimport { executeTool } from './dispatch.js';\nimport * as configuration from './config/deliveryConfig.js';\nimport * as githubClients from './github/client.js';\nimport { execFileSync } from 'node:child_process';\nimport { mkdtempSync, rmSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\ntest('decision journal list fields start below their label and preserve nested structure', () => {\n const result = renderJournal({\n issueNumber: 17,\n kind: 'decision',\n summary: 'A decision was made.',\n status: 'Ready',\n decision: '- First\\n - Nested\\n- Second',\n rationale: 'The existing owner is sufficient.',\n nextStep: 'Run checks',\n nextDate: null,\n keyNumbers: [],\n evidence: [],\n });\n assert.equal(\n result,\n 'Status: Ready. Next: Run checks.\\n\\nA decision was made.\\n\\n**Kind:** decision. **Status:** Ready\\n\\n**Decision:**\\n- First\\n - Nested\\n- Second\\n\\n**Rationale:** The existing owner is sufficient.\\n\\n**Key numbers:** None reported.\\n\\n**Next:** Run checks (date not scheduled).\\n\\n**Evidence:** None yet.',\n );\n});\n\ntest('a cut status or next-step preview ends on a whole word and an ellipsis (ai#3550 comment 6596479566)', () => {\n const first = (status: string, nextStep: string) =>\n renderJournal({\n issueNumber: 3550,\n kind: 'progress',\n summary: 'Weekly screen finished.',\n status,\n done: ['Screened 4,694 cells'],\n decisionNeeded: 'None',\n nextStep,\n nextDate: '2026-11-09',\n keyNumbers: [],\n evidence: ['https://github.com/aviaratech/ai/issues/3550#issuecomment-6502461445'],\n }).split('\\n')[0];\n assert.equal(\n first(\n 'Finished 9:43 pm PT. Nothing is left running; the guard exits at its next 10-minute check.',\n 'Next weekly run Monday Nov 9: `scripts/weekly.sh 2026-11-09`.',\n ),\n 'Status: Finished 9:43 pm PT. Nothing is\u2026. Next: Next weekly run Monday Nov 9:\u2026.',\n );\n assert.equal(first('\uD83D\uDE42'.repeat(40), 'Run checks'), `Status: ${'\uD83D\uDE42'.repeat(15)}\u2026. Next: Run checks.`);\n});\n\ntest('published comment schema lists a plain body or the required fields for every journal kind', () => {\n const schema = z.toJSONSchema(getAiDeliveryMcpTool('issue_comment')!.inputSchema, { io: 'input' });\n const common = ['summary', 'status', 'nextStep', 'nextDate', 'keyNumbers', 'evidence', 'kind'];\n assert.deepEqual(schema.required, ['issueNumber']);\n assert.deepEqual(schema.anyOf, [\n { required: ['body'] },\n { properties: { kind: { const: 'start' } }, required: [...common, 'outcome'] },\n { properties: { kind: { const: 'progress' } }, required: [...common, 'done', 'decisionNeeded'] },\n { properties: { kind: { const: 'decision' } }, required: [...common, 'decision', 'rationale'] },\n { properties: { kind: { const: 'blocker' } }, required: [...common, 'blocker', 'resolution'] },\n { properties: { kind: { const: 'closeout' } }, required: [...common, 'acceptance', 'followUps'] },\n ]);\n});\n\ntest('all typed journals validate and lead with plain status and next-step previews', () => {\n const tool = getAiDeliveryMcpTool('issue_comment');\n assert.ok(tool, 'issue_comment must be exposed');\n const common = {\n issueNumber: 17,\n summary: 'Parser work is underway.',\n status: 'In progress',\n nextStep: 'Run checks',\n nextDate: '2026-10-09',\n keyNumbers: ['3 checks'],\n evidence: ['https://github.com/example/widget/pull/23'],\n };\n const valid: JournalInput[] = [\n { ...common, kind: 'start', outcome: 'Deliver a safe parser' },\n { ...common, kind: 'progress', done: ['Added validation'], decisionNeeded: 'None' },\n { ...common, kind: 'decision', decision: 'Use the existing parser', rationale: 'Preserves the contract' },\n { ...common, kind: 'blocker', blocker: 'Review pending', resolution: 'Independent acceptance' },\n {\n ...common,\n kind: 'closeout',\n acceptance: [{ criterion: 'Reject malformed input', evidence: 'https://github.com/example/widget/pull/23' }],\n followUps: [],\n },\n ];\n for (const input of valid) {\n for (const repo of [undefined, 'example/widget']) {\n for (const nextDate of [null, '2026-10-09', '2028-02-29']) {\n const selected = { ...input, nextDate, ...(repo === undefined ? {} : { repo }) };\n const parsed: ReturnType<typeof tool.inputSchema.safeParse> = tool.inputSchema.safeParse(selected);\n assert.equal(parsed.success, true, JSON.stringify(selected));\n if (parsed.success) assert.deepEqual(parsed.data, selected);\n }\n }\n assert.equal(JournalInputSchema.safeParse(input).success, true);\n assert.equal(JournalInputSchema.safeParse({ ...input, repo: 'example/widget' }).success, false);\n for (const summary of [input.summary, 'S'.repeat(500)]) {\n const marker = `<!-- ai-delivery:journal@1:sha256:${'a'.repeat(64)} -->`;\n const body = renderJournal(\n {\n ...input,\n summary,\n status: '**In progress**',\n nextStep: 'Run\\nchecks',\n lengthCap: 600,\n details: 'D'.repeat(900),\n },\n marker,\n );\n assert.equal(body.startsWith(`Status: In progress. Next: Run checks.\\n\\n${summary}\\n\\n`), true);\n assert.match(body, /<details>/u);\n assert.ok(body.endsWith(marker));\n }\n }\n for (const input of [\n { ...common, kind: 'progress' },\n { ...common, kind: 'start', outcome: '' },\n { ...common, kind: 'closeout', acceptance: [], followUps: [] },\n {\n ...common,\n kind: 'decision',\n decision: 'Use parser',\n rationale: 'Works',\n evidence: ['/Users/operator/checks.log'],\n },\n { ...common, kind: 'start', outcome: 'Deliver', nextDate: 'tomorrow' },\n { ...common, kind: 'start', outcome: 'Deliver', done: ['Wrong variant'] },\n { ...common, kind: 'progress', done: ['Deliver'], decisionNeeded: 'None', rationale: 'Wrong variant' },\n { ...common, kind: 'decision', decision: 'Use parser', rationale: 'Works', blocker: 'Wrong variant' },\n { ...common, kind: 'blocker', blocker: 'Review', resolution: 'Accept', outcome: 'Wrong variant' },\n { ...valid[4], done: ['Wrong variant'] },\n { ...valid[0], unknown: true },\n { ...valid[0], kind: 'unsupported' },\n { ...valid[0], nextDate: '2026-02-30' },\n { ...valid[0], nextDate: 20261009 },\n { ...valid[0], keyNumbers: '3 checks' },\n { ...valid[0], issueNumber: '17' },\n { ...valid[4], acceptance: [{ criterion: 'Deliver', evidence: common.evidence[0], unknown: true }] },\n ])\n for (const repo of [undefined, 'example/widget'])\n assert.equal(tool.inputSchema.safeParse({ ...input, ...(repo === undefined ? {} : { repo }) }).success, false);\n for (const repo of [\n '',\n 'example',\n 'example/widget/extra',\n 'https://github.com/example/widget',\n 'example/\\nwidget',\n 17,\n null,\n [],\n ])\n assert.equal(tool.inputSchema.safeParse({ ...valid[0], repo }).success, false);\n});\n\ntest('journal dispatch refuses invalid fields and repository conflicts before configuration or authentication', async () => {\n const settings = vi.spyOn(configuration, 'loadDeliverySettings').mockImplementation(async () => {\n throw new Error('Configuration must not load for an invalid journal');\n });\n const clients = vi.spyOn(githubClients, 'createDeliveryGitHubClients');\n const valid = {\n repo: 'example/widget',\n issueNumber: 17,\n kind: 'progress',\n summary: 'Parser work is underway.',\n status: 'In progress',\n done: ['Added validation'],\n decisionNeeded: 'None',\n keyNumbers: [],\n evidence: ['https://github.com/example/widget/pull/23'],\n nextStep: 'Run checks',\n nextDate: null,\n };\n try {\n for (const input of [\n { ...valid, kind: 'unsupported' },\n { ...valid, outcome: 'Wrong variant' },\n { ...valid, unknown: true },\n { ...valid, done: [] },\n { ...valid, evidence: [] },\n { ...valid, repo: 'invalid' },\n { ...valid, repo: 17 },\n { ...valid, nextDate: '2026-02-30' },\n ])\n await assert.rejects(executeTool('issue_comment', input, { repoRoot: '/non-git-fixture' }));\n await assert.rejects(\n executeTool('issue_comment', valid, { repoRoot: '/non-git-fixture', repo: 'example/other' }),\n /selectors disagree/u,\n );\n assert.equal(settings.mock.calls.length, 0);\n assert.equal(clients.mock.calls.length, 0, 'no authenticated client or comment writer is reached');\n } finally {\n settings.mockRestore();\n clients.mockRestore();\n }\n});\n\ntest('canonical comment writes read back and recover a lost response without duplicates', async () => {\n const comment = (\n issue as unknown as {\n commentIssue?: (\n context: DeliveryContext,\n input: JournalInput | { issueNumber: number; body: string },\n lifecycleKey?: string,\n ) => Promise<{ commentId: number; url: string; body: string; reused: boolean }>;\n }\n ).commentIssue;\n assert.ok(comment, 'canonical comment writer must exist');\n const agent = await import('./agent.js');\n assert.equal(agent.commentIssue, comment);\n assert.equal(agent.ISSUE_COMMENT_BODY_LIMIT, 65536);\n const root = mkdtempSync(join(tmpdir(), 'ai-delivery-journal-'));\n execFileSync('git', ['init', '-q', '-b', 'main'], { cwd: root });\n const stored: { id: number; body: string; html_url: string; user: { login: string }; issue_url: string }[] = [];\n let loseResponse = true;\n let corruptReadback = false;\n let authorCalls = 0;\n const context = {\n root,\n repo: { owner: 'example', repo: 'widget' },\n clients: {\n role: 'author',\n authenticatedAuthor: async () => {\n authorCalls += 1;\n return { actorLogin: 'operator', credentialIdentity: 'user:1' };\n },\n rest: {\n issues: {\n get: async () => ({ data: { number: 17, state: 'open' } }),\n listComments: async () => ({ data: stored }),\n createComment: async (input: { body: string }) => {\n const id = 91 + stored.length;\n const data = {\n id,\n body: input.body,\n html_url: `https://github.com/example/widget/issues/17#issuecomment-${String(id)}`,\n issue_url: 'https://api.github.com/repos/example/widget/issues/17',\n user: { login: 'operator' },\n };\n stored.push(data);\n if (loseResponse) {\n loseResponse = false;\n throw new Error('response lost');\n }\n return { data };\n },\n getComment: async (input: { comment_id: number }) => ({\n data: {\n ...stored.find((item) => item.id === input.comment_id),\n ...(corruptReadback ? { body: 'changed' } : {}),\n },\n }),\n },\n },\n },\n } as unknown as DeliveryContext;\n const input: JournalInput = {\n issueNumber: 17,\n kind: 'start',\n summary: 'Implementation started.',\n status: 'In progress',\n outcome: 'Deliver validation',\n keyNumbers: [],\n evidence: [],\n nextStep: 'Run checks',\n nextDate: '2026-10-09',\n };\n try {\n await assert.rejects(comment(context, input), /response lost/u);\n const recovered = await comment(context, input);\n assert.equal(recovered.commentId, 91);\n assert.equal(recovered.reused, true);\n assert.equal(stored.length, 1);\n assert.match(recovered.body, /^Status: In progress\\. Next: Run checks\\.\\n\\nImplementation started\\./u);\n corruptReadback = true;\n await assert.rejects(comment(context, input), /readback/u);\n corruptReadback = false;\n\n stored.push({ ...stored[0]!, id: 99, html_url: 'https://github.com/example/widget/issues/17#issuecomment-99' });\n await assert.rejects(comment(context, input), /duplicate authored retry matches/u);\n assert.equal(stored.length, 2, 'ambiguous retries must not write another comment');\n stored.pop();\n\n const rawBody = `\\r\\n <details>\\n<summary>Prior content</summary>\\n<pre>${'\uD83D\uDE42 &amp; prior title/body\\r\\n'.repeat(600)}</pre>\\n</details> \\t\\n`;\n assert.ok(rawBody.length > 10000);\n loseResponse = true;\n await assert.rejects(comment(context, { issueNumber: 17, body: rawBody }), /response lost/u);\n const rawRecovered = await comment(context, { issueNumber: 17, body: rawBody });\n assert.equal(rawRecovered.body, rawBody, 'raw history content must remain exact and unwrapped');\n assert.equal(rawRecovered.commentId, 92);\n assert.equal(rawRecovered.reused, true);\n assert.equal(stored.length, 2);\n assert.equal(stored[1]!.body, rawBody, 'no journal marker or unrequested content is appended');\n\n const maximumBody = '\uD83D\uDE42'.repeat(32768);\n assert.equal(maximumBody.length, 65536);\n assert.equal((await comment(context, { issueNumber: 17, body: maximumBody })).body, maximumBody);\n assert.equal(stored.length, 3);\n const beforeInvalid = authorCalls;\n for (const body of ['', ' \\r\\n\\t ', 'x'.repeat(65537), `${maximumBody}\uD83D\uDE42`])\n await assert.rejects(comment(context, { issueNumber: 17, body }), /comment body/u);\n await assert.rejects(\n comment(context, {\n ...input,\n status: 'x'.repeat(9000),\n outcome: 'x'.repeat(9000),\n nextStep: 'x'.repeat(9000),\n details: 'x'.repeat(9000),\n keyNumbers: Array.from({ length: 4 }, () => 'x'.repeat(9000)),\n }),\n /comment body/u,\n );\n await assert.rejects(\n comment(context, { issueNumber: 17, body: rawBody }, 'start:legacy'),\n /lifecycle journal key/u,\n );\n assert.equal(authorCalls, beforeInvalid, 'unsupported payloads fail before authentication or mutation');\n assert.equal(stored.length, 3);\n corruptReadback = true;\n await assert.rejects(comment(context, { issueNumber: 17, body: rawBody }), /readback/u);\n } finally {\n rmSync(root, { recursive: true, force: true });\n }\n});\n\ntest('length cap keeps the summary visible and moves every excess field into collapsed detail', () => {\n const summary = 'S'.repeat(500);\n const rendered = renderJournal({\n issueNumber: 17,\n kind: 'progress',\n summary,\n status: 'In progress '.repeat(500),\n done: ['A'.repeat(900)],\n decisionNeeded: 'None',\n keyNumbers: ['7 tests'],\n evidence: ['https://github.com/example/widget/pull/23'],\n nextStep: 'Review '.repeat(1000),\n nextDate: '2026-10-09',\n lengthCap: 600,\n });\n const first = rendered.split('\\n')[0]!;\n assert.ok(first.startsWith('Status: In progress'));\n assert.ok(first.length <= 100 && rendered.split('\\n')[2] === summary);\n assert.ok(rendered.indexOf('Next: Review') < rendered.indexOf(summary));\n assert.match(rendered, /<details>/u);\n assert.match(rendered, /A{900}/u);\n assert.match(rendered, /7 tests/u);\n assert.match(rendered, /https:\\/\\/github.com\\/example\\/widget\\/pull\\/23/u);\n});\n\ntest('automatic closeout selects acceptance checkboxes and declared follow-ups without swallowing other sections', () => {\n const body =\n '## Outcome\\nShip.\\n\\n## Acceptance Criteria\\n- [ ] Validation works\\n- [x] Recovery works\\n\\n## Follow-ups\\n- Track post-release adoption: https://github.com/example/widget/issues/24\\n\\n## Non-goals\\n- [ ] Not an acceptance criterion';\n assert.deepEqual(acceptanceCriteria(body), ['Validation works', 'Recovery works']);\n});\n\ntest('closeout accepts every readiness heading level and stops at the next heading', () => {\n for (let level = 1; level <= 6; level += 1) {\n for (let indent = 0; indent <= 3; indent += 1) {\n const heading = `${' '.repeat(indent)}${'#'.repeat(level)}`;\n const body = `${heading}\\tAcceptance Criteria\\n-[ ] Compact bullet\\n*\\t[X]\\tTabbed bullet\\n+ [x] Checked bullet\\n###### Other section\\n- [ ] Excluded\\n${heading} Follow-ups\\n- [ ] Deferred work\\n# Other section\\n- Excluded`;\n assert.deepEqual(acceptanceCriteria(body), ['Compact bullet', 'Tabbed bullet', 'Checked bullet']);\n }\n }\n});\n\ntest('journal evidence rejects local hosts and IP literals while accepting public DNS names', () => {\n const tool = getAiDeliveryMcpTool('issue_comment')!;\n const input = {\n issueNumber: 17,\n kind: 'start',\n summary: 'Work started.',\n status: 'Started',\n outcome: 'Deliver validation',\n keyNumbers: [],\n nextStep: 'Run checks',\n nextDate: null,\n };\n for (const host of [\n 'localhost',\n 'localhost.',\n 'api.localhost',\n 'runner.local',\n '127.0.0.1',\n '10.1.2.3',\n '172.16.0.1',\n '192.168.1.1',\n '169.254.1.1',\n '[::1]',\n '[fd00::1]',\n '[fe80::1]',\n '8.8.8.8',\n ])\n assert.equal(tool.inputSchema.safeParse({ ...input, evidence: [`https://${host}/evidence`] }).success, false, host);\n for (const host of ['github.com', '10.docs.example.com'])\n assert.equal(tool.inputSchema.safeParse({ ...input, evidence: [`https://${host}/evidence`] }).success, true, host);\n});\n\ntest('registered journal tool returns actionable decision refusals before native writes', async ({ signal }) => {\n const f = inertTarget(signal);\n const server = createAiDeliveryMcpServer({ repoRoot: f.root, signal });\n const client = new Client({ name: 'journal-contract-fixture', version: '1' });\n const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();\n const common = {\n repo: 'example/widget',\n issueNumber: 17,\n summary: 'Parser validation is ready.',\n status: 'In progress',\n nextStep: 'Review the parser',\n nextDate: null,\n keyNumbers: [],\n evidence: ['https://github.com/example/widget/pull/23'],\n };\n const decision = {\n ...common,\n kind: 'decision',\n decision: 'Use the existing parser',\n rationale: 'Preserves compatibility',\n };\n try {\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n // A successful call first proves the synthetic external ports and real dispatch are wired correctly.\n const valid = await client.callTool({ name: 'issue_comment', arguments: decision });\n assert.notEqual(valid.isError, true, JSON.stringify(valid));\n assert.equal(f.comments.length, 1);\n const before = f.calls.length;\n const { rationale: _rationale, ...missingRationale } = decision;\n const refused = await client.callTool({ name: 'issue_comment', arguments: missingRationale });\n assert.equal(refused.isError, true);\n assert.equal(f.comments.length, 1, 'the invalid call makes zero additional native writes');\n assert.equal(f.calls.length, before, 'refusal precedes external authentication and reads');\n const text = JSON.stringify(refused);\n assert.doesNotMatch(text, /-32602|Input validation error/u, 'a normal contract refusal must reach the handler');\n assert.match(text, /rationale/u);\n const missingBoth = await client.callTool({ name: 'issue_comment', arguments: { ...common, kind: 'progress' } });\n assert.equal(missingBoth.isError, true);\n assert.match(JSON.stringify(missingBoth), /Missing required fields: done, decisionNeeded/u);\n const missingCommon = await client.callTool({\n name: 'issue_comment',\n arguments: { repo: 'example/widget', issueNumber: 17, kind: 'decision' },\n });\n assert.equal(missingCommon.isError, true);\n assert.match(\n JSON.stringify(missingCommon),\n /Missing required fields: summary, status, nextStep, nextDate, keyNumbers, evidence, decision, rationale/u,\n );\n assert.doesNotMatch(JSON.stringify(missingCommon), /-32602|Input validation error/u);\n\n const published = (await client.listTools()).tools.find((t) => t.name === 'issue_comment');\n assert.deepEqual(\n published?.inputSchema.anyOf,\n z.toJSONSchema(getAiDeliveryMcpTool('issue_comment')!.inputSchema, { io: 'input' }).anyOf,\n );\n assert.match(text, /[Pp]rovide/u, 'the refusal explains the correction');\n const listed = (await client.listTools()).tools.find((tool) => tool.name === 'issue_comment');\n assert.ok(listed);\n assert.match(listed.description ?? '', /decision: non-empty decision and rationale/u);\n const properties = listed.inputSchema.properties as Record<string, { description?: string }>;\n for (const field of ['decision', 'rationale'])\n assert.match(properties[field]?.description ?? '', /Required non-empty text when kind is decision/u);\n assert.match(properties.kind?.description ?? '', /progress: done, decisionNeeded and non-empty evidence/u);\n assert.equal(listed.inputSchema.additionalProperties, false);\n\n const { decision: _decision, ...missingDecision } = decision;\n for (const invalid of [\n missingDecision,\n { ...missingRationale, decision: 'PRIVATE_INPUT_SENTINEL' },\n { ...decision, rationale: '' },\n { ...decision, rationale: 17 },\n { ...decision, kind: 'PRIVATE_INPUT_SENTINEL' },\n { ...decision, unknown: 'PRIVATE_INPUT_SENTINEL' },\n { ...decision, PRIVATE_INPUT_SENTINEL: 'private value' },\n {\n ...common,\n kind: 'closeout',\n acceptance: [{ criterion: 'Validated', evidence: common.evidence[0], PRIVATE_INPUT_SENTINEL: 'private value' }],\n followUps: [],\n },\n { ...decision, outcome: 'PRIVATE_INPUT_SENTINEL' },\n { ...common, kind: 'start' },\n { ...common, kind: 'progress', done: ['Validated'], decisionNeeded: 'None', evidence: [] },\n { ...common, kind: 'blocker', blocker: 'Review pending' },\n { ...common, kind: 'closeout', acceptance: [], followUps: [] },\n ]) {\n const invalidResult = await client.callTool({ name: 'issue_comment', arguments: invalid });\n assert.equal(invalidResult.isError, true);\n assert.doesNotMatch(JSON.stringify(invalidResult), /PRIVATE_INPUT_SENTINEL/u);\n assert.equal(f.comments.length, 1, 'invalid journals never create a native comment');\n assert.equal(f.calls.length, before, 'invalid journals stop before external ports');\n }\n\n const renderedDecision = f.comments[0]!.body;\n assert.match(\n renderedDecision,\n /^Status: In progress\\. Next: Review the parser\\.\\n\\nParser validation is ready\\.\\n\\n\\*\\*Kind:\\*\\* decision\\. \\*\\*Status:\\*\\* In progress\\n\\n\\*\\*Decision:\\*\\* Use the existing parser\\n\\n\\*\\*Rationale:\\*\\* Preserves compatibility/u,\n );\n assert.match(renderedDecision, /<!-- ai-delivery:journal@1:sha256:[a-f0-9]{64} -->$/u);\n const retry = await client.callTool({ name: 'issue_comment', arguments: { ...decision, verbose: true } });\n assert.notEqual(retry.isError, true);\n const retried = JSON.parse((retry.content as { text: string }[])[0]!.text) as {\n body: string;\n reused: boolean;\n commentId: number;\n url: string;\n };\n assert.equal(retried.reused, true);\n assert.equal(retried.body, renderedDecision);\n assert.equal(retried.commentId, 101);\n assert.equal(retried.url, 'https://github.com/example/widget/issues/17#issuecomment-101');\n assert.equal(f.comments.length, 1);\n for (const [variant, section] of [\n [{ ...common, kind: 'start', outcome: 'Deliver validation' }, '**Outcome:** Deliver validation'],\n [\n { ...common, kind: 'progress', done: ['Validated'], decisionNeeded: 'None' },\n '**Done since last:**\\n- Validated',\n ],\n [\n { ...common, kind: 'blocker', blocker: 'Review pending', resolution: 'Independent acceptance' },\n '**Resolution needed:** Independent acceptance',\n ],\n [\n {\n ...common,\n kind: 'closeout',\n acceptance: [{ criterion: 'Validation works', evidence: common.evidence[0] }],\n followUps: [],\n },\n '**Follow-ups:** None.',\n ],\n ] as const) {\n const accepted = await client.callTool({ name: 'issue_comment', arguments: { ...variant, verbose: true } });\n assert.notEqual(accepted.isError, true, JSON.stringify(accepted));\n const value = JSON.parse((accepted.content as { text: string }[])[0]!.text) as { body: string; reused: boolean };\n assert.equal(value.reused, false);\n assert.ok(value.body.includes(section));\n assert.equal(value.body, f.comments.at(-1)!.body, 'response retains authoritative native readback');\n }\n assert.equal(f.comments.length, 5, 'all five valid journal kinds remain usable');\n } finally {\n await client.close();\n await server.close();\n await f.dispose(undefined);\n }\n});\n"],
5
+ "mappings": "AAAA,OAAO,YAAY;AACnB,SAAS,SAAS;AAClB,SAAS,MAAM,UAAU;AACzB,SAAS,cAAc;AACvB,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAC1C,SAAS,mBAAmB;AAE5B,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAGvB,SAAS,oBAAoB,eAAe,0BAA0B;AACtE,SAAS,mBAAmB;AAC5B,YAAY,mBAAmB;AAC/B,YAAY,mBAAmB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,aAAa,cAAc;AACpC,SAAS,cAAc;AACvB,SAAS,YAAY;AAErB,KAAK,sFAAsF,MAAM;AAC/F,QAAM,SAAS,cAAc;AAAA,IAC3B,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,UA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AAAA,MAC/F;AAAA,QACE,EAAE,GAAG,QAAQ,MAAM,YAAY,MAAM,CAAC,WAAW,GAAG,gBAAgB,OAAO;AAAA,QAC3E;AAAA,MACF;AAAA,MACA;AAAA,QACE,EAAE,GAAG,QAAQ,MAAM,WAAW,SAAS,kBAAkB,YAAY,yBAAyB;AAAA,QAC9F;AAAA,MACF;AAAA,MACA;AAAA,QACE;AAAA,UACE,GAAG;AAAA,UACH,MAAM;AAAA,UACN,YAAY,CAAC,EAAE,WAAW,oBAAoB,UAAU,OAAO,SAAS,CAAC,EAAE,CAAC;AAAA,UAC5E,WAAW,CAAC;AAAA,QACd;AAAA,QACA;AAAA,MACF;AAAA,IACF,GAAY;AACV,YAAM,WAAW,MAAM,OAAO,SAAS,EAAE,MAAM,iBAAiB,WAAW,EAAE,GAAG,SAAS,SAAS,KAAK,EAAE,CAAC;AAC1G,aAAO,SAAS,SAAS,SAAS,MAAM,KAAK,UAAU,QAAQ,CAAC;AAChE,YAAM,QAAQ,KAAK,MAAO,SAAS,QAA+B,CAAC,EAAG,IAAI;AAC1E,aAAO,MAAM,MAAM,QAAQ,KAAK;AAChC,aAAO,GAAG,MAAM,KAAK,SAAS,OAAO,CAAC;AACtC,aAAO,MAAM,MAAM,MAAM,EAAE,SAAS,GAAG,EAAE,EAAG,MAAM,gDAAgD;AAAA,IACpG;AACA,WAAO,MAAM,EAAE,SAAS,QAAQ,GAAG,4CAA4C;AAAA,EACjF,UAAE;AACA,UAAM,OAAO,MAAM;AACnB,UAAM,OAAO,MAAM;AACnB,UAAM,EAAE,QAAQ,MAAS;AAAA,EAC3B;AACF,CAAC;",
6
6
  "names": ["input"]
7
7
  }
@@ -41,7 +41,11 @@ function updateFixture() {
41
41
  projectFailure: "",
42
42
  nativeReadsAfterUpdate: 0,
43
43
  failChildReadAfterUpdate: false,
44
- childReadsAfterUpdate: 0
44
+ childReadsAfterUpdate: 0,
45
+ artifacts: [],
46
+ artifactStatus: 200,
47
+ blocking: [],
48
+ blockingStatus: 200
45
49
  };
46
50
  const comments = [];
47
51
  const updates = [];
@@ -120,9 +124,24 @@ function updateFixture() {
120
124
  return { data: { ...live } };
121
125
  }
122
126
  },
123
- request: async () => ({ data: [] })
127
+ request: async (route) => {
128
+ if (!route.endsWith("/artifacts")) return { data: [] };
129
+ if (controls.artifactStatus !== 200)
130
+ throw Object.assign(new Error("Artifacts unavailable"), { status: controls.artifactStatus });
131
+ return { status: 200, data: controls.artifacts };
132
+ }
124
133
  },
125
134
  graphql: async (query, variables) => {
135
+ if (query.includes("blocking(first:")) {
136
+ if (controls.blockingStatus !== 200)
137
+ throw Object.assign(new Error("Bad gateway"), { status: controls.blockingStatus });
138
+ const nodes = controls.blocking.map((node) => ({
139
+ ...node,
140
+ id: `ISSUE${String(node.number)}`,
141
+ title: "Dependent"
142
+ }));
143
+ return { repository: { issue: { blocking: { nodes, pageInfo: { hasNextPage: false, endCursor: null } } } } };
144
+ }
126
145
  if (query.includes("ProjectDelivery") && updates.length && controls.projectFailure) {
127
146
  if (controls.projectFailure === "cancel") throw new DOMException("Cancelled", "AbortError");
128
147
  throw Object.assign(new Error("PRIVATE_RATE_CONTENT"), {
@@ -435,6 +454,120 @@ test("reasoned closure records supersession and verifies native reason and dupli
435
454
  }
436
455
  }
437
456
  });
457
+ const studyArtifact = (number, name) => ({
458
+ number,
459
+ name,
460
+ type: "generic",
461
+ html_url: `https://github.com/example/widget/issues/17/artifacts/${String(number)}`
462
+ });
463
+ test("a study closes as completed only with a verdict, a Result and a READOUT artifact", async () => {
464
+ const close = { issueNumber: 17, state: "closed", closeReason: "completed" };
465
+ const closeout = { verdict: "NONE: no cut passed", result: "Net \u22120.4\xA2/fill (n=212)" };
466
+ const cases = [
467
+ { input: close, refusal: /Pass closeout\.verdict/u },
468
+ { input: { ...close, closeout: { ...closeout, result: "" } }, refusal: /Pass closeout\.result/u },
469
+ {
470
+ input: { ...close, closeout },
471
+ artifacts: [studyArtifact(1, "PLAN.md")],
472
+ refusal: /gh issue artifact create 17/u
473
+ },
474
+ { input: { ...close, closeout }, artifactStatus: 404, refusal: /artifacts \(HTTP 404\)/u },
475
+ { input: { ...close, closeout: { ...closeout, verdict: "a\nb\nc\nd" } }, refusal: /1–3 lines/u },
476
+ { input: { ...close, closeReason: "not_planned" } },
477
+ { title: "Book cell can hold tied", input: close }
478
+ ];
479
+ for (const example of cases) {
480
+ const f2 = updateFixture();
481
+ try {
482
+ f2.live.title = example.title ?? "Study: X";
483
+ f2.controls.artifacts = example.artifacts ?? [];
484
+ f2.controls.artifactStatus = example.artifactStatus ?? 200;
485
+ if (example.refusal) {
486
+ await assert.rejects(issue.updateIssue(f2.context, example.input), example.refusal);
487
+ assert.equal(f2.live.state, "open");
488
+ assert.equal(f2.comments.length, 0);
489
+ } else {
490
+ const result = await issue.updateIssue(f2.context, example.input);
491
+ assert.equal(result.state, "closed");
492
+ assert.match(f2.comments[0].body, /^Requested closure reason: (completed|not_planned)\.$/u);
493
+ }
494
+ } finally {
495
+ f2.cleanup();
496
+ }
497
+ }
498
+ const f = updateFixture();
499
+ try {
500
+ f.live.title = "Study: X";
501
+ f.controls.artifacts = [studyArtifact(1, "READOUT.md"), studyArtifact(2, "SHA256SUMS")];
502
+ const result = await issue.updateIssue(f.context, { ...close, closeout });
503
+ assert.equal(result.state, "closed");
504
+ assert.equal(
505
+ result.closure?.comment.body,
506
+ [
507
+ "**Verdict:** NONE: no cut passed",
508
+ "**Result:**\n\nNet \u22120.4\xA2/fill (n=212)",
509
+ "**Artifacts:**\n- [READOUT.md](https://github.com/example/widget/issues/17/artifacts/1)\n- [SHA256SUMS](https://github.com/example/widget/issues/17/artifacts/2)",
510
+ "Requested closure reason: completed."
511
+ ].join("\n\n")
512
+ );
513
+ } finally {
514
+ f.cleanup();
515
+ }
516
+ });
517
+ test("every close lists the open issues it was blocking", async () => {
518
+ const close = { issueNumber: 17, state: "closed", closeReason: "not_planned" };
519
+ for (const example of [
520
+ {
521
+ blocking: [
522
+ { number: 11, state: "OPEN" },
523
+ { number: 12, state: "CLOSED" }
524
+ ],
525
+ unblocks: [11]
526
+ },
527
+ { blocking: [], unblocks: [] },
528
+ { blocking: [], blockingStatus: 502, unblocks: [] }
529
+ ]) {
530
+ const f = updateFixture();
531
+ try {
532
+ f.controls.blocking = example.blocking;
533
+ f.controls.blockingStatus = example.blockingStatus ?? 200;
534
+ const result = await issue.updateIssue(f.context, close);
535
+ assert.equal(result.state, "closed");
536
+ assert.deepEqual(result.unblocks, example.unblocks);
537
+ const unblocksLine = /\*\*Unblocks:\*\* (.*)$/u.exec(result.closure.comment.body)?.[1];
538
+ assert.equal(unblocksLine, example.unblocks.length ? "#11" : void 0);
539
+ assert.equal(
540
+ result.warnings.some(
541
+ (warning) => warning.code === "close.unblocks" && /issues #17 blocks/u.test(warning.message)
542
+ ),
543
+ example.blockingStatus === 502
544
+ );
545
+ } finally {
546
+ f.cleanup();
547
+ }
548
+ }
549
+ });
550
+ test("issue info lists artifacts on request and warns instead of failing when they are unreadable", async () => {
551
+ const f = updateFixture();
552
+ try {
553
+ f.controls.artifacts = [studyArtifact(1, "READOUT.md"), { ...studyArtifact(2, "s3 link"), type: "link" }];
554
+ assert.deepEqual((await issue.issueInfo(f.context, 17, { artifacts: true })).artifacts, [
555
+ {
556
+ number: 1,
557
+ name: "READOUT.md",
558
+ type: "generic",
559
+ url: "https://github.com/example/widget/issues/17/artifacts/1"
560
+ },
561
+ { number: 2, name: "s3 link", type: "link", url: "https://github.com/example/widget/issues/17/artifacts/2" }
562
+ ]);
563
+ f.controls.artifactStatus = 403;
564
+ const unread = await issue.issueInfo(f.context, 17, { artifacts: true });
565
+ assert.equal(unread.artifacts, void 0);
566
+ assert.match(unread.warnings?.[0]?.message ?? "", /HTTP 403/u);
567
+ } finally {
568
+ f.cleanup();
569
+ }
570
+ });
438
571
  test("invalid superseding issues and contradictory native closure fail closed", async () => {
439
572
  for (const failure of ["self", "pull-request", "reason", "duplicate"]) {
440
573
  const fixture = updateFixture();