Files
pr-vision/includes/providers/interface-prv-probe-provider.php
peptiderepo 68ae5b9b1a PHPCS compliance: fix pre-existing violations exposed by gating the lint step
All violations were present in v0.1.0 and hidden by continue-on-error.
Now that PHPCS gates the build (P2-B), they must be fixed.

- Add file-level @package doc comment to all PHP files (file doc requirement)
- Add short descriptions to @var and constructor docblocks throughout
- Fix @param type spacing throughout (PHPCS alignment rules)
- Expand phpcs:ignore lines to include NoCaching where DirectQuery is already
  suppressed (uninstall.php, cost-ledger, table-manager, collector)
- Suppress EscapeOutput.ExceptionNotEscaped on RuntimeException messages
  (exception strings are not HTML output)
- Suppress error_log_error_log on the probe-runner failure log
- Replace date() with gmdate() in panel (timezone-aware per WP standard)
- Convert inline associative arrays to multi-line in config (WP array style)
- Fix double-arrow alignment in probe-runner counts and insert arrays
- Fix double-space before ?? in provider constructors
- Expand phpcs:ignore for  reads to include MissingUnslash
- Fix $counts++ to ++$counts (prefix increment per WP standard)
- Fix V1/v1 capitalisation in interface doc long description

Agent-Session: pr-vision rename v0.1.1
2026-06-13 09:42:55 +00:00

58 lines
1.8 KiB
PHP

<?php
/** @package PrVision */
declare(strict_types=1);
/**
* Contract for all LLM probe providers.
*
* Each provider implementation wraps one LLM backend (Perplexity sonar,
* OpenRouter GPT-search, OpenRouter Gemini-search, …). Swapping providers
* requires only a new class — the runner, ledger, and storage are agnostic.
*
* Who triggers: PRV_Probe_Runner for each (model, query) combination.
* Dependencies: None — pure interface.
*
* @see class-prv-perplexity-provider.php — Perplexity sonar implementation.
* @see class-prv-openrouter-provider.php — OpenRouter generic implementation.
* @see class-prv-probe-runner.php — Dispatches to providers via this interface.
* @see CONTEXT.md — "provider", "probe".
* @package PrVision
*/
interface PRV_Probe_Provider {
/**
* Send a search/retrieval query and return a structured probe result.
*
* Implementations MUST:
* - Extract cited source domains from the model's response.
* - Detect whether PRV_TARGET_DOMAIN appears in those sources.
* - Record our 1-based position (null when not cited).
* - Return the call's estimated USD cost.
* - Throw \RuntimeException on unrecoverable failure (caller logs + skips).
*
* @param string $query The natural-language query to send.
*
* @return PRV_Probe_Result
*
* @throws \RuntimeException When the API call fails after retries.
*/
public function probe( string $query ): PRV_Probe_Result;
/**
* Get a short human-readable name for this provider (e.g. "Perplexity sonar").
*
* @return string
*/
public function get_name(): string;
/**
* Check whether the required credentials/constants are configured.
*
* Returns false (never throws) so the runner can skip unconfigured
* providers without aborting the whole run.
*
* @return bool
*/
public function is_configured(): bool;
}