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
Member

Summary

  • Replaces per-dependency AgentPhase::find() loop in checkDependencies() with a single AgentPhase::whereIn('id', $dependencies)->get() call, reducing query count from N to 1
  • Adds early-exit short-circuit when the dependencies list is empty (avoids any query at all)
  • Adds four new tests covering: empty deps, skipped-dep passthrough, single-query assertion, and blocker array shape validation

Changes

  • Models/AgentPhase.php — batch whereIn replaces N+1 find() loop
  • tests/Feature/AgentPhaseTest.php — expanded dependency-checking test coverage

Closes #23

## Summary - Replaces per-dependency `AgentPhase::find()` loop in `checkDependencies()` with a single `AgentPhase::whereIn('id', $dependencies)->get()` call, reducing query count from N to 1 - Adds early-exit short-circuit when the dependencies list is empty (avoids any query at all) - Adds four new tests covering: empty deps, skipped-dep passthrough, single-query assertion, and blocker array shape validation ## Changes - `Models/AgentPhase.php` — batch `whereIn` replaces N+1 `find()` loop - `tests/Feature/AgentPhaseTest.php` — expanded dependency-checking test coverage Closes #23
Clotho added 1 commit 2026-02-23 10:42:20 +00:00
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
909c2da6df
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>
Snider merged commit ff34ede167 into main 2026-02-23 11:38:54 +00:00
Snider deleted branch perf/optimize-agent-phase-dependency-checking 2026-02-23 11:38:54 +00:00
Sign in to join this conversation.
No description provided.