> Opened by @abhiaiyer91
Valkey thread streams currently retain saved run events until their size
limit or idle TTL. Implement run-scoped trimming so persisted stream
parts can be removed without deleting other runs, pinned entries, or
retained terminal events. Closes#28974.
Before: `await pubsub.trimTopic(topic, { runId })` leaves all entries
behind. After: it removes that run's eligible entries; `producedBefore`
bounds removal to saved parts and `retainTerminalEvents` preserves
terminal markers. Cleanup now snapshots the current stream tail, so
ongoing publishers cannot extend the scan indefinitely or have their
later entries deleted by that scan.
## Proof
- Real-Valkey concurrency regression: pause the cleanup scan, publish
another target-run entry, resume, and assert only the in-flight entry
remains. This test failed before the tail-snapshot fix (`[]` instead of
`['in-flight']`) and passed after it.
- Existing real-Valkey integration covers more than one scan page,
other-run isolation, pinned entries, produced-time cutoff, and retained
terminal events; the targeted integration and lease suite passed (7/7).
- Full `@mastra/valkey-streams` tests passed (8 files, 42 tests);
package typecheck, lint (0 errors/warnings), formatting, diff check, and
ESM/CJS build passed.
- Earlier local Life Coach run with Postgres and Valkey emitted a finish
event and left 2 stream entries with the patched adapter, compared to
117 before.
## Unverified
- The Life Coach stream iterator remained open after finish, so that
isolated run was stopped by timeout; it is not a completed end-to-end
test. No sustained-production-throughput or multi-process soak test was
run.
## Risk: medium
- Trimming is best-effort and run-scoped, but removal is irreversible.
Real-Valkey tests cover the bounded concurrent-publish race and
preservation predicates; production scheduling and very large/live
streams have not been soak-tested.
Patch changeset included for `@mastra/valkey-streams`.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
When a run is saved, Valkey can keep its stream entries around and use
extra storage. This change removes eligible entries for that run while
keeping entries that must remain.
## What changed
- Added `ValkeyStreamsPubSub.trimTopic` to delete entries for a
specified `runId`.
- When `producedBefore` is set, the method deletes only entries with a
numeric `data.producedAt` at or before the cutoff. It skips pinned
entries.
- When `retainTerminalEvents` is enabled, the method preserves
`run-registered`, `run-completed`, `run-failed`, and `run-aborted`
events, except those marked `suspended`.
- The scan stops at the stream tail captured before scanning starts.
Entries published during the scan are not included.
- Trimming failures are logged as warnings and do not propagate.
- Added integration tests for run-specific trimming, cutoff and
pinned-entry behavior, terminal-event retention, and entries published
during a scan.
- Added a patch changeset for `@mastra/valkey-streams`.
## Validation
The supplied report says six Valkey integration tests passed and the
package TypeScript check, lint, and build succeeded. It also reports a
local Postgres and Valkey test that left two stream entries after a
finish event, down from 117. The stream iterator remained open, so a
timeout stopped the isolated process; the Valkey regression suite
completed normally.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
A production Factory deployment ran out of Redis memory. Every key was a
`mastra:topic:*` stream, and almost all of them (3,673 thread streams)
had no expiry. The deployment built `new RedisStreamsPubSub({ url })`
with defaults, and the default `streamIdleTtlMs` was `0`, meaning
streams never expire. Thread streams are open-ended and never get
`clearTopic()`, so they piled up forever. The Redis instance used
`volatile-lru`, which can't evict keys without a TTL, so writes just
started failing.
This PR makes `@mastra/redis-streams` and `@mastra/valkey-streams` give
every stream a sliding 7-day idle TTL by default. Writes refresh it, and
live subscribers keep receiving events after a stream expires because
the read loop recreates it. Streams are an event bus, not storage:
replay history lives in the caching layer and storage, so the backlog
only matters for grouped workers that are offline longer than the TTL.
```ts
// Before: streams never expire unless you opt in
new RedisStreamsPubSub({ url });
// After: 7-day idle TTL by default; opt out explicitly
new RedisStreamsPubSub({ url });
new RedisStreamsPubSub({ url, streamIdleTtlMs: 0 });
```
Both pubsubs now log one warning after they first connect if Redis has
`maxmemory` set with any policy other than `noeviction`. A TTL makes
streams, consumer groups and lease keys evictable under `volatile-*`,
which would silently drop events and leases (ElastiCache defaults to
`volatile-lru`). The check uses `INFO memory` because managed Redis
often blocks `CONFIG GET`.
`memory.deleteThread()` now also deletes the thread's event stream
through the registered Mastra pubsub. This runs fire-and-forget, so
neither deleting a thread nor `memory.settled()` waits on Redis during
an outage. It's skipped on older core versions. Agents configured with
their own pubsub still rely on the TTL.
The docs now require `noeviction`; the Helm guide used to say a
`volatile-*` policy was fine. They also add a runbook for reclaiming
streams created before the TTL: switch to `noeviction`, upgrade the
writers, then expire each stream relative to its last write. Tested
against real Redis/Valkey containers, including a real TTL expiry while
a subscriber is listening and a thread delete with Redis unreachable.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
Redis and Valkey can keep old event streams forever, which uses storage.
This change removes streams after seven days without writes by default
and cleans up a thread’s stream when the thread is deleted.
## What changed
- Redis and Valkey streams now use a sliding seven-day idle TTL by
default. Writes refresh the TTL; reads do not. Set `streamIdleTtlMs: 0`
to disable expiry.
- The read loop recreates an expired stream so a live subscriber can
continue receiving events.
- After connecting, each pubsub warns once when `maxmemory` is enabled
with a policy other than `noeviction`. The check uses `INFO memory`.
- Thread deletion starts best-effort stream cleanup through the
registered Mastra pubsub without waiting for Redis. Older core versions
skip this cleanup.
- Documentation and the local Docker configuration now recommend
`noeviction`. The documentation also explains how to expire existing
streams that lack a TTL.
## Tests
Tests cover TTL behavior, delivery after expiry for live subscribers,
eviction-policy warnings, and thread-stream cleanup. Test execution
results were not provided.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
Refs mastra-ai/platform#2931
Vanta remediation pass for 2026-10-28. It follows #28325, which has
merged.
## 2026-10-28 update
Today's live Vanta export added 3 advisory IDs on `mastra-ai/mastra`
(GitHub/Dependabot). This PR fixes the two that have a published fix and
leaves deepmerge, which has none.
| Package | From → To | Finding | Where | How |
|---|---|---|---|---|
| qs | 6.16.0 → 6.16.1 | CVE-2026-110816 / GHSA-6pq8-jhm2-2vcw (Medium
×4) | root `pnpm-lock.yaml`, 9 `e2e-tests/*` lockfiles,
`scripts/gh-issue-triage/package-lock.json` | Raised the existing floors
`qs@>=6.7.0 <6.16.0: 6.16.0` → `<6.16.1: 6.16.1` and `'qs@<6.7.0':
6.16.0` → `6.16.1`. Raised the npm override in gh-issue-triage. |
| @modelcontextprotocol/node | 2.0.0 → 2.1.1 | GHSA-f897-62hf-6gxq (High
×2; HTTP transports had no body-size or batch-length limit) | root
`pnpm-lock.yaml` (published `@mastra/mcp` 1.18.0, used as `mcp-legacy`),
`scripts/gh-issue-triage/package-lock.json` | New pnpm override
`'@modelcontextprotocol/node@>=2.0.0 <2.1.0': 2.1.1` and a new npm
override in gh-issue-triage. I used 2.1.1 rather than 2.1.2 because
2.1.2 needs a `@modelcontextprotocol/server` peer of `^2.4.0`, while
`@mastra/mcp` 1.18 resolves server 2.3.1. `packages/mcp` itself already
uses node 2.1.2. |
- Both versions are older than the 1-day `minimumReleaseAge`: qs 6.16.1
was published 10-14 and node 2.1.1 on 10-02. I did not use qs 6.16.2
(10-27), which is too new.
- No floors or overrides were removed; existing ones were only raised.
- `pnpm install --frozen-lockfile --lockfile-only` passes at the root.
Each nested e2e workspace was regenerated with `pnpm install
--lockfile-only`.
- Added the empty changeset
`.changeset/vanta-2026-10-28-security-floors.md`. No published package
changes.
- After this change, osv-scanner over all 33 lockfiles reports only the
documented leftovers:
- zod 3.25.76 (zod v3 compat line on purpose)
- ai 4.3.19 / `@ai-sdk/provider-utils` 2.2.8 (vendored v4 line)
- `@azure/msal-node` 5.6.0 / 6.0.1 (fix 7.1.0 needs majors in identity
and teams)
- `@opentelemetry/core` 1.30.1 (needs pubsub 6)
- extract-zip 2.0.1 (no patched release)
- deepmerge 4.3.1 (CVE-2026-93753 / GHSA-gcqx-w48m-w2h4; no patched
release, 4.3.1 is the latest)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
This PR updates dependency rules and package versions to use newer
releases, including security fixes for `qs` and
`@modelcontextprotocol/node`. It also updates AI SDK dependencies and
does not include published package changes.
## Summary
- Raise the `qs` override target to `6.16.1` in the root and e2e
workspaces and in `scripts/gh-issue-triage`.
- Add an `@modelcontextprotocol/node` override at `2.1.1` in the root
workspace and `scripts/gh-issue-triage`.
- Update AI SDK dependency versions across package manifests and add a
changeset describing the provider-utils update.
- Add an empty changeset for the security-only dependency updates.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Update 2026-10-28 (afternoon)
- Merged origin/main (clean).
- Bumped the AI SDK v5 compat line from @ai-sdk/provider-utils 3.0.41 to
3.0.42 (patch, published 2026-10-21; it blocks `.internal` hostnames in
download URL validation and encodes provider-returned IDs in request
paths). This addresses the Aikido /mastra Highs AIKIDO-2026-10990 and
AIKIDO-2026-10981:
- ai 5.0.277 → 5.0.282, @ai-sdk/gateway 2.0.168 → 2.0.173 (vendored
ai_v5)
- anthropic 2.0.109 → 2.0.110, google 2.0.103 → 2.0.106, groq 2.0.58 →
2.0.59, openai 2.0.135 → 2.0.137, openai-compatible 1.0.58 → 1.0.59, xai
2.0.99 → 2.0.100
- Nested lockfiles updated: memory/integration-tests and
playground/e2e/kitchen-sink.
- No new overrides. Changeset:
`vanta-2026-10-28-ai-sdk-v5-provider-utils.md`.
> Opened by @user_01KN4T0VBWE4X5GKHXP2RCP40M
## What
`@mastra/inngest` (reported in #28120) was published without a `license`
field, so npm reported it as "Unlicensed" to license scanners even
though the tarball ships `LICENSE.md` with Apache-2.0. Auditing the repo
showed 12 publishable packages in the same state, not just Inngest.
This PR:
1. Adds `"license": "Apache-2.0"` to every affected manifest:
- `@mastra/inngest`
- `@mastra/editor`
- `@mastra/google-cloud-pubsub`, `@mastra/redis-streams`,
`@mastra/valkey-streams`
- `@mastra/cloudflare-d1`, `@mastra/couchbase`, `@mastra/dynamodb`,
`@mastra/elasticsearch`, `@mastra/lance`, `@mastra/mongodb`,
`@mastra/opensearch`
2. Teaches `.github/scripts/validate-pkg-json.mjs` to validate the field
for every package it already checks: missing license or a value other
than `Apache-2.0` fails the `Validate package.json files` CI job.
3. Ships one changeset (`patch` for all 12 packages) describing the
`package.json` update.
The validator's existing scope is unchanged: private packages, the
ignore list, and non-published templates/fixtures are still skipped.
Fixes#28120
## Proof
```
$ node .github/scripts/validate-pkg-json.mjs
✅ All checked package.json files passed validation.
Total: 160 files
```
Negative test — removing the new `license` field from
`workflows/inngest/package.json` and re-running:
```
❌ /workspace/mastra/workflows/inngest/package.json: missing license field
exit=1
```
Restoring the field returns the validator to `exit=0`, proving the check
is what fails rather than an unrelated error.
`npx prettier --check` passes on all changed files.
## Unverified
- `npm view @mastra/inngest license` only reflects the fix after the
next release publishes.
## Risk
low — metadata-only manifest changes plus a CI script check.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
This change adds a clear license label to 12 packages. It also updates a
check that warns if a checked package is missing that label or uses a
different one.
## Summary
- Added `"license": "Apache-2.0"` to 12 package manifests.
- Updated `.github/scripts/validate-pkg-json.mjs` to reject checked
packages when the license field is missing or does not match
`Apache-2.0`. The validator’s existing package scope remains unchanged.
- Added a changeset that declares patch releases for 13 `@mastra`
packages.
## Validation
The author reports that the validator passes for 160 files, and that
removing the license field from `workflows/inngest/package.json`
produces an error and exit code 1. The author also reports that Prettier
checks pass on all changed files. Published npm metadata has not been
verified; it will reflect this change after a release.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
Lint now requires `import type` for imports used only as types, as
`oxlint.config.ts` always intended. The two rules have matched no files
since mastra-ai/mastra#20173 broke their override's glob, so the repo
drifted into mixing `import { type X }`, `import { X }` for types, and
`import type`. This turns them back on and fixes the existing imports.
No runtime behavior changes.
## What changed
- `import/consistent-type-specifier-style` and
`typescript/consistent-type-imports` go from `off` to `error`.
- 186 files: type-only imports become `import type { … }`, split from
value imports where a statement had both. Done with `oxlint --fix` plus
6 files the fixer left with inline `type` specifiers, then `oxfmt`.
- `disallowTypeAnnotations` is now `false`: `typeof import('x')` is
already type-only, and 97 of its 112 uses are the
`vi.importActual<typeof import('./x')>()` pattern in tests.
## Could this change behavior?
Only where a package keeps imports at runtime (`verbatimModuleSyntax`,
via `tsconfig.node.json`) and a statement became fully `import type`,
since that drops the module load. That happens in 18 places: 11 in
tests, and in source `GithubAppIdentity` (factory), `Workspace`,
`SpanType`, `Knowledge` and `WORKSPACE_TOOLS` (core), `Observable` from
`rxjs` (nestjs), and `zod` / `@mastra/mcp` in the server adapter test
suite. None of those modules run code at load time.
## Scope
The other rules the broken glob turned off (`no-unused-vars`,
`no-console`/`no-debugger`, `ban-ts-comment`, `no-require-imports`, the
test-file import ban) stay off for their own PRs.
## Testing
1. `pnpm lint`: passes (the 13 `only-export-components` warnings are
already on `main`).
2. `pnpm turbo build` for the 34 changed packages and `typecheck` for
the ones that have it: pass.
3. The test files that lost a runtime import: pass (core, server,
observability, factory, voice).
> Opened by @abhiaiyer91
Fixes#24589
## Problem
Evented workflow events are acked only after the handler finishes. If a
step takes longer than the broker's visibility/idle deadline (for
example, Redis/Valkey `reclaimIdleMs`), the broker redelivers the
`workflow.step.run` event to another worker, and the step runs twice at
the same time.
## Changes
- **Heartbeat contract**: `EventCallback` gets an optional 4th
`extend()` argument. `OrchestrationWorker` calls it on an interval
(`leaseRenewIntervalMs`, default 10s) while it handles an event, and
clears the interval when the handler finishes.
- **Step fence**: `WorkflowEventProcessor` claims a `LeaseProvider`
lease for each `workflow.step.run` event and renews it while the step
runs. If another delivery of the same event arrives while the lease is
held, it is acked and dropped. On failure the lease is released so a
retry can run. Backends without lease support keep their current
behavior.
- **Redis/Valkey Streams**: implement `extend` with `XCLAIM … JUSTID` to
reset the entry's idle time. It also pushes back the local
`inFlightTimeoutMs` deadline.
- GCP Pub/Sub needs no change because its client extends ack deadlines
automatically.
Steps should still be idempotent. A worker crash can still cause a step
to run again.
## Test plan
- New `step-run-fence.test.ts`: a redelivery that arrives while a slow
step is running is dropped; the lease is released on failure.
- New `worker.test.ts` case: the worker calls `extend` repeatedly during
a long handler, acks once, and stops the timer afterward.
- New Redis reclaim integration test: a sibling consumer does not
reclaim an entry whose handler keeps extending it.
- core `src/worker` + `src/workflows/evented`: 387 passed. redis-streams
`reclaim` + `pubsub`: 50 passed.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
If a workflow step takes a long time, the message that started it can
expire and be sent to another worker. This change keeps the message
active and uses a lease to prevent another worker from running the same
step at the same time.
## Summary
- Adds an optional `extend` callback to event handlers and passes it
through the pull transport.
- Renews supported event-delivery leases while `OrchestrationWorker`
processes an event. The interval defaults to 10 seconds and must be
positive and finite when configured.
- Fences identified `workflow.step.run` events with a lease keyed by run
ID and event ID. A duplicate with an active lease is acknowledged
without running; failed runs release the lease so a retry can proceed.
- Adds ownership-checked Redis Streams and Valkey Streams heartbeats.
These refresh the pending entry’s idle time only while the current
consumer still owns it.
- Adds tests for worker heartbeats, step-run fencing, and Redis Streams
heartbeat behavior.
Backends without lease support do not receive delivery heartbeats, and
lease-acquisition errors fall back to running the step without a fence.
A worker crash can still lead to a rerun, so steps should remain
idempotent. Test results were not provided.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Abhi Aiyer <abhiaiyer91@gmail.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>