# Changelog — PR Vision All notable changes to this project will be documented in this file. Format: [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) Versioning: [Semantic Versioning](https://semver.org/) --- ## [0.3.3] — 2026-06-19 P1 security fix: write-only key invariant — remove key-format prefix from placeholder. ### Fixed - **[SECURITY] P1 — API-key input placeholder leaked provider prefix in rendered HTML.** `class-prv-key-manager-renderer.php` rendered `placeholder="sk-or-…"` on the password input. The placeholder contained the literal string `sk-or-` which (a) exposes provider-format information to anyone who can view page source, and (b) caused the `not.toContain('sk-or-')` smoke-suite assertion to fail (confirmed in CI run on 2026-06-17, job 81824705096). The placeholder is now `Paste provider API key` — neutral, no key-format prefix, no provider information. The `value=""` write- only invariant was already correct; this fixes the remaining output surface. - Added inline comment and docblock note: placeholder text must never contain a key-format prefix — even a format hint in a placeholder violates the write-only contract and trips smoke-suite security guards. ### Audit Full-codebase audit performed (2026-06-19): - `class-prv-settings-renderer.php` — no key emission; clean. - `class-prv-key-manager-renderer.php` — placeholder was the sole leak; now fixed. - `class-prv-model-manager-table.php` — no key fields; clean. - `class-prv-settings-controller.php` — processes POST input; never reflects back. - `class-prv-key-store.php` — `get_key()` used server-side only; never echoed. - `class-prv-crypto-helper.php` — encrypt/decrypt helper; no HTML output. - `class-prv-key-test-ajax.php` — AJAX; returns valid/invalid message, never the key. - `class-prv-model-test-ajax.php` — AJAX; returns model health, never the key. - `class-prv-gateway-client.php` — HTTP client; key only in Authorization header. - `class-prv-probe-run-executor.php` — `error_log()` only logs HTTP status, not the key. - `class-prv-capture-writer.php` — allowlisted fields; no key fields. - `class-prv-call-drawer-renderer.php` / `class-prv-call-log-*` — no key fields. - All providers — `get_key()` only flows to HTTP Authorization header. - No `wp_localize_script` calls anywhere in the plugin. - No REST endpoints registered; no REST response surfaces. - No data attributes containing key fields. --- ## [0.3.2] — 2026-06-16 CI/CD adoption: PHPUnit test suite (WP stubs), estate reusable pipeline, and governance workflows. ### Added - **PHPUnit test suite** (`tests: stubs`): 17 hand-rolled test files converted to 17 `tests/unit/*Test.php` PHPUnit TestCases. All security assertions preserved (P0 key-leak / encryption / capture-allowlist tests in `CaptureWriterTest`, `KeyStoreTest`). `composer test` runs `vendor/bin/phpunit`. - **phpunit.xml.dist** — PHPUnit 9.x configuration; discovers `tests/unit/*Test.php`. - **`tests/bootstrap.php`** updated to load Composer autoloader before stubs (PHPUnit stubs pattern; no WP install required). - **`composer.json`** — added `phpunit/phpunit ^9.6` and `yoast/phpunit-polyfills ^2.0` to `require-dev`; added `composer test` script. - **`.github/workflows/ci.yml`** — thin caller of `peptiderepo/peptide-e2e/.github/workflows/ci.yml@main` (`tests: stubs`, `has_js: true`, `workflow_call` trigger, `permissions: contents: write`). Replaces the hand-rolled inline CI. - **`.github/workflows/deploy.yml`** — estate pattern: thin caller of `peptiderepo/peptide-e2e/.github/workflows/deploy-app.yml@main` with `target_path: wp-content/plugins/pr-vision`, gated on the reusable CI job. Replaces the standalone inline rsync. Pull-deploy on Hostinger stays as break-glass. - **`.github/workflows/cto-review.yml`** — Haiku-only automated PR reviewer (estate standard, A/B panel dropped 2026-06-12). - **`.github/workflows/main-push-audit.yml`** — direct-push-to-main audit tripwire (estate standard). --- ## [0.3.1] — 2026-06-15 Self-healing cron scheduling: `PRV_Cron_Guard` ensures managed WP-Cron events are re-scheduled on `init` when missing (e.g. after an rsync deploy that bypasses the activation hook). ### Fixed - Managed cron hooks (`prv_weekly_probe`, `prv_daily_prune`) are now re-scheduled automatically on any page load where they are missing. Delegates to `PRV_Cron::schedule()` and `PRV_Prune_Cron::schedule()` so recurrence and first-run offset are identical to what the activator sets. Hot-path cost: two `wp_next_scheduled()` checks; no DB writes unless an event is missing. ### Added - **`PRV_Cron_Guard`** (`includes/core/class-prv-cron-guard.php`) — idempotent guard registered on `init`; calls canonical scheduler methods when missing. - `PRV_Plugin::init()` — wires `PRV_Cron_Guard::register_hooks()`. - Tests: `test-cron-guard.php`. --- ## [0.3.0] — 2026-06-15 Per-call cost accountability + LLM call audit trail. Every probe call now produces an inspectable record with cost, tokens, latency, and the exact rendered prompt + raw response. Two new admin pages (Costs, Call Log) with a non-modal detail drawer. Raw I/O is pruned on a configurable retention window (default 90 days); cost/metadata kept indefinitely. ### Fixed (pre-launch P2 cleanup) - `io_captured TINYINT(1) NOT NULL DEFAULT 0` column added to `prv_call_meta` CREATE (baked into initial schema — table is new in v0.3.0). Set to `1` by `PRV_Capture_Writer::write_io()` on success, remains `0` for error rows and legacy/pre-feature rows. Drawer state now driven by `io_captured` instead of the `config_version < 3` heuristic: `0` = Legacy/not-captured; `1` + io row present = Normal; `1` + io row absent = Pruned (aged out). Removes a fragile inference. ### Security (P0) - `PRV_Gateway_Client::post_to_gateway()` — removed response body from RuntimeException message; exception now carries HTTP status code only. Closes the pre-existing 401-body → error_log → key-leak vector. - `PRV_Capture_Writer` — allowlist-only capture; NEVER receives `$headers`, `Authorization`, or any raw HTTP request object. Structurally impossible for a key to enter a stored row. - Mandatory capture ordering enforced in `PRV_Probe_Run_Executor`: `can_afford → probe → persist_result → update_row_cost → write_meta → capture_io`. `capture_io` is last and wrapped in a swallowing try/catch. ### Added - **`PRV_Call_Meta_Table`** — per-call cost/metadata table (kept indefinitely). - **`PRV_Call_Io_Table`** — per-call I/O table (pruned on retention window). - **`PRV_Capture_Writer`** — writes metadata + I/O rows; allowlist-only. - **`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 call-log with filters; per-call I/O fetch. - **`PRV_Costs_Page`** — "PR Vision > Costs" admin sub-page. - **`PRV_Costs_Renderer`** — cap progress, bento, model table, drill-down; includes `render_subnav()` shared helper. - **`PRV_Call_Log_Page`** — "PR Vision > Call Log" admin sub-page with filter bar. - **`PRV_Call_Log_Table_Renderer`** — paginated table; cited% 0 = muted, >0 = lime; WCAG AA pagination. - **`PRV_Call_Drawer_Renderer`** — non-modal `role="complementary"` drawer; 5 states (Normal, Pruned, Legacy, Failed, Loading). Focus-managed; Esc closes. - **`PRV_Call_Drawer_Script`** — inline JS for drawer open/close/fetch/copy split for 300-line compliance. - **`PRV_Call_Detail_Ajax`** — `wp_ajax_prv_call_detail` AJAX handler for drawer content. - **`PRV_Admin_Page_Css`** — CSS provider split from `PRV_Admin_Page` for 300-line compliance. - **`PRV_Probe_Run_Executor`** — inner probe loop split from `PRV_Probe_Runner`. - `PRV_Probe_Result` — added `tokens_in`/`tokens_out` params + getters. - Both providers — report `tokens_in`/`tokens_out` from `usage.prompt_tokens`/`completion_tokens`. - `PRV_Config::get_io_retention_days()` — reads `prv_io_retention_days` option. - Retention days field added to Settings form + saved by controller. - Subnav 4-tab strip added to all PR Vision pages (Dashboard | Costs | Call Log | Settings). - Constants `PRV_IO_RETENTION_DEFAULT_DAYS`, `PRV_DAILY_PRUNE_HOOK`. - Tests: `test-capture-writer.php`, `test-cost-audit.php`. ### Changed - `PRV_Probe_Runner` — slimmed to lock + UUID + delegation; inner loop moved to `PRV_Probe_Run_Executor`. Constructor now also accepts `PRV_Capture_Writer`. - `PRV_Upgrader::run()` — creates both new tables on every `plugins_loaded`. - `PRV_Activator::activate()` — creates new tables + schedules `prv_daily_prune` cron. - `PRV_Deactivator::deactivate()` — clears `prv_daily_prune` cron. - `PRV_Plugin::init()` — registers `PRV_Costs_Page`, `PRV_Call_Log_Page`, `PRV_Call_Detail_Ajax`, `PRV_Prune_Cron`. - `PRV_Settings_Renderer` — adds subnav + retention days field. - `PRV_Settings_Controller::handle_save()` — saves `prv_io_retention_days`. - `uninstall.php` — DROPs `prv_call_io` + `prv_call_meta`; clears `prv_daily_prune` cron. - Schema version bumped to 3. ### Security - See P0 section above. --- ## [0.2.3] — 2026-06-15 UI-editable provider API key: encrypted at rest, write-only, wp-config precedence. Output-escaping hardening in key manager renderer (`esc_url`/`esc_attr`/literal-conditional on all echoed values). ### Added - **`PRV_Key_Store`** (`includes/core/class-prv-key-store.php`): single key resolver with precedence chain — `PRV_OPENROUTER_API_KEY` constant → encrypted admin option `prv_provider_key_enc` → none. `get_key()` is the sole key-access point for all probe and test paths. - **`PRV_Crypto_Helper`** (`includes/core/class-prv-crypto-helper.php`): low-level symmetric encryption/decryption. Prefers libsodium `sodium_crypto_secretbox` (XSalsa20-Poly1305); falls back to OpenSSL AES-256-GCM. Encryption key is derived from WP salts (`AUTH_KEY` + `SECURE_AUTH_KEY`) via SHA-256 — environment-specific, never stored. Storage format: `hex(nonce):hex(ciphertext)`. - **`PRV_Key_Manager_Renderer`** (`includes/core/class-prv-key-manager-renderer.php`): renders the write-only "Provider API Key" card in Settings. Shows source status only ("Set via wp-config (takes precedence)" / "Set via admin" / "Not set") plus last-run health. Password input always renders empty. Constant defined → input disabled with note. - **`PRV_Key_Test_Ajax`** (`includes/core/class-prv-key-test-ajax.php`): AJAX handler for the "Test key" button. Resolves key via `PRV_Key_Store::get_key()`, runs one cheap probe, reports valid/invalid with `aria-live` result; key never in response. - **Key set/remove POST actions** in `PRV_Settings_Controller`: `handle_key_set()` (encrypts + stores; empty input = no-op) and `handle_key_remove()`. - **`prv_key_set`, `prv_key_remove`, `prv_key_error`** notices in `PRV_Settings_Renderer`. - **`wp_ajax_prv_test_key`** hook registered in `PRV_Settings_Page` → dispatches to `PRV_Key_Test_Ajax`. - **Tests** (`tests/unit/test-key-store.php`): encrypt↔decrypt round-trip, wrong-key fails silently, resolver precedence (constant > option > none), write-only render emits no key, Remove clears option, constant takes precedence. ### Changed - **`PRV_OpenRouter_Provider`**: removed direct `PRV_OPENROUTER_API_KEY` constant reads; `probe()` now calls `PRV_Key_Store::get_key()`. New `probe_with_key(string $q, string $key)` method for the test path (PRV_Key_Test_Ajax injects the resolved key). `is_configured()` now checks `PRV_Key_Store::get_key() !== ''`. - **`PRV_Perplexity_Provider`**: same key-resolver migration — `probe()` calls `PRV_Key_Store::get_key()`. `is_configured()` checks the store. Direct constant reads removed. - **`PRV_Model_Test_Ajax`**: resolves key via `PRV_Key_Store::get_key()` instead of checking the constant directly. Returns a specific "key not configured — set via Settings" message when no key is available. - **`PRV_Settings_Renderer`**: replaced read-only `render_api_key_status()` with a call to `PRV_Key_Manager_Renderer::render()`. Added key-action notices. Provider API Key card is now separate from the Probe Configuration form. - **`PRV_Settings_Page`**: added `NONCE_KEY` + `NONCE_KEY_TEST` constants; registered `admin_post_prv_key_set`, `admin_post_prv_key_remove`, `wp_ajax_prv_test_key`. - **`uninstall.php`**: updated comment to explicitly list `prv_provider_key_enc` as a v0.2.3 addition purged by the `prv_` wildcard DELETE. - **`tests/unit/test-uninstall.php`**: seeds + asserts `prv_provider_key_enc` purge. ### Security - Plaintext API key never stored in any option, transient, log, or echoed to the browser. - The encrypted option (`prv_provider_key_enc`) is ciphertext only; decryption is server-side at probe time only. The encryption key is derived from WP salts — not stored. - `manage_options` + nonce required for all key actions (set, remove, test). - `wp-config` constant always takes precedence; admin path is only active when absent. --- ## [0.2.2] — 2026-06-14 Kill white WP admin gutters around the dark "Assay" UI — CSS only, no logic change. ### Fixed - **Admin chrome (dashboard + settings):** `#wpcontent`, `#wpbody`, and `#wpbody-content` now receive the dark page background (`#14181C`) on both PR Vision screens. WP's default `20px` left padding on `#wpcontent` is removed so no light gutter appears between the left menu and the dark content area. - **WP admin bar / first-element gap:** `#wpbody` dark fill removes the white strip between the admin bar and the first card. - **Page `