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:
@@ -340,6 +340,48 @@ export function getRecordReach(days = 30): Promise<RecordReachPayload> {
|
||||
return apiGet(`/api/retrieval/record-reach?days=${days}`);
|
||||
}
|
||||
|
||||
/** The gates that can stop a tool call. */
|
||||
export type GateName = "enforce" | "hold" | "checkpoint" | "fence";
|
||||
|
||||
export interface GateCounts {
|
||||
/** Calls denied, or for the fence, put to the operator. */
|
||||
stops: number;
|
||||
/** Calls a hold would have stopped, let through because the session's
|
||||
* stop budget was spent. */
|
||||
let_through: number;
|
||||
/** Stops the session cleared by opening the rule. */
|
||||
cleared: number;
|
||||
/** Stops whose rule the session then reported as a misfire. */
|
||||
misfired: number;
|
||||
/** Stopped calls that ran after all; for the fence, the operator's yes. */
|
||||
ran: number;
|
||||
}
|
||||
|
||||
export interface GateRuleRow extends GateCounts {
|
||||
rule_id: number;
|
||||
gate: GateName;
|
||||
/** The moment or arm the rule was reached at. */
|
||||
at: string | null;
|
||||
title: string | null;
|
||||
sessions: number;
|
||||
last_stopped_at: string | null;
|
||||
}
|
||||
|
||||
export interface GateStopsPayload {
|
||||
days: number;
|
||||
by_gate: Record<GateName, GateCounts & { sessions: number }>;
|
||||
by_rule: GateRuleRow[];
|
||||
fence: { tool: string; target: string | null; asks: number; ran: number }[];
|
||||
/** The first stop ever recorded; null when none has been. */
|
||||
complete_from: string | null;
|
||||
covers_window: boolean | null;
|
||||
}
|
||||
|
||||
/** How often each gate stood in front of a tool call, and what followed. */
|
||||
export function getGateStops(days = 30): Promise<GateStopsPayload> {
|
||||
return apiGet(`/api/retrieval/gate-stops?days=${days}`);
|
||||
}
|
||||
|
||||
/** Whether the rules in force at each moment were followed there. */
|
||||
export function getAdherence(days = 30): Promise<AdherencePayload> {
|
||||
return apiGet(`/api/retrieval/adherence?days=${days}`);
|
||||
|
||||
Reference in New Issue
Block a user