Add annotated trace discovery and export APIs - #310
Merged
johnnygreco merged 1 commit intoJun 17, 2026
Conversation
This was referenced Jun 17, 2026
johnnygreco
force-pushed
the
issue-305-annotation-export
branch
from
June 17, 2026 05:40
9fbfd21 to
0823247
Compare
johnnygreco
force-pushed
the
issue-305-annotation-export
branch
from
June 17, 2026 10:35
0823247 to
bee86e6
Compare
Owner
Author
Review RecordFrozen target: Panel:
Accepted findings fixed:
Rejected findings:
Validation after fixes:
Final status: all rerun reviewers clean; no unresolved blockers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds annotation-aware dataset discovery and export APIs:
GET /api/annotations/traceslists annotated sessions with annotation counts and validated target summaries.GET /api/annotations/exportreturns dataset-ready JSON with session metadata, ordered event context, complete paginated annotation records, schema markers, and truncation warnings.Closes #305
Example Output
Discovery response shape:
{ "schema": "beacon.annotated_traces.index.v1", "include_deleted": false, "items": [ { "session": {"id": "session-1", "title": "..."}, "counts": {"annotation_count": 2, "session_annotation_count": 1, "message_annotation_count": 1, "event_annotation_count": 0, "needs_followup_count": 0}, "targets": [{"target_type": "message", "event_uid": "message-1", "annotation_count": 1}] } ] }Export response shape:
{ "schema": "beacon.annotated_traces.export.v1", "traces": [ { "session": {"id": "session-1", "title": "..."}, "annotations": [{"annotation_id": "ann-session", "target_type": "session", "note": "..."}], "events": [{"event_uid": "message-1", "event_kind": "message", "text_preview": "..."}], "event_truncated": false } ] }Validation
make generate-check-> passedmake fmt-check-> passedmake test-> passedmake build-> passedmake lint-> passednpm run test:frontend-> passedgo test ./internal/web -run 'TestAnnotationAPIAnnotatedTraces|TestAnnotationAPIExportAnnotatedTraces|TestAPIContractsMatchGoStructTags'-> passedgit diff --check-> passedRisks
The export endpoint returns bounded event context per trace.
event_limitdefaults to 1000 and clamps at 5000; responses includeevent_truncatedand warnings when a session has more events than the requested limit.Candidate discovery scans annotation session summaries in bounded batches and revalidates each annotation target before counting or exporting it, so out-of-scope event/message annotations are skipped rather than exposed through counts or metadata.
Reviewer Notes
Focus on
internal/web/api_annotation_exports.goand the extended annotation filters ininternal/store/annotations.go. The tests deliberately cover hidden out-of-scope message annotations, deleted annotations, empty exports, API contracts, event truncation, and annotation pagination beyond the store page cap. No UI controls were added in this PR, so no screenshots are included. Backward compatibility was explicitly not required and no legacy export format was added.