[AUTOMATION] feat: clean up managed ledger streaming#239
Open
michiosw wants to merge 1 commit into
Open
Conversation
Greptile SummaryThis PR centralizes the managed ledger payload contract and tightens stream cursor state handling. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Reviews (1): Last reviewed commit: "feat(managed): consolidate ledger payloa..." | Re-trigger Greptile |
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
This cleans up managed ledger streaming by consolidating the authorization-ledger payload contract and tightening stream state typing.
Before this, the payload schema constants/types lived in
internal/managedstream/stream.goand tests redefined partial request structs. The stream cursorupdated_afterwas a string, which pushed timestamp parsing/validation into call sites.Now
internal/ledgeris the canonical home for the payload contract, and managed stream state uses a typed*time.Timecursor while keeping the on-disk JSON field stable.Why
This gives kontext-cli a single maintenance path for exporting the hosted authorization ledger:
sqlite.Store.LedgerBatch->
internal/managedstream.Flush->
internal/ledger.Payload-> POST
/api/v1/authorization-ledger/batchesThis PR does not broaden behavior beyond the cleanup scope.
What changed
Added
internal/ledgerwith canonical payload types/constantsRemoved duplicated payload schema/types from
internal/managedstreamStrengthened stream state cursor typing (
UpdatedAfter *time.Time) with characterization testsUpdated managed observe daemon test to decode the canonical payload
Stopped ignoring probe
conn.Close()errors (diagnostic log)Verification
go test ./internal/managedstream ./internal/managedobserve ./internal/ledger -count=1go test ./... -count=1go vet ./...