Skip to content

Add logs tail and logs list for project request logs - #73

Merged
purpshell merged 3 commits into
mainfrom
t3code/logs-tail
Oct 10, 2026
Merged

purpshell merged 3 commits into
mainfrom
t3code/logs-tail

Conversation

@purpshell

@purpshell purpshell commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds polymorfa logs tail and polymorfa logs list, the CLI side of the project request log (polymorfa/polymorfa#549). It works like stripe logs tail.

logs tail:

  • Prints the most recent matching requests (--backfill, default 10).
  • Then polls for new ones every --poll-interval seconds (default 2, 1 to 60), and reads again at once while more are waiting.
  • Waits for Retry-After when the 120-reads-a-minute limit is reached.
  • --json writes one JSON line per request; --max-events stops after a fixed number.

logs list prints one newest-first page with a --cursor for older requests.

Both accept --status (codes or classes), --method, --route, --source, --credential, --request-id and --trace-id.

Impact

Impact table

Area Updated / blocked Change or named blocker Paths / companion PRs / evidence
CLI Updated logs tail and logs list, the logs topic, and a filter helper. Calls GET /platform/projects/{projectId}/request-logs through the SDK raw client with zod validation, like billing controls src/commands/logs/*, src/services/request-logs.ts, src/input/request-log-filters.ts, package.json
CLI docs Updated README "Request logs" section README.md
API Companion polymorfa/polymorfa#549 is merged (f97fb511); the commands return data once it is deployed, and 404 before that polymorfa/polymorfa#549
SDK Companion, not a dependency The typed client.requestLogs arrives in polymorfa/sdks#342. This PR keeps the pinned SDK and can switch to the typed method after an accepted nightly polymorfa/sdks#342
Public docs Blocked on publication CLI and SDK pages and the changelog entry in polymorfa/polymorfa docs/ follow once packages publish polymorfa/polymorfa docs PR

No impact table

Area Why there is no impact Supporting paths or evidence
Credentials and profiles Uses the existing developer session: a team key with --project, or a project token src/developer/client.ts unchanged
MCP server in the CLI Not extended. The hosted MCP gains request_log_list in the API PR polymorfa/polymorfa#549
Billing, Usage and Admin Read-only command with no new quantity n/a

Verification

At ddffd33 on main 43e55a4:

  • npm run verify passed: format, lint, typecheck, 109 files and 1,032 tests, build, npm pack --dry-run, and an audit with 0 vulnerabilities.
  • test/commands/request-logs.test.ts, 5 tests, covers:
    • the query string and human output;
    • --cursor combined with filters being refused before any request;
    • tail backfill order and following with the returned cursor;
    • waiting for Retry-After;
    • poll-interval bounds.
  • End to end: the built CLI ran against polymorfa/polymorfa#549's createApp with a real Postgres. It printed a request made before it started, then one made during polling, with the caller's trace IDs. Details are in polymorfa/polymorfa#549.
  • Not exercised: a deployed API.

Review round: fixed both Codex findings: logs list --json uses the standard developerRead envelope, and Retry-After is parsed with the CLI's shared parser. npm run verify passes (1,034 tests), and CI is green on the final head.

Session provenance and UI evidence

  • Agent registration PR: polymorfa/polymorfa#540.
  • Sanitized transcript checkpoint: internal/agent-sessions/sessions/purpshell-t3-claude/request-logs-tail/5a462ed1e620c3ff445ab1a150fc9cfb2154f8a1ee50f22a870e3f5926d221b1.md in polymorfa/polymorfa, evidence commit 750f5a519.
  • UI: none. Terminal output is shown in the tests.

Rollout and rollback

Merge order: after polymorfa/polymorfa#549, which is merged.

Availability: follows the next accepted CLI nightly and the API deployment.

Rollback: revert. The commands are additive.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

The included review limit has been reached and this organization has disabled usage-based review continuation. Wait for reviews to reset or ask a billing admin to change After included review limits.

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 85 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 62d575aa-617c-485b-80d7-9d7893decc1f

📥 Commits

Reviewing files that changed from the base of the PR and between 43e55a4 and 49c53ad.


📒 Files selected for processing (8)
  • README.md
  • package.json
  • src/commands/logs/list.ts
  • src/commands/logs/tail.ts
  • src/errors/present.ts
  • src/input/request-log-filters.ts
  • src/services/request-logs.ts
  • test/commands/request-logs.test.ts

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@purpshell
purpshell marked this pull request as ready for review October 10, 2026 04:13
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T04:19:02.306149Z a2cfebb Draft marked ready
🔒 Security Review ✅ Completed 2026-10-10T04:16:20.052906Z a2cfebb Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2cfebb03c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/logs/list.ts Outdated
Comment on lines +71 to +75
this.writeValue(
{
data: page.items,
page: {
nextCursor: page.nextCursor,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return list JSON in the standard read envelope

When logs list --json succeeds, this hand-built value contains only data and page, omitting the standard schemaVersion, context, and request fields—including the response request ID, status, and API version. Comparable developer list commands use developerRead/readEnvelope, so consumers cannot process request-log results through the established read-output contract. Preserve the response metadata from listRequestLogs and build the standard envelope while retaining followCursor in the page data.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 49c53ad. logs list --json now uses developerRead, giving schemaVersion, context, request (ID, status, API version) and page, with followCursor kept in page. Test: prints list JSON in the standard read envelope with the follow cursor.

Comment thread src/services/request-logs.ts Outdated
Comment on lines +163 to +165
const seconds = Number(error.metadata?.headers['retry-after'])
const waitMs = Math.min(
Number.isFinite(seconds) && seconds > 0 ? seconds * 1000 : 60_000,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor all valid Retry-After values

When a rate-limit response supplies Retry-After: 0 or an HTTP-date, this conversion either rejects the valid zero delay or produces NaN, causing an arbitrary 60-second wait instead of the server-requested delay. The repository's other Retry-After parsers accept nonnegative delta-seconds and HTTP-dates; use equivalent parsing here so logs tail does not resume too early or unnecessarily stall.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 49c53ad. The tail loop now uses the CLI's existing retryAfter parser (delta-seconds including 0, or an HTTP-date), and falls back to 60 s only when the header is missing or invalid. Test: retries at once on Retry-After: 0.

@purpshell
purpshell merged commit c4782df into main Oct 10, 2026
2 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