fix: grow Wiki.js listing limit until page count stabilizes
Live evidence during quality-report verification: pages.list(limit=100) returned 43 pages while 140 existed; limit=500 returned all 140. Wiki.js applies the limit BEFORE its own visibility filtering, so a response with fewer pages than requested does NOT prove the listing is complete. The Phase A limit-growth loop stopped on len < limit and silently truncated listings (page counts, orphan cleanups, integrity scans, and the quality report all consume this listing). The loop now doubles the limit until the returned count stops increasing (fixed point), at the cost of one confirming fetch. Offline pagination tests updated, including a regression test simulating the pre-filter limit behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QbFZyDvYksazX6nYQYZ67L
This commit is contained in:
@@ -143,9 +143,12 @@ class WikiJSClient:
|
||||
Fetch ALL pages from the GraphQL API.
|
||||
|
||||
The Wiki.js 2.x `pages.list` query only supports a `limit` argument
|
||||
(no offset - verified via GraphQL introspection), so exhaustive
|
||||
listing works by growing the limit until the API returns fewer
|
||||
pages than requested.
|
||||
(no offset - verified via GraphQL introspection). Crucially, the
|
||||
limit is applied BEFORE Wiki.js's own visibility filtering, so a
|
||||
response with fewer pages than requested does NOT mean the listing
|
||||
is complete (observed live: limit=100 -> 43 pages, limit=500 ->
|
||||
140 pages). Exhaustive listing therefore grows the limit until the
|
||||
returned page count stops increasing.
|
||||
|
||||
Args:
|
||||
initial_limit: Page count for the first request
|
||||
@@ -155,11 +158,16 @@ class WikiJSClient:
|
||||
"""
|
||||
max_limit = 100_000 # Safety cap against pathological growth
|
||||
limit = max(initial_limit, 1)
|
||||
previous_count: Optional[int] = None
|
||||
|
||||
while True:
|
||||
pages = await self._fetch_pages(limit)
|
||||
if len(pages) < limit or limit >= max_limit:
|
||||
# Complete when a grown limit yields no new pages (fixed point)
|
||||
if previous_count is not None and len(pages) == previous_count:
|
||||
return pages
|
||||
if limit >= max_limit:
|
||||
return pages
|
||||
previous_count = len(pages)
|
||||
limit = min(limit * 2, max_limit)
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user