Skip to content

feat: AI SRE session list (typed) + export (streaming NDJSON)#8

Merged
ysyneu merged 1 commit into
mainfrom
feat/session-list-export
Jun 2, 2026
Merged

feat: AI SRE session list (typed) + export (streaming NDJSON)#8
ysyneu merged 1 commit into
mainfrom
feat/session-list-export

Conversation

@ysyneu
Copy link
Copy Markdown
Collaborator

@ysyneu ysyneu commented Jun 2, 2026

Adds the AI SRE session list and session export endpoints to the go-flashduty SDK, consumed by the /insight feature (L3 CLI + skill).

What

  • Vendor + regenerate: pulled the updated safari session OpenAPI from flashduty-docs and regenerated the typed layer. New Sessions service with List + Info (typed JSON), plus SessionItem / SessionListRequest / SessionListResponse / SessionGetRequest / ExportLine model structs. Epoch-millis fields (created_at, updated_at, last_event_at, archived_at, pinned_at) map to TimestampMilli via the description-driven rule.
  • Generator change: session/export returns application/x-ndjson, which the typed do/doGet path cannot model (it buffers the whole body and decodes one JSON envelope). Taught the generator to skip any operation whose 200 response has no application/json content — a general, first-principles rule, not a one-off — so it no longer emits a broken Export that JSON-decodes a stream.
  • Hand-written streaming Export (sessions_export.go): raw POST returning the live response body as an io.ReadCloser, plus NewExportScanner / DecodeExportLine helpers so callers stream line-by-line straight to a file without buffering the transcript. Non-2xx decodes the JSON error envelope into a typed *ErrorResponse / *RateLimitError, matching the generated endpoints.

Verification

  • make check green: gofmt/gci, golangci-lint 0 issues, go test -race ./... all pass, go build ./....
  • New unit tests (sessions_export_test.go): NDJSON happy path (asserts session_meta first + per-line decode + Accept: application/x-ndjson override + request body), 403 error envelope → *ErrorResponse, 429 → *RateLimitError.
  • TestSpecExamplesRoundTrip round-tripped 156 spec examples (incl. the new session list/get) into the generated types.
  • Live-grounded against the gateway: List returned total=988 / 3 sessions; Export streamed 51 NDJSON lines, first line session_meta.

Depends on

Vendor the updated safari session OpenAPI from flashduty-docs
(feat/safari-session-apis) and regenerate the typed layer, adding a
Sessions service with List + Info (typed JSON) plus the SessionItem /
SessionListResponse / ExportLine model structs (epoch-millis fields
mapped to TimestampMilli).

session/export returns application/x-ndjson, which the typed do/doGet
path cannot model (it buffers the body and decodes one JSON envelope).
Teach the generator to skip any operation whose 200 response has no
application/json content, and hand-write a streaming Export method that
returns the live response body as an io.ReadCloser (plus NewExportScanner
/ DecodeExportLine helpers) so callers stream line-by-line to a file
without buffering the whole transcript. Non-2xx still decodes the JSON
error envelope into a typed *ErrorResponse / *RateLimitError.

Unit tests cover the NDJSON happy path (session_meta first, per-line
consumption, Accept override), the 403 error envelope, and 429.
make check green (fmt + lint 0 issues + race tests + build); live-grounded
against the gateway (List total=988, Export streamed 51 lines).
@ysyneu ysyneu merged commit 7583eba into main Jun 2, 2026
4 checks passed
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.

1 participant