r2luna/brain
Brain is an AI agent framework for Laravel. Build LLM-powered agents with tools, memory, and multi-step workflows using simple PHP classes, then connect them to your app's data, services, and existing Laravel features.
Architecture fit
brain), not a feature release. Its primary value is closing #[Sensitive] redaction leaks, which previously exposed declared sensitive values through: earlier/skipped/cancelled workflow events, validation errors, nested workflow boundaries, exception messages in failure events, brain:run console output, previews/result tables/run history, and VarDumper dumps.#[Sensitive] values are now encrypted with APP_KEY at queue time. This moves the package from "redacted at the edges" to "protected at rest in the queue," which is a meaningful defense-in-depth improvement but introduces a new hard dependency on key management.Workflow/Process/brain:show split into smaller methods, pre-commit gates on cyclomatic complexity (max 10) and CRAP (max 30), and 100% test coverage required. For a package handling sensitive data, enforced quality gates reduce long-term maintenance risk.Integration feasibility
SensitiveValue payloads queued before encryption remain readable, so there is no queue-drain requirement before upgrading.APP_KEY is rotated after upgrading, the old key must remain in APP_PREVIOUS_KEYS until all jobs queued under it are processed. Teams that rotate keys on a schedule, or that share a single APP_KEY across services, need to confirm their rotation runbook supports this.#[Sensitive] behavior, #[OnQueue], and brain:migrate are documented in the README, docs site, and Boost guidelines.Technical risk
brain:run history. Upgrading stops new leaks but does not remediate existing ones. This requires a separate log-hygiene review and possible purge/rotation of any credentials that were exposed.APP_KEY without APP_PREVIOUS_KEYS populated will render queued sensitive payloads undecryptable, and jobs will fail at processing time — potentially after a delay, and potentially in a batch. This is a self-inflicted outage vector for teams with automated rotation.rules() now validates real values. Validation semantics change: rules are applied to the decrypted value rather than a redacted placeholder. This is correct, but it may surface previously-passing payloads as failing, and it changes the shape of validation errors.#[Sensitive] inherited from parent classes, user.password) broaden coverage; the risk here is over-redaction of fields teams expected to inspect, not under-redaction.Key questions
#[Sensitive], and does the new workflow-wide scoping over-redact anything our support or on-call teams depend on?brain:run history by pre-4.1.4 versions, and what is our remediation plan (purge, credential rotation, retention policy change)?APP_KEY rotation policy include APP_PREVIOUS_KEYS, and how long do we retain old keys relative to our maximum queue latency?#[Sensitive] annotation review as a recurring control, so that new workflow actions are annotated at authoring time rather than after a leak?rules() sees real values?Stack fit
brain: no new infrastructure, no new service dependency. The encryption path uses APP_KEY, which the application already manages, so there is no new secret store to stand up.#[Sensitive] get little immediate benefit but also no cost; teams using it get substantial benefit. Gauge value by counting #[Sensitive] declarations in the codebase.Migration path
APP_PREVIOUS_KEYS is wired into the runtime config and document the retention window. If APP_PREVIOUS_KEYS is not currently configured, add it in the same change set as the version bump.#[Sensitive] is applied at the level where inheritance and dot notation actually cover the fields you intend (user.password rather than a broad user), and verify nested workflows inherit as expected.Compatibility
SensitiveValue payloads remain readable. No queue drain required.composer.json and CI.Sequencing
APP_PREVIOUS_KEYS and confirm the key-retention policy; inventory #[Sensitive] usage across workflows.brain:run history for sensitive values emitted by earlier versions; scope remediation.#[Sensitive] payload, rotates the key, and processes the job with the old key present.brain:run console output. Check that rules() validation still passes on real values.#[Sensitive] on new workflow action inputs, so coverage does not regress.Maintenance
APP_PREVIOUS_KEYS must be curated. Old keys should be removed only after the longest possible queue latency plus retry/backoff has elapsed. This is a small but permanent runbook entry.#[Sensitive] must be maintained as workflows evolve, and inheritance/dot-notation rules must be understood by whoever edits workflow definitions.Support
brain:run masks values in previews, result tables, and run history. Expect some "I can't see the value anymore" tickets in the first weeks; set expectations before deploy.brain:run now use hidden input, which changes interactive operator behavior — worth a short internal note for anyone who runs commands manually in production.Scaling
#[Sensitive].Failure modes
APP_PREVIOUS_KEYS: queued sensitive values become undecryptable; jobs fail at processing time, possibly hours after enqueue and potentially across a whole batch. Highest-severity new failure mode.rules() now sees real values, so previously-tolerated payloads may begin failing validation; failures are redacted, so diagnosis requires the workflow/job ID.Ramp-up
APP_PREVIOUS_KEYS) and one documentation pass; estimate one to two days for a small team including the exposure review, and add time if log remediation is in scope.#[Sensitive] model (workflow-wide scoping, inheritance, dot notation), #[OnQueue] behavior, and brain:migrate. The newly expanded README, docs site, and Boost guidelines materially reduce this — onboarding a new engineer to authoring workflows is now realistic in a few days, though truly safe usage still requires the team to agree on what counts as sensitive.#[Sensitive], how APP_PREVIOUS_KEYS is managed, and how to troubleshoot redacted failures via correlation IDs. That document is roughly a half-day of effort and prevents the most likely operational failures.How can I help you explore Laravel packages today?