Skill: TraceMem Overview and Mental Model
Purpose
This skill provides the foundational mental model for using TraceMem. It explains what TraceMem is, why an agent should use it, and how to think about its core primitives: Decision Envelopes and Decision Traces.
When to Use
- When you are an AI agent performing actions that affect the real world (reading private data, changing state, spending money).
- When you need to prove why you did something to a human or auditor.
- When you encounter instructions to "use TraceMem", "open a decision", or "check policy".
- When you need to persist memory or context across different execution sessions (TraceMem is your long-term memory).
When NOT to Use
- For scratchpad operations, intermediate chain-of-thought, or temporary variable storage that does not need audit.
- For purely internal data processing that has no external side effects and strictly public data.
- When low-latency (<10ms) direct database access is required (TraceMem adds governance overhead).
Core Rules
- TraceMem is the Courtroom: You are the agent/defendant. You must present evidence (reads), cite laws (policies), and record your verdict (outcome).
- All Actions Require a Decision: You cannot read or write governed data without first opening a Decision Envelope.
- You are Untrusted: TraceMem assumes you (the agent) might hallucinate or be compromised. You must explicitly log your reasoning and prove your actions are safe.
- Traces are Forever: Everything you do in TraceMem is recorded in an immutable append-only trace. Do not store secrets or PII in purpose fields or context summaries.
Quick Start Workflow
CRITICAL: Decision Envelope is MANDATORY
The Decision Envelope is NOT optional. ALL TraceMem operations MUST happen within a decision envelope:
- ✓ Reading data (
decision_read) - ✓ Writing data (
decision_write- insert/update/delete) - ✓ Evaluating policies (
decision_evaluate) - ✓ Requesting approvals (
decision_request_approval)
You CANNOT perform any of these operations without an active decision_id.
Basic Workflow (Read Data Example)
Here's the exact sequence for reading customer data:
Step 1: Create Decision Envelope
Tool: decision_create
Parameters:
- intent: "customer.lookup.support"
- automation_mode: "autonomous" (must be: propose, approve, override, or autonomous)
Returns: decision_id (e.g., "TMEM_abc123...")
Step 2: Get Product Metadata (Discovery - does NOT require decision envelope)
Tool: product_get
Parameters:
- product: "customers_v1"
Returns: Product metadata including:
- exposed_schema: field names and types
- allowed_purposes: valid purposes for this product
- example_queries: sample query structures
Note: This gets INFORMATION ABOUT the product, not the actual data
Step 3: Read Actual Data (REQUIRES decision_id from Step 1)
Tool: decision_read
Parameters:
- decision_id: "TMEM_abc123..." (from Step 1)
- product: "customers_v1"
- purpose: "support_context" (must be in allowed_purposes from Step 2)
- query: {"customer_id": "1001"} (use field names from schema in Step 2)
Returns: Actual customer records/data from the database
Step 4: Close Decision Envelope (REQUIRED)
Tool: decision_close
Parameters:
- decision_id: "TMEM_abc123..." (from Step 1)
- action: "commit" (or "abort" if cancelled)
OpenCode vs Core MCP Tools
OpenCode Convenience Tools (in OpenCode plugin):
tracemem_open→ convenience wrapper fordecision_createwith action mappingtracemem_note→ convenience wrapper fordecision_add_context
Core MCP Tools (always available):
decision_create,decision_read,decision_write,decision_evaluate,decision_request_approval,decision_closedecision_record-- record a complete decision in one shot (no data operations needed)decision_search-- search previous decisions by text, category, or tagsproducts_list,product_get,capabilities_get
Important: Even when using OpenCode convenience tools, the same rules apply - all operations must be within a decision envelope.
Correct Usage Pattern
- Start with a Decision: Before doing any work, you MUST open a "Decision Envelope" using
decision_create. This is your mandatory workspace container. - Discover Data Products: Use
products_listto find available data products andproduct_getto get metadata about a specific product (schema, purposes). These discovery tools do NOT require a decision envelope. - Access Actual Data: Use
decision_readto read actual data records ordecision_writeto insert/update/delete data. You do not use SQL or API calls directly. ALL data access requires the decision_id from step 1. - Check Policies: You check if your intended action is allowed by evaluating "Policies" using
decision_evaluate(requires decision_id). - Respect Approvals: If a policy requires human approval, you pause and wait using
decision_request_approval(requires decision_id). You never bypass denials. - Close the Decision: When finished, you MUST call
decision_closewith "commit" (if successful) or "abort" (if stopped/cancelled).
Common Mistakes
- Treating TraceMem as a database: It is not a generic database; it is a governance log with attached storage.
- Skipping the Decision Envelope: Trying to read/write data without an active
decision_idwill FAIL. The decision envelope is MANDATORY. - Thinking you have authority: You (the agent) never authorize actions. You request them. Policies and humans authorize them.
- Attempting operations outside decision envelope: Operations like
decision_read,decision_write,decision_evaluate, anddecision_request_approvalREQUIRE an active decision_id. You CANNOT call them without first callingdecision_create.
Safety Notes
- Immutable Record: Never put sensitive credentials (API keys, passwords) into any TraceMem field (intent, purpose, context). These records are often readable by broad audiences for audit.
- Governance Layer: Do not try to bypass TraceMem to "save time". All bypassed actions are unauditable and effectively "rogue" behavior.