ai_runs logging, redaction and retention (#60)
CI / ci (push) Successful in 1m34s

Co-authored-by: dev_agent <dev_agent@cubecraftlabs.com>
This commit was merged in pull request #60.
This commit is contained in:
2026-10-05 09:55:06 -04:00
committed by approver_agent
parent 5d5404b3cb
commit 87316d8b70
13 changed files with 1274 additions and 49 deletions
+12 -1
View File
@@ -150,7 +150,18 @@ automatic** (D-021).
Anthropic and Ollama endpoints, called over plain HTTP — no vendor SDKs.
- **Skill harness** (`ai/harness`): prompt layering, validation of the
structured output, and **one repair retry**; if the repair also fails the
run fails — no silent fallback. Every call is recorded in `ai_runs`.
run fails — no silent fallback. Every run writes one `ai_runs` row when it
ends, covering the repair turn too, with status `ok`, `repaired`,
`bad_output` or `provider_error`; a prompt that cannot be rendered is
`bad_output` and a provider that cannot be built is `provider_error`, both
with no turns. The harness builds the provider itself from the settings
and the decrypted API key (`presets.FromSettings`), so the key it redacts
is always the key the provider sends. Request and response
bodies are redacted before they are stored: the decrypted API key,
Authorization and API-key header values, Google Chat webhook URLs and URLs
with key-like query parameters are removed, inside JSON strings too.
`harness.Purge` deletes rows older than `harness.RunRetention` (30 days),
clearing the `suggestion_batches` and `week_plans` references first.
- **Prompt layering** (D-007): each skill version's prompt is a
`text/template` file embedded from `ai/skills/prompts/`
(`<skill>.v<version>.tmpl`). The system prompt is always, in order: