From b6df2ff395c82bf254e367867d3ea84458b1dae2 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 23 Sep 2025 16:45:28 +0200 Subject: [PATCH] [AI Bundle][MCP Bundle][Platform][Store] Remove useless inline comments from codebase --- src/ai-bundle/src/Command/ChatCommand.php | 6 ------ .../tests/DependencyInjection/McpBundleTest.php | 3 --- .../Gemini/Contract/MessageBagNormalizerTest.php | 2 -- .../Contract/MessageBagNormalizerTest.php | 2 -- .../HuggingFace/Output/FillMaskResultTest.php | 1 - .../Contract/MessageBagNormalizerTest.php | 2 -- .../VertexAi/Embeddings/ModelClientTest.php | 3 --- .../VertexAi/Embeddings/ResultConverterTest.php | 1 - .../Bridge/VertexAi/Gemini/ModelClientTest.php | 3 --- .../VertexAi/Gemini/ResultConverterTest.php | 3 --- .../Bridge/VertexAi/TokenOutputProcessorTest.php | 9 --------- src/store/src/Command/IndexCommand.php | 2 -- src/store/src/Indexer.php | 5 ----- .../tests/Document/Loader/RssFeedLoaderTest.php | 1 - src/store/tests/Document/MetadataTest.php | 16 ---------------- src/store/tests/Document/TextDocumentTest.php | 1 - src/store/tests/Document/VectorDocumentTest.php | 2 -- src/store/tests/IndexerTest.php | 10 ---------- 18 files changed, 72 deletions(-) diff --git a/src/ai-bundle/src/Command/ChatCommand.php b/src/ai-bundle/src/Command/ChatCommand.php index a58cb77f7..6a7f05063 100644 --- a/src/ai-bundle/src/Command/ChatCommand.php +++ b/src/ai-bundle/src/Command/ChatCommand.php @@ -79,7 +79,6 @@ protected function interact(InputInterface $input, OutputInterface $output): voi { $agentArg = $input->getArgument('agent'); - // If agent is already provided and valid, nothing to do if ($agentArg) { return; } @@ -106,7 +105,6 @@ protected function interact(InputInterface $input, OutputInterface $output): voi protected function execute(InputInterface $input, OutputInterface $output): int { - // Initialize agent (moved from initialize() to execute() so it runs after interact()) $availableAgents = array_keys($this->agents->getProvidedServices()); if (0 === \count($availableAgents)) { @@ -116,19 +114,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int $agentArg = $input->getArgument('agent'); $agentName = \is_string($agentArg) ? $agentArg : ''; - // Validate that the agent exists if one was provided if ($agentName && !$this->agents->has($agentName)) { throw new InvalidArgumentException(\sprintf('Agent "%s" not found. Available agents: "%s"', $agentName, implode(', ', $availableAgents))); } - // If we still don't have an agent name at this point, something went wrong if (!$agentName) { throw new InvalidArgumentException(\sprintf('Agent name is required. Available agents: "%s"', implode(', ', $availableAgents))); } $agent = $this->agents->get($agentName); - // Now start the chat $io = new SymfonyStyle($input, $output); $io->title(\sprintf('Chat with %s Agent', $agentName)); @@ -155,7 +150,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $result = $agent->call($messages); - // Display system prompt after first successful call if (!$systemPromptDisplayed && null !== ($systemMessage = $messages->getSystemMessage())) { $io->section('System Prompt'); $io->block($systemMessage->content, null, 'fg=gray', ' ', true); diff --git a/src/mcp-bundle/tests/DependencyInjection/McpBundleTest.php b/src/mcp-bundle/tests/DependencyInjection/McpBundleTest.php index c2af6a1d4..cea33be90 100644 --- a/src/mcp-bundle/tests/DependencyInjection/McpBundleTest.php +++ b/src/mcp-bundle/tests/DependencyInjection/McpBundleTest.php @@ -148,10 +148,8 @@ public function testDefaultPageSizeConfiguration() { $container = $this->buildContainer([]); - // Test that the default page_size parameter is set to 20 $this->assertSame(20, $container->getParameter('mcp.page_size')); - // Test that ToolListHandler is registered $this->assertTrue($container->hasDefinition('mcp.server.request_handler.tool_list')); $definition = $container->getDefinition('mcp.server.request_handler.tool_list'); @@ -166,7 +164,6 @@ public function testCustomPageSizeConfiguration() ], ]); - // Test that the custom page_size parameter is set $this->assertSame(50, $container->getParameter('mcp.page_size')); } diff --git a/src/platform/tests/Bridge/Gemini/Contract/MessageBagNormalizerTest.php b/src/platform/tests/Bridge/Gemini/Contract/MessageBagNormalizerTest.php index 40633db85..61e371f10 100644 --- a/src/platform/tests/Bridge/Gemini/Contract/MessageBagNormalizerTest.php +++ b/src/platform/tests/Bridge/Gemini/Contract/MessageBagNormalizerTest.php @@ -66,11 +66,9 @@ public function testNormalize(MessageBag $bag, array $expected) { $normalizer = new MessageBagNormalizer(); - // Set up the inner normalizers $userMessageNormalizer = new UserMessageNormalizer(); $assistantMessageNormalizer = new AssistantMessageNormalizer(); - // Mock a normalizer that delegates to the appropriate concrete normalizer $mockNormalizer = $this->createMock(NormalizerInterface::class); $mockNormalizer->method('normalize') ->willReturnCallback(function ($message) use ($userMessageNormalizer, $assistantMessageNormalizer): ?array { diff --git a/src/platform/tests/Bridge/HuggingFace/Contract/MessageBagNormalizerTest.php b/src/platform/tests/Bridge/HuggingFace/Contract/MessageBagNormalizerTest.php index 877e832f6..8dd6f0ad2 100644 --- a/src/platform/tests/Bridge/HuggingFace/Contract/MessageBagNormalizerTest.php +++ b/src/platform/tests/Bridge/HuggingFace/Contract/MessageBagNormalizerTest.php @@ -55,10 +55,8 @@ public function testNormalize(MessageBag $bag, array $expected) { $normalizer = new MessageBagNormalizer(); - // Set up the concrete user message normalizer $userMessageNormalizer = new UserMessageNormalizer(); - // Mock a normalizer that delegates to the concrete normalizer $mockNormalizer = $this->createMock(NormalizerInterface::class); $mockNormalizer->method('normalize') ->willReturnCallback(function ($messages) use ($userMessageNormalizer): array { diff --git a/src/platform/tests/Bridge/HuggingFace/Output/FillMaskResultTest.php b/src/platform/tests/Bridge/HuggingFace/Output/FillMaskResultTest.php index 9f9b1faa5..c672595b5 100644 --- a/src/platform/tests/Bridge/HuggingFace/Output/FillMaskResultTest.php +++ b/src/platform/tests/Bridge/HuggingFace/Output/FillMaskResultTest.php @@ -168,7 +168,6 @@ public function testFromArrayWithVariousFormats() $this->assertCount(3, $result->fills); - // Test edge cases are properly handled $this->assertSame(0, $result->fills[0]->token); $this->assertSame('', $result->fills[0]->tokenStr); $this->assertSame('', $result->fills[0]->sequence); diff --git a/src/platform/tests/Bridge/VertexAi/Contract/MessageBagNormalizerTest.php b/src/platform/tests/Bridge/VertexAi/Contract/MessageBagNormalizerTest.php index d51473c65..e2935fd48 100644 --- a/src/platform/tests/Bridge/VertexAi/Contract/MessageBagNormalizerTest.php +++ b/src/platform/tests/Bridge/VertexAi/Contract/MessageBagNormalizerTest.php @@ -66,11 +66,9 @@ public function testNormalize(MessageBag $bag, array $expected) { $normalizer = new MessageBagNormalizer(); - // Set up the inner normalizers $userMessageNormalizer = new UserMessageNormalizer(); $assistantMessageNormalizer = new AssistantMessageNormalizer(); - // Mock a normalizer that delegates to the appropriate concrete normalizer $mockNormalizer = $this->createMock(NormalizerInterface::class); $mockNormalizer->method('normalize') ->willReturnCallback(function ($message) use ($userMessageNormalizer, $assistantMessageNormalizer): ?array { diff --git a/src/platform/tests/Bridge/VertexAi/Embeddings/ModelClientTest.php b/src/platform/tests/Bridge/VertexAi/Embeddings/ModelClientTest.php index 935520fc9..fc94537f7 100644 --- a/src/platform/tests/Bridge/VertexAi/Embeddings/ModelClientTest.php +++ b/src/platform/tests/Bridge/VertexAi/Embeddings/ModelClientTest.php @@ -32,7 +32,6 @@ final class ModelClientTest extends TestCase { public function testItGeneratesTheEmbeddingSuccessfully() { - // Assert $expectedResponse = [ 'predictions' => [ ['embeddings' => ['values' => [0.3, 0.4, 0.4]]], @@ -44,10 +43,8 @@ public function testItGeneratesTheEmbeddingSuccessfully() $model = new Model(Model::GEMINI_EMBEDDING_001, ['outputDimensionality' => 1536, 'task_type' => TaskType::CLASSIFICATION]); - // Act $result = $client->request($model, 'test payload'); - // Assert $this->assertSame($expectedResponse, $result->getData()); } } diff --git a/src/platform/tests/Bridge/VertexAi/Embeddings/ResultConverterTest.php b/src/platform/tests/Bridge/VertexAi/Embeddings/ResultConverterTest.php index ca9ae1e48..b766521c0 100644 --- a/src/platform/tests/Bridge/VertexAi/Embeddings/ResultConverterTest.php +++ b/src/platform/tests/Bridge/VertexAi/Embeddings/ResultConverterTest.php @@ -31,7 +31,6 @@ final class ResultConverterTest extends TestCase { public function testItConvertsAResponseToAVectorResult() { - // Assert $expectedResponse = [ 'predictions' => [ ['embeddings' => ['values' => [0.3, 0.4, 0.4]]], diff --git a/src/platform/tests/Bridge/VertexAi/Gemini/ModelClientTest.php b/src/platform/tests/Bridge/VertexAi/Gemini/ModelClientTest.php index 3324a7ce5..daeea49e2 100644 --- a/src/platform/tests/Bridge/VertexAi/Gemini/ModelClientTest.php +++ b/src/platform/tests/Bridge/VertexAi/Gemini/ModelClientTest.php @@ -27,7 +27,6 @@ final class ModelClientTest extends TestCase { public function testItInvokesTheTextModelsSuccessfully() { - // Arrange $payload = [ 'content' => [ ['parts' => ['text' => 'Hello, world!']], @@ -42,12 +41,10 @@ public function testItInvokesTheTextModelsSuccessfully() $client = new ModelClient($httpClient, 'global', 'test'); - // Act $result = $client->request(new Model(Model::GEMINI_2_0_FLASH), $payload); $data = $result->getData(); $info = $result->getObject()->getInfo(); - // Assert $this->assertNotEmpty($data); $this->assertNotEmpty($info); $this->assertSame('POST', $info['http_method']); diff --git a/src/platform/tests/Bridge/VertexAi/Gemini/ResultConverterTest.php b/src/platform/tests/Bridge/VertexAi/Gemini/ResultConverterTest.php index d77ba1173..4c385fea2 100644 --- a/src/platform/tests/Bridge/VertexAi/Gemini/ResultConverterTest.php +++ b/src/platform/tests/Bridge/VertexAi/Gemini/ResultConverterTest.php @@ -28,7 +28,6 @@ final class ResultConverterTest extends TestCase { public function testItConvertsAResponseToAVectorResult() { - // Arrange $payload = [ 'content' => ['parts' => [['text' => 'Hello, world!']]], ]; @@ -42,10 +41,8 @@ public function testItConvertsAResponseToAVectorResult() $resultConverter = new ResultConverter(); - // Act $result = $resultConverter->convert(new RawHttpResult($response)); - // Assert $this->assertInstanceOf(TextResult::class, $result); $this->assertSame('Hello, world!', $result->getContent()); } diff --git a/src/platform/tests/Bridge/VertexAi/TokenOutputProcessorTest.php b/src/platform/tests/Bridge/VertexAi/TokenOutputProcessorTest.php index d6de42fd5..93d8702ae 100644 --- a/src/platform/tests/Bridge/VertexAi/TokenOutputProcessorTest.php +++ b/src/platform/tests/Bridge/VertexAi/TokenOutputProcessorTest.php @@ -48,7 +48,6 @@ public function testItDoesNothingWithoutRawResponse() public function testItAddsUsageTokensToMetadata() { - // Arrange $textResult = new TextResult('test'); $rawResponse = $this->createRawResponse([ @@ -64,10 +63,8 @@ public function testItAddsUsageTokensToMetadata() $processor = new TokenOutputProcessor(); $output = $this->createOutput($textResult); - // Act $processor->processOutput($output); - // Assert $metadata = $output->result->getMetadata(); $tokenUsage = $metadata->get('token_usage'); @@ -81,7 +78,6 @@ public function testItAddsUsageTokensToMetadata() public function testItHandlesMissingUsageFields() { - // Arrange $textResult = new TextResult('test'); $rawResponse = $this->createRawResponse([ @@ -94,10 +90,8 @@ public function testItHandlesMissingUsageFields() $processor = new TokenOutputProcessor(); $output = $this->createOutput($textResult); - // Act $processor->processOutput($output); - // Assert $metadata = $output->result->getMetadata(); $tokenUsage = $metadata->get('token_usage'); @@ -111,17 +105,14 @@ public function testItHandlesMissingUsageFields() public function testItAddsEmptyTokenUsageWhenUsageMetadataNotPresent() { - // Arrange $textResult = new TextResult('test'); $rawResponse = $this->createRawResponse(['other' => 'data']); $textResult->setRawResult($rawResponse); $processor = new TokenOutputProcessor(); $output = $this->createOutput($textResult); - // Act $processor->processOutput($output); - // Assert $metadata = $output->result->getMetadata(); $tokenUsage = $metadata->get('token_usage'); diff --git a/src/store/src/Command/IndexCommand.php b/src/store/src/Command/IndexCommand.php index 97ae1fae9..65fc75224 100644 --- a/src/store/src/Command/IndexCommand.php +++ b/src/store/src/Command/IndexCommand.php @@ -76,7 +76,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $indexer = $input->getArgument('indexer'); $sources = $input->getOption('source'); - // Convert array of sources to single source or null $source = match (true) { [] === $sources => null, 1 === \count($sources) => $sources[0], @@ -89,7 +88,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $indexerService = $this->indexers->get($indexer); - // If source override is provided, use withSource to create a new indexer instance if (null !== $source) { $indexerService = $indexerService->withSource($source); } diff --git a/src/store/src/Indexer.php b/src/store/src/Indexer.php index 4c74b9f63..684cd9394 100644 --- a/src/store/src/Indexer.php +++ b/src/store/src/Indexer.php @@ -58,7 +58,6 @@ public function index(array $options = []): void $documents = []; if ([] === $this->sources) { - // No specific source provided, load with null $documents = $this->loadSource(null); } else { foreach ($this->sources as $singleSource) { @@ -72,17 +71,14 @@ public function index(array $options = []): void return; } - // Filter documents through all filters foreach ($this->filters as $filter) { $documents = $filter->filter($documents); } - // Transform documents through all transformers foreach ($this->transformers as $transformer) { $documents = $transformer->transform($documents); } - // Vectorize and store documents in chunks $chunkSize = $options['chunk_size'] ?? 50; $counter = 0; $chunk = []; @@ -96,7 +92,6 @@ public function index(array $options = []): void } } - // Handle remaining documents if ([] !== $chunk) { $this->store->add(...$this->vectorizer->vectorizeTextDocuments($chunk)); } diff --git a/src/store/tests/Document/Loader/RssFeedLoaderTest.php b/src/store/tests/Document/Loader/RssFeedLoaderTest.php index f842db6e5..0a5ac425e 100644 --- a/src/store/tests/Document/Loader/RssFeedLoaderTest.php +++ b/src/store/tests/Document/Loader/RssFeedLoaderTest.php @@ -46,7 +46,6 @@ public function testLoadWithValidRssFeed() $documents = iterator_to_array($loader->load('https://feeds.feedburner.com/symfony/blog')); $this->assertCount(10, $documents); - // Test first document $firstDocument = $documents[0]; $this->assertInstanceOf(TextDocument::class, $firstDocument); $this->assertStringStartsWith('Title: Save the date, SymfonyDay Montreal 2026!', $firstDocument->content); diff --git a/src/store/tests/Document/MetadataTest.php b/src/store/tests/Document/MetadataTest.php index 0ffe25399..312dfadf4 100644 --- a/src/store/tests/Document/MetadataTest.php +++ b/src/store/tests/Document/MetadataTest.php @@ -48,11 +48,9 @@ public function testParentIdMethods(int|string|null $parentId) { $metadata = new Metadata(); - // Initially should not have parent ID $this->assertFalse($metadata->hasParentId()); $this->assertNull($metadata->getParentId()); - // Set parent ID $metadata->setParentId($parentId); $this->assertTrue($metadata->hasParentId()); @@ -78,11 +76,9 @@ public function testTextMethods(?string $text) { $metadata = new Metadata(); - // Initially should not have text $this->assertFalse($metadata->hasText()); $this->assertNull($metadata->getText()); - // Set text $metadata->setText($text); $this->assertTrue($metadata->hasText()); @@ -108,11 +104,9 @@ public function testSourceMethods(?string $source) { $metadata = new Metadata(); - // Initially should not have source $this->assertFalse($metadata->hasSource()); $this->assertNull($metadata->getSource()); - // Set source $metadata->setSource($source); $this->assertTrue($metadata->hasSource()); @@ -144,19 +138,15 @@ public function testMetadataInitializedWithSpecialKeys() $metadata = new Metadata($data); - // Test parent ID $this->assertTrue($metadata->hasParentId()); $this->assertSame('parent-123', $metadata->getParentId()); - // Test text $this->assertTrue($metadata->hasText()); $this->assertSame('This is the text content', $metadata->getText()); - // Test source $this->assertTrue($metadata->hasSource()); $this->assertSame('document.pdf', $metadata->getSource()); - // Test regular metadata $this->assertSame('Test Document', $metadata['title']); } @@ -164,22 +154,18 @@ public function testArrayObjectBehavior() { $metadata = new Metadata(); - // Test setting and getting values $metadata['title'] = 'Test Document'; $metadata['category'] = 'test'; $this->assertSame('Test Document', $metadata['title']); $this->assertSame('test', $metadata['category']); - // Test isset $this->assertTrue(isset($metadata['title'])); $this->assertFalse(isset($metadata['nonexistent'])); - // Test unset unset($metadata['category']); $this->assertFalse(isset($metadata['category'])); - // Test count $this->assertCount(1, $metadata); } @@ -218,12 +204,10 @@ public function testOverwritingSpecialKeys() { $metadata = new Metadata(); - // Set initial values $metadata->setParentId('parent-1'); $metadata->setText('initial text'); $metadata->setSource('initial.pdf'); - // Overwrite values $metadata->setParentId('parent-2'); $metadata->setText('updated text'); $metadata->setSource('updated.pdf'); diff --git a/src/store/tests/Document/TextDocumentTest.php b/src/store/tests/Document/TextDocumentTest.php index eaa3887d3..289513c64 100644 --- a/src/store/tests/Document/TextDocumentTest.php +++ b/src/store/tests/Document/TextDocumentTest.php @@ -112,7 +112,6 @@ public function testReadonlyProperties() $document = new TextDocument($id, $content, $metadata); - // Test that properties are publicly accessible $this->assertSame($id, $document->id); $this->assertSame($content, $document->content); $this->assertSame($metadata, $document->metadata); diff --git a/src/store/tests/Document/VectorDocumentTest.php b/src/store/tests/Document/VectorDocumentTest.php index cf65233d3..a30a986d6 100644 --- a/src/store/tests/Document/VectorDocumentTest.php +++ b/src/store/tests/Document/VectorDocumentTest.php @@ -101,13 +101,11 @@ public function testReadonlyProperties() $document = new VectorDocument($id, $vector, $metadata, $score); - // Verify all properties are accessible $this->assertSame($id, $document->id); $this->assertSame($vector, $document->vector); $this->assertSame($metadata, $document->metadata); $this->assertSame($score, $document->score); - // Verify the class is marked as readonly $reflection = new \ReflectionClass(VectorDocument::class); $this->assertTrue($reflection->isReadOnly()); } diff --git a/src/store/tests/IndexerTest.php b/src/store/tests/IndexerTest.php index bd98acd3a..ddc00aa88 100644 --- a/src/store/tests/IndexerTest.php +++ b/src/store/tests/IndexerTest.php @@ -104,13 +104,10 @@ public function testWithSource() $loader = new InMemoryLoader([$document1]); $vectorizer = new Vectorizer(PlatformTestHandler::createPlatform(new VectorResult($vector)), new Embeddings(Embeddings::TEXT_3_SMALL)); - // Create indexer with initial source $indexer = new Indexer($loader, $vectorizer, $store = new TestStore(), 'source1'); - // Create new indexer with different source $indexerWithNewSource = $indexer->withSource('source2'); - // Verify it returns a new instance (immutability) $this->assertNotSame($indexer, $indexerWithNewSource); // Both can index successfully @@ -136,10 +133,8 @@ public function testWithSourceArray() // Create indexer with single source $indexer = new Indexer($loader, $vectorizer, $store1 = new TestStore(), 'source1'); - // Create new indexer with array of sources $indexerWithMultipleSources = $indexer->withSource(['source2', 'source3']); - // Verify it returns a new instance (immutability) $this->assertNotSame($indexer, $indexerWithMultipleSources); // Since InMemoryLoader ignores source, both will index all documents @@ -233,7 +228,6 @@ public function transform(iterable $documents, array $options = []): iterable public function testIndexWithFiltersAndTransformersAppliesBoth() { - // Test that both filters and transformers are applied correctly $documents = [ new TextDocument(Uuid::v4(), 'Keep this document'), new TextDocument(Uuid::v4(), 'Remove this content'), // Will be filtered out @@ -243,7 +237,6 @@ public function testIndexWithFiltersAndTransformersAppliesBoth() $loader = new InMemoryLoader($documents); $vectorizer = new Vectorizer(PlatformTestHandler::createPlatform(new VectorResult($vector)), new Embeddings(Embeddings::TEXT_3_SMALL)); - // Filter that removes documents containing "Remove" $filter = new class implements FilterInterface { public function filter(iterable $documents, array $options = []): iterable { @@ -255,7 +248,6 @@ public function filter(iterable $documents, array $options = []): iterable } }; - // Transformer that adds metadata $transformer = new class implements TransformerInterface { public function transform(iterable $documents, array $options = []): iterable { @@ -281,7 +273,6 @@ public function transform(iterable $documents, array $options = []): iterable public function testIndexWithNoFilters() { - // Test that indexer works with empty filters array (backward compatibility) $document = new TextDocument(Uuid::v4(), 'Test content'); $vector = new Vector([0.1, 0.2, 0.3]); $loader = new InMemoryLoader([$document]); @@ -304,7 +295,6 @@ public function testWithSourcePreservesFilters() $indexer = new Indexer($loader, $vectorizer, $store = new TestStore(), 'source1', [$filter]); $indexerWithNewSource = $indexer->withSource('source2'); - // Verify that the new indexer preserves filters $this->assertNotSame($indexer, $indexerWithNewSource); $indexerWithNewSource->index();