gentle-pi 2.1.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/README.md +108 -79
  2. package/assets/agents/gentle-ai-worker.md +7 -3
  3. package/assets/agents/jd-fix-agent.md +1 -1
  4. package/assets/agents/jd-judge-a.md +3 -1
  5. package/assets/agents/jd-judge-b.md +3 -1
  6. package/assets/agents/review-readability.md +4 -3
  7. package/assets/agents/review-reliability.md +4 -3
  8. package/assets/agents/review-resilience.md +4 -3
  9. package/assets/agents/review-risk.md +4 -3
  10. package/assets/agents/sdd-apply.md +11 -4
  11. package/assets/agents/sdd-archive.md +6 -1
  12. package/assets/agents/sdd-design.md +6 -1
  13. package/assets/agents/sdd-explore.md +6 -2
  14. package/assets/agents/sdd-init.md +10 -2
  15. package/assets/agents/sdd-onboard.md +6 -1
  16. package/assets/agents/sdd-proposal.md +8 -1
  17. package/assets/agents/sdd-research.md +54 -0
  18. package/assets/agents/sdd-spec.md +6 -1
  19. package/assets/agents/sdd-status.md +10 -5
  20. package/assets/agents/sdd-sync.md +6 -1
  21. package/assets/agents/sdd-tasks.md +8 -4
  22. package/assets/agents/sdd-verify.md +27 -2
  23. package/assets/chains/4r-review.chain.md +2 -0
  24. package/assets/chains/sdd-full.chain.md +2 -2
  25. package/assets/chains/sdd-plan.chain.md +1 -1
  26. package/assets/chains/sdd-verify.chain.md +2 -2
  27. package/assets/orchestrator-delegation.md +145 -160
  28. package/assets/orchestrator-memory.md +2 -0
  29. package/assets/orchestrator.md +25 -48
  30. package/assets/sdd-orchestrator-workflow.md +163 -25
  31. package/assets/support/sdd-status-contract.md +24 -6
  32. package/contracts/review-integration/v1/fixtures/consent.fixture.json +3 -3
  33. package/contracts/review-integration/v1/fixtures/start-v2.fixture.json +19 -28
  34. package/contracts/review-integration/v1/fixtures/start.fixture.json +1 -10
  35. package/contracts/review-integration/v1/fixtures/status-v2.fixture.json +12 -21
  36. package/contracts/review-integration/v1/schemas/correction-plan-request.schema.json +49 -0
  37. package/contracts/review-integration/v1/schemas/operation.schema.json +76 -0
  38. package/contracts/review-integration/v1/schemas/repair.schema.json +39 -0
  39. package/contracts/review-integration/v1/schemas/status-v2.schema.json +4 -2
  40. package/contracts/review-integration/v1/schemas/status.schema.json +4 -2
  41. package/contracts/review-integration/v1/schemas/transition-execution.schema.json +42 -0
  42. package/contracts/review-integration/v2/fixtures/consent.fixture.json +1 -1
  43. package/contracts/review-integration/v2/fixtures/start.fixture.json +1 -10
  44. package/contracts/review-integration/v2/fixtures/status.fixture.json +1 -10
  45. package/contracts/review-integration/v2/schemas/failure.schema.json +5 -1
  46. package/contracts/review-integration/v2/schemas/last-event-closure.schema.json +66 -0
  47. package/contracts/review-integration/v2/schemas/opencode-provider-role.schema.json +14 -0
  48. package/contracts/review-integration/v2/schemas/operation.schema.json +6 -1
  49. package/contracts/review-integration/v2/schemas/repair.schema.json +4 -2
  50. package/contracts/review-integration/v2/schemas/start.schema.json +5 -2
  51. package/contracts/review-integration/v2/schemas/status.schema.json +4 -2
  52. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +30 -0
  53. package/contracts/review-provider-contract-mirror/v1.1.0/bundle/README.md +12 -0
  54. package/contracts/review-provider-contract-mirror/v1.1.0/bundle/manifest.json +65 -0
  55. package/contracts/review-provider-contract-mirror/v1.1.0/bundle/schemas/lens.schema.json +16 -0
  56. package/contracts/review-provider-contract-mirror/v1.1.0/bundle/schemas/refuter.schema.json +1 -0
  57. package/contracts/review-provider-contract-mirror/v1.1.0/bundle/schemas/targeted-validator.schema.json +1 -0
  58. package/contracts/review-provider-contract-mirror/v1.1.0/bundle/vectors/lens.json +1 -0
  59. package/contracts/review-provider-contract-mirror/v1.1.0/bundle/vectors/refuter.json +1 -0
  60. package/contracts/review-provider-contract-mirror/v1.1.0/bundle/vectors/targeted-validator.json +1 -0
  61. package/contracts/review-provider-contract-mirror/v1.1.0/generated/provider-capabilities.baseline.json +15 -0
  62. package/contracts/review-provider-contract-mirror/v1.1.0/generated/provider-roles.baseline.json +42 -0
  63. package/docs/native-authority-architecture.md +14 -16
  64. package/docs/review-integration.md +27 -353
  65. package/extensions/ask-user-choice.ts +151 -0
  66. package/extensions/gentle-ai.ts +2710 -3211
  67. package/extensions/quiet-tools.ts +515 -32
  68. package/extensions/sdd-init.ts +21 -12
  69. package/extensions/skill-registry.ts +10 -2
  70. package/extensions/startup-banner.ts +10 -4
  71. package/lib/gentle-ai-binary.ts +173 -2
  72. package/lib/gentle-ai-renderer.ts +70 -0
  73. package/lib/model-routing-authority.ts +133 -0
  74. package/lib/native-review-cli.ts +676 -781
  75. package/lib/opaque-pi-reviewer-adapter.ts +284 -0
  76. package/lib/provider-contract-bundle.ts +704 -0
  77. package/lib/review-candidate-view.ts +836 -118
  78. package/lib/review-compact-contract.ts +59 -248
  79. package/lib/review-host-relay.ts +578 -0
  80. package/lib/review-integration-v2.ts +1254 -221
  81. package/lib/review-last-event-controller.ts +35 -0
  82. package/lib/review-relay-contract.ts +16 -0
  83. package/lib/sdd-preflight.ts +230 -67
  84. package/lib/sdd-status.ts +66 -111
  85. package/lib/terminal-theme.ts +1 -1
  86. package/package.json +83 -79
  87. package/runtime/gentle-ai-binary.mjs +174 -3
  88. package/runtime/native-review-cli.mjs +610 -715
  89. package/runtime/review-integration-v2.mjs +1223 -190
  90. package/runtime/review-relay-contract.mjs +17 -0
  91. package/scripts/{build-git-commit-transaction-runner.mjs → build-runtime-modules.mjs} +5 -5
  92. package/scripts/check-provider-contract.mjs +138 -0
  93. package/scripts/gentle-ai-installer.mjs +85 -22
  94. package/scripts/maintainer/provider-relay-matrix.mjs +403 -0
  95. package/scripts/mirror-provider-contract.mjs +143 -0
  96. package/scripts/test-packed-runner.mjs +20 -9
  97. package/scripts/verify-package-files.mjs +119 -43
  98. package/skills/_shared/review-ledger-contract.md +11 -19
  99. package/skills/chained-pr/SKILL.md +3 -0
  100. package/skills/cognitive-doc-design/SKILL.md +1 -1
  101. package/skills/comment-writer/SKILL.md +1 -1
  102. package/skills/gentle-ai/SKILL.md +7 -74
  103. package/skills/issue-creation/SKILL.md +94 -168
  104. package/skills/judgment-day/SKILL.md +9 -5
  105. package/skills/judgment-day/references/prompts-and-formats.md +2 -0
  106. package/skills/rdd-defect-workflow/SKILL.md +54 -0
  107. package/skills/release/SKILL.md +3 -3
  108. package/skills/skill-registry/SKILL.md +1 -1
  109. package/skills/work-unit-commits/SKILL.md +3 -1
  110. package/tests/artifact-language.test.ts +24 -11
  111. package/tests/ask-user-choice.test.ts +264 -0
  112. package/tests/background-subagents.test.ts +771 -0
  113. package/tests/codegraph-tools.test.ts +3 -3
  114. package/tests/crosslane/cross-lane.mjs +16 -0
  115. package/tests/delegated-key-learnings-contract.test.ts +240 -0
  116. package/tests/devbinary/native-review-parity.devtest.ts +167 -250
  117. package/tests/devbinary/pi-host-relay.devtest.ts +867 -0
  118. package/tests/fixtures/devbinary/capabilities-v2.1.derived.json +331 -0
  119. package/tests/fixtures/devbinary/capabilities-v2.2.captured.json +340 -0
  120. package/tests/fixtures/devbinary/consent-v3.captured.json +37 -0
  121. package/tests/fixtures/devbinary/failure-v2-capture-evidence.captured.json +16 -0
  122. package/tests/fixtures/devbinary/last-event-capture-correction-plan.captured.json +10 -0
  123. package/tests/fixtures/devbinary/last-event-capture-refuter-approved.captured.json +20 -0
  124. package/tests/fixtures/devbinary/last-event-capture-refuter-correction-required.captured.json +26 -0
  125. package/tests/fixtures/devbinary/last-event-capture-result-approved.captured.json +8 -0
  126. package/tests/fixtures/devbinary/last-event-capture-result-correction-required.captured.json +26 -0
  127. package/tests/fixtures/devbinary/last-event-capture-validation-approved.captured.json +8 -0
  128. package/tests/fixtures/devbinary/last-event-closure.provenance.md +13 -0
  129. package/tests/fixtures/devbinary/result-artifact-v2-path.captured.json +12 -0
  130. package/tests/fixtures/devbinary/result-artifact-v2.captured.json +12 -0
  131. package/tests/fixtures/devbinary/review-acknowledged-v1.captured.json +9 -0
  132. package/tests/fixtures/devbinary/review-acknowledged.provenance.md +31 -0
  133. package/tests/fixtures/devbinary/start-v3-consent-declined.captured.json +19 -0
  134. package/tests/fixtures/devbinary/start-v3-consent-granted.captured.json +109 -0
  135. package/tests/fixtures/devbinary/start-v3-zero-lens-closed.captured.json +21 -0
  136. package/tests/fixtures/devbinary/status-v5-capture-result-submission.captured.json +184 -0
  137. package/tests/fixtures/devbinary/status-v5-repository-context.captured.json +138 -0
  138. package/tests/fixtures/devbinary/status-v5.captured.json +88 -0
  139. package/tests/fixtures/native-review-cli/v2.5.0-rc.1/PROVENANCE.txt +15 -0
  140. package/tests/fixtures/provider-contract-bundle/v1.1.0/README.md +12 -0
  141. package/tests/fixtures/provider-contract-bundle/v1.1.0/manifest.json +65 -0
  142. package/tests/fixtures/provider-contract-bundle/v1.1.0/schemas/lens.schema.json +16 -0
  143. package/tests/fixtures/provider-contract-bundle/v1.1.0/schemas/refuter.schema.json +1 -0
  144. package/tests/fixtures/provider-contract-bundle/v1.1.0/schemas/targeted-validator.schema.json +1 -0
  145. package/tests/fixtures/provider-contract-bundle/v1.1.0/vectors/lens.json +1 -0
  146. package/tests/fixtures/provider-contract-bundle/v1.1.0/vectors/refuter.json +1 -0
  147. package/tests/fixtures/provider-contract-bundle/v1.1.0/vectors/targeted-validator.json +1 -0
  148. package/tests/gentle-ai-binary.test.ts +83 -13
  149. package/tests/gentle-ai-dev-binary-surfacing.test.ts +195 -0
  150. package/tests/gentle-ai-dev-binary.test.ts +159 -0
  151. package/tests/gentle-ai-installer.test.ts +138 -48
  152. package/tests/gentle-ai.test.ts +820 -131
  153. package/tests/gentle-theme.test.ts +133 -0
  154. package/tests/maintainer/provider-relay.maintest.ts +601 -0
  155. package/tests/model-routing-authority.test.ts +257 -0
  156. package/tests/native-review-capability-contract.test.ts +75 -2
  157. package/tests/native-review-cli.test.ts +588 -908
  158. package/tests/native-review-consent.test.ts +283 -38
  159. package/tests/native-review-parity-runtime.test.ts +108 -350
  160. package/tests/native-review-parity.test.ts +684 -732
  161. package/tests/native-sdd-attempt-authority.test.ts +235 -0
  162. package/tests/opaque-pi-reviewer-adapter.test.ts +266 -0
  163. package/tests/orchestrator-budget.test.ts +158 -89
  164. package/tests/orchestrator-rdd-ownership.test.ts +103 -0
  165. package/tests/package-manifest.test.ts +128 -100
  166. package/tests/provider-contract-bundle.test.ts +385 -0
  167. package/tests/provider-contract-mirror.test.ts +206 -0
  168. package/tests/provider-defect-handoff.test.ts +252 -0
  169. package/tests/quiet-tool-rendering.test.ts +1055 -28
  170. package/tests/review-actor-tool-deny.test.ts +12 -13
  171. package/tests/review-authority-recovery-docs.test.ts +1 -2
  172. package/tests/review-candidate-view.test.ts +898 -12
  173. package/tests/review-compact-contract.test.ts +29 -122
  174. package/tests/review-controller-lock-status.test.ts +2 -2
  175. package/tests/review-controller-native-recovery.test.ts +366 -857
  176. package/tests/review-controller-native-routing.test.ts +1253 -4199
  177. package/tests/review-controller-retired-ops.test.ts +1 -1
  178. package/tests/review-controller-workspace-root.test.ts +236 -70
  179. package/tests/review-controller.test.ts +26 -816
  180. package/tests/review-corrected-finalize-binding.test.ts +134 -0
  181. package/tests/review-dispatch-hydration-gap.test.ts +145 -0
  182. package/tests/review-gate.test.ts +0 -45
  183. package/tests/review-host-relay-restart-parity.test.ts +360 -0
  184. package/tests/review-host-relay-routing.test.ts +352 -0
  185. package/tests/review-host-relay.test.ts +754 -0
  186. package/tests/review-integration-v2-forward.test.ts +654 -0
  187. package/tests/review-integration-v2.test.ts +317 -129
  188. package/tests/review-last-event-closure.test.ts +408 -0
  189. package/tests/review-ledger-contract.test.ts +106 -60
  190. package/tests/review-recovered-lineage-routing.test.ts +199 -0
  191. package/tests/review-relay-transport-agent.test.ts +322 -0
  192. package/tests/review-snapshot.test.ts +3 -2
  193. package/tests/runtime-harness.mjs +573 -180
  194. package/tests/sdd-agent-tools.test.ts +53 -32
  195. package/tests/sdd-preflight.test.ts +81 -15
  196. package/tests/sdd-status.test.ts +109 -110
  197. package/tests/skill-collision-prefixes.test.ts +6 -8
  198. package/tests/skill-registry.test.ts +50 -1
  199. package/tests/verify-package-files.test.ts +62 -0
  200. package/tests/writer-edit-surface-scope.test.ts +230 -0
  201. package/themes/Gentleman-Cute.json +94 -0
  202. package/themes/Gentleman-Sexy.json +92 -0
  203. package/assets/agents/review-refuter.md +0 -40
  204. package/assets/agents/review-validator.md +0 -23
  205. package/lib/git-commit-transaction.ts +0 -801
  206. package/lib/native-review-remediation.ts +0 -49
  207. package/lib/review-compact.ts +0 -947
  208. package/lib/review-refuter-adapter.ts +0 -129
  209. package/lib/review-runtime-contract.ts +0 -68
  210. package/prompts/gcl.md +0 -54
  211. package/prompts/gis.md +0 -25
  212. package/prompts/gpr.md +0 -41
  213. package/prompts/gwr.md +0 -31
  214. package/runtime/git-commit-transaction.mjs +0 -802
  215. package/scripts/run-git-commit-transaction.mjs +0 -35
  216. package/tests/fixtures/native-review-cli/v2.1.2/bind-sdd.json +0 -25
  217. package/tests/fixtures/native-review-cli/v2.1.2/finalize.json +0 -8
  218. package/tests/fixtures/native-review-cli/v2.1.2/sdd-status-engram.json +0 -139
  219. package/tests/fixtures/native-review-cli/v2.1.2/sdd-status.json +0 -200
  220. package/tests/fixtures/native-review-cli/v2.1.2/start.json +0 -12
  221. package/tests/fixtures/native-review-cli/v2.1.2/validate-allow.json +0 -24
  222. package/tests/fixtures/native-review-cli/v2.1.2/validate-deny-empty-context.json +0 -20
  223. package/tests/fixtures/native-review-cli/v2.1.2/validate-deny.json +0 -28
  224. package/tests/fixtures/native-review-cli/v2.1.3/sdd-status-engram.json +0 -139
  225. package/tests/fixtures/native-review-cli/v2.1.3/sdd-status.json +0 -200
  226. package/tests/git-commit-transaction.test.ts +0 -302
  227. package/tests/review-compact.test.ts +0 -243
  228. package/tests/review-refuter-adapter.test.ts +0 -89
