@quantiya/codevibe-core 2.0.1 → 2.0.2

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 (282) hide show
  1. package/dist/__tests__/prompt-parser.test.d.ts +1 -0
  2. package/dist/adapter/registry.d.ts +69 -2
  3. package/dist/appsync/__tests__/appsync-client-event-source-filter.test.d.ts +1 -0
  4. package/dist/appsync/__tests__/appsync-client-task-group.test.d.ts +1 -0
  5. package/dist/appsync/__tests__/cleanup-subscription.test.d.ts +1 -0
  6. package/dist/appsync/__tests__/coerce-awsjson-and-review-summary.test.d.ts +1 -0
  7. package/dist/appsync/__tests__/cp1f-quorum-sdk.test.d.ts +1 -0
  8. package/dist/appsync/__tests__/event-throttle.test.d.ts +1 -0
  9. package/dist/appsync/appsync-client.d.ts +621 -10
  10. package/dist/appsync/event-throttle.d.ts +28 -0
  11. package/dist/appsync/index.d.ts +3 -0
  12. package/dist/appsync/queries.d.ts +19 -0
  13. package/dist/audit-keys/index.d.ts +32 -0
  14. package/dist/auth/auth-service.d.ts +32 -2
  15. package/dist/auth/auth-telemetry.d.ts +19 -1
  16. package/dist/auth/index.d.ts +1 -0
  17. package/dist/companion-mode/persist-preference.d.ts +1 -1
  18. package/dist/config/config.d.ts +8 -1
  19. package/dist/continuation/__tests__/dirty-state-collector.test.d.ts +1 -0
  20. package/dist/continuation/__tests__/integration.test.d.ts +1 -0
  21. package/dist/continuation/__tests__/packet-reader.test.d.ts +1 -0
  22. package/dist/continuation/__tests__/packet-writer.test.d.ts +1 -0
  23. package/dist/continuation/__tests__/parity.test.d.ts +1 -0
  24. package/dist/continuation/__tests__/status-cli.test.d.ts +1 -0
  25. package/dist/continuation/dirty-state-collector.d.ts +46 -0
  26. package/dist/continuation/index.d.ts +8 -0
  27. package/dist/continuation/packet-reader.d.ts +33 -0
  28. package/dist/continuation/packet-writer.d.ts +86 -0
  29. package/dist/continuation/types.d.ts +239 -0
  30. package/dist/credential-broker/__tests__/broker.test.d.ts +1 -0
  31. package/dist/credential-broker/__tests__/canonical.test.d.ts +1 -0
  32. package/dist/credential-broker/__tests__/scrubber.test.d.ts +1 -0
  33. package/dist/credential-broker/__tests__/upstream-client.test.d.ts +1 -0
  34. package/dist/credential-broker/__tests__/vendor-key-store.test.d.ts +1 -0
  35. package/dist/credential-broker/audit-sink.d.ts +69 -0
  36. package/dist/credential-broker/broker-config.d.ts +39 -0
  37. package/dist/credential-broker/broker-token.d.ts +123 -0
  38. package/dist/credential-broker/broker.d.ts +165 -0
  39. package/dist/credential-broker/canonical.d.ts +119 -0
  40. package/dist/credential-broker/index.d.ts +15 -0
  41. package/dist/credential-broker/scrubber.d.ts +45 -0
  42. package/dist/credential-broker/types.d.ts +141 -0
  43. package/dist/credential-broker/upstream-client.d.ts +20 -0
  44. package/dist/credential-broker/vendor-key-store.d.ts +54 -0
  45. package/dist/index.d.ts +6 -1
  46. package/dist/index.js +427 -124
  47. package/dist/keychain/__tests__/keychain-backend.test.d.ts +1 -0
  48. package/dist/keychain/keychain-backend.d.ts +82 -0
  49. package/dist/local-executor/__tests__/agentic-disposable-repo.test.d.ts +1 -0
  50. package/dist/local-executor/__tests__/agentic-resolve.test.d.ts +1 -0
  51. package/dist/local-executor/__tests__/agentic-resolver-flag.test.d.ts +1 -0
  52. package/dist/local-executor/__tests__/class-a-sign.test.d.ts +1 -0
  53. package/dist/local-executor/__tests__/class1-reconcilers.test.d.ts +1 -0
  54. package/dist/local-executor/__tests__/class2-resolver.test.d.ts +1 -0
  55. package/dist/local-executor/__tests__/confined-model-caller.test.d.ts +1 -0
  56. package/dist/local-executor/__tests__/conflict-classifier.test.d.ts +1 -0
  57. package/dist/local-executor/__tests__/conflict-resolution-durable-store.test.d.ts +1 -0
  58. package/dist/local-executor/__tests__/conflict-resolution-store.test.d.ts +1 -0
  59. package/dist/local-executor/__tests__/cp1f-quorum-consumer.test.d.ts +1 -0
  60. package/dist/local-executor/__tests__/cp7-audit-writer.test.d.ts +1 -0
  61. package/dist/local-executor/__tests__/durable-store.test.d.ts +1 -0
  62. package/dist/local-executor/__tests__/git-lock-retry.test.d.ts +1 -0
  63. package/dist/local-executor/__tests__/implementor-argv.test.d.ts +1 -0
  64. package/dist/local-executor/__tests__/local-executor-teams.test.d.ts +1 -0
  65. package/dist/local-executor/__tests__/merge-conflict-extract.test.d.ts +1 -0
  66. package/dist/local-executor/__tests__/merge-conflict-git.integration.test.d.ts +1 -0
  67. package/dist/local-executor/__tests__/merge-conflict-resolve-agentic.integration.test.d.ts +1 -0
  68. package/dist/local-executor/__tests__/merge-conflict-resolve.integration.test.d.ts +1 -0
  69. package/dist/local-executor/__tests__/merge-journal-store.test.d.ts +1 -0
  70. package/dist/local-executor/__tests__/merge-train-agentic-recovery.integration.test.d.ts +1 -0
  71. package/dist/local-executor/__tests__/merge-train-w3.integration.test.d.ts +1 -0
  72. package/dist/local-executor/__tests__/merge-train-waveb.integration.test.d.ts +1 -0
  73. package/dist/local-executor/__tests__/merge-train.test.d.ts +1 -0
  74. package/dist/local-executor/__tests__/promote-wal-store.test.d.ts +1 -0
  75. package/dist/local-executor/__tests__/revert-reconcile.test.d.ts +1 -0
  76. package/dist/local-executor/__tests__/revert-runner.test.d.ts +1 -0
  77. package/dist/local-executor/__tests__/shared-contract-detector.test.d.ts +1 -0
  78. package/dist/local-executor/__tests__/substrate-engage.test.d.ts +1 -0
  79. package/dist/local-executor/__tests__/team-execution-flag.test.d.ts +1 -0
  80. package/dist/local-executor/__tests__/track-registry.test.d.ts +1 -0
  81. package/dist/local-executor/__tests__/wb2-review-bundle.test.d.ts +1 -0
  82. package/dist/local-executor/__tests__/wb2-substrate-spawn.live.test.d.ts +1 -0
  83. package/dist/local-executor/__tests__/workspace-shadow.test.d.ts +1 -0
  84. package/dist/local-executor/__tests__/worktree-merge.test.d.ts +1 -0
  85. package/dist/local-executor/agentic-disposable-repo.d.ts +52 -0
  86. package/dist/local-executor/agentic-resolve.d.ts +54 -0
  87. package/dist/local-executor/agentic-resolver-flag.d.ts +9 -0
  88. package/dist/local-executor/authority.d.ts +33 -1
  89. package/dist/local-executor/class-a-emit.d.ts +3 -1
  90. package/dist/local-executor/class-a-sign.d.ts +57 -0
  91. package/dist/local-executor/class-b-consumer.d.ts +159 -4
  92. package/dist/local-executor/class-b-verify.d.ts +30 -0
  93. package/dist/local-executor/class1-reconcilers.d.ts +58 -0
  94. package/dist/local-executor/class2-resolver.d.ts +74 -0
  95. package/dist/local-executor/confined-model-caller.d.ts +39 -0
  96. package/dist/local-executor/conflict-classifier.d.ts +21 -0
  97. package/dist/local-executor/conflict-resolution-durable-store.d.ts +61 -0
  98. package/dist/local-executor/conflict-resolution-store.d.ts +210 -0
  99. package/dist/local-executor/conflict-types.d.ts +86 -0
  100. package/dist/local-executor/cp7-audit-writer.d.ts +152 -0
  101. package/dist/local-executor/durable-store.d.ts +334 -0
  102. package/dist/local-executor/git-lock-retry.d.ts +40 -0
  103. package/dist/local-executor/hook-bridge.d.ts +1 -1
  104. package/dist/local-executor/implementor-argv.d.ts +183 -0
  105. package/dist/local-executor/index.d.ts +44 -3
  106. package/dist/local-executor/local-executor-impl.d.ts +645 -4
  107. package/dist/local-executor/merge-conflict-extract.d.ts +34 -0
  108. package/dist/local-executor/merge-conflict-resolve.d.ts +101 -0
  109. package/dist/local-executor/merge-journal-store.d.ts +311 -0
  110. package/dist/local-executor/merge-train.d.ts +713 -0
  111. package/dist/local-executor/promote-wal-store.d.ts +301 -0
  112. package/dist/local-executor/resolution-set-index.d.ts +51 -0
  113. package/dist/local-executor/revert-reconcile.d.ts +89 -0
  114. package/dist/local-executor/revert-runner.d.ts +17 -0
  115. package/dist/local-executor/shared-contract-detector.d.ts +57 -0
  116. package/dist/local-executor/spawn.d.ts +29 -1
  117. package/dist/local-executor/task-group-types.d.ts +346 -0
  118. package/dist/local-executor/team-execution-flag.d.ts +21 -0
  119. package/dist/local-executor/track-registry.d.ts +50 -0
  120. package/dist/local-executor/types.d.ts +238 -4
  121. package/dist/local-executor/wb2-review-bundle.d.ts +59 -0
  122. package/dist/local-executor/workspace-shadow.d.ts +290 -0
  123. package/dist/local-executor/worktree-merge.d.ts +601 -0
  124. package/dist/local-model/__tests__/installer.test.d.ts +1 -0
  125. package/dist/local-model/__tests__/manager.test.d.ts +1 -0
  126. package/dist/local-model/__tests__/ollama.test.d.ts +1 -0
  127. package/dist/local-model/__tests__/runtime.test.d.ts +1 -0
  128. package/dist/local-model/__tests__/state.test.d.ts +1 -0
  129. package/dist/local-model/manager.d.ts +119 -0
  130. package/dist/local-model/ollama.d.ts +27 -0
  131. package/dist/local-model/runtime.d.ts +27 -0
  132. package/dist/local-model/state.d.ts +32 -0
  133. package/dist/orchestration/detect-agents.d.ts +15 -2
  134. package/dist/orchestration/setup-types.d.ts +2 -1
  135. package/dist/orchestration-shell/__tests__/attachments.test.d.ts +1 -0
  136. package/dist/orchestration-shell/__tests__/audit-browser.test.d.ts +1 -0
  137. package/dist/orchestration-shell/__tests__/audited-path-fixes.test.d.ts +1 -0
  138. package/dist/orchestration-shell/__tests__/bracketed-paste.test.d.ts +1 -0
  139. package/dist/orchestration-shell/__tests__/cli-group-halt-wiring.test.d.ts +1 -0
  140. package/dist/orchestration-shell/__tests__/cli-orchestration-session-bootstrap.test.d.ts +1 -0
  141. package/dist/orchestration-shell/__tests__/cli-probe-group-status.test.d.ts +1 -0
  142. package/dist/orchestration-shell/__tests__/cli-quorum-loop-tier.test.d.ts +1 -0
  143. package/dist/orchestration-shell/__tests__/cli-verdict-classifier-wiring.test.d.ts +1 -0
  144. package/dist/orchestration-shell/__tests__/context-store.test.d.ts +1 -0
  145. package/dist/orchestration-shell/__tests__/cp10-585-accept-echo-target.test.d.ts +1 -0
  146. package/dist/orchestration-shell/__tests__/cp10-585-loop.test.d.ts +1 -0
  147. package/dist/orchestration-shell/__tests__/cp10-585-prompts.test.d.ts +1 -0
  148. package/dist/orchestration-shell/__tests__/cp12-w2b-team-loop.test.d.ts +1 -0
  149. package/dist/orchestration-shell/__tests__/cp12-w4-team-recovery.test.d.ts +1 -0
  150. package/dist/orchestration-shell/__tests__/cp1f-quorum-loop.test.d.ts +1 -0
  151. package/dist/orchestration-shell/__tests__/cp606-team-track-user-resolved.test.d.ts +1 -0
  152. package/dist/orchestration-shell/__tests__/cp7-reviewer-substrate.test.d.ts +1 -0
  153. package/dist/orchestration-shell/__tests__/declared-test-runner.test.d.ts +1 -0
  154. package/dist/orchestration-shell/__tests__/familiarize-routing.test.d.ts +1 -0
  155. package/dist/orchestration-shell/__tests__/gate-decision-submit.test.d.ts +1 -0
  156. package/dist/orchestration-shell/__tests__/gate-details-panel.test.d.ts +1 -0
  157. package/dist/orchestration-shell/__tests__/gate-verdict-details-dispatch.test.d.ts +1 -0
  158. package/dist/orchestration-shell/__tests__/group-decision-submit.test.d.ts +1 -0
  159. package/dist/orchestration-shell/__tests__/image-attach-e2e.test.d.ts +1 -0
  160. package/dist/orchestration-shell/__tests__/input-bar-autocomplete.test.d.ts +1 -0
  161. package/dist/orchestration-shell/__tests__/live-region-cap.test.d.ts +1 -0
  162. package/dist/orchestration-shell/__tests__/live-static-order.test.d.ts +1 -0
  163. package/dist/orchestration-shell/__tests__/model-cli.test.d.ts +1 -0
  164. package/dist/orchestration-shell/__tests__/non-gate-prompt-routing.test.d.ts +1 -0
  165. package/dist/orchestration-shell/__tests__/orchestration-app-group-decision-transport.test.d.ts +1 -0
  166. package/dist/orchestration-shell/__tests__/orchestration-app-layout.test.d.ts +1 -0
  167. package/dist/orchestration-shell/__tests__/reissue-team-retained-spec.test.d.ts +1 -0
  168. package/dist/orchestration-shell/__tests__/review-summary-render.test.d.ts +1 -0
  169. package/dist/orchestration-shell/__tests__/reviewer-wizard.test.d.ts +1 -0
  170. package/dist/orchestration-shell/__tests__/reviewers-format.test.d.ts +1 -0
  171. package/dist/orchestration-shell/__tests__/root-discovery.test.d.ts +1 -0
  172. package/dist/orchestration-shell/__tests__/serialize-submissions.test.d.ts +1 -0
  173. package/dist/orchestration-shell/__tests__/slash-suggest.test.d.ts +1 -0
  174. package/dist/orchestration-shell/__tests__/status-format.test.d.ts +1 -0
  175. package/dist/orchestration-shell/__tests__/task-progress.test.d.ts +1 -0
  176. package/dist/orchestration-shell/__tests__/team-decompose-routing.test.d.ts +1 -0
  177. package/dist/orchestration-shell/__tests__/team-decompose-types.test.d.ts +1 -0
  178. package/dist/orchestration-shell/__tests__/team-decompose.test.d.ts +1 -0
  179. package/dist/orchestration-shell/__tests__/team-e2e-smoke.test.d.ts +1 -0
  180. package/dist/orchestration-shell/__tests__/tier2-reviewer-selection.test.d.ts +1 -0
  181. package/dist/orchestration-shell/__tests__/web-browsing.test.d.ts +1 -0
  182. package/dist/orchestration-shell/attachments.d.ts +152 -0
  183. package/dist/orchestration-shell/audit-browser.d.ts +115 -0
  184. package/dist/orchestration-shell/audit-runner.d.ts +59 -0
  185. package/dist/orchestration-shell/bracketed-paste.d.ts +26 -0
  186. package/dist/orchestration-shell/cli.d.ts +336 -1
  187. package/dist/orchestration-shell/cli.js +39318 -3436
  188. package/dist/orchestration-shell/components/AuditLogPanel.d.ts +11 -0
  189. package/dist/orchestration-shell/components/ConversationPane.d.ts +7 -1
  190. package/dist/orchestration-shell/components/GateDetailsPanel.d.ts +57 -0
  191. package/dist/orchestration-shell/components/GatePanelEntry.d.ts +9 -0
  192. package/dist/orchestration-shell/components/GatePromptEntry.d.ts +7 -0
  193. package/dist/orchestration-shell/components/InputBar.d.ts +17 -3
  194. package/dist/orchestration-shell/components/LiveProgressLine.d.ts +8 -0
  195. package/dist/orchestration-shell/components/MultiTrackStatusNode.d.ts +8 -0
  196. package/dist/orchestration-shell/components/OrchestrationApp.d.ts +81 -15
  197. package/dist/orchestration-shell/components/ReviewerSetupWizard.d.ts +24 -0
  198. package/dist/orchestration-shell/components/StatusBar.d.ts +15 -2
  199. package/dist/orchestration-shell/context-store.d.ts +389 -0
  200. package/dist/orchestration-shell/declared-test-runner.d.ts +84 -0
  201. package/dist/orchestration-shell/emit-shell-event.d.ts +1 -1
  202. package/dist/orchestration-shell/gate-decision-submit.d.ts +245 -0
  203. package/dist/orchestration-shell/gate-prompts.d.ts +361 -3
  204. package/dist/orchestration-shell/index.d.ts +613 -1
  205. package/dist/orchestration-shell/ink-runtime.d.ts +21 -1
  206. package/dist/orchestration-shell/live-region-cap.d.ts +70 -0
  207. package/dist/orchestration-shell/live-static-order.d.ts +22 -0
  208. package/dist/orchestration-shell/non-tty-fallback.d.ts +21 -0
  209. package/dist/orchestration-shell/quorum-loop.d.ts +1900 -0
  210. package/dist/orchestration-shell/root-discovery.d.ts +25 -0
  211. package/dist/orchestration-shell/route-browse.d.ts +20 -0
  212. package/dist/orchestration-shell/slash-router.d.ts +20 -1
  213. package/dist/orchestration-shell/slash-routes/continuation.d.ts +71 -0
  214. package/dist/orchestration-shell/slash-routes/reviewers.d.ts +41 -0
  215. package/dist/orchestration-shell/slash-suggest.d.ts +29 -0
  216. package/dist/orchestration-shell/status-format.d.ts +59 -0
  217. package/dist/orchestration-shell/task-progress.d.ts +122 -0
  218. package/dist/orchestration-shell/team-decompose.d.ts +196 -0
  219. package/dist/orchestration-shell/types.d.ts +363 -3
  220. package/dist/orchestration-shell/vendor/ink-parse-keypress.d.ts +42 -0
  221. package/dist/orchestration-shell/web/extract.d.ts +11 -0
  222. package/dist/orchestration-shell/web/fetch.d.ts +15 -0
  223. package/dist/orchestration-shell/web/ip.d.ts +26 -0
  224. package/dist/orchestration-shell/web/sanitize.d.ts +14 -0
  225. package/dist/orchestration-shell/web/search.d.ts +16 -0
  226. package/dist/planner/__tests__/local-gemma.test.d.ts +1 -0
  227. package/dist/planner/index.d.ts +2 -0
  228. package/dist/planner/local-advisory.d.ts +84 -0
  229. package/dist/planner/local-gemma.d.ts +23 -0
  230. package/dist/planner/types.d.ts +16 -6
  231. package/dist/reviewer/__tests__/antigravity-provider.test.d.ts +1 -0
  232. package/dist/reviewer/__tests__/claude-provider-json.test.d.ts +1 -0
  233. package/dist/reviewer/__tests__/cp7-reviewer-sandbox.test.d.ts +1 -0
  234. package/dist/reviewer/__tests__/output-parser-classifier-helpers.test.d.ts +1 -0
  235. package/dist/reviewer/__tests__/verdict-classifier.test.d.ts +1 -0
  236. package/dist/reviewer/index.d.ts +2 -0
  237. package/dist/reviewer/output-parser.d.ts +48 -12
  238. package/dist/reviewer/provider.d.ts +107 -3
  239. package/dist/reviewer/providers/__tests__/failure-classifier.test.d.ts +1 -0
  240. package/dist/reviewer/providers/antigravity.d.ts +49 -0
  241. package/dist/reviewer/providers/claude.d.ts +19 -4
  242. package/dist/reviewer/providers/codex.d.ts +47 -5
  243. package/dist/reviewer/providers/failure-classifier.d.ts +26 -0
  244. package/dist/reviewer/providers/gemini.d.ts +5 -4
  245. package/dist/reviewer/registry.d.ts +5 -5
  246. package/dist/reviewer/subprocess.d.ts +37 -0
  247. package/dist/reviewer/token-usage.d.ts +32 -0
  248. package/dist/reviewer/types.d.ts +5 -5
  249. package/dist/reviewer/verdict-classifier.d.ts +62 -0
  250. package/dist/session/__tests__/prepare-event-timestamp.test.d.ts +1 -0
  251. package/dist/session/index.d.ts +1 -0
  252. package/dist/session/prepare-event-timestamp.d.ts +30 -0
  253. package/dist/substrate/__tests__/docker.test.d.ts +1 -0
  254. package/dist/substrate/__tests__/forwarder.test.d.ts +1 -0
  255. package/dist/substrate/__tests__/git-proxy.test.d.ts +1 -0
  256. package/dist/substrate/__tests__/sandbox-exec.test.d.ts +1 -0
  257. package/dist/substrate/__tests__/substrate-e2e.integration.test.d.ts +1 -0
  258. package/dist/substrate/command-runner.d.ts +19 -0
  259. package/dist/substrate/docker.d.ts +134 -0
  260. package/dist/substrate/errors.d.ts +33 -0
  261. package/dist/substrate/forwarder.d.ts +67 -0
  262. package/dist/substrate/git-proxy.d.ts +35 -0
  263. package/dist/substrate/index.d.ts +12 -0
  264. package/dist/substrate/relay-script.d.ts +27 -0
  265. package/dist/substrate/sandbox-exec.d.ts +116 -0
  266. package/dist/substrate/types.d.ts +218 -0
  267. package/dist/substrate-launch/__tests__/apikey-bootstrap.test.d.ts +1 -0
  268. package/dist/substrate-launch/__tests__/creditless-loop.integration.test.d.ts +1 -0
  269. package/dist/substrate-launch/__tests__/engage-substrate.test.d.ts +1 -0
  270. package/dist/substrate-launch/__tests__/fallback-ladder.test.d.ts +1 -0
  271. package/dist/substrate-launch/__tests__/le-env-scrub.test.d.ts +1 -0
  272. package/dist/substrate-launch/__tests__/sanitized-env.test.d.ts +1 -0
  273. package/dist/substrate-launch/apikey-bootstrap.d.ts +84 -0
  274. package/dist/substrate-launch/engage-substrate.d.ts +102 -0
  275. package/dist/substrate-launch/fallback-ladder.d.ts +49 -0
  276. package/dist/substrate-launch/index.d.ts +12 -0
  277. package/dist/substrate-launch/le-env-scrub.d.ts +77 -0
  278. package/dist/substrate-launch/sanitized-env.d.ts +73 -0
  279. package/dist/types/auth.d.ts +6 -1
  280. package/dist/types/events.d.ts +3 -1
  281. package/dist/types/reviewer.d.ts +6 -6
  282. package/package.json +7 -3
