Download the PHP package kefyusuf/laravel-bloom-gate without Composer
On this page you can find all versions of the php package kefyusuf/laravel-bloom-gate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kefyusuf/laravel-bloom-gate
More information about kefyusuf/laravel-bloom-gate
Files in kefyusuf/laravel-bloom-gate
Package laravel-bloom-gate
Short Description Production-safe probabilistic query gates for Laravel applications.
License MIT
Informations about the package laravel-bloom-gate
Laravel Bloom Gate
Status: evaluation prerelease — v0.1.0-rc.2 is published on GitHub and Packagist; M6 is implementation-complete.
The first evaluation candidate's preparation is documented in the release readiness record. See the publication record for the first immutable tag and verified source revision. The rc.2 publication record records the latest candidate, seven-target release gate and registry installation.
M6 includes coordinated persistence, prepared writers, explicit adoption/recovery, online rebuild/abort, coordination diagnostics, and Laravel adapters/commands. See the final verification report, full local release matrix, final code review and post-fix checks, Laravel coordinated operation, coordination diagnostics and the M6 work-unit plan.
Laravel Bloom Gate is a production-safe probabilistic query gate for Laravel applications.
It can skip an authoritative existence lookup only when the runtime proves that a Bloom negative is safe to trust. A Bloom positive is never authoritative.
Why
A Bloom filter can answer:
- definitely absent
- maybe present
Laravel Bloom Gate preserves the authoritative datastore as the source of truth:
- definitely absent may skip the authoritative lookup only after every M5 safety precondition passes;
- maybe present always performs the authoritative lookup;
- any safety uncertainty bypasses the optimization and performs the authoritative lookup.
The public exists() result is therefore authoritative-correct.
Design goals
- Laravel 12 and 13.
- PHP 8.3+.
- Greenfield and existing applications as equal use cases.
- Redis-backed production operation.
- Side-effect-free Composer/package discovery.
- Explicit versioned lifecycle: build, shadow, verify, activate, retire.
- Fail-open query optimization.
- Framework-independent Core, Contracts, Lifecycle, Drivers, and Application layers.
- No hidden database interception or observer assumptions.
Install and first filter
PHP 8.3+ and Laravel 12/13 are required. The following installation command
targets the published v0.1.0-rc.2 candidate. Direct Packagist installation is
verified. This remains an evaluation prerelease.
Create app/Bloom/CountryCodeFilter.php:
Add this entry to filters in config/bloom-gate.php:
Keep the Redis driver and configure Laravel's Redis connection. Run:
Application code can now call:
Without a qualified Redis trusted-negative profile, lookups still use the
authoritative source. Declare BLOOM_GATE_REDIS_TRUSTED_NEGATIVE_PROFILE only
after verifying the Redis deployment contract.
The three-value immutable example demonstrates the lifecycle, not a performance
benefit. Change semantic identities when their behavior changes. For mutable
data, follow coordinated writing and recovery
and include every membership-entry writer.
For SQL definitions, normalization must match the authoritative query's equality and collation rules. An exact-byte normalizer with a case-insensitive SQL lookup is unsafe: a differently cased value can exist in SQL while its Bloom bits are absent. Normalize both enumeration and query inputs consistently, or use an appropriate exact-comparison column/query. The package cannot infer this contract.
Optional shared descriptor hints (unreleased)
The development branch supports an optional APCu descriptor cache for the Redis
driver. This feature is not included in the published v0.1.0-rc.2 tag.
Enable it in config/bloom-gate.php after installing/enabling APCu for the PHP
SAPI serving your application:
Use a unique namespace for each application, environment and Redis backend.
The package also includes the application base path, Redis connection name and
Bloom keyspace prefix in the cache namespace. Infrastructure settings are bound
when services are resolved; restart long-lived workers after changing them.
The default driver is none; Memory-backed filters do not use these hints.
A cold lookup resolves the descriptor before probing. A warm lookup performs
one live atomic Redis probe. Only a cached control_state_changed result triggers
one fresh resolution and probe; all other bypasses immediately use the
authoritative source. No membership answers, application definitions or enabled
decisions are cached. Current normalization/source/consistency identities are
checked on every lookup. The TTL (1–86400 seconds) limits retention after the last
successful descriptor resolution; warm reads do not extend it. TTL is not a
safety freshness window: every lookup still validates live Redis state and bits.
Missing/disabled APCu, invalid payloads, eviction or cache write failures use the
normal resolver path.
APCu sharing depends on the SAPI and deployment. Separate containers or FPM masters may have separate caches; Windows uses a cache per process. Benchmark your deployment and hit/miss distribution. Fewer Redis calls do not guarantee lower latency than an inexpensive indexed SQL lookup. See the FPM verification record.
The development branch also executes Redis scripts by their SHA1 digest using
EVALSHA. A missing server-side script triggers one EVAL to execute and cache
the source. Subsequent calls use the digest again. Connection failures and Lua
execution errors do not trigger this fallback. This applies to PhpRedis and
Predis without additional configuration; the published rc.2 does not include it.
Restricted Redis users must allow both EVALSHA and EVAL, as well as the
commands used inside the scripts. An ACL denial does not trigger a retry. Verify
these permissions before upgrading; keep the previous package version available
if the deployment cannot grant them.
Current milestone
M6 — Online Rebuild and Write Coordination — implementation complete
The package is evaluating the published v0.1.0-rc.2 candidate. M6 adds
coordinated prepared writes, explicit adoption, resumable online rebuild/abort,
evidence-bound lease recovery, and read-only coordination diagnostics. Laravel
exposes these capabilities through the facade and Artisan commands.
The rc.2 publication record verifies Redis with MySQL and PostgreSQL consumer commit/rollback and rebuild paths; SQLite remains a reference target. The bounded measurements demonstrate query avoidance without a latency speedup in the measured local workloads. MongoDB and production deployment acceptance remain unverified. No M7 feature scope is currently defined.
Query integration foundation
M5 — Safe Laravel Query Integration
M5 adds the application and Laravel integration required to turn the M4 lifecycle/control plane into a safe query gate:
- explicit framework-neutral
FilterDefinitioncontracts; - deterministic semantic identities and SHA-256 fingerprints;
- deterministic Bloom sizing from capacity + false-positive-rate targets;
- generation-scoped semantic binding;
- managed candidate build, verification, activation, discard, and status workflows;
- two explicit consistency contracts:
immutable-v1andpreadd-v1; - public authoritative-correct
QueryGate::exists(); - Laravel
BloomGatefacade; BloomUniqueandBloomExistsvalidation adapters;- revision-pinned atomic Redis authorized probing;
- fail-open authoritative fallback;
- explicit managed membership synchronization for
preadd-v1; bloom:build,bloom:verify,bloom:activate,bloom:discard,bloom:status;bloom:doctorproduction-safety diagnostics;- executable M5 architecture boundaries.
Query-skip safety boundary
ACTIVE + HEALTHY is necessary but not sufficient to skip an authoritative lookup.
A trusted negative also requires, at minimum:
- query optimization enabled globally and for the filter;
- the current active generation to be the revision-pinned
ACTIVE + HEALTHYgeneration; - valid generation storage and the exact persisted layout;
- bound generation semantics;
- exact runtime/persisted equality for:
- normalization fingerprint;
- authoritative-set fingerprint;
- consistency fingerprint;
- a safe authorized probe result;
- for Redis trusted negatives, explicit declaration of the supported production profile.
If any prerequisite is absent, stale, mismatched, corrupt, unavailable, or changed during the authorized probe, the optimization is bypassed and the authoritative source is queried.
Existing M3 generations without M5 semantic fingerprints are not corrupt. They remain valid low-level Bloom storage, but they are query-skip-ineligible until rebuilt/bound through the M5 managed workflow.
Explicit filter definitions
Each registered filter resolves a framework-neutral FilterDefinition:
Managed sizing is configured with:
- capacity;
- false-positive rate.
The package derives the Bloom layout deterministically with the current M5 sizing policy rather than accepting an arbitrary runtime layout for managed builds.
Consistency contracts
immutable-v1
Use when membership does not change while the generation is active.
Managed synchronization writes are rejected.
preadd-v1
Use when the application can guarantee this ordering for every membership-entry write:
This avoids a committed authoritative-present row appearing before its Bloom bits.
Activation requires an explicit quiescent membership-entry window. During activation the package performs full candidate reconciliation, then fresh verification, then promotion.
Eloquent observers are not considered trusted-negative authority because they do not cover every possible write path.
Laravel-facing API
The facade delegates to the canonical Application services:
add() / addMany() are legacy preadd-v1 synchronization operations.
Adopted coordinated filters fence those operations and use BloomGate::prepare()
before the authoritative write, followed by an explicit commit/abort acknowledgement.
Validation adapters:
They delegate to QueryGate. They do not reimplement query correctness and do not claim Laravel native rule features such as ignore(), arbitrary where(), withoutTrashed(), or onlyTrashed().
Managed lifecycle commands
bloom:build creates a candidate only; it does not silently verify or activate.
bloom:activate always performs fresh verification before promotion. preadd-v1 additionally requires --quiescent and performs reconciliation under that window.
bloom:doctor is read-only preflight/diagnostics. It does not repair Redis configuration or mutate filter lifecycle.
Redis production support
M5 trusted-negative Redis support is intentionally narrow.
The recognized profile declaration is:
The production-safety contract requires the configured connection to remain:
- Redis 8;
- standalone;
- authoritative primary/master;
- AOF enabled;
appendfsync = always;maxmemory-policy = noeviction.
bloom:doctor can verify these observable prerequisites at a point in time. It does not make them continuously true. Keeping the declared profile valid remains an operator responsibility.
Redis Sentinel and Redis Cluster runtime support are not M5 support claims. The keyspace remains same-slot/Cluster-aware by construction, but runtime support requires separate evidence.
Safety principles
- The authoritative datastore remains the source of truth.
- Bloom positives never authorize existence.
ACTIVE + HEALTHYalone never authorizes query skipping.- Semantic compatibility is generation-scoped and exact.
- Infrastructure uncertainty fails open to the authoritative lookup.
- Installation and command discovery do not contact Redis or scan authoritative data.
- Missing/corrupt managed Redis storage is never interpreted as a definite negative.
- Old unbound M3 generations are query-skip-ineligible, not automatically corrupt.
- Observer-based eventual synchronization is not trusted-negative authority.
- Coordinated writes require explicit adoption and durable PREPARED evidence before authoritative visibility; unknown outcomes retain active leases.
- CDC/outbox synchronization, Redis Sentinel, and Redis Cluster runtime support remain outside the implemented scope.
Architecture
See:
- Architecture overview
- Core semantics
- Bloom probe and driver contract
- Normalization
- Consistency
- Lifecycle
- Redis foundation
- Redis keyspace
- Laravel coordinated operation
- Coordination diagnostics
- ADRs
Requirements
Current verified anchors:
- PHP 8.3+;
- Laravel 12 or 13;
- Redis 8 standalone integration;
- PhpRedis-backed Laravel/Testbench execution;
- deterministic Memory reference implementations;
- real Redis generation/control/query-safety integration;
- real Redis production-diagnostics reads.
Predis operational-exception normalization is unit-tested, but real Predis runtime execution is not an official support claim.
Roadmap
- M0: repository/package bootstrap — complete
- M1: core semantic value objects — complete
- M2: memory reference driver and contract suite — complete
- M3: Redis foundation — complete
- M4: lifecycle and verification — complete
- M5: safe Laravel query integration — implementation complete
- M6: online rebuild/write coordination — implementation complete; published evaluation candidate
Contributing
See CONTRIBUTING.md.
Security
See SECURITY.md.
License
MIT.
All versions of laravel-bloom-gate with dependencies
illuminate/console Version ^12.0 || ^13.0
illuminate/contracts Version ^12.0 || ^13.0
illuminate/database Version ^12.0 || ^13.0
illuminate/redis Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0