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:
@@ -123,6 +123,11 @@ async def session_context():
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
# The longest carried note a prompt takes: the shape check's note names a
|
||||
# few definitions and the call that lists the rest.
|
||||
_CARRY_CHARS = 3000
|
||||
|
||||
|
||||
@plugin_bp.get("/retrieve")
|
||||
@login_required
|
||||
@memoized_query_embeddings
|
||||
@@ -166,6 +171,10 @@ async def autoinject_retrieve():
|
||||
one-line reminder when present; the hook's
|
||||
ledger is swept on compaction, which is how the
|
||||
full core comes back after one.
|
||||
carry (opt) — a note the session's last stop left for this
|
||||
prompt: the definitions its turn wrote that
|
||||
nobody has judged (/shape-check's `note`).
|
||||
Fitted after the reply shape, before the records.
|
||||
|
||||
ONE PAYLOAD, IN ONE ORDER, UNDER ONE BUDGET (`hook_payload`): the rules
|
||||
this prompt reaches and those mounted on `reply.report`, then the turn's
|
||||
@@ -216,7 +225,9 @@ async def autoinject_retrieve():
|
||||
record=False,
|
||||
)
|
||||
# One payload, in the one order: the rules, then the reply shape, then
|
||||
# the records menu, then the lesson-rule proposal, fitted to the budget.
|
||||
# what the last turn left unjudged, then the records menu, then the
|
||||
# lesson-rule proposal, fitted to the budget.
|
||||
carry = (request.args.get("carry") or "").strip()[:_CARRY_CHARS]
|
||||
turn_parts = (
|
||||
[*turn["rule_parts"], *turn["shape_parts"]] if "shape_parts" in turn
|
||||
else [hook_payload_svc.Part(text=turn.get("context") or "", ids={
|
||||
@@ -227,6 +238,7 @@ async def autoinject_retrieve():
|
||||
fitted = await hook_payload_svc.fit(g.user.id, [
|
||||
*hook_payload_svc.parts_of(rules, {hook_payload_svc.RULE: "shown_rule_ids"}),
|
||||
*turn_parts,
|
||||
*([hook_payload_svc.Part(text=carry)] if carry else []),
|
||||
*hook_payload_svc.parts_of(result, {hook_payload_svc.NOTE: "note_ids"}),
|
||||
*([hook_payload_svc.Part(text=proposal)] if proposal else []),
|
||||
])
|
||||
@@ -365,12 +377,20 @@ async def moment():
|
||||
rules: in full unless `shapes_seen` names it, then as its reminder. The
|
||||
payload is fitted to the user's budget (`hook_payload`), and `shape_keys`
|
||||
are the ones sent in full and kept, for the hook's ledger.
|
||||
|
||||
`decision` is the answer for the act itself (`retrieval_pipeline.
|
||||
act_decision`): `{}` when it goes ahead; `kind: "enforce"` when a rule set
|
||||
to enforce refuses it — the hook denies the call with `reason`, every
|
||||
time; `kind: "hold"` when an unopened rule set to hold asks for one read
|
||||
first — the hook denies once per rule and session, under the act
|
||||
checkpoint's cap. A write is never held, only refused.
|
||||
"""
|
||||
event = await request.get_json(silent=True) or {}
|
||||
tool = str(event.get("tool_name") or "").strip()
|
||||
tool_input = event.get("tool_input")
|
||||
if not tool:
|
||||
return jsonify({"context": "", "rule_ids": [], "moments": [], "shape_keys": []})
|
||||
return jsonify({"context": "", "rule_ids": [], "moments": [], "shape_keys": [],
|
||||
"decision": {}})
|
||||
project_id, _repo, _unbound = await _project_scope()
|
||||
reached, result = await moment_delivery_svc.deliver_for_act(
|
||||
g.user.id, tool, tool_input if isinstance(tool_input, dict) else {},
|
||||
@@ -394,6 +414,7 @@ async def moment():
|
||||
"rule_ids": fitted.keep_only(hook_payload_svc.RULE, result.rule_ids),
|
||||
"moments": [hit["moment"] for hit in reached],
|
||||
"shape_keys": [k for k, form in forms.items() if form == reply_shapes_svc.FULL],
|
||||
"decision": result.decision,
|
||||
})
|
||||
|
||||
|
||||
@@ -633,9 +654,11 @@ async def shape_check():
|
||||
The client's write hooks keep a ledger of the definitions each turn wrote;
|
||||
its Stop hook sends them here. The server decides which carry no judgment
|
||||
— against the ledger and the project's recorded snippets — records the
|
||||
outcome, and for a block returns the `reason` the agent is sent back with.
|
||||
A hook blocks only on a reason it received, so only on a block that was
|
||||
recorded, and never on the stop that follows one (`phase=after`).
|
||||
outcome, and returns the `note` the agent reads at the start of its next
|
||||
turn. Nothing here holds the reply: the question rides the next prompt,
|
||||
in the same session, while the code is still in view. `phase=after` is
|
||||
the stop after that prompt, sent with the lines the note named, and
|
||||
records whether they were judged.
|
||||
|
||||
A GET like every plugin endpoint: a read-scoped key runs the plugin, and
|
||||
this records telemetry the way /reply-rules records its section check. It changes no ledger
|
||||
@@ -682,8 +705,8 @@ async def shape_check():
|
||||
)
|
||||
body["outcome"] = outcome
|
||||
body["unjudged"] = unjudged
|
||||
if outcome == "blocked":
|
||||
body["reason"] = shape_check_svc.block_reason(
|
||||
if outcome == "noted":
|
||||
body["note"] = shape_check_svc.note_text(
|
||||
unjudged, project_id=project_id, repo=repo_key or repo,
|
||||
)
|
||||
return jsonify(body)
|
||||
|
||||
Reference in New Issue
Block a user