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:
@@ -198,92 +198,14 @@ class PRV_Admin_Page {
|
||||
)
|
||||
);
|
||||
echo '</p></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the dashboard CSS for the PR Vision admin page.
|
||||
} /**
|
||||
* Return the combined CSS string for all PR Vision admin screens.
|
||||
*
|
||||
* Covers two concerns:
|
||||
* 1. WP admin wrapper chrome (injected here; fires on BOTH PR Vision screens
|
||||
* because the enqueue_assets guard matches 'pr-vision' in the hook suffix):
|
||||
* #wpcontent / #wpbody-content are set to the dark page bg so no white
|
||||
* gutter/strip shows around or above the dark UI.
|
||||
* 2. Component tokens (.prv-*) — unchanged from prior versions.
|
||||
*
|
||||
* This inline style block is attached to wp-admin (always loaded on admin
|
||||
* pages) via wp_add_inline_style() and therefore only present on the two
|
||||
* PR Vision screens. It must NOT be registered globally.
|
||||
* Delegates to PRV_Admin_Page_Css to keep this class under 300 lines.
|
||||
*
|
||||
* @return string CSS string.
|
||||
*/
|
||||
private function get_dashboard_css(): string {
|
||||
return '
|
||||
/* === PR Vision — WP admin chrome: kill white wrappers (scoped via conditional enqueue) === */
|
||||
#wpcontent{background:#14181C;padding-left:0;}
|
||||
#wpbody-content{background:#14181C;min-height:calc(100vh - 32px);padding-bottom:40px;}
|
||||
#wpbody{background:#14181C;}
|
||||
.wrap>h1,.prv-settings-wrap~*>h1,.wp-heading-inline{color:#EEF2F5;}
|
||||
.notice.prv-proxy-note{background:#1C2228;border-left-color:#34C0CA;color:#EEF2F5;}
|
||||
.notice.prv-proxy-note p{color:#C2CCD6;}
|
||||
/* === PR Vision dashboard — "Assay" palette (dark-adapted) === */
|
||||
.prv-bento{display:grid;grid-template-columns:1.25fr 1fr 1fr;gap:16px;margin:18px 0 22px;}
|
||||
@media(max-width:820px){.prv-bento{grid-template-columns:1fr;}}
|
||||
.prv-tile{background:#1C2228;border:1px solid #3A4651;border-radius:12px;padding:20px 22px;position:relative;min-height:140px;display:flex;flex-direction:column;}
|
||||
.prv-tile-label{font-size:11.5px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:#9AA7B2;margin-bottom:6px;}
|
||||
.prv-tile-big{font-size:42px;font-weight:700;color:#EEF2F5;line-height:1;font-variant-numeric:tabular-nums;margin-top:auto;}
|
||||
.prv-tile-big small{font-size:16px;font-weight:600;color:#9AA7B2;margin-left:3px;}
|
||||
.prv-tile-sub{font-size:12.5px;color:#9AA7B2;margin-top:8px;}
|
||||
.prv-tile-delta{font-size:12.5px;font-weight:600;margin-top:8px;}
|
||||
.prv-delta--up{color:#9BE635;} .prv-delta--down{color:#FF6B5E;} .prv-delta--flat{color:#9AA7B2;}
|
||||
/* health pill */
|
||||
.prv-health-pill{position:absolute;top:14px;right:14px;display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:600;padding:3px 9px 3px 7px;border-radius:999px;}
|
||||
.prv-health-dot{width:7px;height:7px;border-radius:50%;flex:0 0 7px;}
|
||||
.prv-health--ok{background:rgba(155,230,53,.15);color:#9BE635;} .prv-health--ok .prv-health-dot{background:#9BE635;}
|
||||
.prv-health--warn{background:rgba(255,157,77,.15);color:#FFB36E;} .prv-health--warn .prv-health-dot{background:#FF9D4D;}
|
||||
.prv-health--neutral{background:rgba(136,147,160,.14);color:#B4BDC7;} .prv-health--neutral .prv-health-dot{background:#8893A0;}
|
||||
/* cost tile */
|
||||
.prv-cost-row{display:flex;align-items:baseline;gap:4px;margin-top:auto;}
|
||||
.prv-cost-big{font-size:28px;font-weight:700;color:#EEF2F5;font-variant-numeric:tabular-nums;}
|
||||
.prv-cost-cap{font-size:13px;color:#9AA7B2;}
|
||||
.prv-meter{height:10px;border-radius:999px;background:#2A333C;margin-top:8px;border:1px solid #333D47;overflow:hidden;}
|
||||
.prv-meter>span{display:block;height:100%;border-radius:999px;background:#34C0CA;transition:width .3s ease;}
|
||||
.prv-meter--capped>span{background:#FF9D4D;}
|
||||
.prv-trunc-badge{display:flex;align-items:flex-start;gap:7px;margin-top:10px;background:rgba(255,157,77,.15);border:1px solid rgba(255,157,77,.42);border-radius:6px;padding:8px 10px;font-size:12px;color:#EEF2F5;line-height:1.4;}
|
||||
.prv-trunc-icon{color:#FFB36E;font-size:14px;flex:0 0 16px;margin-top:1px;}
|
||||
.prv-trunc-badge b{color:#FFB36E;}
|
||||
/* last run tile */
|
||||
.prv-tile-ts{font-size:20px;font-weight:700;color:#EEF2F5;margin-top:auto;line-height:1.2;}
|
||||
.prv-tile-meta{font-size:12.5px;color:#9AA7B2;margin-top:6px;}
|
||||
/* cards */
|
||||
.prv-card{background:#1C2228;border:1px solid #3A4651;border-radius:12px;margin:0 0 20px;}
|
||||
.prv-card-head{display:flex;align-items:center;justify-content:space-between;padding:18px 22px 0;}
|
||||
.prv-card-head h2{font-size:16px;font-weight:600;color:#EEF2F5;margin:0;}
|
||||
.prv-card-body{padding:10px 22px 20px;}
|
||||
/* chart */
|
||||
.prv-chartbox{position:relative;height:300px;max-height:300px;padding:14px 8px 0;overflow:hidden;}
|
||||
.prv-chartbox canvas{max-height:286px;}
|
||||
.prv-chart-fallback{display:none;height:100%;align-items:center;justify-content:center;text-align:center;color:#9AA7B2;font-size:13px;padding:0 24px;}
|
||||
.prv-chartbox.prv-noscript .prv-chart-fallback{display:flex;}
|
||||
.prv-chartbox.prv-noscript canvas{display:none;}
|
||||
/* chart legend */
|
||||
.prv-chartcap{display:flex;align-items:center;gap:16px;flex-wrap:wrap;padding:8px 22px 4px;font-size:12.5px;color:#9AA7B2;}
|
||||
.prv-chartcap-item{display:inline-flex;align-items:center;gap:6px;}
|
||||
.prv-leg-solid{width:20px;height:0;border-top:3px solid #34C0CA;display:inline-block;}
|
||||
.prv-leg-dash{width:20px;height:0;border-top:2px dashed #B6F25A;display:inline-block;}
|
||||
.prv-leg-cfg{display:inline-flex;align-items:center;gap:3px;}
|
||||
.prv-leg-cfg::before{content:"";width:0;height:14px;border-left:2px dashed #FFB36E;display:inline-block;}
|
||||
.prv-leg-cfg::after{content:"";width:8px;height:8px;border-radius:50%;background:#FF9D4D;display:inline-block;}
|
||||
/* config change note */
|
||||
.prv-cfg-note{display:flex;gap:10px;align-items:flex-start;margin:8px 22px 14px;background:rgba(255,157,77,.15);border:1px solid rgba(255,157,77,.42);border-radius:8px;padding:11px 14px;color:#EEF2F5;font-size:13px;line-height:1.45;}
|
||||
.prv-cfg-note-icon{color:#FFB36E;font-style:normal;flex:0 0 16px;margin-top:1px;}
|
||||
.prv-cfg-note b{color:#FFB36E;}
|
||||
/* standings table */
|
||||
.prv-standings{margin:0;}
|
||||
.prv-status{display:inline-flex;align-items:center;gap:4px;font-size:12.5px;font-weight:600;padding:2px 8px;border-radius:999px;}
|
||||
.prv-status--cited{background:rgba(155,230,53,.15);color:#9BE635;}
|
||||
.prv-status--not-yet{background:rgba(136,147,160,.14);color:#B4BDC7;}
|
||||
/* proxy note */
|
||||
.prv-proxy-note{margin:10px 0;}
|
||||
';
|
||||
return PRV_Admin_Page_Css::get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user