Skip to content

docs(core): document enableCap contract; remove console dev-features guard#8802

Merged
simeng-li merged 2 commits into
masterfrom
simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is
May 14, 2026
Merged

docs(core): document enableCap contract; remove console dev-features guard#8802
simeng-li merged 2 commits into
masterfrom
simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is

Conversation

@simeng-li
Copy link
Copy Markdown
Contributor

Summary

Refs LOG-13434. Stacked on top of #8799.

This is the GA step for the audit-logs count-cap work. The runtime behavior shipped in #8796 (backend) and #8799 (console behind isDevFeaturesEnabled); this PR:

  1. Removes the dev-features gate so the Console always passes ?enableCap=true to GET /api/logs in production.
  2. Documents the enableCap query param, Total-Number-Is-Capped response header, and the capped-mode Link rel behavior in the OpenAPI specs.
  3. Adds a patch-level changeset for the doc-only @logto/core change.

What changed

  • packages/console/src/components/AuditLogTable/index.tsx — drops the isDevFeaturesEnabled import and the ...conditional(isDevFeaturesEnabled && { enableCap: 'true' }) spread. The URL builder now always includes enableCap: 'true'.
  • packages/core/src/routes/log.openapi.json/api/logs: adds the enableCap query parameter, documents Total-Number, Total-Number-Is-Capped, and Link response headers, and adds a "Pagination on large result sets" subsection to the endpoint description.
  • packages/core/src/routes/hooks.openapi.json/api/hooks/{id}/recent-logs: same set of doc additions, with a one-liner noting that this endpoint is already scoped to one hook over the last 24h so the cap rarely triggers in practice.
  • .changeset/logs-enable-cap-docs.md@logto/core: patch noting the OpenAPI updates.

Backward compatibility

  • API runtime behavior: unchanged (the enableCap semantics shipped in feat(core): add enableCap query param to bound countLogs scan #8796).
  • Default GET /api/logs (no enableCap) still returns the exact count. Existing third-party clients are unaffected.
  • Console Audit Logs page: production users with tenants > 10,000 matching logs now get the capped UI (Prev/Next only) instead of hitting statement_timeout. Smaller tenants see no visible change.

Reviewer notes

Testing

Tested locally

Checklist

  • .changeset
  • unit tests
  • integration tests
  • necessary TSDoc comments

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

COMPARE TO master

Total Size Diff 📈 +3.96 KB

Diff by File
Name Diff
.changeset/logs-enable-cap-docs.md 📈 +360 Bytes
packages/console/src/components/AuditLogTable/index.tsx 📈 +97 Bytes
packages/core/src/routes/hooks.openapi.json 📈 +1.46 KB
packages/core/src/routes/log.openapi.json 📈 +2.24 KB

@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from 0743a15 to d3b4d09 Compare May 13, 2026 03:02
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from d3b4d09 to f2d4efd Compare May 13, 2026 03:03
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from f2d4efd to 8f3fa15 Compare May 13, 2026 03:04
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
@simeng-li simeng-li requested a review from Copilot May 13, 2026 03:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR finalizes the GA rollout for capped-count pagination on large audit-log datasets by (1) having Console always opt into enableCap=true for /api/logs, and (2) documenting the enableCap contract plus capped-mode headers/Link behavior in the core OpenAPI specs, with an accompanying changeset.

Changes:

  • Console Audit Logs now always includes enableCap=true when fetching /api/logs.
  • OpenAPI specs document enableCap, Total-Number-Is-Capped, and capped-mode pagination Link semantics for /api/logs and /api/hooks/{id}/recent-logs.
  • Adds a changeset entry for the release note/version bump.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
packages/core/src/routes/log.openapi.json Documents enableCap and capped pagination headers/Link behavior for /api/logs.
packages/core/src/routes/hooks.openapi.json Mirrors the capped pagination documentation for hook recent logs.
packages/console/src/components/AuditLogTable/index.tsx Removes dev-features gating so enableCap=true is always sent.
.changeset/logs-enable-cap-docs.md Adds a changeset entry describing the rollout.
Comments suppressed due to low confidence (3)

packages/core/src/routes/log.openapi.json:33

  • enableCap description mixes the 10,000 threshold with the 10001 saturation sentinel, which may confuse consumers about what value to expect in Total-Number. Suggest clarifying that the cap threshold is 10,000 matching rows, and when exceeded the server returns Total-Number=10001 as the sentinel and emits Total-Number-Is-Capped: true.
            "name": "enableCap",
            "in": "query",
            "description": "When `true`, the underlying `count(*)` query short-circuits at 10,000 rows to avoid `statement_timeout` on tenants with very large log volumes. `Total-Number` then saturates at `10001` and `Total-Number-Is-Capped: true` is emitted; the `Link` header omits `rel=\"last\"` and `rel=\"next\"` because the real total is unknown. Default `false`; recommended `true` for any client whose tenant volume may exceed 10,000 matching logs."
          }

