Investigate the root cause of the push_main race that silently dropped commits from remote main, and implement protections to prevent recurrence. The audit found multiple commits lost including v1 economics participation drivers, v2 credit backprop, research squads, versioned datasets, and parallel agent work (reward_emission_driver.py, wiki_edit_market_driver.py).
0768404a5 ("Fix push_main race that lost commits — root cause + 4 layered fixes"):The Bug: The SciDEX repo had a stale local branch literally named refs/heads/origin/main (SHA 73fecc56) sitting alongside the normal refs/remotes/origin/main remote-tracking ref. Whenever ANY git command referenced the bare name origin/main, git could not disambiguate and either:
FIXED (in /home/ubuntu/Orchestra/orchestra/sync.py and scripts/push_main.sh):
sync.py:_purge_ambiguous_origin_branches() - Defensively deletes any local branch literally named origin/Xsync.py:_do_push_main() - Uses explicit refspecs, captures remote SHA, uses --force-with-lease=main:{sha}push_main.sh - Same pattern: explicit refspec fetch, SHA capture, --force-with-leaseSTILL VULNERABLE (read-only, cannot fix directly):
worktree_hygiene.sh lines 289 and 296 - Does git push origin main without --force-with-leaserepo_health_monitor.sh lines 130 and 143 - Does git push origin main without lease (for auto-revert)Current code:
git push origin main 2>/dev/null || { git reset --hard HEAD~1 2>/dev/null; exit 1; }Required fix:
# After git fetch, capture expected SHA:
EXPECTED_REMOTE="$(git rev-parse refs/remotes/origin/main)"
# When pushing:
git push "--force-with-lease=main:${EXPECTED_REMOTE}" origin main 2>/dev/null || {
git reset --hard "${EXPECTED_REMOTE}" 2>/dev/null || true
exit 1
}Additional changes needed:
push_main.lock flock to serialize with push_main.shgit fetch origin '+refs/heads/main:refs/remotes/origin/main'Current code:
git push origin main 2>/dev/null && \Required fix: When auto-reverting damage, use force-with-lease with the known-good commit SHA rather than blindly force-pushing. The script already captures good_commit - use that SHA for the lease.
Since API credentials are not available, branch protection must be set up manually:
# Using a GitHub account with admin access to the repo:
gh api repos/SciDEX-AI/SciDEX/branches/main/protection -X PUT \
--header "Accept: application/vnd.github+json" \
--field required_status_checks='{"strict":true,"contexts":[]}' \
--field enforce_admins=null \
--field required_linear_history=true \
--field allow_force_pushes=false \
--field allow_deletions=falseRequired protection settings:
required_linear_history: true - Prevents merge commits, ensures linear historyallow_force_pushes: false - Blocks force pushesallow_deletions: false - Prevents branch deletionpush_main.sh and sync.py:_do_push_main already have the fix (commit 0768404a5)--force-with-lease=main:{sha}worktree_hygiene.sh lines 289, 296: plain git push origin mainrepo_health_monitor.sh lines 130, 143: plain git push origin main
.orchestra/push_main_race_fix.patch.orchestra/push_main_race_fix.patch with detailed diff for worktree_hygiene.sh.orchestra/branch_protection_setup.md with instructions for manual GitHub setupfa300983-9ded-4d65-bb84-3645f55b972f - Senate calibration slashing driver (recovered from salvage){
"requirements": {
"coding": 8,
"safety": 9,
"analysis": 7
},
"completion_shas": [
"29eb353f9f39d17dbf8d45cecb51ac053e364ed7"
],
"completion_shas_checked_at": "2026-04-13T21:21:14.904623+00:00",
"completion_shas_missing": [
"3fa4eafc0818521ecd019786153821a9dc23d3fb",
"245e710ce2023d9189d012c93fbd6141e563ecb6",
"1dd4ed84a5f37a747b92defb773854ad9c0e596c"
]
}