Yolk SDK
Connectors

Telegram conformance

Experimental Telegram conformance cases for tests and hand-run practice-bot checks.

Telegram actions are documented in the connectors package guide and the integrations reference. This page lists the experimental conformance cases only.

Conformance cases

Experimental. For tests and hand-run checks against a practice bot and chat.

@yolk-sdk/connectors/telegram/conformance exports conformance cases for @yolk-sdk/conformance/runner. Every case runs the real connector actions, or the host-only downloadTelegramFile helper, over the connector ports, and checks one wire claim the connector relies on. The Telegram actions (telegram.validate, telegram.send_message) read only the HTTP status of Bot API answers, never the body's ok field, so the cases observe that field at the port the host provides; they send no request of their own. The host-only downloadTelegramFile does decode the getFile result (file_id, file_path, and the optional file_size). The claims are as currently understood; none is observed live yet.

Case idSafetySeedsClaim (as currently understood)
telegram.validate.get-chatreadchatIdtelegram.validate is one POST getChat (not getMe), answered 2xx with ok: true for a chat the bot is in
telegram.errors.error-envelopereadchatIdAn absent chat and a token that names no bot both answer a 4xx status (not 200, not 5xx) with ok: false (exact 4xx unverified; other fields unchecked)
telegram.files.get-file-pathreadfileIdgetFile echoes the file_id (unverified) and a relative file_path; the file URL answers exactly file_size bytes (the seed must report a size)
telegram.messages.send-messagewrite-irreversiblechatId, runIdsendMessage answers 2xx with ok: true, still accepting disable_web_page_preview (unverified); the message stays

Claims no live run has settled yet, marked "(unverified: ...)" in each case's wire:

  • getChat for a chat the bot is not a member of answers 400 (chat not found).
  • getChat with a token that names no bot answers 401 or 404.
  • getFile echoes the file_id it was given rather than another valid id for the same file; downloadTelegramFile fails with invalid_metadata otherwise.
  • sendMessage still accepts the deprecated disable_web_page_preview field (Bot API 7.0 replaced it with link_preview_options), which the connector sends on every message.

Not covered: sendMessage rate limiting. The connector maps HTTP 429 to telegram_rate_limited without reading parameters.retry_after, and a practice run cannot provoke a 429 without flooding the chat, so no case claims it; the send case treats a 429 as a definitive rejection.

The error-envelope case checks the part of the envelope the connector's status-only reading depends on: an error comes back as a 4xx status, never as 200 with ok: false (which the connector would report as success) and not as a 5xx (which the send case treats as an unknown outcome). It does not check error_code, description, or parameters, which the connector never reads.

downloadTelegramFile treats file_size as optional and checks the byte count only when it is present. The get-file case therefore requires, as a precondition:, a seeded file whose getFile answer reports file_size, so the byte-count check is exercised; a size-less answer is a seed problem, not a claim failure.

TelegramConformanceConfig holds the seeds: chatId (an integer chat id or @username of a practice chat the bot is a member of), fileId (the file_id of a small plain UTF-8 text file, at most 1 MB, the bot received, whose getFile answer reports its size), and runId. Cases never hard-code account data, and a missing seed fails the case with a precondition: mismatch before any request. Credentials bind through telegramConformanceIntegration(chatId) (telegram.bot_token, credential ref telegram.conformance, integration config chatId). The bot token is part of every Bot API URL: hosts must never log those URLs, and case failures never carry one.

The send is irreversible

telegram.messages.send-message posts a real message to the seeded chat, and the connector cannot delete it (it has no delete action). The case is therefore write-irreversible: it never runs under allowWrites: 'reversible', and a runner starts it only when a person names its exact id (allowIrreversible: ['telegram.messages.send-message']; the live runner's --allow-irreversible telegram.messages.send-message). Nothing is cleaned up afterwards.

  • The message text is yolk-conformance <runId>: synthetic conformance message, safe to ignore. The runId seed is a per-invocation run-<hex> value (the fixtures replay with run-synthetic; the live runner generates a fresh one every time and never takes it as a flag), so each run's message is distinct.
  • The send, the decoding of its observed answer, and its classification run together without interruption; an interruption waits for the answer. Neither the runner nor the bridges set a request timeout.
  • A definitive rejection (HTTP 4xx other than 408; 429 included) sent nothing: the case fails without advice. A 408 (request timeout) counts as ambiguous.
  • An ambiguous outcome (a transport or decoding failure, no status, HTTP 408 or 5xx, or a 2xx whose body does not carry ok: true, which the connector itself would report as sent) may have delivered the message anyway: the case fails with TelegramConformanceActionFailed (sendOutcome: 'unknown') naming the exact text to look for in the chat. When that happens while the case is being interrupted, the message is also handed to ConformanceCleanupReporter, which the live runner prints as a WARN line.

There is no leftover lookup: the Bot API cannot list the messages a bot sent, and there is nothing to clean up.

In the live runner, the first SIGINT or SIGTERM (Ctrl-C) interrupts the run fiber; a send already in flight completes first, and no further case starts. The interruption messages point at the chat: a message the send case posted stays there, starting with yolk-conformance run-, and nothing else is created (there is no leftover advice). When the send is enabled, the runner prints the run id before any case runs, so the message can be found even after a forced exit. Further signals within a second count as the same keypress; a later one exits at once. Run live runs as pnpm conformance:telegram … or ./node_modules/.bin/tsx scripts/run-telegram-conformance.ts …, not pnpm exec tsx …, which returns to the prompt at once on Ctrl-C.

The shipped fixtures are synthetic (evidence: 'unverified'), and their URLs carry the synthetic telegramConformanceReplayBotToken (123456789:yolk-synthetic-replay-token). In this repository, pnpm conformance:telegram dry-runs by default; --live --owner-approved --account <label> (refused whenever CI is non-empty) needs TELEGRAM_BOT_TOKEN (refused before any request unless it has the <bot id>:<secret> shape) and the seeds, and --allow-irreversible telegram.messages.send-message adds the send (--allow-writes never does). --record replaces the live bot token with the replay token in every recorded URL, then refuses to stage, or print a review checklist for, any recording in which the token or its secret part survives anywhere: URLs, request and response headers, request bodies, text bodies, decoded base64 bodies, stream chunks reassembled as bytes, and every JSON string value after parsing (so \u escapes are undone). It looks for each raw, percent-encoded, \u/\x/HTML-escaped, and base64-encoded (standard and URL-safe, at every byte alignment, including MIME-style folded base64).

What the guard can inspect is an allowlist: strict UTF-8 text without NUL characters. Any body, decoded bodyBase64, or reassembled chunk stream that does not decode as strict UTF-8 (a TextDecoder with fatal: true), or that contains a NUL, is refused as uninspectable whatever it contains: binary files, compressed files of any format, images, and UTF-16 text alike, as well as undecodable base64. The fileId seed must therefore name a plain UTF-8 text file; any other download refuses the recording (the case itself still runs and reports normally). Recordings that pass are staged only in the gitignored .conformance-recordings/telegram/ for manual scrubbing and promotion. See Conformance APIs for the bridges.

For offline tests, the experimental Telegram emulator (@yolk-sdk/emulators/telegram) is a stateful, fixture-only stand-in that passes these cases, including the send (recorded in its state, never delivered), without ever keeping or echoing the bot token from the URL path.

On this page