@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
@@ -0,0 +1,713 @@
1
+ import { MergeJournalStore } from './merge-journal-store';
2
+ import type { AgentKind } from './types';
3
+ import { type BranchFoundation } from './worktree-merge';
4
+ import { type RenderedConflict, type TrackIntentDiff } from './wb2-review-bundle';
5
+ import { type ConflictResolverContext } from './merge-conflict-resolve';
6
+ /**
7
+ * The per-track input the merge-train consumes — the W2 view of the planner's §7
8
+ * `Track`. `repoId` + `trackIndex` form the total ordering key; `depends_on` drives
9
+ * the global topological order (§4.1). `trackTip` is the resolved persistent
10
+ * track-branch tip (`codevibe/track/<group>/<trackIndex>`) the train merges IN.
11
+ * `testSurfaces` (the declared `test_surfaces`) are unioned across all tracks for
12
+ * Tier-1 (§4.4). `deletedPaths` carry the diff's `change_kind:'deleted'` set so the
13
+ * declared-test runner's deletion guard holds.
14
+ */
15
+ export interface MergeTrainTrack {
16
+ trackIndex: number;
17
+ repoId: string;
18
+ /** The persistent track-branch tip to merge IN (`theirs`). */
19
+ trackTip: string;
20
+ /** Global topo dependencies (other tracks' `trackIndex`) — §4.1. */
21
+ dependsOn?: number[];
22
+ /** Declared `test_surfaces` (workspace-rel) unioned into Tier-1 (§4.4). */
23
+ testSurfaces?: string[];
24
+ /** The diff's `change_kind:'deleted'` paths (declared-test deletion guard). */
25
+ deletedPaths?: string[];
26
+ /**
27
+ * CP-14 WB2 — the implementor agent + its per-spawn task id that authored this
28
+ * track. The agentic class-2 resolver re-dispatches this (the INCOMING track's)
29
+ * implementor to resolve the slot's conflicts; folded into the generation
30
+ * identity (`tracksEqual`) + persisted in the journal track record. Optional on
31
+ * the type so pre-B2 construction sites compile; the agentic resolve path
32
+ * FAILS CLOSED (human-gate) when absent.
33
+ */
34
+ implementorAgent?: AgentKind;
35
+ implementorTaskId?: string;
36
+ /** The implementor's worktree-shadow path, recorded informationally in the journal. */
37
+ worktreePath?: string | null;
38
+ }
39
+ /** A resolved, total, unique, replay-stable merge-train order (§4.1). */
40
+ export interface MergeOrder {
41
+ /** The tracks in execution order. */
42
+ ordered: MergeTrainTrack[];
43
+ /** The execution order as a list of `trackIndex` (the canonical journal order). */
44
+ resolvedOrder: number[];
45
+ }
46
+ /** Thrown when a decomposition cannot yield a total, unique, acyclic order (§4.1). */
47
+ export declare class MergeOrderError extends Error {
48
+ readonly reason: 'cycle' | 'dangling-ref' | 'duplicate-key';
49
+ constructor(reason: 'cycle' | 'dangling-ref' | 'duplicate-key', message: string);
50
+ }
51
+ /**
52
+ * Compute the GLOBAL, deterministic, replay-stable merge-train order (LOCK
53
+ * #C14-ORDER, §4.1).
54
+ *
55
+ * Order = GLOBAL topological by `depends_on`, tiebroken by the TOTAL key
56
+ * `(repoId ascending, trackIndex ascending)`. Because no two tracks share
57
+ * `(repoId, trackIndex)`, the key is total and unique, so the order is total,
58
+ * unique, and re-derivable IDENTICALLY from the journal on crash recovery.
59
+ *
60
+ * Fail-closed (defensive, surfaced as {@link MergeOrderError}, never a guessed
61
+ * order):
62
+ * - a `depends_on` referencing an unknown `trackIndex` → `dangling-ref`;
63
+ * - a CYCLE in the `depends_on` graph → `cycle`;
64
+ * - a DUPLICATE `(repoId, trackIndex)` key → `duplicate-key`.
65
+ *
66
+ * N-way octopus is rejected by construction — the order is strictly sequential
67
+ * (the train merges one slot at a time). Written GLOBAL-FIRST (the `(repoId,
68
+ * trackIndex)` total key spans the whole workspace) so W4's multi-repo reuses it
69
+ * unchanged; W2 exercises one repo's tracks (all sharing one `repoId`), where the
70
+ * tiebreak degenerates to `trackIndex` ascending.
71
+ *
72
+ * Determinism: Kahn's algorithm with a STABLE ready-set selection — at each step the
73
+ * ready node with the smallest total key is chosen, so the output is a single
74
+ * canonical linearization (not just "a" topo order). Identical inputs → identical
75
+ * order, every time + on replay.
76
+ */
77
+ export declare function computeMergeOrder(tracks: readonly MergeTrainTrack[]): MergeOrder;
78
+ /** The merge-commit trailer that carries the step's pre-input merge key (§3.2). */
79
+ export declare const MERGE_KEY_TRAILER = "Codevibe-Merge-Key";
80
+ /**
81
+ * W3 (§3.2 audit-before-ref) — the merge-commit trailer carrying the
82
+ * `resolution_set_hash` (the sorted set of `conflict_id`s resolved in this slot).
83
+ * Present ONLY on a slot that required conflict resolution; a CLEAN (auto-merged)
84
+ * slot's message is byte-identical to W2 (no second trailer), so the W2 recovery
85
+ * SHA-recomputation probe is unaffected for clean slots. For a RESOLVED slot,
86
+ * recovery re-derives the identical message (the resolution set replays
87
+ * deterministically by `conflict_id`), so the trailer is reproducible.
88
+ */
89
+ export declare const RESOLUTION_SET_TRAILER = "Codevibe-Resolution-Set";
90
+ /**
91
+ * CP-14 WB2 (#C14-WB2-AGENTIC-IDENTITY) — the merge-commit trailer carrying the
92
+ * AGENTIC resolution INSTANCE id, present ONLY on a slot resolved by the agentic
93
+ * (read+write) resolver. The promote-gate verify (§2.5 `verifyAgenticSlot`) + recovery
94
+ * read it to fetch the `AgenticResolutionRecord` (via `getAgentic`) and authenticate the
95
+ * committed FULL tree OID against `resolved_tree_oid` — agentic output is
96
+ * non-deterministic, so these commits are NEVER SHA-recomputed (recovery adopts them by
97
+ * parents + MERGE_KEY). Absent for clean / class-1 / legacy-llm slots, so their message
98
+ * stays byte-identical and their deterministic SHA-recompute recovery is unaffected.
99
+ */
100
+ export declare const AGENTIC_INSTANCE_TRAILER = "Codevibe-Agentic-Instance";
101
+ /**
102
+ * The DETERMINISTIC author+committer date pinned on every merge-train commit
103
+ * (Stage-1 M1). A fixed canonical epoch (`@0 +0000`) makes the merge commit SHA a
104
+ * PURE FUNCTION of `(tree, parents, message, repo identity)` — no wall-clock time
105
+ * leaks in — so a crash-recovery re-merge of identical inputs reproduces the
106
+ * BYTE-IDENTICAL commit (the §3.2 "deterministically identical commit" guarantee).
107
+ * A fixed value is sound: distinct merge commits still differ by their tree/parents/
108
+ * message (the message carries the slot + trackIndex + key), and the integration
109
+ * branch is CodeVibe-owned (never the user's; the date is cosmetic on it). The single
110
+ * user-tree mutation is the W1 promote, which keeps the ambient date (unchanged).
111
+ */
112
+ export declare const MERGE_COMMIT_DATE = "@0 +0000";
113
+ /**
114
+ * The generic BOT identity pinned on every merge-train commit (Stage-2 r1 M1 / agy F-02,
115
+ * Option B). The author+committer name/email of CodeVibe's own machine-generated MERGE
116
+ * commits is pinned to this fixed value so the merge-commit SHA is a PURE FUNCTION of
117
+ * `(tree, parents, message, this identity, MERGE_COMMIT_DATE, UTF-8 encoding, no signature)`
118
+ * — identical across hosts + on crash-recovery replay, regardless of the ambient
119
+ * `user.name`/`user.email`/`i18n.commitEncoding`/`commit.gpgsign`. Pinned ONLY for the
120
+ * integration-branch merge commits the train creates; the user's OWN work commits (on the
121
+ * track branches) keep their real identity (the train never re-authors them).
122
+ */
123
+ export declare const MERGE_COMMIT_IDENTITY: {
124
+ readonly name: "CodeVibe Agent";
125
+ readonly email: "agent@codevibe.ai";
126
+ };
127
+ /**
128
+ * The CANONICAL merge-commit message for a slot (Codex MEDIUM — recovery-trailer
129
+ * authentication). The SINGLE source of truth for the message string used at BOTH the live
130
+ * train site ({@link runMergeTrain}), the recovery re-merge site ({@link recoverMergeTrain}),
131
+ * AND the recovery DETERMINISTIC-RECOMPUTATION probe ({@link findMergeCommitByTrailer}). The
132
+ * commit SHA is a pure function of `(tree, parents, message, identity, date, encoding, no-sig)`;
133
+ * the probe authenticates a trailer-matched candidate by RE-DERIVING the expected SHA, so the
134
+ * message it feeds `commit-tree` MUST be byte-for-byte the message the live train committed.
135
+ * Centralizing it here makes that invariant un-driftable — a future edit to the wording changes
136
+ * all three call sites at once.
137
+ */
138
+ export declare function buildMergeCommitMessage(trackIndex: number, orderSlot: number, mergeKey: string, resolutionSetHash?: string, agenticInstanceId?: string): string;
139
+ /** A surfaced, non-throwing merge-train outcome. */
140
+ export type MergeTrainOutcome = {
141
+ /** Every slot merged (clean or W3-resolved) → integration advanced to `integrationTip`. */
142
+ status: 'merged';
143
+ integrationTip: string;
144
+ /**
145
+ * W3 (§4.4, LOCK #C14-FINAL-TIER2 / #C14-MOAT) — true if ANY class-2
146
+ * (LLM-assisted) resolution was applied to a slot in **THIS run**. Named to
147
+ * NOT overclaim authority: it is the SINGLE-PASS Tier-2 signal, NOT a
148
+ * resume-safe promote gate. The adopt-committed-slot fast path skips
149
+ * already-landed slots, so a class-2 byte from a PRIOR run is absent here.
150
+ *
151
+ * **LOCK #C14-W3-TIER2-AUTHORITY (wiring wave):** the promote gate MUST
152
+ * derive the authoritative "requires final-tip Tier-2" from the DURABLE
153
+ * ConflictResolution store (or a `RESOLUTION_SET_TRAILER` walk of the
154
+ * integration history) — NEVER from this single-pass boolean alone. For a
155
+ * single uninterrupted pass this flag IS complete; across a resume it is a
156
+ * lower bound only. Absent the resolver (W2) → always `false`.
157
+ */
158
+ class2ResolvedThisRun: boolean;
159
+ /** Per-class resolution counts applied this run (informational / audit). */
160
+ resolutionCounts: {
161
+ class1: number;
162
+ class2: number;
163
+ };
164
+ } | {
165
+ /**
166
+ * A slot CONFLICTED → the train HALTED: no commit at that slot, the integration
167
+ * ref is where slot k-1 left it, NOTHING promoted, the user tree untouched.
168
+ */
169
+ status: 'conflict_halt';
170
+ /** The order slot (0-based) that conflicted. */
171
+ haltedSlot: number;
172
+ /** The conflicting track's index. */
173
+ trackIndex: number;
174
+ /** The conflicting paths surfaced to the user / W3 classifier. */
175
+ conflictPaths: string[];
176
+ /** The integration tip the train reached BEFORE the conflict (slot k-1's commit). */
177
+ integrationTip: string;
178
+ } | {
179
+ /**
180
+ * W3 (§4.3) — a slot conflicted AND, with the conflict resolver wired, at
181
+ * least one conflicting path is class-3 (route-to-human): a shared-contract
182
+ * surface, a dangerous attr/submodule/LFS/binary/mode/type/rename conflict,
183
+ * a lockfile version-delta, or an over-budget / fail-closed class-2 resolve.
184
+ * Per LOCK #C14-AON the WHOLE slot escalates (no partial resolution): no
185
+ * commit at that slot, the integration ref is where slot k-1 left it,
186
+ * NOTHING promoted, the user tree untouched. The gated paths + their triggers
187
+ * go to the human gate.
188
+ */
189
+ status: 'conflict_human_gate';
190
+ /** The order slot (0-based) whose conflicts could not be auto-resolved. */
191
+ haltedSlot: number;
192
+ /** The conflicting track's index. */
193
+ trackIndex: number;
194
+ /** The class-3 paths + their human-gate triggers + reasons. */
195
+ gated: {
196
+ path: string;
197
+ trigger: string;
198
+ reason: string;
199
+ }[];
200
+ /** The integration tip the train reached BEFORE this slot (slot k-1's commit). */
201
+ integrationTip: string;
202
+ } | {
203
+ /**
204
+ * A path carries a DANGEROUS `.gitattributes` attribute (`merge=`/`filter=`/LFS/
205
+ * `working-tree-encoding`/`ident`) — the train HALTS BEFORE any merge or Tier-1
206
+ * checkout (Stage-2 r1 H2 pre-merge touched-path scan + Stage-2 r2 H2 pre-checkout
207
+ * full-integration-tree scan). Nothing committed, the integration ref is untouched,
208
+ * NOTHING promoted, the user tree untouched. The attribute-bearing paths require a
209
+ * human gate (§4.2 r3-M), so a custom merge driver or a smudge filter never runs.
210
+ */
211
+ status: 'attribute_halt';
212
+ /** The attribute-bearing paths surfaced to the user / human gate. */
213
+ attributePaths: string[];
214
+ /** The integration tip BEFORE the halt (= the foundation tip; nothing advanced). */
215
+ integrationTip: string;
216
+ } | {
217
+ /**
218
+ * (Codex FIX D) — the repo carries a non-empty `$GIT_DIR/info/grafts` file. Grafts are a
219
+ * SEPARATE, deprecated fake-parent mechanism that `GIT_NO_REPLACE_OBJECTS=1` does NOT
220
+ * disable (proven vs real git 2.50.1: a graft still rewrites `rev-list --parents` /
221
+ * `merge-base` reachability under the full W2 hermetic env), so they corrupt the parent
222
+ * graph the deterministic merge + the recovery trailer-walk depend on. The train HALTS
223
+ * fail-closed BEFORE any merge/checkout — nothing committed, nothing promoted, user tree
224
+ * untouched. Requires the human to remove/convert the grafts file.
225
+ */
226
+ status: 'grafts_halt';
227
+ /** The resolved grafts file path (a non-secret identifier), surfaced to the human gate. */
228
+ graftsPath: string;
229
+ /** The integration tip BEFORE the halt (= the foundation tip; nothing advanced). */
230
+ integrationTip: string;
231
+ } | {
232
+ /**
233
+ * (Codex r7 FIX B) — the repo is SHALLOW (`.git/shallow` /
234
+ * `git rev-parse --is-shallow-repository`). A shallow boundary makes git pretend recorded
235
+ * parents don't exist, rewriting the merge-base / reachability graph the deterministic merge
236
+ * + the recovery trailer-walk depend on (a SIBLING of the grafts lever that
237
+ * `GIT_NO_REPLACE_OBJECTS=1` does NOT cover — proven vs real git 2.50.1 that the same base +
238
+ * tips clean-merge in a full repo but `refusing to merge unrelated histories` in a shallow
239
+ * one). The train HALTS fail-closed BEFORE any merge/checkout — nothing committed, nothing
240
+ * promoted, user tree untouched. Requires the human to UNSHALLOW the repo (`git fetch
241
+ * --unshallow`).
242
+ */
243
+ status: 'shallow_halt';
244
+ /** The resolved `shallow` file path (a non-secret identifier), surfaced to the human gate. */
245
+ shallowPath: string;
246
+ /** The integration tip BEFORE the halt (= the foundation tip; nothing advanced). */
247
+ integrationTip: string;
248
+ } | {
249
+ /**
250
+ * (Codex r6 FIX 3, HIGH) — the EFFECTIVE git config carries a CUSTOM MERGE DRIVER
251
+ * (`merge.<name>.driver`). W2 never legitimately configures one, so any configured driver is
252
+ * pure attack surface: a track can commit a repo-local `.git/config` `merge.default=keepours`
253
+ * + `merge.keepours.driver=<script>` (the named-default lever — runs on attr-free files,
254
+ * invisible to the `.gitattributes` scan) OR a `[merge "text"] driver=<script>` that SHADOWS
255
+ * the built-in `text` driver the r5 `-c merge.default=text` pin relies on (PROVEN vs real git
256
+ * 2.50.1 this session: the shadow FIRES + silently clean-resolves a conflict). The train HALTS
257
+ * fail-closed BEFORE any merge/recovery/checkout — nothing committed/promoted, user tree
258
+ * untouched. The configured driver NAMES (not the script values) go to the human gate.
259
+ */
260
+ status: 'merge_driver_config_halt';
261
+ /** The configured custom-merge-driver NAMES (non-secret identifiers); never the script values. */
262
+ mergeDriverNames: string[];
263
+ /** The integration tip BEFORE the halt (= the foundation tip; nothing advanced). */
264
+ integrationTip: string;
265
+ };
266
+ /**
267
+ * Run the deterministic ordered merge-train for ONE repo (§4.1 / LOCK #C14-ORDER).
268
+ * Advances the ONE integration branch by merging each ordered track tip onto the
269
+ * current tip, write-ahead-journaled (§3.2). On the FIRST conflict it HALTS (no
270
+ * commit, ref not advanced past slot k-1) and returns `conflict_halt` — W2 has no
271
+ * conflict resolver (that is W3); a conflict is a deterministic dead-end here.
272
+ *
273
+ * `foundation` is the W1 {@link BranchFoundation} (the integration branch at
274
+ * `base_sha`); the train consumes the persistent TRACK branches directly
275
+ * (`trackBranchName`) — there are NO per-track promoted branches (resolved decision
276
+ * #3). `mergeImplId` is the W2 derived id ({@link resolveMergeImplId}).
277
+ *
278
+ * Idempotent on replay (the journal): a re-run after a crash recovers via
279
+ * {@link recoverMergeTrain} FIRST (the caller drives that), then re-merges only the
280
+ * un-landed slots deterministically — identical inputs reproduce the identical
281
+ * commit (off-branch `merge-tree` + `commit-tree` with a fixed message trailer).
282
+ */
283
+ export declare function runMergeTrain(repoDir: string, taskGroupId: string, foundation: BranchFoundation, orderedTracks: readonly MergeTrainTrack[], journal: MergeJournalStore, mergeImplId: string, resolver?: ConflictResolverContext): Promise<MergeTrainOutcome>;
284
+ /**
285
+ * Derive the `merge_gate_id` from the ACTUAL integration-tip inputs (§4.5): a
286
+ * `sha256` over `(base_sha, the ORDERED merged track tips, the final integration
287
+ * TREE)`. A real tip-move (a different ordered set or a different final tree) yields
288
+ * a NEW id → re-validate the gate; a pure replay of identical inputs yields the
289
+ * SAME id → dedup. We use `sha256` (the codebase hash primitive) in lieu of the
290
+ * design's blake3 (the discipline, not a binding algorithm) — same as `computePromoteKey`.
291
+ *
292
+ * AUDIT-ANCHOR identity-alignment (resolved decision #4): W2 DERIVES + surfaces this
293
+ * id but does NOT call `submitMergeGateVerdict` — the id it produces here is the one
294
+ * the eventual live verdict's `mergeGateId` must equal (the audit anchor on the
295
+ * shipped `MergeGateResult` kind).
296
+ */
297
+ export declare function deriveMergeGateId(args: {
298
+ baseSha: string;
299
+ /** The merged track tips IN THE TRAIN ORDER (the ordered set of `theirs` inputs). */
300
+ orderedTrackTips: readonly string[];
301
+ /** The final integration TREE (not the commit — the content the promote lands). */
302
+ finalIntegrationTree: string;
303
+ }): string;
304
+ /**
305
+ * Test-only race-injection hooks for {@link recoverMergeTrain} (mirrors the W1
306
+ * `WorktreeMergeRaceHooks` idiom). Prod passes none. `beforeRewindHook` fires AFTER the
307
+ * PASS-1-observed integration tip is captured but BEFORE the CAS rewind, so a test can move
308
+ * the ref in that exact window and prove the rewind's compare-and-swap REFUSES (M2) rather
309
+ * than blind-clobbering the concurrent move.
310
+ */
311
+ export interface MergeTrainRecoveryHooks {
312
+ beforeRewindHook?: () => void | Promise<void>;
313
+ /**
314
+ * Fires in the all-committed completion path (every slot found landed by PASS-1) right
315
+ * before the tip is ensured (F-01), so a test can delete the branch in that window and
316
+ * prove recovery RECREATES it rather than returning `reconciled` with the branch deleted.
317
+ */
318
+ beforeTipEnsureHook?: () => void | Promise<void>;
319
+ }
320
+ /** A surfaced merge-train recovery outcome (§3.2). */
321
+ export interface MergeTrainRecoveryOutcome {
322
+ taskGroupId: string;
323
+ repoId: string;
324
+ /**
325
+ * - `reconciled` : every started-not-committed slot was reconciled (a landed
326
+ * merge re-recorded via its trailer, or reset+re-merged) →
327
+ * the integration branch is at the deterministic resolved tip.
328
+ * - `blocked` : a re-merge could not complete (e.g. a {@link MergeOrderError}
329
+ * or a CAS/state mismatch) → a TERMINAL surface state; the
330
+ * integration ref is left where it is, reconciliation keeps
331
+ * surfacing it. Never silently completes.
332
+ * - `nothing_to_do` : no started-not-committed slots (a clean/terminal journal).
333
+ */
334
+ resolution: 'reconciled' | 'blocked' | 'nothing_to_do';
335
+ /** The integration tip after recovery (when reconciled). */
336
+ integrationTip?: string;
337
+ /** On `blocked`: the surfaced reason. */
338
+ blockedReason?: string;
339
+ }
340
+ /**
341
+ * Crash-resume the merge-train for one `(group, repo)` (§3.2). For each
342
+ * `merge_started` step WITHOUT a `merge_committed`:
343
+ * - search the integration branch's REACHABLE history BACKWARD for a commit whose
344
+ * `${MERGE_KEY_TRAILER}` trailer == the step's `expected_merge_key`
345
+ * (`git log --grep`). git stores only PARENT pointers, so a forward scan from
346
+ * `pre_tip` is impossible; the backward walk of the reachable history is the valid
347
+ * recovery probe (§3.2 r3-recovery).
348
+ * - FOUND (the merge landed; only the journal write was lost) → write
349
+ * `merge_committed` (NO re-merge).
350
+ * - NOT FOUND → reset the integration branch to the step's `pre_tip` (the W1
351
+ * guarded discipline: a CAS ref rewind + `git clean -fd` of any throwaway
352
+ * worktree — but the train operates OFF-BRANCH with no persistent integration
353
+ * worktree, so the reset is a ref-level rewind) + RE-MERGE deterministically.
354
+ *
355
+ * RESET INVALIDATES LATER SLOTS (§3.2 r4 Codex): a reset to slot k rewinds the
356
+ * integration branch past any LATER slots whose trailer-commit is no longer reachable
357
+ * from the rewound tip — every such later slot is RE-MERGED in order. A later slot
358
+ * whose commit is STILL reachable (the reset didn't rewind past it) is kept.
359
+ *
360
+ * A blocked re-merge (a CAS/state mismatch, a `MergeOrderError`) → `blocked` (the
361
+ * `revert_halted`-equivalent terminal): reconciliation keeps surfacing it, never
362
+ * silently completes. After the recovery transitions, GC the dangling aborted-merge
363
+ * commits via {@link gcDanglingPromptly}.
364
+ *
365
+ * Idempotent on replay: a second recovery over a now-reconciled journal is a no-op.
366
+ */
367
+ export declare function recoverMergeTrain(repoDir: string, taskGroupId: string, repoId: string, journal: MergeJournalStore, mergeImplId: string, hooks?: MergeTrainRecoveryHooks, resolver?: ConflictResolverContext): Promise<MergeTrainRecoveryOutcome>;
368
+ /** A surfaced Tier-1 outcome on the merged integration tip. */
369
+ export interface Tier1Outcome {
370
+ /**
371
+ * - `'pass'` — build/typecheck/tests + declared surfaces all green;
372
+ * - `'fail'` — at least one gate/surface failed;
373
+ * - `'attribute_halt'` — (Stage-2 r2 H2) a path in the FULL integration tree carries a
374
+ * dangerous `.gitattributes` attribute, so the `git worktree add` checkout would run a
375
+ * smudge/encoding/ident filter (or a custom merge driver materialized into the tree) on
376
+ * a file. Tier-1 HALTS BEFORE the checkout — no smudge runs — and the caller surfaces a
377
+ * gate-level `attribute_halt` (the human gate, §4.2 r3-M).
378
+ */
379
+ status: 'pass' | 'fail' | 'attribute_halt';
380
+ /** The gate that failed (when failed): a verification-gate kind or `'declared_tests'`. */
381
+ failedGate?: 'build' | 'tests' | 'typecheck' | 'declared_tests';
382
+ /** A short, content-free reason for the surface (exit codes / gate name only). */
383
+ reason?: string;
384
+ /** On `attribute_halt`: the dangerous-attribute paths in the integration tree (Stage-2 r2 H2). */
385
+ attributePaths?: string[];
386
+ }
387
+ /** Which verification gates Tier-1 runs (§4.4 build + tests; typecheck when configured). */
388
+ export interface Tier1GateConfig {
389
+ build?: boolean;
390
+ tests?: boolean;
391
+ typecheck?: boolean;
392
+ /** Per-gate timeout (ms). */
393
+ timeoutMs?: number;
394
+ }
395
+ /**
396
+ * Tier-1 on the FINAL integration tip (§4.4, LOCK #C14-A): check out the integration
397
+ * tip into a THROWAWAY git worktree (the same `git worktree add` / `remove --force`
398
+ * + `prune` lifecycle workspace-shadow.ts uses for implementor shadows — applied
399
+ * directly here, no `WorkspaceShadow` ceremony, since this worktree is read-only +
400
+ * disposable), then run build/typecheck/tests (`runVerificationGates`' per-gate
401
+ * wrappers) + the UNION of the tracks' declared `test_surfaces`
402
+ * ({@link runDeclaredTestSurfaces}) with `cwd`/`shadowDir` = the integration worktree
403
+ * (reads worktree-confined). PASS/FAIL is derived from exit codes (LE-cannot-lie). On
404
+ * FAIL → surface + NO promote (all-or-nothing, §5). The worktree is torn down in a
405
+ * `finally` regardless of outcome.
406
+ *
407
+ * Resolved-decision note: `runVerificationGates` (verification-runner.ts) requires the
408
+ * live Class-A AppSync emitter pipeline — coupling this STANDALONE flag-gated W2 module
409
+ * to that infra would be wrong. The per-gate WRAPPERS (`runBuildGate`/`runTestsGate`/
410
+ * `runTypecheckGate`) are the worktree-confined primitive that yields PASS/FAIL from
411
+ * exit codes WITHOUT the emit infra — the minimal-correct Tier-1 substrate. The live
412
+ * wiring (a later migration) can route through the full emitter.
413
+ */
414
+ export declare function runTier1OnIntegrationWorktree(repoDir: string, integrationTip: string, tracks: readonly MergeTrainTrack[], config?: Tier1GateConfig): Promise<Tier1Outcome>;
415
+ /** The surfaced result of the full W2 merge gate (train → Tier-1 → promote). */
416
+ export type MergeGateResult = {
417
+ /** Every step landed: train merged, Tier-1 green, the promote landed on the user tree. */
418
+ status: 'promoted';
419
+ integrationTip: string;
420
+ mergeGateId: string;
421
+ promotedTip?: string;
422
+ } | {
423
+ /** A conflict halted the train — nothing promoted, user tree untouched. */
424
+ status: 'conflict_halt';
425
+ haltedSlot: number;
426
+ trackIndex: number;
427
+ conflictPaths: string[];
428
+ } | {
429
+ /**
430
+ * A touched path carries a dangerous `.gitattributes` attribute (Stage-2 r1 H2) —
431
+ * the train HALTED before any merge / Tier-1 checkout; nothing promoted, user tree
432
+ * untouched. The attribute-bearing paths require a human gate (§4.2 r3-M).
433
+ */
434
+ status: 'attribute_halt';
435
+ attributePaths: string[];
436
+ } | {
437
+ /**
438
+ * (Codex FIX D) — the repo carries a non-empty `$GIT_DIR/info/grafts` file (a deprecated
439
+ * fake-parent mechanism `GIT_NO_REPLACE_OBJECTS=1` does NOT disable). The train HALTED
440
+ * before any merge / recovery / checkout; nothing promoted, user tree untouched. The
441
+ * grafts file must be removed/converted (human gate).
442
+ */
443
+ status: 'grafts_halt';
444
+ graftsPath: string;
445
+ } | {
446
+ /**
447
+ * (Codex r7 FIX B) — the repo is SHALLOW (`.git/shallow` /
448
+ * `git rev-parse --is-shallow-repository`), a parent-graph-rewrite lever sibling to grafts
449
+ * (`GIT_NO_REPLACE_OBJECTS=1` does NOT cover it). The gate HALTED fail-closed BEFORE recovery /
450
+ * any merge / checkout; nothing promoted, user tree untouched. The repo must be unshallowed
451
+ * (`git fetch --unshallow`) (human gate).
452
+ */
453
+ status: 'shallow_halt';
454
+ shallowPath: string;
455
+ } | {
456
+ /**
457
+ * (Codex r6 FIX 3, HIGH) — the effective git config carries a CUSTOM MERGE DRIVER
458
+ * (`merge.<name>.driver`), which W2 never legitimately uses. The gate HALTED fail-closed
459
+ * BEFORE recovery / any merge / checkout (the scan runs at the gate entry, ahead of
460
+ * `recoverMergeTrain`'s `merge-tree`). Nothing promoted, user tree untouched. The configured
461
+ * driver must be removed (human gate). Closes BOTH the named-default
462
+ * (`merge.default=keepours` + `merge.keepours.driver`) AND the shadow-builtin
463
+ * (`merge.text.driver`) levers in one rule.
464
+ */
465
+ status: 'merge_driver_config_halt';
466
+ mergeDriverNames: string[];
467
+ } | {
468
+ /** Tier-1 failed on the merged tip — nothing promoted, user tree untouched. */
469
+ status: 'tier1_fail';
470
+ integrationTip: string;
471
+ mergeGateId: string;
472
+ failedGate?: string;
473
+ reason?: string;
474
+ } | {
475
+ /** The promote aborted (a preflight overlap) — user tree byte-identical. */
476
+ status: 'promote_aborted';
477
+ integrationTip: string;
478
+ mergeGateId: string;
479
+ reason?: string;
480
+ conflictPaths?: string[];
481
+ } | {
482
+ /**
483
+ * Wave B (§2.2) — the train auto-resolved some conflicts but at least one
484
+ * conflicting path is class-3 (route-to-human): the WHOLE slot escalated
485
+ * (LOCK #C14-AON), nothing committed past slot k-1, nothing promoted, user
486
+ * tree untouched. Terminal FAIL → the existing convergence path.
487
+ */
488
+ status: 'conflict_human_gate';
489
+ haltedSlot: number;
490
+ trackIndex: number;
491
+ gated: {
492
+ path: string;
493
+ trigger: string;
494
+ reason: string;
495
+ }[];
496
+ } | {
497
+ /**
498
+ * Wave B (§2.3) — the mandatory final-tip Tier-2 reviewer REJECTED the
499
+ * integration tip (a class-2 LLM resolution was present). Nothing promoted,
500
+ * user tree untouched (#C14-AON). Terminal FAIL → convergence.
501
+ */
502
+ status: 'tier2_reject';
503
+ integrationTip: string;
504
+ mergeGateId: string;
505
+ reason?: string;
506
+ } | {
507
+ /**
508
+ * Wave B (§2.3, LOCK #C14-MOAT) — the final-tip Tier-2 trigger fired (a
509
+ * class-2 byte is present) but it could NOT be satisfied: the
510
+ * `finalTier2Reviewer` is absent / its audit scope is missing, the reviewer
511
+ * cannot run CONFINED (§2.1 path C), OR the resolution set is unprovable
512
+ * against the §4.5 records (a Tier-2 PASS cannot launder a missing audit
513
+ * record). Fail closed — NOTHING promoted, user tree untouched. Terminal FAIL.
514
+ */
515
+ status: 'tier2_unavailable';
516
+ integrationTip: string;
517
+ mergeGateId: string;
518
+ reason?: string;
519
+ } | {
520
+ /** A recovery left the train BLOCKED (terminal surface) — nothing promoted. */
521
+ status: 'blocked';
522
+ reason?: string;
523
+ };
524
+ /** Inputs to {@link runWorktreeMergeGate} — the full all-or-nothing W2 sequence. */
525
+ export interface WorktreeMergeGateArgs {
526
+ repoDir: string;
527
+ taskGroupId: string;
528
+ foundation: BranchFoundation;
529
+ tracks: readonly MergeTrainTrack[];
530
+ journal: MergeJournalStore;
531
+ /**
532
+ * The W1 promote step — injected so this module stays decoupled from the
533
+ * worktree-merge promote signature (and so tests can drive it without the WAL/git
534
+ * promote machinery when only the train/Tier-1 paths are under test). Production
535
+ * wires `promoteIntegration` (W1). On a non-`promoted` promote outcome the gate
536
+ * surfaces `promote_aborted` (the user tree is byte-identical).
537
+ */
538
+ promote: (integrationTip: string) => Promise<{
539
+ status: 'promoted' | 'aborted';
540
+ promotedTip?: string;
541
+ abortReason?: string;
542
+ conflictPaths?: string[];
543
+ }>;
544
+ /** Tier-1 gate config (default build + tests). */
545
+ tier1?: Tier1GateConfig;
546
+ /**
547
+ * Wave B (§2.2) — the conflict resolver context. PRESENT (worktree_merge +
548
+ * confinement precondition holds) → a class-2 (LLM-assisted) conflict is
549
+ * auto-resolved + the resolution set recorded; forwarded to BOTH the live train
550
+ * and the recovery re-merge. ABSENT → byte-identical halt-on-conflict (the
551
+ * legacy/unconfined path; `resolver === undefined`).
552
+ */
553
+ resolver?: ConflictResolverContext;
554
+ /**
555
+ * Wave B (§2.3, LOCK #C14-FINAL-TIER2 / #C14-MOAT) — the INJECTED final-tip
556
+ * Tier-2 reviewer. The gate cannot call the reviewer path directly
557
+ * (`QuorumLoop`/`ReviewerRegistry`); the desktop wires this to a real reviewer
558
+ * dispatch over the final integration diff (base → tip). It MUST itself run
559
+ * CONFINED (§2.1 (A)/(B)) — it returns `confined: false` when it cannot (path
560
+ * C), which the gate treats as fail-closed NO-PROMOTE. When the Tier-2 trigger
561
+ * fires and this is ABSENT, the scope (`ownerTaskId`) is missing, the reviewer
562
+ * is unconfined, or the resolution set is unprovable → the gate does NOT promote.
563
+ */
564
+ finalTier2Reviewer?: (args: {
565
+ ownerTaskId: string;
566
+ repoDir: string;
567
+ baseSha: string;
568
+ integrationTip: string;
569
+ /**
570
+ * CP-14 WB2 §2.4 — the AGENTIC resolver agents this gate (the incoming tracks'
571
+ * implementors that resolved a class-2 byte). The reviewer dispatch picks the
572
+ * strongest HOST-DETECTED reviewer that is best-effort INDEPENDENT of these
573
+ * (#C14-WB2-TIER2-INDEPENDENT); empty/absent → just the strongest detected. The
574
+ * Tier-2 trigger + fail-closed posture are UNCHANGED (still ALWAYS on class-2).
575
+ */
576
+ resolverAgents?: ReadonlySet<string>;
577
+ /**
578
+ * CP-14 WB2 §2.6 (additive) — the per-conflict 3-way CONTENT (base/ours/theirs)
579
+ * of every agentic-resolved slot + each track's INTENT diff (base → trackTip),
580
+ * folded into the reviewer prompt so it can verify BOTH tracks' intents survived.
581
+ * ALL OPTIONAL: absent (a pre-§2.6 caller, or the path-C branch) ⇒ today's bare
582
+ * base→tip diff (graceful degrade). The dispatcher fails closed (NO-PROMOTE) if
583
+ * the rendered bundle exceeds the aggregate ceiling.
584
+ */
585
+ conflictBundle?: readonly RenderedConflict[];
586
+ trackIntentDiffs?: readonly TrackIntentDiff[];
587
+ }) => Promise<{
588
+ verdict: 'pass' | 'reject';
589
+ confined: boolean;
590
+ reason?: string;
591
+ }>;
592
+ /**
593
+ * Wave B (§2.3) — the merge-gate audit scope the Tier-2 reviewer (+ the §2.1
594
+ * resolver) carry (Stage-2 r2 codex LOW). When the Tier-2 trigger fires and this
595
+ * is absent, the gate fails closed (NO-PROMOTE) — an LLM byte never promotes
596
+ * without a scoped, confined Tier-2.
597
+ */
598
+ ownerTaskId?: string;
599
+ }
600
+ /**
601
+ * The full W2 all-or-nothing merge gate (§5 / LOCK #C14-AON). The sequence is:
602
+ * (1) recover any in-flight train (crash-resume, §3.2) — blocked → surface, no promote;
603
+ * (2) the deterministic ordered TRAIN — a conflict HALTS (user tree untouched);
604
+ * (3) Tier-1 on the merged integration worktree — a fail HALTS (user tree untouched);
605
+ * (4) ONE `promoteIntegration` lands the integration tip on the user tree.
606
+ * The group is treated as `joint` (the #589-preserving default; `independent`/
607
+ * `convergence` validation is W3). A halt at (1)/(2)/(3) leaves the user tree
608
+ * byte-identical (clean by construction — the train + Tier-1 never touch it).
609
+ *
610
+ * `merge_gate_id` is derived from the real integration-tip inputs (§4.5) and surfaced
611
+ * on every post-train outcome; W2 does NOT call `submitMergeGateVerdict` (that is the
612
+ * live `runMergeGate`'s wired job — resolved decision #4).
613
+ */
614
+ export declare function runWorktreeMergeGate(args: WorktreeMergeGateArgs): Promise<MergeGateResult>;
615
+ /**
616
+ * Fail-closed PRE-CHECKOUT FULL-TREE scan of the FINAL integration tip (Stage-2 r2 H2).
617
+ *
618
+ * The pre-merge {@link scanDangerousAttributes} only covers the base→tip TOUCHED paths —
619
+ * the surface the `merge-tree` 3-way merge actually combines. But the Tier-1 `git worktree
620
+ * add` checks out the ENTIRE integration tree and runs smudge/`working-tree-encoding`/
621
+ * `ident` filters (and would materialize the result of any `merge=` driver) on EVERY file,
622
+ * touched or not. The H2 attack: a track adds ONLY `.gitattributes` mapping an UNTOUCHED
623
+ * base file (e.g. `victim.txt`) to `filter=<evil>` → the touched set = `{.gitattributes}`
624
+ * (the pre-merge scan passes) → the `worktree add` checkout runs the smudge filter on the
625
+ * untouched `victim.txt` (arbitrary code). The merge-only reasoning that "an untouched file
626
+ * is a no-op" holds for the MERGE but NOT the CHECKOUT, which materializes the whole tree.
627
+ *
628
+ * So before the disposable Tier-1 worktree is added, enumerate ALL paths in the integration
629
+ * tree (`git ls-tree -r --name-only -z <integrationTip>`) and `git check-attr -a -z
630
+ * --source=<integrationTip>` them against {@link DANGEROUS_MERGE_ATTRS}; ANY dangerous attr
631
+ * on ANY path → HALT (the caller surfaces `attribute_halt`), so no smudge/encoding/ident
632
+ * filter runs on any file. `--source=<integrationTip>` resolves the attributes against the
633
+ * COMMITTED tree (the same `.gitattributes` the checkout would honor), reading the OBJECT
634
+ * STORE — the scan itself runs no filter. Fail-closed: a `ls-tree`/`check-attr` error or an
635
+ * older git without `--source` flags the slice / returns a marker → HALT (never silently
636
+ * proceeds past an undeterminable attribute, never lets a smudge run).
637
+ *
638
+ * Determinism + zero-knowledge: lists only PATHS (non-secret), never content.
639
+ */
640
+ export declare function scanIntegrationTreeAttributes(repoDir: string, integrationTip: string): Promise<string[]>;
641
+ /** Thrown when a recovery-rewind CAS loses the race (the integration ref moved). */
642
+ export declare class RefCasMismatchError extends Error {
643
+ readonly ref: string;
644
+ readonly expectedOldSha: string;
645
+ constructor(ref: string, expectedOldSha: string);
646
+ }
647
+ /**
648
+ * The verified final-tip Tier-2 decision (Wave B §2.3, LOCK #C14-FINAL-TIER2 /
649
+ * #C14-W3-TIER2-AUTHORITY / #C14-MOAT). The skip-Tier-2 NEGATIVE is the dangerous
650
+ * direction (a stale/corrupt index claiming "all class-1" would promote an
651
+ * unreviewed LLM byte), so it is PROVEN — never trusted from a bare bit:
652
+ * - `skip` — no resolution, or every resolved conflict verified class-1
653
+ * against the §4.5 records + the committed tree → Tier-1 only.
654
+ * - `tier2` — a verified class-2 (LLM) resolution is present → mandatory
655
+ * final-tip Tier-2 before promote.
656
+ * - `no_promote` — the resolution set could not be reconstructed+verified from
657
+ * the durable §4.5 records (a missing/tampered record, a
658
+ * composed-bytes-vs-tree mismatch, an unreadable history) →
659
+ * fail closed; a Tier-2 PASS cannot launder a missing audit
660
+ * record (Stage-2 r3 codex MED-1).
661
+ */
662
+ export type FinalTier2Decision = {
663
+ decision: 'skip';
664
+ reason: string;
665
+ } | {
666
+ decision: 'tier2';
667
+ reason: string;
668
+ /**
669
+ * CP-14 WB2 §2.4 — the set of AGENTIC resolver agents (the incoming tracks'
670
+ * implementors) that resolved a class-2 byte in the authenticated integration
671
+ * history. The gate picks a best-effort INDEPENDENT Tier-2 reviewer that is not
672
+ * among these when another host-detected agent is available (#C14-WB2-TIER2-INDEPENDENT).
673
+ * Empty when the only class-2 resolutions were legacy (deterministic/legacy-llm).
674
+ */
675
+ resolverAgents: ReadonlySet<string>;
676
+ /**
677
+ * CP-14 WB2 §2.6 — the per-conflict 3-way CONTENT (base/ours/theirs) of every
678
+ * agentic-resolved slot, re-derived in the verify walk ({@link verifyAgenticSlot})
679
+ * from the slot's re-conflicted parents + the merge-base, byte-bounded per side
680
+ * (Q-RENDER-SITE locked). Folded into the Tier-2 reviewer prompt so the reviewer
681
+ * judges whether the LLM resolution combined BOTH sides faithfully. A REQUIRED side
682
+ * that cannot render within budget → NO-PROMOTE (the walk returns no_promote).
683
+ */
684
+ conflictBundle: RenderedConflict[];
685
+ } | {
686
+ decision: 'no_promote';
687
+ reason: string;
688
+ };
689
+ /**
690
+ * Cheap, bounded check: does `base_sha..integration_tip` contain ANY resolved-slot
691
+ * commit (one carrying a {@link RESOLUTION_SET_TRAILER})? Used as the gate's
692
+ * fail-closed backstop when NO audit context is available this run (Stage-2 r1
693
+ * codex HIGH — a path-C resume must not promote a prior run's resolved bytes
694
+ * unreviewed). FAILS CLOSED (returns `true`) on any enumeration error — an
695
+ * unreadable history is treated as possibly-carrying resolved bytes.
696
+ */
697
+ export declare function integrationHistoryHasResolutionTrailer(repoDir: string, baseSha: string, integrationTip: string): Promise<boolean>;
698
+ /**
699
+ * Decide whether the final integration tip requires a mandatory final-tip Tier-2
700
+ * re-pass (Wave B §2.3). Walks `base_sha..integration_tip` STRICTLY (never past
701
+ * base into a prior promoted group — Stage-2 r2 agy MED), and for every
702
+ * resolved-slot commit (one carrying a {@link RESOLUTION_SET_TRAILER}) PROVES the
703
+ * resolution set against the §4.5 source records + the committed tree before
704
+ * trusting any skip. See {@link FinalTier2Decision}.
705
+ */
706
+ export declare function requiresFinalTier2(args: {
707
+ repoDir: string;
708
+ baseSha: string;
709
+ integrationTip: string;
710
+ repoId: string;
711
+ mergeImplId: string;
712
+ ctx: ConflictResolverContext;
713
+ }): Promise<FinalTier2Decision>;