feat(merge-gate): auto-rebase onto current main + re-test + serialise merges (ORCH-043) #54
Reference in New Issue
Block a user
Delete Branch "feature/ORCH-043-merge-gate-auto-rebase-re-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
deploy-staging → deployedge: catches a feature branch up to the currentorigin/main, re-tests the combined tree, and serialises merges with a per-repo file lease — so two green parallel branches can't breakmain(self-hosting safety for theorchestratorrepo).src/merge_gate.py(never-raise; all git ops in the per-branch worktree):branch_is_behind_main,auto_rebase_onto_main(push --force-with-leaseonly the task branch, nevermain),retest_branch, file merge-lease (atomicO_CREAT|O_EXCL, holder-aware release, stale/corrupt reclaim).check_branch_mergeable(src/qg/checks.py, registered inQG_CHECKS) composes the primitives under the lease. Conditional rollout:merge_gate_enabledkill-switch +merge_gate_reposCSV (default: self-hostingorchestratoronly).src/stage_engine.py: sub-gate hook ondeploy-staging(not a newSTAGE_TRANSITIONSstage). PASS → advance;merge-lock busy→ DEFER (re-queue withavailable_at, anti-deadlock atmax_concurrency=1, capped bymerge_defer_max_attempts); conflict / red re-test → rollback todevelopment+ developer retry (capped byMAX_DEVELOPER_RETRIES). Lease released ondeploy→done/ rollback / PR-merged webhook.src/db.py:enqueue_job(available_at_delay_s=...)for the defer (no schema change).src/webhooks/gitea.py: holder-aware lease release on PR-merged.ORCH_MERGE_*(src/config.py,.env.example). Docs: README +adr-0006already describe the design;CHANGELOG.mdupdated.Test plan
tests/test_merge_gate.py— TC-01..11: behind-detection, rebase (clean push-with-lease / conflict abort / never pushes main), re-test (green/red/timeout), lease (busy/holder-aware/stale/missing) — real local git.tests/test_qg_merge_gate.py— TC-12..17: gate composition + lease lifecycle, conditionality no-ops, never-raise.tests/test_merge_gate_race.py— TC-24: parallel-merge race;origin/mainSHA asserted unchanged.tests/test_stage_engine.py::TestMergeGate— TC-20..23: PASS advance / busy DEFER (+exhaustion) / conflict+red rollback / retry cap / non-self-hosting no-op.tests/test_config.py— TC-25:ORCH_MERGE_*defaults + env override.tests/test_qg_registry_snapshot.py—check_branch_mergeablein the registry contract.🤖 Generated with Claude Code
Refs: ORCH-043