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 Guard Laravel Package

jayanta/laravel-ai-guard

Laravel AI Guard adds a lightweight middleware layer that detects, logs, and blocks unwanted AI traffic hitting your app, and lets you gate AI-powered endpoints behind simple, configurable rules—keeping scrapers and costly requests under control.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit: Strong for Laravel applications that need bot/AI-agent identity without coupling every consumer to AI Guard. The package now acts as an in-process identity publisher: BotClassified, AgentVerified, and SpoofedBotDetected are dispatched through Laravel’s event system, and the same verdict is available via request()->attributes->get('ai_guard.verdict'). That is a good fit for modular monoliths and Laravel services where policy enforcement should remain separate from identity classification.

The main architectural limitation is scope: this is request-local and process-local. Other services cannot consume the verdict unless the application forwards it, queues it, or writes it to a shared store. The named-event subscription model avoids a Composer dependency, which is excellent for decoupling, but it also means consumers rely on a string contract rather than a typed interface.

Integration feasibility: High. The release is explicitly additive: “nothing changes unless you listen.” A TPM can position this as a low-risk, opt-in integration. Adoption requires only a composer update and a listener or request-attribute read. The schema guard (ai-guard.verdict/1) gives consumers a simple compatibility check, and the stable-v1 rules reduce churn risk.

Technical risk: Low-to-moderate. The contract is new, so the primary risk is semantic rather than implementation: teams may misinterpret the absence of an event as “human” or “safe,” when the release states that whitelisted requests are not evaluated and only certain bot/agent outcomes emit events. Listener exceptions are swallowed by design, which protects request handling but can hide integration failures. The “at most once per request” guarantee needs product and engineering alignment on what “once” means per event versus per verdict.

Key questions:

  • Where in the middleware lifecycle are these events dispatched, and is the request attribute guaranteed by the time application listeners run?
  • Does “at most once per request” mean one event total, or each event type at most once?
  • What is the canonical payload shape for each event, and which fields are guaranteed versus optional in v1?
  • Are non-bot, unverified, or unevaluated clients represented anywhere, or is absence the only signal?
  • How should consumers distinguish “not evaluated,” “not a bot,” “verified bot,” and “spoofed bot” without overloading missing events?
  • Is interop.enabled default-on or default-off, and can it be toggled per environment?
  • Are payloads safe to queue as-is, and are there ordering guarantees if multiple listeners process identity?
  • What is the support policy for ai-guard.verdict/1 across major versions, and how will v2 be introduced?

Integration Approach

Stack fit: Good. Laravel 10–13 on PHP 8.1–8.4 covers current supported Laravel application baselines. The package’s use of native events, request attributes, and scalar payloads fits standard Laravel middleware and event-driven architecture. It does not require a new service, broker, or database.

Migration path: Straightforward. Upgrade with composer update jayanta/laravel-ai-guard; no migration is described. Existing behavior should remain unchanged unless consumers register listeners or read the verdict attribute. For teams already using AI Guard, this is a minor-version upgrade with an additive interop surface. The fixed SIEM/OpenTelemetry version reporting issue in 3.0.1 is operationally relevant for telemetry accuracy but not a breaking change.

Compatibility: Strong within v1 by contract: fields may be added but not renamed or removed. Consumers should still validate schema === 'ai-guard.verdict/1' before processing, as shown. The named-event pattern keeps consuming code working if AI Guard is removed, but that also means removal silently stops verdicts. The interop.enabled => false switch is a useful compatibility and rollback control.

Sequencing:

  1. Upgrade in staging and confirm the package version now reports correctly in SIEM/OpenTelemetry exports.
  2. Validate the canonical fixture at tests/Fixtures/interop/verdict-v1.json against the staging payloads.
  3. Add one low-risk listener behind configuration, checking schema before use.
  4. Observe event volume, missing-event cases, and listener errors in non-production.
  5. Canary in production with interop.enabled controlled per environment.
  6. Expand consumers only after confirming semantics around whitelisted and unevaluated requests.
  7. Document that absence of an event is not equivalent to “human” unless the application explicitly establishes that rule.

Operational Impact

Maintenance: Low. The package shows active maintenance signals: 482 tests, PHPStan level 6, Laravel Pint, a canonical fixture, and a documented versioning contract. Pinning to a known minor version and monitoring the changelog is sufficient. The main maintenance burden shifts to consumer listeners, which should be owned by the teams that register them.

Support: Moderate but manageable. The event-name subscription model reduces dependency support, but it can increase discoverability issues: a typo in a string event name fails silently. Internal documentation should include the exact event names, the schema guard, the request-attribute alternative, and the interop.enabled switch. Support teams should know that whitelisted requests produce no verdict and that listener exceptions do not break requests.

Scaling: Low overhead for typical Laravel request volumes. Events are dispatched in-process, payloads are scalar and queueable, and the package fires at most once per request. Scaling risk comes from synchronous listener work: consumers should keep listeners cheap or queue downstream processing. High-traffic applications should monitor listener count and latency, especially if multiple modules subscribe to the same verdict.

Failure modes:

  • Listener throws: request continues, but the consumer silently misses the verdict.
  • Schema drift: consumer ignores the event because the schema guard fails.
  • Whitelisted request: no evaluation and no event, which can be misread as a negative result.
  • Interop disabled: events stop without application errors.
  • Package removed: named listeners remain registered but receive nothing.
  • Event-name typo: no error, no processing.
  • Version reporting: fixed in this release, so telemetry should now reflect the actual package version.

Ramp-up: Low for Laravel developers familiar with events and middleware. A TPM can drive adoption incrementally: start with one consumer, publish an internal example listener, use the fixture as a contract test, and document the “absence is not a verdict” rule. Cross-service consumers will need a separate propagation design, so this release should be positioned as an in-process interoperability contract, not a network-level identity service.

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.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
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