Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/Services/QdrantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ public function upsert(array $entry, string $project = 'default', bool $checkDup
'superseded_reason' => $entry['superseded_reason'] ?? null,
];

// Enhancement fields are optional: only present once the Ollama worker
// has processed the entry, and must survive later re-upserts.
foreach (['enhanced', 'enhanced_at', 'summary', 'concepts'] as $enhancementField) {
if (array_key_exists($enhancementField, $entry)) {
$payload[$enhancementField] = $entry[$enhancementField];
}
}

$point = ['id' => $entry['id'], 'payload' => $payload];

if ($this->hybridEnabled && $this->sparseEmbeddingService instanceof SparseEmbeddingServiceInterface) {
Expand Down Expand Up @@ -661,6 +669,11 @@ private function mapScoredPointToEntry(ScoredPoint $point): array
'superseded_by' => $p['superseded_by'] ?? null,
'superseded_date' => $p['superseded_date'] ?? null,
'superseded_reason' => $p['superseded_reason'] ?? null,
'commit' => $p['commit'] ?? null,
'enhanced' => $p['enhanced'] ?? null,
'enhanced_at' => $p['enhanced_at'] ?? null,
'summary' => $p['summary'] ?? null,
'concepts' => $p['concepts'] ?? null,
];
}

Expand Down
42 changes: 42 additions & 0 deletions tests/Unit/Services/QdrantServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1574,3 +1574,45 @@ function mockCollectionExists(Mockery\MockInterface $qdrant, int $times = 1): vo
expect($this->service->upsert($entry, 'default', true))->toBeTrue();
});
});

describe('enhancement field round-trip', function (): void {
it('persists enhancement fields through updateFields', function (): void {
mockCollectionExists($this->mockQdrant, 2);

$this->mockQdrant->shouldReceive('getPoints')
->once()
->andReturn([
makeScoredPoint('enh-1', 0.0, [
'title' => 'Entry',
'content' => 'Body',
'commit' => 'abc123',
]),
]);

$this->mockEmbedding->shouldReceive('embed')
->once()
->andReturn([0.1, 0.2, 0.3]);

$this->mockQdrant->shouldReceive('upsert')
->once()
->with(Mockery::any(), Mockery::on(function (array $points): bool {
$payload = $points[0]['payload'];

return ($payload['enhanced'] ?? null) === true
&& ($payload['enhanced_at'] ?? null) === '2026-07-03T00:00:00+00:00'
&& ($payload['summary'] ?? null) === 'A summary'
&& ($payload['concepts'] ?? null) === ['mesh', 'router']
&& ($payload['commit'] ?? null) === 'abc123';
}))
->andReturn(makeUpsertResult());

$result = $this->service->updateFields('enh-1', [
'enhanced' => true,
'enhanced_at' => '2026-07-03T00:00:00+00:00',
'summary' => 'A summary',
'concepts' => ['mesh', 'router'],
]);

expect($result)->toBeTrue();
});
});
Loading