feat(brain): add org filter to BrainService::buildQdrantFilter()
Adds an `org` match filter between workspace_id and project in the Qdrant payload filter chain. Multi-org isolation for OpenBrain memory retrieval. Co-authored-by: Codex <noreply@openai.com> Closes tasks.lthn.sh/view.php?id=58
This commit is contained in:
parent
4e190dc7ec
commit
bd060c8aa0
2 changed files with 62 additions and 0 deletions
|
|
@ -217,6 +217,10 @@ class BrainService
|
|||
$must[] = ['key' => 'workspace_id', 'match' => ['value' => $criteria['workspace_id']]];
|
||||
}
|
||||
|
||||
if (isset($criteria['org'])) {
|
||||
$must[] = ['key' => 'org', 'match' => ['value' => $criteria['org']]];
|
||||
}
|
||||
|
||||
if (isset($criteria['project'])) {
|
||||
$must[] = ['key' => 'project', 'match' => ['value' => $criteria['project']]];
|
||||
}
|
||||
|
|
|
|||
58
php/tests/Feature/BrainServiceTest.php
Normal file
58
php/tests/Feature/BrainServiceTest.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Core\Mod\Agentic\Tests\Feature;
|
||||
|
||||
use Core\Mod\Agentic\Services\BrainService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BrainServiceTest extends TestCase
|
||||
{
|
||||
public function test_BrainService_buildQdrantFilter_Good_FiltersByOrgOnly(): void
|
||||
{
|
||||
$filter = (new BrainService)->buildQdrantFilter([
|
||||
'org' => 'core',
|
||||
]);
|
||||
|
||||
$this->assertSame([
|
||||
'must' => [
|
||||
['key' => 'org', 'match' => ['value' => 'core']],
|
||||
],
|
||||
], $filter);
|
||||
}
|
||||
|
||||
public function test_BrainService_buildQdrantFilter_Bad_CombinesOrgAndProject(): void
|
||||
{
|
||||
$filter = (new BrainService)->buildQdrantFilter([
|
||||
'org' => 'core',
|
||||
'project' => 'agent',
|
||||
]);
|
||||
|
||||
$this->assertSame([
|
||||
'must' => [
|
||||
['key' => 'org', 'match' => ['value' => 'core']],
|
||||
['key' => 'project', 'match' => ['value' => 'agent']],
|
||||
],
|
||||
], $filter);
|
||||
}
|
||||
|
||||
public function test_BrainService_buildQdrantFilter_Ugly_CombinesWorkspaceOrgAndProject(): void
|
||||
{
|
||||
$filter = (new BrainService)->buildQdrantFilter([
|
||||
'workspace_id' => 42,
|
||||
'org' => 'core',
|
||||
'project' => 'agent',
|
||||
]);
|
||||
|
||||
$this->assertSame([
|
||||
'must' => [
|
||||
['key' => 'workspace_id', 'match' => ['value' => 42]],
|
||||
['key' => 'org', 'match' => ['value' => 'core']],
|
||||
['key' => 'project', 'match' => ['value' => 'agent']],
|
||||
],
|
||||
], $filter);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue