Harden vision vector search and embedding jobs.

Add point search, circuit-breaking, and safer gateway limits so artwork similarity lookups fail closed instead of hanging the request path.
This commit is contained in:
2026-09-20 14:49:19 +02:00
parent 04b8160d9e
commit 1053a38eee
12 changed files with 903 additions and 64 deletions
@@ -95,13 +95,34 @@ final class AiArtworkVectorSearchService
*/
private function searchMatchesForArtwork(Artwork $artwork, int $limit): array
{
$this->client->assertCircuitClosed();
/*
* Reuse the artwork's already-indexed Qdrant vector when available.
* A missing point is expected for older/rebuilt indexes, so retain the
* existing image/CLIP fallback below.
*/
try {
$pointMatches = $this->client->searchByPointId((int) $artwork->id, $limit);
if ($pointMatches !== null) {
return $pointMatches;
}
} catch (VectorGatewayException $pointFailure) {
$this->client->tripIfCircuitWorthy(
[$pointFailure],
'similar_ai_point',
['artwork_id' => (int) $artwork->id],
);
throw $pointFailure;
}
$url = $this->imageUrl->fromArtwork($artwork);
if ($url === null || $url === '') {
return [];
}
$this->client->assertCircuitClosed();
$fileFailure = null;
$fileGatewayAttempted = false;