Skip to content

feat(api-explorer): add read-only API discovery - #472

Open
sozercan wants to merge 7 commits into
mainfrom
explore
Open

feat(api-explorer): add read-only API discovery#472
sozercan wants to merge 7 commits into
mainfrom
explore

Conversation

@sozercan

@sozercan sozercan commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Description

API Explorer can now follow server-issued read-only routes and report response structure without printing raw values. docs/api-discovery.md collects guest and authenticated findings and marks Kaset capabilities as implemented, partial, or not implemented.

Type of Change

  • New feature
  • Documentation update
  • Test update

Changes Made

  • Add discover with an endpoint and field allowlist, bounded traversal, repeatable --follow navigation, and redacted schema/report output.
  • Extract browse reads from authenticated Library chip and sort-selection commands while excluding persistence, checkbox updates, and taste-profile acceptance from replay.
  • Add iOS and Android Music probes, server authentication diagnostics, and existing OAuth access-token input from private files.
  • Document verified credits, Home activity chips, chart countries, Related content, and radio queue reads. Add signed-in Library sorting and pagination, podcast Channels, Profiles, upload empty states, and taste-profile data, with the remaining Recap and transcript limits.

Actual mobile Speed dial remains not implemented in Kaset. Web credentials authenticate web Home but fail to authenticate the tested mobile clients. A populated mobile OAuth response is still needed before replacing Favorites.

Testing

  • swift build
  • swift test --skip KasetUITests --filter 'DiscoveryAuditTests|APIExplorerActionRoutingTests': 30 tests passed.
  • swiftlint --strict --quiet, SwiftFormat on the changed Swift files, and git diff --check.
  • Read-only live probes with guest and signed-in web sessions, including Library selections and continuations. Mobile authentication comparisons did not establish a working mobile OAuth session.

Checklist

  • Changes follow the project's formatting and lint rules.
  • Tests cover mutation rejection, Library selection replay, traversal, redaction, mobile headers, and private token-file handling.
  • Discovery documentation includes implementation status and verification limits.
  • Review findings are resolved.

Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Copilot AI balanced review requested due to automatic review settings September 5, 2026 06:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 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-09-05T22:50:48.461390Z 4a125d0 New commits
🔒 Security Review Completed 2026-09-05T06:28:06.702169Z 5cf8076 PR opened
ℹ️ 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The unresolved redaction vulnerability and mobile token/profile validation issues must be fixed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 2 Medium severity

New issues introduced by this change (3)
Severity Finding
High severity Sources/​APIExplorer/​DiscoveryAudit.swiftschemaKey is a character-shape check, not an allowlist: an unknown dynamic key such as…
Medium severity Sources/​APIExplorer/​DiscoveryAudit.swift — Invalid mobile-token contents are thrown as DiscoveryError.unsupportedRequest, so this catch…
Medium severity Sources/​APIExplorer/​main.swift — This mobile fingerprint is internally contradictory: Android API level 36 is Android 16, while both…
What changed in this PR

Adds bounded, read-only API discovery with redacted reporting, mobile probes, tests, and capability documentation.

Changes:

  • Adds allowlisted traversal and schema reporting.
  • Adds mobile profiles and private OAuth token input.
  • Documents API capabilities and verification results.
File Review
Tests/​APIExplorerTests/​DiscoveryAuditTests.swift Adds discovery safety, traversal, redaction, and mobile behavior tests.
Sources/​APIExplorer/​main.swift Adds CLI and mobile profiles. Moderate: Android API level 36 conflicts with the Android 13 OS and User-Agent profile.
Sources/​APIExplorer/​DiscoveryAudit.swift Implements validation, traversal, and reporting. Critical: Unknown letters-only dynamic keys can bypass redaction. Moderate: Malformed mobile tokens produce a misleading request-validation error.
Package.swift Registers the API Explorer test target.
docs/​api-discovery.md Documents capabilities, probe results, and verification limits.
Suppressed comments (1)

