code-to10 v6 A1: delete server merge-gate modes, hard only

Server POST /tasks/{id}/merge no longer has record/enforce/off:
hard_mode_from_env and HARD_MODES deleted (not re-defaulted),
handler always evaluates the hard gate, env CLOUD_MERGE_GATE_MODE
and body merge_gate_mode are ignored server-side. The record
'no-evidence passes' and 'unprotected+confirm passes with
merge_gate_risk' server paths are gone with the dead risk audit;
no production caller justified keeping them (only production
caller of the non-hard evaluator was the merge handler itself;
audit_loop_wiring already used the hard gate). cloud/merge_gate
pure functions keep their #209 semantics but are documented as
non-server: they are no longer wired to any endpoint.
Server-level record/enforce/off tests rewritten to the new
behavior (renamed, not deleted silently); pure-function tests
unchanged.

(cherry picked from commit 08e75edbd6d04701965c5db951fa054cfbb75bb0)

Reconcile-port: handler_lifecycle.py hunks redirected into cloud/server.py _merge_task (target keeps 6-mixin split; mixin file does not exist here); handler_support.py kept at HEAD (its A1 hunk is a docstring of _validate_hard_gate_body, ported to server.py copy); test mock paths cloud.handler_lifecycle.* rewritten to cloud.server.*.
This commit is contained in:
host committed 2026-11-04 21:03:32 +00:00
1 parent 593197a4a2
commit e6a1346420
8 files changed
+200 -183

No files matched your search

+33 -10
View File
@@ -546,13 +546,25 @@ class MergeLoopTestCase(_Base):
self.assertIn("files_changed must be a list", payload["error"])
def test_merge_pushback_unavailable_409(self):
# A1 改写:旧用例以 CLOUD_MERGE_GATE_MODE=off + 空 body 走到
# 推回检查;服务端删模式后空 body 在硬门禁体校验前已 400,
# 故改用完整硬证据 body,仍钉“推回状态不可用 → 409”这一性质。
self._project()
self._task(status="completed")
h = self._h(body={})
with mock.patch.dict(os.environ,
{"CLOUD_MERGE_GATE_MODE": "off"}), \
mock.patch("cloud.server._pushback_block",
side_effect=RuntimeError("chain down")):
h = self._h(body={
"files_changed": ["apps/web/a.py"],
"owned_dir": "apps/web",
"branch_protection": "protected",
"ci_status": "success",
"ci_checks": [{"name": "ci", "status": "success"}],
"required_checks": ["ci"],
"contract_version": "v2",
"contract_frozen": True,
"coordinator_approved": True,
"unresolved_review_comments": 0,
})
with mock.patch("cloud.server._pushback_block",
side_effect=RuntimeError("chain down")):
h._merge_task("u1", "t1")
code, payload = self._last(h)
self.assertEqual(code, 409)
@@ -561,11 +573,24 @@ class MergeLoopTestCase(_Base):
self.assertTrue(payload["audit_pushback"]["merge_blocked"])
def test_merge_pushback_unavailable_audit_fails_too(self):
# A1 改写:同上,off + 空 body 改为完整硬证据 body,仍钉
# “审计本身也失败时 handler 仍回同一 409”。
# The audit best-effort except-pass: even when the audit
# write itself raises, the handler still answers the same 409.
self._project()
self._task(status="completed")
h = self._h(body={})
h = self._h(body={
"files_changed": ["apps/web/a.py"],
"owned_dir": "apps/web",
"branch_protection": "protected",
"ci_status": "success",
"ci_checks": [{"name": "ci", "status": "success"}],
"required_checks": ["ci"],
"contract_version": "v2",
"contract_frozen": True,
"coordinator_approved": True,
"unresolved_review_comments": 0,
})
real_auth = server_mod._auth_store
calls = {"n": 0}
@@ -574,10 +599,8 @@ class MergeLoopTestCase(_Base):
if calls["n"] == 1:
return real_auth(db_path)
raise RuntimeError("audit down")
with mock.patch.dict(os.environ,
{"CLOUD_MERGE_GATE_MODE": "off"}), \
mock.patch("cloud.server._pushback_block",
side_effect=RuntimeError("chain down")), \
with mock.patch("cloud.server._pushback_block",
side_effect=RuntimeError("chain down")), \
mock.patch("cloud.server._auth_store",
side_effect=_auth_store):
h._merge_task("u1", "t1")