feat(compat): Profile, Gates und Pods über den Kompatibilitätskern

Neu: Tier, Profile, Compatibility, CapabilityLocked, CapabilityGate, CompatibilityComponent, ProvidesCompatibility, DiviProfile sowie PodsFeature, PodsCompatibility und PodsIntegration. Das CapabilityGate sperrt gesperrte und unbekannte Fähigkeits-IDs (übernimmt die Sperre unbekannter IDs vom DiviFeatureGate) und delegiert nur Divi ausdrücklich. Pods-Schema, -Lesen, -Schreiben und -Feldrechte laufen über usable(PodsFeature::…); Schreiben verlangt FieldRead und FieldWrite, damit ein Rollback keine Werte verliert. lit-site-status meldet Pods über die CompatibilityComponent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-11-06 12:26:54 +01:00
co-authored by Claude Opus 5.5
parent b511ef6348
commit c85131603b
38 changed files with 2259 additions and 135 deletions
+108
View File
@@ -0,0 +1,108 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Compatibility;
use LIT\MCP\Abilities\Errors;
use LIT\MCP\Abilities\ToolRefusal;
use LogicException;
use RuntimeException;
use WP_Error;
defined('ABSPATH') || exit;
/**
* A call refused because a capability it needs is locked, or because no profile knows a capability it declares;
* AbilityRegistrar returns toError().
*/
final class CapabilityLocked extends RuntimeException implements ToolRefusal
{
/**
* @param list<FeatureStatus> $locked The locked capabilities the refused call needs.
* @param list<string> $plugins Labels of the plugins they belong to.
* @param list<string> $unknown Declared IDs no profile knows.
*/
private function __construct(
public readonly array $locked,
public readonly array $plugins,
public readonly array $unknown
) {
parent::__construct(sprintf(
'%s locked – %s refused',
implode(', ', $plugins) ?: 'unknown capability',
implode(', ', $unknown ?: array_map(static fn (FeatureStatus $s): string => $s->feature->id(), $locked))
));
}
/**
* @param list<FeatureStatus> $locked
* @param list<Profile> $profiles The profiles the locked capabilities belong to.
* @throws LogicException When $locked is empty – a lock always names what it locks.
*/
public static function of(array $locked, array $profiles): self
{
if ($locked === []) {
throw new LogicException('a capability lock needs the locked capabilities');
}
return new self($locked, array_map(static fn (Profile $profile): string => $profile->label, $profiles), []);
}
/**
* @param list<string> $ids
* @throws LogicException When $ids is empty.
*/
public static function unknown(array $ids): self
{
if ($ids === []) {
throw new LogicException('an unknown-capability lock needs the IDs');
}
return new self([], [], $ids);
}
public function toError(): WP_Error
{
if ($this->unknown !== []) {
return Errors::make(
'compat_incompatible',
sprintf(
'Das Werkzeug verlangt unbekannte Fähigkeiten (%s). Das ist gesperrt. Es wurde nichts geändert.',
implode(', ', $this->unknown)
),
'Den Nutzer informieren, dass LIT MCP aktualisiert werden muss.',
423,
['unknown' => $this->unknown]
);
}
$named = implode(', ', array_map(
static fn (FeatureStatus $status): string => '„' . $status->feature->label() . '“',
$this->locked
));
$plugins = implode(', ', $this->plugins);
return Errors::make(
'compat_incompatible',
sprintf(
'%s ist auf dieser Website nicht mit LIT MCP kompatibel: %s ist gesperrt. Es wurde nichts geändert.',
$plugins,
$named
),
sprintf(
'Gesperrt: %s. Andere Werkzeuge funktionieren weiter. '
. 'Den Nutzer informieren, dass %s geprüft werden muss.',
$named,
$plugins
),
423,
[
'features' => array_map(static fn (FeatureStatus $status): array => $status->summary(), $this->locked),
'problems' => array_values(array_unique(array_merge(
...array_map(static fn (FeatureStatus $status): array => $status->problems, $this->locked)
))),
]
);
}
}