Outcome
Give the forge the git primitives a stack service composes: ancestry checks, merge-base reads, tree merges, commit replay, and atomic multi-ref updates. Nothing here knows what a pull request is.
Context
docs/stacked-prs.md sections 12.1–12.4, 13.7, and 7.4 define the target surface. Today OpenAgents.Forge.Repos.set_refs!/2 runs plain git update-ref with no expected-old-value check, and read-only plumbing lives in OpenAgents.Forge.Browse. The WAL index generation (OpenAgents.Forge.WAL.cas_index/3) is the existing compare-and-swap token.
Acceptance criteria
- Read helpers resolve refs, test ancestry, and compute merge bases against the bare repo cache after a freshness check.
- Tree merges plan with
git merge-tree --write-tree; conflicts return structured path data without touching refs.
- Commit replay implements the
git rebase --onto boundary semantics: replay only commits reachable from the old head but not from the stored boundary.
- A batch update applies every ref or none, rejecting any mismatched expected OID. The WAL records one entry for the batch so cache convergence and mirrors see one transition.
- Boundary commits stay reachable through hidden internal refs or an equivalent retention rule that the garbage collector honors.
- All git invocations stay argv-only against
--git-dir, per the existing discipline in Repos.git/3.
Verification
Unit tests per primitive plus a property-style test that concurrent writers cannot interleave a batch. Run mix precommit.
Dependencies
None. This is forge-plane work and lands before any stack schema.
Outcome
Give the forge the git primitives a stack service composes: ancestry checks, merge-base reads, tree merges, commit replay, and atomic multi-ref updates. Nothing here knows what a pull request is.
Context
docs/stacked-prs.mdsections 12.1–12.4, 13.7, and 7.4 define the target surface. TodayOpenAgents.Forge.Repos.set_refs!/2runs plaingit update-refwith no expected-old-value check, and read-only plumbing lives inOpenAgents.Forge.Browse. The WAL index generation (OpenAgents.Forge.WAL.cas_index/3) is the existing compare-and-swap token.Acceptance criteria
git merge-tree --write-tree; conflicts return structured path data without touching refs.git rebase --ontoboundary semantics: replay only commits reachable from the old head but not from the stored boundary.--git-dir, per the existing discipline inRepos.git/3.Verification
Unit tests per primitive plus a property-style test that concurrent writers cannot interleave a batch. Run
mix precommit.Dependencies
None. This is forge-plane work and lands before any stack schema.