- P1-007: Tier-based query result size limits with truncation warnings - P1-008: Per-tier query timeout enforcement (MySQL/PostgreSQL/SQLite) - P1-009: Comprehensive audit logging for all query attempts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mcp\Exceptions;
|
|
|
|
use RuntimeException;
|
|
|
|
/**
|
|
* Exception thrown when query results exceed the allowed size limit.
|
|
*
|
|
* This indicates the result set was truncated due to:
|
|
* - Exceeding the configured maximum rows per tier
|
|
* - Data exfiltration prevention measures
|
|
*/
|
|
class ResultSizeLimitException extends RuntimeException
|
|
{
|
|
public function __construct(
|
|
public readonly int $actualRows,
|
|
public readonly int $maxRows,
|
|
public readonly string $tier,
|
|
string $message = '',
|
|
) {
|
|
$message = $message ?: sprintf(
|
|
'Result set truncated: returned %d rows (limit: %d for tier "%s")',
|
|
min($actualRows, $maxRows),
|
|
$maxRows,
|
|
$tier
|
|
);
|
|
|
|
parent::__construct($message);
|
|
}
|
|
|
|
/**
|
|
* Create exception for result truncation.
|
|
*/
|
|
public static function truncated(int $actualRows, int $maxRows, string $tier): self
|
|
{
|
|
return new self(
|
|
$actualRows,
|
|
$maxRows,
|
|
$tier,
|
|
sprintf(
|
|
'Query returned more rows than allowed. Results truncated to %d rows (your tier "%s" limit). Consider adding more specific filters.',
|
|
$maxRows,
|
|
$tier
|
|
)
|
|
);
|
|
}
|
|
}
|