Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Ai Core Laravel Package

apavliukov/laravel-ai-core

Laravel AI Core provides a foundation for integrating AI capabilities into Laravel applications, with configurable drivers, service bindings, and a consistent API for working with AI models and providers. It aims to keep AI configuration and usage organized, testable, and framework-native.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • laravel-ai-core reads as an abstraction layer between Laravel domain models and AI providers: ModelAssignments is a polymorphic pivot assigning AI models/configs to subjects, and "subject key stamping" implies the package now owns derivation/persistence of a stable subject key across those polymorphic relations.
  • "Core" naming plus provider-agnostic feature set (assignments, reports, test factory) fits as a shared internal dependency rather than a user-facing component. It sits below feature code and above HTTP clients.
  • The protected store() extension point is a conventional Laravel template-method pattern — good sign of intentional API design, but it means the package owns persistence control flow.
  • v0.4.1 note: the patch ("stamp before host traits") confirms that the stamping seam interacts with host-model trait bootstrapping — i.e. the package's write path is order-sensitive relative to consumer code. That is a real architectural coupling to be aware of, not just a one-off bug.

Integration feasibility

  • Standard Composer + package auto-discovery install. The 0.4.0 breaking change remains narrow in blast radius: it only affects code that subclasses ModelAssignments. Net-new adoption is unaffected.
  • The row factory materially lowers integration cost — assignment and report fixtures become testable without hand-rolling records, which shortens the spike phase. v0.4.1's "sharper factory" is a usability improvement in exactly the tooling the spike depends on.
  • Feasibility is high for greenfield; medium for anyone already subclassing assign(). v0.4.1 introduces no new migration work beyond 0.4.0.

Technical risk

  • Pre-1.0 churn. v0.4.0 with breaking changes on a minor version is semver-permissible for 0.x but signals an unstable contract. Budget for rework on each minor bump.
  • final assign() removes an escape hatch. Anyone overriding assign() gets a hard fatal error, not a deprecation. This remains the single highest-cost upgrade item and is undiscoverable without reading the changelog.
  • Subject-key stamping is confirmed as the fragile area. v0.4.1 fixing "stamp before host traits" means 0.4.0 could stamp the subject key at the wrong point in the trait lifecycle. The consequence is the same class of failure the original assessment flagged: mis-derived or null keys and silently unmatched assignments. This is now an observed defect class, not a hypothetical — treat it as a data-integrity concern requiring a verification test, not a code concern.
  • Schema/data risk remains. Key derivation or re-keying of existing polymorphic rows still implies migrations plus a backfill on adoption.
  • Rejected-answer reports create an unbounded, likely PII-adjacent table. Retention, redaction, and write-path coupling are still unverified; nothing in 0.4.1 addresses them.
  • Single-maintainer project; bus-factor and long-term support remain the dominant non-technical risks. The fast patch turnaround is a mild positive signal on responsiveness but does not change the bus factor.

Key questions

  1. What is the exact migration footprint of subject key stamping — publishable, reversible, and does it backfill existing rows?
  2. Did 0.4.0's stamping-order defect ever persist wrong keys in the wild, and does 0.4.1 correct already-stamped rows or only future writes? If the former, an app that ran 0.4.0 with real traffic needs a data repair step, not just a version bump.
  3. Is there an upgrade guide for store(), and does assign() still throw a clear error if a subclass defines it?
  4. Are rejected-answer reports opt-in, and what is stored (prompt text? subject identifiers? PII)?
  5. Which Laravel/PHP versions are supported, and is there a CI matrix and coverage signal? Does that matrix cover trait-ordering scenarios like the one 0.4.1 fixed?
  6. Is the 0.4.1 factory change purely internal, or did any factory method signature/return shape change? "Sharper" is ambiguous in a patch release.
  7. Are there plans for a 1.0 / stability commitment, and who owns the dependency internally?

Integration Approach

Stack fit

  • Assumes a Laravel application (10/11/12 — confirm), PHP 8.x, standard queue workers. Reports and assignment writes should be queue-backed; nothing in the feature list suggests a hard runtime dependency on an external service beyond the AI providers themselves.
  • Fits existing Eloquent-centric code without requiring a new persistence layer, which keeps it inside the team's existing competency.
  • v0.4.1's "read providers once" reduces repeated provider/config resolution per operation — mildly favourable for latency budget and provider quota/cost modeling, but it does not change the queue-backed design recommendation.

