Skip to content

[AUTOMATION] feat: clean up managed ledger streaming#239

Open
michiosw wants to merge 1 commit into
mainfrom
feat/cleanup-managed-stream-ledger
Open

[AUTOMATION] feat: clean up managed ledger streaming#239
michiosw wants to merge 1 commit into
mainfrom
feat/cleanup-managed-stream-ledger

Conversation

@michiosw
Copy link
Copy Markdown
Contributor

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.go and tests redefined partial request structs. The stream cursor updated_after was a string, which pushed timestamp parsing/validation into call sites.

Now internal/ledger is the canonical home for the payload contract, and managed stream state uses a typed *time.Time cursor 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/batches

This PR does not broaden behavior beyond the cleanup scope.

What changed
Added internal/ledger with canonical payload types/constants
Removed duplicated payload schema/types from internal/managedstream
Strengthened stream state cursor typing (UpdatedAfter *time.Time) with characterization tests
Updated 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=1
go test ./... -count=1
go vet ./...

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 31, 2026

Greptile Summary

This PR centralizes the managed ledger payload contract and tightens stream cursor state handling. The main changes are:

  • Adds internal/ledger for authorization-ledger payload types and constants.
  • Updates managed stream posting to use the canonical ledger payload.
  • Changes managed stream state to keep updated_after as a typed timestamp in memory.
  • Preserves the on-disk stream state JSON shape through explicit load and save conversion.
  • Logs managed observe probe close errors for diagnostics.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (1): Last reviewed commit: "feat(managed): consolidate ledger payloa..." | Re-trigger Greptile

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