Commit 307573b
## Summary
Follow-up to #17836. Picks up three reviewer comments that landed after
the merge:
- **`Mastra` TTL sweep warning** — When the run-scoped workflow TTL
sweep evicts a registration that was still live, log a warning with
`runId` / `ageMs` / `ttlMs` so abandoned suspended runs are visible in
operator logs instead of disappearing silently. (Comment: P3 follow-up.)
- **`codec.ts` regex-injection suppression** — The `//
lgtm[js/regex-injection]` comment in `decodeRegExpEnvelope` now spells
out the three structural gates that justify the suppression —
`isEnvelope`'s source-length cap + flag whitelist, the local
re-narrowing in `decodeRegExpEnvelope`, and the `try/catch` fallback —
plus an explicit "do not 'fix' by escaping" warning. A future reader
looking only at that screen no longer has to scroll back up to
`isEnvelope` to understand why this is safe.
(#17836 (comment))
- **`evented-unix-pubsub` scenario test** — Allocates the
`UnixSocketPubSub` socket under a short `/tmp/aim-*` directory instead
of `os.tmpdir()`, so the path stays under macOS's 104-byte `sun_path`
limit. (Nit follow-up.)
The three other reviewer comments (`DefaultStepResult` codec
registration, `MAX_REGEXP_SOURCE_LENGTH` constant use,
`hydrate-run-scope` skip-list comment, and the `__m_codec__` reservation
doc) were already handled in the merged PR.
## Test plan
- `pnpm --filter ./packages/core exec vitest run
src/mastra/run-scope.test.ts
src/loop/test-utils/aimock/scenarios/evented-unix-pubsub.scenario.test.ts
src/events/codec` → 70 passed, no type errors
- `pnpm --filter ./packages/core check` → clean
🤖 Generated with [Mastra Code](https://mastra.ai)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
This PR adds three improvements to Mastra's workflow system: (1) it now
tells operators when old workflow runs are automatically cleaned up
instead of silently disappearing, (2) it adds better documentation
explaining why certain security-risky code patterns are actually safe,
and (3) it fixes socket file paths to work properly on macOS where
there's a strict limit on how long paths can be.
---
## Changes
### TTL Sweep Logging Enhancement
Added warning log messages to `Mastra#sweepStaleRunScopedWorkflows` that
are emitted when the TTL sweep evicts stale run-scoped workflow
registrations. The warning includes the `runId`, computed `ageMs`, and
`ttlMs` value, making abandoned suspended runs visible in operator logs.
A corresponding test case was added to verify this logging behavior.
### Regex-Injection Suppression Documentation
Expanded the inline documentation in `decodeRegExpEnvelope` within
`codec.ts` to explicitly document the three structural safety gates that
justify the `// lgtm[js/regex-injection]` suppression:
- `isEnvelope`'s source-length cap and flag whitelist
- Local re-narrowing of `source` and `flags` within
`decodeRegExpEnvelope`
- The `try/catch` fallback mechanism
The documentation also includes an explicit warning against attempting
to fix the issue by escaping characters.
### Unix Socket Path Adjustment
Modified the `evented-unix-pubsub` scenario test to allocate Unix
sockets under a short `/tmp/aim-*` directory created at test time,
instead of using `os.tmpdir()`. This ensures socket paths stay within
macOS's 104-byte `sun_path` limit. The test now uses `mkdtempSync` and
`rmSync` to manage temporary directories, with cleanup occurring in
`afterEach`.
### Changeset Documentation
Added a patch-level changeset for `@mastra/core` documenting all three
follow-up items.
---
## Testing
- 70 tests passed with no type errors
- Package check completed cleanly
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Mastra Code (anthropic/claude-opus-4-7) <noreply@mastra.ai>
1 parent 1556acd commit 307573b
5 files changed
Lines changed: 59 additions & 4 deletions
File tree
- .changeset
- packages/core/src
- events/codec
- loop/test-utils/aimock/scenarios
- mastra
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
| |||
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
33 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2771 | 2771 | | |
2772 | 2772 | | |
2773 | 2773 | | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
2774 | 2783 | | |
2775 | 2784 | | |
2776 | 2785 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
219 | 239 | | |
220 | 240 | | |
221 | 241 | | |
| |||
0 commit comments