perf: optimize AgentPhase dependency checking with batch query #52

Merged
Snider merged 1 commit from perf/optimize-agent-phase-dependency-checking into main 2026-02-23 11:38:54 +00:00

1 commit

Author SHA1 Message Date
darbs-claude
909c2da6df perf: replace N+1 find() with whereIn batch lookup in checkDependencies()
Some checks failed
CI / PHP 8.4 (pull_request) Failing after 1m48s
CI / PHP 8.3 (pull_request) Failing after 2m0s
Resolves #23

- Replace per-dependency `AgentPhase::find()` loop with a single
  `AgentPhase::whereIn('id', $dependencies)->get()` call, reducing
  query count from N to 1 for any number of dependencies
- Short-circuit early when dependencies list is empty to avoid
  unnecessary query at all
- Add tests: empty deps, skipped-dep passthrough, single-query
  assertion, blocker shape validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 10:40:00 +00:00