Migration path

  • Pin ^0.4.1, not 0.4.0. Anyone who adopted 0.4.0 during the last few weeks should take the patch immediately if subject key stamping is enabled, then verify stored keys.
  • Pin ^0.3 if not yet adopted and stamping isn't needed; treat v0.4.x as a planned change, not a patch.
  • For existing integrators: rewrite ModelAssignments subclasses from assign() overrides to protected store(). Call sites are unchanged — assign() remains the public entry point. This is a small, mechanical, but mandatory edit.
  • Sequence the subject-key migration before enabling features that depend on it; verify the backfill on a production-sized snapshot, not a dev DB.

Compatibility

  • Under 0.x, treat every minor as potentially breaking. Lock exact versions, read every changelog, and keep the upgrade diff reviewable. 0.4.1 is a patch and appears non-breaking, but it is not a no-op for stamping behaviour — schedule it, don't let it ride in on a routine composer update.
  • Check transitive constraints (PHP version, Laravel major) against the platform baseline before the spike.

Sequencing

  1. Spike in a throwaway app: install 0.4.1 specifically, publish config/migrations, run the row factory to seed assignments and reports.
  2. Review the generated schema, especially polymorphic indexes and any subject-key columns.
  3. Add a regression test that exercises subject key stamping on a model with host traits defined/booted (SoftDeletes, UUID keys, custom booted hooks) — this is precisely the ordering case 0.4.1 fixed, and it is the cheapest guard against recurrence.
  4. Draft and rehearse the subject-key backfill against a production-sized snapshot.
  5. Refactor any assign() subclasses to store(); add a smoke test asserting assignments still persist.
  6. Decide retention/redaction policy for rejected-answer reports before enabling them; default off.
  7. Roll out behind a config flag with one non-critical consumer, then broaden.

Operational Impact

Maintenance

  • Pre-1.0, single-maintainer dependency: expect periodic breaking changes and plan a recurring "upgrade the AI core" line item rather than treating it as set-and-forget.
  • Pinning exact versions plus reviewing release notes is the primary control. Without that discipline, a routine composer update becomes an incident.
  • v0.4.1 arriving as a quick bug-fix patch is a positive cadence signal — the maintainer is actively fixing the fragile seam — but it also means 0.4.x is still settling. Assume at least one more patch before the API stops moving.

Support

  • No vendor SLA; support is the maintainer's goodwill plus our own internal owner. Name a DBA-adjacent owner for the reports table and an app owner for the assignment abstraction.
  • Codify the store() extension contract, the subject-key format, and the required write ordering relative to host-model traits in internal docs — this knowledge lives only in the package source and in one commit message.

Scaling

  • Polymorphic assignment lookups need composite indexes on (subject_type, subject_id) and on the model/config foreign key; unindexed, these degrade badly as assignments accumulate.
  • "Subject key stamping" likely adds a write on subject creation/update. If subjects are high-volume (e.g. per-request users), batch or defer to avoid write amplification.
  • Rejected-answer reports grow one row per rejection and scale with traffic, not with user count. Plan partitioning or periodic pruning from day one; a naive table will become the largest in the schema.
  • "Read providers once" removes redundant resolution work per operation; still model provider rate limits explicitly, since the dominant scaling cost is upstream API quota, not local CPU.

Failure modes

  • Subclass still defining assign() after upgrade → fatal error at class load. Detected only at runtime; needs a test.
  • Stamping executed before host traits initialize → mis-derived or null subject keys, producing silently unmatched assignments. Fixed in 0.4.1 for new writes; pre-existing rows stamped under 0.4.0 are the open question (see key question 2).
  • Missing or incomplete subject-key backfill → null keys, silently unmatched assignments, hard-to-attribute behaviour bugs.
  • Synchronous report writes coupling AI request latency to database availability — a report outage becomes a product outage.
  • Provider outage or rate limiting surfacing as raw exceptions if the package's error surface isn't wrapped by the host app.
  • Migration ordering issues on deploy if the subject-key column ships before the backfill job.

Ramp-up

  • A Laravel-fluent engineer reaches a working assignment in roughly half a day using the row factory and published config; the improved factory in 0.4.1 shaves some fixture-writing friction from that path.
  • Budget 1–2 additional days for the parts that aren't obvious from the surface: the store() extension contract, the subject-key derivation/backfill, the trait-ordering constraint, and the report retention/redaction policy.
  • The upgrade from 0.3 → 0.4 is a small code change with outsized consequences if missed; document it as a checklist item rather than tribal knowledge, and add "confirm on ≥0.4.1" to that checklist.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle