Skip to content
safran

Type to search. Enter opens the first result.

    Discovery explained

    safran discover turns a seed profile (connectors only) into a draft profile with tracker projects, repo groups, teams, glossary candidates, conventions and languages filled in. This page explains what it reads, how every proposal is computed, which numbers decide it, and how to read the result. Discovery is counting and heuristics, not a language model: it needs history to say anything, and everything it writes is a draft that a person must review.

    A complete run

    The seed profile below has a tracker, a code host and an embedder, and nothing else. safran sync has run once, so the repositories are cloned and indexed (discovery works without that, with less to go on: see what it reads).

    $ safran discover --profile /work/acme/safran.yaml
    Safran discovery — draft for review (statistics and heuristics, no language model)
    6 repos (6 cloned), 69 merged PRs read, 65 used, 63 with a ticket (3% without), 63 ticket titles
    sampled.
    Ignored PRs: 2 by bots, 1 merge/revert, 1 mass changes.
    Legend: + added to the draft, · observation only; [high] [med ] [low ] = confidence.
    
    Coverage (2)
      · [high] pull requests ignored as noise
               4 of 69 merged PRs were ignored: 2 by bot accounts, 1 merge/revert PRs, 1 mass changes, 0
               naming many tickets at once, 0 repeats of the same change to another branch.
      · [high] ticket references in merged PRs
               3% of merged PRs (2 of 65) reference no ticket — the team mapping is based on the other
               63.
    
    Tracker projects (1)
      + [med ] tracker jira
               Tracker "jira" lists 3 projects; all were added. Merged pull requests reference 3 of them
               (PRs per project: PAY 34, WEB 20, MOB 9). Remove the ones no team here works on.
    
    Repo groups (6)
      + [high] acme-android → mobile
               build.gradle.kts + AndroidManifest.xml; name contains "android".
      + [high] acme-ios → mobile
               podfile; name contains "ios".
      + [high] admin-panel → frontend
               package.json depends on react; name contains "panel".
      + [med ] ledger → backend
               go.mod.
      + [high] payments-api → backend
               package.json depends on fastify; name contains "api".
      + [high] web-app → frontend
               package.json depends on react; name contains "web".
    
    Teams (6)
      + [low ] Mobile ↔ acme-android
               Mobile ↔ acme-android: 4 of 4 ticket-linked PRs in this repo reference MOB tickets
               (recency-weighted share 100%).
      + [low ] Mobile ↔ acme-ios
               Mobile ↔ acme-ios: 5 of 5 ticket-linked PRs in this repo reference MOB tickets
               (recency-weighted share 100%).
      + [med ] Payments ↔ ledger
               Payments ↔ ledger: 9 of 9 ticket-linked PRs in this repo reference PAY tickets
               (recency-weighted share 100%).
      + [high] Payments ↔ payments-api
               Payments ↔ payments-api: 24 of 24 ticket-linked PRs in this repo reference PAY tickets
               (recency-weighted share 100%).
      + [med ] Web ↔ admin-panel
               Web ↔ admin-panel: 8 of 9 ticket-linked PRs in this repo reference WEB tickets
               (recency-weighted share 91%).
      + [med ] Web ↔ web-app
               Web ↔ web-app: 12 of 12 ticket-linked PRs in this repo reference WEB tickets
               (recency-weighted share 100%).
    
    Glossary candidates (9)
      + [med ] iade → refund
               "iade" appears in 8 sampled ticket titles; "refund" is in the changed paths of 8 of their
               8 PRs, against 0 of 16 other PRs in the same repos. The term was not found in the code
               index. Co-occurrence, not translation: confirm before trusting it.
      + [low ] sepet → basket
               "sepet" appears in 5 sampled ticket titles; "basket" is in the changed paths of 5 of
               their 5 PRs, against 0 of 7 other PRs in the same repos. The term was not found in the
               code index. Co-occurrence, not translation: confirm before trusting it.
      + [low ] kapanı → close
               "kapanı" appears in 5 sampled ticket titles; "close" is in the changed paths of 3 of
               their 5 PRs, against 0 of 41 other PRs in the same repos. The term was not found in the
               code index. Co-occurrence, not translation: confirm before trusting it.
      + [low ] fatura → invoice
               "fatura" appears in 4 sampled ticket titles; "invoice" is in the changed paths of 4 of
               their 4 PRs, against 0 of 20 other PRs in the same repos. The term was not found in the
               code index. Co-occurrence, not translation: confirm before trusting it.
      + [low ] bildirim → push
               "bildirim" appears in 4 sampled ticket titles; "push" is in the changed paths of 3 of
               their 4 PRs, against 0 of 29 other PRs in the same repos. The term was not found in the
               code index. Co-occurrence, not translation: confirm before trusting it.
      + [low ] arama → search
               "arama" appears in 3 sampled ticket titles; "search" is in the changed paths of 3 of
               their 3 PRs, against 0 of 18 other PRs in the same repos. The term was not found in the
               code index. Co-occurrence, not translation: confirm before trusting it.
      + [low ] bakiye → balance
               "bakiye" appears in 3 sampled ticket titles; "balance" is in the changed paths of 3 of
               their 3 PRs, against 0 of 30 other PRs in the same repos. The term was not found in the
               code index. Co-occurrence, not translation: confirm before trusting it.
      + [low ] mutabakat → settlement
               "mutabakat" appears in 3 sampled ticket titles; "settlement" is in the changed paths of 3
               of their 3 PRs, against 0 of 30 other PRs in the same repos. The term was not found in
               the code index. Co-occurrence, not translation: confirm before trusting it.
      · [low ] glossary candidates
               17 recurring terms in 63 sampled ticket titles: 0 already appear in code or changed
               paths, 0 have too few focused PRs to compare, 8 have no path word that stands out, 1
               point at a code word a commoner term already took; 8 proposed. Single words only; expect
               misses and some wrong pairs.
    
    Conventions (4)
      + [high] ticket title language
               63 of 63 sampled ticket titles look Turkish, 0 English, 0 another language, 0 undecided
               (100% of the classified ones). Language detection is a heuristic (Turkish-only letters
               and small word lists for tr/en).
      + [med ] pull request title language
               1 of 65 pull request titles look Turkish, 44 English, 0 another language, 20 undecided
               (98% of the classified ones). Language detection is a heuristic (Turkish-only letters and
               small word lists for tr/en).
      + [high] branch naming
               63 of 65 source branches (97%) have the shape type/key.
      + [high] pull request titles
               63 of 65 PR titles (97%) have the shape "key: text".
    
    Languages (1)
      + [high] languages.tickets = tr
               63 of 63 sampled ticket titles look Turkish, 0 English, 0 another language, 0 undecided
               (100% of the classified ones). Language detection is a heuristic (Turkish-only letters
               and small word lists for tr/en). `languages.code` is set to "en" by default; it was not
               measured.
    
    Added to the draft: 3 project key(s), 6 grouped repo(s), 3 team(s), 0 repo(s) on existing teams, 8
    glossary candidate(s), 4 convention(s), languages.
    Findings by confidence: 12 high, 7 medium, 10 low.
    
    ✔ Wrote the draft to /work/acme/safran.draft.yaml
    → It is a draft, not your profile. Review it (start with the items marked low),
      then rename it over /work/acme/safran.yaml and run `safran profile check --profile /work/acme/safran.yaml`.

    This is real output of the CLI, run against an in-memory tracker and code host that carry a small fictional acme history (63 finished tickets with Turkish titles, 69 merged pull requests). Progress lines, which go to stderr, are left out. Two things in it are worth a second look before reading on:

    • kapanı → close is a wrong pair. The titles behind it mix "kapanıyor" (an app that shuts down, a session that ends) with "kapanış" (the month-end close of the ledger); three of those five pull requests happen to touch close paths. Nothing in the statistics can tell that apart from a real term. This is what low is for.
    • iade → refund is medium, not high. No glossary candidate is ever high.

    What discovery reads

    Discovery works through one Safran instance built from your seed profile, so it sees exactly what your tokens can see. All of its reading happens in five places:

    SourceWhat is readUsed for
    Code hostsThe repository list (repos.list)Groups; the repos merged pull requests are read for
    Cloned repos on diskNames of the entries in the repository root (the first 400, DEFAULT_MAX_ROOT_ENTRIES), whether an Android manifest exists at app/src/main/AndroidManifest.xml or src/main/AndroidManifest.xml, and the dependencies names of a root package.jsonGroups
    TrackersThe project list of every tracker entry (listProjects)Tracker projects, team names, finding ticket keys in pull requests
    Link storeMerged pull requests of the window: title, source branch, description, author, merge date, linked ticket keys, changed file paths. Refreshed from the code hosts first unless you pass --no-refreshTeams, glossary, conventions
    Trackers, againTitles of up to 200 tickets (DEFAULT_SAMPLE_TICKETS) that those pull requests reference, four requests at a time (DEFAULT_TICKET_CONCURRENCY)Ticket language, glossary

    It also asks the code index whether a glossary candidate already occurs in code (one exact search per candidate). No file content is read beyond the root package.json, and no source text is sent anywhere by discovery itself.

    Details that change what you get:

    • The window. Pull requests merged in the last 12 months (DEFAULT_LOOKBACK_MONTHS) are used, or since --since. Without --since the refresh itself resumes where the link store stopped (see links); with --since it reads back to that date. At most 50,000 stored records are read (DEFAULT_MAX_RECORDS).
    • Ticket keys are looked for again. A seed profile has no project keys yet, so the link store only holds the links the code host itself reports. Discovery takes the project keys from the trackers' listings and searches each pull request's title and source branch for them; the description is searched only when title and branch name no ticket, because descriptions mention other people's tickets. Tokens that only look like keys (UTF-8, SHA-256, ISO-8601 and the rest of DEFAULT_KEY_LOOKALIKES) are never counted. This is done only for trackers whose keys have the PROJECT-123 shape.
    • The ticket sample is spread over repos. The newest unseen key of each repo is taken in turn, so one busy repo does not fill the 200. If the first 10 reads all fail (DEFAULT_TICKET_FAILURE_LIMIT, typically a rejected token), sampling stops and a problem is reported.
    • Not cloned is not fatal. A repo that has not been synced is grouped from its name and primary language only, and its finding says "Not cloned, so manifests were not read." An empty code index means glossary candidates are not checked against code and all stay low. Run safran sync before safran discover when you can.
    • Archived repos are left out of the groups and listed in one finding.

    A failing step does not fail the run. A tracker that cannot list projects, a repo whose pull requests cannot be read, tickets that cannot be fetched: each becomes a finding under Problems and the rest goes on. Only cancellation and invalid options stop the command.

    Pull requests that are dropped

    Before anything is counted, pull requests that would mislead the statistics are removed, in this order:

    DroppedRuleCounted as
    Bot authorsThe author's name, id or e-mail contains [bot] or the word bot, starts with dependabot, renovate, greenkeeper, snyk, mergify, github-actions or semantic-release, or contains build service. The SDK option botAuthors adds exact names.bot
    Merge and revert titlesThe title starts with revert, reverts, merge, merged, backmerge or back-mergenoiseTitle
    Mass changesMore than 50 changed files (DEFAULT_MASS_CHANGE_FILES)massChange
    Many-ticket pull requestsMore than 5 ticket keys (DEFAULT_MAX_TICKETS_PER_PULL): a release or branch merge, not work for one teammanyTickets
    RepeatsSame repo, same title and same tickets as a newer pull request (one change opened to several target branches)duplicate

    The counts are in the summary line (Ignored PRs: …), in the first coverage finding and in stats.dropped.

    What is inferred, and how

    Six steps run over the same filtered pull requests. Each one is a pure function you can also call on its own (they are listed in the @safran/discover reference).

    Tracker projects

    A tracker entry that already lists projects is left alone. For the others, the tracker's own listing decides:

    • Up to 25 projects (DEFAULT_MAX_PROJECTS_PER_TRACKER): all are added, most-referenced first. The finding says how many merged pull requests reference each, so you can remove the ones nobody here works on.
    • More than 25: only projects that at least 2 pull requests reference (DEFAULT_MIN_PROJECT_REFERENCES) are added, up to 25, and the finding counts the rest. A tracker lists every project its token can see; that is not a profile.
    • A project key that another tracker in the profile already owns is not added a second time: a key must map to one tracker (see multiple sources).

    Confidence: low when no pull request references any added project, high when every added project has at least 20 references (DEFAULT_PROJECT_HIGH_REFERENCES), otherwise medium.

    Repo groups

    Every repo that is not already in a group gets one of backend, frontend, mobile, infra, libraries or other. Three kinds of signal vote, and the heaviest group wins:

    SignalWeightExamples
    Manifest in the repo root (cloned repos only)3Podfile or an Xcode project → mobile; Gradle with an Android manifest → mobile, without → backend; go.mod, pom.xml, *.csproj, Cargo.toml, pyproject.toml → backend; a package.json depending on react, vue, next → frontend, on express, fastify, @nestjs/core → backend, on react-native, expo → mobile; Terraform or Helm files with no application manifest → infra
    A word of the repo name (the last matching word counts: admin-api is an API)2api, service, worker → backend; web, admin, panel, portal → frontend; ios, android, mobile → mobile; infra, terraform, helm, deploy → infra; lib, sdk, common, shared → libraries
    Primary language reported by the code host1Swift, Kotlin, Dart → mobile; C#, Java, Go, Python → backend; Vue, Svelte, CSS → frontend; HCL, Shell → infra

    Confidence here means agreement, not weight: high needs a manifest plus one other kind with nothing pointing elsewhere; a manifest alone, or name and language together, is medium; a single name or language signal, a tie, or any signal pointing at another group is low. A repo with no signal goes to other at low.

    Discovery never edits a group you wrote. A repo that looks like backend when your profile already defines backend is reported, not added. With more than 60 repos to classify (DEFAULT_MAX_GROUP_FINDINGS) the findings are summarised per group and confidence instead of one per repo.

    Teams and repo ownership

    A team is inferred as "the people who work on one tracker project", and ownership as "the project most of a repo's ticket-linked pull requests reference".

    1. Every used pull request with at least one ticket of a known project counts as one link for its repo. Its weight halves for every 180 days of age (DEFAULT_RECENCY_HALF_LIFE_DAYS), measured from the newest pull request in the data, not from today, so the same data always gives the same answer. A pull request naming tickets of two projects counts for both and splits its weight between them.
    2. A project's share in a repo is its weight divided by the repo's total weight.
    3. A project owns the repo when it has at least 3 links there (DEFAULT_MIN_LINKS) and a share of at least 60% (DEFAULT_OWNER_SHARE).
    4. Otherwise, up to 2 projects (DEFAULT_MAX_CO_OWNERS) with at least 3 links and a 30% share each (DEFAULT_SHARED_SHARE) become co-owners: the repo is listed under each team, always at low.
    5. A repo spread thinner than that gets a "shared repository" finding and is not assigned. A repo where no project reaches 3 links is listed under "repos with too little history" and not assigned.

    Confidence of an owned repo:

    ConfidenceCondition
    highAt least 20 links (DEFAULT_HIGH_MIN_LINKS) and a share of at least 80% (DEFAULT_HIGH_SHARE)
    mediumAt least 8 links (DEFAULT_MEDIUM_MIN_LINKS)
    lowEverything else; also when the project with the most links over the whole period is not the recency-weighted leader ("ownership seems to have moved recently"), and when the tracker project is the repository itself (issues kept in the code host: the repo's own issues closed by its own pull requests say nothing about who the team is)

    What ends up in the draft depends on what the seed already says:

    • No teams in the profile. One team per project that owns or co-owns a repo, named after the project's display name in the tracker (Payments for PAY). The team's confidence is the lowest of its repos, so one guessed repo marks the whole entry for review, and source carries the link count (33 ticket-PR links across 2 repos).
    • Teams in the profile. No team is invented. A repo is appended to the one team that lists the project. A repo you already gave to a team is never moved or shared out; when history disagrees with the profile, the finding says so and the profile stays as written. A project that no team lists gets a "project PAY has no team" finding.

    Glossary candidates

    This step looks for business words of ticket titles that the code does not use, and for the path word their pull requests keep touching. It runs only when the ticket language differs from the code language; with both en it reports that there is nothing to map.

    1. Terms. Titles are lower-cased with the ticket language's casing rules (so İade and iade are one word), ticket keys are removed, and words shorter than 4 letters or in the stop lists are dropped. Inflected forms are grouped without a stemmer: a word joins the shortest shorter word that is its prefix (iadeler, iadenin → iade; the stem has at least 4 letters and the suffix at most 6), and words without one are grouped on a shared prefix of 5 letters or more.
    2. Frequency. A term must occur in at least 3 sampled tickets (DEFAULT_GLOSSARY_MIN_TICKETS) and, once the sample has 10 tickets, in no more than 40% of them (DEFAULT_GLOSSARY_MAX_TICKET_SHARE).
    3. Already in code. A term that is the start of a word in any changed path, or that the code index finds (case-insensitive exact search for the term, its stem and its folded form), is dropped: the code already speaks that word.
    4. Focused pull requests. Only pull requests of sampled tickets that change at most 20 files (DEFAULT_GLOSSARY_MAX_FILES) are used. The term needs at least 3 of them (DEFAULT_GLOSSARY_MIN_SUPPORT).
    5. Comparison inside each repo. The term's pull requests are compared with the other focused pull requests of the same repo, never across repos; a repo with fewer than 3 others (DEFAULT_GLOSSARY_MIN_CONTRAST) is left out.
    6. Path words. Changed paths are split into words (generic ones such as src or test are ignored). A word is suggested when at least 3 and at least half of the term's pull requests touch it, and its share there exceeds its share in the comparison set by at least 0.4 (DEFAULT_GLOSSARY_MIN_LIFT). At most 3 code words per term (DEFAULT_GLOSSARY_MAX_CODE_WORDS).
    7. One term per code word. When two terms point at the same first code word (words that travel together, like "kısmi" and "iade"), the more frequent one is kept. At most 20 candidates are proposed (DEFAULT_GLOSSARY_MAX_TERMS).

    A candidate is medium only when it was checked against the code index and not found there, at least 8 of its pull requests touch the code word, the lift is at least 0.6 and the term occurs in at least 5 tickets. Everything else is low. The last glossary finding (· [low ] glossary candidates) is the tally: how many recurring terms there were and why the others were not proposed.

    Each candidate is written with a note that starts with discovered and carries the evidence, so it stays recognisable after you merge the draft. How the glossary is then used at search time is on the glossary page; the Turkish case end to end is in non-English tickets.

    Conventions

    A sentence is proposed only for a habit that at least 70% of the samples follow (DEFAULT_CONVENTION_MAJORITY), from at least 10 samples (DEFAULT_CONVENTION_MIN_SAMPLES):

    ConventionSampleShapes recognised
    Ticket title languageSampled ticket titlesTurkish or English
    Pull request title languageTitles of the used pull requestsTurkish or English
    Branch namingSource branches, without trunk and release branchestype/key, key, type/number, type/text. A prefix counts as a type when it is a usual one (feature, fix, hotfix, chore, … in KNOWN_BRANCH_TYPES) or at least 3 authors use it (DEFAULT_BRANCH_TYPE_MIN_AUTHORS), so a personal prefix is not reported as a type
    Pull request titlesTitles of the used pull requestskey: text, key - text, [key] text, key text, text (key), Conventional Commits. When no single shape reaches the majority but titles starting with the key do, the plainer sentence "Pull request titles start with the ticket key." is proposed

    Confidence: high from 50 samples with 90% agreeing, medium from 20 samples with 80%, otherwise low. A convention is never added on a topic your profile already has a sentence about (a second, slightly different sentence about branch names would contradict yours); the finding then shows what the data says.

    Languages

    languages is proposed only when the profile does not have it and the ticket titles are clear: tickets is the detected language and code is set to en without being measured (nothing in discovery reads source text). When the profile already has languages, the finding only says whether the titles agree.

    Confidence, and what low means for you

    Every finding carries one of three levels. They describe how much evidence there is, not how likely the item is to be right in your company.

    LevelRead it as
    highEnough evidence and nothing pointing elsewhere. Skim it.
    mediumPlausible. Check it against what you know.
    lowA guess. Do not let agents rely on it until a person has confirmed, corrected or deleted it.

    low is not a soft "probably". A team with confidence: low reaches agents with that label through get_company_profile, and the skills are written to treat it as unconfirmed, but a wrong glossary pair has no such label at search time: it silently adds the wrong code words to queries. Review low items before the draft becomes your profile, and measure glossary changes with evaluation.

    In the draft, guesses are marked where they sit:

    # DRAFT profile written by `safran discover`. Review it before use.
    #
    # What you wrote was kept as it was. Everything else was inferred from tracker and code-host
    # data with counting and heuristics (no language model), so some of it is wrong.
    # Added: 3 tracker project key(s), 6 repo(s) in new groups, 3 team(s), 8 glossary candidate(s), 4 convention(s), languages.
    #
    # How to review:
    #   1. Lines ending in `# discovered`, teams with `confidence:` / `source:` and glossary entries
    #      whose `note:` starts with "discovered" are guesses. `low` means: do not trust until checked.
    #   2. `safran discover` printed 29 finding(s) with the numbers behind every guess; read the
    #      low-confidence ones first. Glossary candidates are co-occurrence, not translation.
    #   3. Fix or delete what is wrong. Once a team is confirmed, remove its `confidence` and `source`.
    #   4. Run `safran profile check`.
    version: 1
    company: acme

    Further down the same file (the draft of the run above; the connector entries between these parts are your seed, unchanged):

      groups:
        backend:
          - ledger  # discovered (medium)
          - payments-api  # discovered (high)
        frontend:
          - admin-panel  # discovered (high)
          - web-app  # discovered (high)
        mobile:
          - acme-android  # discovered (high)
          - acme-ios  # discovered (high)
    languages:
      tickets: tr  # discovered from ticket titles
      code: en  # default, not measured
    teams:
      - name: Mobile
        projects:
          - MOB
        repos:
          - acme-android
          - acme-ios
        confidence: low
        source: 9 ticket-PR links across 2 repos
      - name: Payments
        projects:
          - PAY
        repos:
          - ledger
          - payments-api
        confidence: medium
        source: 33 ticket-PR links across 2 repos
      - name: Web
        projects:
          - WEB
        repos:
          - admin-panel
          - web-app
        confidence: medium
        source: 20 ticket-PR links across 2 repos
    glossary:
      - term: iade
        code:
          - refund
        note: "discovered, medium confidence: seen in 8 ticket titles as iade, iadeler, iadenin; 8 of 8 of their PRs change \"refund\" paths"
      - term: sepet
        code:
          - basket
        note: "discovered, low confidence: seen in 5 ticket titles as sepet, sepete, sepetteki; 5 of 5 of their PRs change \"basket\" paths"
      - term: kapanı
        code:
          - close
        note: "discovered, low confidence: seen in 5 ticket titles as kapanıyor, kapanış, kapanışı; 3 of 5 of their PRs change \"close\" paths"

    The glossary list continues with the other five candidates, then conventions: with four sentences, each ending in # discovered.

    Reviewing the draft

    1. Read Problems and Coverage first. They say what discovery could not see: a tracker that did not answer, the share of pull requests without a ticket, how many were dropped. A team mapping built on 40% of the pull requests deserves less trust than one built on 97%.
    2. Go through every low finding. For teams: is this really the team, or just the project whose tickets happened to land here? For co-owned repos: is it shared, or did ownership move? For glossary pairs: is the code word what a developer would search for when a ticket says the term?
    3. Fix the draft. Delete wrong glossary entries (kapanı above), correct the term's spelling where the stem was cut short, add the code words you know and discovery could not see (it proposes single path words only). Once a team is confirmed, remove its confidence and source.
    4. Bring the result into your profile and run safran profile check. The draft is written from the parsed seed, so it has your values but not the comments or layout of your file; if you care about those, copy the discovered parts into your own file instead of renaming the draft over it.
    5. If groups changed, run safran sync again, then measure: evaluation.

    Running discovery again on the merged profile is safe: what you wrote is kept, groups you defined are not edited, teams you wrote are not re-invented, and glossary terms you already have are not proposed again.

    Findings and stats

    The printed list is findings grouped by kind, in this order: problem, coverage, project, group, team, glossary, convention, language. + marks a finding that added something to the draft (detail.applied is true); · is an observation that changed nothing. With --json the same findings come as data, with the numbers behind each sentence in detail:

    $ safran discover --no-refresh --no-glossary --json --profile /work/acme/safran.yaml
    {
      "kind": "group",
      "subject": "payments-api → backend",
      "confidence": "high",
      "evidence": "package.json depends on fastify; name contains \"api\".",
      "detail": {
        "applied": true,
        "repo": "payments-api",
        "group": "backend",
        "reasons": [
          "package.json depends on fastify",
          "name contains \"api\""
        ],
        "against": []
      }
    }

    That is one element of findings from the JSON document, whose top-level keys are draft_file, replaced, wrote_profile, stats, findings and profile. In the SDK a finding has this shape:

    FieldMeaning
    kindOne of the eight kinds above
    subjectWhat it is about: Payments ↔ payments-api, iade → refund, tracker jira
    confidencelow, medium or high
    evidenceThe reasoning as a sentence, with its numbers
    detailThe same numbers as data. Always has applied: whether the finding changed the draft

    stats describes the run as a whole. In the SDK the names are camelCase; --json prints them in snake_case.

    FieldMeaning
    reposRepositories the code hosts list
    clonedReposOf those, how many are on disk (only these have their manifests read)
    pullRequestsMerged pull requests read from the link store for the window
    pullRequestsUsedWhat is left after the drop rules
    droppedCounts per drop rule: bot, noiseTitle, massChange, manyTickets, duplicate
    linkedPullRequestsUsed pull requests that reference at least one ticket
    unlinkedShareShare of used pull requests without any ticket key, 0 to 1
    ticketsSampledTicket titles that were read
    ticketsFailedSampled tickets that could not be read
    addedWhat went into the draft: projects, groupedRepos, teams, teamRepos, glossary, conventions (counts) and languages (boolean)
    findingsNumber of findings per confidence level

    Command flags

    FlagEffect
    --out <file>Where to write the draft. Default: safran.draft.yaml next to the profile. Pointing it at the profile itself is refused
    --writeWrite over the profile itself instead of a draft file. Refused without --force, and cannot be combined with --out
    --forceAllows --write to replace the profile
    --since <date>How far back to read merged pull requests (an ISO date). Default: 12 months
    --no-glossarySkip glossary candidates
    --no-refreshUse the local link store as it is; fetch no pull requests. Tracker projects and ticket titles are still read

    An existing draft file is replaced without asking; the last line says "Replaced the draft at" when it was. --write without --force stops before anything is read:

    $ safran discover --write
    ✘ --write replaces your profile with the draft
    → Pass --write --force if that is what you want; without --write the draft goes to safran.draft.yaml for review.

    The flags of every setup command are in the CLI reference.

    From the SDK

    discoverProfile takes a Safran instance and returns the draft as data and as YAML. It writes nothing to disk; what to do with result.yaml is yours to decide. The example runs over in-memory connectors from @safran/kit/testing, so it needs no network:

    discover.ts
    import { mkdtemp } from "node:fs/promises";
    import { tmpdir } from "node:os";
    import { join } from "node:path";
    import { createSafran } from "@safran/core";
    import { discoverProfile } from "@safran/discover";
    import { FakeCodeHost, FakeTracker, fakePlugins } from "@safran/kit/testing";
    
    // A tracker and a code host held in memory: three finished tickets, three merged pull requests.
    const work = [
      { key: "PAY-1423", title: "Kısmi iade işlemi İstanbul şubesinde başarısız oluyor", file: "src/refund/service.ts", mergedAt: "2026-10-30T09:00:00Z" },
      { key: "PAY-1500", title: "Refund webhook retries are not idempotent", file: "src/webhook/retry.ts", mergedAt: "2026-11-12T09:00:00Z" },
      { key: "PAY-1501", title: "Checkout basket total ignores the campaign discount", file: "src/refund/policy.ts", mergedAt: "2026-11-16T09:00:00Z" },
    ];
    const tracker = new FakeTracker({
      id: "jira",
      projects: [{ key: "PAY", name: "Payments" }],
      tickets: work.map(({ key, title }) => ({ key, title })),
    });
    const host = new FakeCodeHost({
      id: "azure",
      repos: [{ name: "payments-api" }],
      pullRequests: work.map(({ key, file, mergedAt }, index) => ({
        id: String(101 + index),
        repo: "payments-api",
        title: `${key}: fix`,
        description: "",
        sourceBranch: `feature/${key}-fix`,
        mergedAt,
        linkedTicketKeys: [key],
        changedFiles: [file],
      })),
    });
    
    await using safran = await createSafran({
      profile: {
        version: 1,
        company: "acme",
        trackers: [{ id: "jira", type: "fake" }],
        code: { hosts: [{ id: "azure", type: "fake" }] },
        embeddings: { type: "fake" },
      },
      builtinPlugins: false,
      plugins: fakePlugins({ trackers: [tracker], hosts: [host] }),
      dataDir: await mkdtemp(join(tmpdir(), "acme-discover-")),
    });
    
    const result = await discoverProfile(safran, {
      since: "2026-01-01",
      glossary: { enabled: false },
      onProgress: ({ step, message }) => console.error(`${step}: ${message}`),
    });
    
    for (const finding of result.findings) {
      console.log(`${finding.detail.applied ? "+" : "·"} ${finding.confidence.padEnd(6)} ${finding.kind.padEnd(10)} ${finding.subject}`);
    }
    console.log(result.profile.teams);
    console.log(result.stats.added);

    Its output (stdout), with three links in one repo, which is exactly the minimum:

    $ bun discover.ts
    · low    coverage   ticket references in merged PRs
    + medium project    tracker jira
    + low    group      payments-api → backend
    + low    team       Payments ↔ payments-api
    · low    language   languages.tickets
    [
      {
        name: "Payments",
        projects: [ "PAY" ],
        repos: [ "payments-api" ],
        confidence: "low",
        source: "3 ticket-PR links",
      }
    ]
    {
      projects: 1,
      groupedRepos: 1,
      teams: 1,
      teamRepos: 0,
      glossary: 0,
      conventions: 0,
      languages: false,
    }

    Three pull requests are enough for a low team and nothing else: no convention (10 samples needed), no language (too few titles to classify).

    Options

    OptionDefaultMeaning
    signalnoneCancels the run; it ends with ABORTED
    onProgressnoneCalled with a step (repos, projects, links, tickets, groups, teams, glossary, conventions, profile), a message and, where known, done and total
    since12 months before nowISO date: how far back merged pull requests are read. An invalid date is INVALID_INPUT
    maxPerRepoThe link store's default (500)Cap on pull requests fetched per repo, newest first
    refreshLinkstruefalse uses the link store as it is and fetches no pull requests
    sampleTickets200Tickets fetched at most for their titles; 0 fetches none
    glossaryenabled, 20 terms, detected languageenabled, maxTerms, and language (ISO 639-1) to state the ticket language instead of detecting it
    thresholdsThe table belowAny subset of the tunable numbers
    botAuthorsnoneAuthor names (case-insensitive) treated as bots on top of the built-in patterns
    seedThe profile file the instance was loaded from, else safran.profileThe profile exactly as the human wrote it. Pass it when the instance was built from an inline profile and you want "not written" told apart from "written as the default"
    nowThe current timeOnly used to compute the default since

    The CLI exposes since, refreshLinks and glossary.enabled as flags. Everything else, thresholds included, is SDK-only.

    Thresholds

    Every tunable number, with the constant that holds its default (all exported from @safran/discover):

    ThresholdDefaultConstantDecides
    maxProjectsPerTracker25DEFAULT_MAX_PROJECTS_PER_TRACKERTracker projects proposed per tracker at most
    massChangeFiles50DEFAULT_MASS_CHANGE_FILESA pull request changing more files is a mass change and is dropped
    maxTicketsPerPull5DEFAULT_MAX_TICKETS_PER_PULLA pull request naming more tickets is dropped
    minLinks3DEFAULT_MIN_LINKSTicket-linked pull requests a repo ↔ project pair needs before anything is proposed
    ownerShare0.6DEFAULT_OWNER_SHARERecency-weighted share one project needs to own a repo
    sharedShare0.3DEFAULT_SHARED_SHAREShare at which a project co-owns a repo nobody owns outright
    maxCoOwners2DEFAULT_MAX_CO_OWNERSCo-owners listed at most; with more, the repo is reported as shared and left unassigned
    recencyHalfLifeDays180DEFAULT_RECENCY_HALF_LIFE_DAYSDays after which a link counts half
    mediumMinLinks8DEFAULT_MEDIUM_MIN_LINKSLinks for medium team confidence
    highMinLinks20DEFAULT_HIGH_MIN_LINKSLinks for high team confidence
    highShare0.8DEFAULT_HIGH_SHAREShare for high team confidence
    glossaryMinTickets3DEFAULT_GLOSSARY_MIN_TICKETSTickets a term must appear in
    glossaryMaxTicketShare0.4DEFAULT_GLOSSARY_MAX_TICKET_SHAREA term in a larger share of tickets is too generic
    glossaryMaxFiles20DEFAULT_GLOSSARY_MAX_FILESWider pull requests are not used for the glossary
    glossaryMinSupport3DEFAULT_GLOSSARY_MIN_SUPPORTPull requests of a term that must touch a path word
    glossaryMinContrast3DEFAULT_GLOSSARY_MIN_CONTRASTOther pull requests in the same repo needed to compare against
    glossaryMinLift0.4DEFAULT_GLOSSARY_MIN_LIFTMinimum difference between the path word's share in the term's pull requests and in the others
    glossaryMaxCodeWords3DEFAULT_GLOSSARY_MAX_CODE_WORDSCode words per glossary candidate at most
    conventionMinSamples10DEFAULT_CONVENTION_MIN_SAMPLESSamples needed before a convention or a language is proposed
    conventionMajority0.7DEFAULT_CONVENTION_MAJORITYShare of samples that must agree

    The defaults are starting points chosen by the authors, not values tuned on your company. If you change one, read the findings again: a lower minLinks produces more teams and more wrong ones.

    The full declarations are in the @safran/discover reference:

    /**
     * Drafts a company profile from what the trackers and code hosts of a Safran instance
     * reveal. The instance is built from a seed profile that has the connectors configured;
     * the result is that seed plus proposals, each explained by a finding. Nothing is written
     * to disk and no language model is involved.
     */
    export async function discoverProfile(safran: Safran, options: DiscoverOptions = {}): Promise<DiscoveryResult>;
    
    export interface DiscoveryResult {
      /** The seed profile plus what discovery added. Validates with `parseProfile`. */
      profile: ProfileInput;
      /** `profile` as YAML with a review header, ready to write. */
      yaml: string;
      findings: Finding[];
      stats: DiscoveryStats;
    }

    defined in packages/discover/src/discover.ts, packages/discover/src/types.ts

    Honest limits

    • It needs history. With no code host that lists merged pull requests (a local host has none) and no tracker, discovery can still group repos, and says so for the rest. This profile has only a local host:

      $ safran discover --profile /work/acme/local/safran.yaml
      Safran discovery — draft for review (statistics and heuristics, no language model)
      6 repos (6 cloned), 0 merged PRs read, 0 used, 0 with a ticket, 0 ticket titles sampled.
      Legend: + added to the draft, · observation only; [high] [med ] [low ] = confidence.
      
      Coverage (2)
        · [high] pull request history
                 Not enough history: no code host in the profile can list pull requests, so teams,
                 glossary and PR conventions cannot be inferred from this instance.
        · [high] ticket titles
                 The profile has no tracker, so no ticket titles were read: ticket language and glossary
                 candidates cannot be inferred.

      The same happens, per repo, below 3 ticket-linked pull requests per project, and for conventions below 10 samples.

    • It only sees linked work. Teams and glossary come from pull requests that name a ticket. If people do not write ticket keys in titles or branch names and the code host links nothing itself, the coverage finding will show a high share without a ticket and the mapping rests on the remainder.

    • A team is a tracker project. Discovery cannot see an org chart. Two teams sharing one project come out as one team; one team working across three projects comes out as three.

    • Glossary candidates are co-occurrence, not translation. A pair is found only when the same word recurs in titles and its pull requests keep touching one path word that other pull requests in the same repo do not. Expect a minority of your real terms, some wrong pairs, single words only, and no handling of consonant softening (kitap / kitabı are two words to it).

    • Languages: Turkish and English only, by a small heuristic. languages.code is never measured.

    • Groups are a fixed vocabulary. Six names, chosen from manifests, name words and the primary language. A monorepo gets one group.

    • Conventions are habits, not rules. "97% of branches look like this" says what people do, not what your team decided.

    Common mistakes

    • Running it before safran sync. Nothing breaks, but repos are grouped without their manifests and glossary candidates are not checked against the code index, so all of them stay low.
    • Running it with a local code host and expecting teams. There is no pull request history to learn from; see the local connector.
    • Renaming the draft over the profile unread. The draft validates, and that says nothing about whether it is true.
    • Leaving confidence: low on a team you have confirmed. Agents keep treating it as unconfirmed. Remove confidence and source once you have checked it.
    • Tuning thresholds until the output looks right. The output looking right on the repos you know is not evidence for the ones you do not. Fix the draft by hand instead.

    Where discovery sits in the whole setup is in Setting up at a new company; errors you may meet on the way are in troubleshooting.