Skip to content

feat: /check from Telegram to look for a new commit now #8

Closed

Description

@groupsky

Today pullgate run NAME starts only from its timer (pullgate-run@NAME.timer, every 5 minutes in the example). After a push, the owner waits for the next round. Let the owner send /check (all instances) or /check NAME to the bot, so the host fetches now and, when there is a new commit, asks the usual Apply question at once.

How it must fit the design

  • The listener stays as small as it is. It also takes message updates (allowed_updates = ["callback_query", "message"]), but only from owner_id in chat_id, and only the exact text /check or /check NAME, where NAME is in instances of listener.toml. Anything else: ignore it (no answer to other users, no log of the text).
  • All the listener can do is write a check request into the instance's inbox: a fixed-form file with no data from the message (the file name or a fixed kind field says "check"; nothing else). It can still not cause an apply.
  • Root decides. A path unit (or the existing apply path unit) starts pullgate-run@NAME.service for the request; root removes the request file under the same checks as an approval (regular file, owner, size, no symlinks). The run is the normal run: same sandbox, same rules (v0.1: pull a repo, ask the owner on Telegram, apply one exact commit #1 rules 1–6). No new code path that applies anything.
  • Rate limit per instance (for example at most one requested run per minute), so a flood of /check cannot make the host fetch all the time. Extra requests in that time are dropped, with one reply.
  • Reply on every accepted /check: "checking NAME…", and after the run either the Apply question (as today) or "NAME: no new commit (applied SHA …)", or "NAME is paused / off".
  • Paused or mode = "off" instances: reply so, do not fetch.

Threats to cover in THREAT-MODEL.md

  • A stolen bot token: the thief cannot send messages as the owner. Even a forged request only fetches and asks; it never applies.
  • A message in another chat or from another user: ignored.
  • Many requests: the rate limit.

Done when

  • /check and /check NAME work as above; DESIGN.md (sections 3, 8, 9) and README describe them.
  • Tests for the deny paths: other user, other chat, unknown NAME, extra text, edited message, rate limit, paused and off instance, a check request file that is a symlink or has the wrong owner. And a test that a check request never leads to an apply without a tap.
  • THREAT-MODEL.md has the entries above.
  • The example units in contrib/systemd/ start the run on a request; the units test in CI covers it.
  • Security review subagent run on the PR, findings fixed.

More from review (2026-11-11)

  • How root checks a request. Today root accepts an inbox file only with a code it recorded (rule 4, THREAT-MODEL T2/T12). A check request has no code. Write down the new file kind, how root checks it, and update T2 and T12. The listener stays untrusted.
  • Root enforces the rate limit, not the listener (T2). The listener may also limit, but root must not trust it.
  • mode = "auto" (DESIGN section 13): there a run writes the auto approval itself, so /check would lead to an apply without a tap. Decide and write down: refuse /check for auto instances, or allow it and say clearly that auto instances apply on /check as on the timer. The "never applies without a tap" test is then for mode = "ask".
  • More deny tests: a replayed update_id; /check@otherbot; a request while the lock is held (it waits or is dropped, never runs twice at once); a request for an auto instance (as decided above).

Activity

  1. groupsky commented on Nov 12, 2026

    @groupsky
    ContributorAuthor

    Done in #13 (fbd8782).

    • /check and /check NAME: the listener writes a fixed spool/NAME/check/request; contrib/systemd/pullgate-check@.path (PathExists=) starts the normal pullgate-run@NAME.service. Root checks and removes the file like an approval, and keeps the rate limit (one requested run per minute, in its own state). Paused/off: reply, no fetch. mode = "auto": allowed, applies as the timer would (DESIGN section 13, README). DESIGN sections 3, 8, 9, 13 and README describe it.
    • Deny tests: TestCheckCommandsThatDoNotCount (other user, other chat, unknown NAME, extra text, edited message, /check@otherbot), TestReplayedUpdateIsIgnored, TestCheckRateLimitByRoot, TestCheckPausedAndOff, TestBadCheckRequests (symlink, wrong owner, too big, wrong content, directory, FIFO), TestCheckBadRequestFiles, TestCheckWaitsForTheLock, TestCheckWaiterStopsWhenRequestIsGone, TestCheckAutoModeApplies, and TestCheckRequestNeverAppliesWithoutTap (mode ask). e2e: /check from another user does nothing; the owner's /check runs and replies.
    • THREAT-MODEL.md: T1 (stolen token, other user/chat), T2 and T12 (the new file kind, root checks it, root keeps the limit), new T18 (many requests).
    • Units: pullgate-check@.path; the CI "example units" job runs systemd-analyze verify on it.
    • Reviews: security reviewer (three passes) and a correctness review; findings fixed. Not fixed (in the PR text): an older pullgate cannot read the new state fields; a taken-over listener can hit the path unit's trigger limit and so turn /check off until reset (only denies).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: lowDo when nothing else waits

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions