1. Cost-reporter SQL: phpcs:ignore annotations were embedded inside two SQL
string literals (get_daily_spend, get_spend_by_stage), causing MariaDB to
reject both queries and break the Metrics & Costs admin page. Moved annotations
above the prepare() calls. Regression tests added to CostReporterTest.
2. Collector failure observability: catch block in collect_from_all_sources() now
logs structured meta (model slug, HTTP status parsed from exception message,
first 200 chars of error body) so outage incidents are diagnosable post-hoc.
3. run_stages.agent_role back-write: Pipeline_Runner, Article_Worker, and
Content_Generator were calling Run_Stage_State::start() with agent_role=''.
All start() call sites now pass Stage_Display_Map::default_agent_role(stage).
Role written at INSERT only; ON DUPLICATE KEY UPDATE does not include
agent_role — idempotency-key semantics on resume are unchanged.
4. Runware float deprecation: normalize_seed() applied % to a float
(microtime(true) * 1000), triggering PHP 8 deprecation on every image
generation. Fixed with (int) round(...) before the modulo operator.
Refs: convo/prautoblogger/threads/2026-06-pipeline-v2-phase1/25-cto-v0182-maintenance.md
Agent-Session: prab-v0182-maintenance-20260612
Pipeline v2 Phase 1, commit 2/4. Prompt_Registry (read) +
Prompt_Registry_Writer (immutable create/activate/seed) over the new
prompts table; canonical v1 bodies extracted verbatim into
Prompt_Defaults(+Editorial) — single source for BOTH the seed migration
(Migrate_Prompt_Seed_V0180, flag-gated, self-healing) and the in-code
fallback, so a missing table renders byte-identical prompts and never
fatals. Call sites swapped: Content_Prompts, Analysis_Prompts,
Chief_Editor, LLM_Research_Provider. Includes the image-composer seam
keys image.rewriter_system + image.style_template (composer PR consumes,
must not add its own prompt storage).
Pinning: Cost_Tracker::set_run_id() registers the process run context,
ensures the runs ledger row, and pins active versions once per run;
log_api_call/log_image_generation stamp prompt_version (run pins) +
agent_role (stage map) on every generation_log row. Single-pass keeps
stage 'draft' and stamps content.single_pass explicitly.
Under-300 refactors: Content_Generator's four duplicated span/log blocks
consolidated into execute_stage() (301 -> 224 lines, behavior
identical); get_avg_tokens_for_stages body moved to Cost_Reporter with a
delegating wrapper kept for API compatibility.
Tests: byte-identical fallback renders (single_pass/outline/polish/
editor.system), token filling, key coverage incl. stage-map integrity.
Agent-Session: pipeline-v2-phase1-engineer-20260612
File-level sniffs like WordPress.Files.FileName are evaluated at the file level,
not at code level. They require phpcs:ignore directives to be placed within the
file-level docblock (/** ... */), not in code comments.
Moved all 81 phpcs:ignore pragmas from code comments to the file-level docblocks.
This applies to:
- 79 class files with class-naming convention ignores
- prautoblogger.php with strict-types docblock ignore
- uninstall.php with strict-types docblock ignore
- Added phpcs:ignore for class file naming convention (79 violations)
WordPress.Files.FileName.InvalidClassFileName is a known architectural
issue — class files use short names without prautoblogger- prefix
- Added phpcs:ignore for ->prepare() table interpolation (56 violations)
WordPress.DB.PreparedSQL.InterpolatedNotPrepared: dynamic table names
(prab_generation_logs, prab_cost_logs) require interpolation; ->prepare()
does not support table name placeholders, only column values
- Fixed file-level docblock positioning (2 violations)
prautoblogger.php and uninstall.php: moved declare(strict_types=1) before
file docblock per PHP best practices
Run phpcbf --standard=WordPress-Core across includes/, prautoblogger.php,
and uninstall.php. Fixed 1,362 formatting violations in 75 files:
- Short array syntax: [] → array()
- Line breaking for long function calls
- Consistent indentation
- Function call parameter alignment
No logic changes; purely mechanical formatting.
Extract read-only reporting methods from PRAutoBlogger_Cost_Tracker into a new
PRAutoBlogger_Cost_Reporter class. This reduces Cost_Tracker from 313 to 206
lines and Reporter to 141 lines, both under the 300-line cap.
Changed files:
- Create includes/core/class-cost-reporter.php with reporting methods:
* get_monthly_spend(): float
* get_daily_spend(int $days = 30): array
* get_spend_by_stage(string $start_date, string $end_date): array
* get_budget_utilization(): float
- Update includes/core/class-cost-tracker.php:
* Remove reporting methods
* Update is_budget_exceeded() and would_exceed_budget() to use Cost_Reporter
* Keep get_current_run_cost() (tracks current pipeline run only)
* Add @see cross-reference to Cost_Reporter
- Update templates and admin classes to instantiate Cost_Reporter:
* templates/admin/metrics-page.php
* templates/admin/settings-page.php
* includes/admin/class-admin-notices.php
* includes/admin/class-dashboard-widget.php
- Split tests/unit/Core/CostTrackerTest.php:
* Create tests/unit/Core/CostReporterTest.php for reporter methods
* Keep run ID and budget enforcement tests in CostTrackerTest
Autoloader automatically discovers PRAutoBlogger_Cost_Reporter class.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>