You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0e8741c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(rust): keyset cursor pagination for v2.session.list
PR #20 (Caminho A): complete v2.session.list with real cursor pagination,
faithful to the TS keyset semantics (session.ts).
- opencode-db: SessionListQuery gains `anchor: Option<ListAnchor>` + `directory`
filter; SessionStore::list implements the keyset boundary on (time_created,
id), flips order + reverses results for a `Previous` anchor, in both
SqlxSessionStore and MemorySessionStore. New ListAnchor/ListDirection types.
- opencode-server: the handler emits `previous`/`next` cursors (from the first/
last row, preserving filters+order) and follows an inbound `cursor`; default
limit 50. Cursor codec is base64url(serde_json) — a Rust-native opaque token
(not byte-interchangeable with TS across a mid-pagination rollback; documented).
Undecodable cursor → 400 InvalidCursorError (the other arm of the golden 400
union). Added the `base64` crate (zero-dep, MIT/Apache).
Verified: build/clippy -D warnings/fmt/test (db 22, server 25) and openapi-diff
all green. Cursor round-trip covered end-to-end (page → next → previous) plus a
DB-level keyset test for both store impls.
https://claude.ai/code/session_017Lo2jkGdTgRvsPG6tcwEqz
- ✅ **Migration-journal verification** (PR #17, "TS migrates / Rust verifies"): boot health check reads the `migration` journal (+ **read-only**`__drizzle_migrations` bridge) and diffs against `EXPECTED_MIGRATIONS` (mirrors `migration.gen.ts`). Behind+journal-present → fatal with a clear message; ahead/no-journal → warn (policy documented in [`MIGRATION_POLICY.md`](./MIGRATION_POLICY.md), owner-approved).
78
78
- ✅ **Session-store tables** (PR #17): `session_input` (event-sourced steering inbox) + `session_context_epoch` (per-session baseline/agent) models + repositories in `opencode-db`, DDL mirroring the final TS schema.
79
79
- ✅ **First session read-route cutover** (PR #18): `GET /api/session/{sessionID}` (`v2.session.get`, group `session`) → `SessionV2Info`, served natively by reading the shared **`session` projection table** via a `SessionStore` wired through `AppContext`. **Finding:** the V2 read routes read projection tables (the projector folds events into them on the *write* path), not the event log per request — so a faithful Rust read is a `SELECT`, not an event fold. `session.status` is **not** cuttable yet (it reads per-process in-memory runner state, which lives in TS until Phase 4). Contract enforced by `openapi-diff` (now collapses `anyOf[X,X]` and drops the `{type:null}` member utoipa adds for `Option<$ref>`); seam-gated (`OPENCODE_RUST_ROUTES=session`, off by default). A separate test exercises `event_store.read()` against externally (TS-)written event rows.
80
-
- ✅ **Session list cutover** (PR #19): `GET /api/session` (`v2.session.list`, group `session`) → `SessionsResponse` (`{ data: SessionV2Info[], cursor }`), same `SessionStore` with `limit`/`order`/`search`/`project`/`workspace` filters. Opaque keyset cursors are a follow-up (the `cursor` object is returned empty; its fields are optional in the contract). Contract-enforced (`/api/session`); the 400 union (`anyOf[InvalidCursorError, InvalidRequestError]`) reuses the dedup-collapsing normalizer.
80
+
- ✅ **Session list cutover** (PR #19): `GET /api/session` (`v2.session.list`, group `session`) → `SessionsResponse` (`{ data: SessionV2Info[], cursor }`), same `SessionStore` with `limit`/`order`/`search`/`project`/`workspace`/`directory` filters. Contract-enforced (`/api/session`); the 400 union (`anyOf[InvalidCursorError, InvalidRequestError]`) reuses the dedup-collapsing normalizer.
81
+
- ✅ **Keyset cursor pagination** (PR #20): `v2.session.list` now returns real `previous`/`next` cursors and follows an inbound `cursor`. Faithful TS keyset semantics (`session.ts`): anchor `(time_created, id)`, order-flip + result-reverse for `previous`, default limit 50; an undecodable cursor → 400 `InvalidCursorError`. The cursor token is a Rust-native `base64url(JSON)` (opaque per the contract; not byte-interchangeable with TS cursors across a mid-pagination rollback — documented). Added the `base64` crate.
0 commit comments