Module DD-14 — Mastra: Observability Primitives (Native Pattern + Read/Write Memory)

Mastra: Observability Primitives (Native Pattern + Read/Write Memory)

TypeScript-first SDK. Observability as a first-class primitive (native event emission, not a wrapper). Explicit read/write memory tiers. The Module 10 reference (5/5) and the Module 4.3 reference (5/5). The only roster harness where the memory-poisoning defense is structural rather than advisory. 34/60 — the observability-and-memory shape.

60
minutes
8
artifacts
3
sub-sections
Mastra optimizes for observability-first and clean memory abstraction — TypeScript components that emit structured events natively (not via a wrapper), with explicit read/write memory tiers that make write-gating an interface-level decision rather than a policy bolt-on. The native pattern buys three properties: internal decisions are visible, the contract cannot drift, and every consumer gets the same stream. The read/write split makes memory-poisoning defense structural — give the agent the read interface, withhold the write interface, and there is no handle to misuse. Structurally identical to NemoClaw (DD-09)'s credential isolation at a different layer. The cost: no sandbox, smaller community, and you must build against its primitives to get the observability benefit.
Key Claims
Load-Bearing Claims

Observability belongs in the component, not around it. The wrapper pattern (most SDKs, Module 1.4) applies observability externally via withObservability — sees only boundary crossings, can drift out of sync. The native pattern (Mastra) makes emission part of the component contract — component.run(input) returns { result, events[] }, internal decisions visible, contract cannot drift. Converges with DD-21 (Tau) on the same conclusion: events ARE the cross-layer contract.

The explicit read/write memory split makes write-gating interface-level — Module 4.3 reference. Read memory and write memory are separate interfaces (readMemory vs writeMemory). Give an agent the read interface, withhold the write interface. The defense is in the type system, not in a policy layer. Compare to CrewAI (DD-12): crew-scoped shared memory means write-gating unavailable by default.

Mastra's split is structurally identical to NemoClaw's credential isolation. NemoClaw places credentials outside the sandbox's reach — no handle to leak. Mastra withholds the write-memory interface — no handle to poison. Different layers (sandbox credentials vs memory writes), one structural principle: remove the handle, do not write a policy. The strongest defense is architectural, not advisory.

34/60 is the observability-and-memory shape, not the production-readiness shape. Two 5/5 peaks (Module 10 Observability, Module 4.3 Write-gating). Production gaps: Module 5 Sandbox 1/5, Module 9 Verification 1/5, Module 11 Security 2/5. Pair Mastra with a harness that has the security modules (the Agents SDK DD-11 for sandboxing, NemoClaw DD-09 for governance).

After This Module
01
Distinguish the wrapper pattern (observability applied externally) from the native pattern (observability emitted as part of the component contract) and explain why Mastra is the native-pattern reference for Module 10.
02
Articulate the three properties native emission buys (internal decisions visible, contract cannot drift, every consumer same stream) and the cost (you must build against Mastra's primitives).
03
Explain the explicit read/write memory boundary and why it makes Module 4.3 (write-gating) an interface-level decision rather than a policy bolt-on.
04
Score Mastra 34/60 and defend the shape: 5/5 on Module 10 and Module 4.3, but 1/5 on Module 5 (no sandbox) and 2/5 on Module 11 (no security framing).
05
Draw the structural parallel between Mastra's interface-level write boundary and NemoClaw's credential-isolation-outside-the-sandbox boundary: both make a security-relevant decision a type-level one.
Artifacts
01
Teaching Document
Teaching document — the observability thesis (wrapper vs native pattern), what native buys you (three properties), the explicit read/write memory boundary (Module 4.3 reference), the NemoClaw parallel (two interface-level defenses), the 34/60 score profile, the OpenHarness-vs-Mastra axis, anti-patterns, key terms, references
READ
02
Diagrams
7 Mermaid/n8n diagrams — wrapper vs native pattern, what native buys you, explicit read/write memory boundary, the NemoClaw parallel (two interface-level defenses), score profile, the OpenHarness-vs-Mastra observability axis, n8n native emission workflow
READ
03
Slide Deck
11 slides — reveal.js, dark theme, design-system teal; covers the wrapper-vs-native thesis, three native properties, read/write split, NemoClaw parallel, 34/60 score interpretation, OpenHarness-vs-Mastra axis, MLSecOps relevance, three better/three to fix
READ
04
Teaching Script
Verbatim teaching transcript with [SLIDE N] cues, ~2,000 words spoken across 11 slide cues; ends with the Course 1 finale note (all 14 deep-dives complete)
READ
05
Flashcards
22 flashcards (TSV) — mix of recall, application, and analysis; covers the wrapper-vs-native distinction, the three native properties, the read/write split, the NemoClaw parallel, the score shape, the OpenHarness-vs-Mastra axis
TEST
06
Exam
15 questions, 20/40/40 Bloom distribution (3 recall / 6 application / 6 analysis), 70% pass; validated JSON with rationale per question; covers the wrapper-vs-native distinction, the read/write split, the NemoClaw structural parallel, the score shape, the OpenHarness-vs-Mastra observability axis
TEST
07
Lab Spec
Implement both observability patterns (wrapper + native) and both memory architectures (conflated + read/write split) in pure Python — Span/Tracer/with_observability, Event/NativeComponent, ConflatedMemory/PolicyGatedMemory, MastraMemory/ReadOnlyAgent/ReadWriteAgent, SandboxAgent (NemoClaw parallel). Verify the structural defense (~90 min)
DO
08
Module Web Page
Single-file HTML hub
HERE