Skip to content

Coordinate CLI and server access to one tgcli store #35

Description

@dapi

Problem

tgcli server and standalone CLI processes can open the same account store without one shared ownership protocol. Some CLI read paths instantiate a writable archive service and can reset a running sync job during shutdown. The CLI must remain able to read the local archive while a server or sync --follow owns the store, and must retain full standalone Telegram and write capabilities when no owner runs.

Decision and implementation contract

Follow docs/adrs/0001-coordinate-cli-and-server-store-access.md and docs/specs/cli-server-store-concurrency.md on branch docs/adr-server-store-owner.

  • One owner per account store opens the writable archive service and MTProto session.
  • Archive-only CLI reads use a separate read-only SQLite path and never initialize Telegram or mutate jobs.
  • A running server, sync --follow, sync --once, or auth --follow serves owner-dependent CLI commands over private local IPC, regardless of mcp.enabled.
  • Without an owner, the CLI acquires the store lock and performs Telegram calls and writes itself. Concurrent one-shot owners wait; a live but unreachable serviceable owner is never bypassed.
  • Route all CLI commands according to the specification, including implicit live fallbacks and media paths.

Acceptance

  • A CLI archive query can run during active sync without changing the active job or opening another Telegram session.
  • Two CLI clients can issue owner-dependent commands to one server or follow process with MCP disabled.
  • With the server stopped, CLI live reads, mutations, and sync work under a single store lock.
  • Startup/shutdown races, stale locks, IPC identity/version/permissions, and unreachable-owner behavior are covered by process-level tests.
  • Update SKILL.md and CLI documentation for the strict --source archive behavior.

Implement in the reviewable phases defined in the specification; keep the ADR in draft until the decision is reviewed.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions