refactor: Übergangs-API der Gesamtsperre entfernt (assertWritable, writable, refusal, writeFeatures, released); DiviLocked verlangt die gesperrten Fähigkeiten, Tests bauen Zustände über ReleaseMatrices
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c036a92b60
commit
d0d3488df8
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace LIT\MCP\Integrations\Divi\Release;
|
||||
|
||||
use LIT\MCP\Abilities\ToolRefusal;
|
||||
use LogicException;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
@@ -13,26 +14,31 @@ defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* A Divi call refused because a feature it needs is not released (spec §5.5, D6); AbilityRegistrar returns
|
||||
* toError(). Without features it is the general write lock of the overall status (texts of spec §5.6).
|
||||
* toError().
|
||||
*/
|
||||
final class DiviLocked extends RuntimeException implements ToolRefusal
|
||||
{
|
||||
/** @param list<DiviFeature> $features The locked features the refused call needs; [] = writing in general. */
|
||||
public function __construct(public readonly ReleaseStatus $status, public readonly array $features = [])
|
||||
/**
|
||||
* @param non-empty-list<DiviFeature> $features The locked features the refused call needs.
|
||||
* @throws LogicException When $features is empty – a lock always names what it locks.
|
||||
*/
|
||||
public function __construct(public readonly ReleaseStatus $status, public readonly array $features)
|
||||
{
|
||||
if ($features === []) {
|
||||
throw new LogicException('a Divi lock needs the locked features');
|
||||
}
|
||||
|
||||
parent::__construct(sprintf(
|
||||
'%s is %s for LIT MCP – %s refused',
|
||||
$status->versionLabel(),
|
||||
$status->state->value,
|
||||
$features === []
|
||||
? 'write'
|
||||
: implode(', ', array_map(static fn (DiviFeature $feature): string => $feature->value, $features))
|
||||
implode(', ', array_map(static fn (DiviFeature $feature): string => $feature->value, $features))
|
||||
));
|
||||
}
|
||||
|
||||
public function toError(): WP_Error
|
||||
{
|
||||
return $this->features === [] ? $this->status->refusal() : $this->status->refusalFor($this->features);
|
||||
return $this->status->refusalFor($this->features);
|
||||
}
|
||||
|
||||
/** The lock anywhere in $e's chain of previous exceptions (callers wrap failures in WriteFailed). */
|
||||
|
||||
Reference in New Issue
Block a user