Sources/APIExplorer/DiscoveryAudit.swift:283

  • Unknown FEmusic_ browse IDs are returned in full whenever they contain only lowercase letters/underscores. Since browse IDs may come from a private body file or an untrusted response, a value such as FEmusic_private_account is printed and saved despite the report's promise to show only ID families. Allowlist the known public frontend routes and collapse every other FEmusic_ value to a family marker.
    static func browseFamily(_ value: String) -> String {
        if value.hasPrefix("FEmusic_"), value.count <= 90,
           value.dropFirst(8).unicodeScalars.allSatisfy({ (97 ... 122).contains($0.value) || $0.value == 95 })
        {
            return value
        }

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Sources/APIExplorer/DiscoveryAudit.swift Outdated
Comment thread Sources/APIExplorer/DiscoveryAudit.swift Outdated
Comment thread Sources/APIExplorer/main.swift Outdated

@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: 5cf8076237

ℹ️ 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 Sources/APIExplorer/DiscoveryAudit.swift Outdated
Comment thread Sources/APIExplorer/DiscoveryAudit.swift Outdated
Comment thread Sources/APIExplorer/main.swift Outdated
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Copilot AI review requested due to automatic review settings September 5, 2026 06:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The unresolved redaction issues and inconsistent Android profile must be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 3 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity Sources/​APIExplorer/​DiscoveryAudit.swift — Value equality is not enough to identify a safe UI label because this helper runs on every response…
Pre-existing issues (3)
Severity Finding
High severity Sources/​APIExplorer/​DiscoveryAudit.swiftschemaKey is a character-shape check, not an allowlist: an unknown dynamic key such as… View comment
Medium severity Sources/​APIExplorer/​main.swift — This mobile fingerprint is internally contradictory: Android API level 36 is Android 16, while both… View comment
Medium severity Sources/​APIExplorer/​DiscoveryAudit.swift — Invalid mobile-token contents are thrown as DiscoveryError.unsupportedRequest, so this catch… View comment
Suppressed comments (3)

Sources/APIExplorer/DiscoveryAudit.swift:259

  • The redaction rule treats every lowercase alphabetic object key as a public schema name. For example, an untrusted response key such as privateaccount is emitted verbatim in verbose output, despite the test and documentation promising that dynamic keys stay hidden. Use a curated set of known schema keys (or redact unknown keys) rather than inferring safety from spelling.
    static func schemaKey(_ key: String) -> String {
        guard !key.isEmpty, key.count <= 100,
              key.first?.isASCII == true, key.first?.isLowercase == true,
              key.unicodeScalars.allSatisfy({ (65 ... 90).contains($0.value) || (97 ... 122).contains($0.value) })
        else { return "<key>" }
        return key

Sources/APIExplorer/main.swift:699

  • This profile sends a contradictory Android identity: both osVersion and the user agent declare Android 13, but API level 36 corresponds to Android 16 (Android 13 is API 33). That undermines the request-comparison results and can itself cause client validation failures. Align the SDK level with Android 13, or update all OS fields together, and adjust the test that currently locks in 36.
            context.merge([
                "osName": "Android", "osVersion": "13", "androidSdkVersion": 36,
                "clientFormFactor": "SMALL_FORM_FACTOR",
            ]) { _, value in value }

docs/api-discovery.md:517

  • account/account_menu is not implemented in Kaset: fetchAccountsList calls only account/accounts_list (Sources/Kaset/Services/API/YTMusicClient.swift:1454-1466), and account/account_menu appears only in the authentication-policy allowlist at line 1908, with no caller or parser. Keep this endpoint in the not-implemented table so the status section does not overstate app support.
| `account/account_menu` | Account Menu | 🔐 | Current account info and settings |

Comment thread Sources/APIExplorer/DiscoveryAudit.swift

@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: 75497d9ab2

ℹ️ 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 Sources/APIExplorer/DiscoveryAudit.swift Outdated
Comment thread Sources/APIExplorer/DiscoveryAudit.swift
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Copilot AI review requested due to automatic review settings September 5, 2026 22:01
@sozercan

sozercan commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Also addressed the documentation finding from the review summary in 75395b6: account/account_menu is now marked not implemented because it has no app caller or parser; account selection uses account/accounts_list.

Validation: swift build, SwiftLint, SwiftFormat, and 36 focused unit tests pass. Guest requests remained guest across a followed Home chip, and the Android comparisons were repeated with matching Android 13 / SDK 33 identities. The results are recorded in docs/api-discovery.md.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Version validation must reject empty dot-delimited components before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity Sources/​APIExplorer/​main.swift — The new version validator still accepts values such as ., 1..2, and 1. because it only checks…
Issues resolved since last review (4)
Severity Finding
Medium severity Sources/​APIExplorer/​DiscoveryAudit.swift — Value equality is not enough to identify a safe UI label because this helper runs on every response… View resolved comment
Medium severity Sources/​APIExplorer/​main.swift — This mobile fingerprint is internally contradictory: Android API level 36 is Android 16, while both… View resolved comment
Medium severity Sources/​APIExplorer/​DiscoveryAudit.swift — Invalid mobile-token contents are thrown as DiscoveryError.unsupportedRequest, so this catch… View resolved comment
High severity Sources/​APIExplorer/​DiscoveryAudit.swiftschemaKey is a character-shape check, not an allowlist: an unknown dynamic key such as… View resolved comment

Comment thread Sources/APIExplorer/main.swift Outdated
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Copilot AI review requested due to automatic review settings September 5, 2026 22:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The authentication, traversal, and security-sensitive discovery changes require final human review.

Review tier: Balanced
Findings: None

Issues resolved since last review (1)
Severity Finding
Medium severity Sources/​APIExplorer/​main.swift — The new version validator still accepts values such as ., 1..2, and 1. because it only checks… View resolved comment

@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: 6737a284ad

ℹ️ 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 Sources/APIExplorer/DiscoveryAudit.swift
Comment thread Sources/APIExplorer/DiscoveryAudit.swift Outdated
Comment thread Sources/APIExplorer/DiscoveryAudit.swift Outdated
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Copilot AI review requested due to automatic review settings September 5, 2026 22:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The authentication, credential handling, and discovery behavior require final human review.

Review tier: Balanced
Findings: None

@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: 870112b9c1

ℹ️ 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 Sources/APIExplorer/main.swift
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Copilot AI review requested due to automatic review settings September 5, 2026 22:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The critical overwrite guard issue could replace saved authentication cookies with report output.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity Sources/​APIExplorer/​DiscoveryAudit.swift — The overwrite guard covers the explicit body/token files but omits the cookie archive that…

Comment thread Sources/APIExplorer/DiscoveryAudit.swift Outdated

@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: 452b984771

ℹ️ 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 Sources/APIExplorer/DiscoveryAudit.swift Outdated
Comment thread Sources/APIExplorer/DiscoveryAudit.swift Outdated
Comment thread Sources/APIExplorer/DiscoveryAudit.swift
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Copilot AI review requested due to automatic review settings September 5, 2026 22:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The authentication and API traversal changes require final human review.

Review tier: Balanced
Findings: None

Issues resolved since last review (1)
Severity Finding
High severity Sources/​APIExplorer/​DiscoveryAudit.swift — The overwrite guard covers the explicit body/token files but omits the cookie archive that… View resolved comment

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.

2 participants