Skip to content

feat(rooms): page /rooms with ?offset= and report truncated (fixes #164) - #175

Closed
farisghossani wants to merge 1 commit into
flop-labs:mainfrom
farisghossani:feat/rooms-offset-pagination
Closed

farisghossani wants to merge 1 commit into
flop-labs:mainfrom
farisghossani:feat/rooms-offset-pagination

Conversation

@farisghossani

@farisghossani farisghossani commented Aug 25, 2026 •

Copy link
Copy Markdown

Fixes #164

What

/rooms currently caps at 200 rooms even when total exceeds it, and neither the limit parameter nor its 200 ceiling is documented. This PR adds full offset pagination so every room is reachable, reports the cut, and documents the surface.

Changes

File Change
src/store.py room_stats gains an offset param (clamped to listing), new truncated field
src/app.py route parses ?offset=, cache key becomes (limit, offset), forwards to store
src/manifest.py documents limit (max 200), new offset, truncated in /openapi.json
src/manual.md, README.md paging paragraph for /rooms
docs/store.md regenerated
tests paging http + unit, kunci cache tuple, empty-dict update
sz-baseline.json, CHANGELOG.md core ratchet + [Unreleased] entry

Verified (per AGENTS.md)

  • ruff check / format / ty — all pass
  • sz.py --check — core 2039 (baseline regenerated from the tree after rebasing on main c5cc02f)
  • 400 tests pass · coverage 97.48% (floor 96%)
  • Contract (Schemathesis): branch failures pre-existing on main, out of scope
  • Behavior: /rooms?limit=201 now returns 201 rooms and truncated: true; all rooms reachable via offset.

Rebased

Rebased onto current main (c5cc02f, 12 commits newer). Cache-key conflict resolved so the eviction fix landed alongside the (limit, offset) key. Three pre-existing tests that reached _rooms_cache[limit] were updated to the tuple key.

Abuse impact

New public surface: offset (clamped), limit ceiling unchanged at 200, single truncated boolean. No additional unbounded resource use.

The /rooms listing capped at 200 while total already exceeded it, and neither
the limit parameter nor the cap was documented, so anything built on the room
list silently saw a subset. Add pagination and make the cut visible.

- store.room_stats takes offset (clamped into the listing) and returns a
  truncated flag; a page past the end is an empty list, never an error or a
  re-read of the top.
- GET /rooms?offset=N skips the N newest rooms; the JSON gains truncated
  (offset + len(rooms) < total) so a client can page forward and know when a
  census is exact. The per-page read bound and the text line shape are unchanged.
- The /rooms cache keys on (limit, offset) — the reply space — bounded by the
  existing 64-entry LRU.
- limit's maximum and the new offset are documented in /openapi.json and the
  /rooms paging paragraph in /llms.txt.

Abuse impact: additive read surface only; offset is clamped and the page bound
is unchanged, so an abusive caller cannot force more tail reads per request than
limit already allowed.
@farisghossani
farisghossani force-pushed the feat/rooms-offset-pagination branch from 2c61978 to 1892592 Compare August 26, 2026 09:56
@sv sv added the enhancement New feature or request label Aug 27, 2026 — with Claude

sv commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Closing as unrebaseable, with the feature half worth resubmitting.

The /rooms cache this reworks is gone. #534 (0.11.0) replaced app._rooms_cache — the OrderedDict this PR rekeys to a tuple — with @lru_cache(maxsize=MAX_ROOMS_CACHE) def _rooms_walk(limit, stamp, bucket) at src/app.py:861. There are eight references to the removed structures in this diff and zero occurrences of them on main, so the cache half cannot be rebased, only re-made — and under lru_cache the tuple key it was reaching for is what the arguments already are.

It also edits sz-baseline.json, which CONTRIBUTING asks fork PRs to leave to the maintainers.

The feature is still open. #164 is unfixed: /rooms clamps limit at 200 while the total exceeds it, and nothing tells a caller the listing was truncated. ?offset= plus a truncated flag is a reasonable answer, and it needs no cache change now — _rooms_walk is keyed on limit already, so an offset joins the key and the memoisation follows for free. That is a much smaller PR than this one, and it is the half that was actually wanted.

Worth pairing with the doc half of #164 while you are there: manual.md's LIST line shows GET /rooms with no limit at all, though /openapi.json documents the clamp.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/rooms caps limit at 200 while total already exceeds it, and neither the parameter nor the cap is documented

2 participants