@jungjaehoon/mama-core 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ -- Migration 061: tool_traces.failure_code — carry the thrower's closed cause.
2
+ --
3
+ -- WHY 061, NOT 043: live DBs carry schema_version rows 44-60 from a RETIRED
4
+ -- 2026-05/06 migration chain that shared this ledger table. The runner skips
5
+ -- any file numbered at or below MAX(version), so this migration shipped as
6
+ -- 043 in core 2.1.0 and silently never applied anywhere the retired chain
7
+ -- had run. New core migrations must number ABOVE that ceiling (60) - the
8
+ -- migration-chain test pins the jump so nobody "fixes" the gap back into
9
+ -- the dead zone.
10
+ --
11
+ -- The failure choke already emits a structured code (envelope_missing,
12
+ -- context_compile_scope_denied, ...) and the sanitizer explicitly preserves
13
+ -- it; the trace INSERT was the one place that dropped it, leaving only
14
+ -- `gateway_tool_failed;sha256=...` digests (measured 2026-07-30: the dominant
15
+ -- digest covered 52% of 2,460 context_compile failures with no name).
16
+ -- Nullable on purpose: a failure without a code stays NULL — labels are
17
+ -- carried, never invented.
18
+
19
+ ALTER TABLE tool_traces ADD COLUMN failure_code TEXT;
@@ -58,6 +58,7 @@ function mapToolTraceRow(row) {
58
58
  execution_status: nullableString(row.execution_status),
59
59
  duration_ms: requiredNonNegativeInteger(row.duration_ms, 'duration_ms'),
60
60
  envelope_hash: nullableString(row.envelope_hash),
61
+ failure_code: nullableString(row.failure_code),
61
62
  created_at: requiredInteger(row.created_at, 'created_at'),
62
63
  };
63
64
  }
@@ -70,7 +71,8 @@ function selectToolTrace(adapter, id) {
70
71
  .prepare(`
71
72
  SELECT
72
73
  trace_id, model_run_id, gateway_call_id, tool_name, input_summary,
73
- output_summary, execution_status, duration_ms, envelope_hash, created_at
74
+ output_summary, execution_status, duration_ms, envelope_hash, failure_code,
75
+ created_at
74
76
  FROM tool_traces
75
77
  WHERE trace_id = ?
76
78
  `)
@@ -89,11 +91,12 @@ async function appendToolTrace(input) {
89
91
  .prepare(`
90
92
  INSERT INTO tool_traces (
91
93
  trace_id, model_run_id, gateway_call_id, tool_name, input_summary,
92
- output_summary, execution_status, duration_ms, envelope_hash, created_at
94
+ output_summary, execution_status, duration_ms, envelope_hash, failure_code,
95
+ created_at
93
96
  )
94
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
97
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
95
98
  `)
96
- .run(id, modelRunId, nullableString(input.gateway_call_id), toolName, nullableString(input.input_summary), nullableString(input.output_summary), nullableString(input.execution_status), normalizeDuration(input.duration_ms), nullableString(input.envelope_hash), normalizeTimestamp(input.created_at));
99
+ .run(id, modelRunId, nullableString(input.gateway_call_id), toolName, nullableString(input.input_summary), nullableString(input.output_summary), nullableString(input.execution_status), normalizeDuration(input.duration_ms), nullableString(input.envelope_hash), nullableString(input.failure_code), normalizeTimestamp(input.created_at));
97
100
  return selectToolTrace(adapter, id);
98
101
  }
99
102
  async function listToolTracesForRun(modelRunId) {
@@ -103,7 +106,8 @@ async function listToolTracesForRun(modelRunId) {
103
106
  .prepare(`
104
107
  SELECT
105
108
  trace_id, model_run_id, gateway_call_id, tool_name, input_summary,
106
- output_summary, execution_status, duration_ms, envelope_hash, created_at
109
+ output_summary, execution_status, duration_ms, envelope_hash, failure_code,
110
+ created_at
107
111
  FROM tool_traces
108
112
  WHERE model_run_id = ?
109
113
  ORDER BY created_at DESC, rowid DESC
@@ -52,6 +52,8 @@ export interface AppendToolTraceInput {
52
52
  execution_status?: string | null;
53
53
  duration_ms?: number | null;
54
54
  envelope_hash?: string | null;
55
+ /** Thrower's closed cause (e.g. envelope_missing). Carried, never invented. */
56
+ failure_code?: string | null;
55
57
  created_at?: number;
56
58
  }
57
59
  export interface ToolTraceRecord {
@@ -64,6 +66,7 @@ export interface ToolTraceRecord {
64
66
  execution_status: string | null;
65
67
  duration_ms: number;
66
68
  envelope_hash: string | null;
69
+ failure_code: string | null;
67
70
  created_at: number;
68
71
  }
69
72
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jungjaehoon/mama-core",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "MAMA Core - Shared modules for Memory-Augmented MCP Assistant",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",