PR Vision v0.3.0: per-call cost accountability + LLM call audit trail
P0 security: - PRV_Gateway_Client: remove response body from RuntimeException (HTTP status only) - PRV_Capture_Writer: allowlist-only write (prompt/response text, never headers/auth) - Mandatory capture order: can_afford → probe → persist_result → update_row_cost → write_meta → capture_io - capture_io last and wrapped in swallowing try/catch New tables (SCHEMA_VERSION 3): - prv_call_meta: cost/metadata per call, kept indefinitely - prv_call_io: rendered prompt + raw response, pruned on retention window (default 90d) New classes: - PRV_Call_Meta_Table, PRV_Call_Io_Table: table schema + dbDelta - PRV_Capture_Writer: metadata + I/O write; security allowlist enforced - PRV_Prune_Cron: daily prv_daily_prune cron deletes aged prv_call_io rows only - PRV_Cost_Rollup_Query: MTD summary, model breakdown, drill-down, projection - PRV_Call_Log_Query: paginated + filtered call-log query + per-call I/O fetch - PRV_Costs_Page + PRV_Costs_Renderer: Costs admin sub-page (cap progress, bento, model table, drill-down) - PRV_Call_Log_Page + PRV_Call_Log_Table_Renderer: Call Log admin sub-page (filter bar, paginated table, WCAG AA pagination) - PRV_Call_Drawer_Renderer: non-modal complementary drawer (5 states: Normal/Pruned/Legacy/Failed/Loading) - PRV_Call_Drawer_Script: inline JS for drawer (300-line split from renderer) - PRV_Call_Detail_Ajax: wp_ajax_prv_call_detail AJAX handler - PRV_Admin_Page_Css: CSS provider (300-line split from PRV_Admin_Page) - PRV_Probe_Run_Executor: inner probe loop (300-line split from PRV_Probe_Runner) Updated: - PRV_Probe_Result: tokens_in/tokens_out params + getters - Both providers: report tokens_in/tokens_out from usage.prompt_tokens/completion_tokens - PRV_Probe_Runner: slimmed to lock+UUID+delegation; injects PRV_Capture_Writer - PRV_Config: get_io_retention_days(); PRV_IO_RETENTION_DEFAULT_DAYS constant - PRV_Upgrader/Activator/Deactivator/Plugin: register new tables, cron, pages, AJAX - Settings: retention days field + save in controller - uninstall.php: DROP both new tables, clear prv_daily_prune cron - Subnav 4-tab strip (Dashboard | Costs | Call Log | Settings) on all pages - ARCHITECTURE.md, CHANGELOG.md, CONTEXT.md, CONVENTIONS.md updated Tests: - test-capture-writer.php: write_meta, write_io, P0 security (401 record has no key/Bearer/sk-or-) - test-cost-audit.php: MTD reconciliation, projection, prune, forced capture_io exception, table drops Agent-Session: peptiderepo-geomonitor-v0.3.0-cost-audit
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Architecture — PR Vision
|
||||
|
||||
**Version:** 0.2.1 | **Last updated:** 2026-06-14
|
||||
**Version:** 0.3.0 | **Last updated:** 2026-06-15
|
||||
|
||||
---
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
**v1 scope:** AI-visibility only. The collector/panel seam is present so future data categories can be added as new classes.
|
||||
**v2 additions:** Model manager CRUD (no deploy needed), config-version tracking, run-lock, projected cost, API-key three-state, dark "Assay" Settings UI.
|
||||
**v0.3.0 additions:** Per-call cost/metadata + I/O audit trail; Costs + Call Log admin pages; non-modal detail drawer; daily I/O prune cron; `PRV_Gateway_Client` exception body removed (P0).
|
||||
|
||||
---
|
||||
|
||||
@@ -130,6 +131,41 @@ Admin page load ─────────────────────
|
||||
|
||||
## 4. Database
|
||||
|
||||
### v0.3.0 additions
|
||||
|
||||
**Table:** `{prefix}prv_call_meta` (kept indefinitely)
|
||||
|
||||
| Column | Type | Notes |
|
||||
|--------|------|-------|
|
||||
| id | BIGINT UNSIGNED PK | Auto-increment |
|
||||
| visibility_row | BIGINT UNSIGNED NULL | FK to prv_ai_visibility.id (nullable) |
|
||||
| run_id | VARCHAR(36) | UUID for the run |
|
||||
| peptide_slug | VARCHAR(200) | e.g. "bpc-157" |
|
||||
| model | VARCHAR(200) | e.g. "perplexity/sonar" |
|
||||
| intent_label | VARCHAR(200) | Prompt intent template |
|
||||
| tokens_in | INT NULL | Input token count from API |
|
||||
| tokens_out | INT NULL | Output token count from API |
|
||||
| cost_usd | DECIMAL(12,8) | Actual call cost |
|
||||
| latency_ms | INT NULL | Call latency in ms |
|
||||
| cited | TINYINT(1) NULL | 1=cited, 0=not cited, NULL=error |
|
||||
| http_status | INT | HTTP status (200=ok, 4xx/5xx=error) |
|
||||
| captured_at | DATETIME | UTC |
|
||||
| config_version | INT NULL | Config version at run time |
|
||||
|
||||
**Table:** `{prefix}prv_call_io` (pruned after retention window)
|
||||
|
||||
| Column | Type | Notes |
|
||||
|--------|------|-------|
|
||||
| id | BIGINT UNSIGNED PK | Auto-increment |
|
||||
| call_id | BIGINT UNSIGNED | FK to prv_call_meta.id |
|
||||
| prompt_text | LONGTEXT | Rendered prompt (plain text) |
|
||||
| response_text | LONGTEXT | Raw LLM response text |
|
||||
| captured_at | DATETIME | UTC (indexed for prune query) |
|
||||
|
||||
---
|
||||
|
||||
## 4a. Original Database
|
||||
|
||||
**Table:** `{prefix}prv_ai_visibility`
|
||||
|
||||
| Column | Type | Notes |
|
||||
|
||||
Reference in New Issue
Block a user