*/ public function middleware(): array { $sourceKey = Finding::find($this->findingId)?->source?->key; if ($sourceKey === null) { return []; } return [new RateLimited('osint-runner:'.$sourceKey)]; } public function handle(RunnerRegistry $registry): void { $finding = Finding::with(['target', 'source'])->findOrFail($this->findingId); $finding->update(['status' => 'running']); try { $result = $registry->resolve($finding->source->key)->run($finding->target); $finding->update([ 'status' => 'completed', 'raw_payload' => $result->raw, 'summary' => $result->summary, 'ran_at' => now(), ]); } catch (\Throwable $e) { $finding->update([ 'status' => 'failed', 'error' => $e->getMessage(), 'ran_at' => now(), ]); } } /** * Only reached if the job itself fails outside handle()'s own * try/catch — e.g. retries exhausted while rate-limited. */ public function failed(\Throwable $exception): void { Finding::where('id', $this->findingId)->update([ 'status' => 'failed', 'error' => 'Gave up after retries: '.$exception->getMessage(), 'ran_at' => now(), ]); } }