Skip to content
safran

Type to search. Enter opens the first result.

    Multiple trackers and code hosts

    A company rarely has one of everything. This guide shows how to describe two trackers and two code hosts in one safran.yaml, how Safran decides which tracker a pasted reference belongs to, what happens when two hosts both have a repo called payments-api, and how to read the warnings that tell you a result does not cover every source.

    The story: acme keeps its product work in Jira (PAY, MOB, WEB) and its code in Azure Repos. The operations team works in Linear (team key OPS) and keeps its repositories in a self-hosted GitLab group.

    A complete profile

    version: 1
    company: acme
    languages:
      tickets: tr
      code: en
    
    trackers:
      - id: jira
        type: jira
        url: https://acme.atlassian.net
        email_env: JIRA_EMAIL
        token_env: JIRA_TOKEN
        projects: [PAY, MOB, WEB]
      - id: linear
        type: linear
        workspace: acme
        token_env: LINEAR_TOKEN
        projects: [OPS]
    
    code:
      hosts:
        - id: azure
          type: azure-repos
          organization: acme
          project: Platform
          token_env: AZURE_DEVOPS_PAT
        - id: gitlab
          type: gitlab
          url: https://gitlab.acme.test
          group: acme/ops
          token_env: GITLAB_TOKEN
          exclude: ["*-archive"]
      groups:
        backend: [payments-api, ledger]
        mobile: [acme-ios, acme-android]
        frontend: [web-app, admin-panel]
        ops: [ops-tools]
    
    teams:
      - name: Payments
        projects: [PAY]
        repos: [payments-api, ledger]
      - name: Mobile
        projects: [MOB]
        repos: [acme-ios, acme-android]
        confidence: low
        source: 9 ticket-PR links
      - name: Web
        projects: [WEB]
        repos: [web-app, admin-panel]
      - name: Ops
        projects: [OPS]
        repos: [ops-tools]

    Three rules of the profile schema matter as soon as there is more than one source:

    • Every id is unique within its list (trackers, code.hosts, docs). The id is what you type in jira:PAY-1423 and what appears as tracker and host in results.
    • A project key may be listed under one tracker only. Listing PAY under both fails validation with project "PAY" is also listed under tracker "jira"; a ticket key must map to one tracker. The comparison ignores case.
    • Once any tracker declares projects, every project a team lists must be declared by some tracker (project "OPS" is not listed under any tracker).

    Check the result the usual way: safran profile check, then safran profile check --online to make one cheap call per connector. Field-by-field detail for each entry is on the connector pages: Jira, Linear, Azure Repos, GitLab.

    How a ticket reference finds its tracker

    Everything that takes a ticket (safran ticket, safran.tickets.get, the MCP tool get_ticket) accepts whatever a person would paste. Routing happens in one place, tickets.resolve, and makes no network call:

    1. Explicit form. If the reference looks like <trackerId>:<ref> and <trackerId> is a tracker id of the profile, only that tracker is asked. jira:PAY-1423 goes to jira. A URL is never read as this form (https://… is not a tracker called https). If the named tracker does not recognise the rest, the error is NOT_FOUND.
    2. Ask every tracker. Otherwise each tracker's matchTicketRef looks at the text. A tracker returns its canonical key when the reference has its shape, and nothing otherwise.
    3. One match wins. No tracker: NOT_FOUND. Exactly one: that tracker.
    4. Several matches: the profile decides. The project part of each candidate key is looked up in the projects lists. If exactly one of the matching trackers declares that project, it owns the reference.
    5. Still several: an error, not a guess. INVALID_INPUT, with the tracker ids in details.trackers.

    This is what step 5 looks like when two trackers both accept PAY-1423 and neither declares its projects:

    $ safran ticket PAY-1423
    ✘ "PAY-1423" could belong to several trackers: jira, linear
    → Say which one with "<trackerId>:<ref>", e.g. "jira:PAY-1423", or list the project under one tracker's `projects` in the profile.

    Both fixes work. safran ticket jira:PAY-1423 answers at once, and listing projects on each tracker makes the plain PAY-1423 unambiguous for everyone, agents included.

    The same rules from the SDK, over two in-memory trackers that both know a PAY project:

    route.ts
    import { createSafran, isSafranError } from "@safran/core";
    import { FakeTracker, fakePlugins } from "@safran/kit/testing";
    
    const jira = new FakeTracker({
      id: "jira",
      projects: [{ key: "PAY", name: "Payments" }],
      tickets: [{ key: "PAY-1423", title: "Kısmi iade işlemi İstanbul şubesinde başarısız oluyor" }],
    });
    const linear = new FakeTracker({
      id: "linear",
      projects: [
        { key: "PAY", name: "Payments (archive)" },
        { key: "OPS", name: "Operations" },
      ],
      tickets: [{ key: "OPS-7", title: "Rotate the payment provider key" }],
    });
    
    async function open(jiraProjects: string[], linearProjects: string[]) {
      return createSafran({
        profile: {
          version: 1,
          company: "acme",
          trackers: [
            { id: "jira", type: "fake", projects: jiraProjects },
            { id: "linear", type: "fake", projects: linearProjects },
          ],
          embeddings: { type: "fake" },
        },
        plugins: fakePlugins({ trackers: [jira, linear] }),
        index: false,
      });
    }
    
    // Neither tracker declares its projects: both accept the shape, nobody owns the key.
    {
      await using safran = await open([], []);
      try {
        safran.tickets.resolve("PAY-1423");
      } catch (error) {
        if (!isSafranError(error, "INVALID_INPUT")) throw error;
        console.log(error.details?.trackers); // ["jira", "linear"]
      }
      // The explicit form always works.
      console.log(safran.tickets.resolve("linear:PAY-9").tracker.id); // "linear"
    }
    
    // With `projects`, the profile gives every key one owner.
    {
      await using safran = await open(["PAY"], ["OPS"]);
      const { tracker, key } = safran.tickets.resolve("PAY-1423");
      console.log(tracker.id, key); // "jira" "PAY-1423"
    }
    export interface ResolvedTicketRef {
      tracker: Tracker;
      /** Canonical key in that tracker. */
      key: string;
    }

    defined in packages/core/src/api.ts

    What each built-in tracker accepts

    Which pairs can collide follows from the shapes each tracker claims.

    TrackerReferences it recognisesNever recognises
    jiraPAY-123; issue URLs under the configured site (/browse/PAY-123, …/issues/PAY-123, REST …/issue/PAY-123, service desk portal URLs, board URLs with ?selectedIssue=)a bare number, #123
    linearOPS-123; https://linear.app/<workspace>/issue/OPS-123/… (only the configured workspace when one is set)a bare number, #123
    azure-boards123, AB#123; work item URLs of the configured organization (…/_workitems/edit/123, REST …/_apis/wit/workItems/123, board URLs with ?workitem=123)#123
    github-issuesrepo#123, owner/repo#123; #123 only when exactly one repository is configured; issue URLs on the web host and the APIa bare number; /pull/123 URLs

    For jira and linear, the projects list also changes how strict the key match is. With a list, only those projects match, in any case (pay-1423 from a branch name works). Without a list, any project matches, but only written in upper case, so utf-8 or sha-256 in a sentence is not taken for a ticket.

    Jira + Linear share the KEY-123 shape. Without projects, every upper-case key matches both and each lookup ends in the ambiguity error above. List projects on both. A URL is never ambiguous: each tracker only accepts URLs of its own site.

    Azure Boards + GitHub Issues do not collide. Azure Boards takes the bare number and AB#123 and leaves #123 alone; GitHub Issues takes #123 and repo#123 and never a bare number. One documented exception: if a repository named AB is configured on the github-issues entry, AB#123 is claimed by both and you name the tracker.

    version: 1
    company: acme
    trackers:
      - id: boards
        type: azure-boards
        organization: acme
        project: Platform
        token_env: AZURE_DEVOPS_PAT
      - id: issues
        type: github-issues
        owner: acme
        repos: [web-app]
        token_env: GITHUB_TOKEN
    code:
      hosts:
        - id: azure
          type: azure-repos
          organization: acme
          project: Platform
          token_env: AZURE_DEVOPS_PAT
        - id: github
          type: github
          owner: acme
          repos: [web-app, admin-panel]
          token_env: GITHUB_TOKEN

    With this profile 1423 and AB#1423 go to boards, and #412 and web-app#412 go to issues (#412 works because exactly one repository is configured there).

    Searching tickets across trackers

    safran tickets, safran.tickets.search and the MCP tool search_tickets ask every tracker that supports search and merge the answers. Each item carries the id of the tracker it came from.

    safran tickets "iade" --status done
    safran tickets "key rotation" --tracker linear
    safran tickets "iade" --project PAY

    How one page is put together:

    • Equal shares. The page size is divided evenly between the trackers that still have results (limit 20 over two trackers: 10 each; an odd remainder goes to the trackers listed first). Results are grouped by tracker, not re-ranked against each other: relevance scores of two trackers are not comparable.
    • One cursor. nextCursor remembers each tracker's own position. Pass it back unchanged with the same query; a cursor from another search is refused with INVALID_INPUT.
    • projects narrows the trackers. A tracker that declares projects and has none of the requested ones is not asked. A tracker without a projects list is always asked, because Safran cannot know what it holds.
    • tracker picks one. An unknown id fails with INVALID_INPUT and a hint listing the configured trackers. A native query (JQL, WIQL) is tracker-specific, so the MCP tool requires tracker with native.
    • A failing tracker does not fail the search. Its error becomes an entry in warnings, it is dropped from the cursor so later pages keep working, and the other trackers' items are returned. Only when every tracker fails does the call throw.

    warnings is therefore the field to check before concluding that nothing exists:

    search-all.ts
    import type { Safran } from "@safran/core";
    
    export async function findEverywhere(safran: Safran, text: string): Promise<void> {
      const page = await safran.tickets.search({ text }, { limit: 20 });
      for (const ticket of page.items) {
        console.log(`${ticket.tracker}  ${ticket.key}  ${ticket.title}`);
      }
      for (const warning of page.warnings ?? []) {
        // The page does not cover this tracker: it failed, or it cannot run this search.
        console.warn(`${warning.source} (${warning.code}): ${warning.message}`);
      }
    }
    export interface TicketSearchResult extends Page<TicketSummary & { tracker: string }> {
      /**
       * Present when the page does not cover every tracker: one entry per tracker that failed (with
       * the code of its failure) or was left out because it cannot run this search (UNSUPPORTED).
       * The items of the others are still returned.
       */
      warnings?: SafranWarning[];
    }
    
    /** Something that did not stop a call but made its answer incomplete or ambiguous. */
    export interface SafranWarning {
      /** Profile entry id of the tracker or code host the warning is about. */
      source: string;
      code: SafranErrorCode;
      message: string;
    }

    defined in packages/core/src/api.ts

    A warning with code UNSUPPORTED means the tracker was left out because it cannot run this kind of search at all; any other code is the code of the failure (AUTH_FAILED, RATE_LIMITED, UPSTREAM, …). More on searching is in Reading tickets and the ticket tools.

    Several code hosts

    Each entry under code.hosts lists its repositories; Safran merges the lists into one namespace of short names. payments-api is the name you use in --repo, in code.groups, in teams[].repos and in every MCP tool, whichever host it lives on.

    include and exclude

    Both are lists of glob patterns per host entry, applied to what the host lists before anything else happens:

    • * is any run of characters, ? is exactly one; everything else is literal.
    • Matching is case-insensitive and always covers the whole name.
    • A pattern is tried against the repo's short name and its full name on the host, so both *-archive and a pattern written against the full path can match.
    • An empty include means "everything". exclude wins over include.

    Name collisions

    When two hosts list the same short name, the host that comes first in the profile keeps it. The later one is renamed to <hostId>/<name>, and the rename is reported. Suppose the gitlab group also has a payments-api (an old fork the operations team keeps):

    $ safran repos
    repo                 host    groups    teams     cloned  indexed
    payments-api         azure   backend   Payments  yes     just now
    ledger               azure   backend   Payments  yes     just now
    web-app              azure   frontend  Web       yes     just now
    admin-panel          azure   frontend  Web       yes     just now
    ops-tools            gitlab  ops       Ops       yes     just now
    gitlab/payments-api  gitlab  ops       Ops       yes     just now
    
    6 repos, all indexed
    ! Repo "payments-api" exists on an earlier code host; the one on "gitlab" is named "gitlab/payments-api"

    The qualified name is a real name from then on. It is what the index stores and what you write in the profile:

    code:
      groups:
        ops: [ops-tools, gitlab/payments-api]
    teams:
      - name: Ops
        projects: [OPS]
        repos: [ops-tools, gitlab/payments-api]
    $ safran owns --repo gitlab/payments-api
    Ops  owns repo gitlab/payments-api — declared in the profile
      Ops  repos ops-tools, gitlab/payments-api

    Three consequences worth knowing:

    • Order is identity. Swapping the two host entries swaps which repo is called payments-api. Groups, teams and the index refer to names, so reorder hosts deliberately and run safran sync afterwards.
    • Prefer exclude when you do not need the duplicate. If the fork is noise, exclude: [payments-api] on the gitlab entry removes the collision and the warning.
    • On disk nothing collides. Clones live under <data dir>/repos/<host>/<repo>, one directory per host.

    Reading the warnings

    Problems with the listing do not stop a command; they are collected and returned by safran.repos.warnings(). The CLI prints them on stderr with a !, and safran repos --json and safran sync --json carry them in warnings.

    repo-warnings.ts
    import type { Safran } from "@safran/core";
    
    export async function listWithWarnings(safran: Safran): Promise<void> {
      const repos = await safran.repos.list({ refresh: true });
      for (const repo of repos) console.log(`${repo.host}\t${repo.name}`);
      for (const warning of safran.repos.warnings()) {
        console.warn(`${warning.source} (${warning.code}): ${warning.message}`);
      }
    }
    SituationcodeWhat Safran does
    A later host lists a short name an earlier host already hasINVALID_INPUTNames the later repo <hostId>/<name>
    One host lists the same repo name twiceUPSTREAMKeeps the first one
    A host could not list its repos (token, network, rate limit)the code of that failureReturns the repos of the other hosts; the incomplete listing is not cached, so the next call asks that host again

    When every host fails, the listing throws instead (the single error, or one error naming each host). And while a listing is incomplete, safran sync does not drop anything from the index: a repo that is missing because its host did not answer is unknown, not gone. Removal of repos no host lists any more only happens after a full sync in which every host answered; see Keeping the index fresh.

    A host whose credentials are rejected during a sync fails once: its remaining repos are reported as failed without being attempted, and the repos of the other hosts are synced normally.

    Groups and teams across hosts

    Groups and teams are lists of repo names and know nothing about hosts. A group can mix hosts freely:

    code:
      groups:
        payments-everywhere: [payments-api, ledger, gitlab/payments-api]

    safran search "iade" --group backend, safran repos --group ops and the groups argument of the MCP code tools all resolve the group from the profile at call time. A repo may sit in several groups. A group name that the profile does not define is an error (INVALID_INPUT, with the known groups in the hint), not an empty result.

    A team owns projects from any tracker and repos from any host. safran owns --project OPS and safran owns --repo ops-tools answer from the same teams list.

    Work history across hosts

    The link store (safran links refresh) keeps merged pull requests from every host that can list them. Each record carries its host next to repo, and records are stored per host and repo, so two hosts' pull request number 101 never overwrite each other.

    Two things decide how well tickets and code are tied together in a mixed setup:

    • Ticket keys are recognised by the declared projects. Besides the links a host reports natively, Safran looks for ticket keys in the pull request title, source branch and description, and it looks only for the project keys declared under trackers[].projects across all trackers. With the profile at the top of this page, a GitLab merge request titled OPS-7 rotate provider key is linked to the Linear ticket and an Azure Repos pull request on branch feature/pay-1423-partial-refund to the Jira one. A profile that declares no projects gets only the host-native links.
    • Not every host has pull requests. azure-repos, github and gitlab list them; a local host does not. A full safran links refresh skips such hosts quietly. Naming one of their repos reports it as failed:
    $ safran links refresh ops-tools
       repo       pull requests  with a ticket  detail
    ✘  ops-tools              0              0  UNSUPPORTED: Code host "gitlab" (local) does not support pull requests
    
    0 pull requests read, 0 with a ticket, in 3 ms
    ✘ ops-tools: Code host "gitlab" (local) does not support pull requests (UNSUPPORTED)
    ✘ 1 repo failed; the others are stored.

    (In this run the gitlab entry was a local directory, to show the message.)

    Queries do not care where a record came from: safran links show --ticket PAY-1423 returns the pull requests for that ticket from every host. If you add or rename project keys later, the stored records can be re-linked without fetching anything again; see Work history.

    Common mistakes

    SymptomCauseFix
    "PAY-1423" could belong to several trackersTwo trackers accept the shape and neither, or both, declare the projectList projects on each tracker, or use jira:PAY-1423
    No tracker recognises "…" as a ticket referenceThe key's project is not in the tracker's projects list, or the key was typed in lower case for a tracker without a listAdd the project, or paste the key as the tracker writes it; the hint lists the configured trackers and their projects
    Tracker "linear" does not recognise "…"The explicit form named a tracker that does not own that shapeCheck the id before the colon
    A team's repo shows no groups and no team in safran reposThe profile lists the short name, but the repo was renamed to <hostId>/<name> after a collisionUse the qualified name in code.groups and teams[].repos, or exclude the duplicate
    Ticket search returns fewer results than expectedOne tracker failed or was left outRead warnings (CLI: the ! lines on stderr)
    Pull requests of one host are never linked to ticketsThe tracker that owns those keys declares no projectsDeclare them, then refresh the links

    More symptoms, with the real messages, are in Troubleshooting.