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

Ai Surreal Db Message Store Laravel Package

symfony/ai-surreal-db-message-store

SurrealDB message store integration for Symfony AI Chat, letting you persist and retrieve conversation messages in SurrealDB via its HTTP integration.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit This is a Symfony AI ecosystem component, not a Laravel package. It implements Symfony AI's message-store abstraction (MessageStoreInterface equivalent) backed by SurrealDB's HTTP API, and is published as a split read-only package from the symfony/ai monorepo. For a Laravel codebase the package is best understood as a reference implementation plus a portable interface contract, not a drop-in dependency. The good news, and the part often misjudged in early evaluations: Symfony components are generally Composer-installable inside Laravel (Laravel already ships HttpFoundation, Console, Process, Finder), so the technical constraint is not "Symfony code cannot run in Laravel." The constraint is container wiring, configuration shape, event semantics, and version pinning, all of which are adapter-level work rather than architectural conflict.

The real architectural question is SurrealDB, not Symfony. SurrealDB earns its place only if the product genuinely needs flexible/document-hybrid message records (embeddings, sentiment, tool-call payloads, per-message metadata that would otherwise become JSON columns or EAV tables), or sub-second reactive reads. If the chat history is a straightforward append-only log with a handful of columns, Postgres with jsonb plus an Eloquent model will be cheaper to own and better supported by the existing team.

Integration feasibility Feasible with a thin Laravel adapter, in the region of one to three engineering weeks for an experienced PHP engineer, contingent on:

  • Binding the store as a singleton in a service provider behind a Laravel-owned interface (MessageRepository), so application code never references the Symfony type directly.
  • Reusing the package's HTTP payload construction and query shapes as reference rather than forking the code; the HTTP surface is narrow and reimplementation cost is low, whereas fork maintenance cost compounds.
  • Translating the Symfony AI message object graph into Laravel-native DTOs at the boundary; do not let Symfony AI value objects leak into controllers, jobs, or Blade/Inertia payloads.
  • Establishing a Composer constraint strategy, since the package versions in lockstep with a pre-1.0 monorepo and explicitly "prepares version constraints for release" of symfony/ai — a classic source of transitive resolution conflicts alongside Laravel's own pins.

Technical risk Rated medium-high, primarily supply-chain and maturity risk rather than capability risk:

  • 2 stars, 0 dependents, no downstream validation. The package is effectively first-party-adjacent (Symfony org) but unproven in the wild.
  • Changelog history shows mostly "no significant changes" releases — these are lockstep monorepo bumps, which means release numbers do not signal stability. One release (v0.11.0) fixes data corruption of the message UUID; that is a serious class of defect to have shipped, and it is a reasonable proxy for the depth of test coverage on the persistence path.
  • Pre-1.0 semver: interface and message-shape churn should be assumed, not merely possible.
  • SurrealDB operational maturity and team familiarity are the largest unknowns; a novel database introduced for a chat log is a disproportionate operational bet unless SurrealDB is already in the platform.
  • Auth model (namespace/database/record-level scoping via headers) does not map onto Laravel's guards; this needs an explicit design, not an afterthought.

Key questions

  1. Is SurrealDB already an approved platform dependency? If not, who owns the on-call story for a new datastore?
  2. What percentage of message records require schema flexibility — if under ~20%, is Postgres jsonb sufficient and materially cheaper?
  3. Do we need real-time subscription semantics (SurrealDB live queries) in the product roadmap within two quarters, or is polling/pagination adequate?
  4. What is our appetite for pinning to a pre-1.0 interface, and do we have a policy for handling breaking changes in a dependency we do not control?
  5. Does the AI chat feature have a hard data-residency/compliance constraint that rules out the managed SurrealDB Cloud option or mandates self-hosting?
  6. Is persistence of conversation history a differentiator or a commodity? Commodity suggests buy/native; differentiator suggests invest in the adapter.

Integration Approach

Stack fit The realistic path is an adapter, not a fork and not a microservice. Concretely:

  • Keep the Symfony package as an optional, isolated dependency confined to one SurrealMessageStore class implementing a Laravel-defined contract.
  • Use Laravel's Http client for the actual transport rather than Symfony's HttpClient, to inherit Laravel's retry, timeout, and Http::fake() testing ergonomics. If the package's concrete class is used directly, wrap it and treat Symfony's HTTP exceptions as an implementation detail translated to Laravel exceptions.
  • Register via a dedicated service provider with config in config/ai.php (or config/chat.php), following Laravel's publishable-config convention.
  • Emit Laravel events (MessageStored, ConversationRetrieved) at the adapter boundary; do not attempt to bridge Symfony's dispatcher into Illuminate\Contracts\Events\Dispatcher.
  • Reject a Symfony microservice for this scope. It adds a network hop and a second deploy target to solve a problem that is a class-file's worth of glue.