@@ -1,7 +1,100 @@
1
+ import type { SubstrateHandle } from '../substrate/types';
1
2
  import { AuthorityScope } from './authority';
2
- import { ClassAEmitter, ClassAEmitterContext, ClassASink } from './class-a-emit';
3
+ import { ClassAEmitter, ClassAEmitterContext, ClassASink, VerificationGateKind } from './class-a-emit';
4
+ import { type DeviceSigningKey } from './class-a-sign';
3
5
  import { EmitShellEventFn } from './hook-bridge';
4
- import { AgentKind, AuthorityAction, ClassBInbound, HookEvent, ImplementorHandle, LocalExecutor, ProbeHandle, ReviewerHandle, SpawnArgs } from './types';
6
+ import { MergeResult, SubmitMergeGateVerdictInput } from './task-group-types';
7
+ import { TrackRegistry } from './track-registry';
8
+ import { AgentKind, AuthorityAction, ClassBInbound, GateDispatchPayload, HookEvent, ImplementorHandle, LocalExecutor, MergeGateDispatchPayload, ProbeHandle, ProcessRole, ReviewerDispatchPayload, ReviseFeedbackPayload, ReviewerHandle, SpawnArgs, TrackAssignedPayload } from './types';
9
+ import { type TeamExecution } from './team-execution-flag';
10
+ import type { RenderedConflict, TrackIntentDiff } from './wb2-review-bundle';
11
+ import type { ConflictModelCaller } from './class2-resolver';
12
+ import type { ConflictResolverContext } from './merge-conflict-resolve';
13
+ import { type ContentCipher } from './conflict-resolution-durable-store';
14
+ import type { TrackTipsView } from './durable-store';
15
+ /**
16
+ * CP-7 W2 Stage-2 HIGH (Finding 2) — STRICT delivery sink for the
17
+ * `tier:'none'` (moat-OFF) reduced-trust badge.
18
+ *
19
+ * The ordinary `emitShellEvent` chokepoint RESOLVES WITHOUT EMITTING when the
20
+ * cohort flag is off, the session is a `cp1a-local-*` stub, or no session key
21
+ * exists (see `emit-shell-event.ts`); the team store tap likewise ignores the
22
+ * `cp7_reduced_trust` notification. A `tier:'none'` badge routed through it can
23
+ * therefore "succeed" (await resolves) while the user sees NOTHING — and the
24
+ * legacy unsandboxed spawn would proceed on only a WARN.
25
+ *
26
+ * A `StrictBadgeSink` MUST instead CONFIRM that the user-facing NOTIFICATION was
27
+ * ACTUALLY delivered (e.g. `createEvent` was invoked) and THROW when it cannot
28
+ * deliver (cohort off / no session / stub / tap-ignored). For `tier:'none'` a
29
+ * throw → FAIL CLOSED (no legacy spawn). It is INTENTIONALLY separate from the
30
+ * audit emit: audit emission stays on the existing Class-A / shell-event path;
31
+ * this sink is ONLY the user-facing moat-OFF warning.
32
+ *
33
+ * Resolves on a confirmed delivery; REJECTS on a silent no-op / undeliverable.
34
+ */
35
+ export type StrictBadgeSink = (badge: {
36
+ sessionId: string;
37
+ content: string;
38
+ metadata: Record<string, unknown>;
39
+ }) => Promise<void>;
40
+ /**
41
+ * CP-12 W2.b — the narrow AppSync surface the MergeGate runner consumes (W2.a
42
+ * `submitMergeGateVerdict`). Declared structurally (NOT importing the concrete
43
+ * `AppSyncClient`) so the LE module stays decoupled and the test surface can
44
+ * inject a mock without constructing the full GraphQL client.
45
+ */
46
+ export interface MergeGateAppSyncClient {
47
+ submitMergeGateVerdict(input: SubmitMergeGateVerdictInput): Promise<{
48
+ outcome: string;
49
+ }>;
50
+ }
51
+ /**
52
+ * CP-12 W2.b — the narrow crypto surface for E2E-encrypting the
53
+ * `submitMergeGateVerdict.detail` payload under the ONE team session key (§0.2 /
54
+ * §6). Matches `cryptoService.encryptContent(content, sessionKeyBase64)` (the
55
+ * SAME path the LE already uses for gate content), but injected structurally so
56
+ * the runner has no hard dependency on the singleton.
57
+ */
58
+ export interface MergeGateContentEncryptor {
59
+ encryptContent(content: string, sessionKeyBase64: string): string;
60
+ }
61
+ /**
62
+ * CP-7 PART F — the narrow result the LE consumes from `engageSubstrate`. Two
63
+ * variants: `substrate` (the moat is ON — the LE passes `substrateHandle` into
64
+ * `spawnImplementor` and calls `teardown()` on process exit) and
65
+ * `reduced_trust` (the moat is OFF — the LE takes the legacy `nodeSpawn` path +
66
+ * surfaces the prominent badge). Declared structurally (NOT importing the
67
+ * concrete `SubstrateLaunch.engageSubstrate`) so the LE module stays decoupled
68
+ * and tests inject a stub. Matches `SubstrateLaunch.EngageResult`.
69
+ */
70
+ export type SubstrateEngageResult = {
71
+ mode: 'substrate';
72
+ tier: 'docker' | 'sandbox_exec';
73
+ reducedTrust: boolean;
74
+ reducedTrustReason?: string;
75
+ substrateHandle: SubstrateHandle;
76
+ refreshBrokerToken(): Promise<void>;
77
+ teardown(): Promise<void>;
78
+ } | {
79
+ mode: 'reduced_trust';
80
+ reducedTrust: true;
81
+ reducedTrustReason: string;
82
+ teardown(): Promise<void>;
83
+ };
84
+ /**
85
+ * CP-7 PART F — the injected substrate engager. The orchestration shell wires
86
+ * this to `SubstrateLaunch.engageSubstrate` for orchestration-mode implementor
87
+ * sessions. ABSENT (the default) → the LE never engages the substrate (companion
88
+ * mode / tests / reviewer-probe-only sessions): the legacy path is byte-identical
89
+ * (§7 non-regression). GEMINI is reduced-trust (§6 Q4) — the engager handles it
90
+ * (returns `reduced_trust`); the LE never calls it for reviewer/probe roles.
91
+ */
92
+ export type SubstrateEngager = (input: {
93
+ taskId: string;
94
+ agentKind: AgentKind;
95
+ workdir: string;
96
+ role: ProcessRole;
97
+ }) => Promise<SubstrateEngageResult>;
5
98
  export interface LocalExecutorImplDeps {
6
99
  sessionId: string;
7
100
  initialScope?: AuthorityScope;
@@ -12,6 +105,271 @@ export interface LocalExecutorImplDeps {
12
105
  logger?: {
13
106
  warn: (msg: string, meta?: Record<string, unknown>) => void;
14
107
  };
108
+ /**
109
+ * Spawns the per-track implementor process. Factored as a dep so tests can
110
+ * substitute a stub. Defaults to the module `spawnImplementor` bound to the
111
+ * track's authority scope. Returns the implementor handle.
112
+ */
113
+ spawnTrackImplementor?: (scope: AuthorityScope, args: SpawnArgs) => Promise<ImplementorHandle>;
114
+ /**
115
+ * Builds the `SpawnArgs.argv` for a track's implementor given the track
116
+ * payload + canonicalized state dir. The shell knows which agent binary
117
+ * (claude/gemini/codex) to invoke and the prompt wiring; the LE only
118
+ * orchestrates spawn + idempotency + state-dir isolation. When omitted, the
119
+ * MergeGate happy-path + idempotency tests still exercise the registry via a
120
+ * `spawnTrackImplementor` stub.
121
+ */
122
+ buildTrackArgv?: (payload: TrackAssignedPayload, stateDir: string) => string[];
123
+ /** AppSync surface for `submitMergeGateVerdict` (W2.a). Required for MergeGate. */
124
+ appsyncClient?: MergeGateAppSyncClient;
125
+ /** LE device P-256 key material — signs the MergeGate classification (#C12-8). */
126
+ deviceSigningKey?: DeviceSigningKey;
127
+ /** LE's registered Class A device id — bound into the classification signature. */
128
+ leDeviceId?: string;
129
+ /** ONE team session key (base64) — encrypts the MergeGate `detail` (§6 / 2f.4). */
130
+ teamSessionKeyB64?: string;
131
+ /** E2E content encryptor. Defaults to `cryptoService` if injected by the shell. */
132
+ contentEncryptor?: MergeGateContentEncryptor;
133
+ /**
134
+ * Repo root (canonicalized absolute) — the parent under which per-track state
135
+ * dirs `<repoRoot>/.codevibe/state/<group>/<track>/` live, and the cwd the
136
+ * MergeGate integration check runs in. Required for team sessions.
137
+ */
138
+ repoRoot?: string;
139
+ /**
140
+ * CP-12 W2.b (§3.C.1 / §3.C.3 / M5) — the brief→task_id bridge callback. On
141
+ * `TrackAssigned`, `launchTrack` calls this with the track's child `task_id`,
142
+ * `trackIndex`, `implementor_agent`, and declared write scope; the shell wires
143
+ * it to look up the parse-time `briefsByTrackIndex.get(track_index)` and
144
+ * register `{ brief, agent, trackIndex, write scope }` in the QuorumLoop's
145
+ * `activeBriefByTask` (which also drains any buffered team `GATE_DISPATCH` for
146
+ * the task). The per-track implementor run then happens in the QuorumLoop on
147
+ * the track's `GATE_DISPATCH` (NOT a bare spawn here). ABSENT (non-team LE /
148
+ * tests) → the track is registered in the registry but no brief bridge runs.
149
+ */
150
+ registerTeamTask?: (info: {
151
+ taskId: string;
152
+ taskGroupId: string;
153
+ trackIndex: number;
154
+ agent: AgentKind;
155
+ writePaths: string[];
156
+ autoModifiedFiles: string[];
157
+ /** #590 — the track's own-module test files; part of the declared write
158
+ * scope (engine disjointness-validated) so a test write stays in-lane. */
159
+ testSurfaces: string[];
160
+ }) => Promise<void>;
161
+ /**
162
+ * CP-12 W4 (#593, Stage-2 r1 Codex MED) — corrupt-brief TOMBSTONE predicate
163
+ * (wired to `QuorumLoop.isTrackTombstoned`). `launchTrack` consults it at the
164
+ * VERY TOP — before any registry mutation / state-dir canonicalization / spawn
165
+ * / lease-renewing progress emit — so a track whose durable brief failed to
166
+ * decrypt is refused on the LIVE path as early as on the recovery path (never
167
+ * an empty-brief implementor; the engine sweeper times the un-launched track
168
+ * out, bounded). ABSENT (non-team LE / tests) → no tombstone gating.
169
+ *
170
+ * Keyed by `(taskGroupId, trackIndex)` (#593 Stage-2 r2) — B.2 recovery
171
+ * aggregates across groups, so a tombstone must be scoped to its group.
172
+ */
173
+ isTrackTombstoned?: (taskGroupId: string, trackIndex: number) => boolean;
174
+ /**
175
+ * #592 PROVENANCE GUARD (live path, wired to `QuorumLoop.isForeignTeamGroup`).
176
+ * `launchTrack` consults it right after the tombstone gate — BEFORE any registry
177
+ * mutation / state-dir canonicalization / spawn — and refuses a `TrackAssigned`
178
+ * for a team group this desktop did NOT originate. Class B team packets broadcast
179
+ * PER-USER, and TWO clients that share one `sessionId` (shared device-home →
180
+ * adopted ACTIVE session) each receive the other's `TrackAssigned`; without this
181
+ * the foreign track would pin ITS base on THIS workspace and submit an empty
182
+ * round-0 → born-halt the real originator's gate (dogfood 2026-06-26, proven).
183
+ * Returns true ONLY when this desktop owns ≥1 group AND the arg is not among them
184
+ * (empty owned-set / fresh process / post-crash → false, so own-group recovery is
185
+ * unaffected). ABSENT (non-team LE / tests) → no provenance gating.
186
+ */
187
+ isForeignTeamGroup?: (taskGroupId: string) => boolean;
188
+ /**
189
+ * The substrate engager (wired by the orchestration shell to
190
+ * `SubstrateLaunch.engageSubstrate`). When present, the LE engages the moat
191
+ * for orchestration-mode IMPLEMENTOR spawns: it runs the agent inside the
192
+ * wiped-env, default-deny-egress sandbox with a per-session broker holding the
193
+ * vendor key (the agent is creditless). ABSENT (default) → the legacy spawn
194
+ * path is byte-identical (§7 non-regression: companion mode / reviewer-probe /
195
+ * tests are unaffected). The engager itself handles the §6 Q2 fallback ladder
196
+ * + the GEMINI reduced-trust case.
197
+ */
198
+ substrateEngager?: SubstrateEngager;
199
+ /**
200
+ * CP-7 W2 Stage-2 HIGH (Finding 2) — STRICT delivery sink for the
201
+ * `tier:'none'` (moat-OFF) reduced-trust badge. When supplied (production
202
+ * wiring in cli.ts), the moat-OFF badge is delivered through THIS sink — which
203
+ * confirms the NOTIFICATION actually reached `createEvent` and THROWS on a
204
+ * silent no-op (cohort off / no session key / stub / tap-ignored) — instead of
205
+ * the cohort-gated `emitShellEvent` that can resolve without emitting. A throw
206
+ * here makes the `tier:'none'` path FAIL CLOSED (no unsandboxed spawn).
207
+ *
208
+ * ABSENT (default) → the legacy behavior: the badge goes through
209
+ * `emitShellEvent` and a reject still fails closed, but a SILENT no-op would
210
+ * NOT (the gap this fix closes). Production MUST wire this; tests that want the
211
+ * pre-fix behavior may omit it.
212
+ */
213
+ strictBadgeSink?: StrictBadgeSink;
214
+ /** §3.C.18 — real Ed25519 signature verifier (resolves+caches the engine key). */
215
+ classBSignatureVerifier?: (packet: ClassBInbound) => Promise<boolean>;
216
+ /**
217
+ * §3.C.20 (Wave 3 FIX) — drive the round-0 implementor spawn off GATE_DISPATCH.
218
+ * CP-12 W2.b (§3.C.2 / H1) — `envelopeTaskId` carries the OUTER Class-B
219
+ * envelope's `task_id` so the team loop routes the round-0 dispatch to the
220
+ * right per-track `task_id` (the payload has none). The engine stamps this on
221
+ * EVERY dispatch — for single-impl it equals the loop's active task, and the
222
+ * loop's `envelopeTaskId !== activeTaskId` discriminator keeps it single-impl
223
+ * (falls back to the single active task). Wired straight through to the
224
+ * consumer's `gateDispatch`.
225
+ */
226
+ gateDispatch?: (payload: GateDispatchPayload, envelopeTaskId?: string) => Promise<void>;
227
+ /** §3.C.21 — spawn all assigned reviewer seats for a REVIEWER_DISPATCH packet. */
228
+ spawnReviewers?: (payload: ReviewerDispatchPayload) => Promise<void>;
229
+ /** §3.C.23 — re-run the implementor for round N+1 on a REVISE_FEEDBACK packet. */
230
+ runReviseRound?: (payload: ReviseFeedbackPayload) => Promise<void>;
231
+ /**
232
+ * CP-1.f execute-first (D5 / #PR-1 / #PR-3) — promote the task's SHADOW onto
233
+ * the real tree on the `TaskAuthorized` Class-B edge. Wired straight through
234
+ * to the consumer's `promoteOnTaskAuthorized`. ABSENT → no promote (back-compat).
235
+ */
236
+ promoteOnTaskAuthorized?: (taskId: string) => Promise<void>;
237
+ /**
238
+ * CP-12 W2.b (§3.C.2b (d) / H3-4) — promote-quiescence BARRIER for a task.
239
+ * Backed by the `QuorumLoop`'s public `awaitTaskShadowQuiescent` (an empty
240
+ * critical section on the per-task shadow-ops mutex). `runMergeGate` awaits
241
+ * this for EVERY member `task_id` (via `trackRegistry.forGroup`) immediately
242
+ * before the integration check, so a `MergeGateDispatch` that races an
243
+ * in-flight `promoteShadow` never reads a tree missing a track's promote.
244
+ * Wired from the shell EXACTLY like `promoteOnTaskAuthorized`. ABSENT (non-team
245
+ * LE / tests) → the barrier is skipped (back-compat; single-impl has no
246
+ * MergeGate so it never calls this).
247
+ */
248
+ awaitTaskShadowQuiescent?: (taskId: string) => Promise<void>;
249
+ /**
250
+ * TEST SEAM — override the bounded await for member track tips in the
251
+ * `worktree_merge` gate (default {@link TRACK_TIP_AWAIT_MS}). The engine
252
+ * dispatches `MergeGateDispatch` as soon as the LAST track flips Passed, but
253
+ * the desktop commits each track's tip asynchronously on its OWN
254
+ * `TaskAuthorized` receipt — so the dispatch can arrive BEFORE the final
255
+ * track's commit has even STARTED (the shadow-ops mutex is not yet held, so
256
+ * the quiescence barrier passes straight through). Dogfood-pinned 2026-07-02:
257
+ * team-joint-conflict read a missing tip 0.1s before the commit landed →
258
+ * FAIL verdict stored → the real train's later PASS hit the #C12-1 replay →
259
+ * "Team halted — merge_integration_failure" AFTER a successful promote.
260
+ */
261
+ trackTipAwaitMs?: number;
262
+ /**
263
+ * CP-14 — the team execution model. Since the §10 retirement (2026-07-03)
264
+ * `worktree_merge` is the ONLY model: the merge gate always runs
265
+ * {@link runWorktreeMergeGate} (merge-train the committed track branches +
266
+ * promote the integration tip). Retained as a dep for wire/test stability.
267
+ */
268
+ teamExecution?: TeamExecution;
269
+ /**
270
+ * CP-14 Wave A — read the durable committed track tips (the merge-train inputs)
271
+ * for a group. Backed by `RevertManifestStore.readTrackTips`. REQUIRED when
272
+ * `teamExecution === 'worktree_merge'` (the gate fails closed without it).
273
+ */
274
+ readTrackTips?: (taskGroupId: string) => Promise<TrackTipsView>;
275
+ /**
276
+ * TEST SEAM (§10 retirement, 2026-07-03) — override the worktree merge gate
277
+ * body. Defaults to the real {@link runWorktreeMergeBranch} (merge-train +
278
+ * promote). Mirrors the `runVerificationGatesFn` precedent: unit tests of the
279
+ * classification/signing/submission flow AROUND the gate inject a fixed
280
+ * result instead of standing up a real git fixture with track branches (the
281
+ * merge-train itself has its own fixture-backed suites).
282
+ */
283
+ worktreeMergeGateFn?: (payload: MergeGateDispatchPayload, repoRootCanonical: string, gateKinds: VerificationGateKind[]) => Promise<MergeResult>;
284
+ /**
285
+ * Audited-path fix (Fix 1) — surface a hosted-side PolicyRejection to the
286
+ * DESKTOP. The LE already emits a mobile-bound NOTIFICATION via
287
+ * `notifyPolicyRejection`, but `handleSubscribedEvent` drops every non-gate
288
+ * shell event, so the desktop user saw NOTHING when a task was policy-rejected.
289
+ * When wired (cli.ts), this is called with the CLASSIFIED rejection fields (no
290
+ * raw plaintext) so the shell can (a) dispatch a `SHELL_ADVISORY` into the
291
+ * store and (b) discard the policy-rejected task's shadow (a policy-rejected
292
+ * task never authorizes, so its shadow must go the same way a signalled
293
+ * terminal does). ABSENT → desktop-surface is skipped (the mobile NOTIFICATION
294
+ * still fires). Best-effort: a throw here is swallowed (never breaks Class B
295
+ * consumption per LOCK #E3-1).
296
+ */
297
+ onPolicyRejection?: (info: {
298
+ detail: string;
299
+ category: string;
300
+ recommendedRecovery: string;
301
+ /**
302
+ * Audited-path fix (Fix B) — the rejected task's OWN taskId (from the Class
303
+ * B envelope; the PolicyRejection payload carries none). The cli.ts wiring
304
+ * discards EXACTLY this task's shadow instead of `quorumLoop.activeTask`,
305
+ * so a DELAYED rejection for an OLD task can never discard the CURRENT
306
+ * task's shadow. Undefined when the envelope lacked a taskId → no discard.
307
+ */
308
+ rejectedTaskId?: string;
309
+ }) => void;
310
+ /**
311
+ * CP-14 Wave B (§2.1) — build the CONFINED class-2 model caller for a merge
312
+ * gate, or `null` when no confinement holds (path C — a bare host with
313
+ * sandboxing off + not a trusted container). Wired (cli.ts) to the QuorumLoop,
314
+ * which owns the substrate-engage / trusted-container / spawn machinery. `null`
315
+ * → the worktree_merge gate runs WITHOUT a resolver (byte-identical
316
+ * halt-on-conflict — no unconfined LLM resolver ever runs). The caller carries
317
+ * the `ownerTaskId` audit scope; `teardown()` is called after the gate.
318
+ */
319
+ makeConflictModelCaller?: (args: {
320
+ ownerTaskId: string;
321
+ }) => Promise<{
322
+ caller: ConflictModelCaller;
323
+ teardown: () => Promise<void>;
324
+ } | null>;
325
+ /**
326
+ * CP-14 WB2 (§2.1/§2.2/§2.3) — build the AGENTIC class-2 resolver for a merge
327
+ * gate, or `null` on path C (no confinement). When wired (cli.ts → QuorumLoop)
328
+ * AND `isAgenticResolverEnabled()` AND confinement holds, a class-2 slot's
329
+ * conflicts are resolved by re-dispatching the INCOMING track's implementor
330
+ * (read+write) in a disposable repo, fd-safe selective-import. `null` → the
331
+ * `resolveAgentic` closure stays unset → the legacy bounded-prompt `caller`
332
+ * path / halt (byte-identical). The agentic resolver NEVER spawns unconfined
333
+ * (fail-closed at construction AND per-resolve dispatch). `teardown()` is called
334
+ * after the gate alongside the model-caller teardown.
335
+ */
336
+ makeAgenticResolver?: (args: {
337
+ ownerTaskId: string;
338
+ }) => Promise<{
339
+ resolveAgentic: NonNullable<ConflictResolverContext['resolveAgentic']>;
340
+ teardown: () => Promise<void>;
341
+ } | null>;
342
+ /**
343
+ * CP-14 Wave B (§2.3, LOCK #C14-FINAL-TIER2 / #C14-MOAT) — dispatch the
344
+ * mandatory final-tip Tier-2 reviewer over the integration diff (base → tip),
345
+ * CONFINED via the same §2.1 tri-state (it returns `confined: false` on path C
346
+ * so the gate fails closed). Wired (cli.ts) to the QuorumLoop's reviewer
347
+ * registry + substrate engage. ABSENT → the gate fails closed when the Tier-2
348
+ * trigger fires (an LLM byte never promotes without a scoped, confined Tier-2).
349
+ */
350
+ dispatchFinalTier2Review?: (args: {
351
+ ownerTaskId: string;
352
+ repoDir: string;
353
+ baseSha: string;
354
+ integrationTip: string;
355
+ /** CP-14 WB2 §2.4 — the agentic resolver set, for independent Tier-2 selection. */
356
+ resolverAgents?: ReadonlySet<string>;
357
+ /** CP-14 WB2 §2.6 (additive) — the rendered intent bundle folded into the prompt. */
358
+ conflictBundle?: readonly RenderedConflict[];
359
+ trackIntentDiffs?: readonly TrackIntentDiff[];
360
+ }) => Promise<{
361
+ verdict: 'pass' | 'reject';
362
+ confined: boolean;
363
+ reason?: string;
364
+ }>;
365
+ /**
366
+ * CP-14 Wave B (§2.4) — symmetric cipher for the durable ConflictResolution
367
+ * store's at-rest content encryption (the team session key, via cli.ts's
368
+ * cryptoService). ABSENT → the durable store persists content plaintext (the
369
+ * structural metadata + the moat are unaffected; encryption is defense-in-depth
370
+ * on the desktop-local store). The conflict_id/hashes/class stay plaintext.
371
+ */
372
+ conflictContentCipher?: ContentCipher;
15
373
  }
16
374
  export declare function makeEmptyScope(): AuthorityScope;
17
375
  export declare class LocalExecutorImpl implements LocalExecutor {
@@ -24,6 +382,22 @@ export declare class LocalExecutorImpl implements LocalExecutor {
24
382
  private readonly baseCtx;
25
383
  private readonly adapter;
26
384
  private readonly sessionId;
385
+ private readonly trackRegistry;
386
+ private readonly trackPayloads;
387
+ private readonly resolvedMergeOutcomes;
388
+ /**
389
+ * CP-14 concurrent-dispatch dedup — the ONE in-flight merge-gate run per
390
+ * `${merge_gate_id}:${dispatch_generation}` (see {@link runMergeGate}). Entries
391
+ * are removed when the run settles, so a post-completion re-drain still takes
392
+ * the #TC-7 replay path (re-submit → server replays the stored outcome).
393
+ */
394
+ private readonly inFlightMergeGates;
395
+ private _lastMergeGateEmitMs;
396
+ private readonly teamDeps;
397
+ private readonly logger;
398
+ private readonly teamModeEnabled;
399
+ private readonly substrateEngager?;
400
+ private readonly strictBadgeSink?;
27
401
  constructor(deps: LocalExecutorImplDeps);
28
402
  /**
29
403
  * Single-entrypoint authority gate per master §9:1284. Dispatches to the
@@ -47,8 +421,60 @@ export declare class LocalExecutorImpl implements LocalExecutor {
47
421
  encoding?: BufferEncoding;
48
422
  }): Promise<string | Buffer>;
49
423
  spawnImplementor(args: SpawnArgs): Promise<ImplementorHandle>;
50
- spawnReviewer(args: SpawnArgs): Promise<ReviewerHandle>;
424
+ spawnReviewer(_args: SpawnArgs): Promise<ReviewerHandle>;
51
425
  spawnHealthProbe(args: SpawnArgs): Promise<ProbeHandle>;
426
+ /**
427
+ * CP-7 PART F — engage the trusted-execution substrate for ONE implementor
428
+ * spawn. Returns the `SpawnArgs` to launch with (substrate-augmented on the
429
+ * `substrate` branch; unchanged on the legacy/reduced-trust branch) + an
430
+ * `onExit` callback the LE wires to the process-exit lifecycle so the broker
431
+ * is stopped (zeroized) + the bootstrap destroyed + the sandbox torn down.
432
+ *
433
+ * Fail-closed: if `engageSubstrate` THROWS (broker couldn't start, etc.) it
434
+ * propagates — we do NOT silently fall back to an unsandboxed run. The ONLY
435
+ * non-substrate outcome is the engager EXPLICITLY returning `reduced_trust`
436
+ * (no runtime available / GEMINI), which surfaces the prominent badge and
437
+ * takes the legacy path.
438
+ */
439
+ private engageSubstrateForSpawn;
440
+ /**
441
+ * CP-7 PART F — surface the PROMINENT reduced-trust badge (§6 Q2). The moat
442
+ * being OFF (or coarse) MUST be visible + auditable, never silent: a
443
+ * user-visible NOTIFICATION carrying a structured `reducedTrust: true` flag +
444
+ * a WARN log line.
445
+ *
446
+ * W2 Stage-2 HIGH — DELIVERY DISCIPLINE per tier:
447
+ * - `tier: 'none'` (the moat is fully OFF — the agent runs unsandboxed with
448
+ * ambient `process.env` reachable): the badge MUST be DELIVERED before the
449
+ * agent runs. It is routed through the STRICT delivery sink
450
+ * (`deps.strictBadgeSink`) which CONFIRMS the NOTIFICATION actually reached
451
+ * `createEvent` and THROWS on a silent no-op (cohort off / no session key /
452
+ * stub / tap-ignored) — the ordinary `emitShellEvent` would RESOLVE without
453
+ * emitting in those cases (Finding 2). This method AWAITS that delivery with
454
+ * a bounded timeout and RE-THROWS on a reject/timeout. The WARN log stays
455
+ * but is NOT sufficient on its own — the caller turns a throw here into a
456
+ * FAIL-CLOSED (no un-badged unsandboxed spawn). When no strict sink is wired
457
+ * (legacy/tests), it falls back to `emitShellEvent` (a reject still fails
458
+ * closed, but a silent no-op would not — production MUST wire the sink).
459
+ * - `tier: 'sandbox_exec' | 'docker'` (the agent is still SANDBOXED, just
460
+ * weakened/coarse egress): a failed badge is far less critical. We AWAIT
461
+ * it (a bounded await is acceptable per §6 Q2) but SWALLOW a delivery
462
+ * failure — the agent is still contained, so a missed coarse badge does
463
+ * not warrant tearing the session down.
464
+ *
465
+ * Returns a promise the `tier:'none'` callers `await` (and fail-closed on
466
+ * reject); the coarse callers may `await` it too (it never rejects for them).
467
+ */
468
+ private surfaceReducedTrustBadge;
469
+ /**
470
+ * W2 Stage-2 HIGH — bound the `tier:'none'` badge delivery. Resolves only if
471
+ * the NOTIFICATION emit settles successfully within
472
+ * `REDUCED_TRUST_BADGE_DELIVERY_TIMEOUT_MS`; REJECTS if the emit rejects OR the
473
+ * timeout fires first. The caller fails closed on a reject (refuses the
474
+ * unsandboxed spawn) so no agent ever runs moat-OFF without the user having
475
+ * been warned.
476
+ */
477
+ private awaitBadgeDeliveryOrThrow;
52
478
  private spawnWithLifecycle;
53
479
  ingestHookEvent(event: HookEvent): Promise<void>;
54
480
  /**
@@ -59,14 +485,229 @@ export declare class LocalExecutorImpl implements LocalExecutor {
59
485
  *
60
486
  * TaskAuthorized advances authority scope + taskId atomically via the DI
61
487
  * closure wired in the constructor (CP-0 §2.5 invariant #6).
488
+ *
489
+ * `envelopeTaskId` (Audited-path fix B) — the OUTER Class B envelope's taskId,
490
+ * forwarded to the consumer so a PolicyRejection (whose payload has no taskId)
491
+ * discards EXACTLY the rejected task's shadow. Optional for non-WS callers.
492
+ */
493
+ consumeClassB(packet: ClassBInbound, envelopeTaskId?: string): Promise<void>;
494
+ /**
495
+ * #C12-14 — launch the implementor for one track. IDEMPOTENT by
496
+ * `(task_group_id, track_index, dispatch_generation)`: a duplicate
497
+ * `TrackAssigned` for an already-launched generation spawns NOTHING
498
+ * (#C12-17). A strictly-newer generation (dispute re-dispatch, #C12-19)
499
+ * supersedes the stale entry.
500
+ *
501
+ * Steps: (1) idempotency check; (2) create + canonicalize the per-track
502
+ * `state_dir` via the existing spawn authority guard (NO bypass —
503
+ * `fs.realpath` exactly as `spawnSubprocess` requires); (3) advance the
504
+ * per-track authority scope to `ownership_scope`; (4) spawn the implementor
505
+ * in `state_dir` with the track's child `task_id`.
506
+ */
507
+ private launchTrack;
508
+ /**
509
+ * CP-12 W4 (#593) — the public team-dispatch recovery entrypoint. Exposes the
510
+ * EXACT private `launchTrack` body (register + brief bridge) so the QuorumLoop
511
+ * `recoverTeamTracks` PASS 2 can re-launch a track whose round-0 `TrackAssigned`
512
+ * was dropped by the emit-before-subscribe race. Returns the explicit result
513
+ * enum (`registered | duplicate | rejected`) the recovery loop discriminates:
514
+ * - `registered` → the `registerTeamTask` brief bridge ran → drive the gate.
515
+ * - `duplicate` → returned BEFORE the bridge → recovery repairs the brief
516
+ * explicitly, then drives the gate.
517
+ * - `rejected` → the track did NOT launch (canonical state-dir confinement)
518
+ * → recovery skips it (no repair, no gate dispatch).
519
+ */
520
+ recoverLaunchTrack(payload: TrackAssignedPayload): Promise<'registered' | 'duplicate' | 'rejected'>;
521
+ /**
522
+ * FIX-4 — wrap a track's `SpawnArgs` with the Class A process-lifecycle
523
+ * audit hooks, mirroring the single-track `spawnWithLifecycle` path but bound
524
+ * to the TRACK's own `task_id` as the Class A context (so PROCESS_SPAWNED /
525
+ * PROCESS_EXITED envelopes attribute to the right track, not the team task).
526
+ */
527
+ private withTrackLifecycle;
528
+ /**
529
+ * #C12-7/#C12-8 — MergeGate runner. The `owner_track_index` track runs the
530
+ * shared integration check, derives a PASS/FAIL classification from the gate
531
+ * EXIT CODES (LE-cannot-lie), builds `changedFileSets` per track, signs the
532
+ * classification via W2.a `signMergeClassification`, and reports it through
533
+ * `submitMergeGateVerdict` (§2.1 shape).
534
+ *
535
+ * The LE reports ONLY the LE-reported failure classes (`IntegrationFailure`,
536
+ * `DirtyRepoState`); the server DERIVES the other 4 classes from the signed
537
+ * `changedFileSets` / cross-track data (#C12-8). The LE NEVER computes
538
+ * SharedFileConflict / ScopeViolation / ReviewerDisagreement / BudgetExhausted.
539
+ */
540
+ /**
541
+ * CP-14 Wave A — the `worktree_merge` merge-gate branch: build the merge-train
542
+ * inputs from the durable committed tips + the live member set, run
543
+ * {@link runWorktreeMergeGate} (merge-train → Tier-1 → promote the integration
544
+ * tip), and map the outcome to a `MergeResult` for the engine verdict. A
545
+ * `merged_promoted` ⇒ PASS; ANY halt ⇒ FAIL (the user tree is untouched by
546
+ * construction — #C14-AON — so there is no content to revert). FAILS CLOSED if
547
+ * `readTrackTips` is unwired (the gate cannot read its inputs).
548
+ */
549
+ private runWorktreeMergeBranch;
550
+ /**
551
+ * [P1b] GUARANTEED LOCAL freeze for the merge-gate timer. Wraps the inner gate
552
+ * so that ANY exit which STARTED the timer ('pending' emitted) but never
553
+ * converged — LEAK C (submit-exhaustion return), LEAK D (a thrown
554
+ * realpath/build/sign/encrypt), a pre-convergence halt — emits a local
555
+ * attempt-end that FREEZES the ticking clock. `runMergeGateInner` returns a
556
+ * DEDICATED `convergedOrBenign` boolean (NOT `resolvedMergeOutcomes.has(mgId)`,
557
+ * per the design's S2-iter3 Codex-L1: that map is set at submit-SUCCESS, before
558
+ * the convergence freeze — so a future refactor that lets `emitGroupConvergence`
559
+ * throw BEFORE its synchronous pass/fail freeze-tap would see `has()===true` and
560
+ * WRONGLY suppress the attempt-end → strand the timer forever). The boolean is
561
+ * `true` ONLY once the timer is actually frozen (convergence emitted) OR on the
562
+ * benign "another dispatch already converged + froze" return — so a throw (which
563
+ * leaves the `= await` assignment incomplete → `false`) always fires the freeze.
564
+ * The reducer no-ops the attempt-end when no live anchor exists (a pre-'pending'
565
+ * guard return / an already-frozen gate), so this is safe on every exit; a throw
566
+ * still propagates (the `finally` only emits — it never swallows).
567
+ */
568
+ private runMergeGate;
569
+ /** The single-flight merge-gate run body (P1b freeze wrapper). See {@link runMergeGate}. */
570
+ private runMergeGateExclusive;
571
+ /**
572
+ * Returns `convergedOrBenign`: `true` once the convergence pass/fail freeze-tap
573
+ * fired (timer frozen) OR on the benign already-resolved return; `false` on a
574
+ * strand exit (submit-exhaustion) so the wrapper's `finally` freezes the timer.
575
+ * A thrown exit never returns → the wrapper's boolean stays `false` → freeze.
576
+ */
577
+ private runMergeGateInner;
578
+ /**
579
+ * PHASE-589+469 W1 (§5.A / §5.C / #TC-2 / #TC-3) — drive the desktop CLI
580
+ * convergence from the AUTHORITATIVE engine `outcome`. Emits, via the SAME
581
+ * `emitShellEvent` tap chokepoint the per-track progress uses:
582
+ * (a) the AUTHORITATIVE-sourced `merge_gate` status ('pass' on "complete",
583
+ * 'fail' on any failure-class outcome) — #TC-2;
584
+ * (b) ONE `team_track_terminal` per member trackIndex (state 'Passed' on
585
+ * "complete", else 'Failed') — flips InFlight→terminal (#TC-3);
586
+ * (c) ONE `team_group_resolved` carrying the outcome — sets groupResolved.
587
+ *
588
+ * NO workspace mutation / promoteShadow here (#TC-1) — files already self-
589
+ * applied at each track's final_approval. Member trackIndices come from the
590
+ * local team registry (`trackPayloads`, the SAME source `buildChangedFileSets`
591
+ * uses). Team-only path — single-impl never reaches runMergeGate (#TC-8).
592
+ */
593
+ private emitGroupConvergence;
594
+ /**
595
+ * PHASE-589/469 W3.2 (D2) — drive the per-track render flip + group-resolved
596
+ * render for a USER GROUP DECISION (the 5-option escalation COMMIT), through
597
+ * the SAME `emitGroupConvergence` chokepoint the MergeGate convergence uses.
598
+ * This is the fix for the recurring "track stays InFlight after the user picks
599
+ * abort_task" gap: the group-decision path previously NEVER reached this
600
+ * chokepoint (only the MergeGate path did), so the per-track flip never fired.
601
+ *
602
+ * `outcome` is `'complete'` for an accept-family decision (tracks render
603
+ * `Passed`/kept) or a halted-reason label for a reject-family decision (tracks
604
+ * render `Failed`/reverted + the group resolves). Public so the orchestration
605
+ * shell can invoke it after the two-phase CLAIM→revert→COMMIT finishes.
606
+ */
607
+ driveGroupDecisionConvergence(taskGroupId: string, outcome: string): Promise<void>;
608
+ /**
609
+ * #C12-12 — surface a group halt to the UI (NOTIFICATION + escalation
610
+ * choices) and signal the in-flight track processes to stop. The deep
611
+ * choice-driven auto-resolution decision tree is server-side (#C12-3) — the
612
+ * LE only surfaces + stops. [DEFERRED — GA/CP-12 Wave 3+] for any LE-side
613
+ * choice-driven auto-action (retry/accept-partial/etc.); CP-8 #469 renders.
614
+ */
615
+ private haltTaskGroup;
616
+ /**
617
+ * FIX-2 — DERIVE + confinement-verify the per-track state dir (#C12-14).
618
+ *
619
+ * The state dir is the trust-boundary root for the per-track WRITE grant
620
+ * (scopeFromOwnership adds it to writeScopes). Trusting the payload's
621
+ * `state_dir` — OR the `task_group_id` / `track_index` we derive it from —
622
+ * verbatim would let a signed-but-malicious `TrackAssigned` point it OUTSIDE
623
+ * the sandbox and obtain a write grant there. So, defense-in-depth (the
624
+ * packet is Ed25519-signed but we still don't trust its fields as safe path
625
+ * segments):
626
+ *
627
+ * 0. VALIDATE `task_group_id` is a safe single path segment (non-empty, not
628
+ * `.`/`..`, no `/`, `\`, or NUL, not absolute) and `track_index` is a
629
+ * non-negative safe integer. Otherwise a `task_group_id` of
630
+ * "../../../../tmp/x" makes the DERIVED path itself escape, and the
631
+ * packet's matching `state_dir` then passes the exact-match check.
632
+ * 1. Compute the trusted state root `realpath(realpath(repoRoot)/.codevibe/
633
+ * state)` (realpath resolves any symlinked component).
634
+ * 2. DERIVE `realpath(stateRoot)/<task_group_id>/<track_index>`, mkdir -p,
635
+ * realpath it (canonical workingDir for the spawn guard).
636
+ * 3. CONTAINMENT CHECK — the realpath'd derived dir MUST stay strictly under
637
+ * the realpath'd state root (catches both `..`-segment AND symlinked-
638
+ * component escapes).
639
+ * 4. Verify the payload's supplied `state_dir` resolves to EXACTLY the
640
+ * derived path. A mismatch / escape ⇒ REJECT (return null): no spawn, no
641
+ * scope grant. Never feed an attacker-controlled path into the grant.
642
+ *
643
+ * Returns the canonical derived dir on success, or `null` on a confinement
644
+ * violation (logged here; the caller drops the packet).
645
+ */
646
+ private canonicalizeStateDir;
647
+ /**
648
+ * Map a track's snake_case `OwnershipScope` to the LE `AuthorityScope`. WRITE
649
+ * is limited to the declared `write_paths` + `auto_modified_files` + the
650
+ * track's own state dir; READ inherits the current scope's read prefixes (the
651
+ * shared workspace) plus the write set. Command/network inherit the current
652
+ * team scope's grants + expiry (the track runs the existing gate flow).
653
+ */
654
+ private scopeFromOwnership;
655
+ /**
656
+ * Build `changedFileSets` per track for the group (#C12-8). M2 derives each
657
+ * track's set from its declared `write_paths` (the LE enforced WRITE only
658
+ * there via the per-track authority scope) — the bounded trust attestation
659
+ * the design names (the signed manifest IS the trusted boundary for 2.0;
660
+ * server-stored signed diff manifests w/ base/head are a CP-7 follow-up,
661
+ * §12 deferred). Paths are relative-to-repo as declared.
662
+ *
663
+ * #590 NOTE — `test_surfaces` are DELIBERATELY NOT attested here. The signed
664
+ * manifest stays the strictly-disjoint `write_paths ∪ auto_modified_files`
665
+ * set so the MergeGate `SharedFileConflict` overlap check (which is unaware of
666
+ * the `isSharedTestOwner` exception) cannot false-positive on legitimately
667
+ * overlapping shared test surfaces. The desktop `filesOutsideWriteScope` guard
668
+ * DOES admit `test_surfaces` (an own-module test write is in-lane), and the
669
+ * server `derive_server_class` ScopeViolation allow-set is a SUPERSET that also
670
+ * admits `test_surfaces` — so a future actual-diff manifest carrying a declared
671
+ * test file stays accepted. Non-divergent because the manifest ⊆ that allow-set.
672
+ */
673
+ private buildChangedFileSets;
674
+ /**
675
+ * §2.3 — emit a per-track progress event carrying `track_index` + `task_id`
676
+ * in metadata so mobile/desktop CAN render per-track threads (CP-8 #469
677
+ * renders; W2.b adds the wire attribution only). Emitting a per-track
678
+ * progress event also renews that track's lease (#C12-18). This path is ONLY
679
+ * for group tracks — single-track events go through the hook bridge and OMIT
680
+ * the field (backward-compatible).
681
+ */
682
+ private emitTrackProgress;
683
+ /**
684
+ * CP-12 W3 Stage-2 r2 — emit the MergeGate lifecycle ('pending' | 'pass' |
685
+ * 'fail') to the status node via the SAME emitShellEvent tap chokepoint the
686
+ * per-track progress uses. `runMergeGate` calls this; the shell tap maps
687
+ * `source: 'merge_gate'` → `TEAM_MERGE_GATE`. Carries `task_group_id` so the
688
+ * tap's per-group isolation guard can drop a stale older-group event. Team-
689
+ * only path — single-track/Companion never reach runMergeGate.
690
+ */
691
+ /** [P1b] Strict-monotonic ISO stamp for the merge-gate `started_at` anchor. */
692
+ private nextMergeGateTs;
693
+ /**
694
+ * [P1b] Emit the merge-gate status to the shell + mobile. SYNCHRONOUS return —
695
+ * TAP-LOCAL-SYNC + FIRE-AND-FORGET the remote: `emitShellEvent` taps the desktop
696
+ * store synchronously (driving the merge-gate timer) then awaits the AppSync/
697
+ * mobile send, which we deliberately do NOT await, so a hung OR throwing remote
698
+ * emitter can never block `runMergeGate` before its `try/finally` freeze (S2 Codex-H
699
+ * "safeEmit is rejection-safe but not hang-safe"). Timestamps: `'pending'` (start)
700
+ * carries a strict-monotonic `started_at`; `attemptEnd`/pass/fail carry `ended_at`.
62
701
  */
63
- consumeClassB(packet: ClassBInbound): Promise<void>;
702
+ private emitMergeGateStatus;
64
703
  /** Set the active taskId (production: CP-1.e on TASK_AUTHORIZED). */
65
704
  setActiveTaskId(taskId: string | null): void;
66
705
  /** Replace the active authority scope (production: CP-1.e on TASK_AUTHORIZED). */
67
706
  setAuthorityScope(scope: AuthorityScope): void;
68
707
  /** Expose emitter for §8.5 integration test introspection. */
69
708
  get emitterForTests(): ClassAEmitter;
709
+ /** CP-12 W2.b — expose the per-track registry for idempotency introspection. */
710
+ get trackRegistryForTests(): TrackRegistry;
70
711
  private contextOrNull;
71
712
  /**
72
713
  * Context resolver for ClassBConsumer emit paths (refusals + PolicyRejection).