Skip to content

Commit 835ae00

Browse files
author
Presta
committed
feat(F37-TRACE-003): data model integration for traces layer
- Add trace.schema.json: Traces layer schema (id, sprint_id, lm_calls array, cost/latency, status) - Add model/traces.json: Initial traces layer (empty) - Register traces_router in api/routers/layers.py - Add traces imports/registration in api/server.py - GET /model/traces/ - list all traces (paginated) - GET /model/traces/{correlation_id} - retrieve single trace - PUT /model/traces/{correlation_id} - upsert trace (auto row versioning, audit fields) - DELETE /model/traces/{correlation_id} - soft delete - Verified endpoints with test trace: PUT + GET + LIST all OK (200 responses) - Cosmos persistence enabled (ACA production) + MemoryStore (local dev) - Ready for lm_tracer output persistence (Phase 3 complete)
1 parent 9e538be commit 835ae00

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed

api/routers/layers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@
4141
milestones_router = make_layer_router("milestones", "/model/milestones", ["milestones"])
4242
risks_router = make_layer_router("risks", "/model/risks", ["risks"])
4343
decisions_router = make_layer_router("decisions", "/model/decisions", ["decisions"])
44+
traces_router = make_layer_router("traces", "/model/traces", ["traces"])

api/server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ async def dispatch(self, request: Request, call_next):
252252
# project plane (E-07/E-08)
253253
projects_router, wbs_router,
254254
sprints_router, milestones_router, risks_router, decisions_router,
255+
traces_router,
255256
)
256257
from api.routers.fp import router as fp_router # noqa: E402
257258
from api.routers.filter_endpoints import router as endpoints_router
@@ -275,6 +276,7 @@ async def dispatch(self, request: Request, call_next):
275276
# project plane
276277
projects_router, wbs_router,
277278
sprints_router, milestones_router, risks_router, decisions_router,
279+
traces_router,
278280
fp_router,
279281
# graph (E-11)
280282
graph_router,

model/traces.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "../schema/trace.schema.json",
3+
"traces": []
4+
}

schema/trace.schema.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "trace.schema.json",
4+
"title": "EVA LM Trace",
5+
"description": "End-to-end trace of LM calls from a single correlation_id. Captures model, tokens, cost, and latency per call. Partition key for Cosmos: correlation_id.",
6+
"type": "object",
7+
"required": ["id", "sprint_id", "created_at", "status"],
8+
"additionalProperties": false,
9+
"properties": {
10+
"id": {
11+
"type": "string",
12+
"description": "Correlation ID, format: SPRINT-{sprint_id}-{timestamp}-{uuid[:8]}",
13+
"examples": ["SPRINT-0.5-20260301143021-a1b2c3d4"]
14+
},
15+
"sprint_id": {
16+
"type": "string",
17+
"description": "Reference to sprint.id from sprints layer"
18+
},
19+
"story_id": {
20+
"type": ["string", "null"],
21+
"description": "Story/bug ID being traced, e.g. BUG-F37-001"
22+
},
23+
"phase": {
24+
"type": ["string", "null"],
25+
"enum": ["A", "B", "C", null],
26+
"description": "Bug fix phase: A=RCA, B=Code, C=Prevention. Null if multi-phase aggregate."
27+
},
28+
"created_at": {
29+
"type": "string",
30+
"format": "date-time",
31+
"description": "When trace was created (RFC3339)"
32+
},
33+
"lm_calls": {
34+
"type": "array",
35+
"description": "Array of LM interactions",
36+
"items": {
37+
"type": "object",
38+
"required": ["model"],
39+
"properties": {
40+
"model": {
41+
"type": "string",
42+
"enum": ["gpt-4o", "gpt-4o-mini", "claude-3-opus", "claude-3-haiku"],
43+
"description": "Model called"
44+
},
45+
"tokens_in": {
46+
"type": ["integer", "null"],
47+
"description": "Input tokens consumed"
48+
},
49+
"tokens_out": {
50+
"type": ["integer", "null"],
51+
"description": "Output tokens generated"
52+
},
53+
"cost_usd": {
54+
"type": ["number", "null"],
55+
"description": "Cost in USD (8 decimal places)"
56+
},
57+
"latency_ms": {
58+
"type": ["integer", "null"],
59+
"description": "API call latency in milliseconds"
60+
}
61+
}
62+
}
63+
},
64+
"total_cost_usd": {
65+
"type": ["number", "null"],
66+
"description": "Sum of all LM call costs (USD, 8 decimals)"
67+
},
68+
"total_latency_ms": {
69+
"type": ["integer", "null"],
70+
"description": "Sum of all LM call latencies (ms)"
71+
},
72+
"status": {
73+
"type": "string",
74+
"enum": ["active", "archived", "failed"],
75+
"description": "Trace lifecycle: active (current), archived (>90d), failed (error during collection)"
76+
},
77+
"is_active": {
78+
"type": "boolean",
79+
"description": "Whether this trace is queryable (false after archival)"
80+
},
81+
"notes": {
82+
"type": ["string", "null"],
83+
"description": "Operator notes or error messages"
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)