Publish FI briefs to origin or fail the day
Some checks failed
Governed runtime contract / contract (push) Failing after 26s

FI-WP-0004 grants origin publication. Local commit without push no
longer posts fi_daily_brief (that cleared due while losing the file).
Prompt/context refuse re-announcing cataloged models and invented sizes.

Assistant: grok
Assistant-Session: 01a09c6a-1cfc-75b1-a78d-c13eaf22241d
This commit is contained in:
tegwick 2026-09-13 22:45:43 +02:00
parent ee3800f26d
commit 11020e8f00
4 changed files with 136 additions and 42 deletions

View file

@ -8,10 +8,14 @@ from pathlib import Path
from rein_aharness import fi_research_brief
def _git(cwd: Path, *args: str) -> None:
subprocess.run(["git", "-C", str(cwd), *args], check=True, capture_output=True)
def _repo(tmp_path: Path) -> Path:
repo = tmp_path / "freedom-intelligence"
repo.mkdir()
subprocess.run(["git", "init", "-q"], cwd=repo, check=True)
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=repo, check=True)
(repo / "README.md").write_text("baseline\n", encoding="utf-8")
subprocess.run(["git", "add", "."], cwd=repo, check=True)
subprocess.run(
@ -31,37 +35,72 @@ def _repo(tmp_path: Path) -> Path:
return repo
def test_fi_brief_never_pushes_even_when_legacy_env_requests_it(
tmp_path: Path,
monkeypatch,
) -> None:
repo = _repo(tmp_path)
monkeypatch.setenv("FI_RESEARCH_BRIEF_PUSH", "1")
original_git = fi_research_brief._git
calls: list[tuple[str, ...]] = []
def _with_origin(tmp_path: Path, repo: Path) -> Path:
remote = tmp_path / "origin.git"
subprocess.run(["git", "init", "--bare", "-q", "-b", "main", str(remote)], check=True)
_git(repo, "remote", "add", "origin", str(remote))
_git(repo, "push", "-u", "origin", "HEAD:main")
return remote
def observed_git(target: Path, *args: str) -> str:
calls.append(args)
return original_git(target, *args)
monkeypatch.setattr(fi_research_brief, "_git", observed_git)
result = fi_research_brief.run_fi_research_brief(
repo,
day=date(2026, 9, 4),
report_to_hub=False,
complete_fn=lambda _prompt: json.dumps(
{
"headline_deltas": ["No material delta after allowlist review."],
"axis_a": [],
"axis_b": [],
"axis_c": [],
"axis_d": [],
"collection_candidates": [],
"lab_implications": ["Recheck tomorrow."],
}
),
def _complete(_prompt: str) -> str:
return json.dumps(
{
"headline_deltas": ["No material delta after allowlist review."],
"axis_a": [],
"axis_b": [],
"axis_c": [],
"axis_d": [],
"collection_candidates": [],
"lab_implications": ["Recheck tomorrow."],
}
)
def test_fi_brief_pushes_to_origin_and_records_sha(tmp_path: Path) -> None:
repo = _repo(tmp_path)
_with_origin(tmp_path, repo)
result = fi_research_brief.run_fi_research_brief(
repo,
day=date(2026, 9, 13),
report_to_hub=False,
complete_fn=_complete,
)
assert result.ok is True
assert result.committed is True
assert not any(args and args[0] == "push" for args in calls)
assert result.pushed is True
assert result.origin_sha
remote_head = subprocess.run(
["git", "-C", str(tmp_path / "origin.git"), "rev-parse", "HEAD"],
check=True,
capture_output=True,
text=True,
).stdout.strip()
assert remote_head == result.origin_sha
brief = repo / "briefs" / "2026" / "09" / "2026-09-13.md"
assert brief.is_file()
def test_fi_brief_push_failure_is_not_a_completed_day(
tmp_path: Path, monkeypatch
) -> None:
repo = _repo(tmp_path)
posted: list[dict] = []
def fake_post(**kwargs):
posted.append(kwargs)
monkeypatch.setattr(fi_research_brief.hub, "post_progress_event", fake_post)
result = fi_research_brief.run_fi_research_brief(
repo,
day=date(2026, 9, 13),
report_to_hub=True,
complete_fn=_complete,
)
assert result.ok is False
assert result.committed is True
assert result.pushed is False
assert "origin publish failed" in result.reason
assert posted
assert posted[-1]["event_type"] == "executor_run"
assert posted[-1]["detail"]["pushed"] is False