# WP Agentic Writer Fourteenth Retrace Audit Audit date: 2026-05-26 Baseline retraced: `docs/architecture/PLUGIN_AUDIT_RETRACE_THIRTEENTH_PASS_2026-05-26.md` Scope: fourteenth pass after thirteenth-retrace implementation, covering legacy chat migration, cost attribution, provider metadata propagation, model preset ownership, UI/UX readiness, and release verification. Status: COMPLETE / RETRACED Completion marker: 2026-05-26 Follow-up retrace: `docs/architecture/PLUGIN_AUDIT_RETRACE_FIFTEENTH_PASS_2026-05-26.md` > This fourteenth-pass report has been implemented and retraced. Keep this document as historical evidence only; use the fifteenth-pass report for current remaining work. ## Executive Summary The thirteenth-pass implementation closed the serious issues from the previous report: - The P0 legacy migration fatal is fixed statically. The canonical `/conversation/{post_id}` migration path now uses `WP_Agentic_Writer_Context_Service::get_instance()` instead of direct construction. - The broad seven-argument cost hook drift is fixed statically. A scan now finds only the central helper hook and the keyword suggester full-contract hook. - The previously listed stream completion payloads now include provider metadata where provider-backed output was involved. - The frontend stream completion branch at `assets/js/sidebar.js:4223-4226` now applies provider metadata. No new P0 or P1 blocker was found in this pass. The remaining work is narrower: - One retry-chat streaming completion path still does not apply provider metadata even though `/chat` completion sends provider fields. - Live WordPress editor/browser verification is still not evidenced. - Curated model presets remain duplicated between Settings V2 JavaScript and the legacy settings UI. ## Verification Performed - PHP syntax check across plugin PHP files: passed. - `node -c assets/js/sidebar.js`: passed. - `node -c assets/js/settings-v2.js`: passed. - `node -c assets/js/sidebar-utils.js`: passed. - Static retrace of thirteenth-pass findings against current code. - Static scan for short-form `wp_aw_after_api_request` calls. - Static scan for direct `new WP_Agentic_Writer_Context_Service`. - Static scan for provider metadata stream completion gaps. - No live WordPress editor/browser workflow was run in this pass. ## Thirteenth-Pass Status Trace | Thirteenth-pass item | Current status | Evidence | |---|---:|---| | P0 direct context-service construction | Fixed | `includes/class-gutenberg-sidebar.php:1413` uses `WP_Agentic_Writer_Context_Service::get_instance()`. | | Seven-argument cost hooks | Fixed statically | Hook scan finds `includes/class-gutenberg-sidebar.php:1004` central helper and `includes/class-keyword-suggester.php:140` full-contract hook only. | | Stream completion metadata payloads | Mostly fixed | Provider metadata now exists at `includes/class-gutenberg-sidebar.php:3730-3733`, `4831-4834`, and `5567-5570`. | | Frontend stream completion metadata application | Mostly fixed | `assets/js/sidebar.js:4223-4226` now calls `applyProviderMetadata(data)`. | | Browser verification | Still open | Static checks passed; no live editor workflow evidence was found. | | Curated model preset duplication | Still open, low priority | Presets remain duplicated in `assets/js/settings-v2.js` and `includes/class-settings.php`. | ## Remaining Findings ### P2: Retry Chat Completion Does Not Apply Provider Metadata Most stream completion branches now call `applyProviderMetadata(data)`, but the retry-chat path still does not. Evidence: - Retry chat posts to `/chat` with `stream: true` at `assets/js/sidebar.js:1140-1152`. - Its completion branch at `assets/js/sidebar.js:1186-1200` finalizes the streaming assistant message and extracts keyword suggestions, but does not call `applyProviderMetadata(data)`. - The backend chat stream completion sends provider transparency fields at `includes/class-gutenberg-sidebar.php:1290-1298`. Impact: - After retrying a failed chat request, the provider/fallback badge can remain stale even though the completion event has provider data. - The normal chat path and many generation/refinement paths are covered, so this is now a focused UI consistency gap rather than a systemic provider transparency failure. Recommended fix: - Add `applyProviderMetadata(data)` inside the retry-chat `data.type === 'complete'` branch before or after the message finalization. - Optionally remove the duplicate `applyProviderMetadata(data)` call in the normal generation branch at `assets/js/sidebar.js:1039-1045` while touching the area. ### P2: Live Browser Verification Is Still Required Static checks are clean, but the audit chain still has no live editor evidence. The browser pass should verify: - Legacy `_wpaw_chat_history` migrates through `/conversation/{post_id}` without fatal error. - Sidebar chat persists after editor reload. - Retry chat updates provider/fallback badge. - Provider badge updates after chat, clarity, planning, generation, block refinement, chat refinement, meta, keyword, intent, and improvement actions. - Cost log rows include provider/session/status for the same actions. - Model setting changes affect generated requests. - Unauthorized REST access remains denied. ### P3: Curated Model Presets Remain Duplicated This is now a low-priority maintenance issue, not a release blocker. Evidence: - Active Settings V2 presets remain hard-coded at `assets/js/settings-v2.js:35-59`. - Legacy settings presets remain hard-coded at `includes/class-settings.php:1027-1051`. - The legacy settings class can still be instantiated at `wp-agentic-writer.php:100-104`. Impact: - Presets can drift between the active and legacy settings UIs. - Model updates still require edits in more than one preset location. Recommended fix: - Keep curated presets, but centralize them in one PHP source and localize them into both UIs. - If the legacy settings UI is truly fallback-only, document who owns preset parity. ## Closed In This Pass - No direct `new WP_Agentic_Writer_Context_Service` references remain. - No short-form seven-argument `wp_aw_after_api_request` calls remain in `class-gutenberg-sidebar.php`. - The previously missing stream completion metadata payloads are now present for provider-backed refinement/generation paths. - JavaScript and PHP syntax checks pass. ## Priority Queue 1. P2: Add provider metadata application to retry-chat stream completion. 2. P2: Run live WordPress editor/browser verification. 3. P3: Centralize or formally own curated preset duplication. ## Completion Criteria For Next Pass The next retrace can mark this pass complete when: - Retry chat applies provider metadata on stream completion. - Live editor verification evidence exists for legacy migration, chat persistence, provider badge updates, cost attribution, model settings, and auth denial. - Any remaining duplicated model presets are either centralized or intentionally owned as product presets.