Skip to content

feat(trace): event types, recorder, and reader for runtime store#48

Merged
leo-aa88 merged 2 commits into
mainfrom
issue/14-trace-recorder
Apr 11, 2026
Merged

feat(trace): event types, recorder, and reader for runtime store#48
leo-aa88 merged 2 commits into
mainfrom
issue/14-trace-recorder

Conversation

@leo-aa88
Copy link
Copy Markdown
Member

What was added

File Role
internal/trace/events.go Event alias for state.TraceEvent; constants EventRunStarted, EventRunFinished, EventStepStarted, EventStepFinished, EventStepFailed, EventToolCalled, EventToolCompleted, EventModelCalled, EventModelCompleted, EventPolicyDenied.
internal/trace/recorder.go Recorder with Append(ctx, runID, stepID, typ string, data map[string]any) → JSON data_json, optional Clock for tests. Calls GetRun first; on sql.ErrNoRows returns fmt.Errorf(..., %w, ErrRunNotFound). Validates non-empty run_id and type.
internal/trace/reader.go Reader.ListByRunIDRuntimeStore.ListTraceEventsByRunID.
internal/trace/recorder_test.go SQLite-backed tests (see below).
internal/trace/doc.go Short package note about run existence check.

Acceptance

  1. Monotonic seq for one run_idTestRecorder_Append_increasingSeqPerRunID uses StartRun + two Append calls; expects seq 1, 2 and the same via Reader.ListByRunID.
  2. Missing run fails clearlyTestRecorder_Append_missingRunFailsWithErrRunNotFound asserts errors.Is(err, ErrRunNotFound) and that the error text includes missing-run (no StartRun, so no FK-only error).

Closes #14.

Add Event type alias and Event* constants per design doc §12.2.
Recorder checks run exists before Append, marshals Data to JSON, and
delegates to RuntimeStore.AppendTraceEvent. Reader wraps ListTraceEventsByRunID.

Tests cover monotonic seq per run_id and ErrRunNotFound when the run row
is missing (issue #14).

Made-with: Cursor
@leo-aa88 leo-aa88 merged commit 70f6917 into main Apr 11, 2026
4 checks passed
@leo-aa88 leo-aa88 deleted the issue/14-trace-recorder branch April 11, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MVP] Trace event model and recorder (internal/trace)

1 participant