feat(infra): auto-commit con 29 cambios
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -59,15 +59,24 @@ ARGS_HASH=$(printf '%s' "$INPUT" | jq -c '.tool_input // {}' | sha256sum | cut -
|
||||
sql_escape() { printf '%s' "$1" | sed "s/'/''/g"; }
|
||||
|
||||
insert_call() {
|
||||
local fn_id="$1" tool_used="$2" duration_ms="${3:-0}"
|
||||
local fn_esc tu_esc ec_esc es_esc sid_esc ah_esc
|
||||
local fn_id="$1" tool_used="$2" duration_ms="${3:-0}" snippet="${4:-}"
|
||||
local fn_esc tu_esc ec_esc es_esc sid_esc ah_esc snip_esc
|
||||
# Politica issue 0087: command_snippet solo se rellena cuando function_id
|
||||
# esta vacio. Si la call golpea una funcion del registry, su ID y
|
||||
# tool_used bastan; no duplicamos el comando.
|
||||
if [ -n "$fn_id" ]; then snippet=""; fi
|
||||
# Redact common secrets antes de persistir
|
||||
snippet=$(printf '%s' "$snippet" \
|
||||
| sed -E 's/(password|token|secret|api[_-]?key|bearer)([[:space:]]*[=:][[:space:]]*)[^[:space:]]+/\1\2<REDACTED>/Ig' \
|
||||
| head -c 200)
|
||||
fn_esc=$(sql_escape "$fn_id")
|
||||
tu_esc=$(sql_escape "$tool_used")
|
||||
ec_esc=$(sql_escape "$ERROR_CLASS")
|
||||
es_esc=$(sql_escape "$ERROR_SNIPPET")
|
||||
sid_esc=$(sql_escape "$SESSION_ID")
|
||||
ah_esc=$(sql_escape "$ARGS_HASH")
|
||||
sqlite3 "$DB" "INSERT INTO calls (session_id, function_id, tool_used, args_hash, duration_ms, success, error_class, error_snippet, ts) VALUES ('$sid_esc','$fn_esc','$tu_esc','$ah_esc',$duration_ms,$SUCCESS,'$ec_esc','$es_esc',$TS);" 2>/dev/null || true
|
||||
snip_esc=$(sql_escape "$snippet")
|
||||
sqlite3 "$DB" "INSERT INTO calls (session_id, function_id, tool_used, args_hash, duration_ms, success, error_class, error_snippet, command_snippet, ts) VALUES ('$sid_esc','$fn_esc','$tu_esc','$ah_esc',$duration_ms,$SUCCESS,'$ec_esc','$es_esc','$snip_esc',$TS);" 2>/dev/null || true
|
||||
}
|
||||
|
||||
insert_code_write() {
|
||||
@@ -204,7 +213,7 @@ case "$TOOL_NAME" in
|
||||
TOOL_USED="sqlite_direct"
|
||||
fi
|
||||
|
||||
insert_call "$FN_ID" "$TOOL_USED"
|
||||
insert_call "$FN_ID" "$TOOL_USED" 0 "$CMD_HEAD"
|
||||
|
||||
# ---- Violation rules ----
|
||||
# 1. sqlite3 directo SELECT sobre registry.db (excepto schema/pragma/count/join)
|
||||
|
||||
Reference in New Issue
Block a user