@opengsd/gsd-core 1.10.0 → 1.12.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 (544) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/agents/gsd-code-fixer.md +1 -1
  4. package/agents/gsd-debug-session-manager.md +12 -1
  5. package/agents/gsd-debugger.md +1 -1
  6. package/agents/gsd-doc-synthesizer.md +2 -4
  7. package/agents/gsd-dom-verifier.md +169 -0
  8. package/agents/gsd-eval-auditor.md +1 -1
  9. package/agents/gsd-executor.md +22 -14
  10. package/agents/gsd-framework-selector.md +1 -3
  11. package/agents/gsd-intel-updater.md +1 -1
  12. package/agents/gsd-mempalace-curator.md +5 -3
  13. package/agents/gsd-pattern-mapper.md +11 -0
  14. package/agents/gsd-phase-researcher.md +23 -2
  15. package/agents/gsd-plan-checker.md +50 -53
  16. package/agents/gsd-planner.md +50 -50
  17. package/agents/gsd-project-researcher.md +1 -1
  18. package/agents/gsd-research-synthesizer.md +2 -2
  19. package/agents/gsd-roadmapper.md +15 -11
  20. package/agents/gsd-ui-checker.md +63 -4
  21. package/agents/gsd-ui-researcher.md +41 -3
  22. package/agents/gsd-user-profiler.md +3 -0
  23. package/agents/gsd-verifier.md +13 -4
  24. package/bin/install.js +1448 -1103
  25. package/commands/gsd/code-review.md +1 -1
  26. package/commands/gsd/discuss-phase.md +1 -1
  27. package/commands/gsd/execute-phase.md +1 -1
  28. package/commands/gsd/import.md +1 -1
  29. package/commands/gsd/map-codebase.md +1 -1
  30. package/commands/gsd/mempalace-capture.md +1 -1
  31. package/commands/gsd/mempalace-recall.md +1 -1
  32. package/commands/gsd/new-milestone.md +1 -1
  33. package/commands/gsd/quick.md +9 -5
  34. package/commands/gsd/review-backlog.md +2 -1
  35. package/commands/gsd/verify-work.md +1 -1
  36. package/gsd-core/bin/gsd-tools.cjs +1035 -138
  37. package/gsd-core/bin/lib/active-workstream-store.cjs +146 -22
  38. package/gsd-core/bin/lib/adr-parser.cjs +13 -7
  39. package/gsd-core/bin/lib/agent-install-check.cjs +392 -32
  40. package/gsd-core/bin/lib/api-coverage.cjs +33 -14
  41. package/gsd-core/bin/lib/artifacts.cjs +5 -0
  42. package/gsd-core/bin/lib/assumption-delta.cjs +32 -15
  43. package/gsd-core/bin/lib/audit-command-router.cjs +9 -2
  44. package/gsd-core/bin/lib/audit.cjs +1026 -268
  45. package/gsd-core/bin/lib/broken-windows.cjs +306 -28
  46. package/gsd-core/bin/lib/capability-consent.cjs +149 -15
  47. package/gsd-core/bin/lib/capability-lifecycle.cjs +45 -0
  48. package/gsd-core/bin/lib/capability-lock.cjs +10 -4
  49. package/gsd-core/bin/lib/capability-registry.cjs +845 -130
  50. package/gsd-core/bin/lib/capability-source.cjs +92 -0
  51. package/gsd-core/bin/lib/capability-state.cjs +18 -3
  52. package/gsd-core/bin/lib/capability-trust.cjs +444 -25
  53. package/gsd-core/bin/lib/capability-validator.cjs +700 -40
  54. package/gsd-core/bin/lib/capability-writer.cjs +3 -2
  55. package/gsd-core/bin/lib/check-command-router.cjs +216 -42
  56. package/gsd-core/bin/lib/claude-orchestration.cjs +56 -3
  57. package/gsd-core/bin/lib/cli-exit.cjs +496 -10
  58. package/gsd-core/bin/lib/code-review-depth.cjs +288 -0
  59. package/gsd-core/bin/lib/codex-agent-toml.cjs +735 -0
  60. package/gsd-core/bin/lib/command-aliases.cjs +22 -0
  61. package/gsd-core/bin/lib/command-arg-projection.cjs +144 -14
  62. package/gsd-core/bin/lib/command-roster.cjs +44 -1
  63. package/gsd-core/bin/lib/command-routing-hub.cjs +31 -2
  64. package/gsd-core/bin/lib/commands.cjs +1172 -108
  65. package/gsd-core/bin/lib/commonjs-marker.cjs +12 -6
  66. package/gsd-core/bin/lib/complexity-trigger.cjs +1192 -0
  67. package/gsd-core/bin/lib/config-loader.cjs +187 -23
  68. package/gsd-core/bin/lib/config.cjs +102 -3
  69. package/gsd-core/bin/lib/configuration.cjs +129 -37
  70. package/gsd-core/bin/lib/core-utils.cjs +208 -33
  71. package/gsd-core/bin/lib/decisions.cjs +23 -0
  72. package/gsd-core/bin/lib/edge-probe.cjs +9 -1
  73. package/gsd-core/bin/lib/estimate-cli.cjs +55 -11
  74. package/gsd-core/bin/lib/exit-code-registry.cjs +98 -0
  75. package/gsd-core/bin/lib/fallow-runner.cjs +20 -44
  76. package/gsd-core/bin/lib/frontmatter.cjs +899 -229
  77. package/gsd-core/bin/lib/gap-checker.cjs +95 -10
  78. package/gsd-core/bin/lib/git-base-branch.cjs +276 -39
  79. package/gsd-core/bin/lib/gsd2-import.cjs +10 -1
  80. package/gsd-core/bin/lib/health-diagnostic-rules/agent-install.cjs +101 -0
  81. package/gsd-core/bin/lib/health-diagnostic-rules/config-validation.cjs +348 -0
  82. package/gsd-core/bin/lib/health-diagnostic-rules/consistency.cjs +149 -0
  83. package/gsd-core/bin/lib/health-diagnostic-rules/install-surface-shadowing.cjs +98 -0
  84. package/gsd-core/bin/lib/health-diagnostic-rules/milestone-archive-hygiene.cjs +100 -0
  85. package/gsd-core/bin/lib/health-diagnostic-rules/phase-structure.cjs +222 -0
  86. package/gsd-core/bin/lib/health-diagnostic-rules/roadmap-disk-consistency.cjs +268 -0
  87. package/gsd-core/bin/lib/health-diagnostic-rules/root-existence.cjs +161 -0
  88. package/gsd-core/bin/lib/health-diagnostic-rules/state-consistency.cjs +303 -0
  89. package/gsd-core/bin/lib/health-diagnostic-rules/worktree-health.cjs +187 -0
  90. package/gsd-core/bin/lib/health-diagnostic-types.cjs +68 -0
  91. package/gsd-core/bin/lib/health-diagnostic.cjs +451 -0
  92. package/gsd-core/bin/lib/host-integration.cjs +39 -6
  93. package/gsd-core/bin/lib/host-runtime-detection.cjs +134 -0
  94. package/gsd-core/bin/lib/init-command-router.cjs +118 -21
  95. package/gsd-core/bin/lib/init.cjs +439 -168
  96. package/gsd-core/bin/lib/install-effort-resolver.cjs +73 -30
  97. package/gsd-core/bin/lib/install-engine.cjs +811 -259
  98. package/gsd-core/bin/lib/install-fs-adapter.cjs +262 -0
  99. package/gsd-core/bin/lib/install-model-override-resolver.cjs +235 -0
  100. package/gsd-core/bin/lib/install-profiles.cjs +212 -61
  101. package/gsd-core/bin/lib/install-scope.cjs +270 -0
  102. package/gsd-core/bin/lib/install-shadow-report.cjs +385 -0
  103. package/gsd-core/bin/lib/installed-surface-resolver.cjs +381 -0
  104. package/gsd-core/bin/lib/installer-migration-report.cjs +3 -0
  105. package/gsd-core/bin/lib/installer-migrations/010-antigravity-retire-confighome-artifacts.cjs +169 -0
  106. package/gsd-core/bin/lib/installer-migrations.cjs +148 -38
  107. package/gsd-core/bin/lib/intel.cjs +101 -26
  108. package/gsd-core/bin/lib/io.cjs +170 -15
  109. package/gsd-core/bin/lib/learnings.cjs +85 -14
  110. package/gsd-core/bin/lib/legacy-cleanup.cjs +8 -2
  111. package/gsd-core/bin/lib/markdown-sectionizer.cjs +2 -1
  112. package/gsd-core/bin/lib/markdown-table.cjs +183 -22
  113. package/gsd-core/bin/lib/milestone-lock.cjs +248 -0
  114. package/gsd-core/bin/lib/milestone.cjs +842 -73
  115. package/gsd-core/bin/lib/model-catalog.cjs +232 -16
  116. package/gsd-core/bin/lib/model-resolver.cjs +193 -68
  117. package/gsd-core/bin/lib/normalize-test-command.cjs +1 -1
  118. package/gsd-core/bin/lib/onboard-projection.cjs +5 -1
  119. package/gsd-core/bin/lib/pattern.cjs +122 -0
  120. package/gsd-core/bin/lib/phase-estimation.cjs +18 -9
  121. package/gsd-core/bin/lib/phase-id.cjs +514 -40
  122. package/gsd-core/bin/lib/phase-lifecycle.cjs +52 -19
  123. package/gsd-core/bin/lib/phase-locator.cjs +262 -34
  124. package/gsd-core/bin/lib/phase.cjs +1038 -214
  125. package/gsd-core/bin/lib/plan-dependency-graph.cjs +72 -1
  126. package/gsd-core/bin/lib/plan-document.cjs +263 -0
  127. package/gsd-core/bin/lib/plan-drift-guard.cjs +120 -0
  128. package/gsd-core/bin/lib/plan-scan.cjs +98 -3
  129. package/gsd-core/bin/lib/planning-command-router.cjs +61 -0
  130. package/gsd-core/bin/lib/planning-inspect.cjs +1168 -0
  131. package/gsd-core/bin/lib/planning-scope.cjs +31 -0
  132. package/gsd-core/bin/lib/planning-snapshot.cjs +894 -0
  133. package/gsd-core/bin/lib/planning-workspace.cjs +112 -6
  134. package/gsd-core/bin/lib/probe-core.cjs +5 -2
  135. package/gsd-core/bin/lib/profile-output.cjs +1 -1
  136. package/gsd-core/bin/lib/profile-pipeline-command-router.cjs +50 -7
  137. package/gsd-core/bin/lib/profile-pipeline.cjs +6 -3
  138. package/gsd-core/bin/lib/real-home-guard.cjs +419 -0
  139. package/gsd-core/bin/lib/refactor-trigger-command-router.cjs +766 -0
  140. package/gsd-core/bin/lib/retired-artifact-cleanup.cjs +11 -6
  141. package/gsd-core/bin/lib/review-lane-descriptor.cjs +22 -13
  142. package/gsd-core/bin/lib/review-lane-invocation.cjs +30 -0
  143. package/gsd-core/bin/lib/review-lane-runner.cjs +421 -66
  144. package/gsd-core/bin/lib/review-reviewer-selection.cjs +13 -18
  145. package/gsd-core/bin/lib/roadmap-command-router.cjs +59 -11
  146. package/gsd-core/bin/lib/roadmap-parser.cjs +1006 -184
  147. package/gsd-core/bin/lib/roadmap-upgrade.cjs +37 -10
  148. package/gsd-core/bin/lib/roadmap.cjs +442 -96
  149. package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +702 -52
  150. package/gsd-core/bin/lib/runtime-artifact-install-plan.cjs +14 -2
  151. package/gsd-core/bin/lib/runtime-artifact-layout.cjs +459 -55
  152. package/gsd-core/bin/lib/runtime-config-adapter-registry.cjs +3 -2
  153. package/gsd-core/bin/lib/runtime-homes.cjs +69 -3
  154. package/gsd-core/bin/lib/runtime-hooks-surface.cjs +402 -58
  155. package/gsd-core/bin/lib/runtime-identity.cjs +234 -0
  156. package/gsd-core/bin/lib/runtime-name-policy.cjs +3 -1
  157. package/gsd-core/bin/lib/runtime-slash.cjs +96 -8
  158. package/gsd-core/bin/lib/security.cjs +104 -5
  159. package/gsd-core/bin/lib/shell-command-projection.cjs +342 -7
  160. package/gsd-core/bin/lib/smart-entry.cjs +133 -23
  161. package/gsd-core/bin/lib/spec-section.cjs +12 -7
  162. package/gsd-core/bin/lib/state-command-router.cjs +52 -19
  163. package/gsd-core/bin/lib/state-contract.cjs +359 -0
  164. package/gsd-core/bin/lib/state-document.cjs +338 -8
  165. package/gsd-core/bin/lib/state-md-schema.cjs +221 -0
  166. package/gsd-core/bin/lib/state-transition.cjs +846 -176
  167. package/gsd-core/bin/lib/state.cjs +2589 -369
  168. package/gsd-core/bin/lib/surface.cjs +33 -11
  169. package/gsd-core/bin/lib/task-command-router.cjs +111 -1
  170. package/gsd-core/bin/lib/task-content-resolution.cjs +368 -0
  171. package/gsd-core/bin/lib/teams-status.cjs +4 -1
  172. package/gsd-core/bin/lib/text-lines.cjs +80 -0
  173. package/gsd-core/bin/lib/token-scanner.cjs +76 -0
  174. package/gsd-core/bin/lib/uat-predicate.cjs +67 -23
  175. package/gsd-core/bin/lib/uat.cjs +1761 -167
  176. package/gsd-core/bin/lib/ui-consideration-probe.cjs +9 -1
  177. package/gsd-core/bin/lib/ui-frontend-evidence.cjs +157 -0
  178. package/gsd-core/bin/lib/ui-safety-gate.cjs +51 -12
  179. package/gsd-core/bin/lib/unusable-input.cjs +37 -0
  180. package/gsd-core/bin/lib/update-context.cjs +8 -2
  181. package/gsd-core/bin/lib/user-artifact-staging.cjs +705 -0
  182. package/gsd-core/bin/lib/validate-command-router.cjs +2 -2
  183. package/gsd-core/bin/lib/validate.cjs +20 -6
  184. package/gsd-core/bin/lib/vendor/README.md +75 -0
  185. package/gsd-core/bin/lib/vendor/js-yaml.cjs +3014 -0
  186. package/gsd-core/bin/lib/vendor/re2js.cjs +6480 -0
  187. package/gsd-core/bin/lib/vendor/re2js.d.cts +938 -0
  188. package/gsd-core/bin/lib/verification-command-router.cjs +2 -1
  189. package/gsd-core/bin/lib/verification.cjs +272 -9
  190. package/gsd-core/bin/lib/verify-command-grounding.cjs +846 -0
  191. package/gsd-core/bin/lib/verify.cjs +453 -918
  192. package/gsd-core/bin/lib/workstream-inventory-builder.cjs +53 -32
  193. package/gsd-core/bin/lib/workstream-inventory.cjs +63 -10
  194. package/gsd-core/bin/lib/workstream-name-policy.cjs +25 -4
  195. package/gsd-core/bin/lib/workstream.cjs +2 -2
  196. package/gsd-core/bin/lib/worktree-base-ref.cjs +66 -12
  197. package/gsd-core/bin/lib/worktree-safety.cjs +341 -18
  198. package/gsd-core/bin/shared/config-defaults.manifest.json +8 -1
  199. package/gsd-core/bin/shared/config-schema.manifest.json +12 -1
  200. package/gsd-core/bin/shared/exit-codes.json +8 -0
  201. package/gsd-core/bin/shared/exit-codes.sh +20 -0
  202. package/gsd-core/bin/shared/model-catalog.json +8 -1
  203. package/gsd-core/references/agent-contracts.md +44 -26
  204. package/gsd-core/references/api-coverage.md +24 -2
  205. package/gsd-core/references/autonomous-smart-discuss.md +3 -3
  206. package/gsd-core/references/checkpoints.md +39 -21
  207. package/gsd-core/references/context-budget.md +1 -1
  208. package/gsd-core/references/decimal-phase-calculation.md +5 -5
  209. package/gsd-core/references/dispatch-isolation-gate.md +138 -0
  210. package/gsd-core/references/doc-conflict-engine.md +1 -1
  211. package/gsd-core/references/edge-probe.md +8 -0
  212. package/gsd-core/references/execute-mvp-tdd.md +4 -6
  213. package/gsd-core/references/execute-phase-between-wave-reset.md +15 -14
  214. package/gsd-core/references/execute-phase-context-guard.md +1 -1
  215. package/gsd-core/references/execute-phase-response-language.md +1 -1
  216. package/gsd-core/references/execute-phase-wave-guard.md +17 -11
  217. package/gsd-core/references/failing-direction.md +78 -0
  218. package/gsd-core/references/gate-prompts.md +1 -1
  219. package/gsd-core/references/git-integration.md +5 -5
  220. package/gsd-core/references/git-planning-commit.md +5 -4
  221. package/gsd-core/references/gsd-run-resolver.md +1 -1
  222. package/gsd-core/references/loop-hook-dispatch.md +61 -2
  223. package/gsd-core/references/model-profiles.md +12 -4
  224. package/gsd-core/references/mvp-concepts.md +9 -9
  225. package/gsd-core/references/nyquist-compliance.md +74 -0
  226. package/gsd-core/references/offer-next.md +3 -5
  227. package/gsd-core/references/phase-argument-parsing.md +3 -3
  228. package/gsd-core/references/planner-failing-direction.md +53 -0
  229. package/gsd-core/references/planner-guidance.md +3 -9
  230. package/gsd-core/references/planner-human-verify-mode.md +15 -1
  231. package/gsd-core/references/planner-preconditions.md +1 -1
  232. package/gsd-core/references/planner-reviews.md +1 -1
  233. package/gsd-core/references/planner-revision.md +1 -1
  234. package/gsd-core/references/planner-verify-command-grounding.md +17 -0
  235. package/gsd-core/references/planning-config.md +44 -13
  236. package/gsd-core/references/reviewer-instances.md +31 -0
  237. package/gsd-core/references/revision-loop.md +1 -1
  238. package/gsd-core/references/runtime-aware-dispatch.md +1 -1
  239. package/gsd-core/references/specless-probe-fallback.md +1 -1
  240. package/gsd-core/references/tdd.md +1 -3
  241. package/gsd-core/references/ui-brand.md +65 -21
  242. package/gsd-core/references/ui-consideration-probe.md +1 -1
  243. package/gsd-core/references/universal-anti-patterns.md +5 -5
  244. package/gsd-core/references/verifier-phase-gates.md +192 -0
  245. package/gsd-core/references/verify-command-path-resolvability.md +42 -0
  246. package/gsd-core/references/verify-mvp-mode.md +2 -2
  247. package/gsd-core/references/workstream-flag.md +33 -17
  248. package/gsd-core/templates/README.md +1 -1
  249. package/gsd-core/templates/SECURITY.md +3 -3
  250. package/gsd-core/templates/UI-SPEC.md +25 -3
  251. package/gsd-core/templates/VALIDATION.md +3 -3
  252. package/gsd-core/templates/discussion-log.md +1 -1
  253. package/gsd-core/templates/phase-prompt.md +5 -4
  254. package/gsd-core/templates/state.md +11 -4
  255. package/gsd-core/templates/verification-report.md +9 -1
  256. package/gsd-core/workflows/_runtime-launcher.snippet.sh +1 -1
  257. package/gsd-core/workflows/add-backlog.md +1 -1
  258. package/gsd-core/workflows/add-phase.md +3 -3
  259. package/gsd-core/workflows/add-tests.md +3 -8
  260. package/gsd-core/workflows/add-todo.md +1 -1
  261. package/gsd-core/workflows/ai-integration-phase.md +13 -20
  262. package/gsd-core/workflows/audit-fix.md +12 -3
  263. package/gsd-core/workflows/audit-milestone.md +9 -9
  264. package/gsd-core/workflows/audit-uat.md +17 -2
  265. package/gsd-core/workflows/autonomous/steps/converge-fail-fast.md +2 -2
  266. package/gsd-core/workflows/autonomous.md +11 -27
  267. package/gsd-core/workflows/check-todos.md +1 -1
  268. package/gsd-core/workflows/cleanup.md +64 -5
  269. package/gsd-core/workflows/code-review/steps/structural-pre-pass.md +14 -4
  270. package/gsd-core/workflows/code-review-fix.md +38 -11
  271. package/gsd-core/workflows/code-review.md +159 -52
  272. package/gsd-core/workflows/complete-milestone.md +151 -23
  273. package/gsd-core/workflows/debug.md +12 -8
  274. package/gsd-core/workflows/diagnose-issues.md +47 -15
  275. package/gsd-core/workflows/discuss-phase/modes/advisor.md +1 -1
  276. package/gsd-core/workflows/discuss-phase/modes/chain.md +5 -8
  277. package/gsd-core/workflows/discuss-phase/modes/default.md +1 -1
  278. package/gsd-core/workflows/discuss-phase/modes/text.md +1 -1
  279. package/gsd-core/workflows/discuss-phase-assumptions/steps/auto-advance-dispatch.md +1 -3
  280. package/gsd-core/workflows/discuss-phase-assumptions.md +4 -3
  281. package/gsd-core/workflows/discuss-phase.md +1 -1
  282. package/gsd-core/workflows/do.md +3 -6
  283. package/gsd-core/workflows/docs-update.md +5 -4
  284. package/gsd-core/workflows/edit-phase.md +27 -2
  285. package/gsd-core/workflows/eval-review.md +7 -14
  286. package/gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md +1 -1
  287. package/gsd-core/workflows/execute-phase/steps/executor-isolation-dispatch.md +142 -15
  288. package/gsd-core/workflows/execute-phase/steps/gap-closure-artifacts.md +1 -1
  289. package/gsd-core/workflows/execute-phase/steps/partial-wave.md +1 -1
  290. package/gsd-core/workflows/execute-phase/steps/per-plan-executor-routing.md +77 -0
  291. package/gsd-core/workflows/execute-phase/steps/per-plan-worktree-gate.md +24 -4
  292. package/gsd-core/workflows/execute-phase/steps/post-merge-gate.md +2 -2
  293. package/gsd-core/workflows/execute-phase/steps/protected-branch.md +21 -0
  294. package/gsd-core/workflows/execute-phase/steps/regression-gate-run.md +2 -2
  295. package/gsd-core/workflows/execute-phase/steps/wave-post-gate-hooks.md +39 -0
  296. package/gsd-core/workflows/execute-phase.md +72 -100
  297. package/gsd-core/workflows/execute-plan.md +52 -15
  298. package/gsd-core/workflows/explore.md +131 -4
  299. package/gsd-core/workflows/extract-learnings.md +1 -1
  300. package/gsd-core/workflows/fast.md +10 -2
  301. package/gsd-core/workflows/forensics.md +1 -1
  302. package/gsd-core/workflows/graduation.md +5 -5
  303. package/gsd-core/workflows/health.md +76 -10
  304. package/gsd-core/workflows/import.md +18 -15
  305. package/gsd-core/workflows/inbox.md +4 -5
  306. package/gsd-core/workflows/ingest-docs.md +49 -16
  307. package/gsd-core/workflows/insert-phase.md +5 -5
  308. package/gsd-core/workflows/list-seeds.md +5 -3
  309. package/gsd-core/workflows/list-workspaces.md +1 -1
  310. package/gsd-core/workflows/manager.md +12 -23
  311. package/gsd-core/workflows/map-codebase.md +1 -1
  312. package/gsd-core/workflows/milestone-summary.md +1 -1
  313. package/gsd-core/workflows/mvp-phase.md +8 -5
  314. package/gsd-core/workflows/new-milestone.md +22 -29
  315. package/gsd-core/workflows/new-project/steps/auto-mode-config.md +1 -1
  316. package/gsd-core/workflows/new-project.md +26 -40
  317. package/gsd-core/workflows/new-workspace.md +1 -1
  318. package/gsd-core/workflows/next.md +14 -2
  319. package/gsd-core/workflows/pause-work.md +1 -1
  320. package/gsd-core/workflows/plan-phase/steps/adr-ingest-express-path.md +1 -1
  321. package/gsd-core/workflows/plan-phase/steps/chunked-planning-mode.md +1 -1
  322. package/gsd-core/workflows/plan-phase/steps/prd-express-path.md +2 -4
  323. package/gsd-core/workflows/plan-phase/steps/stall-detection-helpers.md +3 -3
  324. package/gsd-core/workflows/plan-phase.md +162 -59
  325. package/gsd-core/workflows/plan-review-convergence.md +96 -11
  326. package/gsd-core/workflows/plant-seed.md +2 -2
  327. package/gsd-core/workflows/pr-branch.md +187 -51
  328. package/gsd-core/workflows/profile-user.md +16 -14
  329. package/gsd-core/workflows/progress.md +61 -18
  330. package/gsd-core/workflows/quick/steps/discussion-phase.md +1 -3
  331. package/gsd-core/workflows/quick/steps/plan-checker-loop.md +5 -7
  332. package/gsd-core/workflows/quick/steps/quick-verification.md +28 -9
  333. package/gsd-core/workflows/quick/steps/research-phase.md +4 -6
  334. package/gsd-core/workflows/quick/steps/worktree-pre-dispatch-commit.md +3 -3
  335. package/gsd-core/workflows/quick.md +55 -44
  336. package/gsd-core/workflows/remove-phase.md +4 -4
  337. package/gsd-core/workflows/remove-workspace.md +2 -2
  338. package/gsd-core/workflows/resume-project.md +8 -12
  339. package/gsd-core/workflows/review.md +219 -20
  340. package/gsd-core/workflows/scan.md +1 -1
  341. package/gsd-core/workflows/secure-phase.md +3 -3
  342. package/gsd-core/workflows/session-report.md +2 -1
  343. package/gsd-core/workflows/settings-advanced.md +7 -9
  344. package/gsd-core/workflows/settings-integrations.md +64 -31
  345. package/gsd-core/workflows/settings.md +69 -7
  346. package/gsd-core/workflows/ship.md +116 -50
  347. package/gsd-core/workflows/sketch-wrap-up.md +11 -17
  348. package/gsd-core/workflows/sketch.md +12 -18
  349. package/gsd-core/workflows/smart-entry.md +3 -5
  350. package/gsd-core/workflows/spec-phase.md +53 -13
  351. package/gsd-core/workflows/spike-wrap-up.md +7 -11
  352. package/gsd-core/workflows/spike.md +20 -31
  353. package/gsd-core/workflows/stats.md +2 -2
  354. package/gsd-core/workflows/sync-skills.md +64 -9
  355. package/gsd-core/workflows/thread.md +11 -7
  356. package/gsd-core/workflows/transition.md +49 -14
  357. package/gsd-core/workflows/ui-phase.md +15 -21
  358. package/gsd-core/workflows/ui-review.md +8 -12
  359. package/gsd-core/workflows/ultraplan-phase.md +5 -13
  360. package/gsd-core/workflows/undo.md +8 -16
  361. package/gsd-core/workflows/update.md +7 -11
  362. package/gsd-core/workflows/validate-phase.md +3 -3
  363. package/gsd-core/workflows/verify-work/steps/automated-ui-verification.md +25 -1
  364. package/gsd-core/workflows/verify-work/steps/mvp-uat-framing.md +1 -1
  365. package/gsd-core/workflows/verify-work.md +66 -25
  366. package/hooks/dist/gsd-agent-isolation-guard.js +158 -30
  367. package/hooks/dist/gsd-check-update-worker.js +56 -13
  368. package/hooks/dist/gsd-check-update.js +19 -1
  369. package/hooks/dist/gsd-config-reload.js +18 -12
  370. package/hooks/dist/gsd-context-monitor.js +19 -10
  371. package/hooks/dist/gsd-cursor-post-tool.js +3 -1
  372. package/hooks/dist/gsd-cursor-pre-tool.js +2 -3
  373. package/hooks/dist/gsd-cursor-session-start.js +2 -1
  374. package/hooks/dist/gsd-cursor-stop.js +2 -1
  375. package/hooks/dist/gsd-cursor-subagent-start.js +83 -3
  376. package/hooks/dist/gsd-cursor-subagent-stop.js +6 -3
  377. package/hooks/dist/gsd-ensure-canonical-path.js +2 -1
  378. package/hooks/dist/gsd-graphify-update.sh +22 -18
  379. package/hooks/dist/gsd-node-runner.sh +76 -0
  380. package/hooks/dist/gsd-phase-boundary.sh +1 -0
  381. package/hooks/dist/gsd-prompt-guard.js +37 -27
  382. package/hooks/dist/gsd-read-guard.js +16 -7
  383. package/hooks/dist/gsd-read-injection-scanner.js +55 -32
  384. package/hooks/dist/gsd-session-state.sh +1 -0
  385. package/hooks/dist/gsd-statusline.js +231 -24
  386. package/hooks/dist/gsd-update-banner.js +22 -1
  387. package/hooks/dist/gsd-validate-commit.sh +80 -6
  388. package/hooks/dist/gsd-windsurf-pre-command.js +16 -11
  389. package/hooks/dist/gsd-windsurf-pre-write.js +22 -13
  390. package/hooks/dist/gsd-workflow-guard.js +162 -46
  391. package/hooks/dist/gsd-worktree-path-guard.js +36 -21
  392. package/hooks/dist/gsd-write-guard.js +35 -25
  393. package/hooks/dist/lib/cli-exit.js +560 -0
  394. package/hooks/dist/lib/exit-code-registry.js +98 -0
  395. package/hooks/dist/lib/git-cmd.js +92 -59
  396. package/hooks/dist/lib/git-probe.js +84 -0
  397. package/hooks/dist/lib/hook-exit.js +81 -0
  398. package/hooks/dist/lib/injection-patterns.js +45 -0
  399. package/hooks/dist/lib/isolation-deny-reason.js +39 -0
  400. package/hooks/dist/lib/isolation-sentinel.js +9 -0
  401. package/hooks/dist/managed-hooks-registry.cjs +3 -0
  402. package/hooks/gsd-agent-isolation-guard.js +158 -30
  403. package/hooks/gsd-check-update-worker.js +56 -13
  404. package/hooks/gsd-check-update.js +19 -1
  405. package/hooks/gsd-config-reload.js +18 -12
  406. package/hooks/gsd-context-monitor.js +19 -10
  407. package/hooks/gsd-cursor-post-tool.js +3 -1
  408. package/hooks/gsd-cursor-pre-tool.js +2 -3
  409. package/hooks/gsd-cursor-session-start.js +2 -1
  410. package/hooks/gsd-cursor-stop.js +2 -1
  411. package/hooks/gsd-cursor-subagent-start.js +83 -3
  412. package/hooks/gsd-cursor-subagent-stop.js +6 -3
  413. package/hooks/gsd-ensure-canonical-path.js +2 -1
  414. package/hooks/gsd-graphify-update.sh +22 -18
  415. package/hooks/gsd-node-runner.sh +76 -0
  416. package/hooks/gsd-phase-boundary.sh +1 -0
  417. package/hooks/gsd-prompt-guard.js +37 -27
  418. package/hooks/gsd-read-guard.js +16 -7
  419. package/hooks/gsd-read-injection-scanner.js +55 -32
  420. package/hooks/gsd-session-state.sh +1 -0
  421. package/hooks/gsd-statusline.js +231 -24
  422. package/hooks/gsd-update-banner.js +22 -1
  423. package/hooks/gsd-validate-commit.sh +80 -6
  424. package/hooks/gsd-windsurf-pre-command.js +16 -11
  425. package/hooks/gsd-windsurf-pre-write.js +22 -13
  426. package/hooks/gsd-workflow-guard.js +162 -46
  427. package/hooks/gsd-worktree-path-guard.js +36 -21
  428. package/hooks/gsd-write-guard.js +35 -25
  429. package/hooks/lib/cli-exit.js +560 -0
  430. package/hooks/lib/exit-code-registry.js +98 -0
  431. package/hooks/lib/git-cmd.js +92 -59
  432. package/hooks/lib/git-probe.js +84 -0
  433. package/hooks/lib/hook-exit.js +81 -0
  434. package/hooks/lib/injection-patterns.js +45 -0
  435. package/hooks/lib/isolation-deny-reason.js +39 -0
  436. package/hooks/lib/isolation-sentinel.js +9 -0
  437. package/hooks/managed-hooks-registry.cjs +3 -0
  438. package/package.json +28 -11
  439. package/pi/gsd.cjs +19 -5
  440. package/scripts/base64-scan.sh +74 -12
  441. package/scripts/baselines/planning-prompt-drift-baseline.json +4 -0
  442. package/scripts/baselines/planning-snapshot-bypass-baseline.json +12 -0
  443. package/scripts/baselines/unreachable-guard-drift-baseline.json +4 -0
  444. package/scripts/build-hooks.js +5 -0
  445. package/scripts/changeset/lint.cjs +60 -5
  446. package/scripts/check-alias-drift.cjs +7 -43
  447. package/scripts/check-contract-drift.cjs +297 -0
  448. package/scripts/check-glossary-refs.cjs +77 -15
  449. package/scripts/check-mutation-score-ratchet.cjs +156 -0
  450. package/scripts/ci-check-job-near-cap.cjs +49 -0
  451. package/scripts/ci-pr-mergeability.cjs +262 -0
  452. package/scripts/ci-test-scope.cjs +64 -14
  453. package/scripts/ci-timeout-report.cjs +230 -0
  454. package/scripts/command-contract-helpers.cjs +903 -1
  455. package/scripts/docs-guard-registry.cjs +396 -0
  456. package/scripts/gen-adr-index.cjs +728 -38
  457. package/scripts/gen-capability-registry.cjs +11 -21
  458. package/scripts/gen-context-index.cjs +2 -11
  459. package/scripts/gen-exit-code-docs.cjs +318 -0
  460. package/scripts/gen-exit-code-registry.cjs +891 -0
  461. package/scripts/gen-features.cjs +836 -0
  462. package/scripts/gen-health-docs.cjs +390 -0
  463. package/scripts/gen-hooks-cli-exit.cjs +239 -0
  464. package/scripts/gen-install-tree-fixtures.cjs +2 -2
  465. package/scripts/gen-inventory-manifest.cjs +50 -4
  466. package/scripts/gen-loop-host-contract.cjs +138 -25
  467. package/scripts/gen-registry.cjs +3 -14
  468. package/scripts/gen-scripts-cli-exit.cjs +185 -0
  469. package/scripts/gen-state-md-docs.cjs +727 -0
  470. package/scripts/{test-failure-reasons.cjs → gsd-test-gate-reasons.cjs} +6 -0
  471. package/scripts/lib/alias-drift-families.cjs +46 -0
  472. package/scripts/lib/ci-job-timing.cjs +72 -0
  473. package/scripts/lib/cli-exit.cjs +546 -44
  474. package/scripts/lib/drift-scan.cjs +308 -0
  475. package/scripts/lib/exit-code-registry.cjs +98 -0
  476. package/scripts/lib/ndjson-reporter.cjs +119 -0
  477. package/scripts/lint-allow-test-rule-refs.allowlist.json +1 -26
  478. package/scripts/lint-allow-test-rule-refs.effective-ceiling.json +4 -0
  479. package/scripts/lint-allow-test-rule-refs.unverified-ceiling.json +3 -0
  480. package/scripts/lint-canary-version-leak.cjs +73 -0
  481. package/scripts/lint-command-contract.cjs +96 -13
  482. package/scripts/lint-completion-predicate-drift.cjs +933 -0
  483. package/scripts/lint-completion-ratio-drift.cjs +214 -0
  484. package/scripts/lint-default-flip-documentation.cjs +193 -0
  485. package/scripts/lint-docs-guard-registration.cjs +495 -0
  486. package/scripts/lint-docs-guard-registration.exempt-baseline.cjs +193 -0
  487. package/scripts/lint-eslint-glob-coverage.allowlist.json +38 -0
  488. package/scripts/lint-eslint-glob-coverage.cjs +340 -0
  489. package/scripts/{lint-fix-has-regression-test.cjs → lint-fix-has-regression-tests.cjs} +12 -6
  490. package/scripts/lint-frontmatter-scalar-broad-grep.cjs +237 -0
  491. package/scripts/lint-health-diagnostic-rule-table.cjs +461 -0
  492. package/scripts/lint-hooks-runtime-build-seam.cjs +262 -0
  493. package/scripts/lint-milestone-window-drift.cjs +468 -0
  494. package/scripts/lint-mutation-test-derivation-drift.cjs +86 -0
  495. package/scripts/lint-phase-enumeration-drift.cjs +492 -0
  496. package/scripts/lint-plan-count-drift.cjs +318 -0
  497. package/scripts/lint-planning-artifact-writer-drift.cjs +398 -0
  498. package/scripts/lint-planning-prompt-drift.cjs +471 -0
  499. package/scripts/lint-planning-snapshot-bypass-drift.cjs +544 -0
  500. package/scripts/lint-regression-test-names.cjs +15 -13
  501. package/scripts/lint-removed-but-needed.cjs +488 -0
  502. package/scripts/lint-seam-enforcement.cjs +182 -0
  503. package/scripts/lint-slug-derivation-drift.cjs +921 -0
  504. package/scripts/lint-source-test-name-collision.cjs +241 -0
  505. package/scripts/lint-state-field-drift.cjs +805 -0
  506. package/scripts/lint-state-write-path-drift.cjs +950 -0
  507. package/scripts/lint-test-file-count.allowlist.json +137 -8
  508. package/scripts/lint-test-file-count.cjs +25 -3
  509. package/scripts/lint-unreachable-guard-drift.cjs +830 -0
  510. package/scripts/lint-vendored-deps.cjs +297 -0
  511. package/scripts/mutation-matrix.cjs +599 -50
  512. package/scripts/pr-changed-files.cjs +63 -0
  513. package/scripts/pr-template-policy.cjs +14 -4
  514. package/scripts/prompt-injection-scan.sh +100 -14
  515. package/scripts/require-issue-link-policy.cjs +192 -0
  516. package/scripts/secret-scan.sh +75 -13
  517. package/scripts/select-docs-guards.cjs +56 -0
  518. package/scripts/sync-runtime-launcher.cjs +24 -7
  519. package/skills/gsd-autonomous/SKILL.md +0 -1
  520. package/skills/gsd-code-review/SKILL.md +1 -1
  521. package/skills/gsd-discuss-phase/SKILL.md +1 -1
  522. package/skills/gsd-execute-phase/SKILL.md +1 -2
  523. package/skills/gsd-import/SKILL.md +1 -1
  524. package/skills/gsd-map-codebase/SKILL.md +1 -1
  525. package/skills/gsd-mempalace-capture/SKILL.md +1 -1
  526. package/skills/gsd-mempalace-recall/SKILL.md +1 -1
  527. package/skills/gsd-new-milestone/SKILL.md +1 -1
  528. package/skills/gsd-next/SKILL.md +0 -1
  529. package/skills/gsd-plan-phase/SKILL.md +0 -1
  530. package/skills/gsd-progress/SKILL.md +0 -1
  531. package/skills/gsd-quick/SKILL.md +9 -5
  532. package/skills/gsd-review-backlog/SKILL.md +2 -1
  533. package/skills/gsd-stats/SKILL.md +0 -1
  534. package/skills/gsd-verify-work/SKILL.md +1 -1
  535. package/vscode/package.json +1 -1
  536. package/bin/lib/ui-safety-gate.cjs +0 -107
  537. package/gsd-core/workflows/discovery-phase.md +0 -298
  538. package/gsd-core/workflows/plan-milestone-gaps.md +0 -281
  539. package/gsd-core/workflows/verify-phase.md +0 -574
  540. package/scripts/affected-tests-lib.cjs +0 -554
  541. package/scripts/lint-allow-test-rule-refs.cjs +0 -162
  542. package/scripts/lint-emitted-drift-ack.cjs +0 -344
  543. package/scripts/run-affected-tests.cjs +0 -7
  544. package/scripts/run-tests.cjs +0 -1051
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Capability trust gate — ADR-1244 Phase 4 (Decision D5 + the compatibility half of D6), extended
4
- * by ADR-2782 Phase 3 (#2796) with a FOURTH executable-surface class: the reviewer lane.
4
+ * by ADR-2782 Phase 3 (#2796) with a FOURTH executable-surface class (the reviewer lane), and by
5
+ * ADR-2363 Phase 1 (#3248) with a FIFTH, NON-executable class: the instruction surface.
5
6
  *
6
7
  * PURE module. It computes *what* a capability would do and *whether* policy allows it; it
7
8
  * never mutates the filesystem and never performs I/O beyond reading staged files to confirm
@@ -21,16 +22,33 @@
21
22
  * the signature — the loader has no config resolver and must compute the same signature as the
22
23
  * lifecycle (constraint 2, `.gsd/phase/chore-2796-reviewer-trust-disclosure/40-design.md`).
23
24
  *
25
+ * ADR-2363 D5 (#3248): a capability's declared `skills` are INSTRUCTION surfaces — their bodies are
26
+ * copied verbatim into the user's agent instruction context, so their reach is bounded only by what
27
+ * the agent will do when told. They are disclosed BY NAME and never content-scanned (D2 —
28
+ * Kerckhoffs: a shipped rule set is readable by the adversary who installs it). Unlike the four
29
+ * executable classes they never set `hasExecutable` (D3) and never enter `disclosureSignature` (D4):
30
+ * folding them in would perturb the stored signature of every already-consented skill-bearing
31
+ * capability and fire a spurious re-consent on its next upgrade — the harm ADR-2782 D4 rule 5
32
+ * already forbids. Any future signature binding arrives as a versioned v2, never an in-place
33
+ * re-encoding of v1. ADR-2363 D3's class table names "skills, agents", but third-party `agents[]`
34
+ * are deliberately EXCLUDED here: `stageAgentsForRuntimeWithConverter` (`src/install-profiles.cts`)
35
+ * takes only a source directory, with no registry-aware third-party staging path the way
36
+ * `readInstalledCapabilitySkill` gives skills — so a declared agent is never actually staged into
37
+ * the instruction context, and disclosing it would name a surface that does not exist. Agents stay
38
+ * unimplemented pending a maintainer decision.
39
+ *
24
40
  * Exports:
25
41
  * RESERVED_NAMESPACES — id prefixes third parties may not claim
26
- * discloseExecutableSurfaces(...) — enumerate hooks / command modules / mcpServers / reviewer lanes
42
+ * discloseExecutableSurfaces(...) — enumerate the four executable classes + instruction surfaces
27
43
  * collectReviewerLaneSurfaces(...) — the reviewer-lane collector, independently testable
44
+ * collectInstructionSurfaces(...) — the instruction-surface collector, independently testable
28
45
  * checkReservedNamespace(id) — is this id in a reserved namespace?
29
46
  * evaluateSourceAllowed(parsed,...) — strictKnownRegistries enforcement
30
47
  * checkEngines(manifest, host) — engines.gsd hard gate + compatVersions downgrade
31
48
  * evaluateInstallTrust(args) — compose: source + namespace + engines + disclosure
32
49
  * executableSetChanged(old, new) — did the executable surface set change between versions?
33
50
  * summarizeDisclosure(disclosure) — human-readable consent-prompt lines
51
+ * summarizeInstructionSurfaces(d) — the instruction-surface section of the consent summary
34
52
  * UNRESOLVED_HOST_MARKER — the non-blank marker for an unresolved openai-http host
35
53
  * EGRESS_PAYLOAD_CLASSES — the named data classes every reviewer lane receives
36
54
  */
@@ -403,6 +421,48 @@ function collectReviewerLaneSurfaces(manifest, resolveHost) {
403
421
  const args = rawArgsDeclared.filter((a) => typeof a === 'string');
404
422
  const hostConfigKey = asString(invoke['hostConfigKey']);
405
423
  const promptChannel = asString(invoke['promptChannel']);
424
+ // #2483: the declared env pairs. String-filtered for the human line exactly as `args` is, and
425
+ // prototype-safe (own enumerable keys only, dangerous keys never copied) exactly as `rawConfig`
426
+ // is. Disclosure runs BEFORE validation, so a non-object or non-string-valued `env` reaches here
427
+ // and must degrade to "declares none" rather than throw.
428
+ const env = {};
429
+ const envRaw = invoke['env'];
430
+ if (typeof envRaw === 'object' && envRaw !== null && !Array.isArray(envRaw)) {
431
+ for (const [k, v] of Object.entries(envRaw)) {
432
+ if (k === '__proto__' || k === 'constructor' || k === 'prototype')
433
+ continue;
434
+ if (typeof v === 'string')
435
+ env[k] = v;
436
+ }
437
+ }
438
+ const defaultHost = asString(invoke['defaultHost']);
439
+ // The completeness backstop (mirrors rawConfig). Everything the invoke object declares that the
440
+ // explicit fields above do not already bind. Same prototype-safe copy.
441
+ const residualInvoke = {};
442
+ for (const [k, v] of Object.entries(invoke)) {
443
+ if (k === '__proto__' || k === 'constructor' || k === 'prototype')
444
+ continue;
445
+ if (k === 'binary' || k === 'args' || k === 'hostConfigKey' || k === 'promptChannel')
446
+ continue;
447
+ residualInvoke[k] = v;
448
+ }
449
+ // The outer half of the same backstop. `probe` is the one that matters most — its `binary` is
450
+ // spawned before dispatch — and the two exclusions below are ADR-2782's deliberate cosmetic
451
+ // carve-outs, not fields nobody got round to.
452
+ const residualLane = {};
453
+ for (const [k, v] of Object.entries(rec)) {
454
+ if (k === '__proto__' || k === 'constructor' || k === 'prototype')
455
+ continue;
456
+ if (k === 'slug' || k === 'transport' || k === 'handler' || k === 'invoke')
457
+ continue;
458
+ if (k === 'reviewsSection' || k === 'timeoutFloorMs')
459
+ continue;
460
+ residualLane[k] = v;
461
+ }
462
+ const probeRaw = rec['probe'];
463
+ const probeIsObj = typeof probeRaw === 'object' && probeRaw !== null && !Array.isArray(probeRaw);
464
+ const probeBinary = probeIsObj ? asString(probeRaw['binary']) : '';
465
+ const probeKind = probeIsObj ? asString(probeRaw['kind']) : '';
406
466
  // An EMPTY (or wholly unrecognised) reviewer body declares no lane and must
407
467
  // not be treated as one. Without this, `reviewer: {}` alone flips
408
468
  // hasExecutable true and perturbs the disclosure signature — producing a
@@ -416,8 +476,12 @@ function collectReviewerLaneSurfaces(manifest, resolveHost) {
416
476
  // enough. Requiring specifically a binary, or specifically a slug, would let
417
477
  // a lane declaring only the other slip through unconsented, which is the far
418
478
  // worse failure.
479
+ // `env`/`defaultHost` join the test for the reason the comment above gives for keeping it broad:
480
+ // a lane declaring ONLY an `env` pair would otherwise declare "nothing", disclose nothing, and
481
+ // still hand those pairs to a spawned child once #2927/#3062 made overlay lanes executable —
482
+ // the exact slip-through the broad test exists to refuse.
419
483
  const declaresSomething = Boolean(slug || transport || handler || binary || hostConfigKey || promptChannel
420
- || rawArgsDeclared.length > 0);
484
+ || rawArgsDeclared.length > 0 || Object.keys(env).length > 0 || defaultHost || probeBinary);
421
485
  if (!declaresSomething)
422
486
  return [];
423
487
  // B2/B3/B4: resolvedHost/isLocalDestination are only meaningful for an openai-http lane — a
@@ -462,6 +526,12 @@ function collectReviewerLaneSurfaces(manifest, resolveHost) {
462
526
  isLocalDestination,
463
527
  promptChannel,
464
528
  handler,
529
+ env,
530
+ defaultHost,
531
+ residualInvoke,
532
+ residualLane,
533
+ probeBinary,
534
+ probeKind,
465
535
  // B5: every lane receives the same named egress payload classes — a fresh copy per surface so
466
536
  // no caller can mutate the shared constant through a returned surface.
467
537
  egressPayloadClasses: [...EGRESS_PAYLOAD_CLASSES],
@@ -469,6 +539,56 @@ function collectReviewerLaneSurfaces(manifest, resolveHost) {
469
539
  return [surface];
470
540
  }, []);
471
541
  }
542
+ /**
543
+ * The manifest fields whose declared names become instruction surfaces. Ordered data rather than a
544
+ * hand-rolled loop per field, so a future second member of the class is one row, not a second copy
545
+ * of the same filter. Deliberately a ONE-row table today: third-party `agents[]` are never staged
546
+ * into the instruction context — `stageAgentsForRuntimeWithConverter` (`src/install-profiles.cts`)
547
+ * takes only a source directory, with no registry-aware staging path the way
548
+ * `readInstalledCapabilitySkill` gives skills — so disclosing them would name a surface that does
549
+ * not exist. ADR-2363 D3's class table says "skills, agents"; the agents half is therefore
550
+ * deliberately unimplemented pending a maintainer decision.
551
+ */
552
+ const INSTRUCTION_SURFACE_FIELDS = [
553
+ { field: 'skills', kind: 'skill' },
554
+ ];
555
+ /**
556
+ * Collect the instruction surfaces a manifest declares (ADR-2363 D5, #3248) — peer to the four
557
+ * executable-surface collectors, and invoked through the same `safeCollect` wrapper so a hostile
558
+ * value here degrades ONLY this class to empty rather than losing the other four.
559
+ *
560
+ * Liberal in what it accepts, exactly like the existing collectors: a non-object manifest, an
561
+ * absent field, a non-array field, and a non-string/blank member each degrade quietly. A non-array
562
+ * `skills` is NOT a partial success — it yields nothing, because a scalar declares no set.
563
+ *
564
+ * Deliberately does NOT:
565
+ * - dedup (a manifest declaring a stem twice discloses it twice — disclosure reports what the
566
+ * manifest SAYS; collapsing would misreport it, and dedup is the registry's job);
567
+ * - normalize or truncate a name (it is disclosed verbatim so the user sees what was declared);
568
+ * - existence-check the stem against `stagedDir`. A stem is a REGISTRY name, not a bundle-relative
569
+ * artifact path — checking it would repeat the reviewer-lane `binary` mistake (matrix C6) and
570
+ * put registry names into `missingArtifacts`, which is for declared bundle FILES only.
571
+ */
572
+ function collectInstructionSurfaces(manifest) {
573
+ const surfaces = [];
574
+ if (typeof manifest !== 'object' || manifest === null)
575
+ return surfaces;
576
+ for (const { field, kind } of INSTRUCTION_SURFACE_FIELDS) {
577
+ const declared = manifest[field];
578
+ if (!Array.isArray(declared))
579
+ continue;
580
+ for (const entry of declared) {
581
+ // A non-string or blank member is dropped INDIVIDUALLY — the valid siblings around it still
582
+ // disclose, mirroring how collectHookSurfaces skips a malformed entry rather than the array.
583
+ if (typeof entry !== 'string')
584
+ continue;
585
+ if (entry.trim() === '')
586
+ continue;
587
+ surfaces.push({ kind, name: entry });
588
+ }
589
+ }
590
+ return surfaces;
591
+ }
472
592
  /**
473
593
  * Enumerate every executable surface a capability manifest declares.
474
594
  *
@@ -478,6 +598,13 @@ function collectReviewerLaneSurfaces(manifest, resolveHost) {
478
598
  * - `mcpServers`: { <name>: {...} } | [{ name }] — servers spawned by the host runtime
479
599
  * - `reviewer`: { slug, transport, invoke, ... } — an external reviewer lane (ADR-2782 D5, #2796)
480
600
  *
601
+ * plus ONE non-executable class (ADR-2363 D5, #3248):
602
+ * - `skills`: string[] of owned stems — INSTRUCTION surfaces, whose bodies land in the agent's
603
+ * instruction context. Disclosed by name; they never set `hasExecutable` (D3) and never enter
604
+ * `disclosureSignature` (D4). Stems are registry names, so they are never existence-checked
605
+ * against `stagedDir` and never appear in `missingArtifacts`. `agents` is excluded — see the
606
+ * module header.
607
+ *
481
608
  * `mcpServers` is not a first-party capability.json field today, but a third-party manifest may
482
609
  * declare it, so the trust gate discloses it whenever present (honest disclosure over the
483
610
  * narrower first-party schema). Pure: when `stagedDir` is provided, declared hook/command-module
@@ -490,7 +617,7 @@ function collectReviewerLaneSurfaces(manifest, resolveHost) {
490
617
  * throwing traps, or a property with a throwing getter (matrix C5, E2). Disclosure runs BEFORE
491
618
  * Phase 2's validation, on a manifest validation would reject outright, so it must tolerate what
492
619
  * validation does not. Each surface class is collected independently (`safeCollect`) so a hostile
493
- * value in ONE class degrades only that class to empty rather than losing the other three.
620
+ * value in ONE class degrades only that class to empty rather than losing the others.
494
621
  *
495
622
  * `resolveHost` (optional, #2796) is forwarded to `collectReviewerLaneSurfaces` so a caller with
496
623
  * config access (the lifecycle, never the loader — see `signatureForManifest`) can disclose the REAL
@@ -502,8 +629,11 @@ function discloseExecutableSurfaces(manifest, stagedDir, resolveHost) {
502
629
  const commandModules = safeCollect(() => collectCommandSurfaces(manifest, stagedDir, missingArtifacts), []);
503
630
  const mcpServers = safeCollect(() => collectMcpSurfaces(manifest), []);
504
631
  const reviewerLanes = safeCollect(() => collectReviewerLaneSurfaces(manifest, resolveHost), []);
632
+ const instructionSurfaces = safeCollect(() => collectInstructionSurfaces(manifest), []);
633
+ // ADR-2363 D3: instruction surfaces are deliberately ABSENT from this expression. Adding them
634
+ // would silently change `executableSetChanged` and the auto-update re-consent trigger.
505
635
  const hasExecutable = hooks.length > 0 || commandModules.length > 0 || mcpServers.length > 0 || reviewerLanes.length > 0;
506
- return { hooks, commandModules, mcpServers, reviewerLanes, hasExecutable, missingArtifacts };
636
+ return { hooks, commandModules, mcpServers, reviewerLanes, instructionSurfaces, hasExecutable, missingArtifacts };
507
637
  }
508
638
  /**
509
639
  * Existence-check a manifest-declared artifact path under stagedDir, refusing to follow it
@@ -712,6 +842,15 @@ function evaluateInstallTrust(args) {
712
842
  // openai-http reviewer lane to the human at install/upgrade time — it never affects the
713
843
  // consent-binding signature (disclosureSignature never reads resolvedHost; design constraint 2).
714
844
  const disclosure = discloseExecutableSurfaces(manifest, stagedDir, resolveHost);
845
+ // #3514 (F21c): prompt-only integrity status. Set AFTER discloseExecutableSurfaces so the
846
+ // surface builder (and every signature computed from it) is untouched — see the field's
847
+ // disclosure-interface comment for why this must never reach disclosureSignature.
848
+ if (args.integrityPin === 'sha512')
849
+ disclosure.integrityStatus = 'pinned';
850
+ else if (args.integrityPin === 'git-commit')
851
+ disclosure.integrityStatus = 'commit-pinned';
852
+ else if (args.integrityPin === 'none')
853
+ disclosure.integrityStatus = 'unverified';
715
854
  // A manifest that declares a hook script or command module NOT present in the staged bundle
716
855
  // (missing, or escaping the bundle via an absolute/`..` path) is rejected: such an artifact
717
856
  // would run from outside the integrity-pinned, reversible install root. Only enforced when a
@@ -831,8 +970,41 @@ function disclosureSignature(d) {
831
970
  // 2 — the loader has no config resolver and must compute the SAME signature as the lifecycle, or a
832
971
  // resolver-bearing caller and a resolver-less caller would permanently disagree on one manifest's
833
972
  // signature).
973
+ // #2483: the eight-field enumeration above was a CLOSED list over an OPEN vocabulary, and it had
974
+ // already fallen behind by EIGHT fields before `env` made the ninth — `defaultHost` (the manifest's
975
+ // OWN fallback egress host), `path` (appended to it to build the URL), `outputChannel`, `outputArg`,
976
+ // `modelArg`, `effortChannel`, `modelDiscovery` and `fallbackModel` all reach `resolveLanePlan` and
977
+ // none was signed. Counted, because the number is easy to state ambiguously: `resolveLanePlan`
978
+ // reads THIRTEEN distinct `inv.*` fields once `env` is included (twelve before this PR added it),
979
+ // of which the pre-#2483 tuple bound four — so eight were unbound before `env`, nine including it.
980
+ // So the fix is not a ninth name: it is a residual, the same completeness backstop `rawConfig` gives
981
+ // the MCP line one screen up (#1459 finding 5). `env`/`defaultHost` are ALSO named explicitly,
982
+ // mirroring that line's deliberate explicit-then-backstop overlap, because they are the two the
983
+ // human summary renders and a reader should be able to find them in the signature by name.
984
+ //
985
+ // APPENDED ONLY WHEN NON-EMPTY, which is D4.5 one level down: a lane declaring nothing beyond the
986
+ // eight already-bound fields keeps a BYTE-IDENTICAL signature, so this cannot re-prompt every
987
+ // consented capability for a field it does not use. A lane that DOES declare one re-consents — which
988
+ // is the correct outcome, not a cost: those fields were executable and undisclosed.
834
989
  const lanes = d.reviewerLanes
835
- .map((l) => stableJson(['lane', l.slug, l.transport, l.binary, l.rawArgs || [], l.hostConfigKey, l.promptChannel, l.handler]))
990
+ .map((l) => {
991
+ const tuple = [
992
+ 'lane', l.slug, l.transport, l.binary, l.rawArgs || [], l.hostConfigKey, l.promptChannel, l.handler,
993
+ ];
994
+ const extra = {
995
+ env: l.env || {},
996
+ defaultHost: l.defaultHost || '',
997
+ residual: l.residualInvoke || {},
998
+ laneResidual: l.residualLane || {},
999
+ };
1000
+ const declaresExtra = Object.keys(extra.env).length > 0
1001
+ || extra.defaultHost !== ''
1002
+ || Object.keys(extra.residual).length > 0
1003
+ || Object.keys(extra.laneResidual).length > 0;
1004
+ if (declaresExtra)
1005
+ tuple.push(extra);
1006
+ return stableJson(tuple);
1007
+ })
836
1008
  .sort();
837
1009
  // D4.5 (the highest-consequence line in this phase): the lane element is appended ONLY when at
838
1010
  // least one lane is declared. A lane-free manifest's signature stays BYTE-IDENTICAL to before this
@@ -864,65 +1036,227 @@ function signatureForManifest(manifest, stagedDir) {
864
1036
  // ---------------------------------------------------------------------------
865
1037
  /** Max characters of an env VALUE shown in the human consent prompt before it is truncated. */
866
1038
  const ENV_VALUE_MAX = 60;
1039
+ /**
1040
+ * Environment names that turn a declared pair into arbitrary code execution in a spawned child
1041
+ * (#2483). This list drives the consent prompt's WARNING line. The capability validator carries its
1042
+ * own denylist that REFUSES these names outright (`DENIED_LANE_ENV_KEYS`); the two are deliberately
1043
+ * separate layers rather than one, because they answer different questions: the validator refuses a
1044
+ * manifest it can reject, and this list makes sure anything that DOES reach a prompt is read loudly.
1045
+ * Neither is the boundary — install-time consent is, since no enumeration of execution-primitive
1046
+ * names can be complete against an arbitrary third-party child.
1047
+ */
1048
+ const EXECUTION_PRIMITIVE_ENV = new Set([
1049
+ 'NODE_OPTIONS', 'NODE_REPL_EXTERNAL_MODULE', 'LD_PRELOAD', 'LD_AUDIT', 'LD_LIBRARY_PATH',
1050
+ 'DYLD_INSERT_LIBRARIES', 'DYLD_LIBRARY_PATH', 'PYTHONSTARTUP', 'PYTHONPATH', 'BASH_ENV', 'ENV',
1051
+ 'PERL5OPT', 'RUBYOPT', 'JAVA_TOOL_OPTIONS', '_JAVA_OPTIONS', 'CLASSPATH', 'NODE_PATH',
1052
+ 'GIT_SSH_COMMAND', 'GIT_EXTERNAL_DIFF', 'PATH',
1053
+ ]);
867
1054
  /** Truncate a long env value for the human prompt (the full value is still in the signature). */
868
1055
  function truncateEnvValue(v) {
869
1056
  if (typeof v !== 'string')
870
1057
  return '';
871
1058
  return v.length > ENV_VALUE_MAX ? `${v.slice(0, ENV_VALUE_MAX)}… (${v.length} chars)` : v;
872
1059
  }
1060
+ /**
1061
+ * Characters that must never reach the consent prompt unescaped. `summarizeDisclosure`'s lines are
1062
+ * joined with `\n` and written RAW to stderr on the needs-consent path, and every value in them is
1063
+ * attacker-controlled manifest data. A raw newline forges a line indistinguishable from genuine
1064
+ * disclosure text; a raw ESC lets a value rewrite or clear lines already printed; a bidi override
1065
+ * visually reorders one. C0, DEL, C1, the bidi/isolate controls, and the line/paragraph separators
1066
+ * are all escaped to a visible `\uXXXX`, so the value stays identifiable and cannot forge output.
1067
+ */
1068
+ const UNSAFE_PROMPT_CHARS = /[\u0000-\u001f\u007f-\u009f\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g;
1069
+ /** Max characters of any single manifest-supplied value rendered into the consent prompt. */
1070
+ const PROMPT_VALUE_MAX = 200;
1071
+ /**
1072
+ * Render one manifest-supplied value safely into a consent-prompt line: escape every character that
1073
+ * could forge or rewrite output, then bound the length so one oversized value cannot flood the
1074
+ * prompt and push the rest off screen. Escaping is IDENTITY for ordinary names, so this changes no
1075
+ * existing rendered output for any well-formed manifest — only the disclosure OBJECT is verbatim;
1076
+ * the rendered LINE is always escaped.
1077
+ */
1078
+ function renderValueForPrompt(v) {
1079
+ // `String(v)` on an arbitrary `unknown` risks Object's default `[object Object]` stringification
1080
+ // (@typescript-eslint/no-base-to-string) for a non-primitive; every call site here passes a string
1081
+ // in practice, but the parameter stays `unknown` for the same total-collector discipline as
1082
+ // `renderArgForHuman`, so a non-primitive is JSON-stringified instead of coerced.
1083
+ let s;
1084
+ if (typeof v === 'string') {
1085
+ s = v;
1086
+ }
1087
+ else if (v === null || v === undefined) {
1088
+ s = '';
1089
+ }
1090
+ else if (typeof v === 'number' || typeof v === 'boolean' || typeof v === 'bigint') {
1091
+ s = String(v);
1092
+ }
1093
+ else {
1094
+ try {
1095
+ s = JSON.stringify(v) ?? '';
1096
+ }
1097
+ catch {
1098
+ s = '';
1099
+ }
1100
+ }
1101
+ const escaped = s.replace(UNSAFE_PROMPT_CHARS, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`);
1102
+ return escaped.length > PROMPT_VALUE_MAX
1103
+ ? `${escaped.slice(0, PROMPT_VALUE_MAX)}… (${escaped.length} chars)`
1104
+ : escaped;
1105
+ }
1106
+ /**
1107
+ * Render the instruction-surface section of a consent summary (ADR-2363 D3/D5, #3248).
1108
+ *
1109
+ * Extracted as its own exported function for two reasons. It is called from BOTH branches of
1110
+ * `summarizeDisclosure` — a skill-only capability has `hasExecutable === false` and takes the early
1111
+ * return, so a section appended only at the end would never render for exactly the capabilities
1112
+ * that need it. And it gives tests a typed surface to assert on, instead of regex-matching prose out
1113
+ * of `summarizeDisclosure` (CONTRIBUTING — "Prohibited: Raw Text Matching on Test Outputs").
1114
+ *
1115
+ * Returns `[]` when nothing is declared, so either caller can append unconditionally without
1116
+ * emitting an empty header.
1117
+ *
1118
+ * TOTAL for a partial disclosure object: the CLI edge calls `summarizeDisclosure(res.disclosure || {})`
1119
+ * (`capability-command-router.cjs`), so a bare `{}` — carrying no `instructionSurfaces` at all —
1120
+ * reaches this function whenever a lifecycle result has no disclosure.
1121
+ *
1122
+ * #3248: every manifest-supplied value rendered here (`kind`, `name`) goes through
1123
+ * `renderValueForPrompt` first — the CLI edge writes these lines RAW to stderr on the needs-consent
1124
+ * path, and an unescaped name could forge a line or rewrite output already printed (see that
1125
+ * function's comment).
1126
+ */
1127
+ function summarizeInstructionSurfaces(disclosure) {
1128
+ const declared = disclosure?.instructionSurfaces;
1129
+ const surfaces = Array.isArray(declared) ? declared : [];
1130
+ if (surfaces.length === 0)
1131
+ return [];
1132
+ const lines = [
1133
+ ` instruction surfaces (${surfaces.length}): installed into your agent's instruction context`,
1134
+ ];
1135
+ for (const s of surfaces) {
1136
+ // #3248: kind/name are manifest-supplied — escape+bound before rendering (see `renderValueForPrompt`).
1137
+ const kind = s?.kind ? renderValueForPrompt(s.kind) : '(kind?)';
1138
+ const name = s?.name ? renderValueForPrompt(s.name) : '(name?)';
1139
+ lines.push(` - ${kind}: ${name}`);
1140
+ }
1141
+ // ADR-2363 D1/D2, and Kerckhoffs: say plainly that nothing inspected these bodies. A summary that
1142
+ // named the surface while implying review would be worse than silence — a "looks checked" line
1143
+ // displaces the judgement this prompt exists to provoke (Goodhart, D2).
1144
+ lines.push(' these bodies are installed verbatim and are NOT content-scanned');
1145
+ return lines;
1146
+ }
873
1147
  /**
874
1148
  * Render a disclosure as consent-prompt lines. Returned as an array so the CLI/runtime edge can
875
1149
  * format it; the lib never writes to stdout.
1150
+ *
1151
+ * #3248: every manifest-supplied value interpolated into a line (hook event/script, command
1152
+ * family/module/router, MCP name/transport/url/command/argv/header-keys/env-keys+values/cwd,
1153
+ * reviewer-lane slug/hostConfigKey/resolvedHost/defaultHost/binary/rawArgs/handler/probe-binary/
1154
+ * env-keys+values, missingArtifacts entries)
1155
+ * goes through `renderValueForPrompt` first, which escapes forging/rewriting control characters and
1156
+ * bounds the length. These lines are joined with `\n` and written RAW to stderr on the
1157
+ * needs-consent path (`capability-command-router.cjs`), so an unescaped value could forge a line or
1158
+ * rewrite/clear output already printed — defeating the informed-consent guarantee this function
1159
+ * exists to provide. GSD-authored literals (fallback placeholders, headings, `<redacted>`) are never
1160
+ * escaped — only manifest-supplied data is.
1161
+ */
1162
+ /**
1163
+ * #3515: one predicate for "this MCP server is remote (connects to a URL; nothing local is
1164
+ * spawned)" — shared by the section's confinement notice and the per-server rendering so the
1165
+ * consent-prompt claim cannot drift from what is actually disclosed per server. Branches on the
1166
+ * DECLARED SHAPE: an http/sse transport, or a server with no command but a url.
876
1167
  */
1168
+ function isRemoteMcpServer(s) {
1169
+ return (s.transport === 'http' || s.transport === 'sse') || (!s.command && !!s.url);
1170
+ }
877
1171
  function summarizeDisclosure(disclosure) {
878
1172
  const lines = [];
1173
+ const instructionLines = summarizeInstructionSurfaces(disclosure);
1174
+ // #3514 (F21c): computed once, appended before every return path so a future path cannot miss it.
1175
+ const integrity = integrityStatusLine(disclosure);
879
1176
  if (!disclosure.hasExecutable) {
880
- lines.push('This capability ships no executable surfaces (declarative only).');
1177
+ // ADR-2363 D3: "declarative only" is true ONLY when there is no instruction surface either.
1178
+ // Claiming it unconditionally told a user their capability contributes nothing to weigh while
1179
+ // it was contributing agent instructions — the exact category error ADR-2363 was written to end.
1180
+ if (instructionLines.length === 0) {
1181
+ lines.push('This capability ships no executable surfaces (declarative only).');
1182
+ if (integrity)
1183
+ lines.push(integrity);
1184
+ return lines;
1185
+ }
1186
+ lines.push('This capability ships no executable surfaces, but contributes agent instructions:');
1187
+ for (const line of instructionLines)
1188
+ lines.push(line);
1189
+ if (integrity)
1190
+ lines.push(integrity);
881
1191
  return lines;
882
1192
  }
883
1193
  lines.push('This capability ships executable surfaces that will run in your agent runtime:');
884
1194
  if (disclosure.hooks.length > 0) {
885
1195
  lines.push(` hooks (${disclosure.hooks.length}): run as runtime hook commands`);
886
1196
  for (const h of disclosure.hooks) {
887
- lines.push(` - ${h.event || '(event?)'} -> ${h.script}`);
1197
+ const event = h.event ? renderValueForPrompt(h.event) : '(event?)';
1198
+ lines.push(` - ${event} -> ${renderValueForPrompt(h.script)}`);
888
1199
  }
889
1200
  }
890
1201
  if (disclosure.commandModules.length > 0) {
891
1202
  lines.push(` command modules (${disclosure.commandModules.length}): require()'d into the GSD CLI process`);
892
1203
  for (const m of disclosure.commandModules) {
893
1204
  // TRUST2-3 (#1459): show the router (which exported fn runs) so the user consents to the exact entry point.
894
- const routerSuffix = m.router ? ` [router: ${m.router}]` : '';
895
- lines.push(` - ${m.family || '(family?)'} -> ${m.module}${routerSuffix}`);
1205
+ const routerSuffix = m.router ? ` [router: ${renderValueForPrompt(m.router)}]` : '';
1206
+ const family = m.family ? renderValueForPrompt(m.family) : '(family?)';
1207
+ lines.push(` - ${family} -> ${renderValueForPrompt(m.module)}${routerSuffix}`);
896
1208
  }
897
1209
  }
898
1210
  if (disclosure.mcpServers.length > 0) {
899
1211
  lines.push(` MCP servers (${disclosure.mcpServers.length}): spawned/connected by the host runtime`);
1212
+ // #3515 (epic #1900 F20): the confinement-posture notice. Hook commands are confined to the
1213
+ // capability bundle (D5 rule 5); an MCP server's command/args/env/cwd are written VERBATIM and
1214
+ // may point anywhere on the machine — an intentional asymmetry (confining them would break
1215
+ // global/npx servers), disclosed here so the consent is informed rather than assumed. env is
1216
+ // named explicitly (isolated review finding): an execution-primitive env value changes WHAT
1217
+ // runs without touching command or argv — the classic vector — and omitting it would invite
1218
+ // the inference that env IS confined. Only SPAWNED (stdio) servers earn the line: a remote
1219
+ // (http/sse) server runs nothing locally, and the claim must be exact in a consent prompt.
1220
+ // One shared predicate (below) decides spawn-vs-remote for the notice AND the per-server
1221
+ // rendering, so the two cannot drift into an inexact claim.
1222
+ if (disclosure.mcpServers.some((s) => !isRemoteMcpServer(s))) {
1223
+ lines.push(' intentionally NOT confined to the bundle: a server\'s command, args, env, and cwd are written ' +
1224
+ 'verbatim and may point anywhere on this machine — unlike hooks, which are confined to the capability bundle root');
1225
+ }
900
1226
  for (const s of disclosure.mcpServers) {
901
1227
  // TRUST2-2 (#1459): a non-stdio (http/sse) server connects to a URL; disclose the endpoint, not
902
1228
  // a (nonexistent) command. A stdio server discloses command + args as before.
903
- const isRemote = (s.transport === 'http' || s.transport === 'sse') || (!s.command && !!s.url);
1229
+ const isRemote = isRemoteMcpServer(s);
1230
+ const name = renderValueForPrompt(s.name);
904
1231
  if (isRemote) {
905
- const t = s.transport || 'http';
906
- lines.push(` - ${s.name} -> [${t}] ${s.url || '(no url declared)'}`);
1232
+ const t = s.transport ? renderValueForPrompt(s.transport) : 'http';
1233
+ const url = s.url ? renderValueForPrompt(s.url) : '(no url declared)';
1234
+ lines.push(` - ${name} -> [${t}] ${url}`);
907
1235
  // Header VALUES are redacted in the human summary (they may carry secrets); only the KEY set
908
1236
  // is shown. The full values ARE in the signature, so a value change forces re-consent.
909
1237
  const hdrKeys = s.headers ? Object.keys(s.headers) : [];
910
1238
  if (hdrKeys.length > 0) {
911
- lines.push(` headers: ${hdrKeys.map((k) => `${k}=<redacted>`).join(', ')}`);
1239
+ lines.push(` headers: ${hdrKeys.map((k) => `${renderValueForPrompt(k)}=<redacted>`).join(', ')}`);
912
1240
  }
913
1241
  }
914
1242
  else {
915
- const cmd = [s.command, ...s.argv].filter(Boolean).join(' ');
916
- lines.push(` - ${s.name} -> ${cmd || '(no command declared)'}`);
1243
+ // Command + args are each escaped individually (not the joined string) so a value that
1244
+ // embeds a newline cannot forge a line even when it lands mid-argv.
1245
+ const cmd = [s.command, ...s.argv].filter(Boolean).map(renderValueForPrompt).join(' ');
1246
+ lines.push(` - ${name} -> ${cmd || '(no command declared)'}`);
917
1247
  }
918
1248
  // TRUST-2 (#1459): env can change WHAT runs without touching the command, so show each env key
919
- // and its (truncated) value — the user is consenting to this exact environment.
1249
+ // and its (truncated) value — the user is consenting to this exact environment. Truncate first
1250
+ // (keeps the prompt readable at the existing 60-char bound), then escape the result (#3248) so
1251
+ // the truncated value can still not forge or rewrite output.
920
1252
  const envKeys = s.env ? Object.keys(s.env) : [];
921
1253
  if (envKeys.length > 0) {
922
- lines.push(` env: ${envKeys.map((k) => `${k}=${truncateEnvValue(s.env[k])}`).join(', ')}`);
1254
+ lines.push(` env: ${envKeys
1255
+ .map((k) => `${renderValueForPrompt(k)}=${renderValueForPrompt(truncateEnvValue(s.env[k]))}`)
1256
+ .join(', ')}`);
923
1257
  }
924
1258
  if (s.cwd)
925
- lines.push(` cwd: ${s.cwd}`);
1259
+ lines.push(` cwd: ${renderValueForPrompt(s.cwd)}`);
926
1260
  }
927
1261
  }
928
1262
  if (disclosure.reviewerLanes.length > 0) {
@@ -937,44 +1271,129 @@ function summarizeDisclosure(disclosure) {
937
1271
  // declared)" for a lane that in fact egresses to a live remote host —
938
1272
  // understating the disclosure precisely when it matters. Disclosure runs
939
1273
  // BEFORE validation, so a non-canonical transport does reach this code.
1274
+ const slug = l.slug ? renderValueForPrompt(l.slug) : '(slug?)';
940
1275
  if (l.transport === 'openai-http' || (!l.binary && l.hostConfigKey)) {
941
1276
  const localTag = l.isLocalDestination ? ' [local]' : '';
942
- lines.push(` - ${l.slug || '(slug?)'} -> [openai-http] ${l.hostConfigKey || '(hostConfigKey?)'} => ${l.resolvedHost}${localTag}`);
1277
+ const hostConfigKey = l.hostConfigKey ? renderValueForPrompt(l.hostConfigKey) : '(hostConfigKey?)';
1278
+ lines.push(` - ${slug} -> [openai-http] ${hostConfigKey} => ${renderValueForPrompt(l.resolvedHost)}${localTag}`);
1279
+ // #2483: the MANIFEST's own fallback host, which `resolveLanePlan` uses whenever the config
1280
+ // key resolves to nothing (`configured ?? declaredDefault`). Without this line a lane whose
1281
+ // key is unset renders as "(unresolved)" — which reads as "no destination" — while actually
1282
+ // shipping the egress payload classes below to an address the manifest chose. That is the
1283
+ // understating-the-disclosure failure the branch test one comment up already refuses.
1284
+ // Escaped like every other rendered value (#3248): it is manifest-supplied by the same route.
1285
+ if (l.defaultHost) {
1286
+ lines.push(` fallback destination declared by this capability: ${renderValueForPrompt(l.defaultHost)}`);
1287
+ }
943
1288
  }
944
1289
  else {
945
1290
  // Render the RAW declared args, not the string-filtered view. The raw
946
1291
  // array is what the host receives and what the consent signature binds,
947
1292
  // so a non-string member that is invisible here is a surface the user
948
1293
  // consented to without being shown — the opposite of the disclosure's
949
- // whole purpose.
950
- const cmd = [l.binary, ...l.rawArgs.map(renderArgForHuman)].filter(Boolean).join(' ');
951
- lines.push(` - ${l.slug || '(slug?)'} -> ${cmd || '(no binary declared)'}`);
1294
+ // whole purpose. `renderArgForHuman` stringifies a non-string member; that
1295
+ // string is equally attacker-controlled, so it is escaped too (#3248).
1296
+ const cmd = [l.binary, ...l.rawArgs.map(renderArgForHuman)]
1297
+ .filter(Boolean)
1298
+ .map(renderValueForPrompt)
1299
+ .join(' ');
1300
+ lines.push(` - ${slug} -> ${cmd || '(no binary declared)'}`);
952
1301
  }
953
1302
  if (l.handler)
954
- lines.push(` handler: ${l.handler}`);
1303
+ lines.push(` handler: ${renderValueForPrompt(l.handler)}`);
1304
+ // The probe binary belongs in the prompt beside the dispatch binary when it differs — but the
1305
+ // two probe kinds are NOT the same disclosure and must not be rendered as one.
1306
+ // `command-capability` SPAWNS `<binary> --help`; `command-exists` only asks `hasBinary`, which
1307
+ // scans PATH and spawns nothing. An earlier revision of this line asserted the spawn for both,
1308
+ // which is a FALSE statement in a consent prompt — the one place a claim must be exact.
1309
+ if (l.probeBinary && l.probeBinary !== l.binary) {
1310
+ const probeBinary = renderValueForPrompt(l.probeBinary);
1311
+ lines.push(l.probeKind === 'command-capability'
1312
+ ? ` probes by running: ${probeBinary} --help`
1313
+ : ` probes for the presence of: ${probeBinary} (no process is started)`);
1314
+ }
1315
+ // #2483: identical treatment to the MCP `env` line above, for the identical reason stated
1316
+ // there — env changes WHAT runs without touching the command, so the user consents to this
1317
+ // exact environment or not at all. The parity is byte-level and deliberate: since #3248 the
1318
+ // MCP line escapes BOTH key and value through `renderValueForPrompt`, and a lane's env is
1319
+ // manifest-supplied by the same route — so rendering it raw here would reintroduce, on the
1320
+ // newer surface, precisely the prompt-forging vector #3248 closed on the older one.
1321
+ const laneEnvKeys = l.env ? Object.keys(l.env) : [];
1322
+ if (laneEnvKeys.length > 0) {
1323
+ lines.push(` env: ${laneEnvKeys
1324
+ .map((k) => `${renderValueForPrompt(k)}=${renderValueForPrompt(truncateEnvValue(l.env[k]))}`)
1325
+ .join(', ')}`);
1326
+ // Names that make an environment pair an EXECUTION primitive rather than configuration.
1327
+ // The validator REFUSES these on a reviewer lane (`DENIED_LANE_ENV_KEYS`), so in practice a
1328
+ // first-party or freshly-validated manifest never reaches this line. It still earns its
1329
+ // place, and the reason is the reason to keep both layers:
1330
+ // - Disclosure runs BEFORE validation, and on manifests validation would reject outright.
1331
+ // A user consenting to an already-installed or hand-placed capability sees this line
1332
+ // whether or not the validator ever ran on it.
1333
+ // - No enumeration of execution-primitive names is complete against an arbitrary
1334
+ // third-party child, so consent — not either list — is the boundary. A name missing from
1335
+ // both costs a quieter line on a value that is still SHOWN, which is the only
1336
+ // incompleteness budget an enumeration like this can honestly carry.
1337
+ const flagged = laneEnvKeys.filter((k) => EXECUTION_PRIMITIVE_ENV.has(k));
1338
+ if (flagged.length > 0) {
1339
+ lines.push(` WARNING — ${flagged.map(renderValueForPrompt).join(', ')} can make this lane run code of the capability's choosing`);
1340
+ }
1341
+ }
955
1342
  lines.push(` sends: ${l.egressPayloadClasses.join(', ')}`);
956
1343
  }
957
1344
  }
1345
+ for (const line of instructionLines)
1346
+ lines.push(line);
958
1347
  if (disclosure.missingArtifacts.length > 0) {
959
1348
  lines.push(' WARNING — declared artifacts not found in the staged bundle:');
960
1349
  for (const a of disclosure.missingArtifacts) {
961
- lines.push(` - ${a}`);
1350
+ lines.push(` - ${renderValueForPrompt(a)}`);
962
1351
  }
963
1352
  }
1353
+ if (integrity)
1354
+ lines.push(integrity);
964
1355
  return lines;
965
1356
  }
1357
+ /**
1358
+ * #3514 (F21c): the one-line integrity status for the consent prompt, or null when the caller
1359
+ * supplied no `integrityPin` (legacy — no line, byte-identical output). GSD-authored literals,
1360
+ * never manifest data — no escaping needed. A consent-prompt claim must be EXACT: a git
1361
+ * commit-pinned source renders its own line, never "sha512 pin" — no sha512 was supplied
1362
+ * (isolated review finding).
1363
+ */
1364
+ function integrityStatusLine(disclosure) {
1365
+ if (disclosure.integrityStatus === 'pinned') {
1366
+ return ' content: sha512 pin supplied and verified before staging';
1367
+ }
1368
+ if (disclosure.integrityStatus === 'commit-pinned') {
1369
+ return ' content: pinned to a git commit, checked out before staging';
1370
+ }
1371
+ if (disclosure.integrityStatus === 'unverified') {
1372
+ return ' content: NO PINNED HASH — staged unverified (a computed sha512 is recorded in the ledger at install)';
1373
+ }
1374
+ return null;
1375
+ }
966
1376
  module.exports = {
967
1377
  RESERVED_NAMESPACES,
968
1378
  discloseExecutableSurfaces,
969
1379
  // #2796: the reviewer-lane collector, exported for independent testability (ADR-2782's own
970
1380
  // argument for extracting per-class collectors rather than growing the switch inline).
971
1381
  collectReviewerLaneSurfaces,
1382
+ // ADR-2363 D5 (#3248): the instruction-surface collector, exported for independent testability —
1383
+ // same rationale as `collectReviewerLaneSurfaces` above.
1384
+ collectInstructionSurfaces,
972
1385
  checkReservedNamespace,
973
1386
  evaluateSourceAllowed,
974
1387
  checkEngines,
975
1388
  evaluateInstallTrust,
976
1389
  executableSetChanged,
977
1390
  summarizeDisclosure,
1391
+ // ADR-2363 D3/D5 (#3248): the instruction-surface section of the consent summary, exported so
1392
+ // callers/tests can assert on it directly — see `summarizeInstructionSurfaces`'s own JSDoc.
1393
+ summarizeInstructionSurfaces,
1394
+ // #3248: the consent-prompt escaping/bounding helper, exported so tests can assert directly that
1395
+ // control characters (newline, ESC, bidi overrides, etc.) never reach a rendered prompt line.
1396
+ renderValueForPrompt,
978
1397
  // #1459: the consent-binding signature (single source of truth for loader + lifecycle consent).
979
1398
  disclosureSignature,
980
1399
  signatureForManifest,