feat(8141): every gate that stops a tool call is recorded, with what followed

A rule set to enforce or hold, the act checkpoint and the project fence
stopped work and left no record. The hook that makes each stop now reports
it to POST /api/plugin/gate-stop; the hook decides, not the server, because
the per-rule and per-session caps are kept in the plugin.

- gate_stops table (migration 0138): gate, outcome (stopped / let_through /
  asked), rule, where it was reached, tool, target project, call id.
- An open of the rule stamps the stop as cleared (rule-opened). A fenced
  call that then runs stamps ran: grimoire_fence_ran.sh, a PostToolUse on
  the fenced tools, matches the call id the fence left pending. That is
  the operator's yes.
- A hold or checkpoint the spent session budget lets through is reported
  as let_through; the per-rule once is not.
- The readout: by gate and by rule, stops, cleared by a read, misfired
  (rule_misfired after it), let through by the cap, ran. In
  retrieval_telemetry as `gates`, at /api/retrieval/gate-stops, and on the
  Moments settings page ("When a rule stopped the work").
- act_decision carries `at`, the moment the deciding rule was reached at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 14:12:14 -05:00
co-authored by Claude Opus 5.5
parent 706f49a12a
commit 65f1be80b6
24 changed files with 1128 additions and 13 deletions
+20 -3
View File
@@ -7,9 +7,12 @@ import WeightProposals from "@/components/WeightProposals.vue";
import LessonSituationProposals from "@/components/LessonSituationProposals.vue";
import RecordKinds from "@/components/RecordKinds.vue";
import RecordReach from "@/components/RecordReach.vue";
import GateStops from "@/components/GateStops.vue";
import RuleAdherence from "@/components/RuleAdherence.vue";
import { getAdherence, getRecordReach } from "@/api/moments";
import type { AdherencePayload, MomentAction, MomentAdherenceRow, MomentUsage, RecordReachPayload } from "@/api/moments";
import { getAdherence, getGateStops, getRecordReach } from "@/api/moments";
import type {
AdherencePayload, GateStopsPayload, MomentAction, MomentAdherenceRow, MomentUsage, RecordReachPayload,
} from "@/api/moments";
import { fmtDate } from "@/utils/dateFormat";
/**
@@ -65,6 +68,19 @@ async function loadReach() {
}
}
// When a gate stopped a tool call, read on its own for the same reason.
const gates = ref<GateStopsPayload | null>(null);
const gatesFailed = ref(false);
async function loadGates() {
try {
gates.value = await getGateStops(days.value);
gatesFailed.value = false;
} catch {
gatesFailed.value = true;
}
}
function followed(moment: string): MomentAdherenceRow | null {
return adherence.value?.by_moment.find((m) => m.at === moment) ?? null;
}
@@ -145,7 +161,7 @@ async function addMapping() {
onMounted(async () => {
await store.load(true);
await Promise.all([loadAdherence(), loadReach()]);
await Promise.all([loadAdherence(), loadReach(), loadGates()]);
});
</script>
@@ -174,6 +190,7 @@ onMounted(async () => {
<WeightProposals />
<LessonSituationProposals />
<RuleAdherence :data="adherence" :failed="adherenceFailed" @retry="loadAdherence" />
<GateStops :data="gates" :failed="gatesFailed" @retry="loadGates" />
<RecordReach :data="reach" :failed="reachFailed" @retry="loadReach" />
<RecordKinds :days="days" />