feat(7731): enforced rules refuse the act, only hold rules hold, and the shape question rides the next prompt
CI & Build / TypeScript typecheck (push) Successful in 38s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Python tests (push) Failing after 1m45s
CI & Build / integration (push) Successful in 2m10s
CI & Build / Build & push image (push) Skipped
CI & Build / TypeScript typecheck (push) Successful in 38s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Python tests (push) Failing after 1m45s
CI & Build / integration (push) Successful in 2m10s
CI & Build / Build & push image (push) Skipped
- A rule set to enforce, reached by a mount or a trigger, refuses the tool call in its own words every time (`act_decision`, `/moment` returns `decision`, grimoire_moment.sh denies). Opening it does not lift it. - A rule set to hold denies the call once until read, under the act checkpoint's per-rule and per-session guard; file writes are never held. - The reply hold, the reply backstop and the act checkpoint hold only on rules declared hold or enforce (`rule_order.holds`). An inform rule is a line beside the work. - The prompt arm leaves rules that arrive at an act (mounted on a non-reply moment, or with a tool/path/command trigger) to that act. - The end-of-turn shape check no longer blocks: its note is kept for the next prompt, carried as `carry` into the one fitted payload, and the stop after that prompt records whether the lines were judged (noted / judged_after_note / left_after_note). - Rule editor and list copy say what hold and enforce now do. Plugin 2026.11.23.0005. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""The server half of the end-of-turn shape check: what the
|
||||
agent is asked, what the hook's ledger may say, and the outcome record."""
|
||||
agent is asked at its next prompt, what the hook's ledger may say, and the
|
||||
outcome record."""
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -21,18 +22,18 @@ def test_the_ledger_lines_parse_and_garbage_is_dropped():
|
||||
assert len(parse_written("".join(f"p\tsym\tn{i}\n" for i in range(500)), cap=7)) == 7
|
||||
|
||||
|
||||
def test_a_first_stop_blocks_or_passes_and_the_next_never_blocks():
|
||||
def test_a_stop_notes_or_passes_and_the_stop_after_the_note_records_the_answer():
|
||||
from grimoire.services.shape_check import outcome_for
|
||||
|
||||
one = [{"path": "a", "kind": "sym", "symbol": "b"}]
|
||||
assert outcome_for("check", one) == "blocked"
|
||||
assert outcome_for("check", one) == "noted"
|
||||
assert outcome_for("check", []) == "passed"
|
||||
assert outcome_for("after", one) == "left_after_block"
|
||||
assert outcome_for("after", []) == "judged_after_block"
|
||||
assert outcome_for("after", one) == "left_after_note"
|
||||
assert outcome_for("after", []) == "judged_after_note"
|
||||
|
||||
|
||||
def test_the_reason_names_each_shape_its_evidence_and_the_one_call():
|
||||
from grimoire.services.shape_check import block_reason
|
||||
def test_the_note_names_each_shape_its_evidence_and_the_one_call():
|
||||
from grimoire.services.shape_check import note_text
|
||||
|
||||
unjudged = [
|
||||
{"path": "web/A.svelte", "kind": "file", "symbol": "A", "status": "new", "evidence": {}},
|
||||
@@ -40,8 +41,8 @@ def test_the_reason_names_each_shape_its_evidence_and_the_one_call():
|
||||
"evidence": {"looks_like": {"snippet_id": 12, "basis": "semantic", "score": 0.84},
|
||||
"diverges_from": 9}},
|
||||
]
|
||||
reason = block_reason(unjudged, project_id=3, repo="git.example.com/a/w")
|
||||
assert "2 definitions" in reason
|
||||
reason = note_text(unjudged, project_id=3, repo="git.example.com/a/w")
|
||||
assert "last turn wrote 2 definitions" in reason
|
||||
assert "web/A.svelte · A (file) — new" in reason
|
||||
assert "looks like #12 0.84" in reason and "#9 is canon in this directory" in reason
|
||||
assert 'classify_shapes(project_id=3, repo="git.example.com/a/w"' in reason
|
||||
@@ -50,11 +51,11 @@ def test_the_reason_names_each_shape_its_evidence_and_the_one_call():
|
||||
|
||||
|
||||
def test_a_long_turn_is_listed_with_a_tail_not_dropped():
|
||||
from grimoire.services.shape_check import _LISTED, block_reason
|
||||
from grimoire.services.shape_check import _LISTED, note_text
|
||||
|
||||
many = [{"path": "p.py", "kind": "sym", "symbol": f"f{i}", "status": "new", "evidence": {}}
|
||||
for i in range(_LISTED + 3)]
|
||||
reason = block_reason(many, project_id=1, repo="")
|
||||
reason = note_text(many, project_id=1, repo="")
|
||||
assert "… and 3 more" in reason
|
||||
assert "repo=" not in reason
|
||||
|
||||
@@ -64,10 +65,10 @@ async def test_the_outcome_is_recorded_as_a_plugin_event():
|
||||
|
||||
session = make_mock_session()
|
||||
with patch("grimoire.services.shape_check.async_session", return_value=session):
|
||||
await record_shape_check(7, "blocked", written=5, unjudged=2, project_id=2)
|
||||
await record_shape_check(7, "noted", written=5, unjudged=2, project_id=2)
|
||||
row = session.add.call_args.args[0]
|
||||
assert (row.category, row.action, row.user_id) == ("plugin", "shape_check", 7)
|
||||
assert json.loads(row.details) == {"outcome": "blocked", "written": 5,
|
||||
assert json.loads(row.details) == {"outcome": "noted", "written": 5,
|
||||
"unjudged": 2, "project_id": 2}
|
||||
|
||||
|
||||
@@ -85,5 +86,8 @@ def test_the_window_counts_turns_asks_and_asks_walked_past():
|
||||
from grimoire.services.shape_check import summarise
|
||||
|
||||
assert summarise([]) == {"checked": 0, "asked": 0, "left": 0}
|
||||
got = summarise(["passed", "blocked", "judged_after_block", "blocked", "left_after_block"])
|
||||
got = summarise(["passed", "noted", "judged_after_note", "noted", "left_after_note"])
|
||||
assert got == {"checked": 3, "asked": 2, "left": 1}
|
||||
# A window that spans the end-of-turn hold this check once was still sums.
|
||||
mixed = summarise(["blocked", "left_after_block", "noted", "judged_after_note"])
|
||||
assert mixed == {"checked": 2, "asked": 2, "left": 1}
|
||||
|
||||
Reference in New Issue
Block a user