fix(managedstream): use fixed ledger timestamp cursors#267
Merged
michiosw merged 1 commit intoJun 8, 2026
Merged
Conversation
Greptile SummaryThis PR hardens managed ledger export cursoring and timestamp handling. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "fix(managedstream): use fixed ledger tim..." | 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.

Where We Are
Katana managed observe can fail hosted ingest when old local ledger rows contain timestamps without offsets, exact-second timestamps, or corrupt timestamp strings. The old export path used raw timestamp text for both hosted payloads and cursor pagination.
Where We Want To Go
Managed observe should keep uploading valid ledger batches and keep cursor pagination stable. It should not skip same-second rows, upload invalid datetime strings, leak internal cursor fields, or fail store migration because one legacy timestamp is bad.
How do we get there
This adds a fixed-width UTC cursor key for authorization actions, backfills it during SQLite migration, and uses it for bounded cursor queries. Exported ledger timestamps are normalized to hosted-valid RFC3339 strings; corrupt optional timestamps become null, and corrupt required timestamps fall back to a valid UTC timestamp. Managed-stream state parsing now accepts old no-offset and SQLite-space timestamp formats. Verified with go test -count=1 ./internal/guard/store/sqlite ./internal/managedstream, go test ./..., and pnpm --dir /Users/michelosswald/cobro/code/workspace/kontext --filter api test -- authorization-ledger.validation.spec.ts --runInBand.