P2 pre-merge fixes: io_captured column, reconcile copy, harden security test
Fix 1: Add io_captured TINYINT(1) NOT NULL DEFAULT 0 to prv_call_meta CREATE (baked into initial schema — table is new in v0.3.0, no separate migration needed). PRV_Capture_Writer::write_io() sets io_captured=1 via set_io_captured() on success; error rows and legacy rows keep 0. Drawer state now driven by io_captured instead of config_version heuristic: 0 → Legacy/not-captured 1 + io → Normal 1 + no io → Pruned ARCHITECTURE.md schema section updated. Fix 2: Soften reconciliation copy in PRV_Costs_Renderer (~line 75): 'matches the Dashboard MTD total' → 'approximately reconciles to the Dashboard MTD total' — error calls write prv_call_meta (cost 0) but not prv_ai_visibility, so exact equality is not guaranteed. Fix 3: Harden security test (test-capture-writer Test 4): inject sentinel sk-or-TEST-LEAK-CANARY as PRV_OPENROUTER_API_KEY constant; queue a mocked 401 wp_remote_post response; drive PRV_Probe_Runner → PRV_Probe_Run_Executor → probe_one() 401 error path end-to-end; assert the sentinel, Bearer, and Authorization appear in NO stored row (prv_call_meta or prv_call_io). Original direct-writer security test retained as Test 3.
This commit is contained in:
@@ -86,21 +86,21 @@ class PRV_Call_Drawer_Renderer {
|
||||
$latency_ms = isset( $meta['latency_ms'] ) ? (int) $meta['latency_ms'] : null;
|
||||
$cost_usd = (float) ( $meta['cost_usd'] ?? 0.0 );
|
||||
$run_id = (string) ( $meta['run_id'] ?? '' );
|
||||
$config_ver = isset( $meta['config_version'] ) ? (int) $meta['config_version'] : null;
|
||||
$config_ver = isset( $meta['config_version'] ) ? (int) $meta['config_version'] : null;
|
||||
$io_captured = isset( $meta['io_captured'] ) ? (int) $meta['io_captured'] : 0;
|
||||
|
||||
// Determine drawer state.
|
||||
$is_legacy = ( null === $io && ! $is_error );
|
||||
$is_pruned = false; // Detection: io null + not legacy = checked by caller.
|
||||
// Determine drawer state using the explicit io_captured flag.
|
||||
// io_captured = 1 AND io row present → Normal.
|
||||
// io_captured = 1 AND io row absent → Pruned (aged out by retention cron).
|
||||
// io_captured = 0 → Legacy / not captured (pre-feature row).
|
||||
$has_io = ( null !== $io );
|
||||
$vis_row_null = empty( $meta['visibility_row'] );
|
||||
if ( null === $io && ! $is_error ) {
|
||||
// Could be pruned or legacy (pre-v0.3). Distinguish by config_version.
|
||||
if ( null === $config_ver || $config_ver < 3 ) {
|
||||
$is_legacy = true;
|
||||
} else {
|
||||
$is_pruned = true;
|
||||
$is_legacy = false;
|
||||
}
|
||||
if ( ! $is_error ) {
|
||||
$is_legacy = ( 0 === $io_captured );
|
||||
$is_pruned = ( 1 === $io_captured && ! $has_io );
|
||||
} else {
|
||||
$is_legacy = false;
|
||||
$is_pruned = false;
|
||||
}
|
||||
|
||||
// Header.
|
||||
|
||||
Reference in New Issue
Block a user