@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,601 @@
1
+ import type { ConflictFileMeta } from './conflict-types';
2
+ import { PromoteWalStore, type PromoteMode, type PromoteWalRecord } from './promote-wal-store';
3
+ /**
4
+ * The pinned merge-implementation id (§4.2) folded into the promote key. W1 pins
5
+ * the host git version + the determinism contract id; a change yields a new key
6
+ * → no stale cross-version replay.
7
+ *
8
+ * W1's promote has NO hunk segmentation, so a STATIC pin is sound here (the
9
+ * `TODO(W2)`'s own observation): the promote key only needs a stable per-build
10
+ * identity. W2's merge-train IS hunk-segmentation-sensitive, so it derives a
11
+ * VERSION-AWARE id via {@link resolveMergeImplId} (the W2 finalization of the
12
+ * TODO) — a host-git upgrade whose diff3/ort hunk boundaries differ yields a new
13
+ * key → a cache-miss → re-resolve, never a stale cross-version replay. W1's promote
14
+ * path keeps using this static const (byte-identical); only W2's train uses the
15
+ * derived id.
16
+ */
17
+ export declare const MERGE_IMPL_ID = "git-host-v1";
18
+ /**
19
+ * Resolve the W2 merge-implementation id (§4.2, the finalization of the W1
20
+ * `MERGE_IMPL_ID` TODO). Derives from the REAL host `git --version` folded with the
21
+ * {@link DETERMINISM_CONTRACT_ID} → `git-<version>+<DETERMINISM_CONTRACT_ID>`. A host-git
22
+ * upgrade whose hunk segmentation differs across versions yields a DIFFERENT id, so
23
+ * the merge journal's `expected_merge_key` (which folds in `merge_impl_id`) and any
24
+ * version-sensitive replay change → re-merge, never a stale cross-version replay.
25
+ *
26
+ * Cached per process (the host git binary does not change mid-run). On a failure to
27
+ * read `git --version` it falls back to the static {@link MERGE_IMPL_ID} (fail-safe:
28
+ * a stable id, never a throw). NOT a vendored merge impl — the design's "preferred"
29
+ * vendored option is a later choice; W2 pins the host git version, which is the
30
+ * minimal-correct, deterministic finalization.
31
+ */
32
+ export declare function resolveMergeImplId(): Promise<string>;
33
+ /** Branch namespaces (§3.1). */
34
+ export declare function trackBranchName(taskGroupId: string, trackIndex: number): string;
35
+ export declare function integrationBranchName(taskGroupId: string, repoId: string): string;
36
+ export declare function stashBranchName(taskGroupId: string, repoId: string): string;
37
+ /** The ref pinning the durable UNTRACKED-files tree (HIGH-1) so GC can't reap it. */
38
+ export declare function untrackedTreeRefName(taskGroupId: string, repoId: string): string;
39
+ /**
40
+ * The ref pinning the expected POST-PROMOTE WORKTREE snapshot tree (W1 Stage-2
41
+ * H1/H2/H3) so GC can't reap it before a revert/recovery drift-check needs it.
42
+ */
43
+ export declare function worktreeSnapshotRefName(taskGroupId: string, repoId: string): string;
44
+ /**
45
+ * The ref pinning the PRE-PROMOTE WORKTREE snapshot tree (W1 Stage-2 H6) so GC
46
+ * can't reap it before crash recovery's divergence guard needs it.
47
+ */
48
+ export declare function prePromoteSnapshotRefName(taskGroupId: string, repoId: string): string;
49
+ export declare function rescueRefName(taskGroupId: string, repoId: string): string;
50
+ /**
51
+ * Stage-2 H2 (W1 FINAL) — the durable GC-anchor for the off-branch `dirty_committed`
52
+ * merge/candidate commit. {@link commitTreeOffBranch} produces an otherwise-unreferenced
53
+ * commit; until {@link PromoteWalStore.writeCommitted} records its SHA, it is reachable
54
+ * ONLY via detached `HEAD` (and even after commit the WAL stores the SHA, not a GC root).
55
+ * If the user checks out a branch (HEAD becomes symbolic) before a recovery/revert pins a
56
+ * rescue ref, a `git gc --prune=now` would prune the merge commit and strand the WAL's
57
+ * recovery target (reproduced against real git 2.50.x). So the candidate commit is pinned
58
+ * here IMMEDIATELY when created (BEFORE the landing CAS) and only deleted at terminal
59
+ * cleanup ({@link cleanupGroupRepo}); recovery resolves the promoted tip from this ref when
60
+ * the WAL's `promotedTip` is null (a crash after the CAS, before `writeCommitted`).
61
+ */
62
+ export declare function promotedTipRefName(taskGroupId: string, repoId: string): string;
63
+ /**
64
+ * Stage-2 H2 (W1 round-15) — a SECOND rescue ref for the post-CAS `guard-refused`
65
+ * detached-promote case. When a DETACHED promote's revert/recovery has ALREADY CAS-moved
66
+ * the literal `HEAD` back to `pre_promote_user_ref` and the user THEN checks out a branch
67
+ * (HEAD becomes symbolic) before `restorePrePromote`'s reset, the guard refuses. The
68
+ * PRIMARY {@link rescueRefName} must pin the PRE-CAS recoverable tip (the promoted/crash
69
+ * commit — otherwise it survives only in reflog/WAL text). If the live (now-symbolic) tip
70
+ * the user switched to is DIFFERENT and not already reachable from the primary rescue, it
71
+ * is ALSO pinned here so neither the promoted work NOR the live tip is orphaned.
72
+ */
73
+ export declare function rescueLiveRefName(taskGroupId: string, repoId: string): string;
74
+ export declare function treeOf(repoDir: string, commitish: string, opts?: {
75
+ hermetic?: boolean;
76
+ }): Promise<string>;
77
+ /**
78
+ * W2 seam — run a git command under the SAME pinned, deterministic
79
+ * {@link PINNED_GIT_CONFIG} every CP-14 op uses (§4.2). Exported so the merge-train
80
+ * engine (merge-train.ts) shares the EXACT pinned invocation (no divergent config)
81
+ * without re-exporting the bare module-private {@link git}. `allowFail` mirrors the
82
+ * internal helper: a non-zero exit returns its stdout/stderr/code instead of throwing.
83
+ *
84
+ * W2 Stage-2 r3 (H1 + M1): the W2 seam ALWAYS runs HERMETIC — `hermetic: true` disables
85
+ * git hooks (`core.hooksPath=/dev/null`, so the Tier-1 `worktree add` checkout cannot run a
86
+ * track-committed `post-checkout`/other hook) AND scrubs the inherited ambient `GIT_*`
87
+ * redirect vars (so an ambient `GIT_DIR`/`GIT_OBJECT_DIRECTORY`/etc. cannot redirect the
88
+ * train off the intended repo). Every W2 git call routes through here, so EVERY W2
89
+ * checkout/ref/merge op is hooks-disabled + env-scrubbed. W1 keeps using the bare
90
+ * module-private {@link git} (no `hermetic`), so it is byte-identical.
91
+ */
92
+ export declare function pinnedGit(repoDir: string, args: readonly string[], opts?: {
93
+ allowFail?: boolean;
94
+ }): Promise<{
95
+ stdout: string;
96
+ stderr: string;
97
+ code: number;
98
+ }>;
99
+ /**
100
+ * CP-14 WB2 — a HERMETIC git invocation that accepts STDIN (the `git()` helper
101
+ * uses `execFile`, which cannot pipe stdin). Same hardening as {@link pinnedGit}:
102
+ * the W2 `-c` config pins + the {@link sanitizeGitEnv} allowlist env (no ambient
103
+ * `GIT_*`, replace-refs disabled), so an agent-controlled disposable `.git` /
104
+ * source config cannot inject a hook/redirect. Used to feed an OID list to
105
+ * `pack-objects` for the disposable-repo object import (NO clone / upload-pack).
106
+ * `stdout` is captured as text (the OID-list/pack-objects path writes pack FILES,
107
+ * not binary stdout).
108
+ */
109
+ export declare function pinnedGitWithInput(repoDir: string, args: readonly string[], input: string, opts?: {
110
+ allowFail?: boolean;
111
+ }): Promise<{
112
+ stdout: string;
113
+ stderr: string;
114
+ code: number;
115
+ }>;
116
+ /** The result of standing up the per-group branch foundation for one repo. */
117
+ export interface BranchFoundation {
118
+ repoId: string;
119
+ baseSha: string;
120
+ integrationBranch: string;
121
+ integrationTip: string;
122
+ }
123
+ /**
124
+ * Codex #6 (round-7) — thrown when a `create*Branch` REPLAY finds the branch already
125
+ * present at a SHA that is NOT the expected `base_sha` AND is NOT reachable-from-base
126
+ * (so it carries commits a force-reset would orphan). The caller surfaces it instead of
127
+ * silently force-resetting the accumulated work.
128
+ */
129
+ export declare class BranchStateMismatchError extends Error {
130
+ readonly branch: string;
131
+ readonly expectedBaseSha: string;
132
+ readonly actualSha: string;
133
+ constructor(branch: string, expectedBaseSha: string, actualSha: string);
134
+ }
135
+ /**
136
+ * Stand up the per-repo INTEGRATION branch at `base_sha` (§3.1 item 2). W1 does
137
+ * NOT merge onto it (that is W2); it creates the branch + records the base
138
+ * snapshot so W2 has a deterministic root.
139
+ *
140
+ * Codex #6 (round-7) — CREATE-ONLY (not force-update). A replay over an integration
141
+ * branch that has accumulated commits (W2 merge-train work) must NOT force-reset it back
142
+ * to `base_sha` (orphaning that work). Create when absent; when present, leave it (an
143
+ * idempotent re-create at base, or a legitimate base-rooted advance) and return its LIVE
144
+ * tip — or surface a {@link BranchStateMismatchError} on a divergent branch.
145
+ */
146
+ export declare function createIntegrationBranch(repoDir: string, taskGroupId: string, repoId: string, baseSha: string): Promise<BranchFoundation>;
147
+ /**
148
+ * Create the persistent per-(track,repo) TRACK branch at `base_sha` (§3.1 item 1).
149
+ * The implementor's worktree-shadow (workspace-shadow.ts) commits onto it. W1
150
+ * just stands the branch up; the shadow lifecycle is reused unchanged.
151
+ *
152
+ * Codex #6 (round-7) — CREATE-ONLY (not force-update). A replay over a track branch the
153
+ * implementor's shadow already committed onto must NOT force-reset it back to `base_sha`
154
+ * (orphaning the implementor's commits). Create when absent; when present, leave it
155
+ * untouched (an idempotent re-create at base, or a base-rooted advance) — or surface a
156
+ * {@link BranchStateMismatchError} on a divergent branch.
157
+ */
158
+ export declare function createTrackBranch(repoDir: string, taskGroupId: string, trackIndex: number, baseSha: string): Promise<string>;
159
+ /** A surfaced, non-throwing promote outcome (atomic-or-nothing). */
160
+ export interface PromoteOutcome {
161
+ /** `'promoted'` — the user tree advanced; `'aborted'` — nothing changed + surfaced. */
162
+ status: 'promoted' | 'aborted';
163
+ promoteMode: PromoteMode;
164
+ /** The adopted HEAD (when promoted). */
165
+ promotedTip?: string;
166
+ /**
167
+ * When aborted: the human-readable reason + the overlapping/conflicting paths
168
+ * the caller surfaces. The user tree is byte-identical to its pre-promote state.
169
+ */
170
+ abortReason?: string;
171
+ conflictPaths?: string[];
172
+ }
173
+ /**
174
+ * Codex #1/#2 — a test-only seam to drive the compare-and-swap race deterministically.
175
+ * The TOCTOU window the fix closes lives BETWEEN the surrounding code reading the
176
+ * live ref/state and the destructive mutation. Production passes no hook; a test
177
+ * passes `beforeMutateHook` to fire EXACTLY inside that window (e.g. to commit a
178
+ * concurrent user change) so the test asserts the CAS / re-validate actually
179
+ * refuses-and-rescues against REAL git, not a mock. Never used in production.
180
+ */
181
+ export interface WorktreeMergeRaceHooks {
182
+ /** Fires immediately before the first destructive ref/tree mutation (in-window). */
183
+ beforeMutateHook?: () => void | Promise<void>;
184
+ /**
185
+ * agy HIGH — fires inside `promoteDirtyUncommitted` AFTER the ref CAS-advanced to
186
+ * integration_tip but BEFORE the `read-tree -m -u` rollback path, so a test can both
187
+ * force a read-tree refusal AND move the ref in the rollback window (proving the
188
+ * rollback-CAS-failure → rescue, never-blind-restore guarantee). ALSO drives the
189
+ * round-5 post-CAS BRANCH-SWITCH race (Codex #1): a same-SHA `git checkout` here makes
190
+ * `read-tree -m -u` target the WRONG branch — the `guardedWorktreeSync` re-check must
191
+ * refuse. Never used in prod.
192
+ */
193
+ beforeReadTreeRollbackHook?: () => void | Promise<void>;
194
+ /**
195
+ * Codex #2 (round-5) — fires inside `revertToPrePromote` / `recoverPromote` AFTER the
196
+ * CAS ref-move to `pre_promote_user_ref` but BEFORE the `restorePrePromote` guarded
197
+ * `reset --hard`, so a test can switch HEAD to a same-SHA branch IN that window and
198
+ * prove the restore's symbolic-ref re-check refuses (never rewinds the wrong branch).
199
+ * Never used in prod (typed seam, no live caller).
200
+ */
201
+ beforeRestoreResetHook?: () => void | Promise<void>;
202
+ /**
203
+ * Round-6 (Codex #4) — fires inside `promoteClean` / `promoteDirtyCommitted` AFTER the
204
+ * landing CAS advanced the user branch to the promoted tip but BEFORE the
205
+ * `syncWorktreeToRef` worktree sync, so a test can switch HEAD to a same-SHA sibling
206
+ * branch IN that post-CAS window and prove the landing sync's guard refuses AND the
207
+ * advanced ref is rolled back to `pre_promote_user_ref` (atomic-or-nothing — the
208
+ * branch ref must NOT stay moved when the promote reports aborted, LOCK
209
+ * #C14-PROMOTE-ATOMIC). Never used in prod (typed seam, no live caller).
210
+ */
211
+ beforeWorktreeSyncHook?: () => void | Promise<void>;
212
+ /**
213
+ * Round-7 (Codex #2 + agy MEDIUM) — fires inside a guarded destructive callback
214
+ * IMMEDIATELY before EACH `recheck()` (i.e. between two destructive commands of the
215
+ * SAME callback: between `reset --hard` and `clean -fd`; between the untracked
216
+ * `checkout` and the un-stage `reset`; before the stash-apply fallback). A test
217
+ * switches HEAD to a same-SHA branch here to prove the per-command re-check refuses
218
+ * the SECOND command (no wrong-branch `clean`/`reset`/`stash apply`). Never used in
219
+ * prod (typed seam, no live caller).
220
+ */
221
+ betweenDestructiveCommandsHook?: () => void | Promise<void>;
222
+ /**
223
+ * Round-7 (Codex #2 + agy MEDIUM) — fires inside `restorePrePromote` AFTER the
224
+ * guarded `reset --hard` + `clean -fd` completed but BEFORE the now-IN-GUARD
225
+ * `stash apply` runs, so a test can switch HEAD to a same-SHA branch in that window
226
+ * and prove the stash-apply guard refuses (no wrong-branch `stash apply`). The
227
+ * PRE-FIX code ran `stash apply` OUTSIDE any guard. Never used in prod.
228
+ */
229
+ beforeStashApplyHook?: () => void | Promise<void>;
230
+ /**
231
+ * Stage-2 H1 (W1 round-14, Codex HIGH) (FAIL-ON-OLD) — fires inside `restorePrePromote`
232
+ * in the window AFTER `git stash apply --index` REFUSED but BEFORE the point where the
233
+ * PRE-FIX code ran the plain `stash apply` fallback (a SECOND destructive worktree mutation
234
+ * after the first failed, guarded by ONLY the 3 specific checks — symbolic-ref/ref-at/
235
+ * ignored — so a tracked/staged user change landing here was invisible and the fallback
236
+ * could merge/overwrite it). A test stages/edits a stash-surface path here; with the
237
+ * fail-closed fix (NO plain apply: status=`conflicted`, the durable stash ref surfaced) the
238
+ * in-window bytes/index SURVIVE untouched. Against the pre-fix code the plain apply runs and
239
+ * clobbers them (the test FAILS). Never used in prod (typed seam, no live caller).
240
+ */
241
+ betweenStashIndexApplyAndFallbackHook?: () => void | Promise<void>;
242
+ /**
243
+ * Round-11 (Codex HIGH H3) — fires inside `restorePrePromote` AFTER the untracked
244
+ * `checkout <tree> -- .` pre-op anchor is captured but BEFORE `restoreUntrackedTree`
245
+ * runs the checkout, so a test can create a NON-IGNORED file in that window and prove
246
+ * the (now-anchored) untracked-checkout guard refuses (`pre-op-drift`) instead of
247
+ * overwriting it. The pre-fix code passed NO anchor to the untracked checkout. Never
248
+ * used in prod (typed seam, no live caller).
249
+ */
250
+ beforeUntrackedCheckoutHook?: () => void | Promise<void>;
251
+ /**
252
+ * Stage-2 H1 (W1 round-13, Codex HIGH) (FAIL-ON-OLD) — fires inside `restorePrePromote` in
253
+ * the PRE-CAPTURE window of the untracked re-materialize: AFTER the guarded stash apply (or,
254
+ * with no stash, the reset/clean) completes but BEFORE the point where the PRE-FIX code
255
+ * captured the LIVE untracked-checkout anchor (`capturePreOpAnchor`) — the exact window an
256
+ * external process writes a file at a path the durable untracked tree carries. With the Stage-2
257
+ * H1 fix the anchor is RECONSTRUCTED from recorded inputs (no-stash → `prePromoteUserRef` tree;
258
+ * clean `--index` apply → `stash^{tree}` + `stash^2^{tree}`), so a write here makes
259
+ * `live ≠ reconstructed` → `pre-op-drift` → the checkout never runs → the file is PRESERVED.
260
+ * Against the pre-fix live-capture code the write is ADOPTED into the anchor and the checkout
261
+ * clobbers it (the test FAILS). Distinct from `beforeUntrackedCheckoutHook`, which fires AFTER
262
+ * the (former) live capture (covering only the post-capture window). Never used in prod.
263
+ */
264
+ beforeUntrackedCheckoutAnchorHook?: () => void | Promise<void>;
265
+ /**
266
+ * Round-7 (Codex #4) — fires inside each promote mode AFTER the landing CAS + worktree
267
+ * sync succeeded (the ref is at the promoted tip) but BEFORE `recordPostPromoteState`
268
+ * / `writeCommitted`. A test THROWS from here to simulate a post-mutation
269
+ * snapshot/WAL-write failure, proving the generic promote-error path rolls the
270
+ * CAS-advanced ref BACK to pre-promote + marks the WAL terminal (never leaves the
271
+ * branch promoted + the WAL `promote_started`). Never used in prod.
272
+ */
273
+ afterLandingBeforeCommitHook?: () => void | Promise<void>;
274
+ /**
275
+ * Codex r12 H1 (FAIL-ON-OLD) — fires in the PRE-CAPTURE WINDOW of the landing sync /
276
+ * read-tree / restore reset: AFTER the CAS / pre-reset positioning but BEFORE the point
277
+ * where the PRE-FIX code captured the LIVE `preOpAnchor` (which would have ADOPTED a write
278
+ * landing here and then clobbered it). With the Codex r12 H1 fix the op-site anchor is a
279
+ * RECORDED tree (fixed at promote entry), so a write here makes `live ≠ recorded` →
280
+ * `pre-op-drift` → rescue (the write is PRESERVED). Against the pre-fix live-capture code
281
+ * this hook's write is absorbed into the anchor and clobbered (the test FAILS). Never used
282
+ * in prod (typed seam, no live caller). Distinct from the post-capture
283
+ * `beforeWorktreeSyncHook` / `beforeRestoreResetHook` / `beforeReadTreeRollbackHook`, which
284
+ * only cover the window AFTER the (former) capture.
285
+ */
286
+ beforePreOpAnchorHook?: () => void | Promise<void>;
287
+ /**
288
+ * Stage-1 (W1) H1 (FAIL-ON-OLD) — fires in the BETWEEN-`reset`/`clean` PRE-CAPTURE WINDOW
289
+ * of `syncWorktreeToRef` / `restorePrePromote`: AFTER the guarded `reset --hard` returns but
290
+ * BEFORE the point where the PRE-FIX code captured the LIVE between-command anchor
291
+ * (`capturePreOpAnchor`) — the exact window an external process (the user's shared-worktree
292
+ * IDE) writes a NEW untracked non-ignored file the paired `clean -fd` would then delete. With
293
+ * the W1 fix the between-command anchor is RECONSTRUCTED from RECORDED inputs
294
+ * (`reconstructPostResetAnchor`), so a write here makes `live ≠ reconstructed` → `pre-op-drift`
295
+ * → rescue (the file is PRESERVED). Against the pre-fix live-capture code the write is ADOPTED
296
+ * into the live anchor and `clean -fd` deletes it (the test FAILS). Distinct from
297
+ * `betweenDestructiveCommandsHook` (which fires INSIDE `recheck()`, AFTER the anchor is built,
298
+ * via `onBeforeRecheck` — too late to demonstrate the pre-capture window). Never used in prod.
299
+ */
300
+ beforeCleanRecheckAnchorHook?: () => void | Promise<void>;
301
+ }
302
+ /**
303
+ * Preflight-atomic promote of the integration tip onto the user's tree (§3.1).
304
+ *
305
+ * ALWAYS, before ANY mutation:
306
+ * 1. Capture `pre_promote_user_ref` (the user's current ref value).
307
+ * 2. Stash-commit the user's working-tree+index → `pre_image_manifest_ref`.
308
+ * 3. Write the `promote_started` WAL (mode-aware, keyed on pre-inputs).
309
+ *
310
+ * Then one of three modes (chosen by the user's actual state):
311
+ * - clean : FF ref+index+worktree to `integration_tip`.
312
+ * - dirty-committed : `git merge integration_tip` into the user branch (a
313
+ * merge commit). Preflight the merge — any conflict →
314
+ * abort (promote nothing) + restore the stash + surface.
315
+ * - dirty-uncommitted : preflight the apply-set (incl. UNTRACKED) vs the
316
+ * uncommitted edits; no overlap → advance ref + `read-tree
317
+ * -m -u` to sync index/worktree preserving the edits;
318
+ * overlap → abort + restore stash + surface.
319
+ *
320
+ * Atomic-or-nothing: a preflight abort restores the pre-promote tree (pops the
321
+ * stash, §16 r4-agy) and the user tree is byte-identical to pre-promote.
322
+ */
323
+ export declare function promoteIntegration(repoDir: string, taskGroupId: string, foundation: BranchFoundation, wal: PromoteWalStore, hooks?: WorktreeMergeRaceHooks): Promise<PromoteOutcome>;
324
+ /**
325
+ * The result of an OFF-BRANCH 3-way merge computed by `git merge-tree --write-tree`
326
+ * (Codex #2 / LOCK #C14-PROMOTE-ATOMIC architectural fix): the merge is computed
327
+ * WITHOUT touching any branch ref or the worktree. `clean` carries the merged tree
328
+ * SHA; `conflicted` carries the conflicting paths to surface. NOTHING in the user's
329
+ * repo moved.
330
+ */
331
+ export type MergeTreeResult = {
332
+ kind: 'clean';
333
+ mergedTree: string;
334
+ } | {
335
+ kind: 'conflicted';
336
+ conflictPaths: string[];
337
+ conflictedTree: string;
338
+ };
339
+ /**
340
+ * Codex #2 (LOCK #C14-PROMOTE-ATOMIC) — compute the 3-way merge of two commits
341
+ * OFF-BRANCH via `git merge-tree --write-tree -z <a> <b>`. This writes the merged
342
+ * tree to the object store and prints it, but **moves NO ref and touches NO
343
+ * worktree** — replacing the old in-place `git reset --hard <pre> && git merge` that
344
+ * advanced the user's branch as a non-atomic side effect (so a concurrent commit in
345
+ * the window was orphaned). On a clean merge git returns rc 0 and prints the tree on
346
+ * line 1; on a conflict it returns rc 1 and emits a conflicted-file-info block whose
347
+ * stage entries (`<mode> <oid> <stage>\t<path>`) name every conflicting path.
348
+ *
349
+ * The `-z` form is NUL-delimited and machine-stable (verified against real git
350
+ * 2.50.x): `parts[0]` = the tree OID; subsequent parts up to a blank are the
351
+ * conflicted index entries (each a TAB-containing `<meta>\t<path>`); the trailing
352
+ * parts are human messages we do NOT parse. We extract the conflict paths from the
353
+ * TAB-bearing stage entries — robust to the exact message wording.
354
+ */
355
+ export declare function mergeTreeOffBranch(repoDir: string, oursCommit: string, theirsCommit: string, opts?: {
356
+ hermetic?: boolean;
357
+ }): Promise<MergeTreeResult>;
358
+ /** The merge-base commit of `a` and `b`, or null if they share no ancestor. */
359
+ export declare function mergeBaseOf(repoDir: string, a: string, b: string): Promise<string | null>;
360
+ /**
361
+ * ALL merge-bases of `a` and `b` (`git merge-base --all`). >1 result means a
362
+ * criss-cross history, where `-s ort`'s merge-tree uses a RECURSIVE VIRTUAL base
363
+ * that a single `merge-base` does NOT reproduce — so the 3-way blobs the resolver
364
+ * would see could differ from what produced the conflicted tree (Stage-1 LOW-4).
365
+ * The CP-14 train model shouldn't produce criss-crosses (tracks branch from the
366
+ * shared `base_sha` and never merge each other), but `extractThreeWayConflict`
367
+ * fail-CLOSES to the human gate on >1 base rather than resolve against a base
368
+ * that may not match the merge.
369
+ */
370
+ export declare function mergeBaseAllOf(repoDir: string, a: string, b: string): Promise<string[]>;
371
+ /** A single path's tree entry on a commit (the git object identity for one side). */
372
+ export interface TreeEntry {
373
+ mode: string;
374
+ type: 'blob' | 'commit' | 'tree';
375
+ oid: string;
376
+ }
377
+ /** The tree entry for `p` on `commitish`, or null if the path is absent there. */
378
+ export declare function lsTreeEntry(repoDir: string, commitish: string, p: string): Promise<TreeEntry | null>;
379
+ /**
380
+ * Read the raw blob bytes at `commitish:path`, or `null` if no blob is there
381
+ * (the path is absent / a tree / a gitlink). Hermetic + binary-safe. Used by the
382
+ * Wave B verified-negative walk (`merge-train.ts::requiresFinalTier2`) to re-hash
383
+ * the committed bytes of a resolved path and confirm they match the audited
384
+ * composed-file hash (§4.5 file integrity — the committed bytes ARE the audited
385
+ * resolution, never a tampered tree the gate would skip-Tier-2 over).
386
+ */
387
+ export declare function readBlobAtPath(repoDir: string, commitish: string, p: string): Promise<Buffer | null>;
388
+ /**
389
+ * The HERMETIC integration diff `a..b`, or `null` when it exceeds `maxBytes` or
390
+ * cannot be produced (the caller fails closed — never reviews a partial/altered
391
+ * diff). Runs under the SAME hermetic env + pinned config every CP-14 git op uses
392
+ * AND explicitly disables `--no-ext-diff` / `--no-textconv` (Wave B Stage-2 r1
393
+ * codex HIGH): an ambient `GIT_EXTERNAL_DIFF` / `diff.external` / a textconv driver
394
+ * must NOT be able to alter or hide the bytes the mandatory final-tip Tier-2
395
+ * reviewer sees. `--no-color` keeps the output plain for the prompt.
396
+ */
397
+ export declare function readDiffHermetic(repoDir: string, a: string, b: string, maxBytes: number): Promise<string | null>;
398
+ /**
399
+ * 3-way merge of three blob OIDs at the BLOB level via `git merge-file -p
400
+ * --diff3` (§4.2). Writes the blobs to temp files (NOT the worktree) so no
401
+ * `.gitattributes` driver/filter applies; `--diff3` forces the base section
402
+ * regardless of `merge.conflictStyle`. A null `baseOid` (add/add) uses an empty
403
+ * base. Returns the merged text (with diff3 conflict markers where it couldn't
404
+ * auto-merge). `merge-file` exits non-zero on conflicts — that is expected
405
+ * (allowFail), not an error.
406
+ */
407
+ export declare function diff3MergeBlobs(repoDir: string, oursOid: string, baseOid: string | null, theirsOid: string): Promise<string>;
408
+ /**
409
+ * Extract the full 3-way {@link ConflictFileMeta} for one conflicting `path`,
410
+ * plus the diff3 conflicted blob (for content-eligible conflicts; null
411
+ * otherwise). `oursCommit` = the current integration tip (the §4.5 COUNTERPART);
412
+ * `theirsCommit` = the merging TRACK branch — matching
413
+ * `mergeTreeOffBranch(currentTip, trackTip)`'s arg order. The conflict KIND is
414
+ * derived structurally from the three tree entries; non-regular / mode / type /
415
+ * delete / submodule conflicts are surfaced via `conflictKind` so the classifier
416
+ * routes them to the human gate (§4.3 class-3). `hasLfs` / `hasDangerousAttr` are
417
+ * set by the caller from the existing W2 pre-scans (they cover the whole touched
418
+ * set, not just conflicts).
419
+ */
420
+ export declare function extractThreeWayConflict(repoDir: string, oursCommit: string, theirsCommit: string, p: string): Promise<{
421
+ meta: ConflictFileMeta;
422
+ conflictedBlob: string | null;
423
+ multipleMergeBases: boolean;
424
+ }>;
425
+ /**
426
+ * Assemble a CLEAN resolved tree (§4.3): start from the conflicted tree that
427
+ * `mergeTreeOffBranch` wrote, and REPLACE each resolved path's conflicted blob
428
+ * with the clean resolved blob. Uses a throwaway HERMETIC index (`read-tree` →
429
+ * `update-index --cacheinfo` per resolved path → `write-tree`), so the user's
430
+ * real index is never touched and no ambient `GIT_*` perturbs it. Returns the
431
+ * resolved tree OID (which the merge-train then commits + CAS-advances onto the
432
+ * integration ref, AFTER the ConflictResolution audit is durable — §3.2).
433
+ */
434
+ export declare function assembleResolvedTree(repoDir: string, conflictedTree: string, resolved: ReadonlyMap<string, {
435
+ bytes: Buffer;
436
+ mode: string;
437
+ }>): Promise<string>;
438
+ /**
439
+ * Build a commit object for `tree` with the given ordered `parents` via
440
+ * `git commit-tree` — NO ref moves, NO worktree touch (Codex #2 architectural fix).
441
+ * Returns the new commit SHA. The author/committer identity comes from the repo's
442
+ * own git config (the same identity a `git merge` would have used).
443
+ *
444
+ * `opts.date` (W2 — Stage-1 M1) — when provided, the AUTHOR and COMMITTER dates are
445
+ * BOTH pinned to this value (a git date string, e.g. an ISO-8601 or `@<epoch> +0000`)
446
+ * so the resulting commit SHA is a PURE FUNCTION of `(tree, parents, message, identity,
447
+ * date)`. The W2 merge-train passes a deterministic, input-derived date so a crash-
448
+ * recovery re-merge reproduces the BYTE-IDENTICAL commit (not just an identical tree) —
449
+ * making the §3.2 "deterministically identical commit" guarantee true, and removing the
450
+ * wall-clock-time SHA-instability landmine for any future SHA-based dedup. When ABSENT
451
+ * (the W1 promote path), behavior is BYTE-IDENTICAL to before: the commit picks up the
452
+ * ambient wall-clock date exactly as a `git merge` would (W1 keys on refs/trees, never on
453
+ * a commit SHA's stability).
454
+ *
455
+ * `opts.identity` (W2 — Stage-2 r1 M1 / agy F-02) — when provided, the commit's
456
+ * author+committer NAME and EMAIL are pinned to this generic bot identity, the commit
457
+ * encoding is forced to `UTF-8` (`-c i18n.commitEncoding=UTF-8`, neutralizing an ambient
458
+ * `i18n.commitEncoding` that would otherwise add an `encoding` header), and signing is
459
+ * disabled (`-c commit.gpgsign=false`, no `-S`). Without these pins `commit-tree` reads
460
+ * `user.name`/`user.email` from the ambient env/config, so two hosts (or the same host
461
+ * after a config change) produce DIFFERENT merge commit SHAs for identical inputs —
462
+ * breaking the §3.2 deterministic-replay / SHA-dedup guarantee. With the pin the
463
+ * merge-train commit SHA is a PURE function of `(tree, parents, message, fixed identity,
464
+ * fixed date, fixed encoding, no signature)`. The pins apply ONLY to CodeVibe's own
465
+ * machine-generated MERGE commits on the integration branch — the user's own work commits
466
+ * (on the track branches) are NEVER touched. `opts.identity` is W2-only; the W1 promote
467
+ * path passes neither `date` nor `identity` and stays BYTE-IDENTICAL (ambient identity +
468
+ * date + config, exactly as a `git merge` would).
469
+ */
470
+ export declare function commitTreeOffBranch(repoDir: string, tree: string, parents: readonly string[], message: string, opts?: {
471
+ date?: string;
472
+ identity?: {
473
+ name: string;
474
+ email: string;
475
+ };
476
+ }): Promise<string>;
477
+ export interface RevertToPrePromoteOutcome {
478
+ status: 'restored' | 'rescued' | 'noop';
479
+ /** When rescued: the rescue ref + the user's divergent tip we preserved. */
480
+ rescueRef?: string;
481
+ userTip?: string;
482
+ /** Why the revert rescued instead of restoring (surfaced to the user). */
483
+ rescueReason?: string;
484
+ }
485
+ /**
486
+ * Restore a PROMOTED-then-rejected group's user tree to its PRE-PROMOTE state
487
+ * (LOCK #C14-REVERT, §3.1): ref + index + worktree → `pre_promote_user_ref` +
488
+ * the tracked stash (`pre_image_manifest_ref`) + the durable untracked tree
489
+ * (HIGH-1) — NEVER `base_sha`, NEVER content-only.
490
+ *
491
+ * COMPARE-AND-SWAP: auto-restore ONLY if the user's ref is still exactly the
492
+ * recorded `promoted_tip` AND the index/worktree match the expected promoted tree.
493
+ * If the user MOVED the ref / committed on top since promote → create a RESCUE ref
494
+ * `codevibe/rescue/<group>/<repo>` at the user's current tip and route to surface
495
+ * (never auto-discard user commits).
496
+ *
497
+ * HIGH-2: a post-promote UNTRACKED add doesn't change the index tree, so the CAS
498
+ * tree-match still passes — but the restore's `clean -fd` WOULD delete it. So
499
+ * BEFORE restoring, snapshot the live untracked set; any untracked path that was
500
+ * NOT part of the pre-promote capture is the user's post-promote work →
501
+ * rescue-ref + surface instead of `clean`-ing it away (LOCK #C14-REVERT).
502
+ *
503
+ * NEW-MEDIUM (same data-loss class as HIGH-2, narrower trigger): HIGH-2's guard is a
504
+ * path-name SET DIFFERENCE — it catches only *newly added* untracked paths. A user
505
+ * who EDITS THE CONTENT of a PRE-EXISTING untracked file (same path, no rename) after
506
+ * a `dirty_uncommitted` promote passes that guard; then the restore's
507
+ * `restoreUntrackedTree` (`checkout <pre-promote-tree> -- .`) would overwrite it with
508
+ * the captured pre-promote content, silently LOSING the post-promote edit — and
509
+ * report `restored`. `clean`/`dirty_committed` are immune (their worktree-clean CAS
510
+ * catches any drift), but `dirty_uncommitted` sets `requireCleanWorktree = false`, so
511
+ * nothing else catches it. So BEFORE restoring, hash-compare each live untracked path
512
+ * that IS in the pre-image set against its captured blob; ANY mismatch → rescue-ref +
513
+ * surface (mirror the addition-rescue path), never silently overwrite.
514
+ *
515
+ * MEDIUM-1: if re-applying the tracked stash conflicts, do NOT report `restored` —
516
+ * rescue-ref the conflicted state + surface.
517
+ */
518
+ export declare function revertToPrePromote(repoDir: string, taskGroupId: string, repoId: string, wal: PromoteWalStore, hooks?: WorktreeMergeRaceHooks): Promise<RevertToPrePromoteOutcome>;
519
+ export interface PromoteRecoveryOutcome {
520
+ taskGroupId: string;
521
+ repoId: string;
522
+ /**
523
+ * - `fully_promoted` : user HEAD already == the mode-aware expected promoted
524
+ * HEAD → record `promote_committed` (no tree mutation).
525
+ * - `untouched` : user ref still == pre_promote_user_ref + clean → the
526
+ * promote never started its mutation; resume is the
527
+ * caller's job (W1 reports it; no-op here).
528
+ * - `partial_restored` : a partial mutation was found → restored from the stash.
529
+ * - `rescued` : the live worktree carries user POST-CRASH work (a path/
530
+ * content in NEITHER the pre- nor post-promote snapshot) →
531
+ * rescue-ref'd + surfaced, NEVER auto-restored over (H6).
532
+ */
533
+ resolution: 'fully_promoted' | 'untouched' | 'partial_restored' | 'rescued';
534
+ /** When rescued (H6): the rescue ref + the unexplained user paths surfaced. */
535
+ rescueRef?: string;
536
+ rescueReason?: string;
537
+ }
538
+ /**
539
+ * Mode-aware crash recovery for one `(group, repo)` with a `promote_started` WAL
540
+ * but no `promote_committed` (§3.2). The expected promoted HEAD depends on
541
+ * `promote_mode`:
542
+ * - clean → integration_tip
543
+ * - dirty_committed → a commit with parents [pre_promote_user_ref,
544
+ * integration_tip] AND tree == expected_post_promote_tree
545
+ * - dirty_uncommitted → integration_tip (+ preserved-edits, tree-matched)
546
+ *
547
+ * Then: fully-promoted (HEAD matches by parents+tree) → write `promote_committed`;
548
+ * untouched (ref == pre_promote_user_ref, clean) → report untouched (resume/no-op);
549
+ * partial → restore from the stash (`pre_image_manifest_ref`).
550
+ */
551
+ export declare function recoverPromote(repoDir: string, rec: PromoteWalRecord, wal: PromoteWalStore, hooks?: WorktreeMergeRaceHooks): Promise<PromoteRecoveryOutcome>;
552
+ /**
553
+ * Recover EVERY `(group, repo)` with a started-but-not-committed promote WAL
554
+ * (startup reconciliation, §3.2). Idempotent on replay: a fully-promoted record
555
+ * just writes `promote_committed`; an untouched one is a no-op; a partial one
556
+ * restores. Returns one outcome per recovered record.
557
+ */
558
+ export declare function recoverAllPromotes(resolveRepoDir: (rec: PromoteWalRecord) => string | null, wal: PromoteWalStore): Promise<PromoteRecoveryOutcome[]>;
559
+ /**
560
+ * Hot-path GC after a per-promote/recovery transition (§16 r4-agy) — SHARED-OBJECT-
561
+ * STORE SAFE (MEDIUM-2). The user's real repo shares its object store with
562
+ * concurrent worktree shadows (`workspace-shadow.ts`); a sibling worktree's
563
+ * in-flight merge may hold loose objects NOT yet anchored to any ref. `git gc
564
+ * --prune=now` drops git's 2-week grace and would prune exactly those → corrupting
565
+ * a concurrent op. So the per-promote path does NOT aggressively prune: it only
566
+ * `git worktree prune` (reaps administrative records for removed worktrees — never
567
+ * touches a sibling's live objects) and a `git gc --auto` (which respects the
568
+ * default grace + only runs when git's own heuristics say it's worth it).
569
+ * Aggressive `--prune=now` is reserved for {@link gcGroupTerminal}, which is called
570
+ * ONLY when the whole group is terminal (no sibling worktree is in flight).
571
+ * Best-effort — a GC failure is non-fatal.
572
+ */
573
+ export declare function gcDanglingPromptly(repoDir: string, opts?: {
574
+ hermetic?: boolean;
575
+ }): Promise<void>;
576
+ /**
577
+ * GC for a GROUP-TERMINAL transition (MEDIUM-2). This group's worktrees/branches
578
+ * are being torn down, but the user's repo SHARES its object store with concurrent
579
+ * UNRELATED groups' worktree shadows (`workspace-shadow.ts`), whose in-flight merges
580
+ * may hold loose objects NOT yet anchored to any ref — and a human gate review can
581
+ * legitimately keep such a sibling op un-anchored for far longer than a few minutes.
582
+ *
583
+ * M2 FIX: the previous `--prune=10.minutes.ago` could reap a concurrent >10-min
584
+ * review's unanchored objects → corruption. So we do NOT use a sub-hour prune on
585
+ * the shared store: `git worktree prune` (admin records only — never a sibling's
586
+ * objects) + `git gc --auto` (git's default 2-week prune grace + its own
587
+ * worth-it heuristics). Reaping THIS group's aborted-merge loose objects is left
588
+ * to git's normal grace-respecting GC — correctness over promptness on a shared
589
+ * store. Best-effort.
590
+ */
591
+ export declare function gcGroupTerminal(repoDir: string): Promise<void>;
592
+ /**
593
+ * Terminal cleanup of a group's CP-14 branch resources for one repo: delete the
594
+ * track/integration/stash/rescue refs + the promote WAL, then GC. Called on a
595
+ * group-terminal state (accept-after-promote OR reject-revert-complete). Keeps
596
+ * the rescue ref when one was created (the user's divergent work) unless
597
+ * `dropRescue` is set.
598
+ */
599
+ export declare function cleanupGroupRepo(repoDir: string, taskGroupId: string, repoId: string, trackIndices: readonly number[], wal: PromoteWalStore, opts?: {
600
+ dropRescue?: boolean;
601
+ }): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};