Migration path

  1. Spike (2–3 days). Stand up SurrealDB locally, reproduce the package's read/write payloads with Laravel's Http client, confirm UUID fidelity and ordering semantics. Gate: messages round-trip without corruption.
  2. Contract first. Define MessageRepository (append, listByConversation, deleteConversation) in the Laravel app. Every later decision is reversible behind this interface.
  3. Adapter implementation. Implement against SurrealDB, feature-flagged off by default.
  4. Dual-write shadow period. In non-production or behind a flag, write to both the incumbent store and SurrealDB; compare read results. This directly de-risks the UUID-corruption class of bug.
  5. Cutover per environment, with the incumbent store retained read-only for rollback for at least one release cycle.
  6. Decommission only after a full retention window has passed and export/backup is verified.

Compatibility

  • PHP/Composer: verify the symfony/ai constraint graph resolves against the app's existing Symfony component versions; this is the most likely early blocker and should be checked in hour one, not week two.
  • Schema: SurrealDB tables (messages, conversations) and indexes must be provisioned explicitly — Laravel migrations do not apply. Track them as versioned .surql files in the repo with an idempotent bootstrap command, or you will have an untracked schema drift problem.
  • Auth: namespace/database/scope supplied via headers from config; credentials in Laravel's encrypted config or a secrets manager, never in the repository.
  • Testing: mirror the app's Http::fake() fixtures around the SurrealDB payloads so the suite runs without a live database.

Sequencing Deliver the contract and adapter first, feature-flag second, dual-write third, cutover last. Do not let SurrealDB adoption ride on the first AI feature launch; the AI chat feature should ship on the safer store if there is any schedule pressure, with the SurrealDB path as a follow-on optimization. If the team cannot commit to owning the .surql schema files and the auth header design in sprint one, stop and keep the incumbent store.

Operational Impact

Maintenance Two maintenance surfaces exist: the dependency (pre-1.0, monorepo-lockstep releases, 0 dependents) and the SurrealDB instance. Budget for a quarterly dependency review, and expect at least one breaking change per year while the package is pre-1.0. Keeping the Laravel-owned interface small is the mitigation — it caps blast radius to a single class. Forking is explicitly discouraged: a fork of a monorepo split package re-created on every upstream commit is a permanent tax with no offsetting benefit here.

Support No vendor support; upstream is a community/Symfony org GitHub issue tracker, and issues are filed against the parent symfony/ai repo, not this package. Internal ownership must be named — a specific engineer or team accountable for the adapter and the schema. SurrealDB itself needs an owner for upgrades, backup verification, and access control. Document the adapter as internal infrastructure with a runbook; treat it as critical path once chat history is user-visible.

Scaling HTTP-per-operation introduces per-message latency in the tens of milliseconds, and chat persistence is write-heavy and bursty (a single turn may produce several records). Design for batching writes per turn and paginating reads by conversation with a cursor; avoid unbounded history fetches. Validate against a realistic target — for example, p95 under 100ms for a 20-message append with 3 concurrent turns — before committing. Connection pooling is not available over plain HTTP, so throughput scales with SurrealDB's HTTP endpoint capacity and the PHP worker pool, not with Laravel's queue unless writes are explicitly pushed to jobs. Consider queueing non-blocking writes if the user-facing latency budget is tight.

Failure modes

  • SurrealDB unavailable or slow: chat becomes read-only or returns empty history. Wrap all store calls with short timeouts, a circuit breaker, and degraded-mode UI ("history temporarily unavailable") rather than a 500.
  • Silent data corruption: the v0.11.0 UUID fix proves this failure mode is real. Mitigate with dual-write comparison during rollout and a periodic integrity check that IDs are unique and stable.
  • Schema drift: manual SurrealDB schema edits diverging from code expectations. Mitigate with versioned .surql bootstrap and a CI check.
  • Version-resolution breakage: a routine composer update pulls an incompatible symfony/ai and breaks the adapter at runtime. Mitigate with lockfile discipline and a smoke test in CI.
  • Auth misconfiguration: namespace/database headers wrong in one environment, writing messages to the wrong tenant scope — a data-isolation incident. Mitigate with a startup assertion and an integration test per environment tier.
  • Retention/erasure gaps: user deletion requests not propagating to SurrealDB. This is a compliance failure, not an availability one; add it to the adapter contract now, not later.

Ramp-up Expect two to four days of engineer ramp-up: one day on SurrealDB fundamentals (SurrealQL, the namespace/database/record model, HTTP endpoints), one day on the Symfony AI message-store contract, and one to two days reproducing and testing the payloads. Do not assume Laravel familiarity covers SurrealDB — the query language and auth model are genuinely different. If no one on the team has SurrealDB experience, add a formal learning allocation to the spike, and treat "we'll pick it up" as a schedule risk rather than a plan.

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.
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode