Skip to content

feat(api): opt-in cursor pagination and truncation metadata (API-01), 3.6.0 - #182

Merged
lnieuwenhuis merged 5 commits into
stagingfrom
feat/audit-pagination-staging
Sep 17, 2026
Merged

lnieuwenhuis merged 5 commits into
stagingfrom
feat/audit-pagination-staging

Conversation

@lnieuwenhuis

Copy link
Copy Markdown
Owner

Independent pagination review and staging integration for API-01 (user-approved 3.6.0).

HOLD MERGE pending DATA and API contract PRs. Parent resumes after prerequisite merges, then merges latest staging semantically and reruns combined tests/CI before normal merge/Railway. No force/admin bypass/main/production.

Owned commits (cherry-picked from feat/audit-api-pagination, rebased on origin/staging 6a2146a):

  • c72297f feat(api): opt-in cursor pagination and truncation metadata
  • fd2bfa9 feat(web): pagination contract docs and 3.6.0 (includes docs placeholder review fix)

Scope: backwards-compatible default bare arrays, truthful x-result/x-daily-totals/x-smoothed-weight-trend headers with CORS exposure, bounded keyset limit 1-1000, owner-bound cursors, deterministic ties, complete enumeration, unchanged internal RPC, stats windows that do not hide DATA-03, additive OpenAPI.

Checks (disposable DB macro_tracker_pagination_review_test on 127.0.0.1:55446, never user DB; backend on 127.0.0.1:41447 hidden with finally cleanup):

  • cargo fmt --check PASS
  • cargo check -p macro-tracker-backend --locked PASS
  • cargo test -p macro-tracker-backend --locked with TEST_DATABASE_URL: 191 passed, 0 failed, 0 ignored
  • pagination filter: 12 passed (cap+1 5000/5001, tie walk exactly-once, cross-user/foreign/malformed 400, legacy bodies unchanged, stats 1001 windows)
  • live backend + vitest api-v1.test.ts: 54 passed (legacy array, envelope walk, headers presence/absence, invalid limit/cursor 400, cross-user 400)
  • pnpm typecheck PASS, pnpm lint PASS, pnpm audit:code PASS (exit 0), openapi-parity 3 passed
  • gitleaks git log origin/staging..HEAD: no leaks; file strict scan: no page.tsx leaks (docs examples use \ placeholder, audit-triaged)
  • gh auth: lnieuwenhuis

Dependencies: requires DATA-03 (stats eaten-day fix, goal-hit denominator) and API-02/03 contract PRs to land first or together; OpenAPI date/uuid/format and leaderboard changes are disjoint but must be re-applied on merge. Stats metadata derives from daily/weight counts and follows DATA-03 automatically.

See pr-pagination.md for full findings/PR/checks/dependencies.

API-01: templates, recipes and weight entries keep their capped bare-array bodies for requests without page parameters, announce a bite only via x-result-limit/count/truncated headers, and gain an opt-in { items, nextCursor } envelope that walks a stable keyset bound to the authenticated user.

/stats keeps its full-history aggregates and body, reporting x-daily-totals-* and x-smoothed-weight-trend-* when the newest-1000-row chart windows truncate. Internal session RPCs keep the legacy array builders.
Describe the opt-in limit/cursor envelope and truncation headers in the API docs table and page, pin the checked-in OpenAPI parameters and headers in the parity test, and cover legacy-array compatibility, page walking, invalid parameters, cross-user cursors and header presence through the API proxy. Bump @macro-tracker/web and APP_VERSION to 3.6.0.

Review fix: allowlist docs example bearer tokens (mtk_v1_your_token placeholder, audit triaged) via inline gitleaks:allow and .gitleaksignore so the docs publish without tripping the secrets gate. No behavior change.
Merge resolution for pagination + DATA184: stats_page_data_json now returns StatsPageData (data + window counts) for pagination metadata. Update data_integrity zero-calorie test to read stats.data. No DATA logic changed; pagination metadata still derives from daily.
…ion-staging

# Conflicts:
#	apps/web/lib/api-v1-openapi.ts
#	apps/web/tests/unit/openapi-parity.test.ts
@lnieuwenhuis
lnieuwenhuis merged commit 062e709 into staging Sep 17, 2026
7 checks passed
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