packages/core/src/routes/log.openapi.json:45

  • The Total-Number header description implies counts are exact only when enableCap=false, but enableCap=true still returns an exact count when it does not hit the cap. Also, the “lower-bounded by 10,000” / “treat as ≥ 10,000” wording doesn’t match the actual sentinel value 10001 used when capped. Please update these descriptions to key off presence of Total-Number-Is-Capped and reference 10001 consistently.
              "Total-Number": {
                "description": "Exact match count when `enableCap=false`; lower-bounded by 10,000 when `enableCap=true` and the cap is hit. Inspect `Total-Number-Is-Capped` to distinguish.",
                "schema": { "type": "integer" }
              },
              "Total-Number-Is-Capped": {
                "description": "Present and set to `true` only when `enableCap=true` and the count saturated at the cap. Consumers should treat `Total-Number` as `≥ 10,000` when this header is present.",
                "schema": { "type": "string", "enum": ["true"] }

packages/core/src/routes/hooks.openapi.json:154

  • Similar to /api/logs: Total-Number is still exact when enableCap=true and the cap is not hit, so the current header description is misleading. Also, “lower-bounded by 10,000” doesn’t match the 10001 sentinel used when capped. Recommend describing Total-Number as exact unless Total-Number-Is-Capped is present, and referencing 10001 consistently for the capped sentinel value.
              "Total-Number": {
                "description": "Exact match count when `enableCap=false`; lower-bounded by 10,000 when `enableCap=true` and the cap is hit.",
                "schema": { "type": "integer" }
              },
              "Total-Number-Is-Capped": {
                "description": "Present and set to `true` only when `enableCap=true` and the count saturated at the cap.",
                "schema": { "type": "string", "enum": ["true"] }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/routes/log.openapi.json Outdated
Comment thread packages/core/src/routes/hooks.openapi.json
Comment thread .changeset/logs-enable-cap-docs.md
Comment thread .changeset/logs-enable-cap-docs.md Outdated
@simeng-li simeng-li force-pushed the simeng-log-13417-console-adopt-enablecaptrue-on-the-audit-logs-page-to-render branch from c4e6b04 to f6e563a Compare May 13, 2026 03:50
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from 8f3fa15 to e437e40 Compare May 13, 2026 03:50
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from e437e40 to 15a13f0 Compare May 13, 2026 03:59
@simeng-li simeng-li force-pushed the simeng-log-13417-console-adopt-enablecaptrue-on-the-audit-logs-page-to-render branch from f6e563a to 8eb031a Compare May 13, 2026 03:59
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from 15a13f0 to 01d6db4 Compare May 13, 2026 04:34
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
@simeng-li simeng-li force-pushed the simeng-log-13417-console-adopt-enablecaptrue-on-the-audit-logs-page-to-render branch from 8eb031a to 6ec18b6 Compare May 13, 2026 07:00
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from 01d6db4 to fc5b21b Compare May 13, 2026 07:00
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
@simeng-li simeng-li force-pushed the simeng-log-13417-console-adopt-enablecaptrue-on-the-audit-logs-page-to-render branch from 6ec18b6 to 4fe126d Compare May 13, 2026 07:12
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from fc5b21b to 1700915 Compare May 13, 2026 07:13
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
@simeng-li simeng-li force-pushed the simeng-log-13417-console-adopt-enablecaptrue-on-the-audit-logs-page-to-render branch from 4fe126d to 57b7eae Compare May 13, 2026 07:42
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from 1700915 to 149c016 Compare May 13, 2026 07:42
@github-actions github-actions Bot added size/s and removed size/s labels May 13, 2026
Base automatically changed from simeng-log-13417-console-adopt-enablecaptrue-on-the-audit-logs-page-to-render to master May 13, 2026 08:11
@github-actions github-actions Bot added size/m and removed size/s labels May 13, 2026
…guard

Updates the OpenAPI specs for `GET /api/logs` and
`GET /api/hooks/{id}/recent-logs` to document the `enableCap` query
parameter, `Total-Number-Is-Capped` response header, and the capped-mode
`Link` rel behavior introduced in LOG-13415.

Also removes the `isDevFeaturesEnabled` gate on the Console Audit Logs
page so capped mode is the production default — the backend (#8796) and
console UI (#8799) have both validated.

Refs LOG-13434
Copilot AI review requested due to automatic review settings May 13, 2026 08:36
@simeng-li simeng-li force-pushed the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch from 149c016 to 1c81ceb Compare May 13, 2026 08:36
@github-actions github-actions Bot added size/s and removed size/m labels May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread .changeset/logs-enable-cap-docs.md
update changeset
@github-actions github-actions Bot added size/s and removed size/s labels May 14, 2026
@simeng-li simeng-li merged commit 7b7a5c8 into master May 14, 2026
34 checks passed
@simeng-li simeng-li deleted the simeng-log-13434-docs-document-get-logs-enablecap-contract-total-number-is branch May 14, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants