fix(7733): a rule with triggers holds or refuses only the acts they match
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Plugin hooks (push) Failing after 19s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Successful in 2m31s
CI & Build / integration (push) Successful in 2m18s
CI & Build / Build & push image (push) Canceled after 27s
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Plugin hooks (push) Failing after 19s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Successful in 2m31s
CI & Build / integration (push) Successful in 2m18s
CI & Build / Build & push image (push) Canceled after 27s
Rules 2, 4, 10 and 153 are set to hold and mounted on work.deliver. A push to dev therefore stopped four times in a row, once for each of them, although none of them governs a push to dev: their triggers (git push origin main, git tag, pytest, pull_request_write) name the acts they do govern. A rule that has triggers now stops an act only when one of them matched it. Reached by its moment alone, it is a line beside the work. A rule with no triggers still holds wherever it is mounted, because the mount is all that says where it applies. A mounted rule whose unscoped trigger also matched now counts as reached by the trigger, so it ranks as triggered and may stop the act. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -148,5 +148,32 @@ async def test_a_rule_both_mounted_and_fired_is_delivered_once():
|
||||
assert result.shown_rule_ids == [1]
|
||||
|
||||
|
||||
async def test_a_rule_with_triggers_stops_only_the_acts_they_match():
|
||||
# Rule 2 holds pushes to main; mounted on work.deliver it reaches every
|
||||
# push, and only its own trigger may make one wait.
|
||||
guard = _r(2, enforcement="hold")
|
||||
pairs = [(guard, "work.deliver")]
|
||||
deliver = [{"moment": "work.deliver", "tool": "Bash", "match": "git push", "via": "default"}]
|
||||
to_dev = rt.Board(triggered={2})
|
||||
result = await _arm(pairs, to_dev, reached=deliver)
|
||||
assert result.decision == {} and result.shown_rule_ids == [2]
|
||||
to_main = rt.Board(triggered={2}, fired=[(guard, T("command", "git push origin main"))])
|
||||
result = await _arm(pairs, to_main, reached=deliver)
|
||||
assert result.decision["kind"] == "hold" and result.decision["rule_ids"] == [2]
|
||||
# With no trigger of its own, the mount is all that says where it applies.
|
||||
result = await _arm(pairs, rt.Board(), reached=deliver)
|
||||
assert result.decision["kind"] == "hold"
|
||||
|
||||
|
||||
async def test_the_board_lists_every_rule_that_has_a_trigger(monkeypatch):
|
||||
monkeypatch.setattr(rt, "_in_scope", AsyncMock(return_value=[
|
||||
(_r(1), [T("path", "alembic/**", "work.change")]),
|
||||
(_r(2), [T("command", "git push origin main")]),
|
||||
(_r(3), []),
|
||||
]))
|
||||
out = await rt.board(1, 2, tool="Bash", tool_input={"command": "ls"})
|
||||
assert out.triggered == {1, 2}
|
||||
|
||||
|
||||
def test_triggered_outranks_mounted_in_the_one_order():
|
||||
assert rule_order.BY_TRIGGER > rule_order.BY_MOUNT > rule_order.BY_RESEMBLANCE
|
||||
|
||||
Reference in New Issue
Block a user