fix: bounded usage scan and count-only unreadable posts in global edits (L1, L4)

GlobalUsages runs one query per request (ID, status, type – no content),
checks read_post/edit_post in chunks of 200 with a primed and released post
cache, lists at most 50 readable posts and refuses a confirmed global edit
above 2000 live references (unsupported, edit in the Divi builder). Posts the
caller may not read appear only as hidden_count / blocked_hidden_count;
blocked_ids names readable posts only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 04:12:38 +02:00
co-authored by Claude Opus 5.5
parent bd28c32513
commit e8f69f67ea
12 changed files with 445 additions and 167 deletions
@@ -10,7 +10,6 @@ use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
use LIT\MCP\Integrations\Divi\BlockTree\Parser;
use LIT\MCP\Integrations\Divi\BlockTree\Serializer;
use LIT\MCP\Integrations\Divi\Library\GlobalEdits;
use LIT\MCP\Integrations\Divi\Library\GlobalUsages;
use LIT\MCP\Integrations\Divi\Library\LibraryAccess;
use LIT\MCP\Integrations\Divi\Pages\DiviNodeCopyAbility;
use LIT\MCP\Tests\Support\DiviFixtures;
@@ -48,9 +47,7 @@ final class DiviNodeCopyAbilityTest extends TestCase
$access ??= LibraryFixtures::access();
$loader = LibraryFixtures::loader($access);
$failures = [];
$usages = Mockery::mock(GlobalUsages::class);
$usages->allows('of')->andReturn(['items' => [], 'count' => 0]);
$globals = new GlobalEdits($access, $usages);
$globals = new GlobalEdits($access, LibraryFixtures::usages([]));
return new DiviNodeCopyAbility(
DiviWriterFixture::writer($this->saved, $failures, $unfiltered, $loader, $globals),