Skip to content

feat: nodkey try --telegram (stage 2 of #125) - #144

Draft
groupsky wants to merge 10 commits into
mainfrom
feat/125-try-telegram
Draft

groupsky wants to merge 10 commits into
mainfrom
feat/125-try-telegram

Conversation

@groupsky

@groupsky groupsky commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Refs #125

Stage 2: nodkey try --telegram, approval on a phone with a new bot. Stage 1 (approval in the terminal) was #143.

Behavior for callers

Changes behavior for existing callers: no

nodkey try --telegram is new. nodkey try without the flag, nodkey run and nodkey broker keep their behavior. The only change outside the trial: the body of a Telegram message is cut 32 characters earlier, to keep room for Options.Prefix.

Progress

  • internal/telegram: NewWithToken (token only in memory), Options.Prefix (TRY MODE before every message and edit, at most 32 characters), NewPairing/Wait (getMe, the link, the user ID only from /start CODE in a private chat). Tests: TestPairing*, TestPrefix, TestPrefixRoom, TestNewWithToken.
  • nodkey try --telegram (cmd/nodkey/trytelegram.go): hidden token input (echo off), the /start link with a random code, confirm the name with yes, the Telegram approver with TRY MODE, a clear text on a conflict
  • Tests with the fake Telegram of cmd/nodkey: TestTryTelegram, TestTryTelegramNotConfirmed, TestTryTelegramConflict, TestTryTelegramBadToken, TestTryTelegramInputEnds, TestTryTelegramSignalInSetup, TestTryTelegramWhileATrialRuns
  • DESIGN.md sections 4 and 15, THREAT-MODEL.md T38, README.md "Try it", docs/manual-telegram-test.md check 18 (main added checks 16 and 17) with rows in the results table
  • Rebased onto main on 2026-11-18. Stage 1 is as on main.
  • Reviews after the rebase: correctness and security, then a security review of the fixes (its findings fixed: the network hint only for a failed Bot API call, and a nil error)
  • Manual test with a real new bot: check 18 (needs Geno), then the results in the docs

Fixed after the rebase (review findings)

  • A second nodkey try --telegram checks that no trial runs before it polls the bot, so it cannot stop a running trial with a conflict.
  • A signal during the setup ends with exit code 0 ("stopped before the setup ended"). The end of the input says to run it in a terminal.
  • Every new error says how to fix it (bad token, not confirmed, no user name, network, line too long, core dumps). The usage error names --telegram. The conflict text no longer shows two exit codes.
  • Options.Prefix is at most 32 characters, and every message, also a notice, keeps room for it.
  • THREAT-MODEL T38: what a pasted broker token gives the agent (T6), and that the trial removes the buttons of the broker's message.

Not fixed on purpose (low)

  • Copies of the token as Go strings stay in memory until the GC reuses it. The process is hardened first (no ptrace, no core dump), and T38 already says that the agent may read the trial's memory.
  • The pairing retries a network error every second, with no limit, until Ctrl-C. A person watches it.
  • checkNoTrial takes no lock, so a trial that starts while another waits for its token can still meet it on one bot. Both then deny and stop; nothing is left behind.
  • No cmd-level test for a conflict after the trial started. Check 18 step 4 tests it by hand; the unit tests cover the conflict.

Choices

  • The approver's user ID is taken by a new telegram.Pairing (getMe, then /start CODE in a private chat with its sender). feat: guided broker setup (nodkey setup broker) #98 step 5 can reuse it.
  • TRY MODE on Telegram: telegram.Options.Prefix, added in the client to the text of every sendMessage and editMessageText.
  • Hidden input with TCGETS/TCSETS (echo off), as isTerminal already does: no new dependency.
  • The pairing happens before the trial's directory is made, so a failed pairing leaves nothing behind.

Next

Geno runs check 18 of docs/manual-telegram-test.md and posts the rows on #125. Then a later session adds the results to the docs, marks this ready, merges it and closes #125.

🤖 Generated with Claude Code

groupsky and others added 10 commits November 18, 2026 07:38
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…prefix (#125)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e phone (#125)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…irmed, conflict, bad token (#125)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
….md and the manual test (#125)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Harden the process before the token is read; the guard test covers the
Telegram parts of the trial; Format with value receivers; T38 says that
either poller may stop on a conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main added checks 16 and 17 (1Password, Infisical).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- check that no trial runs before the pairing polls the bot
- a signal during the setup ends with exit code 0; the end of the input says what to do
- every new error says how to fix it; the usage error names --telegram
- Options.Prefix is at most 32 characters, and every message keeps room for it
- the token is trimmed as bytes
- THREAT-MODEL T38: what a pasted broker token gives the agent, and the removed buttons

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…telegram (#125)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@groupsky
groupsky force-pushed the feat/125-try-telegram branch from 998e99a to 0b97ca2 Compare November 18, 2026 05:44

This branch has not been deployed

No deployments
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.

feat: nodkey try, a trial on one machine with fake secrets

1 participant