Linear

Linear is an issue tracker: an issue assigned to kōjō’s Linear user, labelled with a label you choose, or a comment that mentions kōjō starts a session on the repository the issue maps to. kōjō comments the outcome on the issue, with the pull request’s link, and the pull request names the issue so that Linear links the two.

See Surfaces for how Linear compares with Jira and Asana, and Who may trigger what for whose requests may change code.

How it connects

kōjō acts as an ordinary member of the workspace: a Linear user of its own, reached with that user’s personal API key. Assigning an issue to that user, or mentioning it, is how people ask kōjō for work.

Linear sends a webhook for every change to issues and comments to <public_url>/webhooks/linear. kōjō verifies each delivery before it reads it:

  • Linear-Signature must be the hex HMAC-SHA256 of the raw body, keyed with the webhook’s signing secret (webhook_secret).
  • The body’s webhookTimestamp must be within a minute of kōjō’s clock, so a captured delivery cannot be replayed later.
  • A delivery from another workspace than the API key’s is ignored.

kōjō then reads the issue through Linear’s GraphQL API with the API key, and posts comments and moves the issue the same way.

Set up

kojo setup linear --public-url https://kojo.example.com prints these steps with your address filled in.

  1. Add the Linear user kōjō acts as to the workspace, sign in as it, and create a personal API key: Settings → Security & access → Personal API keys.

  2. As a workspace admin, create a webhook: Settings → API → Webhooks → New webhook. The URL is <public_url>/webhooks/linear; the data change events are Issues and Comments; the teams are all public teams, or the ones kōjō works for. Keep the signing secret the webhook’s page shows.

  3. Add the tracker to kojo.yaml:

    trackers:
      linear:
        api_key: ${LINEAR_API_KEY}
        webhook_secret: ${LINEAR_WEBHOOK_SECRET}
        labels: [kojo]          # optional: adding this label also starts work
        status:                 # optional: off unless set
          started: In Progress
          review: In Review
  4. Map each team or project to its repository in the repos object (dashboard: Settings → Repositories). See Mapping issues to repositories.

  5. Give the people who may have kōjō change code the operator role in the rbac object, under the email they sign in to Linear with.

  6. Run kojo doctor. It checks that the API key reads its user, and warns when no enabled repository takes Linear issues.

Events

What happens in Linear Becomes
An issue is assigned to kōjō’s user, or created with it as the assignee A request for the issue
One of the labels in labels is added to an issue, or an issue is created with one A request for the issue
A new comment on an issue mentions kōjō’s user: its profile URL, which is how Linear writes a mention in Markdown, or @ and its name A request for the issue, or a message to its session

kōjō’s own changes and comments are ignored, and so are comments that are not on an issue, edits, and every other kind of entity. An issue that already has a session at work does not start another when it is assigned or labelled.

Mapping issues to repositories

An issue becomes work on the repository whose tickets entry matches it. A Linear entry names a team by its key, a project by its name or ID, or both, and may add a label:

repos:
  github/acme/api:
    enabled: true
    tickets:
      - { tracker: linear, team: ENG, label: api }
  github/acme/web:
    enabled: true
    tickets:
      - { tracker: linear, team: ENG, label: web }
      - { tracker: linear, project: Checkout }

An issue that matches no enabled repository, or several, starts nothing: kōjō comments on it that it belongs to no repository, or names the repositories it belongs to. The full rules are under repos.

Who may change code

A person’s role in kōjō comes from the rbac object, looked up by email. For Linear that is the email Linear reports for the user, because a Linear account’s address is its sign-in identity: people sign in with a link or code sent to it, with Google, or through the workspace’s SAML provider, and Linear confirms a change of address from both the old and the new one. users maps a Linear user ID to another email, for someone whose rbac entry is under a different address.

  • Someone with the operator or admin role gets a trusted session, which may change code and open a pull request.
  • Anyone else, and every change made by an OAuth application or an integration (Linear reports no email for them), gets a read-only session: kōjō answers on the issue and changes nothing. See What an untrusted session may do.

What kōjō posts

  • The outcome is a comment on the issue, in Markdown: the summary, the pull request’s link, and the goal critic’s report when the change did not meet every criterion. The orchestrator may also post short interim comments while it works.
  • The pull request opened on the forge starts its title with the issue’s identifier (ENG-123: …), and its description says Fixes ENG-123, or Refs ENG-123 when the change did not meet every acceptance criterion or spans several repositories, with a link to the issue. Linear’s GitHub and GitLab integrations link a pull request by the identifier in its title. With Fixes, merging the pull request moves the issue to the status the team’s workflow sets for a merge; with Refs it does not.
  • The status moves only when status names one: started when a session that may change code is queued for the issue, review when it opens a pull request. kōjō looks the status up by name among the workflow states of the issue’s team, and leaves an issue that is already there alone. A read-only session moves nothing.

The issue’s title, description, labels and its latest 10 comments are part of the request, inside the fence that marks them as data. See Security.

Talking to a session at work

A new comment that mentions kōjō on an issue whose session is queued or running goes to that session as a message when its author has the operator role. kōjō acknowledges it with a comment, and the session’s next model step reads it. A comment from anyone else is a read-only request of its own. See Talking to a session at work.

Webhook

kōjō answers 200 to a delivery it handled, ignored or turned down, 401 to one whose signature does not verify or that is more than a minute old, and 500 when it could not handle it, for example because Linear’s API did not answer. Linear retries a delivery that did not get a 200 after a minute, an hour and six hours. The same change delivered twice is handled once.

Limits

  • kōjō is a Linear user, so it takes a seat. Linear’s agent features (an OAuth application acting as itself, issues delegated to an agent) are not used.
  • A mention is recognised by kōjō’s profile URL or @ and its name in the comment’s Markdown.
  • An approval the merge policy would ask for in chat has no chat thread to be asked in, so the session takes the more careful outcome there.
Scroll to move. + - zoom, 0 fit, Esc close.100%