fi-research-brief: rebase once onto a moved origin instead of stranding briefs
Some checks failed
Governed runtime contract / contract (push) Failing after 33s

Every push from 2026-09-15 to 2026-09-22 was rejected non-fast-forward
because origin had moved; six briefs stayed local on railiance01. Per
the FI publication decision (2026-09-22), fetch, confirm that unpublished
commits touch only briefs/, rebase once and retry. Never merge or force;
a conflict aborts the rebase and fails the day.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 51320@bnt-lap001
Assistant-Session: 9d40b4c7-8e3c-42ee-b755-d658d4640d6c
This commit is contained in:
tegwick 2026-09-22 16:25:34 +02:00
parent 364bed78b2
commit 294201a367
2 changed files with 99 additions and 2 deletions

View file

@ -351,15 +351,48 @@ def _git(repo: Path, *args: str, timeout: int = 60) -> str:
return result.stdout.strip()
_PUBLISH_PREFIX = "briefs/"
def _publish_origin(repo: Path) -> str:
"""Push HEAD to origin. FI-owned grant: origin is the durable brief store."""
"""Push HEAD to origin. FI-owned grant: origin is the durable brief store.
FI decision 2026-09-22 (docs/decisions/2026-09-22-brief-origin-publication.md):
fast-forward only. If origin moved, rebase the unpublished brief commits
onto it once and retry. Never merge, never force.
"""
branch = _git(repo, "rev-parse", "--abbrev-ref", "HEAD")
if not branch or branch == "HEAD":
branch = "main"
_git(repo, "push", "-u", "origin", f"HEAD:{branch}", timeout=120)
try:
_git(repo, "push", "-u", "origin", f"HEAD:{branch}", timeout=120)
except FiResearchBriefError:
_rebase_onto_origin(repo, branch)
_git(repo, "push", "-u", "origin", f"HEAD:{branch}", timeout=120)
return _git(repo, "rev-parse", "HEAD")
def _rebase_onto_origin(repo: Path, branch: str) -> None:
"""Replay local brief-only commits onto origin/<branch>, or fail closed."""
_git(repo, "fetch", "origin", branch, timeout=120)
upstream = f"origin/{branch}"
changed = _git(repo, "diff", "--name-only", f"{upstream}...HEAD").splitlines()
outside = [p for p in changed if not p.startswith(_PUBLISH_PREFIX)]
if outside:
raise FiResearchBriefError(
f"unpublished commits touch paths outside {_PUBLISH_PREFIX}: {outside[:5]}"
)
try:
_git(repo, "rebase", upstream, timeout=120)
except FiResearchBriefError:
subprocess.run(
["git", "-C", str(repo), "rebase", "--abort"],
capture_output=True,
timeout=60,
)
raise
def run_fi_research_brief(
target_repo: Path,
*,