feat: AI SRE session list (typed) + export (streaming NDJSON)#8
Merged
Conversation
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).
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.
Adds the AI SRE session list and session export endpoints to the go-flashduty SDK, consumed by the
/insightfeature (L3 CLI + skill).What
Sessionsservice withList+Info(typed JSON), plusSessionItem/SessionListRequest/SessionListResponse/SessionGetRequest/ExportLinemodel structs. Epoch-millis fields (created_at,updated_at,last_event_at,archived_at,pinned_at) map toTimestampMillivia the description-driven rule.session/exportreturnsapplication/x-ndjson, which the typeddo/doGetpath cannot model (it buffers the whole body and decodes one JSON envelope). Taught the generator to skip any operation whose 200 response has noapplication/jsoncontent — a general, first-principles rule, not a one-off — so it no longer emits a brokenExportthat JSON-decodes a stream.Export(sessions_export.go): raw POST returning the live response body as anio.ReadCloser, plusNewExportScanner/DecodeExportLinehelpers 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 checkgreen:gofmt/gci,golangci-lint0 issues,go test -race ./...all pass,go build ./....sessions_export_test.go): NDJSON happy path (assertssession_metafirst + per-line decode +Accept: application/x-ndjsonoverride + request body), 403 error envelope →*ErrorResponse, 429 →*RateLimitError.TestSpecExamplesRoundTripround-tripped 156 spec examples (incl. the new session list/get) into the generated types.Listreturnedtotal=988/ 3 sessions;Exportstreamed 51 NDJSON lines, first linesession_meta.Depends on
feat/safari-session-apis). That PR is on a docs branch, so the spec was vendored from the local checkout rather thanmake sync-specfrom remote main. Re-runmake sync-speconce docs#69 merges to keep the vendored copy tracking main.