From b4ab3df2ec85fbe477d7721344a8cd3630b437a1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 13:59:28 +0900 Subject: feat(plugin): guard Rust-owned classes the worker has no proxy for The worker's autoloader fell through to the real Composer source for every Rust-owned FQCN without a proxy stub, so plugin code doing `new Filesystem()` or subclassing `LibraryInstaller` silently ran on a second instance the Rust side never sees. An unimplemented part of the plugin API has to fail with an explicit error naming it, not quietly work on a disconnected copy. The stub generator now emits a guard class for each of those FQCNs: the real declaration, hierarchy and constants, with every constructor and method raising an explicit error. References satisfied by the declaration alone (`instanceof`, `X::class`, `Link::TYPE_REQUIRE`) keep working. Two FQCNs stay resolvable to the real class, each listed with the worker-side mechanism that makes a natively constructed instance correct. The error had nowhere to go: `Installer::run` dropped the `Result` of both `dispatch_script` calls, so an exception from a listener ended in exit 0. Both propagate now, the way the exception does upstream. Three real-plugin E2E comparisons stop at a guard and are ignored, each naming the class it needs. Co-Authored-By: Claude Opus 5 (1M context) --- .../Composer/Repository/Vcs/ForgejoDriver.php | 122 +++++++++++++++ .../Composer/Repository/Vcs/FossilDriver.php | 116 +++++++++++++++ .../Composer/Repository/Vcs/GitBitbucketDriver.php | 137 +++++++++++++++++ .../guards/Composer/Repository/Vcs/GitDriver.php | 106 +++++++++++++ .../Composer/Repository/Vcs/GitHubDriver.php | 147 ++++++++++++++++++ .../Composer/Repository/Vcs/GitLabDriver.php | 165 +++++++++++++++++++++ .../guards/Composer/Repository/Vcs/HgDriver.php | 106 +++++++++++++ .../Composer/Repository/Vcs/PerforceDriver.php | 117 +++++++++++++++ .../guards/Composer/Repository/Vcs/SvnDriver.php | 121 +++++++++++++++ 9 files changed, 1137 insertions(+) create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/ForgejoDriver.php create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/FossilDriver.php create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/GitBitbucketDriver.php create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/GitDriver.php create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/GitHubDriver.php create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/GitLabDriver.php create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/HgDriver.php create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/PerforceDriver.php create mode 100644 crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/SvnDriver.php (limited to 'crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs') diff --git a/crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/ForgejoDriver.php b/crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/ForgejoDriver.php new file mode 100644 index 00000000..0e812dfe --- /dev/null +++ b/crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/ForgejoDriver.php @@ -0,0 +1,122 @@ +https?)://(?P.+?)(?::(?P[0-9]+))?/|git@(?P[^:]+):)(?P.+)/(?P[^/]+?)(?:\.git|/)?$#'; + + public function __construct() + { + \ShirabeUnsupportedClass::fail(self::class, '__construct'); + } + + public function initialize(): void + { + \ShirabeUnsupportedClass::fail(self::class, 'initialize'); + } + + public function setHttpDownloader(HttpDownloader $httpDownloader): void + { + \ShirabeUnsupportedClass::fail(self::class, 'setHttpDownloader'); + } + + public function getComposerInformation(string $identifier): ?array + { + \ShirabeUnsupportedClass::fail(self::class, 'getComposerInformation'); + } + + public function getFileContent(string $file, string $identifier): ?string + { + \ShirabeUnsupportedClass::fail(self::class, 'getFileContent'); + } + + public function getChangeDate(string $identifier): ?\DateTimeImmutable + { + \ShirabeUnsupportedClass::fail(self::class, 'getChangeDate'); + } + + public function getRepositoryUrl(): string + { + \ShirabeUnsupportedClass::fail(self::class, 'getRepositoryUrl'); + } + + public function getUrl(): string + { + \ShirabeUnsupportedClass::fail(self::class, 'getUrl'); + } + + public function getDist(string $identifier): ?array + { + \ShirabeUnsupportedClass::fail(self::class, 'getDist'); + } + + public function getSource(string $identifier): array + { + \ShirabeUnsupportedClass::fail(self::class, 'getSource'); + } + + public function getRootIdentifier(): string + { + \ShirabeUnsupportedClass::fail(self::class, 'getRootIdentifier'); + } + + public function getBranches(): array + { + \ShirabeUnsupportedClass::fail(self::class, 'getBranches'); + } + + public function getTags(): array + { + \ShirabeUnsupportedClass::fail(self::class, 'getTags'); + } + + public function getApiUrl(): string + { + \ShirabeUnsupportedClass::fail(self::class, 'getApiUrl'); + } + + protected function getReferences(string $type): array + { + \ShirabeUnsupportedClass::fail(self::class, 'getReferences'); + } + + protected function fetchProject(): void + { + \ShirabeUnsupportedClass::fail(self::class, 'fetchProject'); + } + + protected function attemptCloneFallback(): bool + { + \ShirabeUnsupportedClass::fail(self::class, 'attemptCloneFallback'); + } + + protected function generateSshUrl(): string + { + \ShirabeUnsupportedClass::fail(self::class, 'generateSshUrl'); + } + + protected function generatePublicUrl(): string + { + \ShirabeUnsupportedClass::fail(self::class, 'generatePublicUrl'); + } + + protected function setupGitDriver(string $url): void + { + \ShirabeUnsupportedClass::fail(self::class, 'setupGitDriver'); + } + + protected function getContents(string $url, bool $fetchingRepoData = false): Response + { + \ShirabeUnsupportedClass::fail(self::class, 'getContents'); + } + + public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool + { + \ShirabeUnsupportedClass::fail(self::class, 'supports'); + } + + public function getRepoData(): ?array + { + \ShirabeUnsupportedClass::fail(self::class, 'getRepoData'); + } + + protected function getNextPage(Response $response): ?string + { + \ShirabeUnsupportedClass::fail(self::class, 'getNextPage'); + } + + protected function shouldCache(string $identifier): bool + { + \ShirabeUnsupportedClass::fail(self::class, 'shouldCache'); + } + + protected function getBaseComposerInformation(string $identifier): ?array + { + \ShirabeUnsupportedClass::fail(self::class, 'getBaseComposerInformation'); + } + + public function hasComposerFile(string $identifier): bool + { + \ShirabeUnsupportedClass::fail(self::class, 'hasComposerFile'); + } + + protected function getScheme(): string + { + \ShirabeUnsupportedClass::fail(self::class, 'getScheme'); + } + + public function cleanup(): void + { + \ShirabeUnsupportedClass::fail(self::class, 'cleanup'); + } +} diff --git a/crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/HgDriver.php b/crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/HgDriver.php new file mode 100644 index 00000000..18cf388d --- /dev/null +++ b/crates/shirabe-php-rpc/php/guards/Composer/Repository/Vcs/HgDriver.php @@ -0,0 +1,106 @@ +