Asana

Asana is an issue tracker: a task assigned to kōjō’s Asana user, or a comment that mentions kōjō, starts a session on the repository the task’s project maps to. kōjō comments the outcome on the task, with the pull request’s link, and the pull request’s description carries the task’s URL so that Asana’s GitHub integration links the two.

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

How it connects

kōjō acts as an Asana user of its own, reached with that user’s personal access token, or as a service account (Enterprise) with its token. Assigning a task to that user, or mentioning it, is how people ask kōjō for work.

Asana delivers a project’s changes to a webhook created on that project, and a webhook belongs to the token that created it. kojo setup asana creates kōjō’s webhooks with its token, one per project, to <public_url>/webhooks/asana:

  • The handshake. While a webhook is being created, Asana sends a request with an X-Hook-Secret header to that address, and creates the webhook only when the answer carries the same header. kōjō answers every handshake that way. Asana returns the secret once more, in its answer to the creation, which is how kojo setup asana learns it. kōjō does not keep it from the handshake.
  • Signatures. Every later delivery carries X-Hook-Signature, the hex HMAC-SHA256 of the raw body keyed with that webhook’s secret. kōjō accepts a delivery signed with one of the secrets in webhook_secrets and refuses any other, so a webhook someone else creates to kōjō’s address delivers nothing.
  • Compact events. A delivery says what changed, not what it says now. kōjō reads the comment or the task from the API with its token before it acts.

Set up

kojo setup asana --public-url https://kojo.example.com prints these steps.

  1. Create the Asana user kōjō acts as, invite it to the projects it works on, and create a personal access token for it. A service account’s token works too.

  2. Add the tracker to kojo.yaml and start kōjō:

    trackers:
      asana:
        token: ${ASANA_TOKEN}
  3. With kōjō serving at its public URL, create a webhook on each project. The project ID is the number in the project’s address.

    ASANA_TOKEN=... kojo setup asana --public-url https://kojo.example.com \
      --project 1209876543210 --project 1209876543211

    The command writes the webhooks’ secrets to secrets/asana-webhooks.env (--out changes the directory), readable only by you, and prints the lines to add:

    trackers:
      asana:
        token: ${ASANA_TOKEN}
        webhook_secrets: ["${ASANA_WEBHOOK_SECRET_1}", "${ASANA_WEBHOOK_SECRET_2}"]
        status:                 # optional: off unless set
          started: Doing
          review: Review
        users:                  # Asana user ID: email in the rbac object
          "1200000000000001": ana@example.com

    Load that file into kōjō’s environment and restart it. Until then kōjō refuses the webhooks’ deliveries, and Asana deletes a webhook whose deliveries fail for 24 hours.

  4. Map each project to its repository in the repos object (dashboard: Settings → Repositories). See Mapping tasks to repositories.

  5. Map the people who may have kōjō change code under users, and give their emails the operator role in the rbac object. See Who may change code.

  6. Run kojo doctor. It checks that the token reads its own user and that webhook_secrets is not empty, and warns when no enabled repository takes Asana tasks.

Events

kōjō’s webhooks ask Asana for two kinds of change:

What happens in Asana Becomes
A task’s assignee changes to kōjō’s user A request for the task
A comment is added to a task and mentions kōjō’s user A request for the task, or a message to its session

A mention is a link to kōjō’s user in the comment’s rich text, which is how Asana writes one. kōjō’s own changes and comments are ignored, and so are heartbeats, the empty deliveries Asana sends every eight hours. A task that already has a session at work does not start another when it is assigned again.

Asana’s documentation names no webhook event for a tag added to a task, so on Asana a label does not start work and trackers.asana has no labels. A tag can still narrow a mapping.

Mapping tasks to repositories

A task becomes work on the repository whose tickets entry matches it. An Asana entry names a project by its ID, in quotes, and may add a tag as label:

repos:
  github/acme/web:
    enabled: true
    tickets:
      - { tracker: asana, project: "1209876543210" }
  github/acme/api:
    enabled: true
    tickets:
      - { tracker: asana, project: "1209876543211", label: backend }

A task can be in several projects; it matches an entry when one of them is the entry’s. A task 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

Asana’s documentation does not say whether the email it reports for a user was verified, so kōjō does not read emails from Asana. users maps an Asana user ID to the email of that person’s entry in the rbac object, and the role found there decides.

  • Someone mapped to an email with the operator or admin role gets a trusted session, which may change code and open a pull request.
  • Anyone else, and a change Asana makes itself (an event without a user), gets a read-only session: kōjō answers on the task and changes nothing. See What an untrusted session may do.

A user’s ID is the gid Asana’s API gives them; GET /users/me shows your own. users is in kojo.yaml, so changing it needs a restart.

What kōjō posts

  • The outcome is a comment on the task, as plain text: 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 has the task’s name as its title, since Asana tasks have no key, and its description carries the task’s URL. Asana’s GitHub integration, set up with its GitHub Actions, attaches a pull request whose description holds a task’s URL to that task.
  • The status is the task’s section. It moves only when status names one: started when a session that may change code is queued for the task, review when it opens a pull request. kōjō moves the task to the section of that name in the first of its projects that has one, and leaves a task that is already there alone. A read-only session moves nothing.

The task’s name, description, tags 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 a task whose session is queued or running goes to that session as a message when its author is mapped to 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 handshake and to a delivery it handled, ignored or turned down, 401 to one whose signature does not verify, and 500 when it could not handle it, for example because Asana’s API did not answer. Asana retries a delivery that failed for up to 24 hours, then deletes the webhook. The same change delivered twice is handled once.

Limits

  • A webhook is created per project, and a new project needs kojo setup asana --project again.
  • A webhook can only be created while kōjō is serving at its public URL, because Asana’s handshake goes there.
  • 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%