@lumenflow/cli 5.5.0 → 5.7.12

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 (213) hide show
  1. package/README.md +42 -40
  2. package/dist/db-journal-recover.js +400 -0
  3. package/dist/db-journal-recover.js.map +1 -0
  4. package/dist/docs-sync.js +8 -3
  5. package/dist/docs-sync.js.map +1 -1
  6. package/dist/gate-defaults.js +37 -0
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  9. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  10. package/dist/gates/prod-migration-drift.js +207 -0
  11. package/dist/gates/prod-migration-drift.js.map +1 -0
  12. package/dist/gates/test-over-deletion-guard.js +255 -0
  13. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  14. package/dist/gates-runners.js +44 -3
  15. package/dist/gates-runners.js.map +1 -1
  16. package/dist/gates.js +3 -2
  17. package/dist/gates.js.map +1 -1
  18. package/dist/lumenflow-setup.js +144 -0
  19. package/dist/lumenflow-setup.js.map +1 -0
  20. package/dist/lumenflow-upgrade.js +2 -1
  21. package/dist/lumenflow-upgrade.js.map +1 -1
  22. package/dist/mem-create.js +10 -1
  23. package/dist/mem-create.js.map +1 -1
  24. package/dist/mem-signal.js +21 -4
  25. package/dist/mem-signal.js.map +1 -1
  26. package/dist/orchestrate-initiative.js +28 -3
  27. package/dist/orchestrate-initiative.js.map +1 -1
  28. package/dist/public-manifest.js +17 -0
  29. package/dist/public-manifest.js.map +1 -1
  30. package/dist/release.js +53 -18
  31. package/dist/release.js.map +1 -1
  32. package/dist/wu-done-gates.js +13 -9
  33. package/dist/wu-done-gates.js.map +1 -1
  34. package/dist/wu-edit-operations.js +74 -0
  35. package/dist/wu-edit-operations.js.map +1 -1
  36. package/dist/wu-edit-validators.js +58 -0
  37. package/dist/wu-edit-validators.js.map +1 -1
  38. package/dist/wu-edit.js +106 -4
  39. package/dist/wu-edit.js.map +1 -1
  40. package/dist/wu-prep.js +41 -7
  41. package/dist/wu-prep.js.map +1 -1
  42. package/dist/wu-recover.js +6 -0
  43. package/dist/wu-recover.js.map +1 -1
  44. package/dist/wu-release.js +120 -2
  45. package/dist/wu-release.js.map +1 -1
  46. package/dist/wu-sizing-validation.js +47 -17
  47. package/dist/wu-sizing-validation.js.map +1 -1
  48. package/dist/wu-status.js +33 -0
  49. package/dist/wu-status.js.map +1 -1
  50. package/package.json +13 -11
  51. package/packs/agent-runtime/package.json +1 -1
  52. package/packs/sidekick/package.json +1 -1
  53. package/packs/software-delivery/package.json +1 -1
  54. package/templates/core/AGENTS.md.template +67 -3
  55. package/templates/core/LUMENFLOW.md.template +197 -47
  56. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  57. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  58. package/packs/agent-runtime/capability-factory.ts +0 -104
  59. package/packs/agent-runtime/constants.ts +0 -21
  60. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  61. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  62. package/packs/agent-runtime/delegation-tree.ts +0 -328
  63. package/packs/agent-runtime/index.ts +0 -20
  64. package/packs/agent-runtime/manifest.ts +0 -348
  65. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  66. package/packs/agent-runtime/orchestration.ts +0 -2027
  67. package/packs/agent-runtime/pack-registration.ts +0 -110
  68. package/packs/agent-runtime/policy-factory.ts +0 -165
  69. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  70. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  71. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  72. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  73. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  74. package/packs/agent-runtime/session-schema.ts +0 -467
  75. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  76. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  77. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  78. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  79. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  80. package/packs/agent-runtime/tools/index.ts +0 -4
  81. package/packs/agent-runtime/tools/types.ts +0 -47
  82. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  83. package/packs/agent-runtime/types.ts +0 -128
  84. package/packs/agent-runtime/vitest.config.ts +0 -11
  85. package/packs/sidekick/channel-ingress.ts +0 -137
  86. package/packs/sidekick/constants.ts +0 -10
  87. package/packs/sidekick/index.ts +0 -8
  88. package/packs/sidekick/manifest-schema.ts +0 -49
  89. package/packs/sidekick/manifest.ts +0 -512
  90. package/packs/sidekick/pack-registration.ts +0 -110
  91. package/packs/sidekick/policy-factory.ts +0 -38
  92. package/packs/sidekick/sidekick-events.ts +0 -694
  93. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  94. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  95. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  96. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  97. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  98. package/packs/sidekick/src/routines/commit.ts +0 -74
  99. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  100. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  101. package/packs/sidekick/tool-impl/index.ts +0 -29
  102. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  103. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  104. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  105. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  106. package/packs/sidekick/tool-impl/shared.ts +0 -125
  107. package/packs/sidekick/tool-impl/storage.ts +0 -325
  108. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  109. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  110. package/packs/sidekick/tools/channel-tools.ts +0 -53
  111. package/packs/sidekick/tools/index.ts +0 -9
  112. package/packs/sidekick/tools/memory-tools.ts +0 -53
  113. package/packs/sidekick/tools/routine-tools.ts +0 -53
  114. package/packs/sidekick/tools/system-tools.ts +0 -47
  115. package/packs/sidekick/tools/task-tools.ts +0 -61
  116. package/packs/sidekick/tools/types.ts +0 -57
  117. package/packs/sidekick/vitest.config.ts +0 -11
  118. package/packs/software-delivery/constants.ts +0 -10
  119. package/packs/software-delivery/extensions.ts +0 -140
  120. package/packs/software-delivery/gate-policies.ts +0 -134
  121. package/packs/software-delivery/index.ts +0 -8
  122. package/packs/software-delivery/manifest-schema.ts +0 -268
  123. package/packs/software-delivery/manifest.ts +0 -657
  124. package/packs/software-delivery/pack-registration.ts +0 -113
  125. package/packs/software-delivery/src/commands/index.ts +0 -5
  126. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  127. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  128. package/packs/software-delivery/src/config/index.ts +0 -8
  129. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  130. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  131. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  132. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  133. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  134. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  135. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  136. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  137. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  138. package/packs/software-delivery/src/constants/index.ts +0 -29
  139. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  140. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  141. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  142. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -500
  143. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  144. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  145. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  146. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  147. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  148. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  149. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  150. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  151. package/packs/software-delivery/src/domain/index.ts +0 -5
  152. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  153. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  154. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  155. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  156. package/packs/software-delivery/src/methodology/index.ts +0 -6
  157. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  158. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  159. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  160. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  161. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  162. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  163. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  164. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  165. package/packs/software-delivery/src/policy/index.ts +0 -22
  166. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  167. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  168. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  169. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  170. package/packs/software-delivery/src/ports/index.ts +0 -10
  171. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  172. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  173. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  174. package/packs/software-delivery/src/primitives/index.ts +0 -5
  175. package/packs/software-delivery/src/runtime/index.ts +0 -6
  176. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  177. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  178. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  179. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  180. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  181. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  182. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  183. package/packs/software-delivery/src/schemas/index.ts +0 -5
  184. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  185. package/packs/software-delivery/src/state/index.ts +0 -15
  186. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  187. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  188. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  189. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  190. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  191. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  192. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  193. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  194. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  195. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  196. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  197. package/packs/software-delivery/tool-impl/index.ts +0 -15
  198. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  199. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  200. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  201. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  202. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  203. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  204. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  205. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  206. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  207. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  208. package/packs/software-delivery/tools/git-tools.ts +0 -55
  209. package/packs/software-delivery/tools/index.ts +0 -8
  210. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  211. package/packs/software-delivery/tools/types.ts +0 -71
  212. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  213. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,657 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import {
5
- SOFTWARE_DELIVERY_PACK_ID,
6
- SOFTWARE_DELIVERY_PACK_VERSION,
7
- SOFTWARE_DELIVERY_POLICY_ID_PREFIX,
8
- } from './constants.js';
9
- import {
10
- MANIFEST_POLICY_DECISIONS,
11
- MANIFEST_POLICY_TRIGGERS,
12
- SoftwareDeliveryManifestSchema,
13
- type SoftwareDeliveryManifestTool,
14
- type SoftwareDeliveryPackManifest,
15
- } from './manifest-schema.js';
16
- import {
17
- TOOL_PERMISSIONS as TOOL_PERMISSION_VALUES,
18
- TOOL_SCOPE_ACCESS,
19
- TOOL_SCOPE_TYPES,
20
- type PathScope,
21
- type ToolPermission,
22
- } from './tools/types.js';
23
-
24
- export { SoftwareDeliveryManifestSchema };
25
- export type {
26
- ManifestPolicyDecision,
27
- ManifestPolicyTrigger,
28
- SoftwareDeliveryManifestPolicy,
29
- SoftwareDeliveryManifestTool,
30
- SoftwareDeliveryPackManifest,
31
- } from './manifest-schema.js';
32
-
33
- const FULL_WORKSPACE_SCOPE_PATTERN = '**';
34
- // WU-2833 (INIT-062 WU-G): the canonical read-only workspace scope used by
35
- // validation runners like gates / gates:docs. Exposed so remote callers
36
- // cannot mis-declare a read-only runner with a broader write scope.
37
- export const SOFTWARE_DELIVERY_READ_SCOPE_PATTERN = FULL_WORKSPACE_SCOPE_PATTERN;
38
- /**
39
- * WU-2833 (INIT-062 WU-G): tools whose runtime handlers perform only
40
- * read-side inspection (no filesystem mutation, no git mutation). Any
41
- * attempt to re-declare these tools with permission: write or admin MUST
42
- * fail the pack:validate gate so the security posture established by
43
- * WU-2810/2811/2816 cannot drift without an explicit ADR.
44
- */
45
- export const SOFTWARE_DELIVERY_READ_ONLY_RUNNER_TOOLS = ['gates', 'gates:docs'] as const;
46
- export type SoftwareDeliveryReadOnlyRunnerTool =
47
- (typeof SOFTWARE_DELIVERY_READ_ONLY_RUNNER_TOOLS)[number];
48
- // WU-2833: metrics:snapshot reads the workspace to compute DORA metrics
49
- // but writes the computed snapshot back into workspace state. This narrow
50
- // write scope keeps mobile/cloud tokens for metrics:snapshot from leaking
51
- // full-tree write access (principle of least privilege).
52
- const SOFTWARE_DELIVERY_WORKSPACE_STATE_WRITE_PATTERN = '.lumenflow/state/**';
53
- const SOFTWARE_DELIVERY_WRITE_DIRECTORY_PATTERNS = [
54
- '.changeset/**',
55
- '.claude/**',
56
- '.codex/**',
57
- '.cursor/**',
58
- '.github/**',
59
- '.git/**',
60
- '.husky/**',
61
- '.lumenflow/**',
62
- '.vercel/**',
63
- '.windsurf/**',
64
- 'apps/**',
65
- 'docs/**',
66
- 'packages/**',
67
- 'scripts/**',
68
- 'tools/**',
69
- 'worktrees/**',
70
- ] as const;
71
- const SOFTWARE_DELIVERY_ROOT_WRITE_FILE_PATTERNS = [
72
- '.gitignore',
73
- '.npmrc',
74
- 'LUMENFLOW.md',
75
- 'README.md',
76
- 'package.json',
77
- 'pnpm-lock.yaml',
78
- 'pnpm-workspace.yaml',
79
- 'turbo.json',
80
- 'workspace.yaml',
81
- '*.cjs',
82
- '*.js',
83
- '*.json',
84
- '*.md',
85
- '*.mjs',
86
- '*.sh',
87
- '*.toml',
88
- '*.ts',
89
- '*.tsx',
90
- '*.txt',
91
- '*.yaml',
92
- '*.yml',
93
- ] as const;
94
- const SOFTWARE_DELIVERY_WRITE_SCOPE_PATTERNS = [
95
- ...SOFTWARE_DELIVERY_WRITE_DIRECTORY_PATTERNS,
96
- ...SOFTWARE_DELIVERY_ROOT_WRITE_FILE_PATTERNS,
97
- ] as const;
98
- const GIT_STATUS_TOOL_ENTRY = 'tool-impl/git-tools.ts#gitStatusTool';
99
- const WU_STATUS_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuStatusTool';
100
- const WU_CREATE_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuCreateTool';
101
- const WU_CLAIM_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuClaimTool';
102
- const WU_DONE_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuDoneTool';
103
- const WU_PREP_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuPrepTool';
104
- const WU_PREFLIGHT_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuPreflightTool';
105
- const WU_VALIDATE_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuValidateTool';
106
- const WU_SANDBOX_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuSandboxTool';
107
- const WU_PRUNE_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuPruneTool';
108
- const WU_DELETE_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuDeleteTool';
109
- const WU_CLEANUP_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuCleanupTool';
110
- const WU_UNLOCK_LANE_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuUnlockLaneTool';
111
- const WU_BRIEF_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuBriefTool';
112
- const WU_DELEGATE_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuDelegateTool';
113
- const WU_DEPS_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuDepsTool';
114
- const WU_EDIT_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuEditTool';
115
- const WU_PROTO_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuProtoTool';
116
- const WU_BLOCK_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuBlockTool';
117
- const WU_UNBLOCK_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuUnblockTool';
118
- const WU_RELEASE_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuReleaseTool';
119
- const WU_RECOVER_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuRecoverTool';
120
- const WU_REPAIR_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuRepairTool';
121
- // WU-2833 (INIT-062 WU-G): admin-mode wu:repair wrapper that forces the
122
- // `--admin` flag; exposed as a separate manifest tool so approvals can
123
- // be attached to the privileged surface independently of wu:repair.
124
- const WU_REPAIR_ADMIN_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#wuRepairAdminTool';
125
- const GATES_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#gatesTool';
126
- // WU-2729 (INIT-060 Phase 2): gates:docs exposes docs-only gate runs via a
127
- // dedicated manifest entry so remote callers can request the docs gate
128
- // without opting into the permissive gates handler surface.
129
- const GATES_DOCS_TOOL_ENTRY = 'tool-impl/wu-lifecycle-tools.ts#gatesDocsTool';
130
- const CONFIG_SET_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#configSetTool';
131
- const CONFIG_GET_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#configGetTool';
132
- const MEM_INIT_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memInitTool';
133
- const MEM_START_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memStartTool';
134
- const MEM_READY_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memReadyTool';
135
- const MEM_CHECKPOINT_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memCheckpointTool';
136
- const MEM_CLEANUP_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memCleanupTool';
137
- const MEM_CONTEXT_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memContextTool';
138
- const MEM_CREATE_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memCreateTool';
139
- const MEM_DELETE_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memDeleteTool';
140
- const MEM_EXPORT_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memExportTool';
141
- const MEM_INBOX_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memInboxTool';
142
- const MEM_SIGNAL_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memSignalTool';
143
- const MEM_CONVERGED_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memConvergedTool';
144
- const MEM_SUMMARIZE_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memSummarizeTool';
145
- const MEM_TRIAGE_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memTriageTool';
146
- const MEM_RECOVER_TOOL_ENTRY = 'tool-impl/memory-tools.ts#memRecoverTool';
147
- const AGENT_SESSION_TOOL_ENTRY = 'tool-impl/agent-tools.ts#agentSessionTool';
148
- const AGENT_SESSION_END_TOOL_ENTRY = 'tool-impl/agent-tools.ts#agentSessionEndTool';
149
- const AGENT_LOG_ISSUE_TOOL_ENTRY = 'tool-impl/agent-tools.ts#agentLogIssueTool';
150
- const AGENT_ISSUES_QUERY_TOOL_ENTRY = 'tool-impl/agent-tools.ts#agentIssuesQueryTool';
151
- const FLOW_BOTTLENECKS_TOOL_ENTRY = 'tool-impl/flow-metrics-tools.ts#flowBottlenecksTool';
152
- const FLOW_REPORT_TOOL_ENTRY = 'tool-impl/flow-metrics-tools.ts#flowReportTool';
153
- const METRICS_TOOL_ENTRY = 'tool-impl/flow-metrics-tools.ts#metricsTool';
154
- const METRICS_SNAPSHOT_TOOL_ENTRY = 'tool-impl/flow-metrics-tools.ts#metricsSnapshotTool';
155
- const WU_INFER_LANE_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#wuInferLaneTool';
156
- const LANE_HEALTH_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#laneHealthTool';
157
- const LANE_SUGGEST_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#laneSuggestTool';
158
- const FILE_READ_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#fileReadTool';
159
- const FILE_WRITE_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#fileWriteTool';
160
- const FILE_EDIT_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#fileEditTool';
161
- const FILE_DELETE_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#fileDeleteTool';
162
- const GIT_BRANCH_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#gitBranchTool';
163
- const GIT_DIFF_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#gitDiffTool';
164
- const GIT_LOG_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#gitLogTool';
165
- const STATE_BOOTSTRAP_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#stateBootstrapTool';
166
- const STATE_CLEANUP_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#stateCleanupTool';
167
- const STATE_DOCTOR_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#stateDoctorTool';
168
- const BACKLOG_PRUNE_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#backlogPruneTool';
169
- const SIGNAL_CLEANUP_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#signalCleanupTool';
170
- const LUMENFLOW_METRICS_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#lumenflowMetricsTool';
171
- const VALIDATE_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#validateTool';
172
- const LUMENFLOW_VALIDATE_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#lumenflowValidateTool';
173
- const VALIDATE_AGENT_SKILLS_TOOL_ENTRY =
174
- 'tool-impl/runtime-native-tools.ts#validateAgentSkillsTool';
175
- const VALIDATE_AGENT_SYNC_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#validateAgentSyncTool';
176
- const VALIDATE_BACKLOG_SYNC_TOOL_ENTRY =
177
- 'tool-impl/runtime-native-tools.ts#validateBacklogSyncTool';
178
- const VALIDATE_SKILLS_SPEC_TOOL_ENTRY = 'tool-impl/runtime-native-tools.ts#validateSkillsSpecTool';
179
- const INITIATIVE_ADD_WU_TOOL_ENTRY =
180
- 'tool-impl/initiative-orchestration-tools.ts#initiativeAddWuTool';
181
- const INITIATIVE_BULK_ASSIGN_TOOL_ENTRY =
182
- 'tool-impl/initiative-orchestration-tools.ts#initiativeBulkAssignTool';
183
- const INITIATIVE_CREATE_TOOL_ENTRY =
184
- 'tool-impl/initiative-orchestration-tools.ts#initiativeCreateTool';
185
- const INITIATIVE_EDIT_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#initiativeEditTool';
186
- const INITIATIVE_LIST_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#initiativeListTool';
187
- const INITIATIVE_PLAN_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#initiativePlanTool';
188
- const INITIATIVE_REMOVE_WU_TOOL_ENTRY =
189
- 'tool-impl/initiative-orchestration-tools.ts#initiativeRemoveWuTool';
190
- const INITIATIVE_STATUS_TOOL_ENTRY =
191
- 'tool-impl/initiative-orchestration-tools.ts#initiativeStatusTool';
192
- const ORCHESTRATE_INIT_STATUS_TOOL_ENTRY =
193
- 'tool-impl/initiative-orchestration-tools.ts#orchestrateInitStatusTool';
194
- const ORCHESTRATE_INITIATIVE_TOOL_ENTRY =
195
- 'tool-impl/initiative-orchestration-tools.ts#orchestrateInitiativeTool';
196
- const ORCHESTRATE_MONITOR_TOOL_ENTRY =
197
- 'tool-impl/initiative-orchestration-tools.ts#orchestrateMonitorTool';
198
- const PLAN_CREATE_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#planCreateTool';
199
- const PLAN_EDIT_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#planEditTool';
200
- const PLAN_LINK_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#planLinkTool';
201
- const PLAN_PROMOTE_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#planPromoteTool';
202
- const DELEGATION_LIST_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#delegationListTool';
203
- const CLOUD_CONNECT_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#cloudConnectTool';
204
- const DOCS_SYNC_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#docsSyncTool';
205
- const INIT_PLAN_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#initPlanTool';
206
- const LUMENFLOW_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#lumenflowTool';
207
- const LUMENFLOW_DOCTOR_TOOL_ENTRY =
208
- 'tool-impl/initiative-orchestration-tools.ts#lumenflowDoctorTool';
209
- const LUMENFLOW_INTEGRATE_TOOL_ENTRY =
210
- 'tool-impl/initiative-orchestration-tools.ts#lumenflowIntegrateTool';
211
- const LUMENFLOW_RELEASE_TOOL_ENTRY =
212
- 'tool-impl/initiative-orchestration-tools.ts#lumenflowReleaseTool';
213
- const LUMENFLOW_UPGRADE_TOOL_ENTRY =
214
- 'tool-impl/initiative-orchestration-tools.ts#lumenflowUpgradeTool';
215
- const WORKSPACE_INIT_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#workspaceInitTool';
216
- const SYNC_TEMPLATES_TOOL_ENTRY = 'tool-impl/initiative-orchestration-tools.ts#syncTemplatesTool';
217
-
218
- const TOOL_PERMISSIONS = {
219
- 'wu:block': 'write',
220
- 'wu:brief': 'read',
221
- 'wu:claim': 'write',
222
- 'wu:cleanup': 'write',
223
- 'wu:create': 'write',
224
- 'wu:delegate': 'write',
225
- 'wu:delete': 'write',
226
- 'wu:deps': 'read',
227
- 'wu:done': 'write',
228
- 'wu:edit': 'write',
229
- 'wu:infer-lane': 'read',
230
- 'wu:preflight': 'read',
231
- 'wu:prep': 'write',
232
- 'wu:proto': 'write',
233
- 'wu:prune': 'write',
234
- 'wu:recover': 'write',
235
- 'wu:release': 'write',
236
- 'wu:repair': 'write',
237
- // WU-2833 (INIT-062 WU-G): privileged recovery surface for cloud-team
238
- // phone UX. Distinct tool name so an approval gate + admin permission
239
- // can be declared without widening the scope of the default wu:repair
240
- // implementer tool.
241
- 'wu:repair:admin': 'admin',
242
- 'wu:sandbox': 'write',
243
- 'wu:status': 'read',
244
- 'wu:unblock': 'write',
245
- 'wu:unlock-lane': 'write',
246
- 'wu:validate': 'read',
247
- 'mem:checkpoint': 'write',
248
- 'mem:cleanup': 'write',
249
- 'mem:converged': 'read',
250
- 'mem:context': 'read',
251
- 'mem:create': 'write',
252
- 'mem:delete': 'write',
253
- 'mem:export': 'read',
254
- 'mem:inbox': 'read',
255
- 'mem:init': 'write',
256
- 'mem:ready': 'read',
257
- 'mem:recover': 'write',
258
- 'mem:signal': 'write',
259
- 'mem:start': 'write',
260
- 'mem:summarize': 'read',
261
- 'mem:triage': 'write',
262
- 'initiative:add-wu': 'write',
263
- 'initiative:bulk-assign': 'write',
264
- 'initiative:create': 'write',
265
- 'initiative:edit': 'write',
266
- 'initiative:list': 'read',
267
- 'initiative:plan': 'read',
268
- 'initiative:remove-wu': 'write',
269
- 'initiative:status': 'read',
270
- 'lane:health': 'read',
271
- 'lane:suggest': 'write',
272
- 'flow:bottlenecks': 'read',
273
- 'flow:report': 'read',
274
- // WU-2833 (INIT-062 WU-G): gates and gates:docs are read-only validation
275
- // runners. Mobile/cloud tokens for these tools must not carry workspace
276
- // write access (principle of least privilege; matches the security
277
- // posture established by WU-2810/2811/2816).
278
- gates: 'read',
279
- 'gates:docs': 'read',
280
- 'file:delete': 'write',
281
- 'file:edit': 'write',
282
- 'file:read': 'read',
283
- 'file:write': 'write',
284
- 'git:branch': 'write',
285
- 'git:diff': 'read',
286
- 'git:log': 'read',
287
- 'git:status': 'read',
288
- 'agent:issues-query': 'read',
289
- 'agent:log-issue': 'write',
290
- 'agent:session': 'write',
291
- 'agent:session-end': 'write',
292
- 'orchestrate:init-status': 'read',
293
- 'orchestrate:initiative': 'write',
294
- 'orchestrate:monitor': 'read',
295
- 'state:bootstrap': 'write',
296
- 'state:cleanup': 'write',
297
- 'state:doctor': 'read',
298
- 'plan:create': 'write',
299
- 'plan:edit': 'write',
300
- 'plan:link': 'write',
301
- 'plan:promote': 'write',
302
- 'backlog:prune': 'write',
303
- 'cloud:connect': 'write',
304
- 'config:get': 'read',
305
- 'config:set': 'write',
306
- 'delegation:list': 'read',
307
- 'docs:sync': 'write',
308
- 'init:plan': 'read',
309
- lumenflow: 'write',
310
- 'lumenflow:doctor': 'read',
311
- 'lumenflow:integrate': 'write',
312
- 'lumenflow:release': 'write',
313
- 'lumenflow:upgrade': 'write',
314
- metrics: 'read',
315
- // WU-2833 (INIT-062 WU-G): metrics:snapshot reads the workspace and
316
- // writes a DORA snapshot back into .lumenflow/state/. Permission role
317
- // is "write" because it mutates state; the explicit SCOPE_OVERRIDE
318
- // narrows the write path to .lumenflow/state/** (no full-tree write).
319
- 'metrics:snapshot': 'write',
320
- 'lumenflow:metrics': 'read',
321
- 'signal:cleanup': 'write',
322
- 'sync:templates': 'write',
323
- validate: 'read',
324
- 'lumenflow:validate': 'read',
325
- 'validate:agent-skills': 'read',
326
- 'validate:agent-sync': 'read',
327
- 'validate:backlog-sync': 'read',
328
- 'validate:skills-spec': 'read',
329
- 'workspace:init': 'write',
330
- } as const satisfies Record<string, ToolPermission>;
331
-
332
- type ToolName = keyof typeof TOOL_PERMISSIONS;
333
-
334
- const TOOL_ENTRY_OVERRIDES: Partial<Record<ToolName, string>> = {
335
- 'git:status': GIT_STATUS_TOOL_ENTRY,
336
- 'git:branch': GIT_BRANCH_TOOL_ENTRY,
337
- 'git:diff': GIT_DIFF_TOOL_ENTRY,
338
- 'git:log': GIT_LOG_TOOL_ENTRY,
339
- 'wu:status': WU_STATUS_TOOL_ENTRY,
340
- 'wu:create': WU_CREATE_TOOL_ENTRY,
341
- 'wu:claim': WU_CLAIM_TOOL_ENTRY,
342
- 'wu:done': WU_DONE_TOOL_ENTRY,
343
- 'wu:prep': WU_PREP_TOOL_ENTRY,
344
- 'wu:preflight': WU_PREFLIGHT_TOOL_ENTRY,
345
- 'wu:validate': WU_VALIDATE_TOOL_ENTRY,
346
- 'wu:sandbox': WU_SANDBOX_TOOL_ENTRY,
347
- 'wu:prune': WU_PRUNE_TOOL_ENTRY,
348
- 'wu:delete': WU_DELETE_TOOL_ENTRY,
349
- 'wu:cleanup': WU_CLEANUP_TOOL_ENTRY,
350
- 'wu:unlock-lane': WU_UNLOCK_LANE_TOOL_ENTRY,
351
- 'wu:brief': WU_BRIEF_TOOL_ENTRY,
352
- 'wu:delegate': WU_DELEGATE_TOOL_ENTRY,
353
- 'wu:deps': WU_DEPS_TOOL_ENTRY,
354
- 'wu:edit': WU_EDIT_TOOL_ENTRY,
355
- 'wu:proto': WU_PROTO_TOOL_ENTRY,
356
- 'wu:block': WU_BLOCK_TOOL_ENTRY,
357
- 'wu:unblock': WU_UNBLOCK_TOOL_ENTRY,
358
- 'wu:release': WU_RELEASE_TOOL_ENTRY,
359
- 'wu:recover': WU_RECOVER_TOOL_ENTRY,
360
- 'wu:repair': WU_REPAIR_TOOL_ENTRY,
361
- 'wu:repair:admin': WU_REPAIR_ADMIN_TOOL_ENTRY,
362
- 'wu:infer-lane': WU_INFER_LANE_TOOL_ENTRY,
363
- gates: GATES_TOOL_ENTRY,
364
- 'gates:docs': GATES_DOCS_TOOL_ENTRY,
365
- 'mem:init': MEM_INIT_TOOL_ENTRY,
366
- 'mem:start': MEM_START_TOOL_ENTRY,
367
- 'mem:ready': MEM_READY_TOOL_ENTRY,
368
- 'mem:checkpoint': MEM_CHECKPOINT_TOOL_ENTRY,
369
- 'mem:cleanup': MEM_CLEANUP_TOOL_ENTRY,
370
- 'mem:context': MEM_CONTEXT_TOOL_ENTRY,
371
- 'mem:create': MEM_CREATE_TOOL_ENTRY,
372
- 'mem:delete': MEM_DELETE_TOOL_ENTRY,
373
- 'mem:export': MEM_EXPORT_TOOL_ENTRY,
374
- 'mem:inbox': MEM_INBOX_TOOL_ENTRY,
375
- 'mem:signal': MEM_SIGNAL_TOOL_ENTRY,
376
- 'mem:converged': MEM_CONVERGED_TOOL_ENTRY,
377
- 'mem:summarize': MEM_SUMMARIZE_TOOL_ENTRY,
378
- 'mem:triage': MEM_TRIAGE_TOOL_ENTRY,
379
- 'mem:recover': MEM_RECOVER_TOOL_ENTRY,
380
- 'agent:session': AGENT_SESSION_TOOL_ENTRY,
381
- 'agent:session-end': AGENT_SESSION_END_TOOL_ENTRY,
382
- 'agent:log-issue': AGENT_LOG_ISSUE_TOOL_ENTRY,
383
- 'agent:issues-query': AGENT_ISSUES_QUERY_TOOL_ENTRY,
384
- 'flow:bottlenecks': FLOW_BOTTLENECKS_TOOL_ENTRY,
385
- 'flow:report': FLOW_REPORT_TOOL_ENTRY,
386
- metrics: METRICS_TOOL_ENTRY,
387
- 'metrics:snapshot': METRICS_SNAPSHOT_TOOL_ENTRY,
388
- 'lumenflow:metrics': LUMENFLOW_METRICS_TOOL_ENTRY,
389
- 'lane:health': LANE_HEALTH_TOOL_ENTRY,
390
- 'lane:suggest': LANE_SUGGEST_TOOL_ENTRY,
391
- 'file:read': FILE_READ_TOOL_ENTRY,
392
- 'file:write': FILE_WRITE_TOOL_ENTRY,
393
- 'file:edit': FILE_EDIT_TOOL_ENTRY,
394
- 'file:delete': FILE_DELETE_TOOL_ENTRY,
395
- 'state:bootstrap': STATE_BOOTSTRAP_TOOL_ENTRY,
396
- 'state:cleanup': STATE_CLEANUP_TOOL_ENTRY,
397
- 'state:doctor': STATE_DOCTOR_TOOL_ENTRY,
398
- 'backlog:prune': BACKLOG_PRUNE_TOOL_ENTRY,
399
- 'config:set': CONFIG_SET_TOOL_ENTRY,
400
- 'config:get': CONFIG_GET_TOOL_ENTRY,
401
- 'signal:cleanup': SIGNAL_CLEANUP_TOOL_ENTRY,
402
- validate: VALIDATE_TOOL_ENTRY,
403
- 'lumenflow:validate': LUMENFLOW_VALIDATE_TOOL_ENTRY,
404
- 'validate:agent-skills': VALIDATE_AGENT_SKILLS_TOOL_ENTRY,
405
- 'validate:agent-sync': VALIDATE_AGENT_SYNC_TOOL_ENTRY,
406
- 'validate:backlog-sync': VALIDATE_BACKLOG_SYNC_TOOL_ENTRY,
407
- 'validate:skills-spec': VALIDATE_SKILLS_SPEC_TOOL_ENTRY,
408
- 'initiative:add-wu': INITIATIVE_ADD_WU_TOOL_ENTRY,
409
- 'initiative:bulk-assign': INITIATIVE_BULK_ASSIGN_TOOL_ENTRY,
410
- 'initiative:create': INITIATIVE_CREATE_TOOL_ENTRY,
411
- 'initiative:edit': INITIATIVE_EDIT_TOOL_ENTRY,
412
- 'initiative:list': INITIATIVE_LIST_TOOL_ENTRY,
413
- 'initiative:plan': INITIATIVE_PLAN_TOOL_ENTRY,
414
- 'initiative:remove-wu': INITIATIVE_REMOVE_WU_TOOL_ENTRY,
415
- 'initiative:status': INITIATIVE_STATUS_TOOL_ENTRY,
416
- 'orchestrate:init-status': ORCHESTRATE_INIT_STATUS_TOOL_ENTRY,
417
- 'orchestrate:initiative': ORCHESTRATE_INITIATIVE_TOOL_ENTRY,
418
- 'orchestrate:monitor': ORCHESTRATE_MONITOR_TOOL_ENTRY,
419
- 'plan:create': PLAN_CREATE_TOOL_ENTRY,
420
- 'plan:edit': PLAN_EDIT_TOOL_ENTRY,
421
- 'plan:link': PLAN_LINK_TOOL_ENTRY,
422
- 'plan:promote': PLAN_PROMOTE_TOOL_ENTRY,
423
- 'cloud:connect': CLOUD_CONNECT_TOOL_ENTRY,
424
- 'delegation:list': DELEGATION_LIST_TOOL_ENTRY,
425
- 'docs:sync': DOCS_SYNC_TOOL_ENTRY,
426
- 'init:plan': INIT_PLAN_TOOL_ENTRY,
427
- lumenflow: LUMENFLOW_TOOL_ENTRY,
428
- 'lumenflow:doctor': LUMENFLOW_DOCTOR_TOOL_ENTRY,
429
- 'lumenflow:integrate': LUMENFLOW_INTEGRATE_TOOL_ENTRY,
430
- 'lumenflow:release': LUMENFLOW_RELEASE_TOOL_ENTRY,
431
- 'lumenflow:upgrade': LUMENFLOW_UPGRADE_TOOL_ENTRY,
432
- 'workspace:init': WORKSPACE_INIT_TOOL_ENTRY,
433
- 'sync:templates': SYNC_TEMPLATES_TOOL_ENTRY,
434
- };
435
-
436
- export interface SoftwareDeliveryMigrationScorecard {
437
- declaredTools: number;
438
- pendingRuntimeEntries: number;
439
- realHandlerEntries: number;
440
- }
441
-
442
- function createPathScopes(
443
- patterns: readonly string[],
444
- access: (typeof TOOL_SCOPE_ACCESS)[keyof typeof TOOL_SCOPE_ACCESS],
445
- ): PathScope[] {
446
- return patterns.map((pattern) => ({
447
- type: TOOL_SCOPE_TYPES.PATH,
448
- pattern,
449
- access,
450
- }));
451
- }
452
-
453
- function requiredScopesForPermission(permission: ToolPermission): PathScope[] {
454
- if (permission === TOOL_PERMISSION_VALUES.READ) {
455
- return createPathScopes([FULL_WORKSPACE_SCOPE_PATTERN], TOOL_SCOPE_ACCESS.READ);
456
- }
457
-
458
- // WU-2833: admin permission inherits the same constrained write-scope
459
- // set as write permission. The admin distinction is carried by the
460
- // required_approvals gate, not by broader path access.
461
- return createPathScopes(SOFTWARE_DELIVERY_WRITE_SCOPE_PATTERNS, TOOL_SCOPE_ACCESS.WRITE);
462
- }
463
-
464
- /**
465
- * WU-2833 (INIT-062 WU-G): per-tool scope overrides for tools whose
466
- * runtime semantics do not match the default read/write scope set. Used
467
- * sparingly — only when a tool legitimately needs both read and a narrow
468
- * write scope (or vice versa).
469
- */
470
- const SCOPE_OVERRIDES: Partial<Record<string, PathScope[]>> = {
471
- // metrics:snapshot reads the full workspace to compute DORA metrics,
472
- // then writes the snapshot back into workspace state. The narrow write
473
- // scope prevents mobile/cloud tokens from leaking full-tree write.
474
- 'metrics:snapshot': [
475
- {
476
- type: TOOL_SCOPE_TYPES.PATH,
477
- pattern: FULL_WORKSPACE_SCOPE_PATTERN,
478
- access: TOOL_SCOPE_ACCESS.READ,
479
- },
480
- {
481
- type: TOOL_SCOPE_TYPES.PATH,
482
- pattern: SOFTWARE_DELIVERY_WORKSPACE_STATE_WRITE_PATTERN,
483
- access: TOOL_SCOPE_ACCESS.WRITE,
484
- },
485
- ],
486
- };
487
-
488
- /**
489
- * WU-2729 (INIT-060 Phase 2): the 10 software-delivery pack tools that are
490
- * callable remotely via POST /tools/:name. The HTTP surface uses this list
491
- * to build its allowlist so the set is the single source of truth (no
492
- * duplicate allowlist in surface code). ADR-013 §3 tool exposure.
493
- */
494
- export const REMOTE_CALLABLE_TOOLS = [
495
- 'gates',
496
- 'gates:docs',
497
- 'lane:suggest',
498
- 'lane:health',
499
- 'plan:create',
500
- 'plan:promote',
501
- 'initiative:create',
502
- 'initiative:add-wu',
503
- 'initiative:status',
504
- 'flow:report',
505
- ] as const satisfies readonly ToolName[];
506
-
507
- export type RemoteCallableToolName = (typeof REMOTE_CALLABLE_TOOLS)[number];
508
-
509
- /**
510
- * Well-known approval identifiers the software-delivery pack may request.
511
- * Kept narrow on purpose; adding a new identifier requires an ADR.
512
- */
513
- export const SOFTWARE_DELIVERY_APPROVAL_IDS = {
514
- REMOTE_MUTATION: 'software-delivery:remote_mutation',
515
- } as const;
516
-
517
- /**
518
- * WU-2729 (INIT-060 Phase 2): per-tool required_approvals overrides.
519
- * Tools absent from this table default to `[]` (no approval required).
520
- * Read-only tools MUST remain at `[]`; state-mutating remote-callable
521
- * tools SHOULD request an explicit approval identifier so the conductor
522
- * UI can surface the approval gate to operators.
523
- */
524
- const APPROVAL_OVERRIDES: Partial<Record<ToolName, readonly string[]>> = {
525
- 'lane:suggest': [SOFTWARE_DELIVERY_APPROVAL_IDS.REMOTE_MUTATION],
526
- 'plan:create': [SOFTWARE_DELIVERY_APPROVAL_IDS.REMOTE_MUTATION],
527
- 'plan:promote': [SOFTWARE_DELIVERY_APPROVAL_IDS.REMOTE_MUTATION],
528
- 'initiative:create': [SOFTWARE_DELIVERY_APPROVAL_IDS.REMOTE_MUTATION],
529
- 'initiative:add-wu': [SOFTWARE_DELIVERY_APPROVAL_IDS.REMOTE_MUTATION],
530
- // WU-2833: privileged recovery MUST present an explicit approval gate
531
- // to conductor/phone UX before dispatch. Without this the admin tool
532
- // is indistinguishable from wu:repair from an authorisation standpoint.
533
- 'wu:repair:admin': [SOFTWARE_DELIVERY_APPROVAL_IDS.REMOTE_MUTATION],
534
- };
535
-
536
- function requiredApprovalsForTool(name: ToolName): string[] | undefined {
537
- // WU-2729: the 10 remote-callable tools carry explicit
538
- // required_approvals metadata (even if empty). Other tools leave the
539
- // field undefined so the manifest stays minimally descriptive.
540
- // WU-2833: admin-permission tools also carry explicit approvals so the
541
- // privileged surface cannot be invoked without a visible approval gate.
542
- const isRemoteCallable = (REMOTE_CALLABLE_TOOLS as readonly string[]).includes(name);
543
- const override = APPROVAL_OVERRIDES[name];
544
- if (!isRemoteCallable && override === undefined) {
545
- return undefined;
546
- }
547
- return override ? [...override] : [];
548
- }
549
-
550
- /**
551
- * WU-2729: ordered list of the 10 remote-callable tool names. Preserves
552
- * declaration order from REMOTE_CALLABLE_TOOLS so callers can render
553
- * stable UIs without re-sorting.
554
- */
555
- export function getRemoteCallableToolNames(): RemoteCallableToolName[] {
556
- return [...REMOTE_CALLABLE_TOOLS];
557
- }
558
-
559
- function createManifestTools(): SoftwareDeliveryManifestTool[] {
560
- return (Object.keys(TOOL_PERMISSIONS) as ToolName[]).map((name) => {
561
- const permission = TOOL_PERMISSIONS[name];
562
- const approvals = requiredApprovalsForTool(name);
563
- // WU-2833: per-tool scope overrides take priority over the default
564
- // permission-derived scope set so read-plus-narrow-write tools like
565
- // metrics:snapshot can declare both accesses on a single entry.
566
- const scopeOverride = SCOPE_OVERRIDES[name];
567
- const entry: SoftwareDeliveryManifestTool = {
568
- name,
569
- entry: resolveToolEntry(name),
570
- permission,
571
- required_scopes: scopeOverride ? [...scopeOverride] : requiredScopesForPermission(permission),
572
- };
573
- if (approvals !== undefined) {
574
- entry.required_approvals = approvals;
575
- }
576
- return entry;
577
- });
578
- }
579
-
580
- function resolveToolEntry(name: ToolName): string {
581
- const entry = TOOL_ENTRY_OVERRIDES[name];
582
- if (!entry) {
583
- throw new Error(`Missing runtime-native tool entry mapping for "${name}"`);
584
- }
585
- return entry;
586
- }
587
-
588
- export function getSoftwareDeliveryMigrationScorecard(
589
- manifest: SoftwareDeliveryPackManifest = SOFTWARE_DELIVERY_MANIFEST,
590
- ): SoftwareDeliveryMigrationScorecard {
591
- const declaredTools = manifest.tools.length;
592
- const pendingRuntimeEntries = 0;
593
- return {
594
- declaredTools,
595
- pendingRuntimeEntries,
596
- realHandlerEntries: declaredTools - pendingRuntimeEntries,
597
- };
598
- }
599
-
600
- export function renderSoftwareDeliveryMigrationScorecard(
601
- manifest: SoftwareDeliveryPackManifest = SOFTWARE_DELIVERY_MANIFEST,
602
- ): string {
603
- return JSON.stringify(getSoftwareDeliveryMigrationScorecard(manifest));
604
- }
605
-
606
- const POLICY_SUFFIXES = ['format', 'lint', 'typecheck', 'test', 'coverage'] as const;
607
- const SOFTWARE_DELIVERY_EMITTED_EVENT_KINDS = [
608
- 'software-delivery:gate_started',
609
- 'software-delivery:gate_passed',
610
- 'software-delivery:gate_failed',
611
- 'software-delivery:co_change_rule_fired',
612
- 'software-delivery:conditional_command_fired',
613
- 'software-delivery:lane_wip_breached',
614
- 'software-delivery:lane_locked',
615
- 'software-delivery:lane_unlocked',
616
- 'software-delivery:lane_suggestion_emitted',
617
- 'software-delivery:initiative_created',
618
- 'software-delivery:initiative_closed',
619
- 'software-delivery:initiative_phase_advanced',
620
- 'software-delivery:plan_created',
621
- 'software-delivery:plan_linked',
622
- 'software-delivery:plan_promoted',
623
- // WU-2832 (INIT-062 WU-F): close the cloud-team polling gap with 9
624
- // additional ephemeral kinds. Validation pair (validated/invalid),
625
- // recovery, preflight, escalation, ratchet, bottleneck, DORA snapshot,
626
- // and replay-artifact addressable by event_id.
627
- 'software-delivery:wu_spec_validated',
628
- 'software-delivery:wu_spec_invalid',
629
- 'software-delivery:wu_recovered',
630
- 'software-delivery:wu_preflight_failed',
631
- 'software-delivery:wu_escalation_resolved',
632
- 'software-delivery:test_ratchet_adjusted',
633
- 'software-delivery:flow_bottleneck_detected',
634
- 'software-delivery:dora_metric_snapshot',
635
- 'software-delivery:replay_artifact_published',
636
- ] as const;
637
- const SOFTWARE_DELIVERY_REQUIRED_SURFACES = ['http'] as const;
638
-
639
- export const SOFTWARE_DELIVERY_MANIFEST: SoftwareDeliveryPackManifest = {
640
- id: SOFTWARE_DELIVERY_PACK_ID,
641
- version: SOFTWARE_DELIVERY_PACK_VERSION,
642
- config_key: 'software_delivery',
643
- task_types: ['work-unit'],
644
- tools: createManifestTools(),
645
- policies: POLICY_SUFFIXES.map((suffix) => ({
646
- id: `${SOFTWARE_DELIVERY_POLICY_ID_PREFIX}.${suffix}`,
647
- trigger: MANIFEST_POLICY_TRIGGERS.ON_COMPLETION,
648
- decision: MANIFEST_POLICY_DECISIONS.ALLOW,
649
- })),
650
- evidence_types: ['gate-run'],
651
- state_aliases: { active: 'in_progress' },
652
- lane_templates: [],
653
- emitted_event_kinds: [...SOFTWARE_DELIVERY_EMITTED_EVENT_KINDS],
654
- subscribed_event_kinds: [],
655
- required_approvals: [],
656
- surfaces_required: [...SOFTWARE_DELIVERY_REQUIRED_SURFACES],
657
- };