test(gate-check-v3): regression tests for trusted governance contexts (#2589) #2621
Reference in New Issue
Block a user
Delete Branch "fix/gate-check-v3-governance-regression-tests"
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?
Closes molecule-core#2615.
Adds regression tests for the gate-check-v3 governance-context logic that molecule-core#2589 changed.
Security behaviour covered
(pull_request_target)governance contexts (qa-review,security-review,sop-checklist).(pull_request)-suffixed governance status does not satisfy the gate.max_by(.id)because Gitea/commits/<sha>/statusesis non-monotonic by id.Implementation changes
tools/gate-check-v3/gate_check.py: collapse duplicate status contexts by max id before evaluating required checks.tools/gate-check-v3/test_gate_check.py: update existing signal-6 tests for the new trusted suffixes and add three #2589 regression tests..gitea/workflows/gate-check-v3-tests.yml: new CI workflow that runspytestwhenever the evaluator or its tests change.Test plan
All 17 tests pass locally.
🤖 Generated with Claude Code
SOP checklist
feedback_no_such_thing_as_flakes,reference_merge_gate_model_changed_2026_05_18,reference_gitea_1_22_6_action_status_enum.Approved on head
dafa67f4e6.5-axis review:
Correctness: the evaluator now collapses duplicate statuses by max
id, which matches the non-monotonic Gitea status feed behavior, and the regression tests cover trusted(pull_request_target)governance contexts, forged(pull_request)contexts, and latest-status-wins behavior.Robustness: missing/pending/failing required contexts still fail closed. The new tests preserve the existing always-required governance behavior when branch protection omits those contexts.
Security: the important security property is covered: attacker-controlled PR-head governance contexts do not satisfy qa/security/sop approval requirements.
Performance: status collapse remains O(n) over the returned status list; no concern.
Readability: small, focused patch; test names and constants make the trust boundary clear.
Verification: ran
python3 -m pytest test_gate_check.py -qin a temporary virtualenv: 17 passed. Note: PR CI was not fully green at review time due other status/governance contexts, but I found no code-review blocker in this patch.dafa67f4e6to821cbe8754New commits pushed, approval review dismissed automatically according to repository settings
Approved on current head
821cbe8754.Security-focused review:
Forged/untrusted governance statuses: covered.
test_signal_6_untrusted_governance_contexts_do_not_satisfyfeeds only(pull_request)qa/security/sop statuses, calls the realsignal_6_ci, and asserts the gate does not clear, trusted contexts remain pending, and untrusted contexts are not counted as passing.Trusted governance statuses: covered.
test_signal_6_trusted_governance_contexts_clearfeeds the three(pull_request_target)contexts and assertsCLEARwith those contexts inpassing_required.Non-monotonic Gitea status collapse: covered. The implementation collapses duplicate contexts by max
id;test_signal_6_status_collapse_uses_max_iddeliberately orders ids non-monotonically and asserts the max-id failure wins.Real gate code: covered. The tests monkeypatch
api_getinputs but callgate_check.py's realsignal_6_ci; they do not reimplement the evaluator.Robustness/security: missing trusted contexts continue to fail closed; spoofable PR-head governance contexts do not satisfy the merge gate. Performance remains O(n) over returned statuses. Readability is clear and narrowly scoped.
Verification: ran
python3 -m pytest test_gate_check.py -qon this head: 17 passed.