@@ -0,0 +1,252 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import test from "node:test";
5
+
6
+ // ---------------------------------------------------------------------------
7
+ // Provider Defect Handoff — structural readback tests (issue #256, track 5)
8
+ //
9
+ // Pins the port of Gentle AI's v2.4.0-rc.8 provider-defect handoff consent
10
+ // contract (the gentle-ai.review-integration.consent/v3 envelope; canonical
11
+ // source internal/assets/generic/sdd-orchestrator.md at tag v2.4.0-rc.8 of
12
+ // Gentleman-Programming/gentle-ai) into Pi's lazy-loaded orchestrator assets.
13
+ // The contract is a prerelease (not in v2.3.0 stable). These tests assert
14
+ // structural presence, ordering, and the removal of stale rc.3-era rules; they
15
+ // do not execute any lifecycle command.
16
+ // ---------------------------------------------------------------------------
17
+
18
+ const REPO_ROOT = join(import.meta.dirname, "..");
19
+ const DELEGATION_PATH = join(REPO_ROOT, "assets", "orchestrator-delegation.md");
20
+ const SDD_WORKFLOW_PATH = join(REPO_ROOT, "assets", "sdd-orchestrator-workflow.md");
21
+
22
+ const DELEGATION = readFileSync(DELEGATION_PATH, "utf8");
23
+ const SDD_WORKFLOW = readFileSync(SDD_WORKFLOW_PATH, "utf8");
24
+
25
+ const CHOICE_TOKENS = ["report_and_continue", "continue_without_reporting", "stop_here"] as const;
26
+
27
+ // rc.8 choice-1 ordering mirrors gentle-ai v2.4.0-rc.8 blocking_prompt_contract_test.go; asserted only where phrases exist.
28
+ function assertChoice1Order(haystack: string, anchors: readonly string[], surface: string): void {
29
+ const positions = anchors.map((p) => haystack.indexOf(p));
30
+ anchors.forEach((p, i) => assert.notEqual(positions[i], -1, `${surface}: missing rc.8 choice-1 anchor: ${JSON.stringify(p)}`));
31
+ for (let i = 1; i < positions.length; i++) {
32
+ assert.ok(positions[i - 1] < positions[i], `${surface}: rc.8 anchor ${i} must precede ${i + 1}; got ${positions}`);
33
+ }
34
+ }
35
+
36
+ const countOccurrences = (haystack: string, needle: string): number => haystack.split(needle).length - 1;
37
+
38
+ const DELEGATION_CHOICE1_ORDER = [
39
+ "complete a definitive lookup across open and closed issues for an equivalent defect",
40
+ "derive its evidence channel only from its build string",
41
+ "If the equivalent has no verifiable relevant published fix, add exactly one occurrence comment",
42
+ "A fix published only to the other evidence channel is not a relevant published fix",
43
+ "If the installed build predates that release, recommend installing the published fix",
44
+ "perform no further GitHub mutation and no blind retry",
45
+ "Confirmed creation requires the GitHub create operation to confirm a newly-created issue identity",
46
+ "execute the shared candidate-scoped continuation below",
47
+ ] as const;
48
+
49
+ // ---------------------------------------------------------------------------
50
+ // 1 — assets/orchestrator-delegation.md structural presence
51
+ // ---------------------------------------------------------------------------
52
+
53
+ test("orchestrator-delegation.md carries the provider defect handoff section", () => {
54
+ assert.match(DELEGATION, /#### Gentle AI Provider Defect Handoff \(MANDATORY\)/);
55
+ });
56
+
57
+ test("orchestrator-delegation.md references the prerelease consent/v3 contract", () => {
58
+ assert.match(DELEGATION, /prerelease/i);
59
+ assert.match(DELEGATION, /gentle-ai\.review-integration\.consent\/v3/);
60
+ });
61
+
62
+ test("orchestrator-delegation.md lists all three semantic choice tokens", () => {
63
+ for (const token of CHOICE_TOKENS) {
64
+ assert.ok(
65
+ DELEGATION.includes(`\`${token}\``),
66
+ `orchestrator-delegation.md missing semantic choice token: ${token}`,
67
+ );
68
+ }
69
+ assert.match(DELEGATION, /\*\*Continue without reporting\*\*: Perform no GitHub search, write, comment, or label, and no report-side privacy scan is required/);
70
+ assert.match(DELEGATION, /\*\*Stop here\*\*: Perform no GitHub operation and no decline invocation; preserve all consumer state and STOP/);
71
+ });
72
+
73
+ test("orchestrator-delegation.md orders the three choices: report_and_continue, continue_without_reporting, stop_here", () => {
74
+ const positions = CHOICE_TOKENS.map((token) => DELEGATION.indexOf(`\`${token}\``));
75
+ for (const pos of positions) {
76
+ assert.notEqual(pos, -1, "a choice token is missing; ordering assertion is meaningless");
77
+ }
78
+ assert.ok(
79
+ positions[0] < positions[1],
80
+ `report_and_continue must appear before continue_without_reporting; got positions ${positions}`,
81
+ );
82
+ assert.ok(
83
+ positions[1] < positions[2],
84
+ `continue_without_reporting must appear before stop_here; got positions ${positions}`,
85
+ );
86
+ });
87
+
88
+ test("orchestrator-delegation.md preserves the rc.8 choice-1 sub-bullet ordering", () => {
89
+ assertChoice1Order(DELEGATION, DELEGATION_CHOICE1_ORDER, "orchestrator-delegation.md");
90
+ });
91
+
92
+ test("orchestrator-delegation.md states the admissibility-before-relay rule", () => {
93
+ assert.match(DELEGATION, /Before losslessly relaying any blocking choice envelope, classify its semantic admissibility/i);
94
+ assert.match(DELEGATION, /The test is what produced the failure, not what the work was doing when it happened/i);
95
+ });
96
+
97
+ test("orchestrator-delegation.md excludes local consent lifecycle outcomes from provider-defect reporting", () => {
98
+ assert.match(DELEGATION, /`consent-binding-expired` and `consent-binding-already-consumed` are local lifecycle outcomes, not Gentle AI provider defects/i);
99
+ assert.match(DELEGATION, /An unknown consent binding is reportable only when independent evidence proves a fresh, same-session, unconsumed binding was lost/i);
100
+ assert.match(DELEGATION, /Never infer that evidence from the old combined stale-binding message/i);
101
+ });
102
+
103
+ test("orchestrator-delegation.md states the never-offer-to-repair rule", () => {
104
+ assert.match(
105
+ DELEGATION,
106
+ /never offer to switch to, inspect, modify, or directly repair the Gentle AI repository/i,
107
+ );
108
+ assert.match(DELEGATION, /reject it as semantically inadmissible and issue this separate orchestrator-owned handoff envelope/i);
109
+ });
110
+
111
+ test("orchestrator-delegation.md states the consent requirement", () => {
112
+ assert.match(DELEGATION, /Ask the user first, in the active orchestrator conversation language/i);
113
+ assert.match(DELEGATION, /for explicit consent to report the apparent defect/i);
114
+ assert.match(DELEGATION, /one single-select blocking envelope with exactly three semantic choices in this order/i);
115
+ });
116
+
117
+ test("orchestrator-delegation.md states the privacy scrub requirement and ordering", () => {
118
+ assert.match(DELEGATION, /Immediately before the first GitHub operation, perform a final privacy scan/i);
119
+ assert.match(DELEGATION, /This scan precedes the definitive lookup, report creation, and occurrence comment/i);
120
+ assert.match(DELEGATION, /raw argv, absolute paths, private project names, usernames, hostnames, credentials, diffs, source contents, and environment values/i);
121
+ });
122
+
123
+ test("orchestrator-delegation.md states the definitive lookup gate", () => {
124
+ assert.match(DELEGATION, /complete a definitive lookup across open and closed issues for an equivalent defect or canonical tracker/i);
125
+ assert.match(DELEGATION, /completed open\+closed lookup with a classifiable result; incomplete, error, or unknown is not definitive/i);
126
+ assert.match(DELEGATION, /Only a definitive lookup may branch to GitHub mutation/i);
127
+ });
128
+
129
+ test("orchestrator-delegation.md states evidence-channel routing from installed build string", () => {
130
+ assert.match(DELEGATION, /derive its evidence channel only from its build string/i);
131
+ assert.match(DELEGATION, /recognized prerelease tags are `-rc\.` and `-main\.`; every other build is stable/i);
132
+ assert.match(DELEGATION, /That release is a relevant published fix only when it is in the installed build's evidence channel/i);
133
+ assert.match(DELEGATION, /A main-only commit, local\/source build, unmerged PR, or unsupported assertion is not published-fix evidence/i);
134
+ });
135
+
136
+ test("orchestrator-delegation.md states other-channel occurrence routing", () => {
137
+ assert.match(DELEGATION, /A fix published only to the other evidence channel is not a relevant published fix for this occurrence: add exactly one occurrence comment/i);
138
+ assert.match(DELEGATION, /note where the fix is published/i);
139
+ assert.match(DELEGATION, /Do not recommend switching channels; channel choice is the user's/i);
140
+ });
141
+
142
+ test("orchestrator-delegation.md states outdated-build and regression routing", () => {
143
+ assert.match(DELEGATION, /If the installed build predates that release, recommend installing the published fix and reproducing; do not create or comment for that occurrence yet/i);
144
+ assert.match(DELEGATION, /treat it as a possible regression: reproduction on a build proven to contain that fix/i);
145
+ assert.match(DELEGATION, /comment on a suitable canonical tracker, or create a linked regression issue when that tracker is unsuitable/i);
146
+ assert.match(DELEGATION, /Never reopen automatically/i);
147
+ });
148
+
149
+ test("orchestrator-delegation.md states confirmed-creation identity requirement", () => {
150
+ assert.match(DELEGATION, /Confirmed creation requires the GitHub create operation to confirm a newly-created issue identity\/URL/i);
151
+ assert.match(DELEGATION, /Never infer creation from output text alone/i);
152
+ });
153
+
154
+ test("orchestrator-delegation.md states the uncertainty continuation (decline invocation runs, not withheld)", () => {
155
+ assert.match(DELEGATION, /perform no further GitHub mutation and no blind retry/i);
156
+ assert.match(
157
+ DELEGATION,
158
+ /execute the exact captured provider-owned decline invocation exactly once, validate it, re-enter native negotiated STATUS, and resume the already-held consumer continuation/i,
159
+ );
160
+ assert.match(DELEGATION, /do not search, comment, update, or retry creation until the exact created issue identity is resolved, then use the uncertainty continuation below/i);
161
+ });
162
+
163
+ test("orchestrator-delegation.md states the exact-captured-decline-invocation rule", () => {
164
+ assert.match(DELEGATION, /Both continue choices execute that exact captured decline invocation exactly once/i);
165
+ assert.match(DELEGATION, /`choices\[answer="declined"\]\.invocation` from the `gentle-ai\.review-integration\.consent\/v3` envelope/i);
166
+ assert.match(
167
+ DELEGATION,
168
+ /Never synthesize the decline command, target, token, or consumer continuation from prose/i,
169
+ );
170
+ assert.match(DELEGATION, /fail closed with all consumer state preserved and do not run a substitute command/i);
171
+ assert.match(DELEGATION, /validate `action: "declined"`, `consent: "declined_this_candidate"`, and the exact target identity match/i);
172
+ });
173
+
174
+ test("orchestrator-delegation.md states handoff scope and mode preservation", () => {
175
+ assert.match(DELEGATION, /Do not invoke `gentle-ai review mode disable` at clone or global scope within this handoff/i);
176
+ assert.match(DELEGATION, /Do not turn RDD off or on within this handoff/i);
177
+ assert.match(DELEGATION, /The result carries no lineage or receipt; ordinary delivery is unmanaged by the candidate choice, and the next candidate asks again/i);
178
+ });
179
+
180
+ test("orchestrator-delegation.md states observed-evidence reporting", () => {
181
+ assert.match(DELEGATION, /Report observed evidence, not an unconfirmed root cause/i);
182
+ assert.match(DELEGATION, /sanitized version\/build, OS\/architecture\/client/i);
183
+ assert.match(DELEGATION, /bounded attempts and outcomes, failure envelopes, mutation outcome/i);
184
+ assert.match(DELEGATION, /expected and actual behavior, a minimal reproduction/i);
185
+ assert.match(DELEGATION, /safe opaque reason\/revision identifiers, and preserved-state evidence/i);
186
+ });
187
+
188
+ test("orchestrator-delegation.md states the resume route (published fix or maintainer-authorized recovery)", () => {
189
+ assert.match(DELEGATION, /Resume after an installed published fix or an explicit maintainer-authorized, documented native recovery or reset/i);
190
+ assert.match(DELEGATION, /A published prerelease or release candidate the user installed satisfies this/i);
191
+ assert.match(DELEGATION, /Never resume against unpublished code: a source checkout, a local build, or an unmerged pull request/i);
192
+ });
193
+
194
+ // ---------------------------------------------------------------------------
195
+ // 2 — Prohibited stale rc.3-era rules (must NOT survive in the handoff)
196
+ // ---------------------------------------------------------------------------
197
+
198
+ test("orchestrator-delegation.md does NOT carry the gentle-report label discipline", () => {
199
+ assert.equal(
200
+ DELEGATION.includes("gentle-report"),
201
+ false,
202
+ "the v2.4.0-rc.8 handoff removed the gentle-report label discipline; the string must not appear",
203
+ );
204
+ });
205
+
206
+ test("orchestrator-delegation.md does NOT make published fixes the sole resumption route", () => {
207
+ assert.equal(
208
+ DELEGATION.includes("Resume only after an installed published fix"),
209
+ false,
210
+ "rc.8 prohibits 'Resume only after an installed published fix' as the sole resumption route",
211
+ );
212
+ assert.equal(
213
+ DELEGATION.includes("latest version"),
214
+ false,
215
+ "rc.8 prohibits 'latest version' wording in the handoff",
216
+ );
217
+ });
218
+
219
+ test("orchestrator-delegation.md does NOT retain the rc.3 hard-stop that withholds the decline invocation", () => {
220
+ assert.equal(
221
+ DELEGATION.includes("Any report ambiguity or failure is a hard stop: preserve all consumer state and do not execute the decline invocation"),
222
+ false,
223
+ "rc.8 replaced the rc.3 hard-stop wedge with the uncertainty continuation that executes the decline invocation",
224
+ );
225
+ });
226
+
227
+ test("orchestrator-delegation.md does NOT reference the rc.3 canon", () => {
228
+ assert.equal(DELEGATION.includes("v2.4.0-rc.3"), false, "stale rc.3 version reference must be removed");
229
+ assert.equal(DELEGATION.includes("gentle-ai#2060"), false, "stale rc.3 issue reference must be removed");
230
+ });
231
+
232
+ // ---------------------------------------------------------------------------
233
+ // 3 — SDD points to the single complete handoff contract
234
+ // ---------------------------------------------------------------------------
235
+
236
+ test("sdd-orchestrator-workflow.md points provider defects to the complete delegation contract", () => {
237
+ assert.match(SDD_WORKFLOW, /## Provider Defect Handoff/);
238
+ assert.match(
239
+ SDD_WORKFLOW,
240
+ /The full contract lives in `assets\/orchestrator-delegation\.md` under `#### Gentle AI Provider Defect Handoff \(MANDATORY\)`/i,
241
+ );
242
+ assert.match(DELEGATION, /^#### Gentle AI Provider Defect Handoff \(MANDATORY\)$/m);
243
+ assert.doesNotMatch(SDD_WORKFLOW, /`report_and_continue`|`continue_without_reporting`|`stop_here`/);
244
+ });
245
+
246
+ test("the complete delegation handoff invokes `gentle-ai review mode disable` exactly once", () => {
247
+ const section = DELEGATION.match(
248
+ /#### Gentle AI Provider Defect Handoff[\s\S]*?(?=\n#### SDD Edit-Authority|$)/,
249
+ )?.[0] ?? "";
250
+ assert.ok(section.length > 0, "orchestrator-delegation.md: provider defect handoff section not found");
251
+ assert.equal(countOccurrences(section, "gentle-ai review mode disable"), 1);
252
+ });