Skip to content

[codex] add platform channel smoke script - #16

Merged
calvin-archastro merged 1 commit into
mainfrom
codex/platform-channel-smoke-tests
Jun 12, 2026
Merged

[codex] add platform channel smoke script#16
calvin-archastro merged 1 commit into
mainfrom
codex/platform-channel-smoke-tests

Conversation

@calvin-archastro

Copy link
Copy Markdown
Contributor

What changed

Adds scripts/smoke_platform_channels.py, a live smoke harness for the generated Python websocket channel helpers. The script creates an authenticated AsyncPlatformClient, opens the platform socket, joins an API chat channel by thread ID or keyed thread, lists messages, optionally posts a simple message, and verifies the posted message is visible on readback.

The script is intentionally small and CLI driven so SDK maintainers can run it against a local platform-rs instance while iterating on websocket generation or channel auth behavior.

Diagrams

sequenceDiagram
    participant Dev as SDK maintainer
    participant Script as smoke_platform_channels.py
    participant Client as AsyncPlatformClient
    participant Socket as Platform socket
    participant Chat as ApiChatChannel
    participant Platform as platform-rs

    Dev->>Script: run with base url api key access token thread id
    Script->>Client: create token client
    Script->>Client: open socket with auto reconnect disabled
    Client->>Socket: connect using auth params
    Script->>Chat: join user thread or keyed thread
    Chat->>Platform: join api chat channel
    Platform-->>Chat: joined with thread metadata
    Script->>Chat: list messages
    Chat-->>Script: message page
    alt posting enabled
        Script->>Chat: post simple message with idempotency key
        Chat-->>Script: message id
        Script->>Chat: list messages again
        Chat-->>Script: posted message visible
    else skip post
        Script->>Script: finish after join and list
    end
    Script->>Chat: leave
Loading
classDiagram
    class SmokeScript {
        +main()
        +_run(args)
        +_join_chat_channel(socket thread_id key transient)
        +_assert_ok_reply(name reply)
        +_message_ids(response)
    }
    class AsyncPlatformClient {
        +with_token(api_key access_token base_url)
        +open_socket(url auto_reconnect)
    }
    class ApiChatChannel {
        +join_user_thread(socket thread_id)
        +join_user_keyed(socket key)
        +join_user_transient(socket key)
        +api_chat_list_messages(payload)
        +api_chat_post_simple_message(payload)
        +leave()
    }
    class PlatformSocket
    SmokeScript ..> AsyncPlatformClient : constructs
    SmokeScript ..> ApiChatChannel : exercises
    AsyncPlatformClient ..> PlatformSocket : opens
    ApiChatChannel ..> PlatformSocket : uses
Loading

Scope indicator

SDK tooling only. This does not change the generated SDK runtime, backend services, or frontend code.

Risk assessment

Low risk. The change adds an opt-in smoke script under scripts/ and does not affect package import behavior or generated code paths. The only runtime dependency is the existing generated Python SDK.

User impact

No direct end-user impact. SDK maintainers get a repeatable local smoke test for websocket channel send and readback behavior.

Testing

  • uv run ruff check scripts/smoke_platform_channels.py
  • uv run ruff format --check scripts/smoke_platform_channels.py
  • git diff --check
  • Live local platform smoke against an existing CLI-created thread:
    • joined API chat channel successfully
    • listed 4 existing messages
    • posted msg_033XHoOV1Qu7D5IegD14or
    • read the same message ID back through the channel

Earlier refreshed-checkout verification also ran ARCHASTRO_RUN_CHANNEL_CONTRACT_TESTS=1 PYTHONDONTWRITEBYTECODE=1 uv run pytest tests/contract -p no:cacheprovider with 1761 passed.

Follow-ups and known issues

No known issues. This script assumes callers provide a valid publishable API key and user access token through CLI flags or ARCHASTRO_API_KEY and ARCHASTRO_ACCESS_TOKEN.

@archastro

archastro Bot commented Jun 12, 2026

Copy link
Copy Markdown

✅ Clean PR, @calvin-archastro! No blocking findings on e69f322 — a few nice things I clocked:

  • Kept credentials out of the diff cleanly — --api-key/--access-token default to ARCHASTRO_API_KEY/ARCHASTRO_ACCESS_TOKEN via the _env helper, nothing committed. 🎯
  • Nice touch on the import guard — ImportError raises a SystemExit pointing at regenerate_sdk.sh instead of a bare traceback when the SDK isn't regenerated yet.
  • _assert_ok_reply surfaces only the server response on failure, keeping auth params out of error output — consistent with your PII-free logging pattern.

Reply @archastro <verb>: review · do <pattern> · don't <pattern> · forget <slug> · list

@calvin-archastro
calvin-archastro marked this pull request as ready for review June 12, 2026 20:37
@calvin-archastro
calvin-archastro merged commit a31e6cf into main Jun 12, 2026
3 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