Piece 1 — Visuals - Add KPI bento bar (score tile with run-health pill, cost tile, last-run tile). Run-health pill shows 'All models healthy' / 'N model(s) degraded' / 'No run yet' sourced from PRV_Model_Registry health fields via collector. - Add config-change trendline marker: inline configMarker Chart.js plugin draws a vertical dashed orange line + pin at every config_version boundary. Legend swatch + annotation note appear when breaks exist. - Chart sits in fixed .prv-chartbox (300px); typeof-Chart guard + .prv-noscript fallback — cannot grow layout, degrades gracefully offline. - PRV_Dashboard_Renderer: new class owns bento tile + trendline rendering. PRV_Ai_Visibility_Panel is now a thin orchestrator (237 lines). - PRV_Ai_Visibility_Collector: trendline query now includes MIN(config_version) per run; collect() adds last_run_counts and config_versions to payload. - PRV_Admin_Page: get_dashboard_css() returns Assay dark palette CSS. Piece 2 — Deploy pipeline - .github/workflows/deploy.yml: on push to main, runs CI, rsyncs plugin to Hostinger PROD (excl. .git .github tests phpunit composer vendor phpcs *.md), purges LiteSpeed, health-checks (200/403). Standalone — not smoke-gated. DoD - Version 0.2.1 in header + constant; CHANGELOG, ARCHITECTURE, CONVENTIONS, CONTEXT all updated same commit. - tests/unit/test-dashboard-panel.php: 27 assertions. - Pre-push checks: no PHP built-in name shadows in bootstrap.php; all includes/*.php files <= 300 lines (max: 298).
3.2 KiB
3.2 KiB
Conventions — PR Vision
Version: 0.2.1 | Last updated: 2026-06-14
Applies to all contributors and AI agents working in this repo. Where this document and AGENT-OPERATING-STANDARD.md conflict on process, the Standard wins; this document wins on code style.
1. PHP style
- Standard: WordPress Coding Standards (PHPCS
ruleset ref="WordPress"). - Declare:
declare(strict_types=1);at the top of every PHP file. - Formatting: Tabs for indentation (WP standard).
2. Naming
| Concept | Convention | Example |
|---|---|---|
| Class | PRV_ prefix + PascalCase |
PRV_Cost_Ledger |
| Interface | PRV_ prefix + PascalCase |
PRV_Probe_Provider |
| File | class-prv-*.php or interface-prv-*.php |
class-prv-probe-runner.php |
| Option | prv_ prefix |
prv_monthly_budget_usd |
| Hook / cron | prv_ prefix |
prv_weekly_probe |
| Constant | PRV_ prefix |
PRV_TARGET_DOMAIN |
| wp-config key | PRV_ prefix |
PRV_OPENROUTER_API_KEY |
| Test file | test-*.php |
test-citation-detector.php |
3. File structure
- One class per file. Interfaces get their own file.
- 300-line limit (enforced by CI). Split at the method boundary when approaching the limit.
- Autoloader resolves
PRV_Foo_Bar→class-prv-foo-bar.phpvia a search acrossincludes/subdirectories.
4. Docblocks
Every class must have a preamble docblock:
/**
* <One-sentence what>.
*
* Who triggers: <which class/hook calls this>.
* Dependencies: <what this class needs to exist>.
*
* @see <cross-reference 1>
* @see <cross-reference 2>
* @package PrVision
*/
Every public method must have:
@paramwith type + description.@returnwith type.- A sentence listing side effects (DB writes, HTTP calls, option writes).
5. Security rules
- Sanitize all input at the boundary (
sanitize_text_field(),absint(),wp_unslash()). - Escape all output at render (
esc_html(),esc_url(),wp_json_encode(),wp_kses_post()). - Nonce every admin form action.
- Capability check (
manage_options) every admin action handler. - No secrets in code — read from wp-config constants at runtime.
6. Tests
- Tests live in
tests/unit/test-*.phpand are run by the CIlint-phpjob viaphp $test. - Each test file
require_oncestests/bootstrap.phpand callsexit( prv_test_summary() ). - Use
prv_assert(),prv_assert_equals(),prv_assert_throws(). - Mock HTTP via
$GLOBALS['prv_test_state']['remote_posts'](queued responses). - No PHPUnit dependency.
7. Adding a new provider
- Create
includes/providers/class-prv-{name}-provider.php. - Implement
PRV_Probe_Provider(probe(),get_name(),is_configured()). - Add a branch in
PRV_Probe_Runner::resolve_provider(). - Update
ARCHITECTURE.md§5 (Providers table). - Add a parse test in
tests/unit/test-provider-parsing.php.
8. Adding a new collector/panel pair
- Implement
PRV_Data_Collectorinincludes/collector/. - Implement
PRV_Dashboard_Panelinincludes/panel/. - Register both in
PRV_Plugin::init()viaPRV_Collector_Registry::instance(). - Update
ARCHITECTURE.md§6 (Collector/Panel seam).